From 6df339b77c75a25bccb775dad9b13a27d0364992 Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Fri, 13 Dec 2024 21:12:30 +0800 Subject: [PATCH] Don't SetCodecPreferences for video transceiver (#3249) The SetCodecPrefrences function will save codecs to the transceiver and if the primary codec is not support by the client, the saved codec will generate rtx codec for the unsupported codec cause corrupted sdp. --- pkg/rtc/transport.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/rtc/transport.go b/pkg/rtc/transport.go index 21d986ccc..0d76fbf70 100644 --- a/pkg/rtc/transport.go +++ b/pkg/rtc/transport.go @@ -811,7 +811,9 @@ func (t *PCTransport) AddTrack(trackLocal webrtc.TrackLocal, params types.AddTra return } - configureAudioTransceiver(transceiver, params.Stereo, !params.Red || !t.params.ClientInfo.SupportsAudioRED()) + if trackLocal.Kind() == webrtc.RTPCodecTypeAudio { + configureAudioTransceiver(transceiver, params.Stereo, !params.Red || !t.params.ClientInfo.SupportsAudioRED()) + } return } @@ -827,7 +829,9 @@ func (t *PCTransport) AddTransceiverFromTrack(trackLocal webrtc.TrackLocal, para return } - configureAudioTransceiver(transceiver, params.Stereo, !params.Red || !t.params.ClientInfo.SupportsAudioRED()) + if trackLocal.Kind() == webrtc.RTPCodecTypeAudio { + configureAudioTransceiver(transceiver, params.Stereo, !params.Red || !t.params.ClientInfo.SupportsAudioRED()) + } return }