Skip to content

fix(moq-mux): land the TS clock fix, Opus packet durations, and a legacy end test from #9192 - #9218

Merged
kixelated merged 5 commits into
mainfrom
quest/m2/time-addressing/branch-salvage
Nov 20, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m2/time-addressing/branch-salvage

Conversation

@kixelated

@kixelated kixelated commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • TS export keeps the clock on a retagged rendition's PID (from 1ca5b60cac). In revise(), 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's revision_test.rs harness 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_clock now also checks that every PCR in the output rides the audio PID, not only the PMT's PCR_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_catalog now reserves that PID for the waiting track alone, covered by a_catalog_update_before_the_replacement_lists_keeps_its_pid.
  • Old publisher's marker group reads as an end on lite-05/06 (from 095cdea03a). The test an_old_publishers_marker_group_reads_as_an_end passes on main as is. It guards behavior that group-end-whole must keep.
  • Opus import times each packet (from c4ad9643f3 and 7bb71b0710). decode() sets Frame.duration from 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:

  • Landed the Opus durations. The quest said to land them only if something still reads the duration once GROUP_END has no End. Something does: container::Producer::discontinuity places 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 test a_pause_ends_where_the_last_packet_does reads end 20000 on main and end 39999 with the change (the marker sits one timescale unit before the end, as discontinuity documents). group-end-whole keeps hang's markers as the only place a group's end lives, so this reader outlives it.
  • Changed the WHEP re-offer test, not moq-net. With durations, moq-webrtc tests::a_reoffer_from_the_same_address_plays failed every run. Root cause: every per-packet Opus group now ends whole. Track::drifted ages 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 than MAX_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's flowing!, inlined at its one caller). The other WHEP tests pass unchanged.
  • Left the rest of the branch behind, as the quest decided: read_breaks, the HLS whole_end reader, the webrtc ingest expectations, and the other end and loss tests all read GROUP_END's position.

Validation

  • just check passes 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.
  • Fails without each fix: with the harness change but without the revise() fix, the clock test fails with "the clock left its PID" (PMT pcr_pid 0x1001). Without the update_catalog reservation, the intervening-snapshot test fails with "the replacement left its PID". Without the Opus duration, the pause test reads end 20000.
  • Second, independent check of the WHEP change: two scratch tests, since deleted, isolated the cause. A local track subscriber still reads the old whole group. A late live subscriber through the origin gets nothing past the 100 ms budget with durations, and gets the newest packet without them. So the change in the test is the documented aging, not a lost packet.

Impact

Public API: none. Wire: none. Behavior: Opus frames from codec::opus::Import now 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 short Delay::max skips a paused Opus source's last packet once it has aged past the budget.

Caused by

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 review after 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-f9461e2244ef

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1f709-b88e-7a91-b4dd-02dead813b6a, round 2

  • Score: 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:

    • Fixed: medium, 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.

kixelated and others added 4 commits November 19, 2026 18:56
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>
@kixelated kixelated changed the title Land what stands alone from the closed declared-ends branch fix(moq-mux): land the TS clock fix, Opus packet durations, and a legacy end test from #9192 Nov 20, 2026
…'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>
@kixelated
kixelated marked this pull request as ready for review November 20, 2026 04:07
@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge pick (maintainer away, granted the coordinator merges it confidently recommends): ✅ /quest-merge at f03141a.

(Written by Claude Opus 5.5 with high)

@kixelated
kixelated enabled auto-merge November 20, 2026 04:08
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cfbccbd6-b6b1-4a54-aee1-897c9a80453e
Commits

Reviewing files that changed from the base of the PR and between b3de94d and f03141a.

Files selected for processing: 7

  • quest/m2/time-addressing/branch-salvage.md
  • quest/m2/time-addressing/group-end-whole.md
  • rs/moq-mux/src/codec/opus/import.rs
  • rs/moq-mux/src/container/ts/export.rs
  • rs/moq-mux/src/container/ts/revision_test.rs
  • rs/moq-mux/tests/legacy_audio.rs
  • rs/moq-webrtc/src/lib.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 a cataloged track sits there, not only a listed one. This closes the retire-before-list gap that moved the clock to 0x1001 for good.
  • The waiting replacement keeps its PID: update_catalog leaves a lone clock PID out of taken when a cataloged && !listed track holds it, and reserved keeps 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 into taken, so nothing stays reserved.
  • Opus packet durations: decode() sets Frame.duration from packet_samples at 48 kHz. That matches what fmp4::export::apply_codec_durations already 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::drifted aging 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.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 95979c7 Nov 20, 2026
7 checks passed
@kixelated
kixelated deleted the quest/m2/time-addressing/branch-salvage branch November 20, 2026 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant