From cb235c123c51902317f525b5fd0ef79c21df4bfb Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Sat, 7 Sep 2024 10:14:35 +0530 Subject: [PATCH] Seed down track state on re-use. (#2985) With the new early negotiation, onBinding callback could happen later. Reset reusingTransceiver only if not re-using it. --- pkg/rtc/mediatracksubscriptions.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/rtc/mediatracksubscriptions.go b/pkg/rtc/mediatracksubscriptions.go index ee49eccaa..ecde486fd 100644 --- a/pkg/rtc/mediatracksubscriptions.go +++ b/pkg/rtc/mediatracksubscriptions.go @@ -187,6 +187,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr * return } if reusingTransceiver.Load() { + sub.GetLogger().Debugw("seeding downtrack state", "trackID", trackID) downTrack.SeedState(dtState) } if err = wr.AddDownTrack(downTrack); err != nil && err != sfu.ErrReceiverClosed { @@ -265,9 +266,9 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr * // will happen and that will notify remote of this stopped // transceiver existingTransceiver.Stop() + reusingTransceiver.Store(false) } } - reusingTransceiver.Store(false) // if cannot replace, find an unused transceiver or add new one if transceiver == nil {