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
impl Programs
Sourcepub fn new(origin: Producer, name: impl Into<Path>, config: Config) -> Self
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.
Sourcepub fn decode(&mut self, data: &[u8]) -> Result<(), Error>
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.
Sourcepub fn stats(&self) -> Snapshot
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.
Sourcepub fn finish(self) -> Result<Finished, Error>
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.