Skip to content

feat(moq-audio): capture and encode while enabled, with an on-demand opt-in - #7159

Merged
kixelated merged 5 commits into
mainfrom
quest/m1/eager-encode/audio
Oct 29, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m1/eager-encode/audio

Conversation

@kixelated

@kixelated kixelated commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Finishes quest/m1/eager-encode/audio.md, part of the always-on encoding epic (moq-dev/moq#7101).

moq-audio's capture publication now keeps an enabled microphone open and encodes whether or not anyone is subscribed, so a late subscriber can FETCH the recent past or reach it with maxDelay. The new Capture::on_demand option brings back the old behavior: the device opens only while the track has a subscriber and closes when the last one leaves.

  • encode::Capture gets pub on_demand: bool (default false). The struct is #[non_exhaustive], so adding the field doesn't break anything.
  • The supervisor's demand now goes through a Wanted wrapper. When on_demand is off, the track counts as wanted until it ends. Status::Waiting is only reported in on-demand mode.
  • The bandwidth reservation still follows subscriber demand, as the epic decided.
  • Docs updated: lib.rs, capture.rs, aec.rs, the Control::new / publish_capture / Status::Waiting doc comments, and doc/lib/rs/moq-audio.md.
  • Quest: removed the finished quest and its links. cli.md now names the audio option it should select.

Public API: the default behavior changes, and one option is added. Wire: no change.

Tests

  • New captures_without_a_subscriber: with no subscriber, the publication goes Live and publishes a group (seen through Consumer::largest, which doesn't register demand). A subscriber that arrives later reads that frame at its capture time.
  • New on_demand_waits_for_a_subscriber: with the opt-in, the device is never opened while nobody listens, and it opens when a subscriber arrives.
  • a_restart_after_idle_keeps_the_gap and hls_records_keep_the_live_timestamps exercise idle restarts, so they now use the opt-in.
  • just check origin/main passes (1544 tests). cargo test -p moq-audio --all-features --lib encode::capture passes (36), and so does cargo clippy -p moq-audio --all-features --all-targets -D warnings.

Choices made without asking

  • Option shape: a plain on_demand: bool on Capture, named to match the planned moq publish --on-demand flag. The parallel moq-video quest should use the same name on its capture config.
  • No Waiting flash: in always-on mode the supervisor skips announcing Waiting, so a Control::changed watcher sees Starting → Live and never a brief "waiting for a subscriber".
  • moq-cli default flips now: moq publish microphone capture goes always-on as soon as this merges. The --on-demand flag comes later in quest/m1/eager-encode/cli.md. This follows the epic's "the default follows the libraries".
  • No CHANGELOG edit: release-plz generates the Rust changelogs.

Follow-ups

None new. The remaining epic children (video, js, cli, raw-audio) and the epic's own doc sweep are already planned.

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

kixelated and others added 4 commits October 28, 2026 15:42
…opt-in

An enabled microphone now captures and encodes whether or not anyone
listens, so the recent past exists for a late subscriber to fetch.
`Capture::on_demand` restores opening the device only while the track
has a subscriber.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title moq-audio captures and encodes while enabled feat(moq-audio): capture and encode while enabled, with an on-demand opt-in Oct 28, 2026
@kixelated
kixelated marked this pull request as ready for review October 28, 2026 23:04
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
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: 10bcabac-545e-4b03-9e3e-43d3ec9308ee
Commits

Reviewing files that changed from the base of the PR and between c45748f and 52e7176.

Files selected for processing: 9
  • doc/lib/rs/moq-audio.md
  • quest/m1/eager-encode/README.md
  • quest/m1/eager-encode/audio.md
  • quest/m1/eager-encode/cli.md
  • quest/m1/eager-encode/raw-audio.md
  • rs/moq-audio/src/aec.rs
  • rs/moq-audio/src/capture.rs
  • rs/moq-audio/src/encode/capture.rs
  • rs/moq-audio/src/lib.rs
Files with no reviewable changes: 3
  • quest/m1/eager-encode/README.md
  • quest/m1/eager-encode/audio.md
  • quest/m1/eager-encode/raw-audio.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Walkthrough

Audio capture now runs without subscribers by default. The new Capture::on_demand option limits input capture to periods when subscribers are present. Demand handling and supervisor behavior support both modes. Tests cover capture before subscribers arrive, on-demand startup, idle restart, and HLS records across restarts. Documentation and quest references now describe the option and the default behavior.

Priority: Normal

Merge Risk: Minimal · up to 52e71

Enabled microphones remain open by default; on-demand mode restores subscriber-gated capture. No merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: always-on capture and encoding with an on-demand opt-in for moq-audio.
Description check Passed The description directly explains the always-on default, the Capture::on_demand option, documentation updates, quest completion, and tests.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 4 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T23:05:21.290446Z 918d147 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 918d14757c

ℹ️ 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".

Comment thread rs/moq-audio/src/encode/capture.rs Resolved

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)
Reviewed commit: 918d147

No actionable runtime bugs found. The small Wanted adapter is an appropriate way to change the capture default while preserving the existing stop/replace, retry and cancellation paths. Always-on capture still exits on track closure, and bandwidth reservation remains tied to actual demand. The late-subscriber test checks capture without creating subscriber demand first.

The existing test-clock comment already covers the real-time 50 ms wait; no duplicate inline comment added. This is test determinism/efficiency feedback, not evidence of a production capture failure.

Verification: static review of the changes and surrounding supervisor/control/track-closure paths. I did not run tests or exercise microphone hardware, permissions, AEC, or cross-platform capture.

…test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)
Reviewed commit: 52e7176

Reviewed the delta from 918d147. The previously referenced real-time-sleep concern is addressed: the on-demand test now synchronizes on Waiting and checks the input-open count without an arbitrary 50 ms delay. This is the simpler approach for a demand transition rather than elapsed-time behavior; the subscription/open assertions remain.

No new actionable bugs found. Production capture behavior is unchanged. Static review only; I did not execute the test.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary:

  • Head 52e7176269 is covered by a clean OpenAI review. The Codex P1 finding about the 50 ms real-time sleep in the on-demand test was fixed by dropping the sleep, and its thread is resolved.
  • The branch already contains the latest main, and quest check --base origin/main passes (finished quest removed).
  • fix(moq-mux): an HLS viewer starts on-demand capture #7054 is still open. If it lands after this, it will need to keep this PR's switch of hls_records_keep_the_live_timestamps to the on-demand fixture.
  • Choices recorded in the body (the on_demand: bool name, no Waiting flash in always-on mode, moq publish going always-on before --on-demand exists) stand as written.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit 487759f Oct 29, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/eager-encode/audio branch October 29, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant