Skip to content

feat(moq-video, moq-audio): decode consumers take a subscription priority - #9282

Draft
kixelated wants to merge 2 commits into
mainfrom
quest/m1/decode-priority
Draft

kixelated wants to merge 2 commits into
mainfrom
quest/m1/decode-priority

Conversation

@kixelated

@kixelated kixelated commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

moq_video::decode::Consumer and moq_audio::decode::Consumer subscribed at hang's fixed PRIORITY.video and PRIORITY.audio, so a player showing several sources (the studio's viewer priorities, moq play composing layers) could not fetch a less important one behind a more important one under congestion.

Approach

  • decode::Options gains priority: i8 in both crates, defaulting to hang's PRIORITY.video (60) and PRIORITY.audio (80). The first subscription carries it. Named after Subscription::priority and the JS player's priority input in moq-dev/moq#9088.
  • decode::Consumer::set_priority(priority) in both crates moves it while running. It updates the existing subscription in place through its moq_net::track::Control, so nothing is resubscribed, re-fetched, or dropped. The video consumer moves its reader into a future while a read is in flight, so a Control (cloneable, needs no borrow of the cursor) is what reaches it. Audio uses the same mechanism for symmetry; its later set_max_delay reads the current subscription, so the priority survives it.
  • rs/moq-video/README.md mentions the new knob.
  • Deletes quest/m1/decode-priority.md, which this finishes.

Impact

  • moq-video: decode::Options::priority, decode::Consumer::set_priority. decode::Options no longer derives Default; it implements it by hand with the same values plus the priority. Additive: the struct is #[non_exhaustive], so outside callers already build it through new()/default().
  • moq-audio: decode::Options::priority, decode::Consumer::set_priority. Additive.
  • No wire change: the value rides the existing subscription priority field.
  • Bindings (moq-ffi, libmoq) are untouched: no binding user needs it yet.

Choices made unattended (open to review)

  • Field name priority (an absolute i8, matching Subscription::priority and moq-dev/moq#9088) rather than a relative rank.
  • set_priority(&mut self, ..) rather than &self, mirroring audio's set_max_delay; it could take &self since Control::update does.
  • Mid-stream changes go through Control::update in the decode crates, not a new moq_mux::container::Consumer::set_priority: that would add moq-mux API and still not reach the video reader while a read holds it.
  • No bindings exposure in this PR.

Validation

  • cargo test -p moq-video --lib decode::consumer: 17 pass, including the new priority_reaches_the_subscription_and_moves_in_place, which reads the priority off the publisher's aggregate subscription (track::Producer::subscription) at the default, after a change, and after a change made while a read is parked on the reader, then shows that parked read still returns the next picture (same subscription, not a new one).
  • Mutation check: with set_priority's update replaced by a no-op, that test fails at the aggregate assertion.
  • cargo test -p moq-audio --lib priority: the new audio test passes; it checks the default, a change, and that a later set_max_delay keeps the priority.
  • just check: clean.
  • Not shown: the effect under congestion (two consumers on one session behind a bufferbloated link). Priority scheduling itself is moq-net's and already covered there; this PR only wires the value.

Follow-ups

None.

Models

Size: S
Implementer: Claude, claude-opus-5-5, medium effort (arm A)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5 with medium)

Review

Rewritten by quest review after each round.

  • Head: 3b40265, named in full once no reviewer reports a finding

  • Base: origin/main at 3728b96

  • Risk: medium, Configurable audio and video subscription priorities change congestion scheduling for playback consumers, but preserve existing defaults and API compatibility, and a revert fully undoes the change.

  • Classified: medium by Codex, gpt-6.1-sol, low effort, session 01a1fc06-69df-7ea3-bc4e-9446d12e54ab

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

  • Session: 01a1fc06-7ed6-7e11-8d2e-b8bc86423e6f, round 1

  • Score: 7/10, The priority updates are straightforward, but failed audio and video readers must release subscription demand before landing.

  • Rounds: 1; first round 1 (medium 1); findings 1 (medium 1): fixed 0, refuted 0, open 1

  • Findings, open until the next round settles them:

    • Medium, rs/moq-video/src/decode/consumer.rs:129: Avoid retaining subscription demand after the container fails

kixelated and others added 2 commits November 20, 2026 18:07
…rity

decode::Options gains priority, defaulting to hang's PRIORITY.video and
PRIORITY.audio, and decode::Consumer::set_priority moves it in place
through the subscription's Control, even while a read holds the reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Decode consumers take a subscription priority feat(moq-video, moq-audio): decode consumers take a subscription priority Nov 21, 2026

This branch has not been deployed

No deployments
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