diff --git a/.agents/plans/moq-engine-implementation.md b/.agents/plans/moq-engine-implementation.md index f4792bd739..2e7d97ebd4 100644 --- a/.agents/plans/moq-engine-implementation.md +++ b/.agents/plans/moq-engine-implementation.md @@ -9,7 +9,7 @@ plan, and what Phase 0/5 still owes. | Plan item | Status | Where | |---|---|---| | §5 type-model change | ✅ | `media/types` — `TrackDeliveryMode` + `LiveOf` (extends `PartiallyResolved`, zero HLS ripple; audit confirmed selection reads only metadata) | -| Phase 1 wire protocol | ✅ | `network/moqt/` — vi64 varint, control messages, request streams, object streams, session driver; 51 tests incl. spec Table 2 golden vectors | +| Phase 1 wire protocol | ✅ | Was `network/moqt/` (vi64 varint, control messages, request streams, object streams, session driver; 51 tests incl. spec Table 2 golden vectors). Since 2026-10-27 the player uses `@caprid/moq-core`, the package extracted from it | | Phase 2 format layer | ✅ | `media/moq/` — parse-source (msf: fragment), parse-catalog (independent + delta), loc, codec-mapping, timeline; 46 tests | | Phase 3 actors/behaviors | ✅ | `playback/actors/{moq-session,track-subscriber}`, `playback/actors/dom/{video,audio}-renderer`, `playback/behaviors/{setup-moq-session,resolve-catalog,subscribe-selected-tracks,sync-latency,track-moq-bandwidth}`, `behaviors/dom/setup-moq-renderers` | | Phase 4 engine + adapter | ✅ | `playback/engines/moq/` — `createMoqEngine`, `MoqMediaMixin` (canvas facade, §6 prototype 1), `./moq` export, `--moq` size flag | @@ -24,9 +24,10 @@ Size baseline (2026-07-17): MoQ entry 18.16 KB min+gzip (90.8% of the Implemented against the actual spec texts (fetched 2026-07-17): `draft-ietf-moq-transport-19`, `draft-ietf-moq-msf-01`, `draft-ietf-moq-loc-02` (LOC moved to loc-04 in PR #9). The spec texts are -now vendored under `internal/specs/moq/` (transport-20, loc-04, msf-01 as of -2026-09-02); the draft-20 migration plan is `moq-transport-20-migration.md` -beside this file. Notable corrections to the plan's assumptions: +now vendored under `internal/specs/moq/` (transport-22, loc-04, msf-01 as of +2026-10-27); the draft-20 migration plan is `moq-transport-20-migration.md` +beside this file, and the transport codec now comes from `@caprid/moq-core` +(moqt-22, falling back to moqt-20). Notable corrections to the plan's assumptions: - **Varint is NOT the QUIC RFC 9000 varint.** Draft-15+ uses a leading-ones vi64 (1–9 bytes). Spec Table 2 vectors are test fixtures. @@ -151,7 +152,7 @@ promotion). Zero page errors. draft-19 bytes (vi64, SETUP/SUBSCRIBE_OK/REQUEST_ERROR, subgroup + LOC framing) over an in-memory `MoqtTransport`, publishing real WebCodecs-encoded VP8 (two renditions) + Opus. Written from the specs - rather than reusing `network/moqt`'s encoders: it is a second + rather than reusing the transport codec: it is a second independent implementation, so it checks the decoder rather than round-tripping against ourselves. `?relay=moqt://…#msf:…` swaps in a real relay. diff --git a/.agents/plans/moq-transport-20-migration.md b/.agents/plans/moq-transport-20-migration.md index 5221199b5e..9eb1f1fc5d 100644 --- a/.agents/plans/moq-transport-20-migration.md +++ b/.agents/plans/moq-transport-20-migration.md @@ -18,6 +18,13 @@ the spec text is ambiguous, and calls out each place it does. Temporary implementation notes — delete before merge per `AGENTS.md`. +**Superseded on the player (2026-10-27):** `mmcc/moq` now takes its transport +from `@caprid/moq-core`, which was extracted from `network/moqt/`. It offers +`moqt-22` first and falls back to `moqt-20`. The local modules this plan +names, and the vendored draft-20 text, are gone. `internal/specs/moq/` now +carries draft-22. Section numbers below are draft-20's. The publisher still +runs the local codec until its own move. + **Issue #45 verification (2026-09-16, moq-relay 0.14.17):** the shared codec uses bare Locations in both directions. Fixed-byte tests pin SUBSCRIBE_OK, REQUEST_OK, multi-byte IDs, following parameters/properties, and truncation. diff --git a/apps/sandbox/templates/moq-relay-interop/main.ts b/apps/sandbox/templates/moq-relay-interop/main.ts index ad0019094e..f0c7177fbf 100644 --- a/apps/sandbox/templates/moq-relay-interop/main.ts +++ b/apps/sandbox/templates/moq-relay-interop/main.ts @@ -1,4 +1,4 @@ -// MoQ (draft-ietf-moq-transport-20 / MSF) relay interop smoke test. +// MoQ (draft-ietf-moq-transport-22 / MSF) relay interop smoke test. // http://localhost:5173/moq-relay-interop/ // // Query params: diff --git a/apps/sandbox/templates/spf-moq-player/loopback-relay.ts b/apps/sandbox/templates/spf-moq-player/loopback-relay.ts index 72d209ceb6..c9367107c1 100644 --- a/apps/sandbox/templates/spf-moq-player/loopback-relay.ts +++ b/apps/sandbox/templates/spf-moq-player/loopback-relay.ts @@ -2,12 +2,12 @@ * Loopback MoQ relay — a synthetic MSF publisher for the sandbox. * * There is no public relay that serves draft-ietf-moq-msf-01 catalogs yet (Phase 0 interop is still owed), so this - * stands in for one: it speaks real draft-20 bytes over an in-memory `MoqtTransport` and publishes real + * stands in for one: it speaks real draft-22 bytes over an in-memory `MoqtTransport` and publishes real * WebCodecs-encoded media, which is enough to drive the whole engine — catalog → selection → subscribe → decode → * canvas + AudioContext. * - * The wire encoding here is written from the specs rather than reusing `network/moqt`'s encoders (they aren't public - * API, and a second independent implementation is worth more as a check on the decoder than a round-trip against + * The wire encoding here is written from the specs rather than reusing `@caprid/moq-core`'s encoders (they aren't + * public API, and a second independent implementation is worth more as a check on the decoder than a round-trip against * ourselves would be). * * Published tracks (subscribe lazily starts a producer per subscription): @@ -19,10 +19,10 @@ import type { CreateMoqTransport } from '@videojs/spf/moq'; // ============================================================================ -// Wire primitives (draft-ietf-moq-transport-20) +// Wire primitives (draft-ietf-moq-transport-22) // ============================================================================ -/** Control/request message types (§10, Table 5). */ +/** Control/request message types (§9, Table 5). */ const MESSAGE_TYPE = { SETUP: 0x2f00, SUBSCRIBE: 0x3, @@ -31,12 +31,12 @@ const MESSAGE_TYPE = { FETCH: 0x16, } as const; -/** REQUEST_ERROR code for "nothing published in that range" (§10.6.1). */ +/** REQUEST_ERROR code for "nothing published in that range" (§12.3). */ const ERROR_INVALID_RANGE = 0x11; /** * SUBGROUP_HEADER stream type: subgroup-id mode `zero`, default publisher priority, objects carry a Properties field, - * not end-of-group. `0b0011_0001` — see §11.4.2 for the flag layout. + * not end-of-group. `0b0011_0001` — see §11.3.1 for the flag layout. */ const SUBGROUP_HEADER_TYPE = 0x31; @@ -44,8 +44,8 @@ const SUBGROUP_HEADER_TYPE = 0x31; const LOC_TIMESTAMP = 0x10; /** - * The vi64 varint of draft-15+ (§1.4.1) — leading ones on the first byte give the encoded length minus one, so an - * L-byte encoding carries 7L value bits. NOT the QUIC RFC 9000 varint. + * The vi64 varint of draft-15+ (§8.1) — leading ones on the first byte give the encoded length minus one, so an L-byte + * encoding carries 7L value bits. NOT the QUIC RFC 9000 varint. */ function varintByteLength(value: number): number { for (let length = 1; length < 8; length++) { @@ -144,14 +144,14 @@ class Reader { } } -/** Control message framing (§10.1): type varint + 16-bit length + body. */ +/** Control message framing (§9): type varint + 16-bit length + body. */ function frame(type: number, body: Uint8Array): Uint8Array { return new Writer().varint(type).u16(body.length).bytes(body).toBytes(); } function encodeSetup(): Uint8Array { // Options-only, and we send none. A Key-Value-Pair block is bounded by its - // enclosing length rather than counted (§10.2), so "no options" is an empty + // enclosing length rather than counted (§9.1), so "no options" is an empty // body — not a zero count. return frame(MESSAGE_TYPE.SETUP, new Uint8Array(0)); } @@ -574,7 +574,7 @@ export function createLoopbackRelay({ onLog }: LoopbackRelayOptions = {}): Loopb const host: ProducerHost = { nowUs, publish: publishObject, log }; /** - * The server's control stream. It stays open for the session's lifetime — closing it ends the session (§3.3) — so + * The server's control stream. It stays open for the session's lifetime — closing it ends the session (§6.3) — so * the writer is held until this transport closes. */ const sendServerSetup = (): void => { @@ -672,7 +672,7 @@ export function createLoopbackRelay({ onLog }: LoopbackRelayOptions = {}): Loopb if (message.type === MESSAGE_TYPE.SUBSCRIBE) { onSubscribe(message.body); } else if (message.type === MESSAGE_TYPE.FETCH) { - // The engine never fetches — a draft-20 join is a subscription + // The engine never fetches — a draft-22 join is a subscription // filter, and every subscription replays the newest group anyway. // Anything else asking for history is refused: none is retained. await writer.write(encodeRequestError(ERROR_INVALID_RANGE, 'nothing published')); @@ -684,7 +684,7 @@ export function createLoopbackRelay({ onLog }: LoopbackRelayOptions = {}): Loopb } const { value, done } = await reader.read(); - // Cancellation *is* the stream lifecycle (§3.3.3): the subscriber + // Cancellation *is* the stream lifecycle (§6.4.2.3): the subscriber // aborting its sending direction ends the subscription. if (done) break; diff --git a/internal/specs/moq/README.md b/internal/specs/moq/README.md index 59ca669a0e..97e87d8550 100644 --- a/internal/specs/moq/README.md +++ b/internal/specs/moq/README.md @@ -4,21 +4,21 @@ Verbatim IETF Internet-Draft texts for the protocols the MoQ stack in `packages/ For a complete catalog example and the current player's media requirements, see [Publish a stream for the MoQ player](../../../packages/spf/docs/moq-publishing.md). -The version the code actually speaks is declared in code: `MOQT_PROTOCOL_ID` in `packages/spf/src/network/moqt/control-messages.ts` for the transport, and the header comments of `packages/spf/src/media/moq/loc.ts` and `parse-catalog.ts` for LOC and MSF. When the vendored text is newer than the code pin, the gap is tracked by a migration plan under `.agents/plans/`. +The version the code actually speaks is declared in code: the transport comes from the `@caprid/moq-core` dependency of `packages/spf` (its `MOQT_PROTOCOL_IDS` lists the versions the player offers, most preferred first; `moqt-20` is the fallback), and the header comments of `packages/spf/src/media/moq/loc.ts` and `parse-catalog.ts` for LOC and MSF. When the vendored text is newer than the code pin, the gap is tracked by a migration plan under `.agents/plans/`. | Draft | Revision | Published | Implemented in | | --- | --- | --- | --- | -| Media over QUIC Transport | `draft-ietf-moq-transport-20` | 2026-08-31 | `packages/spf/src/network/moqt/` | +| Media over QUIC Transport | `draft-ietf-moq-transport-22` | 2026-10-01 | `@caprid/moq-core`, consumed by `packages/spf/src/playback/actors/moq-session.ts` | | Low Overhead Media Container (LOC) | `draft-ietf-moq-loc-04` | 2026-07-20 | `packages/spf/src/media/moq/loc.ts` | | MOQT Streaming Format (MSF) | `draft-ietf-moq-msf-01` | 2026-06-02 | `packages/spf/src/media/moq/parse-catalog.ts`, `parse-source.ts` | ## Provenance -Fetched 2026-09-02 from the IETF archive at `https://www.ietf.org/archive/id/.txt`, unmodified. +Fetched from the IETF archive at `https://www.ietf.org/archive/id/.txt`, unmodified: the transport draft on 2026-10-27, LOC and MSF on 2026-09-02. | File | SHA-256 | | --- | --- | -| `draft-ietf-moq-transport-20.txt` | `96a3a4467da53cd71bb4d1c334ac7ab13887f02b2e27335e715f75889fa9a1c6` | +| `draft-ietf-moq-transport-22.txt` | `1a725f10db526d94f915b30db9004821d86e57afcdde10789c54fee64b3056b5` | | `draft-ietf-moq-loc-04.txt` | `fb29e2805be0511a188683b60fc830fb7fd3ecf19931968755d60d83707c3b47` | | `draft-ietf-moq-msf-01.txt` | `c3e68aac09c36ae1db4afde6fd0600a949e7265348f592520304a31e993c35af` | diff --git a/internal/specs/moq/draft-ietf-moq-transport-20.txt b/internal/specs/moq/draft-ietf-moq-transport-22.txt similarity index 67% rename from internal/specs/moq/draft-ietf-moq-transport-20.txt rename to internal/specs/moq/draft-ietf-moq-transport-22.txt index 866fe4947d..9ce54051de 100644 --- a/internal/specs/moq/draft-ietf-moq-transport-20.txt +++ b/internal/specs/moq/draft-ietf-moq-transport-22.txt @@ -5,15 +5,15 @@ Media Over QUIC S. Nandakumar Internet-Draft Cisco Intended status: Standards Track V. Vasiliev -Expires: 4 March 2027 I. Swett, Ed. +Expires: 4 April 2027 I. Swett, Ed. Google A. Frindell, Ed. Meta - 31 August 2026 + 1 October 2026 Media over QUIC Transport - draft-ietf-moq-transport-20 + draft-ietf-moq-transport-22 Abstract @@ -53,9 +53,9 @@ Status of This Memo -Nandakumar, et al. Expires 4 March 2027 [Page 1] +Nandakumar, et al. Expires 4 April 2027 [Page 1] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 Internet-Drafts are working documents of the Internet Engineering @@ -68,7 +68,7 @@ Internet-Draft moq-transport August 2026 time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on 4 March 2027. + This Internet-Draft will expire on 4 April 2027. Copyright Notice @@ -87,256 +87,283 @@ Copyright Notice Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 7 - 1.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . 7 - 1.1.1. Latency . . . . . . . . . . . . . . . . . . . . . . . 7 - 1.1.2. Leveraging QUIC . . . . . . . . . . . . . . . . . . . 8 - 1.1.3. Convergence . . . . . . . . . . . . . . . . . . . . . 8 - 1.1.4. Relays . . . . . . . . . . . . . . . . . . . . . . . 8 - 1.2. Terms and Definitions . . . . . . . . . . . . . . . . . . 8 - 1.3. Stream Management Terms . . . . . . . . . . . . . . . . . 10 - 1.4. Notational Conventions . . . . . . . . . . . . . . . . . 10 - 1.4.1. Variable-Length Integers . . . . . . . . . . . . . . 10 - 1.4.2. Location Structure . . . . . . . . . . . . . . . . . 12 - 1.4.3. Key-Value-Pair Structure . . . . . . . . . . . . . . 12 - 1.4.4. Reason Phrase Structure . . . . . . . . . . . . . . . 13 - 1.5. Representing Namespace and Track Names . . . . . . . . . 14 - 1.5.1. Parsing Serialized Names . . . . . . . . . . . . . . 14 - 2. Object Data Model . . . . . . . . . . . . . . . . . . . . . . 15 - 2.1. Objects . . . . . . . . . . . . . . . . . . . . . . . . . 15 - 2.2. Subgroups . . . . . . . . . . . . . . . . . . . . . . . . 16 - 2.3. Groups . . . . . . . . . . . . . . . . . . . . . . . . . 18 - 2.3.1. Group IDs . . . . . . . . . . . . . . . . . . . . . . 18 - - - -Nandakumar, et al. Expires 4 March 2027 [Page 2] - -Internet-Draft moq-transport August 2026 - - - 2.4. Track . . . . . . . . . . . . . . . . . . . . . . . . . . 18 - 2.4.1. Track Naming . . . . . . . . . . . . . . . . . . . . 19 - 2.4.2. Malformed Tracks . . . . . . . . . . . . . . . . . . 20 - 2.4.3. Scope . . . . . . . . . . . . . . . . . . . . . . . . 21 - 2.5. Properties . . . . . . . . . . . . . . . . . . . . . . . 22 - 2.5.1. Mandatory Track Properties . . . . . . . . . . . . . 23 - 3. Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . 24 - 3.1. Session establishment . . . . . . . . . . . . . . . . . . 24 - 3.1.1. MOQT URI Scheme . . . . . . . . . . . . . . . . . . . 25 - 3.1.2. Fragment Identifiers . . . . . . . . . . . . . . . . 25 - 3.1.3. Dereferencing a MOQT URI . . . . . . . . . . . . . . 26 - 3.1.4. WebTransport . . . . . . . . . . . . . . . . . . . . 27 - 3.1.5. Native QUIC . . . . . . . . . . . . . . . . . . . . . 27 - 3.1.6. Connection URL . . . . . . . . . . . . . . . . . . . 27 - 3.2. Extension Negotiation . . . . . . . . . . . . . . . . . . 27 - 3.2.1. Reserved Namespaces . . . . . . . . . . . . . . . . . 28 - 3.2.2. Session-Level Tracks and Namespaces . . . . . . . . . 28 - 3.3. Session initialization . . . . . . . . . . . . . . . . . 29 - 3.3.1. 0-RTT . . . . . . . . . . . . . . . . . . . . . . . . 30 - 3.3.2. Graceful Request Stream Closure . . . . . . . . . . . 31 - 3.3.3. Request Cancellation and Rejection . . . . . . . . . 31 - 3.3.4. Stream Reset Error Codes . . . . . . . . . . . . . . 32 - 3.4. Unidirectional Stream Types . . . . . . . . . . . . . . . 32 - 3.5. Termination . . . . . . . . . . . . . . . . . . . . . . . 33 - 3.6. Session Migration . . . . . . . . . . . . . . . . . . . . 35 - 3.7. Congestion Control . . . . . . . . . . . . . . . . . . . 35 - 3.7.1. Bufferbloat . . . . . . . . . . . . . . . . . . . . . 36 - 3.7.2. Application-Limited . . . . . . . . . . . . . . . . . 36 - 3.7.3. Consistent Throughput . . . . . . . . . . . . . . . . 36 - 4. Extensibility . . . . . . . . . . . . . . . . . . . . . . . . 37 - 5. Publishing and Retrieving Tracks . . . . . . . . . . . . . . 37 - 5.1. Subscriptions . . . . . . . . . . . . . . . . . . . . . . 37 - 5.1.1. Subscription State Management . . . . . . . . . . . . 39 - 5.1.2. Location Filters . . . . . . . . . . . . . . . . . . 40 - 5.1.3. Fill Semantics . . . . . . . . . . . . . . . . . . . 42 - 5.1.4. Range Filters . . . . . . . . . . . . . . . . . . . . 43 - 5.1.5. Combining Filters . . . . . . . . . . . . . . . . . . 46 - 5.1.6. Joining an Ongoing Track . . . . . . . . . . . . . . 46 - 5.2. Fetch State Management . . . . . . . . . . . . . . . . . 47 - 6. Namespace Discovery . . . . . . . . . . . . . . . . . . . . . 47 - 6.1. Subscribing to Namespaces . . . . . . . . . . . . . . . . 48 - 6.2. Publishing Namespaces . . . . . . . . . . . . . . . . . . 49 - 6.3. Filtering SUBSCRIBE_TRACKS . . . . . . . . . . . . . . . 50 - 6.3.1. Relay Resource Protection in Large Namespaces . . . . 50 - 7. Priorities . . . . . . . . . . . . . . . . . . . . . . . . . 50 - 7.1. Definitions . . . . . . . . . . . . . . . . . . . . . . . 51 - 7.2. Scheduling Algorithm . . . . . . . . . . . . . . . . . . 52 - 7.3. Considerations for Setting Priorities . . . . . . . . . . 53 - - - -Nandakumar, et al. Expires 4 March 2027 [Page 3] - -Internet-Draft moq-transport August 2026 - - - 8. Delivery Timeouts and Data Reliability . . . . . . . . . . . 54 - 9. Relays . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 - 9.1. Caching Relays . . . . . . . . . . . . . . . . . . . . . 56 - 9.2. Forward Handling . . . . . . . . . . . . . . . . . . . . 56 - 9.3. Multiple Publishers . . . . . . . . . . . . . . . . . . . 57 - 9.4. Subscriber Interactions . . . . . . . . . . . . . . . . . 57 - 9.4.1. Graceful Subscriber Relay Switchover . . . . . . . . 58 - 9.5. Publisher Interactions . . . . . . . . . . . . . . . . . 59 - 9.5.1. Graceful Publisher Relay Switchover . . . . . . . . . 61 - 9.6. Relay Track Handling . . . . . . . . . . . . . . . . . . 61 - 9.7. Relay Object Handling . . . . . . . . . . . . . . . . . . 61 - 10. Control Messages . . . . . . . . . . . . . . . . . . . . . . 61 - 10.1. Request ID . . . . . . . . . . . . . . . . . . . . . . . 63 - 10.2. Message Parameters . . . . . . . . . . . . . . . . . . . 63 - 10.2.1. Parameter Scope . . . . . . . . . . . . . . . . . . 65 - 10.2.2. AUTHORIZATION TOKEN Parameter . . . . . . . . . . . 65 - 10.2.3. SUBGROUP_DELIVERY_TIMEOUT Parameter . . . . . . . . 68 - 10.2.4. OBJECT_DELIVERY_TIMEOUT Parameter . . . . . . . . . 68 - 10.2.5. FILL TIMEOUT Parameter . . . . . . . . . . . . . . . 68 - 10.2.6. RENDEZVOUS TIMEOUT Parameter . . . . . . . . . . . . 69 - 10.2.7. SUBSCRIBER PRIORITY Parameter . . . . . . . . . . . 69 - 10.2.8. GROUP ORDER Parameter . . . . . . . . . . . . . . . 70 - 10.2.9. LOCATION FILTER Parameter . . . . . . . . . . . . . 70 - 10.2.10. SUBGROUP FILTER Parameter . . . . . . . . . . . . . 70 - 10.2.11. OBJECTID FILTER Parameter . . . . . . . . . . . . . 70 - 10.2.12. PRIORITY FILTER Parameter . . . . . . . . . . . . . 70 - 10.2.13. OBJECT PROPERTY FILTER Parameter . . . . . . . . . . 71 - 10.2.14. TRACK PROPERTY FILTER Parameter . . . . . . . . . . 71 - 10.2.15. FILL PARAMETERS Parameter . . . . . . . . . . . . . 71 - 10.2.16. EXPIRES Parameter . . . . . . . . . . . . . . . . . 73 - 10.2.17. LARGEST OBJECT Parameter . . . . . . . . . . . . . . 73 - 10.2.18. FORWARD Parameter . . . . . . . . . . . . . . . . . 74 - 10.2.19. NEW GROUP REQUEST Parameter . . . . . . . . . . . . 74 - 10.2.20. TRACK_NAMESPACE_PREFIX Parameter . . . . . . . . . . 75 - 10.2.21. INCLUDE_PROPERTIES Parameter . . . . . . . . . . . . 75 - 10.3. SETUP . . . . . . . . . . . . . . . . . . . . . . . . . 76 - 10.3.1. Setup Options . . . . . . . . . . . . . . . . . . . 76 - 10.4. GOAWAY . . . . . . . . . . . . . . . . . . . . . . . . . 79 - 10.5. REQUEST_OK . . . . . . . . . . . . . . . . . . . . . . . 80 - 10.6. REQUEST_ERROR . . . . . . . . . . . . . . . . . . . . . 81 - 10.6.1. Redirect Structure . . . . . . . . . . . . . . . . . 81 - 10.6.2. REQUEST_ERROR Message Format . . . . . . . . . . . . 82 - 10.7. SUBSCRIBE . . . . . . . . . . . . . . . . . . . . . . . 84 - 10.8. SUBSCRIBE_OK . . . . . . . . . . . . . . . . . . . . . . 85 - 10.9. REQUEST_UPDATE . . . . . . . . . . . . . . . . . . . . . 86 - 10.9.1. Updating Subscriptions . . . . . . . . . . . . . . . 87 - 10.9.2. Updating Namespace Subscriptions . . . . . . . . . . 87 - 10.10. PUBLISH_STATE_NOTIFY . . . . . . . . . . . . . . . . . . 88 - - - -Nandakumar, et al. Expires 4 March 2027 [Page 4] - -Internet-Draft moq-transport August 2026 - - - 10.11. PUBLISH . . . . . . . . . . . . . . . . . . . . . . . . 89 - 10.12. PUBLISH_DONE . . . . . . . . . . . . . . . . . . . . . . 90 - 10.13. FETCH . . . . . . . . . . . . . . . . . . . . . . . . . 92 - 10.14. FETCH_OK . . . . . . . . . . . . . . . . . . . . . . . . 94 - 10.15. TRACK_STATUS . . . . . . . . . . . . . . . . . . . . . . 95 - 10.16. PUBLISH_NAMESPACE . . . . . . . . . . . . . . . . . . . 95 - 10.17. NAMESPACE . . . . . . . . . . . . . . . . . . . . . . . 96 - 10.18. NAMESPACE_DONE . . . . . . . . . . . . . . . . . . . . . 96 - 10.19. SUBSCRIBE_NAMESPACE . . . . . . . . . . . . . . . . . . 96 - 10.20. SUBSCRIBE_TRACKS . . . . . . . . . . . . . . . . . . . . 98 - 10.20.1. Parameters on SUBSCRIBE_TRACKS . . . . . . . . . . 99 - 10.21. PUBLISH_SKIPPED . . . . . . . . . . . . . . . . . . . . 99 - 11. Data Streams and Datagrams . . . . . . . . . . . . . . . . . 100 - 11.1. Track Alias . . . . . . . . . . . . . . . . . . . . . . 100 - 11.2. Objects . . . . . . . . . . . . . . . . . . . . . . . . 101 - 11.2.1. Object Header . . . . . . . . . . . . . . . . . . . 101 - 11.3. Datagrams . . . . . . . . . . . . . . . . . . . . . . . 103 - 11.3.1. Object Datagram . . . . . . . . . . . . . . . . . . 104 - 11.4. Streams . . . . . . . . . . . . . . . . . . . . . . . . 105 - 11.4.1. Stream Cancellation . . . . . . . . . . . . . . . . 106 - 11.4.2. Subgroup Header . . . . . . . . . . . . . . . . . . 106 - 11.4.3. Closing Subgroup Streams . . . . . . . . . . . . . . 108 - 11.4.4. Fetch Header . . . . . . . . . . . . . . . . . . . . 111 - 11.5. Padding . . . . . . . . . . . . . . . . . . . . . . . . 114 - 11.5.1. Padding Streams . . . . . . . . . . . . . . . . . . 115 - 11.5.2. Padding Datagrams . . . . . . . . . . . . . . . . . 115 - 11.6. Examples . . . . . . . . . . . . . . . . . . . . . . . . 115 - 12. MOQT Properties . . . . . . . . . . . . . . . . . . . . . . . 117 - 12.1. SUBGROUP_DELIVERY_TIMEOUT . . . . . . . . . . . . . . . 117 - 12.2. OBJECT_DELIVERY_TIMEOUT . . . . . . . . . . . . . . . . 118 - 12.3. MAX CACHE DURATION . . . . . . . . . . . . . . . . . . . 118 - 12.4. DEFAULT PUBLISHER PRIORITY . . . . . . . . . . . . . . . 118 - 12.5. DEFAULT PUBLISHER GROUP ORDER . . . . . . . . . . . . . 118 - 12.6. DYNAMIC GROUPS . . . . . . . . . . . . . . . . . . . . . 119 - 12.7. Immutable Properties . . . . . . . . . . . . . . . . . . 119 - 12.8. Prior Group ID Gap . . . . . . . . . . . . . . . . . . . 120 - 12.9. Prior Object ID Gap . . . . . . . . . . . . . . . . . . 121 - 13. Security Considerations . . . . . . . . . . . . . . . . . . . 122 - 13.1. Subscription Amplification . . . . . . . . . . . . . . . 122 - 13.2. Communication Security . . . . . . . . . . . . . . . . . 122 - 13.3. Authorization . . . . . . . . . . . . . . . . . . . . . 123 - 13.3.1. Mutual TLS . . . . . . . . . . . . . . . . . . . . . 123 - 13.3.2. Replay Attacks . . . . . . . . . . . . . . . . . . . 123 - 13.3.3. Preventing Impersonation . . . . . . . . . . . . . . 124 - 13.4. Media Security . . . . . . . . . . . . . . . . . . . . . 124 - 13.5. Resource Exhaustion . . . . . . . . . . . . . . . . . . 125 - 13.6. Timeouts . . . . . . . . . . . . . . . . . . . . . . . . 125 - 13.6.1. Idle Connection Handling . . . . . . . . . . . . . . 125 - - - -Nandakumar, et al. Expires 4 March 2027 [Page 5] - -Internet-Draft moq-transport August 2026 - - - 13.7. Relay security considerations . . . . . . . . . . . . . 126 - 13.7.1. State maintenance . . . . . . . . . . . . . . . . . 126 - 13.7.2. SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS with short - prefixes . . . . . . . . . . . . . . . . . . . . . . 126 - 13.8. Implementation Identification Fingerprinting . . . . . . 126 - 13.9. Logging of Untrusted String Fields . . . . . . . . . . . 127 - 14. Grease . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 - 15. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 128 - 15.1. URI Scheme Registrations . . . . . . . . . . . . . . . . 128 - 15.1.1. "moqt" URI Scheme Registration . . . . . . . . . . . 128 - 15.2. Media Type Registration . . . . . . . . . . . . . . . . 129 - 15.3. MOQT URI Fragment Types . . . . . . . . . . . . . . . . 130 - 15.4. Setup Options . . . . . . . . . . . . . . . . . . . . . 130 - 15.5. Authorization Token Alias Type . . . . . . . . . . . . . 131 - 15.6. MOQT Auth Token Type . . . . . . . . . . . . . . . . . . 131 - 15.7. Message Parameters . . . . . . . . . . . . . . . . . . . 131 - 15.8. Properties . . . . . . . . . . . . . . . . . . . . . . . 132 - 15.9. Object Status . . . . . . . . . . . . . . . . . . . . . 135 - 15.10. Session-Level Track Names . . . . . . . . . . . . . . . 135 - 15.11. Error Codes . . . . . . . . . . . . . . . . . . . . . . 136 - 15.11.1. Session Termination Error Codes . . . . . . . . . . 136 - 15.11.2. REQUEST_ERROR Codes . . . . . . . . . . . . . . . . 137 - 15.11.3. PUBLISH_DONE Codes . . . . . . . . . . . . . . . . 138 - 15.11.4. Stream Reset Error Codes . . . . . . . . . . . . . 139 - Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 139 - Use of Generative AI . . . . . . . . . . . . . . . . . . . . . . 140 - References . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 - Normative References . . . . . . . . . . . . . . . . . . . . . 140 - Informative References . . . . . . . . . . . . . . . . . . . . 142 - Appendix A. Change Log . . . . . . . . . . . . . . . . . . . . . 144 - A.1. Since draft-ietf-moq-transport-19 . . . . . . . . . . . . 144 - A.2. Since draft-ietf-moq-transport-18 . . . . . . . . . . . . 146 - A.3. Since draft-ietf-moq-transport-17 . . . . . . . . . . . . 147 - A.4. Since draft-ietf-moq-transport-16 . . . . . . . . . . . . 150 - A.5. Since draft-ietf-moq-transport-15 . . . . . . . . . . . . 152 - A.6. Since draft-ietf-moq-transport-14 . . . . . . . . . . . . 153 - A.7. Since draft-ietf-moq-transport-13 . . . . . . . . . . . . 155 - A.8. Since draft-ietf-moq-transport-12 . . . . . . . . . . . . 156 - A.9. Since draft-ietf-moq-transport-11 . . . . . . . . . . . . 156 - A.10. Since draft-ietf-moq-transport-10 . . . . . . . . . . . . 157 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 158 - - - - - - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 6] - -Internet-Draft moq-transport August 2026 - + 1.1. Document Structure . . . . . . . . . . . . . . . . . . . 7 + 1.2. Motivation . . . . . . . . . . . . . . . . . . . . . . . 9 + 1.2.1. Latency . . . . . . . . . . . . . . . . . . . . . . . 9 + 1.2.2. Leveraging QUIC . . . . . . . . . . . . . . . . . . . 9 + 1.2.3. Convergence . . . . . . . . . . . . . . . . . . . . . 9 + 1.2.4. Relays . . . . . . . . . . . . . . . . . . . . . . . 10 + 1.3. Terms and Definitions . . . . . . . . . . . . . . . . . . 10 + 1.4. Stream Management Terms . . . . . . . . . . . . . . . . . 11 + 1.5. Response Message Naming . . . . . . . . . . . . . . . . . 12 + 1.6. Modularity . . . . . . . . . . . . . . . . . . . . . . . 12 + 2. Object Data Model . . . . . . . . . . . . . . . . . . . . . . 12 + 2.1. Objects . . . . . . . . . . . . . . . . . . . . . . . . . 13 + 2.1.1. Object Fields . . . . . . . . . . . . . . . . . . . . 13 + 2.1.2. Object States . . . . . . . . . . . . . . . . . . . . 14 + 2.2. Subgroups . . . . . . . . . . . . . . . . . . . . . . . . 14 + 2.3. Groups . . . . . . . . . . . . . . . . . . . . . . . . . 15 + 2.3.1. Group IDs . . . . . . . . . . . . . . . . . . . . . . 16 + 2.4. Track . . . . . . . . . . . . . . . . . . . . . . . . . . 16 + 2.4.1. Track Naming . . . . . . . . . . . . . . . . . . . . 16 + + + +Nandakumar, et al. Expires 4 April 2027 [Page 2] + +Internet-Draft moq-transport October 2026 + + + 2.4.2. Namespace Prefix Matching . . . . . . . . . . . . . . 17 + 2.4.3. Reserved Namespaces . . . . . . . . . . . . . . . . . 17 + 2.5. Scope . . . . . . . . . . . . . . . . . . . . . . . . . . 18 + 3. Publishing and Receiving Tracks . . . . . . . . . . . . . . . 19 + 3.1. Subscriptions . . . . . . . . . . . . . . . . . . . . . . 19 + 3.1.1. Pausing Subscriptions . . . . . . . . . . . . . . . . 21 + 3.1.2. Subscription State Management . . . . . . . . . . . . 21 + 3.1.3. Track Alias . . . . . . . . . . . . . . . . . . . . . 22 + 3.1.4. Largest Object . . . . . . . . . . . . . . . . . . . 23 + 3.2. Fetch . . . . . . . . . . . . . . . . . . . . . . . . . . 23 + 3.2.1. Fetch Object Delivery . . . . . . . . . . . . . . . . 24 + 3.2.2. Gaps in a Fetch Stream . . . . . . . . . . . . . . . 24 + 3.2.3. Relay Fetch Handling . . . . . . . . . . . . . . . . 25 + 3.2.4. Fetch State Management . . . . . . . . . . . . . . . 26 + 3.3. Filtering Tracks and Objects . . . . . . . . . . . . . . 26 + 3.3.1. Location Filters . . . . . . . . . . . . . . . . . . 26 + 3.3.2. Range Filters . . . . . . . . . . . . . . . . . . . . 27 + 3.3.3. Combining Filters . . . . . . . . . . . . . . . . . . 28 + 3.4. Fill Semantics . . . . . . . . . . . . . . . . . . . . . 28 + 3.4.1. Opening and Closing Fill Fetch Streams . . . . . . . 29 + 3.5. Joining an Ongoing Track . . . . . . . . . . . . . . . . 30 + 3.5.1. Dynamically Starting New Groups . . . . . . . . . . . 30 + 3.6. Subscribing to Tracks by Prefix . . . . . . . . . . . . . 31 + 3.6.1. Filtering SUBSCRIBE_TRACKS . . . . . . . . . . . . . 32 + 3.6.2. Parameters on SUBSCRIBE_TRACKS . . . . . . . . . . . 32 + 3.6.3. Skipped Tracks . . . . . . . . . . . . . . . . . . . 32 + 3.7. Mandatory to Understand Track Properties . . . . . . . . 32 + 4. Publisher and Namespace Discovery . . . . . . . . . . . . . . 33 + 4.1. Publishing Namespaces . . . . . . . . . . . . . . . . . . 34 + 4.2. Subscribing to Namespaces . . . . . . . . . . . . . . . . 35 + 4.2.1. Namespace Subscription Authorization . . . . . . . . 36 + 4.2.2. Namespace Subscription State Management . . . . . . . 36 + 4.3. Namespace Discovery Example . . . . . . . . . . . . . . . 36 + 5. Object Transmission . . . . . . . . . . . . . . . . . . . . . 37 + 5.1. Priorities . . . . . . . . . . . . . . . . . . . . . . . 37 + 5.1.1. Definitions . . . . . . . . . . . . . . . . . . . . . 37 + 5.1.2. Scheduling Algorithm . . . . . . . . . . . . . . . . 39 + 5.1.3. Considerations for Setting Priorities . . . . . . . . 40 + 5.2. Delivery Timeouts and Data Reliability . . . . . . . . . 40 + 6. Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . 43 + 6.1. MOQT URI Scheme . . . . . . . . . . . . . . . . . . . . . 43 + 6.1.1. Fragment Identifiers . . . . . . . . . . . . . . . . 43 + 6.1.2. Dereferencing a MOQT URI . . . . . . . . . . . . . . 43 + 6.2. Session establishment . . . . . . . . . . . . . . . . . . 44 + 6.2.1. WebTransport . . . . . . . . . . . . . . . . . . . . 45 + 6.2.2. Native QUIC . . . . . . . . . . . . . . . . . . . . . 45 + 6.3. Session initialization . . . . . . . . . . . . . . . . . 46 + 6.3.1. 0-RTT . . . . . . . . . . . . . . . . . . . . . . . . 47 + + + +Nandakumar, et al. Expires 4 April 2027 [Page 3] + +Internet-Draft moq-transport October 2026 + + + 6.3.2. Extension Negotiation . . . . . . . . . . . . . . . . 48 + 6.4. Stream Usage . . . . . . . . . . . . . . . . . . . . . . 48 + 6.4.1. Unidirectional Streams . . . . . . . . . . . . . . . 48 + 6.4.2. Bidirectional Request Streams . . . . . . . . . . . . 49 + 6.5. Session-Level Tracks and Namespaces . . . . . . . . . . . 50 + 6.6. Termination . . . . . . . . . . . . . . . . . . . . . . . 51 + 6.6.1. Graceful Session Migration . . . . . . . . . . . . . 51 + 7. Relays . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 + 7.1. Caching Relays . . . . . . . . . . . . . . . . . . . . . 52 + 7.2. Paused Subscription Handling . . . . . . . . . . . . . . 53 + 7.3. Multiple Publishers . . . . . . . . . . . . . . . . . . . 53 + 7.4. Subscriber Interactions . . . . . . . . . . . . . . . . . 54 + 7.4.1. Graceful Subscriber Relay Switchover . . . . . . . . 55 + 7.5. Relay Resource Protection in Large Namespaces . . . . . . 55 + 7.6. Publisher Interactions . . . . . . . . . . . . . . . . . 56 + 7.6.1. Graceful Publisher Relay Switchover . . . . . . . . . 57 + 7.7. Relay Track Handling . . . . . . . . . . . . . . . . . . 58 + 7.8. Relay Object Handling . . . . . . . . . . . . . . . . . . 58 + 8. Notational Conventions and Common Structures . . . . . . . . 58 + 8.1. Variable-Length Integers . . . . . . . . . . . . . . . . 58 + 8.2. Location Structure . . . . . . . . . . . . . . . . . . . 60 + 8.3. Key-Value-Pair Structure . . . . . . . . . . . . . . . . 61 + 8.4. Track and Object Properties . . . . . . . . . . . . . . . 62 + 8.5. Reason Phrase Structure . . . . . . . . . . . . . . . . . 63 + 8.6. Range Filter Structure . . . . . . . . . . . . . . . . . 63 + 8.7. Track Namespace Structure . . . . . . . . . . . . . . . . 64 + 8.8. Representing Namespace and Track Names . . . . . . . . . 65 + 8.9. Authorization Token Compression . . . . . . . . . . . . . 65 + 9. Control Messages . . . . . . . . . . . . . . . . . . . . . . 68 + 9.1. SETUP . . . . . . . . . . . . . . . . . . . . . . . . . . 70 + 9.1.1. AUTHORITY . . . . . . . . . . . . . . . . . . . . . . 71 + 9.1.2. PATH . . . . . . . . . . . . . . . . . . . . . . . . 71 + 9.1.3. MAX_AUTH_TOKEN_CACHE_SIZE . . . . . . . . . . . . . . 71 + 9.1.4. AUTHORIZATION TOKEN . . . . . . . . . . . . . . . . . 72 + 9.1.5. MOQT IMPLEMENTATION . . . . . . . . . . . . . . . . . 72 + 9.1.6. MAX FILTER RANGES . . . . . . . . . . . . . . . . . . 73 + 9.1.7. MAX_REQUEST_UPDATES . . . . . . . . . . . . . . . . . 73 + 9.2. GOAWAY . . . . . . . . . . . . . . . . . . . . . . . . . 73 + 9.3. REQUEST_OK . . . . . . . . . . . . . . . . . . . . . . . 75 + 9.4. REQUEST_ERROR . . . . . . . . . . . . . . . . . . . . . . 76 + 9.4.1. Redirect Structure . . . . . . . . . . . . . . . . . 76 + 9.4.2. REQUEST_ERROR Message Format . . . . . . . . . . . . 76 + 9.5. REQUEST_UPDATE . . . . . . . . . . . . . . . . . . . . . 77 + 9.5.1. Updating Subscriptions . . . . . . . . . . . . . . . 79 + 9.5.2. Updating Namespace Subscriptions . . . . . . . . . . 79 + 9.6. SUBSCRIBE . . . . . . . . . . . . . . . . . . . . . . . . 80 + 9.7. SUBSCRIBE_OK . . . . . . . . . . . . . . . . . . . . . . 81 + 9.8. PUBLISH . . . . . . . . . . . . . . . . . . . . . . . . . 81 + + + +Nandakumar, et al. Expires 4 April 2027 [Page 4] + +Internet-Draft moq-transport October 2026 + + + 9.9. PUBLISH_DONE . . . . . . . . . . . . . . . . . . . . . . 83 + 9.10. PUBLISH_STATE_NOTIFY . . . . . . . . . . . . . . . . . . 84 + 9.11. FETCH . . . . . . . . . . . . . . . . . . . . . . . . . . 85 + 9.12. FETCH_OK . . . . . . . . . . . . . . . . . . . . . . . . 86 + 9.13. TRACK_STATUS . . . . . . . . . . . . . . . . . . . . . . 87 + 9.14. PUBLISH_NAMESPACE . . . . . . . . . . . . . . . . . . . . 87 + 9.15. SUBSCRIBE_NAMESPACE . . . . . . . . . . . . . . . . . . . 88 + 9.16. NAMESPACE . . . . . . . . . . . . . . . . . . . . . . . . 89 + 9.17. NAMESPACE_DONE . . . . . . . . . . . . . . . . . . . . . 89 + 9.18. SUBSCRIBE_TRACKS . . . . . . . . . . . . . . . . . . . . 89 + 9.19. PUBLISH_SKIPPED . . . . . . . . . . . . . . . . . . . . . 90 + 9.20. Control Message Parameters . . . . . . . . . . . . . . . 91 + 9.20.1. Parameter Scope . . . . . . . . . . . . . . . . . . 92 + 9.20.2. AUTHORIZATION TOKEN Parameter . . . . . . . . . . . 92 + 9.20.3. SUBGROUP_DELIVERY_TIMEOUT Parameter . . . . . . . . 93 + 9.20.4. OBJECT_DELIVERY_TIMEOUT Parameter . . . . . . . . . 93 + 9.20.5. FILL TIMEOUT Parameter . . . . . . . . . . . . . . . 93 + 9.20.6. RENDEZVOUS TIMEOUT Parameter . . . . . . . . . . . . 93 + 9.20.7. SUBSCRIBER PRIORITY Parameter . . . . . . . . . . . 94 + 9.20.8. GROUP ORDER Parameter . . . . . . . . . . . . . . . 94 + 9.20.9. LOCATION FILTER Parameter . . . . . . . . . . . . . 95 + 9.20.10. SUBGROUP FILTER Parameter . . . . . . . . . . . . . 97 + 9.20.11. OBJECTID FILTER Parameter . . . . . . . . . . . . . 97 + 9.20.12. PRIORITY FILTER Parameter . . . . . . . . . . . . . 97 + 9.20.13. OBJECT PROPERTY FILTER Parameter . . . . . . . . . . 98 + 9.20.14. TRACK PROPERTY FILTER Parameter . . . . . . . . . . 98 + 9.20.15. FILL PARAMETERS Parameter . . . . . . . . . . . . . 98 + 9.20.16. EXPIRES Parameter . . . . . . . . . . . . . . . . . 100 + 9.20.17. LARGEST OBJECT Parameter . . . . . . . . . . . . . . 100 + 9.20.18. FORWARD Parameter . . . . . . . . . . . . . . . . . 101 + 9.20.19. NEW GROUP REQUEST Parameter . . . . . . . . . . . . 101 + 9.20.20. TRACK_NAMESPACE_PREFIX Parameter . . . . . . . . . . 102 + 9.20.21. INCLUDE_PROPERTIES Parameter . . . . . . . . . . . . 102 + 10. MOQT Properties . . . . . . . . . . . . . . . . . . . . . . . 102 + 10.1. SUBGROUP_DELIVERY_TIMEOUT . . . . . . . . . . . . . . . 103 + 10.2. OBJECT_DELIVERY_TIMEOUT . . . . . . . . . . . . . . . . 103 + 10.3. MAX CACHE DURATION . . . . . . . . . . . . . . . . . . . 103 + 10.4. DEFAULT PUBLISHER PRIORITY . . . . . . . . . . . . . . . 103 + 10.5. DEFAULT PUBLISHER GROUP ORDER . . . . . . . . . . . . . 103 + 10.6. DYNAMIC GROUPS . . . . . . . . . . . . . . . . . . . . . 104 + 10.7. Immutable Properties . . . . . . . . . . . . . . . . . . 104 + 10.8. Prior Group ID Gap . . . . . . . . . . . . . . . . . . . 105 + 10.9. Prior Object ID Gap . . . . . . . . . . . . . . . . . . 106 + 11. Data Streams and Datagrams . . . . . . . . . . . . . . . . . 107 + 11.1. Objects . . . . . . . . . . . . . . . . . . . . . . . . 107 + 11.1.1. Object Status . . . . . . . . . . . . . . . . . . . 107 + 11.1.2. Object Properties . . . . . . . . . . . . . . . . . 108 + 11.2. Datagrams . . . . . . . . . . . . . . . . . . . . . . . 108 + + + +Nandakumar, et al. Expires 4 April 2027 [Page 5] + +Internet-Draft moq-transport October 2026 + + + 11.2.1. Object Datagram . . . . . . . . . . . . . . . . . . 109 + 11.3. Subgroup Streams . . . . . . . . . . . . . . . . . . . . 110 + 11.3.1. Subgroup Header . . . . . . . . . . . . . . . . . . 111 + 11.3.2. Closing Subgroup Streams . . . . . . . . . . . . . . 113 + 11.4. Fetch Streams . . . . . . . . . . . . . . . . . . . . . 115 + 11.4.1. Fetch Header . . . . . . . . . . . . . . . . . . . . 116 + 11.5. Padding . . . . . . . . . . . . . . . . . . . . . . . . 119 + 11.5.1. Padding Streams . . . . . . . . . . . . . . . . . . 119 + 11.5.2. Padding Datagrams . . . . . . . . . . . . . . . . . 119 + 12. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 120 + 12.1. Malformed Tracks . . . . . . . . . . . . . . . . . . . . 120 + 12.2. Session Termination Codes . . . . . . . . . . . . . . . 121 + 12.3. Request Error Codes . . . . . . . . . . . . . . . . . . 122 + 12.4. Publish Done Codes . . . . . . . . . . . . . . . . . . . 124 + 12.5. Stream Reset Error Codes . . . . . . . . . . . . . . . . 125 + 13. Grease . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 + 14. Transport Considerations . . . . . . . . . . . . . . . . . . 126 + 14.1. Congestion Control Considerations . . . . . . . . . . . 126 + 14.1.1. Bufferbloat . . . . . . . . . . . . . . . . . . . . 127 + 14.1.2. Application-Limited . . . . . . . . . . . . . . . . 127 + 14.1.3. Consistent Throughput . . . . . . . . . . . . . . . 127 + 15. Security Considerations . . . . . . . . . . . . . . . . . . . 128 + 15.1. Subscription Amplification . . . . . . . . . . . . . . . 128 + 15.2. Communication Security . . . . . . . . . . . . . . . . . 128 + 15.3. Authorization . . . . . . . . . . . . . . . . . . . . . 129 + 15.3.1. Mutual TLS . . . . . . . . . . . . . . . . . . . . . 129 + 15.3.2. Replay Attacks . . . . . . . . . . . . . . . . . . . 129 + 15.3.3. Preventing Impersonation . . . . . . . . . . . . . . 130 + 15.4. Media Security . . . . . . . . . . . . . . . . . . . . . 130 + 15.5. Resource Exhaustion . . . . . . . . . . . . . . . . . . 131 + 15.6. Timeouts . . . . . . . . . . . . . . . . . . . . . . . . 131 + 15.6.1. Idle Connection Handling . . . . . . . . . . . . . . 131 + 15.7. Relay security considerations . . . . . . . . . . . . . 132 + 15.7.1. State maintenance . . . . . . . . . . . . . . . . . 132 + 15.7.2. SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS with short + prefixes . . . . . . . . . . . . . . . . . . . . . . 132 + 15.8. Implementation Identification Fingerprinting . . . . . . 132 + 15.9. Logging of Untrusted String Fields . . . . . . . . . . . 133 + 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 133 + 16.1. URI Scheme Registrations . . . . . . . . . . . . . . . . 133 + 16.1.1. "moqt" URI Scheme Registration . . . . . . . . . . . 134 + 16.2. Media Type Registration . . . . . . . . . . . . . . . . 134 + 16.3. MOQT URI Fragment Types . . . . . . . . . . . . . . . . 135 + 16.4. Setup Options . . . . . . . . . . . . . . . . . . . . . 135 + 16.5. Authorization Token Alias Type . . . . . . . . . . . . . 136 + 16.6. MOQT Auth Token Type . . . . . . . . . . . . . . . . . . 136 + 16.7. Message Parameters . . . . . . . . . . . . . . . . . . . 136 + 16.8. Properties . . . . . . . . . . . . . . . . . . . . . . . 137 + + + +Nandakumar, et al. Expires 4 April 2027 [Page 6] + +Internet-Draft moq-transport October 2026 + + + 16.9. Object Status . . . . . . . . . . . . . . . . . . . . . 140 + 16.10. Session-Level Track Names . . . . . . . . . . . . . . . 140 + 16.11. Error Codes . . . . . . . . . . . . . . . . . . . . . . 141 + 16.11.1. Session Termination Error Codes . . . . . . . . . . 141 + 16.11.2. REQUEST_ERROR Codes . . . . . . . . . . . . . . . . 142 + 16.11.3. PUBLISH_DONE Codes . . . . . . . . . . . . . . . . 143 + 16.11.4. Stream Reset Error Codes . . . . . . . . . . . . . 144 + Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 144 + Use of Generative AI . . . . . . . . . . . . . . . . . . . . . . 145 + References . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 + Normative References . . . . . . . . . . . . . . . . . . . . . 145 + Informative References . . . . . . . . . . . . . . . . . . . . 147 + Appendix A. Change Log . . . . . . . . . . . . . . . . . . . . . 149 + A.1. Since draft-ietf-moq-transport-21 . . . . . . . . . . . . 149 + A.2. Since draft-ietf-moq-transport-20 . . . . . . . . . . . . 150 + A.3. Since draft-ietf-moq-transport-19 . . . . . . . . . . . . 151 + A.4. Since draft-ietf-moq-transport-18 . . . . . . . . . . . . 153 + A.5. Since draft-ietf-moq-transport-17 . . . . . . . . . . . . 154 + A.6. Since draft-ietf-moq-transport-16 . . . . . . . . . . . . 156 + A.7. Since draft-ietf-moq-transport-15 . . . . . . . . . . . . 158 + A.8. Since draft-ietf-moq-transport-14 . . . . . . . . . . . . 160 + A.9. Since draft-ietf-moq-transport-13 . . . . . . . . . . . . 161 + A.10. Since draft-ietf-moq-transport-12 . . . . . . . . . . . . 163 + A.11. Since draft-ietf-moq-transport-11 . . . . . . . . . . . . 163 + A.12. Since draft-ietf-moq-transport-10 . . . . . . . . . . . . 163 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 165 1. Introduction @@ -353,25 +380,86 @@ Internet-Draft moq-transport August 2026 define how specific content types are encoded, packaged, and mapped to MOQT objects, along with policies for discovery and subscription. - * Section 2 describes the data model employed by MOQT. +1.1. Document Structure + + This document describes the MOQT protocol and is structured as + follows: + + * The core concepts and functionality are described first + + + +Nandakumar, et al. Expires 4 April 2027 [Page 7] + +Internet-Draft moq-transport October 2026 + + + - Section 2 Section 2 Object Data Model describes how Objects, + Tracks and Namespaces relate + + - Section 3 Section 3 Describes how Objects in Tracks are + Published and Retrieved. + + - Section 4 Section 4 Describes mechanisms for discovering + Publishers and Namespaces + + * Next, the document describes how Objects are transmitted and MOQT + Sessions + + - Section 5 Section 5 Describes ways MOTQ allows a subscriber to + influence Object transmission order + + - Section 6 Section 6.3 Describes how to initiate a session and + key properties of a session, such as extensibility. + + - Section 7 Section 7 Describes key properties and requirements + of MOQT relays + + * Then the document describes how Control Messages and Objects are + serialized and sent - * Section 3 covers aspects of setting up an MOQT session. + - Section 8 Section 8 Notational Conventions and Common + Structures details structures used by subsequent sections - * Section 7 covers mechanisms for prioritizing subscriptions. + - Section 9 Section 9 Control Messages details how Control + Messages are sent, including their wire encoding - * Section 9 covers behavior at the relay entities. + - Section 10 Section 10 MOQT Properties describes Track and + Object properties defined in the core protocol - * Section 10 covers how control messages are encoded on the wire. + - Section 11 Section 11 Data streams describes the mapping and + serialization of Objects onto streams and datagrams - * Section 11 covers how data messages are encoded on the wire. + * Finally, the document discusses deployment related considerations -1.1. Motivation + - Section 12 Section 12 Discusses MOQT errors and how to best + handle them + + - Section 13 Section 13 Describes how to utilize unspecified + codepoints to prevent protocol ossification. + + - Section 14 Section 14 Discusses transport related + considerations, including congestion control + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 8] + +Internet-Draft moq-transport October 2026 + + + - Section 15 Section 15 Discusses security considerations, + including denial-of-service and authentication + +1.2. Motivation The development of MOQT is driven by goals in a number of areas - specifically latency, the robust feature set of QUIC and relay support. -1.1.1. Latency +1.2.1. Latency Latency is necessary to correct for variable network throughput. Ideally live content is consumed at the same bitrate it is produced. @@ -386,26 +474,18 @@ Internet-Draft moq-transport August 2026 utilizing UDP directly can avoid queuing, but the application is then responsible for the complexity of fragmentation, congestion control, retransmissions, receiver feedback, reassembly, and more. One goal - - - -Nandakumar, et al. Expires 4 March 2027 [Page 7] - -Internet-Draft moq-transport August 2026 - - of MOQT is to achieve the best of both these worlds: leverage the features of QUIC to create a simple yet flexible low latency protocol that can rapidly detect and respond to congestion. -1.1.2. Leveraging QUIC +1.2.2. Leveraging QUIC The parallel nature of QUIC streams can provide improvements in the face of loss. A goal of MOQT is to design a streaming protocol to leverage the transmission benefits afforded by parallel QUIC streams as well as exercising options for flexible loss recovery. -1.1.3. Convergence +1.2.3. Convergence Some live media architectures today have separate protocols for ingest and distribution, for example RTMP and HTTP based HLS or DASH. @@ -418,7 +498,15 @@ Internet-Draft moq-transport August 2026 packaging schemas, both for backwards compatibility and for interoperability with the established content preparation ecosystem. -1.1.4. Relays + + + +Nandakumar, et al. Expires 4 April 2027 [Page 9] + +Internet-Draft moq-transport October 2026 + + +1.2.4. Relays An integral feature of a protocol being successful is its ability to deliver media at scale. Greatest scale is achieved when third-party @@ -431,7 +519,7 @@ Internet-Draft moq-transport August 2026 necessary for distribution is available to relays while the media content itself remains opaque and private. -1.2. Terms and Definitions +1.3. Terms and Definitions The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and @@ -443,16 +531,11 @@ Internet-Draft moq-transport August 2026 Application: The entity using MOQT to transmit and receive data. + Client: The party initiating a Transport Session. A Client can be a + Publisher, a Subscriber, or both. - -Nandakumar, et al. Expires 4 March 2027 [Page 8] - -Internet-Draft moq-transport August 2026 - - - Client: The party initiating a Transport Session. - - Server: The party accepting an incoming Transport Session. + Server: The party accepting an incoming Transport Session. A Server + can be a Publisher, a Subscriber, or both. Endpoint: A Client or Server. @@ -470,7 +553,14 @@ Internet-Draft moq-transport August 2026 Relay: An entity that is both a Publisher and a Subscriber, is not the Original Publisher or End Subscriber, and conforms to all - requirements in Section 9. + requirements in Section 7. + + + +Nandakumar, et al. Expires 4 April 2027 [Page 10] + +Internet-Draft moq-transport October 2026 + Upstream: In the direction of the Original Publisher. @@ -497,52 +587,24 @@ Internet-Draft moq-transport August 2026 Track: A track is a collection of groups. See (Section 2.4). + Subscription: An ongoing relationship in which a publisher delivers + newly published objects from a track to a subscriber. See + (Section 3.1). - - - -Nandakumar, et al. Expires 4 March 2027 [Page 9] - -Internet-Draft moq-transport August 2026 - - -1.3. Stream Management Terms +1.4. Stream Management Terms This document uses stream management terms described in [RFC9000], Section 1.3 including STOP_SENDING, RESET_STREAM, and FIN. It also uses RESET_STREAM_AT from [I-D.draft-ietf-quic-reliable-stream-reset]. RESET_STREAM_AT can be used by MOQT, but the protocol is also designed to work correctly - when the extension is not supported. + when the extension is not used or not supported. When this document says an endpoint "resets" a stream, it means the endpoint sends a RESET_STREAM or RESET_STREAM_AT frame on that stream - (see Section 11.4.3 for considerations on choosing between them). - -1.4. Notational Conventions - - This document uses the conventions detailed in ([RFC9000], - Section 1.3) when describing the binary encoding. - -1.4.1. Variable-Length Integers - - MOQT requires a variable-length integer encoding with the following - properties: - - 1. The encoded length can be determined from the first encoded byte. - - 2. The range of 1 byte values is as large as possible. - - 3. All 64 bit numbers can be encoded. + (see Section 11.3.2 for considerations on choosing between them). - The variable-length integer encoding uses the number of leading 1 - bits of the first byte to indicate the length of the encoding in - bytes. The remaining bits after the first 0 and subsequent bytes, if - any, represent the integer value, encoded in network byte order. - Integers are encoded in 1 to 9 bytes and can encode up to 64 bit - unsigned integers. The following table summarizes the encoding - properties. @@ -551,367 +613,185 @@ Internet-Draft moq-transport August 2026 +Nandakumar, et al. Expires 4 April 2027 [Page 11] + +Internet-Draft moq-transport October 2026 +1.5. Response Message Naming + Most requests in MOQT are answered with a common REQUEST_OK + (Section 9.3) or REQUEST_ERROR (Section 9.4) message. This document + uses the shorthand PUBLISH_OK, REQUEST_UPDATE_OK, TRACK_STATUS_OK, + SUBSCRIBE_NAMESPACE_OK, SUBSCRIBE_TRACKS_OK and PUBLISH_NAMESPACE_OK + to refer to a REQUEST_OK sent in response to the corresponding + request type. Likewise, it uses the shorthand SUBSCRIBE_ERROR, + FETCH_ERROR, PUBLISH_ERROR, SUBSCRIBE_NAMESPACE_ERROR, + SUBSCRIBE_TRACKS_ERROR, PUBLISH_NAMESPACE_ERROR, TRACK_STATUS_ERROR + and REQUEST_UPDATE_ERROR to refer to a REQUEST_ERROR sent in response + to the corresponding request type. +1.6. Modularity + MOQT defines all messages necessary to implement both simple + publishing or subscribing endpoints as well as fully capable Relays. + Non-Relay endpoints MAY implement only the subset of functionality + required to perform necessary tasks. For example, a limited media + player could operate using only SUBSCRIBE related messages. Limited + endpoints SHOULD respond to any unsupported messages with the + appropriate NOT_SUPPORTED error code, rather than ignoring them. -Nandakumar, et al. Expires 4 March 2027 [Page 10] - -Internet-Draft moq-transport August 2026 + Relays MUST implement all MOQT messages defined in this document, as + well as processing rules described in Section 7. +2. Object Data Model - +==============+================+========+========================+ - | Leading Bits | Length (bytes) | Usable | Range | - | | | Bits | | - +==============+================+========+========================+ - | 0 | 1 | 7 | 0-127 | - +--------------+----------------+--------+------------------------+ - | 10 | 2 | 14 | 0-16383 | - +--------------+----------------+--------+------------------------+ - | 110 | 3 | 21 | 0-2097151 | - +--------------+----------------+--------+------------------------+ - | 1110 | 4 | 28 | 0-268435455 | - +--------------+----------------+--------+------------------------+ - | 11110 | 5 | 35 | 0-34359738367 | - +--------------+----------------+--------+------------------------+ - | 111110 | 6 | 42 | 0-4398046511103 | - +--------------+----------------+--------+------------------------+ - | 1111110 | 7 | 49 | 0-562949953421311 | - +--------------+----------------+--------+------------------------+ - | 11111110 | 8 | 56 | 0-72057594037927935 | - +--------------+----------------+--------+------------------------+ - | 11111111 | 9 | 64 | 0-18446744073709551615 | - +--------------+----------------+--------+------------------------+ + MOQT has a hierarchical data model, comprised of tracks which contain + groups, and groups that contain objects. Inside of a group, the + objects can be organized into subgroups. - Table 1: Summary of Integer Encodings + To give an example of how an application might use this data model, + consider an application sending high and low resolution video using a + codec with temporal scalability. Each resolution is sent as a + separate track to allow the subscriber to pick the appropriate + resolution given the display environment and available bandwidth. + Each independently coded sequence of pictures in a resolution is sent + as a group as the first picture in the sequence can be used as a + random access point. This allows the client to join at the logical + points where decoding of the media can start without needing + information before the join points. The temporal layers are sent as + separate subgroups to allow the priority mechanism to favor lower + temporal layers when there is not enough bandwidth to send all + temporal layers. Each frame of video is sent as a single object. - The following table contains some example encodings: - +======================+============================+ - | Byte Sequence | Decimal Value | - +======================+============================+ - | 0x25 | 37 | - +----------------------+----------------------------+ - | 0x8025 | 37 | - +----------------------+----------------------------+ - | 0xbbbd | 15,293 | - +----------------------+----------------------------+ - | 0xed7f3e7d | 226,442,877 | - +----------------------+----------------------------+ - | 0xfaa1a0e403d8 | 2,893,212,287,960 | - +----------------------+----------------------------+ - | 0xfc8998abc66bc0 | 151,288,809,941,952 | - +----------------------+----------------------------+ - | 0xfefa318fa8e3ca11 | 70,423,237,261,249,041 | - +----------------------+----------------------------+ - | 0xffffffffffffffffff | 18,446,744,073,709,551,615 | - +----------------------+----------------------------+ - Table 2: Example Integer Encodings -Nandakumar, et al. Expires 4 March 2027 [Page 11] +Nandakumar, et al. Expires 4 April 2027 [Page 12] -Internet-Draft moq-transport August 2026 - - - Variable-length integers do not need to be encoded using the minimum - number of bytes; any encoding length that can represent the value is - valid. Note that, as a result, the same numeric value can be - represented by more than one byte sequence. For example, the value 0 - can be encoded as 0x00, 0x8000, 0xc00000, or any longer form. +Internet-Draft moq-transport October 2026 - x (vi64): Indicates that x holds an integer value using the - variable-length encoding as described above. -1.4.2. Location Structure - - Location identifies a particular Object in a Group within a Track. +2.1. Objects - Location { - Group (vi64), - Object (vi64) - } + The basic data element of MOQT is an object. An object is an + addressable unit whose payload is a sequence of bytes. All objects + belong to a group, indicating ordering and potential dependencies + (see Section 2.3). An object is uniquely identified by its track + namespace, track name, group ID, and object ID, and must be an + identical sequence of bytes regardless of how or where it is + retrieved. An Object can become unavailable, but its contents MUST + NOT change over time. - Figure 1: Location structure + Every Object within a Group belongs to exactly one Subgroup or + Datagram. An Original Publisher MAY use both Subgroups and Datagrams + within a Group or Track. - In this document, a Location can be expressed in the form of - {GroupID, ObjectID}, where GroupID and ObjectID indicate the Group ID - and Object ID of the Location, respectively. The constituent parts - of any Location A can be referred to using A.Group or A.Object. + Objects are comprised of two parts: metadata and a payload. The + metadata is never encrypted and is always visible to relays (see + Section 7). The payload portion may be encrypted, in which case it + is only visible to the Original Publisher and End Subscribers. The + Original Publisher is solely responsible for the content of the + object payload. This includes the underlying encoding, compression, + any end-to-end encryption, or authentication. - Location A < Location B if: +2.1.1. Object Fields - A.Group < B.Group || (A.Group == B.Group && A.Object < B.Object) + A MOQT Object has the following fields: -1.4.3. Key-Value-Pair Structure + Track Namespace and Track Name: The track this object belongs to. - Key-Value-Pair is a flexible structure that carries key/value pairs - in which the key is a variable-length integer and the value is either - a variable-length integer or a byte field of arbitrary length. + Group ID: The identifier of the Object's Group (see Section 2.3) + within the Track. - Key-Value-Pairs encode a Type value as a delta from the previous Type - value, or from 0 if there is no previous Type value. This is - efficient on the wire and makes it easy to ensure there is only one - instance of a type when needed. The previous Type value plus the - Delta Type MUST NOT be greater than 2^64 - 1. If a Delta Type is - received that would be too large, the Session MUST be closed with a - PROTOCOL_VIOLATION. + Object ID: The order of the object within the group. - Key-Value-Pair is used in both the data plane and control plane, but - is optimized for use in the data plane. + Publisher Priority: An integer indicating the publisher's priority + for the Object (Section 5.1). + Delivery Mode: An enumeration indicating whether an Object is sent in + a Subgroup or Datagram. The Original Publisher establishes an + Object's Delivery Mode by how it first transmits the Object. In a + subscription, an Object MUST be sent according to its Delivery Mode. + Subgroup ID: The identifier of the Object's Subgroup (see + Section 2.2) within the Group. Objects sent in Datagrams do not have + a Subgroup ID. + Object Properties : A sequence of key-value pairs associated with the + object. See Section 11.1.2. -Nandakumar, et al. Expires 4 March 2027 [Page 12] +Nandakumar, et al. Expires 4 April 2027 [Page 13] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - Key-Value-Pair { - Delta Type (vi64), - [Length (vi64),] - Value (..) - } + Object Payload: A possibly empty sequence of bytes. - Figure 2: MOQT Key-Value-Pair +2.1.2. Object States - * Delta Type: an unsigned variable-length integer identifying the - Type as a delta encoded value from the previous Type, if any. The - Type identifies the type of value and also the subsequent - serialization. + From the perspective of a subscriber or a cache, an Object can be in + three possible states: - * Length: Only present when Type is odd. Specifies the length of - the Value field in bytes. The maximum length of a value is 2^16-1 - bytes. If an endpoint receives a length larger than the maximum, - it MUST close the session with a PROTOCOL_VIOLATION. + 1. The Object is known to not exist. This state is permanent. All + signals that an Object does not exist are authoritative. - * Value: A single variable-length integer when Type is even, - otherwise a sequence of Length bytes. + 2. The Object is known to exist. From this state, it can transition + to not existing, but not vice versa. - If a receiver understands a Type, and the following Value or Length/ - Value does not match the serialization defined by that Type, the - receiver MUST close the session with error code - KEY_VALUE_FORMATTING_ERROR. + 3. The state of the Object is unknown, either because it has not yet + been received, or it has not yet been produced. - Key-Value-Pairs are always parsed with a known byte length, which - bounds the sequence. The source of this length varies by context. + A gap in the observed Object IDs does not by itself convey any + information about the skipped Objects. Skipped Objects remain in the + unknown state until they are received or their non-existence is + signalled, for example in a FETCH stream (see Section 11.4.1) or via + a Prior Object ID Gap (see Section 10.9). -1.4.4. Reason Phrase Structure + Since Objects can be delivered out of order, an endpoint can receive + an Object after it has already recorded that the Object does not + exist (e.g., via a FETCH gap from one source and delayed delivery via + a subscription). This is not a protocol error and the Track is not + malformed. - Reason Phrase provides a way for the sender to encode additional - diagnostic information about an error condition, where appropriate. + Whenever the publisher communicates that certain objects do not + exist, this fact is expressed as a contiguous range of non-existent + objects and by including Properties indicating the group/object gaps; + MOQT implementers should take that into account when selecting + appropriate data structures. - Reason Phrase { - Reason Phrase Length (vi64), - Reason Phrase Value (..) - } +2.2. Subgroups - * Reason Phrase Length: A variable-length integer specifying the - length of the reason phrase in bytes. The reason phrase length - has a maximum value of 1024 bytes. If an endpoint receives a - length exceeding the maximum, it MUST close the session with a - PROTOCOL_VIOLATION + A subgroup is a sequence of one or more objects from the same group + (Section 2.3) in ascending order by Object ID. Objects in a subgroup + have a dependency and priority relationship consistent with sharing a + stream and are sent on a single stream whenever possible. A Group is + delivered using at least as many streams as there are Subgroups in + the Group, typically with a one-to-one mapping between Subgroups and + streams. + When an Object's Delivery Mode (see Section 11.1.2) is "Datagram", it + is not sent in Subgroups, does not belong to a Subgroup in any way, + and the description in the remainder of this section does not apply. +Nandakumar, et al. Expires 4 April 2027 [Page 14] + +Internet-Draft moq-transport October 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 13] - -Internet-Draft moq-transport August 2026 - - - * Reason Phrase Value: Additional diagnostic information about an - error condition. The reason phrase value is encoded as UTF-8 - string and does not carry information, such as language tags, that - would aid comprehension by any entity other than the one that - created the text. - -1.5. Representing Namespace and Track Names - - There is often a need to render namespace tuples and track names for - purposes such as logging, representing track filenames, or use in - certain authorization verification schemes. The namespace and track - name are binary and need to be converted to a safe form. - - The following format is RECOMMENDED: - - * Each of the namespace tuples are rendered in order with a hyphen - (-) between them followed by the track name with a double hyphen - (--) between the last namespace and track name. - - * Bytes in the range a-z, A-Z, 0-9 as well as _ (0x5f) are output - verbatim, while all other bytes are encoded as a period (.) symbol - followed by exactly two lowercase hexadecimal digits. - - This format allows many common names to be rendered in an easily - human readable form while still supporting binary values. Note that - while the character set is chosen to be generally both filename and - URL safe, filename safety is platform specific; for instance, on - case-insensitive filesystems, track names can collide. - -1.5.1. Parsing Serialized Names - - When parsing a serialized namespace or track name back to its binary - form, implementations MUST apply the following rules to ensure a - canonical encoding: - - * A period (.) MUST be followed by exactly two hexadecimal digits. - A trailing period or a period followed by fewer than two - hexadecimal digits is invalid. - - * The hexadecimal digits following a period (.) MUST be lowercase - (a-f). Uppercase hexadecimal digits (A-F) are invalid and MUST - cause parsing to fail. - - * Bytes that can be represented literally (a-z, A-Z, 0-9, _) MUST - NOT appear in their hex-encoded form. For example, .61 is invalid - because a must be represented as the literal character a. A - parser MUST reject such redundant encodings. - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 14] - -Internet-Draft moq-transport August 2026 - - - These rules ensure that the encoding is bijective: every binary value - has exactly one valid serialized representation, and every valid - serialized string maps to exactly one binary value. This property - simplifies comparison of serialized names without requiring full - deserialization. - - Implementations that receive an invalid serialized name SHOULD treat - it as an error. The specific error handling behavior is application- - defined. - - Example: - - example.2enet-team2-project_x--report - Namespace tuples: (example.net, team2, project_x) - Track name: report - -2. Object Data Model - - MOQT has a hierarchical data model, comprised of tracks which contain - groups, and groups that contain objects. Inside of a group, the - objects can be organized into subgroups. - - To give an example of how an application might use this data model, - consider an application sending high and low resolution video using a - codec with temporal scalability. Each resolution is sent as a - separate track to allow the subscriber to pick the appropriate - resolution given the display environment and available bandwidth. - Each independently coded sequence of pictures in a resolution is sent - as a group as the first picture in the sequence can be used as a - random access point. This allows the client to join at the logical - points where decoding of the media can start without needing - information before the join points. The temporal layers are sent as - separate subgroups to allow the priority mechanism to favor lower - temporal layers when there is not enough bandwidth to send all - temporal layers. Each frame of video is sent as a single object. - -2.1. Objects - - The basic data element of MOQT is an object. An object is an - addressable unit whose payload is a sequence of bytes. All objects - belong to a group, indicating ordering and potential dependencies - (see Section 2.3). An object is uniquely identified by its track - namespace, track name, group ID, and object ID, and must be an - identical sequence of bytes regardless of how or where it is - retrieved. An Object can become unavailable, but its contents MUST - NOT change over time. - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 15] - -Internet-Draft moq-transport August 2026 - - - Objects are comprised of two parts: metadata and a payload. The - metadata is never encrypted and is always visible to relays (see - Section 9). The payload portion may be encrypted, in which case it - is only visible to the Original Publisher and End Subscribers. The - Original Publisher is solely responsible for the content of the - object payload. This includes the underlying encoding, compression, - any end-to-end encryption, or authentication. - - From the perspective of a subscriber or a cache, an Object can be in - three possible states: - - 1. The Object is known to not exist. This state is permanent. All - signals that an Object does not exist are authoritative. - - 2. The Object is known to exist. From this state, it can transition - to not existing, but not vice versa. - - 3. The state of the Object is unknown, either because it has not yet - been received, or it has not yet been produced. - - A gap in the observed Object IDs does not by itself convey any - information about the skipped Objects. Skipped Objects remain in the - unknown state until they are received or their non-existence is - signalled, for example in a FETCH stream (see Section 11.4.4) or via - a Prior Object ID Gap (see Section 12.9). - - Since Objects can be delivered out of order, an endpoint can receive - an Object after it has already recorded that the Object does not - exist (e.g., via a FETCH gap from one source and delayed delivery via - a subscription). This is not a protocol error and the Track is not - malformed. - - Whenever the publisher communicates that certain objects do not - exist, this fact is expressed as a contiguous range of non-existent - objects and by including Properties indicating the group/object gaps; - MOQT implementers should take that into account when selecting - appropriate data structures. - -2.2. Subgroups - - A subgroup is a sequence of one or more objects from the same group - (Section 2.3) in ascending order by Object ID. Objects in a subgroup - have a dependency and priority relationship consistent with sharing a - stream and are sent on a single stream whenever possible. A Group is - delivered using at least as many streams as there are Subgroups in - the Group, typically with a one-to-one mapping between Subgroups and - streams. - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 16] - -Internet-Draft moq-transport August 2026 - - - When an Object's forwarding preference (see Section 11.2.1.2) is - "Datagram", it is not sent in Subgroups, does not belong to a - Subgroup in any way, and the description in the remainder of this - section does not apply. - Streams offer in-order reliable delivery and the ability to cancel sending and retransmission of data. Furthermore, many QUIC and WebTransport implementations offer the ability to control the relative scheduling priority of pending stream data. - Every Object within a Group belongs to exactly one Subgroup or - Datagram. - - When Objects are sent in a subscription (see Section 5.1), Objects + When Objects are sent in a subscription (see Section 3.1), Objects from two subgroups MUST NOT be sent on the same stream, and Objects from the same Subgroup MUST NOT be sent on different streams, unless one of the streams was reset prematurely, or upstream conditions have @@ -937,23 +817,11 @@ Internet-Draft moq-transport August 2026 used. When the Original Publisher opens a new subgroup, it MUST set the - FIRST_OBJECT bit (Section 11.4.2) to indicate that the first object + FIRST_OBJECT bit (Section 11.3.1) to indicate that the first object in the subgroup stream is the first object ever published in that subgroup. A relay forwarding a subgroup that begins with the first object ever published in that subgroup MUST set the FIRST_OBJECT bit. - - - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 17] - -Internet-Draft moq-transport August 2026 - - 2.3. Groups A group is a collection of Objects and is a sub-unit of a Track @@ -964,6 +832,16 @@ Internet-Draft moq-transport August 2026 starting from a given Group ID. Groups can contain any number of Objects. + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 15] + +Internet-Draft moq-transport October 2026 + + 2.3.1. Group IDs Within a track, the original publisher SHOULD publish Group IDs which @@ -999,77 +877,27 @@ Internet-Draft moq-transport August 2026 group boundary, including any new objects pushed by the publisher while the track is active. - - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 18] - -Internet-Draft moq-transport August 2026 - - 2.4.1. Track Naming In MOQT, every track is identified by a Full Track Name, consisting of a Track Namespace and a Track Name. Track Namespace is an ordered set of between 0 and 32 Track Namespace - Fields, encoded as follows: - - Track Namespace { - Number of Track Namespace Fields (vi64), - Track Namespace Field (..) ... - } - - * Number of Track Namespace Fields: A variable-length integer - specifying the number of Track Namespace Fields in the Track - Namespace. - - Each Track Namespace Field is encoded as follows: - - Track Namespace Field { - Track Namespace Field Length (vi64), - Track Namespace Field Value (..) - } - - * Track Namespace Field Length: A variable-length integer specifying - the length of the Track Namespace Field in bytes. - - * Track Namespace Field Value: A sequence of bytes that forms a - Track Namespace Field. - - Each Track Namespace Field Value MUST contain at least one byte. If - an endpoint receives a Track Namespace Field with a Track Namespace - Field Length of 0, it MUST close the session with a - PROTOCOL_VIOLATION. + Fields, encoded as described in Section 8.7. The structured nature of Track Namespace allows relays and - applications to manipulate prefixes of a namespace. If an endpoint - receives a Track Namespace consisting of greater than 32 Track - Namespace Fields, it MUST close the session with a - PROTOCOL_VIOLATION. + applications to manipulate prefixes of a namespace. Track Name is a sequence of bytes, possibly empty, that identifies an individual track within the namespace. - The maximum total length of a Full Track Name is 4,096 bytes. The - length of a Full Track Name is computed as the sum of the Track - Namespace Field Length fields and the Track Name Length field. The - length of a Track Namespace is the sum of the Track Namespace Field - -Nandakumar, et al. Expires 4 March 2027 [Page 19] +Nandakumar, et al. Expires 4 April 2027 [Page 16] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - Length fields. If an endpoint receives a Track Namespace or a Full - Track Name exceeding 4,096 bytes, it MUST close the session with a - PROTOCOL_VIOLATION. - In this specification, both the Track Namespace Fields and the Track Name are not constrained to a specific encoding. They carry a sequence of bytes and comparison between two Track Namespace Fields @@ -1080,62 +908,53 @@ Internet-Draft moq-transport August 2026 the Track Namespace Fields or Track Name such that exact comparison works. -2.4.2. Malformed Tracks +2.4.2. Namespace Prefix Matching - There are multiple ways a publisher can transmit a Track that does - not conform to MOQT constraints. Such a Track is considered - malformed. Some example conditions that constitute a malformed track - when detected by a receiver include: + To perform a namespace prefix match, the fields of the prefix are + compared sequentially against the leading fields of the Track + Namespace being matched, requiring an exact match for each field. + The prefix matches if all fields in the prefix match the leading + fields of the Namespace. - 1. An Object with a particular Subgroup ID is received, but its - Publisher Priority is different from that of the previous Object - with the same Subgroup ID. + The examples below use the serialized name format from Section 8.8. - 2. An Object is received whose Object ID is larger than the final - Object in the Subgroup. The final Object in a Subgroup is the - last Object received on a Subgroup stream before a FIN. + The Full Track Name foo-bar--x has the namespace foo-bar, so it + matches the prefixes foo and foo-bar. It does not match foobar. - 3. A Subgroup is received over multiple transport streams terminated - by FIN with different final Objects. + The prefix example.2ecom-123 matches the namespaces example.2ecom- + 123-100 and example.2ecom-123-200. - 4. An Object is received in a Group whose Object ID is larger than - the final Object in the Group. The final Object in a Group is - the Object with Status END_OF_GROUP, or the last Object before a - FIN in a Subgroup which has the END_OF_GROUP bit set. If the end - of a Group is implicitly determined via a gap in a FETCH - response, the final Object in the Group remains unknown. +2.4.3. Reserved Namespaces - 5. An Object is received whose Group and Object ID are larger than - the final Object in the Track. The final Object in a Track is - the Object with Status END_OF_TRACK or the last Object sent in a - FETCH whose response indicated End of Track. + MOQT reserves all Track Namespace values whose first tuple field + begins with a period (0x2e, .). These namespaces MUST NOT be used + unless their meaning is defined through IANA registration. Unless + otherwise specified, an endpoint that receives a request for an + unrecognized reserved namespace MUST pass it to the Application, so + that future extensions can define new reserved namespaces without + breaking older implementations. - 6. The same Object is received more than once with different Payload - or other immutable properties. + A Track Namespace whose first field is exactly . (a single period, + 0x2e) is reserved and MUST NOT be used for any purpose; endpoints + MUST NOT publish tracks or namespaces under it and MUST reject + requests referencing it with DOES_NOT_EXIST. -Nandakumar, et al. Expires 4 March 2027 [Page 20] - -Internet-Draft moq-transport August 2026 - 7. An Object is received with a different Forwarding Preference than - previously observed. - The above list of conditions is not considered exhaustive. - When a subscriber detects a Malformed Track, it MUST cancel any - corresponding subscription or fetches for that Track from that - publisher (see Section 3.3.3), and SHOULD deliver an error to the - application. If a relay detects a Malformed Track, it MUST - immediately terminate downstream subscriptions with PUBLISH_DONE and - reset any fetch streams with Status Code MALFORMED_TRACK. Object(s) - triggering Malformed Track status MUST NOT be cached. -2.4.3. Scope + +Nandakumar, et al. Expires 4 April 2027 [Page 17] + +Internet-Draft moq-transport October 2026 + + +2.5. Scope An MOQT scope is a set of servers (as identified by their connection URIs) for which a Full Track Name is guaranteed to be unique and @@ -1150,7 +969,7 @@ Internet-Draft moq-transport August 2026 negotiated in the beginning of the session. Unless the application has additional information, two tracks are assumed to belong to the same scope if and only if the authority and path-abempty components - (Section 3.1.1) of their connection URIs are equal. These values are + (Section 6.1) of their connection URIs are equal. These values are communicated through the SETUP message in case of raw QUIC, and through HTTP request header fields in case of WebTransport. @@ -1167,17 +986,6 @@ Internet-Draft moq-transport August 2026 not depend on those parameters; this is in contrast to protocols like HTTP, where request headers can alter the server response. - - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 21] - -Internet-Draft moq-transport August 2026 - - A publisher that loses state (e.g. crashes) and intends to resume publishing on the same Track risks colliding with previously published Objects and violating the above requirements. A publisher @@ -1195,256 +1003,280 @@ Internet-Draft moq-transport August 2026 3. Use TRACK_STATUS or similar mechanism to query the previous state to determine the largest published Group ID. -2.5. Properties - - Tracks and Objects can have additional relay-visible fields, known as - Properties, which do not require negotiation, and can be used to - alter MOQT Object distribution. - Properties are defined in Section 12 as well as external - specifications and are registered in an IANA table Section 15. These - specifications define the type and value of the property, along with - any rules concerning processing, modification, caching and - forwarding. - If a Relay does not support a Property, it MUST NOT be modified, MUST - be forwarded, and MUST be cached with the Track or Object, unless it - is a Mandatory Track Property as described in Section 2.5.1. If a - Track or Object arrives with a different set of unknown properties - than previously cached, the most recent set SHOULD replace any cached - values, removing any unknown values not present in the new set. - Relays MUST NOT attempt to merge sets of unknown properties received - in different messages. +Nandakumar, et al. Expires 4 April 2027 [Page 18] + +Internet-Draft moq-transport October 2026 - If a Relay supports a Property, it MUST follow the processing rules - in the Property's definition. Unless those rules permit otherwise, a - Relay MUST NOT modify, add, or remove the Property; it MUST forward - the Property to downstream subscribers and MUST cache it with the - Track or Object if the Track or Object is cached. +3. Publishing and Receiving Tracks + A subscription is a stateful ongoing relationship in which the + Publisher delivers newly-published Objects from a single Track to the + Subscriber. It can be established by either endpoint, via either + SUBSCRIBE or PUBLISH. A subscription is active until either endpoint + terminates it, and its parameters can be updated via REQUEST_UPDATE. + A fetch is a request for a bounded set of pre-existing Objects from a + single Track. It is delivered on a single stream, and ends + automatically when all of the objects are delivered. +3.1. Subscriptions + All subscriptions begin in the Idle state. A subscription can be + initiated and moved to the Pending state by either a publisher or a + subscriber. A publisher initiates a subscription to a track by + sending the PUBLISH message. The subscriber either accepts or + rejects the subscription using PUBLISH_OK (Section 9.3) or + PUBLISH_ERROR. A subscriber initiates a subscription to a track by + sending the SUBSCRIBE message. The publisher either accepts or + rejects the subscription using SUBSCRIBE_OK or SUBSCRIBE_ERROR. Once + either of these sequences is successful, the subscription moves to + the Established state and can be updated by the subscriber using + REQUEST_UPDATE. Either endpoint can terminate an Established + subscription, moving it to the Terminated state. The subscriber + terminates a subscription in the Pending (Subscriber) or Established + states by sending STOP_SENDING. The publisher terminates a + subscription in the Pending (Publisher) or Established states by + sending PUBLISH_DONE and closing the stream. + This diagram shows the subscription state machine: -Nandakumar, et al. Expires 4 March 2027 [Page 22] - -Internet-Draft moq-transport August 2026 - Properties are serialized as Key-Value-Pairs (see Figure 2). Track - Properties always appear as the final field in the messages that - carry them; their length is the remaining bytes of the message after - all preceding fields have been consumed. Object Properties - (Section 11.2.1.2) are preceded by an explicit length field. - Property types are registered in the IANA table 'MOQ Properties'. - See Section 15. - Certain Property type ranges are reserved for application-specific - use and will never be allocated by IANA in future MOQT - specifications: - * 0x78 to 0x7F (1-byte encoding): 8 code points for applications - with tight space constraints - * 0x3800 to 0x3FFF (2-byte encoding): 2048 code points (including - grease Section 14) for applications with moderate space - constraints - Applications MAY use code points in these ranges without registration - for format-specific metadata or other application-defined purposes. - Relays that do not understand the application format MUST forward - these properties unchanged but MUST NOT attempt to interpret their - semantic meaning. Different applications using the same code point - in these ranges may assign different meanings; the interpretation - depends on the track or application context known to the publisher - and subscriber. -2.5.1. Mandatory Track Properties - Property types in the range 0x4000-0x7FFF are designated as Mandatory - Track Properties. These properties MUST have Track scope. Mandatory - Track Properties have special handling rules that prevent tracks with - required properties from being forwarded to or processed by endpoints - that do not understand them. - An Object received with a Mandatory Track Property as an Object - Property is malformed (see Section 2.4.2). - When an endpoint receives a Mandatory Track Property in PUBLISH, - SUBSCRIBE_OK, or FETCH_OK that it does not understand, it MUST NOT - process or forward that track: - * For PUBLISH messages: the subscriber MUST respond with - REQUEST_ERROR with error code UNSUPPORTED_EXTENSION. -Nandakumar, et al. Expires 4 March 2027 [Page 23] +Nandakumar, et al. Expires 4 April 2027 [Page 19] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - * For SUBSCRIBE_OK messages: the subscriber MUST cancel the - subscription (see Section 3.3.3). If the subscriber is a relay - with pending downstream subscribers, it MUST send REQUEST_ERROR - with error code UNSUPPORTED_EXTENSION to the downstream - subscribers. + +--------+ + | Idle | + +--------+ + | | + SUBSCRIBE | | PUBLISH + (subscriber)| | (publisher) + V V + +--------------+ +--------------+ + | Pending | | Pending | + +----| (Subscriber) | | (Publisher) |----+ + | +--------------+ +--------------+ | + | | | | +SUBSCRIBE_ERROR | SUBSCRIBE_OK | | PUBLISH_OK | PUBLISH_ERROR +(publisher) | (publisher)| | (subscriber) | (subscriber) + | V V | + | +-------------+ | + | | Established | ------+ + | | | | REQUEST_UPDATE + | +-------------+ <-----+ + | | | | + +--- STOP_SENDING | | PUBLISH_DONE ----+ + | (subscriber)| | (publisher) | + | V V | + | +-------------+ | + +----------->| Terminated | <------------+ + +-------------+ - * For FETCH_OK messages: the subscriber MUST cancel the fetch (see - Section 3.3.3). If the subscriber is a relay and has not yet sent - a FETCH_OK or REQUEST_ERROR downstream, it MUST send REQUEST_ERROR - with error code UNSUPPORTED_EXTENSION to the downstream fetch - requester. If the relay has already forwarded data on a fetch - stream, it MUST reset the stream. + A publisher MUST send exactly one SUBSCRIBE_OK or SUBSCRIBE_ERROR in + response to a SUBSCRIBE. A subscriber MUST send exactly one + PUBLISH_OK (Section 9.3) or PUBLISH_ERROR in response to a PUBLISH. + The peer SHOULD close the session with a protocol error if it + receives more than one. - A publisher that knows a subscriber does not support a Mandatory - Track Property SHOULD take the following action: + Either endpoint can initiate a subscription to a track without + exchanging any prior messages other than SETUP. Relays MUST NOT send + any PUBLISH messages without knowing the client is interested in and + authorized to receive the content. The communication of intent and + authorization can be accomplished by the client sending + SUBSCRIBE_NAMESPACE, or conveyed in other mechanisms out of band. - * For SUBSCRIBE: respond with REQUEST_ERROR with error code - UNSUPPORTED_EXTENSION. + An endpoint MAY SUBSCRIBE to a Track it is publishing, though only + Relays are required to handle such a SUBSCRIBE. Such self- + subscriptions are identical to subscriptions initiated by other + endpoints, and all published Objects will be forwarded back to the + endpoint, subject to priority and congestion response rules. - * For FETCH: respond with REQUEST_ERROR with error code - UNSUPPORTED_EXTENSION. - * For PUBLISH: do not publish the track to that subscriber. -3. Sessions -3.1. Session establishment - This document defines a protocol that can be used interchangeably - both over a QUIC connection directly [QUIC], and over WebTransport - [WebTransport]. Both provide streams and datagrams with similar - semantics (see [I-D.ietf-webtrans-overview], Section 4); thus, the - main difference lies in how the servers are identified and how the - connection is established. The QUIC DATAGRAM extension ([RFC9221]) - MUST be supported and negotiated in the QUIC connection used for - MOQT, which is already a requirement for WebTransport over HTTP/3. - There is no definition of the protocol over other transports, such as - TCP, and applications using MOQT might need to fallback to another - protocol when QUIC or WebTransport aren't available. +Nandakumar, et al. Expires 4 April 2027 [Page 20] + +Internet-Draft moq-transport October 2026 - MOQT uses ALPN in QUIC and "WT-Available-Protocols" in WebTransport - ([WebTransport], Section 3.3) to perform version negotiation. - The ALPN value [RFC7301] for the final version of this specification - is moqt. + An endpoint MAY have multiple concurrent subscriptions to the same + Track, each identified by a unique Request ID. A publisher MAY + assign the same or different Track Aliases to these subscriptions. + When an Object matches the filters of multiple subscriptions to the + same Track, the publisher MUST send the Object once for each matching + subscription, even when those subscriptions share the same Track + Alias. Because subscriptions can share a Track Alias, the subscriber + re-applies each subscription's filter to determine which subscription + a received Object belongs to. Subscribers SHOULD avoid overlapping + filters across subscriptions to the same Track, as they are + responsible for deduplicating any resulting duplicate Objects. + A publisher SHOULD begin sending incomplete objects when available to + avoid incurring additional latency. + Publishers MAY start sending Objects on PUBLISH-initiated + subscriptions before receiving a PUBLISH_OK response to reduce + latency. Doing so can consume unnecessary resources in cases where + the Subscriber rejects the subscription with PUBLISH_ERROR or pauses + the subscription (see below). It can also result in the Subscriber + dropping Objects if its buffering limits are exceeded (see + Section 11.2 and Section 11.3.1). + An object published or received in a subgroup or datagram is + *subscription-delivered*. -Nandakumar, et al. Expires 4 March 2027 [Page 24] - -Internet-Draft moq-transport August 2026 +3.1.1. Pausing Subscriptions + An Established subscription is either paused or not paused. The + publisher does not send Objects on a paused subscription, and does + send them when it is not paused. Control messages, such as + PUBLISH_DONE (Section 9.9), are sent regardless of whether the + subscription is paused. - [[RFC editor: please remove the remainder of this section before - publication.]] + The initiator of the subscription sets the initial state by including + the FORWARD parameter (Section 9.20.18) in PUBLISH or SUBSCRIBE. The + subscriber can pause an Established subscription by sending + REQUEST_UPDATE with FORWARD set to 0, or resume it by sending + REQUEST_UPDATE with FORWARD set to 1. - ALPNs used to identify IETF drafts are created by appending the draft - number to "moqt-". For example, draft-ietf-moq-transport-13 would be - identified as "moqt-13". +3.1.2. Subscription State Management - Note: Draft versions prior to -15 all used moq-00 ALPN, followed by - version negotiation in the SETUP messages. + A subscriber keeps subscription state until it cancels the request + (see Section 6.4.2.3), or until receipt of a PUBLISH_DONE or + REQUEST_ERROR. Note that PUBLISH_DONE does not usually indicate that + state can immediately be removed, see Section 9.9. -3.1.1. MOQT URI Scheme - An MOQT server is identified using a URI with the "moqt" scheme. The - "moqt" URI scheme is defined as follows, using definitions from - [RFC3986]: - moqt-URI = "moqt" "://" authority path-abempty [ "?" query ] - The authority portion MUST NOT contain an empty host portion. The - moqt URI scheme supports the /.well-known/ path prefix defined in - [RFC8615]. +Nandakumar, et al. Expires 4 April 2027 [Page 21] + +Internet-Draft moq-transport October 2026 - The moqt URI scheme follows the generic URI syntax of [RFC3986] for - the authority, path-abempty, and query components, including the use - of reserved characters and percent-encoding defined therein. A moqt - URI can be converted to an https URI by replacing the scheme (see - Section 3.1.4), so the path-abempty and query components use the same - syntax as https URIs. -3.1.2. Fragment Identifiers + The Publisher can remove subscription state as soon as it has + received STOP_SENDING. It MUST reset any open streams associated + with the SUBSCRIBE. - The media type for resources identified by moqt URIs is application/ - moqt (see Section 15.2). + The Publisher can also immediately delete subscription state after + sending PUBLISH_DONE, but MUST NOT send it until it has closed all + related streams. - Fragment identifiers MAY be used with moqt URIs. The fragment is not - transmitted to the server; it is processed locally by the client - after establishing the MOQT session. + A REQUEST_ERROR indicates no objects will be delivered, and both + endpoints can immediately remove relevant state. Objects MUST NOT be + sent for requests that end with an error. - A moqt URI fragment MUST begin with a registered fragment type - identifier, followed by a colon (:), followed by a type-specific - value: +3.1.3. Track Alias - moqt://example.com/app#: + To optimize wire efficiency, Subgroups and Datagrams refer to a track + by a numeric identifier, rather than the Full Track Name. Track + Alias is chosen by the publisher and included in SUBSCRIBE_OK + (Section 9.7) or PUBLISH (Section 9.8). - Fragment type identifiers MUST consist of ASCII lowercase letters, - digits, and hyphens (a-z, 0-9, -). The semantics of the value after - the colon are defined by the specification that registers the - fragment type. + The same Track Alias MUST NOT be used by a publisher to refer to two + different Tracks simultaneously in the same session. If a subscriber + receives a PUBLISH or SUBSCRIBE_OK that uses the same Track Alias as + a different Track with an Established subscription, it MUST close the + session with error DUPLICATE_TRACK_ALIAS. + Objects can be sent before the Subscriber knows the Track Alias, + requiring buffering Objects with an unknown Track Alias. If a Track + Alias is used for two concurrent subscriptions to the same Track, an + Object that arrives with the Track Alias could be for either + Subscription. Reusing the same Track Alias for concurrent + subscriptions to the same Track can lead to missed delivery if + objects for the new subscription arrive before the control message + establishing the shared Alias. The Subscriber can assume the Track + Alias is reused until told otherwise, in order to avoid missing + Objects. + To avoid a protocol violation and to ensure the Subscriber knows + which Track Objects are from, Publishers SHOULD NOT reuse a Track + Alias for different Tracks within a session, unless it is certain the + prior Subscription has been completely closed and no Objects are + scheduled to be sent or in flight. -Nandakumar, et al. Expires 4 March 2027 [Page 25] - -Internet-Draft moq-transport August 2026 + Objects can arrive after a subscription has been cancelled. + Subscribers SHOULD retain sufficient state to quickly discard these + unwanted Objects, rather than treating them as belonging to an + unknown Track Alias. - Fragment type identifiers are registered in the "MOQT URI Fragment - Types" registry (Section 15.3). -3.1.3. Dereferencing a MOQT URI - The default operation for dereferencing a moqt URI is to establish a - MOQT session to the identified server. - The moqt URI scheme has the following security considerations: +Nandakumar, et al. Expires 4 April 2027 [Page 22] + +Internet-Draft moq-transport October 2026 - * The authority component is sent in the TLS SNI extension during - connection establishment, exposing the target server identity to - on-path observers. Encrypted Client Hello (ECH) [RFC9580] can - mitigate this exposure. - * The path-abempty and query components are visible to the relay - that terminates the client's connection. +3.1.3.1. Unknown Track Alias - TODO: Add internationalization statement per RFC 7595 Section 3.6. + When an endpoint receives a datagram or a new stream with a Track + Alias that is not yet associated with an Established subscription, it + MAY drop the data or buffer it briefly to handle reordering with the + control message that establishes the Track Alias. For streams, the + endpoint MAY withhold stream flow control beyond the stream header + until the Track Alias has been established. To prevent deadlocks, + endpoints MUST allocate connection flow control to control streams + before allocating it to any data streams; otherwise a receiver might + wait for a control message containing a Track Alias to release flow + control, while the sender waits for flow control to send the message. - The client resolves the host subcomponent of the authority to one or - more network addresses, most commonly using DNS A [RFC1035] and AAAA - [RFC3596] records. +3.1.4. Largest Object - When SVCB-compatible records [RFC9460] are published for the - authority, a client MAY use them to learn the server's endpoints and - supported ALPN protocols before connecting. A client using - WebTransport resolves the https URI derived in Section 3.1.4 using - HTTPS resource records as for any https origin. TODO: reference moqt - SVCB record draft once available. + The Largest Object is the Object with the largest Location + (Section 8.2) in the Track from the perspective of the publisher + processing the message. Largest Object updates when the first byte + of an Object with a Location larger than the previous value is + published or received through a subscription. Largest Object + therefore identifies an Object that can still be arriving. - If the port is omitted in the URI, a default port of 443 is used. + The Next Object is the Location immediately following Largest Object, + which is {Largest Object.Group, Largest Object.Object + 1}, or {0, 0} + if no content has been delivered yet. The Next Group is the first + Location of the Group following Largest Object, which is {Largest + Object.Group + 1, 0}. Next Object and Next Group are Locations that + do not necessarily refer to an Object that exists. - The client MAY use either native QUIC or WebTransport. On a QUIC - connection, the client offers any combination of MOQT ALPNs (e.g. - moqt-1, moqt-2) and h3 that it supports in its TLS ClientHello, in - preference order. If the server selects an MOQT ALPN, the session - proceeds as described in Section 3.1.5. If the server selects h3, - the client establishes a WebTransport session as described in - Section 3.1.4. On a TCP+TLS connection, the client offers h2 in its - TLS ClientHello and establishes a WebTransport session as described - in Section 3.1.4. +3.2. Fetch + + A FETCH requests pre-existing Objects from a Track between a Start + Location and an End Location, inclusive. This range is specified by + a Location Filter (see Section 3.3.1) when present, or defaults to + {0, 0} and Largest Object (Section 3.1.4) respectively. + Objects with Locations larger than the Largest Object at the time the + request is processed will not be retrieved by a FETCH. The actual + end of the FETCH response is indicated in the FETCH_OK End Location + (see Section 9.12). Because Largest Object can identify an Object + that is still arriving (Section 3.1.4), a FETCH whose range includes + Largest Object includes that Object in full; the publisher delivers + the remainder as it becomes available. @@ -1453,334 +1285,390 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 26] +Nandakumar, et al. Expires 4 April 2027 [Page 23] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 -3.1.4. WebTransport + The publisher MUST send exactly one FETCH_OK or FETCH_ERROR in + response to a FETCH. The FETCH_OK or FETCH_ERROR can come at any + time relative to object delivery. The publisher MAY send Objects in + response to a FETCH before the FETCH_OK message is sent, but the + FETCH_OK MUST NOT be sent until the End Location is known. - When the client uses WebTransport, it constructs an https URI from - the moqt URI by replacing the scheme with https. For example, - moqt://example.com/path becomes https://example.com/path. The client - sends an extended CONNECT request to this URI to establish a - WebTransport session, as described in ([WebTransport], Section 3). - The client includes MOQT protocol identifiers in the WT-Available- - Protocols header ([WebTransport], Section 3.3). + If no Objects have been published for the track or Start Location is + greater than the Largest Object (Section 3.1.4) the publisher MUST + return FETCH_ERROR with error code INVALID_RANGE. -3.1.5. Native QUIC +3.2.1. Fetch Object Delivery - The client establishes a QUIC connection to the host and port - identified by the authority section of the URI. When the client uses - native QUIC, the authority, path-abempty and query portions of the - URI are transmitted in Setup Options (see Section 10.3.1). + The publisher creates a single unidirectional stream (see + Section 11.4) that is used to send the Objects. If no Objects exist + in the requested range, the publisher opens the unidirectional + stream, sends the FETCH_HEADER (see Section 11.4.1) and closes the + stream with a FIN. -3.1.6. Connection URL + A publisher MUST send fetched groups in the requested group order + (see Section 9.20.8). Within each group, objects are sent in Object + ID order; subgroup ID is not used for ordering. The Object Delivery + Mode does not apply. - Each track MAY have one or more associated connection URLs specifying - network hosts through which a track may be accessed. The syntax of - the Connection URL and the associated connection setup procedures are - specific to the underlying transport protocol usage (see Section 3). +3.2.2. Gaps in a Fetch Stream -3.2. Extension Negotiation + A gap in a fetch stream occurs when the publisher has no object for + the next ordered Location. A gap can occur because the object does + not exist, the object was filtered out by the subscriber, or the + object state cannot be determined (e.g. a Relay has temporarily lost + contact with the Original Publisher and does not have the Object in + cache). - Endpoints use the exchange of Setup messages to negotiate MOQT - extensions. Extensions can define new Message types, new Parameters, - new Properties, new Parameter values, or new framing for Streams and - Datagrams. + Unless the request included Range Filters (see Section 3.3.2), any + gaps in the Group and Object IDs in the response stream that are not + otherwise marked indicate objects that do not exist (see + Section 2.1.2). When one or more Range Filters are present, unmarked + gaps indicate objects in the unknown state. - The client and server MUST include all Setup Options Section 10.3.1 - required for the negotiated MOQT version in SETUP. + For Ascending Group Order, and Descending Group Order where Start and + End Location are in the same group, gaps include ranges between the + Start Location and the first object in the stream; between objects in + the stream; and between the last object in the stream and the End + Location indicated in FETCH_OK. - Each endpoint declares the extensions it supports and provides any - initial values required by those extensions as Setup Options in - SETUP. Once an endpoint has both sent and received SETUP messages, - it determines the set of negotiated extensions. + For Descending Group Order where Start and End Location are in + different groups, the first expected Object in the stream is {End + Location.Group, 0} and the last expected Object in the stream is + {Start Location.Group, 2^64-1}. When two consecutive objects A and B - New versions of MOQT MUST specify which existing extensions can be - used with that version. New extensions MUST specify the existing - versions with which they can be used. +Nandakumar, et al. Expires 4 April 2027 [Page 24] + +Internet-Draft moq-transport October 2026 + are in different groups, a gap represents multiple logical gaps: the + tail of A.Group; all skipped groups; and {B.Group, 0} through B, + exclusive. + Gaps at the end of a stream are only detectable when the stream is + terminated by a FIN. + When the cause of the gap differs from the default, the publisher + marks the range of Objects it will not serialize with an End of Range + indicator (see Section 11.4.1.2), identifying those Objects as non- + existent, unknown, or timed out. A publisher SHOULD NOT use End of + Non-Existent Range in a FETCH response except to split a range of + Objects that will not be serialized into those that are known not to + exist and those with unknown or timed out status. + If a Publisher receives a FETCH with a range that includes one or + more Objects with unknown state, it can choose to reset the FETCH + data stream with UNKNOWN_OBJECT_STATUS (Section 12.5), or indicate + the range of unknown Objects (End of Unknown Range, see + Section 11.4.1.2) and continue serving other known Objects. When + resetting the stream, the publisher can do so immediately or after + previously sent objects are delivered. If it has not yet sent + FETCH_OK, it can send FETCH_ERROR in addition to resetting the + stream. +3.2.3. Relay Fetch Handling -Nandakumar, et al. Expires 4 March 2027 [Page 27] - -Internet-Draft moq-transport August 2026 + A relay that has cached objects from the beginning of the range MAY + start sending objects immediately in response to a FETCH. When a + relay encounters Objects within the requested range that are not + immediately available and have unknown status, it issues one or more + upstream FETCHes to retrieve them. + If an upstream FETCH fails, the relay indicates the range of unknown + Objects or resets the FETCH data stream, as described above. -3.2.1. Reserved Namespaces + The Fill Timeout (see Section 9.20.5) represents a total budget for + all upstream FETCHes generated by a single request. If the budget is + exhausted, the relay reports any remaining unavailable Objects as + Timed-Out gaps (End of Timed-Out Range, see Section 11.4.1.2) and + continues delivering available Objects in the range. - MOQT reserves all Track Namespace values whose first tuple field - begins with a period (0x2e, .). These namespaces MUST NOT be used - unless their meaning is defined through IANA registration. Unless - otherwise specified, an endpoint that receives a request for an - unrecognized reserved namespace MUST pass it to the Application, so - that future extensions can define new reserved namespaces without - breaking older implementations. - A Track Namespace whose first field is exactly . (a single period, - 0x2e) is reserved and MUST NOT be used for any purpose; endpoints - MUST NOT publish tracks or namespaces under it and MUST reject - requests referencing it with DOES_NOT_EXIST. -3.2.2. Session-Level Tracks and Namespaces - MOQT defines the .session namespace (the bytes 0x2e, 0x73, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e) in the first position of the Track - Namespace for session-level tracks and namespaces. Session-level - tracks and namespaces are managed by the MOQT implementation, not the - Application. They provide a mechanism for extending MOQT transport - functionality using existing subscription and object delivery - machinery, without defining new control messages or stream types. - The Application MUST NOT publish tracks or namespaces whose first - field is .session. Relays MUST NOT forward requests for session- - level tracks and namespaces to other sessions. - The empty track name in the .session namespace is defined to not - exist. A request with a Track Namespace whose first field is - .session and an empty Track Name MUST be rejected with - DOES_NOT_EXIST. - An endpoint that receives a request for an unrecognized session-level - track or namespace MUST reject it with REQUEST_ERROR using error code - DOES_NOT_EXIST rather than passing it to the Application. - The track names and namespaces available under the .session namespace - are defined by extensions to this specification and registered with - IANA (see Section 15.10). +Nandakumar, et al. Expires 4 April 2027 [Page 25] + +Internet-Draft moq-transport October 2026 +3.2.4. Fetch State Management + A subscriber keeps FETCH state until it cancels the request (see + Section 6.4.2.3), receives FETCH_ERROR, or the FETCH data stream + receives a FIN or is reset. If the data stream is already open, the + subscriber wishing to cancel the FETCH MAY send STOP_SENDING for the + data stream as well as the bidi request stream. It MUST send + STOP_SENDING for the bidi request stream. + The Publisher can remove fetch state as soon as it has received a + STOP_SENDING. It MUST reset the bidi request stream and + unidirectional data stream associated with the FETCH. It can also + remove state after closing the FETCH data stream. + It can remove all FETCH state after closing the data stream with a + FIN. + A FETCH_ERROR indicates that both endpoints can immediately remove + state. Since a relay can start delivering FETCH Objects from cache + before determining the result of the request, some Objects could be + received even if the FETCH results in error. +3.3. Filtering Tracks and Objects -Nandakumar, et al. Expires 4 March 2027 [Page 28] - -Internet-Draft moq-transport August 2026 +3.3.1. Location Filters + A Location filter specifies an inclusive range of Locations or an + inclusive start Location and an open-ended end location. Only + objects with Locations within the inclusive range pass the filter. A + Location filter is encoded as specified in Section 9.20.9. -3.3. Session initialization + Subscribers can specify a Location filter on a subscription to + indicate to the publisher which Objects to send. Subscriptions + without a filter pass all Objects published or received via upstream + subscriptions. - MOQT uses a pair of unidirectional streams for creating the session - and exchanging control messages. Each peer opens one control stream - beginning with a SETUP message. Using a pair of unidirectional - streams rather than a single bidirectional stream allows either peer - to send data as soon as it is able. Depending on whether 0-RTT is - available on the QUIC connection, either the client or the server - might be able to send stream data first. + Fetch requests can also specify a Location filter (see Section 3.2). - In addition to the control streams, this specification uses - bidirectional streams to carry requests. A request stream begins - with one of these seven message types: TRACK_STATUS, SUBSCRIBE, - PUBLISH, FETCH, PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, and - SUBSCRIBE_TRACKS. Bidirectional streams MUST NOT begin with any - other message type unless negotiated. If they do, the peer MUST - close the Session with a PROTOCOL_VIOLATION. Objects are sent on - unidirectional streams. + Some Location filters are defined to be relative to the Largest + Object (Section 3.1.4). - As such, a client can initiate a MOQT session, subscribe, and start - publishing Objects all in parallel. When this is done before the - handshake completes using 0-RTT, the security implications described - in Section 3.3.1 apply. + A Location Filter on a subscription is always valid, even if it + specifies a range entirely before Largest Object. - Unidirectional streams containing Objects or bidirectional stream(s) - beginning with a request message could arrive prior to the control - streams, in which case the data SHOULD be buffered until both control - streams arrive and setup is complete. If an implementation does not - want to buffer or if the message type is not supported, it MAY reset - such bidirectional streams before the session and control streams are - established. + Note that due to network reordering or prioritization, relays can + receive Objects with Locations smaller than Largest Object after the + filter is processed, but these Objects do not pass a filter that + starts at the Next Object. - A control stream MUST NOT be closed at the underlying transport layer - during the session's lifetime. Doing so results in the session being - closed as a PROTOCOL_VIOLATION. - Prior to receiving the peer's SETUP message, it's unknown what - extensions a peer will support. Message Parameters requiring - negotiation SHOULD NOT be used prior to receiving the peer's SETUP - message unless the application requires the extension or the endpoint - knows the peer supports the extension. If an unsupported Message - Parameter is used, the peer will be unable to process it and the - session will be terminated. See Section 10.2. +Nandakumar, et al. Expires 4 April 2027 [Page 26] + +Internet-Draft moq-transport October 2026 + A publisher MUST NOT send objects from outside the requested range. + Because updating filters is asynchronous, subscribers can receive + objects outside the current filter. + A publisher does not end a subscription solely because the Largest + Object advances past the end of the current Location Filter. +3.3.2. Range Filters + Range Filters are parameters in SUBSCRIBE, FETCH, or SUBSCRIBE_TRACKS + that tell a publisher to filter tracks (via TRACK PROPERTY FILTER) + and objects according to subscriber-provided criteria. Range filters + are specified as ranges of integer values in Track and Object + Properties and other Object header fields (Subgroup ID, Object ID, + and Publisher Priority). There are five Range Filter parameter + types, 0x25-0x29. They share the encoding specified in Section 8.6. + An object matches the filter if its value falls within any Range + (i.e., Ranges are OR'd within a filter parameter). -Nandakumar, et al. Expires 4 March 2027 [Page 29] - -Internet-Draft moq-transport August 2026 + Each Range Filter parameter carries a SetID, which identifies the set + of filters it belongs to. Filter parameters with the same SetID are + AND'd; distinct SetIDs are OR'd. The final result is SetID=0 OR + SetID=1 OR ... SetID=255, where each SetID=i is the AND of all filter + parameters carrying that SetID. + The Track Property filter parameter MAY appear multiple times in a + SUBSCRIBE_TRACKS message or REQUEST_UPDATE for it. All other filter + parameters MAY appear multiple times in a FETCH, SUBSCRIBE, + SUBSCRIBE_TRACKS, or REQUEST_UPDATE (on a subscription, from the + subscriber only) message. If the same combination of Parameter Type, + SetID, and Property Type (only in the Track and Object Property + Filters) repeat in any message, an endpoint MUST reject this with + REQUEST_ERROR with error code INVALID_FILTER. -3.3.1. 0-RTT + In REQUEST_UPDATE, Length of 0 removes the filter; non-zero replaces + it entirely. If a filter parameter is omitted from REQUEST_UPDATE, + it is unchanged. If omitted from other messages, the default is no + filter. - QUIC supports 0-RTT (Section 2.3 of [RFC8446]), but WebTransport over - QUIC is not expected to use 0-RTT, because initializing a - WebTransport session uses CONNECT, which is not a safe method. - [RFC8470] describes the use of 0-RTT with HTTP in more detail. If - 0-RTT is used with an existing or future version of WebTransport, the - following would apply to it as well as QUIC. + Range Filters are only allowed if the setup option MAX_FILTER_RANGES + is non-zero, which limits the total number of Ranges allowed in all + Range Filter parameters for a given subscription or fetch. If this + limit is exceeded, an endpoint MUST reject this with REQUEST_ERROR + with error code INVALID_FILTER. - MOQT Messages and Objects as defined in this draft are safe to replay - in most circumstances. - * TRACK_STATUS gets the Largest Object and Track Properties, but - does not change the state of a Track or any Object in the Track. - * SUBSCRIBE requests Objects be delivered, but does not change the - Objects being requested. - * PUBLISH initiates a Subscription. Objects can be immediately sent - to the Subscriber. Processing the same Objects multiple times is - idempotent, as the subscriber or relay can identify and discard - duplicates based on the Group ID and Object ID. - * SUBSCRIBE_NAMESPACE requests a list of namespaces and the - establishment of new subscriptions, but does not change the - available Namespaces, Tracks, or Objects contained within a Track. - * PUBLISH_NAMESPACE requests that Subscriptions under the namespace - be sent to that Publisher. If a Subscription was sent to the - replaying endpoint, it would fail because the endpoint cannot - complete the handshake. +Nandakumar, et al. Expires 4 April 2027 [Page 27] + +Internet-Draft moq-transport October 2026 - Some potential side effects of replay are: - * Publishing Objects that were previously published could cause - those Objects to be distributed to active Subscriptions if the - relays do not identify them as already having been published. - This re-distribution could also make them available in cache again - after they previously expired. + The Track Property Filter can be used in SUBSCRIBE_TRACKS to filter + PUBLISH messages with required Track Property types and values. + PUBLISH messages which pass the filter will be forwarded while those + which do not pass it will not be forwarded nor will any Objects. - Replays could increase load on the MOQT network. For relay to client - traffic, this is no worse than 0-RTT in HTTP/3, since the server is - limited by the amplification factor until address validation. - However, it could cause the relay to initiate new upstream - Subscriptions. For a SUBSCRIBE_TRACKS request, sending that upstream - could cause the Relay to receive a number of new Subscriptions on the - replaying client's behalf. + The Object Property Filter can be used to filter Objects with + required Object Property types and values. It only filters Object + Properties, and does not evaluate Track Properties in PUBLISH + messages. +3.3.3. Combining Filters + All filter types are combined using logical "AND" operations to + further restrict which tracks and objects pass all filter criteria. + This includes all Range Filters Section 3.3.2 and Location Filters + Section 3.3.1, which can be evaluated in any order. The Forward + parameter is also a type of filter. The publisher MUST forward only + objects that pass all filters. + Pass = Forward AND Location Filters AND Range Filters -Nandakumar, et al. Expires 4 March 2027 [Page 30] - -Internet-Draft moq-transport August 2026 +3.4. Fill Semantics + A subscription that carries a FILL_PARAMETERS parameter (see + Section 9.20.15) causes the publisher to open a unidirectional stream + beginning with a FETCH_HEADER (see Section 11.4.1) and delivered as a + FETCH response (see Section 9.11). This is called a fill fetch + stream. - Relays MAY defer initiating upstream subscriptions until the - handshake is complete or reject 0-RTT entirely to mitigate resource - exhaustion from replayed packets. + The *fill range* is the range of Locations selected by the Location + filter inside FILL_PARAMETERS, or the subscription's Location filter + if it is omitted. The filter is evaluated using the rules for a + Fetch in Section 9.20.9, so the fill range never extends beyond + Largest Object. When the subscription has no Location filter, or the + LOCATION_FILTER inside FILL_PARAMETERS is zero-length, the fill range + is the entire track up to Largest Object. The subscriber learns the + Largest Object from the LARGEST_OBJECT parameter in SUBSCRIBE_OK or + REQUEST_UPDATE_OK. -3.3.2. Graceful Request Stream Closure + Because the fill range is specified independently of the + subscription's Location filter, a subscriber can retrieve a range of + Groups prior to Largest Object while the subscription itself starts + at the Next Group. If the fill range is empty, or starts after + Largest Object, the publisher does not open a fill fetch stream. - A request stream is bidirectional and each direction is closed - independently, either gracefully with a FIN or abruptly with - RESET_STREAM. - A FIN only indicates that an endpoint will send no further messages - in that direction; it is not a request cancellation. An endpoint - MUST NOT send a FIN on a direction of a request stream until it has - sent all required messages on that direction for its request type. - In particular, an endpoint sending a response to a request MUST send - the corresponding response message, and the publisher of an - Established subscription MUST send PUBLISH_DONE, before sending a - FIN. A FIN sent by the responder after its response and any - subsequent messages for the request signals that the request is - complete; if it has not already done so, the requester SHOULD then - send a FIN on its direction, gracefully closing the stream. An - endpoint that receives a FIN before all required messages have - arrived treats the request as failed. - An endpoint SHOULD send a FIN promptly after a message when it has - nothing further to send on that direction and will not need to - respond to a future REQUEST_UPDATE. A requester, with the exception - of the sender of PUBLISH, MAY FIN immediately after sending a message - if it will not send a REQUEST_UPDATE. -3.3.3. Request Cancellation and Rejection - Once a request stream has been opened, the request MAY be cancelled - by either endpoint. Senders cancel requests if the response is no - longer of interest; Receivers cancel requests if they are unable to - or choose not to respond. Implementations cancel a request by - abruptly terminating any directions of the stream that are still - open, using RESET_STREAM for a direction they are sending and - STOP_SENDING for a direction they are receiving. An endpoint that - has already sent a FIN on its sending direction and subsequently - wishes to cancel sends STOP_SENDING on the receiving direction. - When an endpoint rejects a request without performing any application - processing, it SHOULD send a REQUEST_ERROR and FIN the stream. +Nandakumar, et al. Expires 4 April 2027 [Page 28] + +Internet-Draft moq-transport October 2026 + The fill fetch stream inherits the subscription's parameters, + including subscriber priority, range filters and authorization; + parameters carried inside FILL_PARAMETERS override them for the fill + fetch stream. FILL_TIMEOUT (see Section 9.20.5) applies to fill + fetch streams in the same way it applies to a FETCH. + The FETCH_HEADER on the fill fetch stream carries the Request ID of + the message that initiated it: the SUBSCRIBE Request ID for the + initial fill, or the REQUEST_UPDATE Request ID for a subsequent fill. + As a result of REQUEST_UPDATE, a subscription can have multiple fill + fetch streams open at once, each identified by its Request ID; + opening a new fill fetch stream does not implicitly cancel any + previously opened fill fetch streams. + An object delivered on the fill fetch stream is *fill-delivered*. + When the fill range overlaps the subscription's Location filter, an + object can be both fill-delivered and subscription-delivered. A + subscriber that wants each Object delivered exactly once uses the + Next Object Subscription Location Filter coupled with an open-ended + fill range, which the publisher will end at Largest Object. +3.4.1. Opening and Closing Fill Fetch Streams -Nandakumar, et al. Expires 4 March 2027 [Page 31] - -Internet-Draft moq-transport August 2026 + A publisher opens a fill fetch stream when it processes a SUBSCRIBE + or REQUEST_UPDATE that carries FILL_PARAMETERS while the subscription + is not paused (see Section 3.1.1). + * FILL_PARAMETERS carried while the subscription is paused opens no + fill fetch stream. Resuming the subscription without re-sending + FILL_PARAMETERS does not open one either. -3.3.4. Stream Reset Error Codes + * A REQUEST_UPDATE that does not carry FILL_PARAMETERS does not open + a new fill fetch stream. - The application SHOULD use a relevant error code when resetting or - sending STOP_SENDING on any stream. + * When the subscription is cancelled, the publisher MUST reset any + open fill fetch streams. - INTERNAL_ERROR (0x0): An implementation specific error. + The publisher signals that the fill is complete by closing the stream + with a FIN once all objects in the fill range have been delivered. + Because there is no REQUEST_ERROR associated with a fill fetch + stream, the publisher signals a fill failure by resetting the stream; + it MUST open a fill fetch stream and reset it immediately after the + FETCH_HEADER if necessary. A subscriber can cancel a fill fetch + stream independently using STOP_SENDING. Resetting or cancelling a + fill fetch stream, by either endpoint, does not affect the + subscription, which continues to deliver objects using subscribe + subgroups and datagrams. - CANCELLED (0x1): The stream was cancelled by either endpoint. For - Subscriptions, PUBLISH_DONE (Section 10.12) may have a more - detailed status code. - DELIVERY_TIMEOUT (0x2): A delivery timeout (Section 8) was exceeded - for this stream. - SESSION_CLOSED (0x3): The session is being closed. - GOING_AWAY (0x4): The endpoint is rejecting this request because it - has sent or received a GOAWAY. +Nandakumar, et al. Expires 4 April 2027 [Page 29] + +Internet-Draft moq-transport October 2026 - TOO_FAR_BEHIND (0x5): The corresponding subscription has exceeded - the publisher's resource limits and is being terminated (see - Section 8). - UNKNOWN_OBJECT_STATUS (0x6): In response to a FETCH, the publisher - is unable to determine the status of the next Object in the - requested range. +3.5. Joining an Ongoing Track - EXPIRED_AUTH_TOKEN (0x7): The authorization token for the request - has expired. + The MOQT Object model is designed with the concept that the beginning + of a Group is a join point, so in order for a subscriber to join a + Track, it needs to request an existing Group or wait for a future + Group. Different applications will have different approaches for + when to begin a new Group. - EXCESSIVE_LOAD (0x9): The endpoint is overloaded and is resetting - this stream. + To join a Track immediately, the subscriber sends a SUBSCRIBE with a + Location Filter Section 3.3.1 that starts at the Next Object. + Delivery begins with the next Object and can begin mid-group. - MALFORMED_TRACK (0x12): A relay publisher detected that the track - was malformed (see Section 2.4.2). + To join a Track at the current Group, the subscriber sends a + SUBSCRIBE with a Location Filter that starts at the Next Object and a + FILL_PARAMETERS parameter (see Section 9.20.15) whose Location filter + has StartGroup=1, which fills the current Group from its start. -3.4. Unidirectional Stream Types + To join a Track at a past Group, the subscriber sends a SUBSCRIBE + with a FILL_PARAMETERS parameter whose Location filter selects the + intended Groups, which can be relative. The publisher delivers the + fill range on a fill fetch stream and subscription-delivered Objects + in subgroups or datagrams (see Section 3.4). - All unidirectional MOQT streams start with a variable-length integer - indicating the type of the stream. + To join a Track at the next Group, the subscriber sends a SUBSCRIBE + with a Location Filter Section 3.3.1 that starts at the Next Group. +3.5.1. Dynamically Starting New Groups + While some publishers will deterministically create new Groups, other + applications might want to only begin a new Group when needed. A + subscriber joining a Track might detect that it is more efficient to + request the Original Publisher create a new group than to fill the + current group. Publishers indicate a Track supports dynamic group + creation using the DYNAMIC_GROUPS Track Property (Section 10.6). + One possible subscriber pattern is to SUBSCRIBE to a Track using a + Location Filter that starts at the Next Object and observe the + Largest Object in the response. If the Object ID is below the + application's threshold, the subscriber sends a FETCH for the + beginning of the Group. If the Object ID is above the threshold and + the Track supports dynamic groups, the subscriber sends a + REQUEST_UPDATE message with the NEW_GROUP_REQUEST parameter equal to + the Next Group (see Section 9.20.19). @@ -1789,607 +1677,607 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 32] +Nandakumar, et al. Expires 4 April 2027 [Page 30] -Internet-Draft moq-transport August 2026 - +Internet-Draft moq-transport October 2026 - +============+==================================+ - | ID | Type | - +============+==================================+ - | 0x05 | FETCH_HEADER (Section 11.4.4) | - +------------+----------------------------------+ - | 0b0XX1XXXX | SUBGROUP_HEADER (Section 11.4.2) | - +------------+----------------------------------+ - | 0x2F00 | SETUP (Section 10.3) | - +------------+----------------------------------+ - | 0x132B3E28 | PADDING (Section 11.5.1) | - +------------+----------------------------------+ - Table 3 + Another possible subscriber pattern is to send a SUBSCRIBE with a + Location Filter that starts at the Next Group and NEW_GROUP_REQUEST + equal to 0. The value of DYNAMIC_GROUPS in SUBSCRIBE_OK will + indicate if the publisher supports dynamic groups. A publisher that + does will begin the next group as soon as practical. - An endpoint that receives an unknown stream type MUST close the - session. +3.6. Subscribing to Tracks by Prefix - Control streams (SETUP) are described in Section 3.3. Data streams - (FETCH_HEADER, SUBGROUP_HEADER) are described in Section 11. Padding - streams are described in Section 11.5. + SUBSCRIBE_TRACKS requests subscriptions: the publisher sends PUBLISH + messages for tracks within matching namespaces, excluding tracks + published by the subscriber. -3.5. Termination + A SUBSCRIBE_TRACKS with zero Track Namespace fields indicates the + subscriber is requesting a Subscription for all Tracks from the + publisher. - The Transport Session can be terminated at any point. When native - QUIC is used, the session is closed using the CONNECTION_CLOSE frame - ([QUIC], Section 19.19). When WebTransport is used, the session is - closed using the CLOSE_WEBTRANSPORT_SESSION capsule ([WebTransport], - Section 6). + SUBSCRIBE_TRACKS is not required for a publisher to send PUBLISH + messages to a subscriber. It is useful, for example, when the + subscriber does not know the exact names of the tracks it wants, or + when those tracks will be published. + + The publisher will respond with SUBSCRIBE_TRACKS_OK or + SUBSCRIBE_TRACKS_ERROR on the response half of the stream. If the + subscriber receives any message other than a SUBSCRIBE_TRACKS_OK or a + SUBSCRIBE_TRACKS_ERROR as the first message on the response half of + the stream, then it MUST close the session with a PROTOCOL_VIOLATION. + If the SUBSCRIBE_TRACKS is successful, the publisher will send + PUBLISH messages on new bidirectional streams for tracks matching the + Namespace Prefix. If it is an error, the stream will be closed via + FIN after SUBSCRIBE_TRACKS_ERROR is sent. - When terminating the Session, the application MAY use any error - message and SHOULD use a relevant code, as defined below: + Within a session, if a publisher receives a SUBSCRIBE_TRACKS with a + Track Namespace Prefix that shares a common prefix with an + established SUBSCRIBE_TRACKS, it MUST respond with + SUBSCRIBE_TRACKS_ERROR with error code PREFIX_OVERLAP. - NO_ERROR (0x0): The session is being terminated without an error. + The publisher MUST ensure the subscriber is authorized to perform + this namespace subscription. - INTERNAL_ERROR (0x1): An implementation specific error occurred. + A SUBSCRIBE_TRACKS is cancelled as described in Section 6.4.2.3. + Cancelling SUBSCRIBE_TRACKS does not prohibit original publishers + from sending further PUBLISH messages, but relays MUST NOT send any + further PUBLISH messages to a client without knowing the client is + interested in and authorized to receive the content. - UNAUTHORIZED (0x2): The client is not authorized to establish a - session. - PROTOCOL_VIOLATION (0x3): The remote endpoint performed an action - that was disallowed by the specification. - INVALID_REQUEST_ID (0x4): The endpoint received a Request ID with an - incorrect least significant bit for the sender, or a duplicate - Request ID. See Section 10.1. - DUPLICATE_TRACK_ALIAS (0x5): The endpoint attempted to use a Track - Alias that was already in use. -Nandakumar, et al. Expires 4 March 2027 [Page 33] +Nandakumar, et al. Expires 4 April 2027 [Page 31] -Internet-Draft moq-transport August 2026 - +Internet-Draft moq-transport October 2026 - KEY_VALUE_FORMATTING_ERROR (0x6): The key-value pair has a - formatting error. - INVALID_PATH (0x8): The PATH parameter was used by a server, on a - WebTransport session, or the server does not support the path. +3.6.1. Filtering SUBSCRIBE_TRACKS - MALFORMED_PATH (0x9): The PATH parameter does not conform to the - rules in Section 10.3.1.2. + Range Filters Section 3.3.2 can be used in SUBSCRIBE_TRACKS to filter + Tracks in a namespace using the Track Property Filter. Objects + published in the resulting Subscriptions can be filtered by any Range + Filter. - GOAWAY_TIMEOUT (0x10): The session was closed because the peer took - too long to close the session in response to a GOAWAY - (Section 10.4) message. See session migration (Section 3.6). +3.6.2. Parameters on SUBSCRIBE_TRACKS - CONTROL_MESSAGE_TIMEOUT (0x11): The session was closed because the - peer took too long to respond to a control message. + Any Parameter that can be specified on a Subscription (ie: in + SUBSCRIBE) is valid in SUBSCRIBE_TRACKS, unless otherwise specified. + These parameters are used by the publisher as the initial + Subscription parameters when a PUBLISH is sent as a result of + SUBSCRIBE_TRACKS, and explicitly communicated in the PUBLISH. When a + Parameter is omitted from the SUBSCRIBE_TRACKS and resulting PUBLISH, + the Subscription uses the default value. - DATA_STREAM_TIMEOUT (0x12): The session was closed because the peer - took too long to send data expected on an open Data Stream (see - Section 11). This includes fields of a stream header or an object - header within a data stream. If an endpoint times out waiting for - a new object header on an open subgroup stream, it MAY send a - STOP_SENDING on that stream or terminate the subscription. + To join Tracks initiated via the resulting PUBLISHes, the subscriber + can specify a Location Filter and optionally include FILL_PARAMETERS + in the SUBSCRIBE_TRACKS, or in a REQUEST_UPDATE following PUBLISH_OK, + as described in Section 3.5. - AUTH_TOKEN_CACHE_OVERFLOW (0x13): The Session limit Section 10.3.1.3 - of the size of all registered Authorization tokens has been - exceeded. +3.6.3. Skipped Tracks - DUPLICATE_AUTH_TOKEN_ALIAS (0x14): Authorization Token attempted to - register an Alias that was in use (see Section 10.2.2). + If a Subscription cannot be created because there are no available + bidirectional streams or any other reason, the Publisher sends a + PUBLISH_SKIPPED message on the SUBSCRIBE_TRACKS response stream to + indicate the Full Track Name of the Subscription that was not + created. The Publisher MUST NOT send a PUBLISH for a Track for a + given SUBSCRIBE_TRACKS after PUBLISH_SKIPPED has been sent, scoped to + a single PUBLISH. If, for example, the publisher disconnects from a + relay and later reconnects and sends a new PUBLISH, the relay MAY + send the new PUBLISH downstream. If desired, the subscriber can + issue a SUBSCRIBE to establish a subscription to that track. - MALFORMED_AUTH_TOKEN (0x16): Invalid Auth Token serialization during - registration (see Section 10.2.2). +3.7. Mandatory to Understand Track Properties - UNKNOWN_AUTH_TOKEN_ALIAS (0x17): No registered token found for the - provided Alias (see Section 10.2.2). + Property types in the range 0x4000-0x7FFF are designated as Mandatory + Track Properties. These properties MUST have Track scope. Mandatory + Track Properties have special handling rules that prevent tracks with + required properties from being forwarded to or processed by endpoints + that do not understand them. - EXPIRED_AUTH_TOKEN (0x18): Authorization token has expired - (Section 10.2.2). + An Object received with a Mandatory Track Property as an Object + Property is malformed (see Section 12.1). - INVALID_AUTHORITY (0x19): The specified AUTHORITY does not - correspond to this server or cannot be used in this context. - MALFORMED_AUTHORITY (0x1A): The AUTHORITY value is syntactically - invalid. - TOO_MANY_REQUEST_UPDATES (0x1B): The endpoint received a - REQUEST_UPDATE that exceeded the per-stream limit communicated via - the MAX_REQUEST_UPDATES Setup Option (Section 10.3.1.7). -Nandakumar, et al. Expires 4 March 2027 [Page 34] +Nandakumar, et al. Expires 4 April 2027 [Page 32] -Internet-Draft moq-transport August 2026 - +Internet-Draft moq-transport October 2026 - An endpoint MAY choose to treat a subscription or request specific - error as a session error under certain circumstances, closing the - entire session in response to a condition with a single subscription - or message. Implementations need to consider the impact on other - outstanding subscriptions before making this choice. - -3.6. Session Migration - MOQT requires a long-lived and stateful session. However, a service - provider needs the ability to shutdown/restart a server without - waiting for all sessions to drain naturally, as that can take days - for long-form media. MOQT enables proactively draining sessions via - the GOAWAY message (Section 10.4). + When an endpoint receives a Mandatory Track Property in PUBLISH, + SUBSCRIBE_OK, or FETCH_OK that it does not understand, it MUST NOT + process or forward that track: - A GOAWAY on the control stream migrates the entire session, as - described in this section. A GOAWAY on a single request stream - instead migrates only that request, leaving the rest of the session - in place; see Section 10.4. + * For PUBLISH messages: the subscriber MUST respond with + PUBLISH_ERROR with error code UNSUPPORTED_EXTENSION. - The server sends a GOAWAY message, signaling the client to establish - a new session and migrate any Established subscriptions. The GOAWAY - message optionally contains a new URI for the new session, otherwise - the current URI is reused. The GOAWAY message contains a Timeout - indicating how long, in milliseconds, the sender intends to wait - before closing the session. The sender SHOULD close the session with - GOAWAY_TIMEOUT after the indicated timeout if there are still open - subscriptions or fetches on a connection. + * For SUBSCRIBE_OK messages: the subscriber MUST cancel the + subscription (see Section 6.4.2.3). If the subscriber is a relay + with pending downstream subscribers, it MUST send SUBSCRIBE_ERROR + with error code UNSUPPORTED_EXTENSION to the downstream + subscribers. - When the server is a subscriber, it SHOULD send a GOAWAY message to - downstream subscribers prior to unsubscribing from upstream - publishers. + * For FETCH_OK messages: the subscriber MUST cancel the fetch (see + Section 6.4.2.3). If the subscriber is a relay and has not yet + sent a FETCH_OK or FETCH_ERROR downstream, it MUST send + FETCH_ERROR with error code UNSUPPORTED_EXTENSION to the + downstream fetch requester. If the relay has already forwarded + data on a fetch stream, it MUST reset the stream. - After the client receives a GOAWAY, it's RECOMMENDED that the client - waits until there are no more Established subscriptions before - closing the session with NO_ERROR. Ideally this is transparent to - the application using MOQT, which involves establishing a new session - in the background and migrating Established subscriptions and - published namespaces. The client can choose to delay closing the - session if it expects more OBJECTs to be delivered. The sender - closes the session with a GOAWAY_TIMEOUT if the peer doesn't close - the session within the indicated Timeout. + A publisher that knows a subscriber does not support a Mandatory + Track Property SHOULD take the following action: -3.7. Congestion Control + * For SUBSCRIBE: respond with SUBSCRIBE_ERROR with error code + UNSUPPORTED_EXTENSION. - MOQT does not specify a congestion controller, but there are - important attributes to consider when selecting a congestion - controller for use with an application built on top of MOQT. + * For FETCH: respond with FETCH_ERROR with error code + UNSUPPORTED_EXTENSION. + * For PUBLISH: do not publish the track to that subscriber. +4. Publisher and Namespace Discovery + Given out-of-band information, a subscriber can retrieve tracks from + a publisher (including a relay) without any previous MOQT messages + besides SETUP. However, MOQT provides in-band messages for a + publisher to advertise the namespaces it has tracks in, and for a + subscriber to discover the namespaces a publisher knows. -Nandakumar, et al. Expires 4 March 2027 [Page 35] - -Internet-Draft moq-transport August 2026 + Discovery of MOQT servers is always done out-of-band: MOQT does not + specify how an endpoint learns where to establish a session. The + discovery described in this section takes place within an established + session. -3.7.1. Bufferbloat - Traditional AIMD congestion controllers (ex. CUBIC [RFC9438] and - Reno [RFC6582]) are prone to Bufferbloat. Bufferbloat occurs when - elements along the path build up a substantial queue of packets, - commonly more than doubling the round trip time. These queued - packets cause head-of-line blocking and latency, even when there is - no packet loss. -3.7.2. Application-Limited - The average bitrate for latency sensitive content needs to be less - than the available bandwidth, otherwise data will be queued and/or - dropped. As such, many MOQT applications will typically be limited - by the available data to send, and not the congestion controller. - Many congestion control algorithms only increase the congestion - window or bandwidth estimate if fully utilized. This combination can - lead to underestimating the available network bandwidth. As a - result, applications might need to periodically ensure the congestion - controller is not app-limited for at least a full round trip to - ensure the available bandwidth can be measured. - Some applications might have APIs to allow sending duplicate data or - forward error correction to probe for more bandwidth while also - limiting the impact of probing in case it causes packet loss. - Subscribers wanting to switch to an alternate representation of a - Track can subscribe to it at a lower priority, or subscribe to - additional Tracks at the lowest (255) priority to fill the congestion - window during probing intervals while minimizing the impact on higher - priority media. Publishers can send padding (Section 11.5) to probe - for additional bandwidth without requiring additional subscriptions. - Network-assisted bandwidth estimation mechanisms such as SCONE - [I-D.ietf-scone-protocol] can provide receivers with sustainable - bandwidth hints, which subscribers can use to inform track selection - decisions and potentially avoid unnecessary probing. -3.7.3. Consistent Throughput - Congestion control algorithms are commonly optimized for throughput, - not consistency. For example, BBR's PROBE_RTT state halves the - sending rate for more than a round trip in order to obtain an - accurate minimum RTT. Similarly, Reno halves its congestion window - upon detecting loss. In both cases, the large reduction in sending - rate might cause issues with latency sensitive applications. +Nandakumar, et al. Expires 4 April 2027 [Page 33] + +Internet-Draft moq-transport October 2026 +4.1. Publishing Namespaces + A publisher MAY send PUBLISH_NAMESPACE messages to any subscriber. A + PUBLISH_NAMESPACE indicates to the subscriber that the publisher has + tracks available in namespaces matching the Track Namespace Prefix it + carries (see Section 2.4.2). A subscriber MAY send SUBSCRIBE, FETCH + or TRACK_STATUS for tracks in a namespace without having received a + PUBLISH_NAMESPACE for it. + The receiver verifies the publisher is authorized to publish tracks + under this prefix. + A subscriber MUST send exactly one PUBLISH_NAMESPACE_OK or + PUBLISH_NAMESPACE_ERROR as the first message on the bidi stream in + response to a PUBLISH_NAMESPACE. The publisher SHOULD close the + session with a protocol error if it receives more than one. + An endpoint SHOULD report the reception of a PUBLISH_NAMESPACE_OK or + PUBLISH_NAMESPACE_ERROR to the application to inform the search for + additional subscribers for a namespace, or to abandon the attempt to + publish under this namespace. -Nandakumar, et al. Expires 4 March 2027 [Page 36] - -Internet-Draft moq-transport August 2026 + If a subscriber has accepted a PUBLISH_NAMESPACE with a namespace + that exactly matches the namespace for a given track, it SHOULD only + request the Track from the sender(s) of those PUBLISH_NAMESPACE + messages. + A PUBLISH_NAMESPACE is withdrawn by cancelling the request (see + Section 6.4.2.3), although it is not a protocol error for the + subscriber to send a SUBSCRIBE, FETCH or TRACK_STATUS message for a + track in a namespace after the namespace is withdrawn. -4. Extensibility + A subscriber can cancel the request (see Section 6.4.2.3) to revoke + acceptance of a PUBLISH_NAMESPACE. If the reason for cancellation is + expiration of authorization credentials, the publisher can send + PUBLISH_NAMESPACE again on a new bidi stream with refreshed + authorization. - MOQT defines all messages necessary to implement both simple - publishing or subscribing endpoints as well as fully capable Relays. - Non-Relay endpoints MAY implement only the subset of functionality - required to perform necessary tasks. For example, a limited media - player could operate using only SUBSCRIBE related messages. Limited - endpoints SHOULD respond to any unsupported messages with the - appropriate NOT_SUPPORTED error code, rather than ignoring them. + While PUBLISH_NAMESPACE indicates to relays how to connect publishers + and subscribers, it is not a full-fledged routing protocol and does + not protect against loops. In particular, PUBLISH_NAMESPACE SHOULD + NOT be used to find paths through richly connected networks of + relays. - Relays MUST implement all MOQT messages defined in this document, as - well as processing rules described in Section 9. -5. Publishing and Retrieving Tracks -5.1. Subscriptions - All subscriptions begin in the Idle state. A subscription can be - initiated and moved to the Pending state by either a publisher or a - subscriber. A publisher initiates a subscription to a track by - sending the PUBLISH message. The subscriber either accepts or - rejects the subscription using PUBLISH_OK (Section 10.5) or - REQUEST_ERROR. A subscriber initiates a subscription to a track by - sending the SUBSCRIBE message. The publisher either accepts or - rejects the subscription using SUBSCRIBE_OK or REQUEST_ERROR. Once - either of these sequences is successful, the subscription moves to - the Established state and can be updated by the subscriber using - REQUEST_UPDATE. Either endpoint can terminate an Established - subscription, moving it to the Terminated state. The subscriber - terminates a subscription in the Pending (Subscriber) or Established - states by sending STOP_SENDING. The publisher terminates a - subscription in the Pending (Publisher) or Established states by - sending PUBLISH_DONE and closing the stream. - - This diagram shows the subscription state machine: +Nandakumar, et al. Expires 4 April 2027 [Page 34] + +Internet-Draft moq-transport October 2026 +4.2. Subscribing to Namespaces + If the subscriber is aware of a namespace of interest, it can send + SUBSCRIBE_NAMESPACE to publishers/relays it has established a session + with. The Track Namespace Prefix it carries is compared against the + namespaces known to the receiver using Namespace Prefix Matching + (Section 2.4.2). + + SUBSCRIBE_NAMESPACE requests namespace discovery: the publisher + responds with NAMESPACE and NAMESPACE_DONE messages. + + A SUBSCRIBE_NAMESPACE with zero Track Namespace fields indicates the + sender is interested in all namespaces from the receiver. + + The subscriber sends SUBSCRIBE_NAMESPACE on a new bidirectional + stream. The publisher MUST send a single SUBSCRIBE_NAMESPACE_OK or + SUBSCRIBE_NAMESPACE_ERROR as the first message on the response half + of the stream; if the subscriber receives any other message first, it + MUST close the session with a PROTOCOL_VIOLATION. + + On success, the publisher MUST send a NAMESPACE message for each + namespace it knows that matches the Track Namespace Prefix, and + further NAMESPACE or NAMESPACE_DONE messages as that set changes. A + publisher knows a namespace if it is an Original Publisher for one or + more tracks in that Namespace Prefix, or is a relay that has received + an authorized PUBLISH_NAMESPACE for the Namespace. On error, the + stream is immediately closed via FIN. + + The namespace in a NAMESPACE message is itself a prefix; tracks can + exist in namespaces matching it. A NAMESPACE_DONE indicates the + publisher intends to stop serving new subscriptions for tracks within + that namespace. + Within a session, if a publisher receives a SUBSCRIBE_NAMESPACE with + a Track Namespace Prefix that shares a common prefix with an + established SUBSCRIBE_NAMESPACE, it MUST respond with + SUBSCRIBE_NAMESPACE_ERROR with error code PREFIX_OVERLAP. + The publisher MUST NOT send NAMESPACE_DONE for a namespace suffix + before the corresponding NAMESPACE. If a subscriber receives a + NAMESPACE_DONE before the corresponding NAMESPACE, it MUST close the + session with a 'PROTOCOL_VIOLATION'. + A subscriber can receive a PUBLISH_NAMESPACE on a request stream for + a namespace that falls within an active SUBSCRIBE_NAMESPACE prefix. + This occurs when SUBSCRIBE_NAMESPACE or its response is in flight at + the same time as a PUBLISH_NAMESPACE, or when an original publisher + sends PUBLISH_NAMESPACE to advertise namespaces within the prefix +Nandakumar, et al. Expires 4 April 2027 [Page 35] + +Internet-Draft moq-transport October 2026 + being discovered. Such a PUBLISH_NAMESPACE is valid and MAY carry an + AUTHORIZATION TOKEN parameter. Its lifetime is independent of the + SUBSCRIBE_NAMESPACE stream. -Nandakumar, et al. Expires 4 March 2027 [Page 37] - -Internet-Draft moq-transport August 2026 + A SUBSCRIBE_NAMESPACE is cancelled as described in Section 6.4.2.3, + by resetting or sending STOP_SENDING on the stream. +4.2.1. Namespace Subscription Authorization - +--------+ - | Idle | - +--------+ - | | - SUBSCRIBE | | PUBLISH - (subscriber)| | (publisher) - V V - +--------------+ +--------------+ - | Pending | | Pending | - +----| (Subscriber) | | (Publisher) |----+ - | +--------------+ +--------------+ | - | | | | - REQUEST_ERROR | SUBSCRIBE_OK | | PUBLISH_OK | REQUEST_ERROR - (publisher) | (publisher)| | (subscriber) | (subscriber) - | V V | - | +-------------+ | - | | Established | ------+ - | | | | REQUEST_UPDATE - | +-------------+ <-----+ - | | | | - +--- STOP_SENDING | | PUBLISH_DONE ----+ - | (subscriber)| | (publisher) | - | V V | - | +-------------+ | - +----------->| Terminated | <------------+ - +-------------+ + The publisher MUST ensure the subscriber is authorized to perform a + namespace subscription. - A publisher MUST send exactly one SUBSCRIBE_OK or REQUEST_ERROR in - response to a SUBSCRIBE. A subscriber MUST send exactly one - PUBLISH_OK (Section 10.5) or REQUEST_ERROR in response to a PUBLISH. - The peer SHOULD close the session with a protocol error if it - receives more than one. + By sending SUBSCRIBE_NAMESPACE, the subscriber indicates that it + trusts the relay to be authoritative for namespaces matching the + requested prefix. NAMESPACE messages received on the + SUBSCRIBE_NAMESPACE response stream inherit this trust and do not + independently carry authorization. - All Established subscriptions have a Forward State which is either 0 - or 1. The publisher does not send Objects if the Forward State is 0, - and does send them if the Forward State is 1. The initiator of the - subscription sets the initial Forward State in either PUBLISH or - SUBSCRIBE. The subscriber can send REQUEST_UPDATE to update the - Forward State. Control messages, such as PUBLISH_DONE - (Section 10.12) are sent regardless of the forward state. +4.2.2. Namespace Subscription State Management - Either endpoint can initiate a subscription to a track without - exchanging any prior messages other than SETUP. Relays MUST NOT send - any PUBLISH messages without knowing the client is interested in and - authorized to receive the content. The communication of intent and - authorization can be accomplished by the client sending - SUBSCRIBE_NAMESPACE, or conveyed in other mechanisms out of band. + If the publisher is unable to send NAMESPACE or NAMESPACE_DONE + messages in a timely manner because the SUBSCRIBE_NAMESPACE response + stream is blocked by flow control, the publisher MAY reset the + SUBSCRIBE_NAMESPACE response stream. When a subscriber receives a + stream reset or FIN on a SUBSCRIBE_NAMESPACE response stream, it + SHOULD treat this as though each active namespace received a + NAMESPACE_DONE. Subscriptions established via PUBLISH on separate + bidi streams are not affected by closure of the SUBSCRIBE_NAMESPACE + stream. +4.3. Namespace Discovery Example + In the following example, a publisher advertises a namespace to a + relay before a subscriber asks that relay for namespaces under a + prefix, so the relay reports it immediately. The publisher then + advertises a second matching namespace, which the relay passes on as + it arrives. When the publisher withdraws that advertisement, the + relay tells the subscriber the namespace is gone. -Nandakumar, et al. Expires 4 March 2027 [Page 38] - -Internet-Draft moq-transport August 2026 - An endpoint MAY SUBSCRIBE to a Track it is publishing, though only - Relays are required to handle such a SUBSCRIBE. Such self- - subscriptions are identical to subscriptions initiated by other - endpoints, and all published Objects will be forwarded back to the - endpoint, subject to priority and congestion response rules. - An endpoint MAY have multiple concurrent subscriptions to the same - Track, each identified by a unique Request ID. A publisher MAY - assign the same or different Track Aliases to these subscriptions. - When an Object matches the filters of multiple subscriptions to the - same Track, the publisher MUST send the Object once for each matching - subscription, even when those subscriptions share the same Track - Alias. Because subscriptions can share a Track Alias, the subscriber - re-applies each subscription's filter to determine which subscription - a received Object belongs to. Subscribers SHOULD avoid overlapping - filters across subscriptions to the same Track, as they are - responsible for deduplicating any resulting duplicate Objects. - A publisher SHOULD begin sending incomplete objects when available to - avoid incurring additional latency. - Publishers MAY start sending Objects on PUBLISH-initiated - subscriptions before receiving a PUBLISH_OK response to reduce - latency. Doing so can consume unnecessary resources in cases where - the Subscriber rejects the subscription with REQUEST_ERROR or sets - Forward=0 in REQUEST_UPDATE. It can also result in the Subscriber - dropping Objects if its buffering limits are exceeded (see - Section 11.3 and Section 11.4.2). -5.1.1. Subscription State Management - A subscriber keeps subscription state until it cancels the request - (see Section 3.3.3), or until receipt of a PUBLISH_DONE or - REQUEST_ERROR. Note that PUBLISH_DONE does not usually indicate that - state can immediately be removed, see Section 10.12. - The Publisher can remove subscription state as soon as it has - received STOP_SENDING. It MUST reset any open streams associated - with the SUBSCRIBE. - The Publisher can also immediately delete subscription state after - sending PUBLISH_DONE, but MUST NOT send it until it has closed all - related streams. - A REQUEST_ERROR indicates no objects will be delivered, and both - endpoints can immediately remove relevant state. Objects MUST NOT be - sent for requests that end with an error. +Nandakumar, et al. Expires 4 April 2027 [Page 36] + +Internet-Draft moq-transport October 2026 + Publisher Relay Subscriber + | | | + | PUBLISH_NAMESPACE | | + | (example-42) | | + |------------------------->| | + | PUBLISH_NAMESPACE_OK | | + |<-------------------------| SUBSCRIBE_NAMESPACE | + | | (example) | + | |<-------------------------| + | | SUBSCRIBE_NAMESPACE_OK | + | |------------------------->| + | | NAMESPACE | + | | (42) | + | |------------------------->| + | PUBLISH_NAMESPACE | | + | (example-123) | | + |------------------------->| | + | PUBLISH_NAMESPACE_OK | NAMESPACE | + |<-------------------------| (123) | + | |------------------------->| + | cancel PUBLISH_NAMESPACE | | + |------------------------->| | + | | NAMESPACE_DONE | + | | (123) | + | |------------------------->| + | | | -Nandakumar, et al. Expires 4 March 2027 [Page 39] - -Internet-Draft moq-transport August 2026 + Figure 1: Namespace discovery through a relay + The NAMESPACE and NAMESPACE_DONE messages carry only the suffixes 42 + and 123, because the prefix example is already known from the + SUBSCRIBE_NAMESPACE. -5.1.2. Location Filters +5. Object Transmission - Subscribers can specify a Location filter on a subscription - indicating to the publisher which Objects to send. Subscriptions - without a filter pass all Objects published or received via upstream - subscriptions. +5.1. Priorities - Fetch requests can also specify a Location filter. Fetch requests - without a filter include all Locations from {0, 0} up to Largest - Object (defined below). + MOQT priorities allow a subscriber and original publisher to + influence the transmission order of Objects within a session in the + presence of congestion. - A Location filter specifies an inclusive range of Locations. Only - objects with Locations within the inclusive range pass the filter. +5.1.1. Definitions - An object published or received in a subgroup or datagram is - *subscription-delivered*. Objects delivered via a fill fetch stream - (see Section 5.1.3) are *fill-delivered*. + MOQT maintains priorities between different schedulable objects. A + schedulable object in MOQT is either: - Some Location filters are defined to be relative to the Largest - Object. The Largest Object is the Object with the largest Location - (Section 1.4.2) in the Track from the perspective of the publisher - processing the message. Largest Object updates when the first byte - of an Object with a Location larger than the previous value is - published or received through a subscription. + 1. The first or next Object in a Subgroup that is in response to a + subscription. - A Location filter parameter has the following length-prefixed - structure: - LOCATION_FILTER Parameter { - Parameter Type (vi64) = 0x21, - Length (vi64), - [StartGroup (vi64),] - [StartObject (vi64),] - [EndGroupDelta (vi64),] - [EndObject (vi64),] - } - Length (in bytes) determines how many optional vi64 fields are - present. A length of 0 indicates no filter, for example to remove - the filter in REQUEST_UPDATE. * If only one field is present, it is - StartGroup. * If only two fields are present, they are StartGroup - and StartObject. * If only three fields are present, they are - StartGroup, StartObject, and EndGroupDelta. +Nandakumar, et al. Expires 4 April 2027 [Page 37] + +Internet-Draft moq-transport October 2026 + 2. An Object with Delivery Mode Datagram. + 3. An Object in response to a FETCH where that Object is the next + Object in the response. + An Object is not schedulable if it is known that no part of it can be + written due to underlying transport flow control limits. + A single subgroup or datagram has a single publisher priority. + Within a subscription, it can be useful to conceptualize this process + as scheduling subgroups or datagrams instead of individual objects on + them. FETCH responses however can contain objects with different + publisher priorities. + A priority numberis an unsigned integer with a value between 0 and + 255. A lower priority number indicates higher priority; the highest + priority is 0. + Subscriber Priority is a priority number associated with an + individual request. It is carried in the SUBSCRIBER_PRIORITY + parameter (Section 9.20.7), and can be updated. The subscriber + priority of an individual schedulable object is the subscriber + priority of the request that caused that object to be sent. When + subscriber priority is changed, a best effort SHOULD be made to apply + the change to all objects that have not been scheduled, but it is + implementation dependent what happens to objects that have already + been scheduled. -Nandakumar, et al. Expires 4 March 2027 [Page 40] - -Internet-Draft moq-transport August 2026 + Publisher Priority is a priority number associated with an individual + schedulable object. A default for the subscription is specified in + the DEFAULT_PUBLISHER_PRIORITY Track Property (Section 10.4). + Publisher priority can also be set per subgroup or datagram in the + subgroup header or datagram (see Section 11), which overrides the + default. + Group Order is a property of an individual subscription. It can be + either 'Ascending' (groups with lower group ID are sent first), or + 'Descending' (groups with higher group ID are sent first). The + subscriber optionally communicates its group order preference in the + SUBSCRIBE or SUBSCRIBE_TRACKS message; the publisher's preference, + carried in the DEFAULT_PUBLISHER_GROUP_ORDER Track Property + (Section 10.5), is used if the subscriber did not express one (by + omitting the Group Order parameter). The group order of an existing + subscription cannot be changed. - If only StartGroup is present, it is a relative number of groups - prior to the Next Group, hence the start Location is {Largest - Object.Group + 1 - StartGroup, 0}. For example: * StartGroup=0 will - start at the Next Group * StartGroup=1 will start at the current - group * StartGroup=2 will start at 1 group prior to the current group - * StartGroup=N will start at N-1 groups prior to the current group - If only StartGroup and StartObject are present and both 0, the start - Location is the Next Object which is {Largest Object.Group, Largest - Object.Object + 1}, or {0, 0} if no content has been delivered yet. - An open-ended filter that starts at absolute Location {0, 0} is - equivalent to unfiltered, so the subscriber need not include a - Location filter. Note that due to network reordering or - prioritization, relays can receive Objects with Locations smaller - than Largest Object after the SUBSCRIBE is processed, but these - Objects do not pass this filter. - If a relative start group results in a computed absolute group less - than 0, the computed value is set to 0; if greater than 2^64 - 1, it - is set to 2^64 - 1. - Otherwise, all fields are absolute. EndGroupDelta is delta encoded - from StartGroup, but both the start and end groups are absolute, not - relative to Largest Object. If StartGroup + EndGroupDelta exceeds - 2^64 - 1, the endpoint MUST close the session with a - PROTOCOL_VIOLATION. - When EndGroupDelta and EndObject are omitted from a subscription - filter, the subscription is open-ended. When they are omitted from a - Fetch, the EndGroup and EndObject are Largest Object. - When EndObject is omitted, the filter includes all objects in the End - Group. - A Location Filter on a subscription is always valid, even if it - specifies a range entirely before Largest Object. +Nandakumar, et al. Expires 4 April 2027 [Page 38] + +Internet-Draft moq-transport October 2026 - A publisher MUST NOT send subscription-delivered objects from outside - the requested range. Because updating filters is asynchronous, - subscribers can receive objects outside the current filter. - A publisher does not end a subscription solely because the Largest - Object advances past the end of the current Location Filter. +5.1.2. Scheduling Algorithm - Fill-delivered objects are governed by the Location filter in - FILL_PARAMETERS (see Section 5.1.3). + When an MOQT publisher has multiple schedulable objects it can choose + between, the objects SHOULD be selected as follows: + 1. If two objects have different subscriber priorities associated + with them, the one with *the highest subscriber priority* is + scheduled to be sent first. + 2. If two objects have the same subscriber priority, but different + publisher priorities, the one with *the highest publisher + priority* is scheduled to be sent first. + 3. If two objects in the same subscription have the same subscriber + and publisher priority, but belong to two different groups of the + same track, *the group order* of the subscription is used to + decide the one that is scheduled to be sent first. When a + subscription fill's Group Order differs from the subscription's + Group Order, the subscription-delivered object is scheduled + first. + 4. If two objects in the same subscription have the same subscriber + and publisher priority and belong to the same group of the same + track, and one is delivered by the fill fetch stream while the + other is subscription-delivered, the fill-delivered object is + scheduled first. Otherwise, the one with *the lowest Subgroup + ID* (for objects with Delivery Mode Subgroup), or *the lowest + Object ID* (for objects with Delivery Mode Datagram) is scheduled + to be sent first. If the two objects have different Delivery + Modes the datagram is sent first. -Nandakumar, et al. Expires 4 March 2027 [Page 41] - -Internet-Draft moq-transport August 2026 + Within the same group, fill-delivered objects win the tie-break over + subscription-delivered objects (rule 4) because objects with smaller + Locations are assumed to be needed before those with larger + Locations. + The definition of "scheduled to be sent first" in the algorithm is + implementation dependent and is constrained by the prioritization + interface of the underlying transport. For some implementations, it + could mean that the object is serialized and passed to the underlying + transport first. Other implementations can control the order packets + are initially transmitted. -5.1.3. Fill Semantics + This algorithm does not provide a well-defined ordering for objects + that belong to different subscriptions or FETCH responses, but have + the same subscriber and publisher priority. The ordering in those + cases is implementation-defined, though the expectation is that all + subscriptions will be able to send some data. - A subscription that carries a FILL_PARAMETERS parameter (see - Section 10.2.15) causes the publisher to open a unidirectional stream - beginning with a FETCH_HEADER (see Section 11.4.4) and delivered as a - FETCH response (see Section 10.13). This is called a fill fetch - stream. - The *fill range* is the range of Locations selected by the Location - filter inside FILL_PARAMETERS, or the subscription's Location filter - if it is omitted. The filter is evaluated using the rules for a - Fetch in Section 5.1.2, so the fill range never extends beyond - Largest Object. When the subscription has no Location filter, or the - LOCATION_FILTER inside FILL_PARAMETERS is zero-length, the fill range - is the entire track up to Largest Object. The subscriber learns the - Largest Object from the LARGEST_OBJECT parameter in SUBSCRIBE_OK or - REQUEST_UPDATE_OK. - Because the fill range is specified independently of the - subscription's Location filter, a subscriber can retrieve a range of - Groups prior to the live edge while the subscription itself starts at - the Next Group. If the fill range is empty, or starts after Largest - Object, the publisher does not open a fill fetch stream. +Nandakumar, et al. Expires 4 April 2027 [Page 39] + +Internet-Draft moq-transport October 2026 - The fill fetch stream inherits the subscription's parameters, - including subscriber priority, range filters and authorization; - parameters carried inside FILL_PARAMETERS override them for the fill - fetch stream. FILL_TIMEOUT (see Section 10.2.5) applies to fill - fetch streams in the same way it applies to a FETCH. - The FETCH_HEADER on the fill fetch stream carries the Request ID of - the message that initiated it: the SUBSCRIBE Request ID for the - initial fill, or the REQUEST_UPDATE Request ID for a subsequent fill. - As a result of REQUEST_UPDATE, a subscription can have multiple fill - fetch streams open at once, each identified by its Request ID; - opening a new fill fetch stream does not implicitly cancel any - previously opened fill fetch streams. + A publisher might not utilize the entire available congestion window, + session flow control, or all available streams for lower priority + Objects if it expects higher priority Objects will be available to + send in the near future or it wants to reserve some bandwidth for + control messages. - An object delivered on the fill fetch stream is *fill-delivered*. - When the fill range overlaps the subscription's Location filter, an - object can be both fill-delivered and subscription-delivered. A - subscriber that wants each Object delivered exactly once uses the - Next Object Subscription Location Filter coupled with an open-ended - fill range, which the publisher will end at Largest Object. + Given the critical nature of control messages and their relatively + small size, the control streams SHOULD be prioritized highest, + followed by the bidi request streams and then all Objects. Bidi + request streams MAY be prioritized within themselves by Subscriber + Priority if specified. +5.1.3. Considerations for Setting Priorities + For downstream subscriptions, relays SHOULD respect the subscriber + and original publisher's priorities. Relays can receive + subscriptions with conflicting subscriber priorities or Group Order + preferences. Relays SHOULD NOT directly use Subscriber Priority or + Group Order from incoming subscriptions for upstream subscriptions. + A Relay's use of these fields for upstream subscriptions can be based + on factors specific to it, such as the popularity of the content or + policy, or relays can specify the same value for all upstream + subscriptions. + MOQT Sessions can span multiple namespaces, and priorities might not + be coordinated across namespaces. The subscriber's priority is + considered first, so there is a mechanism for a subscriber to fix + incompatibilities between different namespaces prioritization + schemes. Additionally, it is anticipated that when multiple + namespaces are present within a session, the namespaces could be + coordinating, possibly part of the same application. In cases when + pooling among namespaces is expected to cause issues, multiple MOQT + sessions, either within a single connection or on multiple + connections can be used. + Implementations that have a default priority SHOULD set it to a value + in the middle of the range (eg: 128) to allow non-default priorities + to be set either higher or lower. +5.2. Delivery Timeouts and Data Reliability + Each MOQT subscription has two timeout values associated with it: a + SUBGROUP_DELIVERY_TIMEOUT and an OBJECT_DELIVERY_TIMEOUT. Both of + those values are expressed in milliseconds and both are optional; a + value of 0 means that there is no timeout set. -Nandakumar, et al. Expires 4 March 2027 [Page 42] - -Internet-Draft moq-transport August 2026 -5.1.3.1. Opening and Closing Fill Fetch Streams - A publisher opens a fill fetch stream when it processes a SUBSCRIBE - or REQUEST_UPDATE that carries FILL_PARAMETERS while Forward State is - 1. - * FILL_PARAMETERS carried while Forward State is 0 opens no fill - fetch stream. Transitioning to Forward State 1 without re-sending - FILL_PARAMETERS does not open one either. - * A REQUEST_UPDATE that does not carry FILL_PARAMETERS does not open - a new fill fetch stream. +Nandakumar, et al. Expires 4 April 2027 [Page 40] + +Internet-Draft moq-transport October 2026 - * When the subscription is cancelled, the publisher MUST reset any - open fill fetch streams. - The publisher signals that the fill is complete by closing the stream - with a FIN once all objects in the fill range have been delivered. - Because there is no REQUEST_ERROR associated with a fill fetch - stream, the publisher signals a fill failure by resetting the stream; - it MUST open a fill fetch stream and reset it immediately after the - FETCH_HEADER if necessary. A subscriber can cancel a fill fetch - stream independently using STOP_SENDING. Resetting or cancelling a - fill fetch stream, by either endpoint, does not affect the - subscription, which continues to deliver objects using subscribe - subgroups and datagrams. + The publisher communicates both timeout values as a Track Property; + the subscriber communicates them as Message Parameters. Either + timeout value can also be set as an Object Property on the first + object in a subgroup, overriding the Track-level value for that + subgroup. If either timeout is set as an Object Property on any + object other than the first in a subgroup, it is ignored. For each + type of timeout, the publisher's value is the Object Property when + present on the first object of the subgroup, and the Track Property + otherwise. If both the publisher's value and the subscriber's value + are non-zero, the smaller of the two is used. -5.1.4. Range Filters + If the OBJECT_DELIVERY_TIMEOUT is not zero, the MOQT implementation + MUST retain the time at which the last header byte of every object + has been either received from the upstream subscription, or provided + by the original publisher application. The actual mechanism by which + the timeout works depends on the Object Delivery Mode: - Range Filters are parameters in SUBSCRIBE, FETCH, or SUBSCRIBE_TRACKS - that tell a publisher to filter tracks (via TRACK PROPERTY FILTER) - and objects according to subscriber-provided criteria. Range filters - are specified as ranges of integer values in Track and Object - Properties and other Object header fields (Subgroup ID, Object ID, - and Publisher Priority). There are five Range Filter parameter - types, 0x25-0x29, as shown below. + * For subgroups, the implementation MUST check the time elapsed + before attempting to pass it to the underlying transport for + transmission; if the time elapsed exceeds OBJECT_DELIVERY_TIMEOUT, + it MUST reset the underlying transport stream with the reset + stream code DELIVERY_TIMEOUT (see Section 11.3.2) and SHOULD NOT + attempt to open a new stream to deliver additional Objects in that + Subgroup. The implementation SHOULD check object delivery + timeouts before retransmitting object data if the underlying + transport implementation allows. The implementations SHOULD + minimize the amount of data buffered at the underlying transport + layer, as any data buffered at this layer can no longer be timed + out, potentially leading to transmission of expired data. + + * For datagrams, the implementation MUST drop the datagrams if the + time elapsed exceeds OBJECT_DELIVERY_TIMEOUT. Similar to + subgroups, implementations SHOULD either minimize datagram + queueing, or use datagram queueing mechanisms that support time + bounds (such as the outgoingMaxAge parameter in the W3C + WebTransport API). @@ -2405,669 +2293,590 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 43] +Nandakumar, et al. Expires 4 April 2027 [Page 41] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - SUBGROUP_FILTER { - Type (vi64) = 0x25, - Length (vi64), - [SetID (8)], - [Range (..) ...] - } + If the Object Delivery Mode is Subgroup and the value of + SUBGROUP_DELIVERY_TIMEOUT is not zero, the MOQT implementation MUST + start a timer of SUBGROUP_DELIVERY_TIMEOUT duration once it becomes + aware that all of the objects on the subgroup have been published + (either by receiving a FIN from the upstream subscription, or, in + case of the original publisher, through being notified of this fact + by the application). If the timer expires before the underlying + transport stream reaches "all data committed" state + ([I-D.ietf-webtrans-overview], Section 4.3), the implementation MUST + reset the stream. This ensures that MOQT can time out subgroups + where all of the data has been sent but not yet fully delivered due + to packet loss. - OBJECTID_FILTER { - Type (vi64) = 0x26, - Length (vi64), - [SetID (8)], - [Range (..) ...] - } + For objects whose Object Delivery Mode is Datagram, the + SUBGROUP_DELIVERY_TIMEOUT acts the same way as + OBJECT_DELIVERY_TIMEOUT; if both are non-zero, the smaller of the two + is used. - PRIORITY_FILTER { - Type (vi64) = 0x27, - Length (vi64), - [SetID (8)], - [Range (..) ...] - } + +=========+===========================+===========================+ + | | SUBGROUP_DELIVERY_TIMEOUT | OBJECT_DELIVERY_TIMEOUT | + +=========+===========================+===========================+ + | Timeout | When the FIN for the | When the last byte of the | + | starts | subgroup is received | object header is received | + +---------+---------------------------+---------------------------+ + | Timeout | Via a timer until all | When the object is sent | + | checked | data is acknowledged | to the underlying | + | at | | transport | + +---------+---------------------------+---------------------------+ + | Action | Reset for subgroups, drop | Reset for subgroups, drop | + | upon | for datagrams | for datagrams | + | timeout | | | + +---------+---------------------------+---------------------------+ - OBJECT_PROPERTY_FILTER { - Type (vi64) = 0x28, - Length (vi64), - [SetID (8)], - [Property Type (vi64)], - [Range (..) ...] - } + Table 1: Comparison of the delivery timeout mechanisms - TRACK_PROPERTY_FILTER { - Type (vi64) = 0x29, - Length (vi64), - [SetID (8)], - [Property Type (vi64)], - [Range (..) ...] - } + Publishers can, at their discretion, discontinue forwarding Objects + before either timeout occurs, subject to stream closure and ordering + constraints described in Section 11.3.2. However, if neither timeout + is set to a non-zero value, all Objects in the track matching the + subscription filter are delivered as indicated by their Group Order + and Priority. If a subscriber fails to consume Objects at a + sufficient rate, causing the publisher to exceed its resource limits, + the publisher MAY terminate the subscription using PUBLISH_DONE with + error TOO_FAR_BEHIND. - Range { - Start (vi64), - [End (vi64)] - } - Length (vi64) is the byte count of all fields after itself. When - Length is 0, there is no filter and no further fields are present. - This can be used in REQUEST_UPDATE to remove a filter. The Object - Property and Track Property Filters include a Property Type (vi64) - which follows SetID. -Nandakumar, et al. Expires 4 March 2027 [Page 44] + +Nandakumar, et al. Expires 4 April 2027 [Page 42] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - Each Range is an inclusive Start/End pair. End is optional in the - last pair; if omitted it indicates the last Range is open-ended. An - object matches the filter if its value falls within any Range (i.e., - Ranges are OR'd within a filter parameter). +6. Sessions - Each Start is delta encoded from the prior Range's End (or from 0 for - the first Range), and End is delta encoded from its own Start. If - adding the delta would exceed 2^64-1, the request MUST be rejected - with INVALID_FILTER. For example, ranges 3-5 and 10-15 encode as: - Start=3, End=2, Start=5, End=5. +6.1. MOQT URI Scheme + + An MOQT server is identified using a URI with the "moqt" scheme. The + "moqt" URI scheme is defined as follows, using definitions from + [RFC3986]: - Filter parameters with the same SetID are AND'd; distinct SetIDs are - OR'd. The final result is SetID=0 OR SetID=1 OR ... SetID=255, where - each SetID=i is the AND of all filter parameters carrying that SetID. + moqt-URI = "moqt" "://" authority path-abempty [ "?" query ] - The Track Property filter parameter MAY appear multiple times in a - SUBSCRIBE_TRACKS message or REQUEST_UPDATE for it. All other filter - parameters MAY appear multiple times in a FETCH, SUBSCRIBE, - SUBSCRIBE_TRACKS, or REQUEST_UPDATE (on a subscription, from the - subscriber only) message. If the same combination of Parameter Type, - SetID, and Property Type (only in the Track and Object Property - Filters) repeat in any message, an endpoint MUST reject this with - REQUEST_ERROR with error code INVALID_FILTER. + The authority portion MUST NOT contain an empty host portion. The + moqt URI scheme supports the /.well-known/ path prefix defined in + [RFC8615]. - In REQUEST_UPDATE, Length of 0 removes the filter; non-zero replaces - it entirely. If a filter parameter is omitted from REQUEST_UPDATE, - it is unchanged. If omitted from other messages, the default is no - filter. + The moqt URI scheme follows the generic URI syntax of [RFC3986] for + the authority, path-abempty, and query components, including the use + of reserved characters and percent-encoding defined therein. A moqt + URI can be converted to an https URI by replacing the scheme (see + Section 6.2.1), so the path-abempty and query components use the same + syntax as https URIs. - Range Filters are only allowed if the setup option MAX_FILTER_RANGES - is non-zero, which limits the total number of Ranges allowed in all - Range Filter parameters for a given subscription or fetch. If this - limit is exceeded, an endpoint MUST reject this with REQUEST_ERROR - with error code INVALID_FILTER. +6.1.1. Fragment Identifiers - The Track Property Filter can be used in SUBSCRIBE_TRACKS to filter - PUBLISH messages with required Track Property types and values. - PUBLISH messages which pass the filter will be forwarded while those - which do not pass it will not be forwarded nor will any Objects. + The media type for resources identified by moqt URIs is application/ + moqt (see Section 16.2). - The Object Property Filter can be used to filter Objects with - required Object Property types and values. It only filters Object - Properties in the Object header, and does not evaluate Track - Properties in PUBLISH messages. + Fragment identifiers MAY be used with moqt URIs. The fragment is not + transmitted to the server; it is processed locally by the client + after establishing the MOQT session. + A moqt URI fragment MUST begin with a registered fragment type + identifier, followed by a colon (:), followed by a type-specific + value: + moqt://example.com/app#: + Fragment type identifiers MUST consist of ASCII lowercase letters, + digits, and hyphens (a-z, 0-9, -). The semantics of the value after + the colon are defined by the specification that registers the + fragment type. + Fragment type identifiers are registered in the "MOQT URI Fragment + Types" registry (Section 16.3). +6.1.2. Dereferencing a MOQT URI + The default operation for dereferencing a moqt URI is to establish a + MOQT session to the identified server. -Nandakumar, et al. Expires 4 March 2027 [Page 45] - -Internet-Draft moq-transport August 2026 -5.1.5. Combining Filters +Nandakumar, et al. Expires 4 April 2027 [Page 43] + +Internet-Draft moq-transport October 2026 - All filter types are combined using logical "AND" operations to - further restrict which tracks and objects pass all filter criteria. - This includes all Range Filters Section 5.1.4 and Location Filters - Section 5.1.2, which can be evaluated in any order. The Forward - parameter is also a type of filter. The publisher MUST forward only - objects that pass all filters. - Pass = Forward AND Location Filters AND Range Filters + The moqt URI scheme has the following security considerations: -5.1.6. Joining an Ongoing Track + * The authority component is sent in the TLS SNI extension during + connection establishment, exposing the target server identity to + on-path observers. Encrypted Client Hello (ECH) [RFC9580] can + mitigate this exposure. - The MOQT Object model is designed with the concept that the beginning - of a Group is a join point, so in order for a subscriber to join a - Track, it needs to request an existing Group or wait for a future - Group. Different applications will have different approaches for - when to begin a new Group. + * The path-abempty and query components are visible to the relay + that terminates the client's connection. - To join a Track immediately, the subscriber sends a SUBSCRIBE with a - Location Filter Section 5.1.2 that starts at the Next Object. - Delivery begins with the next Object and can begin mid-group. + TODO: Add internationalization statement per RFC 7595 Section 3.6. - To join a Track at the current Group, the subscriber sends a - SUBSCRIBE with a Location Filter that starts at the Next Object and a - FILL_PARAMETERS parameter (see Section 10.2.15) whose Location filter - has StartGroup=1, which fills the current Group from its start. + The client resolves the host subcomponent of the authority to one or + more network addresses, most commonly using DNS A [RFC1035] and AAAA + [RFC3596] records. - To join a Track at a past Group, the subscriber sends a SUBSCRIBE - with a FILL_PARAMETERS parameter whose Location filter selects the - intended Groups, which can be relative. The publisher delivers the - fill range on a fill fetch stream and subscription-delivered Objects - in subgroups or datagrams (see Section 5.1.3). + When SVCB-compatible records [RFC9460] are published for the + authority, a client MAY use them to learn the server's endpoints and + supported ALPN protocols before connecting. A client using + WebTransport resolves the https URI derived in Section 6.2.1 using + HTTPS resource records as for any https origin. TODO: reference moqt + SVCB record draft once available. - To join a Track at the next Group, the subscriber sends a SUBSCRIBE - with a Location Filter Section 5.1.2 that starts at the Next Group. + If the port is omitted in the URI, a default port of 443 is used. -5.1.6.1. Dynamically Starting New Groups + The client MAY use either native QUIC or WebTransport. On a QUIC + connection, the client offers any combination of MOQT ALPNs (e.g. + moqt-1, moqt-2) and h3 that it supports in its TLS ClientHello, in + preference order. If the server selects an MOQT ALPN, the session + proceeds as described in Section 6.2.2. If the server selects h3, + the client establishes a WebTransport session as described in + Section 6.2.1. On a TCP+TLS connection, the client offers h2 in its + TLS ClientHello and establishes a WebTransport session as described + in Section 6.2.1. - While some publishers will deterministically create new Groups, other - applications might want to only begin a new Group when needed. A - subscriber joining a Track might detect that it is more efficient to - request the Original Publisher create a new group than to fill the - current group. Publishers indicate a Track supports dynamic group - creation using the DYNAMIC_GROUPS Track Property (Section 12.6). +6.2. Session establishment + This document defines a protocol that can be used interchangeably + both over a QUIC connection directly [QUIC], and over WebTransport + [WebTransport]. Both provide streams and datagrams with similar + semantics (see [I-D.ietf-webtrans-overview], Section 4); thus, the + main difference lies in how the servers are identified and how the + connection is established. When MOQT runs directly over QUIC or over + WebTransport on HTTP/3, the QUIC DATAGRAM extension ([RFC9221]) MUST + be supported and negotiated in the QUIC connection used for MOQT, + which is already a requirement for WebTransport over HTTP/3. -Nandakumar, et al. Expires 4 March 2027 [Page 46] +Nandakumar, et al. Expires 4 April 2027 [Page 44] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - One possible subscriber pattern is to SUBSCRIBE to a Track using a - Location Filter that starts at the Next Object and observe the - Largest Object in the response. If the Object ID is below the - application's threshold, the subscriber sends a FETCH for the - beginning of the Group. If the Object ID is above the threshold and - the Track supports dynamic groups, the subscriber sends a - REQUEST_UPDATE message with the NEW_GROUP_REQUEST parameter equal to - the Next Group (see Section 10.2.19). + WebTransport can itself run over HTTP/2 ([I-D.ietf-webtrans-http2]), + in which case datagrams are reliable and ordered and TCP loss blocks + delivery on every stream. MOQT remains functional, but its latency + behavior differs substantially from a deployment over QUIC. - Another possible subscriber pattern is to send a SUBSCRIBE with a - Location Filter that starts at the Next Group and NEW_GROUP_REQUEST - equal to 0. The value of DYNAMIC_GROUPS in SUBSCRIBE_OK will - indicate if the publisher supports dynamic groups. A publisher that - does will begin the next group as soon as practical. + This document does not define how to run the protocol directly over + other transports, such as TCP, and applications using MOQT might need + to fallback to another protocol when QUIC or WebTransport aren't + available. -5.2. Fetch State Management + MOQT uses ALPN in QUIC and "WT-Available-Protocols" in WebTransport + ([WebTransport], Section 3.3) to perform version negotiation. - The publisher MUST send exactly one FETCH_OK or REQUEST_ERROR in - response to a FETCH. + The ALPN value [RFC7301] for the final version of this specification + is moqt. - A subscriber keeps FETCH state until it cancels the request (see - Section 3.3.3), receives REQUEST_ERROR, or the FETCH data stream - receives a FIN or is reset. If the data stream is already open, the - subscriber wishing to cancel the FETCH MAY send STOP_SENDING for the - data stream as well as the bidi request stream. It MUST send - STOP_SENDING for the bidi request stream. + [[RFC editor: please remove the remainder of this section before + publication.]] - The Publisher can remove fetch state as soon as it has received a - STOP_SENDING. It MUST reset the bidi request stream and - unidirectional data stream associated with the FETCH. It can also - remove state after closing the FETCH data stream. + ALPNs used to identify IETF drafts are created by appending the draft + number to "moqt-". For example, draft-ietf-moq-transport-13 would be + identified as "moqt-13". - It can remove all FETCH state after closing the data stream with a - FIN. + Note: Draft versions prior to -15 all used moq-00 ALPN, followed by + version negotiation in the SETUP messages. - A REQUEST_ERROR indicates that both endpoints can immediately remove - state. Since a relay can start delivering FETCH Objects from cache - before determining the result of the request, some Objects could be - received even if the FETCH results in error. +6.2.1. WebTransport -6. Namespace Discovery + When the client uses WebTransport, it constructs an https URI from + the moqt URI by replacing the scheme with https. For example, + moqt://example.com/path becomes https://example.com/path. The client + sends an extended CONNECT request to this URI to establish a + WebTransport session, as described in ([WebTransport], Section 3). + The client includes MOQT protocol identifiers in the WT-Available- + Protocols header ([WebTransport], Section 3.3). - Discovery of MOQT servers is always done out-of-band. Namespace - discovery can be done in the context of an established MOQT session - using SUBSCRIBE_NAMESPACE (see Section 6.1). +6.2.2. Native QUIC + The client establishes a QUIC connection to the host and port + identified by the authority section of the URI. When the client uses + native QUIC, the authority, path-abempty and query portions of the + URI are transmitted in Setup Options (see Section 9.1). -Nandakumar, et al. Expires 4 March 2027 [Page 47] - -Internet-Draft moq-transport August 2026 - Given sufficient out of band information, it is valid for a - subscriber to send a SUBSCRIBE or FETCH message to a publisher - (including a relay) without any previous MOQT messages besides SETUP. - However, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS, PUBLISH and - PUBLISH_NAMESPACE messages provide an in-band means of discovery of - publishers for a namespace. - The syntax of these messages is described in Section 10. -6.1. Subscribing to Namespaces +Nandakumar, et al. Expires 4 April 2027 [Page 45] + +Internet-Draft moq-transport October 2026 - If the subscriber is aware of a namespace of interest, it can send - SUBSCRIBE_NAMESPACE or SUBSCRIBE_TRACKS to publishers/relays it has - established a session with. The Track Namespace Prefix carried in - these messages is compared against the namespaces known to the - receiver using Namespace Prefix Matching (Section 9.5, Paragraph 6). - SUBSCRIBE_NAMESPACE requests namespace discovery: the publisher sends - relevant NAMESPACE and NAMESPACE_DONE messages for namespaces - matching the prefix, including echoing back Track Namespaces under - the prefix that have been published to it. +6.3. Session initialization - SUBSCRIBE_TRACKS requests track subscriptions: the publisher sends - PUBLISH messages for tracks within matching namespaces, excluding - tracks published by the subscriber. + MOQT uses a pair of unidirectional streams for creating the session + and exchanging control messages. Each peer opens one control stream + beginning with a SETUP message. Using a pair of unidirectional + streams rather than a single bidirectional stream allows either peer + to send data as soon as it is able. Depending on whether 0-RTT is + available on the QUIC connection, either the client or the server + might be able to send stream data first. - Either message with zero Track Namespace fields indicates the sender - is interested in all namespaces or all tracks from the receiver, - respectively. + In addition to the control streams, this specification uses + bidirectional streams to carry requests. A request stream begins + with one of these seven message types: TRACK_STATUS, SUBSCRIBE, + PUBLISH, FETCH, PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, and + SUBSCRIBE_TRACKS. Bidirectional streams MUST NOT begin with any + other message type unless negotiated. If they do, the peer MUST + close the Session with a PROTOCOL_VIOLATION. Objects are sent on + unidirectional streams. - By sending SUBSCRIBE_NAMESPACE, the subscriber indicates that it - trusts the relay to be authoritative for namespaces matching the - requested prefix. NAMESPACE messages received on the - SUBSCRIBE_NAMESPACE response stream inherit this trust and do not - independently carry authorization. + As such, a client can initiate a MOQT session, subscribe, and start + publishing Objects all in parallel. When this is done before the + handshake completes using 0-RTT, the security implications described + in Section 6.3.1 apply. - The subscriber sends SUBSCRIBE_NAMESPACE or SUBSCRIBE_TRACKS on a new - bidirectional stream and the publisher MUST send a single REQUEST_OK - or REQUEST_ERROR as the first message on the bidirectional stream in - response. + Unidirectional streams containing Objects or bidirectional stream(s) + beginning with a request message could arrive prior to the control + streams, in which case the data SHOULD be buffered until both control + streams arrive and setup is complete. If an implementation does not + want to buffer or if the message type is not supported, it MAY reset + such streams before the session and control streams are established. - If a Subscription cannot be created because there are no available - bidirectional streams or any other reason, the Publisher sends a - PUBLISH_SKIPPED message on the SUBSCRIBE_TRACKS response stream to - indicate the Full Track Name of the Subscription that was not - created. The Publisher MUST NOT send a PUBLISH for a Track for a - given SUBSCRIBE_TRACKS after PUBLISH_SKIPPED has been sent, scoped to - a single PUBLISH. If, for example, the publisher disconnects from a + A control stream MUST NOT be closed at the underlying transport layer + during the session's lifetime. Doing so results in the session being + closed as a PROTOCOL_VIOLATION. + Prior to receiving the peer's SETUP message, it's unknown what + extensions a peer will support. Message Parameters requiring + negotiation SHOULD NOT be used prior to receiving the peer's SETUP + message unless the application requires the extension or the endpoint + knows the peer supports the extension. If an unsupported Message + Parameter is used, the peer will be unable to process it and the + session will be terminated. See Section 9.20. -Nandakumar, et al. Expires 4 March 2027 [Page 48] - -Internet-Draft moq-transport August 2026 - relay and later reconnects and sends a new PUBLISH, the relay MAY - send the new PUBLISH downstream. If desired, the subscriber can - issue a SUBSCRIBE to establish a subscription to that track. - The receiver of a REQUEST_OK or REQUEST_ERROR ought to forward the - result to the application, so the application can decide which other - publishers to contact, if any. - A SUBSCRIBE_NAMESPACE or SUBSCRIBE_TRACKS is cancelled as described - in Section 3.3.3, by resetting or sending STOP_SENDING on the stream. - Cancelling SUBSCRIBE_TRACKS does not prohibit original publishers - from sending further PUBLISH messages, but relays MUST NOT send any - further PUBLISH messages to a client without knowing the client is - interested in and authorized to receive the content. -6.2. Publishing Namespaces - A publisher MAY send PUBLISH_NAMESPACE messages to any subscriber. A - PUBLISH_NAMESPACE indicates to the subscriber that the publisher has - tracks available in that namespace. A subscriber MAY send SUBSCRIBE - or FETCH for tracks in a namespace without having received a - PUBLISH_NAMESPACE for it. - If a publisher is the Original Publisher for one or more tracks in a - given namespace, or is a relay that has received an authorized - PUBLISH_NAMESPACE for that namespace from an upstream publisher, it - MUST send a NAMESPACE message that includes this namespace to any - subscriber that has sent a SUBSCRIBE_NAMESPACE whose prefix matches - this namespace. +Nandakumar, et al. Expires 4 April 2027 [Page 46] + +Internet-Draft moq-transport October 2026 - A subscriber can receive a PUBLISH_NAMESPACE on a request stream for - a namespace that falls within an active SUBSCRIBE_NAMESPACE prefix. - This occurs when SUBSCRIBE_NAMESPACE or its response is in flight at - the same time as a PUBLISH_NAMESPACE, or when an original publisher - sends PUBLISH_NAMESPACE to advertise namespaces within the prefix - being discovered. Such a PUBLISH_NAMESPACE is valid and MAY carry an - AUTHORIZATION TOKEN parameter. Its lifetime is independent of the - SUBSCRIBE_NAMESPACE stream. - An endpoint SHOULD report the reception of a REQUEST_OK or - REQUEST_ERROR to the application to inform the search for additional - subscribers for a namespace, or to abandon the attempt to publish - under this namespace. A subscriber MUST send exactly one REQUEST_OK - or REQUEST_ERROR as the first message on the bidi stream in response - to a PUBLISH_NAMESPACE. The publisher SHOULD close the session with - a protocol error if it receives more than one. +6.3.1. 0-RTT + + QUIC supports 0-RTT (Section 2.3 of [RFC8446]), but WebTransport over + QUIC is not expected to use 0-RTT, because initializing a + WebTransport session uses CONNECT, which is not a safe method. + [RFC8470] describes the use of 0-RTT with HTTP in more detail. If + 0-RTT is used with an existing or future version of WebTransport, the + following would apply to it as well as QUIC. + MOQT Messages and Objects as defined in this draft are safe to replay + in most circumstances. + * TRACK_STATUS gets the Largest Object and Track Properties, but + does not change the state of a Track or any Object in the Track. + * SUBSCRIBE requests Objects be delivered, but does not change the + Objects being requested. + * PUBLISH initiates a Subscription. Objects can be immediately sent + to the Subscriber. Processing the same Objects multiple times is + idempotent, as the subscriber or relay can identify and discard + duplicates based on the Group ID and Object ID. -Nandakumar, et al. Expires 4 March 2027 [Page 49] - -Internet-Draft moq-transport August 2026 + * SUBSCRIBE_NAMESPACE requests a list of namespaces and the + establishment of new subscriptions, but does not change the + available Namespaces, Tracks, or Objects contained within a Track. + * PUBLISH_NAMESPACE requests that Subscriptions under the namespace + be sent to that Publisher. If a Subscription was sent to the + replaying endpoint, it would fail because the endpoint cannot + complete the handshake. - A PUBLISH_NAMESPACE is withdrawn by cancelling the request (see - Section 3.3.3), although it is not a protocol error for the - subscriber to send a SUBSCRIBE or FETCH message for a track in a - namespace after the namespace is withdrawn. + Some potential side effects of replay are: - A subscriber can cancel the request (see Section 3.3.3) to revoke - acceptance of a PUBLISH_NAMESPACE. If the reason for cancellation is - expiration of authorization credentials, the publisher can send - PUBLISH_NAMESPACE again on a new bidi stream with refreshed - authorization, or close the stream and discard associated state. + * Publishing Objects that were previously published could cause + those Objects to be distributed to active Subscriptions if the + relays do not identify them as already having been published. + This re-distribution could also make them available in cache again + after they previously expired. - While PUBLISH_NAMESPACE indicates to relays how to connect publishers - and subscribers, it is not a full-fledged routing protocol and does - not protect against loops and other phenomena. In particular, - PUBLISH_NAMESPACE SHOULD NOT be used to find paths through richly - connected networks of relays. + Replays could increase load on the MOQT network. For relay to client + traffic, this is no worse than 0-RTT in HTTP/3, since the server is + limited by the amplification factor until address validation. + However, it could cause the relay to initiate new upstream + Subscriptions. For a SUBSCRIBE_TRACKS request, sending that upstream + could cause the Relay to receive a number of new Subscriptions on the + replaying client's behalf. - A subscriber MAY send a SUBSCRIBE or FETCH for a track to any - publisher. If it has accepted a PUBLISH_NAMESPACE with a namespace - that exactly matches the namespace for that track, it SHOULD only - request it from the senders of those PUBLISH_NAMESPACE messages. -6.3. Filtering SUBSCRIBE_TRACKS - Range Filters Section 5.1.4 can be used in SUBSCRIBE_TRACKS to filter - Tracks in a namespace using the Track Property Filter. Objects - published in the resulting Subscriptions can be filtered by any Range - Filter. -6.3.1. Relay Resource Protection in Large Namespaces +Nandakumar, et al. Expires 4 April 2027 [Page 47] + +Internet-Draft moq-transport October 2026 - Relays SHOULD aggregate and propagate filters upstream on - subscriptions, especially namespace subscriptions, to conserve and - protect their resources from excessive load. They MAY also impose - limits on the number of publishers in a namespace, by rejecting or - closing namespace subscriptions with the error NAMESPACE_TOO_LARGE, - or CONFLICTING_FILTERS if too many disjoint filters are requested on - downstream subscriptions across a large number of subscribers, or - PREFIX_OVERLAP if different subscribers force an aggregated upstream - subscription to overlap. -7. Priorities + Relays MAY defer initiating upstream subscriptions until the + handshake is complete or reject 0-RTT entirely to mitigate resource + exhaustion from replayed packets. - MOQT priorities allow a subscriber and original publisher to - influence the transmission order of Objects within a session in the - presence of congestion. +6.3.2. Extension Negotiation + Endpoints use the exchange of Setup messages to negotiate MOQT + extensions. Extensions can define new Message types, new Parameters, + new Properties, new Parameter values, or new framing for Streams and + Datagrams. + The client and server MUST include all Setup Options Section 9.1 + required for the negotiated MOQT version in SETUP. + Each endpoint declares the extensions it supports and provides any + initial values required by those extensions as Setup Options in + SETUP. Once an endpoint has both sent and received SETUP messages, + it determines the set of negotiated extensions. + There is no generic format for declaring extension support. Each + extension specification defines the Setup Option or Options used to + declare support for that extension, the format of their values, and + the rules for determining whether the extension is negotiated. For + example, an extension could be declared by a zero length option, + where presence alone indicates support, or by an option carrying a + list of supported extension versions from which the endpoints select + a common version. Setup Option types are registered with IANA; see + Section 16.4. -Nandakumar, et al. Expires 4 March 2027 [Page 50] - -Internet-Draft moq-transport August 2026 + New versions of MOQT MUST specify which existing extensions can be + used with that version. New extensions MUST specify the existing + versions with which they can be used. +6.4. Stream Usage -7.1. Definitions +6.4.1. Unidirectional Streams - MOQT maintains priorities between different schedulable objects. A - schedulable object in MOQT is either: + All unidirectional MOQT streams start with a variable-length integer + indicating the type of the stream. - 1. The first or next Object in a Subgroup that is in response to a - subscription. - 2. An Object with forwarding preference Datagram. - 3. An Object in response to a FETCH where that Object is the next - Object in the response. - An Object is not schedulable if it is known that no part of it can be - written due to underlying transport flow control limits. - A single subgroup or datagram has a single publisher priority. - Within a subscription, it can be useful to conceptualize this process - as scheduling subgroups or datagrams instead of individual objects on - them. FETCH responses however can contain objects with different - publisher priorities. - A priority numberis an unsigned integer with a value between 0 and - 255. A lower priority number indicates higher priority; the highest - priority is 0. - Subscriber Priority is a priority number associated with an - individual request. It is carried in the SUBSCRIBER_PRIORITY - parameter (Section 10.2.7), and can be updated. The subscriber - priority of an individual schedulable object is the subscriber - priority of the request that caused that object to be sent. When - subscriber priority is changed, a best effort SHOULD be made to apply - the change to all objects that have not been scheduled, but it is - implementation dependent what happens to objects that have already - been scheduled. - Publisher Priority is a priority number associated with an individual - schedulable object. A default for the subscription is specified in - the DEFAULT_PUBLISHER_PRIORITY Track Property (Section 12.4). - Publisher priority can also be set per subgroup or datagram in the - subgroup header or datagram (see Section 11), which overrides the - default. - Group Order is a property of an individual subscription. It can be - either 'Ascending' (groups with lower group ID are sent first), or - 'Descending' (groups with higher group ID are sent first). The - subscriber optionally communicates its group order preference in the - SUBSCRIBE or SUBSCRIBE_TRACKS message; the publisher's preference, -Nandakumar, et al. Expires 4 March 2027 [Page 51] +Nandakumar, et al. Expires 4 April 2027 [Page 48] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - carried in the DEFAULT_PUBLISHER_GROUP_ORDER Track Property - (Section 12.5), is used if the subscriber did not express one (by - omitting the Group Order parameter). The group order of an existing - subscription cannot be changed. + +============+==================================+ + | ID | Type | + +============+==================================+ + | 0x05 | FETCH_HEADER (Section 11.4.1) | + +------------+----------------------------------+ + | 0b0XX1XXXX | SUBGROUP_HEADER (Section 11.3.1) | + +------------+----------------------------------+ + | 0x2F00 | SETUP (Section 9.1) | + +------------+----------------------------------+ + | 0x132B3E28 | PADDING (Section 11.5.1) | + +------------+----------------------------------+ -7.2. Scheduling Algorithm + Table 2 - When an MOQT publisher has multiple schedulable objects it can choose - between, the objects SHOULD be selected as follows: + An endpoint that receives an unknown stream type MUST close the + session. - 1. If two objects have different subscriber priorities associated - with them, the one with *the highest subscriber priority* is - scheduled to be sent first. + Control streams (SETUP) are described in Section 6.3. Data streams + (FETCH_HEADER, SUBGROUP_HEADER) are described in Section 11. Padding + streams are described in Section 11.5. - 2. If two objects have the same subscriber priority, but different - publisher priorities, the one with *the highest publisher - priority* is scheduled to be sent first. +6.4.2. Bidirectional Request Streams - 3. If two objects in the same subscription have the same subscriber - and publisher priority, but belong to two different groups of the - same track, *the group order* of the subscription is used to - decide the one that is scheduled to be sent first. When a - subscription fill's Group Order differs from the subscription's - Group Order, the subscription-delivered object is scheduled - first. +6.4.2.1. Request ID - 4. If two objects in the same subscription have the same subscriber - and publisher priority and belong to the same group of the same - track, and one is delivered by the fill fetch stream while the - other is subscription-delivered, the fill-delivered object is - scheduled first. Otherwise, the one with *the lowest Subgroup - ID* (for objects with forwarding preference Subgroup), or *the - lowest Object ID* (for objects with forwarding preference - Datagram) is scheduled to be sent first. If the two objects have - different Forwarding Preferences the datagram is sent first. + Request ID is included in request messages and is used to identify + requests across messages. For example, fetch streams reference the + Request ID of a SUBSCRIBE, PUBLISH, FETCH, or REQUEST_UPDATE. - Within the same group, fill-delivered objects win the tie-break over - subscription-delivered objects (rule 4) because objects with smaller - Locations are assumed to be needed before those with larger - Locations. - - The definition of "scheduled to be sent first" in the algorithm is - implementation dependent and is constrained by the prioritization - interface of the underlying transport. For some implementations, it - could mean that the object is serialized and passed to the underlying - transport first. Other implementations can control the order packets - are initially transmitted. + The client generates even numbered Request IDs, starting at 0, and + the server generates odd numbered Request IDs, starting at 1. Each + endpoint increments its Request ID by 2 for each new request. + Each SUBSCRIBE, PUBLISH, FETCH, SUBSCRIBE_NAMESPACE, + SUBSCRIBE_TRACKS, PUBLISH_NAMESPACE, REQUEST_UPDATE, and TRACK_STATUS + message consumes a Request ID. Only request messages include a + Request ID; response messages do not, since they are sent on the same + bidirectional stream as the request. + If an endpoint receives a Request ID where the least significant bit + is incorrect for the sender, or a duplicate Request ID, it MUST close + the session with INVALID_REQUEST_ID. +6.4.2.2. Graceful Request Stream Closure -Nandakumar, et al. Expires 4 March 2027 [Page 52] - -Internet-Draft moq-transport August 2026 + A request stream is bidirectional and each direction is closed + independently, either gracefully with a FIN or abruptly with + RESET_STREAM. - This algorithm does not provide a well-defined ordering for objects - that belong to different subscriptions or FETCH responses, but have - the same subscriber and publisher priority. The ordering in those - cases is implementation-defined, though the expectation is that all - subscriptions will be able to send some data. - A publisher might not utilize the entire available congestion window, - session flow control, or all available streams for lower priority - Objects if it expects higher priority Objects will be available to - send in the near future or it wants to reserve some bandwidth for - control messages. +Nandakumar, et al. Expires 4 April 2027 [Page 49] + +Internet-Draft moq-transport October 2026 - Given the critical nature of control messages and their relatively - small size, the control streams SHOULD be prioritized highest, - followed by the bidi request streams and then all Objects. Bidi - request streams MAY be prioritized within themselves by Subscriber - Priority if specified. -7.3. Considerations for Setting Priorities + A FIN only indicates that an endpoint will send no further messages + in that direction; it is not a request cancellation. An endpoint + MUST NOT send a FIN on a direction of a request stream until it has + sent all required messages on that direction for its request type. + In particular, an endpoint sending a response to a request MUST send + the corresponding response message, and the publisher of an + Established subscription MUST send PUBLISH_DONE, before sending a + FIN. A FIN sent by the responder after its response and any + subsequent messages for the request signals that the request is + complete; if it has not already done so, the requester SHOULD then + send a FIN on its direction, gracefully closing the stream. An + endpoint that receives a FIN before all required messages have + arrived treats the request as failed. - For downstream subscriptions, relays SHOULD respect the subscriber - and original publisher's priorities. Relays can receive - subscriptions with conflicting subscriber priorities or Group Order - preferences. Relays SHOULD NOT directly use Subscriber Priority or - Group Order from incoming subscriptions for upstream subscriptions. - A Relay's use of these fields for upstream subscriptions can be based - on factors specific to it, such as the popularity of the content or - policy, or relays can specify the same value for all upstream - subscriptions. + An endpoint SHOULD send a FIN promptly after a message when it has + nothing further to send on that direction and will not need to + respond to a future REQUEST_UPDATE. A requester, with the exception + of the sender of PUBLISH, MAY FIN immediately after sending a message + if it will not send a REQUEST_UPDATE. - MOQT Sessions can span multiple namespaces, and priorities might not - be coordinated across namespaces. The subscriber's priority is - considered first, so there is a mechanism for a subscriber to fix - incompatibilities between different namespaces prioritization - schemes. Additionally, it is anticipated that when multiple - namespaces are present within a session, the namespaces could be - coordinating, possibly part of the same application. In cases when - pooling among namespaces is expected to cause issues, multiple MOQT - sessions, either within a single connection or on multiple - connections can be used. +6.4.2.3. Request Cancellation and Rejection - Implementations that have a default priority SHOULD set it to a value - in the middle of the range (eg: 128) to allow non-default priorities - to be set either higher or lower. + Once a request stream has been opened, the request MAY be cancelled + by either endpoint. Senders cancel requests if the response is no + longer of interest; Receivers cancel requests if they are unable to + or choose not to respond. Implementations cancel a request by + abruptly terminating any directions of the stream that are still + open, using RESET_STREAM for a direction they are sending and + STOP_SENDING for a direction they are receiving. An endpoint that + has already sent a FIN on its sending direction and subsequently + wishes to cancel sends STOP_SENDING on the receiving direction. + When an endpoint rejects a request without performing any application + processing, it SHOULD send a REQUEST_ERROR and FIN the stream. +6.5. Session-Level Tracks and Namespaces + MOQT defines the .session namespace (the bytes 0x2e, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e) in the first position of the Track + Namespace for session-level tracks and namespaces. Session-level + tracks and namespaces are managed by the MOQT implementation, not the + Application. They provide a mechanism for extending MOQT transport + functionality using existing subscription and object delivery + machinery, without defining new control messages or stream types. + The Application MUST NOT publish tracks or namespaces whose first + field is .session. Relays MUST NOT forward requests for session- + level tracks and namespaces to other sessions. -Nandakumar, et al. Expires 4 March 2027 [Page 53] +Nandakumar, et al. Expires 4 April 2027 [Page 50] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 -8. Delivery Timeouts and Data Reliability + The empty track name in the .session namespace is defined to not + exist. A request with a Track Namespace whose first field is + .session and an empty Track Name MUST be rejected with + DOES_NOT_EXIST. - Each MOQT subscription has two timeout values associated with it: a - SUBGROUP_DELIVERY_TIMEOUT and an OBJECT_DELIVERY_TIMEOUT. Both of - those values are expressed in milliseconds and both are optional; a - value of 0 means that there is no timeout set. + An endpoint that receives a request for an unrecognized session-level + track or namespace MUST reject it with REQUEST_ERROR using error code + DOES_NOT_EXIST rather than passing it to the Application. - The publisher communicates both timeout values as a Track Property; - the subscriber communicates them as Message Parameters. Either - timeout value can also be set as an Object Property on the first - object in a subgroup, overriding the Track-level value for that - subgroup. If either timeout is set as an Object Property on any - object other than the first in a subgroup, it is ignored. For each - type of timeout, the publisher's value is the Object Property when - present on the first object of the subgroup, and the Track Property - otherwise. If both the publisher's value and the subscriber's value - are non-zero, the smaller of the two is used. + The track names and namespaces available under the .session namespace + are defined by extensions to this specification and registered with + IANA (see Section 16.10). - If the OBJECT_DELIVERY_TIMEOUT is not zero, the MOQT implementation - MUST retain the time at which the last header byte of every object - has been either received from the upstream subscription, or provided - by the original publisher application. The actual mechanism by which - the timeout works depends on the Object Forwarding Preference: +6.6. Termination - * For subgroups, the implementation MUST check the time elapsed - before attempting to pass it to the underlying transport for - transmission; if the time elapsed exceeds OBJECT_DELIVERY_TIMEOUT, - it MUST reset the underlying transport stream with the reset - stream code DELIVERY_TIMEOUT (see Section 11.4.3) and SHOULD NOT - attempt to open a new stream to deliver additional Objects in that - Subgroup. The implementation SHOULD check object delivery - timeouts before retransmitting object data if the underlying - transport implementation allows. The implementations SHOULD - minimize the amount of data buffered at the underlying transport - layer, as any data buffered at this layer can no longer be timed - out, potentially leading to transmission of expired data. + The Transport Session can be terminated at any point. When native + QUIC is used, the session is closed using the CONNECTION_CLOSE frame + ([QUIC], Section 19.19). When WebTransport is used, the session is + closed using the CLOSE_WEBTRANSPORT_SESSION capsule ([WebTransport], + Section 6). - * For datagrams, the implementation MUST drop the datagrams if the - time elapsed exceeds OBJECT_DELIVERY_TIMEOUT. Similar to - subgroups, implementations SHOULD either minimize datagram - queueing, or use datagram queueing mechanisms that support time - bounds (such as the outgoingMaxAge parameter in the W3C - WebTransport API). + The error codes used when terminating a Session are defined in + Section 12.2. - If the Object Forwarding Preference is Subgroup and the value of - SUBGROUP_DELIVERY_TIMEOUT is not zero, the MOQT implementation MUST - start a timer of SUBGROUP_DELIVERY_TIMEOUT duration once it becomes - aware that all of the objects on the subgroup have been published + An endpoint MAY choose to treat a subscription or request specific + error as a session error under certain circumstances, closing the + entire session in response to a condition with a single subscription + or message. Implementations need to consider the impact on other + outstanding subscriptions before making this choice. +6.6.1. Graceful Session Migration + MOQT requires a long-lived and stateful session. However, a service + provider needs the ability to shutdown/restart a server without + waiting for all sessions to drain naturally, as that can take days + for long-form media. MOQT enables proactively draining sessions via + the GOAWAY message (Section 9.2). -Nandakumar, et al. Expires 4 March 2027 [Page 54] - -Internet-Draft moq-transport August 2026 + A GOAWAY on the control stream migrates the entire session, as + described in this section. A GOAWAY on a single request stream + instead migrates only that request, leaving the rest of the session + in place; see Section 9.2. + The server sends a GOAWAY message, signaling the client to establish + a new session and migrate any Established subscriptions. The GOAWAY + message optionally contains a new URI for the new session, otherwise + the current URI is reused. The GOAWAY message contains a Timeout + indicating how long, in milliseconds, the sender intends to wait - (either by receiving a FIN from the upstream subscription, or, in - case of the original publisher, through being notified of this fact - by the application). If the timer expires before the underlying - transport stream reaches "all data committed" state - ([I-D.ietf-webtrans-overview], Section 4.3), the implementation MUST - reset the stream. This ensures that MOQT can time out subgroups - where all of the data has been sent but not yet fully delivered due - to packet loss. - For objects whose Object Forwarding Preference is Datagram, the - SUBGROUP_DELIVERY_TIMEOUT acts the same way as - OBJECT_DELIVERY_TIMEOUT; if both are non-zero, the smaller of the two - is used. - +=========+===========================+===========================+ - | | SUBGROUP_DELIVERY_TIMEOUT | OBJECT_DELIVERY_TIMEOUT | - +=========+===========================+===========================+ - | Timeout | When the FIN for the | When the last byte of the | - | starts | subgroup is received | object header is received | - +---------+---------------------------+---------------------------+ - | Timeout | Via a timer until all | When the object is sent | - | checked | data is acknowledged | to the underlying | - | at | | transport | - +---------+---------------------------+---------------------------+ - | Action | Reset for subgroups, drop | Reset for subgroups, drop | - | upon | for datagrams | for datagrams | - | timeout | | | - +---------+---------------------------+---------------------------+ +Nandakumar, et al. Expires 4 April 2027 [Page 51] + +Internet-Draft moq-transport October 2026 - Table 4: Comparison of the delivery timeout mechanisms - Publishers can, at their discretion, discontinue forwarding Objects - before either timeout occurs, subject to stream closure and ordering - constraints described in Section 11.4.3. However, if neither timeout - is set to a non-zero value, all Objects in the track matching the - subscription filter are delivered as indicated by their Group Order - and Priority. If a subscriber fails to consume Objects at a - sufficient rate, causing the publisher to exceed its resource limits, - the publisher MAY terminate the subscription using PUBLISH_DONE with - error TOO_FAR_BEHIND. + before closing the session. The sender SHOULD close the session with + GOAWAY_TIMEOUT after the indicated timeout if there are still open + subscriptions or fetches on a connection. -9. Relays + When the server is a subscriber, it SHOULD send a GOAWAY message to + downstream subscribers prior to unsubscribing from upstream + publishers. + + After the client receives a GOAWAY, it's RECOMMENDED that the client + waits until there are no more Established subscriptions before + closing the session with NO_ERROR. Ideally this is transparent to + the application using MOQT, which involves establishing a new session + in the background and migrating Established subscriptions and + published namespaces. The client can choose to delay closing the + session if it expects more OBJECTs to be delivered. The sender + closes the session with a GOAWAY_TIMEOUT if the peer doesn't close + the session within the indicated Timeout. + +7. Relays Relays are leveraged to enable distribution scale in the MOQT architecture. Relays can be used to form an overlay delivery @@ -3075,17 +2884,15 @@ Internet-Draft moq-transport August 2026 (CDNs). Additionally, relays serve as policy enforcement points by validating subscribe and publish requests at the edge of a network. - - -Nandakumar, et al. Expires 4 March 2027 [Page 55] - -Internet-Draft moq-transport August 2026 - - Relays are endpoints, which means they terminate Transport Sessions in order to have visibility of MOQT Object metadata. -9.1. Caching Relays + For the purposes of this specification, a coordinated set of relays + are treated as a single MOQT relay. How relays within such a set + interconnect, and use cases built on relay to relay communication, + are out of scope. + +7.1. Caching Relays Relays MAY cache Objects, but are not required to. @@ -3100,12 +2907,19 @@ Internet-Draft moq-transport August 2026 1. Object can transition from existing to not existing in cases where the object is no longer available. + + +Nandakumar, et al. Expires 4 April 2027 [Page 52] + +Internet-Draft moq-transport October 2026 + + 2. Object Properties can be added, removed or updated, subject to the constraints of the specific property. An endpoint that receives a duplicate Object with a different - Forwarding Preference, Subgroup ID, Priority or Payload MUST treat - the track as Malformed. + Delivery Mode, Subgroup ID, Priority or Payload MUST treat the track + as Malformed. For ranges of objects that do not exist, relays MAY change the representation of a missing range to a semantically equivalent one. @@ -3117,46 +2931,48 @@ Internet-Draft moq-transport August 2026 it has already recorded that the Object does not exist. A caching relay SHOULD NOT cache or forward the Object in this case. - A cache MUST store all fields of an Object defined in Section 11.2.1, - with the exception of any Object Properties (Section 11.2.1.2) that + A cache MUST store all fields of an Object defined in Section 2.1.1, + with the exception of any Object Properties (Section 11.1.2) that specify otherwise. -9.2. Forward Handling +7.2. Paused Subscription Handling - If one or more downstream subscribers to a track have Forward=1, the - relay MUST set Forward=1 upstream in order to receive and forward the - requested Objects. When no downstream subscriber has Forward=1, the - relay chooses the upstream Forward value at its discretion, - considering the following tradeoffs and deployment considerations: + If one or more downstream subscribers to a track are not paused, the + relay MUST have an unpaused upstream subscription, in order to + receive and forward the requested Objects. When all downstream + subscribers are paused, the relay chooses whether to pause upstream + at its discretion, considering the following tradeoffs and deployment + considerations: + * Leaving the upstream subscription unpaused starts object delivery + and pre-warms the relay's cache, so objects are available when a + downstream subscriber resumes. This reduces latency but consumes + upstream and publisher resources for content no downstream + subscriber is currently receiving. + * Pausing the upstream subscription avoids that work, at the cost of + higher latency when delivery is later resumed. +7.3. Multiple Publishers + A Relay can receive PUBLISH_NAMESPACE for the same Track Namespace + Prefix or PUBLISH messages for the same Track from multiple + publishers. The following sections explain how Relays maintain + subscriptions to all available publishers for a given Track. -Nandakumar, et al. Expires 4 March 2027 [Page 56] - -Internet-Draft moq-transport August 2026 - * Setting Forward=1 upstream starts object delivery and pre-warms - the relay's cache, so objects are available when a downstream - subscriber sets Forward=1. This reduces latency but consumes - upstream and publisher resources for content no downstream - subscriber is currently receiving. - * Setting Forward=0 upstream avoids that work, at the cost of higher - latency when forwarding is later enabled. -9.3. Multiple Publishers - A Relay can receive PUBLISH_NAMESPACE for the same Track Namespace or - PUBLISH messages for the same Track from multiple publishers. The - following sections explain how Relays maintain subscriptions to all - available publishers for a given Track. +Nandakumar, et al. Expires 4 April 2027 [Page 53] + +Internet-Draft moq-transport October 2026 + There is no specified limit to the number of publishers of a Track Namespace or Track. An implementation can use mechanisms such as - REQUEST_ERROR or unsubscribing (see Section 3.3.3) if it cannot + REQUEST_ERROR or unsubscribing (see Section 6.4.2.3) if it cannot accept an additional publisher due to implementation constraints. Implementations can consider the establishment or idle time of the session or subscription to determine which publisher to reject or @@ -3167,10 +2983,10 @@ Internet-Draft moq-transport August 2026 The Relay SHOULD attempt to deduplicate Objects before forwarding, subject to implementation constraints. -9.4. Subscriber Interactions +7.4. Subscriber Interactions - Subscribers request Tracks by sending a SUBSCRIBE (see Section 10.7) - or FETCH (see Section 10.13) control message for each Track of + Subscribers request Tracks by sending a SUBSCRIBE (see Section 9.6) + or FETCH (see Section 9.11) control message for each Track of interest. Relays MUST ensure subscribers are authorized to access the content associated with the Track. The authorization information can be part of request itself or part of the encompassing session. @@ -3182,25 +2998,15 @@ Internet-Draft moq-transport August 2026 relay does not have sufficient information to send a FETCH_OK immediately in response to a FETCH, it MUST withhold sending FETCH_OK until it does. Relays MUST follow the constraints on LARGEST_OBJECT - defined in Section 10.2.17. - - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 57] - -Internet-Draft moq-transport August 2026 - + defined in Section 9.20.17. Publishers maintain a list of Established downstream subscriptions - for each Track. Relays use the Track Alias (Section 11.1) of an + for each Track. Relays use the Track Alias (Section 3.1.3) of an incoming Object to identify its Track and find the current subscribers. Each new Object belonging to the Track is forwarded to each subscriber, as allowed by the subscription's filter (see - Section 10.7), and delivered according to the priority (see - Section 7) and delivery timeout (see Section 8). + Section 9.6), and delivered according to the priority (see + Section 5.1) and delivery timeout (see Section 5.2). A relay MUST NOT reorder or drop objects received on a multi-object stream when forwarding to subscribers. @@ -3212,6 +3018,14 @@ Internet-Draft moq-transport August 2026 subscription request is cached and shared among the pending subscribers. Relays that aggregate subscriptions MAY combine filters from downstream subscribers on the upstream subscription, up to the + + + +Nandakumar, et al. Expires 4 April 2027 [Page 54] + +Internet-Draft moq-transport October 2026 + + peer's MAX_FILTER_RANGES. If adding filters to an upstream subscription is not possible, the relay can either remove some or all filters, or make additional subscriptions to the same Track. @@ -3223,13 +3037,13 @@ Internet-Draft moq-transport August 2026 A subscriber remains subscribed to a Track at a Relay until it unsubscribes, the upstream publisher terminates the subscription, or - the subscription expires (see Section 10.8). A subscription with a + the subscription expires (see Section 9.7). A subscription with a filter can reach a state where all possible Objects matching the filter have been delivered to the subscriber. Since tracking this can be prohibitively expensive, Relays are not required or expected to do so. -9.4.1. Graceful Subscriber Relay Switchover +7.4.1. Graceful Subscriber Relay Switchover This section describes a behavior that a Subscriber MAY implement to improve user experience when a relay sends a GOAWAY or the Subscriber @@ -3240,32 +3054,50 @@ Internet-Draft moq-transport August 2026 of connecting to a new relay and sending the SUBSCRIBE requests for all Established subscriptions to the new relay. The new relay will send a response to the subscribes and if they are successful, the - subscriptions to the old relay can be cancelled (see Section 3.3.3). + subscriptions to the old relay can be cancelled (see + Section 6.4.2.3). + +7.5. Relay Resource Protection in Large Namespaces + + Relays SHOULD aggregate and propagate filters upstream on + subscriptions, especially namespace subscriptions, to conserve and + protect their resources from excessive load. They MAY also impose + limits on the number of publishers in a namespace, by rejecting or + closing namespace subscriptions with the error NAMESPACE_TOO_LARGE. + Relays MAY likewise limit the load imposed by subscribers, by + rejecting or closing namespace subscriptions with CONFLICTING_FILTERS + if too many disjoint filters are requested on downstream + subscriptions across a large number of subscribers, or with + PREFIX_OVERLAP if different subscribers force an aggregated upstream + subscription to overlap. + + -Nandakumar, et al. Expires 4 March 2027 [Page 58] + +Nandakumar, et al. Expires 4 April 2027 [Page 55] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 -9.5. Publisher Interactions +7.6. Publisher Interactions There are two ways to publish through a relay: 1. Send a PUBLISH message for a specific Track to the relay. The - relay MAY pause the Subscription with REQUEST_UPDATE in Forward - State=0 until there are known subscribers for new Tracks. + relay MAY pause the Subscription with REQUEST_UPDATE (see + Section 3.1.1) until there are known subscribers for new Tracks. - 2. Send a PUBLISH_NAMESPACE message for a Track Namespace to the - relay. This enables the relay to send SUBSCRIBE or FETCH - messages to publishers for Tracks in this Namespace in response - to requests received from subscribers. + 2. Send a PUBLISH_NAMESPACE message for a Track Namespace Prefix to + the relay. This enables the relay to send SUBSCRIBE or FETCH + messages to publishers for Tracks matching that prefix in + response to requests received from subscribers. Relays MUST verify that publishers are authorized to publish the set - of Tracks whose Track Namespace matches the namespace in a - PUBLISH_NAMESPACE, or the Full Track Name in PUBLISH. Relays MUST + of Tracks whose Track Namespace matches the Track Namespace Prefix in + a PUBLISH_NAMESPACE, or the Full Track Name in PUBLISH. Relays MUST NOT assume that an authorized publisher of a single Track is implicitly authorized to publish any other Tracks or Track Namespaces. If a Publisher would like Subscriptions in a Namespace @@ -3274,8 +3106,8 @@ Internet-Draft moq-transport August 2026 the relay is managed and is application specific. When a publisher wants to stop new subscriptions for a published - namespace, it cancels the request (see Section 3.3.3) to withdraw the - PUBLISH_NAMESPACE. A subscriber indicates it will no longer + namespace, it cancels the request (see Section 6.4.2.3) to withdraw + the PUBLISH_NAMESPACE. A subscriber indicates it will no longer subscribe to Tracks in a namespace it previously responded PUBLISH_NAMESPACE_OK to by cancelling the PUBLISH_NAMESPACE request. @@ -3284,70 +3116,62 @@ Internet-Draft moq-transport August 2026 message is sent, its Full Track Name is matched exactly against existing upstream subscriptions. - Namespace Prefix Matching is further used to decide which publishers - receive a SUBSCRIBE and which subscribers receive a PUBLISH. In this - process, the fields in the Track Namespace are matched sequentially, - requiring an exact match for each field. If the published or - subscribed Track Namespace has the same or fewer fields than the - Track Namespace in the message, it qualifies as a match. + Namespace Prefix Matching (Section 2.4.2) is further used to decide + which publishers receive a SUBSCRIBE and which subscribers receive a + PUBLISH. - For example: A SUBSCRIBE message with namespace=(foo, bar) and name=x - will match sessions that sent PUBLISH_NAMESPACE messages with - namespace=(foo) or namespace=(foo, bar). It will not match a session - with namespace=(foobar). + Relays MUST send SUBSCRIBE messages to all matching publishers. This + includes matching both Established subscriptions on the Full Track + Name and Namespace Prefix Matching against published Namespaces. + When a Relay needs to make an upstream FETCH request, it determines + the available publishers using the same matching rules as SUBSCRIBE. + When more than one publisher is available, the Relay MUST send the + FETCH to at least one of them. -Nandakumar, et al. Expires 4 March 2027 [Page 59] +Nandakumar, et al. Expires 4 April 2027 [Page 56] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - Relays MUST send SUBSCRIBE messages to all matching publishers. This - includes matching both Established subscriptions on the Full Track - Name and Namespace Prefix Matching against published Namespaces. - Relays MUST forward PUBLISH_NAMESPACE or PUBLISH messages to all - matching subscribers. - - When a Relay needs to make an upstream FETCH request, it determines - the available publishers using the same matching rules as SUBSCRIBE. - When more than one publisher is available, the Relay MUST send the - FETCH to at least one of them. - When a Relay receives a SUBSCRIBE with FILL_PARAMETERS, it serves the fill range from its cache and retrieves any missing objects upstream - using a SUBSCRIBE with FILL_PARAMETERS or FETCHes (see - Section 5.1.3). + using a SUBSCRIBE with FILL_PARAMETERS or FETCHes (see Section 3.4). When a Relay receives an authorized SUBSCRIBE for a Track with one or more Established upstream subscriptions, it MUST reply with - SUBSCRIBE_OK. If the SUBSCRIBE has Forward State=1 and the upstream - subscriptions are in Forward State=0, the Relay MUST send - REQUEST_UPDATE with Forward=1 to all publishers. If there are no + SUBSCRIBE_OK. If the SUBSCRIBE is not paused and the upstream + subscriptions are paused, the Relay MUST resume the upstream + subscriptions with REQUEST_UPDATE to all publishers. If there are no Established upstream subscriptions for the requested Track, the Relay MUST send a SUBSCRIBE request to each publisher that has published - the subscription's namespace or prefix thereof. If the SUBSCRIBE has - Forward=1, then the Relay MUST use Forward=1 when subscribing - upstream. + the subscription's namespace or prefix thereof. If the SUBSCRIBE is + not paused, then the Relay MUST NOT pause when subscribing upstream. When a relay receives an incoming PUBLISH message, it MUST send a PUBLISH request to each subscriber that has sent SUBSCRIBE_TRACKS for the Track's namespace or a prefix thereof. However, if the relay is holding a downstream SUBSCRIBE awaiting a publisher for this Track - (see Section 10.2.6), it MUST proceed with the SUBSCRIBE and MUST NOT + (see Section 9.20.6), it MUST proceed with the SUBSCRIBE and MUST NOT also forward the PUBLISH to that subscriber. + When a relay receives an authorized PUBLISH message for a Track that + has Established downstream subscriptions, it MUST respond with + PUBLISH_OK. If at least one downstream subscriber for the Track is + not paused, the Relay MUST resume the upstream subscription with + REQUEST_UPDATE, if paused. + When a relay receives an authorized PUBLISH_NAMESPACE for a namespace that matches one or more existing subscriptions to other upstream sessions, it MUST send a SUBSCRIBE to the publisher that sent the - PUBLISH_NAMESPACE for each matching subscription. When it receives - an authorized PUBLISH message for a Track that has Established - downstream subscriptions, it MUST respond with PUBLISH_OK. If at - least one downstream subscriber for the Track has Forward State=1, - the Relay MUST change the Forward State to 1 with REQUEST_UPDATE. + PUBLISH_NAMESPACE for each matching subscription. A Relay does not + send PUBLISH_NAMESPACE to a subscriber; it advertises namespaces by + sending NAMESPACE in response to a matching SUBSCRIBE_NAMESPACE (see + Section 4.2). If a Session is closed due to an unknown or invalid control message or Object, the Relay MUST NOT propagate that message or Object to @@ -3355,20 +3179,21 @@ Internet-Draft moq-transport August 2026 force an unrelated Session, which might be handling other subscriptions, to be closed. - - -Nandakumar, et al. Expires 4 March 2027 [Page 60] - -Internet-Draft moq-transport August 2026 - - -9.5.1. Graceful Publisher Relay Switchover +7.6.1. Graceful Publisher Relay Switchover This section describes a behavior that a publisher MAY implement to improve user experience when a relay sends a GOAWAY or the publisher switches between networks, such as WiFi to Cellular, and QUIC Connection Migration is not possible. + + + +Nandakumar, et al. Expires 4 April 2027 [Page 57] + +Internet-Draft moq-transport October 2026 + + A new Session is established, to a new URI if specified in a GOAWAY. The publisher sends PUBLISH_NAMESPACE and/or PUBLISH messages to begin publishing on the new Session, but it does not immediately stop @@ -3380,325 +3205,514 @@ Internet-Draft moq-transport August 2026 Ideally, the subscriptions downstream from the relay do not observe this change, and keep receiving the Objects on the same subscription. -9.6. Relay Track Handling +7.7. Relay Track Handling A relay MUST include all Properties associated with a Track when sending any PUBLISH, SUBSCRIBE_OK, TRACK_STATUS_OK, or FETCH_OK, - unless allowed by the property's specification (see Section 2.5). + unless allowed by the property's specification (see Section 8.4). -9.7. Relay Object Handling +7.8. Relay Object Handling MOQT encodes the delivery information in the Object header - (Section 11.2.1). A relay MUST NOT modify Object fields when - forwarding, except for Object Properties as specified in Section 2.5. + (Section 2.1.1). A relay MUST NOT modify Object fields when + forwarding, except for Object Properties as specified in Section 8.4. A relay MUST treat the object payload as opaque. A relay MUST NOT combine, split, or otherwise modify object payloads. - Relays prioritize forwarded Objects as described in Section 7. + Relays prioritize forwarded Objects as described in Section 5.1. -10. Control Messages +8. Notational Conventions and Common Structures - MOQT uses a pair of unidirectional streams to exchange control - messages, as defined in Section 3.3. Every message on a control or - request stream is formatted as follows: + This document uses the conventions detailed in ([RFC9000], + Section 1.3) when describing the binary encoding. - MOQT Control Message { - Message Type (vi64), - Message Length (16), - Message Body (..), - } +8.1. Variable-Length Integers - Figure 3: MOQT Control Message + MOQT requires a variable-length integer encoding with the following + properties: + 1. The encoded length can be determined from the first encoded byte. + 2. The range of 1 byte values is as large as possible. -Nandakumar, et al. Expires 4 March 2027 [Page 61] - -Internet-Draft moq-transport August 2026 + 3. All 64 bit numbers can be encoded. + The variable-length integer encoding uses the number of leading 1 + bits of the first byte to indicate the length of the encoding in + bytes. The remaining bits after the first 0 and subsequent bytes, if + any, represent the integer value, encoded in network byte order. - The following Message Types are defined. The Stream column indicates - which stream type each message is sent on: Control indicates the - control stream (Section 3.3), and Request indicates a bidirectional - request stream. Messages marked "First" MUST be the first message on - a new request stream. - +========+======================================+==================+ - | ID | Messages | Stream | - +========+======================================+==================+ - | 0x01 | RESERVED (SETUP for version 00) | | - +--------+--------------------------------------+------------------+ - | 0x40 | RESERVED (CLIENT_SETUP for <= 10) | | - +--------+--------------------------------------+------------------+ - | 0x41 | RESERVED (SERVER_SETUP for <= 10) | | - +--------+--------------------------------------+------------------+ - | 0x20 | RESERVED (CLIENT_SETUP in <= 16) | | - +--------+--------------------------------------+------------------+ - | 0x21 | RESERVED (SERVER_SETUP in <= 16) | | - +--------+--------------------------------------+------------------+ - | 0x2F00 | SETUP (Section 10.3) | Control | - +--------+--------------------------------------+------------------+ - | 0x10 | GOAWAY (Section 10.4) | Control, Request | - +--------+--------------------------------------+------------------+ - | 0x3 | SUBSCRIBE (Section 10.7) | Request, First | - +--------+--------------------------------------+------------------+ - | 0x4 | SUBSCRIBE_OK (Section 10.8) | Request | - +--------+--------------------------------------+------------------+ - | 0x22 | PUBLISH_STATE_NOTIFY (Section 10.10) | Request | - +--------+--------------------------------------+------------------+ - | 0x1D | PUBLISH (Section 10.11) | Request, First | - +--------+--------------------------------------+------------------+ - | 0x1E | RESERVED (PUBLISH_OK in <= 17) | Request | - +--------+--------------------------------------+------------------+ - | 0xB | PUBLISH_DONE (Section 10.12) | Request | - +--------+--------------------------------------+------------------+ - | 0x16 | FETCH (Section 10.13) | Request, First | - +--------+--------------------------------------+------------------+ - | 0x18 | FETCH_OK (Section 10.14) | Request | - +--------+--------------------------------------+------------------+ - | 0xD | TRACK_STATUS (Section 10.15) | Request, First | - +--------+--------------------------------------+------------------+ - | 0x6 | PUBLISH_NAMESPACE (Section 10.16) | Request, First | - +--------+--------------------------------------+------------------+ - | 0x50 | SUBSCRIBE_NAMESPACE (Section 10.19) | Request, First | - +--------+--------------------------------------+------------------+ - | 0x51 | SUBSCRIBE_TRACKS (Section 10.20) | Request, First | - +--------+--------------------------------------+------------------+ - | 0x8 | NAMESPACE (Section 10.17) | Request | - - - -Nandakumar, et al. Expires 4 March 2027 [Page 62] - -Internet-Draft moq-transport August 2026 - - - +--------+--------------------------------------+------------------+ - | 0xE | NAMESPACE_DONE (Section 10.18) | Request | - +--------+--------------------------------------+------------------+ - | 0xF | PUBLISH_SKIPPED (Section 10.21) | Request | - +--------+--------------------------------------+------------------+ - | 0x2 | REQUEST_UPDATE (Section 10.9) | Request | - +--------+--------------------------------------+------------------+ - | 0x7 | REQUEST_OK (Section 10.5) | Request | - +--------+--------------------------------------+------------------+ - | 0x5 | REQUEST_ERROR (Section 10.6) | Request | - +--------+--------------------------------------+------------------+ - - Table 5 - An endpoint that receives an unknown message type MUST close the - session. Control messages have a length to simplify parsing, but no - control messages are intended to be ignored. The length is set to - the number of bytes in the Message Body, which is defined by each - message type. If the length does not match the length of the Message - Body, the receiver MUST close the session with a PROTOCOL_VIOLATION. +Nandakumar, et al. Expires 4 April 2027 [Page 58] + +Internet-Draft moq-transport October 2026 -10.1. Request ID - Request ID is included in request messages and is used to identify - requests across messages. For example, fetch streams reference the - Request ID of a SUBSCRIBE, PUBLISH, FETCH, or REQUEST_UPDATE. + Integers are encoded in 1 to 9 bytes and can encode up to 64 bit + unsigned integers. The following table summarizes the encoding + properties. - The client generates even numbered Request IDs, starting at 0, and - the server generates odd numbered Request IDs, starting at 1. Each - endpoint increments its Request ID by 2 for each new request. + +==============+================+========+========================+ + | Leading Bits | Length (bytes) | Usable | Range | + | | | Bits | | + +==============+================+========+========================+ + | 0 | 1 | 7 | 0-127 | + +--------------+----------------+--------+------------------------+ + | 10 | 2 | 14 | 0-16383 | + +--------------+----------------+--------+------------------------+ + | 110 | 3 | 21 | 0-2097151 | + +--------------+----------------+--------+------------------------+ + | 1110 | 4 | 28 | 0-268435455 | + +--------------+----------------+--------+------------------------+ + | 11110 | 5 | 35 | 0-34359738367 | + +--------------+----------------+--------+------------------------+ + | 111110 | 6 | 42 | 0-4398046511103 | + +--------------+----------------+--------+------------------------+ + | 1111110 | 7 | 49 | 0-562949953421311 | + +--------------+----------------+--------+------------------------+ + | 11111110 | 8 | 56 | 0-72057594037927935 | + +--------------+----------------+--------+------------------------+ + | 11111111 | 9 | 64 | 0-18446744073709551615 | + +--------------+----------------+--------+------------------------+ - Each SUBSCRIBE, PUBLISH, FETCH, SUBSCRIBE_NAMESPACE, - SUBSCRIBE_TRACKS, PUBLISH_NAMESPACE, REQUEST_UPDATE, and TRACK_STATUS - message consumes a Request ID. Only request messages include a - Request ID; response messages do not, since they are sent on the same - bidirectional stream as the request. + Table 3: Summary of Integer Encodings - If an endpoint receives a Request ID where the least significant bit - is incorrect for the sender, or a duplicate Request ID, it MUST close - the session with INVALID_REQUEST_ID. + The following table contains some example encodings: -10.2. Message Parameters - Some control messages include a field that encodes optional Message - Parameters. Message Parameters are serialized as follows: -Nandakumar, et al. Expires 4 March 2027 [Page 63] - -Internet-Draft moq-transport August 2026 - Message Parameter { - Type Delta (vi64), - Value (..) - } - Figure 4: Message Parameter - Type Delta: The difference between this Parameter Type and the - previous Parameter Type in the message, or the Parameter Type itself - for the first parameter. Parameters MUST be serialized in ascending - order by Type. If the resulting Type would be greater than 2^64 - 1, - the endpoint MUST close the session with a PROTOCOL_VIOLATION. - * Value: The encoding is specified by each parameter definition. - The encodings defined in this draft are: - - uint8: A single-byte unsigned integer (0-255) - - varint: A variable-length integer - - Location: Two consecutive varints (Group, Object) - - Length-prefixed: A varint length followed by that many bytes - Message Parameters are intended for the peer only and are not - forwarded by Relays, though relays can consider received parameter - values when making a request. - All Message Parameters MUST be defined in the negotiated version of - MOQT or negotiated via Setup Options. An endpoint that receives an - unknown Message Parameter MUST close the session with - PROTOCOL_VIOLATION. Because the receiver has to understand every - Message Parameter, there is no need for a mechanism to skip unknown - parameters. Because unknown parameters cannot be skipped, the block - is bounded by a parameter count rather than a length. - The Message Parameter types defined in this version of MOQT are - defined in the following subsections. - Senders MUST NOT repeat the same Parameter Type in a message unless - the parameter definition explicitly allows multiple instances of that - type to be sent in a single message. Receivers SHOULD check that - there are no unexpected duplicate parameters and close the session - with PROTOCOL_VIOLATION if found. +Nandakumar, et al. Expires 4 April 2027 [Page 59] + +Internet-Draft moq-transport October 2026 - The number of Message Parameters is not specifically limited, but the - total length of a control message is limited to 2^16-1 bytes. + +======================+============================+ + | Byte Sequence | Decimal Value | + +======================+============================+ + | 0x25 | 37 | + +----------------------+----------------------------+ + | 0x8025 | 37 | + +----------------------+----------------------------+ + | 0xbbbd | 15,293 | + +----------------------+----------------------------+ + | 0xed7f3e7d | 226,442,877 | + +----------------------+----------------------------+ + | 0xfaa1a0e403d8 | 2,893,212,287,960 | + +----------------------+----------------------------+ + | 0xfc8998abc66bc0 | 151,288,809,941,952 | + +----------------------+----------------------------+ + | 0xfefa318fa8e3ca11 | 70,423,237,261,249,041 | + +----------------------+----------------------------+ + | 0xffffffffffffffffff | 18,446,744,073,709,551,615 | + +----------------------+----------------------------+ + Table 4: Example Integer Encodings + Variable-length integers do not need to be encoded using the minimum + number of bytes; any encoding length that can represent the value is + valid. Note that, as a result, the same numeric value can be + represented by more than one byte sequence. For example, the value 0 + can be encoded as 0x00, 0x8000, 0xc00000, or any longer form. -Nandakumar, et al. Expires 4 March 2027 [Page 64] - -Internet-Draft moq-transport August 2026 + x (vi64): Indicates that x holds an integer value using the + variable-length encoding as described above. +8.2. Location Structure - Message Parameters in SUBSCRIBE and FETCH MUST NOT cause the - publisher to alter the payload of the objects it sends, as that would - violate the track uniqueness guarantee described in Section 2.4.3. + Location identifies a particular Object in a Group within a Track. -10.2.1. Parameter Scope + Location { + Group (vi64), + Object (vi64) + } - Message Parameters are always intended for the peer endpoint only and - are not forwarded by Relays, though relays can consider received - parameter values when making a request. Track information not - specific to the Message or Session is encoded in Track Properties. - See Section 2.5. + Figure 2: Location structure - Each Message Parameter definition indicates the message types in - which it can appear. If it appears in some other type of message, - the receiving endpoint MUST close the connection with a - PROTOCOL_VIOLATION. Note that since Setup Options use a separate - namespace, it is impossible for Message Parameters to appear in Setup - messages. + In this document, a Location can be expressed in the form of + {GroupID, ObjectID}, where GroupID and ObjectID indicate the Group ID + and Object ID of the Location, respectively. The constituent parts + of any Location A can be referred to using A.Group or A.Object. -10.2.2. AUTHORIZATION TOKEN Parameter + Location A < Location B if: - The AUTHORIZATION TOKEN parameter (Parameter Type 0x03) uses Length- - prefixed encoding. It MAY appear in a PUBLISH, SUBSCRIBE, - REQUEST_UPDATE, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS, - PUBLISH_NAMESPACE, TRACK_STATUS or FETCH message. This parameter - conveys information to authorize the sender to perform the operation - carrying the parameter. This Parameter MUST NOT be copied from a - SUBSCRIBE_TRACKS to the resulting PUBLISH message Parameters. - The parameter value is a Token structure containing an optional - Session-specific Alias. The Alias allows the sender to reference a - previously transmitted Token Type and Token Value in future messages. - The Token structure is serialized as follows: - Token { - Alias Type (vi64), - [Token Alias (vi64),] - [Token Type (vi64),] - [Token Value (..)] - } +Nandakumar, et al. Expires 4 April 2027 [Page 60] + +Internet-Draft moq-transport October 2026 - Figure 5: Token structure - * Alias Type - an integer defining both the serialization and the - processing behavior of the receiver. This Alias type has the - following code points: + A.Group < B.Group || (A.Group == B.Group && A.Object < B.Object) - DELETE (0x0): There is an Alias but no Type or Value. This Alias +8.3. Key-Value-Pair Structure + Key-Value-Pair is a flexible structure that carries key/value pairs + in which the key is a variable-length integer and the value is either + a variable-length integer or a byte field of arbitrary length. + Key-Value-Pairs encode a Type value as a delta from the previous Type + value, or from 0 if there is no previous Type value. This is + efficient on the wire and makes it easy to ensure there is only one + instance of a type when needed. The previous Type value plus the + Delta Type MUST NOT be greater than 2^64 - 1. If a Delta Type is + received that would be too large, the Session MUST be closed with a + PROTOCOL_VIOLATION. -Nandakumar, et al. Expires 4 March 2027 [Page 65] - -Internet-Draft moq-transport August 2026 + Key-Value-Pair is used in both the data plane and control plane, but + is optimized for use in the data plane. + Key-Value-Pair { + Delta Type (vi64), + [Length (vi64),] + Value (..) + } - and the Token Value it was previously associated with MUST be - retired. Retiring removes them from the pool of actively - registered tokens. + Figure 3: MOQT Key-Value-Pair - REGISTER (0x1): There is an Alias, a Type and a Value. This Alias - MUST be associated with the Token Value for the duration of the - Session or it is deleted. This action is termed "registering" the - Token. + * Delta Type: an unsigned variable-length integer identifying the + Type as a delta encoded value from the previous Type, if any. The + Type identifies the type of value and also the subsequent + serialization. - USE_ALIAS (0x2): There is an Alias but no Type or Value. Use the - Token Type and Value previously registered with this Alias. + * Length: Only present when Type is odd. Specifies the length of + the Value field in bytes. The maximum length of a value is 2^16-1 + bytes. If an endpoint receives a length larger than the maximum, + it MUST close the session with a PROTOCOL_VIOLATION. - USE_VALUE (0x3): There is no Alias and there is a Type and Value. - Use the Token Value as provided. The Token Value MAY be discarded - after processing. + * Value: A single variable-length integer when Type is even, + otherwise a sequence of Length bytes. - If a server receives Alias Type DELETE (0x0) or USE_ALIAS (0x2) in a - SETUP message, it MUST close the session with a PROTOCOL_VIOLATION. + If a receiver understands a Type, and the following Value or Length/ + Value does not match the serialization defined by that Type, the + receiver MUST close the session with error code + KEY_VALUE_FORMATTING_ERROR. - * Token Alias - a Session-specific integer identifier that - references a Token Type and Token Value. There are separate Alias - spaces for the client and server (e.g.: they can each register - Alias=1). Once a Token Alias has been registered, it cannot be - re-registered by the same endpoint in the Session without first - being deleted. Use of the Token Alias is optional. + Key-Value-Pairs are always parsed with a known byte length, which + bounds the sequence. The source of this length varies by context. - * Token Type - a numeric identifier for the type of Token payload - being transmitted. This type is defined by the IANA table "MOQT - Auth Token Type" (see Section 15). Type 0 is reserved to indicate - that the type is not defined in the table and is negotiated out- - of-band between client and receiver. - * Token Value - the payload of the Token. The contents and - serialization of this payload are defined by the Token Type. - If the Token structure cannot be decoded, the receiver MUST close the - Session with KEY_VALUE_FORMATTING_ERROR. The receiver of a message - attempting to register an Alias which is already registered MUST - close the Session with DUPLICATE_AUTH_TOKEN_ALIAS. The receiver of a - message referencing an Alias that is not currently registered MUST - reject the message with UNKNOWN_AUTH_TOKEN_ALIAS. - The receiver of a message containing a well-formed Token structure - but otherwise invalid AUTHORIZATION TOKEN parameter MUST reject that - message with an MALFORMED_AUTH_TOKEN error. +Nandakumar, et al. Expires 4 April 2027 [Page 61] + +Internet-Draft moq-transport October 2026 + + +8.4. Track and Object Properties + + Tracks and Objects can have additional relay-visible fields, known as + Properties, which do not require negotiation, and can be used to + alter MOQT Object distribution. + + Properties are defined in Section 10 as well as external + specifications and are registered in an IANA table Section 16. These + specifications define the type and value of the property, along with + any rules concerning processing, modification, caching and + forwarding. + + If a Relay does not support a Property, it MUST NOT be modified, MUST + be forwarded, and MUST be cached with the Track or Object, unless it + is a Mandatory Track Property as described in Section 3.7. If a + Track or Object arrives with a different set of unknown properties + than previously cached, the most recent set SHOULD replace any cached + values, removing any unknown values not present in the new set. + Relays MUST NOT attempt to merge sets of unknown properties received + in different messages. + + If a Relay supports a Property, it MUST follow the processing rules + in the Property's definition. Unless those rules permit otherwise, a + Relay MUST NOT modify, add, or remove the Property; it MUST forward + the Property to downstream subscribers and MUST cache it with the + Track or Object if the Track or Object is cached. + + Properties are serialized as Key-Value-Pairs (see Figure 3). Track + Properties always appear as the final field in the messages that + carry them; their length is the remaining bytes of the message after + all preceding fields have been consumed. Object Properties + (Section 11.1.2) are preceded by an explicit length field. + + Property types are registered in the IANA table 'MOQ Properties'. + See Section 16. + + Certain Property type ranges are reserved for application-specific + use and will never be allocated by IANA in future MOQT + specifications: + + * 0x78 to 0x7F (1-byte encoding): 8 code points for applications + with tight space constraints + + * 0x3800 to 0x3FFF (2-byte encoding): 2048 code points (including + grease Section 13) for applications with moderate space + constraints + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 62] + +Internet-Draft moq-transport October 2026 + + + Applications MAY use code points in these ranges without registration + for format-specific metadata or other application-defined purposes. + Relays that do not understand the application format MUST forward + these properties unchanged but MUST NOT attempt to interpret their + semantic meaning. Different applications using the same code point + in these ranges may assign different meanings; the interpretation + depends on the track or application context known to the publisher + and subscriber. + +8.5. Reason Phrase Structure + + Reason Phrase provides a way for the sender to encode additional + diagnostic information about an error condition, where appropriate. + + Reason Phrase { + Reason Phrase Length (vi64), + Reason Phrase Value (..) + } + + * Reason Phrase Length: A variable-length integer specifying the + length of the reason phrase in bytes. The reason phrase length + has a maximum value of 1024 bytes. If an endpoint receives a + length exceeding the maximum, it MUST close the session with a + PROTOCOL_VIOLATION + + * Reason Phrase Value: Additional diagnostic information about an + error condition. The reason phrase value is encoded as UTF-8 + string and does not carry information, such as language tags, that + would aid comprehension by any entity other than the one that + created the text. + +8.6. Range Filter Structure + + Each Range Filter parameter (see Section 3.3.2) carries a sequence of + Ranges, encoded as follows: + + Range { + Start (vi64), + [End (vi64)] + } + + Length (vi64) is the byte count of all fields after itself. When + Length is 0, there is no filter and no further fields are present. + This can be used in REQUEST_UPDATE to remove a filter. + + Each Range is an inclusive Start/End pair. End is optional in the + last pair; if omitted it indicates the last Range is open-ended. + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 63] + +Internet-Draft moq-transport October 2026 + + + Each Start is delta encoded from the prior Range's End (or from 0 for + the first Range), and End is delta encoded from its own Start. If + adding the delta would exceed 2^64-1, the request MUST be rejected + with INVALID_FILTER. For example, ranges 3-5 and 10-15 encode as: + Start=3, End=2, Start=5, End=5. + +8.7. Track Namespace Structure + + Track Namespace (Section 2.4.1) is encoded as follows: + + Track Namespace { + Number of Track Namespace Fields (vi64), + Track Namespace Field (..) ... + } + + * Number of Track Namespace Fields: A variable-length integer + specifying the number of Track Namespace Fields in the Track + Namespace. + + Each Track Namespace Field is encoded as follows: + + Track Namespace Field { + Track Namespace Field Length (vi64), + Track Namespace Field Value (..) + } + * Track Namespace Field Length: A variable-length integer specifying + the length of the Track Namespace Field in bytes. + + * Track Namespace Field Value: A sequence of bytes that forms a + Track Namespace Field. + + Each Track Namespace Field Value MUST contain at least one byte. If + an endpoint receives a Track Namespace Field with a Track Namespace + Field Length of 0, it MUST close the session with a + PROTOCOL_VIOLATION. + + If an endpoint receives a Track Namespace consisting of greater than + 32 Track Namespace Fields, it MUST close the session with a + PROTOCOL_VIOLATION. + + The maximum total length of a Full Track Name is 4,096 bytes. The + length of a Full Track Name is computed as the sum of the Track + Namespace Field Length fields and the Track Name Length field. The + length of a Track Namespace is the sum of the Track Namespace Field + Length fields. If an endpoint receives a Track Namespace or a Full + Track Name exceeding 4,096 bytes, it MUST close the session with a + PROTOCOL_VIOLATION. + + + +Nandakumar, et al. Expires 4 April 2027 [Page 64] + +Internet-Draft moq-transport October 2026 + + +8.8. Representing Namespace and Track Names + + There is often a need to render namespace tuples and track names for + purposes such as logging, representing track filenames, or use in + certain authorization verification schemes. The namespace and track + name are binary and need to be converted to a safe form. + + The following format is RECOMMENDED: + + * Each of the namespace tuples are rendered in order with a hyphen + (-) between them followed by the track name with a double hyphen + (--) between the last namespace and track name. + + * Bytes in the range a-z, A-Z, 0-9 as well as _ (0x5f) are output + verbatim, while all other bytes are encoded as a period (.) symbol + followed by exactly two lowercase hexadecimal digits. + + This format allows many common names to be rendered in an easily + human readable form while still supporting binary values. Note that + while the character set is chosen to be generally both filename and + URL safe, filename safety is platform specific; for instance, on + case-insensitive filesystems, track names can collide. + + Because this format produces exactly one rendering of any given + binary value, it is bijective: every valid serialized name maps to + exactly one binary value, so serialized names can be compared without + deserializing them. To maintain this property, an implementation + parsing this format MUST reject a name that does not follow the + encoding rules exactly, including a period not followed by exactly + two lowercase hexadecimal digits, or a byte that could have been + represented literally but was hex-encoded. For example, .61 is + invalid because a is represented as the literal character a. How an + invalid name is handled is application-defined. + + Example: + + example.2enet-team2-project_x--report + Namespace tuples: (example.net, team2, project_x) + Track name: report + +8.9. Authorization Token Compression + + Authorization tokens are carried in the AUTHORIZATION TOKEN message + parameter (see Section 9.20.2) and the AUTHORIZATION TOKEN Setup + Option (see Section 9.1.4). Both use the wire format and semantics + defined in this section. + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 65] + +Internet-Draft moq-transport October 2026 + + + The value is a Token structure containing an optional Session- + specific Alias. The Alias allows the sender to reference a + previously transmitted Token Type and Token Value in future messages. + The Token structure is serialized as follows: + + Token { + Alias Type (vi64), + [Token Alias (vi64),] + [Token Type (vi64),] + [Token Value (..)] + } + + Figure 4: Token structure + + * Alias Type - an integer defining both the serialization and the + processing behavior of the receiver. This Alias type has the + following code points: + + DELETE (0x0): There is an Alias but no Type or Value. This Alias + and the Token Value it was previously associated with MUST be + retired. Retiring removes them from the pool of actively + registered tokens. + + REGISTER (0x1): There is an Alias, a Type and a Value. This Alias + MUST be associated with the Token Value for the duration of the + Session or it is deleted. This action is termed "registering" the + Token. + + USE_ALIAS (0x2): There is an Alias but no Type or Value. Use the + Token Type and Value previously registered with this Alias. + + USE_VALUE (0x3): There is no Alias and there is a Type and Value. + Use the Token Value as provided. The Token Value MAY be discarded + after processing. + + * Token Alias - a Session-specific integer identifier that + references a Token Type and Token Value. There are separate Alias + spaces for the client and server (e.g.: they can each register + Alias=1). Once a Token Alias has been registered, it cannot be + re-registered by the same endpoint in the Session without first + being deleted. Use of the Token Alias is optional. + * Token Type - a numeric identifier for the type of Token payload + being transmitted. This type is defined by the IANA table "MOQT + Auth Token Type" (see Section 16). Type 0 is reserved to indicate + that the type is not defined in the table and is negotiated out- + of-band between client and receiver. -Nandakumar, et al. Expires 4 March 2027 [Page 66] +Nandakumar, et al. Expires 4 April 2027 [Page 66] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 + + + * Token Value - the payload of the Token. The contents and + serialization of this payload are defined by the Token Type. + + If the Token structure cannot be decoded, the receiver MUST close the + Session with KEY_VALUE_FORMATTING_ERROR. The receiver of a message + attempting to register an Alias which is already registered MUST + close the Session with DUPLICATE_AUTH_TOKEN_ALIAS. The receiver of a + message referencing an Alias that is not currently registered MUST + reject the message with UNKNOWN_AUTH_TOKEN_ALIAS. + The receiver of a message containing a well-formed Token structure + that is otherwise invalid MUST reject that message with an + MALFORMED_AUTH_TOKEN error. - The receiver of a message carrying an AUTHORIZATION TOKEN with Alias + The receiver of a message carrying an Authorization Token with Alias Type REGISTER that does not result in a Session error MUST register the Token Alias in the token cache, even if the message fails for other reasons, including Unauthorized. This allows senders to @@ -3730,29 +3744,34 @@ Internet-Draft moq-transport August 2026 re-use during the Session and SHOULD retire previously registered tokens once their utility has passed. - By registering a Token, the sender is requiring the receiver to store - the Token Alias and Token Value until they are deleted, or the - Session ends. The receiver can protect its resources by sending a - Setup Option defining the MAX_AUTH_TOKEN_CACHE_SIZE limit (see - Section 10.3.1.3) it is willing to accept. If a registration is - attempted which would cause this limit to be exceeded, the receiver - MUST terminate the Session with a AUTH_TOKEN_CACHE_OVERFLOW error. - The AUTHORIZATION TOKEN parameter MAY be repeated within a message as - long as the combination of Token Type and Token Value are unique - after resolving any aliases. - Messages carrying the AUTHORIZATION TOKEN parameter can appear on - different control streams. Because stream processing order can be - different than send order, the receiver and sender can have - inconsistent views of the token cache state. -Nandakumar, et al. Expires 4 March 2027 [Page 67] +Nandakumar, et al. Expires 4 April 2027 [Page 67] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 + + + By registering a Token, the sender is requiring the receiver to store + the Token Alias and Token Value until they are deleted, or the + Session ends. The receiver can protect its resources by sending a + Setup Option defining the MAX_AUTH_TOKEN_CACHE_SIZE limit (see + Section 9.1.3) it is willing to accept. If a registration outside of + SETUP is attempted that would cause this limit to be exceeded, the + receiver MUST terminate the Session with an AUTH_TOKEN_CACHE_OVERFLOW + error. Registrations in SETUP are handled as described in + Section 9.1.4. + An Authorization Token MAY be repeated within a message as long as + the combination of Token Type and Token Value are unique after + resolving any aliases. + + Messages carrying an Authorization Token can appear on different + control streams. Because stream processing order can be different + than send order, the receiver and sender can have inconsistent views + of the token cache state. Senders MUST NOT send USE_ALIAS on one control stream for an alias registered on a different stream until the sender has received a @@ -3763,209 +3782,470 @@ Internet-Draft moq-transport August 2026 Senders MUST NOT send DELETE for an alias while any message using USE_ALIAS with that alias has not received a response. -10.2.3. SUBGROUP_DELIVERY_TIMEOUT Parameter +9. Control Messages - The SUBGROUP_DELIVERY_TIMEOUT parameter (Parameter Type 0x06) is a - varint. It MAY appear in a SUBSCRIBE, PUBLISH, or REQUEST_UPDATE - message. Its semantics are defined in Section 8. + MOQT uses a pair of unidirectional streams to exchange control + messages, as defined in Section 6.3. Every message on a control or + request stream is formatted as follows: - This parameter is intended to be specific to a subscription, so it - SHOULD NOT be forwarded upstream by a relay that intends to serve - multiple subscriptions for the same track. + MOQT Control Message { + Message Type (vi64), + Message Length (16), + Message Body (..), + } -10.2.4. OBJECT_DELIVERY_TIMEOUT Parameter + Figure 5: MOQT Control Message - The OBJECT_DELIVERY_TIMEOUT parameter (Parameter Type 0x02) is a - varint. It MAY appear in a SUBSCRIBE, PUBLISH, or REQUEST_UPDATE - message. Its semantics are defined in Section 8. + The following Message Types are defined. The Stream column indicates + which stream type each message is sent on: Control indicates the + control stream (Section 6.3), and Request indicates a bidirectional + request stream. Messages marked "First" MUST be the first message on + a new request stream. - This parameter is intended to be specific to a subscription, so it - SHOULD NOT be forwarded upstream by a relay that intends to serve - multiple subscriptions for the same track. -10.2.5. FILL TIMEOUT Parameter - The FILL_TIMEOUT parameter (Parameter Type 0x0A) MAY appear in a - FETCH message, or inside a FILL_PARAMETERS parameter (see - Section 10.2.15) in a SUBSCRIBE or REQUEST_UPDATE (for a - subscription), where it applies to the fill fetch stream. - It is the maximum total duration in milliseconds a relay SHOULD spend - waiting for upstream sources to provide Objects that are not - immediately available before reporting them as Timed-Out gaps in the - FETCH response. When a relay encounters Objects within the requested - range that are not immediately available and have unknown status, it - issues upstream FETCHes to retrieve them. The Fill Timeout - represents a total budget for all such upstream FETCHes generated by - this request. If the budget is exhausted, the relay reports any - remaining unavailable Objects as Timed-Out gaps (End of Timed-Out - Range, see Section 11.4.4.2) and continues delivering available - Objects in the range. +Nandakumar, et al. Expires 4 April 2027 [Page 68] + +Internet-Draft moq-transport October 2026 + + + +========+=====================================+==================+ + | ID | Messages | Stream | + +========+=====================================+==================+ + | 0x01 | RESERVED (SETUP for version 00) | | + +--------+-------------------------------------+------------------+ + | 0x40 | RESERVED (CLIENT_SETUP for <= 10) | | + +--------+-------------------------------------+------------------+ + | 0x41 | RESERVED (SERVER_SETUP for <= 10) | | + +--------+-------------------------------------+------------------+ + | 0x20 | RESERVED (CLIENT_SETUP in <= 16) | | + +--------+-------------------------------------+------------------+ + | 0x21 | RESERVED (SERVER_SETUP in <= 16) | | + +--------+-------------------------------------+------------------+ + | 0x2F00 | SETUP (Section 9.1) | Control | + +--------+-------------------------------------+------------------+ + | 0x10 | GOAWAY (Section 9.2) | Control, Request | + +--------+-------------------------------------+------------------+ + | 0x3 | SUBSCRIBE (Section 9.6) | Request, First | + +--------+-------------------------------------+------------------+ + | 0x4 | SUBSCRIBE_OK (Section 9.7) | Request | + +--------+-------------------------------------+------------------+ + | 0x22 | PUBLISH_STATE_NOTIFY (Section 9.10) | Request | + +--------+-------------------------------------+------------------+ + | 0x1D | PUBLISH (Section 9.8) | Request, First | + +--------+-------------------------------------+------------------+ + | 0x1E | RESERVED (PUBLISH_OK in <= 17) | Request | + +--------+-------------------------------------+------------------+ + | 0xB | PUBLISH_DONE (Section 9.9) | Request | + +--------+-------------------------------------+------------------+ + | 0x16 | FETCH (Section 9.11) | Request, First | + +--------+-------------------------------------+------------------+ + | 0x18 | FETCH_OK (Section 9.12) | Request | + +--------+-------------------------------------+------------------+ + | 0xD | TRACK_STATUS (Section 9.13) | Request, First | + +--------+-------------------------------------+------------------+ + | 0x6 | PUBLISH_NAMESPACE (Section 9.14) | Request, First | + +--------+-------------------------------------+------------------+ + | 0x50 | SUBSCRIBE_NAMESPACE (Section 9.15) | Request, First | + +--------+-------------------------------------+------------------+ + | 0x51 | SUBSCRIBE_TRACKS (Section 9.18) | Request, First | + +--------+-------------------------------------+------------------+ + | 0x8 | NAMESPACE (Section 9.16) | Request | + +--------+-------------------------------------+------------------+ + | 0xE | NAMESPACE_DONE (Section 9.17) | Request | + +--------+-------------------------------------+------------------+ + | 0xF | PUBLISH_SKIPPED (Section 9.19) | Request | + +--------+-------------------------------------+------------------+ + | 0x2 | REQUEST_UPDATE (Section 9.5) | Request | + + + +Nandakumar, et al. Expires 4 April 2027 [Page 69] + +Internet-Draft moq-transport October 2026 + + + +--------+-------------------------------------+------------------+ + | 0x7 | REQUEST_OK (Section 9.3) | Request | + +--------+-------------------------------------+------------------+ + | 0x5 | REQUEST_ERROR (Section 9.4) | Request | + +--------+-------------------------------------+------------------+ + + Table 5 + + An endpoint that receives an unknown message type MUST close the + session. Control messages have a length to simplify parsing, but no + control messages are intended to be ignored. The length is set to + the number of bytes in the Message Body, which is defined by each + message type. If the length does not match the length of the Message + Body, the receiver MUST close the session with a PROTOCOL_VIOLATION. + +9.1. SETUP + + The SETUP message is the first message each endpoint sends on its + control stream (see Section 6.3); it allows the endpoints to agree on + the initial configuration before any other control messages are + exchanged. An endpoint that is not offering extensions which modify + control message semantics MAY pipeline other control messages after + SETUP without waiting for the peer's SETUP. + + The messages contain a sequence of key-value pairs called Setup + Options; the semantics and format of which can vary based on whether + the client or server is sending. To ensure future extensibility of + MOQT, endpoints MUST ignore unknown Setup Options. + + The wire format of the Setup message is as follows: + + SETUP Message { + Type (vi64) = 0x2F00, + Length (16), + Setup Options (..) ..., + } + + Figure 6: MOQT SETUP Message + + Setup Options are serialized as Key-Value-Pairs Figure 3, spanning + the entire message payload, bounded by the message Length field. + Setup Options use a namespace that is constant across all MOQT + versions, separate from Message Parameters. Receivers MUST ignore + unrecognized Setup Options. Senders MUST NOT repeat the same Option + Type in a message unless the option definition explicitly allows + multiple instances. Receivers MUST allow duplicates of unknown Setup + Options. -Nandakumar, et al. Expires 4 March 2027 [Page 68] +Nandakumar, et al. Expires 4 April 2027 [Page 70] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - A value of 0 indicates the subscriber only wants Objects that are - immediately available; the relay MUST NOT wait for upstream delivery - and MUST report any unavailable Objects as Timed-Out gaps. + Setup Options are also the mechanism by which endpoints declare + support for MOQT extensions; see Section 6.3.2. - If the Fill Timeout parameter is absent, the relay waits for an - implementation specific duration before reporting Timed-Out gaps. If - the subscriber specifies a Fill Timeout larger than the relay is - willing to wait, the relay MAY use a shorter timeout without - informing the subscriber. + The available Setup Options are detailed in the next sections. -10.2.6. RENDEZVOUS TIMEOUT Parameter +9.1.1. AUTHORITY - The RENDEZVOUS_TIMEOUT parameter (Parameter Type 0x04) MAY appear in - a SUBSCRIBE message. + The AUTHORITY option (Option Type 0x05) allows the client to specify + the authority component of the MoQ URI when using native QUIC + (Section 6.2.2). It MUST NOT be used by the server, or when + WebTransport is used. When an AUTHORITY option is received from a + server, or when an AUTHORITY option is received while WebTransport is + used, or when an AUTHORITY option is received by a server but the + server does not support the specified authority, the session MUST be + closed with INVALID_AUTHORITY. - It is the duration in milliseconds the subscriber is willing to wait - for a publisher to become available. This applies when a relay - receives a SUBSCRIBE for a Track that has no current publisher. + The AUTHORITY option follows the URI formatting rules [RFC3986]. + When connecting to a server using a URI with the "moqt" scheme, the + client MUST set the AUTHORITY option to the authority portion of the + URI. If an AUTHORITY option does not conform to these rules, the + session MUST be closed with MALFORMED_AUTHORITY. - If the RENDEZVOUS_TIMEOUT is present, the relay SHOULD hold the - subscription and wait for a publisher to appear, up to the specified - duration. The relay does not send SUBSCRIBE_OK until a publisher - becomes available. If a publisher becomes available within this - time, the relay proceeds with the subscription normally. If the - timeout expires without a publisher, the relay SHOULD respond with - REQUEST_ERROR with error code TIMEOUT. +9.1.2. PATH - The relay MAY use a shorter timeout than requested by the subscriber. - For example, a relay might limit the maximum rendezvous timeout to - protect its resources. + The PATH option (Option Type 0x01) allows the client to specify the + path of the MoQ URI when using native QUIC (Section 6.2.2). It MUST + NOT be used by the server, or when WebTransport is used. When a PATH + setup option is received from a server, or when a PATH parameter is + received while WebTransport is used, or when a PATH parameter is + received by a server but the server does not support the specified + path, the session MUST be closed with INVALID_PATH. - A value of 0 indicates the subscriber does not want to wait and - expects an immediate response. The relay MUST immediately return - REQUEST_ERROR with error code DOES_NOT_EXIST if no publisher is - available + The PATH option follows the URI formatting rules [RFC3986]. When + connecting to a server using a URI with the "moqt" scheme, the client + MUST set the PATH option to the path-abempty portion of the URI; if + query is present, the client MUST concatenate ?, followed by the + query portion of the URI to the option. If a PATH does not conform + to these rules, the session MUST be closed with MALFORMED_PATH. - If RENDEZVOUS_TIMEOUT is absent, the default is 0. +9.1.3. MAX_AUTH_TOKEN_CACHE_SIZE -10.2.7. SUBSCRIBER PRIORITY Parameter + The MAX_AUTH_TOKEN_CACHE_SIZE option (Option Type 0x04) communicates + the maximum size in bytes of all actively registered Authorization + tokens that the endpoint is willing to store per Session. This + option is optional. The default value is 0 which prohibits the use + of token Aliases. - The SUBSCRIBER_PRIORITY parameter (Parameter Type 0x20) is a uint8. - It MAY appear in a SUBSCRIBE, PUBLISH, FETCH, or REQUEST_UPDATE (for - a subscription or FETCH). It is an integer expressing the priority - of a subscription relative to other subscriptions and fetch responses - in the same session. Lower numbers get higher priority. See - Section 7. - If omitted from SUBSCRIBE or FETCH, the publisher uses the value 128. -Nandakumar, et al. Expires 4 March 2027 [Page 69] +Nandakumar, et al. Expires 4 April 2027 [Page 71] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 + + The token size is calculated as 16 bytes + the size of the Token + Value field (see Figure 4). The total size as restricted by the + MAX_AUTH_TOKEN_CACHE_SIZE option is calculated as the sum of the + token sizes for all registered tokens (Alias Type value of 0x01) + minus the sum of the token sizes for all deregistered tokens (Alias + Type value of 0x00), since Session initiation. + +9.1.4. AUTHORIZATION TOKEN + + The AUTHORIZATION TOKEN Setup Option (Option Type 0x03) is + functionally equivalent to the AUTHORIZATION TOKEN message parameter, + see Section 9.20.2. The endpoint can specify one or more tokens in + SETUP that the peer can use to authorize MOQT session establishment. + + The option value is a Token structure, whose wire format and + semantics are defined in Section 8.9. + + If a server receives Alias Type DELETE (0x0) or USE_ALIAS (0x2) in a + SETUP message, it MUST close the session with a PROTOCOL_VIOLATION. + + If an endpoint receives an AUTHORIZATION TOKEN option in SETUP with + Alias Type REGISTER that exceeds its MAX_AUTH_TOKEN_CACHE_SIZE, it + MUST NOT fail the session with AUTH_TOKEN_CACHE_OVERFLOW. Instead, + it MUST treat the option as Alias Type USE_VALUE. Since each + endpoint's SETUP may be sent before the peer's SETUP is received, the + sender MUST handle registration failures of this kind by purging any + Token Aliases that failed to register based on the peer's + MAX_AUTH_TOKEN_CACHE_SIZE option in SETUP (or the default value of + 0). + +9.1.5. MOQT IMPLEMENTATION + + The MOQT_IMPLEMENTATION option (Option Type 0x07) identifies the name + and version of the sender's MOQT implementation. This SHOULD be a + UTF-8 encoded string [RFC3629], though the message does not carry + information, such as language tags, that would aid comprehension by + any entity other than the one that created the text. + + An endpoint SHOULD send a MOQT_IMPLEMENTATION option unless + specifically configured not to do so. This option helps identify the + scope of interoperability problems and work around implementation- + specific limitations. + + Senders SHOULD limit the value to the implementation name and + version, avoiding advertising or other nonessential information. + Implementations SHOULD NOT use the identifiers of other + implementations to declare compatibility, as this undermines the + usefulness of implementation identification for debugging. + + + +Nandakumar, et al. Expires 4 April 2027 [Page 72] + +Internet-Draft moq-transport October 2026 + + +9.1.6. MAX FILTER RANGES + + The MAX_FILTER_RANGES option (Type 0x06) limits the peer's total + number of Ranges (Start/End pairs) allowed concurrently in all Range + filter Section 3.3.2 parameters for a given subscription or fetch. + The default value is 0, so if not specified, the peer MUST NOT send + any such filter parameters. If this limit is exceeded, an endpoint + MUST reject this with REQUEST_ERROR with error code INVALID_FILTER. + +9.1.7. MAX_REQUEST_UPDATES + + The MAX_REQUEST_UPDATES option (Option Type 0x08) communicates the + maximum number of unacknowledged REQUEST_UPDATE messages per request + stream that the endpoint is willing to receive. + + A REQUEST_UPDATE is considered outstanding from when it is sent until + the sender receives the corresponding REQUEST_OK or REQUEST_ERROR + response. The sender MUST NOT have more than MAX_REQUEST_UPDATES + outstanding REQUEST_UPDATEs on any single request stream at a time. + Each REQUEST_OK or REQUEST_ERROR response restores one credit on that + stream. An implementation that processes and responds to a + REQUEST_UPDATE immediately might not detect when a peer has pipelined + messages exceeding its limit; coalescing REQUEST_UPDATE processing + (see Section 9.5) can be more effective at enforcing + MAX_REQUEST_UPDATES. + + The value is encoded as a variable-length integer. A value of 0 + means the endpoint does not limit REQUEST_UPDATE concurrency. If not + present, the default value is 0. + + If an endpoint receives a REQUEST_UPDATE on a stream that already has + MAX_REQUEST_UPDATES outstanding REQUEST_UPDATEs, it MUST close the + session with TOO_MANY_REQUEST_UPDATES. + +9.2. GOAWAY + + An endpoint sends a GOAWAY message on its control stream to inform + the peer it intends to close the session soon. When sent by a + server, it can initiate session migration (Section 6.6.1) with an + optional URI. A client MUST send a zero-length New Session URI in + any GOAWAY, as clients cannot instruct servers to initiate + connections. + + A GOAWAY MAY also be sent on a request stream to initiate migration + of that individual request. Upon receiving a GOAWAY on a request + stream, the endpoint SHOULD re-issue that specific request on a + session at the specified URI (or the current session if no URI is + provided), and close the old request stream using the appropriate + + + +Nandakumar, et al. Expires 4 April 2027 [Page 73] + +Internet-Draft moq-transport October 2026 + + + mechanism (e.g. FIN, stream reset, or PUBLISH_DONE). This allows, + for example, moving the publishers and subscribers of a common set of + tracks to a common relay without draining their entire session. + + The GOAWAY message does not impact subscription state. A subscriber + SHOULD individually unsubscribe from each existing subscription, + while a publisher MAY reject new requests after sending a GOAWAY. + + Upon receiving a GOAWAY on the control stream, an endpoint SHOULD NOT + initiate new requests to the peer including SUBSCRIBE, PUBLISH, + FETCH, PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS and + TRACK_STATUS. + + Sending a GOAWAY does not prevent the sender from initiating new + requests, though the sender SHOULD avoid initiating requests unless + required by migration (see (Section 7.4.1 and Section 7.6.1). An + endpoint that receives a GOAWAY MAY reject new requests with an + appropriate error code (e.g., REQUEST_ERROR with error code + GOING_AWAY). + + The endpoint MUST close the session with a PROTOCOL_VIOLATION + (Section 12.2) if it receives more than one GOAWAY on the control + stream or on a single request stream. + + GOAWAY Message { + Type (vi64) = 0x10, + Length (16), + New Session URI Length (vi64), + New Session URI (..), + Timeout (vi64), + } + + Figure 7: MOQT GOAWAY Message -10.2.8. GROUP ORDER Parameter + * New Session URI: When received by a client, indicates where the + client can connect to continue this session or re-issue this + request. The client MUST use this URI for the new session if + provided. If the URI is zero bytes long, the current URI is + reused instead. The new session URI SHOULD use the same scheme as + the current URI to ensure compatibility. The maximum length of + the New Session URI is 8,192 bytes. If an endpoint receives a + length exceeding the maximum, it MUST close the session with a + PROTOCOL_VIOLATION. - The GROUP_ORDER parameter (Parameter Type 0x22) is a uint8. It MAY - appear in a SUBSCRIBE, PUBLISH, SUBSCRIBE_TRACKS, or FETCH, or inside - a FILL_PARAMETERS parameter (see Section 10.2.15). + If a server receives a GOAWAY with a non-zero New Session URI + Length it MUST close the session with a PROTOCOL_VIOLATION. - Its value indicates how to prioritize Objects from different groups - within the same subscription (see Section 7), or how to order Groups - in a Fetch response (see Section 10.13). When it appears inside - FILL_PARAMETERS, it governs the fill fetch stream and its ordering - relative to subscription-delivered Objects (see Section 7). The - allowed values are Ascending (0x1) or Descending (0x2). If an - endpoint receives a value outside this range, it MUST close the - session with PROTOCOL_VIOLATION. - If omitted from SUBSCRIBE or SUBSCRIBE_TRACKS, the publisher's - preference from the Track is used. If omitted from FETCH, the - receiver uses Ascending (0x1). -10.2.9. LOCATION FILTER Parameter - The LOCATION_FILTER parameter (Parameter Type 0x21) uses length- - prefixed encoding. It MAY appear in a FETCH, SUBSCRIBE, PUBLISH, - REQUEST_UPDATE (for a subscription) or PUBLISH_STATE_NOTIFY message. - It is a Location Filter (see Section 5.1.2). - If omitted from FETCH or SUBSCRIBE, the fetch or subscription is - unfiltered. If omitted from REQUEST_UPDATE or PUBLISH_STATE_NOTIFY, - the value is unchanged. When sent in PUBLISH_STATE_NOTIFY, it - reports the Location Filter now in effect at the publisher. +Nandakumar, et al. Expires 4 April 2027 [Page 74] + +Internet-Draft moq-transport October 2026 -10.2.10. SUBGROUP FILTER Parameter - The SUBGROUP_FILTER parameter (Type 0x25) selects objects with - specified Ranges of Subgroup ID. See Section 5.1.4. + * Timeout: The time in milliseconds the sender will wait for + graceful closure. When sent on the control stream, the sender + closes the session with GOAWAY_TIMEOUT after the indicated timeout + if there are still open requests. When sent on a request stream, + the sender SHOULD reset the stream with GOING_AWAY after the + indicated timeout. A value of 0 indicates the sender has no + specific timeout, but the recipient SHOULD migrate as quickly as + possible. This is a hint; the sender of the GOAWAY MAY close the + session or reset the request stream before the indicated timeout + has elapsed. -10.2.11. OBJECTID FILTER Parameter +9.3. REQUEST_OK - The OBJECTID_FILTER parameter (Type 0x26) selects objects with - specified Ranges of Object ID. See Section 5.1.4. + The REQUEST_OK message is sent in response to PUBLISH, + REQUEST_UPDATE, TRACK_STATUS, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS + and PUBLISH_NAMESPACE requests. -10.2.12. PRIORITY FILTER Parameter + REQUEST_OK Message { + Type (vi64) = 0x7, + Length (16), + Number of Parameters (vi64), + Parameters (..) ..., + Track Properties (..), + } - The PRIORITY_FILTER parameter (Type 0x27) selects objects with - specified Ranges of Publisher Priority. See Section 5.1.4. If a - decoded value exceeds 255, the endpoint MUST reject this with - REQUEST_ERROR with error code INVALID_FILTER since Publisher Priority - is an 8-bit field. + Figure 8: MOQT REQUEST_OK Message + * Parameters: The parameters are defined in Section 9.20. The + parameters that can appear depend on the request being answered: + - PUBLISH_OK: EXPIRES -Nandakumar, et al. Expires 4 March 2027 [Page 70] - -Internet-Draft moq-transport August 2026 + - REQUEST_UPDATE_OK: EXPIRES, LARGEST_OBJECT + - TRACK_STATUS_OK: LARGEST_OBJECT -10.2.13. OBJECT PROPERTY FILTER Parameter + - SUBSCRIBE_NAMESPACE_OK: EXPIRES - The OBJECT_PROPERTY_FILTER parameter (Type 0x28) selects objects with - required Ranges of Property Value for a required Object Property Type - which MUST be even, i.e. a single integer value (see Figure 2), - otherwise the endpoint MUST reject this with REQUEST_ERROR with error - code INVALID_FILTER. See Section 5.1.4. + - SUBSCRIBE_TRACKS_OK: EXPIRES -10.2.14. TRACK PROPERTY FILTER Parameter + - PUBLISH_NAMESPACE_OK: EXPIRES - The TRACK_PROPERTY_FILTER parameter (Type 0x29) selects tracks with - required Ranges of Property Value for a required Track Property Type - which MUST be even, i.e. a single integer value (see Figure 2), - otherwise the endpoint MUST reject this with REQUEST_ERROR with error - code INVALID_FILTER. See Section 5.1.4. -10.2.15. FILL PARAMETERS Parameter - The FILL_PARAMETERS parameter (Parameter Type 0x23) uses length- - prefixed encoding. It MAY appear in a SUBSCRIBE or REQUEST_UPDATE - (for a subscription) message. Its value is a sequence of Parameters - that apply to the fill fetch stream (see Section 5.1.3), encoded as - if they were Parameters for a separate message (see Section 15.7). - Its presence is what requests a fill fetch stream; a subscription - with no FILL_PARAMETERS opens none. - The following parameters MAY appear inside FILL_PARAMETERS: +Nandakumar, et al. Expires 4 April 2027 [Page 75] + +Internet-Draft moq-transport October 2026 + * Track Properties : A sequence of Properties. See Section 8.4. + The length of Track Properties is the remaining length of the + message after parsing all previous fields. Track Properties are + populated in TRACK_STATUS_OK; they are empty in PUBLISH_OK, + REQUEST_UPDATE_OK, SUBSCRIBE_NAMESPACE_OK and + PUBLISH_NAMESPACE_OK. If an endpoint receives Track Properties in + one of these messages it MUST close the session with a + PROTOCOL_VIOLATION. +9.4. REQUEST_ERROR + The REQUEST_ERROR message is sent in response to any request + (SUBSCRIBE, FETCH, PUBLISH, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS, + PUBLISH_NAMESPACE, TRACK_STATUS, REQUEST_UPDATE). +9.4.1. Redirect Structure + A Redirect provides a way for an endpoint to direct the peer to retry + a request at a different URI and/or for a different Full Track Name. + Redirect { + Connect URI Length (vi64), + Connect URI (..), + Track Namespace (..), + Track Name Length (vi64), + Track Name (..), + } + * Connect URI: The URI to connect to for the redirected request. If + the length is zero, the requester SHOULD use the current session's + URI. If a server receives a Redirect with a non-zero Connect URI + Length it MUST close the session with a PROTOCOL_VIOLATION. + * Track Namespace and Track Name: The Track Namespace and Track Name + to use for the redirected request, together referred to as the + Redirect target. + Track Name is not meaningful for namespace-scoped requests + (SUBSCRIBE_NAMESPACE, PUBLISH_NAMESPACE, SUBSCRIBE_TRACKS) and + MUST be empty; an endpoint that receives a non-empty Track Name in + a Redirect for a namespace-scoped request MUST close the session + with a PROTOCOL_VIOLATION. +9.4.2. REQUEST_ERROR Message Format @@ -3973,1287 +4253,1341 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 71] +Nandakumar, et al. Expires 4 April 2027 [Page 76] -Internet-Draft moq-transport August 2026 - - - +================+========================+================+ - | Parameter Type | Parameter Name | Specification | - +================+========================+================+ - | 0x0A | FILL_TIMEOUT | Section 10.2.5 | - +----------------+------------------------+----------------+ - | 0x20 | SUBSCRIBER_PRIORITY | Section 10.2.7 | - +----------------+------------------------+----------------+ - | 0x21 | LOCATION_FILTER | Section 10.2.9 | - +----------------+------------------------+----------------+ - | 0x22 | GROUP_ORDER | Section 10.2.8 | - +----------------+------------------------+----------------+ - | 0x25 | SUBGROUP_FILTER | Section 5.1.4 | - +----------------+------------------------+----------------+ - | 0x26 | OBJECTID_FILTER | Section 5.1.4 | - +----------------+------------------------+----------------+ - | 0x27 | PRIORITY_FILTER | Section 5.1.4 | - +----------------+------------------------+----------------+ - | 0x28 | OBJECT_PROPERTY_FILTER | Section 5.1.4 | - +----------------+------------------------+----------------+ +Internet-Draft moq-transport October 2026 - Table 6 - The LOCATION_FILTER inside FILL_PARAMETERS selects the fill range and - is evaluated using the rules for a Fetch (see Section 5.1.2); it is - independent of the subscription's own Location filter. + REQUEST_ERROR Message { + Type (vi64) = 0x5, + Length (16), + Error Code (vi64), + Retry Interval (vi64), + Error Reason (Reason Phrase), + [Redirect (Redirect),] + } - A parameter that is omitted from FILL_PARAMETERS takes the value it - has for the subscription; FILL_PARAMETERS therefore carries only the - settings that differ. An endpoint that receives a parameter inside - FILL_PARAMETERS that is not listed above MUST close the session with - PROTOCOL_VIOLATION. + Figure 9: MOQT REQUEST_ERROR Message - The value of FILL_PARAMETERS is a separate parameter scope. - Parameters inside it are not considered to appear in the enclosing - message for the purposes of Section 10.2, so a Parameter Type MAY - appear both in the message and inside FILL_PARAMETERS. + * Error Code: Identifies an integer error code for request failure. - FILL_PARAMETERS is not retained as subscription state. It applies - only to the message that carries it, so the sticky-parameter rules in - Section 10.9 do not apply to it. + * Retry Interval: The minimum time (in milliseconds) before the + request SHOULD be sent again, plus one. If the value is 0, the + request SHOULD NOT be retried. + * Error Reason: Provides a text description of the request error. + See Section 8.5. + * Redirect: Present only when Error Code is REDIRECT. See + Section 9.4.1. + If a request is retryable with the same parameters at a later time, + the sender of REQUEST_ERROR includes a non-zero Retry Interval in the + message. To minimize the risk of synchronized retry storms, the + sender can apply randomization to each retry interval so that retries + are spread out over time. A Retry Interval value of 1 indicates the + request can be retried immediately. + The error codes used in REQUEST_ERROR are defined in Section 12.3. +9.5. REQUEST_UPDATE + The sender of a request (SUBSCRIBE, PUBLISH, FETCH, + PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS) can later + send a REQUEST_UPDATE on the same bidi stream as the request to + modify it. A subscriber can also send REQUEST_UPDATE to modify + parameters of a subscription established with PUBLISH. + An endpoint that receives a REQUEST_UPDATE other than in the two + cases above MUST close the session with a PROTOCOL_VIOLATION. + The receiver of a REQUEST_UPDATE MUST respond with exactly one + REQUEST_UPDATE_OK or REQUEST_UPDATE_ERROR message indicating if the + update was successful, unless it is coalescing failed updates to + produce just one REQUEST_UPDATE_ERROR for multiple REQUEST_UPDATE + messages. -Nandakumar, et al. Expires 4 March 2027 [Page 72] +Nandakumar, et al. Expires 4 April 2027 [Page 77] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 -10.2.16. EXPIRES Parameter + The number of outstanding REQUEST_UPDATEs on a single request stream + is limited by the MAX_REQUEST_UPDATES Setup Option (Section 9.1.7). - The EXPIRES parameter (Parameter Type 0x8) is a varint. It MAY - appear in SUBSCRIBE_OK, PUBLISH, PUBLISH_OK, SUBSCRIBE_NAMESPACE_OK, - SUBSCRIBE_TRACKS_OK, PUBLISH_NAMESPACE_OK, or REQUEST_UPDATE_OK. It - encodes the time in milliseconds after which the sender of the - parameter will terminate the subscription. The sender will terminate - the subscription using PUBLISH_DONE or by cancelling the request (see - Section 3.3.3). This value is advisory and the sender can terminate - the subscription prior to or after the expiry time. + If a parameter previously set on the request is not present in + REQUEST_UPDATE, its value remains unchanged. - The receiver of the parameter can attempt to extend the subscription - by sending a REQUEST_UPDATE with 0 or more updated parameters. If - the receiver has one or more updated AUTHORIZATION_TOKENs, it SHOULD - include those in the REQUEST_UPDATE. If the extension is granted, - the sender includes a new EXPIRES value in REQUEST_UPDATE_OK. Relays - that send this parameter and applications that receive it MAY - introduce jitter to prevent many endpoints from updating - simultaneously. + There is no generic mechanism to remove a parameter from a request. - If the EXPIRES parameter is 0 or is not present in a message, the - subscription does not expire or expires at an unknown time. + The format of REQUEST_UPDATE is as follows: -10.2.17. LARGEST OBJECT Parameter + REQUEST_UPDATE Message { + Type (vi64) = 0x2, + Length (16), + Request ID (vi64), + Number of Parameters (vi64), + Parameters (..) ... + } - The LARGEST_OBJECT parameter (Parameter Type 0x9) is a Location. It - MAY appear in SUBSCRIBE_OK, PUBLISH, REQUEST_UPDATE_OK, - TRACK_STATUS_OK, or PUBLISH_STATE_NOTIFY. It contains the largest - Location (see Section 1.4.2) in the Track observed by the sending - endpoint (see Section 5.1.2). If Objects have been published on this - Track the Publisher MUST include this parameter. + Figure 10: MOQT REQUEST_UPDATE Message - If omitted from a message, the sending endpoint has not published or - received any Objects in the Track. + * Request ID: See Section 6.4.2.1. - A relay MUST set LARGEST_OBJECT to the largest of the following: + * Parameters: The parameters are defined in Section 9.20. The + parameters that can appear depend on the request being updated: - 1. Any LARGEST_OBJECT value received from the upstream publisher in - SUBSCRIBE_OK, PUBLISH, or REQUEST_UPDATE_OK + - Subscription: OBJECT_DELIVERY_TIMEOUT, AUTHORIZATION_TOKEN, + SUBGROUP_DELIVERY_TIMEOUT, FORWARD, SUBSCRIBER_PRIORITY, + LOCATION_FILTER, FILL_PARAMETERS, SUBGROUP_FILTER, + OBJECTID_FILTER, PRIORITY_FILTER, OBJECT_PROPERTY_FILTER, + NEW_GROUP_REQUEST - 2. The largest Location of an Object received on an upstream - subscription + - FETCH: AUTHORIZATION_TOKEN, SUBSCRIBER_PRIORITY + - PUBLISH_NAMESPACE: AUTHORIZATION_TOKEN + - SUBSCRIBE_NAMESPACE: AUTHORIZATION_TOKEN, + TRACK_NAMESPACE_PREFIX + - SUBSCRIBE_TRACKS: AUTHORIZATION_TOKEN, FORWARD, + TRACK_PROPERTY_FILTER, TRACK_NAMESPACE_PREFIX + Range Filters are only allowed from the subscriber (see + Section 3.3.2). -Nandakumar, et al. Expires 4 March 2027 [Page 73] - -Internet-Draft moq-transport August 2026 -10.2.18. FORWARD Parameter - The FORWARD parameter (Parameter Type 0x10) is a uint8. It MAY - appear in SUBSCRIBE, REQUEST_UPDATE (for a subscription or a - SUBSCRIBE_TRACKS request), PUBLISH, SUBSCRIBE_TRACKS and - PUBLISH_STATE_NOTIFY. It specifies the Forwarding State on affected - subscriptions (see Section 5.1). The allowed values are 0 (don't - forward) or 1 (forward). If an endpoint receives a value outside - this range, it MUST close the session with PROTOCOL_VIOLATION. +Nandakumar, et al. Expires 4 April 2027 [Page 78] + +Internet-Draft moq-transport October 2026 - In the case of a REQUEST_UPDATE for SUBSCRIBE_TRACKS, it specifies - the Forwarding State on future subscriptions that match the prefix. - Existing subscriptions are unaffected. - If the parameter is omitted from REQUEST_UPDATE or - PUBLISH_STATE_NOTIFY, the value for the subscription remains - unchanged. If the parameter is omitted from any other message, the - default value is 1. When sent in PUBLISH_STATE_NOTIFY, it reports - the Forwarding State now in effect at the publisher. +9.5.1. Updating Subscriptions -10.2.19. NEW GROUP REQUEST Parameter + When a subscriber decreases the Start Location of the Location Filter + (see Section 3.3.1), the Start Location can be smaller than the + Track's Largest Object, similar to a new Subscription. Including + FILL_PARAMETERS (see Section 9.20.15) in the REQUEST_UPDATE causes + the publisher to deliver the new fill range by opening a new fill + fetch stream (see Section 3.4). FETCH can also be used to retrieve + any necessary Objects with Locations less than or equal to the + current Largest Object. - The NEW_GROUP_REQUEST parameter (Parameter Type 0x32) is a varint. - It MAY appear in SUBSCRIBE or REQUEST_UPDATE for a subscription. It - represents the largest Group ID in the Track known by the subscriber, - plus 1. A value of 0 indicates that the subscriber has no Group - information for the Track. A subscriber MUST NOT send this parameter - in REQUEST_UPDATE if the Track did not include the DYNAMIC_GROUPS - Property with value 1. A subscriber MAY include this parameter in - SUBSCRIBE without foreknowledge of support. If the original - publisher does not support dynamic Groups, it ignores the parameter - in that case. + When a subscriber increases the End Location, the Largest Object at + the publisher might already be larger than the previous End Location. + This will create a gap in the subscription. The REQUEST_UPDATE_OK + will include the LARGEST_OBJECT parameter, and the subscriber can + issue a FETCH to retrieve the omitted Objects, if any. - When an Original Publisher that supports dynamic Groups receives a - NEW_GROUP_REQUEST with a value of 0 or a value larger than the - current Group, it SHOULD end the current Group and begin a new Group - as soon as practical. The Original Publisher MAY delay the - NEW_GROUP_REQUEST subject to implementation specific concerns, for - example, achieving a minimum duration for each Group. The Original - Publisher chooses the next Group ID; there are no requirements that - it be equal to the NEW_GROUP_REQUEST parameter value. + When a subscriber narrows their subscription (increase the Start + Location and/or decrease the End Group), it might still receive + Objects outside the new range if the publisher sent them before the + update was processed. - Relay Handling: + When a REQUEST_UPDATE is unsuccessful, the publisher MUST also + terminate the subscription by sending a PUBLISH_DONE with error code + UPDATE_FAILED. When a REQUEST_UPDATE fails for a FETCH, the + publisher MUST reset the FETCH data stream. When a REQUEST_UPDATE + fails for a SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS or + PUBLISH_NAMESPACE, the responder MUST close the bidi stream (see + Section 6.4.2.2). - A relay that receives a NEW_GROUP_REQUEST for a Track without an - Established subscription MUST include the NEW_GROUP_REQUEST when - subscribing upstream. + A receiver of multiple REQUEST_UPDATE messages on the same stream MAY + coalesce their processing by applying only the cumulative result. + Parameter values from later REQUEST_UPDATE messages override values + from earlier ones. The receiver MUST still send a REQUEST_UPDATE_OK + for each successful update, but it is not required to process + intermediate states individually. If the coalesced REQUEST_UPDATE + results in an error, only a single REQUEST_UPDATE_ERROR will be sent + and the sender of the REQUEST_UPDATEs will not always be able to + determine which caused an error. +9.5.2. Updating Namespace Subscriptions + + A subscriber can update the Track Namespace Prefix of an established + SUBSCRIBE_NAMESPACE or SUBSCRIBE_TRACKS by including the + TRACK_NAMESPACE_PREFIX parameter (Section 9.20.20) in a + REQUEST_UPDATE. The overlap restriction applies independently per + type: the new prefix MUST NOT share a common prefix with any other + active SUBSCRIBE_NAMESPACE (for a SUBSCRIBE_NAMESPACE update) or -Nandakumar, et al. Expires 4 March 2027 [Page 74] +Nandakumar, et al. Expires 4 April 2027 [Page 79] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - A relay that receives a NEW_GROUP_REQUEST for an Established - subscription with a value of 0 or a value larger than the Largest - Group MUST send a REQUEST_UPDATE including the NEW_GROUP_REQUEST to - the publisher unless: + SUBSCRIBE_TRACKS (for a SUBSCRIBE_TRACKS update) in the same session. + If the update is accepted, NAMESPACE and NAMESPACE_DONE messages + following the REQUEST_OK will contain Track Namespace suffixes + relative to the updated prefix. Updating the prefix of a + SUBSCRIBE_TRACKS has no effect on existing subscriptions. If the + subscriber is no longer interested it can cancel the corresponding + bidirectional stream. + +9.6. SUBSCRIBE - 1. The Track does not support dynamic Groups + SUBSCRIBE initiates a subscription to a track. The associated + parameters determine the range and mechanism of object delivery; the + Location Filter (see Section 3.3.1) selects which Objects are sent, + and a FILL_PARAMETERS parameter (see Section 9.20.15) additionally + retrieves the fill range on a fill fetch stream (see Section 3.4). - 2. There is already an outstanding NEW_GROUP_REQUEST from this Relay - with a greater or equal value + The format of SUBSCRIBE is as follows: - If a relay receives a NEW_GROUP_REQUEST with a non-zero value less - than or equal to the Largest Group, it does not send a - NEW_GROUP_REQUEST upstream. + SUBSCRIBE Message { + Type (vi64) = 0x3, + Length (16), + Request ID (vi64), + Track Namespace (..), + Track Name Length (vi64), + Track Name (..), + Number of Parameters (vi64), + Parameters (..) ... + } - After sending a NEW_GROUP_REQUEST upstream, the request is considered - outstanding until the Largest Group increases. + Figure 11: MOQT SUBSCRIBE Message -10.2.20. TRACK_NAMESPACE_PREFIX Parameter + * Request ID: See Section 6.4.2.1. - The TRACK_NAMESPACE_PREFIX parameter (Parameter Type 0x34) uses the - Track Namespace encoding described in Section 2.4.1. It MAY appear - in REQUEST_UPDATE for a SUBSCRIBE_NAMESPACE or SUBSCRIBE_TRACKS - request. It updates the Track Namespace Prefix for that - subscription. If the new prefix would share a common prefix with - another active subscription of the same type in the same session, the - receiver MUST respond with REQUEST_ERROR with error code - PREFIX_OVERLAP. + * Track Namespace: Identifies the namespace of the track as defined + in (Section 8.7). -10.2.21. INCLUDE_PROPERTIES Parameter + * Track Name: Identifies the track name as defined in + (Section 2.4.1). - The INCLUDE_PROPERTIES parameter (Parameter Type 0x35) is a uint8. - It MAY appear in SUBSCRIBE, TRACK_STATUS, FETCH or SUBSCRIBE_TRACKS. - It specifies whether the OK message sent in response includes Track - Properties or whether the resulting PUBLISH messages include Track - Properties in the case of SUBSCRIBE_TRACKS. If INCLUDE_PROPERTIES is - 0, the Track Properties are still present in the message, but they - SHOULD be empty. The allowed values are 0 (do not send Properties) - or 1 (send Properties), and the default is 1. If an endpoint - receives a value outside this range, it MUST close the session with - PROTOCOL_VIOLATION. + * Parameters: The parameters are defined in Section 9.20. The + parameters that can appear in a SUBSCRIBE are + OBJECT_DELIVERY_TIMEOUT, AUTHORIZATION_TOKEN, RENDEZVOUS_TIMEOUT, + SUBGROUP_DELIVERY_TIMEOUT, FORWARD, SUBSCRIBER_PRIORITY, + LOCATION_FILTER, GROUP_ORDER, FILL_PARAMETERS, SUBGROUP_FILTER, + OBJECTID_FILTER, PRIORITY_FILTER, OBJECT_PROPERTY_FILTER, + NEW_GROUP_REQUEST and INCLUDE_PROPERTIES. +Nandakumar, et al. Expires 4 April 2027 [Page 80] + +Internet-Draft moq-transport October 2026 + On successful subscription, the publisher MUST reply with a + SUBSCRIBE_OK, allowing the subscriber to determine the start group/ + object when not explicitly specified, and start sending objects. +9.7. SUBSCRIBE_OK + A publisher sends a SUBSCRIBE_OK as the first response message on the + bidi stream for successful subscriptions. + SUBSCRIBE_OK Message { + Type (vi64) = 0x4, + Length (16), + Track Alias (vi64), + Number of Parameters (vi64), + Parameters (..) ..., + Track Properties (..), + } -Nandakumar, et al. Expires 4 March 2027 [Page 75] - -Internet-Draft moq-transport August 2026 + Figure 12: MOQT SUBSCRIBE_OK Message + * Track Alias: The identifer used for this track in Subgroups or + Datagrams (see Section 3.1.3). -10.3. SETUP + * Parameters: The parameters are defined in Section 9.20. The + parameters that can appear in a SUBSCRIBE_OK are EXPIRES and + LARGEST_OBJECT. - The SETUP message is the first message each endpoint sends on its - control stream (see Section 3.3); it allows the endpoints to agree on - the initial configuration before any other control messages are - exchanged. An endpoint that is not offering extensions which modify - control message semantics MAY pipeline other control messages after - SETUP without waiting for the peer's SETUP. + * Track Properties : A sequence of Properties. See Section 8.4. - The messages contain a sequence of key-value pairs called Setup - Options; the semantics and format of which can vary based on whether - the client or server is sending. To ensure future extensibility of - MOQT, endpoints MUST ignore unknown Setup Options. +9.8. PUBLISH - The wire format of the Setup message is as follows: + The publisher sends PUBLISH as the first message on a new + bidirectional stream to initiate a subscription for a Track. The + receiver verifies the publisher is authorized to publish this track. - SETUP Message { - Type (vi64) = 0x2F00, + PUBLISH Message { + Type (vi64) = 0x1D, Length (16), - Setup Options (..) ..., + Request ID (vi64), + Track Namespace (..), + Track Name Length (vi64), + Track Name (..), + Track Alias (vi64), + Number of Parameters (vi64), + Parameters (..) ..., + Track Properties (..), } - Figure 6: MOQT SETUP Message - Setup Options are serialized as Key-Value-Pairs Figure 2, spanning - the entire message payload, bounded by the message Length field. - Setup Options use a namespace that is constant across all MOQT - versions, separate from Message Parameters. Receivers MUST ignore - unrecognized Setup Options. Senders MUST NOT repeat the same Option - Type in a message unless the option definition explicitly allows - multiple instances. Receivers MUST allow duplicates of unknown Setup - Options. - The available Setup Options are detailed in the next sections. -10.3.1. Setup Options +Nandakumar, et al. Expires 4 April 2027 [Page 81] + +Internet-Draft moq-transport October 2026 -10.3.1.1. AUTHORITY - The AUTHORITY option (Option Type 0x05) allows the client to specify - the authority component of the MoQ URI when using native QUIC - (Section 3.1.5). It MUST NOT be used by the server, or when - WebTransport is used. When an AUTHORITY option is received from a - server, or when an AUTHORITY option is received while WebTransport is - used, or when an AUTHORITY option is received by a server but the - server does not support the specified authority, the session MUST be - closed with INVALID_AUTHORITY. + Figure 13: MOQT PUBLISH Message + * Request ID: See Section 6.4.2.1. + * Track Namespace: Identifies a track's namespace as defined in + (Section 8.7) + * Track Name: Identifies the track name as defined in + (Section 2.4.1). -Nandakumar, et al. Expires 4 March 2027 [Page 76] - -Internet-Draft moq-transport August 2026 + * Track Alias: The identifer used for this track in Subgroups or + Datagrams (see Section 3.1.3). + + * Parameters: The parameters are defined in Section 9.20. The + parameters that can appear in a PUBLISH are + OBJECT_DELIVERY_TIMEOUT, AUTHORIZATION_TOKEN, + SUBGROUP_DELIVERY_TIMEOUT, EXPIRES, LARGEST_OBJECT, FORWARD, + SUBSCRIBER_PRIORITY, LOCATION_FILTER and GROUP_ORDER. Those + governing delivery, such as FORWARD, GROUP_ORDER, + SUBSCRIBER_PRIORITY, SUBGROUP_DELIVERY_TIMEOUT, + OBJECT_DELIVERY_TIMEOUT and LOCATION_FILTER, inform the Subscriber + of the initial Subscription parameters. If the PUBLISH is the + result of a SUBSCRIBE_TRACKS, the parameters are handled as + described in Section 3.6.2, otherwise, they represent the + publisher's initial settings for the subscription, which the + subscriber can change. + * Track Properties : A sequence of Properties. See Section 8.4. - The AUTHORITY option follows the URI formatting rules [RFC3986]. - When connecting to a server using a URI with the "moqt" scheme, the - client MUST set the AUTHORITY option to the authority portion of the - URI. If an AUTHORITY option does not conform to these rules, the - session MUST be closed with MALFORMED_AUTHORITY. + A subscriber receiving a PUBLISH for a Track it does not wish to + receive SHOULD send PUBLISH_ERROR with error code UNINTERESTED, and + abandon reading any publisher initiated streams associated with that + subscription using a STOP_SENDING frame. -10.3.1.2. PATH + A publisher that pauses the subscription (see Section 3.1.1) + indicates that it will not transmit any objects until the subscriber + resumes it. If the subscription is not paused, the publisher will + start transmitting objects immediately, possibly before PUBLISH_OK. + Delivery starts at the Next Object relative to the Largest Object at + the time the publisher begins sending. - The PATH option (Option Type 0x01) allows the client to specify the - path of the MoQ URI when using native QUIC (Section 3.1.5). It MUST - NOT be used by the server, or when WebTransport is used. When a PATH - setup option is received from a server, or when a PATH parameter is - received while WebTransport is used, or when a PATH parameter is - received by a server but the server does not support the specified - path, the session MUST be closed with INVALID_PATH. - The PATH option follows the URI formatting rules [RFC3986]. When - connecting to a server using a URI with the "moqt" scheme, the client - MUST set the PATH option to the path-abempty portion of the URI; if - query is present, the client MUST concatenate ?, followed by the - query portion of the URI to the option. If a PATH does not conform - to these rules, the session MUST be closed with MALFORMED_PATH. -10.3.1.3. MAX_AUTH_TOKEN_CACHE_SIZE - The MAX_AUTH_TOKEN_CACHE_SIZE option (Option Type 0x04) communicates - the maximum size in bytes of all actively registered Authorization - tokens that the endpoint is willing to store per Session. This - option is optional. The default value is 0 which prohibits the use - of token Aliases. - The token size is calculated as 16 bytes + the size of the Token - Value field (see Figure 5). The total size as restricted by the - MAX_AUTH_TOKEN_CACHE_SIZE option is calculated as the sum of the - token sizes for all registered tokens (Alias Type value of 0x01) - minus the sum of the token sizes for all deregistered tokens (Alias - Type value of 0x00), since Session initiation. -10.3.1.4. AUTHORIZATION TOKEN - The AUTHORIZATION TOKEN Setup Option (Option Type 0x03) is - functionally equivalent to the AUTHORIZATION TOKEN message parameter, - see Section 10.2.2. The endpoint can specify one or more tokens in - SETUP that the peer can use to authorize MOQT session establishment. - If an endpoint receives an AUTHORIZATION TOKEN option in SETUP with - Alias Type REGISTER that exceeds its MAX_AUTH_TOKEN_CACHE_SIZE, it - MUST NOT fail the session with AUTH_TOKEN_CACHE_OVERFLOW. Instead, -Nandakumar, et al. Expires 4 March 2027 [Page 77] +Nandakumar, et al. Expires 4 April 2027 [Page 82] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - it MUST treat the option as Alias Type USE_VALUE. Since each - endpoint's SETUP may be sent before the peer's SETUP is received, the - sender MUST handle registration failures of this kind by purging any - Token Aliases that failed to register based on the peer's - MAX_AUTH_TOKEN_CACHE_SIZE option in SETUP (or the default value of - 0). +9.9. PUBLISH_DONE -10.3.1.5. MOQT IMPLEMENTATION + A publisher sends a PUBLISH_DONE message as the final message before + closing the subscription's bidi stream to indicate it is done + publishing Objects for that subscription. The Status Code indicates + why the subscription ended, and whether it was an error. Because + PUBLISH_DONE is sent on a request stream, it is likely to arrive at + the receiver before late-arriving objects, and often even late- + opening streams. However, the receiver uses it as an indication that + it should receive any late-opening streams in a relatively short + time. - The MOQT_IMPLEMENTATION option (Option Type 0x07) identifies the name - and version of the sender's MOQT implementation. This SHOULD be a - UTF-8 encoded string [RFC3629], though the message does not carry - information, such as language tags, that would aid comprehension by - any entity other than the one that created the text. + Note that some objects in the subscribed track might never be + delivered, because a stream was reset, or never opened in the first + place, due to the delivery timeouts (see Section 5.2). - An endpoint SHOULD send a MOQT_IMPLEMENTATION option unless - specifically configured not to do so. This option helps identify the - scope of interoperability problems and work around implementation- - specific limitations. + A sender MUST NOT send PUBLISH_DONE until it has closed all streams + it will ever open, and has no further datagrams to send, for a + subscription. After sending PUBLISH_DONE, the sender can immediately + destroy subscription state, although stream state can persist until + delivery completes. The sender might persist subscription state to + enforce the subgroup delivery timeout. - Senders SHOULD limit the value to the implementation name and - version, avoiding advertising or other nonessential information. - Implementations SHOULD NOT use the identifiers of other - implementations to declare compatibility, as this undermines the - usefulness of implementation identification for debugging. + A sender MUST NOT destroy subscription state until it sends + PUBLISH_DONE, though it can choose to stop sending objects (and thus + send PUBLISH_DONE) for any reason. -10.3.1.6. MAX FILTER RANGES + A subscriber that receives PUBLISH_DONE SHOULD set a timer of at + least the larger of SUBGROUP_DELIVERY_TIMEOUT or + OBJECT_DELIVERY_TIMEOUT in case some objects are still inbound due to + prioritization or packet loss. The subscriber MAY dispense with a + timer if it unsubscribed or is otherwise no longer interested in + objects from the track. Once the timer has expired, the receiver + destroys subscription state once all open streams for the + subscription have closed. A subscriber MAY discard subscription + state earlier, at the cost of potentially not delivering some late + objects to the application. The subscriber SHOULD send STOP_SENDING + on all streams related to the subscription when it deletes + subscription state. - The MAX_FILTER_RANGES option (Type 0x06) limits the peer's total - number of Ranges (Start/End pairs) allowed concurrently in all Range - filter Section 5.1.4 parameters for a given subscription or fetch. - The default value is 0, so if not specified, the peer MUST NOT send - any such filter parameters. If this limit is exceeded, an endpoint - MUST reject this with REQUEST_ERROR with error code INVALID_FILTER. + The format of PUBLISH_DONE is as follows: -10.3.1.7. MAX_REQUEST_UPDATES - The MAX_REQUEST_UPDATES option (Option Type 0x08) communicates the - maximum number of unacknowledged REQUEST_UPDATE messages per request - stream that the endpoint is willing to receive. - A REQUEST_UPDATE is considered outstanding from when it is sent until - the sender receives the corresponding REQUEST_OK or REQUEST_ERROR - response. The sender MUST NOT have more than MAX_REQUEST_UPDATES - outstanding REQUEST_UPDATEs on any single request stream at a time. - Each REQUEST_OK or REQUEST_ERROR response restores one credit on that - stream. An implementation that processes and responds to a - REQUEST_UPDATE immediately might not detect when a peer has pipelined -Nandakumar, et al. Expires 4 March 2027 [Page 78] - -Internet-Draft moq-transport August 2026 - messages exceeding its limit; coalescing REQUEST_UPDATE processing - (see Section 10.9) can be more effective at enforcing - MAX_REQUEST_UPDATES. - The value is encoded as a variable-length integer. A value of 0 - means the endpoint does not limit REQUEST_UPDATE concurrency. If not - present, the default value is 0. - If an endpoint receives a REQUEST_UPDATE on a stream that already has - MAX_REQUEST_UPDATES outstanding REQUEST_UPDATEs, it MUST close the - session with TOO_MANY_REQUEST_UPDATES. +Nandakumar, et al. Expires 4 April 2027 [Page 83] + +Internet-Draft moq-transport October 2026 -10.4. GOAWAY - An endpoint sends a GOAWAY message on its control stream to inform - the peer it intends to close the session soon. When sent by a - server, it can initiate session migration (Section 3.6) with an - optional URI. A client MUST send a zero-length New Session URI in - any GOAWAY, as clients cannot instruct servers to initiate - connections. + PUBLISH_DONE Message { + Type (vi64) = 0xB, + Length (16), + Status Code (vi64), + Stream Count (vi64), + Error Reason (Reason Phrase) + } - A GOAWAY MAY also be sent on a request stream to initiate migration - of that individual request. Upon receiving a GOAWAY on a request - stream, the endpoint SHOULD re-issue that specific request on a - session at the specified URI (or the current session if no URI is - provided), and close the old request stream using the appropriate - mechanism (e.g. FIN, stream reset, or PUBLISH_DONE). This allows, - for example, moving the publishers and subscribers of a common set of - tracks to a common relay without draining their entire session. + Figure 14: MOQT PUBLISH_DONE Message + + * Status Code: An integer status code indicating why the + subscription ended. + + * Stream Count: An integer indicating the number of data streams the + publisher opened for this subscription, including streams that + contained no Objects (e.g., an empty Subgroup) and including any + fill fetch streams (see Section 3.4). This helps the subscriber + know if it has received all of the data published in this + subscription by comparing the number of streams received. The + subscriber can immediately remove all subscription state once the + same number of streams have been processed. If the publisher did + not open any streams for this subscription, the publisher MUST set + Stream Count to 0. If the publisher is unable to set Stream Count + to the exact number of streams opened for the subscription, it + MUST set Stream Count to 2^64 - 1. Subscribers SHOULD use a + timeout or other mechanism to remove subscription state in case + the publisher set an incorrect value, reset a stream before the + SUBGROUP_HEADER, or set the maximum value. If a subscriber + receives more streams for a subscription than specified in Stream + Count, it MAY close the session with a PROTOCOL_VIOLATION. + + * Error Reason: Provides the reason for subscription error. See + Section 8.5. - The GOAWAY message does not impact subscription state. A subscriber - SHOULD individually unsubscribe from each existing subscription, - while a publisher MAY reject new requests after sending a GOAWAY. + The status codes used in PUBLISH_DONE are defined in Section 12.4. - Upon receiving a GOAWAY on the control stream, an endpoint SHOULD NOT - initiate new requests to the peer including SUBSCRIBE, PUBLISH, - FETCH, PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS and - TRACK_STATUS. +9.10. PUBLISH_STATE_NOTIFY - Sending a GOAWAY does not prevent the sender from initiating new - requests, though the sender SHOULD avoid initiating requests unless - required by migration (see (Section 9.4.1 and Section 9.5.1). An - endpoint that receives a GOAWAY MAY reject new requests with an - appropriate error code (e.g., REQUEST_ERROR with error code - GOING_AWAY). + A publisher sends PUBLISH_STATE_NOTIFY on a subscription's + bidirectional stream to notify the subscriber that the state of the + subscription has changed for a reason other than a subscriber sent + REQUEST_UPDATE. Unlike REQUEST_UPDATE (Section 9.5), it is a + unilateral notification: the receiver does not respond with + REQUEST_OK or REQUEST_ERROR, and the message is not subject to the + MAX_REQUEST_UPDATES limit (Section 9.1.7). -Nandakumar, et al. Expires 4 March 2027 [Page 79] +Nandakumar, et al. Expires 4 April 2027 [Page 84] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - The endpoint MUST close the session with a PROTOCOL_VIOLATION - (Section 3.5) if it receives more than one GOAWAY on the control - stream or on a single request stream. + PUBLISH_STATE_NOTIFY applies only to subscriptions, and is sent only + by the publisher. An endpoint that receives a PUBLISH_STATE_NOTIFY + for any other request type, or from the subscriber, MUST close the + session with a PROTOCOL_VIOLATION. - GOAWAY Message { - Type (vi64) = 0x10, + A PUBLISH_STATE_NOTIFY carries the parameters whose values have + changed. If a parameter is not present, its value is unchanged. The + semantics of each parameter, including whether it may appear in + PUBLISH_STATE_NOTIFY, are defined by the parameter. + + A publisher MUST NOT use PUBLISH_STATE_NOTIFY to change the value of + a subscriber controlled subscription parameter unless the subscriber + requested the change. + + The publisher MUST include the LARGEST_OBJECT parameter + (Section 9.20.17), if known, in PUBLISH_STATE_NOTIFY so the + subscriber can determine the point in the Track at which the change + took effect. + + This message is informative and no action is required by the + recipient. + + The format of PUBLISH_STATE_NOTIFY is as follows: + + PUBLISH_STATE_NOTIFY Message { + Type (vi64) = 0x22, Length (16), - New Session URI Length (vi64), - New Session URI (..), - Timeout (vi64), + Number of Parameters (vi64), + Parameters (..) ... } - Figure 7: MOQT GOAWAY Message + Figure 15: MOQT PUBLISH_STATE_NOTIFY Message - * New Session URI: When received by a client, indicates where the - client can connect to continue this session or re-issue this - request. The client MUST use this URI for the new session if - provided. If the URI is zero bytes long, the current URI is - reused instead. The new session URI SHOULD use the same scheme as - the current URI to ensure compatibility. The maximum length of - the New Session URI is 8,192 bytes. If an endpoint receives a - length exceeding the maximum, it MUST close the session with a - PROTOCOL_VIOLATION. + * Parameters: The parameters are defined in Section 9.20. The + parameters that can appear in a PUBLISH_STATE_NOTIFY are + LARGEST_OBJECT, FORWARD and LOCATION_FILTER. - If a server receives a GOAWAY with a non-zero New Session URI - Length it MUST close the session with a PROTOCOL_VIOLATION. +9.11. FETCH - * Timeout: The time in milliseconds the sender will wait for - graceful closure. When sent on the control stream, the sender - closes the session with GOAWAY_TIMEOUT after the indicated timeout - if there are still open requests. When sent on a request stream, - the sender SHOULD reset the stream with GOING_AWAY after the - indicated timeout. A value of 0 indicates the sender has no - specific timeout, but the recipient SHOULD migrate as quickly as - possible. This is a hint; the sender of the GOAWAY MAY close the - session or reset the request stream before the indicated timeout - has elapsed. + A subscriber sends FETCH as the first message on a new bidi stream to + a publisher to request a range of already published objects within a + track. -10.5. REQUEST_OK + The format of FETCH is as follows: - The REQUEST_OK message is sent in response to PUBLISH, - REQUEST_UPDATE, TRACK_STATUS, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS - and PUBLISH_NAMESPACE requests. - This document uses the shorthand PUBLISH_OK, REQUEST_UPDATE_OK, - TRACK_STATUS_OK, SUBSCRIBE_NAMESPACE_OK, SUBSCRIBE_TRACKS_OK and - PUBLISH_NAMESPACE_OK to refer to a REQUEST_OK sent in response to the - corresponding request type. -Nandakumar, et al. Expires 4 March 2027 [Page 80] + + +Nandakumar, et al. Expires 4 April 2027 [Page 85] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - REQUEST_OK Message { - Type (vi64) = 0x7, + FETCH Message { + Type (vi64) = 0x16, Length (16), + Request ID (vi64), + Track Namespace (..), + Track Name Length (vi64), + Track Name (..), Number of Parameters (vi64), - Parameters (..) ..., - Track Properties (..), + Parameters (..) ... } - Figure 8: MOQT REQUEST_OK Message + Figure 16: MOQT FETCH Message - * Parameters: The parameters are defined in Section 10.2. + * Request ID: See Section 6.4.2.1. - * Track Properties : A sequence of Properties. See Section 2.5. - The length of Track Properties is the remaining length of the - message after parsing all previous fields. Track Properties are - populated in TRACK_STATUS_OK; they are empty in PUBLISH_OK, - REQUEST_UPDATE_OK, SUBSCRIBE_NAMESPACE_OK and - PUBLISH_NAMESPACE_OK. If an endpoint receives Track Properties in - one of these messages it MUST close the session with a - PROTOCOL_VIOLATION. + * Track Namespace: Identifies the namespace of the track as defined + in (Section 8.7). -10.6. REQUEST_ERROR + * Track Name: Identifies the track name as defined in + (Section 2.4.1). - The REQUEST_ERROR message is sent in response to any request - (SUBSCRIBE, FETCH, PUBLISH, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS, - PUBLISH_NAMESPACE, TRACK_STATUS, REQUEST_UPDATE). + * Parameters: The parameters are defined in Section 9.20. The + parameters that can appear in a FETCH are AUTHORIZATION_TOKEN, + FILL_TIMEOUT, SUBSCRIBER_PRIORITY, LOCATION_FILTER, GROUP_ORDER, + SUBGROUP_FILTER, OBJECTID_FILTER, PRIORITY_FILTER, + OBJECT_PROPERTY_FILTER and INCLUDE_PROPERTIES. -10.6.1. Redirect Structure +9.12. FETCH_OK - A Redirect provides a way for an endpoint to direct the peer to retry - a request at a different URI and/or for a different Full Track Name. + A publisher sends a FETCH_OK as the first message on the bidi stream + in response to a successful fetch. - Redirect { - Connect URI Length (vi64), - Connect URI (..), - Track Namespace (..), - Track Name Length (vi64), - Track Name (..), + FETCH_OK Message { + Type (vi64) = 0x18, + Length (16), + End Of Track (8), + End Location (Location), + Number of Parameters (vi64), + Parameters (..) ... + Track Properties (..), } - * Connect URI: The URI to connect to for the redirected request. If - the length is zero, the requester SHOULD use the current session's - URI. If a server receives a Redirect with a non-zero Connect URI - Length it MUST close the session with a PROTOCOL_VIOLATION. + Figure 17: MOQT FETCH_OK Message - * Track Namespace and Track Name: The Track Namespace and Track Name - to use for the redirected request, together referred to as the - Redirect target. + * End Of Track: 1 if all Objects have been published on this Track, + and the End Location is the final Object in the Track, 0 if not. -Nandakumar, et al. Expires 4 March 2027 [Page 81] - -Internet-Draft moq-transport August 2026 - Track Name is not meaningful for namespace-scoped requests - (SUBSCRIBE_NAMESPACE, PUBLISH_NAMESPACE, SUBSCRIBE_TRACKS) and - MUST be empty; an endpoint that receives a non-empty Track Name in - a Redirect for a namespace-scoped request MUST close the session - with a PROTOCOL_VIOLATION. +Nandakumar, et al. Expires 4 April 2027 [Page 86] + +Internet-Draft moq-transport October 2026 -10.6.2. REQUEST_ERROR Message Format - REQUEST_ERROR Message { - Type (vi64) = 0x5, - Length (16), - Error Code (vi64), - Retry Interval (vi64), - Error Reason (Reason Phrase), - [Redirect (Redirect),] - } + * End Location: The end of the range covered by the FETCH response, + inclusive. This is the End Location from the FETCH request + Location Filter parameter unless the requested range extends + beyond Largest Object at the time the request was processed, or + the last Object in the Track. If End Location is smaller than the + Start Location in the corresponding FETCH the receiver MUST close + the session with a PROTOCOL_VIOLATION. - Figure 9: MOQT REQUEST_ERROR Message + * Parameters: The parameters are defined in Section 9.20. No + parameters are currently defined for FETCH_OK. - * Error Code: Identifies an integer error code for request failure. + * Track Properties : A sequence of Properties. See Section 8.4. - * Retry Interval: The minimum time (in milliseconds) before the - request SHOULD be sent again, plus one. If the value is 0, the - request SHOULD NOT be retried. +9.13. TRACK_STATUS - * Error Reason: Provides a text description of the request error. - See Section 1.4.4. + A potential subscriber sends TRACK_STATUS as the first and only + message on a new bidi stream to obtain information about the current + status of a given track. - * Redirect: Present only when Error Code is REDIRECT. See - Section 10.6.1. + The TRACK_STATUS message format is identical to the SUBSCRIBE message + (Section 9.6), but subscriber parameters related to Track delivery + (e.g. SUBSCRIBER_PRIORITY) are not included. The parameters that can + appear in a TRACK_STATUS are AUTHORIZATION_TOKEN and + INCLUDE_PROPERTIES. - The application SHOULD use a relevant error code in REQUEST_ERROR, as - defined below and assigned in Section 15.11.2. Most codepoints have - identical meanings for various request types, but some have request- - specific meanings. + The receiver of a TRACK_STATUS message treats it identically as if it + had received a SUBSCRIBE message, except it does not create + downstream subscription state or send any Objects. If successful, + the publisher responds with a TRACK_STATUS_OK with the same + parameters and Track Properties it would have set in a SUBSCRIBE_OK. + Track Alias is not used. A publisher responds to a failed + TRACK_STATUS with an appropriate TRACK_STATUS_ERROR message. The + bidi stream is closed with a FIN after TRACK_STATUS_OK or + TRACK_STATUS_ERROR are sent. - If a request is retryable with the same parameters at a later time, - the sender of REQUEST_ERROR includes a non-zero Retry Interval in the - message. To minimize the risk of synchronized retry storms, the - sender can apply randomization to each retry interval so that retries - are spread out over time. A Retry Interval value of 1 indicates the - request can be retried immediately. + Relays without an Established subscription MAY forward TRACK_STATUS + to one or more publishers, or MAY initiate a subscription (subject to + authorization) as described in Section 7.6 to determine the response. + The publisher does not send PUBLISH_DONE for this request, and the + subscriber cannot send REQUEST_UPDATE. - INTERNAL_ERROR: An implementation specific or generic error - occurred. +9.14. PUBLISH_NAMESPACE - UNAUTHORIZED: The subscriber is not authorized to perform the + The publisher sends the PUBLISH_NAMESPACE message as the first + message on a new bidi stream to advertise that it has tracks + available in namespaces matching a Track Namespace Prefix. -Nandakumar, et al. Expires 4 March 2027 [Page 82] + +Nandakumar, et al. Expires 4 April 2027 [Page 87] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - requested action on the given track. This might be retryable if - the authorization token is not yet valid. + PUBLISH_NAMESPACE Message { + Type (vi64) = 0x6, + Length (16), + Request ID (vi64), + Track Namespace Prefix (..), + Number of Parameters (vi64), + Parameters (..) ... + } - TIMEOUT: The subscription could not be completed before an - implementation specific timeout. For example, a relay could not - establish an upstream subscription within the timeout. + Figure 18: MOQT PUBLISH_NAMESPACE Message - NOT_SUPPORTED: The endpoint does not support the type of request. + * Request ID: See Section 6.4.2.1. - MALFORMED_AUTH_TOKEN: Invalid Auth Token serialization during - registration (see Section 10.2.2). + * Track Namespace Prefix: A Track Namespace as defined in + Section 8.7, matched as a prefix (see Section 2.4.2). - EXPIRED_AUTH_TOKEN: Authorization token has expired - (Section 10.2.2). + * Parameters: The parameters are defined in Section 9.20. The only + parameter that can appear in a PUBLISH_NAMESPACE is + AUTHORIZATION_TOKEN. - GOING_AWAY: The endpoint has received a GOAWAY and MAY reject new - requests. +9.15. SUBSCRIBE_NAMESPACE - EXCESSIVE_LOAD: The responder is overloaded and cannot process the - request at this time. The sender SHOULD use the Retry Interval to - indicate when the request can be retried. + The subscriber sends a SUBSCRIBE_NAMESPACE control message on a new + bidirectional stream to a publisher to request the current set of + matching published namespaces, as well as future updates to the set. - UNSUPPORTED_EXTENSION: The track contains a Mandatory Track Property - (see Section 2.5.1) that the endpoint does not understand. + SUBSCRIBE_NAMESPACE Message { + Type (vi64) = 0x50, + Length (16), + Request ID (vi64), + Track Namespace Prefix (..), + Number of Parameters (vi64), + Parameters (..) ... + } - REDIRECT: The request cannot be fulfilled by this endpoint, but - could succeed at the location specified in the Redirect structure. - The requester SHOULD establish a new session to the provided URI - (if present) and retry the request using the Redirect target. A - Retry Interval of 0 indicates the original request SHOULD NOT be - retried as sent; it does not prevent the requester from following - a Redirect to a different URI or Redirect target. This error code - can appear in response to SUBSCRIBE, FETCH, TRACK_STATUS, PUBLISH, - PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, and SUBSCRIBE_TRACKS. - Relays are not required to follow redirects from upstream and MAY - forward a REDIRECT response to matching downstream requests. A - relay MAY cache a REDIRECT response for up to Retry Interval - milliseconds and use it to respond to subsequent matching requests - without forwarding them upstream. + Figure 19: MOQT SUBSCRIBE_NAMESPACE Message - Below are errors for use by the publisher. They can appear in - response to SUBSCRIBE, FETCH, TRACK_STATUS, SUBSCRIBE_NAMESPACE, and - SUBSCRIBE_TRACKS, unless otherwise noted. + * Request ID: See Section 6.4.2.1. - DOES_NOT_EXIST: The track or namespace is not available at the - publisher. + * Track Namespace Prefix: A Track Namespace structure as described + in Section 8.7, matched as a prefix (see Section 2.4.2). + + * Parameters: The parameters are defined in Section 9.20. The only + parameter that can appear in a SUBSCRIBE_NAMESPACE is + AUTHORIZATION_TOKEN. + + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 88] + +Internet-Draft moq-transport October 2026 + + +9.16. NAMESPACE + + The NAMESPACE message is similar to the PUBLISH_NAMESPACE message, + except it is sent on the response stream of a SUBSCRIBE_NAMESPACE + request. All NAMESPACE messages are in response to a + SUBSCRIBE_NAMESPACE, so only the namespace tuples after the 'Track + Namespace Prefix' are included in the 'Track Namespace Suffix'. + + NAMESPACE Message { + Type (vi64) = 0x8, + Length (16), + Track Namespace Suffix (..), + } - INVALID_RANGE: In response to SUBSCRIBE or FETCH, specified Filter + Figure 20: MOQT NAMESPACE Message + * Track Namespace Suffix: Specifies the final portion of a track's + namespace as defined in Section 8.7 after removing namespace + tuples included in 'Track Namespace Prefix' Section 9.15. +9.17. NAMESPACE_DONE -Nandakumar, et al. Expires 4 March 2027 [Page 83] - -Internet-Draft moq-transport August 2026 + The publisher sends the NAMESPACE_DONE control message on the + response stream of a SUBSCRIBE_NAMESPACE request. All NAMESPACE_DONE + messages are in response to a SUBSCRIBE_NAMESPACE, so only the + namespace tuples after the 'Track Namespace Prefix' are included in + the 'Track Namespace Suffix'. + NAMESPACE_DONE Message { + Type (vi64) = 0xE, + Length (16), + Track Namespace Suffix (..) + } - or range of Locations cannot be satisfied. + Figure 21: MOQT NAMESPACE_DONE Message - INVALID_FILTER: A filter parameter is invalid. + * Track Namespace Suffix: Specifies the final portion of a track's + namespace as defined in Section 8.7. The namespace begins with + the 'Track Namespace Prefix' specified in Section 9.15. - MALFORMED_TRACK: In response to a FETCH, a relay publisher detected - the track was malformed (see Section 2.4.2). +9.18. SUBSCRIBE_TRACKS - The following are errors for use by the subscriber. They can appear - in response to PUBLISH or PUBLISH_NAMESPACE, unless otherwise noted. + The subscriber sends a SUBSCRIBE_TRACKS control message on a new + bidirectional stream to a publisher to request PUBLISH messages for + all tracks within matching namespaces, as well as future track + publications within those namespaces. - UNINTERESTED: The subscriber is not interested in the track or - namespace. - Errors below can only be used in response to one message type. - PREFIX_OVERLAP: In response to SUBSCRIBE_NAMESPACE or - SUBSCRIBE_TRACKS, the namespace prefix shares a common prefix with - another subscription of the same type in the same session. - SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS have independent overlap - spaces, so a SUBSCRIBE_NAMESPACE and a SUBSCRIBE_TRACKS may share - the same prefix. - NAMESPACE_TOO_LARGE: In response to SUBSCRIBE_NAMESPACE or - SUBSCRIBE_TRACKS, the namespace prefix matches more publishers - than the relay is willing to enumerate. - CONFLICTING_FILTERS: In response to SUBSCRIBE_TRACKS, the filter - parameters conflict among too many subscribers to aggregate the - subscription upstream or otherwise efficiently service it. +Nandakumar, et al. Expires 4 April 2027 [Page 89] + +Internet-Draft moq-transport October 2026 -10.7. SUBSCRIBE - SUBSCRIBE initiates a subscription to a track. The associated - parameters determine the range and mechanism of object delivery; the - Location Filter (see Section 5.1.2) selects which Objects are sent, - and a FILL_PARAMETERS parameter (see Section 10.2.15) additionally - retrieves the fill range on a fill fetch stream (see Section 5.1.3). + SUBSCRIBE_TRACKS Message { + Type (vi64) = 0x51, + Length (16), + Request ID (vi64), + Track Namespace Prefix (..), + Number of Parameters (vi64), + Parameters (..) ... + } - The format of SUBSCRIBE is as follows: + Figure 22: MOQT SUBSCRIBE_TRACKS Message + * Request ID: See Section 6.4.2.1. + * Track Namespace Prefix: A Track Namespace structure as described + in Section 8.7. This prefix is matched against track namespaces + known to the publisher. + * Parameters: The parameters are defined in Section 9.20, though + they are handled differently from the same Parameters on + Subscriptions, as outlined below. The parameters that can appear + in a SUBSCRIBE_TRACKS are AUTHORIZATION_TOKEN, FORWARD, + GROUP_ORDER, SUBGROUP_FILTER, OBJECTID_FILTER, PRIORITY_FILTER, + OBJECT_PROPERTY_FILTER, TRACK_PROPERTY_FILTER and + INCLUDE_PROPERTIES. +9.19. PUBLISH_SKIPPED + The publisher sends the PUBLISH_SKIPPED control message to indicate + it will not send a PUBLISH message to initiate a new Subscription for + a Track in the SUBSCRIBE_TRACKS's Track Namespace. All + PUBLISH_SKIPPED messages are in response to a SUBSCRIBE_TRACKS, so + only the namespace tuples after the 'Track Namespace Prefix' are + included in the 'Track Namespace Suffix'. + PUBLISH_SKIPPED Message { + Type (vi64) = 0xF, + Length (16), + Track Namespace Suffix (..), + Track Name Length (vi64), + Track Name (..), + } + Figure 23: MOQT PUBLISH_SKIPPED Message + * Track Namespace Suffix: Specifies the final portion of a track's + namespace as defined in Section 8.7. The namespace begins with + the 'Track Namespace Prefix' specified in Section 9.18. -Nandakumar, et al. Expires 4 March 2027 [Page 84] +Nandakumar, et al. Expires 4 April 2027 [Page 90] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - SUBSCRIBE Message { - Type (vi64) = 0x3, - Length (16), - Request ID (vi64), - Track Namespace (..), - Track Name Length (vi64), - Track Name (..), - Number of Parameters (vi64), - Parameters (..) ... - } + * Track Name: Identifies the track name as defined in + (Section 2.4.1). - Figure 10: MOQT SUBSCRIBE Message +9.20. Control Message Parameters - * Request ID: See Section 10.1. + Some control messages include a field that encodes optional Message + Parameters. Message Parameters are serialized as follows: - * Track Namespace: Identifies the namespace of the track as defined - in (Section 2.4.1). + Message Parameter { + Type Delta (vi64), + Value (..) + } - * Track Name: Identifies the track name as defined in - (Section 2.4.1). + Figure 24: Message Parameter - * Parameters: The parameters are defined in Section 10.2. + Type Delta: The difference between this Parameter Type and the + previous Parameter Type in the message, or the Parameter Type itself + for the first parameter. Parameters MUST be serialized in ascending + order by Type. If the resulting Type would be greater than 2^64 - 1, + the endpoint MUST close the session with a PROTOCOL_VIOLATION. - On successful subscription, the publisher MUST reply with a - SUBSCRIBE_OK, allowing the subscriber to determine the start group/ - object when not explicitly specified, and start sending objects. + * Value: The encoding is specified by each parameter definition. + The encodings defined in this draft are: -10.8. SUBSCRIBE_OK + - uint8: A single-byte unsigned integer (0-255) - A publisher sends a SUBSCRIBE_OK as the first response message on the - bidi stream for successful subscriptions. + - varint: A variable-length integer - SUBSCRIBE_OK Message { - Type (vi64) = 0x4, - Length (16), - Track Alias (vi64), - Number of Parameters (vi64), - Parameters (..) ..., - Track Properties (..), - } + - Location: Two consecutive varints (Group, Object) + + - Length-prefixed: A varint length followed by that many bytes - Figure 11: MOQT SUBSCRIBE_OK Message + - Track Namespace: A sequence of length-prefixed fields + (Section 8.7) - * Track Alias: The identifer used for this track in Subgroups or - Datagrams (see Section 11.1). + Message Parameters are intended for the peer only and are not + forwarded by Relays, though relays can consider received parameter + values when making a request. + + All Message Parameters MUST be defined in the negotiated version of + MOQT or negotiated via Setup Options. An endpoint that receives an + unknown Message Parameter MUST close the session with + PROTOCOL_VIOLATION. Because the receiver has to understand every + Message Parameter, there is no need for a mechanism to skip unknown + parameters. Because unknown parameters cannot be skipped, the block + is bounded by a parameter count rather than a length. - * Parameters: The parameters are defined in Section 10.2. -Nandakumar, et al. Expires 4 March 2027 [Page 85] +Nandakumar, et al. Expires 4 April 2027 [Page 91] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 + + The Message Parameter types defined in this version of MOQT are + defined in the following subsections. + + Senders MUST NOT repeat the same Parameter Type in a message unless + the parameter definition explicitly allows multiple instances of that + type to be sent in a single message. Receivers SHOULD check that + there are no unexpected duplicate parameters and close the session + with PROTOCOL_VIOLATION if found. - * Track Properties : A sequence of Properties. See Section 2.5. + The number of Message Parameters is not specifically limited, but the + total length of a control message is limited to 2^16-1 bytes. -10.9. REQUEST_UPDATE + Message Parameters in SUBSCRIBE and FETCH MUST NOT cause the + publisher to alter the payload of the objects it sends, as that would + violate the track uniqueness guarantee described in Section 2.5. - The sender of a request (SUBSCRIBE, PUBLISH, FETCH, - PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS) can later - send a REQUEST_UPDATE on the same bidi stream as the request to - modify it. A subscriber can also send REQUEST_UPDATE to modify - parameters of a subscription established with PUBLISH. +9.20.1. Parameter Scope - An endpoint that receives a REQUEST_UPDATE other than in the two - cases above MUST close the session with a PROTOCOL_VIOLATION. + Message Parameters are always intended for the peer endpoint only and + are not forwarded by Relays, though relays can consider received + parameter values when making a request. Track information not + specific to the Message or Session is encoded in Track Properties. + See Section 8.4. - The receiver of a REQUEST_UPDATE MUST respond with exactly one - REQUEST_OK or REQUEST_ERROR message indicating if the update was - successful, unless it is coalescing failed updates to produce just - one REQUEST_ERROR for multiple REQUEST_UPDATE messages. + Each Message Parameter definition indicates the message types in + which it can appear, and each control message definition lists the + parameters it allows. If a parameter appears in some other type of + message, the receiving endpoint MUST close the connection with a + PROTOCOL_VIOLATION. Note that since Setup Options use a separate + namespace, it is impossible for Message Parameters to appear in Setup + messages. - The number of outstanding REQUEST_UPDATEs on a single request stream - is limited by the MAX_REQUEST_UPDATES Setup Option - (Section 10.3.1.7). +9.20.2. AUTHORIZATION TOKEN Parameter - If a parameter previously set on the request is not present in - REQUEST_UPDATE, its value remains unchanged. + The AUTHORIZATION TOKEN parameter (Parameter Type 0x03) uses Length- + prefixed encoding. It MAY appear in a PUBLISH, SUBSCRIBE, + REQUEST_UPDATE, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS, + PUBLISH_NAMESPACE, TRACK_STATUS or FETCH message. This parameter + conveys information to authorize the sender to perform the operation + carrying the parameter. This Parameter MUST NOT be copied from a + SUBSCRIBE_TRACKS to the resulting PUBLISH message Parameters. - There is no mechanism to remove a parameter from a request. + The parameter value is a Token structure, whose wire format and + semantics are defined in Section 8.9. - The format of REQUEST_UPDATE is as follows: - REQUEST_UPDATE Message { - Type (vi64) = 0x2, - Length (16), - Request ID (vi64), - Number of Parameters (vi64), - Parameters (..) ... - } - Figure 12: MOQT REQUEST_UPDATE Message - * Request ID: See Section 10.1. - * Parameters: The parameters are defined in Section 10.2. +Nandakumar, et al. Expires 4 April 2027 [Page 92] + +Internet-Draft moq-transport October 2026 +9.20.3. SUBGROUP_DELIVERY_TIMEOUT Parameter + The SUBGROUP_DELIVERY_TIMEOUT parameter (Parameter Type 0x06) is a + varint. It MAY appear in a SUBSCRIBE, PUBLISH, or REQUEST_UPDATE + message. Its semantics are defined in Section 5.2. + This parameter is intended to be specific to a subscription, so it + SHOULD NOT be forwarded upstream by a relay that intends to serve + multiple subscriptions for the same track. +9.20.4. OBJECT_DELIVERY_TIMEOUT Parameter + The OBJECT_DELIVERY_TIMEOUT parameter (Parameter Type 0x02) is a + varint. It MAY appear in a SUBSCRIBE, PUBLISH, or REQUEST_UPDATE + message. Its semantics are defined in Section 5.2. -Nandakumar, et al. Expires 4 March 2027 [Page 86] - -Internet-Draft moq-transport August 2026 + This parameter is intended to be specific to a subscription, so it + SHOULD NOT be forwarded upstream by a relay that intends to serve + multiple subscriptions for the same track. +9.20.5. FILL TIMEOUT Parameter -10.9.1. Updating Subscriptions + The FILL_TIMEOUT parameter (Parameter Type 0x0A) MAY appear in a + FETCH message, or inside a FILL_PARAMETERS parameter (see + Section 9.20.15) in a SUBSCRIBE or REQUEST_UPDATE (for a + subscription), where it applies to the fill fetch stream. - When a subscriber decreases the Start Location of the Location Filter - (see Section 5.1.2), the Start Location can be smaller than the - Track's Largest Location, similar to a new Subscription. Including - FILL_PARAMETERS (see Section 10.2.15) in the REQUEST_UPDATE causes - the publisher to deliver the new fill range by opening a new fill - fetch stream (see Section 5.1.3). FETCH can also be used to retrieve - any necessary Objects smaller than the current Largest Location. + It is the maximum total duration in milliseconds a relay SHOULD spend + waiting for upstream sources to provide Objects that are not + immediately available before reporting them as Timed-Out gaps in the + FETCH response (see Section 3.2). - When a subscriber increases the End Location, the Largest Object at - the publisher might already be larger than the previous End Location. - This will create a gap in the subscription. The REQUEST_UPDATE_OK - will include the LARGEST_OBJECT parameter, and the subscriber can - issue a FETCH to retrieve the omitted Objects, if any. + A value of 0 indicates the subscriber only wants Objects that are + immediately available; the relay MUST NOT wait for upstream delivery + and MUST report any unavailable Objects as Timed-Out gaps. - When a subscriber narrows their subscription (increase the Start - Location and/or decrease the End Group), it might still receive - Objects outside the new range if the publisher sent them before the - update was processed. + If the Fill Timeout parameter is absent, the relay waits for an + implementation specific duration before reporting Timed-Out gaps. If + the subscriber specifies a Fill Timeout larger than the relay is + willing to wait, the relay MAY use a shorter timeout without + informing the subscriber. - When a REQUEST_UPDATE is unsuccessful, the publisher MUST also - terminate the subscription by sending a PUBLISH_DONE with error code - UPDATE_FAILED. When a REQUEST_UPDATE fails for a FETCH, the - publisher MUST reset the FETCH data stream. When a REQUEST_UPDATE - fails for a SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS or - PUBLISH_NAMESPACE, the responder MUST close the bidi stream (see - Section 3.3.2). +9.20.6. RENDEZVOUS TIMEOUT Parameter - A receiver of multiple REQUEST_UPDATE messages on the same stream MAY - coalesce their processing by applying only the cumulative result. - Parameter values from later REQUEST_UPDATE messages override values - from earlier ones. The receiver MUST still send a REQUEST_OK for - each successful update, but it is not required to process - intermediate states individually. If the coalesced REQUEST_UPDATE - results in REQUEST_ERROR, only a single REQUEST_ERROR will be sent - and the sender of the REQUEST_UPDATEs will not always be able to - determine which caused an error. + The RENDEZVOUS_TIMEOUT parameter (Parameter Type 0x04) MAY appear in + a SUBSCRIBE message. -10.9.2. Updating Namespace Subscriptions - A subscriber can update the Track Namespace Prefix of an established - SUBSCRIBE_NAMESPACE or SUBSCRIBE_TRACKS by including the - TRACK_NAMESPACE_PREFIX parameter (Section 10.2.20) in a - REQUEST_UPDATE. The overlap restriction applies independently per - type: the new prefix MUST NOT share a common prefix with any other - active SUBSCRIBE_NAMESPACE (for a SUBSCRIBE_NAMESPACE update) or - SUBSCRIBE_TRACKS (for a SUBSCRIBE_TRACKS update) in the same session. -Nandakumar, et al. Expires 4 March 2027 [Page 87] +Nandakumar, et al. Expires 4 April 2027 [Page 93] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - If the update is accepted, NAMESPACE and NAMESPACE_DONE messages - following the REQUEST_OK will contain Track Namespace suffixes - relative to the updated prefix. Updating the prefix of a - SUBSCRIBE_TRACKS has no effect on existing subscriptions. If the - subscriber is no longer interested it can cancel the corresponding - bidirectional stream. + It is the duration in milliseconds the subscriber is willing to wait + for a publisher to become available. This applies when a relay + receives a SUBSCRIBE for a Track that has no current publisher. -10.10. PUBLISH_STATE_NOTIFY + If the RENDEZVOUS_TIMEOUT is present, the relay SHOULD hold the + subscription and wait for a publisher to appear, up to the specified + duration. The relay does not send SUBSCRIBE_OK until a publisher + becomes available. If a publisher becomes available within this + time, the relay proceeds with the subscription normally. If the + timeout expires without a publisher, the relay SHOULD respond with + SUBSCRIBE_ERROR with error code TIMEOUT. - A publisher sends PUBLISH_STATE_NOTIFY on a subscription's - bidirectional stream to notify the subscriber that the state of the - subscription has changed for a reason other than a subscriber sent - REQUEST_UPDATE. Unlike REQUEST_UPDATE (Section 10.9), it is a - unilateral notification: the receiver does not respond with - REQUEST_OK or REQUEST_ERROR, and the message is not subject to the - MAX_REQUEST_UPDATES limit (Section 10.3.1.7). + The relay MAY use a shorter timeout than requested by the subscriber. + For example, a relay might limit the maximum rendezvous timeout to + protect its resources. - PUBLISH_STATE_NOTIFY applies only to subscriptions, and is sent only - by the publisher. An endpoint that receives a PUBLISH_STATE_NOTIFY - for any other request type, or from the subscriber, MUST close the - session with a PROTOCOL_VIOLATION. + A value of 0 indicates the subscriber does not want to wait and + expects an immediate response. The relay MUST immediately return + SUBSCRIBE_ERROR with error code DOES_NOT_EXIST if no publisher is + available - A PUBLISH_STATE_NOTIFY carries the parameters whose values have - changed. If a parameter is not present, its value is unchanged. The - semantics of each parameter, including whether it may appear in - PUBLISH_STATE_NOTIFY, are defined by the parameter. + If RENDEZVOUS_TIMEOUT is absent, the default is 0. - A publisher MUST NOT use PUBLISH_STATE_NOTIFY to change the value of - a subscriber controlled subscription parameter unless the subscriber - requested the change. +9.20.7. SUBSCRIBER PRIORITY Parameter - The publisher MUST include the LARGEST_OBJECT parameter - (Section 10.2.17), if known, in PUBLISH_STATE_NOTIFY so the - subscriber can determine the point in the Track at which the change - took effect. + The SUBSCRIBER_PRIORITY parameter (Parameter Type 0x20) is a uint8. + It MAY appear in a SUBSCRIBE, PUBLISH, FETCH, or REQUEST_UPDATE (for + a subscription or FETCH). It is an integer expressing the priority + of a subscription relative to other subscriptions and fetch responses + in the same session. Lower numbers get higher priority. See + Section 5.1. - This message is informative and no action is required by the - recipient. + If omitted from SUBSCRIBE or FETCH, the publisher uses the value 128. - The format of PUBLISH_STATE_NOTIFY is as follows: +9.20.8. GROUP ORDER Parameter - PUBLISH_STATE_NOTIFY Message { - Type (vi64) = 0x22, - Length (16), - Number of Parameters (vi64), - Parameters (..) ... - } + The GROUP_ORDER parameter (Parameter Type 0x22) is a uint8. It MAY + appear in a SUBSCRIBE, PUBLISH, SUBSCRIBE_TRACKS, or FETCH, or inside + a FILL_PARAMETERS parameter (see Section 9.20.15). + Its value indicates how to prioritize Objects from different groups + within the same subscription (see Section 5.1), or how to order + Groups in a Fetch response (see Section 9.11). When it appears + inside FILL_PARAMETERS, it governs the fill fetch stream and its + ordering relative to subscription-delivered Objects (see + Section 5.1). The allowed values are Ascending (0x1) or Descending + (0x2). If an endpoint receives a value outside this range, it MUST + close the session with PROTOCOL_VIOLATION. -Nandakumar, et al. Expires 4 March 2027 [Page 88] +Nandakumar, et al. Expires 4 April 2027 [Page 94] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - Figure 13: MOQT PUBLISH_STATE_NOTIFY Message + If omitted from SUBSCRIBE or SUBSCRIBE_TRACKS, the publisher's + preference from the Track is used. If omitted from FETCH, the + receiver uses Ascending (0x1). - * Parameters: The parameters are defined in Section 10.2. +9.20.9. LOCATION FILTER Parameter -10.11. PUBLISH + The LOCATION_FILTER parameter (Parameter Type 0x21) MAY appear in a + FETCH, SUBSCRIBE, PUBLISH, REQUEST_UPDATE (for a subscription) or + PUBLISH_STATE_NOTIFY message. It is a Location Filter (see + Section 3.3.1). - The publisher sends PUBLISH as the first message on a new - bidirectional stream to initiate a subscription for a Track. The - receiver verifies the publisher is authorized to publish this track. + A Location filter parameter has the following structure: - PUBLISH Message { - Type (vi64) = 0x1D, - Length (16), - Request ID (vi64), - Track Namespace (..), - Track Name Length (vi64), - Track Name (..), - Track Alias (vi64), - Number of Parameters (vi64), - Parameters (..) ..., - Track Properties (..), + LOCATION_FILTER Parameter { + Parameter Type (vi64) = 0x21, + Location Filter Type (vi64), + [StartGroup (vi64),] + [StartObject (vi64),] + [EndGroupDelta (vi64),] + [EndObject (vi64),] } - Figure 14: MOQT PUBLISH Message + The Location Filter Type dictates which optional variable-length + integer fields follow, and how they are interpreted. - * Request ID: See Section 10.1. + * If Location Filter Type is 0x00, no fields follow and there is no + Location Filter. - * Track Namespace: Identifies a track's namespace as defined in - (Section 2.4.1) + * If Location Filter Type is 0x01, a relative StartGroup follows. - * Track Name: Identifies the track name as defined in - (Section 2.4.1). + * If Location Filter Type is 0x02, StartGroup and StartObject + follow. - * Track Alias: The identifer used for this track in Subgroups or - Datagrams (see Section 11.1). - - * Parameters: The parameters are defined in Section 10.2. - Parameters such as FORWARD, GROUP_ORDER, SUBSCRIBER_PRIORITY, - SUBGROUP_DELIVERY_TIMEOUT, OBJECT_DELIVERY_TIMEOUT, and LOCATION - FILTER can appear in the Parameters of a PUBLISH to inform the - Subscriber of the initial Subscription parameters. If the PUBLISH - is the result of a SUBSCRIBE_TRACKS, the parameters are handled as - described in Section 10.20.1, otherwise, they represent the - publisher's initial settings for the subscription, which the - subscriber can change. + * If Location Filter Type is 0x03, StartGroup, StartObject, and + EndGroupDelta follow. + + * If Location Filter Type is 0x04, StartGroup, StartObject, + EndGroupDelta, and EndObject follow. + + * If Location Filter Type is 0x05, no fields follow and it specifies + the Next Object. + + * Any other Location Filter Type is a PROTOCOL_VIOLATION. - * Track Properties : A sequence of Properties. See Section 2.5. + The table below summarizes the encodings. -Nandakumar, et al. Expires 4 March 2027 [Page 89] + + +Nandakumar, et al. Expires 4 April 2027 [Page 95] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - A subscriber receiving a PUBLISH for a Track it does not wish to - receive SHOULD send REQUEST_ERROR with error code UNINTERESTED, and - abandon reading any publisher initiated streams associated with that - subscription using a STOP_SENDING frame. + +================+====================+==================+ + | Location | Start Location | End Location | + | Filter Type | | | + +================+====================+==================+ + | 0x00 (None) | no filter | no filter | + +----------------+--------------------+------------------+ + | 0x01 (Relative | relative: {Largest | open-ended | + | Start) | Object.Group + 1 - | | + | | StartGroup, 0} | | + +----------------+--------------------+------------------+ + | 0x02 (Absolute | absolute: | open-ended | + | Start) | {StartGroup, | | + | | StartObject} | | + +----------------+--------------------+------------------+ + | 0x03 (Absolute | absolute: | last Object of | + | Start, Group | {StartGroup, | Group StartGroup | + | End) | StartObject} | + EndGroupDelta | + +----------------+--------------------+------------------+ + | 0x04 (Absolute | absolute: | {StartGroup + | + | Range) | {StartGroup, | EndGroupDelta, | + | | StartObject} | EndObject} | + +----------------+--------------------+------------------+ + | 0x05 (Next | Next Object | open-ended | + | Object) | | | + +----------------+--------------------+------------------+ - A publisher that sends the FORWARD parameter (Section 10.2.18) equal - to 0 indicates that it will not transmit any objects until the - subscriber sets the Forward State to 1. If the FORWARD parameter is - omitted or equal to 1, the publisher will start transmitting objects - immediately, possibly before PUBLISH_OK. Delivery starts at the Next - Object relative to the Largest Object at the time the publisher - begins sending. + Table 6: Location Filter forms -10.12. PUBLISH_DONE + If Location Filter Type is 0x01, the StartGroup field specifies a + relative number of groups prior to the Next Group, hence the start + Location is {Largest Object.Group + 1 - StartGroup, 0}. For example: + * StartGroup=0 will start at the Next Group * StartGroup=1 will start + at the current group * StartGroup=2 will start at 1 group prior to + the current group * StartGroup=N will start at N-1 groups prior to + the current group - A publisher sends a PUBLISH_DONE message as the final message before - closing the subscription's bidi stream to indicate it is done - publishing Objects for that subscription. The Status Code indicates - why the subscription ended, and whether it was an error. Because - PUBLISH_DONE is sent on a request stream, it is likely to arrive at - the receiver before late-arriving objects, and often even late- - opening streams. However, the receiver uses it as an indication that - it should receive any late-opening streams in a relatively short - time. + If a relative start group results in a computed absolute group less + than 0, the computed value is set to 0; if greater than 2^64 - 1, it + is set to 2^64 - 1. - Note that some objects in the subscribed track might never be - delivered, because a stream was reset, or never opened in the first - place, due to the delivery timeouts (see Section 8). + Otherwise, all fields are absolute. EndGroupDelta is delta encoded + from StartGroup, but both the start and end groups are absolute, not + relative to Largest Object. If StartGroup + EndGroupDelta exceeds + 2^64 - 1, the endpoint MUST close the session with a + PROTOCOL_VIOLATION. - A sender MUST NOT send PUBLISH_DONE until it has closed all streams - it will ever open, and has no further datagrams to send, for a - subscription. After sending PUBLISH_DONE, the sender can immediately - destroy subscription state, although stream state can persist until - delivery completes. The sender might persist subscription state to - enforce the subgroup delivery timeout. - A sender MUST NOT destroy subscription state until it sends - PUBLISH_DONE, though it can choose to stop sending objects (and thus - send PUBLISH_DONE) for any reason. - A subscriber that receives PUBLISH_DONE SHOULD set a timer of at - least the larger of SUBGROUP_DELIVERY_TIMEOUT or - OBJECT_DELIVERY_TIMEOUT in case some objects are still inbound due to - prioritization or packet loss. The subscriber MAY dispense with a - timer if it unsubscribed or is otherwise no longer interested in - objects from the track. Once the timer has expired, the receiver - destroys subscription state once all open streams for the - subscription have closed. A subscriber MAY discard subscription -Nandakumar, et al. Expires 4 March 2027 [Page 90] +Nandakumar, et al. Expires 4 April 2027 [Page 96] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - state earlier, at the cost of potentially not delivering some late - objects to the application. The subscriber SHOULD send STOP_SENDING - on all streams related to the subscription when it deletes - subscription state. + When EndGroupDelta and EndObject are omitted from a subscription + filter, the subscription is open-ended. When they are omitted from a + Fetch, the EndGroup and EndObject are Largest Object. - The format of PUBLISH_DONE is as follows: + When EndObject is omitted, the filter includes all objects in the End + Group. - PUBLISH_DONE Message { - Type (vi64) = 0xB, - Length (16), - Status Code (vi64), - Stream Count (vi64), - Error Reason (Reason Phrase) - } + If omitted from FETCH or SUBSCRIBE, the fetch or subscription is + unfiltered. If omitted from REQUEST_UPDATE or PUBLISH_STATE_NOTIFY, + the value is unchanged. When sent in PUBLISH_STATE_NOTIFY, it + reports the Location Filter now in effect at the publisher. - Figure 15: MOQT PUBLISH_DONE Message +9.20.10. SUBGROUP FILTER Parameter - * Status Code: An integer status code indicating why the - subscription ended. + The SUBGROUP_FILTER parameter (Type 0x25) selects objects with + specified Ranges of Subgroup ID. See Section 3.3.2 and Section 8.6. - * Stream Count: An integer indicating the number of data streams the - publisher opened for this subscription, including streams that - contained no Objects (e.g., an empty Subgroup) and including any - fill fetch streams (see Section 5.1.3). This helps the subscriber - know if it has received all of the data published in this - subscription by comparing the number of streams received. The - subscriber can immediately remove all subscription state once the - same number of streams have been processed. If the publisher did - not open any streams for this subscription, the publisher MUST set - Stream Count to 0. If the publisher is unable to set Stream Count - to the exact number of streams opened for the subscription, it - MUST set Stream Count to 2^64 - 1. Subscribers SHOULD use a - timeout or other mechanism to remove subscription state in case - the publisher set an incorrect value, reset a stream before the - SUBGROUP_HEADER, or set the maximum value. If a subscriber - receives more streams for a subscription than specified in Stream - Count, it MAY close the session with a PROTOCOL_VIOLATION. + SUBGROUP_FILTER { + Type (vi64) = 0x25, + Length (vi64), + [SetID (8)], + [Range (..) ...] + } - * Error Reason: Provides the reason for subscription error. See - Section 1.4.4. +9.20.11. OBJECTID FILTER Parameter - The application SHOULD use a relevant status code in PUBLISH_DONE, as - defined below: + The OBJECTID_FILTER parameter (Type 0x26) selects objects with + specified Ranges of Object ID. See Section 3.3.2 and Section 8.6. - INTERNAL_ERROR (0x0): An implementation specific or generic error - occurred. + OBJECTID_FILTER { + Type (vi64) = 0x26, + Length (vi64), + [SetID (8)], + [Range (..) ...] + } - UNAUTHORIZED (0x1): The subscriber is no longer authorized to +9.20.12. PRIORITY FILTER Parameter + The PRIORITY_FILTER parameter (Type 0x27) selects objects with + specified Ranges of Publisher Priority. See Section 3.3.2 and + Section 8.6. If a decoded value exceeds 255, the endpoint MUST + reject this with REQUEST_ERROR with error code INVALID_FILTER since + Publisher Priority is an 8-bit field. -Nandakumar, et al. Expires 4 March 2027 [Page 91] - -Internet-Draft moq-transport August 2026 - subscribe to the given track. - TRACK_ENDED (0x2): The track is no longer being published. - GOING_AWAY (0x4): The subscriber or publisher issued a GOAWAY - message. - TOO_FAR_BEHIND (0x5): The publisher's queue of objects to be sent to - the given subscriber exceeds its implementation defined limit. - EXPIRED (0x6): The publisher reached the timeout specified in - SUBSCRIBE_OK. +Nandakumar, et al. Expires 4 April 2027 [Page 97] + +Internet-Draft moq-transport October 2026 - MALFORMED_TRACK (0x12): A relay publisher detected that the track - was malformed (see Section 2.4.2). - UPDATE_FAILED (0x8): REQUEST_UPDATE failed on this subscription (see - Section 10.9). + PRIORITY_FILTER { + Type (vi64) = 0x27, + Length (vi64), + [SetID (8)], + [Range (..) ...] + } - EXCESSIVE_LOAD (0x9): The publisher is overloaded and is terminating - the subscription. +9.20.13. OBJECT PROPERTY FILTER Parameter -10.13. FETCH + The OBJECT_PROPERTY_FILTER parameter (Type 0x28) selects objects with + required Ranges of Property Value for a required Object Property Type + which MUST be even, i.e. a single integer value (see Figure 3), + otherwise the endpoint MUST reject this with REQUEST_ERROR with error + code INVALID_FILTER. See Section 3.3.2 and Section 8.6. - A subscriber sends FETCH as the first message on a new bidi stream to - a publisher to request a range of already published objects within a - track. + OBJECT_PROPERTY_FILTER { + Type (vi64) = 0x28, + Length (vi64), + [SetID (8)], + [Property Type (vi64)], + [Range (..) ...] + } - The format of FETCH is as follows: +9.20.14. TRACK PROPERTY FILTER Parameter - FETCH Message { - Type (vi64) = 0x16, - Length (16), - Request ID (vi64), - Track Namespace (..), - Track Name Length (vi64), - Track Name (..), - Number of Parameters (vi64), - Parameters (..) ... + The TRACK_PROPERTY_FILTER parameter (Type 0x29) selects tracks with + required Ranges of Property Value for a required Track Property Type + which MUST be even, i.e. a single integer value (see Figure 3), + otherwise the endpoint MUST reject this with REQUEST_ERROR with error + code INVALID_FILTER. See Section 3.3.2 and Section 8.6. + + TRACK_PROPERTY_FILTER { + Type (vi64) = 0x29, + Length (vi64), + [SetID (8)], + [Property Type (vi64)], + [Range (..) ...] } - Figure 16: MOQT FETCH Message +9.20.15. FILL PARAMETERS Parameter - * Request ID: See Section 10.1. + The FILL_PARAMETERS parameter (Parameter Type 0x23) uses length- + prefixed encoding. It MAY appear in a SUBSCRIBE or REQUEST_UPDATE + (for a subscription) message. Its value is a sequence of Parameters + that apply to the fill fetch stream (see Section 3.4), encoded as if + they were Parameters for a separate message (see Section 16.7). Its + presence is what requests a fill fetch stream; a subscription with no + FILL_PARAMETERS opens none. - * Track Namespace: Identifies the namespace of the track as defined - in (Section 2.4.1). +Nandakumar, et al. Expires 4 April 2027 [Page 98] + +Internet-Draft moq-transport October 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 92] - -Internet-Draft moq-transport August 2026 + The following parameters MAY appear inside FILL_PARAMETERS: + +================+========================+================+ + | Parameter Type | Parameter Name | Specification | + +================+========================+================+ + | 0x0A | FILL_TIMEOUT | Section 9.20.5 | + +----------------+------------------------+----------------+ + | 0x20 | SUBSCRIBER_PRIORITY | Section 9.20.7 | + +----------------+------------------------+----------------+ + | 0x21 | LOCATION_FILTER | Section 9.20.9 | + +----------------+------------------------+----------------+ + | 0x22 | GROUP_ORDER | Section 9.20.8 | + +----------------+------------------------+----------------+ + | 0x25 | SUBGROUP_FILTER | Section 3.3.2 | + +----------------+------------------------+----------------+ + | 0x26 | OBJECTID_FILTER | Section 3.3.2 | + +----------------+------------------------+----------------+ + | 0x27 | PRIORITY_FILTER | Section 3.3.2 | + +----------------+------------------------+----------------+ + | 0x28 | OBJECT_PROPERTY_FILTER | Section 3.3.2 | + +----------------+------------------------+----------------+ - * Track Name: Identifies the track name as defined in - (Section 2.4.1). + Table 7 - * Parameters: The parameters are defined in Section 10.2. - - A publisher responds to a FETCH request with either a FETCH_OK or a - REQUEST_ERROR message. The publisher creates a new unidirectional - stream that is used to send the Objects. The FETCH_OK or - REQUEST_ERROR can come at any time relative to object delivery. - - The publisher responding to a FETCH is responsible for delivering all - available Objects in the requested range in the requested order (see - Section 10.2.8). The Objects in the response are delivered on a - single unidirectional stream. Any gaps in the Group and Object IDs - in the response stream indicate objects that do not exist unless - filters were requested. For Ascending Group Order this includes - ranges between the first requested object and the first object in the - stream; between objects in the stream; and between the last object in - the stream and the Largest Group/Object indicated in FETCH_OK, so - long as the fetch stream is terminated by a FIN. If no Objects exist - in the requested range, the publisher opens the unidirectional - stream, sends the FETCH_HEADER (see Section 11.4.4) and closes the - stream with a FIN. + The LOCATION_FILTER inside FILL_PARAMETERS selects the fill range and + is evaluated using the rules for a Fetch (see Section 9.20.9); it is + independent of the subscription's own Location filter. + + A parameter that is omitted from FILL_PARAMETERS takes the value it + has for the subscription; FILL_PARAMETERS therefore carries only the + settings that differ. An endpoint that receives a parameter inside + FILL_PARAMETERS that is not listed above MUST close the session with + PROTOCOL_VIOLATION. + + The value of FILL_PARAMETERS is a separate parameter scope. + Parameters inside it are not considered to appear in the enclosing + message for the purposes of Section 9.20, so a Parameter Type MAY + appear both in the message and inside FILL_PARAMETERS. + + FILL_PARAMETERS is not retained as subscription state. It applies + only to the message that carries it, so the sticky-parameter rules in + Section 9.5 do not apply to it. - A relay that has cached objects from the beginning of the range MAY - start sending objects immediately in response to a FETCH. If it - encounters an object in the requested range that is not cached and - has unknown status, the relay MUST pause subsequent delivery until it - has confirmed the object's status upstream. If the upstream FETCH - fails, the relay sends a REQUEST_ERROR and can reset the - unidirectional stream. It can choose to do so immediately or wait - until the cached objects have been delivered before resetting the - stream. - The Object Forwarding Preference does not apply to fetches. - Fetch can include a Location Filter parameter (see Section 5.1.2) - which specifies an inclusive range of Objects starting at Start - Location and ending at End Location. - Objects with Locations larger than the Largest Object at the time the - request is processed will not be retrieved by a FETCH. If the - requested End Location exceeds the Largest Object, the actual end of - the FETCH response is indicated in the FETCH_OK End Location. - If no Objects have been published for the track or Start Location is - greater than the Largest Object (Section 10.7) the publisher MUST - return REQUEST_ERROR with error code INVALID_RANGE. -Nandakumar, et al. Expires 4 March 2027 [Page 93] + +Nandakumar, et al. Expires 4 April 2027 [Page 99] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - A publisher MUST send fetched groups in the requested group order, - either ascending or descending. Within each group, objects are sent - in Object ID order; subgroup ID is not used for ordering. +9.20.16. EXPIRES Parameter - If a Publisher receives a FETCH with a range that includes one or - more Objects with unknown status (e.g. a Relay has temporarily lost - contact with the Original Publisher and does not have the Object in - cache), it can choose to reset the FETCH data stream with - UNKNOWN_OBJECT_STATUS (Section 3.3.4), or indicate the range of - unknown Objects and continue serving other known Objects. + The EXPIRES parameter (Parameter Type 0x8) is a varint. It MAY + appear in SUBSCRIBE_OK, PUBLISH, PUBLISH_OK, SUBSCRIBE_NAMESPACE_OK, + SUBSCRIBE_TRACKS_OK, PUBLISH_NAMESPACE_OK, or REQUEST_UPDATE_OK. It + encodes the time in milliseconds after which the sender of the + parameter will terminate the subscription. The sender will terminate + the subscription using PUBLISH_DONE or by cancelling the request (see + Section 6.4.2.3). This value is advisory and the sender can + terminate the subscription prior to or after the expiry time. -10.14. FETCH_OK + The receiver of the parameter can attempt to extend the subscription + by sending a REQUEST_UPDATE with 0 or more updated parameters. If + the receiver has one or more updated AUTHORIZATION_TOKENs, it SHOULD + include those in the REQUEST_UPDATE. If the extension is granted, + the sender includes a new EXPIRES value in REQUEST_UPDATE_OK. Relays + that send this parameter and applications that receive it MAY + introduce jitter to prevent many endpoints from updating + simultaneously. - A publisher sends a FETCH_OK as the first message on the bidi stream - in response to a successful fetch. A publisher MAY send Objects in - response to a FETCH before the FETCH_OK message is sent, but the - FETCH_OK MUST NOT be sent until the End Location is known. + If the EXPIRES parameter is 0 or is not present in a message, the + subscription does not expire or expires at an unknown time. - FETCH_OK Message { - Type (vi64) = 0x18, - Length (16), - End Of Track (8), - End Location (Location), - Number of Parameters (vi64), - Parameters (..) ... - Track Properties (..), - } +9.20.17. LARGEST OBJECT Parameter - Figure 17: MOQT FETCH_OK Message + The LARGEST_OBJECT parameter (Parameter Type 0x9) is a Location. It + MAY appear in SUBSCRIBE_OK, PUBLISH, REQUEST_UPDATE_OK, + TRACK_STATUS_OK, or PUBLISH_STATE_NOTIFY. It contains the Largest + Object (Section 3.1.4) in the Track from the perspective of the + sending endpoint. If Objects have been published on this Track the + Publisher MUST include this parameter. - * End Of Track: 1 if all Objects have been published on this Track, - and the End Location is the final Object in the Track, 0 if not. + If omitted from a message, the sending endpoint has not published or + received any Objects in the Track. - * End Location: The end of the range covered by the FETCH response. - This is the End Location from the FETCH request Location Filter - parameter unless the requested range extends beyond Largest Object - at the time the request was processed, or the last Object in the - Track. If End Location is smaller than the Start Location in the - corresponding FETCH the receiver MUST close the session with a - PROTOCOL_VIOLATION. + A relay MUST set LARGEST_OBJECT to the largest of the following: - * Parameters: The parameters are defined in Section 10.2. + 1. Any LARGEST_OBJECT value received from the upstream publisher in + SUBSCRIBE_OK, PUBLISH, or REQUEST_UPDATE_OK - * Track Properties : A sequence of Properties. See Section 2.5. + 2. The largest Location of an Object received on an upstream + subscription @@ -5261,426 +5595,380 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 94] - -Internet-Draft moq-transport August 2026 -10.15. TRACK_STATUS +Nandakumar, et al. Expires 4 April 2027 [Page 100] + +Internet-Draft moq-transport October 2026 - A potential subscriber sends TRACK_STATUS as the first and only - message on a new bidi stream to obtain information about the current - status of a given track. - The TRACK_STATUS message format is identical to the SUBSCRIBE message - (Section 10.7), but subscriber parameters related to Track delivery - (e.g. SUBSCRIBER_PRIORITY) are not included. +9.20.18. FORWARD Parameter - The receiver of a TRACK_STATUS message treats it identically as if it - had received a SUBSCRIBE message, except it does not create - downstream subscription state or send any Objects. If successful, - the publisher responds with a TRACK_STATUS_OK with the same - parameters and Track Properties it would have set in a SUBSCRIBE_OK. - Track Alias is not used. A publisher responds to a failed - TRACK_STATUS with an appropriate REQUEST_ERROR message. The bidi - stream is closed with a FIN after TRACK_STATUS_OK or REQUEST_ERROR - are sent. + The FORWARD parameter (Parameter Type 0x10) is a uint8. It MAY + appear in SUBSCRIBE, REQUEST_UPDATE (for a subscription or a + SUBSCRIBE_TRACKS request), PUBLISH, SUBSCRIBE_TRACKS and + PUBLISH_STATE_NOTIFY. It specifies whether affected subscriptions + are paused (see Section 3.1.1). The allowed values are 0 (don't + forward) or 1 (forward). If an endpoint receives a value outside + this range, it MUST close the session with PROTOCOL_VIOLATION. - Relays without an Established subscription MAY forward TRACK_STATUS - to one or more publishers, or MAY initiate a subscription (subject to - authorization) as described in Section 9.5 to determine the response. - The publisher does not send PUBLISH_DONE for this request, and the - subscriber cannot send REQUEST_UPDATE. + In the case of a REQUEST_UPDATE for SUBSCRIBE_TRACKS, it specifies + whether future subscriptions that match the prefix are paused. + Existing subscriptions are unaffected. -10.16. PUBLISH_NAMESPACE + If the parameter is omitted from REQUEST_UPDATE or + PUBLISH_STATE_NOTIFY, the value for the subscription remains + unchanged. If the parameter is omitted from any other message, the + default value is 1. When sent in PUBLISH_STATE_NOTIFY, it reports + whether the subscription is paused at the publisher. - The publisher sends the PUBLISH_NAMESPACE message as the first - message on a new bidi stream to advertise that it has tracks - available within a Track Namespace. The receiver verifies the - publisher is authorized to publish tracks under this namespace. +9.20.19. NEW GROUP REQUEST Parameter - PUBLISH_NAMESPACE Message { - Type (vi64) = 0x6, - Length (16), - Request ID (vi64), - Track Namespace (..), - Number of Parameters (vi64), - Parameters (..) ... - } + The NEW_GROUP_REQUEST parameter (Parameter Type 0x32) is a varint. + It MAY appear in SUBSCRIBE or REQUEST_UPDATE for a subscription. It + represents the largest Group ID in the Track known by the subscriber, + plus 1. A value of 0 indicates that the subscriber has no Group + information for the Track. A subscriber MUST NOT send this parameter + in REQUEST_UPDATE if the Track did not include the DYNAMIC_GROUPS + Property with value 1. A subscriber MAY include this parameter in + SUBSCRIBE without foreknowledge of support. If the original + publisher does not support dynamic Groups, it ignores the parameter + in that case. - Figure 18: MOQT PUBLISH_NAMESPACE Message + When an Original Publisher that supports dynamic Groups receives a + NEW_GROUP_REQUEST with a value of 0 or a value larger than the + current Group, it SHOULD end the current Group and begin a new Group + as soon as practical. The Original Publisher MAY delay the + NEW_GROUP_REQUEST subject to implementation specific concerns, for + example, achieving a minimum duration for each Group. The Original + Publisher chooses the next Group ID; there are no requirements that + it be equal to the NEW_GROUP_REQUEST parameter value. - * Request ID: See Section 10.1. + Relay Handling: - * Track Namespace: Identifies a track's namespace as defined in - Section 2.4.1. + A relay that receives a NEW_GROUP_REQUEST for a Track without an + Established subscription MUST include the NEW_GROUP_REQUEST when + subscribing upstream. -Nandakumar, et al. Expires 4 March 2027 [Page 95] - -Internet-Draft moq-transport August 2026 +Nandakumar, et al. Expires 4 April 2027 [Page 101] + +Internet-Draft moq-transport October 2026 - * Parameters: The parameters are defined in Section 10.2. -10.17. NAMESPACE + A relay that receives a NEW_GROUP_REQUEST for an Established + subscription with a value of 0 or a value larger than the Largest + Group MUST send a REQUEST_UPDATE including the NEW_GROUP_REQUEST to + the publisher unless: - The NAMESPACE message is similar to the PUBLISH_NAMESPACE message, - except it is sent on the response stream of a SUBSCRIBE_NAMESPACE - request. All NAMESPACE messages are in response to a - SUBSCRIBE_NAMESPACE, so only the namespace tuples after the 'Track - Namespace Prefix' are included in the 'Track Namespace Suffix'. + 1. The Track does not support dynamic Groups - NAMESPACE Message { - Type (vi64) = 0x8, - Length (16), - Track Namespace Suffix (..), - } + 2. There is already an outstanding NEW_GROUP_REQUEST from this Relay + with a greater or equal value - Figure 19: MOQT NAMESPACE Message + If a relay receives a NEW_GROUP_REQUEST with a non-zero value less + than or equal to the Largest Group, it does not send a + NEW_GROUP_REQUEST upstream. - * Track Namespace Suffix: Specifies the final portion of a track's - namespace as defined in Section 2.4.1 after removing namespace - tuples included in 'Track Namespace Prefix' Section 10.19. + After sending a NEW_GROUP_REQUEST upstream, the request is considered + outstanding until the Largest Group increases. -10.18. NAMESPACE_DONE +9.20.20. TRACK_NAMESPACE_PREFIX Parameter - The publisher sends the NAMESPACE_DONE control message to indicate - its intent to stop serving new subscriptions for tracks within the - provided Track Namespace. All NAMESPACE_DONE messages are in - response to a SUBSCRIBE_NAMESPACE, so only the namespace tuples after - the 'Track Namespace Prefix' are included in the 'Track Namespace - Suffix'. + The TRACK_NAMESPACE_PREFIX parameter (Parameter Type 0x34) uses the + Track Namespace encoding described in Section 8.7. It MAY appear in + REQUEST_UPDATE for a SUBSCRIBE_NAMESPACE or SUBSCRIBE_TRACKS request. + It updates the Track Namespace Prefix for that subscription. If the + new prefix would share a common prefix with another active + subscription of the same type in the same session, the receiver MUST + respond with REQUEST_ERROR with error code PREFIX_OVERLAP. - NAMESPACE_DONE Message { - Type (vi64) = 0xE, - Length (16), - Track Namespace Suffix (..) - } +9.20.21. INCLUDE_PROPERTIES Parameter - Figure 20: MOQT NAMESPACE_DONE Message + The INCLUDE_PROPERTIES parameter (Parameter Type 0x35) is a uint8. + It MAY appear in SUBSCRIBE, TRACK_STATUS, FETCH or SUBSCRIBE_TRACKS. + It specifies whether the OK message sent in response includes Track + Properties or whether the resulting PUBLISH messages include Track + Properties in the case of SUBSCRIBE_TRACKS. If INCLUDE_PROPERTIES is + 0, the Track Properties are still present in the message, but they + SHOULD be empty. The allowed values are 0 (do not send Properties) + or 1 (send Properties), and the default is 1. If an endpoint + receives a value outside this range, it MUST close the session with + PROTOCOL_VIOLATION. - * Track Namespace Suffix: Specifies the final portion of a track's - namespace as defined in Section 2.4.1. The namespace begins with - the 'Track Namespace Prefix' specified in Section 10.19. +10. MOQT Properties -10.19. SUBSCRIBE_NAMESPACE + The following Properties are defined in MOQT. Each Property + specifies whether it can be used with Tracks, Objects, or both. - The subscriber sends a SUBSCRIBE_NAMESPACE control message on a new - bidirectional stream to a publisher to request the current set of - matching published namespaces, as well as future updates to the set. + Property types in ranges reserved for application-specific use + (0x78-0x7F, 0x3800-0x3FFF) are not defined by MOQT. See Section 8.4 + for usage guidance. -Nandakumar, et al. Expires 4 March 2027 [Page 96] +Nandakumar, et al. Expires 4 April 2027 [Page 102] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - SUBSCRIBE_NAMESPACE Message { - Type (vi64) = 0x50, - Length (16), - Request ID (vi64), - Track Namespace Prefix (..), - Number of Parameters (vi64), - Parameters (..) ... - } +10.1. SUBGROUP_DELIVERY_TIMEOUT - Figure 21: MOQT SUBSCRIBE_NAMESPACE Message + SUBGROUP_DELIVERY_TIMEOUT (Property Type 0x06) is a Track and Object + Property. It is a variable-length integer. Its semantics are + defined in Section 5.2. As an Object Property on the first object in + a subgroup, it overrides the Track-level value for that subgroup; it + is ignored on any other object in the subgroup. - * Request ID: See Section 10.1. +10.2. OBJECT_DELIVERY_TIMEOUT - * Track Namespace Prefix: A Track Namespace structure as described - in Section 2.4.1 with between 0 and 32 Track Namespace Fields. - This prefix is matched against track namespaces known to the - publisher. For example, using the serialized format from - Section 1.5, if the publisher is a relay that has received - PUBLISH_NAMESPACE messages for namespaces example.2ecom-123-100 - and example.2ecom-123-200, a SUBSCRIBE_NAMESPACE for - example.2ecom-123 would match both. If an endpoint receives a - Track Namespace Prefix consisting of greater than 32 Track - Namespace Fields, it MUST close the session with a - PROTOCOL_VIOLATION. + OBJECT_DELIVERY_TIMEOUT (Property Type 0x02) is a Track and Object + Property. It is a variable-length integer. Its semantics are + defined in Section 5.2. As an Object Property on the first object in + a subgroup, it overrides the Track-level value for that subgroup; it + is ignored on any other object in the subgroup. - * Parameters: The parameters are defined in Section 10.2. +10.3. MAX CACHE DURATION - The publisher will respond with REQUEST_OK or REQUEST_ERROR on the - response half of the stream. If the subscriber receives any message - other than a REQUEST_OK or a REQUEST_ERROR as the first message on - the response half of the stream, then it MUST close the session with - a PROTOCOL_VIOLATION. If the SUBSCRIBE_NAMESPACE is successful, the - publisher will send matching NAMESPACE messages on the response - stream. If it is an error, the stream will be immediately closed via - FIN. When there are changes to the namespaces being published and - the subscriber is subscribed to them, the publisher sends the - corresponding NAMESPACE or NAMESPACE_DONE messages. + MAX_CACHE_DURATION (Property Type 0x04) is a Track Property. - Within a session, if a publisher receives a SUBSCRIBE_NAMESPACE with - a Track Namespace Prefix that shares a common prefix with an - established SUBSCRIBE_NAMESPACE, it MUST respond with REQUEST_ERROR - with error code PREFIX_OVERLAP. SUBSCRIBE_NAMESPACE and - SUBSCRIBE_TRACKS have independent overlap spaces (see Section 10.20). + It is an integer expressing the number of milliseconds an Object can + be served from a cache. If present, the relay MUST NOT start + forwarding any individual Object received through this subscription + or fetch after the specified number of milliseconds has elapsed since + the beginning of the Object was received. This means Objects earlier + in a multi-object stream will expire earlier than Objects later in + the stream. Once Objects have expired from cache, their state + becomes unknown (see Section 2.1). - The publisher MUST ensure the subscriber is authorized to perform - this namespace subscription. + If MAX_CACHE_DURATION is not sent by the publisher, the Objects can + be cached until implementation constraints cause them to be evicted. +10.4. DEFAULT PUBLISHER PRIORITY + DEFAULT PUBLISHER PRIORITY (Property Type 0x0E) is a Track Property + that specifies the priority of a subscription relative to other + subscriptions in the same session. The value is from 0 to 255 and + lower numbers get higher priority. See Section 5.1. Priorities + above 255 are invalid. Subgroups and Datagrams for this subscription + inherit this priority, unless they specifically override it. + If omitted, the Default Publisher Priority is 128. +10.5. DEFAULT PUBLISHER GROUP ORDER -Nandakumar, et al. Expires 4 March 2027 [Page 97] - -Internet-Draft moq-transport August 2026 + DEFAULT_PUBLISHER_GROUP_ORDER (Property Type 0x22) is a Track + Property. - The publisher MUST NOT send NAMESPACE_DONE for a namespace suffix - before the corresponding NAMESPACE. If a subscriber receives a - NAMESPACE_DONE before the corresponding NAMESPACE, it MUST close the - session with a 'PROTOCOL_VIOLATION'. - If the publisher is unable to send NAMESPACE or NAMESPACE_DONE - messages in a timely manner because the SUBSCRIBE_NAMESPACE response - stream is blocked by flow control, the publisher MAY reset the - SUBSCRIBE_NAMESPACE response stream. When a subscriber receives a - stream reset or FIN on a SUBSCRIBE_NAMESPACE response stream, it - SHOULD treat this as though each active namespace received a - NAMESPACE_DONE. Subscriptions established via PUBLISH on separate - bidi streams are not affected by closure of the SUBSCRIBE_NAMESPACE - stream. -10.20. SUBSCRIBE_TRACKS +Nandakumar, et al. Expires 4 April 2027 [Page 103] + +Internet-Draft moq-transport October 2026 - The subscriber sends a SUBSCRIBE_TRACKS control message on a new - bidirectional stream to a publisher to request PUBLISH messages for - all tracks within matching namespaces, as well as future track - publications within those namespaces. - SUBSCRIBE_TRACKS Message { - Type (vi64) = 0x51, - Length (16), - Request ID (vi64), - Track Namespace Prefix (..), - Number of Parameters (vi64), - Parameters (..) ... - } + It is an enum indicating the publisher's preference for prioritizing + Objects from different groups within the same subscription (see + Section 5.1). The allowed values are Ascending (0x1) or Descending + (0x2). If an endpoint receives a value outside this range, it MUST + close the session with PROTOCOL_VIOLATION. - Figure 22: MOQT SUBSCRIBE_TRACKS Message + If omitted, the publisher's preference is Ascending (0x1). - * Request ID: See Section 10.1. +10.6. DYNAMIC GROUPS - * Track Namespace Prefix: A Track Namespace structure as described - in Section 2.4.1 with between 0 and 32 Track Namespace Fields. - This prefix is matched against track namespaces known to the - publisher. If an endpoint receives a Track Namespace Prefix - consisting of greater than 32 Track Namespace Fields, it MUST - close the session with a PROTOCOL_VIOLATION. + DYNAMIC_GROUPS (Property Type 0x30) is a Track Property. The allowed + values are 0 or 1. When the value is 1, it indicates that the + subscriber can request the Original Publisher to start a new Group by + including the NEW_GROUP_REQUEST parameter in REQUEST_UPDATE for this + Track. If an endpoint receives a value larger than 1, it MUST close + the session with PROTOCOL_VIOLATION. - * Parameters: The parameters are defined in Section 10.2, though - they are handled differently from the same Parameters on - Subscriptions, as outlined below. + If omitted, the value is 0. + +10.7. Immutable Properties + + Immutable Properties (Property Type 0xB) is a Track or Object + Property that contains a sequence of Key-Value-Pairs (see Figure 3) + that are themselves Track or Object Properties, respectively. + + Immutable Properties { + Type (0xB), + Length (vi64), + Key-Value-Pair (..) ... + } + This Property can be added by the Original Publisher, but MUST NOT be + added by Relays. This Property MUST NOT be modified or removed and + the serialization (e.g. variable-length integer encodings) of the + Key-Value-Pairs MUST NOT change). Like other Properties, Relays MUST + cache Immutable Properties if the Object or Track are cached and MUST + forward it. Relays MAY decode and view the Properties in the Key- + Value-Pairs. + Unless specified by a particular Property specification, Properties + MAY appear either in the mutable property list or inside Immutable + Properties. When looking for the value of a property, processors + MUST search both the mutable properties and the contents of Immutable + Properties. + If a Property allows multiple values, the same Property Type MAY + appear in both the mutable list and inside Immutable Properties, + unless prohibited by the Property specification. -Nandakumar, et al. Expires 4 March 2027 [Page 98] +Nandakumar, et al. Expires 4 April 2027 [Page 104] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - The publisher will respond with REQUEST_OK or REQUEST_ERROR on the - response half of the stream. If the subscriber receives any message - other than a REQUEST_OK or a REQUEST_ERROR as the first message on - the response half of the stream, then it MUST close the session with - a PROTOCOL_VIOLATION. If the SUBSCRIBE_TRACKS is successful, the - publisher will send PUBLISH messages on new bidirectional streams for - tracks within matching namespaces. If it is an error, the stream - will be closed via FIN after REQUEST_ERROR is sent. + A Track is considered malformed (see Section 12.1) if any of the + following conditions are detected: - Within a session, if a publisher receives a SUBSCRIBE_TRACKS with a - Track Namespace Prefix that shares a common prefix with an - established SUBSCRIBE_TRACKS, it MUST respond with REQUEST_ERROR with - error code PREFIX_OVERLAP. SUBSCRIBE_TRACKS and SUBSCRIBE_NAMESPACE - have independent overlap spaces (see Section 10.19). + * An Object contains an Immutable Properties property that contains + another Immutable Properties key. - The publisher MUST ensure the subscriber is authorized to perform - this namespace subscription. + * A Key-Value-Pair cannot be parsed. - SUBSCRIBE_TRACKS is not required for a publisher to send PUBLISH - messages to a subscriber. It is useful for subscribers that are only - interested in or authorized to access a subset of available tracks. + The following figure shows an example Object structure with a + combination of mutable and immutable properties and end to end + encrypted metadata in the Object payload. -10.20.1. Parameters on SUBSCRIBE_TRACKS + Object Header Object Payload +<------------------------------------------------> <-------------------> ++--------+-------+------------+-------+-----------+--------------------+ +| Object | Ext 1 | Immutable | Ext N | [Payload] | Private Properties | +| Fields | | Properties | | [Length] | App Payload | ++--------+-------+------------+-------+-----------+--------------------+ + xxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx + yyyyyyyyyyyyyyyyyyyy +x = e2e Authenticated Data +y = e2e Encrypted Data +EXT 1 and EXT N can be modified or removed by Relays - Any Parameter that can be specified on a Subscription (ie: in - SUBSCRIBE) is valid in SUBSCRIBE_TRACKS, unless otherwise specified. - These parameters are used by the publisher as the initial - Subscription parameters when a PUBLISH is sent as a result of - SUBSCRIBE_TRACKS. These Parameters are explicitly communicated in - PUBLISH. When omitted by the publisher in PUBLISH, the subscriber - uses the default value for each. + An Object MUST NOT contain more than one instance of this property. - To join Tracks initiated via the resulting PUBLISHes, the subscriber - can specify a Location Filter and optionally include FILL_PARAMETERS, - as described in Section 5.1.6. +10.8. Prior Group ID Gap -10.21. PUBLISH_SKIPPED + Prior Group ID Gap only applies to Objects, not Tracks. - The publisher sends the PUBLISH_SKIPPED control message to indicate - it will not send a PUBLISH message to initiate a new Subscription for - a Track in the SUBSCRIBE_TRACKS's Track Namespace. All - PUBLISH_SKIPPED messages are in response to a SUBSCRIBE_TRACKS, so - only the namespace tuples after the 'Track Namespace Prefix' are - included in the 'Track Namespace Suffix'. + Prior Group ID Gap (Property Type 0x3C) is a variable-length integer + containing the number of Groups prior to the current Group that do + not, and will never, exist. For example, if the Original Publisher + is publishing an Object in Group 7 and knows it will never publish + any Objects in Group 8 or Group 9, it can include Prior Group ID Gap + = 2 in any number of Objects in Group 10, as it sees fit. A Track is + considered malformed (see Section 12.1) if any of the following + conditions are detected: + * An Object contains more than one instance of Prior Group ID Gap. + * A Group contains more than one Object with different values for + Prior Group ID Gap. + * An Object has a Prior Group ID Gap larger than the Group ID. + * An endpoint receives an Object with a Prior Group ID Gap covering + an Object it previously received. -Nandakumar, et al. Expires 4 March 2027 [Page 99] +Nandakumar, et al. Expires 4 April 2027 [Page 105] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - PUBLISH_SKIPPED Message { - Type (vi64) = 0xF, - Length (16), - Track Namespace Suffix (..), - Track Name Length (vi64), - Track Name (..), - } + * An endpoint receives an Object with a Group ID within a previously + communicated gap. - Figure 23: MOQT PUBLISH_SKIPPED Message + Use of this property is optional, as publishers might not know the + prior gap size, or there may not be a gap. If Prior Group ID Gap is + not present, the receiver cannot infer any information about the + existence of prior groups (see Section 2.3.1). - * Track Namespace Suffix: Specifies the final portion of a track's - namespace as defined in Section 2.4.1. The namespace begins with - the 'Track Namespace Prefix' specified in Section 10.20. + This property can be added by the Original Publisher, but MUST NOT be + added by relays. This property MAY be removed by a relay when the + object in question is served via FETCH, and the gap that the property + communicates is already communicated implicitly in the FETCH + response; it MUST NOT be modified or removed otherwise. - * Track Name: Identifies the track name as defined in - (Section 2.4.1). + An Object MUST NOT contain more than one instance of this property. -11. Data Streams and Datagrams +10.9. Prior Object ID Gap - A publisher sends Objects matching a subscription on Data Streams or - Datagrams and sends Objects matching a FETCH request on one Data - Stream. + Prior Object ID Gap only applies to Objects, not Tracks. - Unidirectional stream types are defined in Section 3.4. Data streams - use SUBGROUP_HEADER or FETCH_HEADER types. + Prior Object ID Gap (Property Type 0x3E) is a variable-length integer + containing the number of Objects prior to the current Object that do + not, and will never, exist. For example, if the Original Publisher + is publishing Object 10 in Group 3 and knows it will never publish + Objects 8 or 9 in this Group, it can include Prior Object ID Gap = 2. + A Track is considered malformed (see Section 12.1) if any of the + following conditions are detected: - All MOQT datagrams start with a variable-length integer indicating - the type of the datagram. See Section 11.3.1. + * An Object contains more than one instance of Prior Object ID Gap. - An endpoint that receives an unknown datagram type MUST close the - session. + * An Object has a Prior Object ID Gap larger than the Object ID. - Every Object has a 'Object Forwarding Preference' and the Original - Publisher MAY use both Subgroups and Datagrams within a Group or - Track. + * An endpoint receives an Object with a Prior Object ID Gap covering + an Object it previously received. -11.1. Track Alias + * An endpoint receives an Object with an Object ID within a + previously communicated gap. - To optimize wire efficiency, Subgroups and Datagrams refer to a track - by a numeric identifier, rather than the Full Track Name. Track - Alias is chosen by the publisher and included in SUBSCRIBE_OK - (Section 10.8) or PUBLISH (Section 10.11). + Use of this property is optional, as publishers might not know the + prior gap size, or there might not be a gap. If Prior Object ID Gap + is not present, the receiver cannot infer any information about the + existence of prior objects (see Section 2.1). - The same Track Alias MUST NOT be used by a publisher to refer to two - different Tracks simultaneously in the same session. If a subscriber - receives a PUBLISH or SUBSCRIBE_OK that uses the same Track Alias as - a different Track with an Established subscription, it MUST close the - session with error DUPLICATE_TRACK_ALIAS. + This property can be added by the Original Publisher, but MUST NOT be + added by relays. This property MAY be removed by a relay when the + object in question is served via FETCH, and the gap that the property + communicates is already communicated implicitly in the FETCH + response; it MUST NOT be modified or removed otherwise. -Nandakumar, et al. Expires 4 March 2027 [Page 100] +Nandakumar, et al. Expires 4 April 2027 [Page 106] -Internet-Draft moq-transport August 2026 - - - Objects can be sent before the Subscriber knows the Track Alias, - requiring buffering Objects with an unknown Track Alias. If a Track - Alias is used for two concurrent subscriptions to the same Track, an - Object that arrives with the Track Alias could be for either - Subscription. Reusing the same Track Alias for concurrent - subscriptions to the same Track can lead to missed delivery if - objects for the new subscription arrive before the control message - establishing the shared Alias. The Subscriber can assume the Track - Alias is reused until told otherwise, in order to avoid missing - Objects. - - To avoid a protocol violation and to ensure the Subscriber knows - which Track Objects are from, Publishers SHOULD NOT reuse a Track - Alias for different Tracks within a session, unless it is certain the - prior Subscription has been completely closed and no Objects are - scheduled to be sent or in flight. - - Objects can arrive after a subscription has been cancelled. - Subscribers SHOULD retain sufficient state to quickly discard these - unwanted Objects, rather than treating them as belonging to an - unknown Track Alias. - -11.2. Objects - - An Object contains a range of contiguous bytes from the specified - track, as well as associated metadata required to deliver, cache, and - forward it. Objects are sent by publishers. - -11.2.1. Object Header - - A canonical MOQT Object has the following fields: - - * Track Namespace and Track Name: The track this object belongs to. - - * Group ID: The identifier of the Object's Group (see Section 2.3) - within the Track. +Internet-Draft moq-transport October 2026 - * Object ID: The order of the object within the group. - - * Publisher Priority: An 8 bit integer indicating the publisher's - priority for the Object (Section 7). - - * Object Forwarding Preference: An enumeration indicating how a - publisher sends an object. The preferences are Subgroup and - Datagram. Object Forwarding Preference is a property of an - individual Object and can vary among Objects in the same Track. - In a subscription, an Object MUST be sent according to its Object - Forwarding Preference. + An Object MUST NOT contain more than one instance of this property. +11. Data Streams and Datagrams -Nandakumar, et al. Expires 4 March 2027 [Page 101] - -Internet-Draft moq-transport August 2026 + A publisher sends Objects matching a subscription on Data Streams or + Datagrams and sends Objects matching a FETCH request on one Data + Stream. + Unidirectional stream types are defined in Section 6.4.1. Data + streams use SUBGROUP_HEADER or FETCH_HEADER types. - * Subgroup ID: The identifier of the Object's Subgroup (see - Section 2.2) within the Group. This field is omitted if the - Object Forwarding Preference is Datagram. + All MOQT datagrams start with a variable-length integer indicating + the type of the datagram. See Section 11.2.1. - * Object Status: An enumeration used to indicate whether the Object - is a normal Object or mark the end of a group or track. See - Section 11.2.1.1 below. + An endpoint that receives an unknown datagram type MUST close the + session. - * Object Properties : A sequence of Properties associated with the - object. See Section 11.2.1.2. +11.1. Objects - * Object Payload: An opaque payload intended for an End Subscriber - and SHOULD NOT be processed by a relay. Only present when 'Object - Status' is Normal (0x0). + An Object contains a range of contiguous bytes from the specified + track, as well as associated metadata required to deliver, cache, and + forward it. Objects are sent by publishers. -11.2.1.1. Object Status +11.1.1. Object Status The Object Status is a field that is only present in objects that are delivered via a SUBSCRIPTION, and is absent in Objects delivered via a FETCH. It allows the publisher to explicitly communicate that a specific range of objects does not exist. - Status can have following values: + Status can have the following values: * 0x0 := Normal object. This status is implicit for any non-zero length object. Zero-length objects explicitly encode the Normal @@ -5692,31 +5980,34 @@ Internet-Draft moq-transport August 2026 ID. * 0x4 := Indicates End of Track. Indicates that no objects with the - location that is equal to or greater than the one specified exist. + Location that is equal to or greater than the one specified exist. All of those SHOULD be cached. + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 107] + +Internet-Draft moq-transport October 2026 + + There is no Object Status value indicating the end of a Subgroup. The end of a Subgroup is signaled by closing its stream with a FIN - (see Section 11.4.3). + (see Section 11.3.2). Any other value SHOULD be treated as a protocol error and the session - SHOULD be closed with a PROTOCOL_VIOLATION (Section 3.5). An Object + SHOULD be closed with a PROTOCOL_VIOLATION (Section 12.2). An Object MUST have an empty payload unless its Object Status value is registered as permitting a payload in the Object Status registry - (Section 15.9). Of the values defined in this document, only Normal + (Section 16.9). Of the values defined in this document, only Normal (0x0) permits a payload. +11.1.2. Object Properties - -Nandakumar, et al. Expires 4 March 2027 [Page 102] - -Internet-Draft moq-transport August 2026 - - -11.2.1.2. Object Properties - - Any Object with status Normal can have properties (Section 2.5). If + Any Object with status Normal can have properties (Section 8.4). If an endpoint receives properties on an Object with status that is not Normal, it MUST close the session with a PROTOCOL_VIOLATION. @@ -5728,11 +6019,11 @@ Internet-Draft moq-transport August 2026 Object Properties set by the Original Publisher that are intended to be visible to relays, but not modified by them, SHOULD be placed in - Immutable Properties (Section 12.7), which enables end-to-end + Immutable Properties (Section 10.7), which enables end-to-end authentication schemes. Object Properties are serialized as a length in bytes followed by - Key-Value-Pairs (see Figure 2). + Key-Value-Pairs (see Figure 3). Object Properties { Properties Length (vi64), @@ -5740,41 +6031,38 @@ Internet-Draft moq-transport August 2026 } Object Property types are registered in the IANA table 'MOQ - Properties'. See Section 15. + Properties'. See Section 16. -11.3. Datagrams +11.2. Datagrams A single object can be conveyed in a datagram. The Track Alias field - (Section 11.1) indicates the track this Datagram belongs to. If an - endpoint receives a datagram with an unknown Track Alias, it MAY drop - the datagram or choose to buffer it for a brief period to handle - reordering with the control message that establishes the Track Alias. - - An Object received in an OBJECT_DATAGRAM message has an Object - Forwarding Preference = Datagram. + (Section 3.1.3) indicates the track this Datagram belongs to; see + Section 3.1.3.1 for handling of unknown Track Aliases. - To send an Object with Object Forwarding Preference = Datagram, - determine the length of the header and payload and send the Object as - datagram. When the total size is larger than the maximum datagram - size for the session, the Object will be dropped without any explicit - notification. + An Object received in an OBJECT_DATAGRAM message has a Delivery Mode + = Datagram. - Each session along the path between the Original Publisher and End - Subscriber might have different maximum datagram sizes. - Additionally, Object Properties (Section 11.2.1.2) can be added to -Nandakumar, et al. Expires 4 March 2027 [Page 103] +Nandakumar, et al. Expires 4 April 2027 [Page 108] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 + To send an Object with Delivery Mode = Datagram, determine the length + of the header and payload and send the Object as datagram. When the + total size is larger than the maximum datagram size for the session, + the Object will be dropped without any explicit notification. + + Each session along the path between the Original Publisher and End + Subscriber might have different maximum datagram sizes. + Additionally, Object Properties (Section 11.1.2) can be added to Objects as they pass through the MOQT network, increasing the size of the Object and the chances it will exceed the maximum datagram size of a downstream session and be dropped. -11.3.1. Object Datagram +11.2.1. Object Datagram An OBJECT_DATAGRAM carries a single object in a datagram. @@ -5789,7 +6077,7 @@ Internet-Draft moq-transport August 2026 [Object Payload (..),] } - Figure 24: MOQT OBJECT_DATAGRAM + Figure 25: MOQT OBJECT_DATAGRAM The Type Flags field in the OBJECT_DATAGRAM is a variable-length integer that encodes a set of flags. All values defined in this @@ -5803,28 +6091,28 @@ Internet-Draft moq-transport August 2026 * The *PROPERTIES* bit (0x01) indicates when the Properties field is present. When set to 1, the Object Properties structure defined - in Section 11.2.1.2 is present. When set to 0, the field is - absent. If an endpoint receives a datagram with the PROPERTIES - bit set and an Properties Length of 0, it MUST close the session - with a PROTOCOL_VIOLATION. + in Section 11.1.2 is present. When set to 0, the field is absent. + If an endpoint receives a datagram with the PROPERTIES bit set and + an Properties Length of 0, it MUST close the session with a + PROTOCOL_VIOLATION. - * The *END_OF_GROUP* bit (0x02) indicates End of Group. When set to - 1, this indicates that no Object with the same Group ID and an - Object ID greater than the Object ID in this datagram exists. - * The *ZERO_OBJECT_ID* bit (0x04) indicates when the Object ID field - is present. When set to 1, the Object ID field is omitted and the - Object ID is 0. When set to 0, the Object ID field is present. +Nandakumar, et al. Expires 4 April 2027 [Page 109] + +Internet-Draft moq-transport October 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 104] - -Internet-Draft moq-transport August 2026 + * The *END_OF_GROUP* bit (0x02) indicates End of Group. When set to + 1, this indicates that no Object with the same Group ID and an + Object ID greater than the Object ID in this datagram exists. + * The *ZERO_OBJECT_ID* bit (0x04) indicates when the Object ID field + is present. When set to 1, the Object ID field is omitted and the + Object ID is 0. When set to 0, the Object ID field is present. * The *DEFAULT_PRIORITY* bit (0x08) indicates when the Priority field is present. When set to 1, the Priority field is omitted @@ -5857,7 +6145,7 @@ Internet-Draft moq-transport August 2026 close the session with a PROTOCOL_VIOLATION, because only Normal Objects can have Properties. -11.4. Streams +11.3. Subgroup Streams When Objects are sent on streams, the stream begins with a Subgroup or Fetch Header and is followed by one or more sets of serialized @@ -5865,48 +6153,26 @@ Internet-Draft moq-transport August 2026 terminates with a FIN) in the middle of a serialized Object, the session SHOULD be closed with a PROTOCOL_VIOLATION. - A publisher SHOULD NOT open more than one stream at a time with the - same Subgroup Header field values. - - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 105] +Nandakumar, et al. Expires 4 April 2027 [Page 110] -Internet-Draft moq-transport August 2026 - +Internet-Draft moq-transport October 2026 -11.4.1. Stream Cancellation - Streams aside from the control streams MAY be canceled due to - congestion or other reasons by either the publisher or subscriber. - Early termination of a unidirectional stream does not affect the MOQT - application state, and therefore has no effect on outstanding - subscriptions. Closing a bidirectional request stream is governed by - Section 3.3.3. + A publisher SHOULD NOT open more than one stream at a time with the + same Subgroup Header field values. -11.4.2. Subgroup Header +11.3.1. Subgroup Header All Objects on a Subgroup stream belong to the track identified by - Track Alias (see Section 11.1) and the Subgroup indicated by 'Group - ID' and Subgroup ID indicated by the SUBGROUP_HEADER. - - If an endpoint receives a subgroup with an unknown Track Alias, it - MAY abandon the stream, or choose to buffer it for a brief period to - handle reordering with the control message that establishes the Track - Alias. The endpoint MAY withhold stream flow control beyond the - SUBGROUP_HEADER until the Track Alias has been established. To - prevent deadlocks, endpoints MUST allocate connection flow control to - the control streams before allocating it to any data streams. - Otherwise, a receiver might wait for a control message containing a - Track Alias to release flow control, while the sender waits for flow - control to send the message. + Track Alias (see Section 3.1.3) and the Subgroup indicated by Group + ID and Subgroup ID in the SUBGROUP_HEADER. + + See Section 3.1.3.1 for handling of subgroups with unknown Track + Aliases. SUBGROUP_HEADER { Type Flags (vi64), @@ -5916,10 +6182,10 @@ Internet-Draft moq-transport August 2026 [Publisher Priority (8),] } - Figure 25: MOQT SUBGROUP_HEADER + Figure 26: MOQT SUBGROUP_HEADER All Objects received on a stream opened with SUBGROUP_HEADER have an - Object Forwarding Preference = Subgroup. + Delivery Mode = Subgroup. The Type Flags field in the SUBGROUP_HEADER is a variable-length integer that encodes a set of flags. All values defined in this @@ -5928,21 +6194,12 @@ Internet-Draft moq-transport August 2026 Bit 4 is always set to 1. The four low-order bits and bits 5-6 determine which fields are present in the header: - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 106] - -Internet-Draft moq-transport August 2026 - - * The *PROPERTIES* bit (0x01) indicates when the Properties field is present in all Objects in this Subgroup. When set to 1, the - Object Properties structure defined in Section 11.2.1.2 is present - in all Objects; Objects with no properties set Properties Length - to 0. When set to 0, the field is never present. + Object Properties structure defined in Section 11.1.2 is present + in all Objects; Objects with no properties or non-Normal status + set Properties Length to 0. When set to 0, the field is never + present in this Subgroup. * The *SUBGROUP_ID_MODE* field (bits 1-2, mask 0x06) is a two-bit field that determines the encoding of the Subgroup ID. To extract @@ -5954,6 +6211,13 @@ Internet-Draft moq-transport August 2026 - 0b01: The Subgroup ID field is absent and the Subgroup ID is the Object ID of the first Object transmitted in this Subgroup. + + +Nandakumar, et al. Expires 4 April 2027 [Page 111] + +Internet-Draft moq-transport October 2026 + + - 0b10: The Subgroup ID field is present in the header. - 0b11: Reserved for future use. @@ -5986,21 +6250,13 @@ Internet-Draft moq-transport August 2026 * Values where bit 4 is not set. Bit 4 MUST be 1 for SUBGROUP_HEADER. - - - -Nandakumar, et al. Expires 4 March 2027 [Page 107] - -Internet-Draft moq-transport August 2026 - - * Values of 128 or greater (i.e., any value that requires more than a one-byte variable-length integer encoding). - To send an Object with Object Forwarding Preference = Subgroup, find - the open stream that is associated with the subscription, Group ID - and Subgroup ID, or open a new one and send the SUBGROUP_HEADER. - Then serialize the following fields. + To send an Object with Delivery Mode = Subgroup, find the open stream + that is associated with the subscription, Group ID and Subgroup ID, + or open a new one and send the SUBGROUP_HEADER. Then serialize the + following fields. The Object Status field is only sent if the Object Payload Length is zero. @@ -6010,11 +6266,19 @@ Internet-Draft moq-transport August 2026 Delta if it's the first Object in the Subgroup stream. If the resulting Object ID would be greater than 2^64 - 1, the endpoint MUST close the session with a PROTOCOL_VIOLATION. For example, a Subgroup + + + +Nandakumar, et al. Expires 4 April 2027 [Page 112] + +Internet-Draft moq-transport October 2026 + + of sequential Object IDs starting at 0 will have 0 for all Object ID Delta values. A consumer cannot infer information about the existence of Objects between the current and previous Object ID in the Subgroup (e.g. when Object ID Delta is non-zero) unless there is - a Prior Object ID Gap property (see Section 12.9). + a Prior Object ID Gap property (see Section 10.9). { Object ID Delta (vi64), @@ -6024,9 +6288,9 @@ Internet-Draft moq-transport August 2026 [Object Payload (..),] } - Figure 26: MOQT Subgroup Object Fields + Figure 27: MOQT Subgroup Object Fields -11.4.3. Closing Subgroup Streams +11.3.2. Closing Subgroup Streams Subscribers will often need to know if they have received all objects in a Subgroup, particularly if they serve as a relay or cache. QUIC @@ -6042,30 +6306,35 @@ Internet-Draft moq-transport August 2026 the QUIC stream, it MUST reset the stream. This includes, but is not limited to: + * Either of the delivery timeouts defined in Section 5.2 + + * Early termination of subscription due to request cancellation + * A publisher's decision to end the subscription early + * A REQUEST_UPDATE moving the subscription's End Group to a smaller + Group or the Start Location to a larger Location -Nandakumar, et al. Expires 4 March 2027 [Page 108] - -Internet-Draft moq-transport August 2026 + * Omitting a Subgroup Object because the subscription is paused - * Either of the delivery timeouts defined in Section 8 - * Early termination of subscription due to request cancellation - * A publisher's decision to end the subscription early - * A REQUEST_UPDATE moving the subscription's End Group to a smaller - Group or the Start Location to a larger Location - * Omitting a Subgroup Object due to the subscriber's Forward State + + + +Nandakumar, et al. Expires 4 April 2027 [Page 113] + +Internet-Draft moq-transport October 2026 + When RESET_STREAM_AT is used, the reliable_size SHOULD include the stream header so the receiver can identify the corresponding subscription and accurately account for reset data streams when - handling PUBLISH_DONE (see Section 10.12). Publishers that reset - data streams without using RESET_STREAM_AT with an appropriate + handling PUBLISH_DONE (see Section 9.9). Publishers that reset data + streams without using RESET_STREAM_AT with an appropriate reliable_size can cause subscribers to hold on to subscription state until a timeout expires. @@ -6098,35 +6367,36 @@ Internet-Draft moq-transport August 2026 Object IDs on the Subgroup stream belong to different Subgroups or do not exist, or do not pass the subscriber's filters. + If the relay does not know if an Object is the next Object, it MUST + reset the Subgroup stream and open a new one to forward it. + + Since SUBSCRIBEs always end on a group boundary, an ending + subscription can always cleanly close all its subgroups. A sender + that terminates a stream early for any other reason (e.g., to handoff + to a different sender) MUST reset the stream. Senders SHOULD + terminate a stream on Group boundaries to avoid doing so. -Nandakumar, et al. Expires 4 March 2027 [Page 109] - -Internet-Draft moq-transport August 2026 - If the relay does not know if an Object is the next Object, it MUST - reset the Subgroup stream and open a new one to forward it. - Since SUBSCRIBEs always end on a group boundary, an ending - subscription can always cleanly close all its subgroups. A sender - that terminates a stream early for any other reason (e.g., to handoff - to a different sender) MUST reset the stream. Senders SHOULD - terminate a stream on Group boundaries to avoid doing so. +Nandakumar, et al. Expires 4 April 2027 [Page 114] + +Internet-Draft moq-transport October 2026 + An MOQT implementation that processes a stream FIN is assured it has received all objects in a subgroup from the start of the subscription. If a relay, it can forward stream FINs to its own subscribers once those objects have been sent. A relay MAY treat - receipt of EndOfGroup or EndOfTrack objects as a signal to close + receipt of End of Group or End of Track objects as a signal to close corresponding streams even if the FIN has not arrived, as further objects on the stream would be a protocol violation. - Similarly, an EndOfGroup message indicates the maximum Object ID in + Similarly, an End of Group Object indicates the maximum Object ID in the Group, so if all Objects in the Group have been received, a FIN can be sent on any stream where the entire subgroup has been sent. - This might be complex to implement. Processing a reset means that there might be other objects in the Subgroup beyond the last one received. A relay might immediately @@ -6151,21 +6421,28 @@ Internet-Draft moq-transport August 2026 A publisher that receives a STOP_SENDING on a Subgroup stream SHOULD NOT attempt to open a new stream to deliver additional Objects in that Subgroup. However, if the publisher subsequently receives a - REQUEST_UPDATE that changes the Forward State from 0 to 1, it MAY - open a new stream to deliver Objects in that Subgroup, as the update - indicates the subscriber has renewed interest in forwarded Objects. + REQUEST_UPDATE that resumes the subscription, it MAY open a new + stream to deliver Objects in that Subgroup, as the update indicates + the subscriber has renewed interest in forwarded Objects. + + The application SHOULD use a relevant error code when resetting a + stream, as defined in Section 12.5. +11.4. Fetch Streams -Nandakumar, et al. Expires 4 March 2027 [Page 110] - -Internet-Draft moq-transport August 2026 - The application SHOULD use a relevant error code when resetting a - stream, as defined in Section 3.3.4. -11.4.4. Fetch Header + + + +Nandakumar, et al. Expires 4 April 2027 [Page 115] + +Internet-Draft moq-transport October 2026 + + +11.4.1. Fetch Header When a stream begins with FETCH_HEADER, all objects on the stream belong to the track requested in the message identified by Request @@ -6176,7 +6453,7 @@ Internet-Draft moq-transport August 2026 Request ID (vi64), } - Figure 27: MOQT FETCH_HEADER + Figure 28: MOQT FETCH_HEADER Each Object sent on a FETCH stream after the FETCH_HEADER has the following format: @@ -6192,12 +6469,14 @@ Internet-Draft moq-transport August 2026 [Object Payload (..),] } - Figure 28: MOQT Fetch Object Fields + Figure 29: MOQT Fetch Object Fields The Serialization Flags field defines the serialization of the Object. It is a variable-length integer. When less than 128, the - bits represent flags described below. The following additional - values are defined: + bits represent flags described in Section 11.4.1.1. When 128 or + greater, the value signals a range indicator; the defined values are: + + *Reserved Serialization Flags values:* +=======+===========================+ | Value | Meaning | @@ -6209,70 +6488,40 @@ Internet-Draft moq-transport August 2026 | 0x20C | End of Timed-Out Range | +-------+---------------------------+ - Table 7 - - - -Nandakumar, et al. Expires 4 March 2027 [Page 111] - -Internet-Draft moq-transport August 2026 - - - Any other value is a PROTOCOL_VIOLATION. - -11.4.4.1. Flags - - The two least significant bits (LSBs) of the Serialization Flags form - a two-bit field that defines the encoding of the Subgroup. To - extract this value, the Subscriber performs a bitwise AND operation - with the mask 0x03. - - +==============================+===============================+ - | Bitmask Result | Meaning | - | (Serialization Flags & 0x03) | | - +==============================+===============================+ - | 0x00 | Subgroup ID is zero | - +------------------------------+-------------------------------+ - | 0x01 | Subgroup ID is the prior | - | | Object's Subgroup ID | - +------------------------------+-------------------------------+ - | 0x02 | Subgroup ID is the prior | - | | Object's Subgroup ID plus one | - +------------------------------+-------------------------------+ - | 0x03 | The Subgroup ID field is | - | | present | - +------------------------------+-------------------------------+ - - Table 8 - - The following table defines additional flags within the Serialization - Flags field. Each flag is an independent boolean value, where a set - bit (1) indicates the corresponding condition is true. - - - - - - - - - - - + Table 8 +Nandakumar, et al. Expires 4 April 2027 [Page 116] + +Internet-Draft moq-transport October 2026 + Any other value 128 or greater is a PROTOCOL_VIOLATION. +11.4.1.1. Flags + *Subgroup ID encoding (bits 0-1, mask 0x03):* The two least + significant bits of the Serialization Flags form a two-bit field that + defines the encoding of the Subgroup ID. + +=======+========================================================+ + | Value | Meaning | + +=======+========================================================+ + | 0x00 | Subgroup ID is zero | + +-------+--------------------------------------------------------+ + | 0x01 | Subgroup ID is the prior Object's Subgroup ID | + +-------+--------------------------------------------------------+ + | 0x02 | Subgroup ID is the prior Object's Subgroup ID plus one | + +-------+--------------------------------------------------------+ + | 0x03 | The Subgroup ID field is present | + +-------+--------------------------------------------------------+ -Nandakumar, et al. Expires 4 March 2027 [Page 112] - -Internet-Draft moq-transport August 2026 + Table 9 + *Independent flag bits:* Each of the following is an independent + boolean; a set bit (1) indicates the corresponding condition is true. +=========+==========================+=========================+ | Bitmask | Condition if set | Condition if not set | @@ -6295,7 +6544,15 @@ Internet-Draft moq-transport August 2026 | | | least significant bits | +---------+--------------------------+-------------------------+ - Table 9 + Table 10 + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 117] + +Internet-Draft moq-transport October 2026 + The first Object MUST include a Group ID Delta and Object ID Delta, and these values are the absolute Group ID and Object ID. If the @@ -6321,32 +6578,21 @@ Internet-Draft moq-transport August 2026 the Subscriber MUST close the Session with error 'PROTOCOL_VIOLATION'. - The Object Properties structure is defined in Section 11.2.1.2. - - - -Nandakumar, et al. Expires 4 March 2027 [Page 113] - -Internet-Draft moq-transport August 2026 - + The Object Properties structure is defined in Section 11.1.2. - When encoding an Object with a Forwarding Preference of "Datagram" - (see Section 11.2.1.2), the object has no Subgroup ID. The publisher - MUST SET bit 0x40 to '1'. When 0x40 is set, it SHOULD set the two - least significant bits to zero and the subscriber MUST ignore the - bits. + When encoding an Object with a Delivery Mode of "Datagram" (see + Section 11.1.2), the object has no Subgroup ID. The publisher MUST + SET bit 0x40 to '1'. When 0x40 is set, it SHOULD set the two least + significant bits to zero and the subscriber MUST ignore the bits. -11.4.4.2. End of Range +11.4.1.2. End of Range When Serialization Flags indicates an End of Range (e.g. values 0x8C, 0x10C, or 0x20C), the Group ID and Object ID fields are present. Subgroup ID, Priority and Properties are not present. All Objects with Locations between the last serialized Object, if any, and this Location, inclusive, either do not exist (when Serialization Flags is - 0x8C), are unknown (0x10C), or timed out (0x20C). A publisher SHOULD - NOT use End of Non-Existent Range in a FETCH response except to split - a range of Objects that will not be serialized into those that are - known not to exist and those with unknown or timed out status. + 0x8C), are unknown (0x10C), or timed out (0x20C). When an Object follows an End of Range indicator and uses flags that reference the "prior Object", the prior Object fields are determined @@ -6355,6 +6601,15 @@ Internet-Draft moq-transport August 2026 * Prior Group ID and prior Object ID: The values from the End of Range indicator. + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 118] + +Internet-Draft moq-transport October 2026 + + * Prior Subgroup ID: The Subgroup ID from the last actual Object before the End of Range indicator. If there was no prior Object, using a flag that references the prior Subgroup ID is a @@ -6375,17 +6630,6 @@ Internet-Draft moq-transport August 2026 send padding streams at a lower priority than any control stream or Object data. - - - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 114] - -Internet-Draft moq-transport August 2026 - - 11.5.1. Padding Streams An endpoint MAY open a unidirectional stream with a stream type of @@ -6397,7 +6641,7 @@ Internet-Draft moq-transport August 2026 Padding Data (..) = 0x00.. } - Figure 29: MOQT Padding Stream + Figure 30: MOQT Padding Stream The receiver MUST discard all data received on a padding stream to prevent exhausting flow control. @@ -6411,361 +6655,453 @@ Internet-Draft moq-transport August 2026 padding data. The datagram contains the type followed by zero or more bytes that MUST all be set to zero. + + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 119] + +Internet-Draft moq-transport October 2026 + + PADDING DATAGRAM { Type (vi64) = 0x132B3E29, Padding Data (..) = 0x00.. } - Figure 30: MOQT Padding Datagram + Figure 31: MOQT Padding Datagram The receiver MUST discard all data received in a padding datagram. -11.6. Examples +12. Error Handling + +12.1. Malformed Tracks + + There are multiple ways a publisher can transmit a Track that does + not conform to MOQT constraints. Such a Track is considered + malformed. Some example conditions that constitute a malformed track + when detected by a receiver include: - Sending a subgroup on one stream: + 1. An Object with a particular Subgroup ID is received, but its + Publisher Priority is different from that of the previous Object + with the same Subgroup ID. + 2. An Object is received whose Object ID is larger than the final + Object in the Subgroup. The final Object in a Subgroup is the + last Object received on a Subgroup stream before a FIN. + 3. A Subgroup is received over multiple transport streams terminated + by FIN with different final Objects. + 4. An Object is received in a Group whose Object ID is larger than + the final Object in the Group. The final Object in a Group is + the Object with Status END_OF_GROUP, or the last Object before a + FIN in a Subgroup which has the END_OF_GROUP bit set. If the end + of a Group is implicitly determined via a gap in a FETCH + response, the final Object in the Group remains unknown. + 5. An Object is received whose Group and Object ID are larger than + the final Object in the Track. The final Object in a Track is + the Object with Status END_OF_TRACK or the last Object sent in a + FETCH whose response indicated End of Track. + 6. The same Object is received more than once with different Payload + or other immutable properties. + 7. An Object is received with a different Delivery Mode than + previously observed. + The above list of conditions is not considered exhaustive. +Nandakumar, et al. Expires 4 April 2027 [Page 120] + +Internet-Draft moq-transport October 2026 + When a subscriber detects a Malformed Track, it MUST cancel any + corresponding subscription or fetches for that Track from that + publisher (see Section 6.4.2.3), and SHOULD deliver an error to the + application. If a relay detects a Malformed Track, it MUST + immediately terminate downstream subscriptions with PUBLISH_DONE and + reset any fetch streams with Status Code MALFORMED_TRACK. Object(s) + triggering Malformed Track status MUST NOT be cached. +12.2. Session Termination Codes -Nandakumar, et al. Expires 4 March 2027 [Page 115] - -Internet-Draft moq-transport August 2026 + When terminating the Session (Section 6.6), the application MAY use + any error message and SHOULD use a relevant code, as defined below: + NO_ERROR (0x0): The session is being terminated without an error. - Stream = 2 + INTERNAL_ERROR (0x1): An implementation specific error occurred. - SUBGROUP_HEADER { - Type Flags = 0x14 - Track Alias = 2 - Group ID = 0 - Subgroup ID = 0 - Priority = 0 - } - { - Object ID = 0 - Object Payload Length = 4 - Payload = "abcd" - } - { - Object ID = 1 - Object Payload Length = 4 - Payload = "efgh" - } + UNAUTHORIZED (0x2): The client is not authorized to establish a + session. - Sending a group on one stream, with the first object containing two - Properties. + PROTOCOL_VIOLATION (0x3): The remote endpoint performed an action + that was disallowed by the specification. + + INVALID_REQUEST_ID (0x4): The endpoint received a Request ID with an + incorrect least significant bit for the sender, or a duplicate + Request ID. See Section 6.4.2.1. + DUPLICATE_TRACK_ALIAS (0x5): The endpoint attempted to use a Track + Alias that was already in use. + KEY_VALUE_FORMATTING_ERROR (0x6): The key-value pair has a + formatting error. + INVALID_PATH (0x8): The PATH parameter was used by a server, on a + WebTransport session, or the server does not support the path. + MALFORMED_PATH (0x9): The PATH parameter does not conform to the + rules in Section 9.1.2. + GOAWAY_TIMEOUT (0x10): The session was closed because the peer took + too long to close the session in response to a GOAWAY + (Section 9.2) message. See session migration (Section 6.6.1). + CONTROL_MESSAGE_TIMEOUT (0x11): The session was closed because the + peer took too long to respond to a control message. + DATA_STREAM_TIMEOUT (0x12): The session was closed because the peer +Nandakumar, et al. Expires 4 April 2027 [Page 121] + +Internet-Draft moq-transport October 2026 + took too long to send data expected on an open Data Stream (see + Section 11). This includes fields of a stream header or an object + header within a data stream. If an endpoint times out waiting for + a new object header on an open subgroup stream, it MAY send a + STOP_SENDING on that stream or terminate the subscription. + AUTH_TOKEN_CACHE_OVERFLOW (0x13): The Session limit Section 9.1.3 of + the size of all registered Authorization tokens has been exceeded. + DUPLICATE_AUTH_TOKEN_ALIAS (0x14): Authorization Token attempted to + register an Alias that was in use (see Section 8.9). + MALFORMED_AUTH_TOKEN (0x16): Invalid Auth Token serialization during + registration (see Section 8.9). + UNKNOWN_AUTH_TOKEN_ALIAS (0x17): No registered token found for the + provided Alias (see Section 8.9). + EXPIRED_AUTH_TOKEN (0x18): Authorization token has expired + (Section 8.9). + INVALID_AUTHORITY (0x19): The specified AUTHORITY does not + correspond to this server or cannot be used in this context. + MALFORMED_AUTHORITY (0x1A): The AUTHORITY value is syntactically + invalid. + TOO_MANY_REQUEST_UPDATES (0x1B): The endpoint received a + REQUEST_UPDATE that exceeded the per-stream limit communicated via + the MAX_REQUEST_UPDATES Setup Option (Section 9.1.7). +12.3. Request Error Codes + The application SHOULD use a relevant error code in REQUEST_ERROR + (Section 9.4), as defined below and assigned in Section 16.11.2. + Most codepoints have identical meanings for various request types, + but some have request-specific meanings. + INTERNAL_ERROR: An implementation specific or generic error + occurred. + UNAUTHORIZED: The subscriber is not authorized to perform the + requested action on the given track. This might be retryable if + the authorization token is not yet valid. + TIMEOUT: The subscription could not be completed before an + implementation specific timeout. For example, a relay could not + establish an upstream subscription within the timeout. -Nandakumar, et al. Expires 4 March 2027 [Page 116] +Nandakumar, et al. Expires 4 April 2027 [Page 122] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - Stream = 2 + NOT_SUPPORTED: The endpoint does not support the type of request. - SUBGROUP_HEADER { - Type Flags = 0x35 - Track Alias = 2 - Group ID = 0 - Subgroup ID = 0 - } - { - Object ID Delta = 0 (Object ID is 0) - Properties Length = 33 - { - Type = 4 - Value = 2186796243 - }, - { - Type = 77 - Length = 21 - Value = "traceID:123456" - } - Object Payload Length = 4 - Payload = "abcd" - } - { - Object ID Delta = 0 (Object ID is 1) - Properties Length = 0 - Object Payload Length = 4 - Payload = "efgh" - } + MALFORMED_AUTH_TOKEN: Invalid Auth Token serialization during + registration (see Section 8.9). -12. MOQT Properties + EXPIRED_AUTH_TOKEN: Authorization token has expired (Section 8.9). - The following Properties are defined in MOQT. Each Property - specifies whether it can be used with Tracks, Objects, or both. + GOING_AWAY: The endpoint has received a GOAWAY and MAY reject new + requests. - Property types in ranges reserved for application-specific use - (0x78-0x7F, 0x3800-0x3FFF) are not defined by MOQT. See Section 2.5 - for usage guidance. + EXCESSIVE_LOAD: The responder is overloaded and cannot process the + request at this time. The sender SHOULD use the Retry Interval to + indicate when the request can be retried. -12.1. SUBGROUP_DELIVERY_TIMEOUT + UNSUPPORTED_EXTENSION: The track contains a Mandatory Track Property + (see Section 3.7) that the endpoint does not understand. - SUBGROUP_DELIVERY_TIMEOUT (Property Type 0x06) is a Track and Object - Property. It is a variable-length integer. Its semantics are - defined in Section 8. As an Object Property on the first object in a - subgroup, it overrides the Track-level value for that subgroup; it is - ignored on any other object in the subgroup. + REDIRECT: The request cannot be fulfilled by this endpoint, but + could succeed at the location specified in the Redirect structure. + The requester SHOULD establish a new session to the provided URI + (if present) and retry the request using the Redirect target. A + Retry Interval of 0 indicates the original request SHOULD NOT be + retried as sent; it does not prevent the requester from following + a Redirect to a different URI or Redirect target. This error code + can appear in response to SUBSCRIBE, FETCH, TRACK_STATUS, PUBLISH, + PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, and SUBSCRIBE_TRACKS. + Relays are not required to follow redirects from upstream and MAY + forward a REDIRECT response to matching downstream requests. A + relay MAY cache a REDIRECT response for up to Retry Interval + milliseconds and use it to respond to subsequent matching requests + without forwarding them upstream. + + Below are errors for use by the publisher. They can appear in + response to SUBSCRIBE, FETCH, TRACK_STATUS, SUBSCRIBE_NAMESPACE, and + SUBSCRIBE_TRACKS, unless otherwise noted. + + DOES_NOT_EXIST: The track or namespace is not available at the + publisher. + + INVALID_RANGE: In response to SUBSCRIBE or FETCH, specified Filter + or range of Locations cannot be satisfied. + + INVALID_FILTER: A filter parameter is invalid. + + MALFORMED_TRACK: In response to a FETCH, a relay publisher detected + the track was malformed (see Section 12.1). -Nandakumar, et al. Expires 4 March 2027 [Page 117] +Nandakumar, et al. Expires 4 April 2027 [Page 123] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 -12.2. OBJECT_DELIVERY_TIMEOUT + The following are errors for use by the subscriber. They can appear + in response to PUBLISH or PUBLISH_NAMESPACE, unless otherwise noted. - OBJECT_DELIVERY_TIMEOUT (Property Type 0x02) is a Track and Object - Property. It is a variable-length integer. Its semantics are - defined in Section 8. As an Object Property on the first object in a - subgroup, it overrides the Track-level value for that subgroup; it is - ignored on any other object in the subgroup. + UNINTERESTED: The subscriber is not interested in the track or + namespace. + + Errors below can only be used in response to one message type. -12.3. MAX CACHE DURATION + PREFIX_OVERLAP: In response to SUBSCRIBE_NAMESPACE or + SUBSCRIBE_TRACKS, the namespace prefix shares a common prefix with + another subscription of the same type in the same session. + SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS have independent overlap + spaces, so a SUBSCRIBE_NAMESPACE and a SUBSCRIBE_TRACKS may share + the same prefix. - MAX_CACHE_DURATION (Property Type 0x04) is a Track Property. + NAMESPACE_TOO_LARGE: In response to SUBSCRIBE_NAMESPACE or + SUBSCRIBE_TRACKS, the namespace prefix matches more publishers + than the relay is willing to enumerate. - It is an integer expressing the number of milliseconds an Object can - be served from a cache. If present, the relay MUST NOT start - forwarding any individual Object received through this subscription - or fetch after the specified number of milliseconds has elapsed since - the beginning of the Object was received. This means Objects earlier - in a multi-object stream will expire earlier than Objects later in - the stream. Once Objects have expired from cache, their state - becomes unknown (see Section 2.1). + CONFLICTING_FILTERS: In response to SUBSCRIBE_TRACKS, the filter + parameters conflict among too many subscribers to aggregate the + subscription upstream or otherwise efficiently service it. + +12.4. Publish Done Codes + + The application SHOULD use a relevant status code in PUBLISH_DONE + (Section 9.9), as defined below: + + INTERNAL_ERROR (0x0): An implementation specific or generic error + occurred. + + UNAUTHORIZED (0x1): The subscriber is no longer authorized to + subscribe to the given track. + + TRACK_ENDED (0x2): The track is no longer being published. - If MAX_CACHE_DURATION is not sent by the publisher, the Objects can - be cached until implementation constraints cause them to be evicted. + GOING_AWAY (0x4): The subscriber or publisher issued a GOAWAY + message. -12.4. DEFAULT PUBLISHER PRIORITY + TOO_FAR_BEHIND (0x5): The publisher's queue of objects to be sent to + the given subscriber exceeds its implementation defined limit. - DEFAULT PUBLISHER PRIORITY (Property Type 0x0E) is a Track Property - that specifies the priority of a subscription relative to other - subscriptions in the same session. The value is from 0 to 255 and - lower numbers get higher priority. See Section 7. Priorities above - 255 are invalid. Subgroups and Datagrams for this subscription - inherit this priority, unless they specifically override it. + EXPIRED (0x6): The publisher reached the timeout specified in + SUBSCRIBE_OK. - If omitted, the Default Publisher Priority is 128. + MALFORMED_TRACK (0x12): A relay publisher detected that the track + was malformed (see Section 12.1). -12.5. DEFAULT PUBLISHER GROUP ORDER - DEFAULT_PUBLISHER_GROUP_ORDER (Property Type 0x22) is a Track - Property. - It is an enum indicating the publisher's preference for prioritizing - Objects from different groups within the same subscription (see - Section 7). The allowed values are Ascending (0x1) or Descending - (0x2). If an endpoint receives a value outside this range, it MUST - close the session with PROTOCOL_VIOLATION. - If omitted, the publisher's preference is Ascending (0x1). +Nandakumar, et al. Expires 4 April 2027 [Page 124] + +Internet-Draft moq-transport October 2026 + UPDATE_FAILED (0x8): REQUEST_UPDATE failed on this subscription (see + Section 9.5). + EXCESSIVE_LOAD (0x9): The publisher is overloaded and is terminating + the subscription. -Nandakumar, et al. Expires 4 March 2027 [Page 118] - -Internet-Draft moq-transport August 2026 +12.5. Stream Reset Error Codes + The application SHOULD use a relevant error code when resetting or + sending STOP_SENDING on any stream. -12.6. DYNAMIC GROUPS + INTERNAL_ERROR (0x0): An implementation specific error. - DYNAMIC_GROUPS (Property Type 0x30) is a Track Property. The allowed - values are 0 or 1. When the value is 1, it indicates that the - subscriber can request the Original Publisher to start a new Group by - including the NEW_GROUP_REQUEST parameter in REQUEST_UPDATE for this - Track. If an endpoint receives a value larger than 1, it MUST close - the session with PROTOCOL_VIOLATION. + CANCELLED (0x1): The stream was cancelled by either endpoint. For + Subscriptions, PUBLISH_DONE (Section 9.9) may have a more detailed + status code. - If omitted, the value is 0. + DELIVERY_TIMEOUT (0x2): A delivery timeout (Section 5.2) was + exceeded for this stream. -12.7. Immutable Properties + SESSION_CLOSED (0x3): The session is being closed. - Immutable Properties (Property Type 0xB) is a Track or Object - Property that contains a sequence of Key-Value-Pairs (see Figure 2) - that are themselves Track or Object Properties, respectively. + GOING_AWAY (0x4): The endpoint is rejecting this request because it + has sent or received a GOAWAY. - Immutable Properties { - Type (0xB), - Length (vi64), - Key-Value-Pair (..) ... - } + TOO_FAR_BEHIND (0x5): The corresponding subscription has exceeded + the publisher's resource limits and is being terminated (see + Section 5.2). - This Property can be added by the Original Publisher, but MUST NOT be - added by Relays. This Property MUST NOT be modified or removed and - the serialization (e.g. variable-length integer encodings) of the - Key-Value-Pairs MUST NOT change). Like other Properties, Relays MUST - cache Immutable Properties if the Object or Track are cached and MUST - forward it. Relays MAY decode and view the Properties in the Key- - Value-Pairs. + UNKNOWN_OBJECT_STATUS (0x6): In response to a FETCH, the publisher + is unable to determine the status of the next Object in the + requested range. - Unless specified by a particular Property specification, Properties - MAY appear either in the mutable property list or inside Immutable - Properties. When looking for the value of a property, processors - MUST search both the mutable properties and the contents of Immutable - Properties. + EXPIRED_AUTH_TOKEN (0x7): The authorization token for the request + has expired. - If a Property allows multiple values, the same Property Type MAY - appear in both the mutable list and inside Immutable Properties, - unless prohibited by the Property specification. + EXCESSIVE_LOAD (0x9): The endpoint is overloaded and is resetting + this stream. - A Track is considered malformed (see Section 2.4.2) if any of the - following conditions are detected: + MALFORMED_TRACK (0x12): A relay publisher detected that the track + was malformed (see Section 12.1). - * An Object contains an Immutable Properties property that contains - another Immutable Properties key. +13. Grease - * A Key-Value-Pair cannot be parsed. + To ensure that implementations correctly handle unknown values and do + not fail when encountering protocol extensions they do not + understand, this document reserves a range of values for the purpose + of greasing; see Section 3.3 of [RFC9170]. -Nandakumar, et al. Expires 4 March 2027 [Page 119] +Nandakumar, et al. Expires 4 April 2027 [Page 125] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - The following figure shows an example Object structure with a - combination of mutable and immutable properties and end to end - encrypted metadata in the Object payload. + Grease values follow the pattern 0x7f * N + 0x9D for non-negative + integer values of N (that is, 0x9D, 0x11C, ..., 0x3fffffffffffffde). - Object Header Object Payload -<------------------------------------------------> <-------------------> -+--------+-------+------------+-------+-----------+--------------------+ -| Object | Ext 1 | Immutable | Ext N | [Payload] | Private Properties | -| Fields | | Properties | | [Length] | App Payload | -+--------+-------+------------+-------+-----------+--------------------+ - xxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx - yyyyyyyyyyyyyyyyyyyy -x = e2e Authenticated Data -y = e2e Encrypted Data -EXT 1 and EXT N can be modified or removed by Relays + The following registries include GREASE reservations: - An Object MUST NOT contain more than one instance of this property. + * Setup Options (Section 16.4) -12.8. Prior Group ID Gap + * Properties (Section 16.8) - Prior Group ID Gap only applies to Objects, not Tracks. + * Session Termination Error Codes (Section 16.11.1) - Prior Group ID Gap (Property Type 0x3C) is a variable-length integer - containing the number of Groups prior to the current Group that do - not, and will never, exist. For example, if the Original Publisher - is publishing an Object in Group 7 and knows it will never publish - any Objects in Group 8 or Group 9, it can include Prior Group ID Gap - = 2 in any number of Objects in Group 10, as it sees fit. A Track is - considered malformed (see Section 2.4.2) if any of the following - conditions are detected: + * REQUEST_ERROR Codes (Section 16.11.2) - * An Object contains more than one instance of Prior Group ID Gap. + * PUBLISH_DONE Codes (Section 16.11.3) - * A Group contains more than one Object with different values for - Prior Group ID Gap. + * Stream Reset Error Codes (Section 16.11.4) - * An Object has a Prior Group ID Gap larger than the Group ID. + * MOQT Auth Token Type - * An endpoint receives an Object with a Prior Group ID Gap covering - an Object it previously received. + Because new values in these registries can be defined without + negotiation, implementations MUST handle unknown values gracefully. + Endpoints MUST NOT close the session solely because they received an + unknown value. The following rules apply: - * An endpoint receives an Object with a Group ID within a previously - communicated gap. + Setup Options with reserved identifiers have no semantics and can + carry arbitrary values. Endpoints MUST ignore unknown Setup Options + as specified in Section 9.1. - Use of this property is optional, as publishers might not know the - prior gap size, or there may not be a gap. If Prior Group ID Gap is - not present, the receiver cannot infer any information about the - existence of prior groups (see Section 2.3.1). + Unknown Properties MUST be handled as specified in Section 8.4. + + Receipt of an unknown error code in any error context (Session + Termination, REQUEST_ERROR, PUBLISH_DONE, or Data Stream Reset) MUST + be treated as equivalent to INTERNAL_ERROR for that context. An + endpoint MUST NOT close the session because it received an unknown + error code in a REQUEST_ERROR or PUBLISH_DONE. +14. Transport Considerations +14.1. Congestion Control Considerations -Nandakumar, et al. Expires 4 March 2027 [Page 120] - -Internet-Draft moq-transport August 2026 + MOQT does not specify a congestion controller, but there are + important attributes to consider when selecting a congestion + controller for use with an application built on top of MOQT. - This property can be added by the Original Publisher, but MUST NOT be - added by relays. This property MAY be removed by a relay when the - object in question is served via FETCH, and the gap that the property - communicates is already communicated implicitly in the FETCH - response; it MUST NOT be modified or removed otherwise. - An Object MUST NOT contain more than one instance of this property. -12.9. Prior Object ID Gap - Prior Object ID Gap only applies to Objects, not Tracks. - Prior Object ID Gap (Property Type 0x3E) is a variable-length integer - containing the number of Objects prior to the current Object that do - not, and will never, exist. For example, if the Original Publisher - is publishing Object 10 in Group 3 and knows it will never publish - Objects 8 or 9 in this Group, it can include Prior Object ID Gap = 2. - A Track is considered malformed (see Section 2.4.2) if any of the - following conditions are detected: - * An Object contains more than one instance of Prior Object ID Gap. - * An Object has a Prior Object ID Gap larger than the Object ID. +Nandakumar, et al. Expires 4 April 2027 [Page 126] + +Internet-Draft moq-transport October 2026 - * An endpoint receives an Object with a Prior Object ID Gap covering - an Object it previously received. - * An endpoint receives an Object with an Object ID within a - previously communicated gap. +14.1.1. Bufferbloat - Use of this property is optional, as publishers might not know the - prior gap size, or there might not be a gap. If Prior Object ID Gap - is not present, the receiver cannot infer any information about the - existence of prior objects (see Section 2.1). + Traditional AIMD congestion controllers (ex. CUBIC [RFC9438] and + Reno [RFC6582]) are prone to Bufferbloat. Bufferbloat occurs when + elements along the path build up a substantial queue of packets, + commonly more than doubling the round trip time. These queued + packets cause head-of-line blocking and latency, even when there is + no packet loss. - This property can be added by the Original Publisher, but MUST NOT be - added by relays. This property MAY be removed by a relay when the - object in question is served via FETCH, and the gap that the property - communicates is already communicated implicitly in the FETCH - response; it MUST NOT be modified or removed otherwise. +14.1.2. Application-Limited - An Object MUST NOT contain more than one instance of this property. + The average bitrate for latency sensitive content needs to be less + than the available bandwidth, otherwise data will be queued and/or + dropped. As such, many MOQT applications will typically be limited + by the available data to send, and not the congestion controller. + Many congestion control algorithms only increase the congestion + window or bandwidth estimate if fully utilized. This combination can + lead to underestimating the available network bandwidth. As a + result, applications might need to periodically ensure the congestion + controller is not app-limited for at least a full round trip to + ensure the available bandwidth can be measured. + + Some applications might have APIs to allow sending duplicate data or + forward error correction to probe for more bandwidth while also + limiting the impact of probing in case it causes packet loss. + Subscribers wanting to switch to an alternate representation of a + Track can subscribe to it at a lower priority, or subscribe to + additional Tracks at the lowest (255) priority to fill the congestion + window during probing intervals while minimizing the impact on higher + priority media. Publishers can send padding (Section 11.5) to probe + for additional bandwidth without requiring additional subscriptions. + Network-assisted bandwidth estimation mechanisms such as SCONE + [I-D.ietf-scone-protocol] can provide receivers with sustainable + bandwidth hints, which subscribers can use to inform track selection + decisions and potentially avoid unnecessary probing. +14.1.3. Consistent Throughput + Congestion control algorithms are commonly optimized for throughput, + not consistency. For example, BBR's PROBE_RTT state halves the + sending rate for more than a round trip in order to obtain an + accurate minimum RTT. Similarly, Reno halves its congestion window + upon detecting loss. In both cases, the large reduction in sending + rate might cause issues with latency sensitive applications. @@ -6773,12 +7109,12 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 121] +Nandakumar, et al. Expires 4 April 2027 [Page 127] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 -13. Security Considerations +15. Security Considerations MOQT is a protocol used hop-by-hop between original publishers to relay, (possibly) relay to relay, and relay to end subscribers. @@ -6793,16 +7129,16 @@ Internet-Draft moq-transport August 2026 relays within the chain from original publisher to end subscribers will have access to Track names, Track Properties, Object Properties, as well as the object's content unless it is end-to-end encrypted - Section 13.4. + Section 15.4. Publishers, including Relays, require authorization to prevent unauthorized subscriptions to content. Subscription requests can - carry authorization tokens (see Section 13.3) to prove the + carry authorization tokens (see Section 15.3) to prove the subscriber's right to access specific tracks or namespaces. Relays that aggregate subscriptions from multiple downstream subscribers MUST ensure each subscriber is independently authorized. -13.1. Subscription Amplification +15.1. Subscription Amplification A malicious subscriber could attempt to overwhelm a publisher or relay by requesting subscriptions to many tracks simultaneously. @@ -6814,14 +7150,14 @@ Internet-Draft moq-transport August 2026 TODO: Describe Cache Poisoning attacks -13.2. Communication Security +15.2. Communication Security MOQT depends on a secure transport to provide confidentiality, integrity and endpoint authentication between subscriber and publisher. Implementations use QUIC or WebTransport to fulfill the basic communication security requirements and these implementations SHOULD follow best practices for TLS 1.3 and QUIC. Relays MUST use - authentication to prevent impersonation (Section 13.3.3). + authentication to prevent impersonation (Section 15.3.3). @@ -6829,9 +7165,9 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 122] +Nandakumar, et al. Expires 4 April 2027 [Page 128] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 Note that the basic security protection offered by QUIC or TCP/TLS @@ -6839,14 +7175,14 @@ Internet-Draft moq-transport August 2026 request messages, etc can make it possible for a third party observer to identify media content, user patterns and media stream origin. -13.3. Authorization +15.3. Authorization MOQT supports authorization via mutual TLS (mTLS) for endpoint identification and via token-based schemes for fine-grained, application-defined access control. The two mechanisms can be used together. -13.3.1. Mutual TLS +15.3.1. Mutual TLS In mutual TLS, both peers present an X.509 certificate during the TLS 1.3 handshake ([RFC8446]), carried in the underlying transport. An @@ -6871,7 +7207,7 @@ Internet-Draft moq-transport August 2026 perform and access. Relays will verify the token to ensure that the request is authorized. -13.3.2. Replay Attacks +15.3.2. Replay Attacks Replay protection for authorization tokens is the responsibility of the specific token scheme used. Token schemes such as [CAT] and @@ -6885,12 +7221,12 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 123] +Nandakumar, et al. Expires 4 April 2027 [Page 129] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 -13.3.3. Preventing Impersonation +15.3.3. Preventing Impersonation A relay MUST ensure that a client cannot publish to namespaces or tracks belonging to another identity. Impersonation occurs when a @@ -6916,7 +7252,7 @@ Internet-Draft moq-transport August 2026 client to inject content into arbitrary namespaces, breaking the integrity of content delivery. -13.4. Media Security +15.4. Media Security MOQT uses secure transports that provide confidentiality and integrity protection. However, media objects are accessible to @@ -6941,9 +7277,9 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 124] +Nandakumar, et al. Expires 4 April 2027 [Page 130] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 Consistent with the principle of confidential operation by default, @@ -6959,7 +7295,7 @@ Internet-Draft moq-transport August 2026 encryption system and deployment, and outside the scope of this document. -13.5. Resource Exhaustion +15.5. Resource Exhaustion Live content requires significant bandwidth and resources. Failure to set limits will quickly cause resource exhaustion. @@ -6977,14 +7313,14 @@ Internet-Draft moq-transport August 2026 publisher and subscriber MUST cancel a stream, preferably the one with the lowest priority, after reaching a resource limit. -13.6. Timeouts +15.6. Timeouts Implementations are advised to use timeouts to prevent resource exhaustion attacks by a peer that does not send expected data within an expected time. Each implementation is expected to set its own timeouts. -13.6.1. Idle Connection Handling +15.6.1. Idle Connection Handling The transport connection (e.g., QUIC) underlying a MOQT session can close due to idle timeout if no data is exchanged, either because @@ -6997,9 +7333,9 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 125] +Nandakumar, et al. Expires 4 April 2027 [Page 131] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 Implementations that want to keep idle sessions open have several @@ -7016,9 +7352,9 @@ Internet-Draft moq-transport August 2026 The choice of mechanism is implementation-specific. -13.7. Relay security considerations +15.7. Relay security considerations -13.7.1. State maintenance +15.7.1. State maintenance A Relay SHOULD have mechanisms to prevent malicious endpoints from flooding it with PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, or @@ -7027,7 +7363,7 @@ Internet-Draft moq-transport August 2026 have application-specific policies that can reject incoming requests that cause the state maintenance for the session to be excessive. -13.7.2. SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS with short prefixes +15.7.2. SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS with short prefixes A Relay can use authorization rules in order to prevent subscriptions closer to the root of a large prefix tree. Otherwise, if an entity @@ -7037,12 +7373,12 @@ Internet-Draft moq-transport August 2026 namespaces, the relay would have to send matching NAMESPACE/ NAMESPACE_DONE messages or initiate new PUBLISH streams. -13.8. Implementation Identification Fingerprinting +15.8. Implementation Identification Fingerprinting - The MOQT_IMPLEMENTATION option (Section 10.3.1.5) can reveal - information that contributes to fingerprinting, a set of techniques - for identifying a specific endpoint over time through its unique set - of characteristics. + The MOQT_IMPLEMENTATION option (Section 9.1.5) can reveal information + that contributes to fingerprinting, a set of techniques for + identifying a specific endpoint over time through its unique set of + characteristics. Detailed implementation information, including specific version numbers, build identifiers, or platform details, can create a unique @@ -7053,9 +7389,9 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 126] +Nandakumar, et al. Expires 4 April 2027 [Page 132] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 To mitigate fingerprinting risks: @@ -7078,68 +7414,17 @@ Internet-Draft moq-transport August 2026 facilitates the same privacy concerns as persistent identifiers, since it enables correlation of sessions across time. -13.9. Logging of Untrusted String Fields - - The Reason Phrase (Section 1.4.4) and MOQT_IMPLEMENTATION option - (Section 10.3.1.5) carry sender-controlled text that is commonly - written to logs. Even though these fields are UTF-8 encoded, an - endpoint that logs or renders them SHOULD sanitize them first (for - example, by escaping bytes outside the printable ASCII range), since - unsanitized values can enable log injection or terminal escape - sequence injection. - -14. Grease - - To ensure that implementations correctly handle unknown values and do - not fail when encountering protocol extensions they do not - understand, this document reserves a range of values for the purpose - of greasing; see Section 3.3 of [RFC9170]. - - Grease values follow the pattern 0x7f * N + 0x9D for non-negative - integer values of N (that is, 0x9D, 0x11C, ..., 0x3fffffffffffffde). - - The following registries include GREASE reservations: - - * Setup Options (Section 15.4) - - * Properties (Section 15.8) - - * Session Termination Error Codes (Section 15.11.1) - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 127] - -Internet-Draft moq-transport August 2026 - - - * REQUEST_ERROR Codes (Section 15.11.2) - - * PUBLISH_DONE Codes (Section 15.11.3) +15.9. Logging of Untrusted String Fields - * Stream Reset Error Codes (Section 15.11.4) + The Reason Phrase (Section 8.5) and MOQT_IMPLEMENTATION option + (Section 9.1.5) carry sender-controlled text that is commonly written + to logs. Even though these fields are UTF-8 encoded, an endpoint + that logs or renders them SHOULD sanitize them first (for example, by + escaping bytes outside the printable ASCII range), since unsanitized + values can enable log injection or terminal escape sequence + injection. - * MOQT Auth Token Type - - Because new values in these registries can be defined without - negotiation, implementations MUST handle unknown values gracefully. - Endpoints MUST NOT close the session solely because they received an - unknown value. The following rules apply: - - Setup Options with reserved identifiers have no semantics and can - carry arbitrary values. Endpoints MUST ignore unknown Setup Options - as specified in Section 10.3. - - Unknown Properties MUST be handled as specified in Section 2.5. - - Receipt of an unknown error code in any error context (Session - Termination, REQUEST_ERROR, PUBLISH_DONE, or Data Stream Reset) MUST - be treated as equivalent to INTERNAL_ERROR for that context. An - endpoint MUST NOT close the session because it received an unknown - error code in a REQUEST_ERROR or PUBLISH_DONE. - -15. IANA Considerations +16. IANA Considerations TODO: fill out currently missing registries: @@ -7149,26 +7434,27 @@ Internet-Draft moq-transport August 2026 * Session-Level Track Names -15.1. URI Scheme Registrations +16.1. URI Scheme Registrations This document requests the registration of the following URI schemes in the "Uniform Resource Identifier (URI) Schemes" registry, per [RFC7595]: -15.1.1. "moqt" URI Scheme Registration - Scheme name: moqt - Status: Permanent +Nandakumar, et al. Expires 4 April 2027 [Page 133] + +Internet-Draft moq-transport October 2026 + +16.1.1. "moqt" URI Scheme Registration -Nandakumar, et al. Expires 4 March 2027 [Page 128] - -Internet-Draft moq-transport August 2026 + Scheme name: moqt + Status: Permanent Applications/protocols that use this scheme name: Media over QUIC Transport (MOQT) over native QUIC or WebTransport, as defined in this @@ -7180,7 +7466,7 @@ Internet-Draft moq-transport August 2026 References: This document -15.2. Media Type Registration +16.2. Media Type Registration This document registers the following media type in the "Media Types" registry [RFC6838]: @@ -7208,29 +7494,27 @@ Internet-Draft moq-transport August 2026 Applications that use this media type: Implementations of the Media over QUIC Transport (MOQT) protocol. - Fragment identifier considerations: Fragment identifiers for - application/moqt follow the syntax defined in Section 3.1.2. - - Additional information: N/A - - Contact: IETF MoQ Working Group (moq@ietf.org) - - Change controller: IETF - + Fragment identifier considerations: Fragment identifiers for + application/moqt follow the syntax defined in Section 6.1.1. + Additional information: N/A -Nandakumar, et al. Expires 4 March 2027 [Page 129] +Nandakumar, et al. Expires 4 April 2027 [Page 134] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 + + + Contact: IETF MoQ Working Group (moq@ietf.org) + Change controller: IETF -15.3. MOQT URI Fragment Types +16.3. MOQT URI Fragment Types This document establishes the "MOQT URI Fragment Types" registry. This registry governs fragment type identifiers used in moqt URI - fragments as defined in Section 3.1.2. + fragments as defined in Section 6.1.1. New fragment type identifiers are registered using the Specification Required policy ([RFC8126], Section 4.6). @@ -7242,44 +7526,40 @@ Internet-Draft moq-transport August 2026 This registry is initially empty. -15.4. Setup Options - - +=================+===========================+==================+ - | Type | Name | Specification | - +=================+===========================+==================+ - | 0x01 | PATH | Section 10.3.1.2 | - +-----------------+---------------------------+------------------+ - | 0x03 | AUTHORIZATION_TOKEN | Section 10.3.1.4 | - +-----------------+---------------------------+------------------+ - | 0x04 | MAX_AUTH_TOKEN_CACHE_SIZE | Section 10.3.1.3 | - +-----------------+---------------------------+------------------+ - | 0x05 | AUTHORITY | Section 10.3.1.1 | - +-----------------+---------------------------+------------------+ - | 0x06 | MAX_FILTER_RANGES | Section 10.3.1.6 | - +-----------------+---------------------------+------------------+ - | 0x07 | MOQT_IMPLEMENTATION | Section 10.3.1.5 | - +-----------------+---------------------------+------------------+ - | 0x08 | MAX_REQUEST_UPDATES | Section 10.3.1.7 | - +-----------------+---------------------------+------------------+ - | 0x7f * N + 0x9D | Reserved for greasing | Section 14 | - +-----------------+---------------------------+------------------+ +16.4. Setup Options + + +=================+===========================+===============+ + | Type | Name | Specification | + +=================+===========================+===============+ + | 0x01 | PATH | Section 9.1.2 | + +-----------------+---------------------------+---------------+ + | 0x03 | AUTHORIZATION_TOKEN | Section 9.1.4 | + +-----------------+---------------------------+---------------+ + | 0x04 | MAX_AUTH_TOKEN_CACHE_SIZE | Section 9.1.3 | + +-----------------+---------------------------+---------------+ + | 0x05 | AUTHORITY | Section 9.1.1 | + +-----------------+---------------------------+---------------+ + | 0x06 | MAX_FILTER_RANGES | Section 9.1.6 | + +-----------------+---------------------------+---------------+ + | 0x07 | MOQT_IMPLEMENTATION | Section 9.1.5 | + +-----------------+---------------------------+---------------+ + | 0x08 | MAX_REQUEST_UPDATES | Section 9.1.7 | + +-----------------+---------------------------+---------------+ + | 0x7f * N + 0x9D | Reserved for greasing | Section 13 | + +-----------------+---------------------------+---------------+ - Table 10 + Table 11 Endpoints MUST ignore unknown Setup Options as specified in - Section 10.3. + Section 9.1. - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 130] +Nandakumar, et al. Expires 4 April 2027 [Page 135] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 New Setup Option types are registered using the Specification @@ -7289,133 +7569,133 @@ Internet-Draft moq-transport August 2026 private or application-specific use; implementations that need custom Setup Options SHOULD request a provisional registration. -15.5. Authorization Token Alias Type +16.5. Authorization Token Alias Type - +======+===========+================+ - | Code | Name | Specification | - +======+===========+================+ - | 0x0 | DELETE | Section 10.2.2 | - +------+-----------+----------------+ - | 0x1 | REGISTER | Section 10.2.2 | - +------+-----------+----------------+ - | 0x2 | USE_ALIAS | Section 10.2.2 | - +------+-----------+----------------+ - | 0x3 | USE_VALUE | Section 10.2.2 | - +------+-----------+----------------+ + +======+===========+===============+ + | Code | Name | Specification | + +======+===========+===============+ + | 0x0 | DELETE | Section 8.9 | + +------+-----------+---------------+ + | 0x1 | REGISTER | Section 8.9 | + +------+-----------+---------------+ + | 0x2 | USE_ALIAS | Section 8.9 | + +------+-----------+---------------+ + | 0x3 | USE_VALUE | Section 8.9 | + +------+-----------+---------------+ - Table 11 + Table 12 -15.6. MOQT Auth Token Type +16.6. MOQT Auth Token Type - +=================+=======================+================+ - | Code | Name | Specification | - +=================+=======================+================+ - | 0x0 | Reserved | Section 10.2.2 | - +-----------------+-----------------------+----------------+ - | 0x7f * N + 0x9D | Reserved for greasing | Section 14 | - +-----------------+-----------------------+----------------+ + +=================+=======================+===============+ + | Code | Name | Specification | + +=================+=======================+===============+ + | 0x0 | Reserved | Section 8.9 | + +-----------------+-----------------------+---------------+ + | 0x7f * N + 0x9D | Reserved for greasing | Section 13 | + +-----------------+-----------------------+---------------+ - Table 12 + Table 13 -15.7. Message Parameters +16.7. Message Parameters +================+===========================+=================+ | Parameter Type | Parameter Name | Specification | +================+===========================+=================+ - | 0x02 | OBJECT_DELIVERY_TIMEOUT | Section 10.2.4 | + | 0x02 | OBJECT_DELIVERY_TIMEOUT | Section 9.20.4 | +----------------+---------------------------+-----------------+ - | 0x03 | AUTHORIZATION_TOKEN | Section 10.2.2 | + | 0x03 | AUTHORIZATION_TOKEN | Section 9.20.2 | +----------------+---------------------------+-----------------+ - | 0x04 | RENDEZVOUS_TIMEOUT | Section 10.2.6 | + | 0x04 | RENDEZVOUS_TIMEOUT | Section 9.20.6 | +----------------+---------------------------+-----------------+ - | 0x06 | SUBGROUP_DELIVERY_TIMEOUT | Section 10.2.3 | + | 0x06 | SUBGROUP_DELIVERY_TIMEOUT | Section 9.20.3 | +----------------+---------------------------+-----------------+ -Nandakumar, et al. Expires 4 March 2027 [Page 131] +Nandakumar, et al. Expires 4 April 2027 [Page 136] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - | 0x08 | EXPIRES | Section 10.2.16 | + | 0x08 | EXPIRES | Section 9.20.16 | +----------------+---------------------------+-----------------+ - | 0x09 | LARGEST_OBJECT | Section 10.2.17 | + | 0x09 | LARGEST_OBJECT | Section 9.20.17 | +----------------+---------------------------+-----------------+ - | 0x0A | FILL_TIMEOUT | Section 10.2.5 | + | 0x0A | FILL_TIMEOUT | Section 9.20.5 | +----------------+---------------------------+-----------------+ - | 0x10 | FORWARD | Section 10.2.18 | + | 0x10 | FORWARD | Section 9.20.18 | +----------------+---------------------------+-----------------+ - | 0x20 | SUBSCRIBER_PRIORITY | Section 10.2.7 | + | 0x20 | SUBSCRIBER_PRIORITY | Section 9.20.7 | +----------------+---------------------------+-----------------+ - | 0x21 | LOCATION_FILTER | Section 10.2.9 | + | 0x21 | LOCATION_FILTER | Section 9.20.9 | +----------------+---------------------------+-----------------+ - | 0x22 | GROUP_ORDER | Section 10.2.8 | + | 0x22 | GROUP_ORDER | Section 9.20.8 | +----------------+---------------------------+-----------------+ - | 0x23 | FILL_PARAMETERS | Section 10.2.15 | + | 0x23 | FILL_PARAMETERS | Section 9.20.15 | +----------------+---------------------------+-----------------+ - | 0x25 | SUBGROUP_FILTER | Section 10.2.10 | + | 0x25 | SUBGROUP_FILTER | Section 9.20.10 | +----------------+---------------------------+-----------------+ - | 0x26 | OBJECTID_FILTER | Section 10.2.11 | + | 0x26 | OBJECTID_FILTER | Section 9.20.11 | +----------------+---------------------------+-----------------+ - | 0x27 | PRIORITY_FILTER | Section 10.2.12 | + | 0x27 | PRIORITY_FILTER | Section 9.20.12 | +----------------+---------------------------+-----------------+ - | 0x28 | OBJECT_PROPERTY_FILTER | Section 10.2.13 | + | 0x28 | OBJECT_PROPERTY_FILTER | Section 9.20.13 | +----------------+---------------------------+-----------------+ - | 0x29 | TRACK_PROPERTY_FILTER | Section 10.2.14 | + | 0x29 | TRACK_PROPERTY_FILTER | Section 9.20.14 | +----------------+---------------------------+-----------------+ - | 0x32 | NEW_GROUP_REQUEST | Section 10.2.19 | + | 0x32 | NEW_GROUP_REQUEST | Section 9.20.19 | +----------------+---------------------------+-----------------+ - | 0x34 | TRACK_NAMESPACE_PREFIX | Section 10.2.20 | + | 0x34 | TRACK_NAMESPACE_PREFIX | Section 9.20.20 | +----------------+---------------------------+-----------------+ - | 0x35 | INCLUDE_PROPERTIES | Section 10.2.21 | + | 0x35 | INCLUDE_PROPERTIES | Section 9.20.21 | +----------------+---------------------------+-----------------+ - Table 13 + Table 14 * Message Parameters - List which params can be repeated in the table. -15.8. Properties +16.8. Properties +==========+===============================+========+===============+ | Type | Name | Scope | Specification | +==========+===============================+========+===============+ - | 0x02 | OBJECT_DELIVERY_TIMEOUT | Track, | Section 12.2 | + | 0x02 | OBJECT_DELIVERY_TIMEOUT | Track, | Section 10.2 | | | | Object | | +----------+-------------------------------+--------+---------------+ - | 0x04 | MAX_CACHE_DURATION | Track | Section 12.3 | + | 0x04 | MAX_CACHE_DURATION | Track | Section 10.3 | +----------+-------------------------------+--------+---------------+ -Nandakumar, et al. Expires 4 March 2027 [Page 132] +Nandakumar, et al. Expires 4 April 2027 [Page 137] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - | 0x06 | SUBGROUP_DELIVERY_TIMEOUT | Track, | Section 12.1 | + | 0x06 | SUBGROUP_DELIVERY_TIMEOUT | Track, | Section 10.1 | | | | Object | | +----------+-------------------------------+--------+---------------+ - | 0x0B | IMMUTABLE_PROPERTIES | Track, | Section 12.7 | + | 0x0B | IMMUTABLE_PROPERTIES | Track, | Section 10.7 | | | | Object | | +----------+-------------------------------+--------+---------------+ - | 0x0E | DEFAULT_PUBLISHER_PRIORITY | Track | Section 12.4 | + | 0x0E | DEFAULT_PUBLISHER_PRIORITY | Track | Section 10.4 | +----------+-------------------------------+--------+---------------+ - | 0x22 | DEFAULT_PUBLISHER_GROUP_ORDER | Track | Section 12.5 | + | 0x22 | DEFAULT_PUBLISHER_GROUP_ORDER | Track | Section 10.5 | +----------+-------------------------------+--------+---------------+ - | 0x30 | DYNAMIC_GROUPS | Track | Section 12.6 | + | 0x30 | DYNAMIC_GROUPS | Track | Section 10.6 | +----------+-------------------------------+--------+---------------+ - | 0x3C | PRIOR_GROUP_ID_GAP | Object | Section 12.8 | + | 0x3C | PRIOR_GROUP_ID_GAP | Object | Section 10.8 | +----------+-------------------------------+--------+---------------+ - | 0x3E | PRIOR_OBJECT_ID_GAP | Object | Section 12.9 | + | 0x3E | PRIOR_OBJECT_ID_GAP | Object | Section 10.9 | +----------+-------------------------------+--------+---------------+ - | 0x7f | Reserved for greasing | Any | Section 14 | + | 0x7f | Reserved for greasing | Any | Section 13 | | * N + | | | | | 0x9D | | | | +----------+-------------------------------+--------+---------------+ - Table 14 + Table 15 The following table contains provisional registrations for other active drafts in the moq wg. These entries share the same Property @@ -7445,9 +7725,9 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 133] +Nandakumar, et al. Expires 4 April 2027 [Page 138] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 +====+=====================+======+===============================+ @@ -7473,7 +7753,7 @@ Internet-Draft moq-transport August 2026 |0x32| PADDING |Object| draft-ietf-moq-secure-objects | +----+---------------------+------+-------------------------------+ - Table 15 + Table 16 Endpoints MUST ignore unknown Property types, skipping them according to the Key-Value-Pair encoding; odd types use their length field, @@ -7494,16 +7774,16 @@ Internet-Draft moq-transport August 2026 encoding, no registration permitted) - 0x4000 to 0x7FFF: Reserved for Mandatory Track Properties (see - Section 2.5.1). Properties registered in this range MUST have + Section 3.7). Properties registered in this range MUST have Track scope; Object scope properties MUST NOT be registered in this range. -Nandakumar, et al. Expires 4 March 2027 [Page 134] +Nandakumar, et al. Expires 4 April 2027 [Page 139] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - 0x8000 and above: First Come First Served @@ -7514,32 +7794,32 @@ Internet-Draft moq-transport August 2026 from uncoordinated sources may encounter different semantics for the same code points, creating potential collision risks. -15.9. Object Status +16.9. Object Status This document establishes a registry for Object Status values (see - Section 11.2.1.1). The "Payload" column indicates whether an Object + Section 11.1.1). The "Payload" column indicates whether an Object with that status is permitted to carry a non-empty payload. - +======+==============+=========+==================+ - | Code | Name | Payload | Specification | - +======+==============+=========+==================+ - | 0x0 | Normal | Yes | Section 11.2.1.1 | - +------+--------------+---------+------------------+ - | 0x3 | End of Group | No | Section 11.2.1.1 | - +------+--------------+---------+------------------+ - | 0x4 | End of Track | No | Section 11.2.1.1 | - +------+--------------+---------+------------------+ + +======+==============+=========+================+ + | Code | Name | Payload | Specification | + +======+==============+=========+================+ + | 0x0 | Normal | Yes | Section 11.1.1 | + +------+--------------+---------+----------------+ + | 0x3 | End of Group | No | Section 11.1.1 | + +------+--------------+---------+----------------+ + | 0x4 | End of Track | No | Section 11.1.1 | + +------+--------------+---------+----------------+ - Table 16 + Table 17 New Object Status values are registered using the Specification Required policy ([RFC8126], Section 4.6). Each registration MUST indicate whether the status permits a payload. -15.10. Session-Level Track Names +16.10. Session-Level Track Names This document establishes a registry for session-level track names - under the .session namespace (see Section 3.2.2). The registration + under the .session namespace (see Section 6.5). The registration policy is Specification Required (per [RFC8126], Section 4.6). Each registration must include: @@ -7557,9 +7837,9 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 135] +Nandakumar, et al. Expires 4 April 2027 [Page 140] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 +=================+==================================+ @@ -7581,189 +7861,189 @@ Internet-Draft moq-transport August 2026 | | specification | +-----------------+----------------------------------+ - Table 17 + Table 18 This document does not define any initial entries. -15.11. Error Codes +16.11. Error Codes -15.11.1. Session Termination Error Codes +16.11.1. Session Termination Error Codes +============================+=================+===============+ | Name | Code | Specification | +============================+=================+===============+ - | NO_ERROR | 0x0 | Section 3.5 | + | NO_ERROR | 0x0 | Section 12.2 | +----------------------------+-----------------+---------------+ - | INTERNAL_ERROR | 0x1 | Section 3.5 | + | INTERNAL_ERROR | 0x1 | Section 12.2 | +----------------------------+-----------------+---------------+ - | UNAUTHORIZED | 0x2 | Section 3.5 | + | UNAUTHORIZED | 0x2 | Section 12.2 | +----------------------------+-----------------+---------------+ - | PROTOCOL_VIOLATION | 0x3 | Section 3.5 | + | PROTOCOL_VIOLATION | 0x3 | Section 12.2 | +----------------------------+-----------------+---------------+ - | INVALID_REQUEST_ID | 0x4 | Section 3.5 | + | INVALID_REQUEST_ID | 0x4 | Section 12.2 | +----------------------------+-----------------+---------------+ - | DUPLICATE_TRACK_ALIAS | 0x5 | Section 3.5 | + | DUPLICATE_TRACK_ALIAS | 0x5 | Section 12.2 | +----------------------------+-----------------+---------------+ - | KEY_VALUE_FORMATTING_ERROR | 0x6 | Section 3.5 | + | KEY_VALUE_FORMATTING_ERROR | 0x6 | Section 12.2 | +----------------------------+-----------------+---------------+ - | INVALID_PATH | 0x8 | Section 3.5 | + | INVALID_PATH | 0x8 | Section 12.2 | +----------------------------+-----------------+---------------+ - | MALFORMED_PATH | 0x9 | Section 3.5 | + | MALFORMED_PATH | 0x9 | Section 12.2 | +----------------------------+-----------------+---------------+ -Nandakumar, et al. Expires 4 March 2027 [Page 136] +Nandakumar, et al. Expires 4 April 2027 [Page 141] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - | GOAWAY_TIMEOUT | 0x10 | Section 3.5 | + | GOAWAY_TIMEOUT | 0x10 | Section 12.2 | +----------------------------+-----------------+---------------+ - | CONTROL_MESSAGE_TIMEOUT | 0x11 | Section 3.5 | + | CONTROL_MESSAGE_TIMEOUT | 0x11 | Section 12.2 | +----------------------------+-----------------+---------------+ - | DATA_STREAM_TIMEOUT | 0x12 | Section 3.5 | + | DATA_STREAM_TIMEOUT | 0x12 | Section 12.2 | +----------------------------+-----------------+---------------+ - | AUTH_TOKEN_CACHE_OVERFLOW | 0x13 | Section 3.5 | + | AUTH_TOKEN_CACHE_OVERFLOW | 0x13 | Section 12.2 | +----------------------------+-----------------+---------------+ - | DUPLICATE_AUTH_TOKEN_ALIAS | 0x14 | Section 3.5 | + | DUPLICATE_AUTH_TOKEN_ALIAS | 0x14 | Section 12.2 | +----------------------------+-----------------+---------------+ - | MALFORMED_AUTH_TOKEN | 0x16 | Section 3.5 | + | MALFORMED_AUTH_TOKEN | 0x16 | Section 12.2 | +----------------------------+-----------------+---------------+ - | UNKNOWN_AUTH_TOKEN_ALIAS | 0x17 | Section 3.5 | + | UNKNOWN_AUTH_TOKEN_ALIAS | 0x17 | Section 12.2 | +----------------------------+-----------------+---------------+ - | EXPIRED_AUTH_TOKEN | 0x18 | Section 3.5 | + | EXPIRED_AUTH_TOKEN | 0x18 | Section 12.2 | +----------------------------+-----------------+---------------+ - | INVALID_AUTHORITY | 0x19 | Section 3.5 | + | INVALID_AUTHORITY | 0x19 | Section 12.2 | +----------------------------+-----------------+---------------+ - | MALFORMED_AUTHORITY | 0x1A | Section 3.5 | + | MALFORMED_AUTHORITY | 0x1A | Section 12.2 | +----------------------------+-----------------+---------------+ - | TOO_MANY_REQUEST_UPDATES | 0x1B | Section 3.5 | + | TOO_MANY_REQUEST_UPDATES | 0x1B | Section 12.2 | +----------------------------+-----------------+---------------+ - | Reserved for greasing | 0x7f * N + 0x9D | Section 14 | + | Reserved for greasing | 0x7f * N + 0x9D | Section 13 | +----------------------------+-----------------+---------------+ - Table 18 + Table 19 -15.11.2. REQUEST_ERROR Codes +16.11.2. REQUEST_ERROR Codes +=======================+=================+===============+ | Name | Code | Specification | +=======================+=================+===============+ - | INTERNAL_ERROR | 0x0 | Section 10.6 | + | INTERNAL_ERROR | 0x0 | Section 12.3 | +-----------------------+-----------------+---------------+ - | UNAUTHORIZED | 0x1 | Section 10.6 | + | UNAUTHORIZED | 0x1 | Section 12.3 | +-----------------------+-----------------+---------------+ - | TIMEOUT | 0x2 | Section 10.6 | + | TIMEOUT | 0x2 | Section 12.3 | +-----------------------+-----------------+---------------+ - | NOT_SUPPORTED | 0x3 | Section 10.6 | + | NOT_SUPPORTED | 0x3 | Section 12.3 | +-----------------------+-----------------+---------------+ - | MALFORMED_AUTH_TOKEN | 0x4 | Section 10.6 | + | MALFORMED_AUTH_TOKEN | 0x4 | Section 12.3 | +-----------------------+-----------------+---------------+ - | EXPIRED_AUTH_TOKEN | 0x5 | Section 10.6 | + | EXPIRED_AUTH_TOKEN | 0x5 | Section 12.3 | +-----------------------+-----------------+---------------+ - | GOING_AWAY | 0x6 | Section 10.6 | + | GOING_AWAY | 0x6 | Section 12.3 | +-----------------------+-----------------+---------------+ - | EXCESSIVE_LOAD | 0x9 | Section 10.6 | + | EXCESSIVE_LOAD | 0x9 | Section 12.3 | +-----------------------+-----------------+---------------+ -Nandakumar, et al. Expires 4 March 2027 [Page 137] +Nandakumar, et al. Expires 4 April 2027 [Page 142] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - | DOES_NOT_EXIST | 0x10 | Section 10.6 | + | DOES_NOT_EXIST | 0x10 | Section 12.3 | +-----------------------+-----------------+---------------+ - | INVALID_RANGE | 0x11 | Section 10.6 | + | INVALID_RANGE | 0x11 | Section 12.3 | +-----------------------+-----------------+---------------+ - | MALFORMED_TRACK | 0x12 | Section 10.6 | + | MALFORMED_TRACK | 0x12 | Section 12.3 | +-----------------------+-----------------+---------------+ - | UNINTERESTED | 0x20 | Section 10.6 | + | UNINTERESTED | 0x20 | Section 12.3 | +-----------------------+-----------------+---------------+ - | PREFIX_OVERLAP | 0x30 | Section 10.6 | + | PREFIX_OVERLAP | 0x30 | Section 12.3 | +-----------------------+-----------------+---------------+ - | NAMESPACE_TOO_LARGE | 0x31 | Section 10.6 | + | NAMESPACE_TOO_LARGE | 0x31 | Section 12.3 | +-----------------------+-----------------+---------------+ - | UNSUPPORTED_EXTENSION | 0x33 | Section 10.6 | + | UNSUPPORTED_EXTENSION | 0x33 | Section 12.3 | +-----------------------+-----------------+---------------+ - | REDIRECT | 0x34 | Section 10.6 | + | REDIRECT | 0x34 | Section 12.3 | +-----------------------+-----------------+---------------+ - | CONFLICTING_FILTERS | 0x35 | Section 10.6 | + | CONFLICTING_FILTERS | 0x35 | Section 12.3 | +-----------------------+-----------------+---------------+ - | INVALID_FILTER | 0x36 | Section 10.6 | + | INVALID_FILTER | 0x36 | Section 12.3 | +-----------------------+-----------------+---------------+ - | Reserved for greasing | 0x7f * N + 0x9D | Section 14 | + | Reserved for greasing | 0x7f * N + 0x9D | Section 13 | +-----------------------+-----------------+---------------+ - Table 19 + Table 20 -15.11.3. PUBLISH_DONE Codes +16.11.3. PUBLISH_DONE Codes +=======================+=================+===============+ | Name | Code | Specification | +=======================+=================+===============+ - | INTERNAL_ERROR | 0x0 | Section 10.12 | + | INTERNAL_ERROR | 0x0 | Section 12.4 | +-----------------------+-----------------+---------------+ - | UNAUTHORIZED | 0x1 | Section 10.12 | + | UNAUTHORIZED | 0x1 | Section 12.4 | +-----------------------+-----------------+---------------+ - | TRACK_ENDED | 0x2 | Section 10.12 | + | TRACK_ENDED | 0x2 | Section 12.4 | +-----------------------+-----------------+---------------+ - | GOING_AWAY | 0x4 | Section 10.12 | + | GOING_AWAY | 0x4 | Section 12.4 | +-----------------------+-----------------+---------------+ - | TOO_FAR_BEHIND | 0x5 | Section 10.12 | + | TOO_FAR_BEHIND | 0x5 | Section 12.4 | +-----------------------+-----------------+---------------+ - | EXPIRED | 0x6 | Section 10.12 | + | EXPIRED | 0x6 | Section 12.4 | +-----------------------+-----------------+---------------+ - | UPDATE_FAILED | 0x8 | Section 10.12 | + | UPDATE_FAILED | 0x8 | Section 12.4 | +-----------------------+-----------------+---------------+ - | EXCESSIVE_LOAD | 0x9 | Section 10.12 | + | EXCESSIVE_LOAD | 0x9 | Section 12.4 | +-----------------------+-----------------+---------------+ - | MALFORMED_TRACK | 0x12 | Section 10.12 | + | MALFORMED_TRACK | 0x12 | Section 12.4 | +-----------------------+-----------------+---------------+ -Nandakumar, et al. Expires 4 March 2027 [Page 138] +Nandakumar, et al. Expires 4 April 2027 [Page 143] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 - | Reserved for greasing | 0x7f * N + 0x9D | Section 14 | + | Reserved for greasing | 0x7f * N + 0x9D | Section 13 | +-----------------------+-----------------+---------------+ - Table 20 + Table 21 -15.11.4. Stream Reset Error Codes +16.11.4. Stream Reset Error Codes +=======================+=================+===============+ | Name | Code | Specification | +=======================+=================+===============+ - | INTERNAL_ERROR | 0x0 | Section 3.3.4 | + | INTERNAL_ERROR | 0x0 | Section 12.5 | +-----------------------+-----------------+---------------+ - | CANCELLED | 0x1 | Section 3.3.4 | + | CANCELLED | 0x1 | Section 12.5 | +-----------------------+-----------------+---------------+ - | DELIVERY_TIMEOUT | 0x2 | Section 3.3.4 | + | DELIVERY_TIMEOUT | 0x2 | Section 12.5 | +-----------------------+-----------------+---------------+ - | SESSION_CLOSED | 0x3 | Section 3.3.4 | + | SESSION_CLOSED | 0x3 | Section 12.5 | +-----------------------+-----------------+---------------+ - | GOING_AWAY | 0x4 | Section 3.3.4 | + | GOING_AWAY | 0x4 | Section 12.5 | +-----------------------+-----------------+---------------+ - | TOO_FAR_BEHIND | 0x5 | Section 3.3.4 | + | TOO_FAR_BEHIND | 0x5 | Section 12.5 | +-----------------------+-----------------+---------------+ - | UNKNOWN_OBJECT_STATUS | 0x6 | Section 3.3.4 | + | UNKNOWN_OBJECT_STATUS | 0x6 | Section 12.5 | +-----------------------+-----------------+---------------+ - | EXPIRED_AUTH_TOKEN | 0x7 | Section 3.3.4 | + | EXPIRED_AUTH_TOKEN | 0x7 | Section 12.5 | +-----------------------+-----------------+---------------+ - | EXCESSIVE_LOAD | 0x9 | Section 3.3.4 | + | EXCESSIVE_LOAD | 0x9 | Section 12.5 | +-----------------------+-----------------+---------------+ - | MALFORMED_TRACK | 0x12 | Section 3.3.4 | + | MALFORMED_TRACK | 0x12 | Section 12.5 | +-----------------------+-----------------+---------------+ - | Reserved for greasing | 0x7f * N + 0x9D | Section 14 | + | Reserved for greasing | 0x7f * N + 0x9D | Section 13 | +-----------------------+-----------------+---------------+ - Table 21 + Table 22 Contributors @@ -7781,9 +8061,9 @@ Contributors -Nandakumar, et al. Expires 4 March 2027 [Page 139] +Nandakumar, et al. Expires 4 April 2027 [Page 144] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 * Ali Begen @@ -7823,9 +8103,9 @@ Normative References [I-D.draft-ietf-quic-reliable-stream-reset] Seemann, M. and K. Oku, "QUIC Stream Resets with Partial Delivery", Work in Progress, Internet-Draft, draft-ietf- - quic-reliable-stream-reset-10, 9 August 2026, + quic-reliable-stream-reset-11, 6 September 2026, . + reliable-stream-reset-11>. [I-D.ietf-webtrans-overview] Kinnear, E. and V. Vasiliev, "The WebTransport Protocol @@ -7837,9 +8117,9 @@ Normative References -Nandakumar, et al. Expires 4 March 2027 [Page 140] +Nandakumar, et al. Expires 4 April 2027 [Page 145] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 [QUIC] Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based @@ -7893,9 +8173,9 @@ Internet-Draft moq-transport August 2026 -Nandakumar, et al. Expires 4 March 2027 [Page 141] +Nandakumar, et al. Expires 4 April 2027 [Page 146] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 [RFC9221] Pauly, T., Kinnear, E., and D. Schinazi, "An Unreliable @@ -7949,9 +8229,9 @@ Informative References -Nandakumar, et al. Expires 4 March 2027 [Page 142] +Nandakumar, et al. Expires 4 April 2027 [Page 147] -Internet-Draft moq-transport August 2026 +Internet-Draft moq-transport October 2026 [I-D.ietf-moq-secure-objects] @@ -7965,9 +8245,16 @@ Internet-Draft moq-transport August 2026 Thomson, M., Huitema, C., Oku, K., Joras, M., and L. M. Ihlar, "Standard Communication with Network Elements (SCONE) Protocol", Work in Progress, Internet-Draft, - draft-ietf-scone-protocol-07, 20 August 2026, + draft-ietf-scone-protocol-09, 24 September 2026, . + protocol-09>. + + [I-D.ietf-webtrans-http2] + Frindell, A., Kinnear, E., Pauly, T., Thomson, M., + Vasiliev, V., and W. Xie, "WebTransport over HTTP/2", Work + in Progress, Internet-Draft, draft-ietf-webtrans-http2-15, + 6 July 2026, . [PPA] Nandakumar, S., Jennings, C. F., and T. Meunier, "Privacy Pass Authentication for Media over QUIC (MoQ)", Work in @@ -7994,6 +8281,15 @@ Internet-Draft moq-transport August 2026 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, . + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 148] + +Internet-Draft moq-transport October 2026 + + [RFC8470] Thomson, M., Nottingham, M., and W. Tarreau, "Using Early Data in HTTP", RFC 8470, DOI 10.17487/RFC8470, September 2018, . @@ -8003,13 +8299,6 @@ Internet-Draft moq-transport August 2026 DOI 10.17487/RFC9000, May 2021, . - - -Nandakumar, et al. Expires 4 March 2027 [Page 143] - -Internet-Draft moq-transport August 2026 - - [RFC9170] Thomson, M. and T. Pauly, "Long-Term Viability of Protocol Extension Mechanisms", RFC 9170, DOI 10.17487/RFC9170, December 2021, . @@ -8039,7 +8328,95 @@ Appendix A. Change Log Issue and pull request numbers are listed with a leading octothorp. -A.1. Since draft-ietf-moq-transport-19 +A.1. Since draft-ietf-moq-transport-21 + + *Session and Control Plane* + + * LOCATION_FILTER carries an explicit Location Filter Type that + selects which fields follow, replacing the length-inferred + encoding (#1913, #1953) + + *Notable Editorial Changes* + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 149] + +Internet-Draft moq-transport October 2026 + + + * Restructure Publisher and Namespace Discovery, add a Namespace + Prefix Matching section, and move SUBSCRIBE_TRACKS to Publishing + and Receiving Tracks (#1946) + + * Add a Fetch semantics section covering object delivery, gaps + (including Descending Group Order), and relay handling (#1895) + + * Rename Forwarding Preference to Delivery Mode, established by the + Original Publisher (#1886, #1891, #1914) + + * Describe the Forward State as a subscription being paused (#1940) + + * Define Subscription and Fetch (#1884, #1925) + + * Add per-request shorthand names for REQUEST_OK and REQUEST_ERROR, + e.g. SUBSCRIBE_ERROR (#1912) + + * List the allowed parameters in each control message (#1916) + + * Clarify that Largest Object can still be arriving and use it + consistently (#1911, #1918) + + * Clarify that FETCH_OK End Location is inclusive (#1910) + + * Clarify how extensions declare support in SETUP (#1921) + + * Scope the auth token cache overflow rule to non-SETUP + registrations (#1927) + + * Relay-to-relay communication is out of scope (#1931) + +A.2. Since draft-ietf-moq-transport-20 + + *Notable Editorial Changes* + + * Add a Document Structure section (#1903) + + * Move-only restructuring across the document (#1877) + + * Restructure and reorder Publishing and Receiving Tracks (#1885, + #1893) + + * Move Error Handling and Grease ahead of the considerations + sections (#1899) + + * Promote each Setup Option to its own section (#1896) + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 150] + +Internet-Draft moq-transport October 2026 + + + * Collect Session Termination, Request Error, and Publish Done codes + into Error Handling (#1879, #1880, #1881) + + * Extract common wire format sections: Authorization Token + Compression, Track Namespace, Location Filter, and Range Filter + (#1882, #1887, #1888, #1892) + + * Remove the Connection URL, Stream Cancellation, and Examples + sections (#1878) + + * Restructuring pull requests that also made editorial + clarifications are included as moves only; the clarifications are + deferred (#1887, #1888, #1892) + +A.3. Since draft-ietf-moq-transport-19 *Session and Control Plane* @@ -8058,14 +8435,6 @@ A.1. Since draft-ietf-moq-transport-19 * Add PUBLISH_STATE_NOTIFY message (#1820) - - - -Nandakumar, et al. Expires 4 March 2027 [Page 144] - -Internet-Draft moq-transport August 2026 - - * Add INCLUDE_PROPERTIES parameter (#1813, #1847) * PUBLISH can carry Subscription Parameters, and AUTHORIZATION TOKEN @@ -8080,6 +8449,15 @@ Internet-Draft moq-transport August 2026 does not end because Largest Object passes the end of the Location Filter (#1833) + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 151] + +Internet-Draft moq-transport October 2026 + + * Change the maximum Stream Count in PUBLISH_DONE to 2^64 - 1 (#1831) @@ -8113,15 +8491,6 @@ Internet-Draft moq-transport August 2026 bitfields; a set bit with no specified meaning is a PROTOCOL_VIOLATION (#1774) - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 145] - -Internet-Draft moq-transport August 2026 - - * Add End of Timed-Out Range for Objects abandoned when Fill Timeout expires (#1822) @@ -8137,6 +8506,14 @@ Internet-Draft moq-transport August 2026 * Add a Preventing Impersonation section (#1737, #1789) + + + +Nandakumar, et al. Expires 4 April 2027 [Page 152] + +Internet-Draft moq-transport October 2026 + + * Expand mutual TLS and authorization guidance (#1786) * Add moqt URI scheme security considerations (#1772) @@ -8157,7 +8534,7 @@ Internet-Draft moq-transport August 2026 * Fix LOC and Secure Objects entries in the provisional Property registry (#1807, #1818, #1848) -A.2. Since draft-ietf-moq-transport-18 +A.4. Since draft-ietf-moq-transport-18 *Session and Control Plane* @@ -8171,13 +8548,6 @@ A.2. Since draft-ietf-moq-transport-18 * Move GROUP_ORDER from PUBLISH_OK to SUBSCRIBE_TRACKS (#1777) - - -Nandakumar, et al. Expires 4 March 2027 [Page 146] - -Internet-Draft moq-transport August 2026 - - * Rename PUBLISH_BLOCKED to PUBLISH_SKIPPED (#1779) * Remove Request ID from GOAWAY (#1623) @@ -8191,6 +8561,15 @@ Internet-Draft moq-transport August 2026 * Update Forward State handling for relays (#1782) + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 153] + +Internet-Draft moq-transport October 2026 + + * Clarify authorization trust model for namespace subscriptions (#1656) @@ -8219,7 +8598,7 @@ Internet-Draft moq-transport August 2026 * Clarify Group and Subgroup terminology and object model (#1708) -A.3. Since draft-ietf-moq-transport-17 +A.5. Since draft-ietf-moq-transport-17 *Session and Control Plane* @@ -8227,13 +8606,6 @@ A.3. Since draft-ietf-moq-transport-17 * Add fragment identifier support for moqt URIs (#1571) - - -Nandakumar, et al. Expires 4 March 2027 [Page 147] - -Internet-Draft moq-transport August 2026 - - * Split SUBSCRIBE_NAMESPACE into SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS (#1542) @@ -8247,6 +8619,13 @@ Internet-Draft moq-transport August 2026 * Add Request ID to GOAWAY (#1559) + + +Nandakumar, et al. Expires 4 April 2027 [Page 154] + +Internet-Draft moq-transport October 2026 + + * Remove PUBLISH_OK message type, make it a REQUEST_OK alias (#1611) * Generalize stream reset codes to all request streams, add new @@ -8282,14 +8661,6 @@ Internet-Draft moq-transport August 2026 - Joining FETCH is unaffected by forward changing to 0 (#1620) - - - -Nandakumar, et al. Expires 4 March 2027 [Page 148] - -Internet-Draft moq-transport August 2026 - - - Joining Fetch forward state mismatch is a request error (#1609) - Clarify Joining Fetch ordering with Forward State transitions @@ -8304,6 +8675,13 @@ Internet-Draft moq-transport August 2026 * Split DELIVERY_TIMEOUT into two types of timeout (#1605) + + +Nandakumar, et al. Expires 4 April 2027 [Page 155] + +Internet-Draft moq-transport October 2026 + + * FILL_TIMEOUT parameter (#1490) * Forbid relays from lying about LARGEST_OBJECT (#1621) @@ -8339,16 +8717,9 @@ Internet-Draft moq-transport August 2026 * Add stream type column to message type table (#1555) - - -Nandakumar, et al. Expires 4 March 2027 [Page 149] - -Internet-Draft moq-transport August 2026 - - * Fix grease examples to match 0x7f multiplier (#1569) -A.4. Since draft-ietf-moq-transport-16 +A.6. Since draft-ietf-moq-transport-16 *Session and Control Plane* @@ -8360,6 +8731,13 @@ A.4. Since draft-ietf-moq-transport-16 * Move requests to bidirectional streams; remove cancel messages (#1389) + + +Nandakumar, et al. Expires 4 April 2027 [Page 156] + +Internet-Draft moq-transport October 2026 + + * Remove MAX_REQUEST_ID/REQUESTS_BLOCKED (#1471) * New variable-length integer encoding (#1016) @@ -8395,13 +8773,6 @@ A.4. Since draft-ietf-moq-transport-16 * Allow DELIVERY_TIMEOUT value of 0 to mean no timeout (#1450) - - -Nandakumar, et al. Expires 4 March 2027 [Page 150] - -Internet-Draft moq-transport August 2026 - - * Allow zero-element namespaces (#1472) * Clarify EXPIRES parameter update mechanism (#1448) @@ -8415,6 +8786,14 @@ Internet-Draft moq-transport August 2026 * Reserve Property type ranges for application-specific use (#1473) + + + +Nandakumar, et al. Expires 4 April 2027 [Page 157] + +Internet-Draft moq-transport October 2026 + + * Make EndGroup in Subscription Filters a delta (#1470) * Copy DELIVERY_TIMEOUT min requirement from parameter to property @@ -8450,21 +8829,13 @@ Internet-Draft moq-transport August 2026 * Add editorial text on bandwidth probing techniques (#1477) - - - -Nandakumar, et al. Expires 4 March 2027 [Page 151] - -Internet-Draft moq-transport August 2026 - - * Explain idle connection handling (#1443) * Fix "SUBSCRIBE_NAMESPACE with short prefixes" (#1502) * Add generative AI disclosure per IRTF guidelines -A.5. Since draft-ietf-moq-transport-15 +A.7. Since draft-ietf-moq-transport-15 *Setup and Control Plane* @@ -8472,6 +8843,13 @@ A.5. Since draft-ietf-moq-transport-15 * Use Request ID in PUBLISH_NAMESPACE_{DONE/CANCEL} (#1329) + + +Nandakumar, et al. Expires 4 April 2027 [Page 158] + +Internet-Draft moq-transport October 2026 + + * Remove delivery related params from TRACK_STATUS for Subscribers (#1325) @@ -8507,13 +8885,6 @@ A.5. Since draft-ietf-moq-transport-15 * Address Track Name/Namespace edge cases (#1399) - - -Nandakumar, et al. Expires 4 March 2027 [Page 152] - -Internet-Draft moq-transport August 2026 - - *Data Plane Wire Format and Handling* * Enable mixing datagrams with streams in one track (#1350) @@ -8528,6 +8899,13 @@ Internet-Draft moq-transport August 2026 * Do not reopen subgroups after delivery timeout or STOP_SENDING (#1396) + + +Nandakumar, et al. Expires 4 April 2027 [Page 159] + +Internet-Draft moq-transport October 2026 + + * Clarify handling of unknown extensions (#1395) * Clarify Delivery Timeout for datagrams (#1406) @@ -8549,7 +8927,7 @@ Internet-Draft moq-transport August 2026 * A Publisher might not use the congestion window (#1408) -A.6. Since draft-ietf-moq-transport-14 +A.8. Since draft-ietf-moq-transport-14 *Setup and Control Plane* @@ -8561,15 +8939,6 @@ A.6. Since draft-ietf-moq-transport-14 * Add Forward to SUBSCRIBE_NAMESPACE (#1220) - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 153] - -Internet-Draft moq-transport August 2026 - - * Parameters for Group Order, Subscribe Priority and Subscription Filter (redo) (#1273) @@ -8585,6 +8954,14 @@ Internet-Draft moq-transport August 2026 * Allow SUBSCRIBE_UPDATE to increase the end location (#1288) + + + +Nandakumar, et al. Expires 4 April 2027 [Page 160] + +Internet-Draft moq-transport October 2026 + + * Add default port for raw QUIC (#1289) * Unsubscribe Namespace should be linked to Subscribe Namespace @@ -8619,16 +8996,9 @@ Internet-Draft moq-transport August 2026 * Define duplication rules for header extensions (#1293) - - -Nandakumar, et al. Expires 4 March 2027 [Page 154] - -Internet-Draft moq-transport August 2026 - - * Clarify joining fetch end location (#1286) -A.7. Since draft-ietf-moq-transport-13 +A.9. Since draft-ietf-moq-transport-13 *Setup and Control Plane* @@ -8641,6 +9011,13 @@ A.7. Since draft-ietf-moq-transport-13 * Indicate which params can appear PUBLISH* messages (#1071) + + +Nandakumar, et al. Expires 4 April 2027 [Page 161] + +Internet-Draft moq-transport October 2026 + + * Add TRACK_STATUS to the list of request types affected by GOAWAY (#1105) @@ -8674,14 +9051,6 @@ A.7. Since draft-ietf-moq-transport-13 *Relay Handling* - - - -Nandakumar, et al. Expires 4 March 2027 [Page 155] - -Internet-Draft moq-transport August 2026 - - * Explain FETCH routing for relays (#1165) * MUST for multi-publisher relay handling (#1115) @@ -8698,6 +9067,13 @@ Internet-Draft moq-transport August 2026 * Explain how to resume publishing after losing state (#1087) + + +Nandakumar, et al. Expires 4 April 2027 [Page 162] + +Internet-Draft moq-transport October 2026 + + *Major Editorial Changes* * Rename ANNOUNCE to PUBLISH_NAMESPACE (#1104) @@ -8708,7 +9084,7 @@ Internet-Draft moq-transport August 2026 * Reformat Error Codes (#1091) -A.8. Since draft-ietf-moq-transport-12 +A.10. Since draft-ietf-moq-transport-12 * TRACK_STATUS_REQUEST and TRACK_STATUS have changed to directly mirror SUBSCRIBE/OK/ERROR (#1015) @@ -8716,7 +9092,7 @@ A.8. Since draft-ietf-moq-transport-12 * SUBSCRIBE_ANNOUNCES was renamed back to SUBSCRIBE_NAMESPACE (#1049) -A.9. Since draft-ietf-moq-transport-11 +A.11. Since draft-ietf-moq-transport-11 * Move Track Alias from SUBSCRIBE to SUBSCRIBE_OK (#977) @@ -8731,13 +9107,6 @@ A.9. Since draft-ietf-moq-transport-11 * Explain Malformed Tracks and what to do with them (#938) - - -Nandakumar, et al. Expires 4 March 2027 [Page 156] - -Internet-Draft moq-transport August 2026 - - * Allow End of Group to be indicated in a normal Object (#1011) * Relays MUST have an upstream subscription to send SUBSCRIBE_OK @@ -8749,11 +9118,18 @@ Internet-Draft moq-transport August 2026 * Add PUBLISH for publisher initiated subscriptions (#995) and fix the PUBLISH codepoints (#1048, #1051) -A.10. Since draft-ietf-moq-transport-10 +A.12. Since draft-ietf-moq-transport-10 * Added Common Structure definitions - Location, Key-Value-Pair and Reason Phrase + + +Nandakumar, et al. Expires 4 April 2027 [Page 163] + +Internet-Draft moq-transport October 2026 + + * Limit lengths of all variable length fields, including Track Namespace and Name @@ -8785,15 +9161,6 @@ A.10. Since draft-ietf-moq-transport-10 * Clarified No Error vs Invalid Range FETCH_ERROR cases - - - - -Nandakumar, et al. Expires 4 March 2027 [Page 157] - -Internet-Draft moq-transport August 2026 - - * Use bits in SUBGROUP_HEADER and DATAGRAM* types to compress subgroup ID and extensions @@ -8811,6 +9178,14 @@ Internet-Draft moq-transport August 2026 more structure, compression, and additional Auth related error codes (#760) + + + +Nandakumar, et al. Expires 4 April 2027 [Page 164] + +Internet-Draft moq-transport October 2026 + + Authors' Addresses Suhas Nandakumar @@ -8845,4 +9220,21 @@ Authors' Addresses -Nandakumar, et al. Expires 4 March 2027 [Page 158] + + + + + + + + + + + + + + + + + +Nandakumar, et al. Expires 4 April 2027 [Page 165] diff --git a/packages/spf/docs/moq-publishing.md b/packages/spf/docs/moq-publishing.md index 9866227aa8..4c2c8447ac 100644 --- a/packages/spf/docs/moq-publishing.md +++ b/packages/spf/docs/moq-publishing.md @@ -8,7 +8,7 @@ Your publisher and relay must serve the versions the subscriber speaks: | Layer | Version | What to serve | | --- | --- | --- | -| Transport | `draft-ietf-moq-transport-20`, protocol ID `moqt-20` | MOQT over WebTransport | +| Transport | `draft-ietf-moq-transport-22`, protocol ID `moqt-22` (`moqt-20` also accepted) | MOQT over WebTransport | | Catalog | `draft-ietf-moq-msf-01` | UTF-8 JSON on a catalog track | | Media | `draft-ietf-moq-loc-04` | One encoded audio or video chunk per MOQT object | diff --git a/packages/spf/package.json b/packages/spf/package.json index 0383c79e0f..c78b038449 100644 --- a/packages/spf/package.json +++ b/packages/spf/package.json @@ -79,7 +79,8 @@ "size:all": "node scripts/measure-size.js --all" }, "dependencies": { - "@caprid/moq-media": "^0.1.0", + "@caprid/moq-core": "^0.1.1", + "@caprid/moq-media": "^0.1.1", "@videojs/media": "workspace:*", "@videojs/utils": "workspace:*", "signal-polyfill": "^0.2.2" diff --git a/packages/spf/src/media/moq/loc.ts b/packages/spf/src/media/moq/loc.ts index 69e6095d7e..ded8e1d440 100644 --- a/packages/spf/src/media/moq/loc.ts +++ b/packages/spf/src/media/moq/loc.ts @@ -5,12 +5,12 @@ * WebCodecs `EncodedVideoChunk`/`EncodedAudioChunk`, and the object properties carry frame metadata (capture timestamp, * timescale, decoder config). * - * DOM-free and wire-free: properties come in as generic key/value pairs (structurally identical to `network/moqt`'s - * `KeyValuePair` — the layering keeps `media/` independent of `network/`, and structural typing lets the playback layer - * pass them straight through). + * DOM-free and wire-free: properties come in as generic key/value pairs (structurally identical to `@caprid/moq-core`'s + * `KeyValuePair` — the layering keeps `media/` free of the transport package, and structural typing lets the playback + * layer pass them straight through). */ -/** Structural twin of `network/moqt`'s `KeyValuePair`. */ +/** Structural twin of `@caprid/moq-core`'s `KeyValuePair`. */ export interface PropertyPair { type: number; value: number | Uint8Array; diff --git a/packages/spf/src/media/moq/parse-source.ts b/packages/spf/src/media/moq/parse-source.ts index 3df3913b4b..8634c439d1 100644 --- a/packages/spf/src/media/moq/parse-source.ts +++ b/packages/spf/src/media/moq/parse-source.ts @@ -26,7 +26,7 @@ export interface MoqNumericRange { export interface MoqSource { /** * WebTransport connect URL — the moqt URI with its scheme replaced by https and the fragment stripped (moq-transport - * §3.1.4). + * draft-22 §6.2.1). */ connectUrl: string; /** The moqt URI without its fragment — the session identity. */ @@ -51,7 +51,7 @@ export interface MoqSource { } // ============================================================================ -// MSF namespace-name string decoding (moq-transport §1.5) +// MSF namespace-name string decoding (moq-transport draft-22 §8.8) // ============================================================================ const LITERAL_CHAR = /^[a-zA-Z0-9_]$/; @@ -60,7 +60,7 @@ const LOWER_HEX = /^[0-9a-f]{2}$/; /** * Decode one MSF-encoded namespace field or track name: literal `[a-zA-Z0-9_]` bytes plus `.xx` lowercase-hex escapes * for every other UTF-8 byte (tuples are byte strings, §11.1.2). Rejects malformed and non-canonical encodings - * (uppercase hex, redundant escapes of literal characters, invalid UTF-8) per moq-transport §1.5.1. + * (uppercase hex, redundant escapes of literal characters, invalid UTF-8) per moq-transport draft-22 §8.8. */ function decodeNameComponent(encoded: string): string { const bytes: number[] = []; diff --git a/packages/spf/src/network/moqt/bytes.ts b/packages/spf/src/network/moqt/bytes.ts deleted file mode 100644 index a5f36e7c96..0000000000 --- a/packages/spf/src/network/moqt/bytes.ts +++ /dev/null @@ -1,249 +0,0 @@ -/** - * Byte-level readers/writers shared by the MOQT wire codecs. - * - * `ByteReader`/`ByteWriter` are synchronous cursors over in-memory buffers, used for control-message bodies (always - * fully buffered — the 16-bit message length bounds them). `StreamReader` is the asynchronous counterpart for - * unidirectional data streams, where headers and objects arrive incrementally over a WebTransport `ReadableStream`. - */ -import { decodeVarint, encodeVarintInto, varintByteLength, varintLengthFromFirstByte } from './varint'; - -const textEncoder = new TextEncoder(); -const textDecoder = new TextDecoder(); - -export function utf8Encode(value: string): Uint8Array { - return textEncoder.encode(value); -} - -export function utf8Decode(bytes: Uint8Array): string { - return textDecoder.decode(bytes); -} - -/** Synchronous cursor over a byte buffer. All reads throw `RangeError` past the end. */ -export class ByteReader { - #bytes: Uint8Array; - #offset: number; - - constructor(bytes: Uint8Array, offset = 0) { - this.#bytes = bytes; - this.#offset = offset; - } - - get offset(): number { - return this.#offset; - } - - get remaining(): number { - return this.#bytes.length - this.#offset; - } - - readVarint(): number { - const { value, byteLength } = decodeVarint(this.#bytes, this.#offset); - - this.#offset += byteLength; - return value; - } - - /** - * Read a count whose "unknown" sentinel is the maximal varint 2^64−1 — PUBLISH_DONE's Stream Count (§10.12). Exactly - * that sentinel reads as `undefined`; any other value above this codec's 2^53−1 ceiling is still the protocol error - * `readVarint` raises, since no real count gets there. - */ - readCountVarint(): number | undefined { - const offset = this.#offset; - - // 2^64−1 has one encoding: the 9-byte form with every bit set. - if (this.remaining >= 9 && this.#bytes.subarray(offset, offset + 9).every((byte) => byte === 0xff)) { - this.#offset += 9; - return undefined; - } - - return this.readVarint(); - } - - readUint8(): number { - if (this.remaining < 1) throw new RangeError('read past end of buffer'); - - return this.#bytes[this.#offset++]!; - } - - readUint16(): number { - if (this.remaining < 2) throw new RangeError('read past end of buffer'); - - const value = this.#bytes[this.#offset]! * 256 + this.#bytes[this.#offset + 1]!; - - this.#offset += 2; - return value; - } - - /** Returns a view (not a copy) of the next `length` bytes. */ - readBytes(length: number): Uint8Array { - if (length < 0 || this.remaining < length) throw new RangeError('read past end of buffer'); - - const view = this.#bytes.subarray(this.#offset, this.#offset + length); - - this.#offset += length; - return view; - } -} - -/** Growable byte sink for encoding wire structures. */ -export class ByteWriter { - #buffer: Uint8Array; - #length = 0; - - constructor(initialCapacity = 256) { - this.#buffer = new Uint8Array(initialCapacity); - } - - get length(): number { - return this.#length; - } - - #ensure(extra: number): void { - const needed = this.#length + extra; - if (needed <= this.#buffer.length) return; - - const grown = new Uint8Array(Math.max(needed, this.#buffer.length * 2)); - - grown.set(this.#buffer.subarray(0, this.#length)); - this.#buffer = grown; - } - - writeVarint(value: number): void { - this.#ensure(varintByteLength(value)); - this.#length += encodeVarintInto(this.#buffer, this.#length, value); - } - - writeUint8(value: number): void { - this.#ensure(1); - this.#buffer[this.#length++] = value & 0xff; - } - - writeUint16(value: number): void { - this.#ensure(2); - this.#buffer[this.#length++] = (value >> 8) & 0xff; - this.#buffer[this.#length++] = value & 0xff; - } - - writeBytes(bytes: Uint8Array): void { - this.#ensure(bytes.length); - this.#buffer.set(bytes, this.#length); - this.#length += bytes.length; - } - - /** Varint length prefix followed by the bytes. */ - writeLengthPrefixed(bytes: Uint8Array): void { - this.writeVarint(bytes.length); - this.writeBytes(bytes); - } - - /** Returns a copy of the written bytes. */ - toBytes(): Uint8Array { - return this.#buffer.slice(0, this.#length); - } -} - -/** - * Buffered asynchronous reader over a `ReadableStream`. - * - * Reads never split a varint or byte run: each method pulls chunks until it can satisfy the request. A clean - * end-of-stream mid-read throws `RangeError`; use `atEnd()` to probe for a clean boundary first. - */ -export class StreamReader { - #reader: ReadableStreamDefaultReader; - #chunks: Uint8Array[] = []; - #buffered = 0; - #done = false; - - constructor(stream: ReadableStream) { - this.#reader = stream.getReader(); - } - - async #pull(): Promise { - if (this.#done) return false; - - const { done, value } = await this.#reader.read(); - - if (done) { - this.#done = true; - return false; - } - - if (value.length > 0) { - this.#chunks.push(value); - this.#buffered += value.length; - } - - return true; - } - - async #fill(length: number): Promise { - while (this.#buffered < length) { - if (!(await this.#pull())) throw new RangeError('unexpected end of stream'); - } - } - - #take(length: number): Uint8Array { - const out = new Uint8Array(length); - let copied = 0; - - while (copied < length) { - const head = this.#chunks[0]!; - const take = Math.min(head.length, length - copied); - - out.set(head.subarray(0, take), copied); - - if (take === head.length) { - this.#chunks.shift(); - } else { - this.#chunks[0] = head.subarray(take); - } - - copied += take; - } - - this.#buffered -= length; - return out; - } - - /** True when the stream ended cleanly with no bytes left unread. */ - async atEnd(): Promise { - while (this.#buffered === 0) { - if (!(await this.#pull())) return true; - } - - return false; - } - - async readBytes(length: number): Promise { - await this.#fill(length); - return this.#take(length); - } - - async readUint8(): Promise { - await this.#fill(1); - return this.#take(1)[0]!; - } - - async readVarint(): Promise { - await this.#fill(1); - const firstByte = this.#chunks[0]![0]!; - const byteLength = varintLengthFromFirstByte(firstByte); - - await this.#fill(byteLength); - return decodeVarint(this.#take(byteLength)).value; - } - - /** Cancel the underlying stream (e.g. drop an unwanted data stream). */ - async cancel(reason?: unknown): Promise { - try { - await this.#reader.cancel(reason); - } finally { - this.#reader.releaseLock(); - } - } - - releaseLock(): void { - this.#reader.releaseLock(); - } -} diff --git a/packages/spf/src/network/moqt/control-messages.ts b/packages/spf/src/network/moqt/control-messages.ts deleted file mode 100644 index 1aa3bb99f4..0000000000 --- a/packages/spf/src/network/moqt/control-messages.ts +++ /dev/null @@ -1,1297 +0,0 @@ -/** - * MOQT control-message wire codecs (moq-transport draft-20 §10). - * - * Every control or request-stream message is framed as: - * - * MOQT Control Message { - * Message Type (vi64), - * Message Length (16), - * Message Body (..), - * } - * - * Scope follows the subscribe-only engine: the encoders cover what a subscriber sends (SETUP, SUBSCRIBE, FETCH, - * TRACK_STATUS, SUBSCRIBE_NAMESPACE, REQUEST_UPDATE, GOAWAY, and REQUEST_OK / REQUEST_ERROR responses to incoming - * PUBLISH); the decoders cover what it receives. All draft-version specifics live in this directory — this is the - * churn-absorption layer for pre-WGLC drafts. - * - * Where the draft text and the deployed relay (moq-relay, moq-dev/moq) disagree on a wire detail, the codec follows the - * relay and says so at the site — interop is with the relay, not the prose. - * - * Namespace fields and track names are byte strings on the wire; this codec surfaces them as UTF-8 `string`s, which is - * what MSF (the streaming format this engine speaks) constrains them to. - */ -import { ByteReader, ByteWriter, utf8Decode, utf8Encode } from './bytes'; -import { MoqtProtocolError } from './errors'; -import { decodeVarint, MAX_VARINT_VALUE } from './varint'; - -// ============================================================================ -// Wire constants -// ============================================================================ - -/** - * ALPN / WebTransport protocol identifier for the implemented draft (§3.1: `moqt-` plus the draft number). Version - * negotiation happens at connection time (`WT-Available-Protocols` in WebTransport, ALPN in native QUIC) — not in - * SETUP. - */ -export const MOQT_PROTOCOL_ID = 'moqt-20'; - -/** Control/request message type codes (§10, Table 5). */ -export const MESSAGE_TYPE = { - SETUP: 0x2f00, - GOAWAY: 0x10, - SUBSCRIBE: 0x3, - SUBSCRIBE_OK: 0x4, - REQUEST_ERROR: 0x5, - PUBLISH_NAMESPACE: 0x6, - REQUEST_OK: 0x7, - NAMESPACE: 0x8, - PUBLISH_DONE: 0xb, - TRACK_STATUS: 0xd, - NAMESPACE_DONE: 0xe, - PUBLISH_SKIPPED: 0xf, - FETCH: 0x16, - FETCH_OK: 0x18, - PUBLISH: 0x1d, - PUBLISH_STATE_NOTIFY: 0x22, - REQUEST_UPDATE: 0x2, - SUBSCRIBE_NAMESPACE: 0x50, - SUBSCRIBE_TRACKS: 0x51, -} as const; - -/** Setup Option types (§10.3.1). A namespace separate from message parameters. */ -export const SETUP_OPTION = { - PATH: 0x01, - AUTHORIZATION_TOKEN: 0x03, - MAX_AUTH_TOKEN_CACHE_SIZE: 0x04, - AUTHORITY: 0x05, - MAX_FILTER_RANGES: 0x06, - MOQT_IMPLEMENTATION: 0x07, - MAX_REQUEST_UPDATES: 0x08, -} as const; - -/** Message parameter types (§10.2, §15.7). */ -export const PARAMETER_TYPE = { - OBJECT_DELIVERY_TIMEOUT: 0x02, - AUTHORIZATION_TOKEN: 0x03, - RENDEZVOUS_TIMEOUT: 0x04, - SUBGROUP_DELIVERY_TIMEOUT: 0x06, - EXPIRES: 0x08, - LARGEST_OBJECT: 0x09, - FILL_TIMEOUT: 0x0a, - FORWARD: 0x10, - SUBSCRIBER_PRIORITY: 0x20, - LOCATION_FILTER: 0x21, - GROUP_ORDER: 0x22, - FILL_PARAMETERS: 0x23, - SUBGROUP_FILTER: 0x25, - OBJECTID_FILTER: 0x26, - PRIORITY_FILTER: 0x27, - OBJECT_PROPERTY_FILTER: 0x28, - TRACK_PROPERTY_FILTER: 0x29, - NEW_GROUP_REQUEST: 0x32, - TRACK_NAMESPACE_PREFIX: 0x34, - INCLUDE_PROPERTIES: 0x35, -} as const; - -/** REQUEST_ERROR codes (§15.11.2). */ -export const REQUEST_ERROR_CODE = { - INTERNAL_ERROR: 0x0, - UNAUTHORIZED: 0x1, - TIMEOUT: 0x2, - NOT_SUPPORTED: 0x3, - MALFORMED_AUTH_TOKEN: 0x4, - EXPIRED_AUTH_TOKEN: 0x5, - GOING_AWAY: 0x6, - EXCESSIVE_LOAD: 0x9, - DOES_NOT_EXIST: 0x10, - INVALID_RANGE: 0x11, - MALFORMED_TRACK: 0x12, - UNINTERESTED: 0x20, - PREFIX_OVERLAP: 0x30, - NAMESPACE_TOO_LARGE: 0x31, - UNSUPPORTED_EXTENSION: 0x33, - REDIRECT: 0x34, - CONFLICTING_FILTERS: 0x35, - INVALID_FILTER: 0x36, -} as const; - -/** PUBLISH_DONE status codes (§10.12). */ -export const PUBLISH_DONE_STATUS = { - INTERNAL_ERROR: 0x0, - UNAUTHORIZED: 0x1, - TRACK_ENDED: 0x2, - GOING_AWAY: 0x4, - TOO_FAR_BEHIND: 0x5, - EXPIRED: 0x6, - UPDATE_FAILED: 0x8, - EXCESSIVE_LOAD: 0x9, - MALFORMED_TRACK: 0x12, -} as const; - -/** - * REQUEST_ERROR codes for which an identical retry can never succeed: the request or its credentials are wrong in a way - * that does not change between attempts. Everything else — including codes this table does not know — is treated as - * retryable, so a relay introducing a new transient code degrades to paced retries rather than a dead player. - * EXPIRED_AUTH_TOKEN is deliberately absent: it has its own refresh path wherever requests are retried. - */ -const PERMANENT_REQUEST_ERROR_CODES: ReadonlySet = new Set([ - REQUEST_ERROR_CODE.UNAUTHORIZED, - REQUEST_ERROR_CODE.NOT_SUPPORTED, - REQUEST_ERROR_CODE.MALFORMED_AUTH_TOKEN, - REQUEST_ERROR_CODE.INVALID_RANGE, - // The track cannot be served as requested; an identical resubscribe - // re-earns the rejection. A publisher fixing the track surfaces as a - // catalog update, which re-selects and re-subscribes through fresh state. - REQUEST_ERROR_CODE.MALFORMED_TRACK, - REQUEST_ERROR_CODE.UNINTERESTED, - REQUEST_ERROR_CODE.PREFIX_OVERLAP, - REQUEST_ERROR_CODE.NAMESPACE_TOO_LARGE, - REQUEST_ERROR_CODE.UNSUPPORTED_EXTENSION, - // Until session migration exists, the redirect target is unreachable and - // re-asking the same relay just re-earns the redirect. - REQUEST_ERROR_CODE.REDIRECT, - REQUEST_ERROR_CODE.CONFLICTING_FILTERS, - REQUEST_ERROR_CODE.INVALID_FILTER, -]); - -/** - * Whether a failed request is worth re-issuing unchanged after a backoff. The transient family (`DOES_NOT_EXIST` while - * a broadcast has not started, `TIMEOUT`, `INTERNAL_ERROR`, overload, `GOING_AWAY`) reflects relay or publisher _state_ - * that time can fix; the permanent family reflects the request itself and loops forever if retried. - */ -export function isRetryableRequestErrorCode(errorCode: number): boolean { - return !PERMANENT_REQUEST_ERROR_CODES.has(errorCode); -} - -/** - * PUBLISH_DONE statuses after which an identical re-subscribe can never succeed: auth-shaped ends (same credentials the - * relay just rejected) and a malformed track (same request re-earns the same end; a publisher fix arrives as a catalog - * update through fresh state). Every other status describes publisher/relay state a broadcaster restart or live-edge - * rejoin legitimately recovers from (`TRACK_ENDED`, `GOING_AWAY`, `TOO_FAR_BEHIND`, overload, …), and unknown statuses - * degrade to paced retries for the same reason as {@link isRetryableRequestErrorCode}. - */ -const PERMANENT_PUBLISH_DONE_STATUSES: ReadonlySet = new Set([ - PUBLISH_DONE_STATUS.UNAUTHORIZED, - PUBLISH_DONE_STATUS.EXPIRED, - PUBLISH_DONE_STATUS.MALFORMED_TRACK, -]); - -/** Whether a PUBLISH_DONE'd subscription is worth re-subscribing. */ -export function isRetryablePublishDoneStatus(statusCode: number): boolean { - return !PERMANENT_PUBLISH_DONE_STATUSES.has(statusCode); -} - -/** Stream reset / STOP_SENDING error codes (§3.3.4). */ -export const STREAM_RESET_CODE = { - INTERNAL_ERROR: 0x0, - CANCELLED: 0x1, - DELIVERY_TIMEOUT: 0x2, - SESSION_CLOSED: 0x3, - GOING_AWAY: 0x4, - TOO_FAR_BEHIND: 0x5, - UNKNOWN_OBJECT_STATUS: 0x6, - EXPIRED_AUTH_TOKEN: 0x7, - EXCESSIVE_LOAD: 0x9, - MALFORMED_TRACK: 0x12, -} as const; - -/** Maximum body size — the frame length field is 16 bits. */ -export const MAX_CONTROL_MESSAGE_LENGTH = 0xffff; - -const MAX_NAMESPACE_FIELDS = 32; -const MAX_FULL_TRACK_NAME_LENGTH = 4096; -const MAX_REASON_PHRASE_LENGTH = 1024; -const MAX_NEW_SESSION_URI_LENGTH = 8192; -const MAX_KVP_VALUE_LENGTH = 0xffff; -const MAX_LOCATION_FILTER_FIELDS = 4; - -// ============================================================================ -// Shared structures -// ============================================================================ - -/** A particular Object in a Group within a Track (§1.4.2). */ -export interface Location { - group: number; - object: number; -} - -/** `A < B` in Location order (group first, then object). */ -export function compareLocations(a: Location, b: Location): number { - return a.group - b.group || a.object - b.object; -} - -/** Track namespace as an ordered tuple of UTF-8 fields. Byte strings on the wire; MSF constrains them to UTF-8 text. */ -export type TrackNamespace = string[]; - -export interface FullTrackName { - namespace: TrackNamespace; - name: string; -} - -function writeTrackNamespace(writer: ByteWriter, namespace: TrackNamespace): void { - if (namespace.length > MAX_NAMESPACE_FIELDS) { - throw new MoqtProtocolError(`track namespace has more than ${MAX_NAMESPACE_FIELDS} fields`); - } - - writer.writeVarint(namespace.length); - - for (const field of namespace) { - const bytes = utf8Encode(field); - if (bytes.length === 0) throw new MoqtProtocolError('track namespace field must not be empty'); - - writer.writeLengthPrefixed(bytes); - } -} - -function readTrackNamespace(reader: ByteReader): TrackNamespace { - const fieldCount = reader.readVarint(); - - if (fieldCount > MAX_NAMESPACE_FIELDS) { - throw new MoqtProtocolError(`track namespace has more than ${MAX_NAMESPACE_FIELDS} fields`); - } - - const namespace: TrackNamespace = []; - let totalLength = 0; - - for (let i = 0; i < fieldCount; i++) { - const length = reader.readVarint(); - if (length === 0) throw new MoqtProtocolError('track namespace field must not be empty'); - - totalLength += length; - - if (totalLength > MAX_FULL_TRACK_NAME_LENGTH) { - throw new MoqtProtocolError('track namespace exceeds 4096 bytes'); - } - - namespace.push(utf8Decode(reader.readBytes(length))); - } - - return namespace; -} - -function writeReasonPhrase(writer: ByteWriter, reason: string): void { - const bytes = utf8Encode(reason); - if (bytes.length > MAX_REASON_PHRASE_LENGTH) throw new MoqtProtocolError('reason phrase exceeds 1024 bytes'); - - writer.writeLengthPrefixed(bytes); -} - -function readReasonPhrase(reader: ByteReader): string { - const length = reader.readVarint(); - if (length > MAX_REASON_PHRASE_LENGTH) throw new MoqtProtocolError('reason phrase exceeds 1024 bytes'); - - return utf8Decode(reader.readBytes(length)); -} - -// Message parameters use per-type encodings: LARGEST_OBJECT is a bare Location -// (§10.2), including with moq-relay 0.14.17+ on draft-17 and newer (moq-dev/moq#3561). -// This engine speaks draft-20 only; older relays' length prefix is incompatible. -function writeLocation(writer: ByteWriter, location: Location): void { - writer.writeVarint(location.group); - writer.writeVarint(location.object); -} - -function readLocation(reader: ByteReader): Location { - return { group: reader.readVarint(), object: reader.readVarint() }; -} - -// ============================================================================ -// Key-Value-Pairs (§1.4.3) — Setup Options and Track Properties -// ============================================================================ - -/** - * A generic MOQT Key-Value-Pair. Even types carry a varint value, odd types a byte field. Used for Setup Options and - * Track/Object Properties (message parameters use per-type encodings instead — see `MessageParameters`). - */ -export interface KeyValuePair { - type: number; - value: number | Uint8Array; -} - -/** Serialize pairs in ascending type order with delta-encoded types. */ -export function encodeKeyValuePairs(writer: ByteWriter, pairs: readonly KeyValuePair[]): void { - const sorted = [...pairs].sort((a, b) => a.type - b.type); - let previousType = 0; - - for (const { type, value } of sorted) { - writer.writeVarint(type - previousType); - previousType = type; - - if (type % 2 === 0) { - if (typeof value !== 'number') throw new MoqtProtocolError(`even KVP type ${type} requires a varint value`); - - writer.writeVarint(value); - } else { - if (typeof value === 'number') throw new MoqtProtocolError(`odd KVP type ${type} requires a byte value`); - - if (value.length > MAX_KVP_VALUE_LENGTH) throw new MoqtProtocolError('KVP value exceeds 2^16-1 bytes'); - - writer.writeLengthPrefixed(value); - } - } -} - -/** Parse pairs until `reader` reaches `endOffset` (KVP blocks are length-bounded). */ -export function decodeKeyValuePairs(reader: ByteReader, endOffset: number): KeyValuePair[] { - const pairs: KeyValuePair[] = []; - let previousType = 0; - - while (reader.offset < endOffset) { - const type = previousType + reader.readVarint(); - - previousType = type; - - if (type % 2 === 0) { - pairs.push({ type, value: reader.readVarint() }); - } else { - const length = reader.readVarint(); - if (length > MAX_KVP_VALUE_LENGTH) throw new MoqtProtocolError('KVP value exceeds 2^16-1 bytes'); - - pairs.push({ type, value: reader.readBytes(length) }); - } - } - - if (reader.offset !== endOffset) throw new MoqtProtocolError('KVP block overran its bound'); - - return pairs; -} - -// ============================================================================ -// Location Filters (§5.1.2) — carried in the LOCATION_FILTER parameter -// ============================================================================ - -/** - * Which Objects a subscription or fetch covers. On the wire the LOCATION_FILTER value is up to four varints — - * StartGroup, StartObject, EndGroupDelta, EndObject — and how many are present selects the meaning: - * - * - `none` — zero fields. Unfiltered: the whole track for a subscription, `{0,0}` up to Largest Object for a fetch; in - * REQUEST_UPDATE it clears the filter. - * - `relative-group` — one field. Start at `{Largest.Group + 1 − groupsBeforeNext, 0}`, open-ended: `0` is the next - * group, `1` the start of the current group (a decodable join), `N` N−1 groups before it. - * - `next-object` — the two-field spelling `{0,0}`: `{Largest.Group, Largest.Object + 1}`, the live edge, which can begin - * mid-group. - * - `absolute` — two to four fields: an explicit start, optionally bounded by an end group (delta from the start group, - * whole group included unless `endObject` narrows it). An open-ended absolute `{0,0}` is unfiltered by definition and - * encodes as `none` — its two-field spelling would read as `next-object`. - */ -export type LocationFilter = - | { type: 'none' } - | { type: 'next-object' } - | { type: 'relative-group'; groupsBeforeNext: number } - | { type: 'absolute'; start: Location; endGroupDelta?: number; endObject?: number }; - -/** Serialize a filter as the LOCATION_FILTER parameter's value (without its length prefix). */ -export function encodeLocationFilter(filter: LocationFilter): Uint8Array { - const writer = new ByteWriter(32); - - switch (filter.type) { - case 'none': - break; - case 'next-object': - writer.writeVarint(0); - writer.writeVarint(0); - break; - case 'relative-group': - writer.writeVarint(filter.groupsBeforeNext); - break; - case 'absolute': { - const { start, endGroupDelta, endObject } = filter; - - if (endObject !== undefined && endGroupDelta === undefined) { - throw new MoqtProtocolError('location filter end object requires an end group'); - } - - if (start.group === 0 && start.object === 0 && endGroupDelta === undefined) break; - - writeLocation(writer, start); - - if (endGroupDelta !== undefined) writer.writeVarint(endGroupDelta); - - if (endObject !== undefined) writer.writeVarint(endObject); - - break; - } - } - - return writer.toBytes(); -} - -export function decodeLocationFilter(bytes: Uint8Array): LocationFilter { - const reader = new ByteReader(bytes); - const fields: number[] = []; - - while (reader.remaining > 0) { - if (fields.length === MAX_LOCATION_FILTER_FIELDS) { - throw new MoqtProtocolError('location filter has more than four fields'); - } - - fields.push(reader.readVarint()); - } - - if (fields.length === 0) return { type: 'none' }; - - if (fields.length === 1) return { type: 'relative-group', groupsBeforeNext: fields[0]! }; - - const [group, object, endGroupDelta, endObject] = fields as [number, number, number?, number?]; - if (fields.length === 2 && group === 0 && object === 0) return { type: 'next-object' }; - - const filter: LocationFilter = { type: 'absolute', start: { group, object } }; - - if (endGroupDelta !== undefined) { - if (group + endGroupDelta > MAX_VARINT_VALUE) { - throw new MoqtProtocolError('location filter end group exceeds supported range'); - } - - filter.endGroupDelta = endGroupDelta; - } - - if (endObject !== undefined) filter.endObject = endObject; - - return filter; -} - -// ============================================================================ -// Message Parameters (§10.2) -// ============================================================================ - -export type GroupOrder = 'ascending' | 'descending'; - -/** - * Decoded message parameters. Unlike Setup Options, message parameters use per-type encodings (uint8 / varint / - * length-prefixed), so the codec is registry-driven. Per §10.2 an unknown parameter type is a PROTOCOL_VIOLATION - * (parameters cannot be skipped — the block is bounded by count, not length). - */ -export interface MessageParameters { - objectDeliveryTimeout?: number; - subgroupDeliveryTimeout?: number; - rendezvousTimeout?: number; - fillTimeout?: number; - /** Serialized Token structures (§10.2.2). May repeat. */ - authorizationTokens?: Uint8Array[]; - expires?: number; - largestObject?: Location; - forward?: 0 | 1; - subscriberPriority?: number; - locationFilter?: LocationFilter; - groupOrder?: GroupOrder; - /** - * FILL_PARAMETERS (§10.2.15): asks the publisher to deliver a fill range on a fetch stream alongside the subscription - * — its presence alone requests the fill. A nested parameter scope: only the fill-scoped subset is legal inside, and - * omitted entries inherit the subscription's own values. - */ - fillParameters?: FillParameters; - newGroupRequest?: number; - /** Range-filter parameters (§5.1.4), kept opaque — the engine never sends or interprets them. */ - rangeFilters?: { type: number; value: Uint8Array }[]; - trackNamespacePrefix?: TrackNamespace; - /** INCLUDE_PROPERTIES (§10.2.21): `0` asks the responder to send empty Track Properties. Default `1`. */ - includeProperties?: 0 | 1; -} - -/** The parameters FILL_PARAMETERS may carry (§10.2.15, Table 6). */ -export type FillParameters = Pick< - MessageParameters, - 'fillTimeout' | 'subscriberPriority' | 'locationFilter' | 'groupOrder' | 'rangeFilters' ->; - -type ParameterScope = 'message' | 'fill'; - -const FILL_SCOPE_TYPES: ReadonlySet = new Set([ - PARAMETER_TYPE.FILL_TIMEOUT, - PARAMETER_TYPE.SUBSCRIBER_PRIORITY, - PARAMETER_TYPE.LOCATION_FILTER, - PARAMETER_TYPE.GROUP_ORDER, - PARAMETER_TYPE.SUBGROUP_FILTER, - PARAMETER_TYPE.OBJECTID_FILTER, - PARAMETER_TYPE.PRIORITY_FILTER, - PARAMETER_TYPE.OBJECT_PROPERTY_FILTER, -]); - -const GROUP_ORDER_WIRE: Record = { ascending: 0x1, descending: 0x2 }; - -interface ParameterEntry { - type: number; - write(writer: ByteWriter): void; -} - -function collectParameterEntries(parameters: MessageParameters): ParameterEntry[] { - const entries: ParameterEntry[] = []; - const push = (type: number, write: (writer: ByteWriter) => void) => entries.push({ type, write }); - - if (parameters.objectDeliveryTimeout !== undefined) { - push(PARAMETER_TYPE.OBJECT_DELIVERY_TIMEOUT, (w) => w.writeVarint(parameters.objectDeliveryTimeout!)); - } - - if (parameters.subgroupDeliveryTimeout !== undefined) { - push(PARAMETER_TYPE.SUBGROUP_DELIVERY_TIMEOUT, (w) => w.writeVarint(parameters.subgroupDeliveryTimeout!)); - } - - if (parameters.rendezvousTimeout !== undefined) { - push(PARAMETER_TYPE.RENDEZVOUS_TIMEOUT, (w) => w.writeVarint(parameters.rendezvousTimeout!)); - } - - if (parameters.fillTimeout !== undefined) { - push(PARAMETER_TYPE.FILL_TIMEOUT, (w) => w.writeVarint(parameters.fillTimeout!)); - } - - for (const token of parameters.authorizationTokens ?? []) { - push(PARAMETER_TYPE.AUTHORIZATION_TOKEN, (w) => w.writeLengthPrefixed(token)); - } - - if (parameters.expires !== undefined) { - push(PARAMETER_TYPE.EXPIRES, (w) => w.writeVarint(parameters.expires!)); - } - - if (parameters.largestObject !== undefined) { - push(PARAMETER_TYPE.LARGEST_OBJECT, (w) => writeLocation(w, parameters.largestObject!)); - } - - if (parameters.forward !== undefined) { - push(PARAMETER_TYPE.FORWARD, (w) => w.writeUint8(parameters.forward!)); - } - - if (parameters.subscriberPriority !== undefined) { - push(PARAMETER_TYPE.SUBSCRIBER_PRIORITY, (w) => w.writeUint8(parameters.subscriberPriority!)); - } - - if (parameters.locationFilter !== undefined) { - push(PARAMETER_TYPE.LOCATION_FILTER, (w) => - w.writeLengthPrefixed(encodeLocationFilter(parameters.locationFilter!)) - ); - } - - if (parameters.groupOrder !== undefined) { - push(PARAMETER_TYPE.GROUP_ORDER, (w) => w.writeUint8(GROUP_ORDER_WIRE[parameters.groupOrder!])); - } - - if (parameters.fillParameters !== undefined) { - push(PARAMETER_TYPE.FILL_PARAMETERS, (w) => - w.writeLengthPrefixed(encodeFillParameters(parameters.fillParameters!)) - ); - } - - if (parameters.newGroupRequest !== undefined) { - push(PARAMETER_TYPE.NEW_GROUP_REQUEST, (w) => w.writeVarint(parameters.newGroupRequest!)); - } - - for (const filter of parameters.rangeFilters ?? []) { - push(filter.type, (w) => w.writeLengthPrefixed(filter.value)); - } - - if (parameters.trackNamespacePrefix !== undefined) { - push(PARAMETER_TYPE.TRACK_NAMESPACE_PREFIX, (w) => writeTrackNamespace(w, parameters.trackNamespacePrefix!)); - } - - if (parameters.includeProperties !== undefined) { - push(PARAMETER_TYPE.INCLUDE_PROPERTIES, (w) => w.writeUint8(parameters.includeProperties!)); - } - - return entries; -} - -/** - * Serialize as `Number of Parameters (vi64)` + delta-typed parameter list. The `'fill'` scope is the nested list inside - * FILL_PARAMETERS, where only Table 6's types are legal. - */ -export function encodeMessageParameters( - writer: ByteWriter, - parameters: MessageParameters = {}, - scope: ParameterScope = 'message' -): void { - const entries = collectParameterEntries(parameters).sort((a, b) => a.type - b.type); - - if (scope === 'fill') { - const disallowed = entries.find((entry) => !FILL_SCOPE_TYPES.has(entry.type)); - - if (disallowed) { - throw new MoqtProtocolError(`parameter type ${disallowed.type} is not allowed inside FILL_PARAMETERS`); - } - } - - writer.writeVarint(entries.length); - let previousType = 0; - - for (const entry of entries) { - writer.writeVarint(entry.type - previousType); - previousType = entry.type; - entry.write(writer); - } -} - -/** FILL_PARAMETERS' value: a parameter list encoded as if for a separate message (§10.2.15). */ -function encodeFillParameters(fill: FillParameters): Uint8Array { - const writer = new ByteWriter(64); - - encodeMessageParameters(writer, fill, 'fill'); - return writer.toBytes(); -} - -const RANGE_FILTER_TYPES: readonly number[] = [ - PARAMETER_TYPE.SUBGROUP_FILTER, - PARAMETER_TYPE.OBJECTID_FILTER, - PARAMETER_TYPE.PRIORITY_FILTER, - PARAMETER_TYPE.OBJECT_PROPERTY_FILTER, - PARAMETER_TYPE.TRACK_PROPERTY_FILTER, -]; - -export function decodeMessageParameters(reader: ByteReader, scope: ParameterScope = 'message'): MessageParameters { - const count = reader.readVarint(); - const parameters: MessageParameters = {}; - let previousType = 0; - - for (let i = 0; i < count; i++) { - const type = previousType + reader.readVarint(); - - previousType = type; - - // §10.2.15: a type outside Table 6 inside FILL_PARAMETERS is a - // PROTOCOL_VIOLATION, the nested scope included. - if (scope === 'fill' && !FILL_SCOPE_TYPES.has(type)) { - throw new MoqtProtocolError(`parameter type ${type} is not allowed inside FILL_PARAMETERS`); - } - - switch (type) { - case PARAMETER_TYPE.OBJECT_DELIVERY_TIMEOUT: - parameters.objectDeliveryTimeout = reader.readVarint(); - break; - case PARAMETER_TYPE.SUBGROUP_DELIVERY_TIMEOUT: - parameters.subgroupDeliveryTimeout = reader.readVarint(); - break; - case PARAMETER_TYPE.RENDEZVOUS_TIMEOUT: - parameters.rendezvousTimeout = reader.readVarint(); - break; - case PARAMETER_TYPE.FILL_TIMEOUT: - parameters.fillTimeout = reader.readVarint(); - break; - case PARAMETER_TYPE.AUTHORIZATION_TOKEN: { - const token = reader.readBytes(reader.readVarint()); - - (parameters.authorizationTokens ??= []).push(token); - break; - } - case PARAMETER_TYPE.EXPIRES: - parameters.expires = reader.readVarint(); - break; - case PARAMETER_TYPE.LARGEST_OBJECT: - parameters.largestObject = readLocation(reader); - break; - case PARAMETER_TYPE.FORWARD: { - const forward = reader.readUint8(); - if (forward !== 0 && forward !== 1) throw new MoqtProtocolError(`invalid FORWARD value ${forward}`); - - parameters.forward = forward; - break; - } - case PARAMETER_TYPE.SUBSCRIBER_PRIORITY: - parameters.subscriberPriority = reader.readUint8(); - break; - case PARAMETER_TYPE.LOCATION_FILTER: - parameters.locationFilter = decodeLocationFilter(reader.readBytes(reader.readVarint())); - break; - case PARAMETER_TYPE.GROUP_ORDER: { - const order = reader.readUint8(); - if (order !== 0x1 && order !== 0x2) throw new MoqtProtocolError(`invalid GROUP_ORDER value ${order}`); - - parameters.groupOrder = order === 0x1 ? 'ascending' : 'descending'; - break; - } - case PARAMETER_TYPE.FILL_PARAMETERS: { - const value = new ByteReader(reader.readBytes(reader.readVarint())); - - parameters.fillParameters = decodeMessageParameters(value, 'fill'); - - if (value.remaining !== 0) throw new MoqtProtocolError('FILL_PARAMETERS has trailing bytes'); - - break; - } - case PARAMETER_TYPE.NEW_GROUP_REQUEST: - parameters.newGroupRequest = reader.readVarint(); - break; - case PARAMETER_TYPE.TRACK_NAMESPACE_PREFIX: - parameters.trackNamespacePrefix = readTrackNamespace(reader); - break; - case PARAMETER_TYPE.INCLUDE_PROPERTIES: { - // moq-relay framed this length-prefixed by type parity until 0.17.0 - // (moq-dev/moq#4610), which reads the §10.2.21 uint8 bare. - const include = reader.readUint8(); - if (include !== 0 && include !== 1) throw new MoqtProtocolError(`invalid INCLUDE_PROPERTIES value ${include}`); - - parameters.includeProperties = include; - break; - } - default: { - if (RANGE_FILTER_TYPES.includes(type)) { - const value = reader.readBytes(reader.readVarint()); - - (parameters.rangeFilters ??= []).push({ type, value }); - break; - } - - // §10.2: unknown parameters cannot be skipped (the block is bounded - // by count, and the value encoding is per-type) — session error. - throw new MoqtProtocolError(`unknown message parameter type ${type}`); - } - } - } - - return parameters; -} - -// ============================================================================ -// Authorization tokens (§10.2.2) -// ============================================================================ - -/** - * Serialize a Token structure with Alias Type USE_VALUE (0x3) — the stateless form the engine uses to attach an - * MSF-provided token to a request without alias registration. - */ -export function encodeAuthTokenUseValue(tokenType: number, value: Uint8Array): Uint8Array { - const writer = new ByteWriter(value.length + 8); - - writer.writeVarint(0x3); - writer.writeVarint(tokenType); - writer.writeBytes(value); - return writer.toBytes(); -} - -// ============================================================================ -// Message framing -// ============================================================================ - -/** A decoded frame: message type + body bytes (not yet interpreted). */ -export interface ControlMessageFrame { - type: number; - body: Uint8Array; -} - -function frameMessage(type: number, body: ByteWriter): Uint8Array { - const bodyBytes = body.toBytes(); - - if (bodyBytes.length > MAX_CONTROL_MESSAGE_LENGTH) { - throw new MoqtProtocolError('control message exceeds 2^16-1 bytes'); - } - - const writer = new ByteWriter(bodyBytes.length + 8); - - writer.writeVarint(type); - writer.writeUint16(bodyBytes.length); - writer.writeBytes(bodyBytes); - return writer.toBytes(); -} - -/** - * Incremental control-message deframer. Feed it stream chunks; it yields complete `ControlMessageFrame`s as they - * materialize. Used for both the control streams and request streams (same framing). - */ -export class ControlMessageDeframer { - #buffer: Uint8Array = new Uint8Array(0); - - push(chunk: Uint8Array): ControlMessageFrame[] { - if (this.#buffer.length === 0) { - this.#buffer = chunk; - } else { - const merged = new Uint8Array(this.#buffer.length + chunk.length); - - merged.set(this.#buffer); - merged.set(chunk, this.#buffer.length); - this.#buffer = merged; - } - - const frames: ControlMessageFrame[] = []; - let offset = 0; - - while (true) { - const frame = this.#tryReadFrame(offset); - if (!frame) break; - - frames.push(frame.frame); - offset = frame.nextOffset; - } - - this.#buffer = offset > 0 ? this.#buffer.subarray(offset) : this.#buffer; - return frames; - } - - /** Bytes buffered but not yet forming a complete frame. */ - get pendingBytes(): number { - return this.#buffer.length; - } - - #tryReadFrame(offset: number): { frame: ControlMessageFrame; nextOffset: number } | null { - const buffer = this.#buffer; - if (offset >= buffer.length) return null; - - let type: number; - let headerLength: number; - - try { - const decoded = decodeVarint(buffer, offset); - - type = decoded.value; - headerLength = decoded.byteLength; - } catch (error) { - // Incomplete varint — wait for more bytes. - if (error instanceof RangeError) return null; - - throw error; - } - - if (offset + headerLength + 2 > buffer.length) return null; - - const length = buffer[offset + headerLength]! * 256 + buffer[offset + headerLength + 1]!; - const bodyStart = offset + headerLength + 2; - if (bodyStart + length > buffer.length) return null; - - return { - frame: { type, body: buffer.slice(bodyStart, bodyStart + length) }, - nextOffset: bodyStart + length, - }; - } -} - -// ============================================================================ -// Encoders (subscriber → publisher) -// ============================================================================ - -/** SETUP (§10.3) — first message on the endpoint's control stream. */ -export function encodeSetup(options: readonly KeyValuePair[] = []): Uint8Array { - const body = new ByteWriter(); - - encodeKeyValuePairs(body, options); - return frameMessage(MESSAGE_TYPE.SETUP, body); -} - -export interface SubscribeRequest { - requestId: number; - trackNamespace: TrackNamespace; - trackName: string; - parameters?: MessageParameters; -} - -/** - * FETCH (§10.13) has the SUBSCRIBE body: the range is `parameters.locationFilter`, evaluated with the fetch rules of - * §5.1.2 — relative starts count back from Largest Object, an omitted end stops there, and no filter means the whole - * track. Nothing selects "standalone" or "joining" any more; a join is a subscription with FILL_PARAMETERS. - */ -export type FetchRequest = SubscribeRequest; - -/** SUBSCRIBE, TRACK_STATUS, and FETCH share one body: Request ID, Full Track Name, Parameters. */ -function encodeTrackRequest(type: number, request: SubscribeRequest): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(request.requestId); - writeTrackNamespace(body, request.trackNamespace); - body.writeLengthPrefixed(utf8Encode(request.trackName)); - encodeMessageParameters(body, request.parameters); - return frameMessage(type, body); -} - -/** SUBSCRIBE (§10.7) — first message on a new request stream. */ -export function encodeSubscribe(request: SubscribeRequest): Uint8Array { - return encodeTrackRequest(MESSAGE_TYPE.SUBSCRIBE, request); -} - -/** TRACK_STATUS (§10.15) — identical wire format to SUBSCRIBE. */ -export function encodeTrackStatus(request: SubscribeRequest): Uint8Array { - return encodeTrackRequest(MESSAGE_TYPE.TRACK_STATUS, request); -} - -/** FETCH (§10.13) — first message on a new request stream. */ -export function encodeFetch(request: FetchRequest): Uint8Array { - return encodeTrackRequest(MESSAGE_TYPE.FETCH, request); -} - -export interface SubscribeNamespaceRequest { - requestId: number; - trackNamespacePrefix: TrackNamespace; - parameters?: MessageParameters; -} - -/** SUBSCRIBE_NAMESPACE (§10.19) — first message on a new request stream. */ -export function encodeSubscribeNamespace(request: SubscribeNamespaceRequest): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(request.requestId); - writeTrackNamespace(body, request.trackNamespacePrefix); - encodeMessageParameters(body, request.parameters); - return frameMessage(MESSAGE_TYPE.SUBSCRIBE_NAMESPACE, body); -} - -/** - * REQUEST_UPDATE (§10.9) — sent on an existing request stream. `requestId` is the update's own, freshly allocated - * Request ID (§10.1 counts REQUEST_UPDATE among the messages that consume one); the stream identifies the request being - * updated. - */ -export function encodeRequestUpdate(requestId: number, parameters: MessageParameters = {}): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(requestId); - encodeMessageParameters(body, parameters); - return frameMessage(MESSAGE_TYPE.REQUEST_UPDATE, body); -} - -/** - * GOAWAY (§10.4). Clients MUST send a zero-length New Session URI, so the encoder takes only the timeout (milliseconds; - * 0 = no specific timeout). - */ -export function encodeGoaway(timeout = 0): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(0); - body.writeVarint(timeout); - return frameMessage(MESSAGE_TYPE.GOAWAY, body); -} - -/** - * REQUEST_OK (§10.5). The subscriber sends this to accept an incoming PUBLISH (PUBLISH_OK). Track Properties are always - * empty in that role, and since draft-20 so are the parameters — a subscriber changes subscription parameters with - * REQUEST_UPDATE, not in PUBLISH_OK (§10.11); the session driver's `accept()` therefore takes none. The parameter slot - * stays for the publisher-side roles of REQUEST_OK (TRACK_STATUS_OK, REQUEST_UPDATE_OK), which the fake peer in tests - * exercises. - */ -export function encodeRequestOk(parameters: MessageParameters = {}): Uint8Array { - const body = new ByteWriter(); - - encodeMessageParameters(body, parameters); - return frameMessage(MESSAGE_TYPE.REQUEST_OK, body); -} - -/** REQUEST_ERROR (§10.6) without a Redirect — enough to reject incoming requests. */ -export function encodeRequestError(errorCode: number, reason = '', retryInterval = 0): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(errorCode); - body.writeVarint(retryInterval); - writeReasonPhrase(body, reason); - return frameMessage(MESSAGE_TYPE.REQUEST_ERROR, body); -} - -// ============================================================================ -// Encoders (publisher → subscriber) -// -// The engine is subscribe-only, but the codec is symmetric: these are used -// by the in-memory fake peer in tests (the same seam a future publish -// path would build on). -// ============================================================================ - -/** SUBSCRIBE_OK (§10.8). */ -export function encodeSubscribeOk( - trackAlias: number, - parameters: MessageParameters = {}, - trackProperties: readonly KeyValuePair[] = [] -): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(trackAlias); - encodeMessageParameters(body, parameters); - encodeKeyValuePairs(body, trackProperties); - return frameMessage(MESSAGE_TYPE.SUBSCRIBE_OK, body); -} - -/** PUBLISH_DONE (§10.12). */ -export function encodePublishDone(statusCode: number, streamCount: number, reason = ''): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(statusCode); - body.writeVarint(streamCount); - writeReasonPhrase(body, reason); - return frameMessage(MESSAGE_TYPE.PUBLISH_DONE, body); -} - -/** PUBLISH_STATE_NOTIFY (§10.10) — the publisher's unilateral "these subscription parameters changed". */ -export function encodePublishStateNotify(parameters: MessageParameters = {}): Uint8Array { - const body = new ByteWriter(); - - encodeMessageParameters(body, parameters); - return frameMessage(MESSAGE_TYPE.PUBLISH_STATE_NOTIFY, body); -} - -/** FETCH_OK (§10.14). */ -export function encodeFetchOk( - endOfTrack: boolean, - endLocation: Location, - parameters: MessageParameters = {}, - trackProperties: readonly KeyValuePair[] = [] -): Uint8Array { - const body = new ByteWriter(); - - body.writeUint8(endOfTrack ? 1 : 0); - writeLocation(body, endLocation); - encodeMessageParameters(body, parameters); - encodeKeyValuePairs(body, trackProperties); - return frameMessage(MESSAGE_TYPE.FETCH_OK, body); -} - -/** PUBLISH (§10.11). */ -export function encodePublish( - request: SubscribeRequest & { trackAlias: number }, - trackProperties: readonly KeyValuePair[] = [] -): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(request.requestId); - writeTrackNamespace(body, request.trackNamespace); - body.writeLengthPrefixed(utf8Encode(request.trackName)); - body.writeVarint(request.trackAlias); - encodeMessageParameters(body, request.parameters); - encodeKeyValuePairs(body, trackProperties); - return frameMessage(MESSAGE_TYPE.PUBLISH, body); -} - -export interface PublishNamespaceRequest { - requestId: number; - trackNamespace: TrackNamespace; - parameters?: MessageParameters; -} - -/** PUBLISH_NAMESPACE (§10.16) — a publisher announcing a namespace. */ -export function encodePublishNamespace(request: PublishNamespaceRequest): Uint8Array { - const body = new ByteWriter(); - - body.writeVarint(request.requestId); - writeTrackNamespace(body, request.trackNamespace); - encodeMessageParameters(body, request.parameters); - return frameMessage(MESSAGE_TYPE.PUBLISH_NAMESPACE, body); -} - -// ============================================================================ -// Decoders (publisher → subscriber) -// ============================================================================ - -export interface Redirect { - connectUri: string; - trackNamespace: TrackNamespace; - trackName: string; -} - -export type ControlMessage = - | { kind: 'setup'; options: KeyValuePair[] } - | { kind: 'goaway'; newSessionUri: string; timeout: number } - | { - kind: 'subscribe'; - requestId: number; - trackNamespace: TrackNamespace; - trackName: string; - parameters: MessageParameters; - } - | { - kind: 'track-status'; - requestId: number; - trackNamespace: TrackNamespace; - trackName: string; - parameters: MessageParameters; - } - | { kind: 'fetch'; request: FetchRequest & { parameters: MessageParameters } } - | { - kind: 'subscribe-namespace'; - requestId: number; - trackNamespacePrefix: TrackNamespace; - parameters: MessageParameters; - } - | { kind: 'subscribe-ok'; trackAlias: number; parameters: MessageParameters; trackProperties: KeyValuePair[] } - | { kind: 'request-ok'; parameters: MessageParameters; trackProperties: KeyValuePair[] } - | { kind: 'request-error'; errorCode: number; retryInterval: number; reason: string; redirect?: Redirect } - | { kind: 'request-update'; requestId: number; parameters: MessageParameters } - | { kind: 'publish-state-notify'; parameters: MessageParameters } - | { - kind: 'publish-done'; - statusCode: number; - /** `undefined` when the publisher could not count its streams (the 2^64−1 sentinel, §10.12). */ - streamCount: number | undefined; - reason: string; - } - | { - kind: 'publish'; - requestId: number; - trackNamespace: TrackNamespace; - trackName: string; - trackAlias: number; - parameters: MessageParameters; - trackProperties: KeyValuePair[]; - } - | { kind: 'publish-namespace'; requestId: number; trackNamespace: TrackNamespace; parameters: MessageParameters } - | { - kind: 'fetch-ok'; - endOfTrack: boolean; - endLocation: Location; - parameters: MessageParameters; - trackProperties: KeyValuePair[]; - } - | { kind: 'namespace'; trackNamespaceSuffix: TrackNamespace } - | { kind: 'namespace-done'; trackNamespaceSuffix: TrackNamespace } - | { kind: 'publish-skipped'; trackNamespaceSuffix: TrackNamespace; trackName: string }; - -function readRedirect(reader: ByteReader): Redirect { - const uriLength = reader.readVarint(); - const connectUri = utf8Decode(reader.readBytes(uriLength)); - const trackNamespace = readTrackNamespace(reader); - const nameLength = reader.readVarint(); - const trackName = utf8Decode(reader.readBytes(nameLength)); - - return { connectUri, trackNamespace, trackName }; -} - -/** - * Decode one control-message frame into a typed message. Throws `MoqtProtocolError` for unknown message types (§10: "An - * endpoint that receives an unknown message type MUST close the session") and for malformed bodies. - */ -export function decodeControlMessage(frame: ControlMessageFrame): ControlMessage { - const reader = new ByteReader(frame.body); - const end = frame.body.length; - let message: ControlMessage; - - try { - message = decodeControlMessageBody(frame.type, reader, end); - } catch (error) { - // Field reads past the declared frame length surface as `RangeError` - // from `ByteReader`. Normalize them: the session's stream loops treat - // only `MoqtProtocolError` as fatal, and a truncated body must - // terminate the session (§10) rather than vanish as a read error. - if (error instanceof RangeError) { - throw new MoqtProtocolError(`control message 0x${frame.type.toString(16)} body is truncated`); - } - - throw error; - } - - if (reader.offset !== end) { - throw new MoqtProtocolError(`control message 0x${frame.type.toString(16)} body length mismatch`); - } - - return message; -} - -function decodeControlMessageBody(type: number, reader: ByteReader, end: number): ControlMessage { - switch (type) { - case MESSAGE_TYPE.SETUP: - return { kind: 'setup', options: decodeKeyValuePairs(reader, end) }; - case MESSAGE_TYPE.GOAWAY: { - const uriLength = reader.readVarint(); - - if (uriLength > MAX_NEW_SESSION_URI_LENGTH) { - throw new MoqtProtocolError('GOAWAY new session URI exceeds 8192 bytes'); - } - - const newSessionUri = utf8Decode(reader.readBytes(uriLength)); - - return { kind: 'goaway', newSessionUri, timeout: reader.readVarint() }; - } - case MESSAGE_TYPE.SUBSCRIBE_OK: { - const trackAlias = reader.readVarint(); - const parameters = decodeMessageParameters(reader); - - return { kind: 'subscribe-ok', trackAlias, parameters, trackProperties: decodeKeyValuePairs(reader, end) }; - } - case MESSAGE_TYPE.REQUEST_OK: { - const parameters = decodeMessageParameters(reader); - - return { kind: 'request-ok', parameters, trackProperties: decodeKeyValuePairs(reader, end) }; - } - case MESSAGE_TYPE.REQUEST_ERROR: { - const errorCode = reader.readVarint(); - const retryInterval = reader.readVarint(); - const reason = readReasonPhrase(reader); - - if (errorCode === REQUEST_ERROR_CODE.REDIRECT) { - return { kind: 'request-error', errorCode, retryInterval, reason, redirect: readRedirect(reader) }; - } - - return { kind: 'request-error', errorCode, retryInterval, reason }; - } - case MESSAGE_TYPE.REQUEST_UPDATE: { - const requestId = reader.readVarint(); - - return { kind: 'request-update', requestId, parameters: decodeMessageParameters(reader) }; - } - case MESSAGE_TYPE.PUBLISH_STATE_NOTIFY: - return { kind: 'publish-state-notify', parameters: decodeMessageParameters(reader) }; - case MESSAGE_TYPE.PUBLISH_DONE: { - const statusCode = reader.readVarint(); - // A publisher that cannot count its streams MUST send 2^64−1 (§10.12), - // which is above this codec's varint ceiling — read that one value as - // "unknown" rather than failing the session over a legitimate - // PUBLISH_DONE. Any other count past the ceiling stays a protocol error. - const streamCount = reader.readCountVarint(); - - return { kind: 'publish-done', statusCode, streamCount, reason: readReasonPhrase(reader) }; - } - case MESSAGE_TYPE.PUBLISH: { - const requestId = reader.readVarint(); - const trackNamespace = readTrackNamespace(reader); - const trackName = utf8Decode(reader.readBytes(reader.readVarint())); - const trackAlias = reader.readVarint(); - const parameters = decodeMessageParameters(reader); - - return { - kind: 'publish', - requestId, - trackNamespace, - trackName, - trackAlias, - parameters, - trackProperties: decodeKeyValuePairs(reader, end), - }; - } - case MESSAGE_TYPE.PUBLISH_NAMESPACE: { - const requestId = reader.readVarint(); - const trackNamespace = readTrackNamespace(reader); - - return { kind: 'publish-namespace', requestId, trackNamespace, parameters: decodeMessageParameters(reader) }; - } - case MESSAGE_TYPE.FETCH_OK: { - const endOfTrackWire = reader.readUint8(); - if (endOfTrackWire > 1) throw new MoqtProtocolError(`invalid FETCH_OK end-of-track value ${endOfTrackWire}`); - - const endOfTrack = endOfTrackWire === 1; - const endLocation = readLocation(reader); - const parameters = decodeMessageParameters(reader); - - return { - kind: 'fetch-ok', - endOfTrack, - endLocation, - parameters, - trackProperties: decodeKeyValuePairs(reader, end), - }; - } - case MESSAGE_TYPE.SUBSCRIBE: - case MESSAGE_TYPE.TRACK_STATUS: - case MESSAGE_TYPE.FETCH: { - const requestId = reader.readVarint(); - const trackNamespace = readTrackNamespace(reader); - const trackName = utf8Decode(reader.readBytes(reader.readVarint())); - const parameters = decodeMessageParameters(reader); - - if (type === MESSAGE_TYPE.FETCH) { - return { kind: 'fetch', request: { requestId, trackNamespace, trackName, parameters } }; - } - - const kind = type === MESSAGE_TYPE.SUBSCRIBE ? 'subscribe' : 'track-status'; - - return { kind, requestId, trackNamespace, trackName, parameters }; - } - case MESSAGE_TYPE.SUBSCRIBE_NAMESPACE: { - const requestId = reader.readVarint(); - const trackNamespacePrefix = readTrackNamespace(reader); - - return { - kind: 'subscribe-namespace', - requestId, - trackNamespacePrefix, - parameters: decodeMessageParameters(reader), - }; - } - case MESSAGE_TYPE.NAMESPACE: - return { kind: 'namespace', trackNamespaceSuffix: readTrackNamespace(reader) }; - case MESSAGE_TYPE.NAMESPACE_DONE: - return { kind: 'namespace-done', trackNamespaceSuffix: readTrackNamespace(reader) }; - case MESSAGE_TYPE.PUBLISH_SKIPPED: { - const trackNamespaceSuffix = readTrackNamespace(reader); - const trackName = utf8Decode(reader.readBytes(reader.readVarint())); - - return { kind: 'publish-skipped', trackNamespaceSuffix, trackName }; - } - default: - throw new MoqtProtocolError(`unknown control message type 0x${type.toString(16)}`); - } -} diff --git a/packages/spf/src/network/moqt/errors.ts b/packages/spf/src/network/moqt/errors.ts deleted file mode 100644 index ee16c972aa..0000000000 --- a/packages/spf/src/network/moqt/errors.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * MOQT session-termination error codes (moq-transport draft-20 §3.5). Used as the close code when terminating the - * transport session and as the `code` carried by `MoqtProtocolError`. - */ -export const SESSION_ERROR = { - NO_ERROR: 0x0, - INTERNAL_ERROR: 0x1, - UNAUTHORIZED: 0x2, - PROTOCOL_VIOLATION: 0x3, - INVALID_REQUEST_ID: 0x4, - DUPLICATE_TRACK_ALIAS: 0x5, - KEY_VALUE_FORMATTING_ERROR: 0x6, - INVALID_PATH: 0x8, - MALFORMED_PATH: 0x9, - GOAWAY_TIMEOUT: 0x10, - CONTROL_MESSAGE_TIMEOUT: 0x11, - DATA_STREAM_TIMEOUT: 0x12, - AUTH_TOKEN_CACHE_OVERFLOW: 0x13, - DUPLICATE_AUTH_TOKEN_ALIAS: 0x14, - MALFORMED_AUTH_TOKEN: 0x16, - UNKNOWN_AUTH_TOKEN_ALIAS: 0x17, - EXPIRED_AUTH_TOKEN: 0x18, - INVALID_AUTHORITY: 0x19, - MALFORMED_AUTHORITY: 0x1a, - TOO_MANY_REQUEST_UPDATES: 0x1b, -} as const; - -export type SessionErrorCode = (typeof SESSION_ERROR)[keyof typeof SESSION_ERROR]; - -const MOQT_PROTOCOL_ERROR_SYMBOL = Symbol.for('@videojs/spf/moqt-protocol-error'); - -/** - * A wire-protocol violation detected while encoding or decoding MOQT data. `code` is the session-termination code - * (§3.5) the session driver should close the transport with — defaults to `PROTOCOL_VIOLATION`. - */ -export class MoqtProtocolError extends Error { - [MOQT_PROTOCOL_ERROR_SYMBOL] = true as const; - readonly code: SessionErrorCode; - - constructor(message: string, code: SessionErrorCode = SESSION_ERROR.PROTOCOL_VIOLATION) { - super(message); - this.name = 'MoqtProtocolError'; - this.code = code; - } -} - -export function isMoqtProtocolError(value: unknown): value is MoqtProtocolError { - return typeof value === 'object' && value !== null && MOQT_PROTOCOL_ERROR_SYMBOL in value; -} diff --git a/packages/spf/src/network/moqt/object-stream.ts b/packages/spf/src/network/moqt/object-stream.ts deleted file mode 100644 index 424c80dda2..0000000000 --- a/packages/spf/src/network/moqt/object-stream.ts +++ /dev/null @@ -1,360 +0,0 @@ -/** - * MOQT unidirectional data-stream parsing (moq-transport draft-20 §3.4, §11). - * - * Every unidirectional stream begins with a varint stream type: - * - * - `SUBGROUP_HEADER` (a Type Flags bitfield with bit 4 set, §11.4.2) — objects for one subgroup of one group of a - * subscribed track, identified by Track Alias. - * - `FETCH_HEADER` (0x05) — objects for a FETCH response, identified by Request ID. A fill fetch stream (§5.1.3) has the - * same shape and names the SUBSCRIBE or REQUEST_UPDATE that asked for it. - * - `SETUP` (0x2F00) — the peer's control stream (handled by the session). - * - `PADDING` (0x132B3E28) — bandwidth probing; drained and ignored. - * - * The parsers are async generators over a `StreamReader`, mirroring how `ChunkedStreamIterable` adapts fetch bodies - * elsewhere in `network/`. - */ -import { ByteReader, type StreamReader } from './bytes'; -import { decodeKeyValuePairs, type KeyValuePair } from './control-messages'; -import { MoqtProtocolError } from './errors'; -import { MAX_VARINT_VALUE } from './varint'; - -// ============================================================================ -// Stream types -// ============================================================================ - -export const STREAM_TYPE = { - FETCH_HEADER: 0x05, - SETUP: 0x2f00, - PADDING: 0x132b3e28, -} as const; - -/** - * Whether a stream-type varint is a SUBGROUP_HEADER. §11.4.2 describes the type as Type Flags: bit 4 is always set, - * SUBGROUP_ID_MODE 0b11 is reserved, and a value of 128 or more — or any set bit without a specified meaning — is a - * PROTOCOL_VIOLATION. Every bit below 0x80 is assigned, so "bit 7 clear" is that last rule in full. - */ -export function isSubgroupHeaderType(type: number): boolean { - if (type > 0x7f || (type & 0x10) === 0) return false; - - return (type & 0x06) >> 1 !== 0b11; -} - -// ============================================================================ -// Object model -// ============================================================================ - -/** - * Ceiling on a single object's payload, and on its Properties block. - * - * Unlike control messages — bounded by their 16-bit frame length — a data stream's payload length is an unbounded - * varint that feeds straight into `StreamReader.readBytes`, which buffers until satisfied. A malformed or hostile relay - * declaring 2^53 would exhaust memory before the read ever completed, so the declaration is rejected before any - * allocation. - * - * 16 MiB clears any real LOC frame (a 4K keyframe is low single-digit MB). The Properties block is Key-Value-Pairs - * whose individual byte values may legally reach 2^16-1 (`MAX_KVP_VALUE_LENGTH`), so its bound leaves room for several - * maximum-size values, not just typical frame metadata. - */ -export const MAX_OBJECT_PAYLOAD_LENGTH = 16 * 1024 * 1024; -export const MAX_OBJECT_PROPERTIES_LENGTH = 1024 * 1024; - -function checkPayloadLength(length: number): number { - if (length > MAX_OBJECT_PAYLOAD_LENGTH) { - throw new MoqtProtocolError(`object payload length ${length} exceeds ${MAX_OBJECT_PAYLOAD_LENGTH} bytes`); - } - - return length; -} - -export type ObjectStatus = 'normal' | 'end-of-group' | 'end-of-track'; - -const OBJECT_STATUS_WIRE: Record = { - 0: 'normal', - 3: 'end-of-group', - 4: 'end-of-track', -}; - -/** An object delivered on a subscription's subgroup stream. */ -export interface MoqtObject { - groupId: number; - objectId: number; - subgroupId: number; - /** Publisher priority; `undefined` inherits the subscription's priority. */ - priority?: number; - status: ObjectStatus; - properties: KeyValuePair[]; - payload: Uint8Array; -} - -// ============================================================================ -// Subgroup streams (§11.4.2) -// ============================================================================ - -const SUBGROUP_FLAG = { - PROPERTIES: 0x01, - SUBGROUP_ID_MODE_MASK: 0x06, - END_OF_GROUP: 0x08, - DEFAULT_PRIORITY: 0x20, - FIRST_OBJECT: 0x40, -} as const; - -export type SubgroupIdMode = 'zero' | 'first-object-id' | 'explicit'; - -export interface SubgroupHeader { - type: number; - trackAlias: number; - groupId: number; - subgroupIdMode: SubgroupIdMode; - /** Present when `subgroupIdMode` is `'explicit'`. */ - subgroupId?: number; - /** Present when the header carries an explicit priority. */ - priority?: number; - /** All objects in this subgroup carry a Properties field. */ - hasProperties: boolean; - /** This subgroup contains the largest object in the group (on FIN). */ - endOfGroup: boolean; - /** The first object on this stream is the subgroup's first published object. */ - firstObject: boolean; -} - -/** Read the SUBGROUP_HEADER fields (the stream-type varint must already be consumed). */ -export async function readSubgroupHeader(reader: StreamReader, type: number): Promise { - if (!isSubgroupHeaderType(type)) { - throw new MoqtProtocolError(`invalid subgroup header type 0x${type.toString(16)}`); - } - - const modeBits = (type & SUBGROUP_FLAG.SUBGROUP_ID_MODE_MASK) >> 1; - const subgroupIdMode: SubgroupIdMode = - modeBits === 0b00 ? 'zero' : modeBits === 0b01 ? 'first-object-id' : 'explicit'; - - const trackAlias = await reader.readVarint(); - const groupId = await reader.readVarint(); - const subgroupId = subgroupIdMode === 'explicit' ? await reader.readVarint() : undefined; - const priority = (type & SUBGROUP_FLAG.DEFAULT_PRIORITY) === 0 ? await reader.readUint8() : undefined; - - return { - type, - trackAlias, - groupId, - subgroupIdMode, - subgroupId, - priority, - hasProperties: (type & SUBGROUP_FLAG.PROPERTIES) !== 0, - endOfGroup: (type & SUBGROUP_FLAG.END_OF_GROUP) !== 0, - firstObject: (type & SUBGROUP_FLAG.FIRST_OBJECT) !== 0, - }; -} - -/** Object Properties structure (§11.2.1.2): varint length + Key-Value-Pairs. */ -async function readObjectProperties(reader: StreamReader): Promise { - const length = await reader.readVarint(); - if (length === 0) return []; - - if (length > MAX_OBJECT_PROPERTIES_LENGTH) { - throw new MoqtProtocolError(`object properties length ${length} exceeds ${MAX_OBJECT_PROPERTIES_LENGTH} bytes`); - } - - const bytes = await reader.readBytes(length); - - return decodeKeyValuePairs(new ByteReader(bytes), length); -} - -function readObjectStatus(statusWire: number): ObjectStatus { - const status = OBJECT_STATUS_WIRE[statusWire]; - if (status === undefined) throw new MoqtProtocolError(`unknown object status ${statusWire}`); - - return status; -} - -/** - * Yield the objects of one subgroup stream until FIN. Object IDs are delta-decoded (`delta + 1` from the previous - * object; absolute for the first). The stream's `subgroupId` resolves per the header's mode — for `'first-object-id'` - * it is the first object's ID. - */ -export async function* readSubgroupObjects(reader: StreamReader, header: SubgroupHeader): AsyncGenerator { - let previousObjectId: number | undefined; - let subgroupId = header.subgroupIdMode === 'explicit' ? header.subgroupId! : 0; - - while (!(await reader.atEnd())) { - const objectIdDelta = await reader.readVarint(); - - const objectId = previousObjectId === undefined ? objectIdDelta : previousObjectId + objectIdDelta + 1; - // Each operand fits the varint range, but the delta sum can round past - // 2^53-1 and silently collide subsequent IDs — the exact corruption the - // varint layer rejects loudly. - if (objectId > MAX_VARINT_VALUE) throw new MoqtProtocolError('subgroup object ID exceeds supported range'); - - if (previousObjectId === undefined && header.subgroupIdMode === 'first-object-id') { - subgroupId = objectId; - } - - previousObjectId = objectId; - - const properties = header.hasProperties ? await readObjectProperties(reader) : []; - const payloadLength = checkPayloadLength(await reader.readVarint()); - const status = payloadLength === 0 ? readObjectStatus(await reader.readVarint()) : 'normal'; - const payload = payloadLength > 0 ? await reader.readBytes(payloadLength) : new Uint8Array(0); - - yield { - groupId: header.groupId, - objectId, - subgroupId, - priority: header.priority, - status, - properties, - payload, - }; - } -} - -// ============================================================================ -// Fetch streams (§11.4.4) -// ============================================================================ - -const FETCH_FLAG = { - SUBGROUP_MODE_MASK: 0x03, - OBJECT_ID_DELTA_PRESENT: 0x04, - GROUP_ID_DELTA_PRESENT: 0x08, - PRIORITY_PRESENT: 0x10, - PROPERTIES_PRESENT: 0x20, - DATAGRAM: 0x40, -} as const; - -/** End of Range serialization flags (§11.4.4, Table 7). */ -const FETCH_END_OF_RANGE_STATUS: Record = { - 0x8c: 'non-existent', - 0x10c: 'unknown', - 0x20c: 'timed-out', -}; - -/** - * Why a run of Locations was not serialized: they do not exist, their status is unknown to the relay, or the relay's - * Fill Timeout expired before upstream supplied them (§10.2.5). - */ -export type FetchEndOfRangeStatus = 'non-existent' | 'unknown' | 'timed-out'; - -export type FetchStreamEntry = - | { - kind: 'object'; - groupId: number; - objectId: number; - /** Absent for objects with Forwarding Preference = Datagram. */ - subgroupId?: number; - priority: number; - properties: KeyValuePair[]; - payload: Uint8Array; - } - | { - kind: 'end-of-range'; - status: FetchEndOfRangeStatus; - groupId: number; - objectId: number; - }; - -/** Read the FETCH_HEADER's Request ID (the stream-type varint must already be consumed). */ -export async function readFetchHeader(reader: StreamReader): Promise<{ requestId: number }> { - return { requestId: await reader.readVarint() }; -} - -/** - * Yield the entries of one FETCH response stream until FIN. Group/object IDs are delta-decoded against the prior entry - * per §11.4.4.1; the first object must carry both deltas (as absolute values). - */ -export async function* readFetchEntries( - reader: StreamReader, - groupOrder: 'ascending' | 'descending' = 'ascending' -): AsyncGenerator { - let prior: { groupId: number; objectId: number; subgroupId?: number; priority?: number } | undefined; - - while (!(await reader.atEnd())) { - const flags = await reader.readVarint(); - const endOfRange = FETCH_END_OF_RANGE_STATUS[flags]; - - if (endOfRange !== undefined) { - const groupId = await reader.readVarint(); - const objectId = await reader.readVarint(); - - // The indicator becomes the prior Location; subgroup/priority carry - // over from the last actual object (§11.4.4.2). - prior = { groupId, objectId, subgroupId: prior?.subgroupId, priority: prior?.priority }; - yield { kind: 'end-of-range', status: endOfRange, groupId, objectId }; - continue; - } - - if (flags > 0x7f) { - throw new MoqtProtocolError(`invalid fetch serialization flags 0x${flags.toString(16)}`); - } - - const groupIdDeltaPresent = (flags & FETCH_FLAG.GROUP_ID_DELTA_PRESENT) !== 0; - const objectIdDeltaPresent = (flags & FETCH_FLAG.OBJECT_ID_DELTA_PRESENT) !== 0; - - if (prior === undefined && (!groupIdDeltaPresent || !objectIdDeltaPresent)) { - throw new MoqtProtocolError('first fetch object must carry group and object IDs'); - } - - const groupIdDelta = groupIdDeltaPresent ? await reader.readVarint() : undefined; - - // Subgroup encoding: 2 LSBs, ignored when the DATAGRAM bit is set. - const isDatagram = (flags & FETCH_FLAG.DATAGRAM) !== 0; - const subgroupMode = isDatagram ? -1 : flags & FETCH_FLAG.SUBGROUP_MODE_MASK; - let subgroupId: number | undefined; - - if (subgroupMode === 0x03) { - subgroupId = await reader.readVarint(); - } else if (subgroupMode === 0x00) { - subgroupId = 0; - } else if (subgroupMode === 0x01 || subgroupMode === 0x02) { - if (prior?.subgroupId === undefined) { - throw new MoqtProtocolError('fetch object references prior subgroup ID with no prior object'); - } - - subgroupId = subgroupMode === 0x01 ? prior.subgroupId : prior.subgroupId + 1; - } - - const objectIdDelta = objectIdDeltaPresent ? await reader.readVarint() : undefined; - - const groupId = - groupIdDelta === undefined - ? prior!.groupId - : prior === undefined - ? groupIdDelta - : groupOrder === 'ascending' - ? prior.groupId + groupIdDelta + 1 - : prior.groupId - (groupIdDelta + 1); - if (groupId < 0) throw new MoqtProtocolError('fetch group ID underflow'); - - const objectId = - prior === undefined - ? objectIdDelta! - : groupIdDelta !== undefined - ? (objectIdDelta ?? prior.objectId + 1) - : objectIdDelta !== undefined - ? prior.objectId + objectIdDelta - : prior.objectId + 1; - - // Mirror of the underflow check above: delta sums can round past 2^53-1 - // and silently collapse later locations. - if (groupId > MAX_VARINT_VALUE || objectId > MAX_VARINT_VALUE) { - throw new MoqtProtocolError('fetch location exceeds supported range'); - } - - let priority: number; - - if ((flags & FETCH_FLAG.PRIORITY_PRESENT) !== 0) { - priority = await reader.readUint8(); - } else { - if (prior?.priority === undefined) { - throw new MoqtProtocolError('fetch object references prior priority with no prior object'); - } - - priority = prior.priority; - } - - const properties = (flags & FETCH_FLAG.PROPERTIES_PRESENT) !== 0 ? await readObjectProperties(reader) : []; - const payloadLength = checkPayloadLength(await reader.readVarint()); - const payload = payloadLength > 0 ? await reader.readBytes(payloadLength) : new Uint8Array(0); - - prior = { groupId, objectId, subgroupId: subgroupId ?? prior?.subgroupId, priority }; - yield { kind: 'object', groupId, objectId, subgroupId, priority, properties, payload }; - } -} diff --git a/packages/spf/src/network/moqt/request-stream.ts b/packages/spf/src/network/moqt/request-stream.ts deleted file mode 100644 index 38c20e3637..0000000000 --- a/packages/spf/src/network/moqt/request-stream.ts +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Per-request bidirectional-stream lifecycle (moq-transport draft-20 §3.3). - * - * The control model is request-stream based: each request (SUBSCRIBE, FETCH, TRACK_STATUS, …) opens its own - * bidirectional stream, the first message on it is the request, and responses (SUBSCRIBE_OK / REQUEST_OK / - * REQUEST_ERROR / PUBLISH_DONE / GOAWAY) arrive as control messages on the same stream. There is no UNSUBSCRIBE message - * — cancellation IS the stream lifecycle: abort our sending direction (RESET_STREAM) and cancel the receiving direction - * (STOP_SENDING), per §3.3.3. - * - * Callback-shaped, no signals — the session driver binds this to its own bookkeeping; SPF actors bind signals at the - * `playback/` layer. - */ -import { type ControlMessage, ControlMessageDeframer, decodeControlMessage } from './control-messages'; -import { MoqtProtocolError } from './errors'; - -/** Structural subset of `WebTransportBidirectionalStream`. */ -export interface BidirectionalStreamLike { - readable: ReadableStream; - writable: WritableStream; -} - -export interface RequestStreamHandlers { - onMessage(message: ControlMessage): void; - /** - * The peer FINed its direction. Per §3.3.2 this signals the request is complete; an endpoint that receives a FIN - * before all required messages treats the request as failed — that judgement is the caller's (it knows which messages - * arrived). - */ - onFin?(): void; - /** Read failure, stream reset, or a decode error (`MoqtProtocolError`). */ - onError?(error: unknown): void; -} - -export interface RequestStream { - /** Send a follow-up message (e.g. REQUEST_UPDATE) on the request stream. */ - send(bytes: Uint8Array): Promise; - /** Gracefully close our sending direction (FIN). Not a cancellation. */ - finWrite(): Promise; - /** - * Cancel the request (§3.3.3): abort the sending direction and stop reading the receiving direction. `reason` is - * surfaced to the transport — a DOM caller passes a `WebTransportError` carrying the stream error code; tests pass - * anything. - */ - cancel(reason?: unknown): void; - readonly cancelled: boolean; -} - -/** - * Open a request over an established bidirectional stream: write the encoded request message, then pump incoming - * control messages to `handlers.onMessage` until FIN, reset, or cancellation. - */ -export function openRequestStream( - stream: BidirectionalStreamLike, - requestMessage: Uint8Array, - handlers: RequestStreamHandlers -): RequestStream { - const writer = stream.writable.getWriter(); - // Acquired here (not inside the loop) so `cancel()` can cancel through - // the reader — cancelling a locked stream directly throws. - const reader = stream.readable.getReader(); - let cancelled = false; - let finished = false; - - const readLoop = async () => { - const deframer = new ControlMessageDeframer(); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) break; - - for (const frame of deframer.push(value)) { - handlers.onMessage(decodeControlMessage(frame)); - } - } - - if (!cancelled) { - // A FIN that lands mid-frame is a truncated response, not a clean - // completion — surfacing it as FIN would leave the request pending - // with neither response nor error. - if (deframer.pendingBytes > 0) { - handlers.onError?.(new MoqtProtocolError('request stream ended mid-control-message')); - } else { - handlers.onFin?.(); - } - } - } catch (error) { - if (!cancelled) handlers.onError?.(error); - } finally { - reader.releaseLock(); - } - }; - - const firstWrite = writer.write(requestMessage).catch((error) => { - if (!cancelled) handlers.onError?.(error); - }); - - void readLoop(); - - return { - async send(bytes: Uint8Array): Promise { - await firstWrite; - await writer.write(bytes); - }, - - async finWrite(): Promise { - if (finished || cancelled) return; - - finished = true; - await firstWrite; - await writer.close(); - }, - - cancel(reason?: unknown): void { - if (cancelled) return; - - cancelled = true; - - if (!finished) { - finished = true; - writer.abort(reason).catch(() => {}); - } - - // STOP_SENDING on the receiving direction. The read loop's pending - // read resolves as done; `cancelled` suppresses the FIN callback. - reader.cancel(reason).catch(() => {}); - }, - - get cancelled(): boolean { - return cancelled; - }, - }; -} diff --git a/packages/spf/src/network/moqt/session.ts b/packages/spf/src/network/moqt/session.ts deleted file mode 100644 index aec5c83739..0000000000 --- a/packages/spf/src/network/moqt/session.ts +++ /dev/null @@ -1,1034 +0,0 @@ -/** - * Pure MOQT session protocol driver (moq-transport draft-20), subscribe side only. - * - * Owns the protocol mechanics over an established transport: the SETUP exchange on paired unidirectional control - * streams (§3.3), request-stream bookkeeping keyed by Request ID (§10.1 — client IDs are even, starting at 0), routing - * of incoming data streams to subscriptions (by Track Alias) and fetches (by Request ID), GOAWAY handling, and session - * termination. - * - * Deliberately callback-shaped with NO signals (like `onMediaSourceReadyStateChange`) — signal awareness enters at the - * `playback/` layer, where the moq-session actor binds these callbacks to SPF state. The transport is a structural - * subset of `WebTransport`, so tests drive the driver with an in-memory fake and the DOM layer passes a real - * `WebTransport` unchanged. - * - * Version negotiation happens at connection time (ALPN / `WT-Available-Protocols`, `MOQT_PROTOCOL_ID`), before this - * driver sees the transport. - * - * Datagram reception is not implemented: MSF maps every object to its own stream, so a subscribe-only MSF engine never - * legitimately receives OBJECT_DATAGRAMs. - */ -import { StreamReader, utf8Encode } from './bytes'; -import { - type ControlMessage, - decodeControlMessage, - encodeFetch, - encodeGoaway, - encodeRequestError, - encodeRequestOk, - encodeRequestUpdate, - encodeSetup, - encodeSubscribe, - encodeTrackStatus, - type FetchRequest, - type KeyValuePair, - MESSAGE_TYPE, - type MessageParameters, - REQUEST_ERROR_CODE, - type Redirect, - SETUP_OPTION, - type TrackNamespace, -} from './control-messages'; -import { isMoqtProtocolError, MoqtProtocolError, SESSION_ERROR } from './errors'; -import { - type FetchStreamEntry, - isSubgroupHeaderType, - type MoqtObject, - readFetchEntries, - readFetchHeader, - readSubgroupHeader, - readSubgroupObjects, - STREAM_TYPE, - type SubgroupHeader, -} from './object-stream'; -import { type BidirectionalStreamLike, openRequestStream, type RequestStream } from './request-stream'; - -// ============================================================================ -// Transport seam -// ============================================================================ - -/** - * Structural subset of `WebTransport` the session driver needs. A real `WebTransport` instance satisfies this; tests - * provide an in-memory fake (the same seam pattern as SPF's fetch injection). - */ -export interface MoqtTransport { - readonly incomingUnidirectionalStreams: ReadableStream>; - readonly incomingBidirectionalStreams: ReadableStream; - createUnidirectionalStream(): Promise>; - createBidirectionalStream(): Promise; - close(closeInfo?: { closeCode?: number; reason?: string }): void; - readonly closed: Promise; -} - -// ============================================================================ -// Public session surface -// ============================================================================ - -export interface RequestError { - errorCode: number; - retryInterval: number; - reason: string; - redirect?: Redirect; -} - -export interface SubscribeOk { - trackAlias: number; - parameters: MessageParameters; - trackProperties: KeyValuePair[]; -} - -export interface PublishDone { - statusCode: number; - /** Data streams the publisher opened; `undefined` when it could not count them (§10.12). */ - streamCount: number | undefined; - reason: string; -} - -export interface SubscriptionHandlers { - onOk?(ok: SubscribeOk): void; - onError?(error: RequestError): void; - onObject?(object: MoqtObject): void; - /** A subgroup stream finished cleanly (FIN). */ - onSubgroupEnd?(info: { groupId: number; subgroupId: number; endOfGroup: boolean }): void; - /** A subgroup stream was reset — objects from it may be missing. */ - onSubgroupReset?(info: { groupId: number; error: unknown }): void; - onDone?(done: PublishDone): void; - /** Response to a REQUEST_UPDATE sent on this subscription. */ - onUpdateOk?(): void; - /** - * PUBLISH_STATE_NOTIFY (§10.10): the publisher changed subscription state on its own — `parameters` carries only what - * changed, with LARGEST_OBJECT marking where. Informational; the session sends no reply. - */ - onStateNotify?(parameters: MessageParameters): void; - /** GOAWAY on this request stream: re-issue the request (possibly elsewhere). */ - onGoaway?(goaway: Goaway): void; -} - -export interface Subscription { - readonly requestId: number; - /** Modify the subscription (REQUEST_UPDATE, §10.9). */ - update(parameters: MessageParameters): void; - /** Tear the subscription down. MOQT has no UNSUBSCRIBE message — teardown is the request stream's lifecycle (§3.3.3). */ - cancel(reason?: unknown): void; -} - -export interface FetchOk { - endOfTrack: boolean; - endLocation: { group: number; object: number }; - parameters: MessageParameters; - trackProperties: KeyValuePair[]; -} - -export interface FetchHandlers { - onOk?(ok: FetchOk): void; - onError?(error: RequestError): void; - onEntry?(entry: FetchStreamEntry): void; - /** The fetch data stream finished cleanly (FIN). */ - onEnd?(): void; - /** The fetch data stream was reset — delivered entries may be incomplete. */ - onReset?(info: { error: unknown }): void; - onGoaway?(goaway: Goaway): void; -} - -export interface FetchHandle { - readonly requestId: number; - cancel(reason?: unknown): void; -} - -export interface TrackStatusHandlers { - onOk?(status: { parameters: MessageParameters; trackProperties: KeyValuePair[] }): void; - onError?(error: RequestError): void; -} - -export interface Goaway { - newSessionUri: string; - timeout: number; -} - -export interface IncomingPublish { - requestId: number; - trackNamespace: TrackNamespace; - trackName: string; - trackAlias: number; - parameters: MessageParameters; -} - -export interface MoqtSessionCallbacks { - /** The server's SETUP arrived; the session is fully established. */ - onReady?(serverOptions: KeyValuePair[]): void; - /** GOAWAY on the control stream: stop initiating requests, migrate. */ - onGoaway?(goaway: Goaway): void; - /** - * A server-initiated PUBLISH arrived. Call exactly one of the responders. Absent, the session rejects with - * UNINTERESTED (a subscribe-only client). - * - * `accept` sends a bare PUBLISH_OK: since draft-20 the subscription parameters (FORWARD, LOCATION_FILTER, …) are - * legal only on PUBLISH and REQUEST_UPDATE, and a parameter in the wrong message is a PROTOCOL_VIOLATION (§10.2.1). - */ - onIncomingPublish?( - publish: IncomingPublish, - respond: { accept(): void; reject(errorCode?: number, reason?: string): void } - ): void; - /** The session ended — transport closed, or a fatal protocol error. */ - onClosed?(info: { error?: unknown }): void; -} - -export interface MoqtSessionConfig { - /** Extra Setup Options to send (an implementation identifier is added automatically). */ - setupOptions?: KeyValuePair[]; - /** Identifies this implementation in SETUP (§10.3.1.5). */ - implementationName?: string; - /** - * How long to hold an incoming data stream whose Track Alias has no registered subscription yet (objects can outrace - * SUBSCRIBE_OK). §11.4.2 allows brief buffering; expired streams are dropped. Default 2000ms. - */ - unknownAliasTimeoutMs?: number; - /** - * How long to wait for a request's first response (SUBSCRIBE_OK / FETCH_OK / REQUEST_OK / REQUEST_ERROR) before - * failing it. The draft expects implementations to bound control exchanges (§3.5's CONTROL_MESSAGE_TIMEOUT); without - * this a relay that accepts the stream and then goes quiet leaves the request pending forever. Default 10000ms. - */ - requestTimeoutMs?: number; - callbacks?: MoqtSessionCallbacks; -} - -export interface MoqtSubscribeOptions { - trackNamespace: TrackNamespace; - trackName: string; - parameters?: MessageParameters; -} - -/** - * FETCH (§10.13) takes the SUBSCRIBE shape; the range is `parameters.locationFilter`, read with fetch rules (§5.1.2): a - * relative start counts back from Largest Object, an omitted end stops there, no filter means the whole track. - */ -export type MoqtFetchOptions = MoqtSubscribeOptions; - -export interface MoqtSession { - /** Resolves when the server's SETUP has been received. */ - readonly ready: Promise; - subscribe(options: MoqtSubscribeOptions, handlers?: SubscriptionHandlers): Subscription; - fetch(options: MoqtFetchOptions, handlers?: FetchHandlers): FetchHandle; - trackStatus(options: MoqtSubscribeOptions, handlers?: TrackStatusHandlers): void; - /** Send GOAWAY then close the transport session. */ - close(closeCode?: number, reason?: string): void; - destroy(): void; -} - -const DEFAULT_UNKNOWN_ALIAS_TIMEOUT_MS = 2000; -const DEFAULT_REQUEST_TIMEOUT_MS = 10_000; -const DEFAULT_IMPLEMENTATION_NAME = '@videojs/spf moqt'; - -/** - * A request failure that arrives as a _stream_ event — FIN before any response, a transport reset, or the response - * timeout — rather than as a REQUEST_ERROR message. Shaped as a `RequestError` so consumers have one failure path - * regardless of how the request died. - */ -function streamFailure(reason: string, errorCode: number = REQUEST_ERROR_CODE.INTERNAL_ERROR): RequestError { - return { errorCode, retryInterval: 0, reason }; -} - -// ============================================================================ -// Internal records -// ============================================================================ - -/** Bookkeeping `#openRequest` manages for every request kind. */ -interface RequestRecordBase { - cancelled: boolean; - pendingCancelReason?: unknown; - stream?: RequestStream; - /** - * The request's first response (an OK or a REQUEST_ERROR) arrived. Until it does, a FIN / reset / timeout on the - * stream is a failure; after it, those are ordinary end-of-request events. - */ - settled: boolean; - responseTimer?: ReturnType; -} - -interface SubscriptionRecord extends RequestRecordBase { - requestId: number; - handlers: SubscriptionHandlers; - trackAlias?: number; -} - -interface FetchRecord extends RequestRecordBase { - requestId: number; - handlers: FetchHandlers; - groupOrder: 'ascending' | 'descending'; -} - -interface TrackStatusRecord extends RequestRecordBase { - requestId: number; - handlers: TrackStatusHandlers; -} - -interface AliasWaiter { - resolve(record: SubscriptionRecord | undefined): void; - timer: ReturnType; -} - -// ============================================================================ -// Session driver -// ============================================================================ - -class MoqtSessionImpl implements MoqtSession { - readonly ready: Promise; - - #transport: MoqtTransport; - #config: MoqtSessionConfig; - #callbacks: MoqtSessionCallbacks; - - #nextRequestId = 0; // client request IDs: even, starting at 0 (§10.1) - #subscriptions = new Map(); - #fetches = new Map(); - #trackStatuses = new Map(); - #aliasRoutes = new Map(); - #aliasWaiters = new Map(); - - #resolveReady!: () => void; - #rejectReady!: (error: unknown) => void; - #controlWriter: WritableStreamDefaultWriter | undefined; - #receivedServerSetup = false; - #receivedControlGoaway = false; - #destroyed = false; - - constructor(transport: MoqtTransport, config: MoqtSessionConfig = {}) { - this.#transport = transport; - this.#config = config; - this.#callbacks = config.callbacks ?? {}; - this.ready = new Promise((resolve, reject) => { - this.#resolveReady = resolve; - this.#rejectReady = reject; - }); - // Consumers may observe readiness through `onClosed` alone. - this.ready.catch(() => {}); - - void this.#start(); - } - - // -------------------------------------------------------------------------- - // Session lifecycle - // -------------------------------------------------------------------------- - - async #start(): Promise { - // Accept loops start first: the peer's streams must be processed even - // while our own SETUP write is still propagating (either peer may send - // stream data first, §3.3). - void this.#acceptUnidirectionalStreams(); - void this.#acceptBidirectionalStreams(); - void this.#transport.closed.then( - () => this.#handleClosed(undefined), - (error) => this.#handleClosed(error) - ); - - try { - const control = await this.#transport.createUnidirectionalStream(); - - this.#controlWriter = control.getWriter(); - const options: KeyValuePair[] = [ - { - type: SETUP_OPTION.MOQT_IMPLEMENTATION, - value: utf8Encode(this.#config.implementationName ?? DEFAULT_IMPLEMENTATION_NAME), - }, - ...(this.#config.setupOptions ?? []), - ]; - - await this.#controlWriter.write(encodeSetup(options)); - } catch (error) { - this.#fatal(error); - } - } - - #fatal(error: unknown): void { - if (this.#destroyed) return; - - const closeCode = isMoqtProtocolError(error) ? error.code : SESSION_ERROR.INTERNAL_ERROR; - - try { - this.#transport.close({ closeCode, reason: error instanceof Error ? error.message : 'session error' }); - } catch { - // transport already gone - } - - this.#handleClosed(error); - } - - #handleClosed(error: unknown, { expected = false }: { expected?: boolean } = {}): void { - if (this.#destroyed) return; - - this.#destroyed = true; - const setupError = this.#receivedServerSetup - ? undefined - : (error ?? new MoqtProtocolError('session closed before server SETUP')); - - if (setupError !== undefined) this.#rejectReady(setupError); - - for (const waiters of this.#aliasWaiters.values()) { - for (const waiter of waiters) { - clearTimeout(waiter.timer); - waiter.resolve(undefined); - } - } - - this.#aliasWaiters.clear(); - - // Requests still awaiting their first response die with the session. An - // unexpected close (transport drop) is a failure each of them has to - // hear about — otherwise a dropped transport leaves subscribers pending - // forever. A deliberate `close()` is ordinary teardown, and cancelled - // requests already have their answer. - const records = [...this.#subscriptions.values(), ...this.#fetches.values(), ...this.#trackStatuses.values()]; - const pending = expected ? [] : records.filter((r) => !r.settled && !r.cancelled); - - for (const record of records) { - this.#settleRequest(record); - record.stream?.cancel(error); - } - - this.#subscriptions.clear(); - this.#fetches.clear(); - this.#trackStatuses.clear(); - this.#aliasRoutes.clear(); - this.#controlWriter = undefined; - - const failure = streamFailure( - error instanceof Error ? error.message : 'session closed before the request was answered' - ); - - for (const record of pending) record.handlers.onError?.(failure); - - // A transport that drops before server SETUP is a session failure even - // when the close itself was clean — callback-only consumers observing - // `onClosed` alone must see the error too. A deliberate local `close()` - // stays a clean close. - const closeError = error ?? (expected ? undefined : setupError); - - this.#callbacks.onClosed?.(closeError === undefined ? {} : { error: closeError }); - } - - close(closeCode = SESSION_ERROR.NO_ERROR, reason = ''): void { - if (this.#destroyed) return; - - // Best-effort GOAWAY so the peer can stop routing to us first. - this.#controlWriter?.write(encodeGoaway(0)).catch(() => {}); - - try { - this.#transport.close({ closeCode, reason }); - } catch { - // transport already gone - } - - this.#handleClosed(undefined, { expected: true }); - } - - destroy(): void { - this.close(); - } - - // -------------------------------------------------------------------------- - // Requests - // -------------------------------------------------------------------------- - - #allocateRequestId(): number { - const id = this.#nextRequestId; - - this.#nextRequestId += 2; - return id; - } - - subscribe(options: MoqtSubscribeOptions, handlers: SubscriptionHandlers = {}): Subscription { - const requestId = this.#allocateRequestId(); - const record: SubscriptionRecord = { requestId, handlers, cancelled: false, settled: false }; - - this.#subscriptions.set(requestId, record); - - const message = encodeSubscribe({ - requestId, - trackNamespace: options.trackNamespace, - trackName: options.trackName, - parameters: options.parameters, - }); - - void this.#openRequest( - message, - record, - (msg) => this.#handleSubscriptionMessage(record, msg), - (error) => { - this.#removeSubscription(record); - handlers.onError?.(error); - } - ); - - return { - requestId, - update: (parameters) => { - // REQUEST_UPDATE consumes a Request ID of its own (§10.1); the stream - // it travels on is what names the subscription. Reusing the - // subscription's id would be a duplicate the peer MUST close on. - record.stream?.send(encodeRequestUpdate(this.#allocateRequestId(), parameters)).catch(() => {}); - }, - cancel: (reason) => this.#cancelSubscription(record, reason), - }; - } - - fetch(options: MoqtFetchOptions, handlers: FetchHandlers = {}): FetchHandle { - const requestId = this.#allocateRequestId(); - const record: FetchRecord = { - requestId, - handlers, - groupOrder: options.parameters?.groupOrder ?? 'ascending', - cancelled: false, - settled: false, - }; - - this.#fetches.set(requestId, record); - - const request: FetchRequest = { requestId, ...options }; - - void this.#openRequest( - encodeFetch(request), - record, - (msg) => this.#handleFetchMessage(record, msg), - (error) => { - this.#fetches.delete(requestId); - handlers.onError?.(error); - } - ); - - return { - requestId, - cancel: (reason) => this.#cancelFetch(record, reason), - }; - } - - trackStatus(options: MoqtSubscribeOptions, handlers: TrackStatusHandlers = {}): void { - const requestId = this.#allocateRequestId(); - const record: TrackStatusRecord = { requestId, handlers, cancelled: false, settled: false }; - - // Tracked so session teardown fails a still-pending TRACK_STATUS the - // same way it fails pending subscriptions and fetches. Answered - // requests leave the map — nothing else arrives on their stream. - this.#trackStatuses.set(requestId, record); - - const message = encodeTrackStatus({ - requestId, - trackNamespace: options.trackNamespace, - trackName: options.trackName, - parameters: options.parameters, - }); - - void this.#openRequest( - message, - record, - (msg) => { - if (msg.kind === 'request-ok') { - this.#settleRequest(record); - this.#trackStatuses.delete(requestId); - handlers.onOk?.({ parameters: msg.parameters, trackProperties: msg.trackProperties }); - record.stream?.finWrite().catch(() => {}); - } else if (msg.kind === 'request-error') { - this.#settleRequest(record); - this.#trackStatuses.delete(requestId); - handlers.onError?.(msg); - record.stream?.finWrite().catch(() => {}); - } - }, - (error) => { - this.#trackStatuses.delete(requestId); - handlers.onError?.(error); - } - ); - } - - /** - * Open a request stream and bind its lifecycle to `record`. - * - * `onFailure` is the caller's "this request died without answering me" path — `request-stream` deliberately leaves - * that judgement here, since only the session knows which messages a given request kind requires. It fires for a FIN - * before any response, a non-protocol stream error (transport reset), and the response timeout; a protocol error - * still kills the whole session. Once `record.settled` is set the same events are ordinary end-of-request signals and - * are ignored. - */ - async #openRequest( - message: Uint8Array, - record: RequestRecordBase, - onMessage: (message: ControlMessage) => void, - onFailure: (error: RequestError) => void - ): Promise { - const fail = (error: RequestError): void => { - if (record.settled || record.cancelled || this.#destroyed) return; - - this.#settleRequest(record); - onFailure(error); - }; - - let stream: BidirectionalStreamLike; - - try { - stream = await this.#transport.createBidirectionalStream(); - } catch (error) { - // Losing the ability to open streams is a session-level failure, but - // this request also has to hear about it. - fail(streamFailure(error instanceof Error ? error.message : 'failed to open request stream')); - - if (!this.#destroyed) this.#fatal(error); - - return; - } - - const timeout = this.#config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS; - - if (timeout > 0 && !record.settled && !record.cancelled) { - record.responseTimer = setTimeout(() => { - const failure = streamFailure('no response before the request timeout', REQUEST_ERROR_CODE.TIMEOUT); - - // The stream dies with the request: left open, a late SUBSCRIBE_OK - // would fire onOk after onError and re-register the alias route of - // a subscription already reported dead. - record.stream?.cancel(failure); - fail(failure); - }, timeout); - } - - record.stream = openRequestStream(stream, message, { - onMessage, - onFin: () => fail(streamFailure('request stream closed before a response')), - onError: (error) => { - if (isMoqtProtocolError(error)) { - this.#fatal(error); - return; - } - - fail(streamFailure(error instanceof Error ? error.message : 'request stream failed')); - }, - }); - - // A cancel that raced the stream opening lands here. - if (record.cancelled) record.stream.cancel(record.pendingCancelReason); - } - - /** Mark a request answered (or dead) and disarm its response timeout. */ - #settleRequest(record: RequestRecordBase): void { - record.settled = true; - - if (record.responseTimer !== undefined) { - clearTimeout(record.responseTimer); - record.responseTimer = undefined; - } - } - - #handleSubscriptionMessage(record: SubscriptionRecord, message: ControlMessage): void { - switch (message.kind) { - case 'subscribe-ok': { - if (record.trackAlias !== undefined && record.trackAlias !== message.trackAlias) { - this.#fatal(new MoqtProtocolError('SUBSCRIBE_OK changed track alias')); - return; - } - - const existing = this.#aliasRoutes.get(message.trackAlias); - - if (existing && existing !== record) { - this.#fatal(new MoqtProtocolError('duplicate track alias', SESSION_ERROR.DUPLICATE_TRACK_ALIAS)); - return; - } - - this.#settleRequest(record); - record.trackAlias = message.trackAlias; - this.#aliasRoutes.set(message.trackAlias, record); - const waiters = this.#aliasWaiters.get(message.trackAlias); - - if (waiters) { - this.#aliasWaiters.delete(message.trackAlias); - - for (const waiter of waiters) { - clearTimeout(waiter.timer); - waiter.resolve(record); - } - } - - record.handlers.onOk?.({ - trackAlias: message.trackAlias, - parameters: message.parameters, - trackProperties: message.trackProperties, - }); - break; - } - case 'request-ok': - record.handlers.onUpdateOk?.(); - break; - case 'request-error': - this.#settleRequest(record); - this.#removeSubscription(record); - record.handlers.onError?.(message); - break; - case 'publish-done': - // Data streams may still be inbound; the alias route stays until - // the subscription is cancelled or the session ends, so late - // subgroups still deliver (§10.12 leaves the timing policy to us). - record.handlers.onDone?.(message); - break; - case 'publish-state-notify': - // Unilateral (§10.10): no REQUEST_OK back, and it does not count - // against MAX_REQUEST_UPDATES. - record.handlers.onStateNotify?.(message.parameters); - break; - case 'goaway': - record.handlers.onGoaway?.(message); - break; - default: - this.#fatal(new MoqtProtocolError(`unexpected ${message.kind} on a subscribe request stream`)); - } - } - - #handleFetchMessage(record: FetchRecord, message: ControlMessage): void { - switch (message.kind) { - case 'fetch-ok': - this.#settleRequest(record); - record.handlers.onOk?.({ - endOfTrack: message.endOfTrack, - endLocation: message.endLocation, - parameters: message.parameters, - trackProperties: message.trackProperties, - }); - break; - // Some deployed relays accept a FETCH with the generic REQUEST_OK - // instead of the FETCH_OK §10.13 mandates. It - // carries no End Location/End Of Track, so `onOk` can't fire — the - // fetch's actual completion still surfaces via onEntry/onEnd on the - // data stream, which this response has no bearing on. It is still - // the response, so it has to settle the request: leaving the timer - // armed would fail an answered fetch (and drop its data stream) - // once the deadline passed. - case 'request-ok': - this.#settleRequest(record); - break; - case 'request-error': - this.#settleRequest(record); - this.#fetches.delete(record.requestId); - record.handlers.onError?.(message); - break; - case 'goaway': - record.handlers.onGoaway?.(message); - break; - default: - this.#fatal(new MoqtProtocolError(`unexpected ${message.kind} on a fetch request stream`)); - } - } - - #cancelSubscription(record: SubscriptionRecord, reason?: unknown): void { - if (record.cancelled) return; - - record.cancelled = true; - record.pendingCancelReason = reason; - this.#settleRequest(record); - record.stream?.cancel(reason); - this.#removeSubscription(record); - } - - #removeSubscription(record: SubscriptionRecord): void { - this.#subscriptions.delete(record.requestId); - - if (record.trackAlias !== undefined && this.#aliasRoutes.get(record.trackAlias) === record) { - this.#aliasRoutes.delete(record.trackAlias); - } - } - - #cancelFetch(record: FetchRecord, reason?: unknown): void { - if (record.cancelled) return; - - record.cancelled = true; - record.pendingCancelReason = reason; - this.#settleRequest(record); - record.stream?.cancel(reason); - this.#fetches.delete(record.requestId); - } - - // -------------------------------------------------------------------------- - // Incoming unidirectional streams (control, subgroup, fetch, padding) - // -------------------------------------------------------------------------- - - async #acceptUnidirectionalStreams(): Promise { - const reader = this.#transport.incomingUnidirectionalStreams.getReader(); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) break; - - void this.#handleUnidirectionalStream(value).catch((error) => { - if (isMoqtProtocolError(error)) this.#fatal(error); - }); - } - } catch { - // Transport went away; `closed` handles the surfacing. - } finally { - reader.releaseLock(); - } - } - - async #handleUnidirectionalStream(stream: ReadableStream): Promise { - const reader = new StreamReader(stream); - const streamType = await reader.readVarint(); - - if (streamType === STREAM_TYPE.SETUP) { - await this.#runControlStream(reader); - return; - } - - if (isSubgroupHeaderType(streamType)) { - const header = await readSubgroupHeader(reader, streamType); - - await this.#runSubgroupStream(reader, header); - return; - } - - if (streamType === STREAM_TYPE.FETCH_HEADER) { - const { requestId } = await readFetchHeader(reader); - - await this.#runFetchStream(reader, requestId); - return; - } - - if (streamType === STREAM_TYPE.PADDING) { - await reader.cancel(); - return; - } - - await reader.cancel(); - throw new MoqtProtocolError(`unknown unidirectional stream type 0x${streamType.toString(16)}`); - } - - /** Read one control-message frame using the pull-based stream reader. */ - async #readControlFrame(reader: StreamReader, type: number): Promise { - const high = await reader.readUint8(); - const low = await reader.readUint8(); - const body = await reader.readBytes(high * 256 + low); - - return decodeControlMessage({ type, body }); - } - - async #runControlStream(reader: StreamReader): Promise { - // The stream-type varint (0x2F00) doubles as the first message's type. - const setup = await this.#readControlFrame(reader, MESSAGE_TYPE.SETUP); - if (setup.kind !== 'setup') throw new MoqtProtocolError('control stream did not begin with SETUP'); - - if (this.#receivedServerSetup) { - throw new MoqtProtocolError('received a second control stream'); - } - - this.#receivedServerSetup = true; - this.#resolveReady(); - this.#callbacks.onReady?.(setup.options); - - // Subsequent control-stream messages: GOAWAY (at most once). - while (!(await reader.atEnd())) { - const type = await reader.readVarint(); - const message = await this.#readControlFrame(reader, type); - if (message.kind !== 'goaway') throw new MoqtProtocolError(`unexpected ${message.kind} on the control stream`); - - if (this.#receivedControlGoaway) { - throw new MoqtProtocolError('received more than one GOAWAY on the control stream'); - } - - this.#receivedControlGoaway = true; - this.#callbacks.onGoaway?.(message); - } - - // A closed control stream ends the session (§3.3). - if (!this.#destroyed) { - this.#fatal(new MoqtProtocolError('peer closed its control stream')); - } - } - - /** Wait briefly for a subscription to claim `trackAlias` (§11.4.2 buffering). */ - #waitForAlias(trackAlias: number): Promise { - const known = this.#aliasRoutes.get(trackAlias); - if (known || this.#destroyed) return Promise.resolve(known); - - return new Promise((resolve) => { - const waiters = this.#aliasWaiters.get(trackAlias) ?? []; - const timeout = this.#config.unknownAliasTimeoutMs ?? DEFAULT_UNKNOWN_ALIAS_TIMEOUT_MS; - const waiter: AliasWaiter = { - resolve, - timer: setTimeout(() => { - const remaining = this.#aliasWaiters.get(trackAlias)?.filter((w) => w !== waiter); - - if (remaining?.length) this.#aliasWaiters.set(trackAlias, remaining); - else this.#aliasWaiters.delete(trackAlias); - - resolve(undefined); - }, timeout), - }; - - waiters.push(waiter); - this.#aliasWaiters.set(trackAlias, waiters); - }); - } - - async #runSubgroupStream(reader: StreamReader, header: SubgroupHeader): Promise { - const record = await this.#waitForAlias(header.trackAlias); - - if (!record || record.cancelled) { - await reader.cancel(); - return; - } - - let lastSubgroupId = header.subgroupIdMode === 'explicit' ? header.subgroupId! : 0; - - try { - for await (const object of readSubgroupObjects(reader, header)) { - if (record.cancelled) { - await reader.cancel(); - return; - } - - lastSubgroupId = object.subgroupId; - record.handlers.onObject?.(object); - } - - record.handlers.onSubgroupEnd?.({ - groupId: header.groupId, - subgroupId: lastSubgroupId, - endOfGroup: header.endOfGroup, - }); - } catch (error) { - if (isMoqtProtocolError(error)) throw error; - - // A reset stream is a delivery event (timeout, cancellation), not a - // session error — surface it to the subscription. - record.handlers.onSubgroupReset?.({ groupId: header.groupId, error }); - } - } - - async #runFetchStream(reader: StreamReader, requestId: number): Promise { - const record = this.#fetches.get(requestId); - - // A FETCH_HEADER naming no fetch of ours is dropped, not fatal. That - // includes a fill fetch stream (§5.1.3), keyed by a SUBSCRIBE's Request - // ID — this subscriber never asks for one, so none is expected. - if (!record || record.cancelled) { - await reader.cancel(); - return; - } - - try { - for await (const entry of readFetchEntries(reader, record.groupOrder)) { - if (record.cancelled) { - await reader.cancel(); - return; - } - - record.handlers.onEntry?.(entry); - } - - record.handlers.onEnd?.(); - } catch (error) { - if (isMoqtProtocolError(error)) throw error; - - // A reset mid-replay means entries may be missing — never report it - // as the clean FIN `onEnd` promises. - record.handlers.onReset?.({ error }); - } - } - - // -------------------------------------------------------------------------- - // Incoming bidirectional streams (server-initiated requests) - // -------------------------------------------------------------------------- - - async #acceptBidirectionalStreams(): Promise { - const reader = this.#transport.incomingBidirectionalStreams.getReader(); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) break; - - void this.#handleIncomingRequest(value).catch((error) => { - if (isMoqtProtocolError(error)) this.#fatal(error); - }); - } - } catch { - // Transport went away. - } finally { - reader.releaseLock(); - } - } - - async #handleIncomingRequest(stream: BidirectionalStreamLike): Promise { - const reader = new StreamReader(stream.readable); - const type = await reader.readVarint(); - const message = await this.#readControlFrame(reader, type); - - const respond = async (bytes: Uint8Array) => { - const writer = stream.writable.getWriter(); - - try { - await writer.write(bytes); - await writer.close(); - } catch { - // Peer cancelled; nothing to clean up. - } - - await reader.cancel(); - }; - - if (message.kind === 'publish') { - const callbacks = this.#callbacks; - - if (callbacks.onIncomingPublish) { - let responded = false; - - callbacks.onIncomingPublish(message, { - accept: () => { - if (responded) return; - - responded = true; - void respond(encodeRequestOk()); - }, - reject: (errorCode = REQUEST_ERROR_CODE.UNINTERESTED, reason = '') => { - if (responded) return; - - responded = true; - void respond(encodeRequestError(errorCode, reason)); - }, - }); - return; - } - - await respond(encodeRequestError(REQUEST_ERROR_CODE.UNINTERESTED, 'subscribe-only client')); - return; - } - - // Any other server-initiated request: this client doesn't serve them. - await respond(encodeRequestError(REQUEST_ERROR_CODE.NOT_SUPPORTED, 'subscribe-only client')); - } -} - -/** - * Create a MOQT session driver over an established transport. - * - * @example - * ```ts - * const transport = new WebTransport(url, { protocols: [MOQT_PROTOCOL_ID] }); - * await transport.ready; - * const session = createMoqtSession(transport, { - * callbacks: { onGoaway: (g) => migrate(g.newSessionUri) }, - * }); - * const subscription = session.subscribe( - * { trackNamespace: ['live', 'stream1'], trackName: 'catalog' }, - * { onObject: (object) => handleCatalogObject(object) } - * ); - * ```; - */ -export function createMoqtSession(transport: MoqtTransport, config: MoqtSessionConfig = {}): MoqtSession { - return new MoqtSessionImpl(transport, config); -} diff --git a/packages/spf/src/network/moqt/tests/control-messages.test.ts b/packages/spf/src/network/moqt/tests/control-messages.test.ts deleted file mode 100644 index fdf49aba02..0000000000 --- a/packages/spf/src/network/moqt/tests/control-messages.test.ts +++ /dev/null @@ -1,576 +0,0 @@ -import { describe, expect, it } from 'vite-plus/test'; - -import { ByteReader, ByteWriter, utf8Encode } from '../bytes'; -import { - ControlMessageDeframer, - decodeControlMessage, - decodeKeyValuePairs, - decodeLocationFilter, - decodeMessageParameters, - encodeFetch, - encodeFetchOk, - encodeGoaway, - encodeKeyValuePairs, - encodeLocationFilter, - encodeMessageParameters, - encodePublishDone, - encodePublishNamespace, - encodePublishStateNotify, - encodeRequestError, - encodeRequestOk, - encodeSetup, - encodeSubscribe, - encodeSubscribeOk, - isRetryablePublishDoneStatus, - isRetryableRequestErrorCode, - type LocationFilter, - MESSAGE_TYPE, - type MessageParameters, - PARAMETER_TYPE, - PUBLISH_DONE_STATUS, - REQUEST_ERROR_CODE, - SETUP_OPTION, -} from '../control-messages'; -import { MoqtProtocolError } from '../errors'; - -function frames(...messages: Uint8Array[]): Uint8Array { - const merged = new Uint8Array(messages.reduce((total, m) => total + m.length, 0)); - let offset = 0; - - for (const message of messages) { - merged.set(message, offset); - offset += message.length; - } - - return merged; -} - -function decodeAll(bytes: Uint8Array) { - const deframer = new ControlMessageDeframer(); - - return deframer.push(bytes).map(decodeControlMessage); -} - -function encodeParameters(parameters: MessageParameters): Uint8Array { - const writer = new ByteWriter(); - - encodeMessageParameters(writer, parameters); - return writer.toBytes(); -} - -describe('ControlMessageDeframer', () => { - it('reassembles messages split across arbitrary chunk boundaries', () => { - const encoded = frames( - encodeSubscribe({ requestId: 0, trackNamespace: ['live', 'a'], trackName: 'video' }), - encodeGoaway(250) - ); - - // Split at every possible boundary and confirm both frames come out. - for (let split = 1; split < encoded.length; split++) { - const deframer = new ControlMessageDeframer(); - const first = deframer.push(encoded.subarray(0, split)); - const second = deframer.push(encoded.subarray(split)); - const all = [...first, ...second]; - - expect(all).toHaveLength(2); - expect(all[0]!.type).toBe(MESSAGE_TYPE.SUBSCRIBE); - expect(all[1]!.type).toBe(MESSAGE_TYPE.GOAWAY); - expect(deframer.pendingBytes).toBe(0); - } - }); - - it('yields one frame per push when messages arrive whole', () => { - const deframer = new ControlMessageDeframer(); - - expect(deframer.push(encodeGoaway(0))).toHaveLength(1); - expect(deframer.push(encodePublishDone(0x2, 5, 'track ended'))).toHaveLength(1); - }); -}); - -describe('encodeSubscribe', () => { - it('round-trips through the decoder', () => { - const parameters: MessageParameters = { - subscriberPriority: 16, - groupOrder: 'ascending', - locationFilter: { type: 'next-object' }, - forward: 1, - }; - const [message] = decodeAll( - encodeSubscribe({ requestId: 4, trackNamespace: ['live', 'stream1'], trackName: 'catalog', parameters }) - ); - - expect(message).toMatchObject({ - kind: 'subscribe', - requestId: 4, - trackNamespace: ['live', 'stream1'], - trackName: 'catalog', - parameters: { - subscriberPriority: 16, - groupOrder: 'ascending', - locationFilter: { type: 'next-object' }, - forward: 1, - }, - }); - }); - - it('round-trips the canonical current-group join: Next Object plus a StartGroup=1 fill', () => { - const parameters: MessageParameters = { - locationFilter: { type: 'next-object' }, - fillParameters: { locationFilter: { type: 'relative-group', groupsBeforeNext: 1 } }, - }; - const [message] = decodeAll( - encodeSubscribe({ requestId: 0, trackNamespace: ['live'], trackName: 'video', parameters }) - ); - - expect(message).toMatchObject({ kind: 'subscribe', parameters }); - }); - - it('rejects empty namespace fields', () => { - expect(() => encodeSubscribe({ requestId: 0, trackNamespace: [''], trackName: 't' })).toThrow(MoqtProtocolError); - }); -}); - -describe('encodeFetch', () => { - it('round-trips a fetch whose range rides in LOCATION_FILTER', () => { - const [message] = decodeAll( - encodeFetch({ - requestId: 2, - trackNamespace: ['live'], - trackName: 'video', - parameters: { locationFilter: { type: 'absolute', start: { group: 10, object: 0 }, endGroupDelta: 2 } }, - }) - ); - - expect(message).toEqual({ - kind: 'fetch', - request: { - requestId: 2, - trackNamespace: ['live'], - trackName: 'video', - parameters: { locationFilter: { type: 'absolute', start: { group: 10, object: 0 }, endGroupDelta: 2 } }, - }, - }); - }); - - it('round-trips an unfiltered fetch (the whole track up to Largest Object)', () => { - const [message] = decodeAll(encodeFetch({ requestId: 6, trackNamespace: ['live'], trackName: 'catalog' })); - - expect(message).toEqual({ - kind: 'fetch', - request: { requestId: 6, trackNamespace: ['live'], trackName: 'catalog', parameters: {} }, - }); - }); -}); - -describe('encodeSubscribeOk', () => { - it('matches relay 0.14.17 framing with content and trailing track properties', () => { - const wire = Uint8Array.of(0x04, 0x00, 0x09, 0x07, 0x01, 0x09, 0x80, 0xff, 0x80, 0x80, 0x02, 0x01); - const parameters = { largestObject: { group: 255, object: 128 } }; - const trackProperties = [{ type: 0x02, value: 1 }]; - - expect(encodeSubscribeOk(7, parameters, trackProperties)).toEqual(wire); - expect(decodeAll(wire)).toEqual([{ kind: 'subscribe-ok', trackAlias: 7, parameters, trackProperties }]); - }); - - it('round-trips alias, parameters, and track properties', () => { - const [message] = decodeAll( - encodeSubscribeOk(7, { expires: 30_000, largestObject: { group: 41, object: 12 } }, [{ type: 0x02, value: 1 }]) - ); - - expect(message).toMatchObject({ - kind: 'subscribe-ok', - trackAlias: 7, - parameters: { expires: 30_000, largestObject: { group: 41, object: 12 } }, - }); - expect(message).toHaveProperty('trackProperties', [{ type: 0x02, value: 1 }]); - }); -}); - -describe('encodeRequestOk', () => { - it('matches relay 0.14.17 framing when acknowledging an update after content exists', () => { - const wire = Uint8Array.of(0x07, 0x00, 0x06, 0x01, 0x09, 0x80, 0xff, 0x80, 0x80); - const parameters = { largestObject: { group: 255, object: 128 } }; - - expect(encodeRequestOk(parameters)).toEqual(wire); - expect(decodeAll(wire)).toEqual([{ kind: 'request-ok', parameters, trackProperties: [] }]); - }); -}); - -describe('encodePublishDone', () => { - it('round-trips a counted stream total', () => { - const [message] = decodeAll(encodePublishDone(PUBLISH_DONE_STATUS.TRACK_ENDED, 5, 'ended')); - - expect(message).toEqual({ - kind: 'publish-done', - statusCode: PUBLISH_DONE_STATUS.TRACK_ENDED, - streamCount: 5, - reason: 'ended', - }); - }); - - it('reads the 2^64-1 "could not count" sentinel as an undefined stream count', () => { - // Status, then the 9-byte varint 0xFF..FF (2^64-1), then an empty reason. - const body = Uint8Array.of(PUBLISH_DONE_STATUS.GOING_AWAY, ...new Array(9).fill(0xff), 0x00); - const message = decodeControlMessage({ type: MESSAGE_TYPE.PUBLISH_DONE, body }); - - expect(message).toEqual({ - kind: 'publish-done', - statusCode: PUBLISH_DONE_STATUS.GOING_AWAY, - streamCount: undefined, - reason: '', - }); - }); - - it('rejects a stream count above 2^53-1 that is not the sentinel', () => { - // A 9-byte varint one bit short of the sentinel: 2^63 + …, not a count any publisher can mean. - const body = Uint8Array.of(PUBLISH_DONE_STATUS.GOING_AWAY, 0xff, 0x80, ...new Array(7).fill(0xff), 0x00); - - expect(() => decodeControlMessage({ type: MESSAGE_TYPE.PUBLISH_DONE, body })).toThrow(MoqtProtocolError); - }); -}); - -describe('encodePublishStateNotify', () => { - it('round-trips the changed parameters', () => { - const parameters: MessageParameters = { - largestObject: { group: 9, object: 4 }, - locationFilter: { type: 'relative-group', groupsBeforeNext: 0 }, - }; - const [message] = decodeAll(encodePublishStateNotify(parameters)); - - expect(message).toEqual({ kind: 'publish-state-notify', parameters }); - }); -}); - -describe('encodeRequestError', () => { - it('round-trips code, retry interval, and reason', () => { - const [message] = decodeAll(encodeRequestError(REQUEST_ERROR_CODE.DOES_NOT_EXIST, 'no such track', 1500)); - - expect(message).toEqual({ - kind: 'request-error', - errorCode: REQUEST_ERROR_CODE.DOES_NOT_EXIST, - retryInterval: 1500, - reason: 'no such track', - }); - }); -}); - -describe('encodeSetup', () => { - it('round-trips setup options as generic key-value pairs', () => { - const [message] = decodeAll( - encodeSetup([ - { type: SETUP_OPTION.MOQT_IMPLEMENTATION, value: utf8Encode('spf-test') }, - { type: SETUP_OPTION.MAX_REQUEST_UPDATES, value: 3 }, - ]) - ); - - expect(message?.kind).toBe('setup'); - - if (message?.kind !== 'setup') return; - - // Serialized in ascending type order regardless of input order. - expect(message.options.map((o) => o.type)).toEqual([ - SETUP_OPTION.MOQT_IMPLEMENTATION, - SETUP_OPTION.MAX_REQUEST_UPDATES, - ]); - expect(message.options[1]!.value).toBe(3); - }); -}); - -describe('encodeGoaway', () => { - it('encodes a zero-length URI (client rule) and round-trips the timeout', () => { - const [message] = decodeAll(encodeGoaway(500)); - - expect(message).toEqual({ kind: 'goaway', newSessionUri: '', timeout: 500 }); - }); -}); - -describe('encodePublishNamespace', () => { - it('round-trips through the decoder', () => { - const [message] = decodeAll( - encodePublishNamespace({ requestId: 1, trackNamespace: ['anon'], parameters: { forward: 1 } }) - ); - - expect(message).toMatchObject({ - kind: 'publish-namespace', - requestId: 1, - trackNamespace: ['anon'], - parameters: { forward: 1 }, - }); - }); -}); - -describe('decodeControlMessage', () => { - it('throws MoqtProtocolError for unknown message types', () => { - expect(() => decodeControlMessage({ type: 0x99, body: new Uint8Array(0) })).toThrow(MoqtProtocolError); - }); - - it('throws when the body has trailing bytes', () => { - // GOAWAY body: uri length 0, timeout 0, plus a stray trailing byte. - expect(() => decodeControlMessage({ type: MESSAGE_TYPE.GOAWAY, body: new Uint8Array([0, 0, 0xab]) })).toThrow( - MoqtProtocolError - ); - }); - - it('throws MoqtProtocolError (not RangeError) for a truncated body', () => { - // PUBLISH_NAMESPACE body cut short: request id, then no namespace — - // the RangeError from reading past the frame must be normalized so - // malformed frames terminate the session. - expect(() => decodeControlMessage({ type: MESSAGE_TYPE.PUBLISH_NAMESPACE, body: new Uint8Array([0x01]) })).toThrow( - MoqtProtocolError - ); - - // A namespace field whose declared length overruns the frame. - const body = new ByteWriter(); - - body.writeVarint(1); // request id - body.writeVarint(1); // field count - body.writeVarint(10); // field length, followed by only 2 bytes - body.writeBytes(utf8Encode('ab')); - expect(() => decodeControlMessage({ type: MESSAGE_TYPE.PUBLISH_NAMESPACE, body: body.toBytes() })).toThrow( - MoqtProtocolError - ); - }); -}); - -describe('encodeMessageParameters', () => { - it('round-trips every supported parameter', () => { - const parameters: MessageParameters = { - objectDeliveryTimeout: 100, - subgroupDeliveryTimeout: 200, - authorizationTokens: [utf8Encode('tok-a'), utf8Encode('tok-b')], - expires: 60_000, - largestObject: { group: 100, object: 3 }, - forward: 0, - subscriberPriority: 200, - locationFilter: { type: 'absolute', start: { group: 5, object: 1 }, endGroupDelta: 4 }, - groupOrder: 'descending', - fillParameters: { - fillTimeout: 500, - subscriberPriority: 8, - locationFilter: { type: 'relative-group', groupsBeforeNext: 1 }, - groupOrder: 'ascending', - }, - newGroupRequest: 42, - includeProperties: 0, - }; - const decoded = decodeMessageParameters(new ByteReader(encodeParameters(parameters))); - - expect(decoded).toEqual(parameters); - }); - - it('throws MoqtProtocolError on an unknown parameter type', () => { - // Hand-craft: 1 parameter, type 0x99 (unknown). - const writer = new ByteWriter(); - - writer.writeVarint(1); - writer.writeVarint(0x99); - expect(() => decodeMessageParameters(new ByteReader(writer.toBytes()))).toThrow(MoqtProtocolError); - }); - - // Draft-17+ vector from moq-dev/moq#3561, shipped in moq-relay 0.14.17. - it('frames LARGEST_OBJECT as two bare varints, byte-for-byte with moq-relay', () => { - const parameters = { largestObject: { group: 255, object: 128 } }; - const wire = Uint8Array.of(0x01, 0x09, 0x80, 0xff, 0x80, 0x80); - - expect(encodeParameters(parameters)).toEqual(wire); - expect(decodeMessageParameters(new ByteReader(wire))).toEqual(parameters); - }); - - it.each([ - [0x01, 0x09], - [0x01, 0x09, 0x00], - [0x01, 0x09, 0x80], - [0x01, 0x09, 0x00, 0x80], - ])('rejects a truncated LARGEST_OBJECT (case %#)', (...wire) => { - expect(() => decodeControlMessage({ type: MESSAGE_TYPE.REQUEST_OK, body: Uint8Array.from(wire) })).toThrow( - MoqtProtocolError - ); - }); - - it('keeps parameters following a small LARGEST_OBJECT aligned', () => { - const parameters: MessageParameters = { largestObject: { group: 0, object: 1 }, forward: 1, includeProperties: 0 }; - const wire = Uint8Array.of(0x03, 0x09, 0x00, 0x01, 0x07, 0x01, 0x25, 0x00); - - expect(encodeParameters(parameters)).toEqual(wire); - expect(decodeMessageParameters(new ByteReader(wire))).toEqual(parameters); - }); - - // Wire vector matches moq-relay 0.17.0, which decodes 0x35 as a bare bool (moq-dev/moq#4610). - it.each([0, 1] as const)('frames INCLUDE_PROPERTIES %i as a bare byte', (includeProperties) => { - const wire = Uint8Array.of(0x01, 0x35, includeProperties); - - expect(encodeParameters({ includeProperties })).toEqual(wire); - expect(decodeMessageParameters(new ByteReader(wire))).toEqual({ includeProperties }); - }); - - it('rejects INCLUDE_PROPERTIES values other than 0 and 1', () => { - expect(() => decodeMessageParameters(new ByteReader(Uint8Array.of(0x01, 0x35, 0x02)))).toThrow( - /INCLUDE_PROPERTIES/ - ); - }); - - it('encodes FILL_PARAMETERS as a nested parameter list', () => { - const bytes = encodeParameters({ - fillParameters: { locationFilter: { type: 'relative-group', groupsBeforeNext: 1 } }, - }); - - // count 1, type 0x23, length 4, then the nested list: count 1, type 0x21, length 1, StartGroup 1. - expect(Array.from(bytes)).toEqual([0x01, 0x23, 0x04, 0x01, 0x21, 0x01, 0x01]); - }); - - it('rejects parameters outside Table 6 inside FILL_PARAMETERS, on both sides', () => { - // Decode: FILL_PARAMETERS whose nested list carries FORWARD (0x10). - const writer = new ByteWriter(); - - writer.writeVarint(1); - writer.writeVarint(PARAMETER_TYPE.FILL_PARAMETERS); - writer.writeVarint(3); - writer.writeVarint(1); // nested count - writer.writeVarint(PARAMETER_TYPE.FORWARD); - writer.writeUint8(1); - expect(() => decodeMessageParameters(new ByteReader(writer.toBytes()))).toThrow(/FILL_PARAMETERS/); - - // Encode: a range filter type the fill scope excludes (TRACK_PROPERTY_FILTER). - expect(() => - encodeParameters({ - fillParameters: { rangeFilters: [{ type: PARAMETER_TYPE.TRACK_PROPERTY_FILTER, value: new Uint8Array(0) }] }, - }) - ).toThrow(/FILL_PARAMETERS/); - }); -}); - -describe('encodeLocationFilter', () => { - it('round-trips every filter shape', () => { - const filters: LocationFilter[] = [ - { type: 'none' }, - { type: 'next-object' }, - { type: 'relative-group', groupsBeforeNext: 0 }, - { type: 'relative-group', groupsBeforeNext: 1 }, - { type: 'relative-group', groupsBeforeNext: 5 }, - { type: 'absolute', start: { group: 3, object: 9 } }, - { type: 'absolute', start: { group: 3, object: 9 }, endGroupDelta: 0 }, - { type: 'absolute', start: { group: 3, object: 9 }, endGroupDelta: 2, endObject: 7 }, - ]; - - for (const filter of filters) { - expect(decodeLocationFilter(encodeLocationFilter(filter))).toEqual(filter); - } - }); - - it('selects the meaning by field count (§5.1.2)', () => { - expect(Array.from(encodeLocationFilter({ type: 'none' }))).toEqual([]); - expect(Array.from(encodeLocationFilter({ type: 'relative-group', groupsBeforeNext: 1 }))).toEqual([1]); - expect(Array.from(encodeLocationFilter({ type: 'next-object' }))).toEqual([0, 0]); - expect(Array.from(encodeLocationFilter({ type: 'absolute', start: { group: 3, object: 9 } }))).toEqual([3, 9]); - expect( - Array.from( - encodeLocationFilter({ type: 'absolute', start: { group: 3, object: 9 }, endGroupDelta: 2, endObject: 7 }) - ) - ).toEqual([3, 9, 2, 7]); - }); - - it('normalizes an open-ended absolute {0,0} to no filter rather than the Next Object spelling', () => { - expect(Array.from(encodeLocationFilter({ type: 'absolute', start: { group: 0, object: 0 } }))).toEqual([]); - // Bounded, {0,0} is a real absolute start. - expect( - Array.from(encodeLocationFilter({ type: 'absolute', start: { group: 0, object: 0 }, endGroupDelta: 3 })) - ).toEqual([0, 0, 3]); - }); - - it('rejects an end object without an end group', () => { - expect(() => encodeLocationFilter({ type: 'absolute', start: { group: 1, object: 0 }, endObject: 4 })).toThrow( - MoqtProtocolError - ); - }); - - it('rejects more than four fields', () => { - expect(() => decodeLocationFilter(Uint8Array.of(1, 2, 3, 4, 5))).toThrow(MoqtProtocolError); - }); - - it('rejects an end group past the supported range', () => { - const writer = new ByteWriter(); - - writer.writeVarint(Number.MAX_SAFE_INTEGER); - writer.writeVarint(0); - writer.writeVarint(1); - expect(() => decodeLocationFilter(writer.toBytes())).toThrow(MoqtProtocolError); - }); -}); - -describe('encodeFetchOk', () => { - it('round-trips and rejects end-of-track values other than 0 and 1', () => { - const notEnded = encodeFetchOk(false, { group: 3, object: 9 }); - const ended = encodeFetchOk(true, { group: 3, object: 9 }); - - expect(decodeAll(notEnded)[0]).toMatchObject({ kind: 'fetch-ok', endOfTrack: false }); - expect(decodeAll(ended)[0]).toMatchObject({ kind: 'fetch-ok', endOfTrack: true }); - - // The end-of-track byte is the single position where the two differ. - const offset = notEnded.findIndex((byte, index) => byte !== ended[index]); - const invalid = notEnded.slice(); - - invalid[offset] = 2; - expect(() => decodeAll(invalid)).toThrow(MoqtProtocolError); - }); -}); - -describe('encodeKeyValuePairs', () => { - it('delta-encodes types and round-trips even/odd values', () => { - const pairs = [ - { type: 0x02, value: 7 }, - { type: 0x07, value: utf8Encode('bytes') }, - { type: 0x08, value: 1_000_000 }, - ]; - const writer = new ByteWriter(); - - encodeKeyValuePairs(writer, pairs); - const bytes = writer.toBytes(); - - // First delta is the absolute type (0x02), then 5, then 1. - expect(bytes[0]).toBe(0x02); - const decoded = decodeKeyValuePairs(new ByteReader(bytes), bytes.length); - - expect(decoded).toEqual(pairs); - }); -}); - -describe('isRetryableRequestErrorCode', () => { - it('keeps transient state-shaped failures retryable', () => { - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.DOES_NOT_EXIST)).toBe(true); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.TIMEOUT)).toBe(true); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.INTERNAL_ERROR)).toBe(true); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.GOING_AWAY)).toBe(true); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.EXCESSIVE_LOAD)).toBe(true); - // EXPIRED_AUTH_TOKEN has its own refresh path; the generic classifier - // must not preempt it. - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.EXPIRED_AUTH_TOKEN)).toBe(true); - }); - - it('treats request-shaped rejections as permanent', () => { - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.UNAUTHORIZED)).toBe(false); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.MALFORMED_AUTH_TOKEN)).toBe(false); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.NOT_SUPPORTED)).toBe(false); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.MALFORMED_TRACK)).toBe(false); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.INVALID_FILTER)).toBe(false); - expect(isRetryableRequestErrorCode(REQUEST_ERROR_CODE.REDIRECT)).toBe(false); - }); - - it('degrades unknown codes to retryable, not dead', () => { - expect(isRetryableRequestErrorCode(0x7fff)).toBe(true); - }); -}); - -describe('isRetryablePublishDoneStatus', () => { - it('keeps publisher/relay life-cycle ends retryable', () => { - expect(isRetryablePublishDoneStatus(PUBLISH_DONE_STATUS.TRACK_ENDED)).toBe(true); - expect(isRetryablePublishDoneStatus(PUBLISH_DONE_STATUS.GOING_AWAY)).toBe(true); - expect(isRetryablePublishDoneStatus(PUBLISH_DONE_STATUS.TOO_FAR_BEHIND)).toBe(true); - expect(isRetryablePublishDoneStatus(0x7fff)).toBe(true); - }); - - it('treats auth-shaped and malformed-track ends as permanent', () => { - expect(isRetryablePublishDoneStatus(PUBLISH_DONE_STATUS.UNAUTHORIZED)).toBe(false); - expect(isRetryablePublishDoneStatus(PUBLISH_DONE_STATUS.EXPIRED)).toBe(false); - expect(isRetryablePublishDoneStatus(PUBLISH_DONE_STATUS.MALFORMED_TRACK)).toBe(false); - }); -}); diff --git a/packages/spf/src/network/moqt/tests/object-stream.test.ts b/packages/spf/src/network/moqt/tests/object-stream.test.ts deleted file mode 100644 index de3e89f8f2..0000000000 --- a/packages/spf/src/network/moqt/tests/object-stream.test.ts +++ /dev/null @@ -1,449 +0,0 @@ -import { describe, expect, it } from 'vite-plus/test'; - -import { ByteWriter, StreamReader, utf8Encode } from '../bytes'; -import { MoqtProtocolError } from '../errors'; -import { - type FetchStreamEntry, - isSubgroupHeaderType, - MAX_OBJECT_PAYLOAD_LENGTH, - MAX_OBJECT_PROPERTIES_LENGTH, - type MoqtObject, - readFetchEntries, - readFetchHeader, - readSubgroupHeader, - readSubgroupObjects, -} from '../object-stream'; - -function streamOf(bytes: Uint8Array, chunkSize = Number.POSITIVE_INFINITY): ReadableStream { - return new ReadableStream({ - start(controller) { - for (let offset = 0; offset < bytes.length; offset += chunkSize) { - controller.enqueue(bytes.subarray(offset, Math.min(offset + chunkSize, bytes.length))); - } - - controller.close(); - }, - }); -} - -/** Build a subgroup stream: header (with explicit subgroup id + priority) and objects. */ -function encodeSubgroupStream(options: { - type: number; - trackAlias: number; - groupId: number; - subgroupId?: number; - priority?: number; - objects: { objectIdDelta: number; payload?: Uint8Array; status?: number; properties?: Uint8Array }[]; -}): Uint8Array { - const writer = new ByteWriter(); - - writer.writeVarint(options.type); - writer.writeVarint(options.trackAlias); - writer.writeVarint(options.groupId); - - if (options.subgroupId !== undefined) writer.writeVarint(options.subgroupId); - - if (options.priority !== undefined) writer.writeUint8(options.priority); - - for (const object of options.objects) { - writer.writeVarint(object.objectIdDelta); - - if (object.properties !== undefined) { - writer.writeVarint(object.properties.length); - writer.writeBytes(object.properties); - } - - const payload = object.payload ?? new Uint8Array(0); - - writer.writeVarint(payload.length); - - if (payload.length === 0) writer.writeVarint(object.status ?? 0x0); - else writer.writeBytes(payload); - } - - return writer.toBytes(); -} - -async function collect(iterable: AsyncIterable): Promise { - const items: T[] = []; - - for await (const item of iterable) items.push(item); - - return items; -} - -describe('isSubgroupHeaderType', () => { - it('accepts the valid 0b0XX1XXXX ranges', () => { - for (const type of [0x10, 0x15, 0x18, 0x1d, 0x30, 0x3d, 0x50, 0x5d, 0x70, 0x7d]) { - expect(isSubgroupHeaderType(type)).toBe(true); - } - }); - - it('rejects reserved SUBGROUP_ID_MODE 0b11 and out-of-form values', () => { - for (const type of [0x16, 0x17, 0x1e, 0x1f, 0x36, 0x76, 0x7e]) { - expect(isSubgroupHeaderType(type)).toBe(false); - } - - for (const type of [0x00, 0x05, 0x0f, 0x20, 0x2f, 0x40, 0x80, 0x2f00]) { - expect(isSubgroupHeaderType(type)).toBe(false); - } - }); -}); - -describe('readSubgroupHeader', () => { - it('parses an explicit-subgroup-id header with priority', () => { - // 0x14: bit4 set, mode 0b10 (explicit), no properties, priority present. - const bytes = encodeSubgroupStream({ - type: 0x14, - trackAlias: 3, - groupId: 41, - subgroupId: 2, - priority: 128, - objects: [], - }); - const reader = new StreamReader(streamOf(bytes)); - - return reader.readVarint().then(async (type) => { - const header = await readSubgroupHeader(reader, type); - - expect(header).toMatchObject({ - trackAlias: 3, - groupId: 41, - subgroupIdMode: 'explicit', - subgroupId: 2, - priority: 128, - hasProperties: false, - endOfGroup: false, - firstObject: false, - }); - }); - }); - - it('parses default-priority and end-of-group flag bits', async () => { - // 0x38: bit4 set, mode 0b00 (zero), END_OF_GROUP (0x08), DEFAULT_PRIORITY (0x20). - const bytes = encodeSubgroupStream({ type: 0x38, trackAlias: 1, groupId: 7, objects: [] }); - const reader = new StreamReader(streamOf(bytes)); - const header = await readSubgroupHeader(reader, await reader.readVarint()); - - expect(header).toMatchObject({ subgroupIdMode: 'zero', endOfGroup: true, priority: undefined }); - }); -}); - -describe('readSubgroupObjects', () => { - it('delta-decodes object IDs (first absolute, then +delta+1)', async () => { - const bytes = encodeSubgroupStream({ - type: 0x38, - trackAlias: 1, - groupId: 7, - objects: [ - { objectIdDelta: 0, payload: utf8Encode('a') }, - { objectIdDelta: 0, payload: utf8Encode('b') }, // 0 + 0 + 1 = 1 - { objectIdDelta: 2, payload: utf8Encode('c') }, // 1 + 2 + 1 = 4 - ], - }); - const reader = new StreamReader(streamOf(bytes, 3)); // tiny chunks - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x38); - const objects = await collect(readSubgroupObjects(reader, header)); - - expect(objects.map((o: MoqtObject) => o.objectId)).toEqual([0, 1, 4]); - expect(objects.map((o) => new TextDecoder().decode(o.payload))).toEqual(['a', 'b', 'c']); - expect(objects[0]).toMatchObject({ groupId: 7, subgroupId: 0, status: 'normal' }); - }); - - it('resolves subgroup id from the first object in first-object-id mode', async () => { - // 0x32: bit4 set... 0x32 = 0b0110010 — bit4 (0x10) set, mode bits (0x06)>>1 = 0b01, DEFAULT_PRIORITY set. - const bytes = encodeSubgroupStream({ - type: 0x32, - trackAlias: 1, - groupId: 9, - objects: [{ objectIdDelta: 5, payload: utf8Encode('x') }], - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x32); - - expect(header.subgroupIdMode).toBe('first-object-id'); - const objects = await collect(readSubgroupObjects(reader, header)); - - expect(objects[0]).toMatchObject({ objectId: 5, subgroupId: 5 }); - }); - - it('parses zero-length objects with explicit status', async () => { - const bytes = encodeSubgroupStream({ - type: 0x38, - trackAlias: 1, - groupId: 7, - objects: [ - { objectIdDelta: 0, payload: utf8Encode('a') }, - { objectIdDelta: 0, status: 0x3 }, // end of group - ], - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x38); - const objects = await collect(readSubgroupObjects(reader, header)); - - expect(objects[1]).toMatchObject({ objectId: 1, status: 'end-of-group', payload: new Uint8Array(0) }); - }); - - it('throws MoqtProtocolError on an unknown object status', async () => { - const bytes = encodeSubgroupStream({ - type: 0x38, - trackAlias: 1, - groupId: 7, - objects: [{ objectIdDelta: 0, status: 0x9 }], - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x38); - - await expect(collect(readSubgroupObjects(reader, header))).rejects.toThrow(MoqtProtocolError); - }); - - it('throws MoqtProtocolError when delta-decoded object IDs overflow the varint range', async () => { - const bytes = encodeSubgroupStream({ - type: 0x38, - trackAlias: 1, - groupId: 7, - objects: [ - { objectIdDelta: Number.MAX_SAFE_INTEGER, payload: utf8Encode('a') }, - { objectIdDelta: 0, payload: utf8Encode('b') }, // 2^53-1 + 0 + 1 overflows - ], - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x38); - - await expect(collect(readSubgroupObjects(reader, header))).rejects.toThrow(MoqtProtocolError); - }); - - // The declared lengths below are followed by NO bytes: reaching the read - // would surface a RangeError from the stream, so a MoqtProtocolError proves - // the declaration is rejected before anything is allocated. - it('rejects a payload length beyond MAX_OBJECT_PAYLOAD_LENGTH before allocating', async () => { - const writer = new ByteWriter(); - - writer.writeVarint(0x38); - writer.writeVarint(1); // track alias - writer.writeVarint(7); // group id - writer.writeVarint(0); // object id delta - writer.writeVarint(MAX_OBJECT_PAYLOAD_LENGTH + 1); - const reader = new StreamReader(streamOf(writer.toBytes())); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x38); - - await expect(collect(readSubgroupObjects(reader, header))).rejects.toThrow(/payload length .* exceeds/); - }); - - it('rejects a properties length beyond MAX_OBJECT_PROPERTIES_LENGTH before allocating', async () => { - const writer = new ByteWriter(); - - writer.writeVarint(0x39); // 0x38 | PROPERTIES - writer.writeVarint(1); - writer.writeVarint(7); - writer.writeVarint(0); // object id delta - writer.writeVarint(MAX_OBJECT_PROPERTIES_LENGTH + 1); - const reader = new StreamReader(streamOf(writer.toBytes())); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x39); - - await expect(collect(readSubgroupObjects(reader, header))).rejects.toThrow(/properties length .* exceeds/); - }); - - it('accepts a payload exactly at MAX_OBJECT_PAYLOAD_LENGTH', async () => { - const bytes = encodeSubgroupStream({ - type: 0x38, - trackAlias: 1, - groupId: 7, - objects: [{ objectIdDelta: 0, payload: new Uint8Array(MAX_OBJECT_PAYLOAD_LENGTH) }], - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x38); - const objects = await collect(readSubgroupObjects(reader, header)); - - expect(objects[0]!.payload.length).toBe(MAX_OBJECT_PAYLOAD_LENGTH); - }); - - it('accepts a properties block holding a maximum-size KVP value', async () => { - // One odd-type KVP whose byte value is the largest the KVP codec - // permits (2^16-1): the aggregate block bound must not reject what the - // per-value rule allows. - const props = new ByteWriter(); - - props.writeVarint(0x07); - props.writeVarint(0xffff); - props.writeBytes(new Uint8Array(0xffff).fill(1)); - const bytes = encodeSubgroupStream({ - type: 0x39, // 0x38 | PROPERTIES - trackAlias: 1, - groupId: 7, - objects: [{ objectIdDelta: 0, payload: utf8Encode('a'), properties: props.toBytes() }], - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x39); - const objects = await collect(readSubgroupObjects(reader, header)); - - expect(objects[0]!.properties).toHaveLength(1); - expect(objects[0]!.properties[0]).toMatchObject({ type: 0x07 }); - expect((objects[0]!.properties[0]!.value as Uint8Array).length).toBe(0xffff); - }); - - it('parses per-object properties when the header PROPERTIES bit is set', async () => { - // Properties KVP: type 0x06 (Timestamp), varint value 90000. - const props = new ByteWriter(); - - props.writeVarint(0x06); - props.writeVarint(90_000); - const bytes = encodeSubgroupStream({ - type: 0x39, // 0x38 | PROPERTIES - trackAlias: 1, - groupId: 7, - objects: [{ objectIdDelta: 0, payload: utf8Encode('a'), properties: props.toBytes() }], - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - const header = await readSubgroupHeader(reader, 0x39); - const objects = await collect(readSubgroupObjects(reader, header)); - - expect(objects[0]!.properties).toEqual([{ type: 0x06, value: 90_000 }]); - }); -}); - -describe('readFetchEntries', () => { - function encodeFetchStream(build: (writer: ByteWriter) => void): Uint8Array { - const writer = new ByteWriter(); - - writer.writeVarint(0x05); // FETCH_HEADER - writer.writeVarint(8); // request id - build(writer); - return writer.toBytes(); - } - - it('parses the fetch header request id', async () => { - const reader = new StreamReader(streamOf(encodeFetchStream(() => {}))); - - await reader.readVarint(); - expect(await readFetchHeader(reader)).toEqual({ requestId: 8 }); - }); - - it('decodes absolute-first then delta-encoded objects', async () => { - const bytes = encodeFetchStream((w) => { - // First object: flags need GROUP_ID_DELTA (0x08) + OBJECT_ID_DELTA (0x04) - // + PRIORITY (0x10); subgroup mode 0 (subgroup id zero). - w.writeVarint(0x1c); - w.writeVarint(10); // group id (absolute) - w.writeVarint(0); // object id (absolute) - w.writeUint8(100); // priority - w.writeVarint(1); // payload length - w.writeBytes(utf8Encode('a')); - // Second object: same group, next object id (no fields at all). - w.writeVarint(0x00); - w.writeVarint(1); - w.writeBytes(utf8Encode('b')); - // Third object: next group (delta 0 → +1), object id resets via delta. - w.writeVarint(0x0c); - w.writeVarint(0); // group delta → 10 + 0 + 1 = 11 - w.writeVarint(0); // object id absolute within new group - w.writeVarint(1); - w.writeBytes(utf8Encode('c')); - }); - const reader = new StreamReader(streamOf(bytes, 4)); - - await reader.readVarint(); - await readFetchHeader(reader); - const entries = await collect(readFetchEntries(reader)); - - expect(entries.map((e: FetchStreamEntry) => (e.kind === 'object' ? [e.groupId, e.objectId] : null))).toEqual([ - [10, 0], - [10, 1], - [11, 0], - ]); - }); - - it('rejects a payload length beyond MAX_OBJECT_PAYLOAD_LENGTH before allocating', async () => { - const bytes = encodeFetchStream((w) => { - w.writeVarint(0x1c); // GROUP_ID_DELTA | OBJECT_ID_DELTA | PRIORITY - w.writeVarint(10); // group id - w.writeVarint(0); // object id - w.writeUint8(100); // priority - w.writeVarint(MAX_OBJECT_PAYLOAD_LENGTH + 1); // no bytes follow - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - await readFetchHeader(reader); - await expect(collect(readFetchEntries(reader))).rejects.toThrow(/payload length .* exceeds/); - }); - - it('yields end-of-range markers for all three statuses (§11.4.4, Table 7)', async () => { - const bytes = encodeFetchStream((w) => { - w.writeVarint(0x8c); // End of Non-Existent Range - w.writeVarint(4); - w.writeVarint(20); - w.writeVarint(0x10c); // End of Unknown Range - w.writeVarint(5); - w.writeVarint(0); - w.writeVarint(0x20c); // End of Timed-Out Range - w.writeVarint(6); - w.writeVarint(2); - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - await readFetchHeader(reader); - const entries = await collect(readFetchEntries(reader)); - - expect(entries).toEqual([ - { kind: 'end-of-range', status: 'non-existent', groupId: 4, objectId: 20 }, - { kind: 'end-of-range', status: 'unknown', groupId: 5, objectId: 0 }, - { kind: 'end-of-range', status: 'timed-out', groupId: 6, objectId: 2 }, - ]); - }); - - it('rejects a first object that references the prior object', async () => { - const bytes = encodeFetchStream((w) => { - w.writeVarint(0x00); // no group/object deltas on the first object - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - await readFetchHeader(reader); - await expect(collect(readFetchEntries(reader))).rejects.toThrow(MoqtProtocolError); - }); - - it('rejects delta-decoded locations that overflow the varint range', async () => { - const bytes = encodeFetchStream((w) => { - // First object: absolute group at the varint ceiling. - w.writeVarint(0x1c); - w.writeVarint(Number.MAX_SAFE_INTEGER); // group id (absolute) - w.writeVarint(0); // object id (absolute) - w.writeUint8(100); // priority - w.writeVarint(1); // payload length - w.writeBytes(utf8Encode('a')); - // Second object: group delta 0 → 2^53-1 + 0 + 1 overflows. - w.writeVarint(0x0c); - w.writeVarint(0); // group delta - w.writeVarint(0); // object id - w.writeVarint(1); - w.writeBytes(utf8Encode('b')); - }); - const reader = new StreamReader(streamOf(bytes)); - - await reader.readVarint(); - await readFetchHeader(reader); - await expect(collect(readFetchEntries(reader))).rejects.toThrow(MoqtProtocolError); - }); -}); diff --git a/packages/spf/src/network/moqt/tests/session.test.ts b/packages/spf/src/network/moqt/tests/session.test.ts deleted file mode 100644 index 53e882ca00..0000000000 --- a/packages/spf/src/network/moqt/tests/session.test.ts +++ /dev/null @@ -1,1008 +0,0 @@ -import { describe, expect, it, vi } from 'vite-plus/test'; - -import { ByteWriter, StreamReader, utf8Encode } from '../bytes'; -import { - type ControlMessage, - ControlMessageDeframer, - decodeControlMessage, - encodePublishDone, - encodePublishNamespace, - encodePublishStateNotify, - encodeRequestError, - encodeRequestOk, - encodeSetup, - encodeSubscribeOk, - type LocationFilter, - PUBLISH_DONE_STATUS, - REQUEST_ERROR_CODE, -} from '../control-messages'; -import type { MoqtObject } from '../object-stream'; -import type { BidirectionalStreamLike } from '../request-stream'; -import { createMoqtSession, type MoqtSessionCallbacks, type MoqtTransport } from '../session'; - -// ============================================================================ -// In-memory transport fake — the same seam pattern as SPF's fetch injection. -// ============================================================================ - -interface PushChannel { - stream: ReadableStream; - push(value: T): void; - close(): void; -} - -function pushChannel(): PushChannel { - let controller!: ReadableStreamDefaultController; - const stream = new ReadableStream({ - start(c) { - controller = c; - }, - }); - - return { - stream, - push: (value) => controller.enqueue(value), - close: () => controller.close(), - }; -} - -/** Server-side view of one client-initiated bidirectional stream. */ -interface ServerRequestStream { - /** Decoded control messages received from the client, in order. */ - messages: ControlMessage[]; - /** Resolves when the first client message has been decoded. */ - firstMessage: Promise; - send(bytes: Uint8Array): Promise; - fin(): Promise; - reset(reason?: unknown): void; -} - -function createFakeTransport() { - const incomingUni = pushChannel>(); - const incomingBidi = pushChannel(); - const clientUniStreams: ReadableStream[] = []; - const requestStreams: ServerRequestStream[] = []; - const requestWaiters: ((stream: ServerRequestStream) => void)[] = []; - let closeInfo: { closeCode?: number; reason?: string } | undefined; - let resolveClosed!: (info: unknown) => void; - const closed = new Promise((resolve) => { - resolveClosed = resolve; - }); - - const transport: MoqtTransport = { - incomingUnidirectionalStreams: incomingUni.stream, - incomingBidirectionalStreams: incomingBidi.stream, - async createUnidirectionalStream() { - const pipe = new TransformStream(); - - clientUniStreams.push(pipe.readable); - return pipe.writable; - }, - async createBidirectionalStream() { - const clientToServer = new TransformStream(); - const serverToClient = new TransformStream(); - const writer = serverToClient.writable.getWriter(); - - const messages: ControlMessage[] = []; - let resolveFirst!: (message: ControlMessage) => void; - const firstMessage = new Promise((resolve) => { - resolveFirst = resolve; - }); - - // Server-side read pump for the client's messages. - void (async () => { - const reader = clientToServer.readable.getReader(); - const deframer = new ControlMessageDeframer(); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) break; - - for (const frame of deframer.push(value)) { - const message = decodeControlMessage(frame); - - messages.push(message); - - if (messages.length === 1) resolveFirst(message); - } - } - } catch { - // client reset its sending direction - } - })(); - - const serverStream: ServerRequestStream = { - messages, - firstMessage, - send: (bytes) => writer.write(bytes), - fin: () => writer.close(), - reset: (reason) => { - writer.abort(reason).catch(() => {}); - }, - }; - - requestStreams.push(serverStream); - requestWaiters.shift()?.(serverStream); - return { readable: serverToClient.readable, writable: clientToServer.writable }; - }, - close(info) { - closeInfo = info; - resolveClosed(info); - }, - closed, - }; - - return { - transport, - /** The SETUP control stream the client opened (first client uni stream). */ - async clientControlStream(): Promise { - await vi.waitFor(() => { - if (clientUniStreams.length === 0) throw new Error('no client uni stream yet'); - }); - return new StreamReader(clientUniStreams[0]!); - }, - /** Wait for the next client-initiated request stream. */ - nextRequestStream(): Promise { - const existing = requestStreams.shift(); - if (existing) return Promise.resolve(existing); - - return new Promise((resolve) => requestWaiters.push(resolve)); - }, - /** Open the server's control stream and send its SETUP. */ - sendServerSetup(): void { - const pipe = new TransformStream(); - const writer = pipe.writable.getWriter(); - - void writer.write(encodeSetup([])); - incomingUni.push(pipe.readable); - }, - /** Open a unidirectional data stream to the client. */ - openDataStream(bytes: Uint8Array): void { - const pipe = new TransformStream(); - const writer = pipe.writable.getWriter(); - - void writer.write(bytes).then(() => writer.close()); - incomingUni.push(pipe.readable); - }, - /** Open a unidirectional data stream the test writes to (and may reset). */ - openControlledDataStream(): { write(bytes: Uint8Array): Promise; reset(error: unknown): void } { - const pipe = new TransformStream(); - const writer = pipe.writable.getWriter(); - - incomingUni.push(pipe.readable); - return { - write: (bytes) => writer.write(bytes), - reset: (error) => { - writer.abort(error).catch(() => {}); - }, - }; - }, - openIncomingBidi(bytes: Uint8Array): { responses: Promise } { - const serverToClient = new TransformStream(); - const clientToServer = new TransformStream(); - const writer = serverToClient.writable.getWriter(); - - void writer.write(bytes).then(() => writer.close()); - incomingBidi.push({ readable: serverToClient.readable, writable: clientToServer.writable }); - const responses = (async () => { - const chunks: Uint8Array[] = []; - const reader = clientToServer.readable.getReader(); - - while (true) { - const { done, value } = await reader.read(); - if (done) break; - - chunks.push(value); - } - - return chunks; - })(); - - return { responses }; - }, - getCloseInfo: () => closeInfo, - /** Simulate a transport-side drop (peer/network close, not a local `close()`). */ - dropTransport: () => resolveClosed(undefined), - }; -} - -/** Encode a one-object subgroup stream for `trackAlias` (type 0x38: subgroup 0, default priority, end-of-group). */ -function encodeSubgroup(trackAlias: number, groupId: number, payload: Uint8Array, objectId = 0): Uint8Array { - const writer = new ByteWriter(); - - writer.writeVarint(0x38); - writer.writeVarint(trackAlias); - writer.writeVarint(groupId); - writer.writeVarint(objectId); // first object id (absolute) - writer.writeVarint(payload.length); - writer.writeBytes(payload); - return writer.toBytes(); -} - -/** The fetch range playback would ask for if it fetched: the current group from its start. */ -const CURRENT_GROUP: LocationFilter = { type: 'relative-group', groupsBeforeNext: 1 }; - -function createSessionHarness(callbacks?: MoqtSessionCallbacks) { - const fake = createFakeTransport(); - const session = createMoqtSession(fake.transport, { callbacks, unknownAliasTimeoutMs: 200 }); - - return { ...fake, session }; -} - -describe('createMoqtSession', () => { - it('sends SETUP on a fresh unidirectional control stream', async () => { - const harness = createSessionHarness(); - const control = await harness.clientControlStream(); - const type = await control.readVarint(); - - expect(type).toBe(0x2f00); - const high = await control.readUint8(); - const low = await control.readUint8(); - const body = await control.readBytes(high * 256 + low); - const setup = decodeControlMessage({ type, body }); - - expect(setup.kind).toBe('setup'); - harness.session.destroy(); - }); - - it('resolves ready and reports server options once the server SETUP arrives', async () => { - const onReady = vi.fn(); - const harness = createSessionHarness({ onReady }); - - harness.sendServerSetup(); - await harness.session.ready; - expect(onReady).toHaveBeenCalledWith([]); - harness.session.destroy(); - }); - - it('subscribes on a new request stream and routes objects by track alias', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const onOk = vi.fn(); - const objects: MoqtObject[] = []; - const subgroupEnds: unknown[] = []; - - harness.session.subscribe( - { trackNamespace: ['live', 'stream1'], trackName: 'video' }, - { - onOk, - onObject: (object) => objects.push(object), - onSubgroupEnd: (info) => subgroupEnds.push(info), - } - ); - - const request = await harness.nextRequestStream(); - const message = await request.firstMessage; - - expect(message).toMatchObject({ - kind: 'subscribe', - requestId: 0, - trackNamespace: ['live', 'stream1'], - trackName: 'video', - }); - - await request.send(encodeSubscribeOk(11)); - await vi.waitFor(() => expect(onOk).toHaveBeenCalled()); - expect(onOk).toHaveBeenCalledWith(expect.objectContaining({ trackAlias: 11 })); - - harness.openDataStream(encodeSubgroup(11, 41, utf8Encode('frame'))); - await vi.waitFor(() => expect(objects).toHaveLength(1)); - expect(objects[0]).toMatchObject({ groupId: 41, objectId: 0, subgroupId: 0, status: 'normal' }); - await vi.waitFor(() => expect(subgroupEnds).toHaveLength(1)); - expect(subgroupEnds[0]).toEqual({ groupId: 41, subgroupId: 0, endOfGroup: true }); - - harness.session.destroy(); - }); - - it('buffers a data stream that arrives before SUBSCRIBE_OK registers the alias', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const objects: MoqtObject[] = []; - - harness.session.subscribe( - { trackNamespace: ['live'], trackName: 'audio' }, - { onObject: (object) => objects.push(object) } - ); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - - // Objects outrace the SUBSCRIBE_OK. - harness.openDataStream(encodeSubgroup(5, 100, utf8Encode('early'))); - await new Promise((resolve) => setTimeout(resolve, 20)); - expect(objects).toHaveLength(0); - - await request.send(encodeSubscribeOk(5)); - await vi.waitFor(() => expect(objects).toHaveLength(1)); - expect(objects[0]).toMatchObject({ groupId: 100 }); - - harness.session.destroy(); - }); - - it('drops a data stream whose alias never registers (timeout)', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - // No subscription at all — stream must be cancelled after the timeout, - // and the session must survive. - harness.openDataStream(encodeSubgroup(99, 1, utf8Encode('orphan'))); - await new Promise((resolve) => setTimeout(resolve, 300)); - expect(harness.getCloseInfo()).toBeUndefined(); - harness.session.destroy(); - }); - - it('surfaces REQUEST_ERROR to the subscription handlers', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const onError = vi.fn(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'nope' }, { onError }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - await request.send(encodeRequestError(REQUEST_ERROR_CODE.DOES_NOT_EXIST, 'no such track')); - - await vi.waitFor(() => expect(onError).toHaveBeenCalled()); - expect(onError).toHaveBeenCalledWith( - expect.objectContaining({ errorCode: REQUEST_ERROR_CODE.DOES_NOT_EXIST, reason: 'no such track' }) - ); - harness.session.destroy(); - }); - - // §3.3.2 leaves "was this FIN premature?" to the caller; the session is the - // only layer that knows a SUBSCRIBE needs a SUBSCRIBE_OK. Without these the - // subscription sits pending forever with neither response nor error. - it('fails a subscription when the peer FINs before SUBSCRIBE_OK', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const onError = vi.fn(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }, { onError }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - await request.fin(); - - await vi.waitFor(() => expect(onError).toHaveBeenCalled()); - expect(onError).toHaveBeenCalledWith( - expect.objectContaining({ reason: 'request stream closed before a response' }) - ); - harness.session.destroy(); - }); - - it('fails a subscription when the request stream is reset before SUBSCRIBE_OK', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const onError = vi.fn(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }, { onError }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - request.reset(new Error('stream reset')); - - await vi.waitFor(() => expect(onError).toHaveBeenCalled()); - harness.session.destroy(); - }); - - it('does not fail a subscription when the FIN follows SUBSCRIBE_OK', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const onOk = vi.fn(); - const onError = vi.fn(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }, { onOk, onError }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - await request.send(encodeSubscribeOk(7)); - await vi.waitFor(() => expect(onOk).toHaveBeenCalled()); - await request.fin(); - - await new Promise((resolve) => setTimeout(resolve, 20)); - expect(onError).not.toHaveBeenCalled(); - harness.session.destroy(); - }); - - it('fails a subscription that gets no response before the request timeout', async () => { - const fake = createFakeTransport(); - const session = createMoqtSession(fake.transport, { requestTimeoutMs: 10 }); - - fake.sendServerSetup(); - - const onError = vi.fn(); - - session.subscribe({ trackNamespace: ['live'], trackName: 'video' }, { onError }); - const request = await fake.nextRequestStream(); - - await request.firstMessage; - - await vi.waitFor(() => expect(onError).toHaveBeenCalled()); - expect(onError).toHaveBeenCalledWith(expect.objectContaining({ errorCode: REQUEST_ERROR_CODE.TIMEOUT })); - session.destroy(); - }); - - it('ignores a response that arrives after the request timeout', async () => { - const fake = createFakeTransport(); - const session = createMoqtSession(fake.transport, { requestTimeoutMs: 10, unknownAliasTimeoutMs: 50 }); - - fake.sendServerSetup(); - - const onOk = vi.fn(); - const onError = vi.fn(); - const objects: MoqtObject[] = []; - - session.subscribe( - { trackNamespace: ['live'], trackName: 'video' }, - { onOk, onError, onObject: (object) => objects.push(object) } - ); - const request = await fake.nextRequestStream(); - - await request.firstMessage; - await vi.waitFor(() => expect(onError).toHaveBeenCalled()); - - // A SUBSCRIBE_OK after the timeout must not fire onOk after onError, - // and must not resurrect the alias route of the dead subscription. - await request.send(encodeSubscribeOk(11)).catch(() => {}); - fake.openDataStream(encodeSubgroup(11, 41, utf8Encode('late'))); - await new Promise((resolve) => setTimeout(resolve, 80)); - expect(onOk).not.toHaveBeenCalled(); - expect(objects).toHaveLength(0); - session.destroy(); - }); - - it('fails a pending trackStatus when the transport drops', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const onError = vi.fn(); - - harness.session.trackStatus({ trackNamespace: ['live'], trackName: 'video' }, { onError }); - await ( - await harness.nextRequestStream() - ).firstMessage; - harness.dropTransport(); - - await vi.waitFor(() => expect(onError).toHaveBeenCalled()); - expect(onError).toHaveBeenCalledWith( - expect.objectContaining({ reason: 'session closed before the request was answered' }) - ); - }); - - it('fails pending requests when the transport drops, but not on a local close()', async () => { - const dropped = createSessionHarness(); - - dropped.sendServerSetup(); - const onDropError = vi.fn(); - - dropped.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }, { onError: onDropError }); - await ( - await dropped.nextRequestStream() - ).firstMessage; - dropped.dropTransport(); - await vi.waitFor(() => expect(onDropError).toHaveBeenCalled()); - - const closed = createSessionHarness(); - - closed.sendServerSetup(); - const onCloseError = vi.fn(); - - closed.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }, { onError: onCloseError }); - await ( - await closed.nextRequestStream() - ).firstMessage; - closed.session.close(); - await new Promise((resolve) => setTimeout(resolve, 20)); - expect(onCloseError).not.toHaveBeenCalled(); - }); - - it('surfaces PUBLISH_DONE and keeps late subgroups flowing until cancel', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const onDone = vi.fn(); - const objects: MoqtObject[] = []; - const subscription = harness.session.subscribe( - { trackNamespace: ['live'], trackName: 'video' }, - { onDone, onObject: (object) => objects.push(object) } - ); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - await request.send(encodeSubscribeOk(7)); - await request.send(encodePublishDone(PUBLISH_DONE_STATUS.TRACK_ENDED, 1, 'ended')); - - await vi.waitFor(() => expect(onDone).toHaveBeenCalled()); - expect(onDone).toHaveBeenCalledWith(expect.objectContaining({ statusCode: PUBLISH_DONE_STATUS.TRACK_ENDED })); - - // A late-opening stream still routes (PUBLISH_DONE often beats data). - harness.openDataStream(encodeSubgroup(7, 1, utf8Encode('late'))); - await vi.waitFor(() => expect(objects).toHaveLength(1)); - - subscription.cancel(); - harness.session.destroy(); - }); - - it('allocates even request IDs starting at 0', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - const first = harness.session.subscribe({ trackNamespace: ['a'], trackName: 'x' }); - const second = harness.session.subscribe({ trackNamespace: ['a'], trackName: 'y' }); - - expect(first.requestId).toBe(0); - expect(second.requestId).toBe(2); - harness.session.destroy(); - }); - - it('routes fetch streams by request id', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'catalog' }); - const subscribeStream = await harness.nextRequestStream(); - - await subscribeStream.firstMessage; - - const entries: unknown[] = []; - const onEnd = vi.fn(); - - harness.session.fetch( - { trackNamespace: ['live'], trackName: 'catalog', parameters: { locationFilter: CURRENT_GROUP } }, - { onEntry: (entry) => entries.push(entry), onEnd } - ); - const fetchStream = await harness.nextRequestStream(); - const fetchMessage = await fetchStream.firstMessage; - - expect(fetchMessage).toMatchObject({ - kind: 'fetch', - request: { - requestId: 2, - trackNamespace: ['live'], - trackName: 'catalog', - parameters: { locationFilter: CURRENT_GROUP }, - }, - }); - - // Fetch data stream: FETCH_HEADER + one object. - const writer = new ByteWriter(); - - writer.writeVarint(0x05); - writer.writeVarint(2); // fetch request id - writer.writeVarint(0x1c); // group delta + object delta + priority present - writer.writeVarint(41); // group (absolute) - writer.writeVarint(0); // object (absolute) - writer.writeUint8(128); - const payload = utf8Encode('{"version":"1"}'); - - writer.writeVarint(payload.length); - writer.writeBytes(payload); - harness.openDataStream(writer.toBytes()); - - await vi.waitFor(() => expect(entries).toHaveLength(1)); - expect(entries[0]).toMatchObject({ kind: 'object', groupId: 41, objectId: 0 }); - await vi.waitFor(() => expect(onEnd).toHaveBeenCalled()); - - harness.session.destroy(); - }); - - it('tolerates REQUEST_OK in place of FETCH_OK on a fetch stream (relay deviation)', async () => { - const onClosed = vi.fn(); - const harness = createSessionHarness({ onClosed }); - - harness.sendServerSetup(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'catalog' }); - - await harness.nextRequestStream(); - - const entries: unknown[] = []; - const onEnd = vi.fn(); - - harness.session.fetch( - { trackNamespace: ['live'], trackName: 'catalog', parameters: { locationFilter: CURRENT_GROUP } }, - { onEntry: (entry) => entries.push(entry), onEnd } - ); - const fetchStream = await harness.nextRequestStream(); - - await fetchStream.firstMessage; - await fetchStream.send(encodeRequestOk()); - - // The data stream still delivers normally — REQUEST_OK on the bidi - // stream has no bearing on the separate unidirectional data stream. - const writer = new ByteWriter(); - - writer.writeVarint(0x05); - writer.writeVarint(2); // fetch request id - writer.writeVarint(0x1c); // group delta + object delta + priority present - writer.writeVarint(41); // group (absolute) - writer.writeVarint(0); // object (absolute) - writer.writeUint8(128); - const payload = utf8Encode('{"version":"1"}'); - - writer.writeVarint(payload.length); - writer.writeBytes(payload); - harness.openDataStream(writer.toBytes()); - - await vi.waitFor(() => expect(entries).toHaveLength(1)); - await vi.waitFor(() => expect(onEnd).toHaveBeenCalled()); - expect(onClosed).not.toHaveBeenCalled(); - - harness.session.destroy(); - }); - - // REQUEST_OK *is* the response on such a relay, so it has to disarm the - // response timer. If it doesn't, the deadline fires on an answered fetch, - // deletes the record, and `#runFetchStream` then cancels the data stream - // instead of delivering it — the replay vanishes with no protocol error. - it('settles a fetch answered with REQUEST_OK so the request timeout cannot fail it', async () => { - const fake = createFakeTransport(); - // 25ms: below the 30ms wait (an un-disarmed timer would still fire in - // time to be observed) with headroom for the REQUEST_OK on slow CI. - const session = createMoqtSession(fake.transport, { requestTimeoutMs: 25, unknownAliasTimeoutMs: 200 }); - - fake.sendServerSetup(); - - session.subscribe({ trackNamespace: ['live'], trackName: 'catalog' }); - - await fake.nextRequestStream(); - - const onError = vi.fn(); - const entries: unknown[] = []; - - session.fetch( - { trackNamespace: ['live'], trackName: 'catalog', parameters: { locationFilter: CURRENT_GROUP } }, - { onEntry: (entry) => entries.push(entry), onError } - ); - const fetchStream = await fake.nextRequestStream(); - - await fetchStream.firstMessage; - await fetchStream.send(encodeRequestOk()); - - await new Promise((resolve) => setTimeout(resolve, 30)); - expect(onError).not.toHaveBeenCalled(); - - // The data stream arrives after the deadline would have passed. - const writer = new ByteWriter(); - - writer.writeVarint(0x05); - writer.writeVarint(2); // fetch request id - writer.writeVarint(0x1c); // group delta + object delta + priority present - writer.writeVarint(41); // group (absolute) - writer.writeVarint(0); // object (absolute) - writer.writeUint8(128); - const payload = utf8Encode('{"version":"1"}'); - - writer.writeVarint(payload.length); - writer.writeBytes(payload); - fake.openDataStream(writer.toBytes()); - - await vi.waitFor(() => expect(entries).toHaveLength(1)); - session.destroy(); - }); - - it('rejects ready when the session closes before the server SETUP', async () => { - const harness = createSessionHarness(); - - harness.session.close(); - await expect(harness.session.ready).rejects.toThrow('session closed before server SETUP'); - }); - - it('reports a transport drop before the server SETUP as an error close', async () => { - const onClosed = vi.fn(); - const harness = createSessionHarness({ onClosed }); - - harness.dropTransport(); - - // Callback-only consumers must observe the failure too — a clean - // `onClosed({})` would read as a normal session close. - await vi.waitFor(() => expect(onClosed).toHaveBeenCalled()); - expect(onClosed).toHaveBeenCalledWith({ - error: expect.objectContaining({ message: 'session closed before server SETUP' }), - }); - await expect(harness.session.ready).rejects.toThrow('session closed before server SETUP'); - }); - - it('reports a local close() before the server SETUP as a clean close', async () => { - const onClosed = vi.fn(); - const harness = createSessionHarness({ onClosed }); - - harness.session.close(); - - await vi.waitFor(() => expect(onClosed).toHaveBeenCalled()); - expect(onClosed).toHaveBeenCalledWith({}); - }); - - it('reports a reset fetch stream as onReset, not a clean onEnd', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'catalog' }); - const subscribeStream = await harness.nextRequestStream(); - - await subscribeStream.firstMessage; - - const entries: unknown[] = []; - const onEnd = vi.fn(); - const onReset = vi.fn(); - - harness.session.fetch( - { trackNamespace: ['live'], trackName: 'catalog', parameters: { locationFilter: CURRENT_GROUP } }, - { onEntry: (entry) => entries.push(entry), onEnd, onReset } - ); - const fetchStream = await harness.nextRequestStream(); - - await fetchStream.firstMessage; - - // Fetch data stream: header + one full entry, then a reset mid-replay. - const writer = new ByteWriter(); - - writer.writeVarint(0x05); - writer.writeVarint(2); // fetch request id - writer.writeVarint(0x1c); // group delta + object delta + priority present - writer.writeVarint(41); - writer.writeVarint(0); - writer.writeUint8(128); - const payload = utf8Encode('{"version":"1"}'); - - writer.writeVarint(payload.length); - writer.writeBytes(payload); - const dataStream = harness.openControlledDataStream(); - - await dataStream.write(writer.toBytes()); - await vi.waitFor(() => expect(entries).toHaveLength(1)); - dataStream.reset(new Error('reset mid-replay')); - - await vi.waitFor(() => expect(onReset).toHaveBeenCalled()); - expect(onEnd).not.toHaveBeenCalled(); - - harness.session.destroy(); - }); - - it('treats a truncated response frame on a request stream as a protocol error', async () => { - const onClosed = vi.fn(); - const harness = createSessionHarness({ onClosed }); - - harness.sendServerSetup(); - await harness.session.ready; - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - - // A frame header promising a 100-byte body, then FIN with none of it. - const partial = new ByteWriter(); - - partial.writeVarint(0x04); - partial.writeUint16(100); - await request.send(partial.toBytes()); - await request.fin(); - - await vi.waitFor(() => expect(onClosed).toHaveBeenCalled()); - expect(harness.getCloseInfo()).toMatchObject({ closeCode: 0x3 }); - }); - - it('reports GOAWAY from the control stream', async () => { - const onGoaway = vi.fn(); - const harness = createSessionHarness({ onGoaway }); - // Server control stream with SETUP then GOAWAY. - const writer = new ByteWriter(); - const setup = encodeSetup([]); - - writer.writeBytes(setup); - // GOAWAY with a migration URI. - const goawayBody = new ByteWriter(); - const uri = utf8Encode('https://relay2.example.com/moq'); - - goawayBody.writeVarint(uri.length); - goawayBody.writeBytes(uri); - goawayBody.writeVarint(1000); - const goawayFrame = new ByteWriter(); - - goawayFrame.writeVarint(0x10); - goawayFrame.writeUint16(goawayBody.length); - goawayFrame.writeBytes(goawayBody.toBytes()); - writer.writeBytes(goawayFrame.toBytes()); - harness.openDataStream(writer.toBytes()); - - await vi.waitFor(() => expect(onGoaway).toHaveBeenCalled()); - expect(onGoaway).toHaveBeenCalledWith( - expect.objectContaining({ newSessionUri: 'https://relay2.example.com/moq', timeout: 1000 }) - ); - harness.session.destroy(); - }); - - it('rejects incoming PUBLISH with UNINTERESTED by default', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - // Server-initiated PUBLISH request stream. - const publishBody = new ByteWriter(); - - publishBody.writeVarint(1); // server request id (odd) - publishBody.writeVarint(1); // namespace field count - const field = utf8Encode('live'); - - publishBody.writeVarint(field.length); - publishBody.writeBytes(field); - const name = utf8Encode('unwanted'); - - publishBody.writeVarint(name.length); - publishBody.writeBytes(name); - publishBody.writeVarint(9); // track alias - publishBody.writeVarint(0); // parameter count - const publishFrame = new ByteWriter(); - - publishFrame.writeVarint(0x1d); - publishFrame.writeUint16(publishBody.length); - publishFrame.writeBytes(publishBody.toBytes()); - - const { responses } = harness.openIncomingBidi(publishFrame.toBytes()); - const chunks = await responses; - const deframer = new ControlMessageDeframer(); - const messages = chunks.flatMap((chunk) => deframer.push(chunk)).map(decodeControlMessage); - - expect(messages[0]).toMatchObject({ kind: 'request-error', errorCode: REQUEST_ERROR_CODE.UNINTERESTED }); - - harness.session.destroy(); - }); - - it('rejects incoming PUBLISH_NAMESPACE with NOT_SUPPORTED by default', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - // Server-initiated PUBLISH_NAMESPACE request stream — relays commonly - // announce active namespaces unsolicited to newly connected clients. - const { responses } = harness.openIncomingBidi(encodePublishNamespace({ requestId: 1, trackNamespace: ['anon'] })); - const chunks = await responses; - const deframer = new ControlMessageDeframer(); - const messages = chunks.flatMap((chunk) => deframer.push(chunk)).map(decodeControlMessage); - - expect(messages[0]).toMatchObject({ kind: 'request-error', errorCode: REQUEST_ERROR_CODE.NOT_SUPPORTED }); - - harness.session.destroy(); - }); - - it('closes the session when an incoming request frame has a truncated body', async () => { - const onClosed = vi.fn(); - const harness = createSessionHarness({ onClosed }); - - harness.sendServerSetup(); - - // A PUBLISH_NAMESPACE frame whose declared body length cuts the - // namespace off — decoding must terminate the session, not vanish as - // an unhandled RangeError in the accept loop. - const frame = new ByteWriter(); - - frame.writeVarint(0x06); // PUBLISH_NAMESPACE - frame.writeUint16(1); - frame.writeVarint(1); // request id, then no namespace at all - harness.openIncomingBidi(frame.toBytes()); - - await vi.waitFor(() => expect(onClosed).toHaveBeenCalled()); - expect(harness.getCloseInfo()).toMatchObject({ closeCode: 0x3 }); - }); - - it('closes the session with PROTOCOL_VIOLATION on an unknown data stream type', async () => { - const onClosed = vi.fn(); - const harness = createSessionHarness({ onClosed }); - - harness.sendServerSetup(); - - const writer = new ByteWriter(); - - writer.writeVarint(0x0f); // not a valid unidirectional stream type - harness.openDataStream(writer.toBytes()); - - await vi.waitFor(() => expect(onClosed).toHaveBeenCalled()); - expect(harness.getCloseInfo()).toMatchObject({ closeCode: 0x3 }); - }); - - it('surfaces PUBLISH_STATE_NOTIFY to the subscription without replying', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const onStateNotify = vi.fn(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }, { onStateNotify }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - await request.send(encodeSubscribeOk(7)); - await request.send(encodePublishStateNotify({ largestObject: { group: 12, object: 3 } })); - - await vi.waitFor(() => expect(onStateNotify).toHaveBeenCalled()); - expect(onStateNotify).toHaveBeenCalledWith({ largestObject: { group: 12, object: 3 } }); - - // §10.10: unilateral — no REQUEST_OK or REQUEST_ERROR goes back. - await new Promise((resolve) => setTimeout(resolve, 20)); - expect(request.messages).toHaveLength(1); - harness.session.destroy(); - }); - - it('closes the session on PUBLISH_STATE_NOTIFY over a fetch stream', async () => { - const onClosed = vi.fn(); - const harness = createSessionHarness({ onClosed }); - - harness.sendServerSetup(); - harness.session.fetch({ trackNamespace: ['live'], trackName: 'catalog' }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - await request.send(encodePublishStateNotify({})); - - await vi.waitFor(() => expect(onClosed).toHaveBeenCalled()); - expect(harness.getCloseInfo()).toMatchObject({ closeCode: 0x3 }); - }); - - // §10.1 counts REQUEST_UPDATE among the messages that consume a Request - // ID; reusing the subscription's would be a duplicate the peer closes on. - it('gives each REQUEST_UPDATE a fresh request id', async () => { - const harness = createSessionHarness(); - - harness.sendServerSetup(); - - const subscription = harness.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - subscription.update({ forward: 0 }); - subscription.update({ forward: 1 }); - - await vi.waitFor(() => expect(request.messages).toHaveLength(3)); - expect(request.messages[1]).toMatchObject({ kind: 'request-update', requestId: 2, parameters: { forward: 0 } }); - expect(request.messages[2]).toMatchObject({ kind: 'request-update', requestId: 4, parameters: { forward: 1 } }); - harness.session.destroy(); - }); - - it('reports an uncountable PUBLISH_DONE stream count as undefined instead of failing the session', async () => { - const onClosed = vi.fn(); - const harness = createSessionHarness({ onClosed }); - - harness.sendServerSetup(); - - const onDone = vi.fn(); - - harness.session.subscribe({ trackNamespace: ['live'], trackName: 'video' }, { onDone }); - const request = await harness.nextRequestStream(); - - await request.firstMessage; - await request.send(encodeSubscribeOk(7)); - - // Status, the 9-byte varint 2^64-1 (§10.12's sentinel), empty reason. - const body = Uint8Array.of(PUBLISH_DONE_STATUS.TRACK_ENDED, ...new Array(9).fill(0xff), 0x00); - const frame = new ByteWriter(); - - frame.writeVarint(0x0b); - frame.writeUint16(body.length); - frame.writeBytes(body); - await request.send(frame.toBytes()); - - await vi.waitFor(() => expect(onDone).toHaveBeenCalled()); - expect(onDone).toHaveBeenCalledWith( - expect.objectContaining({ statusCode: PUBLISH_DONE_STATUS.TRACK_ENDED, streamCount: undefined, reason: '' }) - ); - expect(onClosed).not.toHaveBeenCalled(); - harness.session.destroy(); - }); -}); diff --git a/packages/spf/src/network/moqt/tests/varint.test.ts b/packages/spf/src/network/moqt/tests/varint.test.ts deleted file mode 100644 index 06583a6a27..0000000000 --- a/packages/spf/src/network/moqt/tests/varint.test.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { describe, expect, it } from 'vite-plus/test'; - -import { MoqtProtocolError } from '../errors'; -import { decodeVarint, encodeVarint, varintByteLength, varintLengthFromFirstByte } from '../varint'; - -function bytes(...values: number[]): Uint8Array { - return new Uint8Array(values); -} - -// Golden vectors from moq-transport draft-19 §1.4.1, Table 2. -const SPEC_VECTORS: [Uint8Array, number][] = [ - [bytes(0x25), 37], - [bytes(0x80, 0x25), 37], - [bytes(0xbb, 0xbd), 15_293], - [bytes(0xed, 0x7f, 0x3e, 0x7d), 226_442_877], - [bytes(0xfa, 0xa1, 0xa0, 0xe4, 0x03, 0xd8), 2_893_212_287_960], - [bytes(0xfc, 0x89, 0x98, 0xab, 0xc6, 0x6b, 0xc0), 151_288_809_941_952], -]; - -describe('decodeVarint', () => { - it('decodes the spec example encodings', () => { - for (const [encoded, value] of SPEC_VECTORS) { - expect(decodeVarint(encoded)).toEqual({ value, byteLength: encoded.length }); - } - }); - - it('accepts non-minimal encodings (any representable length is valid)', () => { - expect(decodeVarint(bytes(0x00)).value).toBe(0); - expect(decodeVarint(bytes(0x80, 0x00)).value).toBe(0); - expect(decodeVarint(bytes(0xc0, 0x00, 0x00)).value).toBe(0); - }); - - it('decodes at an offset', () => { - expect(decodeVarint(bytes(0xff, 0xff, 0x25), 2)).toEqual({ value: 37, byteLength: 1 }); - }); - - it('throws RangeError on truncated input', () => { - expect(() => decodeVarint(bytes())).toThrow(RangeError); - expect(() => decodeVarint(bytes(0xbb))).toThrow(RangeError); - expect(() => decodeVarint(bytes(0xed, 0x7f, 0x3e))).toThrow(RangeError); - }); - - it('rejects values above 2^53-1 with MoqtProtocolError', () => { - // 0xfefa318fa8e3ca11 = 70,423,237,261,249,041 (> 2^53-1) from the spec table. - expect(() => decodeVarint(bytes(0xfe, 0xfa, 0x31, 0x8f, 0xa8, 0xe3, 0xca, 0x11))).toThrow(MoqtProtocolError); - expect(() => decodeVarint(bytes(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff))).toThrow(MoqtProtocolError); - }); - - it('accepts 9-byte encodings of in-range values', () => { - // 9-byte non-minimal encoding of 1. - expect(decodeVarint(bytes(0xff, 0, 0, 0, 0, 0, 0, 0, 1))).toEqual({ value: 1, byteLength: 9 }); - }); -}); - -describe('encodeVarint', () => { - it('round-trips boundary values at each length', () => { - const boundaries = [ - 0, - 127, - 128, - 16_383, - 16_384, - 2 ** 21 - 1, - 2 ** 21, - 2 ** 28 - 1, - 2 ** 28, - 2 ** 35 - 1, - 2 ** 35, - 2 ** 42 - 1, - 2 ** 42, - 2 ** 49 - 1, - 2 ** 49, - Number.MAX_SAFE_INTEGER, - ]; - - for (const value of boundaries) { - const encoded = encodeVarint(value); - - expect(encoded.length).toBe(varintByteLength(value)); - expect(decodeVarint(encoded)).toEqual({ value, byteLength: encoded.length }); - } - }); - - it('produces minimal encodings matching the spec vectors', () => { - expect(encodeVarint(37)).toEqual(bytes(0x25)); - expect(encodeVarint(15_293)).toEqual(bytes(0xbb, 0xbd)); - expect(encodeVarint(226_442_877)).toEqual(bytes(0xed, 0x7f, 0x3e, 0x7d)); - expect(encodeVarint(2_893_212_287_960)).toEqual(bytes(0xfa, 0xa1, 0xa0, 0xe4, 0x03, 0xd8)); - }); - - it('rejects negative and unsafe values', () => { - expect(() => encodeVarint(-1)).toThrow(RangeError); - expect(() => encodeVarint(1.5)).toThrow(RangeError); - expect(() => encodeVarint(Number.MAX_SAFE_INTEGER + 2)).toThrow(RangeError); - }); -}); - -describe('varintLengthFromFirstByte', () => { - it('maps prefixes to lengths', () => { - expect(varintLengthFromFirstByte(0x00)).toBe(1); - expect(varintLengthFromFirstByte(0x7f)).toBe(1); - expect(varintLengthFromFirstByte(0x80)).toBe(2); - expect(varintLengthFromFirstByte(0xbf)).toBe(2); - expect(varintLengthFromFirstByte(0xc0)).toBe(3); - expect(varintLengthFromFirstByte(0xe0)).toBe(4); - expect(varintLengthFromFirstByte(0xf0)).toBe(5); - expect(varintLengthFromFirstByte(0xf8)).toBe(6); - expect(varintLengthFromFirstByte(0xfc)).toBe(7); - expect(varintLengthFromFirstByte(0xfe)).toBe(8); - expect(varintLengthFromFirstByte(0xff)).toBe(9); - }); -}); diff --git a/packages/spf/src/network/moqt/varint.ts b/packages/spf/src/network/moqt/varint.ts deleted file mode 100644 index 9a7cf523d9..0000000000 --- a/packages/spf/src/network/moqt/varint.ts +++ /dev/null @@ -1,122 +0,0 @@ -/** - * MOQT variable-length integers (moq-transport draft-20 §1.4.1). - * - * NOT the QUIC RFC 9000 varint: draft-15 replaced it with a leading-ones scheme. The number of leading 1 bits of the - * first byte gives the encoded length minus one (1-9 bytes); the bits after the first 0, plus any subsequent bytes, - * hold the value in network byte order. - * - * Values are represented as JS `number`. The wire format allows up to 2^64-1, but this decoder rejects anything above - * `Number.MAX_SAFE_INTEGER` (2^53-1) with a `MoqtProtocolError` — no field a media subscriber consumes legitimately - * needs more (Group IDs derived from Unix-epoch milliseconds are ~2^41), and silent precision loss would corrupt IDs. - */ -import { MoqtProtocolError } from './errors'; - -export interface VarintDecodeResult { - value: number; - /** Total encoded size in bytes (1-9). */ - byteLength: number; -} - -/** Largest value `encodeVarint` accepts (`Number.MAX_SAFE_INTEGER`). */ -export const MAX_VARINT_VALUE = Number.MAX_SAFE_INTEGER; - -/** Encoded length in bytes implied by a varint's first byte. */ -export function varintLengthFromFirstByte(firstByte: number): number { - let leadingOnes = 0; - let mask = 0x80; - - while (leadingOnes < 8 && (firstByte & mask) !== 0) { - leadingOnes++; - mask >>= 1; - } - - return leadingOnes + 1; -} - -/** - * Decode a varint at `offset`. Throws `RangeError` when `bytes` ends before the encoding completes, and - * `MoqtProtocolError` when the decoded value exceeds `MAX_VARINT_VALUE`. - */ -export function decodeVarint(bytes: Uint8Array, offset = 0): VarintDecodeResult { - const firstByte = bytes[offset]; - if (firstByte === undefined) throw new RangeError('varint: unexpected end of input'); - - const byteLength = varintLengthFromFirstByte(firstByte); - if (offset + byteLength > bytes.length) throw new RangeError('varint: unexpected end of input'); - - // Value bits contributed by the first byte: everything after the - // leading-ones prefix and its terminating 0. For a 9-byte encoding - // (prefix 0xFF) the first byte contributes nothing. - const firstByteBits = byteLength <= 8 ? firstByte & (0xff >> byteLength) : 0; - - if (byteLength <= 7) { - // Up to 49 value bits — exact in double-precision number math. - let value = firstByteBits; - - for (let i = 1; i < byteLength; i++) value = value * 256 + bytes[offset + i]!; - - return { value, byteLength }; - } - - // 8-9 byte encodings can exceed 2^53 — accumulate in bigint, then bound. - let big = BigInt(firstByteBits); - - for (let i = 1; i < byteLength; i++) big = big * 256n + BigInt(bytes[offset + i]!); - - if (big > BigInt(MAX_VARINT_VALUE)) { - throw new MoqtProtocolError(`varint: value ${big} exceeds supported range (2^53-1)`); - } - - return { value: Number(big), byteLength }; -} - -/** Minimal encoded length in bytes for `value`. */ -export function varintByteLength(value: number): number { - if (!Number.isSafeInteger(value) || value < 0) { - throw new RangeError(`varint: value out of range: ${value}`); - } - - if (value < 2 ** 7) return 1; - - if (value < 2 ** 14) return 2; - - if (value < 2 ** 21) return 3; - - if (value < 2 ** 28) return 4; - - if (value < 2 ** 35) return 5; - - if (value < 2 ** 42) return 6; - - if (value < 2 ** 49) return 7; - - // 8 bytes carry 56 value bits, which covers everything up to 2^53-1. - return 8; -} - -/** Encode `value` into `target` at `offset` using the minimal length. Returns the number of bytes written. */ -export function encodeVarintInto(target: Uint8Array, offset: number, value: number): number { - const byteLength = varintByteLength(value); - // Fill value bytes from the least-significant end. Number math is exact - // here: value < 2^53 and each step divides by 256. - let remaining = value; - - for (let i = byteLength - 1; i >= 1; i--) { - target[offset + i] = remaining % 256; - remaining = Math.floor(remaining / 256); - } - - // First byte: leading-ones prefix for (byteLength - 1) ones, then the - // top value bits. - const prefix = byteLength === 1 ? 0 : (0xff << (9 - byteLength)) & 0xff; - - target[offset] = prefix | remaining; - return byteLength; -} - -export function encodeVarint(value: number): Uint8Array { - const bytes = new Uint8Array(varintByteLength(value)); - - encodeVarintInto(bytes, 0, value); - return bytes; -} diff --git a/packages/spf/src/network/tests/helpers/moqt-wire.ts b/packages/spf/src/network/tests/helpers/moqt-wire.ts new file mode 100644 index 0000000000..a71a264f4a --- /dev/null +++ b/packages/spf/src/network/tests/helpers/moqt-wire.ts @@ -0,0 +1,17 @@ +/** + * Relay-side MOQT codec for the in-memory fake relays in SPF's tests. + * + * The player speaks MOQT through `@caprid/moq-core`, whose public entry exports only the subscriber's surface. A fake + * relay also needs the other side of the wire — server SETUP, SUBSCRIBE decoding, SUBSCRIBE_OK and REQUEST_ERROR — so + * this re-exports the package's own codec modules instead of keeping a second implementation that could drift from the + * one the player runs. The deep path bypasses the package's `exports` map on purpose; it is test-only, and a package + * release that moves these modules fails the tests loudly rather than silently. + */ +export { StreamReader, utf8Encode } from '../../../../node_modules/@caprid/moq-core/dist/protocol/bytes.js'; +export { + type ControlMessage, + decodeControlMessage, + encodeRequestError, + encodeSetup, + encodeSubscribeOk, +} from '../../../../node_modules/@caprid/moq-core/dist/protocol/control-messages.js'; diff --git a/packages/spf/src/playback/actors/dom/audio-renderer.ts b/packages/spf/src/playback/actors/dom/audio-renderer.ts index 1cb1dd9773..232dca6ce9 100644 --- a/packages/spf/src/playback/actors/dom/audio-renderer.ts +++ b/packages/spf/src/playback/actors/dom/audio-renderer.ts @@ -198,7 +198,10 @@ const MAX_PLAYBACK_RATE = 2; const createDefaultAudioPlayer: CreateAudioPlayer = async (context) => { if (!context.baseContext) throw new Error('audio renderer context has no baseContext to host the AudioWorklet'); - return createCoreAudioPlayer({ context: context.baseContext }); + // WebCodecs, not the core's WebAssembly libopus: that decoder is single-stream and ignores the OpusHead + // channel mapping, so a multistream (above stereo) track the catalog allows would decode as noise. A lost + // frame plays as silence instead of being concealed. + return createCoreAudioPlayer({ context: context.baseContext, lossConcealment: false }); }; export function createAudioRendererActor(options: CreateAudioRendererOptions): AudioRendererActor { diff --git a/packages/spf/src/playback/actors/dom/tests/audio-renderer.test.ts b/packages/spf/src/playback/actors/dom/tests/audio-renderer.test.ts index dac483314a..add2aad311 100644 --- a/packages/spf/src/playback/actors/dom/tests/audio-renderer.test.ts +++ b/packages/spf/src/playback/actors/dom/tests/audio-renderer.test.ts @@ -1,3 +1,4 @@ +import { createAudioPlayer as createCoreAudioPlayer } from '@caprid/moq-media'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'; import type { JitterFrame } from '../../track-subscriber'; @@ -10,6 +11,12 @@ import { createAudioRendererActor, } from '../audio-renderer'; +vi.mock('@caprid/moq-media', async (importOriginal) => { + const original = await importOriginal(); + + return { ...original, createAudioPlayer: vi.fn(original.createAudioPlayer) }; +}); + const FRAME_US = 20_000; const JITTER_TARGET_US = 60_000; const TICK_MS = 10; @@ -572,6 +579,9 @@ describe('createAudioRendererActor', () => { await vi.advanceTimersByTimeAsync(0); expect(addModule).toHaveBeenCalledTimes(1); + // WebCodecs decoding: the core's WebAssembly libopus ignores a multistream + // OpusHead's channel mapping. + expect(createCoreAudioPlayer).toHaveBeenCalledWith({ context: baseContext, lossConcealment: false }); expect(renderer.snapshot.get().context.error).toBe(workletUnavailable); renderer.destroy(); diff --git a/packages/spf/src/playback/actors/moq-session.ts b/packages/spf/src/playback/actors/moq-session.ts index f98cd3d126..79c1ad31c9 100644 --- a/packages/spf/src/playback/actors/moq-session.ts +++ b/packages/spf/src/playback/actors/moq-session.ts @@ -1,7 +1,7 @@ /** * Actor owning the WebTransport connection + MOQT session for one MoQ source. * - * Wraps the callback-shaped `network/moqt` session driver in a reactive snapshot: behaviors read + * Wraps the callback-shaped `@caprid/moq-core` session driver in a reactive snapshot: behaviors read * `snapshot.context.status` for the connection lifecycle (`'connecting' → 'ready'`, terminal `'closed'`/`'failed'`) and * `snapshot.context.session` for the live `MoqtSession` once ready. A reducer-shaped `TransitionActor` fits — the * interesting state is all context; the finite `value` is just the universal active/destroyed lifecycle marker. @@ -22,10 +22,18 @@ * `MoqAuthProvider.refreshToken`) for a future relay generation that accepts AUTHORIZATION_TOKEN request parameters, at * which point a token could ride a request instead of only the connect URL. */ +import { + createMoqtSession, + type Goaway, + type MessageParameters, + MOQT_PROTOCOL_ID, + MOQT_PROTOCOL_IDS, + type MoqtSession, + type MoqtTransport, +} from '@caprid/moq-core'; + import { createTransitionActor, type TransitionActor } from '../../core/actors/create-transition-actor'; import type { MoqSource } from '../../media/moq/parse-source'; -import { type MessageParameters, MOQT_PROTOCOL_ID } from '../../network/moqt/control-messages'; -import { createMoqtSession, type Goaway, type MoqtSession, type MoqtTransport } from '../../network/moqt/session'; import { DEFAULT_RECONNECT_BACKOFF_CONFIG, type RetryBackoffConfig, @@ -55,7 +63,11 @@ type SessionMessage = | { type: 'closed' } | { type: 'failed'; error: unknown }; -/** Transport factory seam. A browser passes the `WebTransport`-backed default; tests inject an in-memory fake. */ +/** + * Transport factory seam. A browser passes the `WebTransport`-backed default; tests inject an in-memory fake. + * `protocols` lists the MOQT versions on offer, most preferred first. The returned transport must report the one the + * peer selected as `protocol` — the session picks its codec from it, and reads a missing value as `moqt-22`. + */ export type CreateMoqTransport = ( connectUrl: string, protocols: string[] @@ -117,12 +129,16 @@ function createWebTransport( connectUrl: string, protocols: string[] ): { transport: MoqtTransport; ready: Promise } { - const transport = new WebTransport(connectUrl, { protocols }); + // The session reads the negotiated version from `transport.protocol` (the + // `WT-Protocol` response). A browser without that attribute cannot say + // which version the relay picked, so it offers only the default one. + const offered = 'protocol' in WebTransport.prototype ? protocols : [MOQT_PROTOCOL_ID]; + const transport: WebTransport & MoqtTransport = new WebTransport(connectUrl, { protocols: offered }); return { transport, ready: transport.ready.then(() => undefined) }; } -// Fatal, unlike `network/moqt/bytes`' shared `utf8Decode` — that decoder is +// Fatal, unlike `@caprid/moq-core`'s shared `utf8Decode` — that decoder is // non-fatal because other wire code legitimately tolerates lossy text, and // must stay that way. A token is different: silently substituting U+FFFD // for invalid bytes sends a corrupted credential to the relay, which @@ -293,7 +309,7 @@ export function createMoqSessionActor(options: CreateMoqSessionActorOptions): Mo } } - const created = createTransport(composePlaybackConnectUrl(source.connectUrl, authToken), [MOQT_PROTOCOL_ID]); + const created = createTransport(composePlaybackConnectUrl(source.connectUrl, authToken), [...MOQT_PROTOCOL_IDS]); transport = created.transport; pendingTransport = transport; @@ -398,7 +414,7 @@ export function createMoqSessionActor(options: CreateMoqSessionActorOptions): Mo // parameter list) and hard-closes the session (`5 "invalid value"`) // when one appears — the same defect fixed on the publish side in // `publish-session.ts`. Re-attach via this seam - // (encodeAuthTokenUseValue, §10.2.2) once relays accept it. + // (AUTHORIZATION TOKEN Parameter, moqt-22 §9.20.2) once relays accept it. const tokenParameters = (): MessageParameters => ({}); return { diff --git a/packages/spf/src/playback/actors/tests/moq-session.test.ts b/packages/spf/src/playback/actors/tests/moq-session.test.ts index 8aaf6c0bba..f46d84daf0 100644 --- a/packages/spf/src/playback/actors/tests/moq-session.test.ts +++ b/packages/spf/src/playback/actors/tests/moq-session.test.ts @@ -1,8 +1,8 @@ +import type { MoqtTransport } from '@caprid/moq-core'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'; import type { MoqSource } from '../../../media/moq/parse-source'; -import { encodeSetup } from '../../../network/moqt/control-messages'; -import type { MoqtTransport } from '../../../network/moqt/session'; +import { encodeSetup } from '../../../network/tests/helpers/moqt-wire'; import { type CreateMoqTransport, composePlaybackConnectUrl, createMoqSessionActor } from '../moq-session'; // ============================================================================ @@ -81,14 +81,14 @@ makeCreateTransport.lastConnect = undefined as { connectUrl: string; protocols: // ============================================================================ describe('createMoqSessionActor', () => { - it('connects with the draft protocol id and reaches ready on the server SETUP', async () => { + it('offers moqt-22 then moqt-20 and reaches ready on the server SETUP', async () => { const fake = createFakeTransport(); const actor = createMoqSessionActor({ source: makeSource(), createTransport: makeCreateTransport(fake) }); expect(actor.snapshot.get().context.status).toBe('connecting'); expect(makeCreateTransport.lastConnect).toMatchObject({ connectUrl: 'https://relay.example.com/live', - protocols: ['moqt-20'], + protocols: ['moqt-22', 'moqt-20'], }); fake.sendServerSetup(); diff --git a/packages/spf/src/playback/actors/tests/track-subscriber.test.ts b/packages/spf/src/playback/actors/tests/track-subscriber.test.ts index e8c729cf2d..5be3b21590 100644 --- a/packages/spf/src/playback/actors/tests/track-subscriber.test.ts +++ b/packages/spf/src/playback/actors/tests/track-subscriber.test.ts @@ -1,9 +1,13 @@ +import { + type MoqtObject, + type MoqtSession, + PUBLISH_DONE_STATUS, + REQUEST_ERROR_CODE, + type SubscriptionHandlers, +} from '@caprid/moq-core'; import { afterEach, describe, expect, it, vi } from 'vite-plus/test'; import type { MoqTrack } from '../../../media/moq/parse-catalog'; -import { PUBLISH_DONE_STATUS, REQUEST_ERROR_CODE } from '../../../network/moqt/control-messages'; -import type { MoqtObject } from '../../../network/moqt/object-stream'; -import type { MoqtSession, SubscriptionHandlers } from '../../../network/moqt/session'; import { createTrackSubscriberActor, DEFAULT_STALL_TIMEOUT_MS, MEDIA_SUBSCRIBER_PRIORITY } from '../track-subscriber'; // ============================================================================ diff --git a/packages/spf/src/playback/actors/track-subscriber.ts b/packages/spf/src/playback/actors/track-subscriber.ts index e22a21d0eb..7f98ddd706 100644 --- a/packages/spf/src/playback/actors/track-subscriber.ts +++ b/packages/spf/src/playback/actors/track-subscriber.ts @@ -17,19 +17,25 @@ * stays silent past the deadline is treated as dead even though the wire never said so — the subscription is cancelled * and the status goes `'error'`, which is the terminal signal `subscribe-selected-tracks` recovers from. */ -import { createTransitionActor, type TransitionActor } from '../../core/actors/create-transition-actor'; -import { parseTrackTimescale, toLocFrame } from '../../media/moq/loc'; -import type { MoqTrack } from '../../media/moq/parse-catalog'; -import { TIMELINE_DISCONTINUITY_US } from '../../media/moq/timeline'; -import type { Location, LocationFilter, MessageParameters } from '../../network/moqt/control-messages'; import { compareLocations, isRetryablePublishDoneStatus, isRetryableRequestErrorCode, + type Location, + type LocationFilter, + type MessageParameters, + type MoqtObject, + type MoqtSession, + type PublishDone, REQUEST_ERROR_CODE, -} from '../../network/moqt/control-messages'; -import type { MoqtObject } from '../../network/moqt/object-stream'; -import type { MoqtSession, PublishDone, RequestError, Subscription } from '../../network/moqt/session'; + type RequestError, + type Subscription, +} from '@caprid/moq-core'; + +import { createTransitionActor, type TransitionActor } from '../../core/actors/create-transition-actor'; +import { parseTrackTimescale, toLocFrame } from '../../media/moq/loc'; +import type { MoqTrack } from '../../media/moq/parse-catalog'; +import { TIMELINE_DISCONTINUITY_US } from '../../media/moq/timeline'; // ============================================================================= // Types @@ -52,7 +58,7 @@ export interface TrackSubscriberContext { /** True once a keyframe-led group is buffered — safe to hand off to a decoder. */ hasDecodableFrame: boolean; /** - * A valid media frame arrived beyond this subscription's SUBSCRIBE_OK LARGEST_OBJECT boundary (moqt-20 §10.2.17). + * A valid media frame arrived beyond this subscription's SUBSCRIBE_OK LARGEST_OBJECT boundary (moqt-22 §9.20.17). * Latched across buffer drains until auth refresh retires the attempt. Acceptance and cached replay alone leave this * false. An omitted boundary means the publisher had no objects yet, so its first media frame is fresh. */ diff --git a/packages/spf/src/playback/behaviors/adapt-latency-target.ts b/packages/spf/src/playback/behaviors/adapt-latency-target.ts index 6f44fae4ab..56851b5f78 100644 --- a/packages/spf/src/playback/behaviors/adapt-latency-target.ts +++ b/packages/spf/src/playback/behaviors/adapt-latency-target.ts @@ -10,9 +10,10 @@ * * ## What it can observe, and what it cannot * - * There is no transport RTT here. spf speaks its own draft-20 stack (no PROBE — that is a moq-lite extension) and - * browsers do not populate `WebTransport.getStats().smoothedRtt`, so the absolute one-way delay is simply not - * available. The no-RTT path is therefore the only path, and the estimate is built from what _is_ observable: + * There is no transport RTT here. spf speaks IETF MOQT through `@caprid/moq-core` (no PROBE — that is a moq-lite + * extension) and browsers do not populate `WebTransport.getStats().smoothedRtt`, so the absolute one-way delay is + * simply not available. The no-RTT path is therefore the only path, and the estimate is built from what _is_ + * observable: * * - **Arrival jitter** (`TrackSubscriberContext.arrivalJitter`): the decaying spread between the earliest and latest * recent arrival offsets. Offsets mix two unrelated clock epochs so their absolute value means nothing; their diff --git a/packages/spf/src/playback/behaviors/resolve-catalog.ts b/packages/spf/src/playback/behaviors/resolve-catalog.ts index a772bb295a..d9dd94be7f 100644 --- a/packages/spf/src/playback/behaviors/resolve-catalog.ts +++ b/packages/spf/src/playback/behaviors/resolve-catalog.ts @@ -11,7 +11,7 @@ * `state.presentation` (delta re-parse). Stable track ids (`parse-catalog`) keep unchanged track lists from re-firing * selection. * - * Join shape: a `relative-group 1` Location Filter (draft-20 §5.1.2) asks for `{Largest.Group, 0}` onward, and relays + * Join shape: a `relative-group 1` Location Filter (draft-22 §3.3.1) asks for `{Largest.Group, 0}` onward, and relays * serve the already-published head of that group from cache on the ordinary subgroup stream. msf-01 §5 still words the * join as SUBSCRIBE plus a Joining FETCH; draft-20 removed Joining FETCH, and against moq-relay a FETCH never carried * catalog data anyway — the catalog resolved from the relay's current-group replay. This filter asks for that replay @@ -34,6 +34,16 @@ * Multi-writer on `state.presentation` with the engine adapter (initial `{ url }` input) — same legitimate split as * `resolvePresentation`. */ +import { + isRetryablePublishDoneStatus, + isRetryableRequestErrorCode, + type LocationFilter, + type MessageParameters, + REQUEST_ERROR_CODE, + type Subscription, + utf8Decode, +} from '@caprid/moq-core'; + import { defineBehavior } from '../../core/composition/create-composition'; import type { Reactor } from '../../core/reactors/create-machine-reactor'; import { createMachineReactor } from '../../core/reactors/create-machine-reactor'; @@ -46,14 +56,6 @@ import { } from '../../media/moq/parse-catalog'; import { isMoqSourceUrl, parseMoqSource } from '../../media/moq/parse-source'; import type { MaybeResolvedPresentation } from '../../media/types'; -import { utf8Decode } from '../../network/moqt/bytes'; -import type { LocationFilter, MessageParameters } from '../../network/moqt/control-messages'; -import { - isRetryablePublishDoneStatus, - isRetryableRequestErrorCode, - REQUEST_ERROR_CODE, -} from '../../network/moqt/control-messages'; -import type { Subscription } from '../../network/moqt/session'; import { DEFAULT_SUBSCRIBE_RETRY_BACKOFF_CONFIG, MAX_SERVER_RETRY_INTERVAL_MS, @@ -90,7 +92,7 @@ export interface ResolveCatalogConfig { subscribeRetry?: Partial; } -/** The current group from its start: the independent catalog object and the deltas published since (§5.1.2). */ +/** The current group from its start: the independent catalog object and the deltas published since (moqt-22 §3.3.1). */ const CATALOG_JOIN_FILTER: LocationFilter = { type: 'relative-group', groupsBeforeNext: 1 }; type ResolveCatalogFsmState = 'preconditions-unmet' | 'awaiting-session' | 'catalog-active'; diff --git a/packages/spf/src/playback/behaviors/subscribe-selected-tracks.ts b/packages/spf/src/playback/behaviors/subscribe-selected-tracks.ts index ca69567ff4..0067ec934c 100644 --- a/packages/spf/src/playback/behaviors/subscribe-selected-tracks.ts +++ b/packages/spf/src/playback/behaviors/subscribe-selected-tracks.ts @@ -38,6 +38,8 @@ * pending-snapshot changes, plus status _transitions_ of its own actors (equality-gated `computed`s over the slots) and * the rejoin timer's tick, not on its own slot writes. */ +import type { LocationFilter } from '@caprid/moq-core'; + import { defineBehavior } from '../../core/composition/create-composition'; import type { Reactor } from '../../core/reactors/create-machine-reactor'; import { createMachineReactor } from '../../core/reactors/create-machine-reactor'; @@ -45,7 +47,6 @@ import { computed, peek, type ReadonlySignal, type Signal, signal } from '../../ import type { MoqTrack } from '../../media/moq/parse-catalog'; import { isLiveTrack, type MaybeResolvedPresentation } from '../../media/types'; import { findTrack } from '../../media/utils/tracks'; -import type { LocationFilter } from '../../network/moqt/control-messages'; import { DEFAULT_SUBSCRIBE_RETRY_BACKOFF_CONFIG, MAX_SERVER_RETRY_INTERVAL_MS, diff --git a/packages/spf/src/playback/behaviors/tests/resolve-catalog.test.ts b/packages/spf/src/playback/behaviors/tests/resolve-catalog.test.ts index 99ecb47f02..9de7942a8e 100644 --- a/packages/spf/src/playback/behaviors/tests/resolve-catalog.test.ts +++ b/packages/spf/src/playback/behaviors/tests/resolve-catalog.test.ts @@ -1,15 +1,16 @@ +import { + type MessageParameters, + type MoqtSession, + PUBLISH_DONE_STATUS, + REQUEST_ERROR_CODE, + type SubscriptionHandlers, +} from '@caprid/moq-core'; import { afterEach, describe, expect, it, vi } from 'vite-plus/test'; import { signal } from '../../../core/signals/primitives'; import { isResolvedPresentation, type MaybeResolvedPresentation } from '../../../media/types'; import { getTracksByType } from '../../../media/utils/tracks'; -import { utf8Encode } from '../../../network/moqt/bytes'; -import { - type MessageParameters, - PUBLISH_DONE_STATUS, - REQUEST_ERROR_CODE, -} from '../../../network/moqt/control-messages'; -import type { MoqtSession, SubscriptionHandlers } from '../../../network/moqt/session'; +import { utf8Encode } from '../../../network/tests/helpers/moqt-wire'; import type { MoqSessionActor, MoqSessionActorContext } from '../../actors/moq-session'; import { resolveCatalog } from '../resolve-catalog'; diff --git a/packages/spf/src/playback/behaviors/tests/setup-moq-session.test.ts b/packages/spf/src/playback/behaviors/tests/setup-moq-session.test.ts index 65f630c421..5601edb4ca 100644 --- a/packages/spf/src/playback/behaviors/tests/setup-moq-session.test.ts +++ b/packages/spf/src/playback/behaviors/tests/setup-moq-session.test.ts @@ -1,9 +1,9 @@ +import type { MoqtTransport } from '@caprid/moq-core'; import { describe, expect, it, vi } from 'vite-plus/test'; import { signal } from '../../../core/signals/primitives'; import type { MaybeResolvedPresentation } from '../../../media/types'; -import { encodeSetup } from '../../../network/moqt/control-messages'; -import type { MoqtTransport } from '../../../network/moqt/session'; +import { encodeSetup } from '../../../network/tests/helpers/moqt-wire'; import type { MoqSessionActor } from '../../actors/moq-session'; import { setupMoqSession } from '../setup-moq-session'; diff --git a/packages/spf/src/playback/behaviors/tests/subscribe-selected-tracks.test.ts b/packages/spf/src/playback/behaviors/tests/subscribe-selected-tracks.test.ts index 497f28ca1b..658c181041 100644 --- a/packages/spf/src/playback/behaviors/tests/subscribe-selected-tracks.test.ts +++ b/packages/spf/src/playback/behaviors/tests/subscribe-selected-tracks.test.ts @@ -1,14 +1,15 @@ +import { + type MessageParameters, + type MoqtSession, + PUBLISH_DONE_STATUS, + REQUEST_ERROR_CODE, + type SubscriptionHandlers, +} from '@caprid/moq-core'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'; import { signal } from '../../../core/signals/primitives'; import type { MoqAudioTrack, MoqVideoTrack } from '../../../media/moq/parse-catalog'; import type { MaybeResolvedPresentation } from '../../../media/types'; -import { - type MessageParameters, - PUBLISH_DONE_STATUS, - REQUEST_ERROR_CODE, -} from '../../../network/moqt/control-messages'; -import type { MoqtSession, SubscriptionHandlers } from '../../../network/moqt/session'; import type { MoqSessionActor, MoqSessionActorContext } from '../../actors/moq-session'; import { createTrackSubscriberActor, @@ -956,6 +957,7 @@ describe.each([ }, fetch: () => ({ requestId: 0, cancel: vi.fn() }), trackStatus: vi.fn(), + subscribeNamespace: () => ({ requestId: 0, cancel: vi.fn() }), close: vi.fn(), destroy: vi.fn(), }; @@ -1260,6 +1262,7 @@ describe('subscriber priority on the wire', () => { }, fetch: () => ({ requestId: 0, cancel: vi.fn() }), trackStatus: vi.fn(), + subscribeNamespace: () => ({ requestId: 0, cancel: vi.fn() }), close: vi.fn(), destroy: vi.fn(), }; diff --git a/packages/spf/src/playback/engines/moq/tests/engine.test.ts b/packages/spf/src/playback/engines/moq/tests/engine.test.ts index f76a449bbf..0d12b50cdd 100644 --- a/packages/spf/src/playback/engines/moq/tests/engine.test.ts +++ b/packages/spf/src/playback/engines/moq/tests/engine.test.ts @@ -1,23 +1,21 @@ +import { type BidirectionalStreamLike, ByteWriter, type MoqtTransport, REQUEST_ERROR_CODE } from '@caprid/moq-core'; import { describe, expect, it, vi } from 'vite-plus/test'; import { isResolvedPresentation } from '../../../../media/types'; -import { ByteWriter, StreamReader, utf8Encode } from '../../../../network/moqt/bytes'; import { type ControlMessage, - ControlMessageDeframer, decodeControlMessage, encodeRequestError, encodeSetup, encodeSubscribeOk, - REQUEST_ERROR_CODE, -} from '../../../../network/moqt/control-messages'; -import type { BidirectionalStreamLike } from '../../../../network/moqt/request-stream'; -import type { MoqtTransport } from '../../../../network/moqt/session'; + StreamReader, + utf8Encode, +} from '../../../../network/tests/helpers/moqt-wire'; import type { CreateMoqTransport } from '../../../actors/moq-session'; import { createMoqEngine, type MoqEngineConfig, type MoqEngineSignals } from '../engine'; // ============================================================================ -// In-memory relay: speaks real draft-20 bytes over a fake WebTransport. +// In-memory relay: speaks real draft-22 bytes over a fake WebTransport. // ============================================================================ const CATALOG = JSON.stringify({ @@ -83,7 +81,6 @@ function createFakeRelay(catalog: string = CATALOG) { const handleRequestStream = async (stream: BidirectionalStreamLike) => { const reader = new StreamReader(stream.readable); - const deframer = new ControlMessageDeframer(); const writer = stream.writable.getWriter(); const type = await reader.readVarint(); const high = await reader.readUint8(); @@ -91,8 +88,6 @@ function createFakeRelay(catalog: string = CATALOG) { const body = await reader.readBytes(high * 256 + low); const message = decodeControlMessage({ type, body }); - void deframer; - if (message.kind === 'subscribe') { const trackAlias = nextAlias++; @@ -108,7 +103,7 @@ function createFakeRelay(catalog: string = CATALOG) { } if (message.kind === 'fetch') { - // The engine never fetches (a draft-20 join is a subscription filter); + // The engine never fetches (a draft-22 join is a subscription filter); // anything that does is refused — no history is retained. await writer.write(encodeRequestError(REQUEST_ERROR_CODE.INVALID_RANGE, 'nothing published')); await writer.close(); @@ -407,10 +402,10 @@ describe('createMoqEngine', () => { await engine.destroy(); }); - // A relay can replay buffered groups to a joining subscriber (a draft-20 - // current-group join replays that group from cache; older relays replayed - // several), so the jitter buffer can start seconds deep. `latency.joinAtEdge` decides - // whether playout starts at the front of that replay or at its edge. + // A relay can replay buffered groups to a joining subscriber (a current-group + // join replays that group from cache; older relays replayed several), so the + // jitter buffer can start seconds deep. `latency.joinAtEdge` decides whether + // playout starts at the front of that replay or at its edge. // // The canvas is attached after the replay lands so the assertion is about // the anchor and not about how fast the burst arrives; the controller is diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a408954d35..16b615102c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1247,9 +1247,12 @@ importers: packages/spf: dependencies: + '@caprid/moq-core': + specifier: ^0.1.1 + version: 0.1.1 '@caprid/moq-media': - specifier: ^0.1.0 - version: 0.1.0 + specifier: ^0.1.1 + version: 0.1.1 '@videojs/media': specifier: workspace:* version: link:../media @@ -2106,12 +2109,12 @@ packages: cpu: [x64] os: [win32] - '@caprid/moq-core@0.1.0': - resolution: {integrity: sha512-GWNqRU+XODpG/4fCUQVXYZtONVibYOY4BwYH4rt7lQuvBJ0sh49W4gw+1jAhY+a924bMGSSGzJ1shr8G5xMMmQ==} + '@caprid/moq-core@0.1.1': + resolution: {integrity: sha512-y6jUAxcqwutliM3gfIQeWspmw/rtfcJDgktgyx/JkRQwlMeiojMv8No6X4uVyTm2HwBDTRRagTVpDjtPQuhNrw==} engines: {node: '>=24'} - '@caprid/moq-media@0.1.0': - resolution: {integrity: sha512-Iu2+r7JYZoRYzoM9Xf3aK2KqBH8x26NGpKhdI3jFICoSr3IeAIXPYaad46HkHq68ottv5LwV4cxyVaFGrQfbZg==} + '@caprid/moq-media@0.1.1': + resolution: {integrity: sha512-H4KkqLqgdYz01hT2aG+gtza/Af9fXAOjfoMcR0OlbelQmnd9IC4ngCNlp17bPqyfUr7OOtiJzHN0EUxUrk91vQ==} engines: {node: '>=24'} '@capsizecss/unpack@4.0.0': @@ -11015,11 +11018,11 @@ snapshots: '@bruits/satteri-win32-x64-msvc@0.10.5': optional: true - '@caprid/moq-core@0.1.0': {} + '@caprid/moq-core@0.1.1': {} - '@caprid/moq-media@0.1.0': + '@caprid/moq-media@0.1.1': dependencies: - '@caprid/moq-core': 0.1.0 + '@caprid/moq-core': 0.1.1 '@capsizecss/unpack@4.0.0': dependencies: