Skip to content
Closed
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: 4 additions & 1 deletion doc/bin/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ narrow to absorb that one, is logged and counted in `overruns`: the legs can
differ there. So can reordered video whose SPS declares no reorder depth
(`max_num_reorder_frames`), which is logged, and SI while one leg holds an older
revision than the other or around an SI table the catalog adds or drops, which
each leg takes up when its catalog update arrives.
each leg takes up when its catalog update arrives. A track the catalog adds, or
one that ends, revises the PMT and the lanes at the same slot on every leg; a
change to the catalog's program descriptors or `muxRate` alone is logged and
ignored.

A stdout export ends with the broadcast. `export ts --linger 10s` waits that
long for the same publisher instance to come back, and carries on with the same
Expand Down
4 changes: 2 additions & 2 deletions quest/m1/ts-reliability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ refused means an error or a counted drop.
| CAT, EMM/ECM, ATSC PSIP, other SI PIDs, unlisted PIDs, TS scrambling | Outside the profile, raw lane; counted when the import reads every program. Today dropped uncounted | [routes](/quest/m1/ts-reliability/stream-routes.md) |
| DVB SI on 0x0010, 0x0011, 0x0012, 0x0014 | Preserved: snapshot track per PID and `table_id` | landed |
| Program identity, program and ES descriptors | Preserved: descriptors follow each PMT revision; an identity change refuses | landed |
| PMT add, remove, retype; PID reuse | Normalized without a new epoch: a changed or reused PID ends its track and continues under a fresh name, and the export rebuilds the PMT at the next `version_number`. Today `export ts --sync` ends at an added track and announces no other revision | [PMT export](/quest/m1/ts-reliability/pmt-export.md) |
| PMT add, remove, retype; PID reuse | Normalized without a new epoch: a changed or reused PID ends its track and continues under a fresh name, and the export rebuilds the PMT at the next `version_number`; `export ts --sync` at a slot and version every leg derives alike. Today `--sync` ignores a program descriptor or `muxRate` change alone | [PMT export](/quest/m1/ts-reliability/pmt-export.md) |
| PAT changes: moved PMT PID, programs added or removed | Normalized: followed; a removed program retires, and returns as a new epoch. Today ignored, or the whole multiplex stops | [PAT changes](/quest/m1/ts-reliability/pat-lifecycle.md) |
| Programs without video | Preserved when the PMT names a PCR PID; refused without one | landed |
| PCR | Normalized: rebased, carried on the first video PID, else audio, else a dedicated PCR-only PID | landed |
Expand Down Expand Up @@ -102,7 +102,7 @@ remain with their current quests.
- [State bound](/quest/m1/ts-reliability/state-bound.md) - SI and revision state retire with what the source stops repeating
- [Decode order](/quest/m1/ts-reliability/decode-order.md) - TS, MKV and FLV author DTS from decode order and a declared `reorder` depth
- [Shared parser](/quest/m1/ts-reliability/shared-parser.md) - `--program all` scans the multiplex once
- [PMT export](/quest/m1/ts-reliability/pmt-export.md) - synced TS legs revise their PMT and grid identically
- [PMT export](/quest/m1/ts-reliability/pmt-export.md) - synced TS legs agree on a program descriptor or `muxRate` change
- [Access units](/quest/m1/ts-reliability/pes-access-units.md) - a PES carrying several access units publishes each at its own time
- [PAT changes](/quest/m1/ts-reliability/pat-lifecycle.md) - a revised PAT never leaves a broadcast meaning another program
- [Stream routes](/quest/m1/ts-reliability/stream-routes.md) - every PID gets a declared route, and what is not carried is counted
Expand Down
72 changes: 29 additions & 43 deletions quest/m1/ts-reliability/pmt-export.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,38 @@
# [M] Synced TS legs revise their PMT identically
# [S] Synced TS legs agree on catalog-only revisions

## Goal

