From 51650ea3018d3d613606ec4b94203d4a91a11c4f Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Fri, 11 Aug 2023 10:17:13 +0530 Subject: [PATCH] Use refTS if ahead. (#1956) As expectedTS is tied to first packet and first packet adjustment may not have happened, refTS being ahead is not a bad thing. In one example, - first packet was late - a layer switch happened around 110ms later - in that time, 190ms worth of media was forwarded - but first packet adjustment did not happen yet - so at that layer switch, expected was behind - choosing ref at that switch is the right thing --- pkg/sfu/forwarder.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/sfu/forwarder.go b/pkg/sfu/forwarder.go index 74cb87de8..5edbcef57 100644 --- a/pkg/sfu/forwarder.go +++ b/pkg/sfu/forwarder.go @@ -1563,10 +1563,8 @@ func (f *Forwarder) processSourceSwitch(extPkt *buffer.ExtPacket, layer int32) e diffSeconds = float64(int32(expectedTS-refTS)) / float64(f.codec.ClockRate) if diffSeconds < 0.0 && math.Abs(diffSeconds) > SwitchAheadThresholdSeconds { logTransition("layer switch, reference too far ahead", expectedTS, refTS, lastTS, diffSeconds) - nextTS = expectedTS - } else { - nextTS = refTS } + nextTS = refTS } }