Skip to content

Commit 613a09c

Browse files
authored
Fix codec warning (#778)
Cherry-picked from the transceiver branch
1 parent ad2357b commit 613a09c

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Sources/LiveKit/Extensions/RTCRtpTransceiver.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal import LiveKitWebRTC
2020

2121
extension LKRTCRtpTransceiver: Loggable {
2222
/// Attempts to set preferred video codec.
23-
func set(preferredVideoCodec codec: VideoCodec, exceptCodec: VideoCodec? = nil) {
23+
func set(preferredVideoCodec codec: VideoCodec, exceptCodec: VideoCodec? = nil) throws {
2424
// Get list of supported codecs...
2525
let allVideoCodecs = RTC.videoSenderCapabilities.codecs
2626

@@ -36,7 +36,11 @@ extension LKRTCRtpTransceiver: Loggable {
3636
let combinedCapabilities = [preferredCodecCapability] + otherCapabilities
3737

3838
// Codecs not set in codecPreferences will not be negotiated in the offer
39-
codecPreferences = combinedCapabilities.compactMap { $0 }
39+
do {
40+
try setCodecPreferences(combinedCapabilities.compactMap { $0 }, error: ())
41+
} catch {
42+
throw LiveKitError(.webRTC, message: "Failed to set codec preferences", internalError: error)
43+
}
4044

4145
log("codecPreferences set: \(codecPreferences.map { String(describing: $0) }.joined(separator: ", "))")
4246

Sources/LiveKit/Participant/LocalParticipant.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ extension LocalParticipant {
458458
log("[Publish] Added transceiver...")
459459

460460
// Set codec...
461-
transceiver.set(preferredVideoCodec: videoCodec)
461+
try transceiver.set(preferredVideoCodec: videoCodec)
462462

463463
let sender = transceiver.sender
464464

@@ -667,7 +667,7 @@ extension LocalParticipant {
667667
}
668668

669669
if let preferredCodec = publishOptions.preferredCodec {
670-
transceiver.set(preferredVideoCodec: preferredCodec)
670+
try transceiver.set(preferredVideoCodec: preferredCodec)
671671
}
672672
}
673673

0 commit comments

Comments
 (0)