@blockcast/mmt-container 0.4.0-main.66aaafd6f03d → 0.4.0-main.69dc82f179f9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +30 -15
  2. package/dist/browser-runtime.js +1248 -584
  3. package/dist/browser-runtime.js.map +4 -4
  4. package/dist/carp-catalog.d.ts +56 -25
  5. package/dist/carp-catalog.d.ts.map +1 -1
  6. package/dist/carp-catalog.js +262 -196
  7. package/dist/carp-catalog.js.map +3 -3
  8. package/dist/catalog-fec-params.d.ts +6 -3
  9. package/dist/catalog-fec-params.d.ts.map +1 -1
  10. package/dist/catalog-fec-params.js +104 -47
  11. package/dist/catalog-fec-params.js.map +4 -4
  12. package/dist/catalog-network-source.js +3 -0
  13. package/dist/catalog-network-source.js.map +3 -3
  14. package/dist/catalog-validator.d.ts +4 -3
  15. package/dist/catalog-validator.d.ts.map +1 -1
  16. package/dist/catalog-validator.js +0 -29
  17. package/dist/catalog-validator.js.map +3 -3
  18. package/dist/delivery-catalog.js +90 -230
  19. package/dist/delivery-catalog.js.map +4 -4
  20. package/dist/fec-manager.d.ts +15 -0
  21. package/dist/fec-manager.d.ts.map +1 -1
  22. package/dist/fec-manager.js +99 -39
  23. package/dist/fec-manager.js.map +3 -3
  24. package/dist/fec-state.d.ts +3 -2
  25. package/dist/fec-state.d.ts.map +1 -1
  26. package/dist/fec-state.js +30 -11
  27. package/dist/fec-state.js.map +4 -4
  28. package/dist/fec-worker-setup.d.ts.map +1 -1
  29. package/dist/fec-worker-setup.js +13 -2
  30. package/dist/fec-worker-setup.js.map +3 -3
  31. package/dist/index.d.ts +3 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +10 -0
  34. package/dist/index.js.map +2 -2
  35. package/dist/iso-block-locator.js +3 -0
  36. package/dist/iso-block-locator.js.map +3 -3
  37. package/dist/manifest-auth-plan.d.ts +26 -25
  38. package/dist/manifest-auth-plan.d.ts.map +1 -1
  39. package/dist/manifest-auth-plan.js +315 -1163
  40. package/dist/manifest-auth-plan.js.map +4 -4
  41. package/dist/mfu-reassembler.js +24 -13
  42. package/dist/mfu-reassembler.js.map +3 -3
  43. package/dist/mmtp-container-parser.d.ts.map +1 -1
  44. package/dist/mmtp-container-parser.js +96 -22
  45. package/dist/mmtp-container-parser.js.map +3 -3
  46. package/dist/mmtp-container-parser.no-modules.js +1045 -311
  47. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  48. package/dist/mmtp-decode-pipeline.js +96 -22
  49. package/dist/mmtp-decode-pipeline.js.map +3 -3
  50. package/dist/mmtp-fec-session.d.ts +156 -0
  51. package/dist/mmtp-fec-session.d.ts.map +1 -0
  52. package/dist/mmtp-fec-session.js +522 -0
  53. package/dist/mmtp-fec-session.js.map +7 -0
  54. package/dist/mmtp-router.d.ts +14 -4
  55. package/dist/mmtp-router.d.ts.map +1 -1
  56. package/dist/mmtp-router.js +156 -22
  57. package/dist/mmtp-router.js.map +3 -3
  58. package/dist/multicast-auth-catalog.d.ts +86 -92
  59. package/dist/multicast-auth-catalog.d.ts.map +1 -1
  60. package/dist/multicast-auth-catalog.js +331 -124
  61. package/dist/multicast-auth-catalog.js.map +3 -3
  62. package/dist/multicast-input.d.ts +25 -3
  63. package/dist/multicast-input.d.ts.map +1 -1
  64. package/dist/multicast-input.js +273 -13
  65. package/dist/multicast-input.js.map +3 -3
  66. package/dist/multicast-manager.d.ts +72 -4
  67. package/dist/multicast-manager.d.ts.map +1 -1
  68. package/dist/multicast-manager.js +500 -331
  69. package/dist/multicast-manager.js.map +4 -4
  70. package/dist/multicast-transport.d.ts +6 -2
  71. package/dist/multicast-transport.d.ts.map +1 -1
  72. package/dist/multicast-transport.js +99 -234
  73. package/dist/multicast-transport.js.map +4 -4
  74. package/dist/multicast-unwrap.js +24 -13
  75. package/dist/multicast-unwrap.js.map +3 -3
  76. package/dist/no-modules.d.ts +2 -0
  77. package/dist/no-modules.d.ts.map +1 -1
  78. package/dist/no-modules.js +996 -299
  79. package/dist/no-modules.js.map +4 -4
  80. package/dist/repair-fetch.d.ts +23 -1
  81. package/dist/repair-fetch.d.ts.map +1 -1
  82. package/dist/repair-fetch.js +38 -10
  83. package/dist/repair-fetch.js.map +3 -3
  84. package/dist/repair-layers.js +3 -0
  85. package/dist/repair-layers.js.map +3 -3
  86. package/dist/sample-combiner.d.ts +7 -1
  87. package/dist/sample-combiner.d.ts.map +1 -1
  88. package/dist/sample-combiner.js +14 -2
  89. package/dist/sample-combiner.js.map +2 -2
  90. package/dist/signaling.d.ts +2 -2
  91. package/dist/signaling.d.ts.map +1 -1
  92. package/dist/signaling.js +6 -3
  93. package/dist/signaling.js.map +3 -3
  94. package/dist/source-auth.js +22 -6
  95. package/dist/source-auth.js.map +2 -2
  96. package/dist/switching-set-alignment.d.ts +1 -1
  97. package/dist/switching-set-alignment.js.map +1 -1
  98. package/dist/timestamp-codec.js +24 -13
  99. package/dist/timestamp-codec.js.map +3 -3
  100. package/dist/wasm-mfu-reassembler.js +3 -0
  101. package/dist/wasm-mfu-reassembler.js.map +3 -3
  102. package/dist/wasm-mmtp-container-parser.js +96 -22
  103. package/dist/wasm-mmtp-container-parser.js.map +3 -3
  104. package/package.json +5 -5
  105. package/schemas/catalog.schema.json +81 -28
  106. package/src/carp-catalog.ts +109 -48
  107. package/src/catalog-fec-params.ts +43 -19
  108. package/src/catalog-validator.ts +4 -11
  109. package/src/fec-manager.ts +111 -49
  110. package/src/fec-state.ts +6 -10
  111. package/src/fec-worker-setup.ts +16 -1
  112. package/src/index.ts +23 -2
  113. package/src/manifest-auth-plan.ts +39 -91
  114. package/src/mmtp-container-parser.ts +75 -7
  115. package/src/mmtp-fec-session.ts +514 -0
  116. package/src/mmtp-router.ts +101 -5
  117. package/src/multicast-auth-catalog.ts +131 -238
  118. package/src/multicast-input.ts +88 -37
  119. package/src/multicast-manager.ts +231 -21
  120. package/src/multicast-transport.ts +14 -3
  121. package/src/no-modules.ts +2 -0
  122. package/src/repair-fetch.ts +79 -14
  123. package/src/sample-combiner.ts +15 -2
  124. package/src/signaling.ts +2 -2
  125. package/src/switching-set-alignment.ts +1 -1
  126. package/test-vectors/catalog/README.md +43 -4
  127. package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
  128. package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
  129. package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
  130. package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
  131. package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
  132. package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
  133. package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
  134. package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
  135. package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
  136. package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
  137. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
  138. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
  139. package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
  140. package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
  141. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-out-of-range.json +56 -0
  142. package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
  143. package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
  144. package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
  145. package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
  146. package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
  147. package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
  148. package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
  149. package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
  150. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +2 -2
  151. package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
  152. package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
  153. package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
  154. package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
  155. package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
  156. package/test-vectors/catalog/section-codes.json +23 -1
  157. package/test-vectors/catalog-multicast-auth-v1.json +38 -20
  158. package/test-vectors/catalog-validation.json +98 -2
  159. package/test-vectors/catalog-validator-public-api.mjs +14 -9
