diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index b472e7ab9..96be8d46e 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -4244,14 +4244,17 @@ func (p *ParticipantImpl) SupportsSyncStreamID() bool { } func (p *ParticipantImpl) SupportsTransceiverReuse(mt types.MediaTrack) bool { - if !p.params.ClientInfo.SupportsTransceiverReuse() { - return false - } - + // ONE-SHOT-SIGNALLING-MODE: the client cannot negotiate again, so the transceivers of its offer + // are the only place for a subscribed track. This holds for every client, also for one that + // does not re-use transceivers in regular signalling. if p.params.UseOneShotSignallingMode { return p.ProtocolVersion().SupportsTransceiverReuse() } + if !p.params.ClientInfo.SupportsTransceiverReuse() { + return false + } + return p.ProtocolVersion().SupportsTransceiverReuse() && !p.SupportsSyncStreamID() && (!mt.IsEncrypted() || !p.params.DisableTransceiverReuseForE2EE) } diff --git a/pkg/rtc/participant_internal_test.go b/pkg/rtc/participant_internal_test.go index 07bc59773..7fcb2b4c8 100644 --- a/pkg/rtc/participant_internal_test.go +++ b/pkg/rtc/participant_internal_test.go @@ -116,6 +116,24 @@ func TestPublishCodecFallbackSkipsRTX(t *testing.T) { }) } +func TestSupportsTransceiverReuse(t *testing.T) { + // Browser / Os values are what the server's user agent parser sets for desktop Safari + safari := &livekit.ClientInfo{Browser: "Safari", Os: "Mac OS X"} + track := &typesfakes.FakeMediaTrack{} + + // a one shot client, i. e. WHIP, cannot negotiate again, so the transceivers of its offer are + // the only place for a subscribed track, also on a client that does not re-use otherwise + t.Run("one shot signalling re-uses on Safari", func(t *testing.T) { + p := newParticipantForTestWithOpts("test", &participantOpts{clientInfo: safari, oneShot: true}) + require.True(t, p.SupportsTransceiverReuse(track)) + }) + + t.Run("regular signalling does not re-use on Safari", func(t *testing.T) { + p := newParticipantForTestWithOpts("test", &participantOpts{clientInfo: safari}) + require.False(t, p.SupportsTransceiverReuse(track)) + }) +} + func TestSupportsMoving(t *testing.T) { t.Run("current protocol version", func(t *testing.T) { p := newParticipantForTestWithOpts("test", &participantOpts{protocolVersion: types.CurrentProtocol})