@blockcast/mmt-container 2.2.0-main.e1bebe787bc9 → 2.2.0-main.ea9223dc11de

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 (124) hide show
  1. package/dist/block-policy.d.ts +33 -3
  2. package/dist/block-policy.d.ts.map +1 -1
  3. package/dist/block-policy.js +60 -24
  4. package/dist/block-policy.js.map +3 -3
  5. package/dist/browser-runtime.js +1034 -126
  6. package/dist/browser-runtime.js.map +4 -4
  7. package/dist/carp-catalog.d.ts +40 -1
  8. package/dist/carp-catalog.d.ts.map +1 -1
  9. package/dist/carp-catalog.js +163 -10
  10. package/dist/carp-catalog.js.map +4 -4
  11. package/dist/catalog-fec-params.js +34 -0
  12. package/dist/catalog-fec-params.js.map +3 -3
  13. package/dist/catalog-network-source.js +34 -0
  14. package/dist/catalog-network-source.js.map +3 -3
  15. package/dist/datagram-leg-deadline.d.ts +138 -0
  16. package/dist/datagram-leg-deadline.d.ts.map +1 -0
  17. package/dist/datagram-leg-deadline.js +229 -0
  18. package/dist/datagram-leg-deadline.js.map +7 -0
  19. package/dist/delivery-catalog.js +68 -0
  20. package/dist/delivery-catalog.js.map +4 -4
  21. package/dist/delta-fallback-config.js +34 -0
  22. package/dist/delta-fallback-config.js.map +3 -3
  23. package/dist/fec-manager.d.ts +117 -13
  24. package/dist/fec-manager.d.ts.map +1 -1
  25. package/dist/fec-manager.js +358 -42
  26. package/dist/fec-manager.js.map +4 -4
  27. package/dist/fec-state.d.ts +17 -5
  28. package/dist/fec-state.d.ts.map +1 -1
  29. package/dist/fec-state.js +36 -0
  30. package/dist/fec-state.js.map +3 -3
  31. package/dist/fec-worker-setup.js +34 -0
  32. package/dist/fec-worker-setup.js.map +3 -3
  33. package/dist/held-layer-admission.js +34 -0
  34. package/dist/held-layer-admission.js.map +3 -3
  35. package/dist/index.d.ts +6 -4
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +14 -0
  38. package/dist/index.js.map +2 -2
  39. package/dist/iso-block-locator.d.ts +16 -0
  40. package/dist/iso-block-locator.d.ts.map +1 -1
  41. package/dist/iso-block-locator.js +62 -0
  42. package/dist/iso-block-locator.js.map +3 -3
  43. package/dist/mfu-reassembler.js +34 -0
  44. package/dist/mfu-reassembler.js.map +3 -3
  45. package/dist/mmtp-container-parser.d.ts +6 -3
  46. package/dist/mmtp-container-parser.d.ts.map +1 -1
  47. package/dist/mmtp-container-parser.js +34 -0
  48. package/dist/mmtp-container-parser.js.map +3 -3
  49. package/dist/mmtp-container-parser.no-modules.js +167 -13
  50. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  51. package/dist/mmtp-decode-pipeline.js +34 -0
  52. package/dist/mmtp-decode-pipeline.js.map +3 -3
  53. package/dist/mmtp-fec-session.js +34 -0
  54. package/dist/mmtp-fec-session.js.map +3 -3
  55. package/dist/mmtp-mode-selection.d.ts +48 -0
  56. package/dist/mmtp-mode-selection.d.ts.map +1 -0
  57. package/dist/mmtp-mode-selection.js +79 -0
  58. package/dist/mmtp-mode-selection.js.map +7 -0
  59. package/dist/mmtp-router.d.ts +66 -10
  60. package/dist/mmtp-router.d.ts.map +1 -1
  61. package/dist/mmtp-router.js +204 -30
  62. package/dist/mmtp-router.js.map +4 -4
  63. package/dist/multicast-auth-catalog.js +42 -2
  64. package/dist/multicast-auth-catalog.js.map +3 -3
  65. package/dist/multicast-input.js +42 -2
  66. package/dist/multicast-input.js.map +3 -3
  67. package/dist/multicast-manager.d.ts +95 -1
  68. package/dist/multicast-manager.d.ts.map +1 -1
  69. package/dist/multicast-manager.js +613 -92
  70. package/dist/multicast-manager.js.map +4 -4
  71. package/dist/multicast-transport.js +68 -0
  72. package/dist/multicast-transport.js.map +4 -4
  73. package/dist/multicast-unwrap.js +34 -0
  74. package/dist/multicast-unwrap.js.map +3 -3
  75. package/dist/no-modules.js +167 -13
  76. package/dist/no-modules.js.map +4 -4
  77. package/dist/phase14-catalog-override.d.ts +2 -1
  78. package/dist/phase14-catalog-override.d.ts.map +1 -1
  79. package/dist/phase14-catalog-override.js +69 -2
  80. package/dist/phase14-catalog-override.js.map +3 -3
  81. package/dist/repair-fetch.d.ts.map +1 -1
  82. package/dist/repair-fetch.js +50 -0
  83. package/dist/repair-fetch.js.map +3 -3
  84. package/dist/repair-layer-subscriptions.js +34 -0
  85. package/dist/repair-layer-subscriptions.js.map +3 -3
  86. package/dist/signaling.js +34 -0
  87. package/dist/signaling.js.map +3 -3
  88. package/dist/timestamp-codec.js +34 -0
  89. package/dist/timestamp-codec.js.map +3 -3
  90. package/dist/wasm-mfu-reassembler.js +34 -0
  91. package/dist/wasm-mfu-reassembler.js.map +3 -3
  92. package/dist/wasm-mmtp-container-parser.js +34 -0
  93. package/dist/wasm-mmtp-container-parser.js.map +3 -3
  94. package/package.json +5 -5
  95. package/schemas/catalog.schema.json +2 -2
  96. package/src/block-policy.ts +108 -31
  97. package/src/carp-catalog.ts +165 -5
  98. package/src/datagram-leg-deadline.ts +370 -0
  99. package/src/fec-manager.ts +345 -33
  100. package/src/fec-state.ts +21 -5
  101. package/src/index.ts +37 -0
  102. package/src/iso-block-locator.ts +34 -0
  103. package/src/mmtp-container-parser.ts +6 -4
  104. package/src/mmtp-mode-selection.ts +80 -0
  105. package/src/mmtp-router.ts +226 -45
  106. package/src/multicast-manager.ts +126 -0
  107. package/src/phase14-catalog-override.ts +14 -3
  108. package/src/repair-fetch.ts +23 -0
  109. package/test-vectors/catalog/README.md +36 -2
  110. package/test-vectors/catalog/mmtp-siblings/ambiguous-sibling.json +158 -0
  111. package/test-vectors/catalog/mmtp-siblings/ladder-bitrate-only.json +231 -0
  112. package/test-vectors/catalog/mmtp-siblings/ladder-four-rungs.json +405 -0
  113. package/test-vectors/catalog/mmtp-siblings/ladder-other-names.json +231 -0
  114. package/test-vectors/catalog/mmtp-siblings/mmtp-mode-unknown.json +143 -0
  115. package/test-vectors/catalog/mmtp-siblings/multicast-endpoint-lists-datagram-track.json +143 -0
  116. package/test-vectors/catalog/mmtp-siblings/no-sibling.json +79 -0
  117. package/test-vectors/catalog/mmtp-siblings/rendition-mismatch.json +143 -0
  118. package/test-vectors/catalog/mmtp-siblings/stream-delivery-mode.json +143 -0
  119. package/test-vectors/catalog/mmtp-siblings/timescale-mismatch.json +143 -0
  120. package/test-vectors/catalog/mmtp-siblings/valid-pair.json +142 -0
  121. package/test-vectors/catalog/section-codes.json +3 -3
  122. package/test-vectors/catalog-timing.json +742 -1
  123. package/test-vectors/catalog-validation.json +266 -7
  124. package/test-vectors/moq/mmtp-mode-selection.json +259 -0
@@ -33,6 +33,7 @@
33
33
  * Production builds never set the global, so all three helpers are no-ops at
34
34
  * runtime unless the test harness opts in.
35
35
  */
36
+ import { type MmtpMode } from "@blockcast/mmt-base";
36
37
  import type { FecCatalogConfig } from "./carp-catalog.js";
37
38
  /**
38
39
  * A single override track entry — mirrors the fixture at
@@ -51,7 +52,7 @@ export interface Phase14OverrideTrack {
51
52
  source?: string;
52
53
  instanceId?: number;
53
54
  /** Required when packaging is `mmtp`; the current publisher emits MFU mode. */
54
- mmtpMode?: "mfu";
55
+ mmtpMode?: MmtpMode;
55
56
  /** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */
56
57
  timescale?: number;
57
58
  /** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */
