Skip to content

Commit

Permalink
Generated code for reporting connection times and code preference (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski authored Nov 20, 2024
1 parent bb9c4ec commit 1589d1a
Show file tree
Hide file tree
Showing 6 changed files with 449 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ extension Stream_Video_Sfu_Event_SfuEvent.OneOf_EventPayload {
return payload as? T
case let .codecNegotiationComplete(payload):
return payload as? T
case let .changePublishOptions(payload):
return payload as? T
}
}
}
1 change: 1 addition & 0 deletions Sources/StreamVideo/WebSockets/Events/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ extension Stream_Video_Sfu_Event_SfuEvent.OneOf_EventPayload: Event {
case .participantUpdated: return "participantUpdated"
case .participantMigrationComplete: return "participantMigrationComplete"
case .codecNegotiationComplete: return "codecNegotiationComplete"
case .changePublishOptions: return "changePublishOptions"
}
}
}
125 changes: 125 additions & 0 deletions Sources/StreamVideo/protobuf/sfu/event/events.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ struct Stream_Video_Sfu_Event_SfuEvent {
set {eventPayload = .codecNegotiationComplete(newValue)}
}

/// ChangePublishOptions is sent to signal the change in publish options such as a new codec or simulcast layers
var changePublishOptions: Stream_Video_Sfu_Event_ChangePublishOptions {
get {
if case .changePublishOptions(let v)? = eventPayload {return v}
return Stream_Video_Sfu_Event_ChangePublishOptions()
}
set {eventPayload = .changePublishOptions(newValue)}
}

var unknownFields = SwiftProtobuf.UnknownStorage()

enum OneOf_EventPayload: Equatable {
Expand Down Expand Up @@ -319,6 +328,8 @@ struct Stream_Video_Sfu_Event_SfuEvent {
/// CodecNegotiationComplete is sent to signal the completion of a codec negotiation.
/// SDKs can safely stop previous transceivers
case codecNegotiationComplete(Stream_Video_Sfu_Event_CodecNegotiationComplete)
/// ChangePublishOptions is sent to signal the change in publish options such as a new codec or simulcast layers
case changePublishOptions(Stream_Video_Sfu_Event_ChangePublishOptions)

#if !swift(>=4.1)
static func ==(lhs: Stream_Video_Sfu_Event_SfuEvent.OneOf_EventPayload, rhs: Stream_Video_Sfu_Event_SfuEvent.OneOf_EventPayload) -> Bool {
Expand Down Expand Up @@ -414,6 +425,10 @@ struct Stream_Video_Sfu_Event_SfuEvent {
guard case .codecNegotiationComplete(let l) = lhs, case .codecNegotiationComplete(let r) = rhs else { preconditionFailure() }
return l == r
}()
case (.changePublishOptions, .changePublishOptions): return {
guard case .changePublishOptions(let l) = lhs, case .changePublishOptions(let r) = rhs else { preconditionFailure() }
return l == r
}()
default: return false
}
}
Expand All @@ -423,6 +438,27 @@ struct Stream_Video_Sfu_Event_SfuEvent {
init() {}
}

struct Stream_Video_Sfu_Event_ChangePublishOptions {
// 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 publishOption: Stream_Video_Sfu_Models_PublishOption {
get {return _publishOption ?? Stream_Video_Sfu_Models_PublishOption()}
set {_publishOption = newValue}
}
/// Returns true if `publishOption` has been explicitly set.
var hasPublishOption: Bool {return self._publishOption != nil}
/// Clears the value of `publishOption`. Subsequent reads from it will return its default value.
mutating func clearPublishOption() {self._publishOption = nil}

var unknownFields = SwiftProtobuf.UnknownStorage()

init() {}

fileprivate var _publishOption: Stream_Video_Sfu_Models_PublishOption? = nil
}

