From 32b412cf4f714f0d7b3ef3844b8dafd56eb6737e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 15:33:00 -0700 Subject: [PATCH 1/4] chore(quest): claim quest/m1/push-to-talk/hold-js.md Quest-Claim: d92e010ca98fa177 From f0a0ff56fa4c7c9884be3232d5e0e6538d01e9fb Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 16:07:07 -0700 Subject: [PATCH 2/4] fix(watch): hold a disabled rendition while no enabled one remains @moq/watch keeps its selected audio or video rendition, and its subscription, while the publisher has it disabled and no enabled alternative exists, so an unmute plays without a catalog round trip or a resubscribe. Initial selection still skips disabled renditions, an enabled alternative wins, and a removed rendition is dropped. A held disabled audio rendition idles like an absent one, so a muted tile suspends its AudioContext once drained. Neither decoder's startup waits on a held disabled rendition, and the buffering spinner ignores one. The hang draft and catalog docs say a consumer "should not" select a disabled rendition, and may keep one it already selected. Co-Authored-By: Claude Opus 5.5 --- doc/concept/hang.md | 2 +- drafts/draft-lcurley-moq-hang.md | 5 +- js/hang/src/catalog/audio.ts | 3 +- js/hang/src/catalog/video.ts | 3 +- js/watch/src/audio/decoder.test.ts | 59 +++++++++++- js/watch/src/audio/decoder.ts | 12 ++- js/watch/src/audio/source.test.ts | 93 ++++++++++++++++++- js/watch/src/audio/source.ts | 70 ++++++-------- .../src/ui/components/buffering-indicator.ts | 9 +- js/watch/src/video/decoder.test.ts | 22 ++++- js/watch/src/video/decoder.ts | 4 +- js/watch/src/video/source.test.ts | 56 +++++++++++ js/watch/src/video/source.ts | 42 ++++++--- quest/m1/push-to-talk/README.md | 1 - quest/m1/push-to-talk/hold-js.md | 47 ---------- quest/m1/push-to-talk/hold-rs.md | 15 ++- quest/m3/ladder/README.md | 2 +- rs/hang/src/catalog/audio/mod.rs | 3 +- rs/hang/src/catalog/video/mod.rs | 3 +- 19 files changed, 319 insertions(+), 132 deletions(-) delete mode 100644 quest/m1/push-to-talk/hold-js.md diff --git a/doc/concept/hang.md b/doc/concept/hang.md index c1c73d076b0..ebda87c8052 100644 --- a/doc/concept/hang.md +++ b/doc/concept/hang.md @@ -69,7 +69,7 @@ A few things the catalog can express beyond decoder config: - **Reorder depth.** A video rendition may declare `reorder`, the most frames that can precede one in decode order and follow it in presentation, as H.264 `max_num_reorder_frames` counts them; `0` declares none, which is not the same as absent. The Rust H.264 and H.265 importers copy it from the SPS when the SPS declares one (progressive H.264 only), and `@moq/publish` declares `0`. The MPEG-TS, Matroska, and FLV exporters then derive each group's decode times from that group's frames alone, so exports that joined at different groups agree, and they end the export on a frame reordered deeper than declared or a depth the codec level cannot reach. Without it they infer decode times from the timestamps they have read, as before. A publisher never changes it once declared. - **Colour.** A video rendition may carry `color`: the H.273 primaries, transfer, matrix, and range, plus the HDR10 mastering display and content light levels, so a renderer can set up HDR without parsing the bitstream. The Rust importers fill it from the SPS VUI, AV1 sequence header, and VP9 header, then fill gaps from a container's `colr` box or Matroska `Colour` element; the stream wins a disagreement. The HDR10 values come from H.264 and H.265 SEI or AV1 metadata OBUs in MPEG-TS and raw elementary streams, an AV1 track's av1C, or Matroska, but not yet from H.264 or H.265 in fMP4 or FLV. Nothing in `@moq/watch` reads it yet. - **Spatial media.** A video rendition may carry `projection` (flat `rectilinear`, or `equirectangular` with the degrees of longitude it spans, 180 for VR180) and `stereo` (`mono`, `left-right`, or `top-bottom` frame packing), and an audio rendition may carry `layout: "ambisonic"` for AmbiX channels. Readers treat a value they don't recognize as absent. Nothing in `@moq/watch` renders them yet. -- **Disabled renditions.** An audio or video rendition with `enabled: false` has no frames coming, and a player must not select it. Pausing a rendition in `@moq/publish` keeps it in the catalog this way rather than removing it, so a mute is a one-field update; a disabled video rendition encodes one black keyframe first, so a player that predates the field shows black instead of a frozen picture. The field is written only when false. The older video `stalled` field is no longer written, and readers ignore it. +- **Disabled renditions.** An audio or video rendition with `enabled: false` has no frames coming, and a player should not select it. A player may keep a disabled rendition selected, and subscribed, while no enabled alternative exists, so a re-enable plays without a resubscribe; `@moq/watch` does. Pausing a rendition in `@moq/publish` keeps it in the catalog this way rather than removing it, so a mute is a one-field update; a disabled video rendition encodes one black keyframe first, so a player that predates the field shows black instead of a frozen picture. The field is written only when false. The older video `stalled` field is no longer written, and readers ignore it. - **Preference.** A video rendition may carry a signed `preference`, default `0`. A player keeps only the highest preference it can decode, then picks by size and bitrate within it, as do the single-rendition egresses (RTMP play, WHEP, FLV, the transcoder's source). A publisher that adds its own H.264 copy of an H.265 source marks the copy `-1`, so only a viewer that can't decode H.265 pulls it. Picking a rendition by name still overrides it. The field is written only when nonzero. - **HLS records.** A video or audio rendition may carry an `hls` field naming a small track of HLS segment records, each segment's first group and pts, plus the nominal segment duration. Each rendition numbers its own segments, and an edge serves a rendition's segment `n` from its record `n`; segments line up across renditions wherever their keyframes do. The records are what let the [HLS gateway](/bin/hls) build playlists without subscribing to media; a rendition without them gets no playlist. Rust publishers (`moq-mux` and everything built on it) publish them by default; `@moq/publish` does not yet. A reader that cannot decode the field ignores it. - **Clock.** The optional root `clock` maps PTS zero to wall time so every media track and every HLS record share one fixed epoch after timescale conversion. Publish independent sources as sibling broadcasts under one prefix, such as `robot/front.hang` and `robot/rear.hang`; each broadcast's audio and video entries are renditions of that source. In one Rust publisher, pass the same `moq_mux::Clock` to each `catalog::Config::with_clock`; JS publishers on one page already share the page clock. Consumers discover the siblings by prefix and align their timestamps through the advertised wall mapping; `@moq/watch` plays one broadcast at a time. diff --git a/drafts/draft-lcurley-moq-hang.md b/drafts/draft-lcurley-moq-hang.md index 260b9f7b3a1..94f048e619a 100644 --- a/drafts/draft-lcurley-moq-hang.md +++ b/drafts/draft-lcurley-moq-hang.md @@ -774,7 +774,8 @@ For example, with video at 20 millisecond intervals and audio at 15 written as v ### enabled {#field-enabled} The `enabled` field says whether a consumer may select an audio or video rendition; a text rendition does not carry it. -When `enabled` is false, no frames are coming, and a consumer MUST NOT select the rendition. +When `enabled` is false, no frames are coming, and a consumer SHOULD NOT select the rendition. +A consumer MAY keep a rendition it already selected while that rendition is disabled and no enabled one it can decode remains, so a re-enable needs no new subscription. If absent, `enabled` defaults to true; a publisher SHOULD only write it when false. Earlier versions defined a video `stalled` field instead. @@ -1149,7 +1150,7 @@ This document has no IANA actions. - Added the optional `delay` rendition field: how far a rendition's timestamps trail those other renditions already wrote, never lowered once advertised and never subtracted across renditions. - Recommended namespaced keys for application root sections. - Added the optional `delay` field to `json` and `binary` track entries, measured only from payloads stamped with their capture time on the broadcast clock. -- Replaced the video `stalled` field with an optional `enabled` field on audio and video renditions. A consumer MUST NOT select a disabled rendition and ignores `stalled`. A consumer that predates `enabled` keeps selecting a disabled rendition. +- Replaced the video `stalled` field with an optional `enabled` field on audio and video renditions. A consumer SHOULD NOT select a disabled rendition, MAY keep one it already selected while no enabled alternative remains, and ignores `stalled`. A consumer that predates `enabled` keeps selecting a disabled rendition. - Audio `sampleRate` and `numberOfChannels` describe the decoded output, so HE-AAC names its SBR rate and parametric stereo names two channels. - Added an optional `track` field to video, audio, text, `json`, and `binary` entries naming the track in its broadcast; the entry's key is its ID and names the track when `track` is absent. A consumer MUST reject a catalog using one ID for both a video and an audio rendition. - Defined video `displayAspectWidth` and `displayAspectHeight` as the whole picture's display aspect, not the sample aspect. diff --git a/js/hang/src/catalog/audio.ts b/js/hang/src/catalog/audio.ts index 4ab198b21e5..8f743f66b5a 100644 --- a/js/hang/src/catalog/audio.ts +++ b/js/hang/src/catalog/audio.ts @@ -57,7 +57,8 @@ const AudioConfigFields = z.object({ bitrate: z.optional(u53Schema), // Whether this rendition may be selected. When false, no frames are coming and a consumer - // must not select it. Default: true, so publishers only write it when false. + // should not select it, though one may keep it selected while no enabled alternative exists. + // Default: true, so publishers only write it when false. enabled: z.optional(z.boolean()), // The maximum delay between a frame being ready and the publisher flushing it, in whole diff --git a/js/hang/src/catalog/video.ts b/js/hang/src/catalog/video.ts index e75ccc5ad0a..520ae5473bc 100644 --- a/js/hang/src/catalog/video.ts +++ b/js/hang/src/catalog/video.ts @@ -151,7 +151,8 @@ export const VideoConfigSchema = z.object({ bitrate: z.optional(u53Schema), // Whether this rendition may be selected. When false, no frames are coming and a consumer - // must not select it. Default: true, so publishers only write it when false. + // should not select it, though one may keep it selected while no enabled alternative exists. + // Default: true, so publishers only write it when false. enabled: z.optional(z.boolean()), // Higher is preferred: a player selects among the highest preference it can decode, then by diff --git a/js/watch/src/audio/decoder.test.ts b/js/watch/src/audio/decoder.test.ts index f1450bbd4e3..01b5e121d81 100644 --- a/js/watch/src/audio/decoder.test.ts +++ b/js/watch/src/audio/decoder.test.ts @@ -678,7 +678,7 @@ describe("Decoder across a rendition's absence", () => { } }); - it("deselects a disabled rendition and keeps one graph across disable and enable", async () => { + it("holds a disabled rendition and keeps one subscription across mute and unmute", async () => { const playback = await play(Milli(100)); try { await playback.play(12); @@ -686,16 +686,69 @@ describe("Decoder across a rendition's absence", () => { playback.disable(); await microtasks(); - expect(playback.track()).toBeUndefined(); + expect(playback.track()).toBe("audio"); expect(contexts).toHaveLength(1); playback.restore(); await microtasks(); expect(playback.track()).toBe("audio"); - await playback.play(6); + const before = playback.inserted().length; + const timestamps = await playback.play(6); expect(contexts).toHaveLength(1); expect(contexts[0].calls.close).toBe(0); + expect(playback.subscriptions()).toBe(1); + expect(playback.inserted().slice(before)).toEqual(timestamps); + } finally { + playback.close(); + } + }); + + it("suspends a held muted tile once drained, and resumes on unmute", async () => { + const playback = await play(Milli(100)); + try { + await playback.play(12); + const [ring] = playback.rings(); + expect(ring.read([new Float32Array(128), new Float32Array(128)])).toBe(128); + await microtasks(); + + playback.disable(); + await microtasks(); + const [context] = contexts; + expect(context.calls.suspend).toBe(0); + + expect(drain(ring)).toBeGreaterThan(0); + await microtasks(); + expect(context.calls.suspend).toBe(1); + expect(context.state).toBe("suspended"); + expect(playback.track()).toBe("audio"); + + playback.restore(); + await microtasks(); + expect(context.state).toBe("running"); + expect(playback.subscriptions()).toBe(1); + } finally { + playback.close(); + } + }); + + it("drops a held rendition once it is removed", async () => { + const playback = await play(Milli(100)); + try { + await playback.play(12); + playback.disable(); + await microtasks(); + expect(playback.track()).toBe("audio"); + + playback.remove(); + await microtasks(); + expect(playback.track()).toBeUndefined(); + + // Its return is a fresh selection, with a fresh subscription. + playback.restore(); + await microtasks(); + expect(playback.track()).toBe("audio"); + await playback.play(6); expect(playback.subscriptions()).toBe(2); } finally { playback.close(); diff --git a/js/watch/src/audio/decoder.ts b/js/watch/src/audio/decoder.ts index 60c1f4f34ff..2a4b3471a29 100644 --- a/js/watch/src/audio/decoder.ts +++ b/js/watch/src/audio/decoder.ts @@ -183,7 +183,9 @@ export class Decoder { const startup = this.#signals.computed((effect) => { if (!effect.get(this.in.enabled)) return undefined; if (effect.get(this.source.pending)) return null; - if (!effect.get(this.source.out.config)) return undefined; + // A held disabled rendition has no frames coming, so startup does not wait on it. + const config = effect.get(this.source.out.config); + if (!config || config.enabled === false) return undefined; const span = effect.get(this.#decodeBuffered)[0]; if (!span) return null; // Deep targets stay encoded, so count the audio queued past the decoded span. Sum it across @@ -200,9 +202,11 @@ export class Decoder { const config = effect.get(this.source.out.config); return config ? playbackIdentity(config) : undefined; }); - this.#idle = this.#signals.computed( - (effect) => effect.get(this.source.out.config) === undefined && effect.get(this.#out.stalled), - ); + // A held disabled rendition idles too, so a muted tile suspends its AudioContext. + this.#idle = this.#signals.computed((effect) => { + const config = effect.get(this.source.out.config); + return (!config || config.enabled === false) && effect.get(this.#out.stalled); + }); this.#signals.run(this.#runSubscribeMaxDelay.bind(this)); this.#signals.run(this.#runShape.bind(this)); diff --git a/js/watch/src/audio/source.test.ts b/js/watch/src/audio/source.test.ts index d1709b2e2a2..4c2a19a11d9 100644 --- a/js/watch/src/audio/source.test.ts +++ b/js/watch/src/audio/source.test.ts @@ -4,12 +4,13 @@ import { Signal } from "@moq/signals"; import type { Broadcast } from "../broadcast"; import { Source } from "./source"; -function config(codec: string): Catalog.AudioConfig { +function config(codec: string, fields: Record = {}): Catalog.AudioConfig { return Catalog.AudioConfigSchema.parse({ codec, sampleRate: 48000, numberOfChannels: 2, container: { kind: "legacy" }, + ...fields, }); } @@ -66,3 +67,93 @@ test("a rejected replacement catalog clears previously available audio", async ( source.close(); } }); + +test("skips a disabled rendition on the initial selection", async () => { + const state = broadcast({ mic: config("opus", { enabled: false }) }); + const source = new Source({ broadcast: state.broadcast, supported: async () => true }); + try { + await settled(source); + expect(source.out.track.peek()).toBeUndefined(); + + state.catalog.set({ audio: { renditions: { mic: config("opus") } } }); + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + } finally { + source.close(); + } +}); + +test("holds the selected rendition while every rendition is disabled", async () => { + const state = broadcast({ mic: config("opus") }); + const source = new Source({ broadcast: state.broadcast, supported: async () => true }); + try { + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + + state.catalog.set({ audio: { renditions: { mic: config("opus", { enabled: false }) } } }); + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + expect(source.out.config.peek()?.enabled).toBe(false); + + state.catalog.set({ audio: { renditions: { mic: config("opus") } } }); + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + expect(source.out.config.peek()?.enabled).toBeUndefined(); + } finally { + source.close(); + } +}); + +test("an enabled alternative takes over from a disabled rendition", async () => { + const state = broadcast({ mic: config("opus") }); + const source = new Source({ broadcast: state.broadcast, supported: async () => true }); + try { + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + + state.catalog.set({ + audio: { renditions: { mic: config("opus", { enabled: false }), backup: config("opus") } }, + }); + await settled(source); + expect(source.out.track.peek()).toBe("backup"); + } finally { + source.close(); + } +}); + +test("drops a held rendition once it is removed", async () => { + const state = broadcast({ mic: config("opus") }); + const source = new Source({ broadcast: state.broadcast, supported: async () => true }); + try { + await settled(source); + state.catalog.set({ audio: { renditions: { mic: config("opus", { enabled: false }) } } }); + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + + state.catalog.set({ audio: { renditions: { other: config("opus", { enabled: false }) } } }); + await settled(source); + expect(source.out.track.peek()).toBeUndefined(); + expect(source.out.config.peek()).toBeUndefined(); + } finally { + source.close(); + } +}); + +test("does not carry a hold to another broadcast", async () => { + const first = broadcast({ mic: config("opus") }); + const current = new Signal(first.broadcast); + const source = new Source({ broadcast: current, supported: async () => true }); + try { + await settled(source); + first.catalog.set({ audio: { renditions: { mic: config("opus", { enabled: false }) } } }); + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + + // The same catalog on another broadcast probes nothing new, so wait on a timer, not the probe. + current.set(broadcast({ mic: config("opus", { enabled: false }) }).broadcast); + await new Promise((resolve) => setTimeout(resolve, 0)); + expect(source.out.track.peek()).toBeUndefined(); + } finally { + source.close(); + } +}); diff --git a/js/watch/src/audio/source.ts b/js/watch/src/audio/source.ts index 004573ac431..80c9cc236e3 100644 --- a/js/watch/src/audio/source.ts +++ b/js/watch/src/audio/source.ts @@ -60,6 +60,9 @@ export class Source { /** Whether rendition support is still being resolved. @internal */ readonly pending: Getter = this.#pending; + // The last selection, which a disable holds while no enabled rendition remains. + #held?: { broadcast: Broadcast; track: string }; + #signals = new Effect(); constructor(props?: Inputs) { @@ -126,59 +129,44 @@ export class Source { } #runSelected(effect: Effect): void { - // A disabled rendition has no frames coming, so it is never selected, even by name. - const available = Object.fromEntries( - Object.entries(effect.get(this.#out.available)).filter(([, config]) => config.enabled !== false), - ); - if (Object.keys(available).length === 0) return; - + const broadcast = effect.get(this.in.broadcast); + const all = effect.get(this.#out.available); const target = effect.get(this.in.target); - let selected: { track: string; config: Catalog.AudioConfig } | undefined; + // A disabled rendition has no frames coming, so it is never newly selected, even by name. + const available = Object.fromEntries(Object.entries(all).filter(([, config]) => config.enabled !== false)); - // Manual selection by name - if (target?.name && target.name in available) { - selected = { track: target.name, config: available[target.name] }; - } else { - // Automatic selection - selected = this.#select(available); - if (!selected) return; - } + const track = + target?.name && target.name in available + ? target.name + : (this.#select(available) ?? this.#hold(broadcast, all)); + this.#held = track && broadcast ? { broadcast, track } : undefined; + if (!track) return; - effect.set(this.#out.track, selected.track); - effect.set(this.#out.config, selected.config); + const config = all[track]; + effect.set(this.#out.track, track); + effect.set(this.#out.config, config); + effect.set(this.#out.jitter, config.jitter !== undefined ? Milli(config.jitter) : undefined); + } - const jitter = selected.config.jitter; - effect.set(this.#out.jitter, jitter !== undefined ? Milli(jitter) : undefined); + // Every rendition is disabled: keep the selected one, and its subscription, so the re-enable + // plays without a resubscribe. A removed rendition, or another broadcast, starts over. + #hold(broadcast: Broadcast | undefined, all: Record): string | undefined { + if (Object.values(all).some((config) => config.enabled !== false)) return undefined; + const held = this.#held; + if (!held || held.broadcast !== broadcast || !(held.track in all)) return undefined; + return held.track; } /** * Select rendition based on the configured strategy. */ - #select( - renditions: Record, - ): { track: string; config: Catalog.AudioConfig } | undefined { + #select(renditions: Record): string | undefined { const entries = Object.entries(renditions); - if (entries.length === 0) return undefined; - - for (const [track, config] of entries) { - if (config.container.kind === "legacy") { - return { track, config }; - } + for (const kind of ["legacy", "loc", "cmaf"]) { + const found = entries.find(([, config]) => config.container.kind === kind); + if (found) return found[0]; } - - for (const [track, config] of entries) { - if (config.container.kind === "loc") { - return { track, config }; - } - } - - for (const [track, config] of entries) { - if (config.container.kind === "cmaf") { - return { track, config }; - } - } - return undefined; } diff --git a/js/watch/src/ui/components/buffering-indicator.ts b/js/watch/src/ui/components/buffering-indicator.ts index b29a349ebb9..49ea11a739c 100644 --- a/js/watch/src/ui/components/buffering-indicator.ts +++ b/js/watch/src/ui/components/buffering-indicator.ts @@ -13,11 +13,16 @@ export function bufferingIndicator(parent: Effect, watch: MoqWatch): HTMLElement // video one. Gate it on audio actually being downloaded: the ring reports stalled from // construction and drains once the download stops, so a video-only broadcast or a muted // player would otherwise show the spinner forever. "instant" never downloads audio at all. + // A held rendition the publisher disabled has no frames coming, which is not a stall either. + const audioConfig = effect.get(watch.audio.source.out.config); const audio = effect.get(watch.audio.in.enabled) && - effect.get(watch.audio.source.out.config) !== undefined && + audioConfig !== undefined && + audioConfig.enabled !== false && effect.get(watch.controls.delay) !== "instant"; - const buffering = effect.get(watch.video.out.stalled) || (audio && effect.get(watch.audio.out.stalled)); + const video = effect.get(watch.video.source.out.config)?.enabled !== false; + const buffering = + (video && effect.get(watch.video.out.stalled)) || (audio && effect.get(watch.audio.out.stalled)); const status = effect.get(watch.broadcast.out.status); const online = status === "loading" || status === "live"; const unsupported = effect.get(watch.video.source.out.error)?.name === "NotSupportedError"; diff --git a/js/watch/src/video/decoder.test.ts b/js/watch/src/video/decoder.test.ts index a984114ebe6..90bfaf94948 100644 --- a/js/watch/src/video/decoder.test.ts +++ b/js/watch/src/video/decoder.test.ts @@ -479,16 +479,36 @@ it("keeps the clock when only the catalog's broadcast is republished", async () } }); -it("clears the picture once no rendition is selectable", async () => { +it("holds the picture and decoder while the only rendition is disabled", async () => { const playback = await guardedPlayback("legacy", [sample(10, 1000)]); try { const held = playback.decoder.out.frame.peek(); expect(held).toBeDefined(); + const codecs = playback.codecs; const video = playback.catalog.peek().video?.renditions.video; if (!video) throw new Error("missing rendition"); playback.catalog.set({ video: { renditions: { video: { ...video, enabled: false } } } }); await microtasks(); + // The last picture before the disable stays up; the stock publisher makes it black. + expect(playback.decoder.out.frame.peek()).toBe(held); + + playback.catalog.set({ video: { renditions: { video } } }); + await microtasks(); + expect(playback.codecs).toBe(codecs); + } finally { + playback.close(); + } +}); + +it("clears the picture once no rendition is selectable", async () => { + const playback = await guardedPlayback("legacy", [sample(10, 1000)]); + try { + const held = playback.decoder.out.frame.peek(); + expect(held).toBeDefined(); + + playback.catalog.set({}); + await microtasks(); expect(playback.decoder.out.frame.peek()).toBeUndefined(); expect(playback.decoder.out.timestamp.peek()).toBeUndefined(); expect((held as unknown as Picture).closed).toBe(true); diff --git a/js/watch/src/video/decoder.ts b/js/watch/src/video/decoder.ts index 4d0454eea9f..78994dabcb5 100644 --- a/js/watch/src/video/decoder.ts +++ b/js/watch/src/video/decoder.ts @@ -158,7 +158,9 @@ export class Decoder { const startup = this.#signals.computed((effect) => { if (!effect.get(this.in.enabled)) return undefined; if (effect.get(this.source.pending)) return null; - if (!effect.get(this.source.out.config)) return undefined; + // A held disabled rendition has no frames coming, so startup does not wait on it. + const config = effect.get(this.source.out.config); + if (!config || config.enabled === false) return undefined; const active = effect.get(this.#active); if (!active) return null; const timestamp = effect.get(active.first); diff --git a/js/watch/src/video/source.test.ts b/js/watch/src/video/source.test.ts index 23a81562bb3..1655ca89972 100644 --- a/js/watch/src/video/source.test.ts +++ b/js/watch/src/video/source.test.ts @@ -241,6 +241,62 @@ describe("Source disabled rendition selection", () => { source.close(); }); + it("holds the selected rendition while every rendition is disabled", async () => { + const state = mutableBroadcast({ + low: config("avc1.64001e", { bitrate: 1_000_000 }), + high: config("avc1.640028", { bitrate: 2_000_000 }), + }); + const source = new Source({ broadcast: state.broadcast, supported: async () => true }); + + await settle(); + expect(source.out.track.peek()).toBe("high"); + + state.catalog.set({ + video: { + renditions: { + low: config("avc1.64001e", { bitrate: 1_000_000, enabled: false }), + high: config("avc1.640028", { bitrate: 2_000_000, enabled: false }), + }, + }, + }); + await settle(); + expect(source.out.track.peek()).toBe("high"); + expect(source.out.config.peek()?.enabled).toBe(false); + + // An enabled alternative takes over from the held rendition. + state.catalog.set({ + video: { + renditions: { + low: config("avc1.64001e", { bitrate: 1_000_000 }), + high: config("avc1.640028", { bitrate: 2_000_000, enabled: false }), + }, + }, + }); + await settle(); + expect(source.out.track.peek()).toBe("low"); + source.close(); + }); + + it("drops a held rendition once it is removed", async () => { + const state = mutableBroadcast({ high: config("avc1.640028", { bitrate: 2_000_000 }) }); + const source = new Source({ broadcast: state.broadcast, supported: async () => true }); + + await settle(); + state.catalog.set({ + video: { renditions: { high: config("avc1.640028", { bitrate: 2_000_000, enabled: false }) } }, + }); + await settle(); + expect(source.out.track.peek()).toBe("high"); + + state.catalog.set({ + video: { renditions: { low: config("avc1.64001e", { bitrate: 1_000_000, enabled: false }) } }, + }); + await settle(); + expect(source.out.track.peek()).toBeUndefined(); + expect(source.out.config.peek()).toBeUndefined(); + source.close(); + }); + it("ignores a legacy stalled flag", async () => { const source = new Source({ broadcast: mockBroadcast({ diff --git a/js/watch/src/video/source.ts b/js/watch/src/video/source.ts index 5552eefd4d1..5844d14be56 100644 --- a/js/watch/src/video/source.ts +++ b/js/watch/src/video/source.ts @@ -186,7 +186,7 @@ function byBitrate(target: number): RenditionFilter { }; } -/** Return the renditions that may be selected: a disabled one has no frames coming. */ +/** Return the renditions that may be newly selected: a disabled one has no frames coming. */ function enabledRenditions(renditions: Record): Record { return Object.fromEntries(Object.entries(renditions).filter(([, config]) => config.enabled !== false)); } @@ -220,6 +220,9 @@ export class Source { /** Whether rendition support is still being resolved. @internal */ readonly pending: Getter = this.#pending; + // The last selection, which a disable holds while no enabled rendition remains. + #held?: { broadcast: Broadcast; track: string }; + #signals = new Effect(); #supportCache = new WeakMap>(); @@ -315,17 +318,23 @@ export class Source { } #runSelected(effect: Effect): void { - const available = enabledRenditions(effect.get(this.#out.available)); + const broadcast = effect.get(this.in.broadcast); + const all = effect.get(this.#out.available); + const available = enabledRenditions(all); const target = effect.get(this.in.target); - if (target?.name && target.name in available) { - const config = available[target.name]; - effect.set(this.#out.track, target.name); - effect.set(this.#out.config, config); - return; - } + const selected = this.#choose(effect, available, target) ?? this.#hold(broadcast, all); + this.#held = selected && broadcast ? { broadcast, track: selected } : undefined; + if (!selected) return; + + effect.set(this.#out.track, selected); + effect.set(this.#out.config, all[selected]); + } - if (Object.keys(available).length === 0) return; + // Pick among the enabled renditions. + #choose(effect: Effect, available: Record, target?: Target): string | undefined { + if (target?.name && target.name in available) return target.name; + if (Object.keys(available).length === 0) return undefined; // Auto-select: use recv bandwidth if no explicit bitrate target. let effectiveTarget = target; @@ -338,13 +347,16 @@ export class Source { } } - const selected = this.#select(preferredRenditions(available), effectiveTarget); - if (!selected) return; - - const config = available[selected]; + return this.#select(preferredRenditions(available), effectiveTarget); + } - effect.set(this.#out.track, selected); - effect.set(this.#out.config, config); + // Every rendition is disabled: keep the selected one, and its subscription, so the re-enable + // plays without a resubscribe. A removed rendition, or another broadcast, starts over. + #hold(broadcast: Broadcast | undefined, all: Record): string | undefined { + if (Object.values(all).some((config) => config.enabled !== false)) return undefined; + const held = this.#held; + if (!held || held.broadcast !== broadcast || !(held.track in all)) return undefined; + return held.track; } /** diff --git a/quest/m1/push-to-talk/README.md b/quest/m1/push-to-talk/README.md index 42008789dad..d84f3a47bf1 100644 --- a/quest/m1/push-to-talk/README.md +++ b/quest/m1/push-to-talk/README.md @@ -45,7 +45,6 @@ Record both in the PR. ## Required -- [JS consumers hold a disabled rendition](/quest/m1/push-to-talk/hold-js.md) - watch keeps a disabled audio or video rendition subscribed, and the hang spec says "should not select" - [Rust consumers hold a disabled rendition](/quest/m1/push-to-talk/hold-rs.md) - moq-cli play, moq-ffi and moq-mux select follow the same rule - [Re-enable without a probe](/quest/m1/push-to-talk/reenable.md) - the JS audio encoder reuses its probe, so an unmute flips the catalog at once and keeps capture timestamps - [`muted` and `invisible` keep capture open](/quest/m1/push-to-talk/mute.md) - the element disables only the encoder, so unmute skips getUserMedia and AudioContext setup diff --git a/quest/m1/push-to-talk/hold-js.md b/quest/m1/push-to-talk/hold-js.md deleted file mode 100644 index e4e16123d9d..00000000000 --- a/quest/m1/push-to-talk/hold-js.md +++ /dev/null @@ -1,47 +0,0 @@ -# [M] JS consumers hold a disabled rendition - -## Goal - -`@moq/watch` keeps its selected audio or video rendition, and its -subscription, while the publisher has it `enabled: false` and no enabled -alternative exists. Re-enabling it plays without a resubscribe. The hang spec -says a consumer "should not select" a disabled rendition, where it said "must -not". - -## Plan - -Decided 2026-10-28 (maintainer), default on, audio and video: - -- Initial selection still skips disabled renditions, so a listener who joins - during a pause subscribes on the unmute. -- The selected rendition stays selected while it is disabled, still in the - catalog, and every rendition of its kind is disabled. An enabled - alternative wins, so a simulcast ladder (whose lowest rung never disables) - never holds. A rendition removed from the catalog is dropped. -- Audio: `#runSelected` (`js/watch/src/audio/source.ts:129-133`) and the - decoder's subscription (`audio/decoder.ts:363-396`). Key `#idle` - (`decoder.ts:203-205`) on "held and disabled" as well as a missing config, - so a muted tile still suspends its AudioContext. -- Video: `enabledRenditions` (`js/watch/src/video/source.ts:190-191`) with the - same rule. -- A held subscription gets a clean break from the publisher's discontinuity - marker ([#4880](https://github.com/moq-dev/moq/pull/4880)), or after - [time addressing](/quest/m1/time-addressing/consumers.md) from the gap - between groups, and keeps its - audio graph ([#4881](https://github.com/moq-dev/moq/pull/4881)). - -Spec wording lands with whichever hold quest lands first: the hang draft, -`rs/hang/src/catalog/{audio,video}/mod.rs`, `js/hang/src/catalog/audio.ts` and -`video.ts`, and `doc/concept/hang.md`. -[OBS source renditions](/quest/m2/obs-source-renditions.md) already plans the -same hold. - -Tests: mute, then unmute, keeps one subscription. An enabled alternative takes -over. A rendition removed while held is dropped. A held muted tile suspends -its AudioContext. - -Public API: behavior only. Wire: none. - -## Related - -- [Rust consumers hold a disabled rendition](/quest/m1/push-to-talk/hold-rs.md) - the same rule in Rust diff --git a/quest/m1/push-to-talk/hold-rs.md b/quest/m1/push-to-talk/hold-rs.md index c48c8cb6504..91826b13995 100644 --- a/quest/m1/push-to-talk/hold-rs.md +++ b/quest/m1/push-to-talk/hold-rs.md @@ -4,12 +4,13 @@ Every first-party Rust consumer keeps its selected rendition, and its subscription, while the publisher has it disabled and no enabled alternative -exists, as [@moq/watch does](/quest/m1/push-to-talk/hold-js.md). +exists, as `@moq/watch` does (`js/watch/src/audio/source.ts` and +`video/source.ts`, `#hold`). ## Plan Decided 2026-10-28 (maintainer): the hold applies in every first-party -consumer, with the same rule as the JS quest. Initial selection skips disabled +consumer, with the same rule as `@moq/watch`. Initial selection skips disabled renditions, an enabled alternative wins, and a removed rendition is dropped. - `rs/moq-mux/src/select.rs:93,121`: the selection filters require @@ -23,13 +24,11 @@ renditions, an enabled alternative wins, and a removed rendition is dropped. already expects a held listener to keep demand on a single audio rendition disabled below the codec floor. -The spec wording lands with whichever hold quest lands first. +The hang spec and catalog docs already say "should not select". -Tests: the JS quest's cases, in moq-mux select and moq-ffi. +Tests: `@moq/watch`'s cases (mute then unmute keeps one subscription, an +enabled alternative takes over, a rendition removed while held is dropped), in +moq-mux select and moq-ffi. Public API: moq-ffi returns a held disabled rendition where it returned `NotFound`. Wire: none. - -## Related - -- [JS consumers hold a disabled rendition](/quest/m1/push-to-talk/hold-js.md) - the same rule in JS diff --git a/quest/m3/ladder/README.md b/quest/m3/ladder/README.md index 024bdbec998..157e7ecaa47 100644 --- a/quest/m3/ladder/README.md +++ b/quest/m3/ladder/README.md @@ -20,7 +20,7 @@ publisher-side ladder. The catalog and player half is the rendition `enabled` flag, which replaced the `stalled` state shipped in [moq#2865](https://github.com/moq-dev/moq/pull/2865): -`enabled: false` means no frames are coming and a viewer must not select the +`enabled: false` means no frames are coming and a viewer should not select the rendition. Routing, decoder, and presentation identities are split so a metadata-only change cannot rebuild WebCodecs. diff --git a/rs/hang/src/catalog/audio/mod.rs b/rs/hang/src/catalog/audio/mod.rs index 49bdda97753..fe1e336918b 100644 --- a/rs/hang/src/catalog/audio/mod.rs +++ b/rs/hang/src/catalog/audio/mod.rs @@ -151,7 +151,8 @@ pub struct AudioConfig { pub bitrate: Option, /// Whether this rendition may be selected. When false, no frames are coming and a consumer - /// must not select it. Only written when false. + /// should not select it, though one may keep it selected while no enabled alternative exists. + /// Only written when false. #[serde( default = "crate::catalog::enabled_default", skip_serializing_if = "crate::catalog::enabled_skip" diff --git a/rs/hang/src/catalog/video/mod.rs b/rs/hang/src/catalog/video/mod.rs index 03693ae9eb5..a52a474a005 100644 --- a/rs/hang/src/catalog/video/mod.rs +++ b/rs/hang/src/catalog/video/mod.rs @@ -279,7 +279,8 @@ pub struct VideoConfig { pub bitrate: Option, /// Whether this rendition may be selected. When false, no frames are coming and a consumer - /// must not select it. Only written when false. + /// should not select it, though one may keep it selected while no enabled alternative exists. + /// Only written when false. #[serde( default = "crate::catalog::enabled_default", skip_serializing_if = "crate::catalog::enabled_skip" From 6fdd5935c0e400deda0d90eb7351a418f3e6bc41 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 21:41:32 -0700 Subject: [PATCH 3/4] fix(watch): don't hold a selection made from the previous broadcast's renditions On a broadcast switch, selection reran against the previous broadcast's probe result and recorded it as the new broadcast's held rendition, so a disabled same-ID rendition on the new broadcast was held. The probe now reads the catalog from the broadcast it tags, and a hold is recorded only when `available` belongs to the current broadcast. Co-Authored-By: Claude Opus 5.5 --- js/watch/src/audio/source.test.ts | 16 ++++++++++++++++ js/watch/src/audio/source.ts | 11 +++++++++-- js/watch/src/video/source.test.ts | 18 ++++++++++++++++++ js/watch/src/video/source.ts | 11 +++++++++-- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/js/watch/src/audio/source.test.ts b/js/watch/src/audio/source.test.ts index 4c2a19a11d9..e4b25e6be43 100644 --- a/js/watch/src/audio/source.test.ts +++ b/js/watch/src/audio/source.test.ts @@ -157,3 +157,19 @@ test("does not carry a hold to another broadcast", async () => { source.close(); } }); + +test("does not hold an enabled selection into another broadcast's disabled rendition", async () => { + const current = new Signal(broadcast({ mic: config("opus") }).broadcast); + const source = new Source({ broadcast: current, supported: async () => true }); + try { + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + + current.set(broadcast({ mic: config("opus", { enabled: false }) }).broadcast); + for (let i = 0; i < 5; i++) await new Promise((resolve) => setTimeout(resolve, 0)); + expect(source.out.track.peek()).toBeUndefined(); + expect(source.out.config.peek()).toBeUndefined(); + } finally { + source.close(); + } +}); diff --git a/js/watch/src/audio/source.ts b/js/watch/src/audio/source.ts index 80c9cc236e3..9c56b4960ff 100644 --- a/js/watch/src/audio/source.ts +++ b/js/watch/src/audio/source.ts @@ -63,6 +63,9 @@ export class Source { // The last selection, which a disable holds while no enabled rendition remains. #held?: { broadcast: Broadcast; track: string }; + // The broadcast `available` was probed for. It lags a broadcast switch until the new probe lands. + #probed?: Broadcast; + #signals = new Effect(); constructor(props?: Inputs) { @@ -88,7 +91,9 @@ export class Source { } #runSupported(effect: Effect): void { - const renditions = effect.get(this.#out.catalog)?.renditions ?? {}; + // Read the catalog from the broadcast itself, so the probe result is tagged with the right one. + const broadcast = effect.get(this.in.broadcast); + const renditions = (broadcast && effect.get(broadcast.out.catalog)?.audio?.renditions) ?? {}; const supported = effect.get(this.in.supported); if (!supported) return; @@ -121,6 +126,7 @@ export class Source { console.warn("no supported audio renditions found:", renditions); } + this.#probed = broadcast; this.#out.available.set(available); } finally { this.#pending.set(false); @@ -140,7 +146,8 @@ export class Source { target?.name && target.name in available ? target.name : (this.#select(available) ?? this.#hold(broadcast, all)); - this.#held = track && broadcast ? { broadcast, track } : undefined; + // A pick from the previous broadcast's renditions is not this broadcast's selection to hold. + this.#held = track && broadcast && this.#probed === broadcast ? { broadcast, track } : undefined; if (!track) return; const config = all[track]; diff --git a/js/watch/src/video/source.test.ts b/js/watch/src/video/source.test.ts index 1655ca89972..d5fa97a44c1 100644 --- a/js/watch/src/video/source.test.ts +++ b/js/watch/src/video/source.test.ts @@ -297,6 +297,24 @@ describe("Source disabled rendition selection", () => { source.close(); }); + it("does not hold an enabled selection into another broadcast's disabled rendition", async () => { + const current = new Signal( + mutableBroadcast({ high: config("avc1.640028", { bitrate: 2_000_000 }) }).broadcast, + ); + const source = new Source({ broadcast: current, supported: async () => true }); + + await settle(); + expect(source.out.track.peek()).toBe("high"); + + current.set( + mutableBroadcast({ high: config("avc1.640028", { bitrate: 2_000_000, enabled: false }) }).broadcast, + ); + await settle(); + expect(source.out.track.peek()).toBeUndefined(); + expect(source.out.config.peek()).toBeUndefined(); + source.close(); + }); + it("ignores a legacy stalled flag", async () => { const source = new Source({ broadcast: mockBroadcast({ diff --git a/js/watch/src/video/source.ts b/js/watch/src/video/source.ts index 5844d14be56..fbdf06c5da3 100644 --- a/js/watch/src/video/source.ts +++ b/js/watch/src/video/source.ts @@ -223,6 +223,9 @@ export class Source { // The last selection, which a disable holds while no enabled rendition remains. #held?: { broadcast: Broadcast; track: string }; + // The broadcast `available` was probed for. It lags a broadcast switch until the new probe lands. + #probed?: Broadcast; + #signals = new Effect(); #supportCache = new WeakMap>(); @@ -256,7 +259,9 @@ export class Source { return; } - const renditions = effect.get(this.#out.catalog)?.renditions ?? {}; + // Read the catalog from the broadcast itself, so the probe result is tagged with the right one. + const broadcast = effect.get(this.in.broadcast); + const renditions = (broadcast && effect.get(broadcast.out.catalog)?.video?.renditions) ?? {}; this.#out.error.set(undefined); let cache = this.#supportCache.get(supported); if (!cache) { @@ -312,6 +317,7 @@ export class Source { } else { this.#out.error.set(undefined); } + this.#probed = broadcast; this.#out.available.set(available); this.#pending.set(false); }); @@ -324,7 +330,8 @@ export class Source { const target = effect.get(this.in.target); const selected = this.#choose(effect, available, target) ?? this.#hold(broadcast, all); - this.#held = selected && broadcast ? { broadcast, track: selected } : undefined; + // A pick from the previous broadcast's renditions is not this broadcast's selection to hold. + this.#held = selected && broadcast && this.#probed === broadcast ? { broadcast, track: selected } : undefined; if (!selected) return; effect.set(this.#out.track, selected); From e232d20cad9620f71831fa3e2544210d587043ef Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 21:52:43 -0700 Subject: [PATCH 4/4] fix(watch): rerun selection when the probed broadcast changes A switch between broadcasts with identical renditions publishes an equal `available`, which the signal dedupes, so selection never reran with the new broadcast's tag and the hold was never recorded. The probed broadcast is now a signal that selection reads. Co-Authored-By: Claude Opus 5.5 --- js/watch/src/audio/source.test.ts | 21 +++++++++++++++++++++ js/watch/src/audio/source.ts | 8 +++++--- js/watch/src/video/source.test.ts | 22 ++++++++++++++++++++++ js/watch/src/video/source.ts | 8 +++++--- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/js/watch/src/audio/source.test.ts b/js/watch/src/audio/source.test.ts index e4b25e6be43..d67b979bc60 100644 --- a/js/watch/src/audio/source.test.ts +++ b/js/watch/src/audio/source.test.ts @@ -173,3 +173,24 @@ test("does not hold an enabled selection into another broadcast's disabled rendi source.close(); } }); + +test("holds on a broadcast whose renditions match the previous one", async () => { + const current = new Signal(broadcast({ mic: config("opus") }).broadcast); + const source = new Source({ broadcast: current, supported: async () => true }); + try { + await settled(source); + + // The new probe publishes an equal `available`, so only its broadcast tag changes. + const next = broadcast({ mic: config("opus") }); + current.set(next.broadcast); + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + + next.catalog.set({ audio: { renditions: { mic: config("opus", { enabled: false }) } } }); + await settled(source); + expect(source.out.track.peek()).toBe("mic"); + expect(source.out.config.peek()?.enabled).toBe(false); + } finally { + source.close(); + } +}); diff --git a/js/watch/src/audio/source.ts b/js/watch/src/audio/source.ts index 9c56b4960ff..901476fedd0 100644 --- a/js/watch/src/audio/source.ts +++ b/js/watch/src/audio/source.ts @@ -64,7 +64,8 @@ export class Source { #held?: { broadcast: Broadcast; track: string }; // The broadcast `available` was probed for. It lags a broadcast switch until the new probe lands. - #probed?: Broadcast; + // A signal, since the new broadcast's renditions can equal the old ones and leave `available` unchanged. + #probed = new Signal(undefined); #signals = new Effect(); @@ -126,7 +127,7 @@ export class Source { console.warn("no supported audio renditions found:", renditions); } - this.#probed = broadcast; + this.#probed.set(broadcast); this.#out.available.set(available); } finally { this.#pending.set(false); @@ -137,6 +138,7 @@ export class Source { #runSelected(effect: Effect): void { const broadcast = effect.get(this.in.broadcast); const all = effect.get(this.#out.available); + const probed = effect.get(this.#probed); const target = effect.get(this.in.target); // A disabled rendition has no frames coming, so it is never newly selected, even by name. @@ -147,7 +149,7 @@ export class Source { ? target.name : (this.#select(available) ?? this.#hold(broadcast, all)); // A pick from the previous broadcast's renditions is not this broadcast's selection to hold. - this.#held = track && broadcast && this.#probed === broadcast ? { broadcast, track } : undefined; + this.#held = track && broadcast && probed === broadcast ? { broadcast, track } : undefined; if (!track) return; const config = all[track]; diff --git a/js/watch/src/video/source.test.ts b/js/watch/src/video/source.test.ts index d5fa97a44c1..960a0598abc 100644 --- a/js/watch/src/video/source.test.ts +++ b/js/watch/src/video/source.test.ts @@ -315,6 +315,28 @@ describe("Source disabled rendition selection", () => { source.close(); }); + it("holds on a broadcast whose renditions match the previous one", async () => { + const current = new Signal( + mutableBroadcast({ high: config("avc1.640028", { bitrate: 2_000_000 }) }).broadcast, + ); + const source = new Source({ broadcast: current, supported: async () => true }); + await settle(); + + // The new probe publishes an equal `available`, so only its broadcast tag changes. + const next = mutableBroadcast({ high: config("avc1.640028", { bitrate: 2_000_000 }) }); + current.set(next.broadcast); + await settle(); + expect(source.out.track.peek()).toBe("high"); + + next.catalog.set({ + video: { renditions: { high: config("avc1.640028", { bitrate: 2_000_000, enabled: false }) } }, + }); + await settle(); + expect(source.out.track.peek()).toBe("high"); + expect(source.out.config.peek()?.enabled).toBe(false); + source.close(); + }); + it("ignores a legacy stalled flag", async () => { const source = new Source({ broadcast: mockBroadcast({ diff --git a/js/watch/src/video/source.ts b/js/watch/src/video/source.ts index fbdf06c5da3..6ddbf1922c3 100644 --- a/js/watch/src/video/source.ts +++ b/js/watch/src/video/source.ts @@ -224,7 +224,8 @@ export class Source { #held?: { broadcast: Broadcast; track: string }; // The broadcast `available` was probed for. It lags a broadcast switch until the new probe lands. - #probed?: Broadcast; + // A signal, since the new broadcast's renditions can equal the old ones and leave `available` unchanged. + #probed = new Signal(undefined); #signals = new Effect(); #supportCache = new WeakMap>(); @@ -317,7 +318,7 @@ export class Source { } else { this.#out.error.set(undefined); } - this.#probed = broadcast; + this.#probed.set(broadcast); this.#out.available.set(available); this.#pending.set(false); }); @@ -326,12 +327,13 @@ export class Source { #runSelected(effect: Effect): void { const broadcast = effect.get(this.in.broadcast); const all = effect.get(this.#out.available); + const probed = effect.get(this.#probed); const available = enabledRenditions(all); const target = effect.get(this.in.target); const selected = this.#choose(effect, available, target) ?? this.#hold(broadcast, all); // A pick from the previous broadcast's renditions is not this broadcast's selection to hold. - this.#held = selected && broadcast && this.#probed === broadcast ? { broadcast, track: selected } : undefined; + this.#held = selected && broadcast && probed === broadcast ? { broadcast, track: selected } : undefined; if (!selected) return; effect.set(this.#out.track, selected);