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
This commit is contained in:
Raja Subramanian
2023-08-11 10:17:13 +05:30
committed by GitHub
parent 19b84207a1
commit 51650ea301
+1 -3
View File
@@ -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
}
}