@blockcast/mmt-container 0.4.0-main.d6f2737828fc → 0.4.0

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 (102) hide show
  1. package/README.md +12 -9
  2. package/dist/browser-runtime.js +14219 -13716
  3. package/dist/browser-runtime.js.map +4 -4
  4. package/dist/carp-catalog.d.ts +1 -12
  5. package/dist/carp-catalog.d.ts.map +1 -1
  6. package/dist/carp-catalog.js +14 -6
  7. package/dist/carp-catalog.js.map +4 -4
  8. package/dist/catalog-fec-params.d.ts +5 -2
  9. package/dist/catalog-fec-params.d.ts.map +1 -1
  10. package/dist/catalog-fec-params.js +101 -42
  11. package/dist/catalog-fec-params.js.map +4 -4
  12. package/dist/catalog-network-source.js +4 -6
  13. package/dist/catalog-network-source.js.map +4 -4
  14. package/dist/cmcd-producer.d.ts.map +1 -1
  15. package/dist/cmcd-producer.js +0 -4
  16. package/dist/cmcd-producer.js.map +2 -2
  17. package/dist/delivery-catalog.d.ts +124 -0
  18. package/dist/delivery-catalog.d.ts.map +1 -0
  19. package/dist/delivery-catalog.js +1867 -0
  20. package/dist/delivery-catalog.js.map +7 -0
  21. package/dist/fec-manager.d.ts +17 -4
  22. package/dist/fec-manager.d.ts.map +1 -1
  23. package/dist/fec-manager.js +41 -20
  24. package/dist/fec-manager.js.map +4 -4
  25. package/dist/fec-state.d.ts +3 -2
  26. package/dist/fec-state.d.ts.map +1 -1
  27. package/dist/fec-state.js +17 -15
  28. package/dist/fec-state.js.map +4 -4
  29. package/dist/fec-worker-setup.d.ts +2 -8
  30. package/dist/fec-worker-setup.d.ts.map +1 -1
  31. package/dist/fec-worker-setup.js +12 -62
  32. package/dist/fec-worker-setup.js.map +4 -4
  33. package/dist/index.d.ts +2 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +10 -0
  36. package/dist/index.js.map +2 -2
  37. package/dist/iso-block-locator.js +4 -6
  38. package/dist/iso-block-locator.js.map +4 -4
  39. package/dist/mfu-reassembler.js +27 -29
  40. package/dist/mfu-reassembler.js.map +4 -4
  41. package/dist/mmtp-container-parser.d.ts +9 -11
  42. package/dist/mmtp-container-parser.d.ts.map +1 -1
  43. package/dist/mmtp-container-parser.js +107 -98
  44. package/dist/mmtp-container-parser.js.map +4 -4
  45. package/dist/mmtp-container-parser.no-modules.js +133 -108
  46. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  47. package/dist/mmtp-decode-pipeline.js +107 -98
  48. package/dist/mmtp-decode-pipeline.js.map +4 -4
  49. package/dist/mmtp-router.d.ts +34 -14
  50. package/dist/mmtp-router.d.ts.map +1 -1
  51. package/dist/mmtp-router.js +143 -113
  52. package/dist/mmtp-router.js.map +4 -4
  53. package/dist/multicast-input.js +4 -6
  54. package/dist/multicast-input.js.map +4 -4
  55. package/dist/multicast-manager.d.ts +39 -3
  56. package/dist/multicast-manager.d.ts.map +1 -1
  57. package/dist/multicast-manager.js +264 -156
  58. package/dist/multicast-manager.js.map +4 -4
  59. package/dist/multicast-transport.js +14 -14
  60. package/dist/multicast-transport.js.map +4 -4
  61. package/dist/multicast-unwrap.js +32 -34
  62. package/dist/multicast-unwrap.js.map +4 -4
  63. package/dist/no-modules.js +130 -107
  64. package/dist/no-modules.js.map +4 -4
  65. package/dist/repair-fetch.d.ts +86 -2
  66. package/dist/repair-fetch.d.ts.map +1 -1
  67. package/dist/repair-fetch.js +86 -17
  68. package/dist/repair-fetch.js.map +4 -4
  69. package/dist/repair-layers.js +4 -6
  70. package/dist/repair-layers.js.map +4 -4
  71. package/dist/signaling.js +5 -7
  72. package/dist/signaling.js.map +4 -4
  73. package/dist/timestamp-codec.js +27 -29
  74. package/dist/timestamp-codec.js.map +4 -4
  75. package/dist/wasm-mfu-reassembler.js +4 -6
  76. package/dist/wasm-mfu-reassembler.js.map +4 -4
  77. package/dist/wasm-mmtp-container-parser.js +107 -98
  78. package/dist/wasm-mmtp-container-parser.js.map +4 -4
  79. package/package.json +5 -6
  80. package/src/carp-catalog.ts +16 -11
  81. package/src/catalog-fec-params.ts +38 -17
  82. package/src/cmcd-producer.ts +0 -6
  83. package/src/delivery-catalog.ts +498 -0
  84. package/src/fec-manager.ts +44 -17
  85. package/src/fec-state.ts +4 -9
  86. package/src/fec-worker-setup.ts +4 -35
  87. package/src/index.ts +27 -0
  88. package/src/mmtp-container-parser.ts +80 -20
  89. package/src/mmtp-router.ts +71 -29
  90. package/src/multicast-manager.ts +93 -26
  91. package/src/repair-fetch.ts +228 -17
  92. package/test-vectors/catalog/README.md +10 -1
  93. package/test-vectors/catalog/negative/multicast-endpoint-relay-address.json +39 -0
  94. package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +1 -0
  95. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +38 -0
  96. package/test-vectors/catalog/section-codes.json +33 -0
  97. package/test-vectors/delivery-catalog/README.md +11 -0
  98. package/test-vectors/delivery-catalog/negative/missing-block-profile.json +58 -0
  99. package/test-vectors/delivery-catalog/negative/packet-id-signaling.json +59 -0
  100. package/test-vectors/delivery-catalog/negative/retired-k-padded-block-profile.json +59 -0
  101. package/test-vectors/delivery-catalog/positive/dash.json +56 -0
  102. package/test-vectors/delivery-catalog/positive/mmtp-source-only.json +43 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockcast/mmt-container",