struct Stream_Video_Sfu_Event_CodecNegotiationComplete {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
Expand Down Expand Up @@ -726,6 +762,11 @@ struct Stream_Video_Sfu_Event_JoinRequest {
set {_uniqueStorage()._subscriberSdp = newValue}
}

var publisherSdp: String {
get {return _storage._publisherSdp}
set {_uniqueStorage()._publisherSdp = newValue}
}

var clientDetails: Stream_Video_Sfu_Models_ClientDetails {
get {return _storage._clientDetails ?? Stream_Video_Sfu_Models_ClientDetails()}
set {_uniqueStorage()._clientDetails = newValue}
Expand Down Expand Up @@ -768,6 +809,11 @@ struct Stream_Video_Sfu_Event_JoinRequest {
/// Clears the value of `reconnectDetails`. Subsequent reads from it will return its default value.
mutating func clearReconnectDetails() {_uniqueStorage()._reconnectDetails = nil}

var preferredPublishOptions: [Stream_Video_Sfu_Models_PublishOption] {
get {return _storage._preferredPublishOptions}
set {_uniqueStorage()._preferredPublishOptions = newValue}
}

var unknownFields = SwiftProtobuf.UnknownStorage()

init() {}
Expand Down Expand Up @@ -832,6 +878,8 @@ struct Stream_Video_Sfu_Event_JoinResponse {

var fastReconnectDeadlineSeconds: Int32 = 0

var publishOptions: [Stream_Video_Sfu_Models_PublishOption] = []

var unknownFields = SwiftProtobuf.UnknownStorage()

init() {}
Expand Down Expand Up @@ -1180,6 +1228,7 @@ struct Stream_Video_Sfu_Event_CallEnded {
#if swift(>=5.5) && canImport(_Concurrency)
extension Stream_Video_Sfu_Event_SfuEvent: @unchecked Sendable {}
extension Stream_Video_Sfu_Event_SfuEvent.OneOf_EventPayload: @unchecked Sendable {}
extension Stream_Video_Sfu_Event_ChangePublishOptions: @unchecked Sendable {}
extension Stream_Video_Sfu_Event_CodecNegotiationComplete: @unchecked Sendable {}
extension Stream_Video_Sfu_Event_ParticipantMigrationComplete: @unchecked Sendable {}
extension Stream_Video_Sfu_Event_PinsChanged: @unchecked Sendable {}
Expand Down Expand Up @@ -1245,6 +1294,7 @@ extension Stream_Video_Sfu_Event_SfuEvent: SwiftProtobuf.Message, SwiftProtobuf.
24: .standard(proto: "participant_updated"),
25: .standard(proto: "participant_migration_complete"),
26: .standard(proto: "codec_negotiation_complete"),
27: .standard(proto: "change_publish_options"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
Expand Down Expand Up @@ -1539,6 +1589,19 @@ extension Stream_Video_Sfu_Event_SfuEvent: SwiftProtobuf.Message, SwiftProtobuf.
self.eventPayload = .codecNegotiationComplete(v)
}
}()
case 27: try {
var v: Stream_Video_Sfu_Event_ChangePublishOptions?
var hadOneofValue = false
if let current = self.eventPayload {
hadOneofValue = true
if case .changePublishOptions(let m) = current {v = m}
}
try decoder.decodeSingularMessageField(value: &v)
if let v = v {
if hadOneofValue {try decoder.handleConflictingOneOf()}
self.eventPayload = .changePublishOptions(v)
}
}()
default: break
}
}
Expand Down Expand Up @@ -1638,6 +1701,10 @@ extension Stream_Video_Sfu_Event_SfuEvent: SwiftProtobuf.Message, SwiftProtobuf.
guard case .codecNegotiationComplete(let v)? = self.eventPayload else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 26)
}()
case .changePublishOptions?: try {
guard case .changePublishOptions(let v)? = self.eventPayload else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 27)
}()
case nil: break
}
try unknownFields.traverse(visitor: &visitor)
Expand All @@ -1650,6 +1717,42 @@ extension Stream_Video_Sfu_Event_SfuEvent: SwiftProtobuf.Message, SwiftProtobuf.
}
}

extension Stream_Video_Sfu_Event_ChangePublishOptions: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".ChangePublishOptions"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .standard(proto: "publish_option"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(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.decodeSingularMessageField(value: &self._publishOption) }()
default: break
}
}
}

func traverse<V: SwiftProtobuf.Visitor>(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
try { if let v = self._publishOption {
try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
} }()
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Stream_Video_Sfu_Event_ChangePublishOptions, rhs: Stream_Video_Sfu_Event_ChangePublishOptions) -> Bool {
if lhs._publishOption != rhs._publishOption {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Stream_Video_Sfu_Event_CodecNegotiationComplete: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".CodecNegotiationComplete"
static let _protobuf_nameMap = SwiftProtobuf._NameMap()
Expand Down Expand Up @@ -2211,20 +2314,24 @@ extension Stream_Video_Sfu_Event_JoinRequest: SwiftProtobuf.Message, SwiftProtob
1: .same(proto: "token"),
2: .standard(proto: "session_id"),
3: .standard(proto: "subscriber_sdp"),
8: .standard(proto: "publisher_sdp"),
4: .standard(proto: "client_details"),
5: .same(proto: "migration"),
6: .standard(proto: "fast_reconnect"),
7: .standard(proto: "reconnect_details"),
9: .standard(proto: "preferred_publish_options"),
]

fileprivate class _StorageClass {
var _token: String = String()
var _sessionID: String = String()
var _subscriberSdp: String = String()
var _publisherSdp: String = String()
var _clientDetails: Stream_Video_Sfu_Models_ClientDetails? = nil
var _migration: Stream_Video_Sfu_Event_Migration? = nil
var _fastReconnect: Bool = false
var _reconnectDetails: Stream_Video_Sfu_Event_ReconnectDetails? = nil
var _preferredPublishOptions: [Stream_Video_Sfu_Models_PublishOption] = []

static let defaultInstance = _StorageClass()

Expand All @@ -2234,10 +2341,12 @@ extension Stream_Video_Sfu_Event_JoinRequest: SwiftProtobuf.Message, SwiftProtob
_token = source._token
_sessionID = source._sessionID
_subscriberSdp = source._subscriberSdp
_publisherSdp = source._publisherSdp
_clientDetails = source._clientDetails
_migration = source._migration
_fastReconnect = source._fastReconnect
_reconnectDetails = source._reconnectDetails
_preferredPublishOptions = source._preferredPublishOptions
}
}

