Skip to content

Commit 0af59ab

Browse files
authored
Don't report drift that's not applied (#768)
The initial idea behind invoking callback regardless of whether the drift was applied or not was logging. Now that we log not acceptable and high drift values - there is no reason to invoke the callback for the drift that's not applied. Makes data cleaner and prevents acting on something that was essentially skipped.
1 parent ac58665 commit 0af59ab

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/synchronizer/track.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,6 @@ func (t *TrackSynchronizer) onSenderReportWithoutRebase(pkt *rtcp.SenderReport)
538538
}
539539

540540
drift := mediatransportutil.NtpTime(pkt.NTPTime).Time().Sub(t.startTime.Add(pts))
541-
if t.onSR != nil {
542-
t.onSR(drift)
543-
}
544541
if drift > cHighDriftLoggingThreshold || drift < -cHighDriftLoggingThreshold {
545542
t.logger.Infow(
546543
"high drift sender report",
@@ -560,6 +557,10 @@ func (t *TrackSynchronizer) onSenderReportWithoutRebase(pkt *rtcp.SenderReport)
560557
return
561558
}
562559

560+
if t.onSR != nil {
561+
t.onSR(drift)
562+
}
563+
563564
t.desiredPTSOffset = t.basePTSOffset + drift
564565
t.lastSR = augmented
565566
}
@@ -619,9 +620,6 @@ func (t *TrackSynchronizer) onSenderReportWithRebase(pkt *rtcp.SenderReport) {
619620

620621
// drift is based on local clock
621622
drift := time.Unix(0, augmented.receivedAtAdjusted).Sub(t.startTime.Add(ptsSR))
622-
if t.onSR != nil {
623-
t.onSR(drift)
624-
}
625623
if drift > cHighDriftLoggingThreshold || drift < -cHighDriftLoggingThreshold {
626624
t.logger.Infow(
627625
"high drift sender report",
@@ -644,6 +642,10 @@ func (t *TrackSynchronizer) onSenderReportWithRebase(pkt *rtcp.SenderReport) {
644642
return
645643
}
646644

645+
if t.onSR != nil {
646+
t.onSR(drift)
647+
}
648+
647649
t.desiredPTSOffset = t.basePTSOffset + drift
648650
t.lastSR = augmented
649651
}

0 commit comments

Comments
 (0)