@blockcast/mmt-container 0.4.0-main.9d97fa55ba69 → 0.4.0-main.b556167975b5

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 (77) hide show
  1. package/README.md +1 -2
  2. package/dist/browser-runtime.js +38 -53
  3. package/dist/browser-runtime.js.map +3 -3
  4. package/dist/carp-catalog.d.ts +5 -2
  5. package/dist/carp-catalog.d.ts.map +1 -1
  6. package/dist/carp-catalog.js +21 -5
  7. package/dist/carp-catalog.js.map +2 -2
  8. package/dist/catalog-fec-params.d.ts +11 -3
  9. package/dist/catalog-fec-params.d.ts.map +1 -1
  10. package/dist/catalog-fec-params.js +34 -4
  11. package/dist/catalog-fec-params.js.map +2 -2
  12. package/dist/catalog-network-source.js.map +1 -1
  13. package/dist/delivery-catalog.js.map +1 -1
  14. package/dist/fec-manager.js.map +2 -2
  15. package/dist/fec-state.d.ts +2 -1
  16. package/dist/fec-state.d.ts.map +1 -1
  17. package/dist/fec-state.js +5 -2
  18. package/dist/fec-state.js.map +2 -2
  19. package/dist/fec-worker-setup.d.ts +2 -0
  20. package/dist/fec-worker-setup.d.ts.map +1 -1
  21. package/dist/fec-worker-setup.js +1 -1
  22. package/dist/fec-worker-setup.js.map +2 -2
  23. package/dist/index.d.ts +1 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -8
  26. package/dist/index.js.map +2 -2
  27. package/dist/iso-block-locator.js.map +1 -1
  28. package/dist/manifest-auth-plan.js.map +1 -1
  29. package/dist/mfu-reassembler.js.map +1 -1
  30. package/dist/mmtp-container-parser.js.map +1 -1
  31. package/dist/mmtp-container-parser.no-modules.js +33 -14
  32. package/dist/mmtp-container-parser.no-modules.js.map +2 -2
  33. package/dist/mmtp-decode-pipeline.js.map +1 -1
  34. package/dist/mmtp-fec-session.js.map +1 -1
  35. package/dist/mmtp-router.js.map +1 -1
  36. package/dist/multicast-auth-catalog.js.map +1 -1
  37. package/dist/multicast-input.js.map +1 -1
  38. package/dist/multicast-manager.js +13 -1
  39. package/dist/multicast-manager.js.map +2 -2
  40. package/dist/multicast-transport.js.map +1 -1
  41. package/dist/multicast-unwrap.js.map +1 -1
  42. package/dist/no-modules.d.ts +2 -1
  43. package/dist/no-modules.d.ts.map +1 -1
  44. package/dist/no-modules.js +29 -8
  45. package/dist/no-modules.js.map +3 -3
  46. package/dist/repair-fetch.js.map +1 -1
  47. package/dist/repair-layers.d.ts +2 -0
  48. package/dist/repair-layers.d.ts.map +1 -1
  49. package/dist/repair-layers.js +19 -2
  50. package/dist/repair-layers.js.map +2 -2
  51. package/dist/signaling.js.map +1 -1
  52. package/dist/timestamp-codec.js.map +1 -1
  53. package/dist/wasm-mfu-reassembler.js.map +1 -1
  54. package/dist/wasm-mmtp-container-parser.js.map +1 -1
  55. package/package.json +5 -9
  56. package/schemas/catalog.schema.json +5 -1
  57. package/src/carp-catalog.ts +10 -6
  58. package/src/catalog-fec-params.ts +23 -1
  59. package/src/fec-state.ts +9 -3
  60. package/src/fec-worker-setup.ts +3 -1
  61. package/src/index.ts +1 -8
  62. package/src/no-modules.ts +5 -1
  63. package/src/repair-layers.ts +22 -2
  64. package/test-vectors/catalog/README.md +5 -0
  65. package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
  66. package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
  67. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
  68. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-out-of-range.json +1 -1
  69. package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
  70. package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
  71. package/test-vectors/catalog/section-codes.json +3 -0
  72. package/test-vectors/catalog-validation.json +3 -3
  73. package/dist/fec-codec.d.ts +0 -32
  74. package/dist/fec-codec.d.ts.map +0 -1
  75. package/dist/fec-codec.js +0 -47
  76. package/dist/fec-codec.js.map +0 -7
  77. package/src/fec-codec.ts +0 -61
package/README.md CHANGED
@@ -74,7 +74,6 @@ The package exposes a wide subpath surface so consumers can tree-shake aggressiv
74
74
  | `./multicast-unwrap` | Container-aware MMTP dispatch (LOC vs raw MMTP) |
75
75
  | `./signaling` | Packet-type classifier (`isSignalingPacket`, `isSourcePacket`, `classifyPacket`) |
76
76
  | `./mmtp-container-parser` | `MmtpContainerParser` (the unified, transport-agnostic parser) |
77
- | `./fec-codec` | Algorithm-pluggable codec interface — `NoneCodec`, `ReedSolomonCodec`, `createFecCodec` |
78
77
  | `./cmcd-producer` | `CmcdProducer` — RFC 9559 CMCD with `x-bc-*` vendor keys |
79
78
  | `./cmaf-block-assembler` | `CmafBlockAssembler` — assembles one CMAF segment per FEC source block |
80
79
  | `./cmaf-group-batcher` | `CmafGroupBatcher` — MoQ group → CMAF segment batcher |
@@ -384,7 +383,7 @@ Typed evidence is `RepairLifecycleEvent` version 2 and
384
383
  `MulticastManager.getBlockPolicyStats()`.
385
384
 
386
385
  This package depends on the FEC primitives from:
387
- - **`@blockcast/mmt-fec`** — RaptorQ WASM decoder + OTI codec + `computeFecTimeout`
386
+ - **`@blockcast/mmt-fec`** — RaptorQ WASM decoder + OTI codec + `fecBlockDeadlineMs` / `fecBlockBudgetMs`
388
387
  - **`@blockcast/fec-worker`** — Web Worker host, `FecWorkerClient`, `FecTrackStats`
389
388
 
390
389
  ### MMTP → CMAF demux (`./mmtp-to-cmaf`)
@@ -1007,18 +1007,23 @@ function catalogFecAvailable(fec) {
1007
1007
  const block = recordOf(fec);
1008
1008
  if (block === void 0)
1009
1009
  return true;
1010
+ if (fecAlgorithmUnimplemented(block["algorithm"]))
1011
+ return false;
1010
1012
  const declaresFecInstance = block["algorithm"] !== "none";
1011
1013
  const profile = block["blockProfile"];
1012
1014
  const profileOk = isFecBlockProfile(profile) || profile === void 0 && !declaresFecInstance;
1013
1015
  return profileOk && (!declaresFecInstance || isoBlockSpanUsable(block));
1014
1016
  }
1017
+ function fecAlgorithmUnimplemented(algorithm) {
1018
+ return typeof algorithm === "string" && algorithm !== "none" && algorithm !== "raptorq" && algorithm !== "reed-solomon";
1019
+ }
1015
1020
  function isPositiveSafeInteger(value) {
1016
1021
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
1017
1022
  }
1018
1023
  var ISO_SSBG1_MIN_SYMBOL_SIZE = 14;
