@blockcast/mmt-container 2.2.0-main.b4ce3986f2dd → 2.2.0-main.c1482ff09fa3
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 +1300 -180
- package/dist/browser-runtime.js.map +3 -3
- package/dist/cmaf-block-assembler.js +92 -1
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/codec-utils.d.ts.map +1 -1
- package/dist/codec-utils.js +92 -1
- package/dist/codec-utils.js.map +2 -2
- package/dist/delivery-catalog.js +2 -1
- package/dist/delivery-catalog.js.map +2 -2
- package/dist/delta-fallback-config.js.map +1 -1
- package/dist/fec-manager.d.ts +74 -14
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +419 -61
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-worker-setup.js.map +1 -1
- 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 +48 -13
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +97 -25
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/iso-bmff-timing.d.ts +10 -1
- package/dist/iso-bmff-timing.d.ts.map +1 -1
- package/dist/iso-bmff-timing.js +36 -2
- package/dist/iso-bmff-timing.js.map +2 -2
- package/dist/media-router.js.map +1 -1
- package/dist/mmtp-container-parser.d.ts +77 -10
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +295 -27
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +297 -30
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +294 -27
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +34 -8
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +619 -75
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-manager.d.ts +26 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1120 -153
- package/dist/multicast-manager.js.map +3 -3
- package/dist/multicast-transport.js +4 -3
- package/dist/multicast-transport.js.map +2 -2
- package/dist/no-modules.js +294 -27
- package/dist/no-modules.js.map +3 -3
- package/dist/repair-fetch.d.ts +38 -8
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +286 -27
- package/dist/repair-fetch.js.map +3 -3
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +1 -0
- package/dist/track-session.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +294 -27
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/codec-utils.ts +121 -1
- package/src/fec-manager.ts +454 -35
- package/src/index.ts +3 -0
- package/src/iso-block-locator.ts +133 -31
- package/src/iso-bmff-timing.ts +40 -1
- package/src/mmtp-container-parser.ts +294 -29
- package/src/mmtp-router.ts +544 -55
- package/src/multicast-manager.ts +118 -14
- package/src/repair-fetch.ts +366 -50
- package/src/track-session.ts +3 -0
package/dist/fec-manager.js
CHANGED
|
@@ -327,6 +327,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
327
327
|
this.#heldEvicted = 0;
|
|
328
328
|
/** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
|
|
329
329
|
this.#holes = [];
|
|
330
|
+
/** Holes the horizon passed while pending: sources held until closed. */
|
|
331
|
+
this.#expired = [];
|
|
332
|
+
/** Of `#expired`, those `takeExpiredHoles` has not handed out yet. */
|
|
333
|
+
this.#newlyExpired = [];
|
|
334
|
+
/**
|
|
335
|
+
* Spans closed from expired holes: behind the horizon, so kept only for
|
|
336
|
+
* `locate` while their sources are fed, until the next retirement.
|
|
337
|
+
*/
|
|
338
|
+
this.#closedBehind = [];
|
|
330
339
|
/**
|
|
331
340
|
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
332
341
|
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
@@ -348,7 +357,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
348
357
|
#retentionBlocks;
|
|
349
358
|
#heldEvicted;
|
|
350
359
|
#newest;
|
|
360
|
+
#newestSource;
|
|
351
361
|
#holes;
|
|
362
|
+
#expired;
|
|
363
|
+
#newlyExpired;
|
|
364
|
+
#closedBehind;
|
|
352
365
|
static #checkedRetention(retentionBlocks) {
|
|
353
366
|
if (!Number.isSafeInteger(retentionBlocks) || retentionBlocks <= 0) {
|
|
354
367
|
throw new Error(
|
|
@@ -385,6 +398,21 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
385
398
|
observe(position) {
|
|
386
399
|
if (this.#newest === void 0 || serial32Precedes(this.#newest, position)) this.#newest = position;
|
|
387
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* The newest source SS_ID noted with `noteSource` (RFC 1982 order). Unlike
|
|
403
|
+
* `newest`, a repair never moves it: a repair can run ahead of its sources,
|
|
404
|
+
* a source cannot run ahead of the sources sent before it except by
|
|
405
|
+
* reordering.
|
|
406
|
+
*/
|
|
407
|
+
get newestSource() {
|
|
408
|
+
return this.#newestSource;
|
|
409
|
+
}
|
|
410
|
+
/** Note a received source's SS_ID; true when it is the newest one yet. */
|
|
411
|
+
noteSource(ssId) {
|
|
412
|
+
if (this.#newestSource !== void 0 && !serial32Precedes(this.#newestSource, ssId)) return false;
|
|
413
|
+
this.#newestSource = ssId;
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
388
416
|
/** Held sources evicted by `heldCapacity` (never by the horizon itself). */
|
|
389
417
|
get heldEvicted() {
|
|
390
418
|
return this.#heldEvicted;
|
|
@@ -403,17 +431,29 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
403
431
|
}
|
|
404
432
|
/** The known block or span containing `ssId`, with its ESI. */
|
|
405
433
|
locate(ssId) {
|
|
406
|
-
for (
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
434
|
+
for (const blocks of [this.#blocks, this.#closedBehind]) {
|
|
435
|
+
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
436
|
+
const block = blocks[i];
|
|
437
|
+
if (isoBlockContains(block.start, block.length, ssId)) {
|
|
438
|
+
return { block, esi: serial32Distance(block.start, ssId) };
|
|
439
|
+
}
|
|
410
440
|
}
|
|
411
441
|
}
|
|
412
442
|
return null;
|
|
413
443
|
}
|
|
414
|
-
/** Number of pending
|
|
444
|
+
/** Number of holes not closed yet, pending or past the horizon. */
|
|
415
445
|
get holeCount() {
|
|
416
|
-
return this.#holes.length;
|
|
446
|
+
return this.#holes.length + this.#expired.length;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The pending holes the horizon has passed since the last call, in the
|
|
450
|
+
* order it passed them. Each is no longer pending: no repair states a block
|
|
451
|
+
* in it (that repair is `stale`, as for a span the horizon retired) and the
|
|
452
|
+
* release gate does not wait for it. Its owner must close it
|
|
453
|
+
* (`closeHolesWithin`), which turns it into a span that is not kept here.
|
|
454
|
+
*/
|
|
455
|
+
takeExpiredHoles() {
|
|
456
|
+
return this.#newlyExpired.splice(0);
|
|
417
457
|
}
|
|
418
458
|
/** The stated block (never a span) ending exactly at `end`. */
|
|
419
459
|
blockEndingAt(end) {
|
|
@@ -469,9 +509,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
469
509
|
/**
|
|
470
510
|
* Apply one repair symbol's `(SS_Start, SSB_length)`. The first repair of a
|
|
471
511
|
* block states its range and places every held source in it; later repair
|
|
472
|
-
* symbols of the same block change nothing. A range
|
|
473
|
-
*
|
|
474
|
-
*
|
|
512
|
+
* symbols of the same block change nothing. A repair whose range is exactly
|
|
513
|
+
* a repair-less span states that span's one block. A range that contradicts
|
|
514
|
+
* a known block (a different length, or an overlap with another block or
|
|
515
|
+
* with part of a span) fails closed: the repair symbol is dropped and no
|
|
516
|
+
* block changes.
|
|
475
517
|
* A newly stated block retires behind its SS_Start (see the class note).
|
|
476
518
|
* A block so far past `newest` that stating it would retire the position
|
|
477
519
|
* `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
|
|
@@ -490,7 +532,16 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
490
532
|
const known = this.blockAt(start);
|
|
491
533
|
if (known !== void 0) {
|
|
492
534
|
if (known.span) {
|
|
493
|
-
|
|
535
|
+
if (known.length === length) {
|
|
536
|
+
const block2 = { start, length, span: false };
|
|
537
|
+
this.#blocks[this.#blocks.indexOf(known)] = block2;
|
|
538
|
+
return { status: "placed", block: block2, placed: [] };
|
|
539
|
+
}
|
|
540
|
+
return length < known.length ? {
|
|
541
|
+
status: "overlap",
|
|
542
|
+
reason: `repair block ${start}+${length} is only the first block of repair-less span ${known.start}+${known.length}`,
|
|
543
|
+
ofSpan: known
|
|
544
|
+
} : { status: "overlap", reason: `repair block ${start}+${length} runs past repair-less span ${known.start}+${known.length}` };
|
|
494
545
|
}
|
|
495
546
|
if (known.length !== length) {
|
|
496
547
|
return {
|
|
@@ -558,18 +609,28 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
558
609
|
return span === void 0 ? { status: "placed", block, placed } : { status: "placed", block, placed, span };
|
|
559
610
|
}
|
|
560
611
|
/**
|
|
561
|
-
* Turn every
|
|
562
|
-
*
|
|
563
|
-
*
|
|
612
|
+
* Turn every hole inside `[start, start + length)` into a repair-less span,
|
|
613
|
+
* claiming its held sources: its range FETCH ended, so nothing more will
|
|
614
|
+
* state its blocks. A hole the horizon passed (`takeExpiredHoles`) leaves a
|
|
615
|
+
* span that is not kept among the blocks, as the horizon would retire it at
|
|
616
|
+
* once; only `locate` finds it, until the next retirement, so its sources
|
|
617
|
+
* can be fed. Returns the spans, in SS_ID order.
|
|
564
618
|
*/
|
|
565
619
|
closeHolesWithin(start, length) {
|
|
566
620
|
const closed = [];
|
|
567
|
-
for (const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
621
|
+
for (const holes of [this.#holes, this.#expired]) {
|
|
622
|
+
for (const hole of [...holes]) {
|
|
623
|
+
if (!isoBlockContains(start, length, hole.start)) continue;
|
|
624
|
+
holes.splice(holes.indexOf(hole), 1);
|
|
625
|
+
const spanBlock = { start: hole.start, length: hole.length, span: true };
|
|
626
|
+
closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
|
|
627
|
+
if (holes === this.#holes) {
|
|
628
|
+
this.#blocks.push(spanBlock);
|
|
629
|
+
} else {
|
|
630
|
+
this.#closedBehind.push(spanBlock);
|
|
631
|
+
if (this.#newlyExpired.includes(hole)) this.#newlyExpired.splice(this.#newlyExpired.indexOf(hole), 1);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
573
634
|
}
|
|
574
635
|
return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start));
|
|
575
636
|
}
|
|
@@ -583,15 +644,17 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
583
644
|
return void 0;
|
|
584
645
|
}
|
|
585
646
|
/**
|
|
586
|
-
* Retire every block and span whose last SS_ID, and every held source
|
|
587
|
-
* lies more than `retentionBlocks` blocks behind
|
|
588
|
-
* lower-bound metric (`isoBlocksBehindLowerBound`)
|
|
589
|
-
* horizon uses
|
|
647
|
+
* Retire every block and span whose last SS_ID, and every held source
|
|
648
|
+
* outside a hole, lies more than `retentionBlocks` blocks behind
|
|
649
|
+
* `position`, with the shared lower-bound metric (`isoBlocksBehindLowerBound`)
|
|
650
|
+
* every ISO interleave horizon uses; a pending hole so far behind expires
|
|
651
|
+
* (`takeExpiredHoles`). Returns the retired block starts.
|
|
590
652
|
*/
|
|
591
653
|
retireBehind(position) {
|
|
592
654
|
this.observe(position);
|
|
593
655
|
const horizon = this.#retentionBlocks;
|
|
594
656
|
const retired = [];
|
|
657
|
+
this.#closedBehind.length = 0;
|
|
595
658
|
for (let i = this.#blocks.length - 1; i >= 0; i--) {
|
|
596
659
|
const block = this.#blocks[i];
|
|
597
660
|
const last = serial32Add(block.start, block.length - 1);
|
|
@@ -603,10 +666,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
603
666
|
for (let i = this.#holes.length - 1; i >= 0; i--) {
|
|
604
667
|
const hole = this.#holes[i];
|
|
605
668
|
const last = serial32Add(hole.start, hole.length - 1);
|
|
606
|
-
if (isoBlocksBehindLowerBound(last, position, this.#kMax)
|
|
669
|
+
if (isoBlocksBehindLowerBound(last, position, this.#kMax) <= horizon) continue;
|
|
670
|
+
this.#holes.splice(i, 1);
|
|
671
|
+
this.#expired.push(hole);
|
|
672
|
+
this.#newlyExpired.push(hole);
|
|
607
673
|
}
|
|
608
674
|
for (const ssId of [...this.#held.keys()]) {
|
|
609
|
-
if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#
|
|
675
|
+
if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon && !this.#holes.some((hole) => isoBlockContains(hole.start, hole.length, ssId)) && !this.#expired.some((hole) => isoBlockContains(hole.start, hole.length, ssId))) {
|
|
676
|
+
this.#held.delete(ssId);
|
|
677
|
+
}
|
|
610
678
|
}
|
|
611
679
|
return retired;
|
|
612
680
|
}
|
|
@@ -614,9 +682,13 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
614
682
|
reset() {
|
|
615
683
|
this.#blocks.length = 0;
|
|
616
684
|
this.#holes.length = 0;
|
|
685
|
+
this.#expired.length = 0;
|
|
686
|
+
this.#newlyExpired.length = 0;
|
|
687
|
+
this.#closedBehind.length = 0;
|
|
617
688
|
this.#held.clear();
|
|
618
689
|
this.#coverageEnd = void 0;
|
|
619
690
|
this.#newest = void 0;
|
|
691
|
+
this.#newestSource = void 0;
|
|
620
692
|
}
|
|
621
693
|
#claim(block) {
|
|
622
694
|
const placed = [];
|
|
@@ -1081,6 +1153,7 @@ var WORKER_ERROR_LOG_CAP = 5;
|
|
|
1081
1153
|
var WORKER_ERROR_KIND_CAP = 32;
|
|
1082
1154
|
var WORKER_ERROR_OVERFLOW_KIND = "other";
|
|
1083
1155
|
var STARTUP_REPAIR_WAIT_SOURCE_BOUNDARIES = 2;
|
|
1156
|
+
var NOT_TAKEN = Object.freeze({ taken: false, recovered: null });
|
|
1084
1157
|
function isMulticastSymbolDelivery(value) {
|
|
1085
1158
|
return value === "datagram" || value === "ordered-relay";
|
|
1086
1159
|
}
|
|
@@ -1174,10 +1247,18 @@ var FECManager = class _FECManager {
|
|
|
1174
1247
|
// 'pending' forever, which would park every later frame of its stream in
|
|
1175
1248
|
// the in-order release gate. Each entry owns its handle; the callback
|
|
1176
1249
|
// checks it still owns the key, so a settled or reset key is never touched.
|
|
1250
|
+
/**
|
|
1251
|
+
* Per owed Worker cleanup: the bound on its acknowledgement, when its block
|
|
1252
|
+
* was due, and when its cleanup was asked for (see `onCleanupComplete`).
|
|
1253
|
+
*/
|
|
1177
1254
|
this.#pendingWorkerCleanupBounds = /* @__PURE__ */ new Map();
|
|
1178
1255
|
// Source symbol count per track-scoped block — marks complete when K symbols arrive.
|
|
1179
1256
|
this.#blockSourceCounts = /* @__PURE__ */ new Map();
|
|
1180
1257
|
this.#blockSourceEsis = /* @__PURE__ */ new Map();
|
|
1258
|
+
// Source ESIs per block that another FEC instance rebuilt and fed in
|
|
1259
|
+
// (feedRebuiltSourceSymbol). Kept apart from #blockSourceEsis: they are
|
|
1260
|
+
// not network arrivals and never make a block clean.
|
|
1261
|
+
this.#blockRebuiltEsis = /* @__PURE__ */ new Map();
|
|
1181
1262
|
// Authored SSB_length per block (ISO/IEC 23008-1 §C.5.3), learned from the
|
|
1182
1263
|
// first repair symbol. The FFmpeg moq_mmt publisher closes a block every D
|
|
1183
1264
|
// media units, usually before it holds K symbols; under iso-ssbg1-v1
|
|
@@ -1186,10 +1267,14 @@ var FECManager = class _FECManager {
|
|
|
1186
1267
|
// SSB_length source arrivals and recoverable from SSB_length received
|
|
1187
1268
|
// symbols; waiting for K fails every one of them.
|
|
1188
1269
|
this.#blockAuthoredLengths = /* @__PURE__ */ new Map();
|
|
1270
|
+
// Keys whose authored length is a repair-less span's (#openIsoSpan), until
|
|
1271
|
+
// a repair states the block there or the span resolves.
|
|
1272
|
+
this.#isoSpanKeys = /* @__PURE__ */ new Set();
|
|
1189
1273
|
this.#ssbLengthConflictCount = 0;
|
|
1190
1274
|
this.#blockRepairRsIds = /* @__PURE__ */ new Map();
|
|
1191
1275
|
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
1192
|
-
// symbols its repair group carries
|
|
1276
|
+
// symbols its repair group carries; 0 for a repair-less span no repair can
|
|
1277
|
+
// state (#openIsoSpan). Same lifecycle as #blockRepairRsIds.
|
|
1193
1278
|
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
1194
1279
|
/** fec-01 6.3.9 anchor state per stream key, one entry per held layer. */
|
|
1195
1280
|
this.#heldLayerStates = /* @__PURE__ */ new Map();
|
|
@@ -1306,6 +1391,10 @@ var FECManager = class _FECManager {
|
|
|
1306
1391
|
// ── Keyframe-protected repair policy (block-policy.ts) ──
|
|
1307
1392
|
// One classifier per physical stream, built from that stream's geometry.
|
|
1308
1393
|
this.#classifiers = /* @__PURE__ */ new Map();
|
|
1394
|
+
// A stream without catalog timing has no classifier, so the last RAP it
|
|
1395
|
+
// released stands in for one: "an MPU boundary bounds its RAPs" holds until
|
|
1396
|
+
// a second RAP is released inside one MPU (BLO-52085).
|
|
1397
|
+
this.#noSpanRaps = /* @__PURE__ */ new Map();
|
|
1309
1398
|
// Geometry a stream-scoped configuration gave one stream (streamKey). ABR
|
|
1310
1399
|
// rungs can share a packetId with a different framerate or GOP, so the
|
|
1311
1400
|
// packet-level geometry is only the geometry of a packet whose streams
|
|
@@ -1379,7 +1468,10 @@ var FECManager = class _FECManager {
|
|
|
1379
1468
|
// arrives via onBlockRecovered callback.
|
|
1380
1469
|
this.onBlockStarted = null;
|
|
1381
1470
|
this.onBlockComplete = null;
|
|
1382
|
-
/**
|
|
1471
|
+
/**
|
|
1472
|
+
* A block reached its fail bound. `blockClass` is its class at failure.
|
|
1473
|
+
* `span` is set when what failed is a repair-less span starting at `sbn`.
|
|
1474
|
+
*/
|
|
1383
1475
|
this.onBlockFailed = null;
|
|
1384
1476
|
/**
|
|
1385
1477
|
* Fired once per stream when its Worker decoder stops being routable.
|
|
@@ -1421,6 +1513,8 @@ var FECManager = class _FECManager {
|
|
|
1421
1513
|
* for it, which it must be.
|
|
1422
1514
|
*/
|
|
1423
1515
|
this.#onUndelimitedLoss = null;
|
|
1516
|
+
/** Set with the loss handler: true takes an expired hole to close (`closeIsoHoles`). */
|
|
1517
|
+
this.#onIsoHoleExpired = null;
|
|
1424
1518
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
1425
1519
|
this.onBlockVanished = null;
|
|
1426
1520
|
/** A block reached a terminal state (completed, recovered, or failed). */
|
|
@@ -1463,7 +1557,9 @@ var FECManager = class _FECManager {
|
|
|
1463
1557
|
#pendingWorkerCleanupBounds;
|
|
1464
1558
|
#blockSourceCounts;
|
|
1465
1559
|
#blockSourceEsis;
|
|
1560
|
+
#blockRebuiltEsis;
|
|
1466
1561
|
#blockAuthoredLengths;
|
|
1562
|
+
#isoSpanKeys;
|
|
1467
1563
|
#ssbLengthConflictCount;
|
|
1468
1564
|
#blockRepairRsIds;
|
|
1469
1565
|
#blockRsbLengths;
|
|
@@ -1505,6 +1601,7 @@ var FECManager = class _FECManager {
|
|
|
1505
1601
|
#orderedFrontiers;
|
|
1506
1602
|
#orderedPendingBlocks;
|
|
1507
1603
|
#classifiers;
|
|
1604
|
+
#noSpanRaps;
|
|
1508
1605
|
#streamGeometries;
|
|
1509
1606
|
#failedBlocks;
|
|
1510
1607
|
#resolvedBlockClasses;
|
|
@@ -1529,6 +1626,7 @@ var FECManager = class _FECManager {
|
|
|
1529
1626
|
#decoderUnavailableEvents;
|
|
1530
1627
|
#repairSymbolSizeMismatchCount;
|
|
1531
1628
|
#onUndelimitedLoss;
|
|
1629
|
+
#onIsoHoleExpired;
|
|
1532
1630
|
#encodeTrackName(catalogTrackName) {
|
|
1533
1631
|
let encoded = this.#encodedTrackNames.get(catalogTrackName);
|
|
1534
1632
|
if (encoded === void 0) {
|
|
@@ -2000,7 +2098,10 @@ var FECManager = class _FECManager {
|
|
|
2000
2098
|
timer.handle = null;
|
|
2001
2099
|
this.#requestRepair(sbn, packetId, catalogTrackName);
|
|
2002
2100
|
};
|
|
2003
|
-
timer.handle = setTimeout(
|
|
2101
|
+
timer.handle = setTimeout(
|
|
2102
|
+
onFire,
|
|
2103
|
+
this.#receiptAtMs === void 0 ? Math.max(0, deadlineMs - performance.now()) : this.#receiptTimerDelayMs(deadlineMs, 0)
|
|
2104
|
+
);
|
|
2004
2105
|
this.#repairDeadlines.set(key, timer);
|
|
2005
2106
|
}
|
|
2006
2107
|
#requestRepair(sbn, packetId, catalogTrackName, settledByOrder = false) {
|
|
@@ -2144,8 +2245,14 @@ var FECManager = class _FECManager {
|
|
|
2144
2245
|
* Vanished blocks are not enumerated here: their starts are unknown until a
|
|
2145
2246
|
* repair states them. The SS_IDs between two stated blocks become one
|
|
2146
2247
|
* repair-less span when the later block's repair arrives (placeIsoRepair).
|
|
2248
|
+
*
|
|
2249
|
+
* A `held` source arrived before its block was known and is fed only now
|
|
2250
|
+
* that a repair, a span or a closed hole placed it: how far its block start
|
|
2251
|
+
* then lies behind the frontier measures how long the receiver held it, not
|
|
2252
|
+
* where the stream was, so only its SS_ID and packet_sequence_number judge
|
|
2253
|
+
* it (BLO-52085).
|
|
2147
2254
|
*/
|
|
2148
|
-
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber, ssId = sbn) {
|
|
2255
|
+
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber, ssId = sbn, held = false) {
|
|
2149
2256
|
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
2150
2257
|
const now = performance.now();
|
|
2151
2258
|
const previous = (symbol === "source" ? this.#sourceFrontiers : this.#highestSbn).get(streamKey);
|
|
@@ -2166,6 +2273,7 @@ var FECManager = class _FECManager {
|
|
|
2166
2273
|
};
|
|
2167
2274
|
const discontinuity = () => {
|
|
2168
2275
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity();
|
|
2276
|
+
this.#noSpanRaps.delete(streamKey);
|
|
2169
2277
|
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
2170
2278
|
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
2171
2279
|
if (psn === void 0) this.#sourceAnchors.delete(streamKey);
|
|
@@ -2183,7 +2291,7 @@ var FECManager = class _FECManager {
|
|
|
2183
2291
|
return sent <= 2147483647 && serial32Distance(from.ssId, to.ssId) <= sent + config.k;
|
|
2184
2292
|
};
|
|
2185
2293
|
if (!this.#blockPrecedes(previous.sbn, sbn)) {
|
|
2186
|
-
if (symbol === "source" && window !== null && this.#blockPrecedes(sbn, previous.sbn) && (this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId) || psn !== void 0 && anchor !== void 0 && serial32Precedes(ssId, anchor.ssId) && psn !== anchor.psn && !sentInOrder({ ssId, psn }, anchor))) {
|
|
2294
|
+
if (symbol === "source" && window !== null && this.#blockPrecedes(sbn, previous.sbn) && (!held && this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId) || psn !== void 0 && anchor !== void 0 && serial32Precedes(ssId, anchor.ssId) && psn !== anchor.psn && !sentInOrder({ ssId, psn }, anchor))) {
|
|
2187
2295
|
discontinuity();
|
|
2188
2296
|
return;
|
|
2189
2297
|
}
|
|
@@ -2445,17 +2553,21 @@ var FECManager = class _FECManager {
|
|
|
2445
2553
|
this.#blockWaitDeadlinesMs.delete(key);
|
|
2446
2554
|
this.#repairHoldUntilMs.delete(key);
|
|
2447
2555
|
this.#traceLifecycle("timeout-queued", sbn, packetId, catalogTrackName);
|
|
2448
|
-
this.#finalizeExpiredBlock(sbn, packetId, catalogTrackName);
|
|
2556
|
+
this.#finalizeExpiredBlock(sbn, packetId, catalogTrackName, currentDeadlineMs ?? firedAtMs);
|
|
2449
2557
|
};
|
|
2450
|
-
timer.handle = setTimeout(
|
|
2558
|
+
timer.handle = setTimeout(
|
|
2559
|
+
onFire,
|
|
2560
|
+
this.#receiptAtMs === void 0 ? Math.max(1, Math.ceil(deadlineMs - nowMs)) : this.#receiptTimerDelayMs(deadlineMs, 1)
|
|
2561
|
+
);
|
|
2451
2562
|
this.#activeBlocks.set(key, timer);
|
|
2452
2563
|
this.#indexBlockKey(key, sbn, packetId);
|
|
2453
2564
|
}
|
|
2454
2565
|
/**
|
|
2455
2566
|
* Hand a block whose delivery is over to its decoder for finalization: the
|
|
2456
|
-
* datagram deadline fired, or the ordered relay moved past it.
|
|
2567
|
+
* datagram deadline fired, or the ordered relay moved past it. `dueAtMs`
|
|
2568
|
+
* is when it was due: its deadline, or now.
|
|
2457
2569
|
*/
|
|
2458
|
-
#finalizeExpiredBlock(sbn, packetId, catalogTrackName) {
|
|
2570
|
+
#finalizeExpiredBlock(sbn, packetId, catalogTrackName, dueAtMs = performance.now()) {
|
|
2459
2571
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
2460
2572
|
if (this.#materializedBlocks.has(key) && !this.#blockPathCounts.has(key)) {
|
|
2461
2573
|
this.#failBlock(sbn, packetId, catalogTrackName);
|
|
@@ -2471,7 +2583,7 @@ var FECManager = class _FECManager {
|
|
|
2471
2583
|
if (workerClient) {
|
|
2472
2584
|
this.#pendingWorkerCleanups.add(key);
|
|
2473
2585
|
this.#pendingWorkerCleanupClients.set(key, workerClient);
|
|
2474
|
-
this.#boundOwedCleanup(key, packetId, workerClient);
|
|
2586
|
+
this.#boundOwedCleanup(key, packetId, workerClient, dueAtMs);
|
|
2475
2587
|
workerClient.cleanup(sbn);
|
|
2476
2588
|
} else {
|
|
2477
2589
|
const decoder = this.#decoderForPacket(packetId, catalogTrackName)?.client;
|
|
@@ -2578,6 +2690,9 @@ var FECManager = class _FECManager {
|
|
|
2578
2690
|
}
|
|
2579
2691
|
if (policyChanged) {
|
|
2580
2692
|
this.#bumpEpoch(packetId);
|
|
2693
|
+
for (const key of [...this.#noSpanRaps.keys()]) {
|
|
2694
|
+
if (this.#belongsToPacket(key, packetId)) this.#noSpanRaps.delete(key);
|
|
2695
|
+
}
|
|
2581
2696
|
for (const [key, classifier] of [...this.#classifiers]) {
|
|
2582
2697
|
if (!this.#belongsToPacket(key, packetId)) continue;
|
|
2583
2698
|
const stream = this.#parseStreamKey(key);
|
|
@@ -2780,7 +2895,9 @@ var FECManager = class _FECManager {
|
|
|
2780
2895
|
}
|
|
2781
2896
|
resetMap(this.#blockSourceCounts);
|
|
2782
2897
|
resetMap(this.#blockSourceEsis);
|
|
2898
|
+
resetMap(this.#blockRebuiltEsis);
|
|
2783
2899
|
resetMap(this.#blockAuthoredLengths);
|
|
2900
|
+
resetSet(this.#isoSpanKeys);
|
|
2784
2901
|
resetMap(this.#blockRepairRsIds);
|
|
2785
2902
|
resetMap(this.#blockRsbLengths);
|
|
2786
2903
|
resetMap(this.#heldLayerStates);
|
|
@@ -2813,6 +2930,7 @@ var FECManager = class _FECManager {
|
|
|
2813
2930
|
resetMap(this.#isoLocators);
|
|
2814
2931
|
resetMap(this.#sourceAnchors);
|
|
2815
2932
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName));
|
|
2933
|
+
this.#noSpanRaps.delete(this.#streamKey(packetId, catalogTrackName));
|
|
2816
2934
|
this.#bumpEpoch(packetId);
|
|
2817
2935
|
for (const [sbn, keys] of this.#blockKeysBySbn) {
|
|
2818
2936
|
for (const key of keys.keys()) {
|
|
@@ -2903,7 +3021,9 @@ var FECManager = class _FECManager {
|
|
|
2903
3021
|
dropMap(this.#pendingWorkerCleanupClients);
|
|
2904
3022
|
dropMap(this.#blockSourceCounts);
|
|
2905
3023
|
dropMap(this.#blockSourceEsis);
|
|
3024
|
+
dropMap(this.#blockRebuiltEsis);
|
|
2906
3025
|
dropMap(this.#blockAuthoredLengths);
|
|
3026
|
+
dropSet(this.#isoSpanKeys);
|
|
2907
3027
|
dropMap(this.#blockRepairRsIds);
|
|
2908
3028
|
dropMap(this.#blockRsbLengths);
|
|
2909
3029
|
dropMap(this.#blockPathCounts);
|
|
@@ -2919,6 +3039,7 @@ var FECManager = class _FECManager {
|
|
|
2919
3039
|
dropMap(this.#isoLocators);
|
|
2920
3040
|
dropMap(this.#sourceAnchors);
|
|
2921
3041
|
dropMap(this.#classifiers);
|
|
3042
|
+
dropMap(this.#noSpanRaps);
|
|
2922
3043
|
dropMap(this.#streamGeometries);
|
|
2923
3044
|
dropSet(this.#pendingWorkerCleanups);
|
|
2924
3045
|
dropSet(this.#completedBlocks);
|
|
@@ -3064,6 +3185,9 @@ var FECManager = class _FECManager {
|
|
|
3064
3185
|
this.#unindexBlockKey(key);
|
|
3065
3186
|
}
|
|
3066
3187
|
}
|
|
3188
|
+
if (isSourceSymbol && source === "multicast") {
|
|
3189
|
+
this.#noteMulticastSource(this.#isoLocatorFor(packetId, catalogTrackName), sbn + esi >>> 0, packetId, catalogTrackName);
|
|
3190
|
+
}
|
|
3067
3191
|
return true;
|
|
3068
3192
|
}
|
|
3069
3193
|
#observeBlockCatalogTrackName(blockKey, sbn, packetId, catalogTrackName) {
|
|
@@ -3173,8 +3297,10 @@ var FECManager = class _FECManager {
|
|
|
3173
3297
|
}
|
|
3174
3298
|
/**
|
|
3175
3299
|
* An open block's accepted sources, distinct repair RS_IDs, authored K'
|
|
3176
|
-
* (SSB_length) and RSB_length (each undefined until a repair stated it
|
|
3177
|
-
*
|
|
3300
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it; a
|
|
3301
|
+
* repair-less span states its length, and RSB_length 0 when it is longer
|
|
3302
|
+
* than K, since no repair can reach it). Undefined for a block that is not
|
|
3303
|
+
* open.
|
|
3178
3304
|
*/
|
|
3179
3305
|
blockSymbolCounts(sbn, packetId, catalogTrackName) {
|
|
3180
3306
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
@@ -3242,8 +3368,9 @@ var FECManager = class _FECManager {
|
|
|
3242
3368
|
return true;
|
|
3243
3369
|
}
|
|
3244
3370
|
/**
|
|
3245
|
-
* Drop a block's repair hold: its FETCH ended without delivering
|
|
3246
|
-
*
|
|
3371
|
+
* Drop a block's repair hold: its FETCH ended without delivering, or brought
|
|
3372
|
+
* back only a repair that cannot complete it. The block falls back to its
|
|
3373
|
+
* multicast wait, which may already have passed.
|
|
3247
3374
|
*/
|
|
3248
3375
|
releaseRepairHold(sbn, packetId, catalogTrackName) {
|
|
3249
3376
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
@@ -3381,6 +3508,8 @@ var FECManager = class _FECManager {
|
|
|
3381
3508
|
const locator = this.#growingIsoLocatorFor(packetId, catalogTrackName);
|
|
3382
3509
|
const evictedBefore = locator.heldEvicted;
|
|
3383
3510
|
const held = locator.hold(ssId, source);
|
|
3511
|
+
this.#settleExpiredIsoHoles(locator, packetId, catalogTrackName);
|
|
3512
|
+
if (held && source.source === "multicast") this.#noteMulticastSource(locator, ssId, packetId, catalogTrackName);
|
|
3384
3513
|
const evicted = locator.heldEvicted - evictedBefore;
|
|
3385
3514
|
if (evicted > 0) {
|
|
3386
3515
|
const before = this.#isoHeldEvictedCount;
|
|
@@ -3401,17 +3530,20 @@ var FECManager = class _FECManager {
|
|
|
3401
3530
|
* contradicts a known block is refused (counted) and must be dropped.
|
|
3402
3531
|
*/
|
|
3403
3532
|
placeIsoRepair(packetId, catalogTrackName, ssStart, ssbLength) {
|
|
3404
|
-
const
|
|
3533
|
+
const locator = this.#growingIsoLocatorFor(packetId, catalogTrackName);
|
|
3534
|
+
const placement = locator.placeRepair(ssStart, ssbLength);
|
|
3535
|
+
this.#settleExpiredIsoHoles(locator, packetId, catalogTrackName);
|
|
3405
3536
|
if (placement.status !== "placed") {
|
|
3406
3537
|
this.#isoRepairRefusedCount++;
|
|
3407
3538
|
if (this.#isoRepairRefusedCount <= 5 || this.#isoRepairRefusedCount % 100 === 0) {
|
|
3408
3539
|
console.warn(`[FECManager] packetId=${packetId} iso-ssbg1-v1 repair refused (${placement.status}): ${placement.reason}`);
|
|
3409
3540
|
}
|
|
3541
|
+
if (placement.ofSpan !== void 0) this.releaseRepairHold(placement.ofSpan.start, packetId, catalogTrackName);
|
|
3410
3542
|
return placement;
|
|
3411
3543
|
}
|
|
3544
|
+
this.#isoSpanKeys.delete(this.#blockKey(placement.block.start, packetId, catalogTrackName));
|
|
3412
3545
|
if (placement.span !== void 0) this.#openIsoSpan(placement.span, packetId, catalogTrackName);
|
|
3413
3546
|
if (placement.hole !== void 0) {
|
|
3414
|
-
const locator = this.#isoLocatorFor(packetId, catalogTrackName);
|
|
3415
3547
|
const hole = placement.hole.block;
|
|
3416
3548
|
const previous = locator.blockEndingAt(hole.start);
|
|
3417
3549
|
const loss = {
|
|
@@ -3432,17 +3564,29 @@ var FECManager = class _FECManager {
|
|
|
3432
3564
|
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
3433
3565
|
* range repair scheduler; applies to every stream from its next gap. The
|
|
3434
3566
|
* handler and the deferral are one setting, so no hole is ever created with
|
|
3435
|
-
* nobody to close it.
|
|
3567
|
+
* nobody to close it. `onExpired` is told of each pending hole the stream
|
|
3568
|
+
* runs past the locator's horizon (BLO-52085): returning true, it closes
|
|
3569
|
+
* the hole (`closeIsoHoles`), so the span it leaves still fails and is
|
|
3570
|
+
* reported; otherwise the hole is discarded with its sources.
|
|
3436
3571
|
*/
|
|
3437
|
-
setUndelimitedLossHandler(handler) {
|
|
3572
|
+
setUndelimitedLossHandler(handler, onExpired = null) {
|
|
3438
3573
|
this.#onUndelimitedLoss = handler;
|
|
3574
|
+
this.#onIsoHoleExpired = handler === null ? null : onExpired;
|
|
3439
3575
|
this.#deferIsoGaps = handler !== null;
|
|
3440
3576
|
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps;
|
|
3441
3577
|
}
|
|
3578
|
+
/** Hand each hole the locator's horizon passed to its owner, or discard it (setUndelimitedLossHandler). */
|
|
3579
|
+
#settleExpiredIsoHoles(locator, packetId, catalogTrackName) {
|
|
3580
|
+
for (const hole of locator.takeExpiredHoles()) {
|
|
3581
|
+
const expired = { packetId, catalogTrackName, holeStart: hole.start, holeLength: hole.length };
|
|
3582
|
+
if (this.#onIsoHoleExpired?.(expired) !== true) locator.closeHolesWithin(hole.start, hole.length);
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3442
3585
|
/**
|
|
3443
|
-
* The range repair for a hole ended: every hole
|
|
3444
|
-
*
|
|
3445
|
-
* with the held sources they placed, for the caller to feed
|
|
3586
|
+
* The range repair for a hole ended: every hole inside `[start, start +
|
|
3587
|
+
* length)`, pending or expired, becomes a repair-less span. Returns those
|
|
3588
|
+
* spans with the held sources they placed, for the caller to feed
|
|
3589
|
+
* (MmtpRouter).
|
|
3446
3590
|
*/
|
|
3447
3591
|
closeIsoHoles(packetId, catalogTrackName, start, length) {
|
|
3448
3592
|
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
|
|
@@ -3458,10 +3602,22 @@ var FECManager = class _FECManager {
|
|
|
3458
3602
|
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
3459
3603
|
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
3460
3604
|
* block.
|
|
3605
|
+
*
|
|
3606
|
+
* A span longer than K holds more than one block (SSB_length <= K), and the
|
|
3607
|
+
* locator states no block inside a span, only one exactly its range
|
|
3608
|
+
* (IsoBlockLocator.placeRepair): no repair, multicast or FETCHed, can ever
|
|
3609
|
+
* reach it. Its repair group is empty, so only its own late sources can
|
|
3610
|
+
* complete it, and it waits as a stated block its group cannot complete
|
|
3611
|
+
* does (#lateSourceWaitMs; BLO-52085 D4). A span of K or less may be one
|
|
3612
|
+
* block whose repair is still to come, and keeps the whole wait.
|
|
3461
3613
|
*/
|
|
3462
3614
|
#openIsoSpan(span, packetId, catalogTrackName) {
|
|
3463
3615
|
const key = this.#blockKey(span.block.start, packetId, catalogTrackName);
|
|
3464
|
-
if (!this.#blockAuthoredLengths.has(key))
|
|
3616
|
+
if (!this.#blockAuthoredLengths.has(key)) {
|
|
3617
|
+
this.#blockAuthoredLengths.set(key, span.block.length);
|
|
3618
|
+
this.#isoSpanKeys.add(key);
|
|
3619
|
+
if (span.block.length > this.#isoLocatorFor(packetId, catalogTrackName).kMax) this.#blockRsbLengths.set(key, 0);
|
|
3620
|
+
}
|
|
3465
3621
|
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true);
|
|
3466
3622
|
}
|
|
3467
3623
|
/**
|
|
@@ -3549,11 +3705,14 @@ var FECManager = class _FECManager {
|
|
|
3549
3705
|
/**
|
|
3550
3706
|
* Whether an MPU boundary still bounds this stream's RAPs (see
|
|
3551
3707
|
* `BlockClassifier.mpuBoundsRaps`). Gap decisions drop MPU evidence once
|
|
3552
|
-
* it does not. A stream with no classifier yet has shown nothing against it
|
|
3708
|
+
* it does not. A stream with no classifier yet has shown nothing against it,
|
|
3709
|
+
* and neither has a stream without catalog timing until it releases two
|
|
3710
|
+
* RAPs inside one MPU.
|
|
3553
3711
|
*/
|
|
3554
3712
|
mpuBoundsRapsFor(packetId, catalogTrackName) {
|
|
3555
|
-
|
|
3556
|
-
return this.#
|
|
3713
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
3714
|
+
if (!this.#hasCatalogTimingForPacket(packetId)) return this.#noSpanRaps.get(streamKey)?.inside !== true;
|
|
3715
|
+
return this.#classifiers.get(streamKey)?.mpuBoundsRaps ?? true;
|
|
3557
3716
|
}
|
|
3558
3717
|
/** A block's class now, or frozen at its resolution. */
|
|
3559
3718
|
blockClassFor(sbn, packetId, catalogTrackName) {
|
|
@@ -3579,7 +3738,14 @@ var FECManager = class _FECManager {
|
|
|
3579
3738
|
* invariant (consecutive MPUs exactly one keyframe interval apart).
|
|
3580
3739
|
*/
|
|
3581
3740
|
noteReleasedRap(packetId, catalogTrackName, mpu, presentationTime, mediaTimescale) {
|
|
3582
|
-
if (!this.#trackConfigs.has(packetId)
|
|
3741
|
+
if (!this.#trackConfigs.has(packetId)) return;
|
|
3742
|
+
if (!this.#hasCatalogTimingForPacket(packetId)) {
|
|
3743
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
3744
|
+
const last = this.#noSpanRaps.get(streamKey);
|
|
3745
|
+
const inside = last?.inside === true || last?.mpu === mpu && last.presentationTime !== presentationTime;
|
|
3746
|
+
this.#noSpanRaps.set(streamKey, { mpu, presentationTime, inside });
|
|
3747
|
+
return;
|
|
3748
|
+
}
|
|
3583
3749
|
this.#applyClassifierChanges(
|
|
3584
3750
|
packetId,
|
|
3585
3751
|
catalogTrackName,
|
|
@@ -3792,11 +3958,14 @@ var FECManager = class _FECManager {
|
|
|
3792
3958
|
});
|
|
3793
3959
|
client.onCleanupComplete((sbn) => {
|
|
3794
3960
|
if (this.#releasedWorkerClients.has(client)) return;
|
|
3795
|
-
const
|
|
3961
|
+
const owed = [...this.#pendingWorkerCleanups].filter((key) => this.#pendingWorkerCleanupClients.get(key) === client);
|
|
3962
|
+
const cleanupKeys = owed.filter((key) => {
|
|
3796
3963
|
const block = this.#parseBlockKey(key);
|
|
3797
|
-
return block.packetId === packetId && block.sbn === sbn
|
|
3964
|
+
return block.packetId === packetId && block.sbn === sbn;
|
|
3798
3965
|
});
|
|
3799
|
-
|
|
3966
|
+
const askedAtMs = Math.max(...cleanupKeys.map((key) => this.#pendingWorkerCleanupBounds.get(key)?.askedAtMs ?? -Infinity));
|
|
3967
|
+
const due = owed.filter((key) => !cleanupKeys.includes(key) && (this.#pendingWorkerCleanupBounds.get(key)?.dueAtMs ?? Infinity) <= askedAtMs);
|
|
3968
|
+
for (const key of [...cleanupKeys, ...due]) this.#settleOwedCleanup(key, "cleanup-ack");
|
|
3800
3969
|
});
|
|
3801
3970
|
client.onError((msg, code) => {
|
|
3802
3971
|
const requestedKind = code ?? msg;
|
|
@@ -3866,9 +4035,11 @@ var FECManager = class _FECManager {
|
|
|
3866
4035
|
* fail deadline already passed, so failing it is the decision that deadline
|
|
3867
4036
|
* made. A late ack then finds nothing owed and is a no-op.
|
|
3868
4037
|
*/
|
|
3869
|
-
#boundOwedCleanup(key, packetId, client) {
|
|
4038
|
+
#boundOwedCleanup(key, packetId, client, dueAtMs) {
|
|
3870
4039
|
this.#clearOwedCleanupBound(key);
|
|
3871
4040
|
const bound = {
|
|
4041
|
+
dueAtMs,
|
|
4042
|
+
askedAtMs: performance.now(),
|
|
3872
4043
|
handle: setTimeout(() => {
|
|
3873
4044
|
if (this.#pendingWorkerCleanupBounds.get(key) !== bound) return;
|
|
3874
4045
|
this.#pendingWorkerCleanupBounds.delete(key);
|
|
@@ -3966,7 +4137,15 @@ var FECManager = class _FECManager {
|
|
|
3966
4137
|
this.#isoSourceOversizeCount++;
|
|
3967
4138
|
return null;
|
|
3968
4139
|
}
|
|
3969
|
-
|
|
4140
|
+
return this.#feedDecoderSource(packetId, ssId, symbolData, catalogTrackName, located.block.start);
|
|
4141
|
+
}
|
|
4142
|
+
/**
|
|
4143
|
+
* Hand one placed source symbol to the stream's decoder: its Worker, which
|
|
4144
|
+
* answers through onFrame (null here), or its synchronous decoder, whose
|
|
4145
|
+
* recovered block is returned. `sbn` is the SS_Start of the block a repair
|
|
4146
|
+
* stated for `ssId`.
|
|
4147
|
+
*/
|
|
4148
|
+
#feedDecoderSource(packetId, ssId, symbolData, catalogTrackName, sbn) {
|
|
3970
4149
|
const blockKey = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
3971
4150
|
const syncBlockOwner = this.#syncDecoderBlockOwners.get(blockKey);
|
|
3972
4151
|
const workerClient = this.#routableWorkerForPacket(packetId, catalogTrackName);
|
|
@@ -3995,6 +4174,74 @@ var FECManager = class _FECManager {
|
|
|
3995
4174
|
}
|
|
3996
4175
|
return recovered;
|
|
3997
4176
|
}
|
|
4177
|
+
/**
|
|
4178
|
+
* Feed a source symbol of this stream that another FEC instance over the
|
|
4179
|
+
* same packets rebuilt: a keyframe overlay recovery whose base SS_ID the
|
|
4180
|
+
* caller determined (draft-ramadan-moq-mmt-02 7.1, 7.4.4; joint decoding,
|
|
4181
|
+
* BLO-52085). It joins its block's decoder as a received source would, so
|
|
4182
|
+
* it reduces the erasures the block still has to solve, but it is not a
|
|
4183
|
+
* network arrival: no transport accounting, no classification evidence,
|
|
4184
|
+
* no deadline refresh, and it never makes a block clean.
|
|
4185
|
+
*
|
|
4186
|
+
* Only a block a repair stated takes one (a repair-less span has no
|
|
4187
|
+
* decoder block). A block that is terminal, or already holds that source,
|
|
4188
|
+
* does not. The symbol is the exact protected packet, unpadded, as
|
|
4189
|
+
* feedSourceSymbol takes it.
|
|
4190
|
+
*
|
|
4191
|
+
* `recovered` is the block the synchronous decoder completed with it; the
|
|
4192
|
+
* caller routes it and completes the block, as for any recovery. When
|
|
4193
|
+
* every source of the block is then present, received or rebuilt, and no
|
|
4194
|
+
* decoder returned it (a Worker answers asynchronously, and reports such a
|
|
4195
|
+
* block as clean on its own side), the block is completed here as
|
|
4196
|
+
* recovered, with nothing left to route.
|
|
4197
|
+
*/
|
|
4198
|
+
feedRebuiltSourceSymbol(packetId, ssId, symbolData, catalogTrackName) {
|
|
4199
|
+
if (!this.#hasBlockProfile(packetId)) return NOT_TAKEN;
|
|
4200
|
+
const located = this.#isoLocatorFor(packetId, catalogTrackName).locate(ssId);
|
|
4201
|
+
if (located === null || located.block.span) return NOT_TAKEN;
|
|
4202
|
+
if (!ssbg1FitsSymbol(symbolData.byteLength, this.#trackConfig(packetId).symbolSize)) return NOT_TAKEN;
|
|
4203
|
+
const sbn = located.block.start;
|
|
4204
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
4205
|
+
if (this.#completedBlocks.has(key) || this.#blockSourceEsis.get(key)?.has(located.esi)) return NOT_TAKEN;
|
|
4206
|
+
let rebuilt = this.#blockRebuiltEsis.get(key);
|
|
4207
|
+
if (rebuilt?.has(located.esi)) return NOT_TAKEN;
|
|
4208
|
+
if (rebuilt === void 0) {
|
|
4209
|
+
rebuilt = /* @__PURE__ */ new Set();
|
|
4210
|
+
this.#blockRebuiltEsis.set(key, rebuilt);
|
|
4211
|
+
}
|
|
4212
|
+
const config = this.#trackConfigs.get(packetId);
|
|
4213
|
+
const wasShort = config !== void 0 && this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) !== void 0;
|
|
4214
|
+
rebuilt.add(located.esi);
|
|
4215
|
+
const recovered = this.#feedDecoderSource(packetId, ssId, symbolData, catalogTrackName, sbn);
|
|
4216
|
+
if (recovered === null && !this.#completeWhenSourcesPresent(key, sbn, located.block.length, packetId, catalogTrackName)) {
|
|
4217
|
+
if (wasShort && this.#activeBlocks.has(key) && this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) === void 0) {
|
|
4218
|
+
this.#armBlockTimeout(sbn, packetId, catalogTrackName, this.#multicastWaitMs(config));
|
|
4219
|
+
}
|
|
4220
|
+
}
|
|
4221
|
+
return { taken: true, recovered };
|
|
4222
|
+
}
|
|
4223
|
+
/**
|
|
4224
|
+
* A block that holds every one of its `length` sources, received or
|
|
4225
|
+
* rebuilt by another instance, with at least one rebuilt, is recovered:
|
|
4226
|
+
* every packet of it was delivered, by its own arrival or by the instance
|
|
4227
|
+
* that rebuilt it, so nothing is routed. Returns whether it completed it.
|
|
4228
|
+
*/
|
|
4229
|
+
#completeWhenSourcesPresent(key, sbn, length, packetId, catalogTrackName) {
|
|
4230
|
+
const rebuilt = this.#blockRebuiltEsis.get(key);
|
|
4231
|
+
if (rebuilt === void 0 || this.#completedBlocks.has(key)) return false;
|
|
4232
|
+
let present = rebuilt.size;
|
|
4233
|
+
for (const esi of this.#blockSourceEsis.get(key) ?? []) if (!rebuilt.has(esi)) present++;
|
|
4234
|
+
if (present < length) return false;
|
|
4235
|
+
this.#traceLifecycle("recovered", sbn, packetId, catalogTrackName);
|
|
4236
|
+
this.countRecovery(packetId, sbn, catalogTrackName);
|
|
4237
|
+
this.cancelBlockTimeout(sbn, packetId, catalogTrackName);
|
|
4238
|
+
if (catalogTrackName === void 0) {
|
|
4239
|
+
this.onBlockComplete?.(sbn, packetId);
|
|
4240
|
+
} else {
|
|
4241
|
+
this.onBlockComplete?.(sbn, packetId, catalogTrackName);
|
|
4242
|
+
}
|
|
4243
|
+
return true;
|
|
4244
|
+
}
|
|
3998
4245
|
/**
|
|
3999
4246
|
* fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
|
|
4000
4247
|
* exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
|
|
@@ -4197,8 +4444,76 @@ var FECManager = class _FECManager {
|
|
|
4197
4444
|
this.#completeCleanBlock(blockKey, sbn, packetId, catalogTrackName);
|
|
4198
4445
|
return null;
|
|
4199
4446
|
}
|
|
4447
|
+
if (recovered === null) this.#shortenUnrecoverableWait(blockKey, sbn, packetId, catalogTrackName);
|
|
4200
4448
|
return recovered;
|
|
4201
4449
|
}
|
|
4450
|
+
/**
|
|
4451
|
+
* A first-arrival multicast source, held or placed. A datagram flow keeps
|
|
4452
|
+
* its sources in send order, so one that moves the stream's newest source
|
|
4453
|
+
* position past a block leaves the sources that block still misses
|
|
4454
|
+
* reordered behind it at best: it shortens the wait of every block it
|
|
4455
|
+
* passed that only a late source can complete. MoQ is left out: its streams
|
|
4456
|
+
* can overtake one another, so a MoQ source shows nothing about the sources
|
|
4457
|
+
* sent before it.
|
|
4458
|
+
*/
|
|
4459
|
+
#noteMulticastSource(locator, ssId, packetId, catalogTrackName) {
|
|
4460
|
+
const previous = locator.newestSource;
|
|
4461
|
+
if (!locator.noteSource(ssId) || previous === void 0) return;
|
|
4462
|
+
for (const block of locator.blocksBetween(previous - 1 >>> 0, ssId)) {
|
|
4463
|
+
if (!serial32Precedes(serial32Add(block.start, block.length - 1), ssId)) continue;
|
|
4464
|
+
this.#shortenUnrecoverableWait(
|
|
4465
|
+
this.#blockKey(block.start, packetId, catalogTrackName),
|
|
4466
|
+
block.start,
|
|
4467
|
+
packetId,
|
|
4468
|
+
catalogTrackName
|
|
4469
|
+
);
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
/**
|
|
4473
|
+
* The wait of a block that only a late source can complete (BLO-52085): a
|
|
4474
|
+
* repair stated it, or it is a repair-less span longer than K (whose group
|
|
4475
|
+
* is empty, #openIsoSpan), its received sources plus every symbol its
|
|
4476
|
+
* repair group carries (RSB_length) are short of K' (the repair scheduler's
|
|
4477
|
+
* group-cannot-complete), and a later source of the stream has arrived, so
|
|
4478
|
+
* a source it misses is lost or reordered behind that one. The span, which
|
|
4479
|
+
* covers repair symbols paced after its sources, buys it nothing: it waits
|
|
4480
|
+
* the late-symbol allowance alone, the multicast wait less the span (the
|
|
4481
|
+
* catalog tolerance or the measured delivery gap). Undefined for any other
|
|
4482
|
+
* block.
|
|
4483
|
+
*/
|
|
4484
|
+
#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) {
|
|
4485
|
+
const authoredLength = this.#blockAuthoredLengths.get(key);
|
|
4486
|
+
const rsbLength = this.#blockRsbLengths.get(key);
|
|
4487
|
+
if (authoredLength === void 0 || rsbLength === void 0) return void 0;
|
|
4488
|
+
let present = this.#blockSourceCounts.get(key) ?? 0;
|
|
4489
|
+
const received = this.#blockSourceEsis.get(key);
|
|
4490
|
+
for (const esi of this.#blockRebuiltEsis.get(key) ?? []) if (!received?.has(esi)) present++;
|
|
4491
|
+
if (present + rsbLength >= authoredLength) return void 0;
|
|
4492
|
+
const newestSource = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))?.newestSource;
|
|
4493
|
+
if (newestSource === void 0 || !serial32Precedes(serial32Add(sbn, authoredLength - 1), newestSource)) {
|
|
4494
|
+
return void 0;
|
|
4495
|
+
}
|
|
4496
|
+
return this.#multicastWaitMs(config) - config.interleaveDepthMs;
|
|
4497
|
+
}
|
|
4498
|
+
/**
|
|
4499
|
+
* Bring an open block's wait in to its late-source wait, when it has one.
|
|
4500
|
+
* Never later than it is armed: only a source can complete such a block,
|
|
4501
|
+
* so a repair of its group (paced across the span) must not keep it open.
|
|
4502
|
+
*/
|
|
4503
|
+
#shortenUnrecoverableWait(key, sbn, packetId, catalogTrackName) {
|
|
4504
|
+
if (!this.#activeBlocks.has(key)) return;
|
|
4505
|
+
const config = this.#trackConfigs.get(packetId);
|
|
4506
|
+
if (config === void 0) return;
|
|
4507
|
+
const waitMs = this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config);
|
|
4508
|
+
if (waitMs === void 0) return;
|
|
4509
|
+
const armedAtMs = this.#blockWaitDeadlinesMs.get(key);
|
|
4510
|
+
this.#armBlockTimeout(
|
|
4511
|
+
sbn,
|
|
4512
|
+
packetId,
|
|
4513
|
+
catalogTrackName,
|
|
4514
|
+
armedAtMs === void 0 ? waitMs : Math.min(waitMs, armedAtMs - this.#receiptNow())
|
|
4515
|
+
);
|
|
4516
|
+
}
|
|
4202
4517
|
/**
|
|
4203
4518
|
* Record a block's authored SSB_length from a repair symbol. Returns false,
|
|
4204
4519
|
* leaving the block unchanged, when the symbol contradicts the block: a
|
|
@@ -4296,12 +4611,13 @@ var FECManager = class _FECManager {
|
|
|
4296
4611
|
* the inactivity deadline on each symbol, records the symbol's in-band
|
|
4297
4612
|
* classification evidence, and marks the block clean when all of its
|
|
4298
4613
|
* authored source symbols arrived: the SSB_length a repair symbol declared,
|
|
4299
|
-
* otherwise K.
|
|
4614
|
+
* otherwise K. `held` marks a source held unplaced since it arrived and
|
|
4615
|
+
* placed only now (see #noteSbnSeen).
|
|
4300
4616
|
*
|
|
4301
4617
|
* Throws for a packetId that was never configured, so a classified block
|
|
4302
4618
|
* never reads the manager-global K or timeout.
|
|
4303
4619
|
*/
|
|
4304
|
-
trackBlock(sbn, packetId, catalogTrackName, esi, evidence) {
|
|
4620
|
+
trackBlock(sbn, packetId, catalogTrackName, esi, evidence, held = false) {
|
|
4305
4621
|
const trackConfig = this.#trackConfigs.get(packetId);
|
|
4306
4622
|
if (trackConfig === void 0) {
|
|
4307
4623
|
throw new Error(
|
|
@@ -4317,7 +4633,8 @@ var FECManager = class _FECManager {
|
|
|
4317
4633
|
catalogTrackName,
|
|
4318
4634
|
"source",
|
|
4319
4635
|
evidence.packetSequenceNumber,
|
|
4320
|
-
Number.isInteger(esi) ? sbn + esi >>> 0 : sbn
|
|
4636
|
+
Number.isInteger(esi) ? sbn + esi >>> 0 : sbn,
|
|
4637
|
+
held
|
|
4321
4638
|
);
|
|
4322
4639
|
const authoredLength = this.#blockAuthoredLengths.get(key) ?? k;
|
|
4323
4640
|
if (Number.isInteger(esi) && esi >= authoredLength) {
|
|
@@ -4353,6 +4670,15 @@ var FECManager = class _FECManager {
|
|
|
4353
4670
|
this.#completeCleanBlock(key, sbn, packetId, catalogTrackName);
|
|
4354
4671
|
return;
|
|
4355
4672
|
}
|
|
4673
|
+
if (this.#blockRebuiltEsis.has(key) && this.#completeWhenSourcesPresent(
|
|
4674
|
+
key,
|
|
4675
|
+
sbn,
|
|
4676
|
+
this.#isoLocatorFor(packetId, catalogTrackName).blockAt(sbn)?.length ?? authoredLength,
|
|
4677
|
+
packetId,
|
|
4678
|
+
catalogTrackName
|
|
4679
|
+
)) {
|
|
4680
|
+
return;
|
|
4681
|
+
}
|
|
4356
4682
|
this.noteBlockActivity(sbn, packetId, catalogTrackName, true);
|
|
4357
4683
|
}
|
|
4358
4684
|
#completeCleanBlock(key, sbn, packetId, catalogTrackName) {
|
|
@@ -4361,7 +4687,9 @@ var FECManager = class _FECManager {
|
|
|
4361
4687
|
this.cancelBlockTimeout(sbn, packetId, catalogTrackName);
|
|
4362
4688
|
this.#blockSourceCounts.delete(key);
|
|
4363
4689
|
this.#blockSourceEsis.delete(key);
|
|
4690
|
+
this.#blockRebuiltEsis.delete(key);
|
|
4364
4691
|
this.#blockAuthoredLengths.delete(key);
|
|
4692
|
+
this.#isoSpanKeys.delete(key);
|
|
4365
4693
|
this.#blockRepairRsIds.delete(key);
|
|
4366
4694
|
this.#blockRsbLengths.delete(key);
|
|
4367
4695
|
this.#markTerminal(key, sbn, packetId, true);
|
|
@@ -4392,6 +4720,19 @@ var FECManager = class _FECManager {
|
|
|
4392
4720
|
#receiptNow() {
|
|
4393
4721
|
return this.#receiptAtMs ?? performance.now();
|
|
4394
4722
|
}
|
|
4723
|
+
/**
|
|
4724
|
+
* The whole-ms delay of a timer for `deadlineMs` armed inside a receipt
|
|
4725
|
+
* scope: counted from the receipt time, as the timer of a symbol fed when
|
|
4726
|
+
* it was received was, less the whole ms since. So it fires on the tick
|
|
4727
|
+
* that timer would have, never later than a delay counted from now, and
|
|
4728
|
+
* its handler still re-arms a timer that fires before its deadline.
|
|
4729
|
+
* Counted from now, a deadline set from the receipt time is rounded up
|
|
4730
|
+
* from another fraction of a ms (BLO-52085).
|
|
4731
|
+
*/
|
|
4732
|
+
#receiptTimerDelayMs(deadlineMs, minMs) {
|
|
4733
|
+
const receivedAtMs = this.#receiptAtMs;
|
|
4734
|
+
return Math.max(minMs, Math.ceil(deadlineMs - receivedAtMs) - Math.ceil(performance.now() - receivedAtMs));
|
|
4735
|
+
}
|
|
4395
4736
|
/**
|
|
4396
4737
|
* A held packet admitted late arms from its (earlier) receipt time; that
|
|
4397
4738
|
* never pulls in a deadline later activity already armed. Outside a
|
|
@@ -4427,10 +4768,20 @@ var FECManager = class _FECManager {
|
|
|
4427
4768
|
this.#repairDeadlineMs(trackConfig)
|
|
4428
4769
|
);
|
|
4429
4770
|
}
|
|
4430
|
-
this.#
|
|
4771
|
+
if (!sourceProgress && this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, trackConfig) !== void 0) {
|
|
4772
|
+
this.#shortenUnrecoverableWait(key, sbn, packetId, catalogTrackName);
|
|
4773
|
+
return;
|
|
4774
|
+
}
|
|
4775
|
+
this.#armBlockTimeout(
|
|
4776
|
+
sbn,
|
|
4777
|
+
packetId,
|
|
4778
|
+
catalogTrackName,
|
|
4779
|
+
this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, trackConfig) ?? timeoutMs
|
|
4780
|
+
);
|
|
4431
4781
|
}
|
|
4432
4782
|
#failBlock(sbn, packetId, catalogTrackName) {
|
|
4433
4783
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
4784
|
+
const span = this.#isoSpanKeys.delete(key) ? { length: this.#blockAuthoredLengths.get(key) ?? 0, sources: this.#blockSourceCounts.get(key) ?? 0 } : void 0;
|
|
4434
4785
|
this.#traceLifecycle("failed", sbn, packetId, catalogTrackName);
|
|
4435
4786
|
this.#clearRepairDeadline(key);
|
|
4436
4787
|
this.#clearBlockTimer(key);
|
|
@@ -4440,6 +4791,7 @@ var FECManager = class _FECManager {
|
|
|
4440
4791
|
}
|
|
4441
4792
|
this.#blockSourceCounts.delete(key);
|
|
4442
4793
|
this.#blockSourceEsis.delete(key);
|
|
4794
|
+
this.#blockRebuiltEsis.delete(key);
|
|
4443
4795
|
this.#blockAuthoredLengths.delete(key);
|
|
4444
4796
|
this.#blockRepairRsIds.delete(key);
|
|
4445
4797
|
this.#blockRsbLengths.delete(key);
|
|
@@ -4449,7 +4801,8 @@ var FECManager = class _FECManager {
|
|
|
4449
4801
|
this.#markPathBlockComplete(sbn, packetId, catalogTrackName);
|
|
4450
4802
|
this.#fecStats.blocksFailed++;
|
|
4451
4803
|
this.#statsForPacket(packetId).blocksFailed++;
|
|
4452
|
-
this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
4804
|
+
if (span === void 0) this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
4805
|
+
else this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span);
|
|
4453
4806
|
this.onBlockResolved?.(sbn, packetId, catalogTrackName);
|
|
4454
4807
|
}
|
|
4455
4808
|
/**
|
|
@@ -4478,7 +4831,9 @@ var FECManager = class _FECManager {
|
|
|
4478
4831
|
this.#retireBlockClass(key, block.sbn, block.packetId, block.catalogTrackName);
|
|
4479
4832
|
this.#blockSourceCounts.delete(key);
|
|
4480
4833
|
this.#blockSourceEsis.delete(key);
|
|
4834
|
+
this.#blockRebuiltEsis.delete(key);
|
|
4481
4835
|
this.#blockAuthoredLengths.delete(key);
|
|
4836
|
+
this.#isoSpanKeys.delete(key);
|
|
4482
4837
|
this.#blockRepairRsIds.delete(key);
|
|
4483
4838
|
this.#blockRsbLengths.delete(key);
|
|
4484
4839
|
this.#clearBlockTimer(key);
|
|
@@ -4569,7 +4924,9 @@ var FECManager = class _FECManager {
|
|
|
4569
4924
|
this.#blockKeysBySbn.clear();
|
|
4570
4925
|
this.#blockSourceCounts.clear();
|
|
4571
4926
|
this.#blockSourceEsis.clear();
|
|
4927
|
+
this.#blockRebuiltEsis.clear();
|
|
4572
4928
|
this.#blockAuthoredLengths.clear();
|
|
4929
|
+
this.#isoSpanKeys.clear();
|
|
4573
4930
|
this.#blockRepairRsIds.clear();
|
|
4574
4931
|
this.#blockRsbLengths.clear();
|
|
4575
4932
|
this.#heldLayerStates.clear();
|
|
@@ -4594,6 +4951,7 @@ var FECManager = class _FECManager {
|
|
|
4594
4951
|
this.#blockAnchorsMs.clear();
|
|
4595
4952
|
this.#blockCatalogTrackNames.clear();
|
|
4596
4953
|
this.#classifiers.clear();
|
|
4954
|
+
this.#noSpanRaps.clear();
|
|
4597
4955
|
this.#streamGeometries.clear();
|
|
4598
4956
|
this.#failedBlocks.clear();
|
|
4599
4957
|
this.#resolvedBlockClasses.clear();
|