Skip to content

Commit 6d4fab5

Browse files
authored
Use the local variable for lastTS. (#750)
Otherwise, the first sample is way off. Thanks to @milos-lk for the assist and keen 👀
1 parent 758475a commit 6d4fab5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/synchronizer/track.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,14 @@ func (t *TrackSynchronizer) getPTSWithoutRebase(pkt jitter.ExtPacket) (time.Dura
207207
lastTS = ts
208208
}
209209

210-
pts := t.lastPTS + t.toDuration(ts-t.lastTS)
210+
pts := t.lastPTS + t.toDuration(ts-lastTS)
211211
estimatedPTS := time.Since(t.startTime)
212212
if pts < t.lastPTS || !t.acceptable(pts-estimatedPTS) {
213213
newStartRTP := ts - t.toRTP(estimatedPTS)
214214
t.logger.Infow(
215215
"correcting PTS",
216216
"currentTS", ts,
217+
"lastTS", lastTS,
217218
"PTS", pts,
218219
"estimatedPTS", estimatedPTS,
219220
"offset", pts-estimatedPTS,
@@ -320,13 +321,14 @@ func (t *TrackSynchronizer) getPTSWithRebase(pkt jitter.ExtPacket) (time.Duratio
320321
lastTS = ts
321322
}
322323

323-
pts := t.lastPTS + t.toDuration(ts-t.lastTS)
324+
pts := t.lastPTS + t.toDuration(ts-lastTS)
324325
now := mono.Now()
325326
estimatedPTS := now.Sub(t.startTime)
326327
if pts < t.lastPTS || !t.acceptable(pts-estimatedPTS) {
327328
t.logger.Infow(
328329
"correcting PTS",
329330
"currentTS", ts,
331+
"lastTS", lastTS,
330332
"PTS", pts,
331333
"estimatedPTS", estimatedPTS,
332334
"offset", pts-estimatedPTS,

0 commit comments

Comments
 (0)