From 4f6ed65d616f21a60d8f77ee55f37ff48ac6462b Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Tue, 7 Oct 2025 23:28:26 +0530 Subject: [PATCH] Limit check to red + opus when looking for primary codec match. (#3988) For codec regression, even if track is encrypted, should be able to fall back to a backup codec and trigger a regression. --- pkg/sfu/downtrack.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/sfu/downtrack.go b/pkg/sfu/downtrack.go index f5f7aec7f..590a2ac79 100644 --- a/pkg/sfu/downtrack.go +++ b/pkg/sfu/downtrack.go @@ -464,9 +464,19 @@ func (d *DownTrack) Bind(t webrtc.TrackLocalContext) (webrtc.RTPCodecParameters, matchedUpstreamCodec = c break } else { - // for encrypyted tracks, should match on primary codec, i. e. codec at index 0 + // for encrypyted tracks, should match on primary codec, + // i. e. codec at index 0 if the combination of upstream codecs is opus and RED if d.params.IsEncrypted { - break + isRedAndOpus := true + for _, u := range d.upstreamCodecs { + if !mime.IsMimeTypeStringOpus(u.MimeType) || !mime.IsMimeTypeStringRED(u.MimeType) { + isRedAndOpus = false + break + } + } + if isRedAndOpus { + break + } } } }