Repository navigation
feat(publish): encode while enabled, with an onDemand opt-in - #7143
Conversation
Quest-Claim: 1428d0d68e24e736
@moq/publish audio and video encoders now run whenever their rendition is enabled, with or without a subscriber, so their groups wait in the track's cache for a late SUBSCRIBE's maxDelay or a FETCH to reach. The broadcast hands each rendition its track while the track is open; `onDemand: true` on the broadcast restores the old gate for every rendition. - Losing demand no longer ends an epoch; disabling still does. - Video forces a keyframe on join only when demand wants a group past every one written, so a join served by a group cached before any subscriber arrived forces none. - Bandwidth reservations stay keyed on demand: an unwatched rendition claims nothing and encodes at its configured bitrate. Finishes quest/m1/eager-encode/js.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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 2 minutes. 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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fcf3157763
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: fcf3157.
Confirmed the existing P1 decoder-identity finding, rather than duplicating it inline: broadcast.ts:468–471 now exposes tracks before announce, but :250–256 locks/replaces identity only after #served is initialized at :398. With announce:false, a codec/config change can therefore leave cached media under the new catalog's incompatible decoder identity. Lock identity when eager media can first be written and add a pre-announcement codec-change/late-replay regression test.
Otherwise the direction is coherent: one broadcast-level onDemand switch is simpler than separate encoder gates, and demand-scoped reservations avoid charging idle eager renditions against the live bandwidth budget. The cached-group-aware keyframe condition preserves refresh requests without forcing every join to cut.
Verification: static review of changed production code/tests and surrounding catalog identity, encoder lifecycle, track demand, and signal cleanup semantics. No browser, codec, or test execution.
# Conflicts: # quest/m1/push-to-talk/reenable.md
An eager encoder caches groups on its track before the first announce, so fixing a name's identity only at announce let a pre-announce codec change reuse the name, and a late subscriber or fetch read the old codec's groups under the new catalog config. Lock identities when the network broadcast starts instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 0e34efc
The previously confirmed P1 decoder-identity finding is addressed: js/publish/src/broadcast.ts now seeds the identity map when the network broadcast starts, before eager tracks are handed over. Pre-announcement identity changes therefore use the existing replacement-track path instead of relabeling cached groups. The updated regression checks that a bitrate-only change keeps the track, a codec change closes it, and the catalog names a fresh track with sequence zero.
No new actionable bugs found in this update. Moving the identity boundary is the right focused fix and reuses existing lifecycle logic rather than adding a separate eager-mode mechanism.
Verification: base-aware comparison against the prior reviewed head, static inspection of the fix, catalog folding, track replacement, and changed test. No tests, browser playback, codec execution, or late-fetch integration run.
(Written by review (OpenAI))
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge summary
(Written by Claude Opus 5.5) |
Finishes quest/m1/eager-encode/js.md, part of the always-on encoding epic from moq-dev/moq#7101.
Summary
@moq/publishaudio and video encoders now run whenever their rendition is enabled, with or without a subscriber. Their groups sit in the track's cache, where a late SUBSCRIBE can reach them within itsmaxDelay, or a FETCH withinmaxAge. A newonDemandoption onPublish.Broadcastbrings back the old demand gate for every rendition.js/publish/src/broadcast.ts): the broadcast hands each rendition its track whenever the track is open. WithonDemand, it also waits for a subscriber, as before. A closed track now clearsrendition.trackthroughserved.closed; before, that happened through demand.#cut()and the video teardown discontinuity both follow the track, which now stays put. Disabling still ends one. WithonDemand, the last subscriber leaving still ends one.wanted > max(answered, track.largest())). The old check (answered === undefined || wanted > answered) would have forced a keyframe on the first join to a track whose groups were all encoded before anyone subscribed, even when the cached group already served it. A join past the refresh ratio still gets a fresh keyframe.watched()computed ininternal.tsthat changes only when demand appears or goes away. So an unwatched rendition claims nothing and encodes at its configured bitrate, as the epic decided.video/1) instead of leaving the old codec's groups under the new catalog config. This replaces the "identity changes before the first announce keep the catalog ID" behavior from moq-dev/moq#5552. That test is now a regression test that writes a group before announcing.doc/lib/js/publish.md(the Encoding section and the example comment) andjs/publish/README.mddescribe both modes. Code comments no longer call it a "demand gate".js.mdand its links. (The line-reference updates topush-to-talk/reenable.mdwere dropped: moq-dev/moq#7163 finished and deleted that quest.)Public API: the default behavior changes, and
BroadcastInput.onDemand: Getter<boolean>is new (API report updated). Wire: none.Tests
maxDelayreads groups 0 and 1 from before it arrived, with no forced keyframe. WithonDemand, nothing is encoded until it subscribes, and its arrival opens group 0.onDemand.onDemand, it is handed over only while subscribed, and the broadcast keeps the same open track across the gap.activethat is now already true, a replacement track handed over at once, and a recovered encoder active on its fresh track. The two encoder-level "demand gap" tests are renamed "on-demand gap".Local:
sh/js/workspace.py checkandteston the changed packages and their dependents (publish, room, doc, browser harnesses) pass. So do biome, tsc, the API report check and remark on the docs.Choices made without asking
onDemandis a reactiveGetter<boolean>, like the broadcast's other inputs, so it can be toggled at runtime.<moq-publish>gets noon-demandattribute. The quest scopes the option to the broadcast, and push-to-talk/mute is editingelement.tsin parallel. As a result, element users get always-on with no way to opt out.broadcast.text()) follow the same gate, so a caption writer gets its track without a subscriber too, unlessonDemandis set.@moq/publishrelease should be a minor bump, because the default behavior changes.Suggested follow-ups
on-demandattribute on<moq-publish>, if element users need the opt-in. Worth doing after the mute quest lands.@moq/roompublishes throughPublish.Broadcast, so a joined room now encodes the camera and microphone while nobody watches. That is intended by the epic, but the room docs may want to say so. That falls under the epic's own docs work.🤖 Generated with Claude Code
(Written by Claude Opus 5.5)