@blockcast/mmt-container 2.2.0-main.bdefba2a99c2 → 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 +1304 -170
- 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 +79 -10
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +299 -27
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +301 -30
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +298 -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 +623 -65
- 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 +1124 -143
- 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 +298 -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 +298 -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 +306 -29
- package/src/mmtp-router.ts +548 -38
- package/src/multicast-manager.ts +118 -14
- package/src/repair-fetch.ts +366 -50
- package/src/track-session.ts +3 -0
package/dist/browser-runtime.js
CHANGED
|
@@ -851,6 +851,17 @@ function readRepairFecPayloadIdFields(mmtpPacket, parsedHeader) {
|
|
|
851
851
|
dataOffset: off + REPAIR_FEC_PID_SIZE
|
|
852
852
|
};
|
|
853
853
|
}
|
|
854
|
+
function extractRepairFecPayloadId(mmtpPacket) {
|
|
855
|
+
const fields = readRepairFecPayloadIdFields(mmtpPacket);
|
|
856
|
+
if (!fields)
|
|
857
|
+
return null;
|
|
858
|
+
return {
|
|
859
|
+
ssStart: fields.ssStart,
|
|
860
|
+
rsbLength: fields.rsbLength,
|
|
861
|
+
rsId: fields.rsId,
|
|
862
|
+
ssbLength: fields.ssbLength
|
|
863
|
+
};
|
|
864
|
+
}
|
|
854
865
|
function parseMoqRepairFrame(frame) {
|
|
855
866
|
return moqRepairFrameFrom(frame, readRepairFecPayloadIdFields(frame));
|
|
856
867
|
}
|
|
@@ -6088,9 +6099,10 @@ function isH264IntraSlice(nal) {
|
|
|
6088
6099
|
const sliceType = readH264SliceType(nal);
|
|
6089
6100
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
6090
6101
|
}
|
|
6102
|
+
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
6091
6103
|
function readH264SliceType(nal) {
|
|
6092
6104
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
6093
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
6105
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
|
|
6094
6106
|
const state = { bitOffset: 0 };
|
|
6095
6107
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
6096
6108
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -6459,6 +6471,96 @@ if (void 0) {
|
|
|
6459
6471
|
]))).toBe(false);
|
|
6460
6472
|
});
|
|
6461
6473
|
});
|
|
6474
|
+
describe("readH264SliceType", () => {
|
|
6475
|
+
const wholeNalSliceType = (nal) => {
|
|
6476
|
+
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
6477
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
6478
|
+
const state = { bitOffset: 0 };
|
|
6479
|
+
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
6480
|
+
return readUnsignedExpGolomb(rbsp, state);
|
|
6481
|
+
};
|
|
6482
|
+
const hex3 = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
|
|
6483
|
+
const ue = (value) => {
|
|
6484
|
+
const code = (value + 1).toString(2);
|
|
6485
|
+
return "0".repeat(code.length - 1) + code;
|
|
6486
|
+
};
|
|
6487
|
+
const sliceNal = (bits) => {
|
|
6488
|
+
const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
|
|
6489
|
+
const nal = [1];
|
|
6490
|
+
let zeros = 0;
|
|
6491
|
+
for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
|
|
6492
|
+
if (zeros >= 2 && byte <= 3) {
|
|
6493
|
+
nal.push(3);
|
|
6494
|
+
zeros = 0;
|
|
6495
|
+
}
|
|
6496
|
+
nal.push(byte);
|
|
6497
|
+
zeros = byte === 0 ? zeros + 1 : 0;
|
|
6498
|
+
}
|
|
6499
|
+
return Uint8Array.from(nal);
|
|
6500
|
+
};
|
|
6501
|
+
const x264Slices = [
|
|
6502
|
+
["64x48 P", hex3("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
|
|
6503
|
+
["64x48 B", hex3("419e414212fffeeade283707cb70f7"), 6, false],
|
|
6504
|
+
["64x48 non-IDR I", hex3(
|
|
6505
|
+
"4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
|
|
6506
|
+
), 7, true],
|
|
6507
|
+
["1280x720 B, escape at byte 10", hex3(
|
|
6508
|
+
"01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
|
|
6509
|
+
), 6, false],
|
|
6510
|
+
["1280x720 P, escape at byte 15", hex3(
|
|
6511
|
+
"41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
|
|
6512
|
+
), 5, false],
|
|
6513
|
+
["1280x720 B, escape at byte 22", hex3("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
|
|
6514
|
+
["7680x4320 IDR, first_mb_in_slice 97440", hex3(
|
|
6515
|
+
"650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
|
|
6516
|
+
), null, true],
|
|
6517
|
+
["7680x4320 P, first_mb_in_slice 32640", hex3(
|
|
6518
|
+
"410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
|
|
6519
|
+
), 5, false],
|
|
6520
|
+
["7680x4320 P, first_mb_in_slice 97440", hex3(
|
|
6521
|
+
"410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
|
|
6522
|
+
), 5, false]
|
|
6523
|
+
];
|
|
6524
|
+
const syntheticSlices = [
|
|
6525
|
+
["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
|
|
6526
|
+
["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
|
|
6527
|
+
["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
|
|
6528
|
+
["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
|
|
6529
|
+
["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
|
|
6530
|
+
["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
|
|
6531
|
+
["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
|
|
6532
|
+
["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
|
|
6533
|
+
];
|
|
6534
|
+
test("reads the slice_type of real and synthetic slices", () => {
|
|
6535
|
+
for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
|
|
6536
|
+
expect(readH264SliceType(nal), name).toBe(sliceType);
|
|
6537
|
+
}
|
|
6538
|
+
});
|
|
6539
|
+
test("matches the whole-NAL unescape at every truncation", () => {
|
|
6540
|
+
for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
|
|
6541
|
+
for (let end = 0; end <= nal.length; end++) {
|
|
6542
|
+
const cut = nal.subarray(0, end);
|
|
6543
|
+
expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
|
|
6544
|
+
}
|
|
6545
|
+
}
|
|
6546
|
+
});
|
|
6547
|
+
test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
|
|
6548
|
+
const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
|
|
6549
|
+
let seed = 1;
|
|
6550
|
+
const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
|
|
6551
|
+
for (let i = 0; i < 5e3; i++) {
|
|
6552
|
+
const nal = new Uint8Array(2 + next() % 63);
|
|
6553
|
+
nal[0] = 65;
|
|
6554
|
+
for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
|
|
6555
|
+
expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
|
|
6556
|
+
}
|
|
6557
|
+
});
|
|
6558
|
+
test("classifies the x264 slices as keyframes or not", () => {
|
|
6559
|
+
for (const [name, nal, , keyframe] of x264Slices) {
|
|
6560
|
+
expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
|
|
6561
|
+
}
|
|
6562
|
+
});
|
|
6563
|
+
});
|
|
6462
6564
|
describe("avccToAnnexB", () => {
|
|
6463
6565
|
test("converts with SPS/PPS on keyframe", () => {
|
|
6464
6566
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|
|
@@ -8625,9 +8727,9 @@ async function openSubscription(rx, openedPromise, options, packetIds) {
|
|
|
8625
8727
|
} catch (error) {
|
|
8626
8728
|
throw new MulticastError("subscription-failed", "MulticastReceiver did not open", error);
|
|
8627
8729
|
}
|
|
8628
|
-
if (
|
|
8730
|
+
if (opened.integrityScheme !== INTEGRITY_SCHEME) {
|
|
8629
8731
|
await rx.close();
|
|
8630
|
-
throw unsupported(`integrity scheme ${String(
|
|
8732
|
+
throw unsupported(`integrity scheme ${String(opened.integrityScheme)} is not ${INTEGRITY_SCHEME}`);
|
|
8631
8733
|
}
|
|
8632
8734
|
const events = new EventTarget();
|
|
8633
8735
|
let state = "connected";
|
|
@@ -8746,6 +8848,7 @@ var MOQT_PUBLISHER_PRIORITY = Object.freeze({
|
|
|
8746
8848
|
});
|
|
8747
8849
|
|
|
8748
8850
|
// node_modules/@blockcast/mmt-transport/dist/amt-gateway.js
|
|
8851
|
+
var MAX_PENDING_PACKETS = 256;
|
|
8749
8852
|
var AMTGatewayManager = class {
|
|
8750
8853
|
subscriptions = /* @__PURE__ */ new Map();
|
|
8751
8854
|
messageHandler;
|
|
@@ -8869,7 +8972,7 @@ var AMTGatewayManager = class {
|
|
|
8869
8972
|
if (!subscription.handshakeComplete) {
|
|
8870
8973
|
const queue = this.pendingPackets.get(subscriptionId);
|
|
8871
8974
|
const packetData2 = data;
|
|
8872
|
-
if (queue) {
|
|
8975
|
+
if (queue && queue.length < MAX_PENDING_PACKETS) {
|
|
8873
8976
|
queue.push({
|
|
8874
8977
|
data: packetData2.data,
|
|
8875
8978
|
remoteAddress: packetData2.remoteAddress,
|
|
@@ -12434,6 +12537,7 @@ var TrackSession = class {
|
|
|
12434
12537
|
this.#state = "idle";
|
|
12435
12538
|
this.#subscription = null;
|
|
12436
12539
|
this.#disarmFec();
|
|
12540
|
+
this.#unsuppress();
|
|
12437
12541
|
}
|
|
12438
12542
|
// -----------------------------------------------------------------------
|
|
12439
12543
|
// Internal
|
|
@@ -12927,6 +13031,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12927
13031
|
this.#heldEvicted = 0;
|
|
12928
13032
|
/** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
|
|
12929
13033
|
this.#holes = [];
|
|
13034
|
+
/** Holes the horizon passed while pending: sources held until closed. */
|
|
13035
|
+
this.#expired = [];
|
|
13036
|
+
/** Of `#expired`, those `takeExpiredHoles` has not handed out yet. */
|
|
13037
|
+
this.#newlyExpired = [];
|
|
13038
|
+
/**
|
|
13039
|
+
* Spans closed from expired holes: behind the horizon, so kept only for
|
|
13040
|
+
* `locate` while their sources are fed, until the next retirement.
|
|
13041
|
+
*/
|
|
13042
|
+
this.#closedBehind = [];
|
|
12930
13043
|
/**
|
|
12931
13044
|
* Keep a gap that is missing a source as a pending hole rather than a span,
|
|
12932
13045
|
* so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
|
|
@@ -12948,7 +13061,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12948
13061
|
#retentionBlocks;
|
|
12949
13062
|
#heldEvicted;
|
|
12950
13063
|
#newest;
|
|
13064
|
+
#newestSource;
|
|
12951
13065
|
#holes;
|
|
13066
|
+
#expired;
|
|
13067
|
+
#newlyExpired;
|
|
13068
|
+
#closedBehind;
|
|
12952
13069
|
static #checkedRetention(retentionBlocks) {
|
|
12953
13070
|
if (!Number.isSafeInteger(retentionBlocks) || retentionBlocks <= 0) {
|
|
12954
13071
|
throw new Error(
|
|
@@ -12985,6 +13102,21 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
12985
13102
|
observe(position) {
|
|
12986
13103
|
if (this.#newest === void 0 || serial32Precedes(this.#newest, position)) this.#newest = position;
|
|
12987
13104
|
}
|
|
13105
|
+
/**
|
|
13106
|
+
* The newest source SS_ID noted with `noteSource` (RFC 1982 order). Unlike
|
|
13107
|
+
* `newest`, a repair never moves it: a repair can run ahead of its sources,
|
|
13108
|
+
* a source cannot run ahead of the sources sent before it except by
|
|
13109
|
+
* reordering.
|
|
13110
|
+
*/
|
|
13111
|
+
get newestSource() {
|
|
13112
|
+
return this.#newestSource;
|
|
13113
|
+
}
|
|
13114
|
+
/** Note a received source's SS_ID; true when it is the newest one yet. */
|
|
13115
|
+
noteSource(ssId) {
|
|
13116
|
+
if (this.#newestSource !== void 0 && !serial32Precedes(this.#newestSource, ssId)) return false;
|
|
13117
|
+
this.#newestSource = ssId;
|
|
13118
|
+
return true;
|
|
13119
|
+
}
|
|
12988
13120
|
/** Held sources evicted by `heldCapacity` (never by the horizon itself). */
|
|
12989
13121
|
get heldEvicted() {
|
|
12990
13122
|
return this.#heldEvicted;
|
|
@@ -13003,17 +13135,29 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
13003
13135
|
}
|
|
13004
13136
|
/** The known block or span containing `ssId`, with its ESI. */
|
|
13005
13137
|
locate(ssId) {
|
|
13006
|
-
for (
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13138
|
+
for (const blocks of [this.#blocks, this.#closedBehind]) {
|
|
13139
|
+
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
13140
|
+
const block = blocks[i];
|
|
13141
|
+
if (isoBlockContains(block.start, block.length, ssId)) {
|
|
13142
|
+
return { block, esi: serial32Distance(block.start, ssId) };
|
|
13143
|
+
}
|
|
13010
13144
|
}
|
|
13011
13145
|
}
|
|
13012
13146
|
return null;
|
|
13013
13147
|
}
|
|
13014
|
-
/** Number of pending
|
|
13148
|
+
/** Number of holes not closed yet, pending or past the horizon. */
|
|
13015
13149
|
get holeCount() {
|
|
13016
|
-
return this.#holes.length;
|
|
13150
|
+
return this.#holes.length + this.#expired.length;
|
|
13151
|
+
}
|
|
13152
|
+
/**
|
|
13153
|
+
* The pending holes the horizon has passed since the last call, in the
|
|
13154
|
+
* order it passed them. Each is no longer pending: no repair states a block
|
|
13155
|
+
* in it (that repair is `stale`, as for a span the horizon retired) and the
|
|
13156
|
+
* release gate does not wait for it. Its owner must close it
|
|
13157
|
+
* (`closeHolesWithin`), which turns it into a span that is not kept here.
|
|
13158
|
+
*/
|
|
13159
|
+
takeExpiredHoles() {
|
|
13160
|
+
return this.#newlyExpired.splice(0);
|
|
13017
13161
|
}
|
|
13018
13162
|
/** The stated block (never a span) ending exactly at `end`. */
|
|
13019
13163
|
blockEndingAt(end) {
|
|
@@ -13069,9 +13213,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
13069
13213
|
/**
|
|
13070
13214
|
* Apply one repair symbol's `(SS_Start, SSB_length)`. The first repair of a
|
|
13071
13215
|
* block states its range and places every held source in it; later repair
|
|
13072
|
-
* symbols of the same block change nothing. A range
|
|
13073
|
-
*
|
|
13074
|
-
*
|
|
13216
|
+
* symbols of the same block change nothing. A repair whose range is exactly
|
|
13217
|
+
* a repair-less span states that span's one block. A range that contradicts
|
|
13218
|
+
* a known block (a different length, or an overlap with another block or
|
|
13219
|
+
* with part of a span) fails closed: the repair symbol is dropped and no
|
|
13220
|
+
* block changes.
|
|
13075
13221
|
* A newly stated block retires behind its SS_Start (see the class note).
|
|
13076
13222
|
* A block so far past `newest` that stating it would retire the position
|
|
13077
13223
|
* `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
|
|
@@ -13090,7 +13236,16 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
13090
13236
|
const known = this.blockAt(start);
|
|
13091
13237
|
if (known !== void 0) {
|
|
13092
13238
|
if (known.span) {
|
|
13093
|
-
|
|
13239
|
+
if (known.length === length) {
|
|
13240
|
+
const block2 = { start, length, span: false };
|
|
13241
|
+
this.#blocks[this.#blocks.indexOf(known)] = block2;
|
|
13242
|
+
return { status: "placed", block: block2, placed: [] };
|
|
13243
|
+
}
|
|
13244
|
+
return length < known.length ? {
|
|
13245
|
+
status: "overlap",
|
|
13246
|
+
reason: `repair block ${start}+${length} is only the first block of repair-less span ${known.start}+${known.length}`,
|
|
13247
|
+
ofSpan: known
|
|
13248
|
+
} : { status: "overlap", reason: `repair block ${start}+${length} runs past repair-less span ${known.start}+${known.length}` };
|
|
13094
13249
|
}
|
|
13095
13250
|
if (known.length !== length) {
|
|
13096
13251
|
return {
|
|
@@ -13158,18 +13313,28 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
13158
13313
|
return span === void 0 ? { status: "placed", block, placed } : { status: "placed", block, placed, span };
|
|
13159
13314
|
}
|
|
13160
13315
|
/**
|
|
13161
|
-
* Turn every
|
|
13162
|
-
*
|
|
13163
|
-
*
|
|
13316
|
+
* Turn every hole inside `[start, start + length)` into a repair-less span,
|
|
13317
|
+
* claiming its held sources: its range FETCH ended, so nothing more will
|
|
13318
|
+
* state its blocks. A hole the horizon passed (`takeExpiredHoles`) leaves a
|
|
13319
|
+
* span that is not kept among the blocks, as the horizon would retire it at
|
|
13320
|
+
* once; only `locate` finds it, until the next retirement, so its sources
|
|
13321
|
+
* can be fed. Returns the spans, in SS_ID order.
|
|
13164
13322
|
*/
|
|
13165
13323
|
closeHolesWithin(start, length) {
|
|
13166
13324
|
const closed = [];
|
|
13167
|
-
for (const
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13325
|
+
for (const holes of [this.#holes, this.#expired]) {
|
|
13326
|
+
for (const hole of [...holes]) {
|
|
13327
|
+
if (!isoBlockContains(start, length, hole.start)) continue;
|
|
13328
|
+
holes.splice(holes.indexOf(hole), 1);
|
|
13329
|
+
const spanBlock = { start: hole.start, length: hole.length, span: true };
|
|
13330
|
+
closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
|
|
13331
|
+
if (holes === this.#holes) {
|
|
13332
|
+
this.#blocks.push(spanBlock);
|
|
13333
|
+
} else {
|
|
13334
|
+
this.#closedBehind.push(spanBlock);
|
|
13335
|
+
if (this.#newlyExpired.includes(hole)) this.#newlyExpired.splice(this.#newlyExpired.indexOf(hole), 1);
|
|
13336
|
+
}
|
|
13337
|
+
}
|
|
13173
13338
|
}
|
|
13174
13339
|
return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start));
|
|
13175
13340
|
}
|
|
@@ -13183,15 +13348,17 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
13183
13348
|
return void 0;
|
|
13184
13349
|
}
|
|
13185
13350
|
/**
|
|
13186
|
-
* Retire every block and span whose last SS_ID, and every held source
|
|
13187
|
-
* lies more than `retentionBlocks` blocks behind
|
|
13188
|
-
* lower-bound metric (`isoBlocksBehindLowerBound`)
|
|
13189
|
-
* horizon uses
|
|
13351
|
+
* Retire every block and span whose last SS_ID, and every held source
|
|
13352
|
+
* outside a hole, lies more than `retentionBlocks` blocks behind
|
|
13353
|
+
* `position`, with the shared lower-bound metric (`isoBlocksBehindLowerBound`)
|
|
13354
|
+
* every ISO interleave horizon uses; a pending hole so far behind expires
|
|
13355
|
+
* (`takeExpiredHoles`). Returns the retired block starts.
|
|
13190
13356
|
*/
|
|
13191
13357
|
retireBehind(position) {
|
|
13192
13358
|
this.observe(position);
|
|
13193
13359
|
const horizon = this.#retentionBlocks;
|
|
13194
13360
|
const retired = [];
|
|
13361
|
+
this.#closedBehind.length = 0;
|
|
13195
13362
|
for (let i = this.#blocks.length - 1; i >= 0; i--) {
|
|
13196
13363
|
const block = this.#blocks[i];
|
|
13197
13364
|
const last = serial32Add(block.start, block.length - 1);
|
|
@@ -13203,10 +13370,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
13203
13370
|
for (let i = this.#holes.length - 1; i >= 0; i--) {
|
|
13204
13371
|
const hole = this.#holes[i];
|
|
13205
13372
|
const last = serial32Add(hole.start, hole.length - 1);
|
|
13206
|
-
if (isoBlocksBehindLowerBound(last, position, this.#kMax)
|
|
13373
|
+
if (isoBlocksBehindLowerBound(last, position, this.#kMax) <= horizon) continue;
|
|
13374
|
+
this.#holes.splice(i, 1);
|
|
13375
|
+
this.#expired.push(hole);
|
|
13376
|
+
this.#newlyExpired.push(hole);
|
|
13207
13377
|
}
|
|
13208
13378
|
for (const ssId of [...this.#held.keys()]) {
|
|
13209
|
-
if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#
|
|
13379
|
+
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))) {
|
|
13380
|
+
this.#held.delete(ssId);
|
|
13381
|
+
}
|
|
13210
13382
|
}
|
|
13211
13383
|
return retired;
|
|
13212
13384
|
}
|
|
@@ -13214,9 +13386,13 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
13214
13386
|
reset() {
|
|
13215
13387
|
this.#blocks.length = 0;
|
|
13216
13388
|
this.#holes.length = 0;
|
|
13389
|
+
this.#expired.length = 0;
|
|
13390
|
+
this.#newlyExpired.length = 0;
|
|
13391
|
+
this.#closedBehind.length = 0;
|
|
13217
13392
|
this.#held.clear();
|
|
13218
13393
|
this.#coverageEnd = void 0;
|
|
13219
13394
|
this.#newest = void 0;
|
|
13395
|
+
this.#newestSource = void 0;
|
|
13220
13396
|
}
|
|
13221
13397
|
#claim(block) {
|
|
13222
13398
|
const placed = [];
|
|
@@ -13836,6 +14012,7 @@ var WORKER_ERROR_LOG_CAP = 5;
|
|
|
13836
14012
|
var WORKER_ERROR_KIND_CAP = 32;
|
|
13837
14013
|
var WORKER_ERROR_OVERFLOW_KIND = "other";
|
|
13838
14014
|
var STARTUP_REPAIR_WAIT_SOURCE_BOUNDARIES = 2;
|
|
14015
|
+
var NOT_TAKEN = Object.freeze({ taken: false, recovered: null });
|
|
13839
14016
|
function isMulticastSymbolDelivery(value) {
|
|
13840
14017
|
return value === "datagram" || value === "ordered-relay";
|
|
13841
14018
|
}
|
|
@@ -13929,10 +14106,18 @@ var FECManager = class _FECManager {
|
|
|
13929
14106
|
// 'pending' forever, which would park every later frame of its stream in
|
|
13930
14107
|
// the in-order release gate. Each entry owns its handle; the callback
|
|
13931
14108
|
// checks it still owns the key, so a settled or reset key is never touched.
|
|
14109
|
+
/**
|
|
14110
|
+
* Per owed Worker cleanup: the bound on its acknowledgement, when its block
|
|
14111
|
+
* was due, and when its cleanup was asked for (see `onCleanupComplete`).
|
|
14112
|
+
*/
|
|
13932
14113
|
this.#pendingWorkerCleanupBounds = /* @__PURE__ */ new Map();
|
|
13933
14114
|
// Source symbol count per track-scoped block — marks complete when K symbols arrive.
|
|
13934
14115
|
this.#blockSourceCounts = /* @__PURE__ */ new Map();
|
|
13935
14116
|
this.#blockSourceEsis = /* @__PURE__ */ new Map();
|
|
14117
|
+
// Source ESIs per block that another FEC instance rebuilt and fed in
|
|
14118
|
+
// (feedRebuiltSourceSymbol). Kept apart from #blockSourceEsis: they are
|
|
14119
|
+
// not network arrivals and never make a block clean.
|
|
14120
|
+
this.#blockRebuiltEsis = /* @__PURE__ */ new Map();
|
|
13936
14121
|
// Authored SSB_length per block (ISO/IEC 23008-1 §C.5.3), learned from the
|
|
13937
14122
|
// first repair symbol. The FFmpeg moq_mmt publisher closes a block every D
|
|
13938
14123
|
// media units, usually before it holds K symbols; under iso-ssbg1-v1
|
|
@@ -13941,10 +14126,14 @@ var FECManager = class _FECManager {
|
|
|
13941
14126
|
// SSB_length source arrivals and recoverable from SSB_length received
|
|
13942
14127
|
// symbols; waiting for K fails every one of them.
|
|
13943
14128
|
this.#blockAuthoredLengths = /* @__PURE__ */ new Map();
|
|
14129
|
+
// Keys whose authored length is a repair-less span's (#openIsoSpan), until
|
|
14130
|
+
// a repair states the block there or the span resolves.
|
|
14131
|
+
this.#isoSpanKeys = /* @__PURE__ */ new Set();
|
|
13944
14132
|
this.#ssbLengthConflictCount = 0;
|
|
13945
14133
|
this.#blockRepairRsIds = /* @__PURE__ */ new Map();
|
|
13946
14134
|
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
13947
|
-
// symbols its repair group carries
|
|
14135
|
+
// symbols its repair group carries; 0 for a repair-less span no repair can
|
|
14136
|
+
// state (#openIsoSpan). Same lifecycle as #blockRepairRsIds.
|
|
13948
14137
|
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
13949
14138
|
/** fec-01 6.3.9 anchor state per stream key, one entry per held layer. */
|
|
13950
14139
|
this.#heldLayerStates = /* @__PURE__ */ new Map();
|
|
@@ -14061,6 +14250,10 @@ var FECManager = class _FECManager {
|
|
|
14061
14250
|
// ── Keyframe-protected repair policy (block-policy.ts) ──
|
|
14062
14251
|
// One classifier per physical stream, built from that stream's geometry.
|
|
14063
14252
|
this.#classifiers = /* @__PURE__ */ new Map();
|
|
14253
|
+
// A stream without catalog timing has no classifier, so the last RAP it
|
|
14254
|
+
// released stands in for one: "an MPU boundary bounds its RAPs" holds until
|
|
14255
|
+
// a second RAP is released inside one MPU (BLO-52085).
|
|
14256
|
+
this.#noSpanRaps = /* @__PURE__ */ new Map();
|
|
14064
14257
|
// Geometry a stream-scoped configuration gave one stream (streamKey). ABR
|
|
14065
14258
|
// rungs can share a packetId with a different framerate or GOP, so the
|
|
14066
14259
|
// packet-level geometry is only the geometry of a packet whose streams
|
|
@@ -14134,7 +14327,10 @@ var FECManager = class _FECManager {
|
|
|
14134
14327
|
// arrives via onBlockRecovered callback.
|
|
14135
14328
|
this.onBlockStarted = null;
|
|
14136
14329
|
this.onBlockComplete = null;
|
|
14137
|
-
/**
|
|
14330
|
+
/**
|
|
14331
|
+
* A block reached its fail bound. `blockClass` is its class at failure.
|
|
14332
|
+
* `span` is set when what failed is a repair-less span starting at `sbn`.
|
|
14333
|
+
*/
|
|
14138
14334
|
this.onBlockFailed = null;
|
|
14139
14335
|
/**
|
|
14140
14336
|
* Fired once per stream when its Worker decoder stops being routable.
|
|
@@ -14176,6 +14372,8 @@ var FECManager = class _FECManager {
|
|
|
14176
14372
|
* for it, which it must be.
|
|
14177
14373
|
*/
|
|
14178
14374
|
this.#onUndelimitedLoss = null;
|
|
14375
|
+
/** Set with the loss handler: true takes an expired hole to close (`closeIsoHoles`). */
|
|
14376
|
+
this.#onIsoHoleExpired = null;
|
|
14179
14377
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
14180
14378
|
this.onBlockVanished = null;
|
|
14181
14379
|
/** A block reached a terminal state (completed, recovered, or failed). */
|
|
@@ -14218,7 +14416,9 @@ var FECManager = class _FECManager {
|
|
|
14218
14416
|
#pendingWorkerCleanupBounds;
|
|
14219
14417
|
#blockSourceCounts;
|
|
14220
14418
|
#blockSourceEsis;
|
|
14419
|
+
#blockRebuiltEsis;
|
|
14221
14420
|
#blockAuthoredLengths;
|
|
14421
|
+
#isoSpanKeys;
|
|
14222
14422
|
#ssbLengthConflictCount;
|
|
14223
14423
|
#blockRepairRsIds;
|
|
14224
14424
|
#blockRsbLengths;
|
|
@@ -14260,6 +14460,7 @@ var FECManager = class _FECManager {
|
|
|
14260
14460
|
#orderedFrontiers;
|
|
14261
14461
|
#orderedPendingBlocks;
|
|
14262
14462
|
#classifiers;
|
|
14463
|
+
#noSpanRaps;
|
|
14263
14464
|
#streamGeometries;
|
|
14264
14465
|
#failedBlocks;
|
|
14265
14466
|
#resolvedBlockClasses;
|
|
@@ -14284,6 +14485,7 @@ var FECManager = class _FECManager {
|
|
|
14284
14485
|
#decoderUnavailableEvents;
|
|
14285
14486
|
#repairSymbolSizeMismatchCount;
|
|
14286
14487
|
#onUndelimitedLoss;
|
|
14488
|
+
#onIsoHoleExpired;
|
|
14287
14489
|
#encodeTrackName(catalogTrackName) {
|
|
14288
14490
|
let encoded = this.#encodedTrackNames.get(catalogTrackName);
|
|
14289
14491
|
if (encoded === void 0) {
|
|
@@ -14755,7 +14957,10 @@ var FECManager = class _FECManager {
|
|
|
14755
14957
|
timer.handle = null;
|
|
14756
14958
|
this.#requestRepair(sbn, packetId, catalogTrackName);
|
|
14757
14959
|
};
|
|
14758
|
-
timer.handle = setTimeout(
|
|
14960
|
+
timer.handle = setTimeout(
|
|
14961
|
+
onFire,
|
|
14962
|
+
this.#receiptAtMs === void 0 ? Math.max(0, deadlineMs - performance.now()) : this.#receiptTimerDelayMs(deadlineMs, 0)
|
|
14963
|
+
);
|
|
14759
14964
|
this.#repairDeadlines.set(key, timer);
|
|
14760
14965
|
}
|
|
14761
14966
|
#requestRepair(sbn, packetId, catalogTrackName, settledByOrder = false) {
|
|
@@ -14899,8 +15104,14 @@ var FECManager = class _FECManager {
|
|
|
14899
15104
|
* Vanished blocks are not enumerated here: their starts are unknown until a
|
|
14900
15105
|
* repair states them. The SS_IDs between two stated blocks become one
|
|
14901
15106
|
* repair-less span when the later block's repair arrives (placeIsoRepair).
|
|
15107
|
+
*
|
|
15108
|
+
* A `held` source arrived before its block was known and is fed only now
|
|
15109
|
+
* that a repair, a span or a closed hole placed it: how far its block start
|
|
15110
|
+
* then lies behind the frontier measures how long the receiver held it, not
|
|
15111
|
+
* where the stream was, so only its SS_ID and packet_sequence_number judge
|
|
15112
|
+
* it (BLO-52085).
|
|
14902
15113
|
*/
|
|
14903
|
-
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber, ssId = sbn) {
|
|
15114
|
+
#noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber, ssId = sbn, held = false) {
|
|
14904
15115
|
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
14905
15116
|
const now = performance.now();
|
|
14906
15117
|
const previous = (symbol === "source" ? this.#sourceFrontiers : this.#highestSbn).get(streamKey);
|
|
@@ -14921,6 +15132,7 @@ var FECManager = class _FECManager {
|
|
|
14921
15132
|
};
|
|
14922
15133
|
const discontinuity = () => {
|
|
14923
15134
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity();
|
|
15135
|
+
this.#noSpanRaps.delete(streamKey);
|
|
14924
15136
|
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
14925
15137
|
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
14926
15138
|
if (psn === void 0) this.#sourceAnchors.delete(streamKey);
|
|
@@ -14938,7 +15150,7 @@ var FECManager = class _FECManager {
|
|
|
14938
15150
|
return sent <= 2147483647 && serial32Distance(from.ssId, to.ssId) <= sent + config.k;
|
|
14939
15151
|
};
|
|
14940
15152
|
if (!this.#blockPrecedes(previous.sbn, sbn)) {
|
|
14941
|
-
if (symbol === "source" && window2 !== 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))) {
|
|
15153
|
+
if (symbol === "source" && window2 !== 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))) {
|
|
14942
15154
|
discontinuity();
|
|
14943
15155
|
return;
|
|
14944
15156
|
}
|
|
@@ -15200,17 +15412,21 @@ var FECManager = class _FECManager {
|
|
|
15200
15412
|
this.#blockWaitDeadlinesMs.delete(key);
|
|
15201
15413
|
this.#repairHoldUntilMs.delete(key);
|
|
15202
15414
|
this.#traceLifecycle("timeout-queued", sbn, packetId, catalogTrackName);
|
|
15203
|
-
this.#finalizeExpiredBlock(sbn, packetId, catalogTrackName);
|
|
15415
|
+
this.#finalizeExpiredBlock(sbn, packetId, catalogTrackName, currentDeadlineMs ?? firedAtMs);
|
|
15204
15416
|
};
|
|
15205
|
-
timer.handle = setTimeout(
|
|
15417
|
+
timer.handle = setTimeout(
|
|
15418
|
+
onFire,
|
|
15419
|
+
this.#receiptAtMs === void 0 ? Math.max(1, Math.ceil(deadlineMs - nowMs)) : this.#receiptTimerDelayMs(deadlineMs, 1)
|
|
15420
|
+
);
|
|
15206
15421
|
this.#activeBlocks.set(key, timer);
|
|
15207
15422
|
this.#indexBlockKey(key, sbn, packetId);
|
|
15208
15423
|
}
|
|
15209
15424
|
/**
|
|
15210
15425
|
* Hand a block whose delivery is over to its decoder for finalization: the
|
|
15211
|
-
* datagram deadline fired, or the ordered relay moved past it.
|
|
15426
|
+
* datagram deadline fired, or the ordered relay moved past it. `dueAtMs`
|
|
15427
|
+
* is when it was due: its deadline, or now.
|
|
15212
15428
|
*/
|
|
15213
|
-
#finalizeExpiredBlock(sbn, packetId, catalogTrackName) {
|
|
15429
|
+
#finalizeExpiredBlock(sbn, packetId, catalogTrackName, dueAtMs = performance.now()) {
|
|
15214
15430
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
15215
15431
|
if (this.#materializedBlocks.has(key) && !this.#blockPathCounts.has(key)) {
|
|
15216
15432
|
this.#failBlock(sbn, packetId, catalogTrackName);
|
|
@@ -15226,7 +15442,7 @@ var FECManager = class _FECManager {
|
|
|
15226
15442
|
if (workerClient) {
|
|
15227
15443
|
this.#pendingWorkerCleanups.add(key);
|
|
15228
15444
|
this.#pendingWorkerCleanupClients.set(key, workerClient);
|
|
15229
|
-
this.#boundOwedCleanup(key, packetId, workerClient);
|
|
15445
|
+
this.#boundOwedCleanup(key, packetId, workerClient, dueAtMs);
|
|
15230
15446
|
workerClient.cleanup(sbn);
|
|
15231
15447
|
} else {
|
|
15232
15448
|
const decoder = this.#decoderForPacket(packetId, catalogTrackName)?.client;
|
|
@@ -15333,6 +15549,9 @@ var FECManager = class _FECManager {
|
|
|
15333
15549
|
}
|
|
15334
15550
|
if (policyChanged) {
|
|
15335
15551
|
this.#bumpEpoch(packetId);
|
|
15552
|
+
for (const key of [...this.#noSpanRaps.keys()]) {
|
|
15553
|
+
if (this.#belongsToPacket(key, packetId)) this.#noSpanRaps.delete(key);
|
|
15554
|
+
}
|
|
15336
15555
|
for (const [key, classifier] of [...this.#classifiers]) {
|
|
15337
15556
|
if (!this.#belongsToPacket(key, packetId)) continue;
|
|
15338
15557
|
const stream = this.#parseStreamKey(key);
|
|
@@ -15535,7 +15754,9 @@ var FECManager = class _FECManager {
|
|
|
15535
15754
|
}
|
|
15536
15755
|
resetMap(this.#blockSourceCounts);
|
|
15537
15756
|
resetMap(this.#blockSourceEsis);
|
|
15757
|
+
resetMap(this.#blockRebuiltEsis);
|
|
15538
15758
|
resetMap(this.#blockAuthoredLengths);
|
|
15759
|
+
resetSet(this.#isoSpanKeys);
|
|
15539
15760
|
resetMap(this.#blockRepairRsIds);
|
|
15540
15761
|
resetMap(this.#blockRsbLengths);
|
|
15541
15762
|
resetMap(this.#heldLayerStates);
|
|
@@ -15568,6 +15789,7 @@ var FECManager = class _FECManager {
|
|
|
15568
15789
|
resetMap(this.#isoLocators);
|
|
15569
15790
|
resetMap(this.#sourceAnchors);
|
|
15570
15791
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName));
|
|
15792
|
+
this.#noSpanRaps.delete(this.#streamKey(packetId, catalogTrackName));
|
|
15571
15793
|
this.#bumpEpoch(packetId);
|
|
15572
15794
|
for (const [sbn, keys] of this.#blockKeysBySbn) {
|
|
15573
15795
|
for (const key of keys.keys()) {
|
|
@@ -15658,7 +15880,9 @@ var FECManager = class _FECManager {
|
|
|
15658
15880
|
dropMap(this.#pendingWorkerCleanupClients);
|
|
15659
15881
|
dropMap(this.#blockSourceCounts);
|
|
15660
15882
|
dropMap(this.#blockSourceEsis);
|
|
15883
|
+
dropMap(this.#blockRebuiltEsis);
|
|
15661
15884
|
dropMap(this.#blockAuthoredLengths);
|
|
15885
|
+
dropSet(this.#isoSpanKeys);
|
|
15662
15886
|
dropMap(this.#blockRepairRsIds);
|
|
15663
15887
|
dropMap(this.#blockRsbLengths);
|
|
15664
15888
|
dropMap(this.#blockPathCounts);
|
|
@@ -15674,6 +15898,7 @@ var FECManager = class _FECManager {
|
|
|
15674
15898
|
dropMap(this.#isoLocators);
|
|
15675
15899
|
dropMap(this.#sourceAnchors);
|
|
15676
15900
|
dropMap(this.#classifiers);
|
|
15901
|
+
dropMap(this.#noSpanRaps);
|
|
15677
15902
|
dropMap(this.#streamGeometries);
|
|
15678
15903
|
dropSet(this.#pendingWorkerCleanups);
|
|
15679
15904
|
dropSet(this.#completedBlocks);
|
|
@@ -15819,6 +16044,9 @@ var FECManager = class _FECManager {
|
|
|
15819
16044
|
this.#unindexBlockKey(key);
|
|
15820
16045
|
}
|
|
15821
16046
|
}
|
|
16047
|
+
if (isSourceSymbol && source === "multicast") {
|
|
16048
|
+
this.#noteMulticastSource(this.#isoLocatorFor(packetId, catalogTrackName), sbn + esi >>> 0, packetId, catalogTrackName);
|
|
16049
|
+
}
|
|
15822
16050
|
return true;
|
|
15823
16051
|
}
|
|
15824
16052
|
#observeBlockCatalogTrackName(blockKey, sbn, packetId, catalogTrackName) {
|
|
@@ -15928,8 +16156,10 @@ var FECManager = class _FECManager {
|
|
|
15928
16156
|
}
|
|
15929
16157
|
/**
|
|
15930
16158
|
* An open block's accepted sources, distinct repair RS_IDs, authored K'
|
|
15931
|
-
* (SSB_length) and RSB_length (each undefined until a repair stated it
|
|
15932
|
-
*
|
|
16159
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it; a
|
|
16160
|
+
* repair-less span states its length, and RSB_length 0 when it is longer
|
|
16161
|
+
* than K, since no repair can reach it). Undefined for a block that is not
|
|
16162
|
+
* open.
|
|
15933
16163
|
*/
|
|
15934
16164
|
blockSymbolCounts(sbn, packetId, catalogTrackName) {
|
|
15935
16165
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
@@ -15997,8 +16227,9 @@ var FECManager = class _FECManager {
|
|
|
15997
16227
|
return true;
|
|
15998
16228
|
}
|
|
15999
16229
|
/**
|
|
16000
|
-
* Drop a block's repair hold: its FETCH ended without delivering
|
|
16001
|
-
*
|
|
16230
|
+
* Drop a block's repair hold: its FETCH ended without delivering, or brought
|
|
16231
|
+
* back only a repair that cannot complete it. The block falls back to its
|
|
16232
|
+
* multicast wait, which may already have passed.
|
|
16002
16233
|
*/
|
|
16003
16234
|
releaseRepairHold(sbn, packetId, catalogTrackName) {
|
|
16004
16235
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
@@ -16136,6 +16367,8 @@ var FECManager = class _FECManager {
|
|
|
16136
16367
|
const locator = this.#growingIsoLocatorFor(packetId, catalogTrackName);
|
|
16137
16368
|
const evictedBefore = locator.heldEvicted;
|
|
16138
16369
|
const held = locator.hold(ssId, source);
|
|
16370
|
+
this.#settleExpiredIsoHoles(locator, packetId, catalogTrackName);
|
|
16371
|
+
if (held && source.source === "multicast") this.#noteMulticastSource(locator, ssId, packetId, catalogTrackName);
|
|
16139
16372
|
const evicted = locator.heldEvicted - evictedBefore;
|
|
16140
16373
|
if (evicted > 0) {
|
|
16141
16374
|
const before = this.#isoHeldEvictedCount;
|
|
@@ -16156,17 +16389,20 @@ var FECManager = class _FECManager {
|
|
|
16156
16389
|
* contradicts a known block is refused (counted) and must be dropped.
|
|
16157
16390
|
*/
|
|
16158
16391
|
placeIsoRepair(packetId, catalogTrackName, ssStart, ssbLength) {
|
|
16159
|
-
const
|
|
16392
|
+
const locator = this.#growingIsoLocatorFor(packetId, catalogTrackName);
|
|
16393
|
+
const placement = locator.placeRepair(ssStart, ssbLength);
|
|
16394
|
+
this.#settleExpiredIsoHoles(locator, packetId, catalogTrackName);
|
|
16160
16395
|
if (placement.status !== "placed") {
|
|
16161
16396
|
this.#isoRepairRefusedCount++;
|
|
16162
16397
|
if (this.#isoRepairRefusedCount <= 5 || this.#isoRepairRefusedCount % 100 === 0) {
|
|
16163
16398
|
console.warn(`[FECManager] packetId=${packetId} iso-ssbg1-v1 repair refused (${placement.status}): ${placement.reason}`);
|
|
16164
16399
|
}
|
|
16400
|
+
if (placement.ofSpan !== void 0) this.releaseRepairHold(placement.ofSpan.start, packetId, catalogTrackName);
|
|
16165
16401
|
return placement;
|
|
16166
16402
|
}
|
|
16403
|
+
this.#isoSpanKeys.delete(this.#blockKey(placement.block.start, packetId, catalogTrackName));
|
|
16167
16404
|
if (placement.span !== void 0) this.#openIsoSpan(placement.span, packetId, catalogTrackName);
|
|
16168
16405
|
if (placement.hole !== void 0) {
|
|
16169
|
-
const locator = this.#isoLocatorFor(packetId, catalogTrackName);
|
|
16170
16406
|
const hole = placement.hole.block;
|
|
16171
16407
|
const previous = locator.blockEndingAt(hole.start);
|
|
16172
16408
|
const loss = {
|
|
@@ -16187,17 +16423,29 @@ var FECManager = class _FECManager {
|
|
|
16187
16423
|
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
16188
16424
|
* range repair scheduler; applies to every stream from its next gap. The
|
|
16189
16425
|
* handler and the deferral are one setting, so no hole is ever created with
|
|
16190
|
-
* nobody to close it.
|
|
16426
|
+
* nobody to close it. `onExpired` is told of each pending hole the stream
|
|
16427
|
+
* runs past the locator's horizon (BLO-52085): returning true, it closes
|
|
16428
|
+
* the hole (`closeIsoHoles`), so the span it leaves still fails and is
|
|
16429
|
+
* reported; otherwise the hole is discarded with its sources.
|
|
16191
16430
|
*/
|
|
16192
|
-
setUndelimitedLossHandler(handler) {
|
|
16431
|
+
setUndelimitedLossHandler(handler, onExpired = null) {
|
|
16193
16432
|
this.#onUndelimitedLoss = handler;
|
|
16433
|
+
this.#onIsoHoleExpired = handler === null ? null : onExpired;
|
|
16194
16434
|
this.#deferIsoGaps = handler !== null;
|
|
16195
16435
|
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps;
|
|
16196
16436
|
}
|
|
16437
|
+
/** Hand each hole the locator's horizon passed to its owner, or discard it (setUndelimitedLossHandler). */
|
|
16438
|
+
#settleExpiredIsoHoles(locator, packetId, catalogTrackName) {
|
|
16439
|
+
for (const hole of locator.takeExpiredHoles()) {
|
|
16440
|
+
const expired = { packetId, catalogTrackName, holeStart: hole.start, holeLength: hole.length };
|
|
16441
|
+
if (this.#onIsoHoleExpired?.(expired) !== true) locator.closeHolesWithin(hole.start, hole.length);
|
|
16442
|
+
}
|
|
16443
|
+
}
|
|
16197
16444
|
/**
|
|
16198
|
-
* The range repair for a hole ended: every hole
|
|
16199
|
-
*
|
|
16200
|
-
* with the held sources they placed, for the caller to feed
|
|
16445
|
+
* The range repair for a hole ended: every hole inside `[start, start +
|
|
16446
|
+
* length)`, pending or expired, becomes a repair-less span. Returns those
|
|
16447
|
+
* spans with the held sources they placed, for the caller to feed
|
|
16448
|
+
* (MmtpRouter).
|
|
16201
16449
|
*/
|
|
16202
16450
|
closeIsoHoles(packetId, catalogTrackName, start, length) {
|
|
16203
16451
|
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
|
|
@@ -16213,10 +16461,22 @@ var FECManager = class _FECManager {
|
|
|
16213
16461
|
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
16214
16462
|
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
16215
16463
|
* block.
|
|
16464
|
+
*
|
|
16465
|
+
* A span longer than K holds more than one block (SSB_length <= K), and the
|
|
16466
|
+
* locator states no block inside a span, only one exactly its range
|
|
16467
|
+
* (IsoBlockLocator.placeRepair): no repair, multicast or FETCHed, can ever
|
|
16468
|
+
* reach it. Its repair group is empty, so only its own late sources can
|
|
16469
|
+
* complete it, and it waits as a stated block its group cannot complete
|
|
16470
|
+
* does (#lateSourceWaitMs; BLO-52085 D4). A span of K or less may be one
|
|
16471
|
+
* block whose repair is still to come, and keeps the whole wait.
|
|
16216
16472
|
*/
|
|
16217
16473
|
#openIsoSpan(span, packetId, catalogTrackName) {
|
|
16218
16474
|
const key = this.#blockKey(span.block.start, packetId, catalogTrackName);
|
|
16219
|
-
if (!this.#blockAuthoredLengths.has(key))
|
|
16475
|
+
if (!this.#blockAuthoredLengths.has(key)) {
|
|
16476
|
+
this.#blockAuthoredLengths.set(key, span.block.length);
|
|
16477
|
+
this.#isoSpanKeys.add(key);
|
|
16478
|
+
if (span.block.length > this.#isoLocatorFor(packetId, catalogTrackName).kMax) this.#blockRsbLengths.set(key, 0);
|
|
16479
|
+
}
|
|
16220
16480
|
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true);
|
|
16221
16481
|
}
|
|
16222
16482
|
/**
|
|
@@ -16304,11 +16564,14 @@ var FECManager = class _FECManager {
|
|
|
16304
16564
|
/**
|
|
16305
16565
|
* Whether an MPU boundary still bounds this stream's RAPs (see
|
|
16306
16566
|
* `BlockClassifier.mpuBoundsRaps`). Gap decisions drop MPU evidence once
|
|
16307
|
-
* it does not. A stream with no classifier yet has shown nothing against it
|
|
16567
|
+
* it does not. A stream with no classifier yet has shown nothing against it,
|
|
16568
|
+
* and neither has a stream without catalog timing until it releases two
|
|
16569
|
+
* RAPs inside one MPU.
|
|
16308
16570
|
*/
|
|
16309
16571
|
mpuBoundsRapsFor(packetId, catalogTrackName) {
|
|
16310
|
-
|
|
16311
|
-
return this.#
|
|
16572
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
16573
|
+
if (!this.#hasCatalogTimingForPacket(packetId)) return this.#noSpanRaps.get(streamKey)?.inside !== true;
|
|
16574
|
+
return this.#classifiers.get(streamKey)?.mpuBoundsRaps ?? true;
|
|
16312
16575
|
}
|
|
16313
16576
|
/** A block's class now, or frozen at its resolution. */
|
|
16314
16577
|
blockClassFor(sbn, packetId, catalogTrackName) {
|
|
@@ -16334,7 +16597,14 @@ var FECManager = class _FECManager {
|
|
|
16334
16597
|
* invariant (consecutive MPUs exactly one keyframe interval apart).
|
|
16335
16598
|
*/
|
|
16336
16599
|
noteReleasedRap(packetId, catalogTrackName, mpu, presentationTime, mediaTimescale) {
|
|
16337
|
-
if (!this.#trackConfigs.has(packetId)
|
|
16600
|
+
if (!this.#trackConfigs.has(packetId)) return;
|
|
16601
|
+
if (!this.#hasCatalogTimingForPacket(packetId)) {
|
|
16602
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
16603
|
+
const last = this.#noSpanRaps.get(streamKey);
|
|
16604
|
+
const inside = last?.inside === true || last?.mpu === mpu && last.presentationTime !== presentationTime;
|
|
16605
|
+
this.#noSpanRaps.set(streamKey, { mpu, presentationTime, inside });
|
|
16606
|
+
return;
|
|
16607
|
+
}
|
|
16338
16608
|
this.#applyClassifierChanges(
|
|
16339
16609
|
packetId,
|
|
16340
16610
|
catalogTrackName,
|
|
@@ -16547,11 +16817,14 @@ var FECManager = class _FECManager {
|
|
|
16547
16817
|
});
|
|
16548
16818
|
client.onCleanupComplete((sbn) => {
|
|
16549
16819
|
if (this.#releasedWorkerClients.has(client)) return;
|
|
16550
|
-
const
|
|
16820
|
+
const owed = [...this.#pendingWorkerCleanups].filter((key) => this.#pendingWorkerCleanupClients.get(key) === client);
|
|
16821
|
+
const cleanupKeys = owed.filter((key) => {
|
|
16551
16822
|
const block = this.#parseBlockKey(key);
|
|
16552
|
-
return block.packetId === packetId && block.sbn === sbn
|
|
16823
|
+
return block.packetId === packetId && block.sbn === sbn;
|
|
16553
16824
|
});
|
|
16554
|
-
|
|
16825
|
+
const askedAtMs = Math.max(...cleanupKeys.map((key) => this.#pendingWorkerCleanupBounds.get(key)?.askedAtMs ?? -Infinity));
|
|
16826
|
+
const due = owed.filter((key) => !cleanupKeys.includes(key) && (this.#pendingWorkerCleanupBounds.get(key)?.dueAtMs ?? Infinity) <= askedAtMs);
|
|
16827
|
+
for (const key of [...cleanupKeys, ...due]) this.#settleOwedCleanup(key, "cleanup-ack");
|
|
16555
16828
|
});
|
|
16556
16829
|
client.onError((msg, code) => {
|
|
16557
16830
|
const requestedKind = code ?? msg;
|
|
@@ -16621,9 +16894,11 @@ var FECManager = class _FECManager {
|
|
|
16621
16894
|
* fail deadline already passed, so failing it is the decision that deadline
|
|
16622
16895
|
* made. A late ack then finds nothing owed and is a no-op.
|
|
16623
16896
|
*/
|
|
16624
|
-
#boundOwedCleanup(key, packetId, client) {
|
|
16897
|
+
#boundOwedCleanup(key, packetId, client, dueAtMs) {
|
|
16625
16898
|
this.#clearOwedCleanupBound(key);
|
|
16626
16899
|
const bound = {
|
|
16900
|
+
dueAtMs,
|
|
16901
|
+
askedAtMs: performance.now(),
|
|
16627
16902
|
handle: setTimeout(() => {
|
|
16628
16903
|
if (this.#pendingWorkerCleanupBounds.get(key) !== bound) return;
|
|
16629
16904
|
this.#pendingWorkerCleanupBounds.delete(key);
|
|
@@ -16721,7 +16996,15 @@ var FECManager = class _FECManager {
|
|
|
16721
16996
|
this.#isoSourceOversizeCount++;
|
|
16722
16997
|
return null;
|
|
16723
16998
|
}
|
|
16724
|
-
|
|
16999
|
+
return this.#feedDecoderSource(packetId, ssId, symbolData, catalogTrackName, located.block.start);
|
|
17000
|
+
}
|
|
17001
|
+
/**
|
|
17002
|
+
* Hand one placed source symbol to the stream's decoder: its Worker, which
|
|
17003
|
+
* answers through onFrame (null here), or its synchronous decoder, whose
|
|
17004
|
+
* recovered block is returned. `sbn` is the SS_Start of the block a repair
|
|
17005
|
+
* stated for `ssId`.
|
|
17006
|
+
*/
|
|
17007
|
+
#feedDecoderSource(packetId, ssId, symbolData, catalogTrackName, sbn) {
|
|
16725
17008
|
const blockKey = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
16726
17009
|
const syncBlockOwner = this.#syncDecoderBlockOwners.get(blockKey);
|
|
16727
17010
|
const workerClient = this.#routableWorkerForPacket(packetId, catalogTrackName);
|
|
@@ -16750,6 +17033,74 @@ var FECManager = class _FECManager {
|
|
|
16750
17033
|
}
|
|
16751
17034
|
return recovered;
|
|
16752
17035
|
}
|
|
17036
|
+
/**
|
|
17037
|
+
* Feed a source symbol of this stream that another FEC instance over the
|
|
17038
|
+
* same packets rebuilt: a keyframe overlay recovery whose base SS_ID the
|
|
17039
|
+
* caller determined (draft-ramadan-moq-mmt-02 7.1, 7.4.4; joint decoding,
|
|
17040
|
+
* BLO-52085). It joins its block's decoder as a received source would, so
|
|
17041
|
+
* it reduces the erasures the block still has to solve, but it is not a
|
|
17042
|
+
* network arrival: no transport accounting, no classification evidence,
|
|
17043
|
+
* no deadline refresh, and it never makes a block clean.
|
|
17044
|
+
*
|
|
17045
|
+
* Only a block a repair stated takes one (a repair-less span has no
|
|
17046
|
+
* decoder block). A block that is terminal, or already holds that source,
|
|
17047
|
+
* does not. The symbol is the exact protected packet, unpadded, as
|
|
17048
|
+
* feedSourceSymbol takes it.
|
|
17049
|
+
*
|
|
17050
|
+
* `recovered` is the block the synchronous decoder completed with it; the
|
|
17051
|
+
* caller routes it and completes the block, as for any recovery. When
|
|
17052
|
+
* every source of the block is then present, received or rebuilt, and no
|
|
17053
|
+
* decoder returned it (a Worker answers asynchronously, and reports such a
|
|
17054
|
+
* block as clean on its own side), the block is completed here as
|
|
17055
|
+
* recovered, with nothing left to route.
|
|
17056
|
+
*/
|
|
17057
|
+
feedRebuiltSourceSymbol(packetId, ssId, symbolData, catalogTrackName) {
|
|
17058
|
+
if (!this.#hasBlockProfile(packetId)) return NOT_TAKEN;
|
|
17059
|
+
const located = this.#isoLocatorFor(packetId, catalogTrackName).locate(ssId);
|
|
17060
|
+
if (located === null || located.block.span) return NOT_TAKEN;
|
|
17061
|
+
if (!ssbg1FitsSymbol(symbolData.byteLength, this.#trackConfig(packetId).symbolSize)) return NOT_TAKEN;
|
|
17062
|
+
const sbn = located.block.start;
|
|
17063
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
17064
|
+
if (this.#completedBlocks.has(key) || this.#blockSourceEsis.get(key)?.has(located.esi)) return NOT_TAKEN;
|
|
17065
|
+
let rebuilt = this.#blockRebuiltEsis.get(key);
|
|
17066
|
+
if (rebuilt?.has(located.esi)) return NOT_TAKEN;
|
|
17067
|
+
if (rebuilt === void 0) {
|
|
17068
|
+
rebuilt = /* @__PURE__ */ new Set();
|
|
17069
|
+
this.#blockRebuiltEsis.set(key, rebuilt);
|
|
17070
|
+
}
|
|
17071
|
+
const config = this.#trackConfigs.get(packetId);
|
|
17072
|
+
const wasShort = config !== void 0 && this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) !== void 0;
|
|
17073
|
+
rebuilt.add(located.esi);
|
|
17074
|
+
const recovered = this.#feedDecoderSource(packetId, ssId, symbolData, catalogTrackName, sbn);
|
|
17075
|
+
if (recovered === null && !this.#completeWhenSourcesPresent(key, sbn, located.block.length, packetId, catalogTrackName)) {
|
|
17076
|
+
if (wasShort && this.#activeBlocks.has(key) && this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) === void 0) {
|
|
17077
|
+
this.#armBlockTimeout(sbn, packetId, catalogTrackName, this.#multicastWaitMs(config));
|
|
17078
|
+
}
|
|
17079
|
+
}
|
|
17080
|
+
return { taken: true, recovered };
|
|
17081
|
+
}
|
|
17082
|
+
/**
|
|
17083
|
+
* A block that holds every one of its `length` sources, received or
|
|
17084
|
+
* rebuilt by another instance, with at least one rebuilt, is recovered:
|
|
17085
|
+
* every packet of it was delivered, by its own arrival or by the instance
|
|
17086
|
+
* that rebuilt it, so nothing is routed. Returns whether it completed it.
|
|
17087
|
+
*/
|
|
17088
|
+
#completeWhenSourcesPresent(key, sbn, length, packetId, catalogTrackName) {
|
|
17089
|
+
const rebuilt = this.#blockRebuiltEsis.get(key);
|
|
17090
|
+
if (rebuilt === void 0 || this.#completedBlocks.has(key)) return false;
|
|
17091
|
+
let present = rebuilt.size;
|
|
17092
|
+
for (const esi of this.#blockSourceEsis.get(key) ?? []) if (!rebuilt.has(esi)) present++;
|
|
17093
|
+
if (present < length) return false;
|
|
17094
|
+
this.#traceLifecycle("recovered", sbn, packetId, catalogTrackName);
|
|
17095
|
+
this.countRecovery(packetId, sbn, catalogTrackName);
|
|
17096
|
+
this.cancelBlockTimeout(sbn, packetId, catalogTrackName);
|
|
17097
|
+
if (catalogTrackName === void 0) {
|
|
17098
|
+
this.onBlockComplete?.(sbn, packetId);
|
|
17099
|
+
} else {
|
|
17100
|
+
this.onBlockComplete?.(sbn, packetId, catalogTrackName);
|
|
17101
|
+
}
|
|
17102
|
+
return true;
|
|
17103
|
+
}
|
|
16753
17104
|
/**
|
|
16754
17105
|
* fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
|
|
16755
17106
|
* exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
|
|
@@ -16952,8 +17303,76 @@ var FECManager = class _FECManager {
|
|
|
16952
17303
|
this.#completeCleanBlock(blockKey, sbn, packetId, catalogTrackName);
|
|
16953
17304
|
return null;
|
|
16954
17305
|
}
|
|
17306
|
+
if (recovered === null) this.#shortenUnrecoverableWait(blockKey, sbn, packetId, catalogTrackName);
|
|
16955
17307
|
return recovered;
|
|
16956
17308
|
}
|
|
17309
|
+
/**
|
|
17310
|
+
* A first-arrival multicast source, held or placed. A datagram flow keeps
|
|
17311
|
+
* its sources in send order, so one that moves the stream's newest source
|
|
17312
|
+
* position past a block leaves the sources that block still misses
|
|
17313
|
+
* reordered behind it at best: it shortens the wait of every block it
|
|
17314
|
+
* passed that only a late source can complete. MoQ is left out: its streams
|
|
17315
|
+
* can overtake one another, so a MoQ source shows nothing about the sources
|
|
17316
|
+
* sent before it.
|
|
17317
|
+
*/
|
|
17318
|
+
#noteMulticastSource(locator, ssId, packetId, catalogTrackName) {
|
|
17319
|
+
const previous = locator.newestSource;
|
|
17320
|
+
if (!locator.noteSource(ssId) || previous === void 0) return;
|
|
17321
|
+
for (const block of locator.blocksBetween(previous - 1 >>> 0, ssId)) {
|
|
17322
|
+
if (!serial32Precedes(serial32Add(block.start, block.length - 1), ssId)) continue;
|
|
17323
|
+
this.#shortenUnrecoverableWait(
|
|
17324
|
+
this.#blockKey(block.start, packetId, catalogTrackName),
|
|
17325
|
+
block.start,
|
|
17326
|
+
packetId,
|
|
17327
|
+
catalogTrackName
|
|
17328
|
+
);
|
|
17329
|
+
}
|
|
17330
|
+
}
|
|
17331
|
+
/**
|
|
17332
|
+
* The wait of a block that only a late source can complete (BLO-52085): a
|
|
17333
|
+
* repair stated it, or it is a repair-less span longer than K (whose group
|
|
17334
|
+
* is empty, #openIsoSpan), its received sources plus every symbol its
|
|
17335
|
+
* repair group carries (RSB_length) are short of K' (the repair scheduler's
|
|
17336
|
+
* group-cannot-complete), and a later source of the stream has arrived, so
|
|
17337
|
+
* a source it misses is lost or reordered behind that one. The span, which
|
|
17338
|
+
* covers repair symbols paced after its sources, buys it nothing: it waits
|
|
17339
|
+
* the late-symbol allowance alone, the multicast wait less the span (the
|
|
17340
|
+
* catalog tolerance or the measured delivery gap). Undefined for any other
|
|
17341
|
+
* block.
|
|
17342
|
+
*/
|
|
17343
|
+
#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) {
|
|
17344
|
+
const authoredLength = this.#blockAuthoredLengths.get(key);
|
|
17345
|
+
const rsbLength = this.#blockRsbLengths.get(key);
|
|
17346
|
+
if (authoredLength === void 0 || rsbLength === void 0) return void 0;
|
|
17347
|
+
let present = this.#blockSourceCounts.get(key) ?? 0;
|
|
17348
|
+
const received = this.#blockSourceEsis.get(key);
|
|
17349
|
+
for (const esi of this.#blockRebuiltEsis.get(key) ?? []) if (!received?.has(esi)) present++;
|
|
17350
|
+
if (present + rsbLength >= authoredLength) return void 0;
|
|
17351
|
+
const newestSource = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))?.newestSource;
|
|
17352
|
+
if (newestSource === void 0 || !serial32Precedes(serial32Add(sbn, authoredLength - 1), newestSource)) {
|
|
17353
|
+
return void 0;
|
|
17354
|
+
}
|
|
17355
|
+
return this.#multicastWaitMs(config) - config.interleaveDepthMs;
|
|
17356
|
+
}
|
|
17357
|
+
/**
|
|
17358
|
+
* Bring an open block's wait in to its late-source wait, when it has one.
|
|
17359
|
+
* Never later than it is armed: only a source can complete such a block,
|
|
17360
|
+
* so a repair of its group (paced across the span) must not keep it open.
|
|
17361
|
+
*/
|
|
17362
|
+
#shortenUnrecoverableWait(key, sbn, packetId, catalogTrackName) {
|
|
17363
|
+
if (!this.#activeBlocks.has(key)) return;
|
|
17364
|
+
const config = this.#trackConfigs.get(packetId);
|
|
17365
|
+
if (config === void 0) return;
|
|
17366
|
+
const waitMs = this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config);
|
|
17367
|
+
if (waitMs === void 0) return;
|
|
17368
|
+
const armedAtMs = this.#blockWaitDeadlinesMs.get(key);
|
|
17369
|
+
this.#armBlockTimeout(
|
|
17370
|
+
sbn,
|
|
17371
|
+
packetId,
|
|
17372
|
+
catalogTrackName,
|
|
17373
|
+
armedAtMs === void 0 ? waitMs : Math.min(waitMs, armedAtMs - this.#receiptNow())
|
|
17374
|
+
);
|
|
17375
|
+
}
|
|
16957
17376
|
/**
|
|
16958
17377
|
* Record a block's authored SSB_length from a repair symbol. Returns false,
|
|
16959
17378
|
* leaving the block unchanged, when the symbol contradicts the block: a
|
|
@@ -17051,12 +17470,13 @@ var FECManager = class _FECManager {
|
|
|
17051
17470
|
* the inactivity deadline on each symbol, records the symbol's in-band
|
|
17052
17471
|
* classification evidence, and marks the block clean when all of its
|
|
17053
17472
|
* authored source symbols arrived: the SSB_length a repair symbol declared,
|
|
17054
|
-
* otherwise K.
|
|
17473
|
+
* otherwise K. `held` marks a source held unplaced since it arrived and
|
|
17474
|
+
* placed only now (see #noteSbnSeen).
|
|
17055
17475
|
*
|
|
17056
17476
|
* Throws for a packetId that was never configured, so a classified block
|
|
17057
17477
|
* never reads the manager-global K or timeout.
|
|
17058
17478
|
*/
|
|
17059
|
-
trackBlock(sbn, packetId, catalogTrackName, esi, evidence) {
|
|
17479
|
+
trackBlock(sbn, packetId, catalogTrackName, esi, evidence, held = false) {
|
|
17060
17480
|
const trackConfig = this.#trackConfigs.get(packetId);
|
|
17061
17481
|
if (trackConfig === void 0) {
|
|
17062
17482
|
throw new Error(
|
|
@@ -17072,7 +17492,8 @@ var FECManager = class _FECManager {
|
|
|
17072
17492
|
catalogTrackName,
|
|
17073
17493
|
"source",
|
|
17074
17494
|
evidence.packetSequenceNumber,
|
|
17075
|
-
Number.isInteger(esi) ? sbn + esi >>> 0 : sbn
|
|
17495
|
+
Number.isInteger(esi) ? sbn + esi >>> 0 : sbn,
|
|
17496
|
+
held
|
|
17076
17497
|
);
|
|
17077
17498
|
const authoredLength = this.#blockAuthoredLengths.get(key) ?? k;
|
|
17078
17499
|
if (Number.isInteger(esi) && esi >= authoredLength) {
|
|
@@ -17108,6 +17529,15 @@ var FECManager = class _FECManager {
|
|
|
17108
17529
|
this.#completeCleanBlock(key, sbn, packetId, catalogTrackName);
|
|
17109
17530
|
return;
|
|
17110
17531
|
}
|
|
17532
|
+
if (this.#blockRebuiltEsis.has(key) && this.#completeWhenSourcesPresent(
|
|
17533
|
+
key,
|
|
17534
|
+
sbn,
|
|
17535
|
+
this.#isoLocatorFor(packetId, catalogTrackName).blockAt(sbn)?.length ?? authoredLength,
|
|
17536
|
+
packetId,
|
|
17537
|
+
catalogTrackName
|
|
17538
|
+
)) {
|
|
17539
|
+
return;
|
|
17540
|
+
}
|
|
17111
17541
|
this.noteBlockActivity(sbn, packetId, catalogTrackName, true);
|
|
17112
17542
|
}
|
|
17113
17543
|
#completeCleanBlock(key, sbn, packetId, catalogTrackName) {
|
|
@@ -17116,7 +17546,9 @@ var FECManager = class _FECManager {
|
|
|
17116
17546
|
this.cancelBlockTimeout(sbn, packetId, catalogTrackName);
|
|
17117
17547
|
this.#blockSourceCounts.delete(key);
|
|
17118
17548
|
this.#blockSourceEsis.delete(key);
|
|
17549
|
+
this.#blockRebuiltEsis.delete(key);
|
|
17119
17550
|
this.#blockAuthoredLengths.delete(key);
|
|
17551
|
+
this.#isoSpanKeys.delete(key);
|
|
17120
17552
|
this.#blockRepairRsIds.delete(key);
|
|
17121
17553
|
this.#blockRsbLengths.delete(key);
|
|
17122
17554
|
this.#markTerminal(key, sbn, packetId, true);
|
|
@@ -17147,6 +17579,19 @@ var FECManager = class _FECManager {
|
|
|
17147
17579
|
#receiptNow() {
|
|
17148
17580
|
return this.#receiptAtMs ?? performance.now();
|
|
17149
17581
|
}
|
|
17582
|
+
/**
|
|
17583
|
+
* The whole-ms delay of a timer for `deadlineMs` armed inside a receipt
|
|
17584
|
+
* scope: counted from the receipt time, as the timer of a symbol fed when
|
|
17585
|
+
* it was received was, less the whole ms since. So it fires on the tick
|
|
17586
|
+
* that timer would have, never later than a delay counted from now, and
|
|
17587
|
+
* its handler still re-arms a timer that fires before its deadline.
|
|
17588
|
+
* Counted from now, a deadline set from the receipt time is rounded up
|
|
17589
|
+
* from another fraction of a ms (BLO-52085).
|
|
17590
|
+
*/
|
|
17591
|
+
#receiptTimerDelayMs(deadlineMs, minMs) {
|
|
17592
|
+
const receivedAtMs = this.#receiptAtMs;
|
|
17593
|
+
return Math.max(minMs, Math.ceil(deadlineMs - receivedAtMs) - Math.ceil(performance.now() - receivedAtMs));
|
|
17594
|
+
}
|
|
17150
17595
|
/**
|
|
17151
17596
|
* A held packet admitted late arms from its (earlier) receipt time; that
|
|
17152
17597
|
* never pulls in a deadline later activity already armed. Outside a
|
|
@@ -17182,10 +17627,20 @@ var FECManager = class _FECManager {
|
|
|
17182
17627
|
this.#repairDeadlineMs(trackConfig)
|
|
17183
17628
|
);
|
|
17184
17629
|
}
|
|
17185
|
-
this.#
|
|
17630
|
+
if (!sourceProgress && this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, trackConfig) !== void 0) {
|
|
17631
|
+
this.#shortenUnrecoverableWait(key, sbn, packetId, catalogTrackName);
|
|
17632
|
+
return;
|
|
17633
|
+
}
|
|
17634
|
+
this.#armBlockTimeout(
|
|
17635
|
+
sbn,
|
|
17636
|
+
packetId,
|
|
17637
|
+
catalogTrackName,
|
|
17638
|
+
this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, trackConfig) ?? timeoutMs
|
|
17639
|
+
);
|
|
17186
17640
|
}
|
|
17187
17641
|
#failBlock(sbn, packetId, catalogTrackName) {
|
|
17188
17642
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
17643
|
+
const span = this.#isoSpanKeys.delete(key) ? { length: this.#blockAuthoredLengths.get(key) ?? 0, sources: this.#blockSourceCounts.get(key) ?? 0 } : void 0;
|
|
17189
17644
|
this.#traceLifecycle("failed", sbn, packetId, catalogTrackName);
|
|
17190
17645
|
this.#clearRepairDeadline(key);
|
|
17191
17646
|
this.#clearBlockTimer(key);
|
|
@@ -17195,6 +17650,7 @@ var FECManager = class _FECManager {
|
|
|
17195
17650
|
}
|
|
17196
17651
|
this.#blockSourceCounts.delete(key);
|
|
17197
17652
|
this.#blockSourceEsis.delete(key);
|
|
17653
|
+
this.#blockRebuiltEsis.delete(key);
|
|
17198
17654
|
this.#blockAuthoredLengths.delete(key);
|
|
17199
17655
|
this.#blockRepairRsIds.delete(key);
|
|
17200
17656
|
this.#blockRsbLengths.delete(key);
|
|
@@ -17204,7 +17660,8 @@ var FECManager = class _FECManager {
|
|
|
17204
17660
|
this.#markPathBlockComplete(sbn, packetId, catalogTrackName);
|
|
17205
17661
|
this.#fecStats.blocksFailed++;
|
|
17206
17662
|
this.#statsForPacket(packetId).blocksFailed++;
|
|
17207
|
-
this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
17663
|
+
if (span === void 0) this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
17664
|
+
else this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span);
|
|
17208
17665
|
this.onBlockResolved?.(sbn, packetId, catalogTrackName);
|
|
17209
17666
|
}
|
|
17210
17667
|
/**
|
|
@@ -17233,7 +17690,9 @@ var FECManager = class _FECManager {
|
|
|
17233
17690
|
this.#retireBlockClass(key, block.sbn, block.packetId, block.catalogTrackName);
|
|
17234
17691
|
this.#blockSourceCounts.delete(key);
|
|
17235
17692
|
this.#blockSourceEsis.delete(key);
|
|
17693
|
+
this.#blockRebuiltEsis.delete(key);
|
|
17236
17694
|
this.#blockAuthoredLengths.delete(key);
|
|
17695
|
+
this.#isoSpanKeys.delete(key);
|
|
17237
17696
|
this.#blockRepairRsIds.delete(key);
|
|
17238
17697
|
this.#blockRsbLengths.delete(key);
|
|
17239
17698
|
this.#clearBlockTimer(key);
|
|
@@ -17324,7 +17783,9 @@ var FECManager = class _FECManager {
|
|
|
17324
17783
|
this.#blockKeysBySbn.clear();
|
|
17325
17784
|
this.#blockSourceCounts.clear();
|
|
17326
17785
|
this.#blockSourceEsis.clear();
|
|
17786
|
+
this.#blockRebuiltEsis.clear();
|
|
17327
17787
|
this.#blockAuthoredLengths.clear();
|
|
17788
|
+
this.#isoSpanKeys.clear();
|
|
17328
17789
|
this.#blockRepairRsIds.clear();
|
|
17329
17790
|
this.#blockRsbLengths.clear();
|
|
17330
17791
|
this.#heldLayerStates.clear();
|
|
@@ -17349,6 +17810,7 @@ var FECManager = class _FECManager {
|
|
|
17349
17810
|
this.#blockAnchorsMs.clear();
|
|
17350
17811
|
this.#blockCatalogTrackNames.clear();
|
|
17351
17812
|
this.#classifiers.clear();
|
|
17813
|
+
this.#noSpanRaps.clear();
|
|
17352
17814
|
this.#streamGeometries.clear();
|
|
17353
17815
|
this.#failedBlocks.clear();
|
|
17354
17816
|
this.#resolvedBlockClasses.clear();
|
|
@@ -17879,9 +18341,21 @@ var IsoBmffTimingResolver = class {
|
|
|
17879
18341
|
}
|
|
17880
18342
|
#track = null;
|
|
17881
18343
|
#fragments = /* @__PURE__ */ new Map();
|
|
18344
|
+
/** First sample of each pending fragment, kept in `#delivered` with its sample count. */
|
|
18345
|
+
#firstSamples = /* @__PURE__ */ new Map();
|
|
18346
|
+
/**
|
|
18347
|
+
* First sample and sample count of the newest fragments whose every slot was
|
|
18348
|
+
* cleared. Abandonment counts: `releaseSample` clears a slot too, which
|
|
18349
|
+
* matches the combiner, since it retires an abandoned sample as well.
|
|
18350
|
+
*/
|
|
18351
|
+
#delivered = /* @__PURE__ */ new Map();
|
|
17882
18352
|
#pendingSamples = 0;
|
|
17883
18353
|
#evictedSamples = 0;
|
|
17884
18354
|
#lastMovieFragmentRejection = null;
|
|
18355
|
+
/** True once an FT=0 has bound the track that FT=1 timing is read against. */
|
|
18356
|
+
get initialized() {
|
|
18357
|
+
return this.#track !== null;
|
|
18358
|
+
}
|
|
17885
18359
|
get pendingSampleCount() {
|
|
17886
18360
|
return this.#pendingSamples;
|
|
17887
18361
|
}
|
|
@@ -17905,7 +18379,14 @@ var IsoBmffTimingResolver = class {
|
|
|
17905
18379
|
this.#track = timing;
|
|
17906
18380
|
return true;
|
|
17907
18381
|
}
|
|
17908
|
-
|
|
18382
|
+
/**
|
|
18383
|
+
* `recovered` marks an FEC-recovered copy. A recovered block hands back
|
|
18384
|
+
* every FT=1 it holds, the received ones included, so a recovered copy of a
|
|
18385
|
+
* fragment whose samples are all done is a duplicate: admitting it again
|
|
18386
|
+
* would charge stale timing and could displace the live MPU's. A source
|
|
18387
|
+
* copy is still admitted again (a rendition switch re-arms timing that way).
|
|
18388
|
+
*/
|
|
18389
|
+
addMovieFragment(mpuSequenceNumber2, data, additionalSampleLimit = this.maxPendingSamples, recovered = false) {
|
|
17909
18390
|
this.#lastMovieFragmentRejection = null;
|
|
17910
18391
|
if (!Number.isInteger(additionalSampleLimit) || additionalSampleLimit < 0) {
|
|
17911
18392
|
this.#lastMovieFragmentRejection = "invalid";
|
|
@@ -17931,6 +18412,8 @@ var IsoBmffTimingResolver = class {
|
|
|
17931
18412
|
(sample, index) => sample !== null && sameSample(sample, parsed.samples[index])
|
|
17932
18413
|
);
|
|
17933
18414
|
}
|
|
18415
|
+
const delivered = recovered ? this.#delivered.get(key) : void 0;
|
|
18416
|
+
if (delivered && delivered.sampleCount === parsed.samples.length && sameSample(delivered.first, parsed.samples[0])) return true;
|
|
17934
18417
|
let freed = 0;
|
|
17935
18418
|
while (this.#fragments.size > 0 && (this.#pendingSamples + parsed.samples.length > this.maxPendingSamples || parsed.samples.length - freed > additionalSampleLimit)) {
|
|
17936
18419
|
freed += this.#evictOldestFragment();
|
|
@@ -17944,6 +18427,7 @@ var IsoBmffTimingResolver = class {
|
|
|
17944
18427
|
return false;
|
|
17945
18428
|
}
|
|
17946
18429
|
this.#fragments.set(key, [...parsed.samples]);
|
|
18430
|
+
this.#firstSamples.set(key, parsed.samples[0]);
|
|
17947
18431
|
this.#pendingSamples += parsed.samples.length;
|
|
17948
18432
|
return true;
|
|
17949
18433
|
}
|
|
@@ -18001,6 +18485,7 @@ var IsoBmffTimingResolver = class {
|
|
|
18001
18485
|
let live = 0;
|
|
18002
18486
|
for (const sample of samples) if (sample !== null) live++;
|
|
18003
18487
|
this.#fragments.delete(oldest);
|
|
18488
|
+
this.#firstSamples.delete(oldest);
|
|
18004
18489
|
this.#pendingSamples -= live;
|
|
18005
18490
|
this.#evictedSamples += live;
|
|
18006
18491
|
return live;
|
|
@@ -18016,12 +18501,23 @@ var IsoBmffTimingResolver = class {
|
|
|
18016
18501
|
if (!samples || !samples[index]) return false;
|
|
18017
18502
|
samples[index] = null;
|
|
18018
18503
|
this.#pendingSamples--;
|
|
18019
|
-
if (samples.every((value) => value === null))
|
|
18504
|
+
if (samples.every((value) => value === null)) {
|
|
18505
|
+
this.#fragments.delete(key);
|
|
18506
|
+
const first = this.#firstSamples.get(key);
|
|
18507
|
+
this.#firstSamples.delete(key);
|
|
18508
|
+
this.#delivered.delete(key);
|
|
18509
|
+
this.#delivered.set(key, { first, sampleCount: samples.length });
|
|
18510
|
+
if (this.#delivered.size > this.maxPendingSamples) {
|
|
18511
|
+
this.#delivered.delete(this.#delivered.keys().next().value);
|
|
18512
|
+
}
|
|
18513
|
+
}
|
|
18020
18514
|
return true;
|
|
18021
18515
|
}
|
|
18022
18516
|
reset() {
|
|
18023
18517
|
this.#track = null;
|
|
18024
18518
|
this.#fragments.clear();
|
|
18519
|
+
this.#firstSamples.clear();
|
|
18520
|
+
this.#delivered.clear();
|
|
18025
18521
|
this.#pendingSamples = 0;
|
|
18026
18522
|
}
|
|
18027
18523
|
};
|
|
@@ -18191,6 +18687,9 @@ function authoredGap(before, after) {
|
|
|
18191
18687
|
function ssIdAfter(a, b) {
|
|
18192
18688
|
return (a - b | 0) > 0;
|
|
18193
18689
|
}
|
|
18690
|
+
function holdsRebuilt(stream) {
|
|
18691
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
|
|
18692
|
+
}
|
|
18194
18693
|
var FecReleaseSequencer = class {
|
|
18195
18694
|
#streams = /* @__PURE__ */ new Map();
|
|
18196
18695
|
#gate;
|
|
@@ -18253,6 +18752,7 @@ var FecReleaseSequencer = class {
|
|
|
18253
18752
|
stream.lastSbn = void 0;
|
|
18254
18753
|
stream.discontinuity = false;
|
|
18255
18754
|
stream.rapSsId = void 0;
|
|
18755
|
+
stream.sourced = false;
|
|
18256
18756
|
}
|
|
18257
18757
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
18258
18758
|
this.#recordStat("droppedStale");
|
|
@@ -18279,6 +18779,7 @@ var FecReleaseSequencer = class {
|
|
|
18279
18779
|
if (compareFrameOrder(stream.buf[mid], frame) < 0) lo = mid + 1;
|
|
18280
18780
|
else hi = mid;
|
|
18281
18781
|
}
|
|
18782
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true;
|
|
18282
18783
|
stream.buf.splice(lo, 0, frame);
|
|
18283
18784
|
this.#drainUnlessDeferred(stream);
|
|
18284
18785
|
}
|
|
@@ -18314,6 +18815,41 @@ var FecReleaseSequencer = class {
|
|
|
18314
18815
|
}
|
|
18315
18816
|
return false;
|
|
18316
18817
|
}
|
|
18818
|
+
/**
|
|
18819
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
18820
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
18821
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
18822
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
18823
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
18824
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
18825
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
18826
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
18827
|
+
* released.
|
|
18828
|
+
*/
|
|
18829
|
+
unsource(packetId, catalogTrackName) {
|
|
18830
|
+
for (const stream of this.#streams.values()) {
|
|
18831
|
+
if (stream.packetId === packetId && (catalogTrackName === void 0 || stream.catalogTrackName === catalogTrackName)) {
|
|
18832
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
18833
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
18834
|
+
else this.#drain(stream, true);
|
|
18835
|
+
}
|
|
18836
|
+
stream.sourced = false;
|
|
18837
|
+
}
|
|
18838
|
+
}
|
|
18839
|
+
}
|
|
18840
|
+
/**
|
|
18841
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
18842
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
18843
|
+
* packetId.
|
|
18844
|
+
*/
|
|
18845
|
+
holdsRebuilt(packetId, catalogTrackName) {
|
|
18846
|
+
for (const stream of this.#streams.values()) {
|
|
18847
|
+
if (stream.packetId !== packetId) continue;
|
|
18848
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
18849
|
+
if (holdsRebuilt(stream)) return true;
|
|
18850
|
+
}
|
|
18851
|
+
return false;
|
|
18852
|
+
}
|
|
18317
18853
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
18318
18854
|
poke(streamKey) {
|
|
18319
18855
|
if (streamKey !== void 0) {
|
|
@@ -18405,16 +18941,32 @@ var FecReleaseSequencer = class {
|
|
|
18405
18941
|
last: null,
|
|
18406
18942
|
lastSbn: void 0,
|
|
18407
18943
|
discontinuity: false,
|
|
18408
|
-
rapSsId: void 0
|
|
18944
|
+
rapSsId: void 0,
|
|
18945
|
+
sourced: false,
|
|
18946
|
+
draining: 0
|
|
18409
18947
|
};
|
|
18410
18948
|
this.#streams.set(streamKey, stream);
|
|
18411
18949
|
}
|
|
18412
18950
|
return stream;
|
|
18413
18951
|
}
|
|
18414
|
-
#
|
|
18952
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
18953
|
+
#drain(stream, asUnanchored = false) {
|
|
18954
|
+
stream.draining++;
|
|
18955
|
+
try {
|
|
18956
|
+
this.#drainLoop(stream, asUnanchored);
|
|
18957
|
+
} finally {
|
|
18958
|
+
stream.draining--;
|
|
18959
|
+
}
|
|
18960
|
+
}
|
|
18961
|
+
#drainLoop(stream, asUnanchored) {
|
|
18415
18962
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
18416
18963
|
const head = stream.buf[0];
|
|
18417
18964
|
const last = stream.last;
|
|
18965
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
18966
|
+
stream.buf.shift();
|
|
18967
|
+
this.#release(stream, head, void 0);
|
|
18968
|
+
continue;
|
|
18969
|
+
}
|
|
18418
18970
|
if (stream.discontinuity) {
|
|
18419
18971
|
stream.discontinuity = false;
|
|
18420
18972
|
stream.buf.shift();
|
|
@@ -18428,9 +18980,10 @@ var FecReleaseSequencer = class {
|
|
|
18428
18980
|
}
|
|
18429
18981
|
const headSbn = head.meta.fecSbn;
|
|
18430
18982
|
const from = stream.lastSbn ?? headSbn;
|
|
18431
|
-
const to = headSbn ?? stream.lastSbn;
|
|
18983
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn;
|
|
18432
18984
|
let lost = [];
|
|
18433
18985
|
const unanchored = from === void 0 && to === void 0;
|
|
18986
|
+
let unresolved = false;
|
|
18434
18987
|
if (from !== void 0 && to !== void 0) {
|
|
18435
18988
|
const resolved = this.#gate.resolvedLoss(
|
|
18436
18989
|
stream.packetId,
|
|
@@ -18439,7 +18992,8 @@ var FecReleaseSequencer = class {
|
|
|
18439
18992
|
Math.max(from, to),
|
|
18440
18993
|
from
|
|
18441
18994
|
);
|
|
18442
|
-
|
|
18995
|
+
unresolved = resolved === null;
|
|
18996
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored)) {
|
|
18443
18997
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
18444
18998
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
18445
18999
|
this.#recordStat("forcedWindowFlushes");
|
|
@@ -18447,22 +19001,56 @@ var FecReleaseSequencer = class {
|
|
|
18447
19001
|
this.#release(stream, head, this.#gate.decide(last, head, [], true));
|
|
18448
19002
|
continue;
|
|
18449
19003
|
}
|
|
18450
|
-
lost = resolved;
|
|
19004
|
+
lost = resolved ?? [];
|
|
18451
19005
|
}
|
|
18452
19006
|
stream.buf.shift();
|
|
18453
19007
|
this.#release(
|
|
18454
19008
|
stream,
|
|
18455
19009
|
head,
|
|
18456
|
-
lost.length > 0 || unanchored || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
19010
|
+
lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
18457
19011
|
);
|
|
18458
19012
|
}
|
|
18459
19013
|
}
|
|
19014
|
+
/**
|
|
19015
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
19016
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
19017
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
19018
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
19019
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
19020
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
19021
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
19022
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
19023
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
19024
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
19025
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
19026
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
19027
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
19028
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
19029
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
19030
|
+
*/
|
|
19031
|
+
#cursorPassed(stream, asUnanchored) {
|
|
19032
|
+
let at2 = -1;
|
|
19033
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
19034
|
+
const frame = stream.buf[i];
|
|
19035
|
+
if (frame.meta.fecSbnFirst !== void 0 || frame.meta.fecSbn === void 0) {
|
|
19036
|
+
frame.passed = true;
|
|
19037
|
+
if (at2 < 0) at2 = i;
|
|
19038
|
+
} else if (frame.passed !== true) break;
|
|
19039
|
+
}
|
|
19040
|
+
if (at2 < 0) return false;
|
|
19041
|
+
return asUnanchored || !stream.sourced || this.#gate.releaseUnanchored?.(stream.packetId, stream.catalogTrackName) === true || stream.buf.some(({ meta }, i) => i > at2 && meta.fecSbnFirst === void 0 && (meta.recovered !== true || meta.fecSbn !== void 0));
|
|
19042
|
+
}
|
|
18460
19043
|
#release(stream, frame, decision) {
|
|
19044
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0;
|
|
19045
|
+
if (stale) this.#recordStat("droppedStale");
|
|
18461
19046
|
if (decision) frame.meta.gapBefore = decision;
|
|
18462
19047
|
stream.last = frame;
|
|
18463
|
-
if (frame.meta.fecSbn !== void 0
|
|
19048
|
+
if (frame.meta.fecSbn !== void 0 && (frame.meta.fecSbnFirst === void 0 || stream.lastSbn !== void 0)) {
|
|
19049
|
+
stream.lastSbn = frame.meta.fecSbn;
|
|
19050
|
+
}
|
|
19051
|
+
if (frame.meta.recovered !== true) stream.sourced = true;
|
|
18464
19052
|
this.#gate.onReleased?.(frame.data, frame.meta);
|
|
18465
|
-
this.#emit(frame.data, frame.meta);
|
|
19053
|
+
if (!stale) this.#emit(frame.data, frame.meta);
|
|
18466
19054
|
}
|
|
18467
19055
|
};
|
|
18468
19056
|
var FMPU_BOX_TYPES = /* @__PURE__ */ new Set(["ftyp", "moov", "moof"]);
|
|
@@ -18503,6 +19091,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18503
19091
|
this.#reclaimedTimingSamples = 0;
|
|
18504
19092
|
this.#evictedTimingSamples = 0;
|
|
18505
19093
|
this.#rejectedMovieFragments = 0;
|
|
19094
|
+
this.#recoveredHeadsAwaitingTiming = {
|
|
19095
|
+
held: 0,
|
|
19096
|
+
expired: 0,
|
|
19097
|
+
discarded: 0,
|
|
19098
|
+
superseded: 0
|
|
19099
|
+
};
|
|
18506
19100
|
this.#sequencers = /* @__PURE__ */ new Map();
|
|
18507
19101
|
this.#fecGate = null;
|
|
18508
19102
|
this.#fecSequencer = null;
|
|
@@ -18611,6 +19205,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18611
19205
|
#reclaimedTimingSamples;
|
|
18612
19206
|
#evictedTimingSamples;
|
|
18613
19207
|
#rejectedMovieFragments;
|
|
19208
|
+
#recoveredHeadsAwaitingTiming;
|
|
18614
19209
|
#sequencers;
|
|
18615
19210
|
#fecGate;
|
|
18616
19211
|
#fecSequencer;
|
|
@@ -18716,11 +19311,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18716
19311
|
/**
|
|
18717
19312
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
18718
19313
|
*
|
|
18719
|
-
*
|
|
18720
|
-
*
|
|
18721
|
-
*
|
|
18722
|
-
*
|
|
18723
|
-
*
|
|
19314
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
19315
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
19316
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
19317
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
19318
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
19319
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
18724
19320
|
*/
|
|
18725
19321
|
get timingBudgetStats() {
|
|
18726
19322
|
return {
|
|
@@ -18731,6 +19327,14 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18731
19327
|
rejectedMovieFragments: this.#rejectedMovieFragments
|
|
18732
19328
|
};
|
|
18733
19329
|
}
|
|
19330
|
+
/** Recovered heads parked for FT=1 timing (BLO-53369). Survives dispose(). */
|
|
19331
|
+
get recoveredHeadsAwaitingTiming() {
|
|
19332
|
+
let pending = 0;
|
|
19333
|
+
for (const { awaitingTiming } of this.#timingStreams.values()) {
|
|
19334
|
+
for (const head of awaitingTiming) if (head.options?.recovered) pending++;
|
|
19335
|
+
}
|
|
19336
|
+
return { ...this.#recoveredHeadsAwaitingTiming, pending };
|
|
19337
|
+
}
|
|
18734
19338
|
get reorderStats() {
|
|
18735
19339
|
let bufferedFrames = this.#fecSequencer?.buffered ?? 0;
|
|
18736
19340
|
for (const { sequencer } of this.#sequencers.values()) bufferedFrames += sequencer.buffered;
|
|
@@ -18772,6 +19376,14 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18772
19376
|
fecReleaseRapAbove(packetId, catalogTrackName, ssId) {
|
|
18773
19377
|
return this.#fecSequencer?.rapAbove(packetId, catalogTrackName, ssId) ?? false;
|
|
18774
19378
|
}
|
|
19379
|
+
/** See FecReleaseSequencer.unsource. */
|
|
19380
|
+
unsourceFecRelease(packetId, catalogTrackName) {
|
|
19381
|
+
this.#fecSequencer?.unsource(packetId, catalogTrackName);
|
|
19382
|
+
}
|
|
19383
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
19384
|
+
fecReleaseHoldsRebuilt(packetId, catalogTrackName) {
|
|
19385
|
+
return this.#fecSequencer?.holdsRebuilt(packetId, catalogTrackName) ?? false;
|
|
19386
|
+
}
|
|
18775
19387
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
18776
19388
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
18777
19389
|
if (!this.#fecSequencer) return;
|
|
@@ -18904,7 +19516,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
18904
19516
|
const now = Date.now();
|
|
18905
19517
|
for (const { awaitingTiming } of this.#timingStreams.values()) {
|
|
18906
19518
|
while (awaitingTiming.length > 0 && now - awaitingTiming[0].arrivedAt > timeoutMs) {
|
|
18907
|
-
awaitingTiming.shift();
|
|
19519
|
+
this.#leaveAwaitingTiming(awaitingTiming.shift(), "expired");
|
|
18908
19520
|
}
|
|
18909
19521
|
}
|
|
18910
19522
|
}
|
|
@@ -19022,11 +19634,16 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19022
19634
|
if (mpu.fragmentationIndicator !== 0 || mpu.fragmentCounter !== 0)
|
|
19023
19635
|
return this.#drop("fragment-unexpected-fragmentation");
|
|
19024
19636
|
const resolver2 = this.#timingResolver(streamKey, info.packetId, false);
|
|
19025
|
-
if (!resolver2) return this.#drop("fragment-no-resolver");
|
|
19637
|
+
if (!resolver2?.initialized) return this.#drop("fragment-no-resolver");
|
|
19026
19638
|
const pendingBefore = resolver2.pendingSampleCount;
|
|
19027
19639
|
const evictedBefore = resolver2.evictedSampleCount;
|
|
19028
|
-
const remaining = this.#maxPendingTimingSamples -
|
|
19029
|
-
const admitted = resolver2.addMovieFragment(
|
|
19640
|
+
const remaining = this.#maxPendingTimingSamples - resolver2.pendingSampleCount;
|
|
19641
|
+
const admitted = resolver2.addMovieFragment(
|
|
19642
|
+
mpu.mpuSequenceNumber,
|
|
19643
|
+
data,
|
|
19644
|
+
remaining,
|
|
19645
|
+
options?.recovered === true
|
|
19646
|
+
);
|
|
19030
19647
|
this.#pendingTimingSamples += resolver2.pendingSampleCount - pendingBefore;
|
|
19031
19648
|
this.#evictedTimingSamples += resolver2.evictedSampleCount - evictedBefore;
|
|
19032
19649
|
if (!admitted) {
|
|
@@ -19046,7 +19663,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19046
19663
|
};
|
|
19047
19664
|
}
|
|
19048
19665
|
if (fragmentType !== 2) return this.#drop("unknown-fragment-type");
|
|
19049
|
-
const resolver = this.#timingResolver(streamKey, info.packetId,
|
|
19666
|
+
const resolver = this.#timingResolver(streamKey, info.packetId, true);
|
|
19050
19667
|
if (!resolver) return this.#drop("mfu-no-resolver");
|
|
19051
19668
|
if (!Number.isSafeInteger(data.byteLength) || data.byteLength <= 0)
|
|
19052
19669
|
return this.#drop("mfu-empty-payload");
|
|
@@ -19067,6 +19684,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19067
19684
|
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
19068
19685
|
movieFragmentSequenceNumber: mfuDuHeader.movieFragmentSequenceNumber,
|
|
19069
19686
|
sampleNumber: mfuDuHeader.sampleNumber,
|
|
19687
|
+
sequenceNumber: info.sequenceNumber,
|
|
19070
19688
|
arrivedAt: Date.now()
|
|
19071
19689
|
});
|
|
19072
19690
|
return this.#drop("mfu-sample-timing-missing");
|
|
@@ -19092,7 +19710,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19092
19710
|
info,
|
|
19093
19711
|
resolver,
|
|
19094
19712
|
options?.recovered === true,
|
|
19095
|
-
options?.fecSbn
|
|
19713
|
+
options?.fecSbn,
|
|
19714
|
+
options?.fecSbnFirst
|
|
19096
19715
|
);
|
|
19097
19716
|
if (deferred.record === void 0) this.#countDeferredOutcome(deferred.reason);
|
|
19098
19717
|
}
|
|
@@ -19185,7 +19804,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19185
19804
|
info,
|
|
19186
19805
|
resolver,
|
|
19187
19806
|
options?.recovered === true,
|
|
19188
|
-
options?.fecSbn
|
|
19807
|
+
options?.fecSbn,
|
|
19808
|
+
options?.fecSbnFirst
|
|
19189
19809
|
);
|
|
19190
19810
|
if (outcome.record !== void 0) return outcome.record;
|
|
19191
19811
|
return this.#drop(outcome.reason);
|
|
@@ -19205,7 +19825,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19205
19825
|
* attribution exists to keep readable. Leaving the choice at the call site
|
|
19206
19826
|
* is what keeps both true.
|
|
19207
19827
|
*/
|
|
19208
|
-
#emitCombinedSample(combined, info, resolver, recovered, fecSbn) {
|
|
19828
|
+
#emitCombinedSample(combined, info, resolver, recovered, fecSbn, fecSbnFirst) {
|
|
19209
19829
|
const timing = resolver.sampleTiming(
|
|
19210
19830
|
combined.mpuSequenceNumber,
|
|
19211
19831
|
combined.movieFragmentSequenceNumber,
|
|
@@ -19222,6 +19842,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19222
19842
|
);
|
|
19223
19843
|
if (!meta) return { reason: "combined-meta-build-failed" };
|
|
19224
19844
|
if (fecSbn !== void 0) meta.fecSbn = fecSbn;
|
|
19845
|
+
if (fecSbnFirst !== void 0) meta.fecSbnFirst = fecSbnFirst;
|
|
19225
19846
|
if (!resolver.consumeSample(
|
|
19226
19847
|
combined.mpuSequenceNumber,
|
|
19227
19848
|
combined.movieFragmentSequenceNumber,
|
|
@@ -19390,6 +20011,10 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19390
20011
|
}
|
|
19391
20012
|
this.#emitFrame(data, meta);
|
|
19392
20013
|
}
|
|
20014
|
+
/** Whether FT=1 metadata already names this sample, without claiming it. */
|
|
20015
|
+
hasAuthoredTimingFor(packetId, mpuSequenceNumber2, movieFragmentSequenceNumber, sampleNumber, catalogTrackName) {
|
|
20016
|
+
return this.#timingResolver(this.#streamKey(packetId, catalogTrackName), packetId, false)?.sampleTiming(mpuSequenceNumber2, movieFragmentSequenceNumber, sampleNumber) != null;
|
|
20017
|
+
}
|
|
19393
20018
|
/**
|
|
19394
20019
|
* Claim and return the authored timing for a recovered sample. Recovery does
|
|
19395
20020
|
* not pass through the ordinary `feed()` completion path, so it must retire
|
|
@@ -19451,6 +20076,9 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19451
20076
|
for (const { sequencer } of this.#sequencers.values()) sequencer.discard();
|
|
19452
20077
|
this.#sequencers.clear();
|
|
19453
20078
|
this.#fecSequencer?.discard();
|
|
20079
|
+
for (const { awaitingTiming } of this.#timingStreams.values()) {
|
|
20080
|
+
for (const head of awaitingTiming) this.#leaveAwaitingTiming(head, "discarded");
|
|
20081
|
+
}
|
|
19454
20082
|
this.#timingStreams.clear();
|
|
19455
20083
|
this.#pendingTimingSamples = 0;
|
|
19456
20084
|
this.#reliableMoqStartupGate.clear();
|
|
@@ -19469,10 +20097,23 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19469
20097
|
return resolver;
|
|
19470
20098
|
}
|
|
19471
20099
|
#awaitTiming(streamKey, head) {
|
|
19472
|
-
const
|
|
19473
|
-
if (!
|
|
20100
|
+
const state = this.#timingStreams.get(streamKey);
|
|
20101
|
+
if (!state) return;
|
|
20102
|
+
if (!head.options?.recovered) {
|
|
20103
|
+
const kept = state.awaitingTiming.filter((queued) => !queued.options?.recovered || queued.sequenceNumber !== head.sequenceNumber);
|
|
20104
|
+
this.#recoveredHeadsAwaitingTiming.superseded += state.awaitingTiming.length - kept.length;
|
|
20105
|
+
state.awaitingTiming = kept;
|
|
20106
|
+
}
|
|
20107
|
+
const awaitingTiming = state.awaitingTiming;
|
|
19474
20108
|
awaitingTiming.push(head);
|
|
19475
|
-
if (
|
|
20109
|
+
if (head.options?.recovered) this.#recoveredHeadsAwaitingTiming.held++;
|
|
20110
|
+
if (awaitingTiming.length > MAX_AWAITING_TIMING_HEADS) {
|
|
20111
|
+
this.#leaveAwaitingTiming(awaitingTiming.shift(), "expired");
|
|
20112
|
+
}
|
|
20113
|
+
}
|
|
20114
|
+
/** Count a recovered head leaving the queue other than by replay or its source copy. */
|
|
20115
|
+
#leaveAwaitingTiming(head, outcome) {
|
|
20116
|
+
if (head.options?.recovered) this.#recoveredHeadsAwaitingTiming[outcome]++;
|
|
19476
20117
|
}
|
|
19477
20118
|
/**
|
|
19478
20119
|
* Feed again the heads whose timing the FT=1 just admitted declares. That
|
|
@@ -19500,6 +20141,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
19500
20141
|
const state = this.#timingStreams.get(streamKey);
|
|
19501
20142
|
if (!state) return;
|
|
19502
20143
|
this.#timingStreams.delete(streamKey);
|
|
20144
|
+
for (const head of state.awaitingTiming) this.#leaveAwaitingTiming(head, "discarded");
|
|
19503
20145
|
this.#pendingTimingSamples -= state.resolver.pendingSampleCount;
|
|
19504
20146
|
if (this.#pendingTimingSamples < 0) {
|
|
19505
20147
|
throw new Error("[MmtpContainerParser] pending timing sample accounting underflow");
|
|
@@ -22706,7 +23348,18 @@ function keyframeOverlaySsId(header) {
|
|
|
22706
23348
|
if (ext?.type !== KEYFRAME_OVERLAY_EXTENSION_TYPE || ext.data.length !== 4) return void 0;
|
|
22707
23349
|
return new DataView(ext.data.buffer, ext.data.byteOffset, 4).getUint32(0);
|
|
22708
23350
|
}
|
|
23351
|
+
function overlayBaseSsId(anchor, overlaySsId, restoredPsn, headerPsn) {
|
|
23352
|
+
if (anchor.baseSsId === void 0 || headerPsn !== restoredPsn) return void 0;
|
|
23353
|
+
return serial32Add(anchor.baseSsId, overlaySsId - anchor.overlaySsId | 0);
|
|
23354
|
+
}
|
|
23355
|
+
function unstampedBaseSsId(offset, unstampedOffset, headerPsn) {
|
|
23356
|
+
if (offset === void 0 || offset !== unstampedOffset) return void 0;
|
|
23357
|
+
return headerPsn + offset >>> 0;
|
|
23358
|
+
}
|
|
23359
|
+
var OVERLAY_ROUTED_LIMIT = 1024;
|
|
23360
|
+
var OVERLAY_PENDING_LIMIT = 256;
|
|
22709
23361
|
var OVERLAY_OFFSET_MPUS = 16;
|
|
23362
|
+
var OVERLAY_REBUILT_LIMIT = 256;
|
|
22710
23363
|
var OVERLAY_MOQ_HORIZON_BLOCKS = 64;
|
|
22711
23364
|
function assertStreamIdentity(role, stream) {
|
|
22712
23365
|
if (stream === void 0 || !Number.isInteger(stream.packetId) || stream.packetId <= MMTP_SIGNALING_PACKET_ID || typeof stream.catalogTrackName !== "string" || stream.catalogTrackName.length === 0) {
|
|
@@ -22817,6 +23470,7 @@ var MmtpRouter = class {
|
|
|
22817
23470
|
#provenance = /* @__PURE__ */ new Map();
|
|
22818
23471
|
#onFlowProtected = null;
|
|
22819
23472
|
#unadmittedListedDrops = 0;
|
|
23473
|
+
#admittedSourceDatagrams = 0;
|
|
22820
23474
|
#unlistedRepairSetAside = 0;
|
|
22821
23475
|
#assistBlocks = /* @__PURE__ */ new Map();
|
|
22822
23476
|
#assistFailures = /* @__PURE__ */ new Map();
|
|
@@ -22873,6 +23527,26 @@ var MmtpRouter = class {
|
|
|
22873
23527
|
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
22874
23528
|
*/
|
|
22875
23529
|
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
23530
|
+
/**
|
|
23531
|
+
* Per stream, the SS_ID offset at which a base recovery last showed the
|
|
23532
|
+
* sender's own packet_sequence_number: a recovered packet's header psn
|
|
23533
|
+
* equal to its SS_ID minus that offset. While it equals the stream's
|
|
23534
|
+
* current offset, no hop re-stamps the stream, and a packet's protected psn
|
|
23535
|
+
* names its base SS_ID within unstampedBaseSsId's limits (joint decoding of
|
|
23536
|
+
* an MPU no member of which arrived).
|
|
23537
|
+
*/
|
|
23538
|
+
#unstampedSsIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
23539
|
+
/**
|
|
23540
|
+
* The same, shown by the overlay alone, before any base recovery did: a
|
|
23541
|
+
* packet it rebuilt whose base copy carries its protected psn
|
|
23542
|
+
* (#feedOverlaySource), or whose protected psn passes overlayBaseSsId's
|
|
23543
|
+
* test at that offset (#routeOverlayRecovered). A base SS_ID placed by it
|
|
23544
|
+
* anchors the release gate only (BLO-52085 D3): fed to the base, it would
|
|
23545
|
+
* make the base drop a late base copy of a keyframe the overlay never
|
|
23546
|
+
* finished, and lift a block's late-source cut, which nothing before
|
|
23547
|
+
* this offset did.
|
|
23548
|
+
*/
|
|
23549
|
+
#overlayUnstampedSsIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
22876
23550
|
/**
|
|
22877
23551
|
* Streams whose multicast leg delivered a RAP-flagged source packet that was
|
|
22878
23552
|
* not parsed, typically because its overlap copy was parsed first
|
|
@@ -22942,7 +23616,9 @@ var MmtpRouter = class {
|
|
|
22942
23616
|
recovered: 0,
|
|
22943
23617
|
restarts: 0,
|
|
22944
23618
|
unsequencedDropped: 0,
|
|
22945
|
-
protectedDropped: 0
|
|
23619
|
+
protectedDropped: 0,
|
|
23620
|
+
baseFed: 0,
|
|
23621
|
+
baseUndetermined: 0
|
|
22946
23622
|
};
|
|
22947
23623
|
/** Callback fired when a delta-track FEC block completes or fails. */
|
|
22948
23624
|
#onDeltaBlockCompleteCb = null;
|
|
@@ -23115,7 +23791,7 @@ var MmtpRouter = class {
|
|
|
23115
23791
|
const cb = this.#getFrameCallback(packetId);
|
|
23116
23792
|
if (isVideo && !assembler) {
|
|
23117
23793
|
if (frameMeta.recovered) {
|
|
23118
|
-
this.#routeDirectRecoveredVideo(packetId, data, frameMeta, cb);
|
|
23794
|
+
this.#routeDirectRecoveredVideo(packetId, data, frameMeta, cb, meta.fecSbn);
|
|
23119
23795
|
} else {
|
|
23120
23796
|
this.#routeDirectSourceVideo(packetId, data, frameMeta, cb);
|
|
23121
23797
|
}
|
|
@@ -23148,13 +23824,18 @@ var MmtpRouter = class {
|
|
|
23148
23824
|
this.#onDeltaBlockCompleteCb?.(packetId, false);
|
|
23149
23825
|
}
|
|
23150
23826
|
};
|
|
23151
|
-
this.#fecManager.onBlockFailed = (sbn, packetId, catalogTrackName, blockClass) => {
|
|
23827
|
+
this.#fecManager.onBlockFailed = (sbn, packetId, catalogTrackName, blockClass, span) => {
|
|
23152
23828
|
this.#mseAssemblerFor(packetId, catalogTrackName)?.failBlock(sbn);
|
|
23153
23829
|
if (this.#isCatalogTrackUnambiguous(packetId, catalogTrackName) && this.#packetIdRoles.get(packetId) === "delta") {
|
|
23154
23830
|
this.#onDeltaBlockCompleteCb?.(packetId, true);
|
|
23155
23831
|
}
|
|
23156
|
-
|
|
23157
|
-
|
|
23832
|
+
if (span === void 0) {
|
|
23833
|
+
onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
23834
|
+
this.#onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
23835
|
+
} else {
|
|
23836
|
+
onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span);
|
|
23837
|
+
this.#onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span);
|
|
23838
|
+
}
|
|
23158
23839
|
};
|
|
23159
23840
|
}
|
|
23160
23841
|
}
|
|
@@ -23199,8 +23880,9 @@ var MmtpRouter = class {
|
|
|
23199
23880
|
}
|
|
23200
23881
|
/**
|
|
23201
23882
|
* FEC-recovered source symbols whose reconstructed header named a
|
|
23202
|
-
* packet_sequence_number other than the wire sequence their SS_ID maps to
|
|
23203
|
-
*
|
|
23883
|
+
* packet_sequence_number other than the wire sequence their SS_ID maps to,
|
|
23884
|
+
* or, rebuilt by the overlay, than their base copy carries: a hop
|
|
23885
|
+
* re-stamped the sequence after the sender protected the packet.
|
|
23204
23886
|
*/
|
|
23205
23887
|
get restampedRecoveredSequenceCount() {
|
|
23206
23888
|
return this.#restampedRecoveredSeqs;
|
|
@@ -23379,6 +24061,7 @@ var MmtpRouter = class {
|
|
|
23379
24061
|
enableMseAssembler(packetId, config, catalogTrackName) {
|
|
23380
24062
|
const assemblerKey = this.#mseAssemblerKey(packetId, catalogTrackName);
|
|
23381
24063
|
const previous = this.#mseAssemblers.get(assemblerKey);
|
|
24064
|
+
this.#parser.unsourceFecRelease(packetId, catalogTrackName);
|
|
23382
24065
|
if (previous) {
|
|
23383
24066
|
previous.flush();
|
|
23384
24067
|
previous.dispose();
|
|
@@ -23505,6 +24188,10 @@ var MmtpRouter = class {
|
|
|
23505
24188
|
get keyframeOverlayStats() {
|
|
23506
24189
|
return { ...this.#overlayStats };
|
|
23507
24190
|
}
|
|
24191
|
+
/** Recovered FT=2 heads held for their FT=1, and how each left the wait (BLO-53369). */
|
|
24192
|
+
get recoveredHeadsAwaitingTiming() {
|
|
24193
|
+
return this.#parser.recoveredHeadsAwaitingTiming;
|
|
24194
|
+
}
|
|
23508
24195
|
#isOverlayRepair(repairPacketId, repairTrackName) {
|
|
23509
24196
|
return this.#overlayLegs.has(repairPacketId) || repairTrackName !== void 0 && this.#overlayRepairNames.has(repairTrackName);
|
|
23510
24197
|
}
|
|
@@ -23525,7 +24212,8 @@ var MmtpRouter = class {
|
|
|
23525
24212
|
fec,
|
|
23526
24213
|
k,
|
|
23527
24214
|
offsets: /* @__PURE__ */ new Map(),
|
|
23528
|
-
moqBlocks: /* @__PURE__ */ new Set()
|
|
24215
|
+
moqBlocks: /* @__PURE__ */ new Set(),
|
|
24216
|
+
rebuilt: /* @__PURE__ */ new Map()
|
|
23529
24217
|
};
|
|
23530
24218
|
this.#overlays.set(repairPacketId, inst);
|
|
23531
24219
|
return () => {
|
|
@@ -23555,12 +24243,18 @@ var MmtpRouter = class {
|
|
|
23555
24243
|
*/
|
|
23556
24244
|
resetKeyframeOverlays(sourcePacketId, catalogTrackName) {
|
|
23557
24245
|
for (const inst of this.#overlaysForSource(sourcePacketId, catalogTrackName)) this.#resetOverlay(inst);
|
|
24246
|
+
for (const [name, stream] of this.#streams.get(sourcePacketId) ?? []) {
|
|
24247
|
+
if (catalogTrackName !== void 0 && name !== catalogTrackName) continue;
|
|
24248
|
+
stream.overlayToBase.routed.clear();
|
|
24249
|
+
stream.overlayToBase.pending.clear();
|
|
24250
|
+
}
|
|
23558
24251
|
}
|
|
23559
24252
|
#resetOverlay(inst) {
|
|
23560
24253
|
inst.fec.resetTrack(inst.repairPacketId, inst.streamName);
|
|
23561
24254
|
inst.last = void 0;
|
|
23562
24255
|
inst.offsets.clear();
|
|
23563
24256
|
inst.moqBlocks.clear();
|
|
24257
|
+
inst.rebuilt.clear();
|
|
23564
24258
|
}
|
|
23565
24259
|
#overlaysForSource(sourcePacketId, catalogTrackName) {
|
|
23566
24260
|
return [...this.#overlays.values()].filter(({ leg }) => leg.sourcePacketId === sourcePacketId && (catalogTrackName === void 0 || leg.sourceCatalogTrackName === void 0 || leg.sourceCatalogTrackName === catalogTrackName));
|
|
@@ -23611,18 +24305,33 @@ var MmtpRouter = class {
|
|
|
23611
24305
|
* A source packet that carries a 0x8B01 overlay SS_ID is also a symbol of
|
|
23612
24306
|
* every overlay installed for its source, at that SS_ID, with the bytes the
|
|
23613
24307
|
* base protects: the packet minus its 4-byte SS_ID trailer, extension
|
|
23614
|
-
* included (7.1, 7.4.3).
|
|
23615
|
-
|
|
23616
|
-
|
|
24308
|
+
* included (7.1, 7.4.3). `baseSsId` is that trailer's SS_ID, when the base
|
|
24309
|
+
* FEC reads it.
|
|
24310
|
+
*
|
|
24311
|
+
* The base copy of a packet an overlay rebuilt with no base SS_ID shows
|
|
24312
|
+
* what a base recovery of it would (#routeProcessedFecSymbols, BLO-52085):
|
|
24313
|
+
* its wire packet_sequence_number equal to the protected one rebuilt shows
|
|
24314
|
+
* the stream unstamped at the SS_ID offset it states, for the release gate
|
|
24315
|
+
* (#overlayUnstampedSsIdSeqOffsetByStream); any other shows a hop that
|
|
24316
|
+
* re-stamps it, which is counted (restampedRecoveredSequenceCount).
|
|
24317
|
+
*/
|
|
24318
|
+
#feedOverlaySource(packetId, catalogTrackName, packet, header, sequenceNumber, rapFlag, source, baseSsId) {
|
|
23617
24319
|
if (this.#overlays.size === 0) return;
|
|
23618
24320
|
const ssId = keyframeOverlaySsId(header);
|
|
23619
24321
|
if (ssId === void 0) return;
|
|
24322
|
+
let rebuiltPsn;
|
|
23620
24323
|
for (const inst of this.#overlaysForSource(packetId, catalogTrackName)) {
|
|
23621
24324
|
this.#noteOverlaySsId(inst, ssId, sequenceNumber);
|
|
24325
|
+
rebuiltPsn ??= inst.rebuilt.get(ssId);
|
|
24326
|
+
inst.rebuilt.delete(ssId);
|
|
23622
24327
|
const identity = MmtpContainerParser.sourcePacketIdentity(packet, header);
|
|
23623
24328
|
if (identity !== null) {
|
|
23624
24329
|
inst.offsets.delete(identity.mpuSequenceNumber);
|
|
23625
|
-
inst.offsets.set(identity.mpuSequenceNumber,
|
|
24330
|
+
inst.offsets.set(identity.mpuSequenceNumber, {
|
|
24331
|
+
psnOffset: ssId - sequenceNumber >>> 0,
|
|
24332
|
+
overlaySsId: ssId,
|
|
24333
|
+
...baseSsId === void 0 ? {} : { baseSsId }
|
|
24334
|
+
});
|
|
23626
24335
|
if (inst.offsets.size > OVERLAY_OFFSET_MPUS) inst.offsets.delete(inst.offsets.keys().next().value);
|
|
23627
24336
|
}
|
|
23628
24337
|
const { fec, repairPacketId: pid, streamName: name } = inst;
|
|
@@ -23644,6 +24353,14 @@ var MmtpRouter = class {
|
|
|
23644
24353
|
const recovered = fec.feedSourceSymbol(pid, ssId, symbolData, name);
|
|
23645
24354
|
if (recovered && !alreadyCompleted) this.#routeOverlayRecovered(inst, coords.sbn, recovered);
|
|
23646
24355
|
}
|
|
24356
|
+
if (rebuiltPsn === void 0 || this.#classifyPacketId(packetId) === null) return;
|
|
24357
|
+
const streamKey = this.#mediaStreamKey(packetId, catalogTrackName);
|
|
24358
|
+
if (rebuiltPsn !== sequenceNumber) {
|
|
24359
|
+
this.#restampedRecoveredSeqs++;
|
|
24360
|
+
} else if (baseSsId !== void 0) {
|
|
24361
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
24362
|
+
if (offset === baseSsId - sequenceNumber >>> 0) this.#overlayUnstampedSsIdSeqOffsetByStream.set(streamKey, offset);
|
|
24363
|
+
}
|
|
23647
24364
|
}
|
|
23648
24365
|
#noteOverlayMoqBlock(inst, blockStart) {
|
|
23649
24366
|
inst.moqBlocks.add(blockStart);
|
|
@@ -23677,11 +24394,16 @@ var MmtpRouter = class {
|
|
|
23677
24394
|
}
|
|
23678
24395
|
/**
|
|
23679
24396
|
* Route an overlay-recovered block's packets as source media of the
|
|
23680
|
-
* overlay's source (7.2: an overlay coordinate yields no base SS_ID).
|
|
23681
|
-
*
|
|
23682
|
-
*
|
|
23683
|
-
*
|
|
23684
|
-
*
|
|
24397
|
+
* overlay's source (7.2: an overlay coordinate yields no base SS_ID). A
|
|
24398
|
+
* packet whose base SS_ID is determined independently (overlayBaseSsId,
|
|
24399
|
+
* unstampedBaseSsId) enters the release gate at that SS_ID, as a packet
|
|
24400
|
+
* base FEC recovered does, so it waits behind base frames still in flight,
|
|
24401
|
+
* though not for its own MPU's packets (FrameMeta.fecSbnFirst) and no
|
|
24402
|
+
* longer than unanchored; one whose base SS_ID is undetermined has no
|
|
24403
|
+
* release-gate anchor. No parse ledger, no base re-stamp, no block
|
|
24404
|
+
* advance. Each packet's wire sequence is restored from its keyframe's own
|
|
24405
|
+
* offset; without one, a stream the base never re-stamped keeps the
|
|
24406
|
+
* header's sequence and any other drops the packet.
|
|
23685
24407
|
*/
|
|
23686
24408
|
#routeOverlayRecovered(inst, blockStart, recovered) {
|
|
23687
24409
|
const { fec, repairPacketId: pid, streamName: name } = inst;
|
|
@@ -23701,22 +24423,139 @@ var MmtpRouter = class {
|
|
|
23701
24423
|
const streamKey = this.#mediaStreamKey(sourcePacketId, sourceName);
|
|
23702
24424
|
const restamped = this.#restampedStreams.has(streamKey);
|
|
23703
24425
|
const restored = /* @__PURE__ */ new Set();
|
|
24426
|
+
const baseSsIds = /* @__PURE__ */ new Map();
|
|
24427
|
+
const gateOnly = /* @__PURE__ */ new Set();
|
|
23704
24428
|
const symbols = result.symbols.flatMap((sym) => {
|
|
23705
|
-
const
|
|
23706
|
-
|
|
23707
|
-
|
|
24429
|
+
const overlaySsId = serial32Add(blockStart, sym.index);
|
|
24430
|
+
const anchor = inst.offsets.get(sym.fragment.mpuSequenceNumber);
|
|
24431
|
+
if (anchor !== void 0) {
|
|
24432
|
+
const packetSequenceNumber = overlaySsId - anchor.psnOffset >>> 0;
|
|
23708
24433
|
restored.add(packetSequenceNumber);
|
|
23709
|
-
|
|
24434
|
+
const out = { ...sym, packetSequenceNumber };
|
|
24435
|
+
const baseSsId = overlayBaseSsId(anchor, overlaySsId, packetSequenceNumber, sym.packetSequenceNumber);
|
|
24436
|
+
if (baseSsId !== void 0) {
|
|
24437
|
+
baseSsIds.set(sym.index, baseSsId);
|
|
24438
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
24439
|
+
if (!this.#sourceSeqReceived(sourcePacketId, packetSequenceNumber, sourceName) && offset === baseSsId - packetSequenceNumber >>> 0) {
|
|
24440
|
+
this.#overlayUnstampedSsIdSeqOffsetByStream.set(streamKey, offset);
|
|
24441
|
+
}
|
|
24442
|
+
}
|
|
24443
|
+
return [out];
|
|
24444
|
+
}
|
|
24445
|
+
if (!restamped) {
|
|
24446
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
24447
|
+
const fedSsId = unstampedBaseSsId(offset, this.#unstampedSsIdSeqOffsetByStream.get(streamKey), sym.packetSequenceNumber);
|
|
24448
|
+
const baseSsId = fedSsId ?? unstampedBaseSsId(offset, this.#overlayUnstampedSsIdSeqOffsetByStream.get(streamKey), sym.packetSequenceNumber);
|
|
24449
|
+
if (baseSsId !== void 0) {
|
|
24450
|
+
baseSsIds.set(sym.index, baseSsId);
|
|
24451
|
+
if (fedSsId === void 0) gateOnly.add(sym.index);
|
|
24452
|
+
} else {
|
|
24453
|
+
inst.rebuilt.set(overlaySsId, sym.packetSequenceNumber);
|
|
24454
|
+
if (inst.rebuilt.size > OVERLAY_REBUILT_LIMIT) inst.rebuilt.delete(inst.rebuilt.keys().next().value);
|
|
24455
|
+
}
|
|
24456
|
+
return [sym];
|
|
23710
24457
|
}
|
|
23711
|
-
if (!restamped) return [sym];
|
|
23712
24458
|
this.#overlayStats.unsequencedDropped++;
|
|
23713
24459
|
return [];
|
|
23714
24460
|
});
|
|
23715
24461
|
this.#overlayStats.recovered++;
|
|
24462
|
+
const mpuFirst = /* @__PURE__ */ new Map();
|
|
24463
|
+
for (const sym of symbols) {
|
|
24464
|
+
const ssId = baseSsIds.get(sym.index);
|
|
24465
|
+
const mpu = sym.fragment.mpuSequenceNumber;
|
|
24466
|
+
const first = mpuFirst.get(mpu);
|
|
24467
|
+
if (ssId !== void 0 && (first === void 0 || serial32Precedes(ssId, first))) mpuFirst.set(mpu, ssId);
|
|
24468
|
+
}
|
|
24469
|
+
const firstSsIds = /* @__PURE__ */ new Map();
|
|
24470
|
+
for (const sym of symbols) {
|
|
24471
|
+
if (baseSsIds.has(sym.index)) firstSsIds.set(sym.index, mpuFirst.get(sym.fragment.mpuSequenceNumber));
|
|
24472
|
+
}
|
|
23716
24473
|
this.#routeProcessedFecSymbols(blockStart, { ...result, symbols }, sourcePacketId, sourceName, {
|
|
23717
|
-
deliveryProvenance: inst.moqBlocks.has(blockStart) ? "mixed" : "multicast"
|
|
24474
|
+
deliveryProvenance: inst.moqBlocks.has(blockStart) ? "mixed" : "multicast",
|
|
24475
|
+
baseSsIds,
|
|
24476
|
+
firstSsIds
|
|
23718
24477
|
});
|
|
23719
24478
|
this.#noteOverlayRecoveredRaps(sourcePacketId, sourceName, streamKey, symbols.filter((sym) => restored.has(sym.packetSequenceNumber)));
|
|
24479
|
+
this.#feedOverlayRecoveredToBase(inst, blockStart, symbols, gateOnly.size === 0 ? baseSsIds : new Map([...baseSsIds].filter(([index]) => !gateOnly.has(index))));
|
|
24480
|
+
}
|
|
24481
|
+
/**
|
|
24482
|
+
* Joint decoding (BLO-52085). A packet the overlay rebuilt is a source of
|
|
24483
|
+
* its base block too, once its base SS_ID is determined (overlayBaseSsId,
|
|
24484
|
+
* from a received member of its MPU, else unstampedBaseSsId at an offset a
|
|
24485
|
+
* base recovery showed; `baseSsIds` holds no other),
|
|
24486
|
+
* so it is fed to the base decoder as a rebuilt source
|
|
24487
|
+
* (FECManager.feedRebuiltSourceSymbol): the base block has one erasure
|
|
24488
|
+
* fewer to solve, and its repair can recover the block's other packets.
|
|
24489
|
+
* A base block no repair has stated yet takes it when one does
|
|
24490
|
+
* (#feedPendingRebuilt).
|
|
24491
|
+
*
|
|
24492
|
+
* The overlay route already handled each packet fed (delivered it, or
|
|
24493
|
+
* held an untimed head for its FT=1), so a base recovery routes none of
|
|
24494
|
+
* them again (#routeVerifiedFecSymbols): a second recovered copy of a
|
|
24495
|
+
* held head would wait in the parser for timing its first copy consumed.
|
|
24496
|
+
* Only an overlay block decoded from multicast symbols alone is fed: with
|
|
24497
|
+
* a MoQ symbol in it, the base block's recovery would depend on bytes
|
|
24498
|
+
* that crossed no multicast socket, which the provenance counted from the
|
|
24499
|
+
* block's own arrivals cannot show.
|
|
24500
|
+
*/
|
|
24501
|
+
#feedOverlayRecoveredToBase(inst, blockStart, symbols, baseSsIds) {
|
|
24502
|
+
const fec = this.#fecManager;
|
|
24503
|
+
const owner = inst.leg.sourcePacketId;
|
|
24504
|
+
const name = inst.leg.sourceCatalogTrackName;
|
|
24505
|
+
if (!fec?.feedRebuiltSourceSymbol || inst.moqBlocks.has(blockStart)) return;
|
|
24506
|
+
if (this.#classifyPacketId(owner) === null || fec.isTrackConfigured?.(owner) === false) return;
|
|
24507
|
+
const { duplicates, overlayToBase: { routed } } = this.#stream(owner, name);
|
|
24508
|
+
const feeds = [];
|
|
24509
|
+
for (const sym of symbols) {
|
|
24510
|
+
if (duplicates.sourceSeqs.has(sym.packetSequenceNumber)) continue;
|
|
24511
|
+
const ssId = baseSsIds.get(sym.index);
|
|
24512
|
+
if (ssId === void 0) {
|
|
24513
|
+
this.#overlayStats.baseUndetermined++;
|
|
24514
|
+
continue;
|
|
24515
|
+
}
|
|
24516
|
+
routed.delete(ssId);
|
|
24517
|
+
routed.add(ssId);
|
|
24518
|
+
if (routed.size > OVERLAY_ROUTED_LIMIT) routed.delete(routed.values().next().value);
|
|
24519
|
+
feeds.push([ssId, sym.rawSymbol]);
|
|
24520
|
+
}
|
|
24521
|
+
for (const [ssId, symbolData] of feeds) {
|
|
24522
|
+
if (this.#classifyPacketId(owner) === null) return;
|
|
24523
|
+
this.#feedRebuiltToBase(owner, name, ssId, symbolData);
|
|
24524
|
+
}
|
|
24525
|
+
}
|
|
24526
|
+
/** Feed one rebuilt source to its base block, or keep it until a repair states that block. */
|
|
24527
|
+
#feedRebuiltToBase(owner, name, ssId, symbolData) {
|
|
24528
|
+
const fec = this.#fecManager;
|
|
24529
|
+
if (!fec?.feedRebuiltSourceSymbol) return;
|
|
24530
|
+
const coords = fec.locateIsoSource?.(owner, name, ssId);
|
|
24531
|
+
if (coords == null) {
|
|
24532
|
+
const pending = this.#stream(owner, name).overlayToBase.pending;
|
|
24533
|
+
pending.delete(ssId);
|
|
24534
|
+
pending.set(ssId, symbolData.slice());
|
|
24535
|
+
if (pending.size > OVERLAY_PENDING_LIMIT) pending.delete(pending.keys().next().value);
|
|
24536
|
+
return;
|
|
24537
|
+
}
|
|
24538
|
+
const fed = fec.feedRebuiltSourceSymbol(owner, ssId, symbolData, name);
|
|
24539
|
+
if (!fed.taken) return;
|
|
24540
|
+
this.#overlayStats.baseFed++;
|
|
24541
|
+
if (fed.recovered === null) return;
|
|
24542
|
+
const sbn = coords.sbn;
|
|
24543
|
+
this.#routeRecoveredBlock(sbn, fed.recovered, owner, name, () => {
|
|
24544
|
+
fec.cancelBlockTimeout(sbn, owner, name);
|
|
24545
|
+
fec.countRecovery(owner, sbn, name);
|
|
24546
|
+
fec.markBlockCompleted(sbn, owner, name);
|
|
24547
|
+
});
|
|
24548
|
+
}
|
|
24549
|
+
/** A repair stated `block`: the rebuilt sources that waited for it join it now. */
|
|
24550
|
+
#feedPendingRebuilt(owner, name, block) {
|
|
24551
|
+
const pending = this.#streams.get(owner)?.get(name)?.overlayToBase.pending;
|
|
24552
|
+
if (pending === void 0 || pending.size === 0) return;
|
|
24553
|
+
for (const [ssId, symbolData] of [...pending]) {
|
|
24554
|
+
if (this.#classifyPacketId(owner) === null) return;
|
|
24555
|
+
if (serial32Distance(block.start, ssId) >= block.length) continue;
|
|
24556
|
+
pending.delete(ssId);
|
|
24557
|
+
this.#feedRebuiltToBase(owner, name, ssId, symbolData);
|
|
24558
|
+
}
|
|
23720
24559
|
}
|
|
23721
24560
|
/** fec-multicast-00 §6.6: report each base block whose RAP MFU fragments
|
|
23722
24561
|
* the overlay restored, when the keyframe's FT=0 and FT=1 are held too. A
|
|
@@ -23856,6 +24695,10 @@ var MmtpRouter = class {
|
|
|
23856
24695
|
get unadmittedListedDropCount() {
|
|
23857
24696
|
return this.#unadmittedListedDrops;
|
|
23858
24697
|
}
|
|
24698
|
+
/** Source datagrams (multicast or MoQ) a protected flow's bc-provenance v2 receiver released: admitted at once or held, then admitted by a record. Repair symbols and user-agent-admitted datagrams are not counted. Counted at release, before this router's own track checks: a released datagram those drop, which only a track change between hold and release can cause, still counts, so this is not a count of routed media. */
|
|
24699
|
+
get admittedSourceDatagramCount() {
|
|
24700
|
+
return this.#admittedSourceDatagrams;
|
|
24701
|
+
}
|
|
23859
24702
|
/** MoQ repair symbols of an unlisted track kept out of a governed FEC instance (7.2.7 step 2). */
|
|
23860
24703
|
get unlistedRepairSetAsideCount() {
|
|
23861
24704
|
return this.#unlistedRepairSetAside;
|
|
@@ -24342,6 +25185,8 @@ var MmtpRouter = class {
|
|
|
24342
25185
|
)) return;
|
|
24343
25186
|
fec.noteBlockActivity?.(blockStart, ownerPacketId, catalogTrackName);
|
|
24344
25187
|
fec.noteRepairGroupLength?.(blockStart, ownerPacketId, repair.rsbLength, catalogTrackName);
|
|
25188
|
+
this.#feedPendingRebuilt(ownerPacketId, catalogTrackName, placement.block);
|
|
25189
|
+
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
24345
25190
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, ownerPacketId, catalogTrackName);
|
|
24346
25191
|
const recovered = fec.feedRepairSymbol(
|
|
24347
25192
|
ownerPacketId,
|
|
@@ -24392,7 +25237,7 @@ var MmtpRouter = class {
|
|
|
24392
25237
|
catalogTrackName
|
|
24393
25238
|
)) continue;
|
|
24394
25239
|
if (fec.isTrackConfigured?.(ownerPacketId) !== false) {
|
|
24395
|
-
fec.trackBlock(blockStart, ownerPacketId, catalogTrackName, esi, payload.evidence);
|
|
25240
|
+
fec.trackBlock(blockStart, ownerPacketId, catalogTrackName, esi, payload.evidence, true);
|
|
24396
25241
|
this.#requestFecPoke(ownerPacketId, catalogTrackName);
|
|
24397
25242
|
}
|
|
24398
25243
|
if (payload.oversized) continue;
|
|
@@ -24479,6 +25324,8 @@ var MmtpRouter = class {
|
|
|
24479
25324
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
24480
25325
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
24481
25326
|
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
25327
|
+
this.#unstampedSsIdSeqOffsetByStream.delete(streamKey);
|
|
25328
|
+
this.#overlayUnstampedSsIdSeqOffsetByStream.delete(streamKey);
|
|
24482
25329
|
this.#multicastRapTwinByStream.delete(streamKey);
|
|
24483
25330
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
24484
25331
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
@@ -24605,6 +25452,12 @@ var MmtpRouter = class {
|
|
|
24605
25452
|
* the outgoing stream stops. The hold is bounded by the incoming stream's
|
|
24606
25453
|
* own RAP cadence, so no timer is involved.
|
|
24607
25454
|
*
|
|
25455
|
+
* While the switch is staged, the FEC release gate lets a keyframe the
|
|
25456
|
+
* overlay rebuilt reach it, on either side, when the keyframe did before
|
|
25457
|
+
* the gate anchored it (FecReleaseGate.releaseUnanchored): the switch
|
|
25458
|
+
* decides on what each side delivered, and the commit discards the gate's
|
|
25459
|
+
* frames of the outgoing stream.
|
|
25460
|
+
*
|
|
24608
25461
|
* The commit is one synchronous transition inside the frame path: the
|
|
24609
25462
|
* outgoing stream's already-admitted frames are released (its queued FEC
|
|
24610
25463
|
* gap fills only up to the RAP, since recovery can queue a frame ahead of
|
|
@@ -24655,6 +25508,9 @@ var MmtpRouter = class {
|
|
|
24655
25508
|
droppedIncomingFrames: 0
|
|
24656
25509
|
};
|
|
24657
25510
|
this.#staged = state;
|
|
25511
|
+
if (this.#parser.fecReleaseHoldsRebuilt(from.packetId, from.catalogTrackName)) {
|
|
25512
|
+
this.#requestFecPoke(from.packetId, from.catalogTrackName);
|
|
25513
|
+
}
|
|
24658
25514
|
return {
|
|
24659
25515
|
cancel: () => {
|
|
24660
25516
|
if (this.#staged !== state) return false;
|
|
@@ -24737,7 +25593,17 @@ var MmtpRouter = class {
|
|
|
24737
25593
|
*/
|
|
24738
25594
|
#routeParsedFrame(data, meta) {
|
|
24739
25595
|
if (this.#classifyPacketId(meta.packetId) === null) return;
|
|
24740
|
-
if (this.#staged !== null
|
|
25596
|
+
if (this.#staged !== null) {
|
|
25597
|
+
let consumed = false;
|
|
25598
|
+
this.#fecPokeDepth++;
|
|
25599
|
+
try {
|
|
25600
|
+
consumed = this.#interceptSwitchFrame(data, meta);
|
|
25601
|
+
} finally {
|
|
25602
|
+
this.#fecPokeDepth--;
|
|
25603
|
+
this.#flushPendingFecPokes();
|
|
25604
|
+
}
|
|
25605
|
+
if (consumed) return;
|
|
25606
|
+
}
|
|
24741
25607
|
this.#deliverParsedFrame(data, meta);
|
|
24742
25608
|
}
|
|
24743
25609
|
#commitStreamSwitch(state, rap, reason) {
|
|
@@ -24889,12 +25755,16 @@ var MmtpRouter = class {
|
|
|
24889
25755
|
this.#parser.deferFecRelease(work);
|
|
24890
25756
|
} finally {
|
|
24891
25757
|
this.#fecPokeDepth--;
|
|
24892
|
-
|
|
24893
|
-
|
|
24894
|
-
|
|
24895
|
-
|
|
24896
|
-
|
|
24897
|
-
|
|
25758
|
+
this.#flushPendingFecPokes();
|
|
25759
|
+
}
|
|
25760
|
+
}
|
|
25761
|
+
/** Run the pokes requested while #fecPokeDepth was raised, once it is 0. */
|
|
25762
|
+
#flushPendingFecPokes() {
|
|
25763
|
+
if (this.#fecPokeDepth === 0 && this.#pendingFecPokes.size > 0 && !this.#disposed) {
|
|
25764
|
+
const pokes = [...this.#pendingFecPokes.values()];
|
|
25765
|
+
this.#pendingFecPokes.clear();
|
|
25766
|
+
for (const poke of pokes) {
|
|
25767
|
+
this.#parser.pokeFecRelease(poke.packetId, poke.catalogTrackName);
|
|
24898
25768
|
}
|
|
24899
25769
|
}
|
|
24900
25770
|
}
|
|
@@ -24972,6 +25842,14 @@ var MmtpRouter = class {
|
|
|
24972
25842
|
onRap: (packetId, catalogTrackName, ssId) => {
|
|
24973
25843
|
for (const observer of this.#fecRapObservers) observer(packetId, catalogTrackName, ssId);
|
|
24974
25844
|
},
|
|
25845
|
+
// A staged switch commits on when each side's frames reach it
|
|
25846
|
+
// (#interceptSwitchFrame): both sides' overlay keyframes reach it when
|
|
25847
|
+
// they did unanchored.
|
|
25848
|
+
releaseUnanchored: (packetId, catalogTrackName) => {
|
|
25849
|
+
const staged = this.#staged;
|
|
25850
|
+
const stream = { packetId, ...catalogTrackName === void 0 ? {} : { catalogTrackName } };
|
|
25851
|
+
return staged !== null && (isStream(stream, staged.from) || isStream(stream, staged.to));
|
|
25852
|
+
},
|
|
24975
25853
|
onReleased: (data, meta) => {
|
|
24976
25854
|
if (meta.trackType !== "video" || meta.mpuSequenceNumber === void 0) return;
|
|
24977
25855
|
const timing = meta.authoredTiming;
|
|
@@ -25113,6 +25991,7 @@ var MmtpRouter = class {
|
|
|
25113
25991
|
const parsed = this.#parser.parsePacket(packet);
|
|
25114
25992
|
if (!parsed) return;
|
|
25115
25993
|
const info = parsed.info;
|
|
25994
|
+
if (manifestAdmitted && !info.isRepair && ingress?.admittedBy !== USER_AGENT_VERIFIED) this.#admittedSourceDatagrams++;
|
|
25116
25995
|
if (source === "multicast" && !manifestAdmitted) {
|
|
25117
25996
|
this.#fecManager?.noteMulticastArrival?.(info.packetId, info.sequenceNumber);
|
|
25118
25997
|
}
|
|
@@ -25394,7 +26273,8 @@ var MmtpRouter = class {
|
|
|
25394
26273
|
parsed.header,
|
|
25395
26274
|
info.sequenceNumber,
|
|
25396
26275
|
info.rapFlag,
|
|
25397
|
-
source
|
|
26276
|
+
source,
|
|
26277
|
+
fecPayloadId?.ssId
|
|
25398
26278
|
);
|
|
25399
26279
|
}
|
|
25400
26280
|
}
|
|
@@ -25420,7 +26300,8 @@ var MmtpRouter = class {
|
|
|
25420
26300
|
source: parserOptions?.source,
|
|
25421
26301
|
deliveryProvenance: parserOptions?.deliveryProvenance,
|
|
25422
26302
|
catalogTrackName: parserOptions?.catalogTrackName,
|
|
25423
|
-
...parserOptions?.fecSbn === void 0 ? {} : { fecSbn: parserOptions.fecSbn }
|
|
26303
|
+
...parserOptions?.fecSbn === void 0 ? {} : { fecSbn: parserOptions.fecSbn },
|
|
26304
|
+
...parserOptions?.fecSbnFirst === void 0 ? {} : { fecSbnFirst: parserOptions.fecSbnFirst }
|
|
25424
26305
|
};
|
|
25425
26306
|
if (parsed) this.#parser.feedParsed(packet, parsed, feedOptions);
|
|
25426
26307
|
else this.#parser.feed(packet, feedOptions);
|
|
@@ -25544,7 +26425,8 @@ var MmtpRouter = class {
|
|
|
25544
26425
|
if (stream === void 0) {
|
|
25545
26426
|
stream = {
|
|
25546
26427
|
key: JSON.stringify([packetId, catalogTrackName ?? null]),
|
|
25547
|
-
duplicates: new StreamDuplicateLedgers(() => this.duplicateHorizonFor(packetId))
|
|
26428
|
+
duplicates: new StreamDuplicateLedgers(() => this.duplicateHorizonFor(packetId)),
|
|
26429
|
+
overlayToBase: { routed: /* @__PURE__ */ new Set(), pending: /* @__PURE__ */ new Map() }
|
|
25548
26430
|
};
|
|
25549
26431
|
byName.set(catalogTrackName, stream);
|
|
25550
26432
|
}
|
|
@@ -25659,8 +26541,16 @@ var MmtpRouter = class {
|
|
|
25659
26541
|
this.#drainDirectRecoveredVideo(streamKey, packetId, (frame) => frame.timestamp <= meta.timestamp, cb);
|
|
25660
26542
|
this.#emitDirectVideo(packetId, data, meta, cb);
|
|
25661
26543
|
}
|
|
25662
|
-
#routeDirectRecoveredVideo(packetId, data, meta, cb) {
|
|
26544
|
+
#routeDirectRecoveredVideo(packetId, data, meta, cb, fecSbn) {
|
|
25663
26545
|
const streamKey = this.#mediaStreamKey(packetId, meta.catalogTrackName);
|
|
26546
|
+
if (this.#isFecTrack(packetId)) {
|
|
26547
|
+
const high = this.#deliveredVideoHighWaterByStream.get(streamKey);
|
|
26548
|
+
if (fecSbn !== void 0 || high !== void 0 && authoredAdjacent(high, meta)) {
|
|
26549
|
+
this.#drainDirectRecoveredVideo(streamKey, packetId, (frame) => frame.timestamp <= meta.timestamp, cb);
|
|
26550
|
+
this.#emitDirectVideo(packetId, data, meta, cb);
|
|
26551
|
+
return;
|
|
26552
|
+
}
|
|
26553
|
+
}
|
|
25664
26554
|
this.#enqueueDirectRecoveredVideo(packetId, data, meta);
|
|
25665
26555
|
const lastSourceTs = this.#lastDirectSourceVideoTsByStream.get(streamKey);
|
|
25666
26556
|
this.#drainDirectRecoveredVideo(
|
|
@@ -25814,6 +26704,13 @@ var MmtpRouter = class {
|
|
|
25814
26704
|
* frames by epoch only if pre-protection input ever matters.
|
|
25815
26705
|
*/
|
|
25816
26706
|
#routeVerifiedFecSymbols(blockId, result, ownerPacketId, catalogTrackName, complete, assisted = false) {
|
|
26707
|
+
const overlayRouted = ownerPacketId == null ? void 0 : this.#streams.get(ownerPacketId)?.get(catalogTrackName)?.overlayToBase.routed;
|
|
26708
|
+
if (overlayRouted !== void 0 && overlayRouted.size > 0) {
|
|
26709
|
+
result = {
|
|
26710
|
+
...result,
|
|
26711
|
+
symbols: result.symbols.filter((sym) => !overlayRouted.has(this.#fecAnchorForRecovered(blockId, sym.index)))
|
|
26712
|
+
};
|
|
26713
|
+
}
|
|
25817
26714
|
const entry = ownerPacketId == null ? void 0 : this.#provenanceFor(ownerPacketId, catalogTrackName);
|
|
25818
26715
|
const receiver = entry === void 0 || entry === "ambiguous" ? entry : entry.receiver;
|
|
25819
26716
|
const userAgent = !assisted && entry !== void 0 && entry !== "ambiguous" && entry.protected === true && entry.userAgent === true;
|
|
@@ -25870,7 +26767,12 @@ var MmtpRouter = class {
|
|
|
25870
26767
|
#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName, overlay) {
|
|
25871
26768
|
if (ownerPacketId == null) return;
|
|
25872
26769
|
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
25873
|
-
const fecSbnOf = (index) =>
|
|
26770
|
+
const fecSbnOf = (index) => {
|
|
26771
|
+
if (!overlay) return { fecSbn: this.#fecAnchorForRecovered(blockId, index) };
|
|
26772
|
+
const fecSbn = overlay.baseSsIds.get(index);
|
|
26773
|
+
const fecSbnFirst = overlay.firstSsIds.get(index);
|
|
26774
|
+
return fecSbn === void 0 || fecSbnFirst === void 0 ? {} : { fecSbn, fecSbnFirst };
|
|
26775
|
+
};
|
|
25874
26776
|
const streamKey = this.#mediaStreamKey(ownerPacketId, catalogTrackName);
|
|
25875
26777
|
const ssIdSeqOffset = overlay ? void 0 : this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
25876
26778
|
if (ssIdSeqOffset !== void 0) {
|
|
@@ -25878,7 +26780,10 @@ var MmtpRouter = class {
|
|
|
25878
26780
|
...result,
|
|
25879
26781
|
symbols: result.symbols.map((sym) => {
|
|
25880
26782
|
const wire = this.#fecAnchorForRecovered(blockId, sym.index) - ssIdSeqOffset >>> 0;
|
|
25881
|
-
if (wire === sym.packetSequenceNumber)
|
|
26783
|
+
if (wire === sym.packetSequenceNumber) {
|
|
26784
|
+
this.#unstampedSsIdSeqOffsetByStream.set(streamKey, ssIdSeqOffset);
|
|
26785
|
+
return sym;
|
|
26786
|
+
}
|
|
25882
26787
|
this.#restampedRecoveredSeqs++;
|
|
25883
26788
|
this.#restampedStreams.add(streamKey);
|
|
25884
26789
|
return { ...sym, packetSequenceNumber: wire };
|
|
@@ -25914,6 +26819,29 @@ var MmtpRouter = class {
|
|
|
25914
26819
|
}
|
|
25915
26820
|
);
|
|
25916
26821
|
}
|
|
26822
|
+
const untimedHead = (sym) => sym.fragmentType === 2 && sym.fragment.fragmentationIndicator === 1 && sym.fragment.movieFragmentSequenceNumber !== void 0 && sym.fragment.sampleNumber !== void 0 && !this.#parser.hasAuthoredTimingFor(
|
|
26823
|
+
ownerPacketId,
|
|
26824
|
+
sym.fragment.mpuSequenceNumber,
|
|
26825
|
+
sym.fragment.movieFragmentSequenceNumber,
|
|
26826
|
+
sym.fragment.sampleNumber,
|
|
26827
|
+
catalogTrackName
|
|
26828
|
+
);
|
|
26829
|
+
for (const sym of result.symbols) {
|
|
26830
|
+
if (!untimedHead(sym) || this.#sourceSeqReceived(ownerPacketId, sym.packetSequenceNumber, catalogTrackName)) continue;
|
|
26831
|
+
this.#feedViaParser(
|
|
26832
|
+
sym.rawSymbol,
|
|
26833
|
+
{ packetId: ownerPacketId, sequenceNumber: sym.packetSequenceNumber },
|
|
26834
|
+
void 0,
|
|
26835
|
+
{
|
|
26836
|
+
skipFecPayloadId: true,
|
|
26837
|
+
recovered: true,
|
|
26838
|
+
deliveryProvenance,
|
|
26839
|
+
...fecSbnOf(sym.index),
|
|
26840
|
+
...catalogTrackName === void 0 ? {} : { catalogTrackName }
|
|
26841
|
+
}
|
|
26842
|
+
);
|
|
26843
|
+
}
|
|
26844
|
+
result = { ...result, symbols: result.symbols.filter((sym) => !untimedHead(sym)) };
|
|
25917
26845
|
const gated = this.#isFecTrack(ownerPacketId);
|
|
25918
26846
|
const assembler = this.#mseAssemblerFor(ownerPacketId, catalogTrackName);
|
|
25919
26847
|
if (assembler) {
|
|
@@ -27640,6 +28568,12 @@ function isNonNegativeSafeInteger(value) {
|
|
|
27640
28568
|
function isSymbolCounts(value) {
|
|
27641
28569
|
return isRecord(value) && hasExactKeys(value, ["multicast", "moq"]) && isNonNegativeSafeInteger(value["multicast"]) && isNonNegativeSafeInteger(value["moq"]);
|
|
27642
28570
|
}
|
|
28571
|
+
function isSpanFailure(value) {
|
|
28572
|
+
if (!isRecord(value) || !hasExactKeys(value, ["length", "sources"])) return false;
|
|
28573
|
+
const length = value["length"];
|
|
28574
|
+
const sources = value["sources"];
|
|
28575
|
+
return Number.isSafeInteger(length) && length > 0 && isNonNegativeSafeInteger(sources) && sources < length;
|
|
28576
|
+
}
|
|
27643
28577
|
function isNullableNonNegative(value) {
|
|
27644
28578
|
return value === null || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
27645
28579
|
}
|
|
@@ -27659,7 +28593,10 @@ function isRepairLifecycleEvent(value) {
|
|
|
27659
28593
|
case "recovered":
|
|
27660
28594
|
return hasExactKeys(value, ["version", "type", "block", "blockClass", "via", "symbols"]) && isRepairBlockIdentity(block) && BLOCK_CLASSES.has(value["blockClass"]) && (value["via"] === "inband" || value["via"] === "quic") && isSymbolCounts(value["symbols"]);
|
|
27661
28595
|
case "failed":
|
|
27662
|
-
return hasExactKeys(
|
|
28596
|
+
return hasExactKeys(
|
|
28597
|
+
value,
|
|
28598
|
+
"span" in value ? ["version", "type", "block", "blockClass", "symbols", "span"] : ["version", "type", "block", "blockClass", "symbols"]
|
|
28599
|
+
) && isRepairBlockIdentity(block) && BLOCK_CLASSES.has(value["blockClass"]) && isSymbolCounts(value["symbols"]) && (!("span" in value) || isSpanFailure(value["span"]));
|
|
27663
28600
|
case "repair-preempted":
|
|
27664
28601
|
case "repair-deferred":
|
|
27665
28602
|
return hasExactKeys(value, ["version", "type", "block"]) && isRepairBlockIdentity(block);
|
|
@@ -27868,6 +28805,8 @@ var MulticastManager = class {
|
|
|
27868
28805
|
/** Live joinRepairEndpoints() releases → the repair owners they registered,
|
|
27869
28806
|
* re-applied after configureMultiTrack() clears catalog-derived owners. */
|
|
27870
28807
|
#repairReleases = /* @__PURE__ */ new Map();
|
|
28808
|
+
/** Protected repair flows owned by each live repair-endpoint release. */
|
|
28809
|
+
#repairProvenanceFlows = /* @__PURE__ */ new Map();
|
|
27871
28810
|
/** Each source's catalog keyframe overlay, from its `ok` binding. */
|
|
27872
28811
|
#overlayBindings = /* @__PURE__ */ new Map();
|
|
27873
28812
|
/** Installed overlay decoders (`setKeyframeOverlayDecoder`), by source. */
|
|
@@ -27925,7 +28864,7 @@ var MulticastManager = class {
|
|
|
27925
28864
|
onPublisherRestart: (packetId, catalogTrackName) => {
|
|
27926
28865
|
this.#resetStreamOutsideRouter(packetId, catalogTrackName);
|
|
27927
28866
|
},
|
|
27928
|
-
onBlockFailed: (sbn, packetId, catalogTrackName, blockClass) => {
|
|
28867
|
+
onBlockFailed: (sbn, packetId, catalogTrackName, blockClass, span) => {
|
|
27929
28868
|
const pathCount = this.#fec.blockPathCount(
|
|
27930
28869
|
sbn,
|
|
27931
28870
|
packetId,
|
|
@@ -27943,7 +28882,8 @@ var MulticastManager = class {
|
|
|
27943
28882
|
symbols: {
|
|
27944
28883
|
multicast: pathCount?.multicastSymbols ?? 0,
|
|
27945
28884
|
moq: pathCount?.moqSymbols ?? 0
|
|
27946
|
-
}
|
|
28885
|
+
},
|
|
28886
|
+
...span === void 0 ? {} : { span }
|
|
27947
28887
|
});
|
|
27948
28888
|
},
|
|
27949
28889
|
onFrameGap: (decision) => {
|
|
@@ -28533,6 +29473,9 @@ var MulticastManager = class {
|
|
|
28533
29473
|
this.#transport.onFailback((reason) => {
|
|
28534
29474
|
const joined = this.#provenanceJoin;
|
|
28535
29475
|
if (joined !== null) this.#router.unprotectProvenanceFlow(joined.flow);
|
|
29476
|
+
for (const flows of this.#repairProvenanceFlows.values()) {
|
|
29477
|
+
for (const flow of flows) this.#router.unprotectProvenanceFlow(flow);
|
|
29478
|
+
}
|
|
28536
29479
|
this.#onFailback?.(reason);
|
|
28537
29480
|
});
|
|
28538
29481
|
}
|
|
@@ -28567,6 +29510,12 @@ var MulticastManager = class {
|
|
|
28567
29510
|
"[MulticastManager] join: provenance flow (S, G, port) must match sourceAddress ?? senderAddress, groupAddress and port"
|
|
28568
29511
|
);
|
|
28569
29512
|
}
|
|
29513
|
+
if (provenanceFlow !== void 0) {
|
|
29514
|
+
const flow = multicastProvenanceFlowKey(provenanceFlow);
|
|
29515
|
+
if ([...this.#repairProvenanceFlows.values()].some((flows) => flows.includes(flow))) {
|
|
29516
|
+
throw new TypeError(`[MulticastManager] join: provenance flow already registered by a repair endpoint: ${flow}`);
|
|
29517
|
+
}
|
|
29518
|
+
}
|
|
28570
29519
|
const staged = this.#renditionSwitch;
|
|
28571
29520
|
if (staged !== null) this.#endRenditionSwitch(staged, { reason: "superseded" }, false);
|
|
28572
29521
|
this.configureFec(config);
|
|
@@ -28574,8 +29523,8 @@ var MulticastManager = class {
|
|
|
28574
29523
|
const selectedPacketIds = config.packetIds?.length ? new Set(config.packetIds) : null;
|
|
28575
29524
|
const catalogTracks = config.tracks?.filter(({ packetId }) => selectedPacketIds === null || selectedPacketIds.has(packetId));
|
|
28576
29525
|
const ingressTracks = catalogTracks ? catalogTracks : selectedPacketIds === null ? void 0 : [...selectedPacketIds].map((packetId) => ({ name: "", packetId }));
|
|
28577
|
-
this.#releaseProvenanceJoin();
|
|
28578
29526
|
const provenance = config.provenance;
|
|
29527
|
+
this.#releaseProvenanceJoin();
|
|
28579
29528
|
const protectedTracks = ingressTracks ?? provenance?.flow.tracks;
|
|
28580
29529
|
const ingress = protectedTracks === void 0 ? void 0 : {
|
|
28581
29530
|
tracks: Object.freeze(
|
|
@@ -28628,8 +29577,13 @@ var MulticastManager = class {
|
|
|
28628
29577
|
* feeds the flow's receiver; media datagrams are held until one admits them.
|
|
28629
29578
|
*/
|
|
28630
29579
|
#joinProvenance(provenance, ingress) {
|
|
29580
|
+
this.#router.registerProvenanceFlow(ingress, this.#provenanceReceiver(provenance));
|
|
29581
|
+
this.#hookFailback();
|
|
29582
|
+
this.#provenanceJoin = { flow: ingress.flow };
|
|
29583
|
+
}
|
|
29584
|
+
#provenanceReceiver(provenance) {
|
|
28631
29585
|
const { flow, auth } = provenance;
|
|
28632
|
-
|
|
29586
|
+
return new BcProvenanceV2Receiver({
|
|
28633
29587
|
...provenance.receiver,
|
|
28634
29588
|
// The caller's ctx when it passes one, else the catalog's: an explicit
|
|
28635
29589
|
// `catalogCtx: undefined` must not switch off the 7.2.4 ctx check.
|
|
@@ -28646,9 +29600,6 @@ var MulticastManager = class {
|
|
|
28646
29600
|
maxAuthDelayMs: flow.maxAuthDelayMs,
|
|
28647
29601
|
manifestTimerMs: flow.manifestTimerMs
|
|
28648
29602
|
});
|
|
28649
|
-
this.#router.registerProvenanceFlow(ingress, receiver);
|
|
28650
|
-
this.#hookFailback();
|
|
28651
|
-
this.#provenanceJoin = { flow: ingress.flow };
|
|
28652
29603
|
}
|
|
28653
29604
|
/** Un-protect: drop the flow's hold queues (no expiry counted). */
|
|
28654
29605
|
#releaseProvenanceJoin() {
|
|
@@ -28679,8 +29630,25 @@ var MulticastManager = class {
|
|
|
28679
29630
|
* callback delivers must come from a subscription opened on
|
|
28680
29631
|
* `options.gateway`. A callback that also merges another source (a MoQ or
|
|
28681
29632
|
* WebSocket repair feed) must not name a native provider here.
|
|
29633
|
+
*
|
|
29634
|
+
* An endpoint's `provenance` makes its group a protected flow of its own
|
|
29635
|
+
* (multicast-02 7.2.7), registered here and released with the group; its
|
|
29636
|
+
* records ride in band on the group's port. On the user-agent path a
|
|
29637
|
+
* flow-less repair group of a protected track is set aside, never read, so
|
|
29638
|
+
* a player joining a protected catalog's repair groups passes it.
|
|
28682
29639
|
*/
|
|
28683
29640
|
joinRepairEndpoints(endpoints, provider, options) {
|
|
29641
|
+
for (const { provenance, flow, source, group, port: port2 } of endpoints) {
|
|
29642
|
+
if (provenance === void 0) continue;
|
|
29643
|
+
if (flow !== void 0) {
|
|
29644
|
+
throw new TypeError("[MulticastManager] joinRepairEndpoints: an endpoint names provenance or flow, never both");
|
|
29645
|
+
}
|
|
29646
|
+
if (!sameIpAddress(source, provenance.flow.source) || !sameIpAddress(group, provenance.flow.groupAddress) || port2 !== provenance.flow.port) {
|
|
29647
|
+
throw new RangeError(
|
|
29648
|
+
"[MulticastManager] joinRepairEndpoints: provenance flow (S, G, port) must match the endpoint's source, group and port"
|
|
29649
|
+
);
|
|
29650
|
+
}
|
|
29651
|
+
}
|
|
28684
29652
|
const releases = [];
|
|
28685
29653
|
let released = false;
|
|
28686
29654
|
const safely = (each) => {
|
|
@@ -28690,17 +29658,36 @@ var MulticastManager = class {
|
|
|
28690
29658
|
console.warn("[MulticastManager] repair group release failed", error);
|
|
28691
29659
|
}
|
|
28692
29660
|
};
|
|
29661
|
+
const usedFlows = /* @__PURE__ */ new Set();
|
|
29662
|
+
const preparedProvenance = endpoints.map((endpoint) => {
|
|
29663
|
+
if (endpoint.provenance === void 0) return void 0;
|
|
29664
|
+
const flow = multicastProvenanceFlowKey(endpoint.provenance.flow);
|
|
29665
|
+
if (usedFlows.has(flow) || this.#provenanceJoin?.flow === flow || [...this.#repairProvenanceFlows.values()].some((flows) => flows.includes(flow))) {
|
|
29666
|
+
throw new TypeError(`[MulticastManager] joinRepairEndpoints: provenance flow already registered: ${flow}`);
|
|
29667
|
+
}
|
|
29668
|
+
usedFlows.add(flow);
|
|
29669
|
+
return { flow, receiver: this.#provenanceReceiver(endpoint.provenance) };
|
|
29670
|
+
});
|
|
29671
|
+
const provenanceFlows = [];
|
|
28693
29672
|
const repairOwners = endpoints.flatMap((endpoint) => endpoint.repairOwners.map((owner) => owner.instance !== "keyframe" ? owner : {
|
|
28694
29673
|
...owner,
|
|
28695
29674
|
ownerTrackName: endpoint.tracks.find((t) => t.packetId === owner.ownerPacketId)?.name,
|
|
28696
29675
|
repairTrackName: endpoint.tracks.find((t) => t.packetId === owner.packetId)?.name
|
|
28697
29676
|
}));
|
|
28698
29677
|
this.#applyRepairOwners(repairOwners);
|
|
28699
|
-
for (const endpoint of endpoints) {
|
|
29678
|
+
for (const [index, endpoint] of endpoints.entries()) {
|
|
29679
|
+
const flow = endpoint.provenance === void 0 ? endpoint.flow : multicastProvenanceFlowKey(endpoint.provenance.flow);
|
|
28700
29680
|
const ingress = {
|
|
28701
29681
|
tracks: Object.freeze(endpoint.tracks.map(({ name, packetId }) => Object.freeze({ name, packetId }))),
|
|
28702
|
-
...
|
|
29682
|
+
...flow === void 0 ? {} : { flow }
|
|
28703
29683
|
};
|
|
29684
|
+
if (endpoint.provenance !== void 0) {
|
|
29685
|
+
const prepared = preparedProvenance[index];
|
|
29686
|
+
if (prepared === void 0) throw new Error("[MulticastManager] repair provenance preparation missing");
|
|
29687
|
+
this.#router.registerProvenanceFlow(ingress, prepared.receiver);
|
|
29688
|
+
provenanceFlows.push(prepared.flow);
|
|
29689
|
+
releases.push(() => this.#router.releaseProvenanceFlow(flow));
|
|
29690
|
+
}
|
|
28704
29691
|
let sender;
|
|
28705
29692
|
const feed = (packet, sourceAddress, ingressToFeed) => {
|
|
28706
29693
|
if (released) return;
|
|
@@ -28730,7 +29717,7 @@ var MulticastManager = class {
|
|
|
28730
29717
|
packetIds: endpoint.packetIds,
|
|
28731
29718
|
tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId })),
|
|
28732
29719
|
// A protected repair group's records ride in band on its port (7.2.3).
|
|
28733
|
-
...
|
|
29720
|
+
...flow === void 0 ? {} : { protected: true }
|
|
28734
29721
|
}, ingress).then((joined) => {
|
|
28735
29722
|
if (!joined && !released) fail(transport.lastJoinOutcome);
|
|
28736
29723
|
});
|
|
@@ -28739,9 +29726,12 @@ var MulticastManager = class {
|
|
|
28739
29726
|
if (released) return;
|
|
28740
29727
|
released = true;
|
|
28741
29728
|
this.#repairReleases.delete(release);
|
|
29729
|
+
this.#repairProvenanceFlows.delete(release);
|
|
28742
29730
|
for (const each of releases.splice(0)) safely(each);
|
|
28743
29731
|
};
|
|
28744
29732
|
this.#repairReleases.set(release, repairOwners);
|
|
29733
|
+
this.#repairProvenanceFlows.set(release, provenanceFlows);
|
|
29734
|
+
if (provenanceFlows.length) this.#hookFailback();
|
|
28745
29735
|
return release;
|
|
28746
29736
|
}
|
|
28747
29737
|
#applyRepairOwners(owners) {
|
|
@@ -29323,10 +30313,12 @@ var MulticastManager = class {
|
|
|
29323
30313
|
* Register the range repair scheduler (draft-ramadan-moq-fec §7.5): from now
|
|
29324
30314
|
* on an iso-ssbg1-v1 gap missing a source and every repair is kept as a
|
|
29325
30315
|
* pending hole and reported here, and `closeIsoHoles` must be called for it
|
|
29326
|
-
* once its range FETCH ends (or none is sent).
|
|
30316
|
+
* once its range FETCH ends (or none is sent). `onExpired` is told of a
|
|
30317
|
+
* pending hole the stream runs past the locator's horizon: returning true,
|
|
30318
|
+
* the caller closes it (`closeIsoHoles`); otherwise it is discarded.
|
|
29327
30319
|
*/
|
|
29328
|
-
onUndelimitedLoss(cb) {
|
|
29329
|
-
this.#fec.setUndelimitedLossHandler(cb);
|
|
30320
|
+
onUndelimitedLoss(cb, onExpired) {
|
|
30321
|
+
this.#fec.setUndelimitedLossHandler(cb, onExpired ?? null);
|
|
29330
30322
|
}
|
|
29331
30323
|
/**
|
|
29332
30324
|
* Report each stream whose FEC fails closed at runtime (fec-01 6.3.9), e.g.
|
|
@@ -29562,7 +30554,8 @@ var MulticastManager = class {
|
|
|
29562
30554
|
"stream" in event ? { ...event, stream: Object.freeze({ ...event.stream }) } : {
|
|
29563
30555
|
...event,
|
|
29564
30556
|
block: Object.freeze({ ...event.block }),
|
|
29565
|
-
..."symbols" in event ? { symbols: Object.freeze({ ...event.symbols }) } : {}
|
|
30557
|
+
..."symbols" in event ? { symbols: Object.freeze({ ...event.symbols }) } : {},
|
|
30558
|
+
..."span" in event && event.span !== void 0 ? { span: Object.freeze({ ...event.span }) } : {}
|
|
29566
30559
|
}
|
|
29567
30560
|
);
|
|
29568
30561
|
if (this.#logRepairLifecycle) {
|
|
@@ -32234,6 +33227,7 @@ var RepairLayerSubscriptions = class {
|
|
|
32234
33227
|
|
|
32235
33228
|
// src/repair-fetch.ts
|
|
32236
33229
|
var MOQT_PRIORITY_MAX = 255;
|
|
33230
|
+
var WALK_LEAD_MS = 3;
|
|
32237
33231
|
var SOURCE_MEDIA_PRIORITY_MAX = REPAIR_PRIORITY_MIN - 1;
|
|
32238
33232
|
function isMoqtPriority(value) {
|
|
32239
33233
|
return Number.isSafeInteger(value) && value >= 0 && value <= MOQT_PRIORITY_MAX;
|
|
@@ -32284,8 +33278,17 @@ function wireRepairFetch(mc, opts) {
|
|
|
32284
33278
|
mc.noteRepairScheduling(type, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
32285
33279
|
};
|
|
32286
33280
|
const clearEntry = (entry) => {
|
|
32287
|
-
|
|
32288
|
-
|
|
33281
|
+
const { range } = entry;
|
|
33282
|
+
if (range) {
|
|
33283
|
+
atReport(range, () => mc.closeIsoHoles(entry.packetId, entry.catalogTrackName, entry.sbn, range.holeLength));
|
|
33284
|
+
} else {
|
|
33285
|
+
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
33286
|
+
}
|
|
33287
|
+
};
|
|
33288
|
+
const atReport = (range, work) => {
|
|
33289
|
+
const fec = mc.fecManager;
|
|
33290
|
+
if (range.groups !== null || fec.withReceiptTime === void 0) work();
|
|
33291
|
+
else fec.withReceiptTime(range.reportedAt, work);
|
|
32289
33292
|
};
|
|
32290
33293
|
const releaseHold = (entry) => {
|
|
32291
33294
|
if (entry.range) return;
|
|
@@ -32297,7 +33300,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
32297
33300
|
if (!run) return;
|
|
32298
33301
|
entry.running = null;
|
|
32299
33302
|
run.stopped = reason;
|
|
32300
|
-
run.controller.abort();
|
|
33303
|
+
run.controller.abort(reason);
|
|
32301
33304
|
if (reason === "preempted") releaseHold(entry);
|
|
32302
33305
|
mc.noteRepairStopped?.(reason, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
32303
33306
|
};
|
|
@@ -32352,21 +33355,42 @@ function wireRepairFetch(mc, opts) {
|
|
|
32352
33355
|
const admit = (entry, now) => {
|
|
32353
33356
|
const budgetMs = entry.deadlineAt - now;
|
|
32354
33357
|
const rttMs = readRtt();
|
|
32355
|
-
const reason =
|
|
33358
|
+
const reason = refusal(entry, now, rttMs);
|
|
32356
33359
|
if (reason === null) return rttMs;
|
|
32357
33360
|
skip(entry, reason, rttMs, budgetMs);
|
|
32358
33361
|
return null;
|
|
32359
33362
|
};
|
|
33363
|
+
const refusal = (entry, now, rttMs) => !entry.range && !groupCanComplete(entry.sbn, entry.packetId, entry.catalogTrackName) ? "group-cannot-complete" : rttMs === null ? "rtt-unmeasured" : rttMs < entry.deadlineAt - now ? null : "rtt-exceeds-budget";
|
|
32360
33364
|
const retire = (entry) => {
|
|
32361
33365
|
if (entries.get(entry.key) === entry) entries.delete(entry.key);
|
|
32362
33366
|
if (entry.expiry !== void 0) clearTimeout(entry.expiry);
|
|
32363
33367
|
};
|
|
32364
|
-
const
|
|
33368
|
+
const holdsBack = (entry, priority, videoWalks = true) => {
|
|
33369
|
+
if (entry.priority >= priority) return false;
|
|
33370
|
+
const { walk } = entry;
|
|
33371
|
+
if (walk === void 0) return true;
|
|
33372
|
+
if (entry.priority !== 0 || !videoWalks) return false;
|
|
33373
|
+
return entry.running === null || walk.group !== null && !walk.group.controller.signal.aborted;
|
|
33374
|
+
};
|
|
33375
|
+
const outstandingBelow = (priority, videoWalks = true) => {
|
|
32365
33376
|
for (const entry of entries.values()) {
|
|
32366
|
-
if (entry
|
|
33377
|
+
if (holdsBack(entry, priority, videoWalks)) return true;
|
|
32367
33378
|
}
|
|
32368
33379
|
return false;
|
|
32369
33380
|
};
|
|
33381
|
+
const yieldVideoWalks = (queued) => {
|
|
33382
|
+
const now = performance.now();
|
|
33383
|
+
const rttMs = readRtt();
|
|
33384
|
+
const due = queued.some((entry) => entry.priority !== 0 && entry.walk === void 0 && !outstandingBelow(entry.priority, false) && refusal(entry, now, rttMs) === null);
|
|
33385
|
+
if (!due) return;
|
|
33386
|
+
for (const entry of entries.values()) {
|
|
33387
|
+
const walk = entry.walk;
|
|
33388
|
+
if (entry.priority !== 0 || walk === void 0 || walk.group === null) continue;
|
|
33389
|
+
if (walk.group.controller.signal.aborted) continue;
|
|
33390
|
+
walk.yielded = true;
|
|
33391
|
+
walk.group.controller.abort();
|
|
33392
|
+
}
|
|
33393
|
+
};
|
|
32370
33394
|
const preemptBestEffort = () => {
|
|
32371
33395
|
for (const entry of entries.values()) {
|
|
32372
33396
|
if (entry.priority === 0 || !entry.running) continue;
|
|
@@ -32395,7 +33419,8 @@ function wireRepairFetch(mc, opts) {
|
|
|
32395
33419
|
}
|
|
32396
33420
|
const rttMs = admit(entry, now);
|
|
32397
33421
|
if (rttMs === null) return;
|
|
32398
|
-
if (entry.priority === 0) preemptBestEffort();
|
|
33422
|
+
if (entry.priority === 0 && entry.walk === void 0) preemptBestEffort();
|
|
33423
|
+
if (entry.range === void 0) leaveWalkedGroup(entry);
|
|
32399
33424
|
if (counted) entry.attempts++;
|
|
32400
33425
|
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName, {
|
|
32401
33426
|
rttMs,
|
|
@@ -32417,6 +33442,14 @@ function wireRepairFetch(mc, opts) {
|
|
|
32417
33442
|
}
|
|
32418
33443
|
void execute(entry, run);
|
|
32419
33444
|
};
|
|
33445
|
+
const leaveWalkedGroup = (block) => {
|
|
33446
|
+
for (const entry of entries.values()) {
|
|
33447
|
+
const group = entry.walk?.group;
|
|
33448
|
+
if (group?.sbn === block.sbn && entry.packetId === block.packetId && entry.catalogTrackName === block.catalogTrackName) {
|
|
33449
|
+
group.controller.abort();
|
|
33450
|
+
}
|
|
33451
|
+
}
|
|
33452
|
+
};
|
|
32420
33453
|
const dispatch = () => {
|
|
32421
33454
|
if (disposed) return;
|
|
32422
33455
|
const now = performance.now();
|
|
@@ -32441,6 +33474,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
32441
33474
|
for (const entry of queued) {
|
|
32442
33475
|
if (entry.priority === 0) start(entry);
|
|
32443
33476
|
}
|
|
33477
|
+
yieldVideoWalks(queued);
|
|
32444
33478
|
if (outstandingBelow(1)) return;
|
|
32445
33479
|
for (const entry of queued) {
|
|
32446
33480
|
if (entry.priority === 1) start(entry);
|
|
@@ -32467,6 +33501,16 @@ function wireRepairFetch(mc, opts) {
|
|
|
32467
33501
|
}
|
|
32468
33502
|
return counts.sources + counts.repairGroupLength >= counts.authoredLength;
|
|
32469
33503
|
};
|
|
33504
|
+
const groupServed = (sbn, packetId, catalogTrackName) => {
|
|
33505
|
+
if (mc.fecManager.blockSymbolCounts === void 0) return false;
|
|
33506
|
+
const counts = symbolCounts(sbn, packetId, catalogTrackName);
|
|
33507
|
+
if (counts === void 0 || counts.authoredLength === void 0) return true;
|
|
33508
|
+
return counts.sources + counts.repairs >= counts.authoredLength || !groupCanComplete(sbn, packetId, catalogTrackName);
|
|
33509
|
+
};
|
|
33510
|
+
const statedEnd = (sbn, packetId, catalogTrackName) => {
|
|
33511
|
+
const length = symbolCounts(sbn, packetId, catalogTrackName)?.authoredLength;
|
|
33512
|
+
return length === void 0 ? void 0 : serial32Add(sbn, length);
|
|
33513
|
+
};
|
|
32470
33514
|
const finish = (entry, run, fed, error) => {
|
|
32471
33515
|
if (run.stopped !== null || entry.running !== run || entries.get(entry.key) !== entry) {
|
|
32472
33516
|
return;
|
|
@@ -32511,27 +33555,81 @@ function wireRepairFetch(mc, opts) {
|
|
|
32511
33555
|
signal: run.controller.signal,
|
|
32512
33556
|
subscriberPriority: entry.subscriberPriority
|
|
32513
33557
|
};
|
|
33558
|
+
const { range } = entry;
|
|
33559
|
+
const feed = (packet) => {
|
|
33560
|
+
if (entry.catalogTrackName === void 0) {
|
|
33561
|
+
mc.processRepairFromMoQ(packet, entry.packetId);
|
|
33562
|
+
} else {
|
|
33563
|
+
mc.processRepairFromMoQ(packet, entry.packetId, entry.catalogTrackName);
|
|
33564
|
+
}
|
|
33565
|
+
};
|
|
32514
33566
|
try {
|
|
32515
|
-
const packets = entry.
|
|
33567
|
+
const packets = range === void 0 ? opts.transport({ ...common, sbn: entry.sbn }) : entry.walk !== void 0 ? walkHole(entry, entry.walk, range, common) : opts.rangeTransport({
|
|
32516
33568
|
...common,
|
|
32517
|
-
startGroup:
|
|
32518
|
-
endGroup:
|
|
32519
|
-
lostSsId:
|
|
32520
|
-
})
|
|
33569
|
+
startGroup: range.groups.startGroup,
|
|
33570
|
+
endGroup: range.groups.endGroup,
|
|
33571
|
+
lostSsId: range.lostSsId
|
|
33572
|
+
});
|
|
32521
33573
|
for await (const packet of packets) {
|
|
32522
33574
|
if (run.stopped !== null || entry.running !== run) break;
|
|
32523
33575
|
fed++;
|
|
32524
|
-
if (
|
|
32525
|
-
|
|
32526
|
-
} else {
|
|
32527
|
-
mc.processRepairFromMoQ(packet, entry.packetId, entry.catalogTrackName);
|
|
32528
|
-
}
|
|
33576
|
+
if (range === void 0) feed(packet);
|
|
33577
|
+
else atReport(range, () => feed(packet));
|
|
32529
33578
|
}
|
|
32530
33579
|
finish(entry, run, fed, void 0);
|
|
32531
33580
|
} catch (error) {
|
|
32532
33581
|
finish(entry, run, fed, error ?? new Error("repair transport rejected"));
|
|
32533
33582
|
}
|
|
32534
33583
|
};
|
|
33584
|
+
async function* walkHole(entry, walk, hole, common) {
|
|
33585
|
+
const lostAt = serial32Distance(entry.sbn, hole.lostSsId);
|
|
33586
|
+
for (let first = true; !common.signal.aborted; first = false) {
|
|
33587
|
+
if (!first && entry.priority !== 0 && outstandingBelow(1)) {
|
|
33588
|
+
stop(entry, "preempted");
|
|
33589
|
+
note("repair-preempted", entry);
|
|
33590
|
+
return;
|
|
33591
|
+
}
|
|
33592
|
+
if (!first && entry.priority === 0) {
|
|
33593
|
+
dispatch();
|
|
33594
|
+
if (common.signal.aborted) return;
|
|
33595
|
+
}
|
|
33596
|
+
const sbn = walk.next;
|
|
33597
|
+
let next;
|
|
33598
|
+
if (entries.get(requestKey(sbn, entry.packetId, entry.catalogTrackName))?.running == null) {
|
|
33599
|
+
const rsIds = /* @__PURE__ */ new Set();
|
|
33600
|
+
const group = new AbortController();
|
|
33601
|
+
const cancel = () => group.abort(common.signal.reason);
|
|
33602
|
+
common.signal.addEventListener("abort", cancel, { once: true });
|
|
33603
|
+
walk.group = { sbn, controller: group };
|
|
33604
|
+
try {
|
|
33605
|
+
for await (const packet of opts.transport({ ...common, sbn, signal: group.signal })) {
|
|
33606
|
+
yield packet;
|
|
33607
|
+
const id = extractRepairFecPayloadId(packet);
|
|
33608
|
+
if (id === null || id.ssStart !== sbn || id.ssbLength === 0) continue;
|
|
33609
|
+
next ??= serial32Add(sbn, id.ssbLength);
|
|
33610
|
+
rsIds.add(id.rsId);
|
|
33611
|
+
if (rsIds.size >= id.rsbLength || groupServed(sbn, entry.packetId, entry.catalogTrackName)) {
|
|
33612
|
+
group.abort();
|
|
33613
|
+
break;
|
|
33614
|
+
}
|
|
33615
|
+
}
|
|
33616
|
+
} catch (error) {
|
|
33617
|
+
if (!group.signal.aborted || common.signal.aborted) throw error;
|
|
33618
|
+
} finally {
|
|
33619
|
+
common.signal.removeEventListener("abort", cancel);
|
|
33620
|
+
walk.group = null;
|
|
33621
|
+
}
|
|
33622
|
+
if (walk.yielded) {
|
|
33623
|
+
walk.yielded = false;
|
|
33624
|
+
continue;
|
|
33625
|
+
}
|
|
33626
|
+
}
|
|
33627
|
+
next ??= statedEnd(sbn, entry.packetId, entry.catalogTrackName);
|
|
33628
|
+
if (next === void 0) return;
|
|
33629
|
+
if (serial32Distance(entry.sbn, next) > lostAt) return;
|
|
33630
|
+
walk.next = next;
|
|
33631
|
+
}
|
|
33632
|
+
}
|
|
32535
33633
|
const removeResetObserver = mc.addTrackResetObserver((packetId, catalogTrackName) => {
|
|
32536
33634
|
for (const entry of [...entries.values()]) {
|
|
32537
33635
|
if (entry.packetId !== packetId || entry.catalogTrackName !== catalogTrackName) continue;
|
|
@@ -32727,7 +33825,37 @@ function wireRepairFetch(mc, opts) {
|
|
|
32727
33825
|
throw error;
|
|
32728
33826
|
}
|
|
32729
33827
|
};
|
|
32730
|
-
|
|
33828
|
+
const trackKind = (packetId) => {
|
|
33829
|
+
try {
|
|
33830
|
+
return mc.fecManager.trackKindFor?.(packetId);
|
|
33831
|
+
} catch {
|
|
33832
|
+
return void 0;
|
|
33833
|
+
}
|
|
33834
|
+
};
|
|
33835
|
+
const walkDeadlineAt = (packetId, now, deadlineAt) => {
|
|
33836
|
+
let repairDeadlineMs;
|
|
33837
|
+
try {
|
|
33838
|
+
repairDeadlineMs = mc.fecManager.repairDeadlineMsForPacket?.(packetId);
|
|
33839
|
+
} catch {
|
|
33840
|
+
repairDeadlineMs = void 0;
|
|
33841
|
+
}
|
|
33842
|
+
if (repairDeadlineMs === void 0 || !Number.isFinite(repairDeadlineMs)) return deadlineAt;
|
|
33843
|
+
return Math.min(deadlineAt, now + repairDeadlineMs - WALK_LEAD_MS);
|
|
33844
|
+
};
|
|
33845
|
+
const onHoleExpired = (hole) => {
|
|
33846
|
+
if (disposed) return false;
|
|
33847
|
+
const entry = [...entries.values()].find((candidate) => candidate.walk !== void 0 && candidate.packetId === hole.packetId && candidate.catalogTrackName === hole.catalogTrackName && serial32Distance(candidate.sbn, hole.holeStart) < candidate.range.holeLength);
|
|
33848
|
+
if (entry === void 0) return false;
|
|
33849
|
+
queueMicrotask(() => {
|
|
33850
|
+
if (entries.get(entry.key) !== entry) return;
|
|
33851
|
+
retire(entry);
|
|
33852
|
+
stop(entry, "expired");
|
|
33853
|
+
clearEntry(entry);
|
|
33854
|
+
dispatch();
|
|
33855
|
+
});
|
|
33856
|
+
return true;
|
|
33857
|
+
};
|
|
33858
|
+
if (mc.onUndelimitedLoss !== void 0 && mc.closeIsoHoles !== void 0) {
|
|
32731
33859
|
mc.onUndelimitedLoss((loss) => {
|
|
32732
33860
|
const { packetId, catalogTrackName, holeStart, holeLength } = loss;
|
|
32733
33861
|
const close = () => mc.closeIsoHoles(packetId, catalogTrackName, holeStart, holeLength);
|
|
@@ -32735,9 +33863,11 @@ function wireRepairFetch(mc, opts) {
|
|
|
32735
33863
|
const blockProfile = blockProfileOf(packetId);
|
|
32736
33864
|
const target = opts.resolveTarget(packetId, catalogTrackName);
|
|
32737
33865
|
if (!target) return close();
|
|
32738
|
-
const
|
|
32739
|
-
const
|
|
32740
|
-
|
|
33866
|
+
const walked = opts.rangeTransport === void 0;
|
|
33867
|
+
const holeClass = walked && trackKind(packetId) === "audio" ? "audio" : "unknown";
|
|
33868
|
+
const priority = repairPriorityForClass(holeClass);
|
|
33869
|
+
const groups = walked ? null : rangeFor(loss, target.repairTrack);
|
|
33870
|
+
if (!walked && groups === null) {
|
|
32741
33871
|
close();
|
|
32742
33872
|
mc.noteRepairSkipped("range-no-anchor", { rttMs: readRtt(), budgetMs: 0, priority }, holeStart, packetId, catalogTrackName);
|
|
32743
33873
|
return;
|
|
@@ -32748,8 +33878,10 @@ function wireRepairFetch(mc, opts) {
|
|
|
32748
33878
|
packetId,
|
|
32749
33879
|
...catalogTrackName === void 0 ? {} : { catalogTrackName }
|
|
32750
33880
|
};
|
|
32751
|
-
const wire = wirePriority(identity,
|
|
32752
|
-
|
|
33881
|
+
const wire = wirePriority(identity, holeClass);
|
|
33882
|
+
if (wire === null) return close();
|
|
33883
|
+
const now = performance.now();
|
|
33884
|
+
const deadline = presentationDeadlineAt(holeStart, packetId, catalogTrackName, now, holeClass);
|
|
32753
33885
|
if (deadline === null) {
|
|
32754
33886
|
close();
|
|
32755
33887
|
mc.noteRepairSkipped(
|
|
@@ -32761,6 +33893,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
32761
33893
|
);
|
|
32762
33894
|
return;
|
|
32763
33895
|
}
|
|
33896
|
+
const deadlineAt = walked ? walkDeadlineAt(packetId, now, deadline.deadlineAt) : deadline.deadlineAt;
|
|
32764
33897
|
const entry = {
|
|
32765
33898
|
key: JSON.stringify(["range", packetId, catalogTrackName ?? null, holeStart]),
|
|
32766
33899
|
...identity,
|
|
@@ -32768,15 +33901,16 @@ function wireRepairFetch(mc, opts) {
|
|
|
32768
33901
|
blockProfile,
|
|
32769
33902
|
priority,
|
|
32770
33903
|
subscriberPriority: wire.subscriberPriority,
|
|
32771
|
-
deadlineAt
|
|
32772
|
-
playoutDeadlineAt:
|
|
33904
|
+
deadlineAt,
|
|
33905
|
+
playoutDeadlineAt: deadlineAt - deadline.extensionMs,
|
|
32773
33906
|
anchorAt: deadline.anchorAt,
|
|
32774
33907
|
delayMs: deadline.delayMs,
|
|
32775
33908
|
bound: deadline.bound,
|
|
32776
33909
|
order: enqueueOrder++,
|
|
32777
33910
|
attempts: 0,
|
|
32778
33911
|
running: null,
|
|
32779
|
-
range: {
|
|
33912
|
+
range: { lostSsId: loss.lostSsId, holeLength, groups, reportedAt: now },
|
|
33913
|
+
...walked ? { walk: { next: holeStart, group: null, yielded: false } } : {}
|
|
32780
33914
|
};
|
|
32781
33915
|
const previous = entries.get(entry.key);
|
|
32782
33916
|
if (previous) {
|
|
@@ -32786,7 +33920,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
32786
33920
|
entries.set(entry.key, entry);
|
|
32787
33921
|
entry.expiry = setTimeout(dispatch, Math.max(0, entry.deadlineAt - performance.now()) + 1);
|
|
32788
33922
|
dispatch();
|
|
32789
|
-
});
|
|
33923
|
+
}, onHoleExpired);
|
|
32790
33924
|
}
|
|
32791
33925
|
const removeRapObserver = mc.addRapCompleteObserver?.((packetId) => {
|
|
32792
33926
|
queueMicrotask(() => {
|