@blockcast/mmt-container 0.4.0 → 0.4.1-main.2e0aa69d293d
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 +37 -21
- 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 +5070 -908
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +76 -39
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +321 -205
- 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 +28 -7
- 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/cmcd-producer.d.ts +13 -1
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +14 -0
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.js +115 -235
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +113 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +464 -66
- package/dist/fec-manager.js.map +4 -4
- 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 +10 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -4
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.d.ts +58 -0
- package/dist/held-layer-admission.d.ts.map +1 -0
- package/dist/held-layer-admission.js +105 -0
- package/dist/held-layer-admission.js.map +7 -0
- 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 +39 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +109 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +21 -13
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +93 -22
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +3692 -1213
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +93 -22
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +192 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +640 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +101 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +422 -189
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +94 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +746 -131
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +31 -8
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +299 -35
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +140 -12
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +4104 -605
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +16 -3
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +127 -240
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +21 -13
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +5 -3
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +3643 -1197
- 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 +90 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +160 -32
- 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/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.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/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +21 -13
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js +93 -22
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -18
- package/schemas/catalog.schema.json +133 -38
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +188 -68
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +49 -7
- package/src/catalog-validator.ts +4 -11
- package/src/cmcd-producer.ts +23 -1
- package/src/fec-manager.ts +378 -63
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +30 -2
- package/src/held-layer-admission.ts +161 -0
- package/src/index.ts +32 -19
- package/src/iso-block-locator.ts +110 -7
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +606 -0
- package/src/mmtp-router.ts +453 -236
- package/src/multicast-auth-catalog.ts +196 -231
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +447 -53
- package/src/multicast-transport.ts +23 -5
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +306 -42
- package/src/repair-layers.ts +22 -2
- package/src/sample-combiner.ts +15 -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 +71 -4
- 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-amt-driad-with-relay.json +38 -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 +3 -3
- 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 +31 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +101 -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/dist/manifest-auth-plan.d.ts +0 -30
- package/dist/manifest-auth-plan.d.ts.map +0 -1
- package/dist/manifest-auth-plan.js +0 -1266
- package/dist/manifest-auth-plan.js.map +0 -7
- package/dist/source-auth.d.ts +0 -2
- package/dist/source-auth.d.ts.map +0 -1
- package/dist/source-auth.js +0 -1209
- package/dist/source-auth.js.map +0 -7
- package/src/fec-codec.ts +0 -61
- package/src/manifest-auth-plan.ts +0 -107
- package/src/source-auth.ts +0 -1
- package/test-vectors/generate-source-auth-fixture.mjs +0 -114
- package/test-vectors/source-auth-v1.json +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,EAAE,KAAK,CAAC;IACjB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;+CAG2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG;QAAE,SAAS,EAAE,YAAY,CAAA;KAAE,CAAC;CAC9D;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,oBAAoB,EAAE,CAAC;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,CA2CH;AAMD;;;;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,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,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,O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B,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,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,K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W,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,40 @@ 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
|
+
* The block lost more sources than its repair group carries symbols
|
|
344
|
+
* (sources + RSB_length < K'): no FETCH of the group can complete it, and
|
|
345
|
+
* when multicast already delivered the whole group the relay could serve
|
|
346
|
+
* only duplicates (BLO-50082).
|
|
347
|
+
*/
|
|
348
|
+
| 'group-cannot-complete';
|
|
349
|
+
/**
|
|
350
|
+
* Which term set a FETCH's deadline (BLO-33597): the multicast wait, the
|
|
351
|
+
* player's presentation delay past the block anchor, the keyframe budget past
|
|
352
|
+
* the anchor (when it granted more than the presentation delay), or the
|
|
353
|
+
* release gate's retention ceiling.
|
|
354
|
+
*/
|
|
355
|
+
export type RepairDeadlineBound = 'wait' | 'presentation' | 'keyframe' | 'retention';
|
|
356
|
+
/** The admission inputs of a FETCH the scheduler sent (BLO-33597). */
|
|
357
|
+
export interface RepairSendMeasurement {
|
|
358
|
+
/** The reliable-path RTT admission compared against `budgetMs`. */
|
|
359
|
+
readonly rttMs: number;
|
|
360
|
+
/** Time left to the entry's deadline when the FETCH was sent. */
|
|
361
|
+
readonly budgetMs: number;
|
|
362
|
+
/**
|
|
363
|
+
* Delay past the block anchor the deadline was computed from; null when
|
|
364
|
+
* the block had no anchor (its deadline is then the multicast wait).
|
|
365
|
+
*/
|
|
366
|
+
readonly delayMs: number | null;
|
|
367
|
+
/** Time since the block anchor; null when the block had no anchor. */
|
|
368
|
+
readonly blockAgeMs: number | null;
|
|
369
|
+
readonly bound: RepairDeadlineBound;
|
|
370
|
+
/** True for a range repair FETCH (§7.5 lost SS_ID); absent for a block FETCH. */
|
|
371
|
+
readonly range?: true;
|
|
372
|
+
}
|
|
295
373
|
/** The subset of MulticastManager the scheduler drives. */
|
|
296
374
|
export interface RepairFetchHost {
|
|
297
375
|
readonly fecManager: {
|
|
@@ -330,8 +408,14 @@ export interface RepairFetchHost {
|
|
|
330
408
|
noteKeyframeBudgetGranted?(extensionMs: number, sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
331
409
|
addRepairLifecycleObserver(observer: RepairLifecycleObserver): () => void;
|
|
332
410
|
addTrackResetObserver(observer: (packetId: number, catalogTrackName: string) => void): () => void;
|
|
411
|
+
/** Register for lost SS_IDs in undelimited spans (required with `rangeTransport`). */
|
|
412
|
+
onUndelimitedLoss?(cb: (loss: UndelimitedIsoLoss) => void): void;
|
|
413
|
+
/** A hole's range repair ended, or none is sent: feed what was not stated. */
|
|
414
|
+
closeIsoHoles?(packetId: number, catalogTrackName: string | undefined, start: number, length: number): void;
|
|
333
415
|
clearRepairForBlock(sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
334
416
|
processRepairFromMoQ(packet: Uint8Array, ownerPacketId?: number, catalogTrackName?: string): void;
|
|
417
|
+
/** This scheduler can request unicast repair: protected flows keep pending entries for it (optional). */
|
|
418
|
+
setUnicastRepair?(enabled: boolean): void;
|
|
335
419
|
noteRepairScheduling(type: 'repair-preempted' | 'repair-deferred', sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
336
420
|
/** A request whose wire priority the catalog could not supply. */
|
|
337
421
|
noteRepairPriority(action: 'omitted' | 'declined', reason: RepairPriorityReason, blockClass: BlockClass, sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
@@ -349,7 +433,7 @@ export interface RepairFetchHost {
|
|
|
349
433
|
* A FETCH the scheduler admitted and handed to the transport (optional):
|
|
350
434
|
* every attempt, a retry or a reprioritised restart included.
|
|
351
435
|
*/
|
|
352
|
-
noteRepairFetchSent?(priority: RepairPriority, sbn: number, packetId: number, catalogTrackName
|
|
436
|
+
noteRepairFetchSent?(priority: RepairPriority, sbn: number, packetId: number, catalogTrackName: string | undefined, measurement: RepairSendMeasurement): void;
|
|
353
437
|
}
|
|
354
438
|
/**
|
|
355
439
|
* 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,KA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AAE,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAwqB7F"}
|
package/dist/repair-fetch.js
CHANGED
|
@@ -27,6 +27,9 @@ function parseFecBlockProfile(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,10 @@ 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
|
+
}
|
|
87
|
+
mc.setUnicastRepair?.(true);
|
|
81
88
|
const entries = /* @__PURE__ */ new Map();
|
|
82
89
|
const warnedNoTarget = /* @__PURE__ */ new Set();
|
|
83
90
|
let disposed = false;
|
|
@@ -91,7 +98,12 @@ function wireRepairFetch(mc, opts) {
|
|
|
91
98
|
const note = (type, entry) => {
|
|
92
99
|
mc.noteRepairScheduling(type, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
93
100
|
};
|
|
101
|
+
const clearEntry = (entry) => {
|
|
102
|
+
if (entry.range) mc.closeIsoHoles(entry.packetId, entry.catalogTrackName, entry.sbn, entry.range.holeLength);
|
|
103
|
+
else clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
104
|
+
};
|
|
94
105
|
const releaseHold = (entry) => {
|
|
106
|
+
if (entry.range) return;
|
|
95
107
|
if (entry.catalogTrackName === void 0) mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId);
|
|
96
108
|
else mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
97
109
|
};
|
|
@@ -124,21 +136,23 @@ function wireRepairFetch(mc, opts) {
|
|
|
124
136
|
const admit = (entry, now) => {
|
|
125
137
|
const budgetMs = entry.deadlineAt - now;
|
|
126
138
|
const rttMs = readRtt();
|
|
127
|
-
|
|
139
|
+
const reason = !entry.range && !groupCanComplete(entry.sbn, entry.packetId, entry.catalogTrackName) ? "group-cannot-complete" : rttMs === null ? "rtt-unmeasured" : rttMs < budgetMs ? null : "rtt-exceeds-budget";
|
|
140
|
+
if (reason === null) return rttMs;
|
|
128
141
|
retire(entry);
|
|
129
142
|
releaseHold(entry);
|
|
130
|
-
|
|
143
|
+
clearEntry(entry);
|
|
131
144
|
mc.noteRepairSkipped(
|
|
132
|
-
|
|
145
|
+
reason,
|
|
133
146
|
{ rttMs, budgetMs, priority: entry.priority },
|
|
134
147
|
entry.sbn,
|
|
135
148
|
entry.packetId,
|
|
136
149
|
entry.catalogTrackName
|
|
137
150
|
);
|
|
138
|
-
return
|
|
151
|
+
return null;
|
|
139
152
|
};
|
|
140
153
|
const retire = (entry) => {
|
|
141
154
|
if (entries.get(entry.key) === entry) entries.delete(entry.key);
|
|
155
|
+
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
142
156
|
};
|
|
143
157
|
const urgentOutstanding = () => {
|
|
144
158
|
for (const entry of entries.values()) {
|
|
@@ -167,17 +181,28 @@ function wireRepairFetch(mc, opts) {
|
|
|
167
181
|
return derived.kind === "omit" ? { subscriberPriority: void 0 } : null;
|
|
168
182
|
};
|
|
169
183
|
const start = (entry, counted = true) => {
|
|
170
|
-
|
|
184
|
+
const now = performance.now();
|
|
185
|
+
const rttMs = admit(entry, now);
|
|
186
|
+
if (rttMs === null) return;
|
|
171
187
|
if (counted) entry.attempts++;
|
|
172
|
-
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName
|
|
188
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName, {
|
|
189
|
+
rttMs,
|
|
190
|
+
budgetMs: entry.deadlineAt - now,
|
|
191
|
+
delayMs: entry.delayMs,
|
|
192
|
+
blockAgeMs: entry.anchorAt === null ? null : Math.max(0, now - entry.anchorAt),
|
|
193
|
+
bound: entry.bound,
|
|
194
|
+
...entry.range ? { range: true } : {}
|
|
195
|
+
});
|
|
173
196
|
const run = { controller: new AbortController(), stopped: null };
|
|
174
197
|
entry.running = run;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
198
|
+
if (!entry.range) {
|
|
199
|
+
mc.fecManager.holdBlockForRepair(
|
|
200
|
+
entry.sbn,
|
|
201
|
+
entry.packetId,
|
|
202
|
+
entry.catalogTrackName,
|
|
203
|
+
entry.deadlineAt
|
|
204
|
+
);
|
|
205
|
+
}
|
|
181
206
|
void execute(entry, run);
|
|
182
207
|
};
|
|
183
208
|
const dispatch = () => {
|
|
@@ -189,14 +214,14 @@ function wireRepairFetch(mc, opts) {
|
|
|
189
214
|
if (entry.deadlineAt <= now) {
|
|
190
215
|
stop(entry, "expired");
|
|
191
216
|
retire(entry);
|
|
192
|
-
|
|
217
|
+
clearEntry(entry);
|
|
193
218
|
}
|
|
194
219
|
continue;
|
|
195
220
|
}
|
|
196
221
|
if (entry.deadlineAt <= now) {
|
|
197
222
|
retire(entry);
|
|
198
223
|
if (entry.priority === 2 && entry.attempts === 0) note("repair-deferred", entry);
|
|
199
|
-
|
|
224
|
+
clearEntry(entry);
|
|
200
225
|
continue;
|
|
201
226
|
}
|
|
202
227
|
queued.push(entry);
|
|
@@ -233,9 +258,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
233
258
|
entry.running = null;
|
|
234
259
|
if (error === void 0) {
|
|
235
260
|
retire(entry);
|
|
236
|
-
if (fed === 0 || !decodable(entry)) {
|
|
261
|
+
if (entry.range || fed === 0 || !decodable(entry)) {
|
|
237
262
|
releaseHold(entry);
|
|
238
|
-
|
|
263
|
+
clearEntry(entry);
|
|
239
264
|
}
|
|
240
265
|
dispatch();
|
|
241
266
|
return;
|
|
@@ -247,7 +272,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
247
272
|
}
|
|
248
273
|
retire(entry);
|
|
249
274
|
if (fed === 0) releaseHold(entry);
|
|
250
|
-
|
|
275
|
+
clearEntry(entry);
|
|
251
276
|
console.warn(
|
|
252
277
|
`[RepairFetch] fetch failed pid=${entry.packetId} sbn=${entry.sbn} track=${entry.repairTrack}:`,
|
|
253
278
|
error
|
|
@@ -263,15 +288,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
263
288
|
};
|
|
264
289
|
const execute = async (entry, run) => {
|
|
265
290
|
let fed = 0;
|
|
291
|
+
const common = {
|
|
292
|
+
repairTrack: entry.repairTrack,
|
|
293
|
+
blockProfile: entry.blockProfile,
|
|
294
|
+
packetId: entry.packetId,
|
|
295
|
+
signal: run.controller.signal,
|
|
296
|
+
subscriberPriority: entry.subscriberPriority
|
|
297
|
+
};
|
|
266
298
|
try {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
})) {
|
|
299
|
+
const packets = entry.range ? opts.rangeTransport({
|
|
300
|
+
...common,
|
|
301
|
+
startGroup: entry.range.startGroup,
|
|
302
|
+
endGroup: entry.range.endGroup,
|
|
303
|
+
lostSsId: entry.range.lostSsId
|
|
304
|
+
}) : opts.transport({ ...common, sbn: entry.sbn });
|
|
305
|
+
for await (const packet of packets) {
|
|
275
306
|
if (run.stopped !== null || entry.running !== run) break;
|
|
276
307
|
fed++;
|
|
277
308
|
if (entry.catalogTrackName === void 0) {
|
|
@@ -290,6 +321,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
290
321
|
if (entry.packetId !== packetId || entry.catalogTrackName !== catalogTrackName) continue;
|
|
291
322
|
retire(entry);
|
|
292
323
|
stop(entry, "reset");
|
|
324
|
+
if (entry.range) clearEntry(entry);
|
|
293
325
|
}
|
|
294
326
|
warnedNoTarget.delete(noTargetKey(packetId, catalogTrackName));
|
|
295
327
|
dispatch();
|
|
@@ -316,6 +348,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
316
348
|
);
|
|
317
349
|
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
318
350
|
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
351
|
+
entry2.anchorAt = promotedDeadline.anchorAt;
|
|
352
|
+
entry2.delayMs = promotedDeadline.delayMs;
|
|
353
|
+
entry2.bound = promotedDeadline.bound;
|
|
319
354
|
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
320
355
|
}
|
|
321
356
|
if (entry2.running) {
|
|
@@ -341,7 +376,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
341
376
|
if (waitMs === void 0) return null;
|
|
342
377
|
const waitDeadlineAt = now + waitMs;
|
|
343
378
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
344
|
-
if (anchor === void 0)
|
|
379
|
+
if (anchor === void 0) {
|
|
380
|
+
return { deadlineAt: waitDeadlineAt, extensionMs: 0, anchorAt: null, delayMs: null, bound: "wait" };
|
|
381
|
+
}
|
|
345
382
|
let delayMs;
|
|
346
383
|
try {
|
|
347
384
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -352,12 +389,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
352
389
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
353
390
|
if (retentionMs === void 0) return null;
|
|
354
391
|
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
355
|
-
const
|
|
356
|
-
|
|
392
|
+
const at = (delay, delayBound) => {
|
|
393
|
+
const presentAt = Math.min(anchor + delay, ceilingAt);
|
|
394
|
+
if (waitDeadlineAt >= presentAt) return { deadlineAt: waitDeadlineAt, bound: "wait" };
|
|
395
|
+
return { deadlineAt: presentAt, bound: anchor + delay <= ceilingAt ? delayBound : "retention" };
|
|
396
|
+
};
|
|
397
|
+
const base = at(delayMs, "presentation");
|
|
357
398
|
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 {
|
|
399
|
+
if (budgetMs === null || budgetMs <= delayMs) return { ...base, extensionMs: 0, anchorAt: anchor, delayMs };
|
|
400
|
+
const extended = at(budgetMs, "keyframe");
|
|
401
|
+
return {
|
|
402
|
+
...extended,
|
|
403
|
+
extensionMs: extended.deadlineAt - base.deadlineAt,
|
|
404
|
+
anchorAt: anchor,
|
|
405
|
+
delayMs: budgetMs
|
|
406
|
+
};
|
|
361
407
|
};
|
|
362
408
|
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
363
409
|
try {
|
|
@@ -434,6 +480,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
434
480
|
priority,
|
|
435
481
|
subscriberPriority: wire.subscriberPriority,
|
|
436
482
|
deadlineAt: deadline.deadlineAt,
|
|
483
|
+
anchorAt: deadline.anchorAt,
|
|
484
|
+
delayMs: deadline.delayMs,
|
|
485
|
+
bound: deadline.bound,
|
|
437
486
|
order: enqueueOrder++,
|
|
438
487
|
attempts: 0,
|
|
439
488
|
running: null
|
|
@@ -443,14 +492,93 @@ function wireRepairFetch(mc, opts) {
|
|
|
443
492
|
if (entry.priority < 2) preemptDeltas();
|
|
444
493
|
dispatch();
|
|
445
494
|
});
|
|
495
|
+
const rangeFor = (loss, repairTrack) => {
|
|
496
|
+
let reference;
|
|
497
|
+
try {
|
|
498
|
+
reference = opts.repairEpochReference(repairTrack);
|
|
499
|
+
} catch {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
if (reference === void 0) return null;
|
|
503
|
+
try {
|
|
504
|
+
const anchor = loss.previousBlockStart === void 0 ? { reference } : { previousBlockStart: extendSsId(reference, loss.previousBlockStart) };
|
|
505
|
+
return repairFetchRange(loss.lostSsId, loss.kMax, anchor);
|
|
506
|
+
} catch (error) {
|
|
507
|
+
if (error instanceof RangeError) return null;
|
|
508
|
+
throw error;
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
if (opts.rangeTransport !== void 0) {
|
|
512
|
+
mc.onUndelimitedLoss((loss) => {
|
|
513
|
+
const { packetId, catalogTrackName, holeStart, holeLength } = loss;
|
|
514
|
+
const close = () => mc.closeIsoHoles(packetId, catalogTrackName, holeStart, holeLength);
|
|
515
|
+
if (disposed) return close();
|
|
516
|
+
const blockProfile = blockProfileOf(packetId);
|
|
517
|
+
const target = opts.resolveTarget(packetId, catalogTrackName);
|
|
518
|
+
if (!target) return close();
|
|
519
|
+
const priority = repairPriorityForClass("unknown");
|
|
520
|
+
const range = rangeFor(loss, target.repairTrack);
|
|
521
|
+
if (range === null) {
|
|
522
|
+
close();
|
|
523
|
+
mc.noteRepairSkipped("range-no-anchor", { rttMs: readRtt(), budgetMs: 0, priority }, holeStart, packetId, catalogTrackName);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
const identity = {
|
|
527
|
+
target,
|
|
528
|
+
sbn: holeStart,
|
|
529
|
+
packetId,
|
|
530
|
+
...catalogTrackName === void 0 ? {} : { catalogTrackName }
|
|
531
|
+
};
|
|
532
|
+
const wire = wirePriority(identity, "unknown");
|
|
533
|
+
const deadline = presentationDeadlineAt(holeStart, packetId, catalogTrackName, performance.now(), "unknown");
|
|
534
|
+
if (deadline === null) {
|
|
535
|
+
close();
|
|
536
|
+
mc.noteRepairSkipped(
|
|
537
|
+
"presentation-delay-unavailable",
|
|
538
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
539
|
+
holeStart,
|
|
540
|
+
packetId,
|
|
541
|
+
catalogTrackName
|
|
542
|
+
);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const entry = {
|
|
546
|
+
key: JSON.stringify(["range", packetId, catalogTrackName ?? null, holeStart]),
|
|
547
|
+
...identity,
|
|
548
|
+
repairTrack: target.repairTrack,
|
|
549
|
+
blockProfile,
|
|
550
|
+
priority,
|
|
551
|
+
subscriberPriority: wire.subscriberPriority,
|
|
552
|
+
deadlineAt: deadline.deadlineAt,
|
|
553
|
+
anchorAt: deadline.anchorAt,
|
|
554
|
+
delayMs: deadline.delayMs,
|
|
555
|
+
bound: deadline.bound,
|
|
556
|
+
order: enqueueOrder++,
|
|
557
|
+
attempts: 0,
|
|
558
|
+
running: null,
|
|
559
|
+
range: { ...range, lostSsId: loss.lostSsId, holeLength }
|
|
560
|
+
};
|
|
561
|
+
const previous = entries.get(entry.key);
|
|
562
|
+
if (previous) {
|
|
563
|
+
retire(previous);
|
|
564
|
+
stop(previous, "reset");
|
|
565
|
+
}
|
|
566
|
+
entries.set(entry.key, entry);
|
|
567
|
+
entry.expiry = setTimeout(dispatch, Math.max(0, entry.deadlineAt - performance.now()) + 1);
|
|
568
|
+
preemptDeltas();
|
|
569
|
+
dispatch();
|
|
570
|
+
});
|
|
571
|
+
}
|
|
446
572
|
return () => {
|
|
447
573
|
disposed = true;
|
|
574
|
+
mc.setUnicastRepair?.(false);
|
|
448
575
|
removeResetObserver();
|
|
449
576
|
removeLifecycleObserver();
|
|
450
577
|
for (const entry of [...entries.values()]) {
|
|
451
|
-
|
|
578
|
+
clearEntry(entry);
|
|
452
579
|
if (entry.running) releaseHold(entry);
|
|
453
580
|
stop(entry, "disposed");
|
|
581
|
+
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
454
582
|
}
|
|
455
583
|
entries.clear();
|
|
456
584
|
};
|