Skip to main content

Programs

Struct Programs 

Source
pub struct Programs { /* private fields */ }
Expand description

Imports every program the PAT lists, each as its own broadcast on origin, with its own clock and catalog.

Program n of event.hang publishes on event/n.hang, keeping the catalog suffix last so format detection still sees it; a name without one gains a plain /n. A program starts once its PMT lists an elementary stream; until then it publishes nothing. One whose PMT has not arrived 0.5 s of program clock after the PAT listed it, the bound TR 101 290 sets for PMT_error_2, is late: each 0.5 s its PMT PID carries no PMT section counts in stats::Snapshot::pmt_error, its PIDs count as unclaimed, and the other programs carry on. It starts whenever its PMT arrives. The clock is a running program’s, so nothing is late before one runs, and one whose PMT arrived listing no stream yet is not late. Input ahead of that PMT is dropped, as a single Import drops media ahead of its PSI; its SI arrives with the next repetition, as for an import joining mid-stream.

The PAT is followed as it changes. A program a later PAT adds waits for its PMT as the first PAT’s do, and each program follows its PMT to the PID the latest PAT names. One a later PAT drops is retired: its tracks finish and its broadcast is unannounced, while the other programs carry on. A program that returns publishes a new stream, under a new identity.

The multiplex is parsed once: framing, continuity, the PAT and the SI sections are shared, and each program reads only the packets on the PIDs its PAT entry and PMT claim. A packet on a PID no program reads, the PAT’s PMT PIDs, the SI PIDs and the null PID aside, is counted once for the multiplex (see stats::Snapshot::streams). Counting waits until every program the PAT lists has its PMT or is late, since until then a PID may be a program’s still to come.

Each PID is counted once, so a PID several programs read has one continuous set of counters while they start and retire. The PMT sections are reassembled here, once per PMT PID, so a bad CRC counts once however many programs read the PID. Every other count of a PID is taken from one program at a time for each way it is read: its row and PTS cadence from a program carrying it, or else one reading it, its PCR checks from one taking its clock there, and its PMT interval from one reading its PMT there. When that program stops reading it so, the earliest running one that does takes over the intervals it was timing, and counts on from the total it leaves.

Implementations§

Source§

impl Programs

Source

pub fn new(origin: Producer, name: impl Into<Path>, config: Config) -> Self

Split the multiplex into broadcasts named after name, each catalog built from config.

Source

pub fn decode(&mut self, data: &[u8]) -> Result<(), Error>

Demux a chunk of the multiplex. A trailing partial packet is retained for the next call.

Source

pub fn stats(&self) -> Snapshot

Every program’s counters in one map, each PID counted once.

The multiplex is graded once. Programs sharing a PMT PID read the same PMT sections, so a dropped section counts once however many read it, and a PID several programs read is counted by one of them at a time. What a retired program counted stays in the totals, so no total goes back when a program leaves or returns. So are the packets on PIDs no program reads, in the row of the program that reads the PID whenever one does.

Source

pub fn finish(self) -> Result<Finished, Error>

Finish each program’s tracks, then its catalog while it still lists them, and return the Finished programs.

The finished tracks stay servable while the Finished programs are held, so hand them and their broadcasts to a Linger to keep them up for late subscribers. Fails when the input ended before its PAT listed a program or any program declared a track. A finish that fails aborts every program with the cause, so it can’t be retried.

Source

pub fn abort(self, err: Error)

Abort every program’s catalog and media tracks with err. Consumes the importer.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more