package/README.md CHANGED
@@ -121,7 +121,7 @@ function parseAlFecMessage(buf: Uint8Array): AlFecMessage | null // every FEC
121
121
  function parseMoqRepairFrame(buf: Uint8Array): MoqRepairFrame
122
122
  ```
123
123
 
124
- Constants worth knowing: `MMTP_HEADER_SIZE = 12`, `MPU_HEADER_SIZE = 8`, `MFU_DU_HEADER_SIZE_TIMED = 14`, `PACKET_TYPE_MPU = 0x00`, `PACKET_TYPE_REPAIR = 0x03`, `ALFEC_MESSAGE_ID = 0x0203`, `FEC_CODE_RAPTORQ = 2`.
124
+ Constants worth knowing: `MMTP_HEADER_SIZE = 12`, `MPU_HEADER_SIZE = 8`, `MFU_DU_HEADER_SIZE_TIMED = 14`, `PACKET_TYPE_MPU = 0x00`, `PACKET_TYPE_REPAIR = 0x03`, `ALFEC_MESSAGE_ID = 0x0203`, `FEC_CODE_RAPTORQ = 3`, `FEC_CODE_REED_SOLOMON = 1`.
125
125
 
126
126
  ```ts
127
127
  import { parseMMTPHeader, extractMFUPayload } from "@blockcast/mmt-base"
