@blockcast/mmt-container 2.2.0-main.7e8a9d13c01c → 2.2.0-main.8cff791d86f5
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 +374 -29
- package/dist/browser-runtime.js.map +3 -3
- package/dist/carp-catalog.js.map +2 -2
- package/dist/catalog-fec-params.d.ts +1 -1
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +14 -1
- package/dist/catalog-fec-params.js.map +2 -2
- package/dist/catalog-network-source.js.map +2 -2
- 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.map +2 -2
- package/dist/delta-fallback-config.js +5 -1
- package/dist/delta-fallback-config.js.map +3 -3
- package/dist/fec-manager.d.ts +44 -3
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +141 -14
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-state.js +5 -1
- package/dist/fec-state.js.map +2 -2
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts +27 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +106 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +126 -5
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +106 -2
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.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 +149 -2
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-auth-catalog.js.map +2 -2
- package/dist/multicast-input.js.map +2 -2
- package/dist/multicast-manager.d.ts +13 -0
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +363 -27
- package/dist/multicast-manager.js.map +3 -3
- package/dist/multicast-transport.js.map +2 -2
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +1 -0
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +128 -6
- package/dist/no-modules.js.map +4 -4
- 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/repair-layer-subscriptions.js.map +2 -2
- package/dist/signaling.js.map +2 -2
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +106 -2
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/catalog-fec-params.ts +1 -0
- package/src/codec-utils.ts +121 -1
- package/src/fec-manager.ts +185 -14
- package/src/index.ts +2 -0
- package/src/mmtp-container-parser.ts +55 -11
- package/src/mmtp-router.ts +56 -0
- package/src/multicast-manager.ts +92 -10
- package/src/no-modules.ts +3 -0
- package/src/repair-fetch.ts +4 -2
package/dist/browser-runtime.js
CHANGED
|
@@ -1797,13 +1797,25 @@ function fecCatalogTracks(catalog) {
|
|
|
1797
1797
|
});
|
|
1798
1798
|
return { tracks, pointers };
|
|
1799
1799
|
}
|
|
1800
|
-
function
|
|
1800
|
+
function runtimeView(catalog, receiver) {
|
|
1801
1801
|
const { tracks, pointers } = fecCatalogTracks(catalog);
|
|
1802
1802
|
const report = validateFecCatalog({ tracks }, receiver);
|
|
1803
1803
|
const at2 = (path) => {
|
|
1804
1804
|
const m = /^\/tracks\/(\d+)(.*)$/.exec(path);
|
|
1805
1805
|
return m ? pointers[Number(m[1])] + m[2] : path;
|
|
1806
1806
|
};
|
|
1807
|
+
return { tracks, pointers, report, at: at2 };
|
|
1808
|
+
}
|
|
1809
|
+
function runtimeFecCatalogReport(catalog, receiver = RUNTIME_FEC_RECEIVER) {
|
|
1810
|
+
const { report, at: at2 } = runtimeView(catalog, receiver);
|
|
1811
|
+
const issue = (i) => Object.freeze({ code: i.code, path: at2(i.path) });
|
|
1812
|
+
return Object.freeze({
|
|
1813
|
+
instances: Object.freeze(report.instances.map((i) => Object.freeze({ ...i, path: at2(i.path), issues: Object.freeze(i.issues.map(issue)) }))),
|
|
1814
|
+
issues: Object.freeze(report.issues.map(issue))
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
function resolveFecBindings(catalog, receiver = RUNTIME_FEC_RECEIVER) {
|
|
1818
|
+
const { tracks, pointers, report, at: at2 } = runtimeView(catalog, receiver);
|
|
1807
1819
|
const trackAt = (i) => recordOf(tracks[i]) ?? {};
|
|
1808
1820
|
const nameAt = (i) => i === null ? void 0 : trackAt(i)["name"];
|
|
1809
1821
|
const why = (i) => Object.freeze({
|
|
@@ -6099,9 +6111,10 @@ function isH264IntraSlice(nal) {
|
|
|
6099
6111
|
const sliceType = readH264SliceType(nal);
|
|
6100
6112
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
6101
6113
|
}
|
|
6114
|
+
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
6102
6115
|
function readH264SliceType(nal) {
|
|
6103
6116
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
6104
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
6117
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
|
|
6105
6118
|
const state = { bitOffset: 0 };
|
|
6106
6119
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
6107
6120
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -6470,6 +6483,96 @@ if (void 0) {
|
|
|
6470
6483
|
]))).toBe(false);
|
|
6471
6484
|
});
|
|
6472
6485
|
});
|
|
6486
|
+
describe("readH264SliceType", () => {
|
|
6487
|
+
const wholeNalSliceType = (nal) => {
|
|
6488
|
+
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
6489
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
6490
|
+
const state = { bitOffset: 0 };
|
|
6491
|
+
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
6492
|
+
return readUnsignedExpGolomb(rbsp, state);
|
|
6493
|
+
};
|
|
6494
|
+
const hex3 = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
|
|
6495
|
+
const ue = (value) => {
|
|
6496
|
+
const code = (value + 1).toString(2);
|
|
6497
|
+
return "0".repeat(code.length - 1) + code;
|
|
6498
|
+
};
|
|
6499
|
+
const sliceNal = (bits) => {
|
|
6500
|
+
const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
|
|
6501
|
+
const nal = [1];
|
|
6502
|
+
let zeros = 0;
|
|
6503
|
+
for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
|
|
6504
|
+
if (zeros >= 2 && byte <= 3) {
|
|
6505
|
+
nal.push(3);
|
|
6506
|
+
zeros = 0;
|
|
6507
|
+
}
|
|
6508
|
+
nal.push(byte);
|
|
6509
|
+
zeros = byte === 0 ? zeros + 1 : 0;
|
|
6510
|
+
}
|
|
6511
|
+
return Uint8Array.from(nal);
|
|
6512
|
+
};
|
|
6513
|
+
const x264Slices = [
|
|
6514
|
+
["64x48 P", hex3("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
|
|
6515
|
+
["64x48 B", hex3("419e414212fffeeade283707cb70f7"), 6, false],
|
|
6516
|
+
["64x48 non-IDR I", hex3(
|
|
6517
|
+
"4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
|
|
6518
|
+
), 7, true],
|
|
6519
|
+
["1280x720 B, escape at byte 10", hex3(
|
|
6520
|
+
"01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
|
|
6521
|
+
), 6, false],
|
|
6522
|
+
["1280x720 P, escape at byte 15", hex3(
|
|
6523
|
+
"41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
|
|
6524
|
+
), 5, false],
|
|
6525
|
+
["1280x720 B, escape at byte 22", hex3("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
|
|
6526
|
+
["7680x4320 IDR, first_mb_in_slice 97440", hex3(
|
|
6527
|
+
"650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
|
|
6528
|
+
), null, true],
|
|
6529
|
+
["7680x4320 P, first_mb_in_slice 32640", hex3(
|
|
6530
|
+
"410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
|
|
6531
|
+
), 5, false],
|
|
6532
|
+
["7680x4320 P, first_mb_in_slice 97440", hex3(
|
|
6533
|
+
"410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
|
|
6534
|
+
), 5, false]
|
|
6535
|
+
];
|
|
6536
|
+
const syntheticSlices = [
|
|
6537
|
+
["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
|
|
6538
|
+
["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
|
|
6539
|
+
["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
|
|
6540
|
+
["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
|
|
6541
|
+
["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
|
|
6542
|
+
["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
|
|
6543
|
+
["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
|
|
6544
|
+
["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
|
|
6545
|
+
];
|
|
6546
|
+
test("reads the slice_type of real and synthetic slices", () => {
|
|
6547
|
+
for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
|
|
6548
|
+
expect(readH264SliceType(nal), name).toBe(sliceType);
|
|
6549
|
+
}
|
|
6550
|
+
});
|
|
6551
|
+
test("matches the whole-NAL unescape at every truncation", () => {
|
|
6552
|
+
for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
|
|
6553
|
+
for (let end = 0; end <= nal.length; end++) {
|
|
6554
|
+
const cut = nal.subarray(0, end);
|
|
6555
|
+
expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
|
|
6556
|
+
}
|
|
6557
|
+
}
|
|
6558
|
+
});
|
|
6559
|
+
test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
|
|
6560
|
+
const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
|
|
6561
|
+
let seed = 1;
|
|
6562
|
+
const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
|
|
6563
|
+
for (let i = 0; i < 5e3; i++) {
|
|
6564
|
+
const nal = new Uint8Array(2 + next() % 63);
|
|
6565
|
+
nal[0] = 65;
|
|
6566
|
+
for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
|
|
6567
|
+
expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
|
|
6568
|
+
}
|
|
6569
|
+
});
|
|
6570
|
+
test("classifies the x264 slices as keyframes or not", () => {
|
|
6571
|
+
for (const [name, nal, , keyframe] of x264Slices) {
|
|
6572
|
+
expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
|
|
6573
|
+
}
|
|
6574
|
+
});
|
|
6575
|
+
});
|
|
6473
6576
|
describe("avccToAnnexB", () => {
|
|
6474
6577
|
test("converts with SPS/PPS on keyframe", () => {
|
|
6475
6578
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|
|
@@ -14041,7 +14144,8 @@ var FECManager = class _FECManager {
|
|
|
14041
14144
|
this.#ssbLengthConflictCount = 0;
|
|
14042
14145
|
this.#blockRepairRsIds = /* @__PURE__ */ new Map();
|
|
14043
14146
|
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
14044
|
-
// symbols its repair group carries
|
|
14147
|
+
// symbols its repair group carries; 0 for a repair-less span no repair can
|
|
14148
|
+
// state (#openIsoSpan). Same lifecycle as #blockRepairRsIds.
|
|
14045
14149
|
this.#blockRsbLengths = /* @__PURE__ */ new Map();
|
|
14046
14150
|
/** fec-01 6.3.9 anchor state per stream key, one entry per held layer. */
|
|
14047
14151
|
this.#heldLayerStates = /* @__PURE__ */ new Map();
|
|
@@ -14229,6 +14333,7 @@ var FECManager = class _FECManager {
|
|
|
14229
14333
|
this.#workerErrorCounts = /* @__PURE__ */ new Map();
|
|
14230
14334
|
this.#decoderUnavailableEvents = 0;
|
|
14231
14335
|
this.#repairSymbolSizeMismatchCount = 0;
|
|
14336
|
+
this.#unlistedRepairTrackRefusals = 0;
|
|
14232
14337
|
// Event callbacks — block lifecycle notifications for MmtpRouter wiring.
|
|
14233
14338
|
// NOTE: For sync WASM path, recovery routing is handled by MmtpRouter from
|
|
14234
14339
|
// feedSourceSymbol/feedRepairSymbol return values. For Worker path, recovery
|
|
@@ -14288,6 +14393,16 @@ var FECManager = class _FECManager {
|
|
|
14288
14393
|
this.onBlockResolved = null;
|
|
14289
14394
|
/** A stream's SBN went backwards (or jumped implausibly): the source restarted. */
|
|
14290
14395
|
this.onSourceDiscontinuity = null;
|
|
14396
|
+
/**
|
|
14397
|
+
* The span and tolerance the catalog states for a keyframe overlay
|
|
14398
|
+
* installed over a source track (draft-ramadan-moq-mmt-02 7.4.1: the
|
|
14399
|
+
* overlay instance's own interleaveDepthMs and reorderToleranceMs), or
|
|
14400
|
+
* undefined while none is installed. A stated block only a late source
|
|
14401
|
+
* can complete, and a frame whose gap may hide a RAP behind a span only a
|
|
14402
|
+
* late source can fill, also wait for that overlay's repair
|
|
14403
|
+
* (#overlayLateWaitMs).
|
|
14404
|
+
*/
|
|
14405
|
+
this.keyframeOverlayTiming = null;
|
|
14291
14406
|
// Worker-path callbacks — async recovery and stats from FecWorkerClient.
|
|
14292
14407
|
/**
|
|
14293
14408
|
* A recovered source symbol. Return false when admission refused the
|
|
@@ -14392,6 +14507,7 @@ var FECManager = class _FECManager {
|
|
|
14392
14507
|
#workerErrorCounts;
|
|
14393
14508
|
#decoderUnavailableEvents;
|
|
14394
14509
|
#repairSymbolSizeMismatchCount;
|
|
14510
|
+
#unlistedRepairTrackRefusals;
|
|
14395
14511
|
#onUndelimitedLoss;
|
|
14396
14512
|
#onIsoHoleExpired;
|
|
14397
14513
|
#encodeTrackName(catalogTrackName) {
|
|
@@ -15560,6 +15676,7 @@ var FECManager = class _FECManager {
|
|
|
15560
15676
|
packetId
|
|
15561
15677
|
})),
|
|
15562
15678
|
repairSymbolSizeMismatches: this.#repairSymbolSizeMismatchCount,
|
|
15679
|
+
unlistedRepairTrackRefusals: this.#unlistedRepairTrackRefusals,
|
|
15563
15680
|
repairObjectRejects: [...this.#repairObjectRejects.values()].map((r) => ({ ...r })),
|
|
15564
15681
|
workerErrors: Object.fromEntries(this.#workerErrorCounts)
|
|
15565
15682
|
};
|
|
@@ -16064,8 +16181,10 @@ var FECManager = class _FECManager {
|
|
|
16064
16181
|
}
|
|
16065
16182
|
/**
|
|
16066
16183
|
* 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
|
-
*
|
|
16184
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it; a
|
|
16185
|
+
* repair-less span states its length, and RSB_length 0 when it is longer
|
|
16186
|
+
* than K, since no repair can reach it). Undefined for a block that is not
|
|
16187
|
+
* open.
|
|
16069
16188
|
*/
|
|
16070
16189
|
blockSymbolCounts(sbn, packetId, catalogTrackName) {
|
|
16071
16190
|
const key = this.#blockKey(sbn, packetId, catalogTrackName);
|
|
@@ -16181,7 +16300,7 @@ var FECManager = class _FECManager {
|
|
|
16181
16300
|
}
|
|
16182
16301
|
const trackConfig = this.#trackConfigs.get(packetId);
|
|
16183
16302
|
if (trackConfig === void 0) return void 0;
|
|
16184
|
-
return Math.max(1, trackConfig
|
|
16303
|
+
return Math.max(1, this.#repairGraceMs(trackConfig, this.#multicastWaitMs(trackConfig)));
|
|
16185
16304
|
}
|
|
16186
16305
|
/** True once configureTrack/setFecDecoder/setFecWorker configured this packetId. */
|
|
16187
16306
|
// -----------------------------------------------------------------------
|
|
@@ -16367,12 +16486,24 @@ var FECManager = class _FECManager {
|
|
|
16367
16486
|
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
16368
16487
|
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
16369
16488
|
* block.
|
|
16489
|
+
*
|
|
16490
|
+
* A span longer than K holds more than one block (SSB_length <= K), and the
|
|
16491
|
+
* locator states no block inside a span, only one exactly its range
|
|
16492
|
+
* (IsoBlockLocator.placeRepair): no repair, multicast or FETCHed, can ever
|
|
16493
|
+
* reach it. Its repair group is empty, so the repair scheduler FETCHes no
|
|
16494
|
+
* Group of it (group-cannot-complete). Every span still keeps its whole
|
|
16495
|
+
* wait (#lateSourceWaitMs): failing it early released the frames behind it
|
|
16496
|
+
* past a keyframe the overlay was still rebuilding (BLO-52085). The release
|
|
16497
|
+
* gate lets those frames go once only a late source can fill the gap
|
|
16498
|
+
* before them, as long after they arrived as the gap's decision allows
|
|
16499
|
+
* (isoRepairlessWaitMs).
|
|
16370
16500
|
*/
|
|
16371
16501
|
#openIsoSpan(span, packetId, catalogTrackName) {
|
|
16372
16502
|
const key = this.#blockKey(span.block.start, packetId, catalogTrackName);
|
|
16373
16503
|
if (!this.#blockAuthoredLengths.has(key)) {
|
|
16374
16504
|
this.#blockAuthoredLengths.set(key, span.block.length);
|
|
16375
16505
|
this.#isoSpanKeys.add(key);
|
|
16506
|
+
if (span.block.length > this.#isoLocatorFor(packetId, catalogTrackName).kMax) this.#blockRsbLengths.set(key, 0);
|
|
16376
16507
|
}
|
|
16377
16508
|
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true);
|
|
16378
16509
|
}
|
|
@@ -16411,6 +16542,62 @@ var FECManager = class _FECManager {
|
|
|
16411
16542
|
}
|
|
16412
16543
|
return lost;
|
|
16413
16544
|
}
|
|
16545
|
+
/**
|
|
16546
|
+
* The release gate's wait, from a frame's arrival, for the SS_IDs strictly
|
|
16547
|
+
* between two released frames' SS_IDs once only a late source can still
|
|
16548
|
+
* fill them, else undefined. That is when every one missing (neither
|
|
16549
|
+
* arrived nor held) lies in a repair-less span longer than K, which no
|
|
16550
|
+
* repair can state a block of (#openIsoSpan), or in a stated block its
|
|
16551
|
+
* own repair group cannot complete every SS_ID of which it misses lies
|
|
16552
|
+
* between them (so the gap's decision covers all it lost), and a multicast
|
|
16553
|
+
* source at or past `toSsId` arrived, so each is lost or reordered behind
|
|
16554
|
+
* it (a MoQ source shows nothing: MoQ streams overtake one another). The
|
|
16555
|
+
* span or block itself keeps its own wait.
|
|
16556
|
+
*
|
|
16557
|
+
* The wait is the late-symbol allowance, unless `rapMayHide`: the gap may
|
|
16558
|
+
* hold a RAP packet an installed keyframe overlay can still rebuild (its
|
|
16559
|
+
* decision stalls, or it ends at a RAP that may lie past a whole MPU).
|
|
16560
|
+
* Then the frame waits as a stated block its group cannot complete does
|
|
16561
|
+
* (#overlayLateWaitMs): the allowance alone with no overlay installed, the
|
|
16562
|
+
* overlay's span plus the larger of the allowance and its tolerance, or,
|
|
16563
|
+
* for an overlay that states no span, the span's whole wait (undefined).
|
|
16564
|
+
* So does `rapNext` (the gap ends at the RAP that opens the next MPU) when
|
|
16565
|
+
* the gap holds a stated block's loss.
|
|
16566
|
+
*/
|
|
16567
|
+
isoRepairlessWaitMs(packetId, catalogTrackName, fromSsId, toSsId, rapMayHide = false, rapNext = false) {
|
|
16568
|
+
const config = this.#trackConfigs.get(packetId);
|
|
16569
|
+
if (config === void 0 || !_FECManager.#hasCatalogTiming(config)) return void 0;
|
|
16570
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
|
|
16571
|
+
if (locator === void 0 || !locator.coversBetween(fromSsId, toSsId)) return void 0;
|
|
16572
|
+
const newestSource = locator.newestSource;
|
|
16573
|
+
if (newestSource === void 0 || serial32Precedes(newestSource, toSsId)) return void 0;
|
|
16574
|
+
let repairless = false;
|
|
16575
|
+
let stated = false;
|
|
16576
|
+
for (const block of locator.blocksBetween(fromSsId, toSsId)) {
|
|
16577
|
+
const key = this.#blockKey(block.start, packetId, catalogTrackName);
|
|
16578
|
+
if (this.#completedBlocks.has(key)) continue;
|
|
16579
|
+
if (block.span && block.length > locator.kMax) {
|
|
16580
|
+
repairless = true;
|
|
16581
|
+
continue;
|
|
16582
|
+
}
|
|
16583
|
+
const received = this.#blockSourceEsis.get(key);
|
|
16584
|
+
const rebuilt = this.#blockRebuiltEsis.get(key);
|
|
16585
|
+
let missesInGap = false;
|
|
16586
|
+
let missesOutside = false;
|
|
16587
|
+
for (let esi = 0; esi < block.length; esi++) {
|
|
16588
|
+
const ssId = serial32Add(block.start, esi);
|
|
16589
|
+
if (received?.has(esi) || locator.isHeld(ssId)) continue;
|
|
16590
|
+
if (serial32Precedes(fromSsId, ssId) && serial32Precedes(ssId, toSsId)) missesInGap = true;
|
|
16591
|
+
else if (!rebuilt?.has(esi)) missesOutside = true;
|
|
16592
|
+
}
|
|
16593
|
+
if (!missesInGap) continue;
|
|
16594
|
+
if (missesOutside || block.span || !this.#groupCannotComplete(key)) return void 0;
|
|
16595
|
+
repairless = stated = true;
|
|
16596
|
+
}
|
|
16597
|
+
if (!repairless) return void 0;
|
|
16598
|
+
const waitMs = rapMayHide || stated && rapNext ? this.#overlayLateWaitMs(packetId, catalogTrackName, config) : this.#multicastWaitMs(config) - config.interleaveDepthMs;
|
|
16599
|
+
return waitMs === void 0 ? void 0 : Math.max(0, waitMs);
|
|
16600
|
+
}
|
|
16414
16601
|
/**
|
|
16415
16602
|
* iso-ssbg1-v1 block location: repair symbols it refused, oversize sources,
|
|
16416
16603
|
* the sources held now for a block no repair has stated yet, and the held
|
|
@@ -17059,7 +17246,10 @@ var FECManager = class _FECManager {
|
|
|
17059
17246
|
this.#layerAnchorHorizon(packetId),
|
|
17060
17247
|
this.#sourceFrontiers.get(streamKey)?.sbn
|
|
17061
17248
|
);
|
|
17062
|
-
if (verdict === "discard")
|
|
17249
|
+
if (verdict === "discard") {
|
|
17250
|
+
this.#unlistedRepairTrackRefusals++;
|
|
17251
|
+
return false;
|
|
17252
|
+
}
|
|
17063
17253
|
if (verdict !== void 0) {
|
|
17064
17254
|
this.#failClosed(streamKey, verdict, packetId, catalogTrackName);
|
|
17065
17255
|
return false;
|
|
@@ -17216,7 +17406,7 @@ var FECManager = class _FECManager {
|
|
|
17216
17406
|
const previous = locator.newestSource;
|
|
17217
17407
|
if (!locator.noteSource(ssId) || previous === void 0) return;
|
|
17218
17408
|
for (const block of locator.blocksBetween(previous - 1 >>> 0, ssId)) {
|
|
17219
|
-
if (
|
|
17409
|
+
if (!serial32Precedes(serial32Add(block.start, block.length - 1), ssId)) continue;
|
|
17220
17410
|
this.#shortenUnrecoverableWait(
|
|
17221
17411
|
this.#blockKey(block.start, packetId, catalogTrackName),
|
|
17222
17412
|
block.start,
|
|
@@ -17234,21 +17424,61 @@ var FECManager = class _FECManager {
|
|
|
17234
17424
|
* covers repair symbols paced after its sources, buys it nothing: it waits
|
|
17235
17425
|
* the late-symbol allowance alone, the multicast wait less the span (the
|
|
17236
17426
|
* catalog tolerance or the measured delivery gap). Undefined for any other
|
|
17237
|
-
* block.
|
|
17427
|
+
* block. While a keyframe overlay is installed, the block waits for its
|
|
17428
|
+
* repair too (#overlayLateWaitMs). A repair-less span keeps its whole
|
|
17429
|
+
* wait, even one longer than K whose group is empty (#openIsoSpan): its
|
|
17430
|
+
* resolution is what releases the frames behind it, and failing it early
|
|
17431
|
+
* released them past a keyframe the overlay was still rebuilding, which
|
|
17432
|
+
* then arrived stale. The release gate lets them go instead
|
|
17433
|
+
* (isoRepairlessWaitMs).
|
|
17238
17434
|
*/
|
|
17239
17435
|
#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) {
|
|
17436
|
+
if (this.#isoSpanKeys.has(key) || !this.#groupCannotComplete(key)) return void 0;
|
|
17240
17437
|
const authoredLength = this.#blockAuthoredLengths.get(key);
|
|
17241
|
-
const rsbLength = this.#blockRsbLengths.get(key);
|
|
17242
|
-
if (authoredLength === void 0 || rsbLength === void 0) return void 0;
|
|
17243
|
-
let present = this.#blockSourceCounts.get(key) ?? 0;
|
|
17244
|
-
const received = this.#blockSourceEsis.get(key);
|
|
17245
|
-
for (const esi of this.#blockRebuiltEsis.get(key) ?? []) if (!received?.has(esi)) present++;
|
|
17246
|
-
if (present + rsbLength >= authoredLength) return void 0;
|
|
17247
17438
|
const newestSource = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))?.newestSource;
|
|
17248
17439
|
if (newestSource === void 0 || !serial32Precedes(serial32Add(sbn, authoredLength - 1), newestSource)) {
|
|
17249
17440
|
return void 0;
|
|
17250
17441
|
}
|
|
17251
|
-
return this.#
|
|
17442
|
+
return this.#overlayLateWaitMs(packetId, catalogTrackName, config);
|
|
17443
|
+
}
|
|
17444
|
+
/**
|
|
17445
|
+
* A repair stated the block, and its sources plus every symbol its repair
|
|
17446
|
+
* group carries (RSB_length) are short of its SSB_length.
|
|
17447
|
+
*/
|
|
17448
|
+
#groupCannotComplete(key) {
|
|
17449
|
+
const authoredLength = this.#blockAuthoredLengths.get(key);
|
|
17450
|
+
const rsbLength = this.#blockRsbLengths.get(key);
|
|
17451
|
+
if (authoredLength === void 0 || rsbLength === void 0) return false;
|
|
17452
|
+
let present = this.#blockSourceCounts.get(key) ?? 0;
|
|
17453
|
+
const received = this.#blockSourceEsis.get(key);
|
|
17454
|
+
for (const esi of this.#blockRebuiltEsis.get(key) ?? []) if (!received?.has(esi)) present++;
|
|
17455
|
+
return present + rsbLength < authoredLength;
|
|
17456
|
+
}
|
|
17457
|
+
/**
|
|
17458
|
+
* How long a loss only a late source or an installed keyframe overlay can
|
|
17459
|
+
* still fill waits once a later source passed it: the late-symbol
|
|
17460
|
+
* allowance alone (the multicast wait less the span) while no overlay is
|
|
17461
|
+
* installed. An installed one (keyframeOverlayTiming) may still rebuild a
|
|
17462
|
+
* RAP packet the loss took: a second FEC instance over the same packets
|
|
17463
|
+
* (draft-ramadan-moq-mmt-02 7.4), whose repair is paced across its own
|
|
17464
|
+
* span, unrelated to the base's. That packet can complete a stated block
|
|
17465
|
+
* (feedRebuiltSourceSymbol), or play behind a span; giving the loss up
|
|
17466
|
+
* first lets the release gate pass the keyframe, whose rebuild then lands
|
|
17467
|
+
* stale. The overlay repair of a packet the loss took goes out within the
|
|
17468
|
+
* overlay's span of that packet (fec-core-00 9.3), and the later source was
|
|
17469
|
+
* sent after it, so the loss waits that span plus the larger of the
|
|
17470
|
+
* allowance and the overlay's own tolerance. An overlay that states no
|
|
17471
|
+
* span (its block may then span keyframes), or one whose wait is not
|
|
17472
|
+
* shorter than the whole multicast wait, leaves the whole wait: undefined.
|
|
17473
|
+
*/
|
|
17474
|
+
#overlayLateWaitMs(packetId, catalogTrackName, config) {
|
|
17475
|
+
const waitMs = this.#multicastWaitMs(config);
|
|
17476
|
+
const allowanceMs = waitMs - config.interleaveDepthMs;
|
|
17477
|
+
const overlay = this.keyframeOverlayTiming?.(packetId, catalogTrackName);
|
|
17478
|
+
if (overlay === void 0) return allowanceMs;
|
|
17479
|
+
const overlaySpanMs = overlay.interleaveDepthMs ?? 0;
|
|
17480
|
+
const overlayWaitMs = overlaySpanMs + Math.max(allowanceMs, overlay.reorderToleranceMs ?? 0);
|
|
17481
|
+
return overlaySpanMs > 0 && overlayWaitMs < waitMs ? overlayWaitMs : void 0;
|
|
17252
17482
|
}
|
|
17253
17483
|
/**
|
|
17254
17484
|
* Bring an open block's wait in to its late-source wait, when it has one.
|
|
@@ -18889,7 +19119,7 @@ var FecReleaseSequencer = class {
|
|
|
18889
19119
|
from
|
|
18890
19120
|
);
|
|
18891
19121
|
unresolved = resolved === null;
|
|
18892
|
-
if (unresolved && !this.#cursorPassed(stream, asUnanchored)) {
|
|
19122
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored) && !this.#unrepairableWaitOver(stream, last, head, from, to)) {
|
|
18893
19123
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
18894
19124
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
18895
19125
|
this.#recordStat("forcedWindowFlushes");
|
|
@@ -18907,6 +19137,19 @@ var FecReleaseSequencer = class {
|
|
|
18907
19137
|
);
|
|
18908
19138
|
}
|
|
18909
19139
|
}
|
|
19140
|
+
/**
|
|
19141
|
+
* The head has waited out a gap only a late source can still fill
|
|
19142
|
+
* (FecReleaseGate.unrepairableWaitMs). Not yet: the gate is asked to poke
|
|
19143
|
+
* the stream when it has (`wakeAt`), since no packet may come by then.
|
|
19144
|
+
*/
|
|
19145
|
+
#unrepairableWaitOver(stream, last, head, from, to) {
|
|
19146
|
+
const waitMs = this.#gate.unrepairableWaitMs?.(last, head, from, to);
|
|
19147
|
+
if (waitMs === void 0) return false;
|
|
19148
|
+
const atMs = head.arrivedAtMs + waitMs;
|
|
19149
|
+
if (performance.now() >= atMs) return true;
|
|
19150
|
+
this.#gate.wakeAt?.(stream.packetId, stream.catalogTrackName, atMs);
|
|
19151
|
+
return false;
|
|
19152
|
+
}
|
|
18910
19153
|
/**
|
|
18911
19154
|
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
18912
19155
|
* source cursor holds it unanchored, and neither does a later frame behind
|
|
@@ -23488,6 +23731,8 @@ var MmtpRouter = class {
|
|
|
23488
23731
|
// end: a synchronous recovery completes its block BEFORE routing the
|
|
23489
23732
|
// recovered frames, and releasing a held gap in between would strand them.
|
|
23490
23733
|
#fecPokeDepth = 0;
|
|
23734
|
+
/** FecReleaseGate.wakeAt timers, by media stream key. */
|
|
23735
|
+
#fecWakes = /* @__PURE__ */ new Map();
|
|
23491
23736
|
#pendingFecPokes = /* @__PURE__ */ new Map();
|
|
23492
23737
|
// ── Phase 14: per-role packetId dispatch (D-26, D-27, D-28) ───────
|
|
23493
23738
|
/** Maps packetId → TrackRole. Default: 'single' when absent (legacy path). */
|
|
@@ -25548,6 +25793,8 @@ var MmtpRouter = class {
|
|
|
25548
25793
|
this.#disposed = true;
|
|
25549
25794
|
this.#staged = null;
|
|
25550
25795
|
this.cancelKeyframeLostTimer();
|
|
25796
|
+
for (const { timer } of this.#fecWakes.values()) clearTimeout(timer);
|
|
25797
|
+
this.#fecWakes.clear();
|
|
25551
25798
|
this.#parser.dispose();
|
|
25552
25799
|
this.#streams.clear();
|
|
25553
25800
|
this.#trackPacketCallbacks.clear();
|
|
@@ -25729,6 +25976,31 @@ var MmtpRouter = class {
|
|
|
25729
25976
|
if (!fec?.terminalRetentionMsForPacket) return Infinity;
|
|
25730
25977
|
return fec.terminalRetentionMsForPacket(packetId) ?? 0;
|
|
25731
25978
|
},
|
|
25979
|
+
// Once no repair can fill a gap (FECManager.isoRepairlessWaitMs: only a
|
|
25980
|
+
// late source can), its frame waits the late-symbol allowance when the
|
|
25981
|
+
// gap holds no RAP an installed keyframe overlay could still rebuild:
|
|
25982
|
+
// lost deltas of one MPU (delta-lost), the tail of the MPU before a RAP
|
|
25983
|
+
// that opens the next one while MPU boundaries bound RAPs (rap-next,
|
|
25984
|
+
// unless the gap holds a stated block's loss: the overlay may rebuild
|
|
25985
|
+
// that MPU's FT=0, and the block's group then complete it), or
|
|
25986
|
+
// an audio gap. A gap that may hold one (rap-lost, rap-unknown, or any
|
|
25987
|
+
// other rap-next, whose gap may hold a whole MPU and the keyframe the
|
|
25988
|
+
// overlay protects) waits for that overlay's repair too (BLO-52085
|
|
25989
|
+
// D4). The FEC check comes first: most held gaps are not behind such a
|
|
25990
|
+
// span, and deciding one scans both frames' bitstreams.
|
|
25991
|
+
unrepairableWaitMs: (before, after, fromSbn, toSbn) => {
|
|
25992
|
+
const fec = this.#fecManager;
|
|
25993
|
+
const { packetId, catalogTrackName } = after.meta;
|
|
25994
|
+
const allowanceMs = fec?.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn);
|
|
25995
|
+
if (!fec || allowanceMs === void 0) return void 0;
|
|
25996
|
+
const decision = this.#decideGap(before, after, [], false);
|
|
25997
|
+
const mpu = before.meta.mpuSequenceNumber;
|
|
25998
|
+
const intoNextMpu = decision.reason === "rap-next" && mpu !== void 0 && after.meta.mpuSequenceNumber === mpu + 1 >>> 0 && fec.mpuBoundsRapsFor?.(packetId, catalogTrackName) === true;
|
|
25999
|
+
if (decision.action === "stall" || decision.reason === "rap-next" && !intoNextMpu) {
|
|
26000
|
+
return fec.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn, true);
|
|
26001
|
+
}
|
|
26002
|
+
return decision.reason === "rap-next" ? fec.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn, false, true) : allowanceMs;
|
|
26003
|
+
},
|
|
25732
26004
|
decide: (before, after, lostBlocks, discontinuity) => {
|
|
25733
26005
|
const decision = this.#decideGap(before, after, lostBlocks, discontinuity);
|
|
25734
26006
|
this.#onFrameGap?.(decision);
|
|
@@ -25738,6 +26010,20 @@ var MmtpRouter = class {
|
|
|
25738
26010
|
onRap: (packetId, catalogTrackName, ssId) => {
|
|
25739
26011
|
for (const observer of this.#fecRapObservers) observer(packetId, catalogTrackName, ssId);
|
|
25740
26012
|
},
|
|
26013
|
+
// One timer per stream, at the earliest wake asked: its drain re-arms
|
|
26014
|
+
// for the next frame still waiting.
|
|
26015
|
+
wakeAt: (packetId, catalogTrackName, atMs) => {
|
|
26016
|
+
if (this.#disposed) return;
|
|
26017
|
+
const key = this.#mediaStreamKey(packetId, catalogTrackName);
|
|
26018
|
+
const armed = this.#fecWakes.get(key);
|
|
26019
|
+
if (armed !== void 0 && armed.atMs <= atMs) return;
|
|
26020
|
+
if (armed !== void 0) clearTimeout(armed.timer);
|
|
26021
|
+
const timer = setTimeout(() => {
|
|
26022
|
+
this.#fecWakes.delete(key);
|
|
26023
|
+
this.#requestFecPoke(packetId, catalogTrackName);
|
|
26024
|
+
}, Math.max(0, Math.ceil(atMs - performance.now())));
|
|
26025
|
+
this.#fecWakes.set(key, { atMs, timer });
|
|
26026
|
+
},
|
|
25741
26027
|
// A staged switch commits on when each side's frames reach it
|
|
25742
26028
|
// (#interceptSwitchFrame): both sides' overlay keyframes reach it when
|
|
25743
26029
|
// they did unanchored.
|
|
@@ -28701,6 +28987,8 @@ var MulticastManager = class {
|
|
|
28701
28987
|
/** Live joinRepairEndpoints() releases → the repair owners they registered,
|
|
28702
28988
|
* re-applied after configureMultiTrack() clears catalog-derived owners. */
|
|
28703
28989
|
#repairReleases = /* @__PURE__ */ new Map();
|
|
28990
|
+
/** Protected repair flows owned by each live repair-endpoint release. */
|
|
28991
|
+
#repairProvenanceFlows = /* @__PURE__ */ new Map();
|
|
28704
28992
|
/** Each source's catalog keyframe overlay, from its `ok` binding. */
|
|
28705
28993
|
#overlayBindings = /* @__PURE__ */ new Map();
|
|
28706
28994
|
/** Installed overlay decoders (`setKeyframeOverlayDecoder`), by source. */
|
|
@@ -28865,6 +29153,11 @@ var MulticastManager = class {
|
|
|
28865
29153
|
this.#fec.onBlockVanished = (_sbn, packetId, catalogTrackName) => {
|
|
28866
29154
|
this.#statsFor(packetId, catalogTrackName).vanishedBlocks++;
|
|
28867
29155
|
};
|
|
29156
|
+
this.#fec.keyframeOverlayTiming = (packetId, catalogTrackName) => {
|
|
29157
|
+
const binding = this.#overlayInstalls.has(packetId) ? this.#overlayBindings.get(packetId) : void 0;
|
|
29158
|
+
if (binding === void 0) return void 0;
|
|
29159
|
+
return catalogTrackName === void 0 || catalogTrackName === binding.sourceCatalogTrackName ? binding.geometry : void 0;
|
|
29160
|
+
};
|
|
28868
29161
|
this.#fec.onDecoderUnavailable = (event) => {
|
|
28869
29162
|
this.#emitRepairLifecycle({
|
|
28870
29163
|
version: 2,
|
|
@@ -29367,6 +29660,9 @@ var MulticastManager = class {
|
|
|
29367
29660
|
this.#transport.onFailback((reason) => {
|
|
29368
29661
|
const joined = this.#provenanceJoin;
|
|
29369
29662
|
if (joined !== null) this.#router.unprotectProvenanceFlow(joined.flow);
|
|
29663
|
+
for (const flows of this.#repairProvenanceFlows.values()) {
|
|
29664
|
+
for (const flow of flows) this.#router.unprotectProvenanceFlow(flow);
|
|
29665
|
+
}
|
|
29370
29666
|
this.#onFailback?.(reason);
|
|
29371
29667
|
});
|
|
29372
29668
|
}
|
|
@@ -29401,6 +29697,12 @@ var MulticastManager = class {
|
|
|
29401
29697
|
"[MulticastManager] join: provenance flow (S, G, port) must match sourceAddress ?? senderAddress, groupAddress and port"
|
|
29402
29698
|
);
|
|
29403
29699
|
}
|
|
29700
|
+
if (provenanceFlow !== void 0) {
|
|
29701
|
+
const flow = multicastProvenanceFlowKey(provenanceFlow);
|
|
29702
|
+
if ([...this.#repairProvenanceFlows.values()].some((flows) => flows.includes(flow))) {
|
|
29703
|
+
throw new TypeError(`[MulticastManager] join: provenance flow already registered by a repair endpoint: ${flow}`);
|
|
29704
|
+
}
|
|
29705
|
+
}
|
|
29404
29706
|
const staged = this.#renditionSwitch;
|
|
29405
29707
|
if (staged !== null) this.#endRenditionSwitch(staged, { reason: "superseded" }, false);
|
|
29406
29708
|
this.configureFec(config);
|
|
@@ -29408,8 +29710,8 @@ var MulticastManager = class {
|
|
|
29408
29710
|
const selectedPacketIds = config.packetIds?.length ? new Set(config.packetIds) : null;
|
|
29409
29711
|
const catalogTracks = config.tracks?.filter(({ packetId }) => selectedPacketIds === null || selectedPacketIds.has(packetId));
|
|
29410
29712
|
const ingressTracks = catalogTracks ? catalogTracks : selectedPacketIds === null ? void 0 : [...selectedPacketIds].map((packetId) => ({ name: "", packetId }));
|
|
29411
|
-
this.#releaseProvenanceJoin();
|
|
29412
29713
|
const provenance = config.provenance;
|
|
29714
|
+
this.#releaseProvenanceJoin();
|
|
29413
29715
|
const protectedTracks = ingressTracks ?? provenance?.flow.tracks;
|
|
29414
29716
|
const ingress = protectedTracks === void 0 ? void 0 : {
|
|
29415
29717
|
tracks: Object.freeze(
|
|
@@ -29462,8 +29764,13 @@ var MulticastManager = class {
|
|
|
29462
29764
|
* feeds the flow's receiver; media datagrams are held until one admits them.
|
|
29463
29765
|
*/
|
|
29464
29766
|
#joinProvenance(provenance, ingress) {
|
|
29767
|
+
this.#router.registerProvenanceFlow(ingress, this.#provenanceReceiver(provenance));
|
|
29768
|
+
this.#hookFailback();
|
|
29769
|
+
this.#provenanceJoin = { flow: ingress.flow };
|
|
29770
|
+
}
|
|
29771
|
+
#provenanceReceiver(provenance) {
|
|
29465
29772
|
const { flow, auth } = provenance;
|
|
29466
|
-
|
|
29773
|
+
return new BcProvenanceV2Receiver({
|
|
29467
29774
|
...provenance.receiver,
|
|
29468
29775
|
// The caller's ctx when it passes one, else the catalog's: an explicit
|
|
29469
29776
|
// `catalogCtx: undefined` must not switch off the 7.2.4 ctx check.
|
|
@@ -29480,9 +29787,6 @@ var MulticastManager = class {
|
|
|
29480
29787
|
maxAuthDelayMs: flow.maxAuthDelayMs,
|
|
29481
29788
|
manifestTimerMs: flow.manifestTimerMs
|
|
29482
29789
|
});
|
|
29483
|
-
this.#router.registerProvenanceFlow(ingress, receiver);
|
|
29484
|
-
this.#hookFailback();
|
|
29485
|
-
this.#provenanceJoin = { flow: ingress.flow };
|
|
29486
29790
|
}
|
|
29487
29791
|
/** Un-protect: drop the flow's hold queues (no expiry counted). */
|
|
29488
29792
|
#releaseProvenanceJoin() {
|
|
@@ -29513,8 +29817,25 @@ var MulticastManager = class {
|
|
|
29513
29817
|
* callback delivers must come from a subscription opened on
|
|
29514
29818
|
* `options.gateway`. A callback that also merges another source (a MoQ or
|
|
29515
29819
|
* WebSocket repair feed) must not name a native provider here.
|
|
29820
|
+
*
|
|
29821
|
+
* An endpoint's `provenance` makes its group a protected flow of its own
|
|
29822
|
+
* (multicast-02 7.2.7), registered here and released with the group; its
|
|
29823
|
+
* records ride in band on the group's port. On the user-agent path a
|
|
29824
|
+
* flow-less repair group of a protected track is set aside, never read, so
|
|
29825
|
+
* a player joining a protected catalog's repair groups passes it.
|
|
29516
29826
|
*/
|
|
29517
29827
|
joinRepairEndpoints(endpoints, provider, options) {
|
|
29828
|
+
for (const { provenance, flow, source, group, port: port2 } of endpoints) {
|
|
29829
|
+
if (provenance === void 0) continue;
|
|
29830
|
+
if (flow !== void 0) {
|
|
29831
|
+
throw new TypeError("[MulticastManager] joinRepairEndpoints: an endpoint names provenance or flow, never both");
|
|
29832
|
+
}
|
|
29833
|
+
if (!sameIpAddress(source, provenance.flow.source) || !sameIpAddress(group, provenance.flow.groupAddress) || port2 !== provenance.flow.port) {
|
|
29834
|
+
throw new RangeError(
|
|
29835
|
+
"[MulticastManager] joinRepairEndpoints: provenance flow (S, G, port) must match the endpoint's source, group and port"
|
|
29836
|
+
);
|
|
29837
|
+
}
|
|
29838
|
+
}
|
|
29518
29839
|
const releases = [];
|
|
29519
29840
|
let released = false;
|
|
29520
29841
|
const safely = (each) => {
|
|
@@ -29524,17 +29845,36 @@ var MulticastManager = class {
|
|
|
29524
29845
|
console.warn("[MulticastManager] repair group release failed", error);
|
|
29525
29846
|
}
|
|
29526
29847
|
};
|
|
29848
|
+
const usedFlows = new Set(endpoints.flatMap(({ flow }) => flow === void 0 ? [] : [flow]));
|
|
29849
|
+
const preparedProvenance = endpoints.map((endpoint) => {
|
|
29850
|
+
if (endpoint.provenance === void 0) return void 0;
|
|
29851
|
+
const flow = multicastProvenanceFlowKey(endpoint.provenance.flow);
|
|
29852
|
+
if (usedFlows.has(flow) || this.#provenanceJoin?.flow === flow || [...this.#repairProvenanceFlows.values()].some((flows) => flows.includes(flow))) {
|
|
29853
|
+
throw new TypeError(`[MulticastManager] joinRepairEndpoints: provenance flow already registered: ${flow}`);
|
|
29854
|
+
}
|
|
29855
|
+
usedFlows.add(flow);
|
|
29856
|
+
return { flow, receiver: this.#provenanceReceiver(endpoint.provenance) };
|
|
29857
|
+
});
|
|
29858
|
+
const provenanceFlows = [];
|
|
29527
29859
|
const repairOwners = endpoints.flatMap((endpoint) => endpoint.repairOwners.map((owner) => owner.instance !== "keyframe" ? owner : {
|
|
29528
29860
|
...owner,
|
|
29529
29861
|
ownerTrackName: endpoint.tracks.find((t) => t.packetId === owner.ownerPacketId)?.name,
|
|
29530
29862
|
repairTrackName: endpoint.tracks.find((t) => t.packetId === owner.packetId)?.name
|
|
29531
29863
|
}));
|
|
29532
29864
|
this.#applyRepairOwners(repairOwners);
|
|
29533
|
-
for (const endpoint of endpoints) {
|
|
29865
|
+
for (const [index, endpoint] of endpoints.entries()) {
|
|
29866
|
+
const flow = endpoint.provenance === void 0 ? endpoint.flow : multicastProvenanceFlowKey(endpoint.provenance.flow);
|
|
29534
29867
|
const ingress = {
|
|
29535
29868
|
tracks: Object.freeze(endpoint.tracks.map(({ name, packetId }) => Object.freeze({ name, packetId }))),
|
|
29536
|
-
...
|
|
29869
|
+
...flow === void 0 ? {} : { flow }
|
|
29537
29870
|
};
|
|
29871
|
+
if (endpoint.provenance !== void 0) {
|
|
29872
|
+
const prepared = preparedProvenance[index];
|
|
29873
|
+
if (prepared === void 0) throw new Error("[MulticastManager] repair provenance preparation missing");
|
|
29874
|
+
this.#router.registerProvenanceFlow(ingress, prepared.receiver);
|
|
29875
|
+
provenanceFlows.push(prepared.flow);
|
|
29876
|
+
releases.push(() => this.#router.releaseProvenanceFlow(flow));
|
|
29877
|
+
}
|
|
29538
29878
|
let sender;
|
|
29539
29879
|
const feed = (packet, sourceAddress, ingressToFeed) => {
|
|
29540
29880
|
if (released) return;
|
|
@@ -29564,7 +29904,7 @@ var MulticastManager = class {
|
|
|
29564
29904
|
packetIds: endpoint.packetIds,
|
|
29565
29905
|
tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId })),
|
|
29566
29906
|
// A protected repair group's records ride in band on its port (7.2.3).
|
|
29567
|
-
...
|
|
29907
|
+
...flow === void 0 ? {} : { protected: true }
|
|
29568
29908
|
}, ingress).then((joined) => {
|
|
29569
29909
|
if (!joined && !released) fail(transport.lastJoinOutcome);
|
|
29570
29910
|
});
|
|
@@ -29573,9 +29913,12 @@ var MulticastManager = class {
|
|
|
29573
29913
|
if (released) return;
|
|
29574
29914
|
released = true;
|
|
29575
29915
|
this.#repairReleases.delete(release);
|
|
29916
|
+
this.#repairProvenanceFlows.delete(release);
|
|
29576
29917
|
for (const each of releases.splice(0)) safely(each);
|
|
29577
29918
|
};
|
|
29578
29919
|
this.#repairReleases.set(release, repairOwners);
|
|
29920
|
+
this.#repairProvenanceFlows.set(release, provenanceFlows);
|
|
29921
|
+
if (provenanceFlows.length) this.#hookFailback();
|
|
29579
29922
|
return release;
|
|
29580
29923
|
}
|
|
29581
29924
|
#applyRepairOwners(owners) {
|
|
@@ -30061,7 +30404,8 @@ var MulticastManager = class {
|
|
|
30061
30404
|
blockProfile: parseFecBlockProfile(
|
|
30062
30405
|
geometry2.blockProfile,
|
|
30063
30406
|
`tracks[${JSON.stringify(track.name)}].fec keyframe overlay blockProfile`
|
|
30064
|
-
)
|
|
30407
|
+
),
|
|
30408
|
+
geometry: geometry2
|
|
30065
30409
|
});
|
|
30066
30410
|
}
|
|
30067
30411
|
}
|
|
@@ -30100,7 +30444,7 @@ var MulticastManager = class {
|
|
|
30100
30444
|
for (const [sourcePacketId, install] of [...this.#overlayInstalls]) {
|
|
30101
30445
|
const before = this.#overlayBindings.get(sourcePacketId);
|
|
30102
30446
|
const after = overlayBindings.get(sourcePacketId);
|
|
30103
|
-
const same = before !== void 0 && after !== void 0 && Object.keys(after).every((key) => after[key] === before[key]);
|
|
30447
|
+
const same = before !== void 0 && after !== void 0 && Object.keys(after).every((key) => key === "geometry" || after[key] === before[key]);
|
|
30104
30448
|
if (!same) install.dispose();
|
|
30105
30449
|
else if (this.#router.hasKeyframeOverlay(after.repairPacketId)) this.#router.resetKeyframeOverlays(sourcePacketId);
|
|
30106
30450
|
else install.reattach();
|
|
@@ -33144,7 +33488,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
33144
33488
|
if (!run) return;
|
|
33145
33489
|
entry.running = null;
|
|
33146
33490
|
run.stopped = reason;
|
|
33147
|
-
run.controller.abort();
|
|
33491
|
+
run.controller.abort(reason);
|
|
33148
33492
|
if (reason === "preempted") releaseHold(entry);
|
|
33149
33493
|
mc.noteRepairStopped?.(reason, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
33150
33494
|
};
|
|
@@ -33442,7 +33786,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
33442
33786
|
if (entries.get(requestKey(sbn, entry.packetId, entry.catalogTrackName))?.running == null) {
|
|
33443
33787
|
const rsIds = /* @__PURE__ */ new Set();
|
|
33444
33788
|
const group = new AbortController();
|
|
33445
|
-
const cancel = () => group.abort();
|
|
33789
|
+
const cancel = () => group.abort(common.signal.reason);
|
|
33446
33790
|
common.signal.addEventListener("abort", cancel, { once: true });
|
|
33447
33791
|
walk.group = { sbn, controller: group };
|
|
33448
33792
|
try {
|
|
@@ -33978,6 +34322,7 @@ export {
|
|
|
33978
34322
|
resolveGroupDurationMs,
|
|
33979
34323
|
resolveGroupDurationTicks,
|
|
33980
34324
|
resolveRepairLayers,
|
|
34325
|
+
runtimeFecCatalogReport,
|
|
33981
34326
|
secondsFromTicks,
|
|
33982
34327
|
setupFecWorkerForTrack,
|
|
33983
34328
|
setupTrackPipeline,
|