@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
|
@@ -441,11 +441,16 @@ function catalogFecAvailable(fec) {
|
|
|
441
441
|
const block = recordOf(fec);
|
|
442
442
|
if (block === void 0)
|
|
443
443
|
return true;
|
|
444
|
+
if (fecAlgorithmUnimplemented(block["algorithm"]))
|
|
445
|
+
return false;
|
|
444
446
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
445
447
|
const profile = block["blockProfile"];
|
|
446
448
|
const profileOk = isFecBlockProfile(profile) || profile === void 0 && !declaresFecInstance;
|
|
447
449
|
return profileOk && (!declaresFecInstance || isoBlockSpanUsable(block));
|
|
448
450
|
}
|
|
451
|
+
function fecAlgorithmUnimplemented(algorithm) {
|
|
452
|
+
return typeof algorithm === "string" && algorithm !== "none" && algorithm !== "raptorq" && algorithm !== "reed-solomon";
|
|
453
|
+
}
|
|
449
454
|
|
|
450
455
|
// src/track-session.ts
|
|
451
456
|
import { fecBlockBudgetMs } from "@blockcast/mmt-fec";
|
|
@@ -564,16 +569,6 @@ import {
|
|
|
564
569
|
|
|
565
570
|
// src/iso-block-locator.ts
|
|
566
571
|
var IsoBlockLocator = class _IsoBlockLocator {
|
|
567
|
-
/** Known blocks and spans, in serial order of their start. */
|
|
568
|
-
#blocks = [];
|
|
569
|
-
/** Held first-arrival sources whose block no repair has stated yet. */
|
|
570
|
-
#held = /* @__PURE__ */ new Map();
|
|
571
|
-
/** End of contiguous coverage: the SS_ID the next unknown block starts at. */
|
|
572
|
-
#coverageEnd;
|
|
573
|
-
#kMax;
|
|
574
|
-
#retentionBlocks;
|
|
575
|
-
#heldEvicted = 0;
|
|
576
|
-
#newest;
|
|
577
572
|
/**
|
|
578
573
|
* @param kMax the catalog maximum K (`sourceSymbols`), the bound on SSB_length.
|
|
579
574
|
* @param retentionBlocks how many blocks behind the newest position the
|
|
@@ -581,12 +576,35 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
581
576
|
* no locator exists without retention.
|
|
582
577
|
*/
|
|
583
578
|
constructor(kMax, retentionBlocks) {
|
|
579
|
+
/** Known blocks and spans, in serial order of their start. */
|
|
580
|
+
this.#blocks = [];
|
|
581
|
+
/** Held first-arrival sources whose block no repair has stated yet. */
|
|
582
|
+
this.#held = /* @__PURE__ */ new Map();
|
|
583
|
+
this.#heldEvicted = 0;
|
|
584
|
+
/** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
|
|
585
|
+
this.#holes = [];
|
|
586
|
+
/**
|
|
587
|
+
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
588
|
+
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
589
|
+
* its blocks. Set only while a range repair scheduler is wired; its owner
|
|
590
|
+
* must close every hole it is told about (`closeHolesWithin`).
|
|
591
|
+
*/
|
|
592
|
+
this.deferIncompleteGaps = false;
|
|
584
593
|
if (!Number.isSafeInteger(kMax) || kMax <= 0) {
|
|
585
594
|
throw new Error(`[IsoBlockLocator] maximum K must be a positive integer (got ${kMax})`);
|
|
586
595
|
}
|
|
587
596
|
this.#kMax = kMax;
|
|
588
597
|
this.#retentionBlocks = _IsoBlockLocator.#checkedRetention(retentionBlocks);
|
|
589
598
|
}
|
|
599
|
+
#blocks;
|
|
600
|
+
#held;
|
|
601
|
+
/** End of contiguous coverage: the SS_ID the next unknown block starts at. */
|
|
602
|
+
#coverageEnd;
|
|
603
|
+
#kMax;
|
|
604
|
+
#retentionBlocks;
|
|
605
|
+
#heldEvicted;
|
|
606
|
+
#newest;
|
|
607
|
+
#holes;
|
|
590
608
|
static #checkedRetention(retentionBlocks) {
|
|
591
609
|
if (!Number.isSafeInteger(retentionBlocks) || retentionBlocks <= 0) {
|
|
592
610
|
throw new Error(
|
|
@@ -649,6 +667,14 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
649
667
|
}
|
|
650
668
|
return null;
|
|
651
669
|
}
|
|
670
|
+
/** Number of pending holes. */
|
|
671
|
+
get holeCount() {
|
|
672
|
+
return this.#holes.length;
|
|
673
|
+
}
|
|
674
|
+
/** The stated block (never a span) ending exactly at `end`. */
|
|
675
|
+
blockEndingAt(end) {
|
|
676
|
+
return this.#blocks.find((block) => !block.span && isoBlockEnd(block.start, block.length) === end);
|
|
677
|
+
}
|
|
652
678
|
/** The known block or span starting exactly at `start`. */
|
|
653
679
|
blockAt(start) {
|
|
654
680
|
return this.#blocks.find((block) => block.start === start);
|
|
@@ -671,6 +697,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
671
697
|
coversBetween(a, b) {
|
|
672
698
|
if (this.#coverageEnd === void 0) return false;
|
|
673
699
|
if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return true;
|
|
700
|
+
const first = a + 1 >>> 0;
|
|
701
|
+
const count = serial32Distance(a, b) - 1;
|
|
702
|
+
if (this.#holes.some((hole) => isoRangesOverlap(first, count, hole.start, hole.length))) return false;
|
|
674
703
|
return serial32Precedes(b - 1 >>> 0, this.#coverageEnd);
|
|
675
704
|
}
|
|
676
705
|
/**
|
|
@@ -718,6 +747,22 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
718
747
|
}
|
|
719
748
|
return { status: "placed", block: known, placed: [] };
|
|
720
749
|
}
|
|
750
|
+
const pending = this.#holes.find((h) => isoBlockContains(h.start, h.length, start));
|
|
751
|
+
if (pending !== void 0) {
|
|
752
|
+
if (!isoBlockContains(pending.start, pending.length, serial32Add(start, length - 1))) {
|
|
753
|
+
return { status: "overlap", reason: `repair block ${start}+${length} runs past pending hole ${pending.start}+${pending.length}` };
|
|
754
|
+
}
|
|
755
|
+
this.#holes.splice(this.#holes.indexOf(pending), 1);
|
|
756
|
+
const before = serial32Distance(pending.start, start);
|
|
757
|
+
const afterStart = isoBlockEnd(start, length);
|
|
758
|
+
const after = pending.length - before - length;
|
|
759
|
+
if (before > 0) this.#holes.push({ start: pending.start, length: before, span: false });
|
|
760
|
+
if (after > 0) this.#holes.push({ start: afterStart, length: after, span: false });
|
|
761
|
+
const block2 = { start, length, span: false };
|
|
762
|
+
const placed2 = this.#claim(block2);
|
|
763
|
+
this.#blocks.push(block2);
|
|
764
|
+
return { status: "placed", block: block2, placed: placed2 };
|
|
765
|
+
}
|
|
721
766
|
for (const block2 of this.#blocks) {
|
|
722
767
|
if (isoBlockContains(block2.start, block2.length, start) || isoBlockContains(start, length, block2.start)) {
|
|
723
768
|
return {
|
|
@@ -727,6 +772,7 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
727
772
|
}
|
|
728
773
|
}
|
|
729
774
|
let span;
|
|
775
|
+
let hole;
|
|
730
776
|
if (this.#coverageEnd === void 0) {
|
|
731
777
|
for (const ssId of this.#held.keys()) {
|
|
732
778
|
if (serial32Precedes(ssId, start)) this.#held.delete(ssId);
|
|
@@ -735,21 +781,51 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
735
781
|
} else if (serial32Precedes(start, this.#coverageEnd)) {
|
|
736
782
|
return { status: "stale", reason: `repair block ${start}+${length} precedes known coverage` };
|
|
737
783
|
} else if (start !== this.#coverageEnd) {
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
span:
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
784
|
+
const gap = { start: this.#coverageEnd, length: serial32Distance(this.#coverageEnd, start) };
|
|
785
|
+
const lostSsId = this.deferIncompleteGaps ? this.#highestMissing(gap.start, gap.length) : void 0;
|
|
786
|
+
if (lostSsId !== void 0) {
|
|
787
|
+
const holeBlock = { ...gap, span: false };
|
|
788
|
+
this.#holes.push(holeBlock);
|
|
789
|
+
hole = { block: holeBlock, lostSsId };
|
|
790
|
+
} else {
|
|
791
|
+
const spanBlock = { ...gap, span: true };
|
|
792
|
+
span = { block: spanBlock, placed: this.#claim(spanBlock) };
|
|
793
|
+
this.#blocks.push(spanBlock);
|
|
794
|
+
}
|
|
745
795
|
}
|
|
746
796
|
const block = { start, length, span: false };
|
|
747
797
|
const placed = this.#claim(block);
|
|
748
798
|
this.#blocks.push(block);
|
|
749
799
|
this.#coverageEnd = isoBlockEnd(start, length);
|
|
750
800
|
this.retireBehind(start);
|
|
801
|
+
if (hole !== void 0) return { status: "placed", block, placed, hole };
|
|
751
802
|
return span === void 0 ? { status: "placed", block, placed } : { status: "placed", block, placed, span };
|
|
752
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Turn every pending hole inside `[start, start + length)` into a
|
|
806
|
+
* repair-less span, claiming its held sources: its range FETCH ended, so
|
|
807
|
+
* nothing more will state its blocks. Returns the spans, in SS_ID order.
|
|
808
|
+
*/
|
|
809
|
+
closeHolesWithin(start, length) {
|
|
810
|
+
const closed = [];
|
|
811
|
+
for (const hole of [...this.#holes]) {
|
|
812
|
+
if (!isoBlockContains(start, length, hole.start)) continue;
|
|
813
|
+
this.#holes.splice(this.#holes.indexOf(hole), 1);
|
|
814
|
+
const spanBlock = { start: hole.start, length: hole.length, span: true };
|
|
815
|
+
closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
|
|
816
|
+
this.#blocks.push(spanBlock);
|
|
817
|
+
}
|
|
818
|
+
return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start));
|
|
819
|
+
}
|
|
820
|
+
/** The highest SS_ID in the range no source is held for, or undefined when all are. */
|
|
821
|
+
#highestMissing(start, length) {
|
|
822
|
+
const steps = Math.min(length, this.#held.size + 1);
|
|
823
|
+
for (let i = 1; i <= steps; i++) {
|
|
824
|
+
const ssId = serial32Add(start, length - i);
|
|
825
|
+
if (!this.#held.has(ssId)) return ssId;
|
|
826
|
+
}
|
|
827
|
+
return void 0;
|
|
828
|
+
}
|
|
753
829
|
/**
|
|
754
830
|
* Retire every block and span whose last SS_ID, and every held source,
|
|
755
831
|
* lies more than `retentionBlocks` blocks behind `position`, with the shared
|
|
@@ -768,6 +844,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
768
844
|
this.#blocks.splice(i, 1);
|
|
769
845
|
}
|
|
770
846
|
}
|
|
847
|
+
for (let i = this.#holes.length - 1; i >= 0; i--) {
|
|
848
|
+
const hole = this.#holes[i];
|
|
849
|
+
const last = serial32Add(hole.start, hole.length - 1);
|
|
850
|
+
if (isoBlocksBehindLowerBound(last, position, this.#kMax) > horizon) this.#holes.splice(i, 1);
|
|
851
|
+
}
|
|
771
852
|
for (const ssId of [...this.#held.keys()]) {
|
|
772
853
|
if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#held.delete(ssId);
|
|
773
854
|
}
|
|
@@ -776,6 +857,7 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
776
857
|
/** Forget everything (publisher restart, track reset). */
|
|
777
858
|
reset() {
|
|
778
859
|
this.#blocks.length = 0;
|
|
860
|
+
this.#holes.length = 0;
|
|
779
861
|
this.#held.clear();
|
|
780
862
|
this.#coverageEnd = void 0;
|
|
781
863
|
this.#newest = void 0;
|
|
@@ -791,6 +873,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
791
873
|
return placed;
|
|
792
874
|
}
|
|
793
875
|
};
|
|
876
|
+
function isoRangesOverlap(aStart, aLength, bStart, bLength) {
|
|
877
|
+
return serial32Distance(aStart, bStart) < aLength || serial32Distance(bStart, aStart) < bLength;
|
|
878
|
+
}
|
|
794
879
|
|
|
795
880
|
// src/fec-state.ts
|
|
796
881
|
var MIN_INTERLEAVE_DEPTH_MS = 1;
|
|
@@ -1265,6 +1350,7 @@ function decideGap(input) {
|
|
|
1265
1350
|
}
|
|
1266
1351
|
|
|
1267
1352
|
// src/fec-manager.ts
|
|
1353
|
+
var RS_MAX_BLOCK_SYMBOLS = 255;
|
|
1268
1354
|
var WORKER_ERROR_LOG_CAP = 5;
|
|
1269
1355
|
var WORKER_ERROR_KIND_CAP = 32;
|
|
1270
1356
|
var WORKER_ERROR_OVERFLOW_KIND = "other";
|
|
@@ -1509,6 +1595,7 @@ var FECManager = class _FECManager {
|
|
|
1509
1595
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
1510
1596
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
1511
1597
|
this.#isoLocators = /* @__PURE__ */ new Map();
|
|
1598
|
+
this.#deferIsoGaps = false;
|
|
1512
1599
|
this.#isoRepairRefusedCount = 0;
|
|
1513
1600
|
this.#isoSourceOversizeCount = 0;
|
|
1514
1601
|
// Held sources a locator's capacity cap evicted (IsoBlockLocator.heldCapacity):
|
|
@@ -1583,6 +1670,14 @@ var FECManager = class _FECManager {
|
|
|
1583
1670
|
this.onBlockReclassified = null;
|
|
1584
1671
|
/** A video stream's classifier mode was established or changed. */
|
|
1585
1672
|
this.onClassifierMode = null;
|
|
1673
|
+
/**
|
|
1674
|
+
* A repair stated a block past a gap that is missing a source and whose
|
|
1675
|
+
* every repair was lost: a lost SS_ID in an undelimited span
|
|
1676
|
+
* (draft-ramadan-moq-fec §7.5). Set with `setUndelimitedLossHandler`; the
|
|
1677
|
+
* receiver keeps the gap as a pending hole until `closeIsoHoles` is called
|
|
1678
|
+
* for it, which it must be.
|
|
1679
|
+
*/
|
|
1680
|
+
this.#onUndelimitedLoss = null;
|
|
1586
1681
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
1587
1682
|
this.onBlockVanished = null;
|
|
1588
1683
|
/** A block reached a terminal state (completed, recovered, or failed). */
|
|
@@ -1664,6 +1759,7 @@ var FECManager = class _FECManager {
|
|
|
1664
1759
|
#highestSbn;
|
|
1665
1760
|
#sourceFrontiers;
|
|
1666
1761
|
#isoLocators;
|
|
1762
|
+
#deferIsoGaps;
|
|
1667
1763
|
#isoRepairRefusedCount;
|
|
1668
1764
|
#isoSourceOversizeCount;
|
|
1669
1765
|
#isoHeldEvictedCount;
|
|
@@ -1677,6 +1773,7 @@ var FECManager = class _FECManager {
|
|
|
1677
1773
|
#workerErrorCounts;
|
|
1678
1774
|
#decoderUnavailableEvents;
|
|
1679
1775
|
#repairSymbolSizeMismatchCount;
|
|
1776
|
+
#onUndelimitedLoss;
|
|
1680
1777
|
#encodeTrackName(catalogTrackName) {
|
|
1681
1778
|
let encoded = this.#encodedTrackNames.get(catalogTrackName);
|
|
1682
1779
|
if (encoded === void 0) {
|
|
@@ -2667,8 +2764,10 @@ var FECManager = class _FECManager {
|
|
|
2667
2764
|
);
|
|
2668
2765
|
}
|
|
2669
2766
|
const hasCatalogTiming = _FECManager.#hasCatalogTiming({ interleaveDepthMs: ownInterleaveDepthMs });
|
|
2767
|
+
const algorithm = config.algorithm ?? previous.algorithm;
|
|
2670
2768
|
const next = {
|
|
2671
2769
|
blockProfile,
|
|
2770
|
+
...algorithm === void 0 ? {} : { algorithm },
|
|
2672
2771
|
k,
|
|
2673
2772
|
symbolSize: config.symbolSize != null && config.symbolSize > 0 ? config.symbolSize : previousTrack?.symbolSize ?? 0,
|
|
2674
2773
|
interleaveDepthMs: ownInterleaveDepthMs,
|
|
@@ -3421,6 +3520,7 @@ var FECManager = class _FECManager {
|
|
|
3421
3520
|
let locator = this.#isoLocators.get(streamKey);
|
|
3422
3521
|
if (!locator) {
|
|
3423
3522
|
locator = new IsoBlockLocator(this.#trackConfig(packetId).k, this.#isoRetentionBlocks(packetId));
|
|
3523
|
+
locator.deferIncompleteGaps = this.#deferIsoGaps;
|
|
3424
3524
|
this.#isoLocators.set(streamKey, locator);
|
|
3425
3525
|
}
|
|
3426
3526
|
return locator;
|
|
@@ -3517,15 +3617,61 @@ var FECManager = class _FECManager {
|
|
|
3517
3617
|
}
|
|
3518
3618
|
return placement;
|
|
3519
3619
|
}
|
|
3520
|
-
if (placement.span !== void 0)
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3620
|
+
if (placement.span !== void 0) this.#openIsoSpan(placement.span, packetId, catalogTrackName);
|
|
3621
|
+
if (placement.hole !== void 0) {
|
|
3622
|
+
const locator = this.#isoLocatorFor(packetId, catalogTrackName);
|
|
3623
|
+
const hole = placement.hole.block;
|
|
3624
|
+
const previous = locator.blockEndingAt(hole.start);
|
|
3625
|
+
const loss = {
|
|
3626
|
+
packetId,
|
|
3627
|
+
catalogTrackName,
|
|
3628
|
+
holeStart: hole.start,
|
|
3629
|
+
holeLength: hole.length,
|
|
3630
|
+
lostSsId: placement.hole.lostSsId,
|
|
3631
|
+
kMax: this.#trackConfig(packetId).k,
|
|
3632
|
+
...previous === void 0 ? {} : { previousBlockStart: previous.start }
|
|
3633
|
+
};
|
|
3634
|
+
this.#onUndelimitedLoss(loss);
|
|
3526
3635
|
}
|
|
3527
3636
|
return placement;
|
|
3528
3637
|
}
|
|
3638
|
+
/**
|
|
3639
|
+
* Keep an iso-ssbg1-v1 gap missing a source as a pending hole, reported to
|
|
3640
|
+
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
3641
|
+
* range repair scheduler; applies to every stream from its next gap. The
|
|
3642
|
+
* handler and the deferral are one setting, so no hole is ever created with
|
|
3643
|
+
* nobody to close it.
|
|
3644
|
+
*/
|
|
3645
|
+
setUndelimitedLossHandler(handler) {
|
|
3646
|
+
this.#onUndelimitedLoss = handler;
|
|
3647
|
+
this.#deferIsoGaps = handler !== null;
|
|
3648
|
+
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps;
|
|
3649
|
+
}
|
|
3650
|
+
/**
|
|
3651
|
+
* The range repair for a hole ended: every hole still pending inside
|
|
3652
|
+
* `[start, start + length)` becomes a repair-less span. Returns those spans
|
|
3653
|
+
* with the held sources they placed, for the caller to feed (MmtpRouter).
|
|
3654
|
+
*/
|
|
3655
|
+
closeIsoHoles(packetId, catalogTrackName, start, length) {
|
|
3656
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
|
|
3657
|
+
if (locator === void 0) return [];
|
|
3658
|
+
const spans = locator.closeHolesWithin(start, length);
|
|
3659
|
+
for (const span of spans) this.#openIsoSpan(span, packetId, catalogTrackName);
|
|
3660
|
+
return spans;
|
|
3661
|
+
}
|
|
3662
|
+
/**
|
|
3663
|
+
* A repair-less span has no repair to state its length, so it is known
|
|
3664
|
+
* here: its sources make it clean exactly when all of them arrived. A
|
|
3665
|
+
* stated block learns its SSB_length from its own repair symbol, fed after
|
|
3666
|
+
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
3667
|
+
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
3668
|
+
* block.
|
|
3669
|
+
*/
|
|
3670
|
+
#openIsoSpan(span, packetId, catalogTrackName) {
|
|
3671
|
+
const key = this.#blockKey(span.block.start, packetId, catalogTrackName);
|
|
3672
|
+
if (!this.#blockAuthoredLengths.has(key)) this.#blockAuthoredLengths.set(key, span.block.length);
|
|
3673
|
+
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true);
|
|
3674
|
+
}
|
|
3529
3675
|
/**
|
|
3530
3676
|
* Resolution of the SS_IDs strictly between two released frames' SS_IDs on
|
|
3531
3677
|
* an iso-ssbg1-v1 stream, for in-order frame release: null while a block
|
|
@@ -4061,6 +4207,18 @@ var FECManager = class _FECManager {
|
|
|
4061
4207
|
* counted (BLO-48306). A packetId with no configured block profile admits
|
|
4062
4208
|
* nothing here; its repair is dropped upstream as unreadable.
|
|
4063
4209
|
*/
|
|
4210
|
+
/**
|
|
4211
|
+
* fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
|
|
4212
|
+
* exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
|
|
4213
|
+
* block state unchanged. The router calls this before the repair places a
|
|
4214
|
+
* block or takes any other part in block bookkeeping. A RaptorQ track admits
|
|
4215
|
+
* every header that parsed (its RS_ID < RSB_length check is in the parser).
|
|
4216
|
+
*/
|
|
4217
|
+
admitRepairBlockLength(packetId, ssbLength, rsbLength, rsId) {
|
|
4218
|
+
if (rsId >= rsbLength) return false;
|
|
4219
|
+
if (this.#trackConfigs.get(packetId)?.algorithm !== "reed-solomon") return true;
|
|
4220
|
+
return ssbLength + rsbLength <= RS_MAX_BLOCK_SYMBOLS;
|
|
4221
|
+
}
|
|
4064
4222
|
admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, byteLength) {
|
|
4065
4223
|
if (!this.#hasBlockProfile(packetId)) return false;
|
|
4066
4224
|
const symbolSize = this.#trackConfig(packetId).symbolSize;
|
|
@@ -12587,6 +12745,12 @@ var MmtpRouter = class {
|
|
|
12587
12745
|
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
12588
12746
|
*/
|
|
12589
12747
|
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
12748
|
+
/**
|
|
12749
|
+
* Streams whose multicast leg delivered a RAP-flagged source packet that was
|
|
12750
|
+
* not parsed, typically because its overlap copy was parsed first
|
|
12751
|
+
* (BLO-49179). The next video keyframe emitted on the stream consumes it.
|
|
12752
|
+
*/
|
|
12753
|
+
#multicastRapTwinByStream = /* @__PURE__ */ new Set();
|
|
12590
12754
|
#lastDirectSourceVideoTsByStream = /* @__PURE__ */ new Map();
|
|
12591
12755
|
#lastDirectEmittedVideoTsByStream = /* @__PURE__ */ new Map();
|
|
12592
12756
|
#pendingDirectRecoveredVideoByStream = /* @__PURE__ */ new Map();
|
|
@@ -12720,6 +12884,12 @@ var MmtpRouter = class {
|
|
|
12720
12884
|
...meta.catalogTrackName === void 0 ? {} : { catalogTrackName: meta.catalogTrackName }
|
|
12721
12885
|
};
|
|
12722
12886
|
if (meta.source) frameMeta.source = meta.source;
|
|
12887
|
+
if (isVideo && frameMeta.keyframe) {
|
|
12888
|
+
const twinSeen = this.#multicastRapTwinByStream.delete(
|
|
12889
|
+
this.#mediaStreamKey(packetId, frameMeta.catalogTrackName)
|
|
12890
|
+
);
|
|
12891
|
+
if (twinSeen && frameMeta.source === "moq") frameMeta.source = "multicast";
|
|
12892
|
+
}
|
|
12723
12893
|
if (meta.deliveryProvenance !== void 0)
|
|
12724
12894
|
frameMeta.deliveryProvenance = meta.deliveryProvenance;
|
|
12725
12895
|
if (meta.recovered) frameMeta.recovered = true;
|
|
@@ -13405,6 +13575,7 @@ var MmtpRouter = class {
|
|
|
13405
13575
|
`[MmtpRouter] packetId=${ownerPacketId} is iso-ssbg1-v1 but its FEC manager cannot place ISO blocks`
|
|
13406
13576
|
);
|
|
13407
13577
|
}
|
|
13578
|
+
if (fec.admitRepairBlockLength && !fec.admitRepairBlockLength(ownerPacketId, repair.ssbLength, repair.rsbLength, repair.rsId)) return;
|
|
13408
13579
|
if (fec.admitRepairSymbolSize && !fec.admitRepairSymbolSize(
|
|
13409
13580
|
ownerPacketId,
|
|
13410
13581
|
repair.ssStart,
|
|
@@ -13446,6 +13617,17 @@ var MmtpRouter = class {
|
|
|
13446
13617
|
this.#routeRecoveredBlock(blockStart, recovered, ownerPacketId, catalogTrackName);
|
|
13447
13618
|
}
|
|
13448
13619
|
}
|
|
13620
|
+
/**
|
|
13621
|
+
* The range repair FETCH for an undelimited hole ended (draft-ramadan-moq-fec
|
|
13622
|
+
* §7.5): what no repair stated becomes repair-less spans, whose held sources
|
|
13623
|
+
* are fed exactly as a span a repair closed.
|
|
13624
|
+
*/
|
|
13625
|
+
closeIsoHoles(ownerPacketId, catalogTrackName, start, length) {
|
|
13626
|
+
const spans = this.#fecManager?.closeIsoHoles?.(ownerPacketId, catalogTrackName, start, length) ?? [];
|
|
13627
|
+
for (const span of spans) {
|
|
13628
|
+
this.#replayIsoSources(ownerPacketId, catalogTrackName, span.block.start, span.placed);
|
|
13629
|
+
}
|
|
13630
|
+
}
|
|
13449
13631
|
/**
|
|
13450
13632
|
* Feed iso-ssbg1-v1 sources a repair just placed, in SS_ID order, exactly as
|
|
13451
13633
|
* a first-arrival source is fed once its block is known: transport
|
|
@@ -13542,6 +13724,7 @@ var MmtpRouter = class {
|
|
|
13542
13724
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
13543
13725
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
13544
13726
|
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
13727
|
+
this.#multicastRapTwinByStream.delete(streamKey);
|
|
13545
13728
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
13546
13729
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
13547
13730
|
this.#pendingDirectRecoveredVideoByStream.delete(streamKey);
|
|
@@ -14340,6 +14523,10 @@ var MmtpRouter = class {
|
|
|
14340
14523
|
// An FEC source frame is anchored by its own SS_ID (C.5.2).
|
|
14341
14524
|
...fecSource && fecPayloadId ? { fecSbn: fecPayloadId.ssId } : {}
|
|
14342
14525
|
}, parsed);
|
|
14526
|
+
} else if (source === "multicast" && info.rapFlag) {
|
|
14527
|
+
this.#multicastRapTwinByStream.add(
|
|
14528
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName)
|
|
14529
|
+
);
|
|
14343
14530
|
}
|
|
14344
14531
|
if (this.#classifyPacketId(info.packetId) === null) return;
|
|
14345
14532
|
if (this.#fecManager && fecPayloadId && coords && sourceSymbolAccepted && sourceSymbolTrackable) {
|
|
@@ -15393,14 +15580,6 @@ var MmtpRouter = class {
|
|
|
15393
15580
|
}
|
|
15394
15581
|
};
|
|
15395
15582
|
|
|
15396
|
-
// node_modules/@blockcast/mmt-transport/dist/types.js
|
|
15397
|
-
var MoqFecAlgorithm;
|
|
15398
|
-
(function(MoqFecAlgorithm2) {
|
|
15399
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["None"] = 0] = "None";
|
|
15400
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["Xor"] = 1] = "Xor";
|
|
15401
|
-
MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
|
|
15402
|
-
})(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
|
|
15403
|
-
|
|
15404
15583
|
// node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
|
|
15405
15584
|
function endpointKey(endpoint) {
|
|
15406
15585
|
return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
|
|
@@ -15531,8 +15710,8 @@ var AdaptiveBitrateController = class {
|
|
|
15531
15710
|
/**
|
|
15532
15711
|
* Update FEC statistics for ABR decisions
|
|
15533
15712
|
*
|
|
15534
|
-
*
|
|
15535
|
-
*
|
|
15713
|
+
* ABR uses the effective loss rate (after FEC recovery) rather than the
|
|
15714
|
+
* raw transport loss rate.
|
|
15536
15715
|
*
|
|
15537
15716
|
* @param stats - FEC statistics from the FEC decoder
|
|
15538
15717
|
*/
|
|
@@ -15884,6 +16063,20 @@ function toWindowMulticastSubscribeConfig(input) {
|
|
|
15884
16063
|
consume: "bytes",
|
|
15885
16064
|
...input.packetIds?.length ? { packetIds: [...input.packetIds] } : {}
|
|
15886
16065
|
};
|
|
16066
|
+
if (input.atsc3) {
|
|
16067
|
+
const { frequency, plpId, serviceId } = input.atsc3;
|
|
16068
|
+
if (!Number.isInteger(frequency) || frequency < 1) {
|
|
16069
|
+
throw new TypeError(`ATSC3 tuning requires a positive integer frequency in kHz, got ${String(frequency)}`);
|
|
16070
|
+
}
|
|
16071
|
+
return {
|
|
16072
|
+
...base,
|
|
16073
|
+
origin: "tuner",
|
|
16074
|
+
standard: "atsc3",
|
|
16075
|
+
frequency,
|
|
16076
|
+
...plpId !== void 0 ? { plpId } : {},
|
|
16077
|
+
...serviceId !== void 0 ? { serviceId } : {}
|
|
16078
|
+
};
|
|
16079
|
+
}
|
|
15887
16080
|
const relay = input.amtRelay?.trim();
|
|
15888
16081
|
const driad = !relay && input.amtDiscovery === "driad";
|
|
15889
16082
|
const wantsAmt = input.mode === "tunnel" || input.mode !== "native" && (relay !== void 0 && relay !== "" || driad);
|
|
@@ -16916,7 +17109,8 @@ var MulticastTransport = class {
|
|
|
16916
17109
|
amtRelayPort: config.amtRelayPort,
|
|
16917
17110
|
amtDiscovery: config.amtDiscovery,
|
|
16918
17111
|
packetIds: config.packetIds,
|
|
16919
|
-
tracks: config.tracks
|
|
17112
|
+
tracks: config.tracks,
|
|
17113
|
+
atsc3: config.atsc3
|
|
16920
17114
|
});
|
|
16921
17115
|
failure = "provider-rejected";
|
|
16922
17116
|
const subscription = await gateway.subscribe(subscribeConfig);
|
|
@@ -17506,16 +17700,6 @@ var MulticastTransport = class {
|
|
|
17506
17700
|
// src/multicast-manager.ts
|
|
17507
17701
|
import { deriveFecInterleaveDepth as deriveFecInterleaveDepth3, FecBlockMapper as FecBlockMapper2 } from "@blockcast/mmt-fec";
|
|
17508
17702
|
|
|
17509
|
-
// src/multicast-auth-catalog.ts
|
|
17510
|
-
var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
17511
|
-
var BASE64URL_DECODE_TABLE = (() => {
|
|
17512
|
-
const table = new Int8Array(128).fill(-1);
|
|
17513
|
-
for (let i = 0; i < BASE64URL_ALPHABET.length; i++) {
|
|
17514
|
-
table[BASE64URL_ALPHABET.charCodeAt(i)] = i;
|
|
17515
|
-
}
|
|
17516
|
-
return table;
|
|
17517
|
-
})();
|
|
17518
|
-
|
|
17519
17703
|
// src/repair-layers.ts
|
|
17520
17704
|
var RepairContractError = class extends Error {
|
|
17521
17705
|
constructor(code, path, message) {
|
|
@@ -17589,7 +17773,7 @@ function isFecCatalogGeometry(obj) {
|
|
|
17589
17773
|
const o = obj;
|
|
17590
17774
|
const algorithm = o["algorithm"];
|
|
17591
17775
|
const symbolSize = o["symbolSize"];
|
|
17592
|
-
return typeof algorithm === "string" &&
|
|
17776
|
+
return typeof algorithm === "string" && algorithm.length > 0 && typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 && typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 && typeof symbolSize === "number" && symbolSize >= 1 && (algorithm !== "raptorq" || symbolSize % 8 === 0) && typeof o["repairTrack"] === "string" && o["repairTrack"].length > 0;
|
|
17593
17777
|
}
|
|
17594
17778
|
function isFecCatalogConfig(obj) {
|
|
17595
17779
|
if (!isFecCatalogGeometry(obj)) return false;
|
|
@@ -17625,6 +17809,13 @@ function isoSpanUnavailable(fec, path, declaresFecInstance) {
|
|
|
17625
17809
|
function catalogFecUnavailable(fec, fecPath) {
|
|
17626
17810
|
if (catalogFecAvailable(fec)) return void 0;
|
|
17627
17811
|
const block = recordOf2(fec);
|
|
17812
|
+
if (fecAlgorithmUnimplemented(block["algorithm"])) {
|
|
17813
|
+
return Object.freeze({
|
|
17814
|
+
code: "track_fec_algorithm_unimplemented",
|
|
17815
|
+
path: `${fecPath}.algorithm`,
|
|
17816
|
+
message: `algorithm ${JSON.stringify(block["algorithm"])} is not implemented: the track plays without FEC`
|
|
17817
|
+
});
|
|
17818
|
+
}
|
|
17628
17819
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
17629
17820
|
const reason = blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ?? isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
|
|
17630
17821
|
if (reason === void 0) {
|
|
@@ -17667,8 +17858,10 @@ function newBlockPolicyStats(packetId, catalogTrackName, epoch) {
|
|
|
17667
17858
|
repairsSkippedRttUnmeasured: 0,
|
|
17668
17859
|
repairsSkippedRttExceedsBudget: 0,
|
|
17669
17860
|
repairsSkippedPresentationDelayUnavailable: 0,
|
|
17861
|
+
repairsSkippedRangeNoAnchor: 0,
|
|
17670
17862
|
lastRepairSkip: null,
|
|
17671
17863
|
keyframeRepairFetchesSent: 0,
|
|
17864
|
+
rangeRepairFetchesSent: 0,
|
|
17672
17865
|
keyframeBudgetHolds: 0,
|
|
17673
17866
|
keyframeBudgetHoldMs: 0,
|
|
17674
17867
|
deltaBlocksFailed: 0,
|
|
@@ -17747,6 +17940,12 @@ var REPAIR_PRIORITY_REASONS = /* @__PURE__ */ new Set([
|
|
|
17747
17940
|
"repair-priority-absent",
|
|
17748
17941
|
"repair-priority-invalid"
|
|
17749
17942
|
]);
|
|
17943
|
+
var REPAIR_SKIP_REASONS = /* @__PURE__ */ new Set([
|
|
17944
|
+
"rtt-unmeasured",
|
|
17945
|
+
"rtt-exceeds-budget",
|
|
17946
|
+
"presentation-delay-unavailable"
|
|
17947
|
+
]);
|
|
17948
|
+
var REPAIR_DEADLINE_BOUNDS = /* @__PURE__ */ new Set(["wait", "presentation", "keyframe", "retention"]);
|
|
17750
17949
|
var GAP_REASONS = {
|
|
17751
17950
|
"rap-lost": "stall",
|
|
17752
17951
|
"rap-unknown": "stall",
|
|
@@ -17769,6 +17968,9 @@ function isSymbolCounts(value) {
|
|
|
17769
17968
|
function isNullableNonNegative(value) {
|
|
17770
17969
|
return value === null || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
17771
17970
|
}
|
|
17971
|
+
function isFiniteNumber(value) {
|
|
17972
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
17973
|
+
}
|
|
17772
17974
|
function isRepairLifecycleEvent(value) {
|
|
17773
17975
|
if (!isRecord(value) || value["version"] !== 2) return false;
|
|
17774
17976
|
const block = value["block"];
|
|
@@ -17786,6 +17988,20 @@ function isRepairLifecycleEvent(value) {
|
|
|
17786
17988
|
case "repair-preempted":
|
|
17787
17989
|
case "repair-deferred":
|
|
17788
17990
|
return hasExactKeys(value, ["version", "type", "block"]) && isRepairBlockIdentity(block);
|
|
17991
|
+
case "repair-sent":
|
|
17992
|
+
return hasExactKeys(value, [
|
|
17993
|
+
"version",
|
|
17994
|
+
"type",
|
|
17995
|
+
"block",
|
|
17996
|
+
"priority",
|
|
17997
|
+
"rttMs",
|
|
17998
|
+
"budgetMs",
|
|
17999
|
+
"delayMs",
|
|
18000
|
+
"blockAgeMs",
|
|
18001
|
+
"bound"
|
|
18002
|
+
]) && isRepairBlockIdentity(block) && (value["priority"] === 0 || value["priority"] === 1 || value["priority"] === 2) && isFiniteNumber(value["rttMs"]) && value["rttMs"] > 0 && isFiniteNumber(value["budgetMs"]) && value["budgetMs"] > value["rttMs"] && isNullableNonNegative(value["delayMs"]) && isNullableNonNegative(value["blockAgeMs"]) && value["delayMs"] === null === (value["blockAgeMs"] === null) && REPAIR_DEADLINE_BOUNDS.has(value["bound"]);
|
|
18003
|
+
case "repair-skipped":
|
|
18004
|
+
return hasExactKeys(value, ["version", "type", "block", "reason", "rttMs", "budgetMs"]) && isRepairBlockIdentity(block) && REPAIR_SKIP_REASONS.has(value["reason"]) && isNullableNonNegative(value["rttMs"]) && isFiniteNumber(value["budgetMs"]);
|
|
17789
18005
|
case "repair-priority": {
|
|
17790
18006
|
const blockClass = value["blockClass"];
|
|
17791
18007
|
const action = value["action"];
|
|
@@ -18975,7 +19191,7 @@ var MulticastManager = class {
|
|
|
18975
19191
|
*
|
|
18976
19192
|
* D-04: Validates completeness via validateSwitchingSet — throws if incomplete.
|
|
18977
19193
|
* D-07: Applies per-track FEC configs (base+delta get decoders; repair does not).
|
|
18978
|
-
* D-17: Builds altGroup → track-name index for getSwitchingSet().
|
|
19194
|
+
* D-17: Builds altGroup → track-name index for getSwitchingSet() (repair legs excluded).
|
|
18979
19195
|
* D-26: Registers packetId → TrackRole on MmtpRouter for block-complete fanout.
|
|
18980
19196
|
*
|
|
18981
19197
|
* FEC availability is per track (draft-ramadan-moq-fec §5.1). A media track
|
|
@@ -19026,11 +19242,9 @@ var MulticastManager = class {
|
|
|
19026
19242
|
}
|
|
19027
19243
|
}
|
|
19028
19244
|
const repairOwnerGroup = /* @__PURE__ */ new Map();
|
|
19029
|
-
const repairOwnerAltGroup = /* @__PURE__ */ new Map();
|
|
19030
19245
|
for (const track of catalog.tracks) {
|
|
19031
19246
|
for (const repairName of repairNamesBySource.get(track.name) ?? []) {
|
|
19032
19247
|
repairOwnerGroup.set(repairName, altGroupKey(track));
|
|
19033
|
-
repairOwnerAltGroup.set(repairName, track.altGroup);
|
|
19034
19248
|
}
|
|
19035
19249
|
}
|
|
19036
19250
|
const groupKeyFor = (track) => repairOwnerGroup.get(track.name) ?? altGroupKey(track);
|
|
@@ -19129,11 +19343,10 @@ var MulticastManager = class {
|
|
|
19129
19343
|
for (let i = 0; i < catalog.tracks.length; i++) {
|
|
19130
19344
|
const track = catalog.tracks[i];
|
|
19131
19345
|
const role = resolvedRoles[i];
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
const existing = this.#switchingSets.get(altGroup) ?? [];
|
|
19346
|
+
if (role !== "repair" && track.altGroup !== void 0) {
|
|
19347
|
+
const existing = this.#switchingSets.get(track.altGroup) ?? [];
|
|
19135
19348
|
existing.push(track.name);
|
|
19136
|
-
this.#switchingSets.set(altGroup, existing);
|
|
19349
|
+
this.#switchingSets.set(track.altGroup, existing);
|
|
19137
19350
|
}
|
|
19138
19351
|
if (track.packetId !== void 0) {
|
|
19139
19352
|
this.#router.setPacketIdRole(track.packetId, role);
|
|
@@ -19208,7 +19421,7 @@ var MulticastManager = class {
|
|
|
19208
19421
|
#multiTrackFecTracks = /* @__PURE__ */ new Map();
|
|
19209
19422
|
/**
|
|
19210
19423
|
* Return the track names belonging to the given altGroup switching set.
|
|
19211
|
-
* D-17:
|
|
19424
|
+
* D-17: tracks with equal altGroup form one switching set; repair legs are in none.
|
|
19212
19425
|
*
|
|
19213
19426
|
* @param altGroup - The altGroup number to look up.
|
|
19214
19427
|
* @returns Array of track names in that switching set (empty if none).
|
|
@@ -19236,6 +19449,19 @@ var MulticastManager = class {
|
|
|
19236
19449
|
this.requestRepairForBlock(sbn, packetId, catalogTrackName, blockClass);
|
|
19237
19450
|
};
|
|
19238
19451
|
}
|
|
19452
|
+
/**
|
|
19453
|
+
* Register the range repair scheduler (draft-ramadan-moq-fec §7.5): from now
|
|
19454
|
+
* on an iso-ssbg1-v1 gap missing a source and every repair is kept as a
|
|
19455
|
+
* pending hole and reported here, and `closeIsoHoles` must be called for it
|
|
19456
|
+
* once its range FETCH ends (or none is sent).
|
|
19457
|
+
*/
|
|
19458
|
+
onUndelimitedLoss(cb) {
|
|
19459
|
+
this.#fec.setUndelimitedLossHandler(cb);
|
|
19460
|
+
}
|
|
19461
|
+
/** End a pending hole's range repair: feed what no repair stated as spans. */
|
|
19462
|
+
closeIsoHoles(packetId, catalogTrackName, start, length) {
|
|
19463
|
+
this.#router.closeIsoHoles(packetId, catalogTrackName, start, length);
|
|
19464
|
+
}
|
|
19239
19465
|
/**
|
|
19240
19466
|
* Record a repair request whose SUBSCRIBER_PRIORITY the catalog could not
|
|
19241
19467
|
* supply (draft-ramadan-moq-fec §11.4.5): sent without the parameter, or
|
|
@@ -19257,6 +19483,7 @@ var MulticastManager = class {
|
|
|
19257
19483
|
stats.repairsSkipped++;
|
|
19258
19484
|
if (reason === "rtt-unmeasured") stats.repairsSkippedRttUnmeasured++;
|
|
19259
19485
|
else if (reason === "rtt-exceeds-budget") stats.repairsSkippedRttExceedsBudget++;
|
|
19486
|
+
else if (reason === "range-no-anchor") stats.repairsSkippedRangeNoAnchor++;
|
|
19260
19487
|
else stats.repairsSkippedPresentationDelayUnavailable++;
|
|
19261
19488
|
stats.lastRepairSkip = {
|
|
19262
19489
|
reason,
|
|
@@ -19288,8 +19515,20 @@ var MulticastManager = class {
|
|
|
19288
19515
|
stats.keyframeBudgetHoldMs += extensionMs;
|
|
19289
19516
|
}
|
|
19290
19517
|
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
19291
|
-
noteRepairFetchSent(priority,
|
|
19518
|
+
noteRepairFetchSent(priority, sbn, packetId, catalogTrackName, measurement) {
|
|
19292
19519
|
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
19520
|
+
if (measurement.range) this.#statsFor(packetId, catalogTrackName).rangeRepairFetchesSent++;
|
|
19521
|
+
this.#emitRepairLifecycle({
|
|
19522
|
+
version: 2,
|
|
19523
|
+
type: "repair-sent",
|
|
19524
|
+
block: repairBlockIdentity(packetId, sbn, catalogTrackName),
|
|
19525
|
+
priority,
|
|
19526
|
+
rttMs: measurement.rttMs,
|
|
19527
|
+
budgetMs: measurement.budgetMs,
|
|
19528
|
+
delayMs: measurement.delayMs,
|
|
19529
|
+
blockAgeMs: measurement.blockAgeMs,
|
|
19530
|
+
bound: measurement.bound
|
|
19531
|
+
});
|
|
19293
19532
|
}
|
|
19294
19533
|
/**
|
|
19295
19534
|
* Record a repair-scheduler decision about a delta block: preempted for
|