1019
1024
  function catalogFecDeclaresUnconfigurableInstance(fec) {
1020
1025
  const block = recordOf(fec);
1021
- if (block === void 0 || block["algorithm"] === "none")
1026
+ if (block === void 0 || block["algorithm"] === "none" || fecAlgorithmUnimplemented(block["algorithm"]))
1022
1027
  return false;
1023
1028
  if (!(isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"])))
1024
1029
  return true;
@@ -6281,6 +6286,7 @@ var DEFAULT_REPAIR_PRIORITY = 240;
6281
6286
  var MAX_RAPTORQ_SOURCE_SYMBOLS = 56403;
6282
6287
  var MAX_REPAIR_SYMBOLS = 16777215;
6283
6288
  var MAX_ENCODING_SYMBOL_ID = 16777215;
6289
+ var MAX_REED_SOLOMON_BLOCK_SYMBOLS = 255;
6284
6290
  var RepairContractError = class extends Error {
6285
6291
  constructor(code, path, message) {
6286
6292
  super(`[repair-layers:${code}] ${path}: ${message}`);
@@ -6463,11 +6469,12 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
6463
6469
  if (layered && !positiveInteger(source.sourceSymbols)) {
6464
6470
  fail("track_fec", `${source.path}.sourceSymbols`, "layered or overlay repair needs a positive integer sourceSymbols on the source");
6465
6471
  }
6466
- if (layered && source.algorithm !== "raptorq") {
6472
+ const reedSolomon = source.algorithm === "reed-solomon";
6473
+ if (layered && source.algorithm !== "raptorq" && !reedSolomon) {
6467
6474
  fail(
6468
6475
  "track_fec",
6469
6476
  `${source.path}.algorithm`,
6470
- "repair layers and overlays are defined only for raptorq: a block code fixes its codeword length, so symbols of a larger P are not symbols of the code a receiver holding fewer layers decodes"
6477
+ "repair layers and overlays are defined only for raptorq and reed-solomon (draft-ramadan-moq-fec-01 6.3.4 rule 7)"
6471
6478
  );
6472
6479
  }
6473
6480
  let layerZeroPriority = DEFAULT_REPAIR_PRIORITY;
@@ -6526,6 +6533,13 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
6526
6533
  `overlay sourceSymbols + repairSymbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
6527
6534
  );
6528
6535
  }
6536
+ if (reedSolomon && sourceSymbols + repairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
6537
+ fail(
6538
+ "track_fec_bounds",
6539
+ `${d.path}.repairSymbols`,
6540
+ `reed-solomon overlay sourceSymbols + repairSymbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`
6541
+ );
6542
+ }
6529
6543
  overlays.push({ repairTrackName: d.name, scope: "keyframe", sourceSymbols, repairSymbols, priority: d.priority });
6530
6544
  }
6531
6545
  let offset = layerZeroSymbols;
@@ -6570,6 +6584,13 @@ function assembleRepairLayers(source, descriptors, fail = throwRepairContractErr
6570
6584
  `sourceSymbols + total base repair symbols - 1 exceeds the 24-bit ESI space (${MAX_ENCODING_SYMBOL_ID})`
6571
6585
  );
6572
6586
  }
6587
+ if (reedSolomon && k + totalBaseRepairSymbols > MAX_REED_SOLOMON_BLOCK_SYMBOLS) {
6588
+ fail(
6589
+ "track_fec_bounds",
6590
+ `${source.path}.sourceSymbols`,
6591
+ `reed-solomon sourceSymbols + total base repair symbols exceeds ${MAX_REED_SOLOMON_BLOCK_SYMBOLS} (draft-ramadan-moq-fec-01 6.3.4 rule 12)`
6592
+ );
6593
+ }
6573
6594
  return { sourceTrackName: source.name, baseLayers, overlays, totalBaseRepairSymbols };
6574
6595
  }
6575
6596
 
@@ -6617,7 +6638,7 @@ function isFecCatalogGeometry(obj) {
6617
6638
  const o = obj;
6618
6639
  const algorithm = o["algorithm"];
6619
6640
  const symbolSize = o["symbolSize"];
6620
- return typeof algorithm === "string" && (algorithm === "none" || algorithm === "raptorq" || algorithm === "reed-solomon") && typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 && typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 && typeof symbolSize === "number" && symbolSize >= 1 && (algorithm !== "raptorq" || symbolSize % 8 === 0) && typeof o["repairTrack"] === "string" && o["repairTrack"].length > 0;
6641
+ return typeof algorithm === "string" && algorithm.length > 0 && typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 && typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 && typeof symbolSize === "number" && symbolSize >= 1 && (algorithm !== "raptorq" || symbolSize % 8 === 0) && typeof o["repairTrack"] === "string" && o["repairTrack"].length > 0;
6621
6642
  }
6622
6643
  function isFecCatalogConfig(obj) {
6623
6644
  if (!isFecCatalogGeometry(obj)) return false;
@@ -6863,8 +6884,8 @@ function validateCmsfMmtpCatalog(value, options = {}) {
6863
6884
  }
6864
6885
  const config = fec;
6865
6886
  const algorithm = config["algorithm"];
6866
- if (algorithm !== "none" && algorithm !== "raptorq" && algorithm !== "reed-solomon") {
6867
- catalogError("track_fec", `${path}.fec.algorithm`, "algorithm is not supported");
6887
+ if (typeof algorithm !== "string" || algorithm.length === 0) {
6888
+ catalogError("track_fec", `${path}.fec.algorithm`, "must be a non-empty string");
6868
6889
  }
6869
6890
  if ("interleaveDepth" in config || "interleaveMs" in config) {
6870
6891
  catalogError("track_fec", `${path}.fec`, "interleaveDepthMs is the only supported interleave field");
@@ -12721,7 +12742,7 @@ function isPositiveSafeInteger2(value) {
12721
12742
  }
12722
12743
  function catalogDeclaresFec(fec) {
12723
12744
  const block = recordOf2(fec);
12724
- if (block === void 0 || block["algorithm"] === "none") return false;
12745
+ if (block === void 0 || block["algorithm"] === "none" || fecAlgorithmUnimplemented(block["algorithm"])) return false;
12725
12746
  return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block) && !catalogFecDeclaresUnconfigurableInstance(block);
12726
12747
  }
12727
12748
  function requireBoolean(value, field) {
@@ -22302,48 +22323,6 @@ function createWasmMmtpContainerParser(config) {
22302
22323
  });
22303
22324
  }
22304
22325
 
22305
- // src/fec-codec.ts
22306
- var NoneCodec = class {
22307
- constructor() {
22308
- this.algorithm = "none";
22309
- }
22310
- addSymbol(_blockId, _symbolId, data, _isRepair) {
22311
- return data;
22312
- }
22313
- configure(_params) {
22314
- }
22315
- cleanup(_now) {
22316
- return new Uint8Array(0);
22317
- }
22318
- };
22319
- function createFecCodec(algorithm) {
22320
- switch (algorithm) {
22321
- case "none":
22322
- return new NoneCodec();
22323
- case "reed-solomon":
22324
- return new ReedSolomonCodec();
22325
- case "raptorq":
22326
- console.warn("[FEC] RaptorQ requested via createFecCodec \u2014 use FECManager.setFecDecoder() for WASM RaptorQ. Falling back to NoneCodec.");
22327
- return new NoneCodec();
22328
- default:
22329
- console.warn(`[FEC] Unknown algorithm "${algorithm}", falling back to NoneCodec`);
22330
- return new NoneCodec();
22331
- }
22332
- }
22333
- var ReedSolomonCodec = class {
22334
- constructor() {
22335
- this.algorithm = "reed-solomon";
22336
- }
22337
- addSymbol(_blockId, _symbolId, _data, _isRepair) {
22338
- return null;
22339
- }
22340
- configure(_params) {
22341
- }
22342
- cleanup(_now) {
22343
- return new Uint8Array(0);
22344
- }
22345
- };
22346
-
22347
22326
  // src/multicast-transport.ts
22348
22327
  var JOIN_SUCCEEDED = Object.freeze({ ok: true });
22349
22328
  function providerErrorOf(error) {
@@ -23333,6 +23312,13 @@ function isoSpanUnavailable(fec, path, declaresFecInstance) {
23333
23312
  function catalogFecUnavailable(fec, fecPath) {
23334
23313
  if (catalogFecAvailable(fec)) return void 0;
23335
23314
  const block = recordOf3(fec);
23315
+ if (fecAlgorithmUnimplemented(block["algorithm"])) {
23316
+ return Object.freeze({
23317
+ code: "track_fec_algorithm_unimplemented",
23318
+ path: `${fecPath}.algorithm`,
23319
+ message: `algorithm ${JSON.stringify(block["algorithm"])} is not implemented: the track plays without FEC`
23320
+ });
23321
+ }
23336
23322
  const declaresFecInstance = block["algorithm"] !== "none";
23337
23323
  const reason = blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
23338
23324
  if (reason === void 0) {
@@ -23361,6 +23347,7 @@ function fecParams(catalog, track, rendition, fps, sampleRate) {
23361
23347
  const fecBlockProfile = readFecBlockProfile(fec.blockProfile, `${fecPath}.blockProfile`, true, throwRepairContractError);
23362
23348
  return {
23363
23349
  fecK: fec.sourceSymbols ?? 0,
23350
+ fecAlgorithm: fec.algorithm === "reed-solomon" ? "reed-solomon" : "raptorq",
23364
23351
  fecBlockProfile,
23365
23352
  fecRepairCount: fec.repairSymbols ?? 0,
23366
23353
  // The wire RSB_length: every base layer's packets carry the base total (§7.1).
@@ -25354,7 +25341,7 @@ async function setupFecWorkerForTrack(opts) {
25354
25341
  trackType: opts.trackType,
25355
25342
  framerate: opts.framerate,
25356
25343
  sampleRate: opts.sampleRate,
25357
- algorithm: "raptor",
25344
+ algorithm: opts.fecAlgorithm ?? "raptorq",
25358
25345
  blockProfile,
25359
25346
  k: opts.fecK,
25360
25347
  // P as this receiver joined it, not the catalog total: the worker snapshot
@@ -27966,14 +27953,12 @@ export {
27966
27953
  MulticastInputError,
27967
27954
  MulticastManager,
27968
27955
  MulticastTransport,
27969
- NoneCodec,
27970
27956
  REPAIR_LIFECYCLE_EVENT_TYPE,
27971
27957
  REPAIR_LIFECYCLE_LOG_PREFIX,
27972
27958
  REPAIR_PRIORITY_MAX,
27973
27959
  REPAIR_PRIORITY_MIN,
27974
27960
  REPAIR_TRACK_GEOMETRY_KEYS,
27975
27961
  REPAIR_TRACK_ONLY_KEYS,
27976
- ReedSolomonCodec,
27977
27962
  RepairContractError,
27978
27963
  SOURCE_MEDIA_PRIORITY_MAX,
27979
27964
  SampleCombineError,
@@ -28011,7 +27996,6 @@ export {
28011
27996
  computeFecDeliveryWindowMediaUnits,
28012
27997
  computeFecDeliveryWindowMs,
28013
27998
  computeFecLossWindowMs,
28014
- createFecCodec,
28015
27999
  createFragment,
28016
28000
  createWasmMmtpContainerParser,
28017
28001
  datagramMfuReassembly,
@@ -28039,6 +28023,7 @@ export {
28039
28023
  extractHevcCodecDescription,
28040
28024
  extractHevcParameterSets,
28041
28025
  extractSpsPpsFromAvcC,
28026
+ fecAlgorithmUnimplemented,
28042
28027
  findAnnexBStartCode,
28043
28028
  forwardRepairLifecycleEvents,
28044
28029
  frameSamplesFromInit,