diff --git a/Sources/LiveKit/Core/SignalClient.swift b/Sources/LiveKit/Core/SignalClient.swift index 52ef3ad5e..695a22999 100644 --- a/Sources/LiveKit/Core/SignalClient.swift +++ b/Sources/LiveKit/Core/SignalClient.swift @@ -271,6 +271,7 @@ private extension SignalClient { _lastJoinResponse = joinResponse _delegate.notifyDetached { await $0.signalClient(self, didReceiveConnectResponse: .join(joinResponse)) } _connectResponseCompleter.resume(returning: .join(joinResponse)) + print("creationTime: \(joinResponse.room.creationTime)") await _restartPingTimer() case let .reconnect(response): diff --git a/Sources/LiveKit/Protos/livekit_metrics.pb.swift b/Sources/LiveKit/Protos/livekit_metrics.pb.swift index d384b603f..4f0a9878a 100644 --- a/Sources/LiveKit/Protos/livekit_metrics.pb.swift +++ b/Sources/LiveKit/Protos/livekit_metrics.pb.swift @@ -74,6 +74,15 @@ enum Livekit_MetricLabel: SwiftProtobuf.Enum, Swift.CaseIterable { /// total duration spent in other quality limitation case clientVideoPublisherQualityLimitationDurationOther // = 16 + + /// Publisher RTT (participant -> server) + case publisherRtt // = 17 + + /// RTT between publisher node and subscriber node (could involve intermedia node(s)) + case serverMeshRtt // = 18 + + /// Subscribe RTT (server -> participant) + case subscriberRtt // = 19 case predefinedMaxValue // = 4096 case UNRECOGNIZED(Int) @@ -100,6 +109,9 @@ enum Livekit_MetricLabel: SwiftProtobuf.Enum, Swift.CaseIterable { case 14: self = .clientVideoPublisherQualityLimitationDurationBandwidth case 15: self = .clientVideoPublisherQualityLimitationDurationCpu case 16: self = .clientVideoPublisherQualityLimitationDurationOther + case 17: self = .publisherRtt + case 18: self = .serverMeshRtt + case 19: self = .subscriberRtt case 4096: self = .predefinedMaxValue default: self = .UNRECOGNIZED(rawValue) } @@ -124,6 +136,9 @@ enum Livekit_MetricLabel: SwiftProtobuf.Enum, Swift.CaseIterable { case .clientVideoPublisherQualityLimitationDurationBandwidth: return 14 case .clientVideoPublisherQualityLimitationDurationCpu: return 15 case .clientVideoPublisherQualityLimitationDurationOther: return 16 + case .publisherRtt: return 17 + case .serverMeshRtt: return 18 + case .subscriberRtt: return 19 case .predefinedMaxValue: return 4096 case .UNRECOGNIZED(let i): return i } @@ -148,6 +163,9 @@ enum Livekit_MetricLabel: SwiftProtobuf.Enum, Swift.CaseIterable { .clientVideoPublisherQualityLimitationDurationBandwidth, .clientVideoPublisherQualityLimitationDurationCpu, .clientVideoPublisherQualityLimitationDurationOther, + .publisherRtt, + .serverMeshRtt, + .subscriberRtt, .predefinedMaxValue, ] @@ -321,6 +339,9 @@ extension Livekit_MetricLabel: SwiftProtobuf._ProtoNameProviding { 14: .same(proto: "CLIENT_VIDEO_PUBLISHER_QUALITY_LIMITATION_DURATION_BANDWIDTH"), 15: .same(proto: "CLIENT_VIDEO_PUBLISHER_QUALITY_LIMITATION_DURATION_CPU"), 16: .same(proto: "CLIENT_VIDEO_PUBLISHER_QUALITY_LIMITATION_DURATION_OTHER"), + 17: .same(proto: "PUBLISHER_RTT"), + 18: .same(proto: "SERVER_MESH_RTT"), + 19: .same(proto: "SUBSCRIBER_RTT"), 4096: .same(proto: "METRIC_LABEL_PREDEFINED_MAX_VALUE"), ] } diff --git a/Sources/LiveKit/Protos/livekit_models.pb.swift b/Sources/LiveKit/Protos/livekit_models.pb.swift index f6997c43b..880a51f07 100644 --- a/Sources/LiveKit/Protos/livekit_models.pb.swift +++ b/Sources/LiveKit/Protos/livekit_models.pb.swift @@ -392,6 +392,15 @@ enum Livekit_DisconnectReason: SwiftProtobuf.Enum, Swift.CaseIterable { /// the room was closed, due to all Standard and Ingress participants having left case roomClosed // = 10 + + /// SIP callee did not respond in time + case userUnavailable // = 11 + + /// SIP callee rejected the call (busy) + case userRejected // = 12 + + /// SIP protocol failure or unexpected response + case sipTrunkFailure // = 13 case UNRECOGNIZED(Int) init() { @@ -411,6 +420,9 @@ enum Livekit_DisconnectReason: SwiftProtobuf.Enum, Swift.CaseIterable { case 8: self = .migration case 9: self = .signalClose case 10: self = .roomClosed + case 11: self = .userUnavailable + case 12: self = .userRejected + case 13: self = .sipTrunkFailure default: self = .UNRECOGNIZED(rawValue) } } @@ -428,6 +440,9 @@ enum Livekit_DisconnectReason: SwiftProtobuf.Enum, Swift.CaseIterable { case .migration: return 8 case .signalClose: return 9 case .roomClosed: return 10 + case .userUnavailable: return 11 + case .userRejected: return 12 + case .sipTrunkFailure: return 13 case .UNRECOGNIZED(let i): return i } } @@ -445,6 +460,9 @@ enum Livekit_DisconnectReason: SwiftProtobuf.Enum, Swift.CaseIterable { .migration, .signalClose, .roomClosed, + .userUnavailable, + .userRejected, + .sipTrunkFailure, ] } @@ -1194,6 +1212,22 @@ struct Livekit_DataPacket: Sendable { set {value = .rpcResponse(newValue)} } + var streamHeader: Livekit_DataStream.Header { + get { + if case .streamHeader(let v)? = value {return v} + return Livekit_DataStream.Header() + } + set {value = .streamHeader(newValue)} + } + + var streamChunk: Livekit_DataStream.Chunk { + get { + if case .streamChunk(let v)? = value {return v} + return Livekit_DataStream.Chunk() + } + set {value = .streamChunk(newValue)} + } + var unknownFields = SwiftProtobuf.UnknownStorage() enum OneOf_Value: Equatable, Sendable { @@ -1207,6 +1241,8 @@ struct Livekit_DataPacket: Sendable { case rpcRequest(Livekit_RpcRequest) case rpcAck(Livekit_RpcAck) case rpcResponse(Livekit_RpcResponse) + case streamHeader(Livekit_DataStream.Header) + case streamChunk(Livekit_DataStream.Chunk) } @@ -2264,6 +2300,210 @@ struct Livekit_TimedVersion: Sendable { init() {} } +struct Livekit_DataStream: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + /// enum for operation types (specific to TextHeader) + enum OperationType: SwiftProtobuf.Enum, Swift.CaseIterable { + typealias RawValue = Int + case create // = 0 + case update // = 1 + case delete // = 2 + case reaction // = 3 + case UNRECOGNIZED(Int) + + init() { + self = .create + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .create + case 1: self = .update + case 2: self = .delete + case 3: self = .reaction + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .create: return 0 + case .update: return 1 + case .delete: return 2 + case .reaction: return 3 + case .UNRECOGNIZED(let i): return i + } + } + + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [Livekit_DataStream.OperationType] = [ + .create, + .update, + .delete, + .reaction, + ] + + } + + /// header properties specific to text streams + struct TextHeader: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var operationType: Livekit_DataStream.OperationType = .create + + /// Optional: Version for updates/edits + var version: Int32 = 0 + + /// Optional: Reply to specific message + var replyToStreamID: String = String() + + /// file attachments for text streams + var attachedStreamIds: [String] = [] + + /// true if the text has been generated by an agent from a participant's audio transcription + var generated: Bool = false + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + } + + /// header properties specific to file or image streams + struct FileHeader: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// name of the file + var fileName: String = String() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + } + + /// main DataStream.Header that contains a oneof for specific headers + struct Header: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// unique identifier for this data stream + var streamID: String = String() + + /// using int64 for Unix timestamp + var timestamp: Int64 = 0 + + var topic: String = String() + + var mimeType: String = String() + + /// only populated for finite streams, if it's a stream of unknown size this stays empty + var totalLength: UInt64 { + get {return _totalLength ?? 0} + set {_totalLength = newValue} + } + /// Returns true if `totalLength` has been explicitly set. + var hasTotalLength: Bool {return self._totalLength != nil} + /// Clears the value of `totalLength`. Subsequent reads from it will return its default value. + mutating func clearTotalLength() {self._totalLength = nil} + + /// only populated for finite streams, if it's a stream of unknown size this stays empty + var totalChunks: UInt64 { + get {return _totalChunks ?? 0} + set {_totalChunks = newValue} + } + /// Returns true if `totalChunks` has been explicitly set. + var hasTotalChunks: Bool {return self._totalChunks != nil} + /// Clears the value of `totalChunks`. Subsequent reads from it will return its default value. + mutating func clearTotalChunks() {self._totalChunks = nil} + + /// defaults to NONE + var encryptionType: Livekit_Encryption.TypeEnum = .none + + /// user defined extensions map that can carry additional info + var extensions: Dictionary = [:] + + /// oneof to choose between specific header types + var contentHeader: Livekit_DataStream.Header.OneOf_ContentHeader? = nil + + var textHeader: Livekit_DataStream.TextHeader { + get { + if case .textHeader(let v)? = contentHeader {return v} + return Livekit_DataStream.TextHeader() + } + set {contentHeader = .textHeader(newValue)} + } + + var fileHeader: Livekit_DataStream.FileHeader { + get { + if case .fileHeader(let v)? = contentHeader {return v} + return Livekit_DataStream.FileHeader() + } + set {contentHeader = .fileHeader(newValue)} + } + + var unknownFields = SwiftProtobuf.UnknownStorage() + + /// oneof to choose between specific header types + enum OneOf_ContentHeader: Equatable, Sendable { + case textHeader(Livekit_DataStream.TextHeader) + case fileHeader(Livekit_DataStream.FileHeader) + + } + + init() {} + + fileprivate var _totalLength: UInt64? = nil + fileprivate var _totalChunks: UInt64? = nil + } + + struct Chunk: @unchecked Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// unique identifier for this data stream to map it to the correct header + var streamID: String = String() + + var chunkIndex: UInt64 = 0 + + /// content as binary (bytes) + var content: Data = Data() + + /// true only if this is the last chunk of this stream - can also be sent with empty content + var complete: Bool = false + + /// a version indicating that this chunk_index has been retroactively modified and the original one needs to be replaced + var version: Int32 = 0 + + /// optional, initialization vector for AES-GCM encryption + var iv: Data { + get {return _iv ?? Data()} + set {_iv = newValue} + } + /// Returns true if `iv` has been explicitly set. + var hasIv: Bool {return self._iv != nil} + /// Clears the value of `iv`. Subsequent reads from it will return its default value. + mutating func clearIv() {self._iv = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _iv: Data? = nil + } + + init() {} +} + // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "livekit" @@ -2350,6 +2590,9 @@ extension Livekit_DisconnectReason: SwiftProtobuf._ProtoNameProviding { 8: .same(proto: "MIGRATION"), 9: .same(proto: "SIGNAL_CLOSE"), 10: .same(proto: "ROOM_CLOSED"), + 11: .same(proto: "USER_UNAVAILABLE"), + 12: .same(proto: "USER_REJECTED"), + 13: .same(proto: "SIP_TRUNK_FAILURE"), ] } @@ -3219,6 +3462,8 @@ extension Livekit_DataPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImple 10: .standard(proto: "rpc_request"), 11: .standard(proto: "rpc_ack"), 12: .standard(proto: "rpc_response"), + 13: .standard(proto: "stream_header"), + 14: .standard(proto: "stream_chunk"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -3347,6 +3592,32 @@ extension Livekit_DataPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImple self.value = .rpcResponse(v) } }() + case 13: try { + var v: Livekit_DataStream.Header? + var hadOneofValue = false + if let current = self.value { + hadOneofValue = true + if case .streamHeader(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.value = .streamHeader(v) + } + }() + case 14: try { + var v: Livekit_DataStream.Chunk? + var hadOneofValue = false + if let current = self.value { + hadOneofValue = true + if case .streamChunk(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.value = .streamChunk(v) + } + }() default: break } } @@ -3406,6 +3677,14 @@ extension Livekit_DataPacket: SwiftProtobuf.Message, SwiftProtobuf._MessageImple guard case .rpcResponse(let v)? = self.value else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 12) }() + case .streamHeader?: try { + guard case .streamHeader(let v)? = self.value else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + }() + case .streamChunk?: try { + guard case .streamChunk(let v)? = self.value else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 14) + }() default: break } try unknownFields.traverse(visitor: &visitor) @@ -5245,3 +5524,303 @@ extension Livekit_TimedVersion: SwiftProtobuf.Message, SwiftProtobuf._MessageImp return true } } + +extension Livekit_DataStream: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".DataStream" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Livekit_DataStream, rhs: Livekit_DataStream) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Livekit_DataStream.OperationType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "CREATE"), + 1: .same(proto: "UPDATE"), + 2: .same(proto: "DELETE"), + 3: .same(proto: "REACTION"), + ] +} + +extension Livekit_DataStream.TextHeader: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Livekit_DataStream.protoMessageName + ".TextHeader" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "operation_type"), + 2: .same(proto: "version"), + 3: .standard(proto: "reply_to_stream_id"), + 4: .standard(proto: "attached_stream_ids"), + 5: .same(proto: "generated"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.operationType) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.version) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.replyToStreamID) }() + case 4: try { try decoder.decodeRepeatedStringField(value: &self.attachedStreamIds) }() + case 5: try { try decoder.decodeSingularBoolField(value: &self.generated) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.operationType != .create { + try visitor.visitSingularEnumField(value: self.operationType, fieldNumber: 1) + } + if self.version != 0 { + try visitor.visitSingularInt32Field(value: self.version, fieldNumber: 2) + } + if !self.replyToStreamID.isEmpty { + try visitor.visitSingularStringField(value: self.replyToStreamID, fieldNumber: 3) + } + if !self.attachedStreamIds.isEmpty { + try visitor.visitRepeatedStringField(value: self.attachedStreamIds, fieldNumber: 4) + } + if self.generated != false { + try visitor.visitSingularBoolField(value: self.generated, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Livekit_DataStream.TextHeader, rhs: Livekit_DataStream.TextHeader) -> Bool { + if lhs.operationType != rhs.operationType {return false} + if lhs.version != rhs.version {return false} + if lhs.replyToStreamID != rhs.replyToStreamID {return false} + if lhs.attachedStreamIds != rhs.attachedStreamIds {return false} + if lhs.generated != rhs.generated {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Livekit_DataStream.FileHeader: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Livekit_DataStream.protoMessageName + ".FileHeader" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "file_name"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.fileName) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.fileName.isEmpty { + try visitor.visitSingularStringField(value: self.fileName, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Livekit_DataStream.FileHeader, rhs: Livekit_DataStream.FileHeader) -> Bool { + if lhs.fileName != rhs.fileName {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Livekit_DataStream.Header: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Livekit_DataStream.protoMessageName + ".Header" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "stream_id"), + 2: .same(proto: "timestamp"), + 3: .same(proto: "topic"), + 4: .standard(proto: "mime_type"), + 5: .standard(proto: "total_length"), + 6: .standard(proto: "total_chunks"), + 7: .standard(proto: "encryption_type"), + 8: .same(proto: "extensions"), + 9: .standard(proto: "text_header"), + 10: .standard(proto: "file_header"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.streamID) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &self.timestamp) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.topic) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.mimeType) }() + case 5: try { try decoder.decodeSingularUInt64Field(value: &self._totalLength) }() + case 6: try { try decoder.decodeSingularUInt64Field(value: &self._totalChunks) }() + case 7: try { try decoder.decodeSingularEnumField(value: &self.encryptionType) }() + case 8: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.extensions) }() + case 9: try { + var v: Livekit_DataStream.TextHeader? + var hadOneofValue = false + if let current = self.contentHeader { + hadOneofValue = true + if case .textHeader(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.contentHeader = .textHeader(v) + } + }() + case 10: try { + var v: Livekit_DataStream.FileHeader? + var hadOneofValue = false + if let current = self.contentHeader { + hadOneofValue = true + if case .fileHeader(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.contentHeader = .fileHeader(v) + } + }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.streamID.isEmpty { + try visitor.visitSingularStringField(value: self.streamID, fieldNumber: 1) + } + if self.timestamp != 0 { + try visitor.visitSingularInt64Field(value: self.timestamp, fieldNumber: 2) + } + if !self.topic.isEmpty { + try visitor.visitSingularStringField(value: self.topic, fieldNumber: 3) + } + if !self.mimeType.isEmpty { + try visitor.visitSingularStringField(value: self.mimeType, fieldNumber: 4) + } + try { if let v = self._totalLength { + try visitor.visitSingularUInt64Field(value: v, fieldNumber: 5) + } }() + try { if let v = self._totalChunks { + try visitor.visitSingularUInt64Field(value: v, fieldNumber: 6) + } }() + if self.encryptionType != .none { + try visitor.visitSingularEnumField(value: self.encryptionType, fieldNumber: 7) + } + if !self.extensions.isEmpty { + try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.extensions, fieldNumber: 8) + } + switch self.contentHeader { + case .textHeader?: try { + guard case .textHeader(let v)? = self.contentHeader else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 9) + }() + case .fileHeader?: try { + guard case .fileHeader(let v)? = self.contentHeader else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 10) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Livekit_DataStream.Header, rhs: Livekit_DataStream.Header) -> Bool { + if lhs.streamID != rhs.streamID {return false} + if lhs.timestamp != rhs.timestamp {return false} + if lhs.topic != rhs.topic {return false} + if lhs.mimeType != rhs.mimeType {return false} + if lhs._totalLength != rhs._totalLength {return false} + if lhs._totalChunks != rhs._totalChunks {return false} + if lhs.encryptionType != rhs.encryptionType {return false} + if lhs.extensions != rhs.extensions {return false} + if lhs.contentHeader != rhs.contentHeader {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Livekit_DataStream.Chunk: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Livekit_DataStream.protoMessageName + ".Chunk" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "stream_id"), + 2: .standard(proto: "chunk_index"), + 3: .same(proto: "content"), + 4: .same(proto: "complete"), + 5: .same(proto: "version"), + 6: .same(proto: "iv"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.streamID) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.chunkIndex) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.content) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self.complete) }() + case 5: try { try decoder.decodeSingularInt32Field(value: &self.version) }() + case 6: try { try decoder.decodeSingularBytesField(value: &self._iv) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.streamID.isEmpty { + try visitor.visitSingularStringField(value: self.streamID, fieldNumber: 1) + } + if self.chunkIndex != 0 { + try visitor.visitSingularUInt64Field(value: self.chunkIndex, fieldNumber: 2) + } + if !self.content.isEmpty { + try visitor.visitSingularBytesField(value: self.content, fieldNumber: 3) + } + if self.complete != false { + try visitor.visitSingularBoolField(value: self.complete, fieldNumber: 4) + } + if self.version != 0 { + try visitor.visitSingularInt32Field(value: self.version, fieldNumber: 5) + } + try { if let v = self._iv { + try visitor.visitSingularBytesField(value: v, fieldNumber: 6) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Livekit_DataStream.Chunk, rhs: Livekit_DataStream.Chunk) -> Bool { + if lhs.streamID != rhs.streamID {return false} + if lhs.chunkIndex != rhs.chunkIndex {return false} + if lhs.content != rhs.content {return false} + if lhs.complete != rhs.complete {return false} + if lhs.version != rhs.version {return false} + if lhs._iv != rhs._iv {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +}