Skip to main content

TransitionPlan

Struct TransitionPlan 

Source
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: u64

The channel-timeline instant the join happens at — to’s planned_start.

§pts_rebase_offset: i128

Add 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: bool

Whether 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

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for TransitionPlan

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TransitionPlan

Source§

impl Debug for TransitionPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for TransitionPlan

Source§

impl PartialEq for TransitionPlan

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TransitionPlan

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.