@@ -1 +1 @@
1
- {"version":3,"file":"phase14-catalog-override.d.ts","sourceRoot":"","sources":["../src/phase14-catalog-override.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAM1D;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb;sEACkE;IAClE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,GAAG,YAAY,CAAC;IAChE,yEAAyE;IACzE,MAAM,CAAC,E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AC;CAC/B;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,sBAAsB,GAAG,IAAI,CAkCzE;AAMD;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5E,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,sBAAsB,GAAG,IAAI,GACrC,CAAC,CAiEH;AAkBD;;;;GAIG;AACH,KAAK,aAAa,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACrB,CAAC;AAMF;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAC1C,MAAM,EAAE,aAAa,EAAE,EACvB,QAAQ,EAAE,sBAAsB,GAAG,IAAI,GACrC,aAAa,EAAE,CA2HjB"}
@@ -1,3 +1,62 @@
1
+ // ../mmt-base/dist/mmtp.js
2
+ var MPU_HEADER_SIZE = 8;
3
+ var MPU_LENGTH_FIELD_SIZE = 2;
4
+ var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
5
+
6
+ // ../mmt-base/dist/ntp-short.js
7
+ var NTP_SHORT_BITS = 32;
8
+ var NTP_SHORT_MODULUS = 2 ** NTP_SHORT_BITS;
9
+ var NTP_SHORT_HALF_RANGE = 2 ** (NTP_SHORT_BITS - 1);
10
+
11
+ // ../mmt-base/dist/fec-block-profile.js
12
+ var FEC_BLOCK_PROFILES = Object.freeze([
13
+ "iso-ssbg1-v1"
14
+ ]);
15
+
16
+ // ../mmt-base/dist/fec-bindings.js
17
+ var RUNTIME_FEC_RECEIVER = Object.freeze({
18
+ schemes: Object.freeze(["raptorq", "reed-solomon"]),
19
+ blockProfiles: Object.freeze(["iso-ssbg1-v1"]),
20
+ overlays: true
21
+ });
22
+
23
+ // ../mmt-base/dist/mmtp-siblings.js
24
+ var MMTP_MODES = Object.freeze(["mfu", "mfu-datagram"]);
25
+ function isMmtpMode(value) {
26
+ return typeof value === "string" && MMTP_MODES.includes(value);
27
+ }
28
+ var MMTP_SIBLING_HARD_FIELDS = Object.freeze([
29
+ "namespace",
30
+ "timescale",
31
+ "presentationAnchorTicks",
32
+ "groupDuration"
33
+ ]);
34
+ var MMTP_SIBLING_RENDITION_FIELDS = Object.freeze([
35
+ "codec",
36
+ "width",
37
+ "height",
38
+ "framerate",
39
+ "bitrate",
40
+ "samplerate",
41
+ "channelConfig",
42
+ "lang"
43
+ ]);
44
+ var MMTP_SIBLING_SOFT_FIELDS = Object.freeze([
45
+ "initRef",
46
+ "keyframeIntervalMs",
47
+ "keyframeIntervalTicks",
48
+ "isLive",
49
+ "altGroup"
50
+ ]);
51
+
52
+ // ../mmt-base/dist/datagram-leg-size.js
53
+ var DATAGRAM_LEG_UDP_FLOOR = 1200;
54
+ var DATAGRAM_LEG_QUIC_WT_FRAMING = 48;
55
+ var DATAGRAM_LEG_OBJECT_HEADER = 13;
56
+ var DATAGRAM_LEG_RELAY_ROOM = 16;
57
+ var DATAGRAM_LEG_DATAGRAM_MAX = DATAGRAM_LEG_UDP_FLOOR - DATAGRAM_LEG_QUIC_WT_FRAMING;
58
+ var DATAGRAM_LEG_BODY_MAX = DATAGRAM_LEG_DATAGRAM_MAX - DATAGRAM_LEG_OBJECT_HEADER - DATAGRAM_LEG_RELAY_ROOM;
59
+
1
60
  // src/phase14-catalog-override.ts
2
61
  function getPhase14CatalogOverride() {
3
62
  const g = globalThis;
@@ -99,11 +158,15 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
99
158
  if (ot.role !== void 0 && existing.role === void 0) existing.role = ot.role;
100
159
  if (existing.packaging === "mmtp") {
101
160
  const mode = existing.mmtpMode ?? ot.mmtpMode;
102
- if (mode !== "mfu") {
161
+ if (mode === void 0) {
103
162
  throw new Error(
104
163
  `[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
105
164
  );
106
165
  }
166
+ if (!isMmtpMode(mode)) {
167
+ console.warn(`[phase14-catalog-override] track "${ot.name}" has unknown mmtpMode ${JSON.stringify(mode)}; skipping the override`);
168
+ continue;
169
+ }
107
170
  existing.mmtpMode = mode;
108
171
  if (existing.timescale === void 0 && ot.timescale !== void 0) existing.timescale = ot.timescale;
109
172
  if (existing.groupDurationMs === void 0 && ot.groupDurationMs !== void 0) {
@@ -140,11 +203,15 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
140
203
  );
141
204
  }
142
205
  const mmtpMode = ot.mmtpMode;
143
- if (packaging === "mmtp" && mmtpMode !== "mfu") {
206
+ if (packaging === "mmtp" && mmtpMode === void 0) {
144
207
  throw new Error(
145
208
  `[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
146
209
  );
147
210
  }
211
+ if (packaging === "mmtp" && !isMmtpMode(mmtpMode)) {
212
+ console.warn(`[phase14-catalog-override] track "${ot.name}" has unknown mmtpMode ${JSON.stringify(mmtpMode)}; skipping the track`);
213
+ continue;
214
+ }
148
215
  if (packaging === "mmtp" && !isPositiveInteger(ot.timescale)) {
149
216
  throw new Error(
150
217
  `[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid timescale`
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/phase14-catalog-override.ts"],
4
- "sourcesContent": ["/**\n * Phase 14 catalog-override hook (test harness only).\n *\n * When `globalThis.__PHASE14_CATALOG_OVERRIDE` is set (injected by the\n * 7point test via `page.addInitScript` \u2014 see\n * packages/moq-server/tests/7point-validation.test.mjs `applyPhase14CatalogOverride`)\n * the override's `tracks[]` are merged into whatever catalog the MoQ-delivered\n * JSON produced:\n *\n * - Dedupe by `track.name`.\n * - When both sides carry a track with the same name, the override's\n * `fec` config wins \u2014 this is how the 7point harness steers multi-track\n * tests onto the Phase 14 `video/base` + `video/delta` + `video/repair`\n * switching set without asking the publisher to change its catalog.\n * - Tracks present only in the override are appended as-is.\n * - Tracks present only in the MoQ catalog are preserved unchanged.\n * - `fec` is the draft-ramadan-moq-fec-catalog-00 instance array; a repair\n * track is `packaging: \"fec-repair\"` with `source` + `instanceId`, and each\n * of base and delta names its own (one Track Name in two `repairTrack`\n * members is no FEC on either, catalog-00 5 rule 2).\n *\n * This module is deliberately player-agnostic. It exposes:\n *\n * getPhase14CatalogOverride() \u2014 read + shape-check the global.\n * mergeOverrideIntoHangRenditions() \u2014 merge into a `@moq/hang`\n * Catalog.Root `video.renditions` /\n * `audio.renditions` dict. Used by\n * hang-mmt-fec/js/watch/src/broadcast.ts.\n * mergeOverrideIntoCmsfTracks() \u2014 merge into moqtail's CMSF-flat\n * `tracks[]` array. Used by\n * moqtail-private CMSFCatalog.from().\n *\n * Production builds never set the global, so all three helpers are no-ops at\n * runtime unless the test harness opts in.\n */\n\nimport type { FecCatalogConfig } from \"./carp-catalog.js\";\n\n// ---------------------------------------------------------------------------\n// Override fixture shape (IETF draft-ietf-moq-catalogformat-01)\n// ---------------------------------------------------------------------------\n\n/**\n * A single override track entry \u2014 mirrors the fixture at\n * `packages/moq-server/tests/fixtures/multi-track-catalog.json`.\n *\n * Kept intentionally permissive: the canonical fixture carries `name`,\n * `altGroup`, `framerate`, and `fec`, but future 7point scenarios may extend\n * with additional hints without wanting this module to gate-keep them.\n */\nexport interface Phase14OverrideTrack {\n\tname: string;\n\t/** CMSF packaging kind. Optional per track \u2014 when absent, the merge\n\t * derives it from the override's top-level `streamingFormat`. */\n\tpackaging?: \"mmtp\" | \"cmaf\" | \"loc\" | \"timeline\" | \"fec-repair\";\n\t/** A `fec-repair` track's source track and instance (catalog-00 3.2). */\n\tsource?: string;\n\tinstanceId?: number;\n\t/** Required when packaging is `mmtp`; the current publisher emits MFU mode. */\n\tmmtpMode?: \"mfu\";\n\t/** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */\n\ttimescale?: number;\n\t/** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */\n\tgroupDurationMs?: number;\n\t/** Codec string. Optional per track \u2014 when absent, the merge inherits\n\t * from the existing video/audio rendition in the MoQ catalog (the\n\t * publisher's declaration). Throws only when neither the override nor\n\t * any existing rendition supplies one. */\n\tcodec?: string;\n\trole?: \"video\" | \"audio\" | \"timeline\";\n\taltGroup?: number;\n\tframerate?: number;\n\tfec?: FecCatalogConfig;\n}\n\n/**\n * The shape the 7point harness writes to `globalThis.__PHASE14_CATALOG_OVERRIDE`.\n * Extra top-level fields (`version`, `streamingFormat`, ...) are ignored \u2014\n * the merge only consumes `tracks[]`.\n */\nexport interface Phase14CatalogOverride {\n\tversion?: string;\n\tstreamingFormat?: string;\n\ttracks: Phase14OverrideTrack[];\n}\n\n// ---------------------------------------------------------------------------\n// Global reader\n// ---------------------------------------------------------------------------\n\n/**\n * Read `globalThis.__PHASE14_CATALOG_OVERRIDE` and return it only when it has\n * a well-formed `tracks[]` array. Malformed values log + return `null` rather\n * than throw so a broken fixture never kills the MoQ path for a real stream.\n */\nexport function getPhase14CatalogOverride(): Phase14CatalogOverride | null {\n\t// `globalThis` is defined in workers, service workers, and the main window;\n\t// it's the portable way to reach the test-injected hook from any context.\n\tconst g = globalThis as Record<string, unknown>;\n\tconst raw = g[\"__PHASE14_CATALOG_OVERRIDE\"];\n\tif (raw === undefined || raw === null) return null;\n\tif (typeof raw !== \"object\") {\n\t\tconsole.warn(\"[phase14-catalog-override] hook is not an object; ignoring\");\n\t\treturn null;\n\t}\n\tconst obj = raw as Record<string, unknown>;\n\tconst tracks = obj[\"tracks\"];\n\tif (!Array.isArray(tracks)) {\n\t\tconsole.warn(\"[phase14-catalog-override] hook.tracks is not an array; ignoring\");\n\t\treturn null;\n\t}\n\t// Shallow filter: keep only entries that at least have a string name.\n\t// Each consumer (hang or CMSF merge) validates shape further.\n\tconst filtered: Phase14OverrideTrack[] = [];\n\tfor (const t of tracks) {\n\t\tif (typeof t === \"object\" && t !== null) {\n\t\t\tconst entry = t as Record<string, unknown>;\n\t\t\tif (typeof entry[\"name\"] === \"string\" && (entry[\"name\"] as string).length > 0) {\n\t\t\t\tfiltered.push(entry as unknown as Phase14OverrideTrack);\n\t\t\t}\n\t\t}\n\t}\n\tif (filtered.length === 0) return null;\n\treturn {\n\t\tversion: typeof obj[\"version\"] === \"string\" ? (obj[\"version\"] as string) : undefined,\n\t\tstreamingFormat:\n\t\t\ttypeof obj[\"streamingFormat\"] === \"string\" ? (obj[\"streamingFormat\"] as string) : undefined,\n\t\ttracks: filtered,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Hang renditions merge (moq-lib / hang-mmt-fec)\n// ---------------------------------------------------------------------------\n\n/**\n * Merge override tracks into a `@moq/hang` Catalog.Root-like object. The\n * caller passes the already-parsed Catalog.Root (mutates in place and also\n * returns it for convenience). No-op when `override` is null.\n *\n * Dedupe rule: override wins for `fec` config and `framerate`. Everything\n * else (codec, container kind) is preserved from the MoQ-delivered rendition\n * when it exists, or synthesised from the override when it does not.\n *\n * Typed `any` here rather than narrow-matching `Catalog.Root` because the\n * upstream `@moq/hang` schema is branded (u53) and the container `kind` union\n * varies by version (`loc` kind appears in hang-mmt-fec's fork). Matching\n * that surface exactly would over-couple this module to a single upstream\n * revision; the runtime shape we rely on (`.video.renditions` dict mutation)\n * is stable.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mergeOverrideIntoHangRenditions<T extends Record<string, any>>(\n\tcatalog: T,\n\toverride: Phase14CatalogOverride | null,\n): T {\n\tif (!override) return catalog;\n\n\tfor (const track of override.tracks) {\n\t\t// Repair tracks are placed after the media merge, below.\n\t\tif (track.packaging === \"fec-repair\") continue;\n\t\t// Default role inference: names without an explicit role field are\n\t\t// treated as video unless the name suffix says audio.\n\t\tconst role: \"video\" | \"audio\" =\n\t\t\ttrack.role === \"audio\" || track.name.startsWith(\"audio\") ? \"audio\" : \"video\";\n\n\t\tconst bagKey = role === \"audio\" ? \"audio\" : \"video\";\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst bag: { renditions: Record<string, any>; priority?: number } =\n\t\t\tcatalog[bagKey] ?? { renditions: {}, priority: 1 };\n\t\tconst existing = bag.renditions[track.name];\n\n\t\t// Merge: override fills gaps, does NOT overwrite existing fec/framerate.\n\t\t// The publisher's real catalog is ground truth for wire parameters:\n\t\t// if the existing rendition already has a matching fec config, that's\n\t\t// what the publisher's packets actually carry. Overwriting it with a\n\t\t// fixture value (e.g. Phase 14 target K=768 when publisher emits K=4)\n\t\t// causes the FEC manager to wait for symbols that never arrive.\n\t\t// Only when the rendition is brand-new (no existing fec) do we seed\n\t\t// from the fixture.\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst merged: Record<string, any> = {\n\t\t\t...(existing ?? {}),\n\t\t\tcontainer: existing?.container ?? { kind: \"mmtp-fec\" },\n\t\t\tcodec: existing?.codec ?? \"\",\n\t\t};\n\t\tif (existing?.framerate === undefined && track.framerate !== undefined) {\n\t\t\tmerged[\"framerate\"] = track.framerate;\n\t\t}\n\t\tif (existing?.fec === undefined && track.fec !== undefined) {\n\t\t\tmerged[\"fec\"] = track.fec;\n\t\t}\n\n\t\tbag.renditions[track.name] = merged;\n\t\t// Reassign so a freshly-created bag is actually reachable on the\n\t\t// catalog when the MoQ side was missing video/audio entirely.\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t(catalog as any)[bagKey] = bag;\n\t}\n\n\t// A repair track is a hang `repair.renditions` entry, bound by `source` +\n\t// `instanceId`, never a media rendition. It is added only when the\n\t// source's effective `fec` names it: a publisher `fec` that won the merge\n\t// may bind a different repair track, and attaching this one would cost\n\t// that instance its FEC (rule 3).\n\tfor (const track of override.tracks) {\n\t\tif (track.packaging !== \"fec-repair\") continue;\n\t\tconst source =\n\t\t\tcatalog[\"video\"]?.renditions?.[track.source as string] ??\n\t\t\tcatalog[\"audio\"]?.renditions?.[track.source as string];\n\t\tif (!namesRepairTrack(source?.fec, track.name, track.instanceId)) continue;\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst repair: { renditions?: Record<string, any> } = catalog[\"repair\"] ?? {};\n\t\trepair.renditions ??= {};\n\t\tconst { name, packaging: _p, mmtpMode: _m, timescale: _t, groupDurationMs: _g, altGroup: _a, ...entry } = track;\n\t\trepair.renditions[name] ??= entry;\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t(catalog as any)[\"repair\"] = repair;\n\t}\n\treturn catalog;\n}\n\n/** Whether `fec` holds the instance `instanceId` (default 0) whose `repairTrack` is `name`. */\nfunction namesRepairTrack(fec: unknown, name: string, instanceId: unknown): boolean {\n\tconst id = instanceId ?? 0;\n\treturn (\n\t\tArray.isArray(fec) &&\n\t\tfec.some(\n\t\t\t(i) =>\n\t\t\t\ttypeof i === \"object\" && i !== null && (i.instanceId ?? 0) === id && i.repairTrack === name,\n\t\t)\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// CMSF tracks merge (moqtail-private)\n// ---------------------------------------------------------------------------\n\n/**\n * Shape-minimal description of a CMSF track input (pre-validation JSON, not\n * the parsed `CMSFTrack`). Keeps this module free of a hard dependency on\n * moqtail-ts.\n */\ntype CmsfTrackJson = {\n\tname: string;\n\tpackaging?: string;\n\tmmtpMode?: string;\n\ttimescale?: number;\n\tgroupDurationMs?: number;\n\trole?: string;\n\tcodec?: string;\n\tframerate?: number;\n\tfec?: unknown;\n\t[k: string]: unknown;\n};\n\nfunction isPositiveInteger(value: unknown): value is number {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value > 0;\n}\n\n/**\n * Merge override tracks into a raw CMSF `tracks[]` JSON array (as produced\n * by `JSON.parse(catalog.json)` inside `CMSFCatalog.from`).\n *\n * Dedupe by `name`. For name collisions, publisher-emitted `fec` + `framerate`\n * are preserved (the publisher is ground truth for wire parameters). For new\n * track names, missing `packaging` is derived from the override's top-level\n * `streamingFormat`, and missing `codec` is inherited from any existing video\n * track in the catalog. Throws on bad init when neither source supplies them.\n */\nexport function mergeOverrideIntoCmsfTracks(\n\ttracks: CmsfTrackJson[],\n\toverride: Phase14CatalogOverride | null,\n): CmsfTrackJson[] {\n\tif (!override) return tracks;\n\n\tconst byName = new Map<string, CmsfTrackJson>();\n\tfor (const t of tracks) {\n\t\tif (typeof t?.name === \"string\") byName.set(t.name, t);\n\t}\n\n\t// Catalog-derived fallbacks (NOT magic numbers) \u2014 inherited from existing\n\t// publisher tracks. Used only when the override track doesn't carry them.\n\tconst derivedPackaging = override.streamingFormat;\n\tconst existingVideoTrack = tracks.find(\n\t\t(t) => t.role === \"video\" && typeof t.codec === \"string\" && (t.codec as string).length > 0,\n\t);\n\tconst existingAudioTrack = tracks.find(\n\t\t(t) => t.role === \"audio\" && typeof t.codec === \"string\" && (t.codec as string).length > 0,\n\t);\n\n\t// Media first, so a repair track can check its source's effective `fec`.\n\tconst ordered = [\n\t\t...override.tracks.filter((t) => t.packaging !== \"fec-repair\"),\n\t\t...override.tracks.filter((t) => t.packaging === \"fec-repair\"),\n\t];\n\tfor (const ot of ordered) {\n\t\tconst existing = byName.get(ot.name);\n\t\tif (existing !== undefined) {\n\t\t\t// Preserve publisher-emitted fec + framerate \u2014 those describe what\n\t\t\t// is actually on the wire. Overwriting with fixture values causes\n\t\t\t// the player's FEC manager to wait for symbols that never arrive\n\t\t\t// when the fixture's K/P don't match the publisher's.\n\t\t\tif (existing.fec === undefined && ot.fec !== undefined) existing.fec = ot.fec;\n\t\t\tif (existing.framerate === undefined && ot.framerate !== undefined) {\n\t\t\t\texisting.framerate = ot.framerate;\n\t\t\t}\n\t\t\tif (ot.role !== undefined && existing.role === undefined) existing.role = ot.role;\n\t\t\tif (existing.packaging === \"mmtp\") {\n\t\t\t\tconst mode = existing.mmtpMode ?? ot.mmtpMode;\n\t\t\t\tif (mode !== \"mfu\") {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid mmtpMode`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\texisting.mmtpMode = mode;\n\t\t\t\tif (existing.timescale === undefined && ot.timescale !== undefined) existing.timescale = ot.timescale;\n\t\t\t\tif (existing.groupDurationMs === undefined && ot.groupDurationMs !== undefined) {\n\t\t\t\t\texisting.groupDurationMs = ot.groupDurationMs;\n\t\t\t\t}\n\t\t\t\tif (!isPositiveInteger(existing.timescale)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid timescale`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!isPositiveInteger(existing.groupDurationMs)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid groupDurationMs`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst packaging = ot.packaging ?? derivedPackaging;\n\t\t\tif (typeof packaging !== \"string\" || packaging.length === 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has no packaging \u2014 supply per-track or set top-level streamingFormat`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Role inference: repair tracks stay role-less per CMSF convention;\n\t\t\t// others default to video. Decided by packaging, never by name.\n\t\t\tconst isRepair = packaging === \"fec-repair\";\n\t\t\t// Same rule as the hang path: only a repair track its source names.\n\t\t\tif (isRepair && !namesRepairTrack(byName.get(ot.source as string)?.fec, ot.name, ot.instanceId)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst role = ot.role ?? (isRepair ? undefined : \"video\");\n\t\t\tconst inheritedCodec =\n\t\t\t\trole === \"audio\" ? existingAudioTrack?.codec : existingVideoTrack?.codec;\n\t\t\tconst codec = ot.codec ?? inheritedCodec;\n\t\t\tif (packaging !== \"timeline\" && !isRepair && (typeof codec !== \"string\" || codec.length === 0)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has no codec (packaging='${packaging}') \u2014 supply per-track or ensure the publisher catalog has a ${role ?? \"video\"} track to inherit from`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst mmtpMode = ot.mmtpMode;\n\t\t\tif (packaging === \"mmtp\" && mmtpMode !== \"mfu\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid mmtpMode`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (packaging === \"mmtp\" && !isPositiveInteger(ot.timescale)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid timescale`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (packaging === \"mmtp\" && !isPositiveInteger(ot.groupDurationMs)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid groupDurationMs`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst entry: CmsfTrackJson = { name: ot.name, packaging };\n\t\t\tif (codec !== undefined && !isRepair) entry.codec = codec as string;\n\t\t\tif (ot.source !== undefined) entry[\"source\"] = ot.source;\n\t\t\tif (ot.instanceId !== undefined) entry[\"instanceId\"] = ot.instanceId;\n\t\t\t// Block geometry on a repair track costs its instance FEC (rule 1).\n\t\t\tif (mmtpMode !== undefined && !isRepair) entry.mmtpMode = mmtpMode;\n\t\t\tif (ot.timescale !== undefined && !isRepair) entry.timescale = ot.timescale;\n\t\t\tif (ot.groupDurationMs !== undefined && !isRepair) entry.groupDurationMs = ot.groupDurationMs;\n\t\t\tif (role !== undefined) entry.role = role;\n\t\t\tif (ot.framerate !== undefined) entry.framerate = ot.framerate;\n\t\t\tif (ot.fec !== undefined) entry.fec = ot.fec;\n\t\t\ttracks.push(entry);\n\t\t\tbyName.set(ot.name, entry);\n\t\t}\n\t}\n\treturn tracks;\n}\n"],
5
- "mappings": ";AA+FO,SAAS,4BAA2D;AAG1E,QAAM,IAAI;AACV,QAAM,MAAM,EAAE,4BAA4B;AAC1C,MAAI,QAAQ,UAAa,QAAQ,KAAM,QAAO;AAC9C,MAAI,OAAO,QAAQ,UAAU;AAC5B,YAAQ,KAAK,4DAA4D;AACzE,WAAO;AAAA,EACR;AACA,QAAM,MAAM;AACZ,QAAM,SAAS,IAAI,QAAQ;AAC3B,MAAI,CAAC,MAAM,QAAQ,MAAM,GAAG;AAC3B,YAAQ,KAAK,kEAAkE;AAC/E,WAAO;AAAA,EACR;AAGA,QAAM,WAAmC,CAAC;AAC1C,aAAW,KAAK,QAAQ;AACvB,QAAI,OAAO,MAAM,YAAY,MAAM,MAAM;AACxC,YAAM,QAAQ;AACd,UAAI,OAAO,MAAM,MAAM,MAAM,YAAa,MAAM,MAAM,EAAa,SAAS,GAAG;AAC9E,iBAAS,KAAK,KAAwC;AAAA,MACvD;AAAA,IACD;AAAA,EACD;AACA,MAAI,SAAS,WAAW,EAAG,QAAO;AAClC,SAAO;AAAA,IACN,SAAS,OAAO,IAAI,SAAS,MAAM,WAAY,IAAI,SAAS,IAAe;AAAA,IAC3E,iBACC,OAAO,IAAI,iBAAiB,MAAM,WAAY,IAAI,iBAAiB,IAAe;AAAA,IACnF,QAAQ;AAAA,EACT;AACD;AAuBO,SAAS,gCACf,SACA,UACI;AACJ,MAAI,CAAC,SAAU,QAAO;AAEtB,aAAW,SAAS,SAAS,QAAQ;AAEpC,QAAI,MAAM,cAAc,aAAc;AAGtC,UAAM,OACL,MAAM,SAAS,WAAW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AA,MACD;AACA,UAAI,cAAc,UAAU,CAAC,kBAAkB,GAAG,SAAS,GAAG;AAC7D,cAAM,IAAI;AAAA,UACT,qCAAqC,GAAG,IAAI;AAAA,QAC7C;AAAA,MACD;AACA,UAAI,cAAc,UAAU,CAAC,kBAAkB,GAAG,eAAe,GAAG;AACnE,cAAM,IAAI;AAAA,UACT,qCAAqC,GAAG,IAAI;AAAA,QAC7C;AAAA,MACD;AACA,YAAM,QAAuB,EAAE,MAAM,GAAG,MAAM,UAAU;AACxD,UAAI,UAAU,UAAa,CAAC,SAAU,OAAM,QAAQ;AACpD,UAAI,GAAG,WAAW,OAAW,OAAM,QAAQ,IAAI,GAAG;AAClD,UAAI,GAAG,eAAe,OAAW,OAAM,YAAY,IAAI,GAAG;AAE1D,UAAI,aAAa,UAAa,CAAC,SAAU,OAAM,WAAW;AAC1D,UAAI,GAAG,cAAc,UAAa,CAAC,SAAU,OAAM,YAAY,GAAG;AAClE,UAAI,GAAG,oBAAoB,UAAa,CAAC,SAAU,OAAM,kBAAkB,GAAG;AAC9E,UAAI,SAAS,OAAW,OAAM,OAAO;AACrC,UAAI,GAAG,cAAc,OAAW,OAAM,YAAY,GAAG;AACrD,UAAI,GAAG,QAAQ,OAAW,OAAM,MAAM,GAAG;AACzC,aAAO,KAAK,KAAK;AACjB,aAAO,IAAI,GAAG,MAAM,KAAK;AAAA,IAC1B;AAAA,EACD;AACA,SAAO;AACR;",
3
+ "sources": ["../../mmt-base/src/mmtp.ts", "../../mmt-base/src/ntp-short.ts", "../../mmt-base/src/fec-block-profile.ts", "../../mmt-base/src/fec-bindings.ts", "../../mmt-base/src/mmtp-siblings.ts", "../../mmt-base/src/datagram-leg-size.ts", "../src/phase14-catalog-override.ts"],
4
+ "sourcesContent": ["/**\n * @mmt/container - MMTP Parser\n *\n * MMTP (MMT Protocol) packet parser based on ISO/IEC 23008-1:2023 Section 9.2\n *\n * MMTP header format (12 bytes):\n * - Byte 0: V(2) | C(1) | FEC_type(2) | r(1) | X(1) | R(1)\n * - Byte 1: reserved(2) | packet_type(6)\n * - Bytes 2-3: packet_id (big-endian)\n * - Bytes 4-7: timestamp (big-endian, 32-bit)\n * - Bytes 8-11: sequence_number (big-endian)\n *\n * FEC_type values:\n * - 0: No FEC / source packet\n * - 1: FEC mode 0 (source with FEC payload ID)\n * - 2: FEC repair packet mode 0\n * - 3: FEC repair packet mode 1\n *\n * @packageDocumentation\n */\n\nexport interface MMTPHeader {\n version: number\n /** Packet type: 0x00=MPU, 0x02=Signaling, 0x03=Repair */\n packetType: number\n packetId: number\n timestamp: bigint\n sequenceNumber: number\n payloadLength: number\n fecType: number\n /** C flag: header carries a 32-bit packet_counter. */\n packetCounterFlag: boolean\n packetCounter?: number\n /** X flag: header carries an extension header and value. */\n extensionFlag: boolean\n extension?: { type: number; data: Uint8Array }\n /** Byte offset at which the MMTP payload begins. */\n headerLength: number\n /** Random Access Point flag - indicates keyframe (ISO 23008-1, byte 0 bit 0) */\n rapFlag: boolean\n}\n\nexport interface MPUHeader {\n mpuSequenceNumber: number\n fragmentationIndicator: number // FI: 0=complete, 1=first, 2=middle, 3=last\n /** 8-bit MPU fragment_counter from byte 3. */\n fragmentCounter: number\n /** T flag: 1=timed media (14-byte MFU DU header), 0=non-timed (4-byte header) */\n timedFlag: number\n /** A flag: aggregated MPU payload. This strict profile requires A=0. */\n aggregationFlag: boolean\n /** MPU payload_length (bytes 0-1): bytes after the length field, including\n * the remaining six MPU-header bytes and all data-unit bytes. */\n payloadLength: number\n}\n\nexport interface MFUDuHeader {\n movieFragmentSequenceNumber: number\n sampleNumber: number\n offset: number\n priority: number\n dependencyCounter: number\n}\n\nexport interface MMTPPacket {\n header: MMTPHeader\n payload: Uint8Array\n}\n\nexport const MMTP_HEADER_SIZE = 12\nexport const MPU_HEADER_SIZE = 8\nexport const MFU_DU_HEADER_SIZE_TIMED = 14 // T=1: timed media (video/audio samples)\nexport const MFU_DU_HEADER_SIZE_NONTIMED = 4 // T=0: non-timed media (item_id only)\n\nconst MPU_LENGTH_FIELD_SIZE = 2\nconst MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE\nexport const SOURCE_FEC_PAYLOAD_ID_SIZE = 4\n\n// MMTP Packet Types (ISO/IEC 23008-1:2023 Section 9.2.2)\nexport const PACKET_TYPE_MPU = 0x00\nexport const PACKET_TYPE_SIGNALING = 0x02\nexport const PACKET_TYPE_REPAIR = 0x03\n\n// AL-FEC Signaling Message ID (ISO/IEC 23008-1:2023 Amendment 1:2025)\nexport const ALFEC_MESSAGE_ID = 0x0203\n\n/**\n * MMTP `packet_id` of the signaling flow, which carries PACKET_TYPE_SIGNALING\n * packets such as the AL-FEC message (ALFEC_MESSAGE_ID). The FFmpeg `moq_mmt`\n * muxer sends that message on this packet_id into the same multicast group as\n * the media, and moqcast-draft (PR #44) makes advertising it for a track a\n * MUST NOT. A track's packet_id is therefore 1..MMTP_PACKET_ID_MAX.\n */\nexport const MMTP_SIGNALING_PACKET_ID = 0\n\n/** Largest value of the 16-bit MMTP `packet_id` header field. */\nexport const MMTP_PACKET_ID_MAX = 0xffff\n\n// fec_code_id_for_repair_flow code points (ISO/IEC 23008-10 Table 1;\n// draft-ramadan-moq-mmt-01 Section 8.3).\nexport const FEC_CODE_REED_SOLOMON = 1\nexport const FEC_CODE_RAPTORQ = 3\n\n/**\n * Parse MMTP header from buffer\n */\nexport function parseMMTPHeader(buffer: Uint8Array): MMTPHeader {\n if (buffer.length < MMTP_HEADER_SIZE) {\n throw new Error(`MMTP packet too small: ${buffer.length} bytes`)\n }\n\n const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)\n\n const version = (buffer[0]! >> 6) & 0x03\n if (version !== 0) {\n throw new Error(`Unsupported MMTP version: ${version}`)\n }\n\n // Extract FEC type from byte 0, bits 3-4\n const fecType = (buffer[0]! >> 3) & 0x03\n const packetCounterFlag = (buffer[0]! & 0x20) !== 0\n const extensionFlag = (buffer[0]! & 0x02) !== 0\n\n // Extract RAP flag from byte 0, bit 0 (R bit - Random Access Point)\n const rapFlag = (buffer[0]! & 0x01) === 1\n\n // ISO/IEC 23008-1:2023 Figure 8 (V=0) places reserved(2) before\n // packet_type(6), so packet_type occupies the low six bits of byte 1.\n const packetType = buffer[1]! & 0x3F\n\n let offset = 2\n\n // Packet ID (2 bytes, big-endian)\n const packetId = view.getUint16(offset, false)\n offset += 2\n\n // Timestamp (4 bytes, big-endian)\n const timestamp = BigInt(view.getUint32(offset, false))\n offset += 4\n\n // Sequence number (4 bytes, big-endian)\n const sequenceNumber = view.getUint32(offset, false)\n offset += 4\n\n let packetCounter: number | undefined\n if (packetCounterFlag) {\n if (offset + 4 > buffer.length) throw new Error('MMTP packet truncated in packet_counter')\n packetCounter = view.getUint32(offset, false)\n offset += 4\n }\n\n let extension: { type: number; data: Uint8Array } | undefined\n if (extensionFlag) {\n if (offset + 4 > buffer.length) throw new Error('MMTP packet truncated in header extension')\n const type = view.getUint16(offset, false)\n const length = view.getUint16(offset + 2, false)\n offset += 4\n if (offset + length > buffer.length) throw new Error('MMTP packet truncated in header extension value')\n extension = { type, data: buffer.subarray(offset, offset + length) }\n offset += length\n }\n\n return {\n version,\n packetType,\n packetId,\n timestamp,\n sequenceNumber,\n payloadLength: buffer.length - offset,\n fecType,\n packetCounterFlag,\n packetCounter,\n extensionFlag,\n extension,\n headerLength: offset,\n rapFlag,\n }\n}\n\n/**\n * The MMTP `packet_id` of `buffer`, or null exactly when parseMMTPHeader would\n * throw for it (short buffer, V != 0, truncated packet_counter or header\n * extension).\n *\n * This is the per-packet filter a receiver runs before any other work, so it\n * builds no header object, DataView or BigInt timestamp (BLO-36599). Use\n * parseMMTPHeader when any other header field is needed.\n */\nexport function readMMTPPacketId(buffer: Uint8Array): number | null {\n if (buffer.length < MMTP_HEADER_SIZE) return null\n const flags = buffer[0]!\n if (((flags >> 6) & 0x03) !== 0) return null\n let offset = MMTP_HEADER_SIZE\n if ((flags & 0x20) !== 0) {\n if (offset + 4 > buffer.length) return null\n offset += 4\n }\n if ((flags & 0x02) !== 0) {\n if (offset + 4 > buffer.length) return null\n const length = (buffer[offset + 2]! << 8) | buffer[offset + 3]!\n if (offset + 4 + length > buffer.length) return null\n }\n return (buffer[2]! << 8) | buffer[3]!\n}\n\n/**\n * Unwrap MMTP packet to extract payload\n */\nexport function unwrapMMTP(buffer: Uint8Array): MMTPPacket {\n const header = parseMMTPHeader(buffer)\n const payload = buffer.subarray(header.headerLength)\n\n return { header, payload }\n}\n\n/**\n * Parse MPU header from payload\n * ISO/IEC 23008-1:2023 Section 9.2.3.3\n *\n * MPU Header format (8 bytes) as written by FFmpeg/libmmt:\n * - Bytes 0-1: payload_length (16 bits, big-endian)\n * - Byte 2: FT(4) | T(1) | FI(2) | A(1)\n * - Byte 3: fragment_counter (8 bits)\n * - Bytes 4-7: MPU_sequence_number (32 bits, big-endian)\n */\nexport function parseMPUHeader(payload: Uint8Array): MPUHeader {\n if (payload.length < MPU_HEADER_SIZE) {\n throw new Error(`Payload too small for MPU header: ${payload.length} bytes`)\n }\n\n const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength)\n\n // Bytes 0-1: payload_length (16 bits, big-endian)\n const payloadLength = view.getUint16(0, false)\n\n // Byte 2: FT(4) | T(1) | FI(2) | A(1)\n const flagsByte = payload[2]!\n const timedFlag = (flagsByte >> 3) & 0x01\n const fragmentationIndicator = (flagsByte >> 1) & 0x03\n const aggregationFlag = (flagsByte & 0x01) !== 0\n\n // Byte 3: fragment_counter (8 bits). The high bit is part of the counter in\n // the current libmmt/FFmpeg writer ABI.\n const fragmentCounter = payload[3]!\n\n // Bytes 4-7: MPU_sequence_number (32 bits, big-endian)\n const mpuSequenceNumber = view.getUint32(4, false)\n\n return {\n mpuSequenceNumber,\n fragmentationIndicator,\n fragmentCounter,\n timedFlag,\n aggregationFlag,\n payloadLength,\n }\n}\n\nexport function parseTimedMfuDuHeader(payload: Uint8Array, offset: number): MFUDuHeader | null {\n if (offset < 0 || offset + MFU_DU_HEADER_SIZE_TIMED > payload.length) return null\n const view = new DataView(payload.buffer, payload.byteOffset + offset, MFU_DU_HEADER_SIZE_TIMED)\n return {\n movieFragmentSequenceNumber: view.getUint32(0, false),\n sampleNumber: view.getUint32(4, false),\n offset: view.getUint32(8, false),\n priority: payload[offset + 12]!,\n dependencyCounter: payload[offset + 13]!,\n }\n}\n\n/**\n * Why `extractMFUPayload` refused a packet.\n *\n * These identifiers are part of the public contract: callers surface them in\n * diagnostics, so renaming one is a breaking change.\n */\nexport type MFURejectionGate =\n | 'packet-shorter-than-mmtp-plus-mpu-header'\n | 'mmtp-header-unparseable'\n | 'not-an-mpu-packet'\n | 'payload-shorter-than-mpu-header'\n | 'aggregation-flag-set'\n | 'mpu-payload-length-below-header-remainder'\n | 'mpu-declared-end-exceeds-payload'\n | 'mfu-offset-at-or-past-declared-end'\n | 'source-fec-payload-id-width-mismatch'\n | 'declared-trailers-unresolved'\n\nexport interface MFURejection {\n gate: MFURejectionGate\n /** Human-readable detail, including the byte arithmetic that decided it. */\n detail: string\n}\n\ninterface MfuPayloadLayout {\n hasMfuDuHeader: boolean\n mfuOffset: number\n dataEnd: number\n}\n\nfunction resolveMfuPayloadLayout(\n mpu: MPUHeader,\n fragmentType: number,\n payload: Uint8Array,\n): { layout: MfuPayloadLayout } | { rejection: MFURejection } {\n if (mpu.payloadLength < MPU_HEADER_REMAINDER_SIZE) {\n return {\n rejection: {\n gate: 'mpu-payload-length-below-header-remainder',\n detail: `payload_length=${mpu.payloadLength} < ${MPU_HEADER_REMAINDER_SIZE}`,\n },\n }\n }\n\n // ISO/IEC 23008-1 defines payload_length from immediately after its own\n // two-byte field. It therefore includes the remaining six MPU-header bytes.\n const declaredEnd = MPU_LENGTH_FIELD_SIZE + mpu.payloadLength\n if (declaredEnd > payload.length) {\n return {\n rejection: {\n gate: 'mpu-declared-end-exceeds-payload',\n detail:\n `payload_length=${mpu.payloadLength} implies end=${declaredEnd}, ` +\n `payload is ${payload.length} bytes`,\n },\n }\n }\n\n const hasHeader = fragmentType === 2 && mpu.fragmentationIndicator <= 1\n const mfuHeaderSize = mpu.timedFlag ? MFU_DU_HEADER_SIZE_TIMED : MFU_DU_HEADER_SIZE_NONTIMED\n const mfuOffset = MPU_HEADER_SIZE + (hasHeader ? mfuHeaderSize : 0)\n if (mfuOffset >= declaredEnd) {\n return {\n rejection: {\n gate: 'mfu-offset-at-or-past-declared-end',\n detail: `mfuOffset=${mfuOffset} >= declaredEnd=${declaredEnd}`,\n },\n }\n }\n\n return {\n layout: {\n hasMfuDuHeader: hasHeader,\n mfuOffset,\n dataEnd: declaredEnd,\n },\n }\n}\n\n// Legacy detached per-packet authenticator suffix `[0xf0a1][len][auth]`. Its\n// producer was removed (BLO-16483) and nothing verifies it any more; provenance\n// is the signed per-group manifest. Receivers still skip an exact suffix so a\n// stale producer degrades to unauthenticated playback instead of dropped\n// packets. ponytail: hard-cut to reject once no deployed producer can emit it.\nconst LEGACY_TRAILER_EXT_TYPE = 0xf0a1\nconst LEGACY_TRAILER_HEADER_SIZE = 4\n\nfunction isEmptyOrExactLegacyTrailer(payload: Uint8Array, start: number, end: number): boolean {\n if (start === end) return true\n if (start < 0 || end > payload.length || start + LEGACY_TRAILER_HEADER_SIZE > end) {\n return false\n }\n\n const view = new DataView(\n payload.buffer,\n payload.byteOffset + start,\n end - start,\n )\n if (view.getUint16(0, false) !== LEGACY_TRAILER_EXT_TYPE) return false\n\n const authLength = view.getUint16(2, false)\n return start + LEGACY_TRAILER_HEADER_SIZE + authLength === end\n}\n\ninterface DeclaredTrailerLayout {\n hasFecId: boolean\n}\n\n/** Options for extractMFUPayload and explainMFURejection. */\nexport interface MFUExtractOptions {\n /**\n * When true, do NOT subtract the Source FEC Payload ID from the payload\n * boundary, even if fecType >= 1. For FEC-recovered symbols whose FEC PID\n * was already stripped before WASM decoding.\n */\n skipFecId?: boolean\n}\n\nfunction resolveDeclaredTrailers(\n payload: Uint8Array,\n declaredEnd: number,\n fecType: number,\n options?: MFUExtractOptions,\n): DeclaredTrailerLayout | null {\n if (declaredEnd > payload.length) return null\n\n if (options?.skipFecId) {\n return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)\n ? { hasFecId: false }\n : null\n }\n\n if (fecType === 1) {\n const fecStart = payload.length - SOURCE_FEC_PAYLOAD_ID_SIZE\n if (fecStart < declaredEnd || !isEmptyOrExactLegacyTrailer(payload, declaredEnd, fecStart)) {\n return null\n }\n return { hasFecId: true }\n }\n if (fecType !== 0) return null\n\n if (isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)) {\n return { hasFecId: false }\n }\n\n return null\n}\n\n/**\n * Extract NAL unit payload from MMTP packet\n */\nexport function extractNALUnit(mmtpPacket: Uint8Array): Uint8Array {\n const extraction = extractMFUPayload(mmtpPacket)\n if (!extraction) throw new Error('Malformed MMTP MPU payload')\n return extraction.data\n}\n\n/** Result of extracting MFU payload from an MMTP packet */\nexport interface MFUExtraction {\n /** MMTP header fields */\n header: MMTPHeader\n /** MPU header fields */\n mpu: MPUHeader\n /** Fragment type (FT field, 4 bits): 0=metadata, 2=MFU data */\n fragmentType: number\n /** MFU payload data (video/audio bytes, headers stripped, FEC ID excluded) */\n data: Uint8Array\n /** Parsed timed MFU DU header when present, otherwise null */\n mfuDuHeader: MFUDuHeader | null\n /** Non-timed MFU Item_ID when the 4-byte DU header is present. */\n itemId: number | null\n /** Source FEC Payload ID if present (`FEC_type == 1`), or null */\n fecPayloadId: { ssId: number } | null\n}\n\n/**\n * Extract MFU payload from a raw MMTP packet.\n *\n * Handles all the byte arithmetic for:\n * - MMTP header (12 bytes)\n * - MPU sub-header (8 bytes, payloadLength field)\n * - MFU DU header (14 bytes timed / 4 bytes non-timed, only for FI \u2264 1)\n * - Source FEC Payload ID (4 bytes at end, only when `FEC_type == 1`)\n *\n * `payloadLength` is the ISO length-after-field value: six remaining MPU-header\n * bytes, then the MFU DU header when present, then media. The legacy\n * authenticator suffix and the Source FEC trailer are outside that declared span and must consume the exact suffix.\n *\n * @param mmtpPacket Raw MMTP packet (from multicast or MoQ)\n * @param options.skipFecId When true, do NOT subtract the 4-byte Source FEC Payload ID\n * from the payload boundary, even if fecType >= 1 in the MMTP header. Use this for\n * FEC-recovered symbols where the FEC PID was already stripped before WASM decoding\n * but the fecType bits in byte 0 still reflect the original packet (FEC Type=1 per\n * draft-ramadan-moq-mmt-01 \u00A73.1).\n * @returns Extracted MFU data + metadata, or null if packet is too small\n */\ninterface MfuPlan {\n header: MMTPHeader\n payload: Uint8Array\n mpu: MPUHeader\n fragmentType: number\n layout: MfuPayloadLayout\n trailerLayout: DeclaredTrailerLayout\n}\n\n/**\n * Single source of truth for whether a packet yields an MFU payload.\n *\n * `extractMFUPayload` and `explainMFURejection` both delegate here, so the\n * reason reported to operators can never drift from the decision the parser\n * actually made.\n */\nfunction planMfuExtraction(\n mmtpPacket: Uint8Array,\n options?: MFUExtractOptions,\n parsedHeader?: MMTPHeader,\n): { plan: MfuPlan } | { rejection: MFURejection } {\n if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE) {\n return {\n rejection: {\n gate: 'packet-shorter-than-mmtp-plus-mpu-header',\n detail: `${mmtpPacket.length} bytes < ${MMTP_HEADER_SIZE + MPU_HEADER_SIZE}`,\n },\n }\n }\n\n let header: MMTPHeader\n if (parsedHeader) {\n header = parsedHeader\n } else {\n try {\n header = parseMMTPHeader(mmtpPacket)\n } catch (error) {\n return {\n rejection: {\n gate: 'mmtp-header-unparseable',\n detail: error instanceof Error ? error.message : String(error),\n },\n }\n }\n }\n if (header.packetType !== PACKET_TYPE_MPU) {\n return {\n rejection: {\n gate: 'not-an-mpu-packet',\n detail: `packetType=0x${header.packetType.toString(16).padStart(2, '0')}`,\n },\n }\n }\n\n const payload = mmtpPacket.subarray(header.headerLength)\n if (payload.length < MPU_HEADER_SIZE) {\n return {\n rejection: {\n gate: 'payload-shorter-than-mpu-header',\n detail: `${payload.length} bytes < ${MPU_HEADER_SIZE}`,\n },\n }\n }\n\n const mpu = parseMPUHeader(payload)\n if (mpu.aggregationFlag) {\n return {\n rejection: { gate: 'aggregation-flag-set', detail: 'strict profile requires A=0' },\n }\n }\n\n // Fragment type from byte 2 upper nibble (not returned by parseMPUHeader)\n const fragmentType = (payload[2]! >> 4) & 0x0f\n\n const layoutResult = resolveMfuPayloadLayout(mpu, fragmentType, payload)\n if ('rejection' in layoutResult) return layoutResult\n const { layout } = layoutResult\n\n const trailerLayout = resolveDeclaredTrailers(\n payload,\n layout.dataEnd,\n header.fecType,\n options,\n )\n if (!trailerLayout) {\n // The most common cause is a producer whose Source FEC Payload ID width\n // disagrees with ISO/IEC 23008-1 \u00A7C.5.2. Name that explicitly rather than\n // leaving operators to infer it from a generic trailer error.\n if (!options?.skipFecId && header.fecType === 1) {\n const observed = payload.length - layout.dataEnd\n const expected = SOURCE_FEC_PAYLOAD_ID_SIZE\n if (observed !== expected) {\n return {\n rejection: {\n gate: 'source-fec-payload-id-width-mismatch',\n detail:\n `producer wrote a ${observed}-byte Source FEC Payload ID, ` +\n `ISO/IEC 23008-1 \u00A7C.5.2 requires ${expected} ` +\n `(payload=${payload.length}, declaredEnd=${layout.dataEnd})`,\n },\n }\n }\n }\n return {\n rejection: {\n gate: 'declared-trailers-unresolved',\n detail:\n `trailer bytes [${layout.dataEnd}, ${payload.length}) are neither empty ` +\n `nor an exact legacy authenticator trailer (fecType=${header.fecType})`,\n },\n }\n }\n\n return { plan: { header, payload, mpu, fragmentType, layout, trailerLayout } }\n}\n\n/**\n * Report why `extractMFUPayload` would refuse this packet, or null if it would\n * accept it.\n *\n * `extractMFUPayload` returns bare `null` on ten distinct conditions, which\n * makes a producer/consumer framing disagreement indistinguishable from a\n * publisher that never started \u2014 both render as silence. Use this wherever\n * that distinction matters: diagnostics, contract tests, and operator-facing\n * logs.\n */\nexport function explainMFURejection(\n mmtpPacket: Uint8Array,\n options?: MFUExtractOptions,\n): MFURejection | null {\n const result = planMfuExtraction(mmtpPacket, options)\n return 'rejection' in result ? result.rejection : null\n}\n\nexport function extractMFUPayload(\n mmtpPacket: Uint8Array,\n options?: MFUExtractOptions,\n): MFUExtraction | null {\n return extractPlannedMfu(mmtpPacket, planMfuExtraction(mmtpPacket, options))\n}\n\n/**\n * extractMFUPayload for a caller that already holds this packet's parsed MMTP\n * header, so the header is not parsed a second time (BLO-36599).\n *\n * `header` must be `parseMMTPHeader(mmtpPacket)` of this same packet; the\n * result is then identical to `extractMFUPayload(mmtpPacket, options)`.\n */\nexport function extractMFUPayloadWithHeader(\n mmtpPacket: Uint8Array,\n header: MMTPHeader,\n options?: MFUExtractOptions,\n): MFUExtraction | null {\n return extractPlannedMfu(mmtpPacket, planMfuExtraction(mmtpPacket, options, header))\n}\n\nfunction extractPlannedMfu(\n mmtpPacket: Uint8Array,\n result: { plan: MfuPlan } | { rejection: MFURejection },\n): MFUExtraction | null {\n if ('rejection' in result) return null\n const { header, payload, mpu, fragmentType, layout, trailerLayout } = result.plan\n\n const mfuDuHeaderPresent = layout.hasMfuDuHeader\n const mfuOffset = layout.mfuOffset\n const dataEnd = layout.dataEnd\n\n const mfuDuHeader =\n mfuDuHeaderPresent && mpu.timedFlag === 1\n ? parseTimedMfuDuHeader(payload, MPU_HEADER_SIZE)\n : null\n const itemId =\n mfuDuHeaderPresent && mpu.timedFlag === 0\n ? new DataView(payload.buffer, payload.byteOffset + MPU_HEADER_SIZE, 4).getUint32(0, false)\n : null\n\n const data = payload.subarray(mfuOffset, dataEnd)\n\n const fecPayloadId = trailerLayout.hasFecId\n ? {\n ssId: new DataView(\n mmtpPacket.buffer,\n mmtpPacket.byteOffset + mmtpPacket.length - SOURCE_FEC_PAYLOAD_ID_SIZE,\n 4,\n ).getUint32(0, false),\n }\n : null\n\n return { header, mpu, fragmentType, data, mfuDuHeader, itemId, fecPayloadId }\n}\n\n/**\n * Extract timestamp from MMTP packet\n */\nexport function extractTimestamp(mmtpPacket: Uint8Array): bigint {\n const { header } = unwrapMMTP(mmtpPacket)\n return header.timestamp\n}\n\n/**\n * Check if MMTP packet is an FEC repair packet\n * FEC_type 2 and 3 are repair packets\n */\nexport function isFecRepairPacket(mmtpPacket: Uint8Array): boolean {\n if (mmtpPacket.length < 1) return false\n const fecType = (mmtpPacket[0]! >> 3) & 0x03\n return fecType >= 2\n}\n\n/**\n * Extract Source FEC Payload ID (SS_ID) from the last 4 bytes of an MMTP\n * source packet per ISO/IEC 23008-1:2023 Section C.5.2 Figure C.10.\n *\n * SS_ID is a flat 32-bit monotonic counter (incremented by 1 per packet\n * for ssbg_mode0 and ssbg_mode1). Block membership and ESI use the\n * configured K; repair SS_Start identifies the first SS_ID of the block and\n * SSB_length records the authored source-symbol count:\n * SBN = floor(SS_ID / K), ESI = SS_ID % K\n * SS_Start = SBN * K (first SS_ID of the block)\n *\n * This matches FFmpeg moqenc_mmt.c, the drafts (draft-ramadan-moq-fec \u00A76.2),\n * and ATSC A/331 \u00A78.1.2.5 which defers to ISO 23008-1 Annex C.\n */\nexport function extractFecPayloadId(mmtpPacket: Uint8Array): { ssId: number } | null {\n const header = parseHeaderForSourceFecId(mmtpPacket)\n return header ? sourceFecPayloadIdOf(mmtpPacket, header) : null\n}\n\n/**\n * Return true when FEC_type=1 and the exact suffix after the ISO-declared MPU\n * payload contains a four-byte Source FEC Payload ID.\n */\nexport function hasSourceFecPayloadId(mmtpPacket: Uint8Array): boolean {\n const header = parseHeaderForSourceFecId(mmtpPacket)\n return header !== null && sourceFecPayloadIdOf(mmtpPacket, header) !== null\n}\n\nfunction parseHeaderForSourceFecId(mmtpPacket: Uint8Array): MMTPHeader | null {\n if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE) return null\n try {\n return parseMMTPHeader(mmtpPacket)\n } catch {\n return null\n }\n}\n\n/**\n * The Source FEC Payload ID of a packet whose MMTP header the caller already\n * parsed, or null when the packet carries none: present only when FEC_type=1\n * and the exact suffix after the ISO-declared MPU payload holds the four-byte\n * ID (ISO/IEC 23008-1 \u00A7C.5.2). Same answer as extractFecPayloadId, without a\n * second header parse (BLO-36599).\n *\n * `header` must be `parseMMTPHeader(mmtpPacket)` of this same packet.\n */\nexport function sourceFecPayloadIdOf(\n mmtpPacket: Uint8Array,\n header: MMTPHeader,\n): { ssId: number } | null {\n if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE) return null\n if (header.packetType !== PACKET_TYPE_MPU) return null\n\n const payload = mmtpPacket.subarray(header.headerLength)\n if (payload.length < MPU_HEADER_SIZE) return null\n const payloadLength = (payload[0]! << 8) | payload[1]!\n if (payloadLength < MPU_HEADER_REMAINDER_SIZE) return null\n const declaredEnd = MPU_LENGTH_FIELD_SIZE + payloadLength\n if (!resolveDeclaredTrailers(payload, declaredEnd, header.fecType)?.hasFecId) return null\n\n // Flat 4-byte SS_ID: encoder writes block_id * K + symbol_id\n const off = mmtpPacket.length - SOURCE_FEC_PAYLOAD_ID_SIZE\n return {\n ssId:\n ((mmtpPacket[off]! << 24) |\n (mmtpPacket[off + 1]! << 16) |\n (mmtpPacket[off + 2]! << 8) |\n mmtpPacket[off + 3]!) >>>\n 0,\n }\n}\n\n/** Size of Repair FEC Payload ID per ISO/IEC 23008-1 Section C.5.3 */\nexport const REPAIR_FEC_PID_SIZE = 13\n\n/**\n * Parse the 13-byte Repair FEC Payload ID after the complete dynamic MMTP header.\n * `parsedHeader`, when given, must be `parseMMTPHeader(mmtpPacket)` of this\n * same packet; it spares the second header parse (BLO-36599).\n */\nfunction readRepairFecPayloadIdFields(mmtpPacket: Uint8Array, parsedHeader?: MMTPHeader): {\n packetId: number; ssStart: number; rsbLength: number; rsId: number; ssbLength: number; dataOffset: number\n} | null {\n let header: MMTPHeader\n if (parsedHeader) {\n header = parsedHeader\n } else {\n try {\n header = parseMMTPHeader(mmtpPacket)\n } catch {\n return null\n }\n }\n if (header.packetType !== PACKET_TYPE_REPAIR || header.fecType !== 2) return null\n\n const off = header.headerLength\n if (mmtpPacket.length < off + REPAIR_FEC_PID_SIZE) return null\n const ssStart =\n ((mmtpPacket[off]! << 24) |\n (mmtpPacket[off + 1]! << 16) |\n (mmtpPacket[off + 2]! << 8) |\n mmtpPacket[off + 3]!) >>>\n 0 // 32 bits\n const rsbLength = (mmtpPacket[off + 4]! << 16) | (mmtpPacket[off + 5]! << 8) | mmtpPacket[off + 6]! // 24 bits\n const rsId = (mmtpPacket[off + 7]! << 16) | (mmtpPacket[off + 8]! << 8) | mmtpPacket[off + 9]! // 24 bits\n const ssbLength = (mmtpPacket[off + 10]! << 16) | (mmtpPacket[off + 11]! << 8) | mmtpPacket[off + 12]! // 24 bits\n return {\n packetId: header.packetId,\n ssStart,\n rsbLength,\n rsId,\n ssbLength,\n dataOffset: off + REPAIR_FEC_PID_SIZE,\n }\n}\n\n/**\n * Extract Repair FEC Payload ID from a raw-multicast MMTP repair packet.\n * Per ISO/IEC 23008-1:2023 Section C.5.3 (ssbg_mode0, one-stage, no FFSRP_TS):\n * [MMTP header][SS_Start:4][RSB_length:3][RS_ID:3][SSB_length:3][repair data]\n * OTI is delivered via AL-FEC signaling message (Table C.3), not per-packet.\n *\n * Byte 1 is reserved(2)|packet_type(6) for V=0, so repair type 0x03 is 0x03.\n * Pre-migration high-bits bytes (0x0c) are rejected \u2014 no compatibility decode.\n */\nexport function extractRepairFecPayloadId(mmtpPacket: Uint8Array): {\n ssStart: number; rsbLength: number; rsId: number; ssbLength: number\n} | null {\n const fields = readRepairFecPayloadIdFields(mmtpPacket)\n if (!fields) return null\n return {\n ssStart: fields.ssStart,\n rsbLength: fields.rsbLength,\n rsId: fields.rsId,\n ssbLength: fields.ssbLength,\n }\n}\n\n/** Parsed MoQ repair frame per ISO/IEC 23008-1 Section C.4.3 + C.5.3 */\nexport interface MoqRepairFrame {\n /** MMTP packetId (1=video, 2=audio) \u2014 for routing to correct FEC decoder */\n packetId: number\n /** SS_Start (32 bits): SS_ID of first source symbol in block */\n ssStart: number\n /** RSB_length (24 bits): number of repair symbols (P) */\n rsbLength: number\n /** RS_ID (24 bits): repair symbol index (0-based) */\n rsId: number\n /** SSB_length (24 bits): authored source-symbol count (1..=configured K) */\n ssbLength: number\n /** Repair symbol data after the dynamic MMTP header and 13-byte FEC payload ID. */\n symbolData: Uint8Array\n}\n\n/**\n * Parse a MoQ repair frame (ISO/IEC 23008-1 Annex C format).\n *\n * Wire format per ISO 23008-1 \u00A7C.4.3 + \u00A7C.5.3:\n * MMTP Header: fixed 12 bytes plus C/X optional fields\n * then SS_Start (4 bytes) \u2192 block identifier\n * then RSB_length (3 bytes) \u2192 P\n * then RS_ID (3 bytes) \u2192 ESI = K + RS_ID\n * then SSB_length (3 bytes) \u2192 authored source-symbol count (1..=K)\n * then Repair Symbol Data (T bytes)\n *\n * @param frame - Raw MoQ repair frame bytes\n * @returns Parsed frame or null if invalid\n */\nexport function parseMoqRepairFrame(frame: Uint8Array): MoqRepairFrame | null {\n return moqRepairFrameFrom(frame, readRepairFecPayloadIdFields(frame))\n}\n\n/**\n * parseMoqRepairFrame for a caller that already holds this frame's parsed MMTP\n * header, so the header is not parsed a second time (BLO-36599). The router's\n * multicast repair branch uses it: one repair packet in every K + P otherwise\n * paid two header parses.\n *\n * `header` must be `parseMMTPHeader(frame)` of this same frame; the result is\n * then identical to `parseMoqRepairFrame(frame)`.\n */\nexport function parseMoqRepairFrameWithHeader(\n frame: Uint8Array,\n header: MMTPHeader,\n): MoqRepairFrame | null {\n return moqRepairFrameFrom(frame, readRepairFecPayloadIdFields(frame, header))\n}\n\nfunction moqRepairFrameFrom(\n frame: Uint8Array,\n repairId: ReturnType<typeof readRepairFecPayloadIdFields>,\n checkRsId = true,\n): MoqRepairFrame | null {\n if (!repairId) return null\n\n const symbolData = frame.subarray(repairId.dataOffset)\n if (\n repairId.ssbLength === 0 ||\n (checkRsId && repairId.rsId >= repairId.rsbLength) ||\n symbolData.length === 0\n ) return null\n\n return {\n packetId: repairId.packetId,\n ssStart: repairId.ssStart,\n rsbLength: repairId.rsbLength,\n rsId: repairId.rsId,\n ssbLength: repairId.ssbLength,\n symbolData,\n }\n}\n\n/**\n * Why a repair object of an mmtp track is discarded on admission:\n * `repairLength` -- the object is not exactly 12 + 13 + T bytes with a\n * 12-byte MMTP header (C = 0, X = 0; draft-ramadan-moq-mmt-02 7.3, judged\n * before any Repair FEC Payload ID field is read); `repairRsId` -- RS_ID is not\n * below RSB_length, under every scheme; `repairSchemeBound` -- the object\n * breaks its scheme's bound: reed-solomon SSB_length + RSB_length > 255, which\n * also caps RS_ID at 253, or raptorq SSB_length + RSB_length - 1 > 2^24 - 1\n * (draft-ramadan-moq-fec-core-00 7.5 and 10.3, -block-codes-00 7).\n */\nexport type RepairObjectReject = 'repairLength' | 'repairRsId' | 'repairSchemeBound'\n\n/**\n * Admission of one mmtp repair object under its instance's T and scheme. The\n * caller names the instance (by the repair track it subscribed); nothing here\n * infers it from the fields. `repairRsId` and `repairSchemeBound` carry the\n * frame so the caller can first route an RSB_length below a held layer's\n * O_i + P_i to the 7.3.2 stop, which takes precedence over the discard.\n * `null`: not an iso repair packet, or SSB_length 0.\n */\nexport function admitMmtpRepairObject(\n packet: Uint8Array,\n header: MMTPHeader,\n symbolSize: number,\n algorithm: string | undefined,\n): { frame: MoqRepairFrame; reject?: Exclude<RepairObjectReject, 'repairLength'> } | { reject: 'repairLength' } | null {\n if (header.packetType !== PACKET_TYPE_REPAIR || header.fecType !== 2) return null\n if (header.headerLength !== MMTP_HEADER_SIZE || packet.length !== MMTP_HEADER_SIZE + REPAIR_FEC_PID_SIZE + symbolSize) {\n return { reject: 'repairLength' }\n }\n const frame = moqRepairFrameFrom(packet, readRepairFecPayloadIdFields(packet, header), false)\n if (!frame) return null\n if (frame.rsId >= frame.rsbLength) return { frame, reject: 'repairRsId' }\n const blockSymbols = frame.ssbLength + frame.rsbLength\n if (algorithm === 'reed-solomon' ? blockSymbols > 255 : algorithm === 'raptorq' && blockSymbols - 1 > 0xffffff) {\n return { frame, reject: 'repairSchemeBound' }\n }\n return { frame }\n}\n\n// The signalling-message parsers (9.3.4.2 payload header, AL-FEC message,\n// PA/MPT) live in ./signalling.ts.\n", "/**\n * NTP short format (RFC 5905 \u00A76): an unsigned 32-bit, 16.16 fixed-point count\n * of seconds. The MMTP header `timestamp` field (ISO/IEC 23008-1 \u00A79.2.2)\n * carries each packet's UTC sending instant in this format, so the value wraps\n * to 0 every 2^16 s (~18.2 h).\n *\n * Plain numeric order on these values breaks at every wrap: a retained\n * `Math.max` stays at the pre-wrap value and every later instant compares as\n * older. Order send times only with {@link compareNtpShort}, which applies\n * RFC 1982 serial-number arithmetic over the field's width.\n */\n\n/** Width in bits of the MMTP `timestamp` field (NTP short). */\nexport const NTP_SHORT_BITS = 32\n\n/** Number of distinct NTP-short values; the field wraps to 0 here. */\nexport const NTP_SHORT_MODULUS = 2 ** NTP_SHORT_BITS\n\n/**\n * RFC 1982 \u00A73.2's `2^(SERIAL_BITS - 1)`. Two values whose forward distance is\n * below this are ordered; exactly this far apart they are not ordered at all.\n * Two instants must be less than this far apart (2^15 s, ~9.1 h of send time)\n * for the comparison to give their true order.\n */\nexport const NTP_SHORT_HALF_RANGE = 2 ** (NTP_SHORT_BITS - 1)\n\n/**\n * Serial order of one NTP-short value relative to another.\n *\n * `'unordered'` is RFC 1982's undefined case: the values are exactly\n * {@link NTP_SHORT_HALF_RANGE} apart, so neither precedes the other. It is\n * never folded into `'before'` or `'after'`; each caller decides what an\n * unorderable pair means for it.\n */\nexport type NtpShortOrder = 'before' | 'equal' | 'after' | 'unordered'\n\n/** True when `value` is an NTP-short value: an integer in [0, NTP_SHORT_MODULUS). */\nexport function isNtpShort(value: number): boolean {\n return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS\n}\n\n/**\n * RFC 1982 serial comparison of NTP-short `a` against `b`: `'after'` when `a`\n * is the later instant, `'before'` when it is the earlier one.\n *\n * The answer is the true order only while the two instants are less than\n * {@link NTP_SHORT_HALF_RANGE} apart. Past that a 32-bit field cannot tell\n * later from earlier, and the result names whichever direction is nearer.\n * This is not a total order (it is not transitive across the whole space), so\n * it must never be used to sort.\n *\n * @throws {RangeError} if either operand is not an NTP-short value\n */\nexport function compareNtpShort(a: number, b: number): NtpShortOrder {\n if (!isNtpShort(a) || !isNtpShort(b)) {\n throw new RangeError(\n `NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS}), got ${String(a)} and ${String(b)}`,\n )\n }\n if (a === b) return 'equal'\n // Forward distance from b to a, reduced into [1, NTP_SHORT_MODULUS). Both\n // operands are below 2^32, so every step is exact in a double.\n const forward = (a - b + NTP_SHORT_MODULUS) % NTP_SHORT_MODULUS\n if (forward < NTP_SHORT_HALF_RANGE) return 'after'\n if (forward > NTP_SHORT_HALF_RANGE) return 'before'\n return 'unordered'\n}\n", "/**\n * FEC block profile (BLO-35597, ISO/IEC 23008-1 Annex C).\n *\n * Every catalog `fec` object that declares an FEC instance names its block\n * profile in `fec.blockProfile`. A receiver applies all of a profile's rules\n * or none of them, so the token is the one explicit per-stream discriminator:\n * it is never defaulted and never inferred from the wire.\n *\n * draft-ramadan-moq-fec \u00A75.1 defines exactly one value, and it is the only\n * profile this library implements:\n *\n * - `iso-ssbg1-v1`: ssbg_mode1 (C.3.3): a source symbol is\n * `u16 length || protected packet || zero padding` to T; a block is a\n * K' = SSB_length RaptorQ block (C.5.3) and repair ESI = SSB_length + RS_ID;\n * SS_ID increments by one per FEC source packet and wraps at 2^32 (C.5.2),\n * so a block is located by membership in `[SS_Start, SS_Start + SSB_length)`\n * under RFC 1982 serial arithmetic; the MoQ repair group id is the 62-bit\n * wrap-epoch-extended SS_Start. The AL-FEC coding byte for this profile is\n * 0x14 (one-stage, ssbg_mode1, fec_payload_id_mode 0, Amd 1:2025 Table C.3).\n *\n * A track whose `blockProfile` is absent or names any other token (the\n * retired Blockcast-private `k-padded-v1` included) has no FEC: a receiver\n * consumes its source without FEC and joins none of its repair tracks\n * (draft-ramadan-moq-fec \u00A75.1). `parseFecBlockProfile` throws for such a\n * token; the per-track catalog resolver turns the same rule into a typed\n * per-track \"FEC unavailable\" outcome instead of failing the session.\n */\nimport { serial32Add, serial32Distance, serial32Precedes } from './serial-number.js'\n\n/** The block profile a catalog `fec.blockProfile` may name: the one this library implements. */\nexport type FecBlockProfile = 'iso-ssbg1-v1'\n\n/** Every accepted `fec.blockProfile` token. */\nexport const FEC_BLOCK_PROFILES: readonly FecBlockProfile[] = Object.freeze([\n 'iso-ssbg1-v1',\n])\n\n/** True for a block-profile token this library implements. */\nexport function isFecBlockProfile(value: unknown): value is FecBlockProfile {\n return value === 'iso-ssbg1-v1'\n}\n\n/**\n * Read a required `fec.blockProfile`. Throws on an absent token and on any\n * token other than `iso-ssbg1-v1`: there is no default and nothing is\n * inferred from the wire (draft-ramadan-moq-fec \u00A75.1).\n *\n * @param where the catalog path of the field, for the error message.\n */\nexport function parseFecBlockProfile(value: unknown, where: string): FecBlockProfile {\n if (isFecBlockProfile(value)) return value\n if (value === undefined) {\n throw new Error(`${where} is required: name the FEC block profile (\"iso-ssbg1-v1\")`)\n }\n throw new Error(`${where} must be \"iso-ssbg1-v1\" (got ${JSON.stringify(value)})`)\n}\n\n/** ISO/IEC 23008-1 C.3.3 ssbg_mode1: the two-octet packet length field. */\nexport const SSBG1_LENGTH_FIELD_BYTES = 2\n\n/** The largest protected packet an ssbg_mode1 symbol of size T can carry. */\nexport function ssbg1MaxPacketLength(symbolSize: number): number {\n return symbolSize - SSBG1_LENGTH_FIELD_BYTES\n}\n\n/** Whether a protected packet of `packetLength` bytes fits one T-byte ssbg_mode1 symbol. */\nexport function ssbg1FitsSymbol(packetLength: number, symbolSize: number): boolean {\n return (\n Number.isSafeInteger(packetLength) &&\n packetLength >= 0 &&\n packetLength <= ssbg1MaxPacketLength(symbolSize) &&\n packetLength <= 0xffff\n )\n}\n\n/**\n * Build one ssbg_mode1 source symbol (C.3.3): the protected packet's length\n * in two octets, network byte order, then the packet, then zero octets up to\n * T. The protected packet is the MMTP packet before its Source FEC Payload ID\n * is appended (C.4.2).\n *\n * @throws when `length + 2 > T`: the packet cannot be protected under this\n * profile, and silently truncating it would corrupt every repair symbol.\n */\nexport function buildSsbg1SourceSymbol(packet: Uint8Array, symbolSize: number): Uint8Array {\n if (!Number.isSafeInteger(symbolSize) || symbolSize <= SSBG1_LENGTH_FIELD_BYTES) {\n throw new Error(`ssbg_mode1 symbol size must exceed ${SSBG1_LENGTH_FIELD_BYTES} (got ${symbolSize})`)\n }\n if (!ssbg1FitsSymbol(packet.byteLength, symbolSize)) {\n throw new Error(\n `ssbg_mode1 source symbol needs ${packet.byteLength} + ${SSBG1_LENGTH_FIELD_BYTES} bytes but T is ${symbolSize}`,\n )\n }\n const symbol = new Uint8Array(symbolSize)\n symbol[0] = (packet.byteLength >>> 8) & 0xff\n symbol[1] = packet.byteLength & 0xff\n symbol.set(packet, SSBG1_LENGTH_FIELD_BYTES)\n return symbol\n}\n\n/**\n * Recover the protected packet from one ssbg_mode1 source symbol: the bytes\n * the length field names. Returns null, never a guess, when the length field\n * points past the symbol or any padding octet is non-zero (C.3.3 padding is\n * all 00h), since either means the recovered symbol is not what was sent.\n */\nexport function trimSsbg1SourceSymbol(symbol: Uint8Array): Uint8Array | null {\n if (symbol.byteLength < SSBG1_LENGTH_FIELD_BYTES) return null\n const length = (symbol[0]! << 8) | symbol[1]!\n const end = SSBG1_LENGTH_FIELD_BYTES + length\n if (end > symbol.byteLength) return null\n for (let i = end; i < symbol.byteLength; i++) {\n if (symbol[i] !== 0) return null\n }\n return symbol.subarray(SSBG1_LENGTH_FIELD_BYTES, end)\n}\n\n/** The SS_ID after the last source symbol of `[ssStart, ssStart + ssbLength)`. */\nexport function isoBlockEnd(ssStart: number, ssbLength: number): number {\n return serial32Add(ssStart, ssbLength)\n}\n\n/**\n * Range membership (C.5.2, C.5.3): whether `ssId` is one of the\n * `ssbLength` consecutive SS_IDs starting at `ssStart`, modulo 2^32.\n */\nexport function isoBlockContains(ssStart: number, ssbLength: number, ssId: number): boolean {\n return serial32Distance(ssStart, ssId) < ssbLength\n}\n\n/**\n * A lower bound on how many blocks the block starting at `a` lies behind the\n * one starting at `b` (0 when `a` does not precede `b`). An iso-ssbg1-v1\n * block holds at most `kMax` source symbols (the catalog `sourceSymbols`, the\n * AL-FEC maximum_k_for_repair_flow), so `n * kMax` SS_IDs always span at least\n * `n` blocks. Every interleave horizon in the receiver (decoder retention,\n * worker retirement, ordered-relay settlement) uses this one bound, so the\n * manager's horizon can never fall inside the decoder's.\n */\nexport function isoBlocksBehindLowerBound(a: number, b: number, kMax: number): number {\n if (!Number.isSafeInteger(kMax) || kMax <= 0) {\n throw new Error(`iso-ssbg1-v1 block horizon needs a positive maximum K (got ${kMax})`)\n }\n return serial32Precedes(a, b) ? Math.floor(serial32Distance(a, b) / kMax) : 0\n}\n", "/**\n * Runtime FEC bindings (BLO-50171): what each source track's FEC resolves to\n * for this library's receiver, read from `validateFecCatalog`'s per-instance\n * result and never re-derived.\n *\n * Every runtime reader (the container's `resolveCatalogTrackFec`,\n * `resolveRepairLayers`, `MulticastManager.configureMultiTrack`, transport's\n * `catalogRepairTracks`) goes through `resolveFecBindings`, so they cannot\n * disagree with the validator or with each other about which tracks have FEC\n * and which repair tracks belong to them.\n *\n * The draft-ramadan-moq-fec-catalog-00 array is the only shape. Both catalog\n * dialects bind through it: an MSF `tracks[]` entry directly, and a hang\n * `video`/`audio` rendition (`fec` the same array) with its `repair.renditions`\n * entries (`source` + `instanceId`), mapped onto a `tracks[]` view so the same\n * validator runs. A hang rendition is authoritative over a `tracks[]` entry of\n * the same name.\n *\n * Fail closed per instance: a source whose base instance is not `ok` resolves\n * to `unavailable` with the validator's code and path, and costs no other\n * track anything. A draft-01 object `fec` is `fec_member` at that track's\n * `fec`: the track plays without FEC.\n */\nimport {\n validateFecCatalog,\n type FecCatalogCode,\n type FecCatalogIssue,\n type FecCatalogReceiver,\n type FecCatalogReport,\n} from './fec-catalog.js'\n\n/** The receiver this runtime is: it decodes `iso-ssbg1-v1` only. */\nexport const RUNTIME_FEC_RECEIVER: FecCatalogReceiver = Object.freeze({\n schemes: Object.freeze(['raptorq', 'reed-solomon']),\n blockProfiles: Object.freeze(['iso-ssbg1-v1']),\n overlays: true,\n})\n\n/** Repair track priority when the track states none (MoQT scale, 192..255). */\nexport const DEFAULT_FEC_REPAIR_PRIORITY = 240\n\n/** One `ok` instance's geometry. */\nexport interface FecInstanceGeometry {\n readonly instanceId: number\n readonly scheme: 'raptorq' | 'reed-solomon'\n /** `iso-ssbg1-v1` under `RUNTIME_FEC_RECEIVER`. */\n readonly blockProfile: string\n /** K. */\n readonly sourceSymbols: number\n /** P_0 for a base instance; the overlay's own P for an overlay. */\n readonly repairSymbols: number\n /** T. */\n readonly symbolSize: number\n readonly interleaveDepthMs?: number\n readonly reorderToleranceMs?: number\n readonly repairTrack: string\n readonly symbolTrack?: string\n}\n\nexport interface FecLayerBinding {\n readonly layer: number\n readonly repairTrackName: string\n readonly repairSymbols: number\n /** O_i = sum(P_j, j < i). */\n readonly rsIdOffset: number\n readonly priority: number\n}\n\nexport interface FecOverlayBinding {\n readonly repairTrackName: string\n readonly scope: 'keyframe'\n readonly sourceSymbols: number\n readonly repairSymbols: number\n readonly priority: number\n readonly geometry: FecInstanceGeometry\n}\n\nexport interface FecBindingUnavailable {\n /** The validator's code, or `fec_base_instances` for a track with no base\n * instance or more than one `ok` one (the MMTP wire carries one base Source FEC Payload\n * ID, mmt-02 7.4.1). */\n readonly code: FecCatalogCode | 'fec_base_instances'\n /** JSON Pointer into the catalog (a hang path starts `/video` or `/audio`). */\n readonly path: string\n readonly outcome: 'unavailable' | 'violation'\n}\n\nexport type FecSourceBinding =\n | {\n readonly status: 'ok'\n readonly track: string\n /** JSON Pointer of the source track (`/tracks/<i>`, `/video/renditions/<name>`). */\n readonly pointer: string\n readonly base: FecInstanceGeometry\n /** Base layers in order, layer 0 first. */\n readonly layers: readonly FecLayerBinding[]\n /** Sum of P over the base layers: the wire RSB_length. */\n readonly totalBaseRepairSymbols: number\n readonly overlay?: FecOverlayBinding\n /** Why a declared overlay is not used, when one is not. */\n readonly overlayUnavailable?: FecBindingUnavailable\n }\n | {\n readonly status: 'unavailable'\n readonly track: string\n readonly pointer: string\n readonly reason: FecBindingUnavailable\n }\n\ntype Obj = Record<string, unknown>\nconst recordOf = (v: unknown): Obj | undefined =>\n typeof v === 'object' && v !== null && !Array.isArray(v) ? (v as Obj) : undefined\nconst escape = (s: string) => s.replace(/~/g, '~0').replace(/\\//g, '~1')\n\n/**\n * The `tracks[]` view of a catalog in either dialect, with each view track's\n * JSON Pointer in the original catalog.\n */\nexport function fecCatalogTracks(catalog: unknown): { tracks: unknown[]; pointers: string[] } {\n const root = recordOf(catalog) ?? {}\n const tracks: unknown[] = []\n const pointers: string[] = []\n const hangNames = new Set<string>()\n for (const role of ['video', 'audio'] as const) {\n for (const [name, r] of Object.entries(recordOf(recordOf(root[role])?.['renditions']) ?? {})) {\n const entry = recordOf(r)\n if (!entry) continue\n hangNames.add(name)\n const kind = recordOf(entry['container'])?.['kind']\n // A hang rendition carries no `packaging`; its container kind is it.\n // `mmtp-fec` is hang's kind for MMTP that carries FEC (the FFmpeg\n // publisher's `moq_publish_set_video_packaging`): MMTP packaging.\n const view: Obj = { name, packaging: kind === undefined || kind === 'mmtp-fec' ? 'mmtp' : kind }\n if (entry['fec'] !== undefined) view['fec'] = entry['fec']\n tracks.push(view)\n pointers.push(`/${role}/renditions/${escape(name)}`)\n }\n }\n const hangRenditions = tracks.length\n for (const [name, r] of Object.entries(recordOf(recordOf(root['repair'])?.['renditions']) ?? {})) {\n hangNames.add(name)\n tracks.push({ packaging: 'fec-repair', ...recordOf(r), name })\n pointers.push(`/repair/renditions/${escape(name)}`)\n }\n const raw = Array.isArray(root['tracks']) ? root['tracks'] : []\n const named = new Set(hangNames)\n raw.forEach((t, i) => {\n const name = recordOf(t)?.['name']\n if (typeof name === 'string') named.add(name)\n if (typeof name === 'string' && hangNames.has(name)) return\n tracks.push(t)\n pointers.push(`/tracks/${i}`)\n })\n // hang layer 0 needs no `repair.renditions` entry: the rendition's instance\n // names it, and a hang Root (hang's toHang) carries no repair block. Such a\n // name stands for a repair track of that instance.\n tracks.slice(0, hangRenditions).forEach((t, ti) => {\n const view = t as Obj\n if (!Array.isArray(view['fec'])) return\n view['fec'].forEach((o, ii) => {\n const repairTrack = recordOf(o)?.['repairTrack']\n if (typeof repairTrack !== 'string' || named.has(repairTrack)) return\n named.add(repairTrack)\n const instanceId = recordOf(o)?.['instanceId']\n tracks.push({ name: repairTrack, packaging: 'fec-repair', source: view['name'], ...(instanceId === undefined ? {} : { instanceId }) })\n pointers.push(`${pointers[ti]}/fec/${ii}/repairTrack`)\n })\n })\n return { tracks, pointers }\n}\n\nfunction runtimeView(catalog: unknown, receiver: FecCatalogReceiver) {\n const { tracks, pointers } = fecCatalogTracks(catalog)\n const report = validateFecCatalog({ tracks }, receiver)\n const at = (path: string) => {\n const m = /^\\/tracks\\/(\\d+)(.*)$/.exec(path)\n return m ? pointers[Number(m[1])] + m[2] : path\n }\n return { tracks, pointers, report, at }\n}\n\n/**\n * The `validateFecCatalog` report `resolveFecBindings` acts on (BLO-55242):\n * the same `tracks[]` view and the same receiver, so a host publishing it\n * cannot disagree with what the runtime does. Paths are JSON Pointers into\n * the original catalog (a hang path starts `/video`, `/audio` or `/repair`).\n * One kind does not resolve: a hang layer 0 repair track with no\n * `repair.renditions` entry stands at the `repairTrack` string that names it\n * (`.../fec/<j>/repairTrack`), so a path below that track names nothing in\n * the catalog. The track indices (`trackIndex`, `repairTrack`,\n * `boundRepairTracks`, `symbolTrack`) index `fecCatalogTracks(catalog).tracks`.\n */\nexport function runtimeFecCatalogReport(\n catalog: unknown,\n receiver: FecCatalogReceiver = RUNTIME_FEC_RECEIVER,\n): FecCatalogReport {\n const { report, at } = runtimeView(catalog, receiver)\n const issue = (i: FecCatalogIssue) => Object.freeze({ code: i.code, path: at(i.path) })\n return Object.freeze({\n instances: Object.freeze(\n report.instances.map((i) => Object.freeze({ ...i, path: at(i.path), issues: Object.freeze(i.issues.map(issue)) })),\n ),\n issues: Object.freeze(report.issues.map(issue)),\n })\n}\n\n/**\n * Every source track's runtime FEC binding, by track name. A track with no\n * `fec`, or an empty `fec` array, declares no FEC and has no entry.\n */\nexport function resolveFecBindings(\n catalog: unknown,\n receiver: FecCatalogReceiver = RUNTIME_FEC_RECEIVER,\n): ReadonlyMap<string, FecSourceBinding> {\n const { tracks, pointers, report, at } = runtimeView(catalog, receiver)\n const trackAt = (i: number) => recordOf(tracks[i]) ?? {}\n const nameAt = (i: number | null) => (i === null ? undefined : (trackAt(i)['name'] as string))\n const why = (i: { outcome: string; issues: readonly { code: FecCatalogCode; path: string }[]; path: string }) =>\n Object.freeze({\n code: i.issues[0]?.code ?? 'fec_member',\n path: at(i.issues[0]?.path ?? i.path),\n outcome: i.outcome === 'unavailable' ? ('unavailable' as const) : ('violation' as const),\n })\n\n const out = new Map<string, FecSourceBinding>()\n tracks.forEach((t, ti) => {\n const track = recordOf(t)\n const name = track?.['name']\n if (!track || typeof name !== 'string' || out.has(name)) return\n if (track['packaging'] === 'fec-repair' || track['packaging'] === 'fec-source') return\n const fec = track['fec']\n if (fec === undefined) return\n if (!Array.isArray(fec)) {\n const reason = { code: 'fec_member' as const, path: at(`/tracks/${ti}/fec`), outcome: 'violation' as const }\n out.set(name, Object.freeze({ status: 'unavailable', track: name, pointer: pointers[ti]!, reason: Object.freeze(reason) }))\n return\n }\n if (fec.length === 0) return\n const insts = report.instances.filter((i) => i.trackIndex === ti)\n const isOverlay = (i: (typeof insts)[number]) => Object.hasOwn(recordOf(fec[Number(i.path.split('/').pop())]) ?? {}, 'scope')\n const bases = insts.filter((i) => !isOverlay(i))\n const okBases = bases.filter((i) => i.outcome === 'ok')\n if (okBases.length !== 1) {\n const reason =\n // No base instance at all (overlay-only `fec`) is a count of 0, not\n // the overlay's own issue.\n okBases.length > 1 || bases.length === 0\n ? Object.freeze({ code: 'fec_base_instances' as const, path: at(`/tracks/${ti}/fec`), outcome: 'violation' as const })\n : why(bases[0] ?? insts[0]!)\n out.set(name, Object.freeze({ status: 'unavailable', track: name, pointer: pointers[ti]!, reason }))\n return\n }\n const b = okBases[0]!\n const base = geometry(recordOf(fec[Number(b.path.split('/').pop())])!, b.instanceId!, nameAt(b.symbolTrack))\n const priorityOf = (i: number | null) => {\n const p = i === null ? undefined : trackAt(i)['priority']\n return typeof p === 'number' ? p : DEFAULT_FEC_REPAIR_PRIORITY\n }\n const layers: FecLayerBinding[] = [\n { layer: 0, repairTrackName: base.repairTrack, repairSymbols: base.repairSymbols, rsIdOffset: 0, priority: priorityOf(b.repairTrack) },\n ]\n const more = b.boundRepairTracks\n .map((tj) => ({ tj, layer: trackAt(tj)['repairLayer'] as number }))\n .sort((x, y) => x.layer - y.layer)\n let offset = base.repairSymbols\n for (const { tj, layer } of more) {\n const repairSymbols = trackAt(tj)['repairSymbols'] as number\n layers.push({ layer, repairTrackName: nameAt(tj)!, repairSymbols, rsIdOffset: offset, priority: priorityOf(tj) })\n offset += repairSymbols\n }\n let overlay: FecOverlayBinding | undefined\n let overlayUnavailable: FecBindingUnavailable | undefined\n const ov = insts.find(isOverlay)\n if (ov?.outcome === 'ok') {\n const g = geometry(recordOf(fec[Number(ov.path.split('/').pop())])!, ov.instanceId!, nameAt(ov.symbolTrack))\n overlay = Object.freeze({\n repairTrackName: g.repairTrack,\n scope: 'keyframe' as const,\n sourceSymbols: g.sourceSymbols,\n repairSymbols: g.repairSymbols,\n priority: priorityOf(ov.repairTrack),\n geometry: g,\n })\n } else if (ov) overlayUnavailable = why(ov)\n out.set(\n name,\n Object.freeze({\n status: 'ok' as const,\n track: name,\n pointer: pointers[ti]!,\n base,\n layers: Object.freeze(layers.map((l) => Object.freeze(l))),\n totalBaseRepairSymbols: offset,\n ...(overlay ? { overlay } : {}),\n ...(overlayUnavailable ? { overlayUnavailable } : {}),\n }),\n )\n })\n return out\n}\n\n// The validator passed this instance for this receiver, so every member read\n// here is present and in range.\nfunction geometry(o: Obj, instanceId: number, symbolTrack: string | undefined): FecInstanceGeometry {\n return Object.freeze({\n instanceId,\n scheme: o['scheme'] as 'raptorq' | 'reed-solomon',\n blockProfile: o['blockProfile'] as string,\n sourceSymbols: o['sourceSymbols'] as number,\n repairSymbols: o['repairSymbols'] as number,\n symbolSize: o['symbolSize'] as number,\n ...(typeof o['interleaveDepthMs'] === 'number' ? { interleaveDepthMs: o['interleaveDepthMs'] } : {}),\n ...(typeof o['reorderToleranceMs'] === 'number' ? { reorderToleranceMs: o['reorderToleranceMs'] } : {}),\n repairTrack: o['repairTrack'] as string,\n ...(symbolTrack !== undefined ? { symbolTrack } : {}),\n })\n}\n", "// The mmtp track modes of draft-ramadan-moq-mmt-02 13.1 and the pairing of\n// an \"mfu-datagram\" track with the \"mfu\" track it mirrors (4.3.1).\n//\n// A publisher MUST NOT publish an \"mfu-datagram\" track without an \"mfu\" track\n// of the same namespace whose objects are identical in Group ID, Object ID\n// and payload. The catalog carries no sibling pointer, so the pair is read\n// from what the two entries state: they are siblings when their whole\n// identity set is equal, field by field or absent on both. The identity set\n// is the hard set (what the Group and Object IDs are derived from) and the\n// rendition fields of mmt-02 13.1 (one payload has one codec, size, bitrate\n// and language; the rungs of a ladder share the hard set, so nothing else\n// tells them apart). A datagram track with no sibling, or more than one, is\n// rejected and the player plays \"mfu\". The soft set is reported, never a\n// fault. Names, roles and labels are not read: fec-catalog-00 makes names\n// non-normative. Known limit: two \"mfu\" tracks with one description cannot\n// carry datagram siblings until the draft defines a pointer.\n//\n// The rule is a per-pair predicate: it answers the same over the whole\n// catalog and over any subset of it a consumer kept.\n\n/** Every mmtpMode this library accepts (mmt-02 13.1). Anything else rejects the track. */\nexport const MMTP_MODES = Object.freeze(['mfu', 'mfu-datagram'] as const)\n\nexport type MmtpMode = (typeof MMTP_MODES)[number]\n\nexport function isMmtpMode(value: unknown): value is MmtpMode {\n return typeof value === 'string' && (MMTP_MODES as readonly string[]).includes(value)\n}\n\n/**\n * Fields the Group and Object IDs of an mmtp track are derived from: two\n * tracks whose values differ cannot carry identical ids (mmt-02 4.4.2, 4.6).\n * Compared equal-or-both-absent, group duration as resolved ticks.\n */\nexport const MMTP_SIBLING_HARD_FIELDS = Object.freeze([\n 'namespace',\n 'timescale',\n 'presentationAnchorTicks',\n 'groupDuration',\n] as const)\n\n/**\n * Fields that describe the media a track carries. The pair carries one\n * payload (mmt-02 4.3.1), so it has one description: an \"mfu\" track whose\n * description differs is another rendition. The rungs of a ladder share the\n * hard set and nothing else in the catalog tells them apart. Compared\n * equal-or-both-absent, like the hard set.\n */\nexport const MMTP_SIBLING_RENDITION_FIELDS = Object.freeze([\n 'codec',\n 'width',\n 'height',\n 'framerate',\n 'bitrate',\n 'samplerate',\n 'channelConfig',\n 'lang',\n] as const)\n\n/**\n * Fields the pair SHOULD share; a mismatch is reported, not a fault. A soft\n * field is read from the entry of the track subscribed, never borrowed from\n * its sibling: a leg takes the keyframe interval its \"mfu-datagram\" entry\n * states, and none when that entry states none (mmt-02 4.4.3).\n */\nexport const MMTP_SIBLING_SOFT_FIELDS = Object.freeze([\n 'initRef',\n 'keyframeIntervalMs',\n 'keyframeIntervalTicks',\n 'isLive',\n 'altGroup',\n] as const)\n\nexport interface MmtpSiblingPair<T> {\n /** The \"mfu\" track. */\n readonly stream: T\n /** Its \"mfu-datagram\" sibling, when the catalog carries exactly one. */\n readonly datagram?: T\n /** Soft-set fields on which the two differ (empty without a datagram sibling). */\n readonly softMismatches: readonly string[]\n}\n\ntype Fields = Record<string, unknown>\n\nfunction fields(track: object): Fields {\n return track as Fields\n}\n\nfunction groupDurationTicks(track: Fields): bigint | undefined {\n const ticks = track['groupDurationTicks']\n if (Number.isSafeInteger(ticks)) return BigInt(ticks as number)\n const ms = track['groupDurationMs']\n const timescale = track['timescale']\n if (!Number.isSafeInteger(ms) || !Number.isSafeInteger(timescale)) return undefined\n return (BigInt(ms as number) * BigInt(timescale as number)) / 1000n\n}\n\nfunction identityEqual(a: Fields, b: Fields): boolean {\n return (\n a['namespace'] === b['namespace'] &&\n a['timescale'] === b['timescale'] &&\n a['presentationAnchorTicks'] === b['presentationAnchorTicks'] &&\n groupDurationTicks(a) === groupDurationTicks(b) &&\n MMTP_SIBLING_RENDITION_FIELDS.every((field) => a[field] === b[field])\n )\n}\n\nfunction isMmtpTrack(track: unknown, mode: MmtpMode): track is object {\n return (\n typeof track === 'object' && track !== null && !Array.isArray(track) &&\n fields(track)['packaging'] === 'mmtp' && fields(track)['mmtpMode'] === mode\n )\n}\n\n/**\n * The \"mfu\" tracks of `tracks` an \"mfu-datagram\" track could be the sibling\n * of: the ones whose identity set (hard set and rendition fields) equals its own. Exactly one\n * pairs it; zero or more than one rejects the datagram track (mmt-02 4.3.1).\n */\nexport function mmtpSiblingCandidates<T extends object>(tracks: readonly T[], datagram: T): T[] {\n const own = fields(datagram)\n return tracks.filter((track) => isMmtpTrack(track, 'mfu') && identityEqual(fields(track), own))\n}\n\n/**\n * Every \"mfu\" track of `tracks` by name, each with its \"mfu-datagram\" sibling\n * when exactly one matches its identity set. A datagram track that matches no\n * \"mfu\" track or more than one pairs with none, and two datagram tracks that\n * match the same \"mfu\" track pair with neither (each is rejected by\n * `mmtpTrackIssues` in the container validator, which first sets aside a\n * track it rejects for its delivery mode); the \"mfu\" tracks are listed\n * whatever happens to their siblings. Never throws.\n */\nexport function pairMmtpSiblings<T extends object>(tracks: readonly T[]): ReadonlyMap<string, MmtpSiblingPair<T>> {\n const pairs = new Map<string, MmtpSiblingPair<T>>()\n for (const track of tracks) {\n if (!isMmtpTrack(track, 'mfu')) continue\n const name = fields(track)['name']\n if (typeof name === 'string' && !pairs.has(name)) pairs.set(name, { stream: track, softMismatches: [] })\n }\n // Two datagram tracks matching one \"mfu\" track pair with neither: the\n // catalog says nothing about which mirrors it.\n const datagrams = new Map<string, T[]>()\n for (const datagram of tracks) {\n if (!isMmtpTrack(datagram, 'mfu-datagram')) continue\n const candidates = mmtpSiblingCandidates(tracks, datagram)\n if (candidates.length !== 1) continue\n const name = fields(candidates[0]!)['name']\n if (typeof name !== 'string' || pairs.get(name)?.stream !== candidates[0]) continue\n datagrams.set(name, [...(datagrams.get(name) ?? []), datagram])\n }\n for (const [name, matched] of datagrams) {\n if (matched.length !== 1) continue\n const { stream } = pairs.get(name)!\n const a = fields(stream)\n const b = fields(matched[0]!)\n const softMismatches = MMTP_SIBLING_SOFT_FIELDS.filter((field) => a[field] !== b[field])\n pairs.set(name, { stream, datagram: matched[0]!, softMismatches })\n }\n return pairs\n}\n", "// The datagram-leg size table of draft-ramadan-moq-mmt-02 4.3.1: every object\n// of an \"mfu-datagram\" track and of its repair tracks MUST fit one datagram,\n// and SHOULD fit a 1200-byte UDP payload with its QUIC and WebTransport\n// framing, its OBJECT_DATAGRAM header and room for the Object Properties a\n// relay adds. The same numbers live in FFmpeg's moqenc_mmt.h\n// (FF_MOQ_MMT_DG_*) and the dual-stack relay's conformance test; change them\n// together.\n\n/** The smallest maximum UDP payload QUIC allows (RFC 9000 14). */\nexport const DATAGRAM_LEG_UDP_FLOOR = 1200\n/** QUIC short header (1 + DCID <= 20 + PN <= 4) + AEAD tag 16, DATAGRAM frame type + length 3, WebTransport quarter-stream-id varint <= 4. */\nexport const DATAGRAM_LEG_QUIC_WT_FRAMING = 48\n/** OBJECT_DATAGRAM header, varint worst cases: type 1 + alias <= 4 + group <= 4 + object <= 2 + priority 1 + extensions length 1. */\nexport const DATAGRAM_LEG_OBJECT_HEADER = 13\n/** Room for two small varint properties a relay may add (e.g. draft-20 Prior Group/Object ID Gap). */\nexport const DATAGRAM_LEG_RELAY_ROOM = 16\n/** FEC Source Info 0x11 inside Immutable Properties 0x0B on a source object. */\nexport const DATAGRAM_LEG_SOURCE_PROPS = 8\n/** A repair packet is 12 (MMTP header) + 13 (Repair FEC Payload ID) + T bytes (mmt-02 7.3). */\nexport const DATAGRAM_LEG_REPAIR_OVERHEAD = 25\n/** The MoQ datagram budget: what reaches the MoQ layer of a 1200-byte UDP payload. */\nexport const DATAGRAM_LEG_DATAGRAM_MAX = DATAGRAM_LEG_UDP_FLOOR - DATAGRAM_LEG_QUIC_WT_FRAMING\n/** The object body budget: the datagram minus the OBJECT_DATAGRAM header and the relay room. */\nexport const DATAGRAM_LEG_BODY_MAX = DATAGRAM_LEG_DATAGRAM_MAX - DATAGRAM_LEG_OBJECT_HEADER - DATAGRAM_LEG_RELAY_ROOM\n/** The largest RaptorQ symbol size (a multiple of 8) whose repair object fits the body budget. */\nexport const DATAGRAM_LEG_SYMBOL_SIZE_MAX = 1096\n\n/**\n * The largest MoQ datagram a receiver of the leg gets at symbol size T: a\n * repair object with its OBJECT_DATAGRAM header, 13 + 25 + T. The relay's\n * property room is a publisher reserve (DATAGRAM_LEG_BODY_MAX), not a\n * receiver cost: what arrives already carries those properties. A session\n * whose `datagrams.maxDatagramSize` is below it cannot carry the track's\n * repair, so the subscriber takes the \"mfu\" track (mmt-02 4.3.1).\n */\nexport function datagramLegObjectMax(symbolSize: number): number {\n return DATAGRAM_LEG_OBJECT_HEADER + DATAGRAM_LEG_REPAIR_OVERHEAD + symbolSize\n}\n\n/** Whether a RaptorQ symbol size keeps every object of the leg inside the 1200-byte table. */\nexport function datagramLegSymbolSizeFits(symbolSize: number): boolean {\n return (\n Number.isInteger(symbolSize) && symbolSize > 0 && symbolSize % 8 === 0 &&\n symbolSize + DATAGRAM_LEG_REPAIR_OVERHEAD <= DATAGRAM_LEG_BODY_MAX\n )\n}\n", "/**\n * Phase 14 catalog-override hook (test harness only).\n *\n * When `globalThis.__PHASE14_CATALOG_OVERRIDE` is set (injected by the\n * 7point test via `page.addInitScript` \u2014 see\n * packages/moq-server/tests/7point-validation.test.mjs `applyPhase14CatalogOverride`)\n * the override's `tracks[]` are merged into whatever catalog the MoQ-delivered\n * JSON produced:\n *\n * - Dedupe by `track.name`.\n * - When both sides carry a track with the same name, the override's\n * `fec` config wins \u2014 this is how the 7point harness steers multi-track\n * tests onto the Phase 14 `video/base` + `video/delta` + `video/repair`\n * switching set without asking the publisher to change its catalog.\n * - Tracks present only in the override are appended as-is.\n * - Tracks present only in the MoQ catalog are preserved unchanged.\n * - `fec` is the draft-ramadan-moq-fec-catalog-00 instance array; a repair\n * track is `packaging: \"fec-repair\"` with `source` + `instanceId`, and each\n * of base and delta names its own (one Track Name in two `repairTrack`\n * members is no FEC on either, catalog-00 5 rule 2).\n *\n * This module is deliberately player-agnostic. It exposes:\n *\n * getPhase14CatalogOverride() \u2014 read + shape-check the global.\n * mergeOverrideIntoHangRenditions() \u2014 merge into a `@moq/hang`\n * Catalog.Root `video.renditions` /\n * `audio.renditions` dict. Used by\n * hang-mmt-fec/js/watch/src/broadcast.ts.\n * mergeOverrideIntoCmsfTracks() \u2014 merge into moqtail's CMSF-flat\n * `tracks[]` array. Used by\n * moqtail-private CMSFCatalog.from().\n *\n * Production builds never set the global, so all three helpers are no-ops at\n * runtime unless the test harness opts in.\n */\n\nimport { isMmtpMode, type MmtpMode } from \"@blockcast/mmt-base\";\nimport type { FecCatalogConfig } from \"./carp-catalog.js\";\n\n// ---------------------------------------------------------------------------\n// Override fixture shape (IETF draft-ietf-moq-catalogformat-01)\n// ---------------------------------------------------------------------------\n\n/**\n * A single override track entry \u2014 mirrors the fixture at\n * `packages/moq-server/tests/fixtures/multi-track-catalog.json`.\n *\n * Kept intentionally permissive: the canonical fixture carries `name`,\n * `altGroup`, `framerate`, and `fec`, but future 7point scenarios may extend\n * with additional hints without wanting this module to gate-keep them.\n */\nexport interface Phase14OverrideTrack {\n\tname: string;\n\t/** CMSF packaging kind. Optional per track \u2014 when absent, the merge\n\t * derives it from the override's top-level `streamingFormat`. */\n\tpackaging?: \"mmtp\" | \"cmaf\" | \"loc\" | \"timeline\" | \"fec-repair\";\n\t/** A `fec-repair` track's source track and instance (catalog-00 3.2). */\n\tsource?: string;\n\tinstanceId?: number;\n\t/** Required when packaging is `mmtp`; the current publisher emits MFU mode. */\n\tmmtpMode?: MmtpMode;\n\t/** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */\n\ttimescale?: number;\n\t/** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */\n\tgroupDurationMs?: number;\n\t/** Codec string. Optional per track \u2014 when absent, the merge inherits\n\t * from the existing video/audio rendition in the MoQ catalog (the\n\t * publisher's declaration). Throws only when neither the override nor\n\t * any existing rendition supplies one. */\n\tcodec?: string;\n\trole?: \"video\" | \"audio\" | \"timeline\";\n\taltGroup?: number;\n\tframerate?: number;\n\tfec?: FecCatalogConfig;\n}\n\n/**\n * The shape the 7point harness writes to `globalThis.__PHASE14_CATALOG_OVERRIDE`.\n * Extra top-level fields (`version`, `streamingFormat`, ...) are ignored \u2014\n * the merge only consumes `tracks[]`.\n */\nexport interface Phase14CatalogOverride {\n\tversion?: string;\n\tstreamingFormat?: string;\n\ttracks: Phase14OverrideTrack[];\n}\n\n// ---------------------------------------------------------------------------\n// Global reader\n// ---------------------------------------------------------------------------\n\n/**\n * Read `globalThis.__PHASE14_CATALOG_OVERRIDE` and return it only when it has\n * a well-formed `tracks[]` array. Malformed values log + return `null` rather\n * than throw so a broken fixture never kills the MoQ path for a real stream.\n */\nexport function getPhase14CatalogOverride(): Phase14CatalogOverride | null {\n\t// `globalThis` is defined in workers, service workers, and the main window;\n\t// it's the portable way to reach the test-injected hook from any context.\n\tconst g = globalThis as Record<string, unknown>;\n\tconst raw = g[\"__PHASE14_CATALOG_OVERRIDE\"];\n\tif (raw === undefined || raw === null) return null;\n\tif (typeof raw !== \"object\") {\n\t\tconsole.warn(\"[phase14-catalog-override] hook is not an object; ignoring\");\n\t\treturn null;\n\t}\n\tconst obj = raw as Record<string, unknown>;\n\tconst tracks = obj[\"tracks\"];\n\tif (!Array.isArray(tracks)) {\n\t\tconsole.warn(\"[phase14-catalog-override] hook.tracks is not an array; ignoring\");\n\t\treturn null;\n\t}\n\t// Shallow filter: keep only entries that at least have a string name.\n\t// Each consumer (hang or CMSF merge) validates shape further.\n\tconst filtered: Phase14OverrideTrack[] = [];\n\tfor (const t of tracks) {\n\t\tif (typeof t === \"object\" && t !== null) {\n\t\t\tconst entry = t as Record<string, unknown>;\n\t\t\tif (typeof entry[\"name\"] === \"string\" && (entry[\"name\"] as string).length > 0) {\n\t\t\t\tfiltered.push(entry as unknown as Phase14OverrideTrack);\n\t\t\t}\n\t\t}\n\t}\n\tif (filtered.length === 0) return null;\n\treturn {\n\t\tversion: typeof obj[\"version\"] === \"string\" ? (obj[\"version\"] as string) : undefined,\n\t\tstreamingFormat:\n\t\t\ttypeof obj[\"streamingFormat\"] === \"string\" ? (obj[\"streamingFormat\"] as string) : undefined,\n\t\ttracks: filtered,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Hang renditions merge (moq-lib / hang-mmt-fec)\n// ---------------------------------------------------------------------------\n\n/**\n * Merge override tracks into a `@moq/hang` Catalog.Root-like object. The\n * caller passes the already-parsed Catalog.Root (mutates in place and also\n * returns it for convenience). No-op when `override` is null.\n *\n * Dedupe rule: override wins for `fec` config and `framerate`. Everything\n * else (codec, container kind) is preserved from the MoQ-delivered rendition\n * when it exists, or synthesised from the override when it does not.\n *\n * Typed `any` here rather than narrow-matching `Catalog.Root` because the\n * upstream `@moq/hang` schema is branded (u53) and the container `kind` union\n * varies by version (`loc` kind appears in hang-mmt-fec's fork). Matching\n * that surface exactly would over-couple this module to a single upstream\n * revision; the runtime shape we rely on (`.video.renditions` dict mutation)\n * is stable.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mergeOverrideIntoHangRenditions<T extends Record<string, any>>(\n\tcatalog: T,\n\toverride: Phase14CatalogOverride | null,\n): T {\n\tif (!override) return catalog;\n\n\tfor (const track of override.tracks) {\n\t\t// Repair tracks are placed after the media merge, below.\n\t\tif (track.packaging === \"fec-repair\") continue;\n\t\t// Default role inference: names without an explicit role field are\n\t\t// treated as video unless the name suffix says audio.\n\t\tconst role: \"video\" | \"audio\" =\n\t\t\ttrack.role === \"audio\" || track.name.startsWith(\"audio\") ? \"audio\" : \"video\";\n\n\t\tconst bagKey = role === \"audio\" ? \"audio\" : \"video\";\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst bag: { renditions: Record<string, any>; priority?: number } =\n\t\t\tcatalog[bagKey] ?? { renditions: {}, priority: 1 };\n\t\tconst existing = bag.renditions[track.name];\n\n\t\t// Merge: override fills gaps, does NOT overwrite existing fec/framerate.\n\t\t// The publisher's real catalog is ground truth for wire parameters:\n\t\t// if the existing rendition already has a matching fec config, that's\n\t\t// what the publisher's packets actually carry. Overwriting it with a\n\t\t// fixture value (e.g. Phase 14 target K=768 when publisher emits K=4)\n\t\t// causes the FEC manager to wait for symbols that never arrive.\n\t\t// Only when the rendition is brand-new (no existing fec) do we seed\n\t\t// from the fixture.\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst merged: Record<string, any> = {\n\t\t\t...(existing ?? {}),\n\t\t\tcontainer: existing?.container ?? { kind: \"mmtp-fec\" },\n\t\t\tcodec: existing?.codec ?? \"\",\n\t\t};\n\t\tif (existing?.framerate === undefined && track.framerate !== undefined) {\n\t\t\tmerged[\"framerate\"] = track.framerate;\n\t\t}\n\t\tif (existing?.fec === undefined && track.fec !== undefined) {\n\t\t\tmerged[\"fec\"] = track.fec;\n\t\t}\n\n\t\tbag.renditions[track.name] = merged;\n\t\t// Reassign so a freshly-created bag is actually reachable on the\n\t\t// catalog when the MoQ side was missing video/audio entirely.\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t(catalog as any)[bagKey] = bag;\n\t}\n\n\t// A repair track is a hang `repair.renditions` entry, bound by `source` +\n\t// `instanceId`, never a media rendition. It is added only when the\n\t// source's effective `fec` names it: a publisher `fec` that won the merge\n\t// may bind a different repair track, and attaching this one would cost\n\t// that instance its FEC (rule 3).\n\tfor (const track of override.tracks) {\n\t\tif (track.packaging !== \"fec-repair\") continue;\n\t\tconst source =\n\t\t\tcatalog[\"video\"]?.renditions?.[track.source as string] ??\n\t\t\tcatalog[\"audio\"]?.renditions?.[track.source as string];\n\t\tif (!namesRepairTrack(source?.fec, track.name, track.instanceId)) continue;\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst repair: { renditions?: Record<string, any> } = catalog[\"repair\"] ?? {};\n\t\trepair.renditions ??= {};\n\t\tconst { name, packaging: _p, mmtpMode: _m, timescale: _t, groupDurationMs: _g, altGroup: _a, ...entry } = track;\n\t\trepair.renditions[name] ??= entry;\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t(catalog as any)[\"repair\"] = repair;\n\t}\n\treturn catalog;\n}\n\n/** Whether `fec` holds the instance `instanceId` (default 0) whose `repairTrack` is `name`. */\nfunction namesRepairTrack(fec: unknown, name: string, instanceId: unknown): boolean {\n\tconst id = instanceId ?? 0;\n\treturn (\n\t\tArray.isArray(fec) &&\n\t\tfec.some(\n\t\t\t(i) =>\n\t\t\t\ttypeof i === \"object\" && i !== null && (i.instanceId ?? 0) === id && i.repairTrack === name,\n\t\t)\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// CMSF tracks merge (moqtail-private)\n// ---------------------------------------------------------------------------\n\n/**\n * Shape-minimal description of a CMSF track input (pre-validation JSON, not\n * the parsed `CMSFTrack`). Keeps this module free of a hard dependency on\n * moqtail-ts.\n */\ntype CmsfTrackJson = {\n\tname: string;\n\tpackaging?: string;\n\tmmtpMode?: string;\n\ttimescale?: number;\n\tgroupDurationMs?: number;\n\trole?: string;\n\tcodec?: string;\n\tframerate?: number;\n\tfec?: unknown;\n\t[k: string]: unknown;\n};\n\nfunction isPositiveInteger(value: unknown): value is number {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value > 0;\n}\n\n/**\n * Merge override tracks into a raw CMSF `tracks[]` JSON array (as produced\n * by `JSON.parse(catalog.json)` inside `CMSFCatalog.from`).\n *\n * Dedupe by `name`. For name collisions, publisher-emitted `fec` + `framerate`\n * are preserved (the publisher is ground truth for wire parameters). For new\n * track names, missing `packaging` is derived from the override's top-level\n * `streamingFormat`, and missing `codec` is inherited from any existing video\n * track in the catalog. Throws on bad init when neither source supplies them.\n */\nexport function mergeOverrideIntoCmsfTracks(\n\ttracks: CmsfTrackJson[],\n\toverride: Phase14CatalogOverride | null,\n): CmsfTrackJson[] {\n\tif (!override) return tracks;\n\n\tconst byName = new Map<string, CmsfTrackJson>();\n\tfor (const t of tracks) {\n\t\tif (typeof t?.name === \"string\") byName.set(t.name, t);\n\t}\n\n\t// Catalog-derived fallbacks (NOT magic numbers) \u2014 inherited from existing\n\t// publisher tracks. Used only when the override track doesn't carry them.\n\tconst derivedPackaging = override.streamingFormat;\n\tconst existingVideoTrack = tracks.find(\n\t\t(t) => t.role === \"video\" && typeof t.codec === \"string\" && (t.codec as string).length > 0,\n\t);\n\tconst existingAudioTrack = tracks.find(\n\t\t(t) => t.role === \"audio\" && typeof t.codec === \"string\" && (t.codec as string).length > 0,\n\t);\n\n\t// Media first, so a repair track can check its source's effective `fec`.\n\tconst ordered = [\n\t\t...override.tracks.filter((t) => t.packaging !== \"fec-repair\"),\n\t\t...override.tracks.filter((t) => t.packaging === \"fec-repair\"),\n\t];\n\tfor (const ot of ordered) {\n\t\tconst existing = byName.get(ot.name);\n\t\tif (existing !== undefined) {\n\t\t\t// Preserve publisher-emitted fec + framerate \u2014 those describe what\n\t\t\t// is actually on the wire. Overwriting with fixture values causes\n\t\t\t// the player's FEC manager to wait for symbols that never arrive\n\t\t\t// when the fixture's K/P don't match the publisher's.\n\t\t\tif (existing.fec === undefined && ot.fec !== undefined) existing.fec = ot.fec;\n\t\t\tif (existing.framerate === undefined && ot.framerate !== undefined) {\n\t\t\t\texisting.framerate = ot.framerate;\n\t\t\t}\n\t\t\tif (ot.role !== undefined && existing.role === undefined) existing.role = ot.role;\n\t\t\tif (existing.packaging === \"mmtp\") {\n\t\t\t\tconst mode = existing.mmtpMode ?? ot.mmtpMode;\n\t\t\t\tif (mode === undefined) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid mmtpMode`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// mmt-02 13.1: an unknown mode rejects the track, never the\n\t\t\t\t// catalog (`mmtpTrackIssues`); the override leaves it alone.\n\t\t\t\tif (!isMmtpMode(mode)) {\n\t\t\t\t\tconsole.warn(`[phase14-catalog-override] track \"${ot.name}\" has unknown mmtpMode ${JSON.stringify(mode)}; skipping the override`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\texisting.mmtpMode = mode;\n\t\t\t\tif (existing.timescale === undefined && ot.timescale !== undefined) existing.timescale = ot.timescale;\n\t\t\t\tif (existing.groupDurationMs === undefined && ot.groupDurationMs !== undefined) {\n\t\t\t\t\texisting.groupDurationMs = ot.groupDurationMs;\n\t\t\t\t}\n\t\t\t\tif (!isPositiveInteger(existing.timescale)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid timescale`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!isPositiveInteger(existing.groupDurationMs)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid groupDurationMs`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst packaging = ot.packaging ?? derivedPackaging;\n\t\t\tif (typeof packaging !== \"string\" || packaging.length === 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has no packaging \u2014 supply per-track or set top-level streamingFormat`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Role inference: repair tracks stay role-less per CMSF convention;\n\t\t\t// others default to video. Decided by packaging, never by name.\n\t\t\tconst isRepair = packaging === \"fec-repair\";\n\t\t\t// Same rule as the hang path: only a repair track its source names.\n\t\t\tif (isRepair && !namesRepairTrack(byName.get(ot.source as string)?.fec, ot.name, ot.instanceId)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst role = ot.role ?? (isRepair ? undefined : \"video\");\n\t\t\tconst inheritedCodec =\n\t\t\t\trole === \"audio\" ? existingAudioTrack?.codec : existingVideoTrack?.codec;\n\t\t\tconst codec = ot.codec ?? inheritedCodec;\n\t\t\tif (packaging !== \"timeline\" && !isRepair && (typeof codec !== \"string\" || codec.length === 0)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has no codec (packaging='${packaging}') \u2014 supply per-track or ensure the publisher catalog has a ${role ?? \"video\"} track to inherit from`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst mmtpMode = ot.mmtpMode;\n\t\t\tif (packaging === \"mmtp\" && mmtpMode === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid mmtpMode`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (packaging === \"mmtp\" && !isMmtpMode(mmtpMode)) {\n\t\t\t\tconsole.warn(`[phase14-catalog-override] track \"${ot.name}\" has unknown mmtpMode ${JSON.stringify(mmtpMode)}; skipping the track`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (packaging === \"mmtp\" && !isPositiveInteger(ot.timescale)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid timescale`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (packaging === \"mmtp\" && !isPositiveInteger(ot.groupDurationMs)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[phase14-catalog-override] track \"${ot.name}\" has packaging='mmtp' but no valid groupDurationMs`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst entry: CmsfTrackJson = { name: ot.name, packaging };\n\t\t\tif (codec !== undefined && !isRepair) entry.codec = codec as string;\n\t\t\tif (ot.source !== undefined) entry[\"source\"] = ot.source;\n\t\t\tif (ot.instanceId !== undefined) entry[\"instanceId\"] = ot.instanceId;\n\t\t\t// Block geometry on a repair track costs its instance FEC (rule 1).\n\t\t\tif (mmtpMode !== undefined && !isRepair) entry.mmtpMode = mmtpMode;\n\t\t\tif (ot.timescale !== undefined && !isRepair) entry.timescale = ot.timescale;\n\t\t\tif (ot.groupDurationMs !== undefined && !isRepair) entry.groupDurationMs = ot.groupDurationMs;\n\t\t\tif (role !== undefined) entry.role = role;\n\t\t\tif (ot.framerate !== undefined) entry.framerate = ot.framerate;\n\t\t\tif (ot.fec !== undefined) entry.fec = ot.fec;\n\t\t\ttracks.push(entry);\n\t\t\tbyName.set(ot.name, entry);\n\t\t}\n\t}\n\treturn tracks;\n}\n"],
5
+ "mappings": ";AAsEO,IAAM,kBAAkB;AAI/B,IAAM,wBAAwB;AAC9B,IAAM,4BAA4B,kBAAkB;;;AC9D7C,IAAM,iBAAiB;AAGvB,IAAM,oBAAoB,KAAK;AAQ/B,IAAM,uBAAuB,MAAM,iBAAiB;;;ACSpD,IAAM,qBAAiD,OAAO,OAAO;EAC1E;CACD;;;ACHM,IAAM,uBAA2C,OAAO,OAAO;EACpE,SAAS,OAAO,OAAO,CAAC,WAAW,cAAc,CAAC;EAClD,eAAe,OAAO,OAAO,CAAC,cAAc,CAAC;EAC7C,UAAU;CACX;;;ACfM,IAAM,aAAa,OAAO,OAAO,CAAC,OAAO,cAAc,CAAU;AAIlE,SAAU,WAAW,OAAc;AACvC,SAAO,OAAO,UAAU,YAAa,WAAiC,SAAS,KAAK;AACtF;AAOO,IAAM,2BAA2B,OAAO,OAAO;EACpD;EACA;EACA;EACA;CACQ;AASH,IAAM,gCAAgC,OAAO,OAAO;EACzD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACQ;AAQH,IAAM,2BAA2B,OAAO,OAAO;EACpD;EACA;EACA;EACA;EACA;CACQ;;;AC9DH,IAAM,yBAAyB;AAE/B,IAAM,+BAA+B;AAErC,IAAM,6BAA6B;AAEnC,IAAM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C,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,GACtF,MAAM,IAAI,CAAA;IACb;;;OAGG;IACH,mBAAmB,CAAC,CAClB,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,WAAW,EAAE,qBAAqB,GACjC,IAAI,CAAA;CACR;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,eAAe,GACf,SAAS,GACT,UAAU,GACV,OAAO,GACP,UAAU,GACV,MAAM,GACN,mBAAmB,CAAA;AAwEvB;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAqhC7F"}
@@ -149,6 +149,40 @@ var RUNTIME_FEC_RECEIVER = Object.freeze({
149
149
  overlays: true
150
150
  });
151
151
 
152
+ // ../mmt-base/dist/mmtp-siblings.js
153
+ var MMTP_MODES = Object.freeze(["mfu", "mfu-datagram"]);
154
+ var MMTP_SIBLING_HARD_FIELDS = Object.freeze([
155
+ "namespace",
156
+ "timescale",
157
+ "presentationAnchorTicks",
158
+ "groupDuration"
159
+ ]);
160
+ var MMTP_SIBLING_RENDITION_FIELDS = Object.freeze([
161
+ "codec",
162
+ "width",
163
+ "height",
164
+ "framerate",
165
+ "bitrate",
166
+ "samplerate",
167
+ "channelConfig",
168
+ "lang"
169
+ ]);
170
+ var MMTP_SIBLING_SOFT_FIELDS = Object.freeze([
171
+ "initRef",
172
+ "keyframeIntervalMs",
173
+ "keyframeIntervalTicks",
174
+ "isLive",
175
+ "altGroup"
176
+ ]);
177
+
178
+ // ../mmt-base/dist/datagram-leg-size.js
179
+ var DATAGRAM_LEG_UDP_FLOOR = 1200;
180
+ var DATAGRAM_LEG_QUIC_WT_FRAMING = 48;
181
+ var DATAGRAM_LEG_OBJECT_HEADER = 13;
182
+ var DATAGRAM_LEG_RELAY_ROOM = 16;
183
+ var DATAGRAM_LEG_DATAGRAM_MAX = DATAGRAM_LEG_UDP_FLOOR - DATAGRAM_LEG_QUIC_WT_FRAMING;
184
+ var DATAGRAM_LEG_BODY_MAX = DATAGRAM_LEG_DATAGRAM_MAX - DATAGRAM_LEG_OBJECT_HEADER - DATAGRAM_LEG_RELAY_ROOM;
185
+
152
186
  // src/repair-fetch.ts
153
187
  import { extendSsId, repairFetchRange } from "@blockcast/mmt-fec";
154
188
 
@@ -622,6 +656,22 @@ function wireRepairFetch(mc, opts) {
622
656
  dispatch();
623
657
  return;
624
658
  }
659
+ if (event.type === "gap") {
660
+ if (event.action !== "stall" || event.reason !== "discontinuity") return;
661
+ const now = performance.now();
662
+ let expired = false;
663
+ for (const entry2 of [...entries.values()]) {
664
+ if (entry2.packetId !== event.stream.packetId) continue;
665
+ if (entry2.catalogTrackName !== (event.stream.catalogTrackName ?? void 0)) continue;
666
+ if (!entry2.running || entry2.deadlineAt > now) continue;
667
+ stop(entry2, "expired");
668
+ retire(entry2);
669
+ clearEntry(entry2);
670
+ expired = true;
671
+ }
672
+ if (expired) dispatch();
673
+ return;
674
+ }
625
675
  if (event.type !== "recovered" && event.type !== "failed") return;
626
676
  const entry = entries.get(
627
677
  requestKey(event.block.sbn, event.block.packetId, event.block.catalogTrackName ?? void 0)