Skip to content

Commit

Permalink
Sending codec in setPublisher
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski committed Dec 23, 2024
1 parent 93ee255 commit 01ae4ad
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### ✅ Added
- CallKit availability policies allows you to control wether `Callkit` should be enabled/disabled based on different rules [#611](https://github.com/GetStream/stream-video-swift/pull/611)
- Codec negotiation during calls (#606)(https://github.com/GetStream/stream-video-swift/pull/606)

### 🐞 Fixed
- By observing the `CallKitPushNotificationAdapter.deviceToken` you will be notified with an empty `deviceToken` value, once the object unregister push notifications. [#608](https://github.com/GetStream/stream-video-swift/pull/608)
Expand Down
10 changes: 10 additions & 0 deletions Sources/StreamVideo/Models/PublishOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ struct PublishOptions: Sendable, Hashable {
) -> Bool {
lhs.id == rhs.id && lhs.codec == rhs.codec
}

/// Returns the codec for the specified track type.
/// - Parameter trackType: The type of track for which to get the codec.
/// - Returns: The codec for the specified track type.
func codec(for trackType: TrackType) -> Stream_Video_Sfu_Models_Codec {
Stream_Video_Sfu_Models_PublishOption(
self,
trackType: trackType == .video ? .video : .screenShare
).codec
}

/// Builds video layers for the specified track type.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ final class LocalScreenShareMediaAdapter: LocalMediaAdapting, @unchecked Sendabl
trackInfo.layers = publishOptions.buildLayers(for: .screenshare)
trackInfo.mid = transceiver.mid
trackInfo.muted = transceiver.sender.track?.isEnabled ?? true
trackInfo.codec = publishOptions.codec(for: .screenshare)
return trackInfo
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ final class LocalVideoMediaAdapter: LocalMediaAdapting, @unchecked Sendable {
trackInfo.layers = publishOptions.buildLayers(for: .video)
trackInfo.mid = transceiver.mid
trackInfo.muted = transceiver.sender.track?.isEnabled ?? true
trackInfo.codec = publishOptions.codec(for: .video)
return trackInfo
}
}
Expand Down
21 changes: 21 additions & 0 deletions Sources/StreamVideo/protobuf/sfu/models/models.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1081,9 +1081,20 @@ struct Stream_Video_Sfu_Models_TrackInfo {

var muted: Bool = false

var codec: Stream_Video_Sfu_Models_Codec {
get {return _codec ?? Stream_Video_Sfu_Models_Codec()}
set {_codec = newValue}
}
/// Returns true if `codec` has been explicitly set.
var hasCodec: Bool {return self._codec != nil}
/// Clears the value of `codec`. Subsequent reads from it will return its default value.
mutating func clearCodec() {self._codec = nil}

var unknownFields = SwiftProtobuf.UnknownStorage()

init() {}

fileprivate var _codec: Stream_Video_Sfu_Models_Codec? = nil
}

struct Stream_Video_Sfu_Models_Error {
Expand Down Expand Up @@ -2109,6 +2120,7 @@ extension Stream_Video_Sfu_Models_TrackInfo: SwiftProtobuf.Message, SwiftProtobu
8: .same(proto: "stereo"),
9: .same(proto: "red"),
10: .same(proto: "muted"),
11: .same(proto: "codec"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
Expand All @@ -2125,12 +2137,17 @@ extension Stream_Video_Sfu_Models_TrackInfo: SwiftProtobuf.Message, SwiftProtobu
case 8: try { try decoder.decodeSingularBoolField(value: &self.stereo) }()
case 9: try { try decoder.decodeSingularBoolField(value: &self.red) }()
case 10: try { try decoder.decodeSingularBoolField(value: &self.muted) }()
case 11: try { try decoder.decodeSingularMessageField(value: &self._codec) }()
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
if !self.trackID.isEmpty {
try visitor.visitSingularStringField(value: self.trackID, fieldNumber: 1)
}
Expand All @@ -2155,6 +2172,9 @@ extension Stream_Video_Sfu_Models_TrackInfo: SwiftProtobuf.Message, SwiftProtobu
if self.muted != false {
try visitor.visitSingularBoolField(value: self.muted, fieldNumber: 10)
}
try { if let v = self._codec {
try visitor.visitSingularMessageField(value: v, fieldNumber: 11)
} }()
try unknownFields.traverse(visitor: &visitor)
}

Expand All @@ -2167,6 +2187,7 @@ extension Stream_Video_Sfu_Models_TrackInfo: SwiftProtobuf.Message, SwiftProtobu
if lhs.stereo != rhs.stereo {return false}
if lhs.red != rhs.red {return false}
if lhs.muted != rhs.muted {return false}
if lhs._codec != rhs._codec {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class StreamAppStateAdapter_Tests: XCTestCase, @unchecked Sendable {

// MARK: - Private Helpers

private func assertApplicationState(
@MainActor private func assertApplicationState(
initial: StreamAppStateAdapter.State,
target: StreamAppStateAdapter.State,
file: StaticString = #file,
Expand Down

0 comments on commit 01ae4ad

Please sign in to comment.