Expand All @@ -2263,6 +2372,8 @@ extension Stream_Video_Sfu_Event_JoinRequest: SwiftProtobuf.Message, SwiftProtob
case 5: try { try decoder.decodeSingularMessageField(value: &_storage._migration) }()
case 6: try { try decoder.decodeSingularBoolField(value: &_storage._fastReconnect) }()
case 7: try { try decoder.decodeSingularMessageField(value: &_storage._reconnectDetails) }()
case 8: try { try decoder.decodeSingularStringField(value: &_storage._publisherSdp) }()
case 9: try { try decoder.decodeRepeatedMessageField(value: &_storage._preferredPublishOptions) }()
default: break
}
}
Expand Down Expand Up @@ -2296,6 +2407,12 @@ extension Stream_Video_Sfu_Event_JoinRequest: SwiftProtobuf.Message, SwiftProtob
try { if let v = _storage._reconnectDetails {
try visitor.visitSingularMessageField(value: v, fieldNumber: 7)
} }()
if !_storage._publisherSdp.isEmpty {
try visitor.visitSingularStringField(value: _storage._publisherSdp, fieldNumber: 8)
}
if !_storage._preferredPublishOptions.isEmpty {
try visitor.visitRepeatedMessageField(value: _storage._preferredPublishOptions, fieldNumber: 9)
}
}
try unknownFields.traverse(visitor: &visitor)
}
Expand All @@ -2308,10 +2425,12 @@ extension Stream_Video_Sfu_Event_JoinRequest: SwiftProtobuf.Message, SwiftProtob
if _storage._token != rhs_storage._token {return false}
if _storage._sessionID != rhs_storage._sessionID {return false}
if _storage._subscriberSdp != rhs_storage._subscriberSdp {return false}
if _storage._publisherSdp != rhs_storage._publisherSdp {return false}
if _storage._clientDetails != rhs_storage._clientDetails {return false}
if _storage._migration != rhs_storage._migration {return false}
if _storage._fastReconnect != rhs_storage._fastReconnect {return false}
if _storage._reconnectDetails != rhs_storage._reconnectDetails {return false}
if _storage._preferredPublishOptions != rhs_storage._preferredPublishOptions {return false}
return true
}
if !storagesAreEqual {return false}
Expand Down Expand Up @@ -2433,6 +2552,7 @@ extension Stream_Video_Sfu_Event_JoinResponse: SwiftProtobuf.Message, SwiftProto
1: .standard(proto: "call_state"),
2: .same(proto: "reconnected"),
3: .standard(proto: "fast_reconnect_deadline_seconds"),
4: .standard(proto: "publish_options"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
Expand All @@ -2444,6 +2564,7 @@ extension Stream_Video_Sfu_Event_JoinResponse: SwiftProtobuf.Message, SwiftProto
case 1: try { try decoder.decodeSingularMessageField(value: &self._callState) }()
case 2: try { try decoder.decodeSingularBoolField(value: &self.reconnected) }()
case 3: try { try decoder.decodeSingularInt32Field(value: &self.fastReconnectDeadlineSeconds) }()
case 4: try { try decoder.decodeRepeatedMessageField(value: &self.publishOptions) }()
default: break
}
}
Expand All @@ -2463,13 +2584,17 @@ extension Stream_Video_Sfu_Event_JoinResponse: SwiftProtobuf.Message, SwiftProto
if self.fastReconnectDeadlineSeconds != 0 {
try visitor.visitSingularInt32Field(value: self.fastReconnectDeadlineSeconds, fieldNumber: 3)
}
if !self.publishOptions.isEmpty {
try visitor.visitRepeatedMessageField(value: self.publishOptions, fieldNumber: 4)
}
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Stream_Video_Sfu_Event_JoinResponse, rhs: Stream_Video_Sfu_Event_JoinResponse) -> Bool {
if lhs._callState != rhs._callState {return false}
if lhs.reconnected != rhs.reconnected {return false}
if lhs.fastReconnectDeadlineSeconds != rhs.fastReconnectDeadlineSeconds {return false}
if lhs.publishOptions != rhs.publishOptions {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
Expand Down
Loading

0 comments on commit 1589d1a

Please sign in to comment.