Repository navigation
feat(spf): send SUBSCRIBER_PRIORITY by track kind on MoQ media subscribes - #69
Conversation
…ibes Audio subscribes carry 16 and video 96, matching the relay SDKs' mediaSubscribeParameters (muxinc/relay-sdks#337). moq-relay 0.17 orders a viewer's downlink by subscriber priority alone, so without it audio queues behind video on a congested link. Closes #68
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. |
📦 Bundle Size Report🎨 @videojs/html — 1 small size change
Presets (7)
Media (19)
Players (5)
Skins (29)
UI Components (62)
⚛️ @videojs/react — no changesPresets (7)
Media (22)
Extensions (2)
Players (5)
Skins (18)
UI Components (39)
🧩 @videojs/core — no changesEntries (76)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (13)
📦 @videojs/cdn — no changes📦 @videojs/cloudflare-video — no changes📦 @videojs/dash-video — no changes📦 @videojs/google-cast — no changes📦 @videojs/hlsjs-video — no changes📦 @videojs/media — no changesEntries (3)
📦 @videojs/mux — no changes📦 @videojs/mux-audio — no changesEntries (2)
📦 @videojs/mux-data — no changes📦 @videojs/mux-video — no changesEntries (2)
📦 @videojs/native-hls-video — no changes📦 @videojs/shaka-video — no changes📦 @videojs/spf — 1 small size change
Entries (8)
📦 @videojs/spotify-audio — no changes📦 @videojs/tiktok-video — no changes📦 @videojs/twitch-video — no changes📦 @videojs/other — no changesEntries (3)
📦 @videojs/vimeo-video — no changes📦 @videojs/wistia-video — no changesEntries (2)
📦 @videojs/youtube-video — no changesℹ️ How to interpretEach entry is independently bundled, minified, and brotli-compressed. Initial size includes its static import graph; lazy dynamic chunks are reported separately. Entries are not additive because their dependency graphs overlap. Preset rows represent realistic combined bundles. Changes of 300 B or less across initial, lazy, and total size are collapsed, not discarded. Run |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/spf/src/playback/actors/track-subscriber.ts">
<violation number="1" location="packages/spf/src/playback/actors/track-subscriber.ts:617">
P3: The auth-refresh resubscribe drops any `subscriberPriority` that `refreshAuth` returns, because this line overwrites it after `...refreshed`. `refreshAuth` is documented to return parameters to retry with, so a refreshed value should win and the resolved kind default should be the fallback. Use `refreshed.subscriberPriority ?? parameters.subscriberPriority`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| subscribe({ | ||
| ...parameters, | ||
| ...refreshed, | ||
| subscriberPriority: parameters.subscriberPriority, |
There was a problem hiding this comment.
P3: The auth-refresh resubscribe drops any subscriberPriority that refreshAuth returns, because this line overwrites it after ...refreshed. refreshAuth is documented to return parameters to retry with, so a refreshed value should win and the resolved kind default should be the fallback. Use refreshed.subscriberPriority ?? parameters.subscriberPriority.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/spf/src/playback/actors/track-subscriber.ts, line 617:
<comment>The auth-refresh resubscribe drops any `subscriberPriority` that `refreshAuth` returns, because this line overwrites it after `...refreshed`. `refreshAuth` is documented to return parameters to retry with, so a refreshed value should win and the resolved kind default should be the fallback. Use `refreshed.subscriberPriority ?? parameters.subscriberPriority`.</comment>
<file context>
@@ -596,7 +611,12 @@ export function createTrackSubscriberActor(options: CreateTrackSubscriberOptions
+ subscribe({
+ ...parameters,
+ ...refreshed,
+ subscriberPriority: parameters.subscriberPriority,
+ locationFilter: parameters.locationFilter,
+ });
</file context>
| subscriberPriority: parameters.subscriberPriority, | |
| subscriberPriority: refreshed.subscriberPriority ?? parameters.subscriberPriority, |
Closes #68.
The MoQ player's media SUBSCRIBEs now carry SUBSCRIBER_PRIORITY: 16 for audio and 96 for video, so a congested relay-to-viewer downlink sends audio first. moq-relay 0.17 orders a viewer's downlink by subscriber priority alone and ignores the publisher's 0x0E (muxinc/relay-sdks#154). On that relay any REQUEST_UPDATE ends the subscription, so the priority has to go on the SUBSCRIBE. The values match the relay SDKs'
mediaSubscribeParameters(muxinc/relay-sdks#337, videojs#343), which measured audio p99 at 74-76 ms with these priorities and 253-259 ms without, on ord behind an 800 kbit/s cap.What changed
MEDIA_SUBSCRIBER_PRIORITYintrack-subscriber.tsholds{ audio: 16, video: 96 }. The actor picks the value from the track's catalog kind (track.type), not its name.track-subscriberis the only place that builds a media SUBSCRIBE, so the initial join, ABR/layer-switch handoffs, dead-subscription rejoins and suspend/resume rejoins all get the priority. The auth-refresh resubscribe keeps it too.subscriberPriorityinCreateTrackSubscriberOptions.parametersreplaces the default. That option is already documented as "auth tokens, priority". No new public player API.Verification
subscribe-selected-trackswith real subscribers, an ABR switch HD→SD plus a rejoin of the handoff target, and an audio rejoin after PUBLISH_DONE.pnpm -F @videojs/spf test(2429 passed),pnpm lint,pnpm typecheck.videojs_streampublisher and thespf-moq-playersandbox in headless Chromium. Decoding the page's WebTransport writes with the player's own parameter decoder gave:The relay accepted both subscriptions and playback started.
Notes
mmcc/moq-publisher,setup-track-publisherssets a per-subgroup-header publisher priority (catalog 0, audio 64, camera 128, screen 192) and does not send the 0x0E Default Publisher Priority track property with the SDK values (audio 16 / video 96). moq-relay 0.17 ignores both for viewer ordering anyway.🤖 Generated with Claude Code
Summary by cubic
Media SUBSCRIBEs now carry
SUBSCRIBER_PRIORITYchosen by track kind — 16 for audio, 96 for video — so audio stays ahead of video on a congested relay-to-viewer downlink. moq-relay 0.17 orders by subscriber priority alone, so this value rides every media SUBSCRIBE: initial join, ABR/layer-switch handoffs, dead-subscription and suspend/resume rejoins, and the auth-refresh resubscribe. The values match the relay SDKs'mediaSubscribeParameters.The priority comes from
MEDIA_SUBSCRIBER_PRIORITYintrack-subscriber.ts, selected bytrack.type, and can be overridden withsubscriberPriorityinCreateTrackSubscriberOptions.parameters.refreshAuthonly supplies fresh auth: the resubscribe keeps the originalsubscriberPriorityand location whatever it returns. Catalog and text track subscribes send no priority and leave the peer's default.Written for commit 366a58d. Summary will update on new commits.