Skip to content

Synchronizer: add explicit sender report sync modes and one-shot drift correction#865

Merged
milos-lk merged 2 commits intomainfrom
sr-assited-time-jump
Mar 25, 2026
Merged

Synchronizer: add explicit sender report sync modes and one-shot drift correction#865
milos-lk merged 2 commits intomainfrom
sr-assited-time-jump

Conversation

@milos-lk
Copy link
Copy Markdown
Contributor

This change introduces an explicit sender report sync mode model in the synchronizer and adds a new one-shot drift correction path for mixer-oriented pipelines.

The main motivation is SIP silence suppression (which frequently doesn't get signaled properly) drift in room composite recordings. In that scenario, RTP timestamps can remain continuous while wall clock time advances much faster, which means the existing silence gap handling does not trigger. Over time, the audio track falls behind the mixer window and samples get dropped before the late correction path kicks in.

To address that, this PR adds a one-shot correction mode that:

  • uses rebased, OWD-normalized sender report timing for drift measurement
  • avoids gradual per-packet PTS slewing
  • applies a bounded one-shot PTS offset correction only when drift crosses a configured threshold
  • only applies that correction when a media deadline is available and the corrected PTS lands inside the live media window

This keeps normal packet PTS generation stable while still allowing the synchronizer to recover before the track falls out of the mixer’s live window.

What changed

Added explicit SenderReportSyncMode values:

  • without_rebase
  • rebase
  • one_shot
  • Added WithSenderReportSyncMode(...) to make SR behavior explicit on the API surface
  • Added WithOneShotDriftCorrectionThreshold(...) for configuring one-shot correction

Kept legacy APIs for compatibility:

  • WithRTCPSenderReportRebaseEnabled() still maps to rebase
  • WithAudioPTSAdjustmentDisabled() still controls audio SR slewing in the legacy without_rebase path
    Refactored track logic to branch on sync mode instead of implicit boolean combinations
    In one-shot mode:
  • SR drift is measured from rebased SR timing in adjusted PTS space
  • startTime is not adjusted
  • gradual SR-driven offset slewing is suppressed
  • correction is skipped entirely when no media deadline is available

This PR preserves existing behavior by default:

if nothing is configured, synchronizer stays on the legacy without_rebase path legacy rebase option still works.
WithAudioPTSAdjustmentDisabled() remains available because it is still needed to suppress audio SR-driven drift action in the legacy non-rebased path.
One-shot mode is opt-in and requires explicit configuration.

Why this shape

The previous option surface made it easy to end up with ambiguous combinations such as “rebase enabled + one-shot threshold + audio adjustment disabled”. This PR makes the behavior mode-based instead of relying on interacting booleans.

That should make it clearer which SR path is used, how drift is measured, and how drift is applied.

…t correction

This change introduces an explicit sender report sync mode model in the synchronizer and adds a new one-shot drift correction path for mixer-oriented pipelines.

The main motivation is SIP silence suppression (which frequently doesn't get signalled properly) drift in room composite recordings. In that scenario, RTP timestamps can remain continuous while wall clock time advances much faster, which means the existing silence gap handling does not trigger. Over time, the audio track falls behind the mixer window and samples get dropped before the late correction path kicks in.
@milos-lk milos-lk merged commit 3302552 into main Mar 25, 2026
5 checks passed
@milos-lk milos-lk deleted the sr-assited-time-jump branch March 25, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants