@blockcast/mmt-container 0.4.0 → 0.4.1-main.47aa22331187

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 (210) hide show
  1. package/README.md +36 -20
  2. package/dist/align.d.ts +24 -18
  3. package/dist/align.d.ts.map +1 -1
  4. package/dist/align.js +23 -4
  5. package/dist/align.js.map +2 -2
  6. package/dist/browser-runtime.js +1839 -692
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +76 -39
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +321 -205
  11. package/dist/carp-catalog.js.map +3 -3
  12. package/dist/catalog-fec-params.d.ts +12 -4
  13. package/dist/catalog-fec-params.d.ts.map +1 -1
  14. package/dist/catalog-fec-params.js +40 -17
  15. package/dist/catalog-fec-params.js.map +3 -3
  16. package/dist/catalog-network-source.d.ts +28 -7
  17. package/dist/catalog-network-source.d.ts.map +1 -1
  18. package/dist/catalog-network-source.js +21 -1
  19. package/dist/catalog-network-source.js.map +2 -2
  20. package/dist/catalog-validator.d.ts +4 -3
  21. package/dist/catalog-validator.d.ts.map +1 -1
  22. package/dist/catalog-validator.js +0 -29
  23. package/dist/catalog-validator.js.map +3 -3
  24. package/dist/cmcd-producer.d.ts +8 -0
  25. package/dist/cmcd-producer.d.ts.map +1 -1
  26. package/dist/cmcd-producer.js +14 -0
  27. package/dist/cmcd-producer.js.map +2 -2
  28. package/dist/delivery-catalog.js +98 -234
  29. package/dist/delivery-catalog.js.map +4 -4
  30. package/dist/fec-manager.d.ts +121 -1
  31. package/dist/fec-manager.d.ts.map +1 -1
  32. package/dist/fec-manager.js +421 -66
  33. package/dist/fec-manager.js.map +3 -3
  34. package/dist/fec-state.d.ts +2 -1
  35. package/dist/fec-state.d.ts.map +1 -1
  36. package/dist/fec-state.js +18 -3
  37. package/dist/fec-state.js.map +3 -3
  38. package/dist/fec-worker-setup.d.ts +10 -0
  39. package/dist/fec-worker-setup.d.ts.map +1 -1
  40. package/dist/fec-worker-setup.js +15 -4
  41. package/dist/fec-worker-setup.js.map +2 -2
  42. package/dist/index.d.ts +5 -5
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +8 -8
  45. package/dist/index.js.map +2 -2
  46. package/dist/iso-block-locator.d.ts +39 -1
  47. package/dist/iso-block-locator.d.ts.map +1 -1
  48. package/dist/iso-block-locator.js +109 -17
  49. package/dist/iso-block-locator.js.map +3 -3
  50. package/dist/manifest-auth-plan.d.ts +26 -25
  51. package/dist/manifest-auth-plan.d.ts.map +1 -1
  52. package/dist/manifest-auth-plan.js +331 -1171
  53. package/dist/manifest-auth-plan.js.map +4 -4
  54. package/dist/mfu-reassembler.js +21 -13
  55. package/dist/mfu-reassembler.js.map +2 -2
  56. package/dist/mmtp-container-parser.d.ts.map +1 -1
  57. package/dist/mmtp-container-parser.js +93 -22
  58. package/dist/mmtp-container-parser.js.map +2 -2
  59. package/dist/mmtp-container-parser.no-modules.js +1137 -317
  60. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  61. package/dist/mmtp-decode-pipeline.js +93 -22
  62. package/dist/mmtp-decode-pipeline.js.map +2 -2
  63. package/dist/mmtp-fec-session.d.ts +159 -0
  64. package/dist/mmtp-fec-session.d.ts.map +1 -0
  65. package/dist/mmtp-fec-session.js +531 -0
  66. package/dist/mmtp-fec-session.js.map +7 -0
  67. package/dist/mmtp-router.d.ts +39 -6
  68. package/dist/mmtp-router.d.ts.map +1 -1
  69. package/dist/mmtp-router.js +184 -27
  70. package/dist/mmtp-router.js.map +2 -2
  71. package/dist/multicast-auth-catalog.d.ts +86 -92
  72. package/dist/multicast-auth-catalog.d.ts.map +1 -1
  73. package/dist/multicast-auth-catalog.js +347 -132
  74. package/dist/multicast-auth-catalog.js.map +4 -4
  75. package/dist/multicast-input.d.ts +31 -8
  76. package/dist/multicast-input.d.ts.map +1 -1
  77. package/dist/multicast-input.js +299 -35
  78. package/dist/multicast-input.js.map +3 -3
  79. package/dist/multicast-manager.d.ts +94 -5
  80. package/dist/multicast-manager.d.ts.map +1 -1
  81. package/dist/multicast-manager.js +877 -357
  82. package/dist/multicast-manager.js.map +4 -4
  83. package/dist/multicast-transport.d.ts +12 -2
  84. package/dist/multicast-transport.d.ts.map +1 -1
  85. package/dist/multicast-transport.js +108 -238
  86. package/dist/multicast-transport.js.map +4 -4
  87. package/dist/multicast-unwrap.js +21 -13
  88. package/dist/multicast-unwrap.js.map +2 -2
  89. package/dist/no-modules.d.ts +4 -1
  90. package/dist/no-modules.d.ts.map +1 -1
  91. package/dist/no-modules.js +1086 -301
  92. package/dist/no-modules.js.map +4 -4
  93. package/dist/phase14-catalog-override.d.ts +1 -1
  94. package/dist/phase14-catalog-override.d.ts.map +1 -1
  95. package/dist/phase14-catalog-override.js +2 -2
  96. package/dist/phase14-catalog-override.js.map +2 -2
  97. package/dist/repair-fetch.d.ts +81 -6
  98. package/dist/repair-fetch.d.ts.map +1 -1
  99. package/dist/repair-fetch.js +156 -31
  100. package/dist/repair-fetch.js.map +3 -3
  101. package/dist/repair-layers.d.ts +2 -0
  102. package/dist/repair-layers.d.ts.map +1 -1
  103. package/dist/repair-layers.js +19 -2
  104. package/dist/repair-layers.js.map +2 -2
  105. package/dist/sample-combiner.d.ts +7 -1
  106. package/dist/sample-combiner.d.ts.map +1 -1
  107. package/dist/sample-combiner.js +14 -2
  108. package/dist/sample-combiner.js.map +2 -2
  109. package/dist/signaling.d.ts +2 -2
  110. package/dist/signaling.d.ts.map +1 -1
  111. package/dist/signaling.js +3 -3
  112. package/dist/signaling.js.map +2 -2
  113. package/dist/source-auth.js +2710 -7
  114. package/dist/source-auth.js.map +4 -4
  115. package/dist/switching-set-alignment.d.ts +1 -1
  116. package/dist/switching-set-alignment.js.map +1 -1
  117. package/dist/timestamp-codec.js +21 -13
  118. package/dist/timestamp-codec.js.map +2 -2
  119. package/dist/wasm-mfu-reassembler.js.map +1 -1
  120. package/dist/wasm-mmtp-container-parser.js +93 -22
  121. package/dist/wasm-mmtp-container-parser.js.map +2 -2
  122. package/package.json +6 -9
  123. package/schemas/catalog.schema.json +133 -38
  124. package/src/align.ts +52 -21
  125. package/src/carp-catalog.ts +188 -68
  126. package/src/catalog-fec-params.ts +28 -3
  127. package/src/catalog-network-source.ts +49 -7
  128. package/src/catalog-validator.ts +4 -11
  129. package/src/cmcd-producer.ts +17 -0
  130. package/src/fec-manager.ts +452 -63
  131. package/src/fec-state.ts +11 -4
  132. package/src/fec-worker-setup.ts +30 -2
  133. package/src/index.ts +27 -10
  134. package/src/iso-block-locator.ts +110 -7
  135. package/src/manifest-auth-plan.ts +39 -91
  136. package/src/mmtp-container-parser.ts +75 -7
  137. package/src/mmtp-fec-session.ts +533 -0
  138. package/src/mmtp-router.ts +166 -7
  139. package/src/multicast-auth-catalog.ts +131 -238
  140. package/src/multicast-input.ts +148 -124
  141. package/src/multicast-manager.ts +267 -21
  142. package/src/multicast-transport.ts +17 -3
  143. package/src/no-modules.ts +7 -1
  144. package/src/phase14-catalog-override.ts +3 -3
  145. package/src/repair-fetch.ts +283 -39
  146. package/src/repair-layers.ts +22 -2
  147. package/src/sample-combiner.ts +15 -2
  148. package/src/signaling.ts +2 -2
  149. package/src/switching-set-alignment.ts +1 -1
  150. package/test-vectors/align.json +108 -32
  151. package/test-vectors/bc-provenance-v2.json +1526 -0
  152. package/test-vectors/catalog/README.md +71 -4
  153. package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
  154. package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
  155. package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
  156. package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
  157. package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
  158. package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
  159. package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
  160. package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
  161. package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
  162. package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
  163. package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
  164. package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
  165. package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
  166. package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
  167. package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
  168. package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
  169. package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
  170. package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
  171. package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
  172. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
  173. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
  174. package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
  175. package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
  176. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
  177. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
  178. package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
  179. package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
  180. package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
  181. package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
  182. package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
  183. package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
  184. package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
  185. package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
  186. package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
  187. package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
  188. package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
  189. package/test-vectors/catalog/positive/fec-multicast.json +1 -1
  190. package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
  191. package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
  192. package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
  193. package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
  194. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
  195. package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
  196. package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
  197. package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
  198. package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
  199. package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
  200. package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
  201. package/test-vectors/catalog/section-codes.json +31 -1
  202. package/test-vectors/catalog-multicast-auth-v1.json +38 -20
  203. package/test-vectors/catalog-validation.json +101 -5
  204. package/test-vectors/catalog-validator-public-api.mjs +14 -9
  205. package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
  206. package/dist/fec-codec.d.ts +0 -32
  207. package/dist/fec-codec.d.ts.map +0 -1
  208. package/dist/fec-codec.js +0 -47
  209. package/dist/fec-codec.js.map +0 -7
  210. package/src/fec-codec.ts +0 -61
