@blockcast/mmt-container 0.4.0-main.66aaafd6f03d → 0.4.0-main.726ce14f2b17

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 (62) hide show
  1. package/dist/browser-runtime.js +108 -37
  2. package/dist/browser-runtime.js.map +4 -4
  3. package/dist/carp-catalog.js +3 -0
  4. package/dist/carp-catalog.js.map +3 -3
  5. package/dist/catalog-fec-params.d.ts +5 -2
  6. package/dist/catalog-fec-params.d.ts.map +1 -1
  7. package/dist/catalog-fec-params.js +100 -36
  8. package/dist/catalog-fec-params.js.map +4 -4
  9. package/dist/catalog-network-source.js +3 -0
  10. package/dist/catalog-network-source.js.map +3 -3
  11. package/dist/delivery-catalog.js +10 -0
  12. package/dist/delivery-catalog.js.map +4 -4
  13. package/dist/fec-manager.js +3 -0
  14. package/dist/fec-manager.js.map +3 -3
  15. package/dist/fec-state.d.ts +3 -2
  16. package/dist/fec-state.d.ts.map +1 -1
  17. package/dist/fec-state.js +16 -9
  18. package/dist/fec-state.js.map +4 -4
  19. package/dist/fec-worker-setup.js +3 -0
  20. package/dist/fec-worker-setup.js.map +3 -3
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +6 -0
  24. package/dist/index.js.map +2 -2
  25. package/dist/iso-block-locator.js +3 -0
  26. package/dist/iso-block-locator.js.map +3 -3
  27. package/dist/mfu-reassembler.js +3 -0
  28. package/dist/mfu-reassembler.js.map +3 -3
  29. package/dist/mmtp-container-parser.js +3 -0
  30. package/dist/mmtp-container-parser.js.map +3 -3
  31. package/dist/mmtp-container-parser.no-modules.js +16 -9
  32. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  33. package/dist/mmtp-decode-pipeline.js +3 -0
  34. package/dist/mmtp-decode-pipeline.js.map +3 -3
  35. package/dist/mmtp-router.js +3 -0
  36. package/dist/mmtp-router.js.map +3 -3
  37. package/dist/multicast-input.js +3 -0
  38. package/dist/multicast-input.js.map +3 -3
  39. package/dist/multicast-manager.js +35 -11
  40. package/dist/multicast-manager.js.map +4 -4
  41. package/dist/multicast-transport.js +10 -0
  42. package/dist/multicast-transport.js.map +4 -4
  43. package/dist/multicast-unwrap.js +3 -0
  44. package/dist/multicast-unwrap.js.map +3 -3
  45. package/dist/no-modules.js +16 -9
  46. package/dist/no-modules.js.map +4 -4
  47. package/dist/repair-fetch.js +3 -0
  48. package/dist/repair-fetch.js.map +3 -3
  49. package/dist/repair-layers.js +3 -0
  50. package/dist/repair-layers.js.map +3 -3
  51. package/dist/signaling.js +3 -0
  52. package/dist/signaling.js.map +3 -3
  53. package/dist/timestamp-codec.js +3 -0
  54. package/dist/timestamp-codec.js.map +3 -3
  55. package/dist/wasm-mfu-reassembler.js +3 -0
  56. package/dist/wasm-mfu-reassembler.js.map +3 -3
  57. package/dist/wasm-mmtp-container-parser.js +3 -0
  58. package/dist/wasm-mmtp-container-parser.js.map +3 -3
  59. package/package.json +5 -5
  60. package/src/catalog-fec-params.ts +38 -17
  61. package/src/fec-state.ts +4 -9
  62. package/src/index.ts +5 -0
@@ -949,6 +949,71 @@ function isoBlocksBehindLowerBound(a, b, kMax) {
949
949
  return serial32Precedes(a, b) ? Math.floor(serial32Distance(a, b) / kMax) : 0;
950
950
  }
951
951
 