@@ -135,7 +135,7 @@ if (hdr.packetType === 0x00) { // MPU
135
135
 
136
136
  ### MFU reassembler (`./mfu`)
137
137
 
138
- Stateful reassembler for fragmented MFUs per ISO/IEC 23008-1:2023 §9.2.3.3 and the repository's contiguous-source producer profile. It partitions bounded continuation state by physical stream, MPU, and wrapping terminal source-packet sequence (`packet_sequence + fragment_counter`), queues FI=2/FI=3 by run and counter until FI=1 and any missing predecessor arrive, then propagates FI=1's intrinsic DU identity while draining the exact countdown. The terminal sequence is transport association only. ISO-permitted interleaving remains separated and incomplete; there is no scope, timestamp, SS_ID, or arrival-order fallback. Recovered packets use the authored u32 sequence from the reconstructed MMTP header.
138
+ Stateful reassembler for fragmented MFUs per ISO/IEC 23008-1:2023 §9.2.3.3 and the repository's contiguous-source producer profile. It partitions bounded continuation state by physical stream, MPU, and wrapping terminal source-packet sequence (`packet_sequence + fragment_counter`), queues FI=2/FI=3 by run and counter until FI=1 and any missing predecessor arrive, then propagates FI=1's intrinsic DU identity while draining the exact countdown. The terminal sequence is transport association only. ISO-permitted interleaving remains separated and incomplete; there is no scope, timestamp, SS_ID, or arrival-order fallback. The router feeds a recovered packet under the wire u32 sequence its SS_ID maps to through the stream's received FEC sources, since a hop may re-stamp the sequence after protection.
139
139
 
140
140
  ```ts
141
141
  interface MFUReassemblerOptions {
@@ -158,10 +158,12 @@ The constructor rejects non-null, non-finite, or non-positive deadlines. Reliabl
158
158
 
159
159
  ### CARP / CMSF catalog (`./carp-catalog`)
160
160
 
161
- Validate the published catalog schema through the package API. The schema uses
162
- the package-defined `uniqueMulticastAuthTrackBindings` keyword to reject reused
163
- `(mediaTrack, sourceSymbolFormat)` bindings, so compiling the JSON with a bare
164
- JSON Schema validator is not supported.
161
+ Validate the published catalog schema through the package API, then run
162
+ `validateCmsfMmtpCatalog`: the multicast rules of draft-ramadan-moq-multicast-01
163
+ that JSON Schema cannot state (a repeated `kid` or `firstEpoch` in
164
+ `multicast.auth.keys`, a `manifestPort` that clashes with a port of its
165
+ `(S, G)`, a track declaring a foreign namespace) live only in the runtime
166
+ validator.
165
167
 
166
168
  ```ts
167
169
  import schema from "@blockcast/mmt-container/catalog.schema.json" with { type: "json" }
@@ -173,7 +175,7 @@ if (!validateCatalog(catalog)) {
173
175
  }
174
176
  ```
175
177
 
176
- Implements `draft-law-ramadan-moq-carp-reliability` §3 (FEC), §4 (multicast endpoints), and `draft-ramadan-moq-mmt-00` §4.4.4 (track timing). Plain TypeScript interfaces with type guards — no Zod, no runtime schema dependency. Upstream Zod schemas should derive from these via `z.infer<>`.
178
+ Implements `draft-law-ramadan-moq-carp-reliability` §3 (FEC), §4 (multicast endpoints), and `draft-ramadan-moq-mmt-01` §4.4.2 (track timing). Plain TypeScript interfaces with type guards — no Zod, no runtime schema dependency. Upstream Zod schemas should derive from these via `z.infer<>`.
177
179
 
178
180
  ```ts
179
181
  type FecAlgorithm = "none" | "raptorq" | "reed-solomon"
@@ -187,7 +189,7 @@ interface FecCatalogConfig {
187
189
  interleaveDepthMs?: number // FEC block span in MILLISECONDS, default 0 (single-group blocks)
188
190
  repairTrack: string // §6.1 — required
189
191
  mode?: "interleaved" | "object" // extension; "object" (per-frame object blocks) is retired: @blockcast/mmt-fec refuses it
190
- uep?: { keyRatio: number; deltaRatio: number } // §9.1 — Unequal Error Protection
192
+ uep?: { keyRatio: number; deltaRatio: number } // Unequal Error Protection — Blockcast extension, not in draft-ramadan-moq-fec-01
191
193
  deltaFailWindowBlocks?: number // D-11, base track only
192
194
  deltaProbeIntervalMs?: number // D-13, base track only
193
195
  }
@@ -248,7 +250,9 @@ non-DRIAD AMT entry, so the manual one carries the relay while the DRIAD one
248
250
  keeps the discovery request. An `atsc3` endpoint now
249
251
  requires a `{type: "atsc3", …}` entry and throws `atsc3_requires_tuning`
250
252
  without one: that entry carries the frequency, PLP, service id and SLS URI,
251
- which is the only tuning information an ATSC3 receiver has, and the schema
253
+ which is the only tuning information an ATSC3 receiver has (the SLS behind
254
+ `slsUri` describes the MMTP session, MP table included, per A/331:2026-04 7.2,
255
+ and nothing of this profile, so `manifestPort` and keys come from provisioning), and the schema
252
256
  cannot enforce it because `networkSource` is optional there (a native join has
253
257
  none). `version`, `validUntil` and `enabled` are still emitted and still
254
258
  outside `$defs/multicast` (the BLO-3323 freshness model, tracked separately).
@@ -265,7 +269,7 @@ per-commit `0.1.0-main.<sha>` prerelease from `stamp-prerelease.mjs`), and a
265
269
  > Superseded by BLO-40665. Every package is now bumped in lockstep by a `v*`