@@ -11,10 +11,12 @@
11
11
  import {
12
12
  MMTP_PACKET_ID_MAX,
13
13
  MMTP_SIGNALING_PACKET_ID,
14
+ ISO_SSBG1_MIN_SYMBOL_SIZE,
14
15
  isFecBlockProfile,
15
16
  type FecBlockProfile,
16
17
  } from "@blockcast/mmt-base";
17
- import { resolveMulticastAuthCatalog, type MulticastAuthConfig } from "./multicast-auth-catalog.js";
18
+ import { multicastCatalogIssues, multicastEndpointSource } from "@blockcast/mmt-base";
19
+ import type { EndpointAuthConfig, MulticastAuthConfig } from "./multicast-auth-catalog.js";
18
20
  import {
19
21
  assembleRepairLayers,
20
22
  assertRepairTrackReachable,
@@ -126,13 +128,15 @@ export function hasSwitchingSetRole(names: string[]): boolean {
126
128
  * Validate that a set of track names forms a complete switching set.
127
129
  *
128
130
  * - Empty or single-track sets (all parsing to `"single"`) → `{ ok: true }`.
129
- * - Multi-track sets (any name has a role suffix) MUST include all three
130
- * roles (`base`, `delta`, `repair`). Missing roles are listed.
131
+ * - Multi-track sets (any name has a role suffix) MUST include `base` and
132
+ * `repair`. `delta` is optional (BLO-49199): base is the self-decodable leg,
133
+ * so a base-only set plays in base-only mode; a delta without base cannot.
134
+ * Missing roles are listed.
131
135
  *
132
136
  * Propagates throws from `parseTrackRole` (non-ASCII, unknown suffix, etc.).
133
137
  *
134
138
  * D-04: Legacy single-track streams pass without enforcement.
135
- * D-04: Once any suffix appears, the set is multi-track and must be complete.
139
+ * D-04: Once any suffix appears, the set is multi-track and needs base + repair.
136
140
  */
137
141
  export function validateSwitchingSet(
138
142
  trackNames: string[],
@@ -147,11 +151,11 @@ export function validateSwitchingSet(
147
151
  }
148
152
 
149
153
  // Multi-track: at least one name has a role suffix.
150
- // The set MUST contain all three required roles.
154
+ // The set MUST contain base and repair; delta is optional (BLO-49199).
151
155
  // Explicit Set<TrackRole> so the TrackRole-typed `required.filter`
152
156
  // callback can call .has(r) without a narrow-mismatch complaint.
153
157
  const presentRoles: Set<TrackRole> = new Set(roles.filter((r) => r !== "single"));
154
- const required: TrackRole[] = ["base", "delta", "repair"];
158
+ const required: TrackRole[] = ["base", "repair"];
155
159
  const missing = required.filter((r) => !presentRoles.has(r));
156
160
 
157
161
  if (missing.length > 0) {
@@ -162,7 +166,10 @@ export function validateSwitchingSet(
162
166
 
163
167
  // ── FEC Catalog Extension (CARP §3.2) ─────────────────────────
164
168
 
165
- export type FecAlgorithm = "none" | "raptorq" | "reed-solomon";
169
+ /** draft-ramadan-moq-fec-01 4: `none` and the two specified schemes, or any
170
+ * other registered token, which a receiver that does not implement it
171
+ * consumes without FEC (`fecAlgorithmUnimplemented`). */
172
+ export type FecAlgorithm = "none" | "raptorq" | "reed-solomon" | (string & {});
166
173
 
167
174
  export interface FecCatalogConfig {
168
175
  /** FEC algorithm identifier (REQUIRED per §4.1, values per §3.1). */
@@ -199,9 +206,9 @@ export interface FecCatalogConfig {
199
206
  * per draft-ramadan-moq-fec §6.3, never listed here. */
200
207
  repairTrack: string;
201
208
  /** FEC block mode: "interleaved" (default) or "object" (per-frame). */
202
- // extensions feature — see moqcast-draft docs/fec-extensions-material.md, not in public -00
209
+ // Blockcast extension, not in draft-ramadan-moq-fec-01 (its public object protection is the moq-object-v1 block profile, Section 7.6, which libmmt does not implement)
203
210
  mode?: "interleaved" | "object";
204
- /** UEP (Unequal Error Protection) — extensions feature, see moqcast-draft docs/fec-extensions-material.md, not in public -00. When present, repair count
211
+ /** UEP (Unequal Error Protection) — Blockcast extension, not in draft-ramadan-moq-fec-01. When present, repair count
205
212
  * varies per frame type. repairSymbols becomes the base (P-frame) count.
206
213
  * MUST be omitted on multi-track base/delta streams (D-08). */
207
214
  uep?: {
@@ -243,7 +250,7 @@ export interface FecCatalogConfig {
243
250
 
244
251
  /**
245
252
  * Whether a catalog `fec` block carries the FEC instance geometry a receiver
246
- * configures, its block profile aside: a supported `algorithm`, positive
253
+ * configures, its block profile aside: a non-empty `algorithm` token, positive
247
254
  * `sourceSymbols`, `repairSymbols` and `symbolSize` (8-byte aligned for
248
255
  * RaptorQ), and a non-empty `repairTrack`. A block that fails this is
249
256
  * malformed whatever its profile. Total: never throws.
@@ -254,8 +261,7 @@ export function isFecCatalogGeometry(obj: unknown): boolean {
254
261
  const algorithm = o["algorithm"];
255
262
  const symbolSize = o["symbolSize"];
256
263
  return (
257
- typeof algorithm === "string" &&
258
- (algorithm === "none" || algorithm === "raptorq" || algorithm === "reed-solomon") &&
264
+ typeof algorithm === "string" && algorithm.length > 0 &&
259
265
  typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 &&
260
266
  typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 &&
261
267
  typeof symbolSize === "number" && symbolSize >= 1 &&
@@ -280,10 +286,18 @@ export function isFecCatalogConfig(obj: unknown): obj is FecCatalogConfig {
280
286
 
281
287
  // ── Multicast Catalog Extension (CARP §4.1-4.4) ───────────────
282
288
 
283
- export type MulticastProtocol = "ssm" | "asm" | "amt" | "atsc3";
289
+ /**
290
+ * An endpoint's join mode, per draft-ramadan-moq-multicast-01 4.1 at
291
+ * Blockcast/moqcast-draft@fd962fd73d21ed281b60219c11ea61cc9e4e91c4.
292
+ * `sourceAddress` selects it (present: SSM, absent: ASM) and `protocol` only
293
+ * restates it. A bearer (AMT, ATSC 3.0) is a `networkSource` entry, never a
294
+ * protocol; `multicastEndpointSource` in `@blockcast/mmt-base` derives the
295
+ * mode and `S` for every reader.
296
+ */
297
+ export type MulticastProtocol = "ssm" | "asm";
284
298
 
285
299
  /**
286
- * Per-track endpoint membership, per draft-ramadan-moq-multicast-00 §4.1.
300
+ * Per-track endpoint membership, per draft-ramadan-moq-multicast-01 §4.1.
287
301
  *
288
302
  * `packetId` is the MMTP packet_id used for packet-level demux on the
289
303
  * multicast wire, in 1..65535: packet_id 0 (`MMTP_SIGNALING_PACKET_ID`) is
@@ -301,9 +315,9 @@ export interface MulticastTrackObject {
301
315
  export type MulticastTrack = string | MulticastTrackObject;
302
316
 
303
317
  export interface MulticastEndpoint {
304
- /** Transport protocol. Defaults to SSM when sourceAddress is present. */
318
+ /** Restates the mode `sourceAddress` selects; an endpoint where it disagrees is ignored. */
305
319
  protocol?: MulticastProtocol;
306
- /** SSM source IP address (REQUIRED for SSM). */
320
+ /** SSM source address; its absence selects ASM. */
307
321
  sourceAddress?: string;
308
322
  /** Multicast group address (REQUIRED). */
309
323
  groupAddress: string;
@@ -320,25 +334,35 @@ export interface MulticastEndpoint {
320
334
  tracks: MulticastTrack[];
321
335
  /**
322
336
  * Aggregate bandwidth of this endpoint in bits per second.
323
- * RECOMMENDED per draft §4.1 — enables capacity-aware joins.
337
+ * RECOMMENDED per draft §4.1 — enables capacity-aware joins; REQUIRED on a
338
+ * protected endpoint, where it bounds the receiver's hold queues (7.2.6).
324
339
  */
325
340
  bandwidth?: number;
341
+ /**
342
+ * Marks the endpoint's flow protected (7.2.6). REQUIRED when the
343
+ * `multicast` object carries `auth`, forbidden when it does not.
344
+ */
345
+ auth?: EndpointAuthConfig;
346
+ /** Bearers for this endpoint alone (4.2); readers prefer it to the catalog-level array. */
347
+ networkSource?: NetworkSource[];
326
348
  }
327
349
 
328
- export type AmtDiscovery = "driad" | "manual";
350
+ export type AmtDiscovery = "dns" | "driad" | "manual";
329
351
 
330
352
  /**
331
353
  * One `multicast.networkSource[]` entry, per draft-ramadan-moq-multicast §4.1.
332
354
  *
333
355
  * Mirrors moq-rs `NetworkSource` (the normative validator) and the
334
356
  * `networkSource` `$def` in `catalog.schema.json` 1:1 — a change here needs the
335
- * same change in both. `discovery: "manual"` requires `relay`; that relay is
336
- * the one the player joins. Under `discovery: "driad"` the relay is resolved at
337
- * runtime, so `relay` is OPTIONAL and, when present, only a discovery hint
338
- * (e.g. the `amtFallback.relayDns` name the derived path carries over): readers
339
- * do not join it (`findAmtRelay` in packages/transport
340
- * multicast-catalog-policy.ts and `catalogAmtNetworkSource` in
341
- * catalog-network-source.ts both skip it), so a DRIAD entry never pins a relay.
357
+ * same change in both. `discovery` is OPTIONAL (draft -01 4.2.1): `"dns"`
358
+ * names a relay service hostname whose A/AAAA answers are candidates,
359
+ * `"manual"` a literal relay, and omitted means `"dns"` when `relay` is a
360
+ * hostname (DRIAD when `relay` is absent too). `"dns"` and `"manual"` require
361
+ * `relay`; that relay is the one the player joins. Under `discovery: "driad"` the relay is resolved at
362
+ * runtime and `relay` MUST be omitted (draft -01 4.2.1); the schema, the
363
+ * runtime validator and `multicastFromConfig` all reject one. The tolerant
364
+ * readers (`findAmtRelay`, `catalogAmtNetworkSource`) still skip a DRIAD
365
+ * entry's relay, so a DRIAD entry never pins a relay.
342
366
  * `port` is OPTIONAL on the wire: the join boundary itself has no default, but
343
367
  * every reader resolves one before that boundary, so a manual relay without a
344
368
  * port joins on RFC 7450's 2268 rather than failing (BLO-38176).
@@ -353,12 +377,25 @@ export type AmtDiscovery = "driad" | "manual";
353
377
  * reject catalogs already in the wild, so when this type changes, widen the
354
378
  * reader only if the new shape must be consumed; never narrow it to match.
355
379
  *
356
- * This is the one place a catalog declares an AMT relay. It is catalog-level,
357
- * not per-endpoint: the normative endpoint model carries no relay field.
380
+ * This is the one place a catalog declares an AMT relay: in the `multicast`
381
+ * object for every endpoint, or in one endpoint's own `networkSource`
382
+ * (draft -01 4.2). The endpoint model carries no relay field.
358
383
  */
359
384
  export type NetworkSource =
360
- | { type: "amt"; discovery: AmtDiscovery; relay?: string; port?: number }
361
- | { type: "atsc3"; frequency: number; plpId: number; serviceId: number; slsUri: string };
385
+ | { type: "amt"; discovery?: AmtDiscovery; relay?: string; port?: number }
386
+ | {
387
+ type: "atsc3";
388
+ /** RF centre frequency in kHz (draft -01 4.2.2). The only REQUIRED tuning field. */
389
+ frequency: number;
390
+ plpId?: number;
391
+ serviceId?: number;
392
+ /**
393
+ * SLS of the MMTP service, MP table included (A/331:2026-04 7.2). It
394
+ * describes the MMTP session and nothing of this profile: manifestPort
395
+ * and keys come from provisioning. libmmt does not fetch it.
396
+ */
397
+ slsUri?: string;
398
+ };
362
399
 
363
400
  export interface MulticastCatalogConfig {
364
401
  /** Enable/disable multicast (OPTIONAL, default true). */
@@ -366,12 +403,13 @@ export interface MulticastCatalogConfig {
366
403
  /** Multicast endpoints (REQUIRED). */
367
404
  endpoints: MulticastEndpoint[];
368
405
  /**
369
- * Relay/tuning discovery for these endpoints. Required whenever an endpoint
370
- * declares a bearer protocol (`amt`, `atsc3`), which must name its own entry
371
- * type here; omitted for native joins (`ssm`, `asm`), whose endpoint tuple is
372
- * the whole join.
406
+ * Relay/tuning discovery applying to every endpoint (4.2); omitted for
407
+ * native joins, whose endpoint tuple is the whole join. An endpoint's own
408
+ * `networkSource` takes precedence for that endpoint.
373
409
  */
374
410
  networkSource?: NetworkSource[];
411
+ /** bc-provenance version 2 profile and keys (7.2.6). */
412
+ auth?: MulticastAuthConfig;
375
413
  /**
376
414
  * AMT fallback configuration.
377
415
  *
@@ -423,11 +461,8 @@ export function isMulticastTrackObject(obj: unknown): obj is MulticastTrackObjec
423
461
  export function isMulticastEndpoint(obj: unknown): obj is MulticastEndpoint {
424
462
  if (typeof obj !== "object" || obj === null) return false;
425
463
  const o = obj as Record<string, unknown>;
426
- const protocol = o["protocol"] ??
427
- (typeof o["sourceAddress"] === "string" && o["sourceAddress"].length > 0 ? "ssm" : undefined);
428
464
  return (
429
- typeof protocol === "string" &&
430
- (protocol === "ssm" || protocol === "asm" || protocol === "amt" || protocol === "atsc3") &&
465
+ multicastEndpointSource(o) !== undefined &&
431
466
  typeof o["groupAddress"] === "string" && (o["groupAddress"] as string).length > 0 &&
432
467
  typeof o["port"] === "number" && (o["port"] as number) > 0 && (o["port"] as number) <= 65535 &&
433
468
  Array.isArray(o["tracks"]) &&
@@ -456,7 +491,7 @@ export function isMulticastCatalogConfig(obj: unknown): obj is MulticastCatalogC
456
491
  );
457
492
  }
458
493
 
459
- // ── Track Timing (mmt-00 §4.4.4) ──────────────────────────────
494
+ // ── Track Timing (mmt-01 §4.4.2) ──────────────────────────────
460
495
 
461
496
  /**
462
497
  * Per-track group-duration signaling.
@@ -472,9 +507,9 @@ export function isMulticastCatalogConfig(obj: unknown): obj is MulticastCatalogC
472
507
  * (e.g. 44 100 Hz × 333 ms = 14 685.3 ticks).
473
508
  *
474
509
  * If both fields are present, `groupDurationTicks` wins (matches the
475
- * spec, mmt-00 §4.4.4).
510
+ * spec, mmt-01 §4.4.2).
476
511
  *
477
- * @see draft-ramadan-moq-mmt-00 §4.4.4
512
+ * @see draft-ramadan-moq-mmt-01 §4.4.2
478
513
  * @see ./align.ts groupIdForTicks
479
514
  */
480
515
  export interface TrackTimingConfig {
@@ -504,7 +539,7 @@ export function isTrackTimingConfig(obj: unknown): obj is TrackTimingConfig {
504
539
  /** Resolve catalog group timing to an operational wall-clock duration.
505
540
  *
506
541
  * `groupDurationTicks` wins when both wire fields are present, matching
507
- * mmt-00 §4.4.4. The result may be fractional because exact frame cadences
542
+ * mmt-01 §4.4.2. The result may be fractional because exact frame cadences
508
543
  * such as 33_333 ticks at 1 MHz cannot be represented by the wire catalog's
509
544
  * integer `groupDurationMs` field.
510
545
  */
@@ -655,7 +690,6 @@ export type CmsfCatalog = {
655
690
  version: number;
656
691
  tracks: Record<string, unknown>[];
657
692
  multicast?: Record<string, unknown>;
658
- "multicast.auth"?: MulticastAuthConfig;
659
693
  archive?: ArchiveConfig;
660
694
  [key: string]: unknown;
661
695
  };
@@ -672,6 +706,9 @@ export type CmsfCatalogErrorCode =
672
706
  | "track_is_live"
673
707
  | "track_codec"
674
708
  | "track_mmtp_mode"
709
+ | "track_presentation_anchor"
710
+ | "track_init_ref"
711
+ | "catalog_init_data_list"
675
712
  | "track_timescale"
676
713
  | "track_group_duration_ms"
677
714
  | "track_group_duration_ticks"
@@ -689,9 +726,12 @@ export type CmsfCatalogErrorCode =
689
726
  | "track_repair_geometry"
690
727
  | "track_switching_set"
691
728
  | "multicast_auth"
729
+ | "multicast_endpoint"
730
+ | "multicast_endpoint_auth"
692
731
  | "multicast_track"
693
732
  | "multicast_packet_id"
694
733
  | "multicast_relay_address"
734
+ | "multicast_network_source"
695
735
  | "archive_object"
696
736
  | "archive_origin";
697
737
 
@@ -710,8 +750,28 @@ function catalogError(code: CmsfCatalogErrorCode, path: string, message: string)
710
750
  throw new CmsfCatalogValidationError(code, path, message);
711
751
  }
712
752
 
713
- /** Validate the common CMSF shape and the MMTP required-field profile. */
714
- export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
753
+ // draft-ramadan-moq-multicast-01 4.2.1: DRIAD supplies the relay
754
+ // candidates, so a `discovery: "driad"` entry MUST omit `relay`.
755
+ function validateNetworkSourceRelays(sources: unknown, path: string): void {
756
+ if (!Array.isArray(sources)) return;
757
+ sources.forEach((source, i) => {
758
+ const s = source as Record<string, unknown> | null;
759
+ if (s?.["type"] === "amt" && s["discovery"] === "driad" && s["relay"] !== undefined) {
760
+ catalogError("multicast_network_source", `${path}[${i}].relay`, 'relay must be omitted with discovery "driad"');
761
+ }
762
+ });
763
+ }
764
+
765
+ /**
766
+ * Validate the common CMSF shape and the MMTP required-field profile.
767
+ * `catalogNamespace`, the namespace of the catalog track, sharpens the
768
+ * foreign-namespace rule of draft -01 4.1; without it listed tracks are only
769
+ * compared with each other.
770
+ */
771
+ export function validateCmsfMmtpCatalog(
772
+ value: unknown,
773
+ options: { catalogNamespace?: string } = {},
774
+ ): CmsfCatalog {
715
775
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
716
776
  catalogError("catalog_object", "$", "catalog must be an object");
717
777
  }
@@ -719,7 +779,8 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
719
779
  // IETF-draft catalogs (cast `ladder_catalog.rs`, moq-server
720
780
  // `catalog-synthesizer.ts`, consumed by the hang player) carry a string
721
781
  // version tag such as "draft-ietf-moq-catalogformat-01" instead of the CMSF
722
- // `version: 1` integer. Nothing keys behavior off the catalog version, so
782
+ // `version: 1` integer, and the draft-ramadan-moq-*-01 examples carry
783
+ // "draft-01". Nothing keys behavior off the catalog version, so
723
784
  // normalize the tag to a number rather than rejecting the whole catalog —
724
785
  // mirrors the relay (dual-stack-relay `bridge/catalog.rs`
725
786
  // `deserialize_optional_u32_lenient`, #825) and moqtail-ts
@@ -729,7 +790,7 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
729
790
  typeof rawVersion === "string"
730
791
  ? Number.isFinite(Number(rawVersion))
731
792
  ? Number(rawVersion)
732
- : rawVersion.startsWith("draft-ietf-moq-catalogformat")
793
+ : rawVersion.startsWith("draft-ietf-moq-catalogformat") || rawVersion === "draft-01"
733
794
  ? 1
734
795
  : NaN
735
796
  : rawVersion;
@@ -748,6 +809,26 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
748
809
  "commonTrackFields is retired; every track carries its own fields",
749
810
  );
750
811
  }
812
+ // mmt-01 4.5 / MSF 5.1.7: entries carry an id and a type; an "inline"
813
+ // entry carries its base64 init segment in data.
814
+ const initDataList = catalog["initDataList"];
815
+ if (initDataList !== undefined) {
816
+ if (!Array.isArray(initDataList)) {
817
+ catalogError("catalog_init_data_list", "$.initDataList", "initDataList must be an array");
818
+ }
819
+ initDataList.forEach((entry: unknown, i: number) => {
820
+ const e = entry as Record<string, unknown> | null;
821
+ const entryPath = `$.initDataList[${i}]`;
822
+ if (typeof e !== "object" || e === null || Array.isArray(e) ||
823
+ typeof e["id"] !== "string" || e["id"].length === 0 ||
824
+ typeof e["type"] !== "string" || e["type"].length === 0) {
825
+ catalogError("catalog_init_data_list", entryPath, "entry needs a non-empty string id and type");
826
+ }
827
+ if (e["type"] === "inline" && (typeof e["data"] !== "string" || e["data"].length === 0)) {
828
+ catalogError("catalog_init_data_list", `${entryPath}.data`, 'an "inline" entry needs non-empty data');
829
+ }
830
+ });
831
+ }
751
832
  const tracks = catalog["tracks"] as unknown[];
752
833
  const trackRecords: Record<string, unknown>[] = [];
753
834
  const positiveInteger = (input: unknown): input is number => Number.isSafeInteger(input) && (input as number) > 0;
@@ -805,6 +886,16 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
805
886
  (keyframeIntervalTicks !== undefined && !positiveInteger(keyframeIntervalTicks))) {
806
887
  catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
807
888
  }
889
+ // mmt-01 4.4.1: a signed integer in the track's timescale.
890
+ const anchor = track["presentationAnchorTicks"];
891
+ if (anchor !== undefined && !Number.isSafeInteger(anchor)) {
892
+ catalogError("track_presentation_anchor", `${path}.presentationAnchorTicks`, "must be a safe integer");
893
+ }
894
+ // mmt-01 4.5: the id of a root initDataList entry.
895
+ const initRef = track["initRef"];
896
+ if (initRef !== undefined && (typeof initRef !== "string" || initRef.length === 0)) {
897
+ catalogError("track_init_ref", `${path}.initRef`, "must be a non-empty string");
898
+ }
808
899
  // draft-ramadan-moq-fec §6.3: repair tracks describe themselves and carry
809
900
  // no block geometry; media tracks never carry repair-track fields.
810
901
  if (packaging === "fec-repair") {
@@ -814,9 +905,9 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
814
905
  rejectRepairFieldsOnMediaTrack(path, track, catalogError);
815
906
  }
816
907
  if (packaging === "mmtp") {
817
- const mmtpMode = track["mmtpMode"];
818
- if (mmtpMode !== "mpu" && mmtpMode !== "mfu") {
819
- catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mpu or mfu");
908
+ // mmt-01 12.1: MUST be "mfu"; a subscriber rejects anything else.
909
+ if (track["mmtpMode"] !== "mfu") {
910
+ catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mfu");
820
911
  }
821
912
  if (!positiveInteger(timescale)) {
822
913
  catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
@@ -841,8 +932,10 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
841
932
  }
842
933
  const config = fec as Record<string, unknown>;
843
934
  const algorithm = config["algorithm"];
844
- if (algorithm !== "none" && algorithm !== "raptorq" && algorithm !== "reed-solomon") {
845
- catalogError("track_fec", `${path}.fec.algorithm`, "algorithm is not supported");
935
+ // Any token is valid (fec-01 4): a receiver that does not implement it
936
+ // plays the track without FEC (`fecAlgorithmUnimplemented`).
937
+ if (typeof algorithm !== "string" || algorithm.length === 0) {
938
+ catalogError("track_fec", `${path}.fec.algorithm`, "must be a non-empty string");
846
939
  }
847
940
  if ("interleaveDepth" in config || "interleaveMs" in config) {
848
941
  catalogError("track_fec", `${path}.fec`, "interleaveDepthMs is the only supported interleave field");
@@ -875,6 +968,11 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
875
968
  }
876
969
  // Required on a declared FEC instance, optional but implemented on "none".
877
970
  readFecBlockProfile(config["blockProfile"], `${path}.fec.blockProfile`, algorithm !== "none", catalogError);
971
+ // draft-ramadan-moq-fec-01 6.3.4 rule 13: an iso-ssbg1-v1 symbol shorter
972
+ // than 14 octets carries no protected MMTP packet (7.3).
973
+ if (algorithm !== "none" && (config["symbolSize"] as number) < ISO_SSBG1_MIN_SYMBOL_SIZE) {
974
+ catalogError("track_fec", `${path}.fec.symbolSize`, "iso-ssbg1-v1 symbolSize must be at least 14");
975
+ }
878
976
  }
879
977
  }
880
978
 
@@ -927,7 +1025,14 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
927
1025
  );
928
1026
  }
929
1027
 
930
- const switchingSets = new Map<number, { name: string; ticks: bigint; timescale: bigint }>();
1028
+ // mmt-01 §4.4: alternates share group boundaries so a subscriber can switch
1029
+ // at any of them. An intra-only member (one frame per group, e.g. the demo's
1030
+ // forceIOnly `video/base`) has a boundary at every frame, so it switches
1031
+ // cleanly with any GOP peer whose group duration is a whole number of its
1032
+ // groups. Such a member is checked for divisibility against the first GOP
1033
+ // member; every GOP member must still match that anchor exactly (BLO-49202).
1034
+ type SwitchingMember = { index: number; name: string; ticks: bigint; timescale: bigint; intraOnly: boolean };
1035
+ const switchingSets = new Map<number, SwitchingMember[]>();
931
1036
  for (let index = 0; index < trackRecords.length; index++) {
932
1037
  const track = trackRecords[index]!;
933
1038
  if (track["packaging"] !== "mmtp") continue;
@@ -938,20 +1043,39 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
938
1043
  const ticks = durationTicks !== undefined
939
1044
  ? BigInt(durationTicks as number)
940
1045
  : BigInt(track["groupDurationMs"] as number) * timescale / 1000n;
941
- const anchor = switchingSets.get(altGroup as number);
942
- if (anchor && ticks * anchor.timescale !== anchor.ticks * timescale) {
943
- catalogError("track_switching_set", `$.tracks[${index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
1046
+ const framerate = track["framerate"];
1047
+ // Group duration == one frame period. `framerate` is a float (29.97), so
1048
+ // compare within 0.1%; a GOP track is off by a factor of >= 2.
1049
+ const intraOnly = positiveNumber(framerate) &&
1050
+ Math.abs(Number(ticks) * framerate - Number(timescale)) <= Number(timescale) * 1e-3;
1051
+ const members = switchingSets.get(altGroup as number) ?? [];
1052
+ members.push({ index, name: track["name"] as string, ticks, timescale, intraOnly });
1053
+ switchingSets.set(altGroup as number, members);
1054
+ }
1055
+ for (const [altGroup, members] of switchingSets) {
1056
+ const anchor = members.find((member) => !member.intraOnly) ?? members[0]!;
1057
+ for (const member of members) {
1058
+ if (member === anchor || member.ticks * anchor.timescale === anchor.ticks * member.timescale) continue;
1059
+ const nests = member.intraOnly && !anchor.intraOnly &&
1060
+ (anchor.ticks * member.timescale) % (member.ticks * anchor.timescale) === 0n;
1061
+ if (!nests) {
1062
+ catalogError("track_switching_set", `$.tracks[${member.index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
1063
+ }
944
1064
  }
945
- if (!anchor) switchingSets.set(altGroup as number, { name: track["name"] as string, ticks, timescale });
946
1065
  }
947
1066
 
948
1067
  const multicast = catalog["multicast"];
949
1068
  if (typeof multicast === "object" && multicast !== null && !Array.isArray(multicast)) {
1069
+ validateNetworkSourceRelays((multicast as Record<string, unknown>)["networkSource"], "$.multicast.networkSource");
950
1070
  const endpoints = (multicast as Record<string, unknown>)["endpoints"];
951
1071
  if (Array.isArray(endpoints)) {
952
1072
  for (let endpointIndex = 0; endpointIndex < endpoints.length; endpointIndex++) {
953
1073
  const endpoint = endpoints[endpointIndex];
954
1074
  if (typeof endpoint !== "object" || endpoint === null || Array.isArray(endpoint)) continue;
1075
+ validateNetworkSourceRelays(
1076
+ (endpoint as Record<string, unknown>)["networkSource"],
1077
+ `$.multicast.endpoints[${endpointIndex}].networkSource`,
1078
+ );
955
1079
  // The endpoint relay moved to `multicast.networkSource[{type:"amt",relay}]`.
956
1080
  // Refuse rather than ignore: a dropped relay strands an AMT endpoint
957
1081
  // with no tunnel and reads as a gateway failure, not a bad catalog.
@@ -995,15 +1119,11 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
995
1119
  }
996
1120
  }
997
1121
 
998
- try {
999
- resolveMulticastAuthCatalog(catalog);
1000
- } catch (error) {
1001
- catalogError(
1002
- "multicast_auth",
1003
- "$.multicast.auth",
1004
- error instanceof Error ? error.message : "invalid multicast.auth v2 block",
1005
- );
1006
- }
1122
+ // draft -01 4.1 / 7.2.6: protocol and S, auth all-or-nothing, the key set,
1123
+ // tuple and manifestPort uniqueness, foreign-namespace tracks. Receivers
1124
+ // ignore what this rejects (`admittedMulticastEndpoints`).
1125
+ const [multicastIssue] = multicastCatalogIssues(catalog, options);
1126
+ if (multicastIssue) catalogError(multicastIssue.code, multicastIssue.path, multicastIssue.message);
1007
1127
 
1008
1128
  validateArchive(catalog);
1009
1129
 
@@ -1012,7 +1132,7 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
1012
1132
 
1013
1133
  /**
1014
1134
  * Resolve a track's group duration to integer ticks using the supplied
1015
- * timescale (Hz). Implements mmt-00 §4.4.4:
1135
+ * timescale (Hz). Implements mmt-01 §4.4.2:
1016
1136
  *
1017
1137
  * - If `groupDurationTicks` is present, return it (override wins).
1018
1138
  * - Else compute `groupDurationMs * timescale / 1000`. The result MUST
@@ -1047,7 +1167,7 @@ export function resolveGroupDurationTicks(
1047
1167
  if (product % 1000 !== 0) {
1048
1168
  throw new Error(
1049
1169
  `[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} ` +
1050
- `produces non-integer ticks (${product / 1000}); publisher must use groupDurationTicks override (mmt-00 §4.4.4)`,
1170
+ `produces non-integer ticks (${product / 1000}); publisher must use groupDurationTicks override (mmt-01 §4.4.2)`,
1051
1171
  );
1052
1172
  }
1053
1173
  return product / 1000;
@@ -1055,7 +1175,7 @@ export function resolveGroupDurationTicks(
1055
1175
 
1056
1176
  /**
1057
1177
  * Validate that every track in a switching set agrees on the same
1058
- * wall-clock group duration (mmt-00 §4.4.4). Per-track timescales may
1178
+ * wall-clock group duration (mmt-01 §4.4.2). Per-track timescales may
1059
1179
  * differ, so raw tick counts cannot be compared directly.
1060
1180
  *
1061
1181
  * Returns `{ ok: true }` when all tracks agree (or the set is empty);
@@ -9,6 +9,8 @@
9
9
  import {
10
10
  catalogFecAvailable,
11
11
  catalogFecDeclaresUnconfigurableInstance,
12
+ fecAlgorithmUnimplemented,
13
+ ISO_SSBG1_MIN_SYMBOL_SIZE,
12
14
  FEC_BLOCK_PROFILES,
13
15
  isFecBlockProfile,
14
16
  locateCatalogFecSource,
@@ -47,6 +49,7 @@ export { FEC_BLOCK_PROFILES, isFecBlockProfile, parseFecBlockProfile, type FecBl
47
49
  export {
48
50
  catalogFecAvailable,
49
51
  catalogFecDeclaresUnconfigurableInstance,
52
+ fecAlgorithmUnimplemented,
50
53
  locateCatalogFecSource,
51
54
  type CatalogFecRole,
52
55
  type CatalogFecSource,
@@ -174,7 +177,7 @@ function timescaleHz(value: unknown): number | undefined {
174
177
  * carries none.
175
178
  *
176
179
  * `groupDurationTicks` over a timescale wins when both are present, through
177
- * `resolveGroupDurationMs` (draft-ramadan-moq-mmt-00 §4.4.4). The timescale is
180
+ * `resolveGroupDurationMs` (draft-ramadan-moq-mmt-01 §4.4.2). The timescale is
178
181
  * the MMTP container's when the rendition declares one, else the rendition's
179
182
  * own `timescale`. Only the ticks are forwarded: a catalog `groupDurationMs`
180
183
  * is often a rounded fraction (21.33 for 1024/48000), which the ticks path
@@ -301,7 +304,14 @@ export function catalogFecMediaUnitsPerSecond(
301
304
  export type TrackFecUnavailable = {
302
305
  /** The repair-contract code a catalog validator reports for the same field
303
306
  * (`track_fec_block_span` excepted: an omitted span is valid shape). */
304
- readonly code: "track_fec_block_profile" | "track_fec_block_profile_unimplemented" | "track_fec_block_span" | "track_fec";
307
+ readonly code:
308
+ | "track_fec_block_profile"
309
+ | "track_fec_block_profile_unimplemented"
310
+ | "track_fec_block_span"
311
+ | "track_fec"
312
+ /** draft-ramadan-moq-fec-01 4: an `algorithm` this receiver does not
313
+ * implement. No validator reports it: such a catalog is valid. */
314
+ | "track_fec_algorithm_unimplemented";
305
315
  /** JSON path of the offending field: `blockProfile`, or `interleaveDepthMs`. */
306
316
  readonly path: string;
307
317
  /** What is wrong, worded as the `RepairContractError` a validator throws. */
@@ -310,6 +320,11 @@ export type TrackFecUnavailable = {
310
320
 
311
321
  export type TrackFecParams = {
312
322
  fecK: number;
323
+ /** The FEC scheme the track's decoder runs (draft-ramadan-moq-fec-01 4):
324
+ * present exactly when the track has FEC. An absent catalog `algorithm`
325
+ * (the hang dialect) is RaptorQ; a token this receiver does not implement
326
+ * leaves the track without FEC (`track_fec_algorithm_unimplemented`). */
327
+ fecAlgorithm?: "raptorq" | "reed-solomon";
313
328
  /** The catalog `fec.blockProfile` (BLO-35597, ISO/IEC 23008-1 Annex C).
314
329
  * Present exactly when the track has FEC (`fecK > 0`) and absent on no
315
330
  * FEC. The only profile is `iso-ssbg1-v1` (ssbg_mode1, K' = SSB_length,
@@ -681,6 +696,13 @@ export function catalogFecUnavailable(fec: unknown, fecPath: string): TrackFecUn
681
696
  // too; this function only explains a negative one.
682
697
  if (catalogFecAvailable(fec)) return undefined;
683
698
  const block = recordOf(fec)!;
699
+ if (fecAlgorithmUnimplemented(block["algorithm"])) {
700
+ return Object.freeze({
701
+ code: "track_fec_algorithm_unimplemented",
702
+ path: `${fecPath}.algorithm`,
703
+ message: `algorithm ${JSON.stringify(block["algorithm"])} is not implemented: the track plays without FEC`,
704
+ });
705
+ }
684
706
  const declaresFecInstance = block["algorithm"] !== "none";
685
707
  const reason =
686
708
  blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ??
@@ -733,7 +755,9 @@ function fecParams(
733
755
  throwRepairContractError(
734
756
  "track_fec",
735
757
  `${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
736
- "must be a positive integer",
758
+ kValid && Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0
759
+ ? `iso-ssbg1-v1 symbolSize must be at least ${ISO_SSBG1_MIN_SYMBOL_SIZE}`
760
+ : "must be a positive integer",
737
761
  );
738
762
  }
739
763
  // What remains is `algorithm: "none"` (which carries no profile; a token
@@ -747,6 +771,7 @@ function fecParams(
747
771
  const fecBlockProfile = readFecBlockProfile(fec.blockProfile, `${fecPath}.blockProfile`, true, throwRepairContractError);
748
772
  return {
749
773
  fecK: fec.sourceSymbols ?? 0,
774
+ fecAlgorithm: fec.algorithm === "reed-solomon" ? "reed-solomon" : "raptorq",
750
775
  fecBlockProfile,
751
776
  fecRepairCount: fec.repairSymbols ?? 0,
752
777
  // The wire RSB_length: every base layer's packets carry the base total (§7.1).