952
+ // ../mmt-base/dist/catalog-fec-source.js
953
+ var ALL_ROLES = Object.freeze(["video", "audio"]);
954
+ function recordOf(value) {
955
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
956
+ }
957
+ function locateCatalogFecSource(catalog, source, roles = ALL_ROLES) {
958
+ const root = recordOf(catalog);
959
+ if (root === void 0)
960
+ return void 0;
961
+ for (const role of roles) {
962
+ const renditions = recordOf(recordOf(root[role])?.["renditions"]);
963
+ if (renditions === void 0 || !Object.hasOwn(renditions, source))
964
+ continue;
965
+ const entry2 = recordOf(renditions[source]);
966
+ if (entry2 === void 0)
967
+ continue;
968
+ return Object.freeze({
969
+ dialect: "hang",
970
+ role,
971
+ entry: entry2,
972
+ fec: entry2["fec"],
973
+ fecPath: `$.${role}.renditions[${JSON.stringify(source)}].fec`
974
+ });
975
+ }
976
+ const tracks = root["tracks"];
977
+ if (!Array.isArray(tracks))
978
+ return void 0;
979
+ const index = tracks.findIndex((track) => recordOf(track)?.["name"] === source);
980
+ if (index < 0)
981
+ return void 0;
982
+ const entry = recordOf(tracks[index]) ?? {};
983
+ return Object.freeze({
984
+ dialect: "msf",
985
+ index,
986
+ entry,
987
+ fec: entry["fec"],
988
+ fecPath: `$.tracks[${index}].fec`
989
+ });
990
+ }
991
+ function isoBlockSpanUsable(fec) {
992
+ const block = recordOf(fec);
993
+ if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1")
994
+ return true;
995
+ const ms = block["interleaveDepthMs"];
996
+ return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
997
+ }
998
+ function catalogFecAvailable(fec) {
999
+ const block = recordOf(fec);
1000
+ if (block === void 0)
1001
+ return true;
1002
+ const declaresFecInstance = block["algorithm"] !== "none";
1003
+ const profile = block["blockProfile"];
1004
+ const profileOk = isFecBlockProfile(profile) || profile === void 0 && !declaresFecInstance;
1005
+ return profileOk && (!declaresFecInstance || isoBlockSpanUsable(block));
1006
+ }
1007
+ function isPositiveSafeInteger(value) {
1008
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
1009
+ }
1010
+ function catalogFecDeclaresUnconfigurableInstance(fec) {
1011
+ const block = recordOf(fec);
1012
+ if (block === void 0 || block["algorithm"] === "none")
1013
+ return false;
1014
+ return !(isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"]));
1015
+ }
1016
+
952
1017
  // src/mfu-reassembler.ts
953
1018
  function fragmentProvenance(fragment) {
954
1019
  if (fragment.deliveryProvenance !== void 0) return fragment.deliveryProvenance;
@@ -6926,6 +6991,9 @@ var FEC_BLOCK_PROFILES2 = Object.freeze([
6926
6991
  "iso-ssbg1-v1"
6927
6992
  ]);
6928
6993
 
6994
+ // node_modules/@blockcast/mmt-base/dist/catalog-fec-source.js
6995
+ var ALL_ROLES2 = Object.freeze(["video", "audio"]);
6996
+
6929
6997
  // node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
6930
6998
  var DRIADDiscovery = class {
6931
6999
  cache = /* @__PURE__ */ new Map();
@@ -8128,6 +8196,10 @@ var TransportManager = class {
8128
8196
  pollMulticastTierSwitch() {
8129
8197
  return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.poll());
8130
8198
  }
8199
+ /** Abandon the in-flight tier join, e.g. because the host could not join the target. */
8200
+ cancelMulticastTierJoin() {
8201
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
8202
+ }
8131
8203
  /**
8132
8204
  * Set packet callback
8133
8205
  */
@@ -12575,22 +12647,16 @@ var INACTIVE = Object.freeze({
12575
12647
  "reliable-moq": Object.freeze({ state: "inactive", reason: "reliable-moq" }),
12576
12648
  "no-multicast-bridge": Object.freeze({ state: "inactive", reason: "no-multicast-bridge" })
12577
12649
  });
12578
- function recordOf(value) {
12650
+ function recordOf2(value) {
12579
12651
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
12580
12652
  }
12581
- function isPositiveSafeInteger(value) {
12653
+ function isPositiveSafeInteger2(value) {
12582
12654
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
12583
12655
  }
12584
12656
  function catalogDeclaresFec(fec) {
12585
- const block = recordOf(fec);
12657
+ const block = recordOf2(fec);
12586
12658
  if (block === void 0 || block["algorithm"] === "none") return false;
12587
- return isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block);
12588
- }
12589
- function isoBlockSpanUsable(fec) {
12590
- const block = recordOf(fec);
12591
- if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1") return true;
12592
- const ms = block["interleaveDepthMs"];
12593
- return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
12659
+ return isPositiveSafeInteger2(block["sourceSymbols"]) && isPositiveSafeInteger2(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block);
12594
12660
  }
12595
12661
  function requireBoolean(value, field) {
12596
12662
  if (typeof value !== "boolean") {
@@ -12606,7 +12672,7 @@ function resolveFecState(evidence) {
12606
12672
  if (typeof transportPolicy !== "string" || !TRANSPORT_POLICIES.has(transportPolicy)) {
12607
12673
  throw new TypeError(`resolveFecState: unsupported transportPolicy ${JSON.stringify(transportPolicy)}`);
12608
12674
  }
12609
- if (stats !== null && stats !== void 0 && recordOf(stats) === void 0) {
12675
+ if (stats !== null && stats !== void 0 && recordOf2(stats) === void 0) {
12610
12676
  throw new TypeError("resolveFecState: stats must be a plain object, null or undefined");
12611
12677
  }
12612
12678
  if (!catalogFec) return INACTIVE["no-catalog-fec"];
@@ -22778,28 +22844,28 @@ function joinedRepairSymbolCount(params, joinedRepairTrackNames) {
22778
22844
  }
22779
22845
  return total;
22780
22846
  }
22781
- function recordOf2(value) {
22847
+ function recordOf3(value) {
22782
22848
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
22783
22849
  }
22784
22850
  function msfTracks(catalog) {
22785
22851
  const raw = catalog.tracks;
22786
22852
  if (!Array.isArray(raw)) return void 0;
22787
- return { tracks: raw.map((t) => recordOf2(t) ?? {}) };
22853
+ return { tracks: raw.map((t) => recordOf3(t) ?? {}) };
22788
22854
  }
22789
22855
  function resolveRepairLayers(catalog, source) {
22790
22856
  if (!catalog) return void 0;
22791
22857
  const sourceName = typeof source === "string" ? source : source.name;
22792
22858
  const hang = catalog;
22793
22859
  const roles = typeof source === "string" ? ["video", "audio"] : source.type === "audio" ? ["audio"] : source.type === "video" ? ["video"] : ["video", "audio"];
22794
- const role = roles.find((r) => recordOf2(hang[r]?.renditions?.[sourceName]) !== void 0);
22795
- if (role !== void 0) {
22796
- const renditionPath = `$.${role}.renditions[${JSON.stringify(sourceName)}]`;
22797
- const rendition = recordOf2(hang[role].renditions[sourceName]);
22860
+ const located = locateCatalogFecSource(catalog, sourceName, roles);
22861
+ if (located?.dialect === "hang") {
22862
+ const renditionPath = `$.${located.role}.renditions[${JSON.stringify(sourceName)}]`;
22863
+ const rendition = located.entry;
22798
22864
  rejectRepairFieldsOnMediaTrack(renditionPath, rendition, throwRepairContractError);
22799
- const repairRenditions = recordOf2(hang.repair?.renditions) ?? {};
22865
+ const repairRenditions = recordOf3(hang.repair?.renditions) ?? {};
22800
22866
  const descriptors2 = Object.entries(repairRenditions).map(([name, entry]) => {
22801
22867
  const path = `$.repair.renditions[${JSON.stringify(name)}]`;
22802
- const fields = recordOf2(entry);
22868
+ const fields = recordOf3(entry);
22803
22869
  if (fields === void 0) {
22804
22870
  throwRepairContractError("track_repair_layer", path, "a repair rendition must be an object");
22805
22871
  }
@@ -22807,14 +22873,14 @@ function resolveRepairLayers(catalog, source) {
22807
22873
  return describeRepairTrack(name, path, fields);
22808
22874
  });
22809
22875
  const fecOfRendition = (entry) => {
22810
- const fec2 = recordOf2(recordOf2(entry)?.["fec"]);
22876
+ const fec2 = recordOf3(recordOf3(entry)?.["fec"]);
22811
22877
  return fec2 !== void 0 && fec2["algorithm"] !== "none" ? fec2 : void 0;
22812
22878
  };
22813
22879
  const mediaRenditions = [
22814
- ...Object.values(recordOf2(hang.video?.renditions) ?? {}),
22815
- ...Object.values(recordOf2(hang.audio?.renditions) ?? {})
22880
+ ...Object.values(recordOf3(hang.video?.renditions) ?? {}),
22881
+ ...Object.values(recordOf3(hang.audio?.renditions) ?? {})
22816
22882
  ];
22817
- const reachability2 = repairReachability(mediaRenditions.map((entry) => recordOf2(entry)?.["fec"]));
22883
+ const reachability2 = repairReachability(mediaRenditions.map((entry) => recordOf3(entry)?.["fec"]));
22818
22884
  for (const d of descriptors2) {
22819
22885
  validateRepairTrackFields(d, throwRepairContractError);
22820
22886
  assertRepairTrackReachable(d, reachability2, throwRepairContractError);
@@ -22830,20 +22896,20 @@ function resolveRepairLayers(catalog, source) {
22830
22896
  }
22831
22897
  }
22832
22898
  const layers2 = assembleRepairLayers(
22833
- geometryOf(sourceName, `${renditionPath}.fec`, recordOf2(rendition["fec"])),
22899
+ geometryOf(sourceName, `${renditionPath}.fec`, recordOf3(rendition["fec"])),
22834
22900
  descriptors2,
22835
22901
  throwRepairContractError
22836
22902
  );
22837
22903
  return catalogFecUnavailable(rendition["fec"], `${renditionPath}.fec`) === void 0 ? layers2 : void 0;
22838
22904
  }
22839
22905
  const msf = msfTracks(catalog);
22840
- const msfIndex = msf ? msf.tracks.findIndex((t) => t["name"] === sourceName) : -1;
22841
- if (!msf || msfIndex < 0) return void 0;
22906
+ if (!msf || located?.dialect !== "msf") return void 0;
22907
+ const msfIndex = located.index;
22842
22908
  const track = msf.tracks[msfIndex];
22843
- const fec = recordOf2(track["fec"]);
22909
+ const fec = recordOf3(track["fec"]);
22844
22910
  const packagingOf = (t) => t["packaging"];
22845
22911
  const fecOfTrack = (t) => {
22846
- const trackFec = recordOf2(t?.["fec"]);
22912
+ const trackFec = recordOf3(t?.["fec"]);
22847
22913
  return trackFec !== void 0 && trackFec["algorithm"] !== "none" ? trackFec : void 0;
22848
22914
  };
22849
22915
  const descriptors = [];
@@ -22893,8 +22959,8 @@ function catalogRepairTarget(catalog, source) {
22893
22959
  const entry = msf?.tracks.find((t) => t["name"] === sourceName);
22894
22960
  const hang = catalog;
22895
22961
  const roles = typeof source === "string" ? ["video", "audio"] : source.type === "video" ? ["video"] : source.type === "audio" ? ["audio"] : ["video", "audio"];
22896
- const rendition = roles.map((role) => hang[role]?.renditions?.[sourceName]).find((r) => recordOf2(r) !== void 0);
22897
- const fec = rendition === void 0 ? recordOf2(entry?.["fec"]) : recordOf2(rendition.fec);
22962
+ const rendition = roles.map((role) => hang[role]?.renditions?.[sourceName]).find((r) => recordOf3(r) !== void 0);
22963
+ const fec = rendition === void 0 ? recordOf3(entry?.["fec"]) : recordOf3(rendition.fec);
22898
22964
  if (!fec || !(catalogFecInterleaveMs(fec) ?? 0)) return null;
22899
22965
  const sourcePriority = entry === void 0 ? null : moqtPriority2(entry["priority"]);
22900
22966
  return { repairTrack: layerZero.repairTrackName, sourcePriority, repairPriority: layerZero.priority };
@@ -22937,10 +23003,14 @@ function isoSpanUnavailable(fec, path, declaresFecInstance) {
22937
23003
  });
22938
23004
  }
22939
23005
  function catalogFecUnavailable(fec, fecPath) {
22940
- const block = recordOf2(fec);
22941
- if (block === void 0) return void 0;
23006
+ if (catalogFecAvailable(fec)) return void 0;
23007
+ const block = recordOf3(fec);
22942
23008
  const declaresFecInstance = block["algorithm"] !== "none";
22943
- return blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
23009
+ const reason = blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
23010
+ if (reason === void 0) {
23011
+ throw new Error(`catalogFecUnavailable: ${fecPath} is unavailable but no reason applies (rule drift)`);
23012
+ }
23013
+ return reason;
22944
23014
  }
22945
23015
  function fecParams(catalog, track, rendition, fps, sampleRate) {
22946
23016
  const mediaRate = sampleRate === void 0 ? { fps } : { fps, sampleRate };
@@ -22949,10 +23019,8 @@ function fecParams(catalog, track, rendition, fps, sampleRate) {
22949
23019
  const repair = resolveRepairLayers(catalog, track);
22950
23020
  const fecPath = `$.${track.type}.renditions[${JSON.stringify(track.name)}].fec`;
22951
23021
  if (!catalogDeclaresFec(fec)) {
22952
- const declaresFecInstance = fec.algorithm !== "none";
22953
- const kValid = Number.isSafeInteger(fec.sourceSymbols) && (fec.sourceSymbols ?? 0) > 0;
22954
- const tValid = Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0;
22955
- if (declaresFecInstance && !(kValid && tValid)) {
23022
+ if (catalogFecDeclaresUnconfigurableInstance(fec)) {
23023
+ const kValid = Number.isSafeInteger(fec.sourceSymbols) && (fec.sourceSymbols ?? 0) > 0;
22956
23024
  throwRepairContractError(
22957
23025
  "track_fec",
22958
23026
  `${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
@@ -26988,6 +27056,8 @@ export {
26988
27056
  buildVideoInitSegment,
26989
27057
  catalogAmtNetworkSource,
26990
27058
  catalogDeclaresFec,
27059
+ catalogFecAvailable,
27060
+ catalogFecDeclaresUnconfigurableInstance,
26991
27061
  catalogFecInterleaveMs,
26992
27062
  catalogFecMediaUnitsPerSecond,
26993
27063
  catalogFecUnavailable,
@@ -27062,6 +27132,7 @@ export {
27062
27132
  isTrackTimingConfig,
27063
27133
  joinedRepairSymbolCount,
27064
27134
  keyframeIntervalMediaTicks,
27135
+ locateCatalogFecSource,
27065
27136
  mergeOverrideIntoCmsfTracks,
27066
27137
  mergeOverrideIntoHangRenditions,
27067
27138
  mfuReassemblyTimeoutMs,