pub struct TransitionPlan {
pub at_pts: u64,
pub pts_rebase_offset: i128,
pub discontinuity: bool,
}Expand description
The computed plan for joining from into to at Self::at_pts.
Fields§
§at_pts: u64The channel-timeline instant the join happens at — to’s
planned_start.
pts_rebase_offset: i128Add this to one of to’s own PTS values to place it on the shared
channel timeline (see Self::rebase). i128 so it can hold the
full possible difference of two u64 instants without clamping —
this crate never silently narrows a rebase computation. May be
negative when to’s own clock numbering starts after the channel
instant it is joining at (an unusual but not-impossible schedule).
discontinuity: boolWhether from and to carry different
CodecConfigIds — a discontinuity
that must be signalled downstream (init-segment change / new codec
config), never something this crate transcodes or conforms away.
Implementations§
Source§impl TransitionPlan
impl TransitionPlan
Sourcepub fn plan(from: &ScheduleEntry, to: &ScheduleEntry) -> Self
pub fn plan(from: &ScheduleEntry, to: &ScheduleEntry) -> Self
Plan the transition from from into to. to.planned_start is the
channel-timeline instant the join happens at; the rebase offset is
derived so that to.source_start_pts, once rebased, lands exactly on
that instant.
Sourcepub fn rebase(&self, source_pts: u64) -> Option<u64>
pub fn rebase(&self, source_pts: u64) -> Option<u64>
Map one of to’s own PTS values onto the shared channel timeline
(source_pts + pts_rebase_offset).
Returns None rather than wrapping if the rebased instant would fall
outside u64’s range (e.g. a source PTS before the source’s own
declared start, rebasing to before the join instant) — this crate
never silently produces a timeline instant that doesn’t correspond to
the input.
§source_pts must already be unwrapped (PLAY-W2, #1126)
pts_rebase_offset is fixed once, at Self::plan, from
to.source_start_pts. If to is a live or long-running source whose
own PTS numbering wraps mid-entry (e.g. a 33-bit MPEG PTS every
~26.5 h) and source_pts here is the raw, wrapped value, the
result is off by the wrap modulus — silently landing far from the
true timeline position (“the right thing at the wrong timestamp”,
exactly what this module’s own doc warns against). This crate has no
way to detect that from a single source_pts value: rebase is
pure, with no memory of previously-seen values to compare against.
The caller must unroll any source-clock wrap before calling this
(timed_metadata::Timeline already does exactly this for 33-bit MPEG PTS)
so every source_pts passed here is monotonic within the entry — or
use Self::rebase_wrapped, which does the unroll for a raw 33-bit PTS.
Sourcepub fn rebase_wrapped(
&self,
raw_pts: u64,
last_unwrapped_pts: u64,
) -> Option<u64>
pub fn rebase_wrapped( &self, raw_pts: u64, last_unwrapped_pts: u64, ) -> Option<u64>
Self::rebase for a raw, still-wrapped 33-bit source PTS
(PLAY-W2 hardening): raw_pts is unrolled against
last_unwrapped_pts (the previous unwrapped source PTS of this
entry, e.g. to.source_start_pts for the first sample) with
broadcast_common::clock33::unwrap_delta, then rebased. Handles one
wrap in either direction, so a source straddling 2^33 lands on the
right timeline instant instead of off by the modulus.
Returns None if raw_pts is not a 33-bit value (>= 2^33, i.e.
it is not a raw wire PTS) or the result is out of u64 range.