Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/bin/ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ A broadcast holds one program. A multi-program stream is refused until
broadcast (`event.hang` becomes `event/1.hang`, `event/2.hang`), following the
PAT: a program it adds publishes, one it drops ends, and one that returns
publishes as a new [instance](/concept/moq-lite#publisher-instances). A listed
program whose PMT does not arrive within 0.5 s of program clock ends the import.
program whose PMT does not arrive within 0.5 s of program clock counts as
`PMT_error_2` in the feed health while the others publish, and starts once its
PMT arrives.

A PMT that adds, removes, or retypes a stream, or reuses a PID, ends the old
track and continues under a fresh name; the export announces each layout at its
Expand Down
25 changes: 0 additions & 25 deletions quest/m1/ts-late-pmt.md

This file was deleted.

39 changes: 35 additions & 4 deletions rs/moq-mux/src/container/ts/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ impl Errors {
}
}

/// Count `count` more `PMT_error_2` intervals on `pid`.
pub(super) fn pmt_error(&mut self, pid: u16, count: u64) {
self.pid(pid).pmt_error += count;
}

fn pid(&mut self, pid: u16) -> &mut PidErrors {
self.pids.entry(pid).or_default()
}
Expand Down Expand Up @@ -346,10 +351,10 @@ impl Health {
}
}
} else if let Some(timer) = self.pmt.get_mut(&pid) {
if scrambled {
self.errors.pid(pid).pmt_error += 1;
} else if section_start(pkt) == Some(PMT_TABLE_ID) {
timer.reset(now);
match PmtPacket::of(pkt, continuation) {
PmtPacket::Scrambled => self.errors.pid(pid).pmt_error += 1,
PmtPacket::Section => timer.reset(now),
PmtPacket::Other => {}
}
}
if self.pcr_pid == Some(pid) && self.pcr(pid, pkt, at.count) {
Expand Down Expand Up @@ -665,6 +670,32 @@ impl Delta {
}
}

/// What a packet on a PMT PID means for its `PMT_error_2` timer.
#[derive(Clone, Copy, PartialEq, Eq)]
pub(super) enum PmtPacket {
/// It starts a PMT section, whatever its CRC, so the timer restarts.
Section,
/// It is scrambled, itself a `PMT_error_2`.
Scrambled,
/// Neither, as one continuing a section, or one the [`Multiplex`] graded corrupt or a
/// duplicate.
Other,
}

impl PmtPacket {
pub(super) fn of(pkt: &[u8; TsPacket::SIZE], continuation: Continuation) -> Self {
if matches!(continuation, Continuation::Corrupt | Continuation::Duplicate) {
Self::Other
} else if pkt[3] & 0xc0 != 0 {
Self::Scrambled
} else if section_start(pkt) == Some(PMT_TABLE_ID) {
Self::Section
} else {
Self::Other
}
}
}

/// The table_id of the first section a PSI packet starts, if it starts one.
fn section_start(pkt: &[u8; TsPacket::SIZE]) -> Option<u8> {
if pkt[1] & 0x40 == 0 {
Expand Down
Loading