3
- "version": "0.4.0-main.d6f2737828fc",
3
+ "version": "0.4.0",
4
4
  "description": "MMTP/LOC container parsing for MMT over MoQ and SSM",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -178,11 +178,10 @@
178
178
  },
179
179
  "dependencies": {
180
180
  "@noble/hashes": "^1.8.0",
181
- "@blockcast/mmt-fec": "0.3.0-main.d6f2737828fc",
182
- "@blockcast/mmt-manifest-verify": "0.3.0-main.d6f2737828fc",
183
- "@blockcast/fec-worker": "0.3.0-main.d6f2737828fc",
184
- "@blockcast/mmt-alta-parse": "0.3.0-main.d6f2737828fc",
185
- "@blockcast/mmt-base": "0.3.0-main.d6f2737828fc",
181
+ "@blockcast/mmt-fec": "^0.4.0",
182
+ "@blockcast/mmt-manifest-verify": "^0.4.0",
183
+ "@blockcast/fec-worker": "^0.4.0",
184
+ "@blockcast/mmt-base": "^0.4.0",
186
185
  "ajv": "^8.17.1",
187
186
  "ajv-formats": "^3.0.1"
188
187
  },
@@ -318,17 +318,6 @@ export interface MulticastEndpoint {
318
318
  * type-narrow with `typeof t === "string"` to handle both.
319
319
  */
320
320
  tracks: MulticastTrack[];
321
- /**
322
- * AMT relay hostname.
323
- *
324
- * @deprecated Superseded by catalog-level `multicast.networkSource`
325
- * (`{type: "amt", discovery, relay}`). Retained so a catalog published
326
- * before the migration still parses; emitters MUST NOT write it, and
327
- * `catalog.schema.json` already rejects it (`additionalProperties: false`
328
- * on the endpoint), as does moq-rs `MulticastEndpoint`
329
- * (`deny_unknown_fields`, and it carries no relay field at all).
330
- */
331
- relayAddress?: string;
332
321
  /**
333
322
  * Aggregate bandwidth of this endpoint in bits per second.
334
323
  * RECOMMENDED per draft §4.1 — enables capacity-aware joins.
@@ -702,6 +691,7 @@ export type CmsfCatalogErrorCode =
702
691
  | "multicast_auth"
703
692
  | "multicast_track"
704
693
  | "multicast_packet_id"
694
+ | "multicast_relay_address"
705
695
  | "archive_object"
706
696
  | "archive_origin";
707
697
 
@@ -874,6 +864,11 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
874
864
  catalogError("track_fec", `${path}.fec.${field}`, "must be a positive integer");
875
865
  }
876
866
  }
867
+ // The receiver refuses unaligned RaptorQ geometry (`isFecCatalogGeometry`);
868
+ // the schema's `multipleOf: 8` says the same, so the validator does too.
869
+ if (algorithm === "raptorq" && (config["symbolSize"] as number) % 8 !== 0) {
870
+ catalogError("track_fec", `${path}.fec.symbolSize`, "RaptorQ symbolSize must be a multiple of 8");
871
+ }
877
872
  if (typeof config["repairTrack"] !== "string" || config["repairTrack"].length === 0) {
878
873
  catalogError("track_fec", `${path}.fec.repairTrack`, "must be a non-empty string");
879
874
  }
@@ -957,6 +952,16 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
957
952
  for (let endpointIndex = 0; endpointIndex < endpoints.length; endpointIndex++) {
958
953
  const endpoint = endpoints[endpointIndex];
959
954
  if (typeof endpoint !== "object" || endpoint === null || Array.isArray(endpoint)) continue;
955
+ // The endpoint relay moved to `multicast.networkSource[{type:"amt",relay}]`.
956
+ // Refuse rather than ignore: a dropped relay strands an AMT endpoint
957
+ // with no tunnel and reads as a gateway failure, not a bad catalog.
958
+ if ("relayAddress" in endpoint) {
959
+ catalogError(
960
+ "multicast_relay_address",
961
+ `$.multicast.endpoints[${endpointIndex}].relayAddress`,
962
+ 'relayAddress is retired; publish the relay as multicast.networkSource[{type:"amt",relay}]',
963
+ );
964
+ }
960
965
  const refs = (endpoint as Record<string, unknown>)["tracks"];
961
966
  if (!Array.isArray(refs)) continue;
962
967
  const packetIds = new Map<number, string>();
@@ -7,9 +7,14 @@
7
7
  // player-agnostic.
8
8
 
9
9
  import {
10
+ catalogFecAvailable,
11
+ catalogFecDeclaresUnconfigurableInstance,
10
12
  FEC_BLOCK_PROFILES,
11
13
  isFecBlockProfile,
14
+ locateCatalogFecSource,
12
15
  parseFecBlockProfile,
16
+ type CatalogFecRole,
17
+ type CatalogFecSource,
13
18
  type FecBlockProfile,
14
19
  } from "@blockcast/mmt-base";
15
20
  import { catalogFecInterleaveMs, type FecInterleaveCatalog } from "@blockcast/mmt-fec";
@@ -37,6 +42,15 @@ import type { RepairTarget } from "./repair-fetch.js";
37
42
 
38
43
  export { catalogFecInterleaveMs, type FecInterleaveCatalog };
39
44
  export { FEC_BLOCK_PROFILES, isFecBlockProfile, parseFecBlockProfile, type FecBlockProfile };
45
+ // The shared catalog FEC source rules (BLO-40851): one copy, in the leaf
46
+ // package transport and every player also read.
47
+ export {
48
+ catalogFecAvailable,
49
+ catalogFecDeclaresUnconfigurableInstance,
50
+ locateCatalogFecSource,
51
+ type CatalogFecRole,
52
+ type CatalogFecSource,
53
+ };
40
54
  export {
41
55
  assembleRepairLayers,
42
56
  assertRepairTrackReachable,
@@ -416,8 +430,10 @@ export function resolveRepairLayers(
416
430
  // beside a tracks[] switching-set index (the unified ABR ladder catalog),
417
431
  // the rendition blocks are authoritative, exactly as they are for hang's own
418
432
  // catalog decode. A typed ref resolves only within its own role.
433
+ // `locateCatalogFecSource` is that precedence rule, shared with transport's
434
+ // endpoint selection and the players' repair inventories.
419
435
  const hang = catalog as CatalogWithRenditions;
420
- const roles: Array<"video" | "audio"> =
436
+ const roles: CatalogFecRole[] =
421
437
  typeof source === "string"
422
438
  ? ["video", "audio"]
423
439
  : source.type === "audio"
@@ -425,10 +441,10 @@ export function resolveRepairLayers(
425
441
  : source.type === "video"
426
442
  ? ["video"]
427
443
  : ["video", "audio"];
428
- const role = roles.find((r) => recordOf(hang[r]?.renditions?.[sourceName]) !== undefined);
429
- if (role !== undefined) {
430
- const renditionPath = `$.${role}.renditions[${JSON.stringify(sourceName)}]`;
431
- const rendition = recordOf(hang[role]!.renditions![sourceName])!;
444
+ const located = locateCatalogFecSource(catalog, sourceName, roles);
445
+ if (located?.dialect === "hang") {
446
+ const renditionPath = `$.${located.role}.renditions[${JSON.stringify(sourceName)}]`;
447
+ const rendition = located.entry;
432
448
  rejectRepairFieldsOnMediaTrack(renditionPath, rendition, throwRepairContractError);
433
449
  const repairRenditions = recordOf(hang.repair?.renditions) ?? {};
434
450
  const descriptors: RepairTrackDescriptor[] = Object.entries(repairRenditions).map(([name, entry]) => {
@@ -473,8 +489,8 @@ export function resolveRepairLayers(
473
489
  }
474
490
 
475
491
  const msf = msfTracks(catalog);
476
- const msfIndex = msf ? msf.tracks.findIndex((t) => t["name"] === sourceName) : -1;
477
- if (!msf || msfIndex < 0) return undefined;
492
+ if (!msf || located?.dialect !== "msf") return undefined;
493
+ const msfIndex = located.index;
478
494
  const track = msf.tracks[msfIndex]!;
479
495
  const fec = recordOf(track["fec"]);
480
496
  const packagingOf = (t: Record<string, unknown>): unknown => t["packaging"];
@@ -653,19 +669,26 @@ function isoSpanUnavailable(
653
669
  * `iso-ssbg1-v1` instance, carries no usable block span. Returns undefined for
654
670
  * a non-object and for every block whose FEC is available. It reads only the
655
671
  * profile and the span: malformed geometry (`sourceSymbols`, `symbolSize`, ...)
656
- * is the caller's to reject, and takes precedence. Never throws.
672
+ * is the caller's to reject, and takes precedence. Never throws on catalog
673
+ * input: whether FEC is available is `catalogFecAvailable` (mmt-base), and a
674
+ * test pins that every unavailable block gets a reason here.
657
675
  *
658
676
  * @param fec the track's catalog `fec` value.
659
677
  * @param fecPath JSON path of that `fec` block; the reason's `path` extends it.
660
678
  */
661
679
  export function catalogFecUnavailable(fec: unknown, fecPath: string): TrackFecUnavailable | undefined {
662
- const block = recordOf(fec);
663
- if (block === undefined) return undefined;
680
+ // The decision is mmt-base's `catalogFecAvailable`, which transport reads
681
+ // too; this function only explains a negative one.
682
+ if (catalogFecAvailable(fec)) return undefined;
683
+ const block = recordOf(fec)!;
664
684
  const declaresFecInstance = block["algorithm"] !== "none";
665
- return (
685
+ const reason =
666
686
  blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ??
667
- isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance)
668
- );
687
+ isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
688
+ if (reason === undefined) {
689
+ throw new Error(`catalogFecUnavailable: ${fecPath} is unavailable but no reason applies (rule drift)`);
690
+ }
691
+ return reason;
669
692
  }
