pub struct PcrTracker {
pub max_jitter_27mhz: u32,
/* private fields */
}Expand description
Per-PCR-PID PCR recovery + discontinuity detector.
Construct one per PCR_PID and call [observe] for every TS
packet on that PID. Packets without a PCR are silently ignored
(the tracker still reads them for the discontinuity_indicator
flag, since §2.4.3.5 allows the indicator to be set in packets
prior to the one carrying the new PCR).
The tracker keeps the last PCR + byte-offset to compute the instantaneous bitrate, and the previous pair so a fresh sample can have its jitter computed without a second sample arriving.
Fields§
§max_jitter_27mhz: u32Threshold (in 27 MHz ticks) beyond which an unsignalled jump is reported as a discontinuity. Defaults to 100 ms × 27000 = 2 700 000 ticks. The spec says ±500 ns is the spec tolerance; real-world re-mux jitter is far higher (tens of milliseconds) so we use a window large enough to ignore schedule wobble but small enough to catch a clean time-base reset.
Implementations§
Source§impl PcrTracker
impl PcrTracker
Sourcepub const DEFAULT_MAX_JITTER_27MHZ: u32 = 2_700_000
pub const DEFAULT_MAX_JITTER_27MHZ: u32 = 2_700_000
Default jitter window: 100 ms.
At 27 MHz that’s 2 700 000 ticks. Comfortably above the ±500 ns spec PCR tolerance but tight enough that a clean re-mux time-base reset (which jumps by seconds or hours) fires the discontinuity path.
Sourcepub fn with_jitter_window(max_jitter_27mhz: u32) -> Self
pub fn with_jitter_window(max_jitter_27mhz: u32) -> Self
Build a tracker with a custom jitter window (27 MHz ticks).
Sourcepub fn observe(
&mut self,
af: &AdaptationField<'_>,
byte_offset: u64,
) -> Option<PcrEvent>
pub fn observe( &mut self, af: &AdaptationField<'_>, byte_offset: u64, ) -> Option<PcrEvent>
Observe one packet’s adaptation field.
byte_offset is the position of this packet’s first byte in
the contiguous TS stream. It only needs to be monotonic; the
tracker uses differences, not absolute values. Typical
callers pass bytes_read - 188.
Returns None when the packet had no PCR and no pending
discontinuity to commit.
Trait Implementations§
Source§impl Clone for PcrTracker
impl Clone for PcrTracker
Source§fn clone(&self) -> PcrTracker
fn clone(&self) -> PcrTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more