266
270
  > tag and the sibling ranges move with it, so the objection above no longer
267
271
  > applies -- it was an argument against bumping *one* package. The set is at
268
- > `0.3.0`; see `RELEASES.md`.
272
+ > `0.4.0`; see `RELEASES.md`.
269
273
 
270
274
  #### Track-role convention (Phase 14)
271
275
 
@@ -278,7 +282,7 @@ This is **project-specific**, not in any IETF draft yet. The container's switchi
278
282
  | `video/repair` | `repair` | FEC repair-symbol leg, cross-CDN federated |
279
283
  | `video` (no slash) | `single` | Legacy single-track stream (D-04) |
280
284
 
281
- Empty names, unknown suffixes, trailing slashes, and any non-ASCII / control characters all throw at parse time (T-14-01 fuzz hardening at `carp-catalog.ts:49-57`). Multi-track switching sets must include all three roles or `validateSwitchingSet` reports the missing roles.
285
+ Empty names, unknown suffixes, trailing slashes, and any non-ASCII / control characters all throw at parse time (T-14-01 fuzz hardening at `carp-catalog.ts:49-57`). Multi-track switching sets must include `base` and `repair` or `validateSwitchingSet` reports the missing roles; `delta` is optional, since base is self-decodable and a base-only set plays in base-only mode (BLO-49199).
282
286
 
283
287
  ```ts
284
288
  import { parseTrackRole, validateSwitchingSet } from "@blockcast/mmt-container/carp-catalog"
@@ -289,6 +293,8 @@ parseTrackRole("video/foo") // throws "unknown role suffix"
289
293
 
290
294
  validateSwitchingSet(["v/base", "v/delta", "v/repair"]) // { ok: true }
291
295
  validateSwitchingSet(["v/base", "v/delta"]) // { ok: false, missing: ["repair"] }
296
+ validateSwitchingSet(["v/base", "v/repair"]) // { ok: true } — base-only
297
+ validateSwitchingSet(["v/delta", "v/repair"]) // { ok: false, missing: ["base"] }
292
298
  ```
293
299
 
294
300
  ### FEC manager (`./fec-manager`)
