@blockcast/mmt-container 2.2.0-main.2c4d96d3ffc2 → 2.2.0-main.34b53d33bace
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 +954 -157
- 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/delta-fallback-config.js.map +1 -1
- package/dist/fec-manager.d.ts +71 -14
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +300 -60
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-worker-setup.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -13
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +80 -25
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/media-router.js.map +1 -1
- package/dist/mmtp-container-parser.d.ts +63 -10
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +218 -18
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +217 -19
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +218 -18
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +22 -9
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +384 -51
- 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 +774 -130
- package/dist/multicast-manager.js.map +3 -3
- package/dist/multicast-transport.js +2 -2
- package/dist/multicast-transport.js.map +2 -2
- package/dist/no-modules.js +218 -18
- 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 +218 -18
- 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 +316 -34
- package/src/index.ts +2 -0
- package/src/iso-block-locator.ts +114 -31
- package/src/mmtp-container-parser.ts +238 -21
- package/src/mmtp-router.ts +271 -58
- package/src/multicast-manager.ts +136 -16
- package/src/repair-fetch.ts +366 -50
- package/src/track-session.ts +3 -0
package/dist/mmtp-router.js
CHANGED
|
@@ -4827,9 +4827,10 @@ function isH264IntraSlice(nal) {
|
|
|
4827
4827
|
const sliceType = readH264SliceType(nal);
|
|
4828
4828
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
4829
4829
|
}
|
|
4830
|
+
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
4830
4831
|
function readH264SliceType(nal) {
|
|
4831
4832
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4832
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4833
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
|
|
4833
4834
|
const state = { bitOffset: 0 };
|
|
4834
4835
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4835
4836
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -4976,6 +4977,96 @@ if (void 0) {
|
|
|
4976
4977
|
]))).toBe(false);
|
|
4977
4978
|
});
|
|
4978
4979
|
});
|
|
4980
|
+
describe("readH264SliceType", () => {
|
|
4981
|
+
const wholeNalSliceType = (nal) => {
|
|
4982
|
+
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4983
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4984
|
+
const state = { bitOffset: 0 };
|
|
4985
|
+
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4986
|
+
return readUnsignedExpGolomb(rbsp, state);
|
|
4987
|
+
};
|
|
4988
|
+
const hex = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
|
|
4989
|
+
const ue = (value) => {
|
|
4990
|
+
const code = (value + 1).toString(2);
|
|
4991
|
+
return "0".repeat(code.length - 1) + code;
|
|
4992
|
+
};
|
|
4993
|
+
const sliceNal = (bits) => {
|
|
4994
|
+
const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
|
|
4995
|
+
const nal = [1];
|
|
4996
|
+
let zeros = 0;
|
|
4997
|
+
for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
|
|
4998
|
+
if (zeros >= 2 && byte <= 3) {
|
|
4999
|
+
nal.push(3);
|
|
5000
|
+
zeros = 0;
|
|
5001
|
+
}
|
|
5002
|
+
nal.push(byte);
|
|
5003
|
+
zeros = byte === 0 ? zeros + 1 : 0;
|
|
5004
|
+
}
|
|
5005
|
+
return Uint8Array.from(nal);
|
|
5006
|
+
};
|
|
5007
|
+
const x264Slices = [
|
|
5008
|
+
["64x48 P", hex("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
|
|
5009
|
+
["64x48 B", hex("419e414212fffeeade283707cb70f7"), 6, false],
|
|
5010
|
+
["64x48 non-IDR I", hex(
|
|
5011
|
+
"4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
|
|
5012
|
+
), 7, true],
|
|
5013
|
+
["1280x720 B, escape at byte 10", hex(
|
|
5014
|
+
"01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
|
|
5015
|
+
), 6, false],
|
|
5016
|
+
["1280x720 P, escape at byte 15", hex(
|
|
5017
|
+
"41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
|
|
5018
|
+
), 5, false],
|
|
5019
|
+
["1280x720 B, escape at byte 22", hex("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
|
|
5020
|
+
["7680x4320 IDR, first_mb_in_slice 97440", hex(
|
|
5021
|
+
"650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
|
|
5022
|
+
), null, true],
|
|
5023
|
+
["7680x4320 P, first_mb_in_slice 32640", hex(
|
|
5024
|
+
"410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
|
|
5025
|
+
), 5, false],
|
|
5026
|
+
["7680x4320 P, first_mb_in_slice 97440", hex(
|
|
5027
|
+
"410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
|
|
5028
|
+
), 5, false]
|
|
5029
|
+
];
|
|
5030
|
+
const syntheticSlices = [
|
|
5031
|
+
["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
|
|
5032
|
+
["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
|
|
5033
|
+
["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
|
|
5034
|
+
["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
|
|
5035
|
+
["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
|
|
5036
|
+
["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
|
|
5037
|
+
["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
|
|
5038
|
+
["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
|
|
5039
|
+
];
|
|
5040
|
+
test("reads the slice_type of real and synthetic slices", () => {
|
|
5041
|
+
for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
|
|
5042
|
+
expect(readH264SliceType(nal), name).toBe(sliceType);
|
|
5043
|
+
}
|
|
5044
|
+
});
|
|
5045
|
+
test("matches the whole-NAL unescape at every truncation", () => {
|
|
5046
|
+
for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
|
|
5047
|
+
for (let end = 0; end <= nal.length; end++) {
|
|
5048
|
+
const cut = nal.subarray(0, end);
|
|
5049
|
+
expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
});
|
|
5053
|
+
test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
|
|
5054
|
+
const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
|
|
5055
|
+
let seed = 1;
|
|
5056
|
+
const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
|
|
5057
|
+
for (let i = 0; i < 5e3; i++) {
|
|
5058
|
+
const nal = new Uint8Array(2 + next() % 63);
|
|
5059
|
+
nal[0] = 65;
|
|
5060
|
+
for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
|
|
5061
|
+
expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
|
|
5062
|
+
}
|
|
5063
|
+
});
|
|
5064
|
+
test("classifies the x264 slices as keyframes or not", () => {
|
|
5065
|
+
for (const [name, nal, , keyframe] of x264Slices) {
|
|
5066
|
+
expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
|
|
5067
|
+
}
|
|
5068
|
+
});
|
|
5069
|
+
});
|
|
4979
5070
|
describe("avccToAnnexB", () => {
|
|
4980
5071
|
test("converts with SPS/PPS on keyframe", () => {
|
|
4981
5072
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|
|
@@ -8023,6 +8114,9 @@ function authoredGap(before, after) {
|
|
|
8023
8114
|
function ssIdAfter(a, b) {
|
|
8024
8115
|
return (a - b | 0) > 0;
|
|
8025
8116
|
}
|
|
8117
|
+
function holdsRebuilt(stream) {
|
|
8118
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
|
|
8119
|
+
}
|
|
8026
8120
|
var FecReleaseSequencer = class {
|
|
8027
8121
|
#streams = /* @__PURE__ */ new Map();
|
|
8028
8122
|
#gate;
|
|
@@ -8085,6 +8179,7 @@ var FecReleaseSequencer = class {
|
|
|
8085
8179
|
stream.lastSbn = void 0;
|
|
8086
8180
|
stream.discontinuity = false;
|
|
8087
8181
|
stream.rapSsId = void 0;
|
|
8182
|
+
stream.sourced = false;
|
|
8088
8183
|
}
|
|
8089
8184
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
8090
8185
|
this.#recordStat("droppedStale");
|
|
@@ -8111,6 +8206,7 @@ var FecReleaseSequencer = class {
|
|
|
8111
8206
|
if (compareFrameOrder(stream.buf[mid], frame) < 0) lo = mid + 1;
|
|
8112
8207
|
else hi = mid;
|
|
8113
8208
|
}
|
|
8209
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true;
|
|
8114
8210
|
stream.buf.splice(lo, 0, frame);
|
|
8115
8211
|
this.#drainUnlessDeferred(stream);
|
|
8116
8212
|
}
|
|
@@ -8146,6 +8242,41 @@ var FecReleaseSequencer = class {
|
|
|
8146
8242
|
}
|
|
8147
8243
|
return false;
|
|
8148
8244
|
}
|
|
8245
|
+
/**
|
|
8246
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
8247
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
8248
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
8249
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
8250
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
8251
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
8252
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
8253
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
8254
|
+
* released.
|
|
8255
|
+
*/
|
|
8256
|
+
unsource(packetId, catalogTrackName) {
|
|
8257
|
+
for (const stream of this.#streams.values()) {
|
|
8258
|
+
if (stream.packetId === packetId && (catalogTrackName === void 0 || stream.catalogTrackName === catalogTrackName)) {
|
|
8259
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
8260
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
8261
|
+
else this.#drain(stream, true);
|
|
8262
|
+
}
|
|
8263
|
+
stream.sourced = false;
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
/**
|
|
8268
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
8269
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
8270
|
+
* packetId.
|
|
8271
|
+
*/
|
|
8272
|
+
holdsRebuilt(packetId, catalogTrackName) {
|
|
8273
|
+
for (const stream of this.#streams.values()) {
|
|
8274
|
+
if (stream.packetId !== packetId) continue;
|
|
8275
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
8276
|
+
if (holdsRebuilt(stream)) return true;
|
|
8277
|
+
}
|
|
8278
|
+
return false;
|
|
8279
|
+
}
|
|
8149
8280
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
8150
8281
|
poke(streamKey) {
|
|
8151
8282
|
if (streamKey !== void 0) {
|
|
@@ -8237,16 +8368,32 @@ var FecReleaseSequencer = class {
|
|
|
8237
8368
|
last: null,
|
|
8238
8369
|
lastSbn: void 0,
|
|
8239
8370
|
discontinuity: false,
|
|
8240
|
-
rapSsId: void 0
|
|
8371
|
+
rapSsId: void 0,
|
|
8372
|
+
sourced: false,
|
|
8373
|
+
draining: 0
|
|
8241
8374
|
};
|
|
8242
8375
|
this.#streams.set(streamKey, stream);
|
|
8243
8376
|
}
|
|
8244
8377
|
return stream;
|
|
8245
8378
|
}
|
|
8246
|
-
#
|
|
8379
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
8380
|
+
#drain(stream, asUnanchored = false) {
|
|
8381
|
+
stream.draining++;
|
|
8382
|
+
try {
|
|
8383
|
+
this.#drainLoop(stream, asUnanchored);
|
|
8384
|
+
} finally {
|
|
8385
|
+
stream.draining--;
|
|
8386
|
+
}
|
|
8387
|
+
}
|
|
8388
|
+
#drainLoop(stream, asUnanchored) {
|
|
8247
8389
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
8248
8390
|
const head = stream.buf[0];
|
|
8249
8391
|
const last = stream.last;
|
|
8392
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
8393
|
+
stream.buf.shift();
|
|
8394
|
+
this.#release(stream, head, void 0);
|
|
8395
|
+
continue;
|
|
8396
|
+
}
|
|
8250
8397
|
if (stream.discontinuity) {
|
|
8251
8398
|
stream.discontinuity = false;
|
|
8252
8399
|
stream.buf.shift();
|
|
@@ -8260,9 +8407,10 @@ var FecReleaseSequencer = class {
|
|
|
8260
8407
|
}
|
|
8261
8408
|
const headSbn = head.meta.fecSbn;
|
|
8262
8409
|
const from = stream.lastSbn ?? headSbn;
|
|
8263
|
-
const to = headSbn ?? stream.lastSbn;
|
|
8410
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn;
|
|
8264
8411
|
let lost = [];
|
|
8265
8412
|
const unanchored = from === void 0 && to === void 0;
|
|
8413
|
+
let unresolved = false;
|
|
8266
8414
|
if (from !== void 0 && to !== void 0) {
|
|
8267
8415
|
const resolved = this.#gate.resolvedLoss(
|
|
8268
8416
|
stream.packetId,
|
|
@@ -8271,7 +8419,8 @@ var FecReleaseSequencer = class {
|
|
|
8271
8419
|
Math.max(from, to),
|
|
8272
8420
|
from
|
|
8273
8421
|
);
|
|
8274
|
-
|
|
8422
|
+
unresolved = resolved === null;
|
|
8423
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored) && !this.#unrepairableWaitOver(last, head, from, to)) {
|
|
8275
8424
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
8276
8425
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
8277
8426
|
this.#recordStat("forcedWindowFlushes");
|
|
@@ -8279,22 +8428,61 @@ var FecReleaseSequencer = class {
|
|
|
8279
8428
|
this.#release(stream, head, this.#gate.decide(last, head, [], true));
|
|
8280
8429
|
continue;
|
|
8281
8430
|
}
|
|
8282
|
-
lost = resolved;
|
|
8431
|
+
lost = resolved ?? [];
|
|
8283
8432
|
}
|
|
8284
8433
|
stream.buf.shift();
|
|
8285
8434
|
this.#release(
|
|
8286
8435
|
stream,
|
|
8287
8436
|
head,
|
|
8288
|
-
lost.length > 0 || unanchored || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
8437
|
+
lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
8289
8438
|
);
|
|
8290
8439
|
}
|
|
8291
8440
|
}
|
|
8441
|
+
/** The head has waited out a gap only a late source can still fill (FecReleaseGate.unrepairableWaitMs). */
|
|
8442
|
+
#unrepairableWaitOver(last, head, from, to) {
|
|
8443
|
+
const waitMs = this.#gate.unrepairableWaitMs?.(last, head, from, to);
|
|
8444
|
+
return waitMs !== void 0 && performance.now() - head.arrivedAtMs >= waitMs;
|
|
8445
|
+
}
|
|
8446
|
+
/**
|
|
8447
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
8448
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
8449
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
8450
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
8451
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
8452
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
8453
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
8454
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
8455
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
8456
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
8457
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
8458
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
8459
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
8460
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
8461
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
8462
|
+
*/
|
|
8463
|
+
#cursorPassed(stream, asUnanchored) {
|
|
8464
|
+
let at = -1;
|
|
8465
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
8466
|
+
const frame = stream.buf[i];
|
|
8467
|
+
if (frame.meta.fecSbnFirst !== void 0 || frame.meta.fecSbn === void 0) {
|
|
8468
|
+
frame.passed = true;
|
|
8469
|
+
if (at < 0) at = i;
|
|
8470
|
+
} else if (frame.passed !== true) break;
|
|
8471
|
+
}
|
|
8472
|
+
if (at < 0) return false;
|
|
8473
|
+
return asUnanchored || !stream.sourced || this.#gate.releaseUnanchored?.(stream.packetId, stream.catalogTrackName) === true || stream.buf.some(({ meta }, i) => i > at && meta.fecSbnFirst === void 0 && (meta.recovered !== true || meta.fecSbn !== void 0));
|
|
8474
|
+
}
|
|
8292
8475
|
#release(stream, frame, decision) {
|
|
8476
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0;
|
|
8477
|
+
if (stale) this.#recordStat("droppedStale");
|
|
8293
8478
|
if (decision) frame.meta.gapBefore = decision;
|
|
8294
8479
|
stream.last = frame;
|
|
8295
|
-
if (frame.meta.fecSbn !== void 0
|
|
8480
|
+
if (frame.meta.fecSbn !== void 0 && (frame.meta.fecSbnFirst === void 0 || stream.lastSbn !== void 0)) {
|
|
8481
|
+
stream.lastSbn = frame.meta.fecSbn;
|
|
8482
|
+
}
|
|
8483
|
+
if (frame.meta.recovered !== true) stream.sourced = true;
|
|
8296
8484
|
this.#gate.onReleased?.(frame.data, frame.meta);
|
|
8297
|
-
this.#emit(frame.data, frame.meta);
|
|
8485
|
+
if (!stale) this.#emit(frame.data, frame.meta);
|
|
8298
8486
|
}
|
|
8299
8487
|
};
|
|
8300
8488
|
var FMPU_BOX_TYPES = /* @__PURE__ */ new Set(["ftyp", "moov", "moof"]);
|
|
@@ -8555,11 +8743,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
8555
8743
|
/**
|
|
8556
8744
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
8557
8745
|
*
|
|
8558
|
-
*
|
|
8559
|
-
*
|
|
8560
|
-
*
|
|
8561
|
-
*
|
|
8562
|
-
*
|
|
8746
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
8747
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
8748
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
8749
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
8750
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
8751
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
8563
8752
|
*/
|
|
8564
8753
|
get timingBudgetStats() {
|
|
8565
8754
|
return {
|
|
@@ -8619,6 +8808,14 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
8619
8808
|
fecReleaseRapAbove(packetId, catalogTrackName, ssId) {
|
|
8620
8809
|
return this.#fecSequencer?.rapAbove(packetId, catalogTrackName, ssId) ?? false;
|
|
8621
8810
|
}
|
|
8811
|
+
/** See FecReleaseSequencer.unsource. */
|
|
8812
|
+
unsourceFecRelease(packetId, catalogTrackName) {
|
|
8813
|
+
this.#fecSequencer?.unsource(packetId, catalogTrackName);
|
|
8814
|
+
}
|
|
8815
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
8816
|
+
fecReleaseHoldsRebuilt(packetId, catalogTrackName) {
|
|
8817
|
+
return this.#fecSequencer?.holdsRebuilt(packetId, catalogTrackName) ?? false;
|
|
8818
|
+
}
|
|
8622
8819
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
8623
8820
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
8624
8821
|
if (!this.#fecSequencer) return;
|
|
@@ -8872,7 +9069,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
8872
9069
|
if (!resolver2?.initialized) return this.#drop("fragment-no-resolver");
|
|
8873
9070
|
const pendingBefore = resolver2.pendingSampleCount;
|
|
8874
9071
|
const evictedBefore = resolver2.evictedSampleCount;
|
|
8875
|
-
const remaining = this.#maxPendingTimingSamples -
|
|
9072
|
+
const remaining = this.#maxPendingTimingSamples - resolver2.pendingSampleCount;
|
|
8876
9073
|
const admitted = resolver2.addMovieFragment(
|
|
8877
9074
|
mpu.mpuSequenceNumber,
|
|
8878
9075
|
data,
|
|
@@ -8945,7 +9142,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
8945
9142
|
info,
|
|
8946
9143
|
resolver,
|
|
8947
9144
|
options?.recovered === true,
|
|
8948
|
-
options?.fecSbn
|
|
9145
|
+
options?.fecSbn,
|
|
9146
|
+
options?.fecSbnFirst
|
|
8949
9147
|
);
|
|
8950
9148
|
if (deferred.record === void 0) this.#countDeferredOutcome(deferred.reason);
|
|
8951
9149
|
}
|
|
@@ -9038,7 +9236,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
9038
9236
|
info,
|
|
9039
9237
|
resolver,
|
|
9040
9238
|
options?.recovered === true,
|
|
9041
|
-
options?.fecSbn
|
|
9239
|
+
options?.fecSbn,
|
|
9240
|
+
options?.fecSbnFirst
|
|
9042
9241
|
);
|
|
9043
9242
|
if (outcome.record !== void 0) return outcome.record;
|
|
9044
9243
|
return this.#drop(outcome.reason);
|
|
@@ -9058,7 +9257,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
9058
9257
|
* attribution exists to keep readable. Leaving the choice at the call site
|
|
9059
9258
|
* is what keeps both true.
|
|
9060
9259
|
*/
|
|
9061
|
-
#emitCombinedSample(combined, info, resolver, recovered, fecSbn) {
|
|
9260
|
+
#emitCombinedSample(combined, info, resolver, recovered, fecSbn, fecSbnFirst) {
|
|
9062
9261
|
const timing = resolver.sampleTiming(
|
|
9063
9262
|
combined.mpuSequenceNumber,
|
|
9064
9263
|
combined.movieFragmentSequenceNumber,
|
|
@@ -9075,6 +9274,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
9075
9274
|
);
|
|
9076
9275
|
if (!meta) return { reason: "combined-meta-build-failed" };
|
|
9077
9276
|
if (fecSbn !== void 0) meta.fecSbn = fecSbn;
|
|
9277
|
+
if (fecSbnFirst !== void 0) meta.fecSbnFirst = fecSbnFirst;
|
|
9078
9278
|
if (!resolver.consumeSample(
|
|
9079
9279
|
combined.mpuSequenceNumber,
|
|
9080
9280
|
combined.movieFragmentSequenceNumber,
|
|
@@ -9925,6 +10125,7 @@ function unstampedBaseSsId(offset, unstampedOffset, headerPsn) {
|
|
|
9925
10125
|
var OVERLAY_ROUTED_LIMIT = 1024;
|
|
9926
10126
|
var OVERLAY_PENDING_LIMIT = 256;
|
|
9927
10127
|
var OVERLAY_OFFSET_MPUS = 16;
|
|
10128
|
+
var OVERLAY_REBUILT_LIMIT = 256;
|
|
9928
10129
|
var OVERLAY_MOQ_HORIZON_BLOCKS = 64;
|
|
9929
10130
|
function assertStreamIdentity(role, stream) {
|
|
9930
10131
|
if (stream === void 0 || !Number.isInteger(stream.packetId) || stream.packetId <= MMTP_SIGNALING_PACKET_ID || typeof stream.catalogTrackName !== "string" || stream.catalogTrackName.length === 0) {
|
|
@@ -10035,6 +10236,7 @@ var MmtpRouter = class {
|
|
|
10035
10236
|
#provenance = /* @__PURE__ */ new Map();
|
|
10036
10237
|
#onFlowProtected = null;
|
|
10037
10238
|
#unadmittedListedDrops = 0;
|
|
10239
|
+
#admittedSourceDatagrams = 0;
|
|
10038
10240
|
#unlistedRepairSetAside = 0;
|
|
10039
10241
|
#assistBlocks = /* @__PURE__ */ new Map();
|
|
10040
10242
|
#assistFailures = /* @__PURE__ */ new Map();
|
|
@@ -10100,6 +10302,17 @@ var MmtpRouter = class {
|
|
|
10100
10302
|
* an MPU no member of which arrived).
|
|
10101
10303
|
*/
|
|
10102
10304
|
#unstampedSsIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
10305
|
+
/**
|
|
10306
|
+
* The same, shown by the overlay alone, before any base recovery did: a
|
|
10307
|
+
* packet it rebuilt whose base copy carries its protected psn
|
|
10308
|
+
* (#feedOverlaySource), or whose protected psn passes overlayBaseSsId's
|
|
10309
|
+
* test at that offset (#routeOverlayRecovered). A base SS_ID placed by it
|
|
10310
|
+
* anchors the release gate only (BLO-52085 D3): fed to the base, it would
|
|
10311
|
+
* make the base drop a late base copy of a keyframe the overlay never
|
|
10312
|
+
* finished, and lift a block's late-source cut, which nothing before
|
|
10313
|
+
* this offset did.
|
|
10314
|
+
*/
|
|
10315
|
+
#overlayUnstampedSsIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
10103
10316
|
/**
|
|
10104
10317
|
* Streams whose multicast leg delivered a RAP-flagged source packet that was
|
|
10105
10318
|
* not parsed, typically because its overlap copy was parsed first
|
|
@@ -10377,13 +10590,18 @@ var MmtpRouter = class {
|
|
|
10377
10590
|
this.#onDeltaBlockCompleteCb?.(packetId, false);
|
|
10378
10591
|
}
|
|
10379
10592
|
};
|
|
10380
|
-
this.#fecManager.onBlockFailed = (sbn, packetId, catalogTrackName, blockClass) => {
|
|
10593
|
+
this.#fecManager.onBlockFailed = (sbn, packetId, catalogTrackName, blockClass, span) => {
|
|
10381
10594
|
this.#mseAssemblerFor(packetId, catalogTrackName)?.failBlock(sbn);
|
|
10382
10595
|
if (this.#isCatalogTrackUnambiguous(packetId, catalogTrackName) && this.#packetIdRoles.get(packetId) === "delta") {
|
|
10383
10596
|
this.#onDeltaBlockCompleteCb?.(packetId, true);
|
|
10384
10597
|
}
|
|
10385
|
-
|
|
10386
|
-
|
|
10598
|
+
if (span === void 0) {
|
|
10599
|
+
onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
10600
|
+
this.#onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
10601
|
+
} else {
|
|
10602
|
+
onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span);
|
|
10603
|
+
this.#onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span);
|
|
10604
|
+
}
|
|
10387
10605
|
};
|
|
10388
10606
|
}
|
|
10389
10607
|
}
|
|
@@ -10428,8 +10646,9 @@ var MmtpRouter = class {
|
|
|
10428
10646
|
}
|
|
10429
10647
|
/**
|
|
10430
10648
|
* FEC-recovered source symbols whose reconstructed header named a
|
|
10431
|
-
* packet_sequence_number other than the wire sequence their SS_ID maps to
|
|
10432
|
-
*
|
|
10649
|
+
* packet_sequence_number other than the wire sequence their SS_ID maps to,
|
|
10650
|
+
* or, rebuilt by the overlay, than their base copy carries: a hop
|
|
10651
|
+
* re-stamped the sequence after the sender protected the packet.
|
|
10433
10652
|
*/
|
|
10434
10653
|
get restampedRecoveredSequenceCount() {
|
|
10435
10654
|
return this.#restampedRecoveredSeqs;
|
|
@@ -10608,6 +10827,7 @@ var MmtpRouter = class {
|
|
|
10608
10827
|
enableMseAssembler(packetId, config, catalogTrackName) {
|
|
10609
10828
|
const assemblerKey = this.#mseAssemblerKey(packetId, catalogTrackName);
|
|
10610
10829
|
const previous = this.#mseAssemblers.get(assemblerKey);
|
|
10830
|
+
this.#parser.unsourceFecRelease(packetId, catalogTrackName);
|
|
10611
10831
|
if (previous) {
|
|
10612
10832
|
previous.flush();
|
|
10613
10833
|
previous.dispose();
|
|
@@ -10758,7 +10978,8 @@ var MmtpRouter = class {
|
|
|
10758
10978
|
fec,
|
|
10759
10979
|
k,
|
|
10760
10980
|
offsets: /* @__PURE__ */ new Map(),
|
|
10761
|
-
moqBlocks: /* @__PURE__ */ new Set()
|
|
10981
|
+
moqBlocks: /* @__PURE__ */ new Set(),
|
|
10982
|
+
rebuilt: /* @__PURE__ */ new Map()
|
|
10762
10983
|
};
|
|
10763
10984
|
this.#overlays.set(repairPacketId, inst);
|
|
10764
10985
|
return () => {
|
|
@@ -10799,6 +11020,7 @@ var MmtpRouter = class {
|
|
|
10799
11020
|
inst.last = void 0;
|
|
10800
11021
|
inst.offsets.clear();
|
|
10801
11022
|
inst.moqBlocks.clear();
|
|
11023
|
+
inst.rebuilt.clear();
|
|
10802
11024
|
}
|
|
10803
11025
|
#overlaysForSource(sourcePacketId, catalogTrackName) {
|
|
10804
11026
|
return [...this.#overlays.values()].filter(({ leg }) => leg.sourcePacketId === sourcePacketId && (catalogTrackName === void 0 || leg.sourceCatalogTrackName === void 0 || leg.sourceCatalogTrackName === catalogTrackName));
|
|
@@ -10851,13 +11073,23 @@ var MmtpRouter = class {
|
|
|
10851
11073
|
* base protects: the packet minus its 4-byte SS_ID trailer, extension
|
|
10852
11074
|
* included (7.1, 7.4.3). `baseSsId` is that trailer's SS_ID, when the base
|
|
10853
11075
|
* FEC reads it.
|
|
11076
|
+
*
|
|
11077
|
+
* The base copy of a packet an overlay rebuilt with no base SS_ID shows
|
|
11078
|
+
* what a base recovery of it would (#routeProcessedFecSymbols, BLO-52085):
|
|
11079
|
+
* its wire packet_sequence_number equal to the protected one rebuilt shows
|
|
11080
|
+
* the stream unstamped at the SS_ID offset it states, for the release gate
|
|
11081
|
+
* (#overlayUnstampedSsIdSeqOffsetByStream); any other shows a hop that
|
|
11082
|
+
* re-stamps it, which is counted (restampedRecoveredSequenceCount).
|
|
10854
11083
|
*/
|
|
10855
11084
|
#feedOverlaySource(packetId, catalogTrackName, packet, header, sequenceNumber, rapFlag, source, baseSsId) {
|
|
10856
11085
|
if (this.#overlays.size === 0) return;
|
|
10857
11086
|
const ssId = keyframeOverlaySsId(header);
|
|
10858
11087
|
if (ssId === void 0) return;
|
|
11088
|
+
let rebuiltPsn;
|
|
10859
11089
|
for (const inst of this.#overlaysForSource(packetId, catalogTrackName)) {
|
|
10860
11090
|
this.#noteOverlaySsId(inst, ssId, sequenceNumber);
|
|
11091
|
+
rebuiltPsn ??= inst.rebuilt.get(ssId);
|
|
11092
|
+
inst.rebuilt.delete(ssId);
|
|
10861
11093
|
const identity = MmtpContainerParser.sourcePacketIdentity(packet, header);
|
|
10862
11094
|
if (identity !== null) {
|
|
10863
11095
|
inst.offsets.delete(identity.mpuSequenceNumber);
|
|
@@ -10887,6 +11119,14 @@ var MmtpRouter = class {
|
|
|
10887
11119
|
const recovered = fec.feedSourceSymbol(pid, ssId, symbolData, name);
|
|
10888
11120
|
if (recovered && !alreadyCompleted) this.#routeOverlayRecovered(inst, coords.sbn, recovered);
|
|
10889
11121
|
}
|
|
11122
|
+
if (rebuiltPsn === void 0 || this.#classifyPacketId(packetId) === null) return;
|
|
11123
|
+
const streamKey = this.#mediaStreamKey(packetId, catalogTrackName);
|
|
11124
|
+
if (rebuiltPsn !== sequenceNumber) {
|
|
11125
|
+
this.#restampedRecoveredSeqs++;
|
|
11126
|
+
} else if (baseSsId !== void 0) {
|
|
11127
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
11128
|
+
if (offset === baseSsId - sequenceNumber >>> 0) this.#overlayUnstampedSsIdSeqOffsetByStream.set(streamKey, offset);
|
|
11129
|
+
}
|
|
10890
11130
|
}
|
|
10891
11131
|
#noteOverlayMoqBlock(inst, blockStart) {
|
|
10892
11132
|
inst.moqBlocks.add(blockStart);
|
|
@@ -10920,11 +11160,16 @@ var MmtpRouter = class {
|
|
|
10920
11160
|
}
|
|
10921
11161
|
/**
|
|
10922
11162
|
* Route an overlay-recovered block's packets as source media of the
|
|
10923
|
-
* overlay's source (7.2: an overlay coordinate yields no base SS_ID).
|
|
10924
|
-
*
|
|
10925
|
-
*
|
|
10926
|
-
*
|
|
10927
|
-
*
|
|
11163
|
+
* overlay's source (7.2: an overlay coordinate yields no base SS_ID). A
|
|
11164
|
+
* packet whose base SS_ID is determined independently (overlayBaseSsId,
|
|
11165
|
+
* unstampedBaseSsId) enters the release gate at that SS_ID, as a packet
|
|
11166
|
+
* base FEC recovered does, so it waits behind base frames still in flight,
|
|
11167
|
+
* though not for its own MPU's packets (FrameMeta.fecSbnFirst) and no
|
|
11168
|
+
* longer than unanchored; one whose base SS_ID is undetermined has no
|
|
11169
|
+
* release-gate anchor. No parse ledger, no base re-stamp, no block
|
|
11170
|
+
* advance. Each packet's wire sequence is restored from its keyframe's own
|
|
11171
|
+
* offset; without one, a stream the base never re-stamped keeps the
|
|
11172
|
+
* header's sequence and any other drops the packet.
|
|
10928
11173
|
*/
|
|
10929
11174
|
#routeOverlayRecovered(inst, blockStart, recovered) {
|
|
10930
11175
|
const { fec, repairPacketId: pid, streamName: name } = inst;
|
|
@@ -10945,40 +11190,65 @@ var MmtpRouter = class {
|
|
|
10945
11190
|
const restamped = this.#restampedStreams.has(streamKey);
|
|
10946
11191
|
const restored = /* @__PURE__ */ new Set();
|
|
10947
11192
|
const baseSsIds = /* @__PURE__ */ new Map();
|
|
11193
|
+
const gateOnly = /* @__PURE__ */ new Set();
|
|
10948
11194
|
const symbols = result.symbols.flatMap((sym) => {
|
|
11195
|
+
const overlaySsId = serial32Add(blockStart, sym.index);
|
|
10949
11196
|
const anchor = inst.offsets.get(sym.fragment.mpuSequenceNumber);
|
|
10950
11197
|
if (anchor !== void 0) {
|
|
10951
|
-
const overlaySsId = serial32Add(blockStart, sym.index);
|
|
10952
11198
|
const packetSequenceNumber = overlaySsId - anchor.psnOffset >>> 0;
|
|
10953
11199
|
restored.add(packetSequenceNumber);
|
|
10954
11200
|
const out = { ...sym, packetSequenceNumber };
|
|
10955
11201
|
const baseSsId = overlayBaseSsId(anchor, overlaySsId, packetSequenceNumber, sym.packetSequenceNumber);
|
|
10956
|
-
if (baseSsId !== void 0)
|
|
11202
|
+
if (baseSsId !== void 0) {
|
|
11203
|
+
baseSsIds.set(sym.index, baseSsId);
|
|
11204
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
11205
|
+
if (!this.#sourceSeqReceived(sourcePacketId, packetSequenceNumber, sourceName) && offset === baseSsId - packetSequenceNumber >>> 0) {
|
|
11206
|
+
this.#overlayUnstampedSsIdSeqOffsetByStream.set(streamKey, offset);
|
|
11207
|
+
}
|
|
11208
|
+
}
|
|
10957
11209
|
return [out];
|
|
10958
11210
|
}
|
|
10959
11211
|
if (!restamped) {
|
|
10960
|
-
const
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
11212
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
11213
|
+
const fedSsId = unstampedBaseSsId(offset, this.#unstampedSsIdSeqOffsetByStream.get(streamKey), sym.packetSequenceNumber);
|
|
11214
|
+
const baseSsId = fedSsId ?? unstampedBaseSsId(offset, this.#overlayUnstampedSsIdSeqOffsetByStream.get(streamKey), sym.packetSequenceNumber);
|
|
11215
|
+
if (baseSsId !== void 0) {
|
|
11216
|
+
baseSsIds.set(sym.index, baseSsId);
|
|
11217
|
+
if (fedSsId === void 0) gateOnly.add(sym.index);
|
|
11218
|
+
} else {
|
|
11219
|
+
inst.rebuilt.set(overlaySsId, sym.packetSequenceNumber);
|
|
11220
|
+
if (inst.rebuilt.size > OVERLAY_REBUILT_LIMIT) inst.rebuilt.delete(inst.rebuilt.keys().next().value);
|
|
11221
|
+
}
|
|
10966
11222
|
return [sym];
|
|
10967
11223
|
}
|
|
10968
11224
|
this.#overlayStats.unsequencedDropped++;
|
|
10969
11225
|
return [];
|
|
10970
11226
|
});
|
|
10971
11227
|
this.#overlayStats.recovered++;
|
|
11228
|
+
const mpuFirst = /* @__PURE__ */ new Map();
|
|
11229
|
+
for (const sym of symbols) {
|
|
11230
|
+
const ssId = baseSsIds.get(sym.index);
|
|
11231
|
+
const mpu = sym.fragment.mpuSequenceNumber;
|
|
11232
|
+
const first = mpuFirst.get(mpu);
|
|
11233
|
+
if (ssId !== void 0 && (first === void 0 || serial32Precedes(ssId, first))) mpuFirst.set(mpu, ssId);
|
|
11234
|
+
}
|
|
11235
|
+
const firstSsIds = /* @__PURE__ */ new Map();
|
|
11236
|
+
for (const sym of symbols) {
|
|
11237
|
+
if (baseSsIds.has(sym.index)) firstSsIds.set(sym.index, mpuFirst.get(sym.fragment.mpuSequenceNumber));
|
|
11238
|
+
}
|
|
10972
11239
|
this.#routeProcessedFecSymbols(blockStart, { ...result, symbols }, sourcePacketId, sourceName, {
|
|
10973
|
-
deliveryProvenance: inst.moqBlocks.has(blockStart) ? "mixed" : "multicast"
|
|
11240
|
+
deliveryProvenance: inst.moqBlocks.has(blockStart) ? "mixed" : "multicast",
|
|
11241
|
+
baseSsIds,
|
|
11242
|
+
firstSsIds
|
|
10974
11243
|
});
|
|
10975
11244
|
this.#noteOverlayRecoveredRaps(sourcePacketId, sourceName, streamKey, symbols.filter((sym) => restored.has(sym.packetSequenceNumber)));
|
|
10976
|
-
this.#feedOverlayRecoveredToBase(inst, blockStart, symbols, baseSsIds);
|
|
11245
|
+
this.#feedOverlayRecoveredToBase(inst, blockStart, symbols, gateOnly.size === 0 ? baseSsIds : new Map([...baseSsIds].filter(([index]) => !gateOnly.has(index))));
|
|
10977
11246
|
}
|
|
10978
11247
|
/**
|
|
10979
11248
|
* Joint decoding (BLO-52085). A packet the overlay rebuilt is a source of
|
|
10980
11249
|
* its base block too, once its base SS_ID is determined (overlayBaseSsId,
|
|
10981
|
-
* from a received member of its MPU, else unstampedBaseSsId
|
|
11250
|
+
* from a received member of its MPU, else unstampedBaseSsId at an offset a
|
|
11251
|
+
* base recovery showed; `baseSsIds` holds no other),
|
|
10982
11252
|
* so it is fed to the base decoder as a rebuilt source
|
|
10983
11253
|
* (FECManager.feedRebuiltSourceSymbol): the base block has one erasure
|
|
10984
11254
|
* fewer to solve, and its repair can recover the block's other packets.
|
|
@@ -11004,7 +11274,7 @@ var MmtpRouter = class {
|
|
|
11004
11274
|
const feeds = [];
|
|
11005
11275
|
for (const sym of symbols) {
|
|
11006
11276
|
if (duplicates.sourceSeqs.has(sym.packetSequenceNumber)) continue;
|
|
11007
|
-
const ssId = baseSsIds.get(sym);
|
|
11277
|
+
const ssId = baseSsIds.get(sym.index);
|
|
11008
11278
|
if (ssId === void 0) {
|
|
11009
11279
|
this.#overlayStats.baseUndetermined++;
|
|
11010
11280
|
continue;
|
|
@@ -11191,6 +11461,10 @@ var MmtpRouter = class {
|
|
|
11191
11461
|
get unadmittedListedDropCount() {
|
|
11192
11462
|
return this.#unadmittedListedDrops;
|
|
11193
11463
|
}
|
|
11464
|
+
/** 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. */
|
|
11465
|
+
get admittedSourceDatagramCount() {
|
|
11466
|
+
return this.#admittedSourceDatagrams;
|
|
11467
|
+
}
|
|
11194
11468
|
/** MoQ repair symbols of an unlisted track kept out of a governed FEC instance (7.2.7 step 2). */
|
|
11195
11469
|
get unlistedRepairSetAsideCount() {
|
|
11196
11470
|
return this.#unlistedRepairSetAside;
|
|
@@ -11729,7 +12003,7 @@ var MmtpRouter = class {
|
|
|
11729
12003
|
catalogTrackName
|
|
11730
12004
|
)) continue;
|
|
11731
12005
|
if (fec.isTrackConfigured?.(ownerPacketId) !== false) {
|
|
11732
|
-
fec.trackBlock(blockStart, ownerPacketId, catalogTrackName, esi, payload.evidence);
|
|
12006
|
+
fec.trackBlock(blockStart, ownerPacketId, catalogTrackName, esi, payload.evidence, true);
|
|
11733
12007
|
this.#requestFecPoke(ownerPacketId, catalogTrackName);
|
|
11734
12008
|
}
|
|
11735
12009
|
if (payload.oversized) continue;
|
|
@@ -11817,6 +12091,7 @@ var MmtpRouter = class {
|
|
|
11817
12091
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
11818
12092
|
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
11819
12093
|
this.#unstampedSsIdSeqOffsetByStream.delete(streamKey);
|
|
12094
|
+
this.#overlayUnstampedSsIdSeqOffsetByStream.delete(streamKey);
|
|
11820
12095
|
this.#multicastRapTwinByStream.delete(streamKey);
|
|
11821
12096
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
11822
12097
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
@@ -11943,6 +12218,12 @@ var MmtpRouter = class {
|
|
|
11943
12218
|
* the outgoing stream stops. The hold is bounded by the incoming stream's
|
|
11944
12219
|
* own RAP cadence, so no timer is involved.
|
|
11945
12220
|
*
|
|
12221
|
+
* While the switch is staged, the FEC release gate lets a keyframe the
|
|
12222
|
+
* overlay rebuilt reach it, on either side, when the keyframe did before
|
|
12223
|
+
* the gate anchored it (FecReleaseGate.releaseUnanchored): the switch
|
|
12224
|
+
* decides on what each side delivered, and the commit discards the gate's
|
|
12225
|
+
* frames of the outgoing stream.
|
|
12226
|
+
*
|
|
11946
12227
|
* The commit is one synchronous transition inside the frame path: the
|
|
11947
12228
|
* outgoing stream's already-admitted frames are released (its queued FEC
|
|
11948
12229
|
* gap fills only up to the RAP, since recovery can queue a frame ahead of
|
|
@@ -11993,6 +12274,9 @@ var MmtpRouter = class {
|
|
|
11993
12274
|
droppedIncomingFrames: 0
|
|
11994
12275
|
};
|
|
11995
12276
|
this.#staged = state;
|
|
12277
|
+
if (this.#parser.fecReleaseHoldsRebuilt(from.packetId, from.catalogTrackName)) {
|
|
12278
|
+
this.#requestFecPoke(from.packetId, from.catalogTrackName);
|
|
12279
|
+
}
|
|
11996
12280
|
return {
|
|
11997
12281
|
cancel: () => {
|
|
11998
12282
|
if (this.#staged !== state) return false;
|
|
@@ -12075,7 +12359,17 @@ var MmtpRouter = class {
|
|
|
12075
12359
|
*/
|
|
12076
12360
|
#routeParsedFrame(data, meta) {
|
|
12077
12361
|
if (this.#classifyPacketId(meta.packetId) === null) return;
|
|
12078
|
-
if (this.#staged !== null
|
|
12362
|
+
if (this.#staged !== null) {
|
|
12363
|
+
let consumed = false;
|
|
12364
|
+
this.#fecPokeDepth++;
|
|
12365
|
+
try {
|
|
12366
|
+
consumed = this.#interceptSwitchFrame(data, meta);
|
|
12367
|
+
} finally {
|
|
12368
|
+
this.#fecPokeDepth--;
|
|
12369
|
+
this.#flushPendingFecPokes();
|
|
12370
|
+
}
|
|
12371
|
+
if (consumed) return;
|
|
12372
|
+
}
|
|
12079
12373
|
this.#deliverParsedFrame(data, meta);
|
|
12080
12374
|
}
|
|
12081
12375
|
#commitStreamSwitch(state, rap, reason) {
|
|
@@ -12227,12 +12521,16 @@ var MmtpRouter = class {
|
|
|
12227
12521
|
this.#parser.deferFecRelease(work);
|
|
12228
12522
|
} finally {
|
|
12229
12523
|
this.#fecPokeDepth--;
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12524
|
+
this.#flushPendingFecPokes();
|
|
12525
|
+
}
|
|
12526
|
+
}
|
|
12527
|
+
/** Run the pokes requested while #fecPokeDepth was raised, once it is 0. */
|
|
12528
|
+
#flushPendingFecPokes() {
|
|
12529
|
+
if (this.#fecPokeDepth === 0 && this.#pendingFecPokes.size > 0 && !this.#disposed) {
|
|
12530
|
+
const pokes = [...this.#pendingFecPokes.values()];
|
|
12531
|
+
this.#pendingFecPokes.clear();
|
|
12532
|
+
for (const poke of pokes) {
|
|
12533
|
+
this.#parser.pokeFecRelease(poke.packetId, poke.catalogTrackName);
|
|
12236
12534
|
}
|
|
12237
12535
|
}
|
|
12238
12536
|
}
|
|
@@ -12301,6 +12599,26 @@ var MmtpRouter = class {
|
|
|
12301
12599
|
if (!fec?.terminalRetentionMsForPacket) return Infinity;
|
|
12302
12600
|
return fec.terminalRetentionMsForPacket(packetId) ?? 0;
|
|
12303
12601
|
},
|
|
12602
|
+
// Once no repair can fill a gap (FECManager.isoRepairlessWaitMs: only a
|
|
12603
|
+
// late source can), its frame waits the late-symbol allowance when the
|
|
12604
|
+
// gap holds no RAP an installed keyframe overlay could still rebuild:
|
|
12605
|
+
// lost deltas of one MPU (delta-lost), the tail of the MPU before a RAP
|
|
12606
|
+
// that opens the next one while MPU boundaries bound RAPs (rap-next), or
|
|
12607
|
+
// an audio gap. A gap that may hold one (rap-lost, rap-unknown, or any
|
|
12608
|
+
// other rap-next, whose gap may hold a whole MPU and the keyframe the
|
|
12609
|
+
// overlay protects) waits for that overlay's repair too (BLO-52085
|
|
12610
|
+
// D4). The FEC check comes first: most held gaps are not behind such a
|
|
12611
|
+
// span, and deciding one scans both frames' bitstreams.
|
|
12612
|
+
unrepairableWaitMs: (before, after, fromSbn, toSbn) => {
|
|
12613
|
+
const fec = this.#fecManager;
|
|
12614
|
+
const { packetId, catalogTrackName } = after.meta;
|
|
12615
|
+
const allowanceMs = fec?.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn);
|
|
12616
|
+
if (!fec || allowanceMs === void 0) return void 0;
|
|
12617
|
+
const decision = this.#decideGap(before, after, [], false);
|
|
12618
|
+
const mpu = before.meta.mpuSequenceNumber;
|
|
12619
|
+
const intoNextMpu = decision.reason === "rap-next" && mpu !== void 0 && after.meta.mpuSequenceNumber === mpu + 1 >>> 0 && fec.mpuBoundsRapsFor?.(packetId, catalogTrackName) === true;
|
|
12620
|
+
return decision.action === "stall" || decision.reason === "rap-next" && !intoNextMpu ? fec.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn, true) : allowanceMs;
|
|
12621
|
+
},
|
|
12304
12622
|
decide: (before, after, lostBlocks, discontinuity) => {
|
|
12305
12623
|
const decision = this.#decideGap(before, after, lostBlocks, discontinuity);
|
|
12306
12624
|
this.#onFrameGap?.(decision);
|
|
@@ -12310,6 +12628,14 @@ var MmtpRouter = class {
|
|
|
12310
12628
|
onRap: (packetId, catalogTrackName, ssId) => {
|
|
12311
12629
|
for (const observer of this.#fecRapObservers) observer(packetId, catalogTrackName, ssId);
|
|
12312
12630
|
},
|
|
12631
|
+
// A staged switch commits on when each side's frames reach it
|
|
12632
|
+
// (#interceptSwitchFrame): both sides' overlay keyframes reach it when
|
|
12633
|
+
// they did unanchored.
|
|
12634
|
+
releaseUnanchored: (packetId, catalogTrackName) => {
|
|
12635
|
+
const staged = this.#staged;
|
|
12636
|
+
const stream = { packetId, ...catalogTrackName === void 0 ? {} : { catalogTrackName } };
|
|
12637
|
+
return staged !== null && (isStream(stream, staged.from) || isStream(stream, staged.to));
|
|
12638
|
+
},
|
|
12313
12639
|
onReleased: (data, meta) => {
|
|
12314
12640
|
if (meta.trackType !== "video" || meta.mpuSequenceNumber === void 0) return;
|
|
12315
12641
|
const timing = meta.authoredTiming;
|
|
@@ -12451,6 +12777,7 @@ var MmtpRouter = class {
|
|
|
12451
12777
|
const parsed = this.#parser.parsePacket(packet);
|
|
12452
12778
|
if (!parsed) return;
|
|
12453
12779
|
const info = parsed.info;
|
|
12780
|
+
if (manifestAdmitted && !info.isRepair && ingress?.admittedBy !== USER_AGENT_VERIFIED) this.#admittedSourceDatagrams++;
|
|
12454
12781
|
if (source === "multicast" && !manifestAdmitted) {
|
|
12455
12782
|
this.#fecManager?.noteMulticastArrival?.(info.packetId, info.sequenceNumber);
|
|
12456
12783
|
}
|
|
@@ -12759,7 +13086,8 @@ var MmtpRouter = class {
|
|
|
12759
13086
|
source: parserOptions?.source,
|
|
12760
13087
|
deliveryProvenance: parserOptions?.deliveryProvenance,
|
|
12761
13088
|
catalogTrackName: parserOptions?.catalogTrackName,
|
|
12762
|
-
...parserOptions?.fecSbn === void 0 ? {} : { fecSbn: parserOptions.fecSbn }
|
|
13089
|
+
...parserOptions?.fecSbn === void 0 ? {} : { fecSbn: parserOptions.fecSbn },
|
|
13090
|
+
...parserOptions?.fecSbnFirst === void 0 ? {} : { fecSbnFirst: parserOptions.fecSbnFirst }
|
|
12763
13091
|
};
|
|
12764
13092
|
if (parsed) this.#parser.feedParsed(packet, parsed, feedOptions);
|
|
12765
13093
|
else this.#parser.feed(packet, feedOptions);
|
|
@@ -13225,7 +13553,12 @@ var MmtpRouter = class {
|
|
|
13225
13553
|
#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName, overlay) {
|
|
13226
13554
|
if (ownerPacketId == null) return;
|
|
13227
13555
|
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
13228
|
-
const fecSbnOf = (index) =>
|
|
13556
|
+
const fecSbnOf = (index) => {
|
|
13557
|
+
if (!overlay) return { fecSbn: this.#fecAnchorForRecovered(blockId, index) };
|
|
13558
|
+
const fecSbn = overlay.baseSsIds.get(index);
|
|
13559
|
+
const fecSbnFirst = overlay.firstSsIds.get(index);
|
|
13560
|
+
return fecSbn === void 0 || fecSbnFirst === void 0 ? {} : { fecSbn, fecSbnFirst };
|
|
13561
|
+
};
|
|
13229
13562
|
const streamKey = this.#mediaStreamKey(ownerPacketId, catalogTrackName);
|
|
13230
13563
|
const ssIdSeqOffset = overlay ? void 0 : this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
13231
13564
|
if (ssIdSeqOffset !== void 0) {
|