Two `moq export ts --sync` legs of a broadcast whose layout changes
mid-stream revise their PMT identically: the same `version_number`, in the
same slot, listing the same streams, wherever both legs hold the content
around it. A track added no longer ends a synced export.
Under `moq export ts --sync`, a catalog change no stream's media anchors
lands at the same slot on every leg, including one that joins after it, or
is refused loudly. That covers a `programDescriptors` change and a
`muxRate` change. Today each leg logs and ignores them, so a leg that opens
after the change lays different tables or a different grid than the legs
that saw it.

## Plan

Outside `--sync`, the export follows a PMT revision at the next
`version_number`: a stream joins the PMT with its first frame, and leaves
once the catalog has dropped it and nothing of it is left to go out. A track
recorded on the PID of a dropped stream waits for that stream to drain, and
cuts it if it never ends. Each revision is one boundary: versions go out in
order, no packet of a stream a revision adds goes ahead of it, and its PCR
PID and `muxRate` take over after its last packet. The PCR keeps its PID
unless its track retires.

What `--sync` does today:

- The tables are laid once, from the catalog the leg opened on. A track
added afterward fails the export ("… under --sync").
- A track that leaves the catalog keeps its PID and its lane, and an entry
or `programDescriptors` change is not announced.
- A `muxRate` change is warned and ignored: the leg keeps the rate its grid
was laid at.
- So legs that open on either side of a catalog change lay different PMTs
and grids, and a pair does not survive an added stream.

Decided 2026-10-22 by the maintainer: under `moq export ts --sync`, the
revision is a function of the catalog alone, so identical legs revise
their PMT identically. A revision is one transaction over everything the
catalog configures: a `muxRate` change applies with the tables at the same
boundary and, under `--sync`, rebuilds the grid there.

Open: where a revision lands. Each leg reads the catalog update at its own
moment, so the slot that carries the revised PMT, and its `version_number`,
must follow from something both legs read alike, such as an added track's
first unit on its lane or the end of a retired track's last group. A
revision that adds a track also needs a lane the rate can carry.

Rust: `rs/moq-mux` TS export (`with_sync`).

Tests: two synced legs, joined apart, across a PMT add, remove, retype,
descriptor change and `muxRate` change, write the same packets from the
revision on, PMTs included; a leg that joins after a revision lays the
revised PMT at the same `version_number`, and the revised grid.
A track added, a track that ends, and a PID another stream takes over
already revise the PMT and the lanes at the first table repetition two
slots past the jitter-buffer key of that stream's first or last unit, which
every leg reads alike. The revised `version_number` follows from what the
PMT lists, so a joiner announces it alike. The catalog carries no media
time, so nothing in it says where a catalog-only change would land.

Options, to settle with the maintainer:

- The TS importer records where the change took effect, as a media time
(and perhaps the source's PMT `version_number`) in the `mpegts` section.
Export lands it there. A wire change, so the MPEG-TS draft changes too.
- The change rides the next media-anchored revision, as one transaction. A
leg that opens in between differs until then.
- Keep ignoring it, and document that a leg must restart to take it up.

A `muxRate` change also needs lane positions that survive a rate change:
today every layout counts packets at one rate.

Also open: a track without a recorded PID takes the next free one in catalog
name order, so a track added under a name that sorts before the others gets
a different PID on a leg that joins later. TS sources record their PIDs.

## Related

Expand Down
11 changes: 11 additions & 0 deletions rs/moq-mux/benches/ts_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ mod export {
pub const PSI_INTERVAL: Duration = Duration::from_millis(500);
use std::time::Duration;
}
#[allow(dead_code)]
mod psi {
/// What a synced slot's tables say, which the schedule only carries.
#[derive(Clone, Debug)]
pub struct Pmt {
pub program_number: u16,
pub pcr_pid: Option<u16>,
pub program_info: Vec<()>,
pub streams: Vec<()>,
}
}
#[path = "../src/container/ts/lane.rs"]
#[allow(dead_code)]
mod lane;
Expand Down
Loading
Loading