From 16bbe13f388bece914a9591757f174be413428c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 17 Feb 2025 14:18:05 +0200 Subject: [PATCH] mpegtslivesrc: Consider the initial calibration of the clock too Previously we assumed that the calibration is always at the origin but this is not necessarily true. Part-of: --- net/mpegtslive/src/mpegtslive/imp.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/net/mpegtslive/src/mpegtslive/imp.rs b/net/mpegtslive/src/mpegtslive/imp.rs index 95395ab34..77e72d414 100644 --- a/net/mpegtslive/src/mpegtslive/imp.rs +++ b/net/mpegtslive/src/mpegtslive/imp.rs @@ -366,6 +366,14 @@ impl State { self.discont_pending = true; } } else { + let (cinternal, cexternal, cnum, cdenom) = imp.external_clock.calibration(); + let base_external = gst::Clock::adjust_with_calibration( + observation_internal, + cinternal, + cexternal, + cnum, + cdenom, + ); gst::debug!( CAT, imp = imp, @@ -376,7 +384,13 @@ impl State { ); new_pcr = MpegTsPcr::new(pcr); self.base_pcr = Some(new_pcr); - self.base_external = Some(observation_internal); + self.base_external = Some(base_external); + imp.external_clock + .set_calibration(observation_internal, base_external, 1, 1); + // Hack to flush out observations, we set the window-size to the + // same value + imp.external_clock + .set_window_size(imp.external_clock.window_size()); self.discont_pending = true; } self.last_seen_pcr = Some(new_pcr);