670
693
 
671
694
  /**
@@ -701,10 +724,8 @@ function fecParams(
701
724
  // and T are positive integers, the algorithm is not `none`, and the block
702
725
  // profile is known.
703
726
  if (!catalogDeclaresFec(fec)) {
704
- const declaresFecInstance = fec.algorithm !== "none";
705
- const kValid = Number.isSafeInteger(fec.sourceSymbols) && (fec.sourceSymbols ?? 0) > 0;
706
- const tValid = Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0;
707
- if (declaresFecInstance && !(kValid && tValid)) {
727
+ if (catalogFecDeclaresUnconfigurableInstance(fec)) {
728
+ const kValid = Number.isSafeInteger(fec.sourceSymbols) && (fec.sourceSymbols ?? 0) > 0;
708
729
  // Any algorithm but `none` declares an FEC instance, so geometry a
709
730
  // decoder cannot configure is a malformed catalog, not "no FEC".
710
731
  // Returning NO_FEC would silently drop the track's repair
@@ -97,12 +97,6 @@ function buildFecParams(stats: FecTrackStats): CmcdParams {
97
97
  params['x-bc-fec-p'] = cfg.repairCount
98
98
  params['x-bc-fec-recovery'] = parseFloat((stats.recoveryRate / 100).toFixed(4))
99
99
 
100
- // ALTA keys: omit entirely when altaEnabled is false (D-09)
101
- if (cfg.altaEnabled) {
102
- params['x-bc-alta-verified'] = stats.altaVerified > 0
103
- params['x-bc-alta-failures'] = stats.altaFailed
104
- }
105
-
106
100
  return params
107
101
  }
108
102