@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/no-modules.js
CHANGED
|
@@ -4576,9 +4576,10 @@ function isH264IntraSlice(nal) {
|
|
|
4576
4576
|
const sliceType = readH264SliceType(nal);
|
|
4577
4577
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
4578
4578
|
}
|
|
4579
|
+
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
4579
4580
|
function readH264SliceType(nal) {
|
|
4580
4581
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4581
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4582
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
|
|
4582
4583
|
const state = { bitOffset: 0 };
|
|
4583
4584
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4584
4585
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -4725,6 +4726,96 @@ if (void 0) {
|
|
|
4725
4726
|
]))).toBe(false);
|
|
4726
4727
|
});
|
|
4727
4728
|
});
|
|
4729
|
+
describe("readH264SliceType", () => {
|
|
4730
|
+
const wholeNalSliceType = (nal) => {
|
|
4731
|
+
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4732
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4733
|
+
const state = { bitOffset: 0 };
|
|
4734
|
+
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4735
|
+
return readUnsignedExpGolomb(rbsp, state);
|
|
4736
|
+
};
|
|
4737
|
+
const hex2 = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
|
|
4738
|
+
const ue = (value) => {
|
|
4739
|
+
const code = (value + 1).toString(2);
|
|
4740
|
+
return "0".repeat(code.length - 1) + code;
|
|
4741
|
+
};
|
|
4742
|
+
const sliceNal = (bits) => {
|
|
4743
|
+
const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
|
|
4744
|
+
const nal = [1];
|
|
4745
|
+
let zeros = 0;
|
|
4746
|
+
for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
|
|
4747
|
+
if (zeros >= 2 && byte <= 3) {
|
|
4748
|
+
nal.push(3);
|
|
4749
|
+
zeros = 0;
|
|
4750
|
+
}
|
|
4751
|
+
nal.push(byte);
|
|
4752
|
+
zeros = byte === 0 ? zeros + 1 : 0;
|
|
4753
|
+
}
|
|
4754
|
+
return Uint8Array.from(nal);
|
|
4755
|
+
};
|
|
4756
|
+
const x264Slices = [
|
|
4757
|
+
["64x48 P", hex2("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
|
|
4758
|
+
["64x48 B", hex2("419e414212fffeeade283707cb70f7"), 6, false],
|
|
4759
|
+
["64x48 non-IDR I", hex2(
|
|
4760
|
+
"4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
|
|
4761
|
+
), 7, true],
|
|
4762
|
+
["1280x720 B, escape at byte 10", hex2(
|
|
4763
|
+
"01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
|
|
4764
|
+
), 6, false],
|
|
4765
|
+
["1280x720 P, escape at byte 15", hex2(
|
|
4766
|
+
"41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
|
|
4767
|
+
), 5, false],
|
|
4768
|
+
["1280x720 B, escape at byte 22", hex2("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
|
|
4769
|
+
["7680x4320 IDR, first_mb_in_slice 97440", hex2(
|
|
4770
|
+
"650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
|
|
4771
|
+
), null, true],
|
|
4772
|
+
["7680x4320 P, first_mb_in_slice 32640", hex2(
|
|
4773
|
+
"410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
|
|
4774
|
+
), 5, false],
|
|
4775
|
+
["7680x4320 P, first_mb_in_slice 97440", hex2(
|
|
4776
|
+
"410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
|
|
4777
|
+
), 5, false]
|
|
4778
|
+
];
|
|
4779
|
+
const syntheticSlices = [
|
|
4780
|
+
["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
|
|
4781
|
+
["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
|
|
4782
|
+
["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
|
|
4783
|
+
["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
|
|
4784
|
+
["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
|
|
4785
|
+
["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
|
|
4786
|
+
["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
|
|
4787
|
+
["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
|
|
4788
|
+
];
|
|
4789
|
+
test("reads the slice_type of real and synthetic slices", () => {
|
|
4790
|
+
for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
|
|
4791
|
+
expect(readH264SliceType(nal), name).toBe(sliceType);
|
|
4792
|
+
}
|
|
4793
|
+
});
|
|
4794
|
+
test("matches the whole-NAL unescape at every truncation", () => {
|
|
4795
|
+
for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
|
|
4796
|
+
for (let end = 0; end <= nal.length; end++) {
|
|
4797
|
+
const cut = nal.subarray(0, end);
|
|
4798
|
+
expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
});
|
|
4802
|
+
test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
|
|
4803
|
+
const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
|
|
4804
|
+
let seed = 1;
|
|
4805
|
+
const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
|
|
4806
|
+
for (let i = 0; i < 5e3; i++) {
|
|
4807
|
+
const nal = new Uint8Array(2 + next() % 63);
|
|
4808
|
+
nal[0] = 65;
|
|
4809
|
+
for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
|
|
4810
|
+
expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
|
|
4811
|
+
}
|
|
4812
|
+
});
|
|
4813
|
+
test("classifies the x264 slices as keyframes or not", () => {
|
|
4814
|
+
for (const [name, nal, , keyframe] of x264Slices) {
|
|
4815
|
+
expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
|
|
4816
|
+
}
|
|
4817
|
+
});
|
|
4818
|
+
});
|
|
4728
4819
|
describe("avccToAnnexB", () => {
|
|
4729
4820
|
test("converts with SPS/PPS on keyframe", () => {
|
|
4730
4821
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|
|
@@ -5914,6 +6005,9 @@ function authoredGap(before, after) {
|
|
|
5914
6005
|
function ssIdAfter(a, b) {
|
|
5915
6006
|
return (a - b | 0) > 0;
|
|
5916
6007
|
}
|
|
6008
|
+
function holdsRebuilt(stream) {
|
|
6009
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
|
|
6010
|
+
}
|
|
5917
6011
|
var FecReleaseSequencer = class {
|
|
5918
6012
|
#streams = /* @__PURE__ */ new Map();
|
|
5919
6013
|
#gate;
|
|
@@ -5976,6 +6070,7 @@ var FecReleaseSequencer = class {
|
|
|
5976
6070
|
stream.lastSbn = void 0;
|
|
5977
6071
|
stream.discontinuity = false;
|
|
5978
6072
|
stream.rapSsId = void 0;
|
|
6073
|
+
stream.sourced = false;
|
|
5979
6074
|
}
|
|
5980
6075
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
5981
6076
|
this.#recordStat("droppedStale");
|
|
@@ -6002,6 +6097,7 @@ var FecReleaseSequencer = class {
|
|
|
6002
6097
|
if (compareFrameOrder(stream.buf[mid], frame) < 0) lo = mid + 1;
|
|
6003
6098
|
else hi = mid;
|
|
6004
6099
|
}
|
|
6100
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true;
|
|
6005
6101
|
stream.buf.splice(lo, 0, frame);
|
|
6006
6102
|
this.#drainUnlessDeferred(stream);
|
|
6007
6103
|
}
|
|
@@ -6037,6 +6133,41 @@ var FecReleaseSequencer = class {
|
|
|
6037
6133
|
}
|
|
6038
6134
|
return false;
|
|
6039
6135
|
}
|
|
6136
|
+
/**
|
|
6137
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
6138
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
6139
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
6140
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
6141
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
6142
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
6143
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
6144
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
6145
|
+
* released.
|
|
6146
|
+
*/
|
|
6147
|
+
unsource(packetId, catalogTrackName) {
|
|
6148
|
+
for (const stream of this.#streams.values()) {
|
|
6149
|
+
if (stream.packetId === packetId && (catalogTrackName === void 0 || stream.catalogTrackName === catalogTrackName)) {
|
|
6150
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
6151
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
6152
|
+
else this.#drain(stream, true);
|
|
6153
|
+
}
|
|
6154
|
+
stream.sourced = false;
|
|
6155
|
+
}
|
|
6156
|
+
}
|
|
6157
|
+
}
|
|
6158
|
+
/**
|
|
6159
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
6160
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
6161
|
+
* packetId.
|
|
6162
|
+
*/
|
|
6163
|
+
holdsRebuilt(packetId, catalogTrackName) {
|
|
6164
|
+
for (const stream of this.#streams.values()) {
|
|
6165
|
+
if (stream.packetId !== packetId) continue;
|
|
6166
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
6167
|
+
if (holdsRebuilt(stream)) return true;
|
|
6168
|
+
}
|
|
6169
|
+
return false;
|
|
6170
|
+
}
|
|
6040
6171
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
6041
6172
|
poke(streamKey) {
|
|
6042
6173
|
if (streamKey !== void 0) {
|
|
@@ -6128,16 +6259,32 @@ var FecReleaseSequencer = class {
|
|
|
6128
6259
|
last: null,
|
|
6129
6260
|
lastSbn: void 0,
|
|
6130
6261
|
discontinuity: false,
|
|
6131
|
-
rapSsId: void 0
|
|
6262
|
+
rapSsId: void 0,
|
|
6263
|
+
sourced: false,
|
|
6264
|
+
draining: 0
|
|
6132
6265
|
};
|
|
6133
6266
|
this.#streams.set(streamKey, stream);
|
|
6134
6267
|
}
|
|
6135
6268
|
return stream;
|
|
6136
6269
|
}
|
|
6137
|
-
#
|
|
6270
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
6271
|
+
#drain(stream, asUnanchored = false) {
|
|
6272
|
+
stream.draining++;
|
|
6273
|
+
try {
|
|
6274
|
+
this.#drainLoop(stream, asUnanchored);
|
|
6275
|
+
} finally {
|
|
6276
|
+
stream.draining--;
|
|
6277
|
+
}
|
|
6278
|
+
}
|
|
6279
|
+
#drainLoop(stream, asUnanchored) {
|
|
6138
6280
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
6139
6281
|
const head = stream.buf[0];
|
|
6140
6282
|
const last = stream.last;
|
|
6283
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
6284
|
+
stream.buf.shift();
|
|
6285
|
+
this.#release(stream, head, void 0);
|
|
6286
|
+
continue;
|
|
6287
|
+
}
|
|
6141
6288
|
if (stream.discontinuity) {
|
|
6142
6289
|
stream.discontinuity = false;
|
|
6143
6290
|
stream.buf.shift();
|
|
@@ -6151,9 +6298,10 @@ var FecReleaseSequencer = class {
|
|
|
6151
6298
|
}
|
|
6152
6299
|
const headSbn = head.meta.fecSbn;
|
|
6153
6300
|
const from = stream.lastSbn ?? headSbn;
|
|
6154
|
-
const to = headSbn ?? stream.lastSbn;
|
|
6301
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn;
|
|
6155
6302
|
let lost = [];
|
|
6156
6303
|
const unanchored = from === void 0 && to === void 0;
|
|
6304
|
+
let unresolved = false;
|
|
6157
6305
|
if (from !== void 0 && to !== void 0) {
|
|
6158
6306
|
const resolved = this.#gate.resolvedLoss(
|
|
6159
6307
|
stream.packetId,
|
|
@@ -6162,7 +6310,8 @@ var FecReleaseSequencer = class {
|
|
|
6162
6310
|
Math.max(from, to),
|
|
6163
6311
|
from
|
|
6164
6312
|
);
|
|
6165
|
-
|
|
6313
|
+
unresolved = resolved === null;
|
|
6314
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored) && !this.#unrepairableWaitOver(last, head, from, to)) {
|
|
6166
6315
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
6167
6316
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
6168
6317
|
this.#recordStat("forcedWindowFlushes");
|
|
@@ -6170,22 +6319,61 @@ var FecReleaseSequencer = class {
|
|
|
6170
6319
|
this.#release(stream, head, this.#gate.decide(last, head, [], true));
|
|
6171
6320
|
continue;
|
|
6172
6321
|
}
|
|
6173
|
-
lost = resolved;
|
|
6322
|
+
lost = resolved ?? [];
|
|
6174
6323
|
}
|
|
6175
6324
|
stream.buf.shift();
|
|
6176
6325
|
this.#release(
|
|
6177
6326
|
stream,
|
|
6178
6327
|
head,
|
|
6179
|
-
lost.length > 0 || unanchored || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
6328
|
+
lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
6180
6329
|
);
|
|
6181
6330
|
}
|
|
6182
6331
|
}
|
|
6332
|
+
/** The head has waited out a gap only a late source can still fill (FecReleaseGate.unrepairableWaitMs). */
|
|
6333
|
+
#unrepairableWaitOver(last, head, from, to) {
|
|
6334
|
+
const waitMs = this.#gate.unrepairableWaitMs?.(last, head, from, to);
|
|
6335
|
+
return waitMs !== void 0 && performance.now() - head.arrivedAtMs >= waitMs;
|
|
6336
|
+
}
|
|
6337
|
+
/**
|
|
6338
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
6339
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
6340
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
6341
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
6342
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
6343
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
6344
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
6345
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
6346
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
6347
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
6348
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
6349
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
6350
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
6351
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
6352
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
6353
|
+
*/
|
|
6354
|
+
#cursorPassed(stream, asUnanchored) {
|
|
6355
|
+
let at = -1;
|
|
6356
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
6357
|
+
const frame = stream.buf[i];
|
|
6358
|
+
if (frame.meta.fecSbnFirst !== void 0 || frame.meta.fecSbn === void 0) {
|
|
6359
|
+
frame.passed = true;
|
|
6360
|
+
if (at < 0) at = i;
|
|
6361
|
+
} else if (frame.passed !== true) break;
|
|
6362
|
+
}
|
|
6363
|
+
if (at < 0) return false;
|
|
6364
|
+
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));
|
|
6365
|
+
}
|
|
6183
6366
|
#release(stream, frame, decision) {
|
|
6367
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0;
|
|
6368
|
+
if (stale) this.#recordStat("droppedStale");
|
|
6184
6369
|
if (decision) frame.meta.gapBefore = decision;
|
|
6185
6370
|
stream.last = frame;
|
|
6186
|
-
if (frame.meta.fecSbn !== void 0
|
|
6371
|
+
if (frame.meta.fecSbn !== void 0 && (frame.meta.fecSbnFirst === void 0 || stream.lastSbn !== void 0)) {
|
|
6372
|
+
stream.lastSbn = frame.meta.fecSbn;
|
|
6373
|
+
}
|
|
6374
|
+
if (frame.meta.recovered !== true) stream.sourced = true;
|
|
6187
6375
|
this.#gate.onReleased?.(frame.data, frame.meta);
|
|
6188
|
-
this.#emit(frame.data, frame.meta);
|
|
6376
|
+
if (!stale) this.#emit(frame.data, frame.meta);
|
|
6189
6377
|
}
|
|
6190
6378
|
};
|
|
6191
6379
|
var FMPU_BOX_TYPES = /* @__PURE__ */ new Set(["ftyp", "moov", "moof"]);
|
|
@@ -6446,11 +6634,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6446
6634
|
/**
|
|
6447
6635
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
6448
6636
|
*
|
|
6449
|
-
*
|
|
6450
|
-
*
|
|
6451
|
-
*
|
|
6452
|
-
*
|
|
6453
|
-
*
|
|
6637
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
6638
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
6639
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
6640
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
6641
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
6642
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
6454
6643
|
*/
|
|
6455
6644
|
get timingBudgetStats() {
|
|
6456
6645
|
return {
|
|
@@ -6510,6 +6699,14 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6510
6699
|
fecReleaseRapAbove(packetId, catalogTrackName, ssId) {
|
|
6511
6700
|
return this.#fecSequencer?.rapAbove(packetId, catalogTrackName, ssId) ?? false;
|
|
6512
6701
|
}
|
|
6702
|
+
/** See FecReleaseSequencer.unsource. */
|
|
6703
|
+
unsourceFecRelease(packetId, catalogTrackName) {
|
|
6704
|
+
this.#fecSequencer?.unsource(packetId, catalogTrackName);
|
|
6705
|
+
}
|
|
6706
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
6707
|
+
fecReleaseHoldsRebuilt(packetId, catalogTrackName) {
|
|
6708
|
+
return this.#fecSequencer?.holdsRebuilt(packetId, catalogTrackName) ?? false;
|
|
6709
|
+
}
|
|
6513
6710
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
6514
6711
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
6515
6712
|
if (!this.#fecSequencer) return;
|
|
@@ -6763,7 +6960,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6763
6960
|
if (!resolver2?.initialized) return this.#drop("fragment-no-resolver");
|
|
6764
6961
|
const pendingBefore = resolver2.pendingSampleCount;
|
|
6765
6962
|
const evictedBefore = resolver2.evictedSampleCount;
|
|
6766
|
-
const remaining = this.#maxPendingTimingSamples -
|
|
6963
|
+
const remaining = this.#maxPendingTimingSamples - resolver2.pendingSampleCount;
|
|
6767
6964
|
const admitted = resolver2.addMovieFragment(
|
|
6768
6965
|
mpu.mpuSequenceNumber,
|
|
6769
6966
|
data,
|
|
@@ -6836,7 +7033,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6836
7033
|
info,
|
|
6837
7034
|
resolver,
|
|
6838
7035
|
options?.recovered === true,
|
|
6839
|
-
options?.fecSbn
|
|
7036
|
+
options?.fecSbn,
|
|
7037
|
+
options?.fecSbnFirst
|
|
6840
7038
|
);
|
|
6841
7039
|
if (deferred.record === void 0) this.#countDeferredOutcome(deferred.reason);
|
|
6842
7040
|
}
|
|
@@ -6929,7 +7127,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6929
7127
|
info,
|
|
6930
7128
|
resolver,
|
|
6931
7129
|
options?.recovered === true,
|
|
6932
|
-
options?.fecSbn
|
|
7130
|
+
options?.fecSbn,
|
|
7131
|
+
options?.fecSbnFirst
|
|
6933
7132
|
);
|
|
6934
7133
|
if (outcome.record !== void 0) return outcome.record;
|
|
6935
7134
|
return this.#drop(outcome.reason);
|
|
@@ -6949,7 +7148,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6949
7148
|
* attribution exists to keep readable. Leaving the choice at the call site
|
|
6950
7149
|
* is what keeps both true.
|
|
6951
7150
|
*/
|
|
6952
|
-
#emitCombinedSample(combined, info, resolver, recovered, fecSbn) {
|
|
7151
|
+
#emitCombinedSample(combined, info, resolver, recovered, fecSbn, fecSbnFirst) {
|
|
6953
7152
|
const timing = resolver.sampleTiming(
|
|
6954
7153
|
combined.mpuSequenceNumber,
|
|
6955
7154
|
combined.movieFragmentSequenceNumber,
|
|
@@ -6966,6 +7165,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6966
7165
|
);
|
|
6967
7166
|
if (!meta) return { reason: "combined-meta-build-failed" };
|
|
6968
7167
|
if (fecSbn !== void 0) meta.fecSbn = fecSbn;
|
|
7168
|
+
if (fecSbnFirst !== void 0) meta.fecSbnFirst = fecSbnFirst;
|
|
6969
7169
|
if (!resolver.consumeSample(
|
|
6970
7170
|
combined.mpuSequenceNumber,
|
|
6971
7171
|
combined.movieFragmentSequenceNumber,
|