Repository navigation
fix(moq-mux): land the TS clock fix, Opus packet durations, and a legacy end test from #9192 - #9218
Conversation
Quest-Claim: 6ebcc17f775b3af1
A rendition the source reopens (a language retag) can retire before the one replacing it on the same PID lists with its first frame. The export moved the clock to its own PID in that gap; it now keeps the clock while a cataloged track holds the PID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…roup as an end Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pause's marker now lands where the last packet's audio stops rather than where that packet starts, which cut the last 20 ms short. Each packet's group also ends whole there, so a paused source's last group ages out of a live subscription's delay budget; the WHEP re-offer test now keeps its source live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s PID While a retag's replacement waits to list, the clock keeps its PID with no stream on it, which read as the clock's own PID and pushed the replacement elsewhere on the next snapshot. That PID is now reserved for the track holding it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merge pick (maintainer away, granted the coordinator merges it confidently recommends): ✅ /quest-merge at f03141a. (Written by Claude Opus 5.5 with high) |
|
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 53 seconds. View limit details
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. |
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. Each salvaged piece fixes its cause where the state lives: revise() and update_catalog agree on who may hold the clock's PID, and the Opus import states the packet's duration once at the source.
Reviewed changes
All 7 files at f03141a, checked against the surrounding ts/export.rs clock and PID code, the fMP4 export's duration inference, and the WHEP tests.
- TS clock survives a retag:
revise()keeps the clock on a PID when acatalogedtrack sits there, not only alistedone. This closes the retire-before-list gap that moved the clock to 0x1001 for good. - The waiting replacement keeps its PID:
update_catalogleaves a lone clock PID out oftakenwhen acataloged && !listedtrack holds it, andreservedkeeps every other joining track off it in both passes. When the replacement's recorded PID changes, the holder lookup finds nothing on the next snapshot and the PID goes back intotaken, so nothing stays reserved. - Opus packet durations:
decode()setsFrame.durationfrompacket_samplesat 48 kHz. That matches whatfmp4::export::apply_codec_durationsalready infers, so fMP4 output is unchanged. A pause's marker now lands at the packet's end, not its start. - WHEP re-offer test: the source keeps sending every 20 ms until the new session plays. This matches the documented
Track::driftedaging of a whole group with no successor, which the PR body explains. - Tests: the back-to-back AAC harness exposes the race, the clock is now checked on every PCR packet, there is a new intervening-snapshot regression test, a lite-05/06 marker-group guard and an Opus pause-end test.
claude-opus-5-5 | 𝕏

Finishes quest/m2/time-addressing/branch-salvage.md: lands the parts of closed moq-dev/moq#9192's branch (
quest/m2/time-addressing/consumers, left in place) that don't depend on reading GROUP_END's position. Each one has a test that fails on main without it.Summary
1ca5b60cac). Inrevise(), the clock now stays on its PID when a track the catalog lists holds that PID (cataloged), not only one the PMT lists (listed). Before, when a language retag reopened a rendition, the old rendition could retire before the new one listed with its first frame. In that gap the export moved the clock to a PID of its own (0x1001) and kept it there. The branch'srevision_test.rsharness change (AAC frames back to back across each 40 ms interval) is ported too: that change alone makes main lose the race.a_descriptor_change_revises_the_entry_and_keeps_the_clocknow also checks that every PCR in the output rides the audio PID, not only the PMT'sPCR_PID. Review found a gap this opened: with the clock kept on an empty PID, a catalog snapshot before the replacement's first frame read that PID as the clock's own and moved the replacement off it.update_catalognow reserves that PID for the waiting track alone, covered bya_catalog_update_before_the_replacement_lists_keeps_its_pid.095cdea03a). The testan_old_publishers_marker_group_reads_as_an_endpasses on main as is. It guards behavior that group-end-whole must keep.c4ad9643f3and7bb71b0710).decode()setsFrame.durationfrom the packet's TOC byte (packet_samples).Decisions
The maintainer was away, so I took my recommendation on each of these. A later review can undo any of them:
container::Producer::discontinuityplaces hang's pause marker at the furthest point written, which counts the last frame's duration. Without durations, an Opus pause read as ending at its last packet's start, which cut off that packet's 20 ms. The new testa_pause_ends_where_the_last_packet_doesreadsend 20000on main andend 39999with the change (the marker sits one timescale unit before the end, asdiscontinuitydocuments). group-end-whole keeps hang's markers as the only place a group's end lives, so this reader outlives it.moq-webrtc tests::a_reoffer_from_the_same_address_playsfailed every run. Root cause: every per-packet Opus group now ends whole.Track::driftedages a whole group with no successor from its arrival plus its span (documented: "so the last group of a paused or finished track ages out"). The test pushed one packet before the re-offered session's egress subscribed. That session joined more thanMAX_DELAY(100 ms) after the packet's group ended, so it was right to skip it. I reproduced this outside WebRTC: a second live subscriber through the origin, 200 ms after two whole groups, got nothing with durations and the newest packet without them. The test now keeps the source sending every 20 ms until the new session plays, as a live source does (the branch'sflowing!, inlined at its one caller). The other WHEP tests pass unchanged.read_breaks, the HLSwhole_endreader, the webrtc ingest expectations, and the other end and loss tests all read GROUP_END's position.Validation
just checkpasses on the head (4936 tests).just test -p moq-mux -p moq-webrtc -p moq-hls: 2519 passed.just test -p moq-audio -p moq-ffi -p moq-gst -p moq-cli -p moq-rtmp(other users of the Opus import): 1333 passed.revise()fix, the clock test fails with "the clock left its PID" (PMTpcr_pid0x1001). Without theupdate_catalogreservation, the intervening-snapshot test fails with "the replacement left its PID". Without the Opus duration, the pause test readsend 20000.Impact
Public API: none. Wire: none. Behavior: Opus frames from
codec::opus::Importnow carry a duration. A pause marker after Opus lands at the true end. Each per-packet group ends whole at the packet's end, so a live subscriber with a shortDelay::maxskips a paused Opus source's last packet once it has aged past the budget.Caused by
revise()kept the clock only for a track the PMT lists, so a retag's gap between retire and list moved it (found by check, the harness change on feat!: media readers take declared ends from the group, and hang writes no markers #9192).Follow-ups
None.
Models
Size: S
Implementer: Claude Code, claude-opus-5-5, medium effort
🤖 Generated with Claude Code
(Written by Claude Opus 5.5 with medium)
Review
Rewritten by
quest reviewafter each round.Head: f03141a
Base: origin/main at 4d9190a
Risk: medium,
Opus pause timing and MPEG-TS PID/clock allocation changes could disrupt playback for media consumers, but preserve existing APIs and formats and are fully undone by a revert.Classified: medium by Codex, gpt-6.1-sol, low effort, session
01a1f722-8358-7b02-879f-f9461e2244efReviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1f709-b88e-7a91-b4dd-02dead813b6a, round 2Score: 10/10,
The follow-up fixes the PID ownership race and adds a regression test covering the intervening catalog update; code inspection found no new issues.Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none
The last round's findings, at 38b5213:
rs/moq-mux/src/container/ts/export.rs:3414:Preserve the replacement's PID across subsequent catalog updates;update_catalog preserves the pending replacement's clock PID while excluding other joining tracks in both allocation passes, and the added regression test covers an intervening catalog snapshot before the replacement lists.