@blockcast/mmt-container 2.2.0-main.7e8a9d13c01c → 2.2.0-main.88a4d1b4803a
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 +296 -20
- 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/fec-manager.d.ts +34 -3
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +108 -6
- package/dist/fec-manager.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts +21 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +98 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +99 -3
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +98 -2
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +2 -0
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +118 -2
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-manager.d.ts +13 -0
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +294 -18
- package/dist/multicast-manager.js.map +3 -3
- package/dist/no-modules.js +98 -2
- package/dist/no-modules.js.map +3 -3
- package/dist/repair-fetch.d.ts +2 -0
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +2 -2
- package/dist/repair-fetch.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +98 -2
- 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 +137 -6
- package/src/mmtp-container-parser.ts +36 -8
- package/src/mmtp-router.ts +32 -0
- package/src/multicast-manager.ts +90 -10
- package/src/repair-fetch.ts +4 -2
package/dist/browser-runtime.js
CHANGED
|
@@ -6099,9 +6099,10 @@ function isH264IntraSlice(nal) {
|
|
|
6099
6099
|
const sliceType = readH264SliceType(nal);
|
|
6100
6100
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
6101
6101
|
}
|
|
6102
|
+
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
6102
6103
|
function readH264SliceType(nal) {
|
|
6103
6104
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
6104
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
6105
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
|
|
6105
6106
|
const state = { bitOffset: 0 };
|
|
6106
6107
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
6107
6108
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -6470,6 +6471,96 @@ if (void 0) {
|
|
|
6470
6471
|
]))).toBe(false);
|
|
6471
6472
|
});
|
|
6472
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
|
+
});
|
|
6473
6564
|
describe("avccToAnnexB", () => {
|
|
6474
6565
|
test("converts with SPS/PPS on keyframe", () => {
|
|
6475
6566
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|
|
@@ -14041,7 +14132,8 @@ var FECManager = class _FECManager {
|
|
|
14041
14132
|
this.#ssbLengthConflictCount = 0;
|
|
14042
14133
|
this.#blockRepairRsIds = /* @__PURE__ */ new Map();
|
|
14043
14134
|
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
14044
|
-
// 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.
|
|
14045
14137
|
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
14046
14138
|
/** fec-01 6.3.9 anchor state per stream key, one entry per held layer. */
|
|
14047
14139
|
this.#heldLayerStates = /* @__PURE__ */ new Map();
|
|
@@ -14288,6 +14380,16 @@ var FECManager = class _FECManager {
|
|
|
14288
14380
|
this.onBlockResolved = null;
|
|
14289
14381
|
/** A stream's SBN went backwards (or jumped implausibly): the source restarted. */
|
|
14290
14382
|
this.onSourceDiscontinuity = null;
|
|
14383
|
+
/**
|
|
14384
|
+
* The span and tolerance the catalog states for a keyframe overlay
|
|
14385
|
+
* installed over a source track (draft-ramadan-moq-mmt-02 7.4.1: the
|
|
14386
|
+
* overlay instance's own interleaveDepthMs and reorderToleranceMs), or
|
|
14387
|
+
* undefined while none is installed. A stated block only a late source
|
|
14388
|
+
* can complete, and a frame whose gap may hide a RAP behind a span only a
|
|
14389
|
+
* late source can fill, also wait for that overlay's repair
|
|
14390
|
+
* (#overlayLateWaitMs).
|
|
14391
|
+
*/
|
|
14392
|
+
this.keyframeOverlayTiming = null;
|
|
14291
14393
|
// Worker-path callbacks — async recovery and stats from FecWorkerClient.
|
|
14292
14394
|
/**
|
|
14293
14395
|
* A recovered source symbol. Return false when admission refused the
|
|
@@ -16064,8 +16166,10 @@ var FECManager = class _FECManager {
|
|
|
16064
16166
|
}
|
|
16065
16167
|
/**
|
|
16066
16168
|
* An open block's accepted sources, distinct repair RS_IDs, authored K'
|
|
16067
|
-
* (SSB_length) and RSB_length (each undefined until a repair stated it
|
|
16068
|
-
*
|
|
16169
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it; a
|
|
16170
|
+
* repair-less span states its length, and RSB_length 0 when it is longer
|
|
16171
|
+
* than K, since no repair can reach it). Undefined for a block that is not
|
|
16172
|
+
* open.
|
|
16069
16173
|
*/
|
|
16070
16174
|
blockSymbolCounts(sbn, packetId, catalogTrackName) {
|
|
16071
16175
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
@@ -16367,12 +16471,24 @@ var FECManager = class _FECManager {
|
|
|
16367
16471
|
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
16368
16472
|
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
16369
16473
|
* block.
|
|
16474
|
+
*
|
|
16475
|
+
* A span longer than K holds more than one block (SSB_length <= K), and the
|
|
16476
|
+
* locator states no block inside a span, only one exactly its range
|
|
16477
|
+
* (IsoBlockLocator.placeRepair): no repair, multicast or FETCHed, can ever
|
|
16478
|
+
* reach it. Its repair group is empty, so the repair scheduler FETCHes no
|
|
16479
|
+
* Group of it (group-cannot-complete). Every span still keeps its whole
|
|
16480
|
+
* wait (#lateSourceWaitMs): failing it early released the frames behind it
|
|
16481
|
+
* past a keyframe the overlay was still rebuilding (BLO-52085). The release
|
|
16482
|
+
* gate lets those frames go once only a late source can fill the gap
|
|
16483
|
+
* before them, as long after they arrived as the gap's decision allows
|
|
16484
|
+
* (isoRepairlessWaitMs).
|
|
16370
16485
|
*/
|
|
16371
16486
|
#openIsoSpan(span, packetId, catalogTrackName) {
|
|
16372
16487
|
const key = this.#blockKey(span.block.start, packetId, catalogTrackName);
|
|
16373
16488
|
if (!this.#blockAuthoredLengths.has(key)) {
|
|
16374
16489
|
this.#blockAuthoredLengths.set(key, span.block.length);
|
|
16375
16490
|
this.#isoSpanKeys.add(key);
|
|
16491
|
+
if (span.block.length > this.#isoLocatorFor(packetId, catalogTrackName).kMax) this.#blockRsbLengths.set(key, 0);
|
|
16376
16492
|
}
|
|
16377
16493
|
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true);
|
|
16378
16494
|
}
|
|
@@ -16411,6 +16527,50 @@ var FECManager = class _FECManager {
|
|
|
16411
16527
|
}
|
|
16412
16528
|
return lost;
|
|
16413
16529
|
}
|
|
16530
|
+
/**
|
|
16531
|
+
* The release gate's wait, from a frame's arrival, for the SS_IDs strictly
|
|
16532
|
+
* between two released frames' SS_IDs once only a late source can still
|
|
16533
|
+
* fill them, else undefined. That is when every one missing (neither
|
|
16534
|
+
* arrived nor held) lies in a repair-less span longer than K, which no
|
|
16535
|
+
* repair can state a block of (#openIsoSpan), and a multicast source at or
|
|
16536
|
+
* past `toSsId` arrived, so each is lost or reordered behind it (a MoQ
|
|
16537
|
+
* source shows nothing: MoQ streams overtake one another). The span itself
|
|
16538
|
+
* keeps its whole wait.
|
|
16539
|
+
*
|
|
16540
|
+
* The wait is the late-symbol allowance, unless `rapMayHide`: the gap may
|
|
16541
|
+
* hold a RAP packet an installed keyframe overlay can still rebuild (its
|
|
16542
|
+
* decision stalls, or it ends at a RAP that may lie past a whole MPU).
|
|
16543
|
+
* Then the frame waits as a stated block its group cannot complete does
|
|
16544
|
+
* (#overlayLateWaitMs): the allowance alone with no overlay installed, the
|
|
16545
|
+
* overlay's span plus the larger of the allowance and its tolerance, or,
|
|
16546
|
+
* for an overlay that states no span, the span's whole wait (undefined).
|
|
16547
|
+
*/
|
|
16548
|
+
isoRepairlessWaitMs(packetId, catalogTrackName, fromSsId, toSsId, rapMayHide = false) {
|
|
16549
|
+
const config = this.#trackConfigs.get(packetId);
|
|
16550
|
+
if (config === void 0 || !_FECManager.#hasCatalogTiming(config)) return void 0;
|
|
16551
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
|
|
16552
|
+
if (locator === void 0 || !locator.coversBetween(fromSsId, toSsId)) return void 0;
|
|
16553
|
+
const newestSource = locator.newestSource;
|
|
16554
|
+
if (newestSource === void 0 || serial32Precedes(newestSource, toSsId)) return void 0;
|
|
16555
|
+
let repairless = false;
|
|
16556
|
+
for (const block of locator.blocksBetween(fromSsId, toSsId)) {
|
|
16557
|
+
const key = this.#blockKey(block.start, packetId, catalogTrackName);
|
|
16558
|
+
if (this.#completedBlocks.has(key)) continue;
|
|
16559
|
+
if (block.span && block.length > locator.kMax) {
|
|
16560
|
+
repairless = true;
|
|
16561
|
+
continue;
|
|
16562
|
+
}
|
|
16563
|
+
const received = this.#blockSourceEsis.get(key);
|
|
16564
|
+
for (let esi = 0; esi < block.length; esi++) {
|
|
16565
|
+
const ssId = serial32Add(block.start, esi);
|
|
16566
|
+
if (!serial32Precedes(fromSsId, ssId) || !serial32Precedes(ssId, toSsId)) continue;
|
|
16567
|
+
if (!received?.has(esi) && !locator.isHeld(ssId)) return void 0;
|
|
16568
|
+
}
|
|
16569
|
+
}
|
|
16570
|
+
if (!repairless) return void 0;
|
|
16571
|
+
const waitMs = rapMayHide ? this.#overlayLateWaitMs(packetId, catalogTrackName, config) : this.#multicastWaitMs(config) - config.interleaveDepthMs;
|
|
16572
|
+
return waitMs === void 0 ? void 0 : Math.max(0, waitMs);
|
|
16573
|
+
}
|
|
16414
16574
|
/**
|
|
16415
16575
|
* iso-ssbg1-v1 block location: repair symbols it refused, oversize sources,
|
|
16416
16576
|
* the sources held now for a block no repair has stated yet, and the held
|
|
@@ -17216,7 +17376,7 @@ var FECManager = class _FECManager {
|
|
|
17216
17376
|
const previous = locator.newestSource;
|
|
17217
17377
|
if (!locator.noteSource(ssId) || previous === void 0) return;
|
|
17218
17378
|
for (const block of locator.blocksBetween(previous - 1 >>> 0, ssId)) {
|
|
17219
|
-
if (
|
|
17379
|
+
if (!serial32Precedes(serial32Add(block.start, block.length - 1), ssId)) continue;
|
|
17220
17380
|
this.#shortenUnrecoverableWait(
|
|
17221
17381
|
this.#blockKey(block.start, packetId, catalogTrackName),
|
|
17222
17382
|
block.start,
|
|
@@ -17234,9 +17394,16 @@ var FECManager = class _FECManager {
|
|
|
17234
17394
|
* covers repair symbols paced after its sources, buys it nothing: it waits
|
|
17235
17395
|
* the late-symbol allowance alone, the multicast wait less the span (the
|
|
17236
17396
|
* catalog tolerance or the measured delivery gap). Undefined for any other
|
|
17237
|
-
* block.
|
|
17397
|
+
* block. While a keyframe overlay is installed, the block waits for its
|
|
17398
|
+
* repair too (#overlayLateWaitMs). A repair-less span keeps its whole
|
|
17399
|
+
* wait, even one longer than K whose group is empty (#openIsoSpan): its
|
|
17400
|
+
* resolution is what releases the frames behind it, and failing it early
|
|
17401
|
+
* released them past a keyframe the overlay was still rebuilding, which
|
|
17402
|
+
* then arrived stale. The release gate lets them go instead
|
|
17403
|
+
* (isoRepairlessWaitMs).
|
|
17238
17404
|
*/
|
|
17239
17405
|
#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) {
|
|
17406
|
+
if (this.#isoSpanKeys.has(key)) return void 0;
|
|
17240
17407
|
const authoredLength = this.#blockAuthoredLengths.get(key);
|
|
17241
17408
|
const rsbLength = this.#blockRsbLengths.get(key);
|
|
17242
17409
|
if (authoredLength === void 0 || rsbLength === void 0) return void 0;
|
|
@@ -17248,7 +17415,33 @@ var FECManager = class _FECManager {
|
|
|
17248
17415
|
if (newestSource === void 0 || !serial32Precedes(serial32Add(sbn, authoredLength - 1), newestSource)) {
|
|
17249
17416
|
return void 0;
|
|
17250
17417
|
}
|
|
17251
|
-
return this.#
|
|
17418
|
+
return this.#overlayLateWaitMs(packetId, catalogTrackName, config);
|
|
17419
|
+
}
|
|
17420
|
+
/**
|
|
17421
|
+
* How long a loss only a late source or an installed keyframe overlay can
|
|
17422
|
+
* still fill waits once a later source passed it: the late-symbol
|
|
17423
|
+
* allowance alone (the multicast wait less the span) while no overlay is
|
|
17424
|
+
* installed. An installed one (keyframeOverlayTiming) may still rebuild a
|
|
17425
|
+
* RAP packet the loss took: a second FEC instance over the same packets
|
|
17426
|
+
* (draft-ramadan-moq-mmt-02 7.4), whose repair is paced across its own
|
|
17427
|
+
* span, unrelated to the base's. That packet can complete a stated block
|
|
17428
|
+
* (feedRebuiltSourceSymbol), or play behind a span; giving the loss up
|
|
17429
|
+
* first lets the release gate pass the keyframe, whose rebuild then lands
|
|
17430
|
+
* stale. The overlay repair of a packet the loss took goes out within the
|
|
17431
|
+
* overlay's span of that packet (fec-core-00 9.3), and the later source was
|
|
17432
|
+
* sent after it, so the loss waits that span plus the larger of the
|
|
17433
|
+
* allowance and the overlay's own tolerance. An overlay that states no
|
|
17434
|
+
* span (its block may then span keyframes), or one whose wait is not
|
|
17435
|
+
* shorter than the whole multicast wait, leaves the whole wait: undefined.
|
|
17436
|
+
*/
|
|
17437
|
+
#overlayLateWaitMs(packetId, catalogTrackName, config) {
|
|
17438
|
+
const waitMs = this.#multicastWaitMs(config);
|
|
17439
|
+
const allowanceMs = waitMs - config.interleaveDepthMs;
|
|
17440
|
+
const overlay = this.keyframeOverlayTiming?.(packetId, catalogTrackName);
|
|
17441
|
+
if (overlay === void 0) return allowanceMs;
|
|
17442
|
+
const overlaySpanMs = overlay.interleaveDepthMs ?? 0;
|
|
17443
|
+
const overlayWaitMs = overlaySpanMs + Math.max(allowanceMs, overlay.reorderToleranceMs ?? 0);
|
|
17444
|
+
return overlaySpanMs > 0 && overlayWaitMs < waitMs ? overlayWaitMs : void 0;
|
|
17252
17445
|
}
|
|
17253
17446
|
/**
|
|
17254
17447
|
* Bring an open block's wait in to its late-source wait, when it has one.
|
|
@@ -18889,7 +19082,7 @@ var FecReleaseSequencer = class {
|
|
|
18889
19082
|
from
|
|
18890
19083
|
);
|
|
18891
19084
|
unresolved = resolved === null;
|
|
18892
|
-
if (unresolved && !this.#cursorPassed(stream, asUnanchored)) {
|
|
19085
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored) && !this.#unrepairableWaitOver(last, head, from, to)) {
|
|
18893
19086
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
18894
19087
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
18895
19088
|
this.#recordStat("forcedWindowFlushes");
|
|
@@ -18907,6 +19100,11 @@ var FecReleaseSequencer = class {
|
|
|
18907
19100
|
);
|
|
18908
19101
|
}
|
|
18909
19102
|
}
|
|
19103
|
+
/** The head has waited out a gap only a late source can still fill (FecReleaseGate.unrepairableWaitMs). */
|
|
19104
|
+
#unrepairableWaitOver(last, head, from, to) {
|
|
19105
|
+
const waitMs = this.#gate.unrepairableWaitMs?.(last, head, from, to);
|
|
19106
|
+
return waitMs !== void 0 && performance.now() - head.arrivedAtMs >= waitMs;
|
|
19107
|
+
}
|
|
18910
19108
|
/**
|
|
18911
19109
|
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
18912
19110
|
* source cursor holds it unanchored, and neither does a later frame behind
|
|
@@ -25729,6 +25927,26 @@ var MmtpRouter = class {
|
|
|
25729
25927
|
if (!fec?.terminalRetentionMsForPacket) return Infinity;
|
|
25730
25928
|
return fec.terminalRetentionMsForPacket(packetId) ?? 0;
|
|
25731
25929
|
},
|
|
25930
|
+
// Once no repair can fill a gap (FECManager.isoRepairlessWaitMs: only a
|
|
25931
|
+
// late source can), its frame waits the late-symbol allowance when the
|
|
25932
|
+
// gap holds no RAP an installed keyframe overlay could still rebuild:
|
|
25933
|
+
// lost deltas of one MPU (delta-lost), the tail of the MPU before a RAP
|
|
25934
|
+
// that opens the next one while MPU boundaries bound RAPs (rap-next), or
|
|
25935
|
+
// an audio gap. A gap that may hold one (rap-lost, rap-unknown, or any
|
|
25936
|
+
// other rap-next, whose gap may hold a whole MPU and the keyframe the
|
|
25937
|
+
// overlay protects) waits for that overlay's repair too (BLO-52085
|
|
25938
|
+
// D4). The FEC check comes first: most held gaps are not behind such a
|
|
25939
|
+
// span, and deciding one scans both frames' bitstreams.
|
|
25940
|
+
unrepairableWaitMs: (before, after, fromSbn, toSbn) => {
|
|
25941
|
+
const fec = this.#fecManager;
|
|
25942
|
+
const { packetId, catalogTrackName } = after.meta;
|
|
25943
|
+
const allowanceMs = fec?.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn);
|
|
25944
|
+
if (!fec || allowanceMs === void 0) return void 0;
|
|
25945
|
+
const decision = this.#decideGap(before, after, [], false);
|
|
25946
|
+
const mpu = before.meta.mpuSequenceNumber;
|
|
25947
|
+
const intoNextMpu = decision.reason === "rap-next" && mpu !== void 0 && after.meta.mpuSequenceNumber === mpu + 1 >>> 0 && fec.mpuBoundsRapsFor?.(packetId, catalogTrackName) === true;
|
|
25948
|
+
return decision.action === "stall" || decision.reason === "rap-next" && !intoNextMpu ? fec.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn, true) : allowanceMs;
|
|
25949
|
+
},
|
|
25732
25950
|
decide: (before, after, lostBlocks, discontinuity) => {
|
|
25733
25951
|
const decision = this.#decideGap(before, after, lostBlocks, discontinuity);
|
|
25734
25952
|
this.#onFrameGap?.(decision);
|
|
@@ -28701,6 +28919,8 @@ var MulticastManager = class {
|
|
|
28701
28919
|
/** Live joinRepairEndpoints() releases → the repair owners they registered,
|
|
28702
28920
|
* re-applied after configureMultiTrack() clears catalog-derived owners. */
|
|
28703
28921
|
#repairReleases = /* @__PURE__ */ new Map();
|
|
28922
|
+
/** Protected repair flows owned by each live repair-endpoint release. */
|
|
28923
|
+
#repairProvenanceFlows = /* @__PURE__ */ new Map();
|
|
28704
28924
|
/** Each source's catalog keyframe overlay, from its `ok` binding. */
|
|
28705
28925
|
#overlayBindings = /* @__PURE__ */ new Map();
|
|
28706
28926
|
/** Installed overlay decoders (`setKeyframeOverlayDecoder`), by source. */
|
|
@@ -28865,6 +29085,11 @@ var MulticastManager = class {
|
|
|
28865
29085
|
this.#fec.onBlockVanished = (_sbn, packetId, catalogTrackName) => {
|
|
28866
29086
|
this.#statsFor(packetId, catalogTrackName).vanishedBlocks++;
|
|
28867
29087
|
};
|
|
29088
|
+
this.#fec.keyframeOverlayTiming = (packetId, catalogTrackName) => {
|
|
29089
|
+
const binding = this.#overlayInstalls.has(packetId) ? this.#overlayBindings.get(packetId) : void 0;
|
|
29090
|
+
if (binding === void 0) return void 0;
|
|
29091
|
+
return catalogTrackName === void 0 || catalogTrackName === binding.sourceCatalogTrackName ? binding.geometry : void 0;
|
|
29092
|
+
};
|
|
28868
29093
|
this.#fec.onDecoderUnavailable = (event) => {
|
|
28869
29094
|
this.#emitRepairLifecycle({
|
|
28870
29095
|
version: 2,
|
|
@@ -29367,6 +29592,9 @@ var MulticastManager = class {
|
|
|
29367
29592
|
this.#transport.onFailback((reason) => {
|
|
29368
29593
|
const joined = this.#provenanceJoin;
|
|
29369
29594
|
if (joined !== null) this.#router.unprotectProvenanceFlow(joined.flow);
|
|
29595
|
+
for (const flows of this.#repairProvenanceFlows.values()) {
|
|
29596
|
+
for (const flow of flows) this.#router.unprotectProvenanceFlow(flow);
|
|
29597
|
+
}
|
|
29370
29598
|
this.#onFailback?.(reason);
|
|
29371
29599
|
});
|
|
29372
29600
|
}
|
|
@@ -29401,6 +29629,12 @@ var MulticastManager = class {
|
|
|
29401
29629
|
"[MulticastManager] join: provenance flow (S, G, port) must match sourceAddress ?? senderAddress, groupAddress and port"
|
|
29402
29630
|
);
|
|
29403
29631
|
}
|
|
29632
|
+
if (provenanceFlow !== void 0) {
|
|
29633
|
+
const flow = multicastProvenanceFlowKey(provenanceFlow);
|
|
29634
|
+
if ([...this.#repairProvenanceFlows.values()].some((flows) => flows.includes(flow))) {
|
|
29635
|
+
throw new TypeError(`[MulticastManager] join: provenance flow already registered by a repair endpoint: ${flow}`);
|
|
29636
|
+
}
|
|
29637
|
+
}
|
|
29404
29638
|
const staged = this.#renditionSwitch;
|
|
29405
29639
|
if (staged !== null) this.#endRenditionSwitch(staged, { reason: "superseded" }, false);
|
|
29406
29640
|
this.configureFec(config);
|
|
@@ -29408,8 +29642,8 @@ var MulticastManager = class {
|
|
|
29408
29642
|
const selectedPacketIds = config.packetIds?.length ? new Set(config.packetIds) : null;
|
|
29409
29643
|
const catalogTracks = config.tracks?.filter(({ packetId }) => selectedPacketIds === null || selectedPacketIds.has(packetId));
|
|
29410
29644
|
const ingressTracks = catalogTracks ? catalogTracks : selectedPacketIds === null ? void 0 : [...selectedPacketIds].map((packetId) => ({ name: "", packetId }));
|
|
29411
|
-
this.#releaseProvenanceJoin();
|
|
29412
29645
|
const provenance = config.provenance;
|
|
29646
|
+
this.#releaseProvenanceJoin();
|
|
29413
29647
|
const protectedTracks = ingressTracks ?? provenance?.flow.tracks;
|
|
29414
29648
|
const ingress = protectedTracks === void 0 ? void 0 : {
|
|
29415
29649
|
tracks: Object.freeze(
|
|
@@ -29462,8 +29696,13 @@ var MulticastManager = class {
|
|
|
29462
29696
|
* feeds the flow's receiver; media datagrams are held until one admits them.
|
|
29463
29697
|
*/
|
|
29464
29698
|
#joinProvenance(provenance, ingress) {
|
|
29699
|
+
this.#router.registerProvenanceFlow(ingress, this.#provenanceReceiver(provenance));
|
|
29700
|
+
this.#hookFailback();
|
|
29701
|
+
this.#provenanceJoin = { flow: ingress.flow };
|
|
29702
|
+
}
|
|
29703
|
+
#provenanceReceiver(provenance) {
|
|
29465
29704
|
const { flow, auth } = provenance;
|
|
29466
|
-
|
|
29705
|
+
return new BcProvenanceV2Receiver({
|
|
29467
29706
|
...provenance.receiver,
|
|
29468
29707
|
// The caller's ctx when it passes one, else the catalog's: an explicit
|
|
29469
29708
|
// `catalogCtx: undefined` must not switch off the 7.2.4 ctx check.
|
|
@@ -29480,9 +29719,6 @@ var MulticastManager = class {
|
|
|
29480
29719
|
maxAuthDelayMs: flow.maxAuthDelayMs,
|
|
29481
29720
|
manifestTimerMs: flow.manifestTimerMs
|
|
29482
29721
|
});
|
|
29483
|
-
this.#router.registerProvenanceFlow(ingress, receiver);
|
|
29484
|
-
this.#hookFailback();
|
|
29485
|
-
this.#provenanceJoin = { flow: ingress.flow };
|
|
29486
29722
|
}
|
|
29487
29723
|
/** Un-protect: drop the flow's hold queues (no expiry counted). */
|
|
29488
29724
|
#releaseProvenanceJoin() {
|
|
@@ -29513,8 +29749,25 @@ var MulticastManager = class {
|
|
|
29513
29749
|
* callback delivers must come from a subscription opened on
|
|
29514
29750
|
* `options.gateway`. A callback that also merges another source (a MoQ or
|
|
29515
29751
|
* WebSocket repair feed) must not name a native provider here.
|
|
29752
|
+
*
|
|
29753
|
+
* An endpoint's `provenance` makes its group a protected flow of its own
|
|
29754
|
+
* (multicast-02 7.2.7), registered here and released with the group; its
|
|
29755
|
+
* records ride in band on the group's port. On the user-agent path a
|
|
29756
|
+
* flow-less repair group of a protected track is set aside, never read, so
|
|
29757
|
+
* a player joining a protected catalog's repair groups passes it.
|
|
29516
29758
|
*/
|
|
29517
29759
|
joinRepairEndpoints(endpoints, provider, options) {
|
|
29760
|
+
for (const { provenance, flow, source, group, port: port2 } of endpoints) {
|
|
29761
|
+
if (provenance === void 0) continue;
|
|
29762
|
+
if (flow !== void 0) {
|
|
29763
|
+
throw new TypeError("[MulticastManager] joinRepairEndpoints: an endpoint names provenance or flow, never both");
|
|
29764
|
+
}
|
|
29765
|
+
if (!sameIpAddress(source, provenance.flow.source) || !sameIpAddress(group, provenance.flow.groupAddress) || port2 !== provenance.flow.port) {
|
|
29766
|
+
throw new RangeError(
|
|
29767
|
+
"[MulticastManager] joinRepairEndpoints: provenance flow (S, G, port) must match the endpoint's source, group and port"
|
|
29768
|
+
);
|
|
29769
|
+
}
|
|
29770
|
+
}
|
|
29518
29771
|
const releases = [];
|
|
29519
29772
|
let released = false;
|
|
29520
29773
|
const safely = (each) => {
|
|
@@ -29524,17 +29777,36 @@ var MulticastManager = class {
|
|
|
29524
29777
|
console.warn("[MulticastManager] repair group release failed", error);
|
|
29525
29778
|
}
|
|
29526
29779
|
};
|
|
29780
|
+
const usedFlows = /* @__PURE__ */ new Set();
|
|
29781
|
+
const preparedProvenance = endpoints.map((endpoint) => {
|
|
29782
|
+
if (endpoint.provenance === void 0) return void 0;
|
|
29783
|
+
const flow = multicastProvenanceFlowKey(endpoint.provenance.flow);
|
|
29784
|
+
if (usedFlows.has(flow) || this.#provenanceJoin?.flow === flow || [...this.#repairProvenanceFlows.values()].some((flows) => flows.includes(flow))) {
|
|
29785
|
+
throw new TypeError(`[MulticastManager] joinRepairEndpoints: provenance flow already registered: ${flow}`);
|
|
29786
|
+
}
|
|
29787
|
+
usedFlows.add(flow);
|
|
29788
|
+
return { flow, receiver: this.#provenanceReceiver(endpoint.provenance) };
|
|
29789
|
+
});
|
|
29790
|
+
const provenanceFlows = [];
|
|
29527
29791
|
const repairOwners = endpoints.flatMap((endpoint) => endpoint.repairOwners.map((owner) => owner.instance !== "keyframe" ? owner : {
|
|
29528
29792
|
...owner,
|
|
29529
29793
|
ownerTrackName: endpoint.tracks.find((t) => t.packetId === owner.ownerPacketId)?.name,
|
|
29530
29794
|
repairTrackName: endpoint.tracks.find((t) => t.packetId === owner.packetId)?.name
|
|
29531
29795
|
}));
|
|
29532
29796
|
this.#applyRepairOwners(repairOwners);
|
|
29533
|
-
for (const endpoint of endpoints) {
|
|
29797
|
+
for (const [index, endpoint] of endpoints.entries()) {
|
|
29798
|
+
const flow = endpoint.provenance === void 0 ? endpoint.flow : multicastProvenanceFlowKey(endpoint.provenance.flow);
|
|
29534
29799
|
const ingress = {
|
|
29535
29800
|
tracks: Object.freeze(endpoint.tracks.map(({ name, packetId }) => Object.freeze({ name, packetId }))),
|
|
29536
|
-
...
|
|
29801
|
+
...flow === void 0 ? {} : { flow }
|
|
29537
29802
|
};
|
|
29803
|
+
if (endpoint.provenance !== void 0) {
|
|
29804
|
+
const prepared = preparedProvenance[index];
|
|
29805
|
+
if (prepared === void 0) throw new Error("[MulticastManager] repair provenance preparation missing");
|
|
29806
|
+
this.#router.registerProvenanceFlow(ingress, prepared.receiver);
|
|
29807
|
+
provenanceFlows.push(prepared.flow);
|
|
29808
|
+
releases.push(() => this.#router.releaseProvenanceFlow(flow));
|
|
29809
|
+
}
|
|
29538
29810
|
let sender;
|
|
29539
29811
|
const feed = (packet, sourceAddress, ingressToFeed) => {
|
|
29540
29812
|
if (released) return;
|
|
@@ -29564,7 +29836,7 @@ var MulticastManager = class {
|
|
|
29564
29836
|
packetIds: endpoint.packetIds,
|
|
29565
29837
|
tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId })),
|
|
29566
29838
|
// A protected repair group's records ride in band on its port (7.2.3).
|
|
29567
|
-
...
|
|
29839
|
+
...flow === void 0 ? {} : { protected: true }
|
|
29568
29840
|
}, ingress).then((joined) => {
|
|
29569
29841
|
if (!joined && !released) fail(transport.lastJoinOutcome);
|
|
29570
29842
|
});
|
|
@@ -29573,9 +29845,12 @@ var MulticastManager = class {
|
|
|
29573
29845
|
if (released) return;
|
|
29574
29846
|
released = true;
|
|
29575
29847
|
this.#repairReleases.delete(release);
|
|
29848
|
+
this.#repairProvenanceFlows.delete(release);
|
|
29576
29849
|
for (const each of releases.splice(0)) safely(each);
|
|
29577
29850
|
};
|
|
29578
29851
|
this.#repairReleases.set(release, repairOwners);
|
|
29852
|
+
this.#repairProvenanceFlows.set(release, provenanceFlows);
|
|
29853
|
+
if (provenanceFlows.length) this.#hookFailback();
|
|
29579
29854
|
return release;
|
|
29580
29855
|
}
|
|
29581
29856
|
#applyRepairOwners(owners) {
|
|
@@ -30061,7 +30336,8 @@ var MulticastManager = class {
|
|
|
30061
30336
|
blockProfile: parseFecBlockProfile(
|
|
30062
30337
|
geometry2.blockProfile,
|
|
30063
30338
|
`tracks[${JSON.stringify(track.name)}].fec keyframe overlay blockProfile`
|
|
30064
|
-
)
|
|
30339
|
+
),
|
|
30340
|
+
geometry: geometry2
|
|
30065
30341
|
});
|
|
30066
30342
|
}
|
|
30067
30343
|
}
|
|
@@ -30100,7 +30376,7 @@ var MulticastManager = class {
|
|
|
30100
30376
|
for (const [sourcePacketId, install] of [...this.#overlayInstalls]) {
|
|
30101
30377
|
const before = this.#overlayBindings.get(sourcePacketId);
|
|
30102
30378
|
const after = overlayBindings.get(sourcePacketId);
|
|
30103
|
-
const same = before !== void 0 && after !== void 0 && Object.keys(after).every((key) => after[key] === before[key]);
|
|
30379
|
+
const same = before !== void 0 && after !== void 0 && Object.keys(after).every((key) => key === "geometry" || after[key] === before[key]);
|
|
30104
30380
|
if (!same) install.dispose();
|
|
30105
30381
|
else if (this.#router.hasKeyframeOverlay(after.repairPacketId)) this.#router.resetKeyframeOverlays(sourcePacketId);
|
|
30106
30382
|
else install.reattach();
|
|
@@ -33144,7 +33420,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
33144
33420
|
if (!run) return;
|
|
33145
33421
|
entry.running = null;
|
|
33146
33422
|
run.stopped = reason;
|
|
33147
|
-
run.controller.abort();
|
|
33423
|
+
run.controller.abort(reason);
|
|
33148
33424
|
if (reason === "preempted") releaseHold(entry);
|
|
33149
33425
|
mc.noteRepairStopped?.(reason, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
33150
33426
|
};
|
|
@@ -33442,7 +33718,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
33442
33718
|
if (entries.get(requestKey(sbn, entry.packetId, entry.catalogTrackName))?.running == null) {
|
|
33443
33719
|
const rsIds = /* @__PURE__ */ new Set();
|
|
33444
33720
|
const group = new AbortController();
|
|
33445
|
-
const cancel = () => group.abort();
|
|
33721
|
+
const cancel = () => group.abort(common.signal.reason);
|
|
33446
33722
|
common.signal.addEventListener("abort", cancel, { once: true });
|
|
33447
33723
|
walk.group = { sbn, controller: group };
|
|
33448
33724
|
try {
|