Repository navigation
feat(spf): speak moqt-22 through @caprid/moq-core #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,13 @@ the spec text is ambiguous, and calls out each place it does. | |
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This migration plan is explicitly superseded, so retaining its draft-20 checklist leaves stale instructions in the repository. Delete Prompt for AI agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't fix. The MoQ plan files are kept on these integration branches deliberately. This one is marked superseded on the player instead. |
||
| 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. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The sandbox UI still says the default loopback relay speaks draft-20, contradicting this draft-22 update. Update Prompt for AI agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #77: the sandbox page now says draft-22. |
||||||||||
| * 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,21 +31,21 @@ 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; | ||||||||||
|
|
||||||||||
| /** LOC property IDs (draft-ietf-moq-loc-04 §2.3). */ | ||||||||||
| 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. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The draft-22 vi64 comment omits the 9-byte, 64-bit form, and Prompt for AI agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Corrected the comment in #77, but no encoder change. The decoder already reads the 9-byte form, and the 8-byte form's 56 bits cover every integer a JS number represents exactly (2^53), so the encoder never needs 9 bytes. |
||||||||||
| */ | ||||||||||
| 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. | ||||||||||
|
Comment on lines
+687
to
688
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Section 6.4.2.3 does not define FIN as cancellation; it explicitly distinguishes FIN from RESET_STREAM/STOP_SENDING cancellation. Describe the Prompt for AI agents
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #77. The comment now says a FIN isn't a cancellation (§6.4.2.2), that this loopback ends the subscription on either, and why that's harmless with this player (moq-core cancels with a reset and FINs only after the publisher). |
||||||||||
| if (done) break; | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: This temporary implementation plan should not remain in the repository after the implementation lands. Delete
.agents/plans/moq-engine-implementation.mdbefore merging, as required by.agents/plans/README.md.Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't fix, for the same reason: the MoQ plan files are kept on these integration branches deliberately.