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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2105>
This commit is contained in:
Sebastian Dröge 2025-02-17 14:18:05 +02:00 committed by GStreamer Marge Bot
parent 7b780e2aaf
commit 16bbe13f38

View file

@ -366,6 +366,14 @@ impl State {
self.discont_pending = true; self.discont_pending = true;
} }
} else { } 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!( gst::debug!(
CAT, CAT,
imp = imp, imp = imp,
@ -376,7 +384,13 @@ impl State {
); );
new_pcr = MpegTsPcr::new(pcr); new_pcr = MpegTsPcr::new(pcr);
self.base_pcr = Some(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.discont_pending = true;
} }
self.last_seen_pcr = Some(new_pcr); self.last_seen_pcr = Some(new_pcr);