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
5 changes: 3 additions & 2 deletions doc/bin/srt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ description: SRT contribution and playback
source (`--connect`); `moq export srt` serves SRT to players or pushes to a
remote. The payload is MPEG-TS, so the same codecs and behavior as
[`import ts`](/bin/ts) apply: H.264/H.265 video and AAC, MP2, AC-3, E-AC-3, or
Opus audio. A damaged unit is dropped and the session stays up; video resumes at its
next keyframe, freezing for up to one GOP.
Opus audio. A lost or flagged-corrupt packet drops only its unit and the session
stays up; video freezes until the next keyframe that arrives intact. A unit
that arrives whole but does not decode ends the session with the cause.

```bash
# Accept a contribution feed and publish it
Expand Down
11 changes: 7 additions & 4 deletions doc/bin/ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,11 @@ what the network drops, so random packet loss alone loses no content.
the output decodes, or meets the T-STD, across the gap.

Damage in the source is the importer's concern, not MoQ's. In semantic mode a
damaged packet is dropped on its own PID, so video freezes until its next
keyframe while the other tracks carry on, and feed health (stalled streams,
TR 101 290 counters) is logged and reported without changing what publishes.
lost packet, or one the receiver flagged with the transport error indicator, is
dropped on its own PID, so video freezes until its next keyframe while the
other tracks carry on, and feed health (stalled streams, TR 101 290 counters)
is logged and reported without changing what publishes. A media unit that
arrives whole but does not decode ends the import with the cause.
Passthrough carries damaged packets as they came.

## Evidence
Expand Down Expand Up @@ -258,7 +260,8 @@ details each grader and its negative controls.
| Semantic: a congested and an overflowing path shed whole groups, stay T-STD compliant, keep their latency | `just test ts --headroom --rate 7000000`, with `--queue 250ms` | Nightly only |
| Passthrough: a missing group leaves its time out and counts one gap; a cut group loses only its tail; a late run is dropped alone | [`release_test.rs`](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/src/container/ts/release_test.rs) `a_group_never_delivered_leaves_its_time_out`, `a_group_cut_short_loses_only_its_tail`, `an_object_past_its_deadline_is_a_gap_in_that_release_only` | PR |
| Passthrough: an overflowing path keeps surviving packets in place through the source's last | `just test ts --passthrough --rate 7000000 --queue 250ms` | Nightly only |
| Source damage drops only the damaged PID's unit | [`import.rs`](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/src/container/ts/import.rs) `damaged_h264_nal_recovers`, `video_drops_a_partial_access_unit_across_a_continuity_break` | PR |
| Source damage drops only the damaged PID's unit | [`import.rs`](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/src/container/ts/import.rs) `damaged_tei_recovers`, `video_drops_a_partial_access_unit_across_a_continuity_break` | PR |
| A whole unit that does not decode ends the import | [`import.rs`](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/src/container/ts/import.rs) `undecodable_nal_ends_the_import`, `malformed_opus_pes_ends_the_import_unpublished` | PR |

### Not claimed

Expand Down
40 changes: 40 additions & 0 deletions quest/m1/ts-packet-abort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# [S] A TS import ends on a packet header it cannot parse

## Goal

moq-mux's TS import ends with the cause on a TS adaptation field or PES header
that arrives intact but does not parse, instead of counting it as `damaged`
and resuming at the next PES. Loss (a continuity break) and packets the
receiver flagged with the transport error indicator keep today's handling:
both are understood source behavior, detected where they happen.

## Plan

Found by [moq-dev/moq#9170](https://github.com/moq-dev/moq/pull/9170), which
made an undecodable media unit end the import and left these packet-level
paths alone because its quest's Goal named only `Fault` and `unit_error`.
The same rule applies (maintainer, 2026-11-18): "We should not try to support
random bit flips that we don't understand and limp along with broken
functionality." Over UDP and SRT a packet arrives whole or not at all, and RF
corruption sets the transport error indicator, so a malformed header with
neither is a muxer bug or an unexplained flip.

In `rs/moq-mux/src/container/ts/import.rs`, `Import::damage` is reached for
`malformed TS adaptation field` (`route` and `pes_packet`), a `PesStart`
parse or length failure (`pes_packet`, `pes_header`), and `scrambled PES is
not supported` (`handle_pes_start`). Recommended: the first two end the
import; truncation by loss, a header cut short at a PMT revision or end of
input, and the transport error indicator stay as damage. Scrambled PES is a
known source (conditional access) and likely belongs with `refuse` rather
than `damage`; decide it here with a test that names the source.

Tests: `damaged_video_recovers`' `pes`, `adaptation`, and `adaptation-clock`
cases, `invalid_adaptation_lengths_damage_media_and_dedicated_clock_pids`,
`damaged_adaptation_on_a_dedicated_pcr_pid_keeps_the_clock`,
`damaged_pes_start_flushes_the_unit_before_it`, and
`malformed_pes_prefix_is_refused_without_waiting_for_more_bytes` become
"ends with the cause". `doc/bin/ts.md` and `doc/bin/srt.md` already say a
whole unit that does not decode ends the import; extend them to headers.

Public API: none. Behavior: a TS ingest with a malformed packet header ends
instead of continuing. Wire: none.
10 changes: 3 additions & 7 deletions quest/m1/ts-step-damage.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Superseded 2026-11-18 (maintainer, /quest-plan of the enum-return audit):
flips that we don't understand and limp along with broken functionality."
This replaces the 2026-11-17 design above that drops and counts a lone
stream's stray packets as damage (rejected now: tolerating an unexplained
step). [TS unit abort](/quest/m1/ts-unit-abort.md) removes the import's
damage tolerance; this quest adds back only a step with a known source, as an
explicit case. If no real source turns up, delete this quest and record why.
step). [moq-dev/moq#9170](https://github.com/moq-dev/moq/pull/9170) removed
the import's unit damage tolerance; this quest adds back only a step with a
known source, as an explicit case. If no real source turns up, delete this quest and record why.

Tests: a capture or generator reproducing the step's real source, and the
import's behavior on it; for unexplained corruption, the import ends with the
Expand All @@ -56,10 +56,6 @@ Caused by, for the fix PR's `## Caused by`:
- [moq-dev/moq#7898](https://github.com/moq-dev/moq/pull/7898) - made a lone stream's rewind fatal to the import
- [moq-dev/moq#5967](https://github.com/moq-dev/moq/pull/5967) - PCR unwrap that can go negative on a data-only program

## Required

- [TS unit abort](/quest/m1/ts-unit-abort.md) - removes the import's damage tolerance, so a known step is added back as an explicit case

## Related

- [moq-dev/moq#9035](https://github.com/moq-dev/moq/pull/9035) - plans `quest/m2/ts-passthrough-splice.md`, which handles a whole-source PCR step on the passthrough lane; this quest is the lone-stream step on the import
35 changes: 0 additions & 35 deletions quest/m1/ts-unit-abort.md

This file was deleted.

1 change: 0 additions & 1 deletion quest/m3/error-matches.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Sites, with recommendations (re-grep each on the head):
Not here: moq-lite's control streams
([control-stream-recv](/quest/m3/control-stream-recv.md)), the moq-json
stream producer and moqsink ([error-outcomes-rest](/quest/m3/error-outcomes-rest.md)),
the TS import's `unit_error` ([TS unit abort](/quest/m1/ts-unit-abort.md)),
moq-quic's stream errors (reshaped in
[moq-dev/moq#9152](https://github.com/moq-dev/moq/pull/9152)), `Duplicate` ([small-public](/quest/m2/outcome-enums/small-public.md)), and
moq-e2ee ([e2ee-format](/quest/m3/e2ee-format.md)).
Expand Down
5 changes: 5 additions & 0 deletions rs/moq-mux/src/codec/aac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ fn read_general_audio<T: Buf>(reader: &mut BitReader<T>, core: u8) -> Result<boo
Ok(reader.read(1, Error::IncompleteConfig)? == 1)
}

/// Whether the raw data block `block` leads with a program config element.
pub(crate) fn leads_with_program_config(block: &[u8]) -> bool {
block.first().is_some_and(|&byte| u32::from(byte >> 5) == ID_PCE)
}

/// Build the AudioSpecificConfig for a stream that signals its fields per frame, as ADTS does.
///
/// A `channel_config` of 0 means a program config element leads `block`, the stream's first raw
Expand Down
9 changes: 1 addition & 8 deletions rs/moq-mux/src/codec/h264/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,14 @@ impl Split {
self.pending.clear();
}

/// The retained parameter sets, for [`restore`](Self::restore) to put back.
/// The retained parameter sets, which bootstrap a reset picture clock.
pub(crate) fn params(&self) -> Params {
Params {
sps: self.sps.clone(),
pps: self.pps.clone(),
}
}

/// Put back parameter sets a refused access unit replaced, so a later bare keyframe
/// re-injects the last good ones rather than the refused unit's.
pub(crate) fn restore(&mut self, params: Params) {
self.sps = params.sps;
self.pps = params.pps;
}

fn pts(&mut self, hint: Option<moq_net::Timestamp>) -> Result<moq_net::Timestamp> {
if let Some(pts) = hint {
return Ok(pts);
Expand Down
10 changes: 1 addition & 9 deletions rs/moq-mux/src/codec/h265/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl Split {
self.pending.clear();
}

/// The retained parameter sets, for [`restore`](Self::restore) to put back.
/// The retained parameter sets, which bootstrap a reset picture clock.
pub(crate) fn params(&self) -> Params {
Params {
vps: self.vps.clone(),
Expand All @@ -285,14 +285,6 @@ impl Split {
}
}

/// Put back parameter sets a refused access unit replaced, so a later bare keyframe
/// re-injects the last good ones rather than the refused unit's.
pub(crate) fn restore(&mut self, params: Params) {
self.vps = params.vps;
self.sps = params.sps;
self.pps = params.pps;
}

fn pts(&mut self, hint: Option<moq_net::Timestamp>) -> Result<moq_net::Timestamp> {
if let Some(pts) = hint {
return Ok(pts);
Expand Down
Loading