fix: skip RTX/FEC when picking a fallback video codec (#4930)

selectAlternativeVideoCodec walked the enabled codecs and returned the
first one with a video/ prefix. video/rtx and video/flexfec-03 both have
that prefix, so when the requested codec was not enabled the track could
fall back to RTX. RTX is a retransmission stream, not a real codec, so
the track got registered as video/rtx and subscribers saw a blank tile.

Skip RTX and FEC entries so the fallback is always a valid video codec.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Raja Subramanian
2026-10-04 21:20:28 +05:30
committed by GitHub
co-authored by Claude Opus 4.8
parent edb19c9e8f
commit c2339b2b85
3 changed files with 53 additions and 0 deletions
+17
View File
@@ -73,6 +73,23 @@ func TestIsCodecEnabled(t *testing.T) {
})
}
func TestSelectAlternativeVideoCodec(t *testing.T) {
// RTX and FEC have the video/ prefix but are not real codecs. The fallback must skip them.
t.Run("skips rtx and fec, picks real codec", func(t *testing.T) {
enabled := []*livekit.Codec{
{Mime: mime.MimeTypeRTX.String()},
{Mime: mime.MimeTypeFlexFEC03.String()},
{Mime: mime.MimeTypeH264.String()},
}
require.Equal(t, mime.MimeTypeH264.String(), selectAlternativeVideoCodec(enabled))
})
t.Run("falls back to vp8 when only rtx is enabled", func(t *testing.T) {
enabled := []*livekit.Codec{{Mime: mime.MimeTypeRTX.String()}}
require.Equal(t, mime.MimeTypeVP8.String(), selectAlternativeVideoCodec(enabled))
})
}
type offeredCodec struct {
payloadType webrtc.PayloadType
name string