@blockcast/mmt-container 0.4.0-main.bbd83cb48eff → 0.4.0-main.bbdfdbf39ded
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.
- package/README.md +31 -17
- package/dist/align.d.ts +24 -18
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js +23 -4
- package/dist/align.js.map +2 -2
- package/dist/browser-runtime.js +1192 -375
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +67 -31
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +291 -199
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +24 -2
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/delivery-catalog.js +18 -12
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +49 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +176 -23
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +2 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +2 -1
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +29 -0
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +97 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/manifest-auth-plan.d.ts +26 -25
- package/dist/manifest-auth-plan.d.ts.map +1 -1
- package/dist/manifest-auth-plan.js +331 -1171
- package/dist/manifest-auth-plan.js.map +4 -4
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +1014 -289
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +159 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +531 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +17 -1
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +29 -0
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +347 -132
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +28 -6
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +290 -28
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +40 -5
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +293 -54
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +6 -0
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +18 -11
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +4 -1
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +964 -274
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +81 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +156 -31
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/source-auth.js +2710 -7
- package/dist/source-auth.js.map +4 -4
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -9
- package/schemas/catalog.schema.json +124 -37
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +131 -52
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +45 -2
- package/src/catalog-validator.ts +4 -11
- package/src/fec-manager.ts +128 -14
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +4 -1
- package/src/index.ts +24 -10
- package/src/iso-block-locator.ts +97 -6
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-fec-session.ts +533 -0
- package/src/mmtp-router.ts +57 -0
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +119 -61
- package/src/multicast-manager.ts +115 -14
- package/src/multicast-transport.ts +3 -0
- package/src/no-modules.ts +7 -1
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +283 -39
- package/src/repair-layers.ts +22 -2
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +60 -3
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
- package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
- package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
- package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
- package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
- package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
- package/test-vectors/catalog/positive/fec-multicast.json +1 -1
- package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
- package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
- package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
- package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +2 -2
- package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
- package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
- package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
- package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
- package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +30 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +6 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/src/fec-codec.ts +0 -61
|
@@ -44,7 +44,7 @@ export interface Phase14OverrideTrack {
|
|
|
44
44
|
* derives it from the override's top-level `streamingFormat`. */
|
|
45
45
|
packaging?: "mmtp" | "cmaf" | "loc" | "timeline";
|
|
46
46
|
/** Required when packaging is `mmtp`; the current publisher emits MFU mode. */
|
|
47
|
-
mmtpMode?: "
|
|
47
|
+
mmtpMode?: "mfu";
|
|
48
48
|
/** Required when packaging is `mmtp`; copied into synthesized CMSF tracks. */
|
|
49
49
|
timescale?: number;
|
|
50
50
|
/** 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMxE;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb;sEACkE;IAClE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;IACjD,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"phase14-catalog-override.d.ts","sourceRoot":"","sources":["../src/phase14-catalog-override.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMxE;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb;sEACkE;IAClE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;IACjD,+EAA+E;IAC/E,QAAQ,CAAC,E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;CACrB,CAAC;AAMF;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAC1C,MAAM,EAAE,aAAa,EAAE,EACvB,QAAQ,EAAE,sBAAsB,GAAG,IAAI,GACrC,aAAa,EAAE,CAuGjB"}
|
|
@@ -78,7 +78,7 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
|
|
|
78
78
|
if (ot.role !== void 0 && existing.role === void 0) existing.role = ot.role;
|
|
79
79
|
if (existing.packaging === "mmtp") {
|
|
80
80
|
const mode = existing.mmtpMode ?? ot.mmtpMode;
|
|
81
|
-
if (mode !== "
|
|
81
|
+
if (mode !== "mfu") {
|
|
82
82
|
throw new Error(
|
|
83
83
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
|
|
84
84
|
);
|
|
@@ -115,7 +115,7 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
|
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
const mmtpMode = ot.mmtpMode;
|
|
118
|
-
if (packaging === "mmtp" && mmtpMode !== "
|
|
118
|
+
if (packaging === "mmtp" && mmtpMode !== "mfu") {
|
|
119
119
|
throw new Error(
|
|
120
120
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
|
|
121
121
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 *\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 { FecAlgorithm, 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\";\n\t/** Required when packaging is `mmtp`; the current publisher emits MFU mode. */\n\tmmtpMode?: \"mpu\" | \"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?: Partial<FecCatalogConfig> & { algorithm: FecAlgorithm };\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// 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\treturn catalog;\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\tfor (const ot of override.tracks) {\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 !== \"mpu\" && 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 (ending in /repair) stay role-less\n\t\t\t// per CMSF convention; others default to video.\n\t\t\tconst role = ot.role ?? (ot.name.endsWith(\"/repair\") ? 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\" && (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 !== \"mpu\" && 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 = {\n\t\t\t\tname: ot.name,\n\t\t\t\tpackaging,\n\t\t\t\tcodec: codec as string,\n\t\t\t};\n\t\t\tif (mmtpMode !== undefined) entry.mmtpMode = mmtpMode;\n\t\t\tif (ot.timescale !== undefined) entry.timescale = ot.timescale;\n\t\t\tif (ot.groupDurationMs !== undefined) 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": ";AAwFO,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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AM,IAAI,IAAI;AAI7B,IAAC,QAAgB,MAAM,IAAI;AAAA,EAC5B;AACA,SAAO;AACR;AAwBA,SAAS,kBAAkB,OAAiC;AAC3D,SAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,QAAQ;AACxE;AAYO,SAAS,4BACf,QACA,UACkB;AAClB,MAAI,CAAC,SAAU,QAAO;AAEtB,QAAM,SAAS,oBAAI,IAA2B;AAC9C,aAAW,KAAK,QAAQ;AACvB,QAAI,OAAO,GAAG,SAAS,SAAU,QAAO,IAAI,EAAE,MAAM,CAAC;AAAA,EACtD;AAIA,QAAM,mBAAmB,SAAS;AAClC,QAAM,qBAAqB,OAAO;AAAA,IACjC,CAAC,MAAM,EAAE,SAAS,WAAW,OAAO,EAAE,UAAU,YAAa,EAAE,MAAiB,SAAS;AAAA,EAC1F;AACA,QAAM,qBAAqB,OAAO;AAAA,IACjC,CAAC,MAAM,EAAE,SAAS,WAAW,OAAO,EAAE,UAAU,YAAa,EAAE,MAAiB,SAAS;AAAA,EAC1F;AAEA,aAAW,MAAM,SAAS,QAAQ;AACjC,UAAM,WAAW,OAAO,IAAI,GAAG,IAAI;AACnC,QAAI,aAAa,QAAW;AAK3B,UAAI,SAAS,QAAQ,UAAa,GAAG,QAAQ,OAAW,UAAS,MAAM,GAAG;AAC1E,UAAI,SAAS,cAAc,UAAa,GAAG,cAAc,QAAW;AACnE,iBAAS,YAAY,GAAG;AAAA,MACzB;AACA,UAAI,GAAG,SAAS,UAAa,SAAS,SAAS,OAAW,UAAS,OAAO,GAAG;AAC7E,UAAI,SAAS,cAAc,QAAQ;AAClC,cAAM,OAAO,SAAS,YAAY,GAAG;AACrC,YAAI,SAAS,
|
|
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 *\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 { FecAlgorithm, 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\";\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?: Partial<FecCatalogConfig> & { algorithm: FecAlgorithm };\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// 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\treturn catalog;\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\tfor (const ot of override.tracks) {\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 (ending in /repair) stay role-less\n\t\t\t// per CMSF convention; others default to video.\n\t\t\tconst role = ot.role ?? (ot.name.endsWith(\"/repair\") ? 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\" && (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 = {\n\t\t\t\tname: ot.name,\n\t\t\t\tpackaging,\n\t\t\t\tcodec: codec as string,\n\t\t\t};\n\t\t\tif (mmtpMode !== undefined) entry.mmtpMode = mmtpMode;\n\t\t\tif (ot.timescale !== undefined) entry.timescale = ot.timescale;\n\t\t\tif (ot.groupDurationMs !== undefined) 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": ";AAwFO,SAAS,4BAA2D;AAG1E,QAAM,IAAI;AACV,QAAM,MAAM,EAAE,4BAA4B;AAC1C,MAAI,QAAQ,UAAa,QAAQ,KAAM,QAAO;AAC9C,MAAI,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AAG,eAAe,GAAG;AACnE,cAAM,IAAI;AAAA,UACT,qCAAqC,GAAG,IAAI;AAAA,QAC7C;AAAA,MACD;AACA,YAAM,QAAuB;AAAA,QAC5B,MAAM,GAAG;AAAA,QACT;AAAA,QACA;AAAA,MACD;AACA,UAAI,aAAa,OAAW,OAAM,WAAW;AAC7C,UAAI,GAAG,cAAc,OAAW,OAAM,YAAY,GAAG;AACrD,UAAI,GAAG,oBAAoB,OAAW,OAAM,kBAAkB,GAAG;AACjE,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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/repair-fetch.d.ts
CHANGED
|
@@ -80,13 +80,19 @@
|
|
|
80
80
|
* A FETCH landing after the gate forced that frame out would recover media
|
|
81
81
|
* the gate then drops as stale.
|
|
82
82
|
*
|
|
83
|
-
* The scheduler arms no timers. A fetch ends when its
|
|
84
|
-
* throws, when it is preempted, when any later
|
|
85
|
-
* its presentation deadline, when its block
|
|
86
|
-
* that deadline), on track reset, or on
|
|
83
|
+
* The scheduler arms no timers for block requests. A fetch ends when its
|
|
84
|
+
* transport completes or throws, when it is preempted, when any later
|
|
85
|
+
* scheduling event finds it past its presentation deadline, when its block
|
|
86
|
+
* resolves (recovered, or failed at that deadline), on track reset, or on
|
|
87
|
+
* dispose. A range request (§7.5) is for a hole, not a tracked block, so no
|
|
88
|
+
* FEC deadline resolves it: it arms one timer at its deadline, cleared when
|
|
89
|
+
* it retires, so a hung range FETCH cannot hold the hole (and the release
|
|
90
|
+
* gate behind it) past that deadline.
|
|
87
91
|
*/
|
|
88
92
|
import { type FecBlockProfile } from '@blockcast/mmt-base';
|
|
93
|
+
import { type RepairFetchRange } from '@blockcast/mmt-fec';
|
|
89
94
|
import { type BlockClass, type ClassifierMode, type RepairPriority } from './block-policy.js';
|
|
95
|
+
import type { UndelimitedIsoLoss } from './fec-manager.js';
|
|
90
96
|
import type { RepairLifecycleObserver } from './multicast-manager.js';
|
|
91
97
|
/**
|
|
92
98
|
* The highest value in the Source Media priority range of
|
|
@@ -186,6 +192,29 @@ export interface RepairFetchRequest {
|
|
|
186
192
|
* must already be queued ahead of that request. A FETCH whose Request ID
|
|
187
193
|
* is not known yet is cancelled as soon as FETCH_OK assigns it. */
|
|
188
194
|
export type RepairFetchTransport = (request: RepairFetchRequest) => AsyncIterable<Uint8Array>;
|
|
195
|
+
/**
|
|
196
|
+
* One range repair FETCH for a lost SS_ID in an undelimited span
|
|
197
|
+
* (draft-ramadan-moq-fec §7.5): the absolute, inclusive repair-track Group
|
|
198
|
+
* range `repairFetchRange` gives. The last Group returned is the block holding
|
|
199
|
+
* `lostSsId`; earlier ones are other blocks, admitted like any repair object.
|
|
200
|
+
*/
|
|
201
|
+
export interface RepairRangeFetchRequest extends RepairFetchRange {
|
|
202
|
+
readonly repairTrack: string;
|
|
203
|
+
/** The lost SS_ID x the range was computed for. */
|
|
204
|
+
readonly lostSsId: number;
|
|
205
|
+
readonly blockProfile: FecBlockProfile;
|
|
206
|
+
readonly packetId: number;
|
|
207
|
+
/** Same contract as `RepairFetchRequest.signal`: cancel on the wire. */
|
|
208
|
+
readonly signal: AbortSignal;
|
|
209
|
+
/** Same contract as `RepairFetchRequest.subscriberPriority`. */
|
|
210
|
+
readonly subscriberPriority: number | undefined;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Protocol-specific range FETCH (e.g. MoQT LOCATION_FILTER 0x03 Group range).
|
|
214
|
+
* Yield each repair object payload; return when the range ends. The abort
|
|
215
|
+
* rules of {@link RepairFetchTransport} apply unchanged.
|
|
216
|
+
*/
|
|
217
|
+
export type RepairRangeFetchTransport = (request: RepairRangeFetchRequest) => AsyncIterable<Uint8Array>;
|
|
189
218
|
/** Why a request could not carry a catalog-derived priority. */
|
|
190
219
|
export type RepairPriorityReason = 'source-priority-absent' | 'source-priority-invalid' | 'repair-priority-absent' | 'repair-priority-invalid';
|
|
191
220
|
/**
|
|
@@ -281,6 +310,22 @@ export interface WireRepairFetchOptions {
|
|
|
281
310
|
* `all-protected` stream.
|
|
282
311
|
*/
|
|
283
312
|
keyframeRepairBudgetMs?: (packetId: number, catalogTrackName?: string) => number;
|
|
313
|
+
/**
|
|
314
|
+
* Range repair for a lost SS_ID whose block no repair delimited
|
|
315
|
+
* (draft-ramadan-moq-fec §7.5), optional. Given, the host keeps such a gap
|
|
316
|
+
* as a pending hole and the scheduler FETCHes `repairFetchRange(x, K,
|
|
317
|
+
* anchor)` for it under the same admission, priority and abort rules as a
|
|
318
|
+
* block request (class `unknown`, P0). Requires `repairEpochReference`.
|
|
319
|
+
*/
|
|
320
|
+
rangeTransport?: RepairRangeFetchTransport;
|
|
321
|
+
/**
|
|
322
|
+
* The epoch reference r of `repairTrack` on the live session
|
|
323
|
+
* (`RepairEpochReferences.reference`), or undefined while none is held.
|
|
324
|
+
* The §7.5 anchor is ext(S_prev) extended from it when a stated block ends
|
|
325
|
+
* where the hole starts, else r itself; without r no range request is sent
|
|
326
|
+
* (`range-no-anchor`).
|
|
327
|
+
*/
|
|
328
|
+
repairEpochReference?: (repairTrack: string) => bigint | undefined;
|
|
284
329
|
}
|
|
285
330
|
/** Why the D-28 layer asked for a repair: the block's class at its deadline. */
|
|
286
331
|
export type RepairSubscribeCallback = (sbn: number, packetId: number, catalogTrackName: string | undefined, blockClass: BlockClass) => void;
|
|
@@ -291,7 +336,33 @@ export type RepairSkipReason =
|
|
|
291
336
|
/** The measured RTT is not less than the time left to the deadline. */
|
|
292
337
|
| 'rtt-exceeds-budget'
|
|
293
338
|
/** The player gave no usable presentation delay for the block's stream. */
|
|
294
|
-
| 'presentation-delay-unavailable'
|
|
339
|
+
| 'presentation-delay-unavailable'
|
|
340
|
+
/** A lost SS_ID in an undelimited span had no §7.5 anchor to extend it from. */
|
|
341
|
+
| 'range-no-anchor';
|
|
342
|
+
/**
|
|
343
|
+
* Which term set a FETCH's deadline (BLO-33597): the multicast wait, the
|
|
344
|
+
* player's presentation delay past the block anchor, the keyframe budget past
|
|
345
|
+
* the anchor (when it granted more than the presentation delay), or the
|
|
346
|
+
* release gate's retention ceiling.
|
|
347
|
+
*/
|
|
348
|
+
export type RepairDeadlineBound = 'wait' | 'presentation' | 'keyframe' | 'retention';
|
|
349
|
+
/** The admission inputs of a FETCH the scheduler sent (BLO-33597). */
|
|
350
|
+
export interface RepairSendMeasurement {
|
|
351
|
+
/** The reliable-path RTT admission compared against `budgetMs`. */
|
|
352
|
+
readonly rttMs: number;
|
|
353
|
+
/** Time left to the entry's deadline when the FETCH was sent. */
|
|
354
|
+
readonly budgetMs: number;
|
|
355
|
+
/**
|
|
356
|
+
* Delay past the block anchor the deadline was computed from; null when
|
|
357
|
+
* the block had no anchor (its deadline is then the multicast wait).
|
|
358
|
+
*/
|
|
359
|
+
readonly delayMs: number | null;
|
|
360
|
+
/** Time since the block anchor; null when the block had no anchor. */
|
|
361
|
+
readonly blockAgeMs: number | null;
|
|
362
|
+
readonly bound: RepairDeadlineBound;
|
|
363
|
+
/** True for a range repair FETCH (§7.5 lost SS_ID); absent for a block FETCH. */
|
|
364
|
+
readonly range?: true;
|
|
365
|
+
}
|
|
295
366
|
/** The subset of MulticastManager the scheduler drives. */
|
|
296
367
|
export interface RepairFetchHost {
|
|
297
368
|
readonly fecManager: {
|
|
@@ -330,6 +401,10 @@ export interface RepairFetchHost {
|
|
|
330
401
|
noteKeyframeBudgetGranted?(extensionMs: number, sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
331
402
|
addRepairLifecycleObserver(observer: RepairLifecycleObserver): () => void;
|
|
332
403
|
addTrackResetObserver(observer: (packetId: number, catalogTrackName: string) => void): () => void;
|
|
404
|
+
/** Register for lost SS_IDs in undelimited spans (required with `rangeTransport`). */
|
|
405
|
+
onUndelimitedLoss?(cb: (loss: UndelimitedIsoLoss) => void): void;
|
|
406
|
+
/** A hole's range repair ended, or none is sent: feed what was not stated. */
|
|
407
|
+
closeIsoHoles?(packetId: number, catalogTrackName: string | undefined, start: number, length: number): void;
|
|
333
408
|
clearRepairForBlock(sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
334
409
|
processRepairFromMoQ(packet: Uint8Array, ownerPacketId?: number, catalogTrackName?: string): void;
|
|
335
410
|
noteRepairScheduling(type: 'repair-preempted' | 'repair-deferred', sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
@@ -349,7 +424,7 @@ export interface RepairFetchHost {
|
|
|
349
424
|
* A FETCH the scheduler admitted and handed to the transport (optional):
|
|
350
425
|
* every attempt, a retry or a reprioritised restart included.
|
|
351
426
|
*/
|
|
352
|
-
noteRepairFetchSent?(priority: RepairPriority, sbn: number, packetId: number, catalogTrackName
|
|
427
|
+
noteRepairFetchSent?(priority: RepairPriority, sbn: number, packetId: number, catalogTrackName: string | undefined, measurement: RepairSendMeasurement): void;
|
|
353
428
|
}
|
|
354
429
|
/**
|
|
355
430
|
* Wire the D-28 repair-fetch scheduler onto a MulticastManager.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repair-fetch.d.ts","sourceRoot":"","sources":["../src/repair-fetch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"repair-fetch.d.ts","sourceRoot":"","sources":["../src/repair-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AAEH,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAgC,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACxF,OAAO,EAEL,KAAK,UAAU,EACf,KA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FecBlockProfile(value, where) {
|
|
|
27
27
|
// ../mmt-base/dist/catalog-fec-source.js
|
|
28
28
|
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
29
29
|
|
|
30
|
+
// src/repair-fetch.ts
|
|
31
|
+
import { extendSsId, repairFetchRange } from "@blockcast/mmt-fec";
|
|
32
|
+
|
|
30
33
|
// src/block-policy.ts
|
|
31
34
|
import { deriveFecInterleaveDepth } from "@blockcast/mmt-fec";
|
|
32
35
|
function repairPriorityForClass(blockClass) {
|
|
@@ -78,6 +81,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
78
81
|
if (typeof opts.presentationDelayMs !== "function") {
|
|
79
82
|
throw new Error("[RepairFetch] presentationDelayMs is required: a repair FETCH is due by the block's presentation deadline");
|
|
80
83
|
}
|
|
84
|
+
if (opts.rangeTransport !== void 0 && (typeof opts.repairEpochReference !== "function" || !mc.onUndelimitedLoss || !mc.closeIsoHoles)) {
|
|
85
|
+
throw new Error("[RepairFetch] rangeTransport needs repairEpochReference and a host that reports undelimited losses");
|
|
86
|
+
}
|
|
81
87
|
const entries = /* @__PURE__ */ new Map();
|
|
82
88
|
const warnedNoTarget = /* @__PURE__ */ new Set();
|
|
83
89
|
let disposed = false;
|
|
@@ -91,7 +97,12 @@ function wireRepairFetch(mc, opts) {
|
|
|
91
97
|
const note = (type, entry) => {
|
|
92
98
|
mc.noteRepairScheduling(type, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
93
99
|
};
|
|
100
|
+
const clearEntry = (entry) => {
|
|
101
|
+
if (entry.range) mc.closeIsoHoles(entry.packetId, entry.catalogTrackName, entry.sbn, entry.range.holeLength);
|
|
102
|
+
else clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
103
|
+
};
|
|
94
104
|
const releaseHold = (entry) => {
|
|
105
|
+
if (entry.range) return;
|
|
95
106
|
if (entry.catalogTrackName === void 0) mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId);
|
|
96
107
|
else mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
97
108
|
};
|
|
@@ -124,10 +135,10 @@ function wireRepairFetch(mc, opts) {
|
|
|
124
135
|
const admit = (entry, now) => {
|
|
125
136
|
const budgetMs = entry.deadlineAt - now;
|
|
126
137
|
const rttMs = readRtt();
|
|
127
|
-
if (rttMs !== null && rttMs < budgetMs) return
|
|
138
|
+
if (rttMs !== null && rttMs < budgetMs) return rttMs;
|
|
128
139
|
retire(entry);
|
|
129
140
|
releaseHold(entry);
|
|
130
|
-
|
|
141
|
+
clearEntry(entry);
|
|
131
142
|
mc.noteRepairSkipped(
|
|
132
143
|
rttMs === null ? "rtt-unmeasured" : "rtt-exceeds-budget",
|
|
133
144
|
{ rttMs, budgetMs, priority: entry.priority },
|
|
@@ -135,10 +146,11 @@ function wireRepairFetch(mc, opts) {
|
|
|
135
146
|
entry.packetId,
|
|
136
147
|
entry.catalogTrackName
|
|
137
148
|
);
|
|
138
|
-
return
|
|
149
|
+
return null;
|
|
139
150
|
};
|
|
140
151
|
const retire = (entry) => {
|
|
141
152
|
if (entries.get(entry.key) === entry) entries.delete(entry.key);
|
|
153
|
+
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
142
154
|
};
|
|
143
155
|
const urgentOutstanding = () => {
|
|
144
156
|
for (const entry of entries.values()) {
|
|
@@ -167,17 +179,28 @@ function wireRepairFetch(mc, opts) {
|
|
|
167
179
|
return derived.kind === "omit" ? { subscriberPriority: void 0 } : null;
|
|
168
180
|
};
|
|
169
181
|
const start = (entry, counted = true) => {
|
|
170
|
-
|
|
182
|
+
const now = performance.now();
|
|
183
|
+
const rttMs = admit(entry, now);
|
|
184
|
+
if (rttMs === null) return;
|
|
171
185
|
if (counted) entry.attempts++;
|
|
172
|
-
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName
|
|
186
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName, {
|
|
187
|
+
rttMs,
|
|
188
|
+
budgetMs: entry.deadlineAt - now,
|
|
189
|
+
delayMs: entry.delayMs,
|
|
190
|
+
blockAgeMs: entry.anchorAt === null ? null : Math.max(0, now - entry.anchorAt),
|
|
191
|
+
bound: entry.bound,
|
|
192
|
+
...entry.range ? { range: true } : {}
|
|
193
|
+
});
|
|
173
194
|
const run = { controller: new AbortController(), stopped: null };
|
|
174
195
|
entry.running = run;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
196
|
+
if (!entry.range) {
|
|
197
|
+
mc.fecManager.holdBlockForRepair(
|
|
198
|
+
entry.sbn,
|
|
199
|
+
entry.packetId,
|
|
200
|
+
entry.catalogTrackName,
|
|
201
|
+
entry.deadlineAt
|
|
202
|
+
);
|
|
203
|
+
}
|
|
181
204
|
void execute(entry, run);
|
|
182
205
|
};
|
|
183
206
|
const dispatch = () => {
|
|
@@ -189,14 +212,14 @@ function wireRepairFetch(mc, opts) {
|
|
|
189
212
|
if (entry.deadlineAt <= now) {
|
|
190
213
|
stop(entry, "expired");
|
|
191
214
|
retire(entry);
|
|
192
|
-
|
|
215
|
+
clearEntry(entry);
|
|
193
216
|
}
|
|
194
217
|
continue;
|
|
195
218
|
}
|
|
196
219
|
if (entry.deadlineAt <= now) {
|
|
197
220
|
retire(entry);
|
|
198
221
|
if (entry.priority === 2 && entry.attempts === 0) note("repair-deferred", entry);
|
|
199
|
-
|
|
222
|
+
clearEntry(entry);
|
|
200
223
|
continue;
|
|
201
224
|
}
|
|
202
225
|
queued.push(entry);
|
|
@@ -233,9 +256,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
233
256
|
entry.running = null;
|
|
234
257
|
if (error === void 0) {
|
|
235
258
|
retire(entry);
|
|
236
|
-
if (fed === 0 || !decodable(entry)) {
|
|
259
|
+
if (entry.range || fed === 0 || !decodable(entry)) {
|
|
237
260
|
releaseHold(entry);
|
|
238
|
-
|
|
261
|
+
clearEntry(entry);
|
|
239
262
|
}
|
|
240
263
|
dispatch();
|
|
241
264
|
return;
|
|
@@ -247,7 +270,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
247
270
|
}
|
|
248
271
|
retire(entry);
|
|
249
272
|
if (fed === 0) releaseHold(entry);
|
|
250
|
-
|
|
273
|
+
clearEntry(entry);
|
|
251
274
|
console.warn(
|
|
252
275
|
`[RepairFetch] fetch failed pid=${entry.packetId} sbn=${entry.sbn} track=${entry.repairTrack}:`,
|
|
253
276
|
error
|
|
@@ -263,15 +286,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
263
286
|
};
|
|
264
287
|
const execute = async (entry, run) => {
|
|
265
288
|
let fed = 0;
|
|
289
|
+
const common = {
|
|
290
|
+
repairTrack: entry.repairTrack,
|
|
291
|
+
blockProfile: entry.blockProfile,
|
|
292
|
+
packetId: entry.packetId,
|
|
293
|
+
signal: run.controller.signal,
|
|
294
|
+
subscriberPriority: entry.subscriberPriority
|
|
295
|
+
};
|
|
266
296
|
try {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
})) {
|
|
297
|
+
const packets = entry.range ? opts.rangeTransport({
|
|
298
|
+
...common,
|
|
299
|
+
startGroup: entry.range.startGroup,
|
|
300
|
+
endGroup: entry.range.endGroup,
|
|
301
|
+
lostSsId: entry.range.lostSsId
|
|
302
|
+
}) : opts.transport({ ...common, sbn: entry.sbn });
|
|
303
|
+
for await (const packet of packets) {
|
|
275
304
|
if (run.stopped !== null || entry.running !== run) break;
|
|
276
305
|
fed++;
|
|
277
306
|
if (entry.catalogTrackName === void 0) {
|
|
@@ -290,6 +319,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
290
319
|
if (entry.packetId !== packetId || entry.catalogTrackName !== catalogTrackName) continue;
|
|
291
320
|
retire(entry);
|
|
292
321
|
stop(entry, "reset");
|
|
322
|
+
if (entry.range) clearEntry(entry);
|
|
293
323
|
}
|
|
294
324
|
warnedNoTarget.delete(noTargetKey(packetId, catalogTrackName));
|
|
295
325
|
dispatch();
|
|
@@ -316,6 +346,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
316
346
|
);
|
|
317
347
|
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
318
348
|
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
349
|
+
entry2.anchorAt = promotedDeadline.anchorAt;
|
|
350
|
+
entry2.delayMs = promotedDeadline.delayMs;
|
|
351
|
+
entry2.bound = promotedDeadline.bound;
|
|
319
352
|
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
320
353
|
}
|
|
321
354
|
if (entry2.running) {
|
|
@@ -341,7 +374,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
341
374
|
if (waitMs === void 0) return null;
|
|
342
375
|
const waitDeadlineAt = now + waitMs;
|
|
343
376
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
344
|
-
if (anchor === void 0)
|
|
377
|
+
if (anchor === void 0) {
|
|
378
|
+
return { deadlineAt: waitDeadlineAt, extensionMs: 0, anchorAt: null, delayMs: null, bound: "wait" };
|
|
379
|
+
}
|
|
345
380
|
let delayMs;
|
|
346
381
|
try {
|
|
347
382
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -352,12 +387,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
352
387
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
353
388
|
if (retentionMs === void 0) return null;
|
|
354
389
|
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
355
|
-
const
|
|
356
|
-
|
|
390
|
+
const at = (delay, delayBound) => {
|
|
391
|
+
const presentAt = Math.min(anchor + delay, ceilingAt);
|
|
392
|
+
if (waitDeadlineAt >= presentAt) return { deadlineAt: waitDeadlineAt, bound: "wait" };
|
|
393
|
+
return { deadlineAt: presentAt, bound: anchor + delay <= ceilingAt ? delayBound : "retention" };
|
|
394
|
+
};
|
|
395
|
+
const base = at(delayMs, "presentation");
|
|
357
396
|
const budgetMs = keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) && groupCanComplete(sbn, packetId, catalogTrackName) ? readKeyframeBudget(packetId, catalogTrackName) : null;
|
|
358
|
-
if (budgetMs === null || budgetMs <= delayMs) return {
|
|
359
|
-
const extended =
|
|
360
|
-
return {
|
|
397
|
+
if (budgetMs === null || budgetMs <= delayMs) return { ...base, extensionMs: 0, anchorAt: anchor, delayMs };
|
|
398
|
+
const extended = at(budgetMs, "keyframe");
|
|
399
|
+
return {
|
|
400
|
+
...extended,
|
|
401
|
+
extensionMs: extended.deadlineAt - base.deadlineAt,
|
|
402
|
+
anchorAt: anchor,
|
|
403
|
+
delayMs: budgetMs
|
|
404
|
+
};
|
|
361
405
|
};
|
|
362
406
|
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
363
407
|
try {
|
|
@@ -434,6 +478,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
434
478
|
priority,
|
|
435
479
|
subscriberPriority: wire.subscriberPriority,
|
|
436
480
|
deadlineAt: deadline.deadlineAt,
|
|
481
|
+
anchorAt: deadline.anchorAt,
|
|
482
|
+
delayMs: deadline.delayMs,
|
|
483
|
+
bound: deadline.bound,
|
|
437
484
|
order: enqueueOrder++,
|
|
438
485
|
attempts: 0,
|
|
439
486
|
running: null
|
|
@@ -443,14 +490,92 @@ function wireRepairFetch(mc, opts) {
|
|
|
443
490
|
if (entry.priority < 2) preemptDeltas();
|
|
444
491
|
dispatch();
|
|
445
492
|
});
|
|
493
|
+
const rangeFor = (loss, repairTrack) => {
|
|
494
|
+
let reference;
|
|
495
|
+
try {
|
|
496
|
+
reference = opts.repairEpochReference(repairTrack);
|
|
497
|
+
} catch {
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
if (reference === void 0) return null;
|
|
501
|
+
try {
|
|
502
|
+
const anchor = loss.previousBlockStart === void 0 ? { reference } : { previousBlockStart: extendSsId(reference, loss.previousBlockStart) };
|
|
503
|
+
return repairFetchRange(loss.lostSsId, loss.kMax, anchor);
|
|
504
|
+
} catch (error) {
|
|
505
|
+
if (error instanceof RangeError) return null;
|
|
506
|
+
throw error;
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
if (opts.rangeTransport !== void 0) {
|
|
510
|
+
mc.onUndelimitedLoss((loss) => {
|
|
511
|
+
const { packetId, catalogTrackName, holeStart, holeLength } = loss;
|
|
512
|
+
const close = () => mc.closeIsoHoles(packetId, catalogTrackName, holeStart, holeLength);
|
|
513
|
+
if (disposed) return close();
|
|
514
|
+
const blockProfile = blockProfileOf(packetId);
|
|
515
|
+
const target = opts.resolveTarget(packetId, catalogTrackName);
|
|
516
|
+
if (!target) return close();
|
|
517
|
+
const priority = repairPriorityForClass("unknown");
|
|
518
|
+
const range = rangeFor(loss, target.repairTrack);
|
|
519
|
+
if (range === null) {
|
|
520
|
+
close();
|
|
521
|
+
mc.noteRepairSkipped("range-no-anchor", { rttMs: readRtt(), budgetMs: 0, priority }, holeStart, packetId, catalogTrackName);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const identity = {
|
|
525
|
+
target,
|
|
526
|
+
sbn: holeStart,
|
|
527
|
+
packetId,
|
|
528
|
+
...catalogTrackName === void 0 ? {} : { catalogTrackName }
|
|
529
|
+
};
|
|
530
|
+
const wire = wirePriority(identity, "unknown");
|
|
531
|
+
const deadline = presentationDeadlineAt(holeStart, packetId, catalogTrackName, performance.now(), "unknown");
|
|
532
|
+
if (deadline === null) {
|
|
533
|
+
close();
|
|
534
|
+
mc.noteRepairSkipped(
|
|
535
|
+
"presentation-delay-unavailable",
|
|
536
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
537
|
+
holeStart,
|
|
538
|
+
packetId,
|
|
539
|
+
catalogTrackName
|
|
540
|
+
);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const entry = {
|
|
544
|
+
key: JSON.stringify(["range", packetId, catalogTrackName ?? null, holeStart]),
|
|
545
|
+
...identity,
|
|
546
|
+
repairTrack: target.repairTrack,
|
|
547
|
+
blockProfile,
|
|
548
|
+
priority,
|
|
549
|
+
subscriberPriority: wire.subscriberPriority,
|
|
550
|
+
deadlineAt: deadline.deadlineAt,
|
|
551
|
+
anchorAt: deadline.anchorAt,
|
|
552
|
+
delayMs: deadline.delayMs,
|
|
553
|
+
bound: deadline.bound,
|
|
554
|
+
order: enqueueOrder++,
|
|
555
|
+
attempts: 0,
|
|
556
|
+
running: null,
|
|
557
|
+
range: { ...range, lostSsId: loss.lostSsId, holeLength }
|
|
558
|
+
};
|
|
559
|
+
const previous = entries.get(entry.key);
|
|
560
|
+
if (previous) {
|
|
561
|
+
retire(previous);
|
|
562
|
+
stop(previous, "reset");
|
|
563
|
+
}
|
|
564
|
+
entries.set(entry.key, entry);
|
|
565
|
+
entry.expiry = setTimeout(dispatch, Math.max(0, entry.deadlineAt - performance.now()) + 1);
|
|
566
|
+
preemptDeltas();
|
|
567
|
+
dispatch();
|
|
568
|
+
});
|
|
569
|
+
}
|
|
446
570
|
return () => {
|
|
447
571
|
disposed = true;
|
|
448
572
|
removeResetObserver();
|
|
449
573
|
removeLifecycleObserver();
|
|
450
574
|
for (const entry of [...entries.values()]) {
|
|
451
|
-
|
|
575
|
+
clearEntry(entry);
|
|
452
576
|
if (entry.running) releaseHold(entry);
|
|
453
577
|
stop(entry, "disposed");
|
|
578
|
+
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
454
579
|
}
|
|
455
580
|
entries.clear();
|
|
456
581
|
};
|