@blockcast/mmt-container 0.4.0-main.c7ae84be5039 → 0.4.0-main.ca8cf388ed86
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/dist/browser-runtime.js +308 -45
- package/dist/browser-runtime.js.map +3 -3
- package/dist/fec-manager.d.ts +36 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +161 -23
- package/dist/fec-manager.js.map +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- 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.js +16 -8
- package/dist/manifest-auth-plan.js.map +4 -4
- package/dist/mmtp-container-parser.no-modules.js +16 -8
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-router.d.ts +14 -1
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +11 -0
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.js +16 -8
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-manager.d.ts +17 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +189 -23
- package/dist/multicast-manager.js.map +3 -3
- package/dist/no-modules.js +16 -8
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.d.ts +58 -5
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +122 -22
- package/dist/repair-fetch.js.map +3 -3
- package/dist/source-auth.js +442 -1
- package/dist/source-auth.js.map +4 -4
- package/package.json +5 -5
- package/src/fec-manager.ts +99 -14
- package/src/index.ts +3 -0
- package/src/iso-block-locator.ts +97 -6
- package/src/mmtp-router.ts +24 -0
- package/src/multicast-manager.ts +27 -0
- package/src/repair-fetch.ts +204 -25
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
package/dist/browser-runtime.js
CHANGED
|
@@ -12376,16 +12376,6 @@ var DeliveryGapEstimator = class {
|
|
|
12376
12376
|
|
|
12377
12377
|
// src/iso-block-locator.ts
|
|
12378
12378
|
var IsoBlockLocator = class _IsoBlockLocator {
|
|
12379
|
-
/** Known blocks and spans, in serial order of their start. */
|
|
12380
|
-
#blocks = [];
|
|
12381
|
-
/** Held first-arrival sources whose block no repair has stated yet. */
|
|
12382
|
-
#held = /* @__PURE__ */ new Map();
|
|
12383
|
-
/** End of contiguous coverage: the SS_ID the next unknown block starts at. */
|
|
12384
|
-
#coverageEnd;
|
|
12385
|
-
#kMax;
|
|
12386
|
-
#retentionBlocks;
|
|
12387
|
-
#heldEvicted = 0;
|
|
12388
|
-
#newest;
|
|
12389
12379
|
/**
|
|
12390
12380
|
* @param kMax the catalog maximum K (`sourceSymbols`), the bound on SSB_length.
|
|
12391
12381
|
* @param retentionBlocks how many blocks behind the newest position the
|
|
@@ -12393,12 +12383,35 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12393
12383
|
* no locator exists without retention.
|
|
12394
12384
|
*/
|
|
12395
12385
|
constructor(kMax, retentionBlocks) {
|
|
12386
|
+
/** Known blocks and spans, in serial order of their start. */
|
|
12387
|
+
this.#blocks = [];
|
|
12388
|
+
/** Held first-arrival sources whose block no repair has stated yet. */
|
|
12389
|
+
this.#held = /* @__PURE__ */ new Map();
|
|
12390
|
+
this.#heldEvicted = 0;
|
|
12391
|
+
/** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
|
|
12392
|
+
this.#holes = [];
|
|
12393
|
+
/**
|
|
12394
|
+
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
12395
|
+
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
12396
|
+
* its blocks. Set only while a range repair scheduler is wired; its owner
|
|
12397
|
+
* must close every hole it is told about (`closeHolesWithin`).
|
|
12398
|
+
*/
|
|
12399
|
+
this.deferIncompleteGaps = false;
|
|
12396
12400
|
if (!Number.isSafeInteger(kMax) || kMax <= 0) {
|
|
12397
12401
|
throw new Error(`[IsoBlockLocator] maximum K must be a positive integer (got ${kMax})`);
|
|
12398
12402
|
}
|
|
12399
12403
|
this.#kMax = kMax;
|
|
12400
12404
|
this.#retentionBlocks = _IsoBlockLocator.#checkedRetention(retentionBlocks);
|
|
12401
12405
|
}
|
|
12406
|
+
#blocks;
|
|
12407
|
+
#held;
|
|
12408
|
+
/** End of contiguous coverage: the SS_ID the next unknown block starts at. */
|
|
12409
|
+
#coverageEnd;
|
|
12410
|
+
#kMax;
|
|
12411
|
+
#retentionBlocks;
|
|
12412
|
+
#heldEvicted;
|
|
12413
|
+
#newest;
|
|
12414
|
+
#holes;
|
|
12402
12415
|
static #checkedRetention(retentionBlocks) {
|
|
12403
12416
|
if (!Number.isSafeInteger(retentionBlocks) || retentionBlocks <= 0) {
|
|
12404
12417
|
throw new Error(
|
|
@@ -12461,6 +12474,14 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12461
12474
|
}
|
|
12462
12475
|
return null;
|
|
12463
12476
|
}
|
|
12477
|
+
/** Number of pending holes. */
|
|
12478
|
+
get holeCount() {
|
|
12479
|
+
return this.#holes.length;
|
|
12480
|
+
}
|
|
12481
|
+
/** The stated block (never a span) ending exactly at `end`. */
|
|
12482
|
+
blockEndingAt(end) {
|
|
12483
|
+
return this.#blocks.find((block) => !block.span && isoBlockEnd(block.start, block.length) === end);
|
|
12484
|
+
}
|
|
12464
12485
|
/** The known block or span starting exactly at `start`. */
|
|
12465
12486
|
blockAt(start) {
|
|
12466
12487
|
return this.#blocks.find((block) => block.start === start);
|
|
@@ -12483,6 +12504,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12483
12504
|
coversBetween(a, b) {
|
|
12484
12505
|
if (this.#coverageEnd === void 0) return false;
|
|
12485
12506
|
if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return true;
|
|
12507
|
+
const first = a + 1 >>> 0;
|
|
12508
|
+
const count = serial32Distance(a, b) - 1;
|
|
12509
|
+
if (this.#holes.some((hole) => isoRangesOverlap(first, count, hole.start, hole.length))) return false;
|
|
12486
12510
|
return serial32Precedes(b - 1 >>> 0, this.#coverageEnd);
|
|
12487
12511
|
}
|
|
12488
12512
|
/**
|
|
@@ -12530,6 +12554,22 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12530
12554
|
}
|
|
12531
12555
|
return { status: "placed", block: known, placed: [] };
|
|
12532
12556
|
}
|
|
12557
|
+
const pending = this.#holes.find((h) => isoBlockContains(h.start, h.length, start));
|
|
12558
|
+
if (pending !== void 0) {
|
|
12559
|
+
if (!isoBlockContains(pending.start, pending.length, serial32Add(start, length - 1))) {
|
|
12560
|
+
return { status: "overlap", reason: `repair block ${start}+${length} runs past pending hole ${pending.start}+${pending.length}` };
|
|
12561
|
+
}
|
|
12562
|
+
this.#holes.splice(this.#holes.indexOf(pending), 1);
|
|
12563
|
+
const before = serial32Distance(pending.start, start);
|
|
12564
|
+
const afterStart = isoBlockEnd(start, length);
|
|
12565
|
+
const after = pending.length - before - length;
|
|
12566
|
+
if (before > 0) this.#holes.push({ start: pending.start, length: before, span: false });
|
|
12567
|
+
if (after > 0) this.#holes.push({ start: afterStart, length: after, span: false });
|
|
12568
|
+
const block2 = { start, length, span: false };
|
|
12569
|
+
const placed2 = this.#claim(block2);
|
|
12570
|
+
this.#blocks.push(block2);
|
|
12571
|
+
return { status: "placed", block: block2, placed: placed2 };
|
|
12572
|
+
}
|
|
12533
12573
|
for (const block2 of this.#blocks) {
|
|
12534
12574
|
if (isoBlockContains(block2.start, block2.length, start) || isoBlockContains(start, length, block2.start)) {
|
|
12535
12575
|
return {
|
|
@@ -12539,6 +12579,7 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12539
12579
|
}
|
|
12540
12580
|
}
|
|
12541
12581
|
let span;
|
|
12582
|
+
let hole;
|
|
12542
12583
|
if (this.#coverageEnd === void 0) {
|
|
12543
12584
|
for (const ssId of this.#held.keys()) {
|
|
12544
12585
|
if (serial32Precedes(ssId, start)) this.#held.delete(ssId);
|
|
@@ -12547,21 +12588,51 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12547
12588
|
} else if (serial32Precedes(start, this.#coverageEnd)) {
|
|
12548
12589
|
return { status: "stale", reason: `repair block ${start}+${length} precedes known coverage` };
|
|
12549
12590
|
} else if (start !== this.#coverageEnd) {
|
|
12550
|
-
const
|
|
12551
|
-
|
|
12552
|
-
|
|
12553
|
-
span:
|
|
12554
|
-
|
|
12555
|
-
|
|
12556
|
-
|
|
12591
|
+
const gap = { start: this.#coverageEnd, length: serial32Distance(this.#coverageEnd, start) };
|
|
12592
|
+
const lostSsId = this.deferIncompleteGaps ? this.#highestMissing(gap.start, gap.length) : void 0;
|
|
12593
|
+
if (lostSsId !== void 0) {
|
|
12594
|
+
const holeBlock = { ...gap, span: false };
|
|
12595
|
+
this.#holes.push(holeBlock);
|
|
12596
|
+
hole = { block: holeBlock, lostSsId };
|
|
12597
|
+
} else {
|
|
12598
|
+
const spanBlock = { ...gap, span: true };
|
|
12599
|
+
span = { block: spanBlock, placed: this.#claim(spanBlock) };
|
|
12600
|
+
this.#blocks.push(spanBlock);
|
|
12601
|
+
}
|
|
12557
12602
|
}
|
|
12558
12603
|
const block = { start, length, span: false };
|
|
12559
12604
|
const placed = this.#claim(block);
|
|
12560
12605
|
this.#blocks.push(block);
|
|
12561
12606
|
this.#coverageEnd = isoBlockEnd(start, length);
|
|
12562
12607
|
this.retireBehind(start);
|
|
12608
|
+
if (hole !== void 0) return { status: "placed", block, placed, hole };
|
|
12563
12609
|
return span === void 0 ? { status: "placed", block, placed } : { status: "placed", block, placed, span };
|
|
12564
12610
|
}
|
|
12611
|
+
/**
|
|
12612
|
+
* Turn every pending hole inside `[start, start + length)` into a
|
|
12613
|
+
* repair-less span, claiming its held sources: its range FETCH ended, so
|
|
12614
|
+
* nothing more will state its blocks. Returns the spans, in SS_ID order.
|
|
12615
|
+
*/
|
|
12616
|
+
closeHolesWithin(start, length) {
|
|
12617
|
+
const closed = [];
|
|
12618
|
+
for (const hole of [...this.#holes]) {
|
|
12619
|
+
if (!isoBlockContains(start, length, hole.start)) continue;
|
|
12620
|
+
this.#holes.splice(this.#holes.indexOf(hole), 1);
|
|
12621
|
+
const spanBlock = { start: hole.start, length: hole.length, span: true };
|
|
12622
|
+
closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
|
|
12623
|
+
this.#blocks.push(spanBlock);
|
|
12624
|
+
}
|
|
12625
|
+
return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start));
|
|
12626
|
+
}
|
|
12627
|
+
/** The highest SS_ID in the range no source is held for, or undefined when all are. */
|
|
12628
|
+
#highestMissing(start, length) {
|
|
12629
|
+
const steps = Math.min(length, this.#held.size + 1);
|
|
12630
|
+
for (let i = 1; i <= steps; i++) {
|
|
12631
|
+
const ssId = serial32Add(start, length - i);
|
|
12632
|
+
if (!this.#held.has(ssId)) return ssId;
|
|
12633
|
+
}
|
|
12634
|
+
return void 0;
|
|
12635
|
+
}
|
|
12565
12636
|
/**
|
|
12566
12637
|
* Retire every block and span whose last SS_ID, and every held source,
|
|
12567
12638
|
* lies more than `retentionBlocks` blocks behind `position`, with the shared
|
|
@@ -12580,6 +12651,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12580
12651
|
this.#blocks.splice(i, 1);
|
|
12581
12652
|
}
|
|
12582
12653
|
}
|
|
12654
|
+
for (let i = this.#holes.length - 1; i >= 0; i--) {
|
|
12655
|
+
const hole = this.#holes[i];
|
|
12656
|
+
const last = serial32Add(hole.start, hole.length - 1);
|
|
12657
|
+
if (isoBlocksBehindLowerBound(last, position, this.#kMax) > horizon) this.#holes.splice(i, 1);
|
|
12658
|
+
}
|
|
12583
12659
|
for (const ssId of [...this.#held.keys()]) {
|
|
12584
12660
|
if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#held.delete(ssId);
|
|
12585
12661
|
}
|
|
@@ -12588,6 +12664,7 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12588
12664
|
/** Forget everything (publisher restart, track reset). */
|
|
12589
12665
|
reset() {
|
|
12590
12666
|
this.#blocks.length = 0;
|
|
12667
|
+
this.#holes.length = 0;
|
|
12591
12668
|
this.#held.clear();
|
|
12592
12669
|
this.#coverageEnd = void 0;
|
|
12593
12670
|
this.#newest = void 0;
|
|
@@ -12603,6 +12680,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12603
12680
|
return placed;
|
|
12604
12681
|
}
|
|
12605
12682
|
};
|
|
12683
|
+
function isoRangesOverlap(aStart, aLength, bStart, bLength) {
|
|
12684
|
+
return serial32Distance(aStart, bStart) < aLength || serial32Distance(bStart, aStart) < bLength;
|
|
12685
|
+
}
|
|
12606
12686
|
|
|
12607
12687
|
// src/fec-state.ts
|
|
12608
12688
|
var MIN_INTERLEAVE_DEPTH_MS = 1;
|
|
@@ -13357,6 +13437,7 @@ var FECManager = class _FECManager {
|
|
|
13357
13437
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
13358
13438
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
13359
13439
|
this.#isoLocators = /* @__PURE__ */ new Map();
|
|
13440
|
+
this.#deferIsoGaps = false;
|
|
13360
13441
|
this.#isoRepairRefusedCount = 0;
|
|
13361
13442
|
this.#isoSourceOversizeCount = 0;
|
|
13362
13443
|
// Held sources a locator's capacity cap evicted (IsoBlockLocator.heldCapacity):
|
|
@@ -13431,6 +13512,14 @@ var FECManager = class _FECManager {
|
|
|
13431
13512
|
this.onBlockReclassified = null;
|
|
13432
13513
|
/** A video stream's classifier mode was established or changed. */
|
|
13433
13514
|
this.onClassifierMode = null;
|
|
13515
|
+
/**
|
|
13516
|
+
* A repair stated a block past a gap that is missing a source and whose
|
|
13517
|
+
* every repair was lost: a lost SS_ID in an undelimited span
|
|
13518
|
+
* (draft-ramadan-moq-fec §7.5). Set with `setUndelimitedLossHandler`; the
|
|
13519
|
+
* receiver keeps the gap as a pending hole until `closeIsoHoles` is called
|
|
13520
|
+
* for it, which it must be.
|
|
13521
|
+
*/
|
|
13522
|
+
this.#onUndelimitedLoss = null;
|
|
13434
13523
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
13435
13524
|
this.onBlockVanished = null;
|
|
13436
13525
|
/** A block reached a terminal state (completed, recovered, or failed). */
|
|
@@ -13512,6 +13601,7 @@ var FECManager = class _FECManager {
|
|
|
13512
13601
|
#highestSbn;
|
|
13513
13602
|
#sourceFrontiers;
|
|
13514
13603
|
#isoLocators;
|
|
13604
|
+
#deferIsoGaps;
|
|
13515
13605
|
#isoRepairRefusedCount;
|
|
13516
13606
|
#isoSourceOversizeCount;
|
|
13517
13607
|
#isoHeldEvictedCount;
|
|
@@ -13525,6 +13615,7 @@ var FECManager = class _FECManager {
|
|
|
13525
13615
|
#workerErrorCounts;
|
|
13526
13616
|
#decoderUnavailableEvents;
|
|
13527
13617
|
#repairSymbolSizeMismatchCount;
|
|
13618
|
+
#onUndelimitedLoss;
|
|
13528
13619
|
#encodeTrackName(catalogTrackName) {
|
|
13529
13620
|
let encoded = this.#encodedTrackNames.get(catalogTrackName);
|
|
13530
13621
|
if (encoded === void 0) {
|
|
@@ -15269,6 +15360,7 @@ var FECManager = class _FECManager {
|
|
|
15269
15360
|
let locator = this.#isoLocators.get(streamKey);
|
|
15270
15361
|
if (!locator) {
|
|
15271
15362
|
locator = new IsoBlockLocator(this.#trackConfig(packetId).k, this.#isoRetentionBlocks(packetId));
|
|
15363
|
+
locator.deferIncompleteGaps = this.#deferIsoGaps;
|
|
15272
15364
|
this.#isoLocators.set(streamKey, locator);
|
|
15273
15365
|
}
|
|
15274
15366
|
return locator;
|
|
@@ -15365,15 +15457,61 @@ var FECManager = class _FECManager {
|
|
|
15365
15457
|
}
|
|
15366
15458
|
return placement;
|
|
15367
15459
|
}
|
|
15368
|
-
if (placement.span !== void 0)
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15460
|
+
if (placement.span !== void 0) this.#openIsoSpan(placement.span, packetId, catalogTrackName);
|
|
15461
|
+
if (placement.hole !== void 0) {
|
|
15462
|
+
const locator = this.#isoLocatorFor(packetId, catalogTrackName);
|
|
15463
|
+
const hole = placement.hole.block;
|
|
15464
|
+
const previous = locator.blockEndingAt(hole.start);
|
|
15465
|
+
const loss = {
|
|
15466
|
+
packetId,
|
|
15467
|
+
catalogTrackName,
|
|
15468
|
+
holeStart: hole.start,
|
|
15469
|
+
holeLength: hole.length,
|
|
15470
|
+
lostSsId: placement.hole.lostSsId,
|
|
15471
|
+
kMax: this.#trackConfig(packetId).k,
|
|
15472
|
+
...previous === void 0 ? {} : { previousBlockStart: previous.start }
|
|
15473
|
+
};
|
|
15474
|
+
this.#onUndelimitedLoss(loss);
|
|
15374
15475
|
}
|
|
15375
15476
|
return placement;
|
|
15376
15477
|
}
|
|
15478
|
+
/**
|
|
15479
|
+
* Keep an iso-ssbg1-v1 gap missing a source as a pending hole, reported to
|
|
15480
|
+
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
15481
|
+
* range repair scheduler; applies to every stream from its next gap. The
|
|
15482
|
+
* handler and the deferral are one setting, so no hole is ever created with
|
|
15483
|
+
* nobody to close it.
|
|
15484
|
+
*/
|
|
15485
|
+
setUndelimitedLossHandler(handler) {
|
|
15486
|
+
this.#onUndelimitedLoss = handler;
|
|
15487
|
+
this.#deferIsoGaps = handler !== null;
|
|
15488
|
+
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps;
|
|
15489
|
+
}
|
|
15490
|
+
/**
|
|
15491
|
+
* The range repair for a hole ended: every hole still pending inside
|
|
15492
|
+
* `[start, start + length)` becomes a repair-less span. Returns those spans
|
|
15493
|
+
* with the held sources they placed, for the caller to feed (MmtpRouter).
|
|
15494
|
+
*/
|
|
15495
|
+
closeIsoHoles(packetId, catalogTrackName, start, length) {
|
|
15496
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
|
|
15497
|
+
if (locator === void 0) return [];
|
|
15498
|
+
const spans = locator.closeHolesWithin(start, length);
|
|
15499
|
+
for (const span of spans) this.#openIsoSpan(span, packetId, catalogTrackName);
|
|
15500
|
+
return spans;
|
|
15501
|
+
}
|
|
15502
|
+
/**
|
|
15503
|
+
* A repair-less span has no repair to state its length, so it is known
|
|
15504
|
+
* here: its sources make it clean exactly when all of them arrived. A
|
|
15505
|
+
* stated block learns its SSB_length from its own repair symbol, fed after
|
|
15506
|
+
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
15507
|
+
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
15508
|
+
* block.
|
|
15509
|
+
*/
|
|
15510
|
+
#openIsoSpan(span, packetId, catalogTrackName) {
|
|
15511
|
+
const key = this.#blockKey(span.block.start, packetId, catalogTrackName);
|
|
15512
|
+
if (!this.#blockAuthoredLengths.has(key)) this.#blockAuthoredLengths.set(key, span.block.length);
|
|
15513
|
+
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true);
|
|
15514
|
+
}
|
|
15377
15515
|
/**
|
|
15378
15516
|
* Resolution of the SS_IDs strictly between two released frames' SS_IDs on
|
|
15379
15517
|
* an iso-ssbg1-v1 stream, for in-order frame release: null while a block
|
|
@@ -19930,6 +20068,17 @@ var MmtpRouter = class {
|
|
|
19930
20068
|
this.#routeRecoveredBlock(blockStart, recovered, ownerPacketId, catalogTrackName);
|
|
19931
20069
|
}
|
|
19932
20070
|
}
|
|
20071
|
+
/**
|
|
20072
|
+
* The range repair FETCH for an undelimited hole ended (draft-ramadan-moq-fec
|
|
20073
|
+
* §7.5): what no repair stated becomes repair-less spans, whose held sources
|
|
20074
|
+
* are fed exactly as a span a repair closed.
|
|
20075
|
+
*/
|
|
20076
|
+
closeIsoHoles(ownerPacketId, catalogTrackName, start, length) {
|
|
20077
|
+
const spans = this.#fecManager?.closeIsoHoles?.(ownerPacketId, catalogTrackName, start, length) ?? [];
|
|
20078
|
+
for (const span of spans) {
|
|
20079
|
+
this.#replayIsoSources(ownerPacketId, catalogTrackName, span.block.start, span.placed);
|
|
20080
|
+
}
|
|
20081
|
+
}
|
|
19933
20082
|
/**
|
|
19934
20083
|
* Feed iso-ssbg1-v1 sources a repair just placed, in SS_ID order, exactly as
|
|
19935
20084
|
* a first-arrival source is fed once its block is known: transport
|
|
@@ -23272,8 +23421,10 @@ function newBlockPolicyStats(packetId, catalogTrackName, epoch) {
|
|
|
23272
23421
|
repairsSkippedRttUnmeasured: 0,
|
|
23273
23422
|
repairsSkippedRttExceedsBudget: 0,
|
|
23274
23423
|
repairsSkippedPresentationDelayUnavailable: 0,
|
|
23424
|
+
repairsSkippedRangeNoAnchor: 0,
|
|
23275
23425
|
lastRepairSkip: null,
|
|
23276
23426
|
keyframeRepairFetchesSent: 0,
|
|
23427
|
+
rangeRepairFetchesSent: 0,
|
|
23277
23428
|
keyframeBudgetHolds: 0,
|
|
23278
23429
|
keyframeBudgetHoldMs: 0,
|
|
23279
23430
|
deltaBlocksFailed: 0,
|
|
@@ -24861,6 +25012,19 @@ var MulticastManager = class {
|
|
|
24861
25012
|
this.requestRepairForBlock(sbn, packetId, catalogTrackName, blockClass);
|
|
24862
25013
|
};
|
|
24863
25014
|
}
|
|
25015
|
+
/**
|
|
25016
|
+
* Register the range repair scheduler (draft-ramadan-moq-fec §7.5): from now
|
|
25017
|
+
* on an iso-ssbg1-v1 gap missing a source and every repair is kept as a
|
|
25018
|
+
* pending hole and reported here, and `closeIsoHoles` must be called for it
|
|
25019
|
+
* once its range FETCH ends (or none is sent).
|
|
25020
|
+
*/
|
|
25021
|
+
onUndelimitedLoss(cb) {
|
|
25022
|
+
this.#fec.setUndelimitedLossHandler(cb);
|
|
25023
|
+
}
|
|
25024
|
+
/** End a pending hole's range repair: feed what no repair stated as spans. */
|
|
25025
|
+
closeIsoHoles(packetId, catalogTrackName, start, length) {
|
|
25026
|
+
this.#router.closeIsoHoles(packetId, catalogTrackName, start, length);
|
|
25027
|
+
}
|
|
24864
25028
|
/**
|
|
24865
25029
|
* Record a repair request whose SUBSCRIBER_PRIORITY the catalog could not
|
|
24866
25030
|
* supply (draft-ramadan-moq-fec §11.4.5): sent without the parameter, or
|
|
@@ -24882,6 +25046,7 @@ var MulticastManager = class {
|
|
|
24882
25046
|
stats.repairsSkipped++;
|
|
24883
25047
|
if (reason === "rtt-unmeasured") stats.repairsSkippedRttUnmeasured++;
|
|
24884
25048
|
else if (reason === "rtt-exceeds-budget") stats.repairsSkippedRttExceedsBudget++;
|
|
25049
|
+
else if (reason === "range-no-anchor") stats.repairsSkippedRangeNoAnchor++;
|
|
24885
25050
|
else stats.repairsSkippedPresentationDelayUnavailable++;
|
|
24886
25051
|
stats.lastRepairSkip = {
|
|
24887
25052
|
reason,
|
|
@@ -24915,6 +25080,7 @@ var MulticastManager = class {
|
|
|
24915
25080
|
/** Record a repair FETCH the scheduler admitted and sent. */
|
|
24916
25081
|
noteRepairFetchSent(priority, sbn, packetId, catalogTrackName, measurement) {
|
|
24917
25082
|
if (priority === 0) this.#statsFor(packetId, catalogTrackName).keyframeRepairFetchesSent++;
|
|
25083
|
+
if (measurement.range) this.#statsFor(packetId, catalogTrackName).rangeRepairFetchesSent++;
|
|
24918
25084
|
this.#emitRepairLifecycle({
|
|
24919
25085
|
version: 2,
|
|
24920
25086
|
type: "repair-sent",
|
|
@@ -27222,6 +27388,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
27222
27388
|
if (typeof opts.presentationDelayMs !== "function") {
|
|
27223
27389
|
throw new Error("[RepairFetch] presentationDelayMs is required: a repair FETCH is due by the block's presentation deadline");
|
|
27224
27390
|
}
|
|
27391
|
+
if (opts.rangeTransport !== void 0 && (typeof opts.repairEpochReference !== "function" || !mc.onUndelimitedLoss || !mc.closeIsoHoles)) {
|
|
27392
|
+
throw new Error("[RepairFetch] rangeTransport needs repairEpochReference and a host that reports undelimited losses");
|
|
27393
|
+
}
|
|
27225
27394
|
const entries = /* @__PURE__ */ new Map();
|
|
27226
27395
|
const warnedNoTarget = /* @__PURE__ */ new Set();
|
|
27227
27396
|
let disposed = false;
|
|
@@ -27235,7 +27404,12 @@ function wireRepairFetch(mc, opts) {
|
|
|
27235
27404
|
const note = (type, entry) => {
|
|
27236
27405
|
mc.noteRepairScheduling(type, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
27237
27406
|
};
|
|
27407
|
+
const clearEntry = (entry) => {
|
|
27408
|
+
if (entry.range) mc.closeIsoHoles(entry.packetId, entry.catalogTrackName, entry.sbn, entry.range.holeLength);
|
|
27409
|
+
else clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
27410
|
+
};
|
|
27238
27411
|
const releaseHold = (entry) => {
|
|
27412
|
+
if (entry.range) return;
|
|
27239
27413
|
if (entry.catalogTrackName === void 0) mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId);
|
|
27240
27414
|
else mc.fecManager.releaseRepairHold(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
27241
27415
|
};
|
|
@@ -27271,7 +27445,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
27271
27445
|
if (rttMs !== null && rttMs < budgetMs) return rttMs;
|
|
27272
27446
|
retire(entry);
|
|
27273
27447
|
releaseHold(entry);
|
|
27274
|
-
|
|
27448
|
+
clearEntry(entry);
|
|
27275
27449
|
mc.noteRepairSkipped(
|
|
27276
27450
|
rttMs === null ? "rtt-unmeasured" : "rtt-exceeds-budget",
|
|
27277
27451
|
{ rttMs, budgetMs, priority: entry.priority },
|
|
@@ -27283,6 +27457,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
27283
27457
|
};
|
|
27284
27458
|
const retire = (entry) => {
|
|
27285
27459
|
if (entries.get(entry.key) === entry) entries.delete(entry.key);
|
|
27460
|
+
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
27286
27461
|
};
|
|
27287
27462
|
const urgentOutstanding = () => {
|
|
27288
27463
|
for (const entry of entries.values()) {
|
|
@@ -27320,16 +27495,19 @@ function wireRepairFetch(mc, opts) {
|
|
|
27320
27495
|
budgetMs: entry.deadlineAt - now,
|
|
27321
27496
|
delayMs: entry.delayMs,
|
|
27322
27497
|
blockAgeMs: entry.anchorAt === null ? null : Math.max(0, now - entry.anchorAt),
|
|
27323
|
-
bound: entry.bound
|
|
27498
|
+
bound: entry.bound,
|
|
27499
|
+
...entry.range ? { range: true } : {}
|
|
27324
27500
|
});
|
|
27325
27501
|
const run = { controller: new AbortController(), stopped: null };
|
|
27326
27502
|
entry.running = run;
|
|
27327
|
-
|
|
27328
|
-
|
|
27329
|
-
|
|
27330
|
-
|
|
27331
|
-
|
|
27332
|
-
|
|
27503
|
+
if (!entry.range) {
|
|
27504
|
+
mc.fecManager.holdBlockForRepair(
|
|
27505
|
+
entry.sbn,
|
|
27506
|
+
entry.packetId,
|
|
27507
|
+
entry.catalogTrackName,
|
|
27508
|
+
entry.deadlineAt
|
|
27509
|
+
);
|
|
27510
|
+
}
|
|
27333
27511
|
void execute(entry, run);
|
|
27334
27512
|
};
|
|
27335
27513
|
const dispatch = () => {
|
|
@@ -27341,14 +27519,14 @@ function wireRepairFetch(mc, opts) {
|
|
|
27341
27519
|
if (entry.deadlineAt <= now) {
|
|
27342
27520
|
stop(entry, "expired");
|
|
27343
27521
|
retire(entry);
|
|
27344
|
-
|
|
27522
|
+
clearEntry(entry);
|
|
27345
27523
|
}
|
|
27346
27524
|
continue;
|
|
27347
27525
|
}
|
|
27348
27526
|
if (entry.deadlineAt <= now) {
|
|
27349
27527
|
retire(entry);
|
|
27350
27528
|
if (entry.priority === 2 && entry.attempts === 0) note("repair-deferred", entry);
|
|
27351
|
-
|
|
27529
|
+
clearEntry(entry);
|
|
27352
27530
|
continue;
|
|
27353
27531
|
}
|
|
27354
27532
|
queued.push(entry);
|
|
@@ -27385,9 +27563,9 @@ function wireRepairFetch(mc, opts) {
|
|
|
27385
27563
|
entry.running = null;
|
|
27386
27564
|
if (error === void 0) {
|
|
27387
27565
|
retire(entry);
|
|
27388
|
-
if (fed === 0 || !decodable(entry)) {
|
|
27566
|
+
if (entry.range || fed === 0 || !decodable(entry)) {
|
|
27389
27567
|
releaseHold(entry);
|
|
27390
|
-
|
|
27568
|
+
clearEntry(entry);
|
|
27391
27569
|
}
|
|
27392
27570
|
dispatch();
|
|
27393
27571
|
return;
|
|
@@ -27399,7 +27577,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
27399
27577
|
}
|
|
27400
27578
|
retire(entry);
|
|
27401
27579
|
if (fed === 0) releaseHold(entry);
|
|
27402
|
-
|
|
27580
|
+
clearEntry(entry);
|
|
27403
27581
|
console.warn(
|
|
27404
27582
|
`[RepairFetch] fetch failed pid=${entry.packetId} sbn=${entry.sbn} track=${entry.repairTrack}:`,
|
|
27405
27583
|
error
|
|
@@ -27415,15 +27593,21 @@ function wireRepairFetch(mc, opts) {
|
|
|
27415
27593
|
};
|
|
27416
27594
|
const execute = async (entry, run) => {
|
|
27417
27595
|
let fed = 0;
|
|
27596
|
+
const common = {
|
|
27597
|
+
repairTrack: entry.repairTrack,
|
|
27598
|
+
blockProfile: entry.blockProfile,
|
|
27599
|
+
packetId: entry.packetId,
|
|
27600
|
+
signal: run.controller.signal,
|
|
27601
|
+
subscriberPriority: entry.subscriberPriority
|
|
27602
|
+
};
|
|
27418
27603
|
try {
|
|
27419
|
-
|
|
27420
|
-
|
|
27421
|
-
|
|
27422
|
-
|
|
27423
|
-
|
|
27424
|
-
|
|
27425
|
-
|
|
27426
|
-
})) {
|
|
27604
|
+
const packets = entry.range ? opts.rangeTransport({
|
|
27605
|
+
...common,
|
|
27606
|
+
startGroup: entry.range.startGroup,
|
|
27607
|
+
endGroup: entry.range.endGroup,
|
|
27608
|
+
lostSsId: entry.range.lostSsId
|
|
27609
|
+
}) : opts.transport({ ...common, sbn: entry.sbn });
|
|
27610
|
+
for await (const packet of packets) {
|
|
27427
27611
|
if (run.stopped !== null || entry.running !== run) break;
|
|
27428
27612
|
fed++;
|
|
27429
27613
|
if (entry.catalogTrackName === void 0) {
|
|
@@ -27442,6 +27626,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
27442
27626
|
if (entry.packetId !== packetId || entry.catalogTrackName !== catalogTrackName) continue;
|
|
27443
27627
|
retire(entry);
|
|
27444
27628
|
stop(entry, "reset");
|
|
27629
|
+
if (entry.range) clearEntry(entry);
|
|
27445
27630
|
}
|
|
27446
27631
|
warnedNoTarget.delete(noTargetKey(packetId, catalogTrackName));
|
|
27447
27632
|
dispatch();
|
|
@@ -27612,14 +27797,92 @@ function wireRepairFetch(mc, opts) {
|
|
|
27612
27797
|
if (entry.priority < 2) preemptDeltas();
|
|
27613
27798
|
dispatch();
|
|
27614
27799
|
});
|
|
27800
|
+
const rangeFor = (loss, repairTrack) => {
|
|
27801
|
+
let reference;
|
|
27802
|
+
try {
|
|
27803
|
+
reference = opts.repairEpochReference(repairTrack);
|
|
27804
|
+
} catch {
|
|
27805
|
+
return null;
|
|
27806
|
+
}
|
|
27807
|
+
if (reference === void 0) return null;
|
|
27808
|
+
try {
|
|
27809
|
+
const anchor = loss.previousBlockStart === void 0 ? { reference } : { previousBlockStart: extendSsId(reference, loss.previousBlockStart) };
|
|
27810
|
+
return repairFetchRange(loss.lostSsId, loss.kMax, anchor);
|
|
27811
|
+
} catch (error) {
|
|
27812
|
+
if (error instanceof RangeError) return null;
|
|
27813
|
+
throw error;
|
|
27814
|
+
}
|
|
27815
|
+
};
|
|
27816
|
+
if (opts.rangeTransport !== void 0) {
|
|
27817
|
+
mc.onUndelimitedLoss((loss) => {
|
|
27818
|
+
const { packetId, catalogTrackName, holeStart, holeLength } = loss;
|
|
27819
|
+
const close = () => mc.closeIsoHoles(packetId, catalogTrackName, holeStart, holeLength);
|
|
27820
|
+
if (disposed) return close();
|
|
27821
|
+
const blockProfile = blockProfileOf(packetId);
|
|
27822
|
+
const target = opts.resolveTarget(packetId, catalogTrackName);
|
|
27823
|
+
if (!target) return close();
|
|
27824
|
+
const priority = repairPriorityForClass("unknown");
|
|
27825
|
+
const range = rangeFor(loss, target.repairTrack);
|
|
27826
|
+
if (range === null) {
|
|
27827
|
+
close();
|
|
27828
|
+
mc.noteRepairSkipped("range-no-anchor", { rttMs: readRtt(), budgetMs: 0, priority }, holeStart, packetId, catalogTrackName);
|
|
27829
|
+
return;
|
|
27830
|
+
}
|
|
27831
|
+
const identity = {
|
|
27832
|
+
target,
|
|
27833
|
+
sbn: holeStart,
|
|
27834
|
+
packetId,
|
|
27835
|
+
...catalogTrackName === void 0 ? {} : { catalogTrackName }
|
|
27836
|
+
};
|
|
27837
|
+
const wire = wirePriority(identity, "unknown");
|
|
27838
|
+
const deadline = presentationDeadlineAt(holeStart, packetId, catalogTrackName, performance.now(), "unknown");
|
|
27839
|
+
if (deadline === null) {
|
|
27840
|
+
close();
|
|
27841
|
+
mc.noteRepairSkipped(
|
|
27842
|
+
"presentation-delay-unavailable",
|
|
27843
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
27844
|
+
holeStart,
|
|
27845
|
+
packetId,
|
|
27846
|
+
catalogTrackName
|
|
27847
|
+
);
|
|
27848
|
+
return;
|
|
27849
|
+
}
|
|
27850
|
+
const entry = {
|
|
27851
|
+
key: JSON.stringify(["range", packetId, catalogTrackName ?? null, holeStart]),
|
|
27852
|
+
...identity,
|
|
27853
|
+
repairTrack: target.repairTrack,
|
|
27854
|
+
blockProfile,
|
|
27855
|
+
priority,
|
|
27856
|
+
subscriberPriority: wire.subscriberPriority,
|
|
27857
|
+
deadlineAt: deadline.deadlineAt,
|
|
27858
|
+
anchorAt: deadline.anchorAt,
|
|
27859
|
+
delayMs: deadline.delayMs,
|
|
27860
|
+
bound: deadline.bound,
|
|
27861
|
+
order: enqueueOrder++,
|
|
27862
|
+
attempts: 0,
|
|
27863
|
+
running: null,
|
|
27864
|
+
range: { ...range, lostSsId: loss.lostSsId, holeLength }
|
|
27865
|
+
};
|
|
27866
|
+
const previous = entries.get(entry.key);
|
|
27867
|
+
if (previous) {
|
|
27868
|
+
retire(previous);
|
|
27869
|
+
stop(previous, "reset");
|
|
27870
|
+
}
|
|
27871
|
+
entries.set(entry.key, entry);
|
|
27872
|
+
entry.expiry = setTimeout(dispatch, Math.max(0, entry.deadlineAt - performance.now()) + 1);
|
|
27873
|
+
preemptDeltas();
|
|
27874
|
+
dispatch();
|
|
27875
|
+
});
|
|
27876
|
+
}
|
|
27615
27877
|
return () => {
|
|
27616
27878
|
disposed = true;
|
|
27617
27879
|
removeResetObserver();
|
|
27618
27880
|
removeLifecycleObserver();
|
|
27619
27881
|
for (const entry of [...entries.values()]) {
|
|
27620
|
-
|
|
27882
|
+
clearEntry(entry);
|
|
27621
27883
|
if (entry.running) releaseHold(entry);
|
|
27622
27884
|
stop(entry, "disposed");
|
|
27885
|
+
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
27623
27886
|
}
|
|
27624
27887
|
entries.clear();
|
|
27625
27888
|
};
|