@@ -444,7 +450,7 @@ All string values pass through `sanitize()` (T-06-01) — commas, `\r`, `\n` are
444
450
 
445
451
  ### Multicast transport (`./multicast-transport`)
446
452
 
447
- Thin wrapper around the lowercase `window.multicast` gateway. Calls `globalThis.multicast.subscribe({ group, source, port, consume: 'bytes' })`, listens for `"bytes"` events (`CustomEvent<ArrayBuffer>`) on the returned `EventTarget` subscription, pumps packets to a callback, runs a 5-second watchdog, and fires `onTakeover` once both video and audio are confirmed receiving.
453
+ Thin wrapper around the lowercase `window.multicast` gateway. Calls `globalThis.multicast.subscribe({ group, source, port, consume: 'bytes' })`, listens for `"bytes"` events (`CustomEvent<ArrayBuffer>`) on the returned `EventTarget` subscription, pumps packets to a callback, runs a silence watchdog over the catalog-derived failback window (`setFailbackWindowMs`), and fires `onTakeover` once both video and audio are confirmed receiving.
448
454
 
449
455
  ```ts
450
456
  class MulticastTransport {
@@ -455,12 +461,21 @@ class MulticastTransport {
455
461
  confirmVideo(): void
456
462
  confirmAudio(): void
457
463
  onTakeover(cb: () => void): void
458
- onFailback(cb: () => void): void
464
+ onFailback(cb: (reason: MulticastFailbackReason) => void): void
465
+ setFailbackWindowMs(windowMs: number | null): void
459
466
  dispose(): void
460
467
  readonly stats: { packetsReceived: number; bytesReceived: number }
461
468
  }
462
469
  ```
463
470
 
471
+ **Failover vocabulary.** draft-multicast-01 Section 6 "failover" (multicast to
472
+ unicast) is libmmt's *failback*: `onFailback`, `MulticastManager.onFailback`,
473
+ `failbackAll`, `MediaRouter.failbackToMoq`, `MulticastFailbackReason`, and CMCD
474
+ `x-bc-ct` `mc-to-uc`. libmmt's in-code *failover* (`track-session.ts`) is the
475
+ per-track hop along a track's transport chain. The return to multicast is the
476
+ draft's switch to multicast / join / switch back; CMCD `mc-start` is fired
477
+ host-side.
478
+
464
479
  Direct Sockets is Chrome-IWA-only. Outside an IWA context `isAvailable()` returns false and join() warns + returns false. AMT tunneling and unicast fallback are handled by `@blockcast/mmt-transport`, not by this transport class.
465
480
 
466
481
  ## Track-role convention summary (Phase 14)
@@ -501,11 +516,11 @@ Roles are required by:
501
516
  - **ISO/IEC 14496-12** — ISOBMFF (consumed for fMP4 box construction in `mmtp-to-cmaf.ts`)
502
517
  - **draft-ietf-moq-catalogformat** — CMSF catalog (IETF MOQ WG)
503
518
  - **draft-law-ramadan-moq-carp-reliability** — CARP §3 (FEC) + §4 (multicast endpoints) + §5.1 (interleave units) + §6.1 (repair track)
504
- - **draft-ramadan-moq-mmt-00** — MMT-over-MoQ wire format (§4.4.4 group-duration signaling, §5.3 MMTP→CMAF mapping)
519
+ - **draft-ramadan-moq-mmt-01** — MMT-over-MoQ wire format (§4.4.2 group-duration signaling, §4 MoQ object mapping, §5 MFU mode)
505
520
  - **draft-ramadan-moq-fec** — AL-FEC over MoQ (§5.3 FEC Source Info object extension 0x11: SS_ID(32), fixed 4 bytes)
506
521
  - **RFC 6330** — RaptorQ Forward Error Correction (strict OTI codec in `@blockcast/mmt-fec`)
507
522
  - **RFC 9559** — CMCD (used by `CmcdProducer`)
508
- - **ATSC A/331** — Signaling, Delivery, Synchronization, Error Protection
523
+ - **ATSC A/331:2026-02 (informative for draft-fec-01 / draft-mmt-01; 7.2 SLS/MP table, 8.1.2.1 MMTP session, 8.1.2.5 AL-FEC) and A/331:2026-04 (normative for draft-multicast-01)** — Signaling, Delivery, Synchronization, Error Protection
509
524
 
510
525
  ## Related packages
511
526