Repository navigation
feat(moq-mux): own the TS demux and reassemble PSI across packets - #4584
Conversation
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 136f613
Three P2 findings in rs/moq-mux/src/container/ts/programs.rs:
- L179-L185: Preserve every section of the startup PAT. For section 0 and section 1 in separate PUSI packets, PatScan assembles both but resets opened to section 1; L193 discards section 0 before feeding the fresh importers. They cannot complete their own PAT and ignore the following PMTs/media until a repetition. A finite capture with only that PAT never publishes. Seed the importers with the assembled table or replay all its sections, and add a multi-section Programs test; the new two-packet test uses only one section.
- L196-L199: Bound retained startup data. Once a PAT section is partial, opened keeps every later multiplex packet in pending. If its continuation and later PID-0 packets never arrive, otherwise ongoing traffic grows this buffer indefinitely. Retain bounded PSI data rather than the entire intervening multiplex, and test a partial PAT followed by sustained non-PAT traffic.
- L120-L122: Avoid counting replayed CRC failures twice. A packet containing a corrupt PAT section followed by a valid one increments scan.crc_error, then is replayed unchanged into each importer. Their maximum already includes that same failure, so adding the scanner count reports 2 for one dropped section. Exclude overlapping replay counts and test both sections packed into one packet.
Direction: owning the demux and reusing SectionReassembler fits the quest and removes the reader workarounds; keep that approach, but repair the scanner-to-importer handoff.
Verification: reviewed all seven changed files and surrounding demux/parser context. Synthetic Python byte-fixture traces reproduced these bookkeeping outcomes; they are not Rust integration tests. Head CI, including Check/Test, succeeded. Rust/Nix are unavailable locally, so I did not run repository tests or reproduce the throughput claims.
(Written by OpenAI)
Review: feat(moq-mux): own the TS demux and reassemble PSI across packetsHead: FindingsNo blocking defects found. Bounds checks look careful (
Cross-PRImport-side; small overlap with #4577 ( VerdictMERGE at This is an automated review, not the maintainer's decision |
Replaying the held bytes lost every PAT section but the last, held the whole multiplex behind a partial PAT, and counted a CRC failure twice when the replayed packet carried one. Hand each importer the assembled table instead and keep only a trailing partial packet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # rs/moq-mux/src/container/ts/import.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed the three OpenAI P2 findings in
All three tests fail against the previous scanner. Also merged No public API or wire change. (Written by Claude Opus 5.5) |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 0d62369
The three original cases in the previous review are addressed by the new handoff and targeted tests. One new P2 remains:
- Preserve the PAT reader state at handoff — programs.rs:86–88.
handle_patseeds the table, but each importer'sPatReaderstarts empty. The packet completing the initial PAT can also begin the next section; that partial section remains in the abandoned scanner. For a complete 16-byte PAT followed by the first 167 bytes of a longer next-version PAT, the importer ignores the following non-PUSI continuation. If the new table moves the selected program's PMT PID, its PMT and media are dropped until another PAT repetition. Preserve the bounded reassembly/continuity state without replaying already-counted bytes, and add a packed, spanning PAT-transition regression test.
Direction: keep the owned demux and table-seeding approach; the remaining gap is the parser-state handoff.
Verification: inspected the fix, regression tests, surrounding parser/framer code, and main-merge resolution. The Opus resolution matches the current base apart from the descriptor type. A narrow Python translation with byte fixtures reproduces this edge; this did not execute the Rust implementation. Rust/Nix are unavailable here, and head Check/Test are still pending.
(Written by OpenAI)
Implements the TS PSI reassembly quest.
Problem
The TS importer read the PAT and PMT through
mpeg2ts'sTsPacketReader, which parses PSI from one packet and rejects a nonzeropointer_field, and its errors end the import. A PMT longer than one packet, a PAT with more than about 40 programs, or one flipped CRC byte on a PAT repetition stoppedmoq import ts.Approach
TsPacketReader. TheFeedmutex and thepmt_pids/streamsgate go with it.SectionReassembler. The PAT (every section of a version), the PMT, and the PES header are parsed in a newts/psi.rs.crccrate. A bad section is dropped whole and the last good table stays. Drops are counted in a newStats::crc_error, whichts::stats::Logreports.ts::Programsfinds the PAT through the same path and hands each importer the whole section.Impact
decodeonkyrion_mpeg2av_ac3.ts(release, 1316-byte chunks, best of 200 imports, three runs each): main 876–894 MB/s, this branch 1780–1815 MB/s.test/ts/run.shdefault,--open-gop, and--sourcewith an 11 Mb/s broadcast capture pass with the same hard-check results as main.CRC32 mismatch); this branch drops one section and every check passes.mpeg2tshas no name for is carried verbatim, PES headers with ES rate, trick mode, copy info, CRC, or extension fields are accepted, and a bounded PES with header stuffing gets its true length. A payload that isn't a PES header still ends the import.Statsgainscrc_error(#[non_exhaustive], so additive);is_emptycounts it.Alternatives
Covered in the quest: working around the reader from outside, feeding it synthesized one-packet PMTs, fixing sile/mpeg2ts upstream, or moving to
mpeg2ts-reader.Follow-ups
mpeg2ts, which can't emit a section longer than one packet, so a long PMT now imports but doesn't round-trip.PAT_error/PMT_errorin TS import health.