@blockcast/mmt-container 2.2.0-main.da2e7cd1dd5d → 2.2.0-main.ef09fa701ea8
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 +1447 -179
- package/dist/browser-runtime.js.map +3 -3
- package/dist/cmaf-block-assembler.js +92 -1
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/codec-utils.d.ts.map +1 -1
- package/dist/codec-utils.js +92 -1
- package/dist/codec-utils.js.map +2 -2
- package/dist/delivery-catalog.js +2 -1
- package/dist/delivery-catalog.js.map +2 -2
- package/dist/delta-fallback-config.js.map +1 -1
- package/dist/fec-manager.d.ts +105 -14
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +502 -58
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-worker-setup.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +48 -13
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +97 -25
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/iso-bmff-timing.d.ts +10 -1
- package/dist/iso-bmff-timing.d.ts.map +1 -1
- package/dist/iso-bmff-timing.js +36 -2
- package/dist/iso-bmff-timing.js.map +2 -2
- package/dist/media-router.js.map +1 -1
- package/dist/mmtp-container-parser.d.ts +104 -12
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +308 -27
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +310 -30
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +307 -27
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +36 -8
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +675 -75
- 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 +1267 -152
- package/dist/multicast-manager.js.map +3 -3
- package/dist/multicast-transport.js +4 -3
- package/dist/multicast-transport.js.map +2 -2
- package/dist/no-modules.js +307 -27
- package/dist/no-modules.js.map +3 -3
- package/dist/repair-fetch.d.ts +38 -8
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +286 -27
- package/dist/repair-fetch.js.map +3 -3
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +1 -0
- package/dist/track-session.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +307 -27
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/codec-utils.ts +121 -1
- package/src/fec-manager.ts +571 -32
- package/src/index.ts +3 -0
- package/src/iso-block-locator.ts +133 -31
- package/src/iso-bmff-timing.ts +40 -1
- package/src/mmtp-container-parser.ts +341 -32
- package/src/mmtp-router.ts +600 -55
- package/src/multicast-manager.ts +136 -16
- package/src/repair-fetch.ts +366 -50
- package/src/track-session.ts +3 -0
|
@@ -4650,9 +4650,10 @@ var BlockcastMmt = (() => {
|
|
|
4650
4650
|
const sliceType = readH264SliceType(nal);
|
|
4651
4651
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
4652
4652
|
}
|
|
4653
|
+
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
4653
4654
|
function readH264SliceType(nal) {
|
|
4654
4655
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4655
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4656
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
|
|
4656
4657
|
const state = { bitOffset: 0 };
|
|
4657
4658
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4658
4659
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -4799,6 +4800,96 @@ var BlockcastMmt = (() => {
|
|
|
4799
4800
|
]))).toBe(false);
|
|
4800
4801
|
});
|
|
4801
4802
|
});
|
|
4803
|
+
describe("readH264SliceType", () => {
|
|
4804
|
+
const wholeNalSliceType = (nal) => {
|
|
4805
|
+
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4806
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4807
|
+
const state = { bitOffset: 0 };
|
|
4808
|
+
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4809
|
+
return readUnsignedExpGolomb(rbsp, state);
|
|
4810
|
+
};
|
|
4811
|
+
const hex2 = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
|
|
4812
|
+
const ue = (value) => {
|
|
4813
|
+
const code = (value + 1).toString(2);
|
|
4814
|
+
return "0".repeat(code.length - 1) + code;
|
|
4815
|
+
};
|
|
4816
|
+
const sliceNal = (bits) => {
|
|
4817
|
+
const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
|
|
4818
|
+
const nal = [1];
|
|
4819
|
+
let zeros = 0;
|
|
4820
|
+
for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
|
|
4821
|
+
if (zeros >= 2 && byte <= 3) {
|
|
4822
|
+
nal.push(3);
|
|
4823
|
+
zeros = 0;
|
|
4824
|
+
}
|
|
4825
|
+
nal.push(byte);
|
|
4826
|
+
zeros = byte === 0 ? zeros + 1 : 0;
|
|
4827
|
+
}
|
|
4828
|
+
return Uint8Array.from(nal);
|
|
4829
|
+
};
|
|
4830
|
+
const x264Slices = [
|
|
4831
|
+
["64x48 P", hex2("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
|
|
4832
|
+
["64x48 B", hex2("419e414212fffeeade283707cb70f7"), 6, false],
|
|
4833
|
+
["64x48 non-IDR I", hex2(
|
|
4834
|
+
"4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
|
|
4835
|
+
), 7, true],
|
|
4836
|
+
["1280x720 B, escape at byte 10", hex2(
|
|
4837
|
+
"01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
|
|
4838
|
+
), 6, false],
|
|
4839
|
+
["1280x720 P, escape at byte 15", hex2(
|
|
4840
|
+
"41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
|
|
4841
|
+
), 5, false],
|
|
4842
|
+
["1280x720 B, escape at byte 22", hex2("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
|
|
4843
|
+
["7680x4320 IDR, first_mb_in_slice 97440", hex2(
|
|
4844
|
+
"650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
|
|
4845
|
+
), null, true],
|
|
4846
|
+
["7680x4320 P, first_mb_in_slice 32640", hex2(
|
|
4847
|
+
"410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
|
|
4848
|
+
), 5, false],
|
|
4849
|
+
["7680x4320 P, first_mb_in_slice 97440", hex2(
|
|
4850
|
+
"410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
|
|
4851
|
+
), 5, false]
|
|
4852
|
+
];
|
|
4853
|
+
const syntheticSlices = [
|
|
4854
|
+
["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
|
|
4855
|
+
["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
|
|
4856
|
+
["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
|
|
4857
|
+
["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
|
|
4858
|
+
["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
|
|
4859
|
+
["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
|
|
4860
|
+
["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
|
|
4861
|
+
["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
|
|
4862
|
+
];
|
|
4863
|
+
test("reads the slice_type of real and synthetic slices", () => {
|
|
4864
|
+
for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
|
|
4865
|
+
expect(readH264SliceType(nal), name).toBe(sliceType);
|
|
4866
|
+
}
|
|
4867
|
+
});
|
|
4868
|
+
test("matches the whole-NAL unescape at every truncation", () => {
|
|
4869
|
+
for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
|
|
4870
|
+
for (let end = 0; end <= nal.length; end++) {
|
|
4871
|
+
const cut = nal.subarray(0, end);
|
|
4872
|
+
expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
});
|
|
4876
|
+
test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
|
|
4877
|
+
const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
|
|
4878
|
+
let seed = 1;
|
|
4879
|
+
const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
|
|
4880
|
+
for (let i = 0; i < 5e3; i++) {
|
|
4881
|
+
const nal = new Uint8Array(2 + next() % 63);
|
|
4882
|
+
nal[0] = 65;
|
|
4883
|
+
for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
|
|
4884
|
+
expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
|
|
4885
|
+
}
|
|
4886
|
+
});
|
|
4887
|
+
test("classifies the x264 slices as keyframes or not", () => {
|
|
4888
|
+
for (const [name, nal, , keyframe] of x264Slices) {
|
|
4889
|
+
expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
|
|
4890
|
+
}
|
|
4891
|
+
});
|
|
4892
|
+
});
|
|
4802
4893
|
describe("avccToAnnexB", () => {
|
|
4803
4894
|
test("converts with SPS/PPS on keyframe", () => {
|
|
4804
4895
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|
|
@@ -5633,13 +5724,21 @@ var BlockcastMmt = (() => {
|
|
|
5633
5724
|
function sameSample(a, b) {
|
|
5634
5725
|
return a.decodeTime === b.decodeTime && a.presentationTime === b.presentationTime && a.duration === b.duration && a.timescale === b.timescale && a.size === b.size && a.bytePosition === b.bytePosition;
|
|
5635
5726
|
}
|
|
5636
|
-
var _track, _fragments, _pendingSamples, _evictedSamples, _lastMovieFragmentRejection, _IsoBmffTimingResolver_instances, evictOldestFragment_fn, clearSlot_fn;
|
|
5727
|
+
var _track, _fragments, _firstSamples, _delivered, _pendingSamples, _evictedSamples, _lastMovieFragmentRejection, _IsoBmffTimingResolver_instances, evictOldestFragment_fn, clearSlot_fn;
|
|
5637
5728
|
var IsoBmffTimingResolver = class {
|
|
5638
5729
|
constructor(maxPendingSamples) {
|
|
5639
5730
|
this.maxPendingSamples = maxPendingSamples;
|
|
5640
5731
|
__privateAdd(this, _IsoBmffTimingResolver_instances);
|
|
5641
5732
|
__privateAdd(this, _track, null);
|
|
5642
5733
|
__privateAdd(this, _fragments, /* @__PURE__ */ new Map());
|
|
5734
|
+
/** First sample of each pending fragment, kept in `#delivered` with its sample count. */
|
|
5735
|
+
__privateAdd(this, _firstSamples, /* @__PURE__ */ new Map());
|
|
5736
|
+
/**
|
|
5737
|
+
* First sample and sample count of the newest fragments whose every slot was
|
|
5738
|
+
* cleared. Abandonment counts: `releaseSample` clears a slot too, which
|
|
5739
|
+
* matches the combiner, since it retires an abandoned sample as well.
|
|
5740
|
+
*/
|
|
5741
|
+
__privateAdd(this, _delivered, /* @__PURE__ */ new Map());
|
|
5643
5742
|
__privateAdd(this, _pendingSamples, 0);
|
|
5644
5743
|
__privateAdd(this, _evictedSamples, 0);
|
|
5645
5744
|
__privateAdd(this, _lastMovieFragmentRejection, null);
|
|
@@ -5647,6 +5746,10 @@ var BlockcastMmt = (() => {
|
|
|
5647
5746
|
throw new Error("[IsoBmffTimingResolver] maxPendingSamples must be a positive integer");
|
|
5648
5747
|
}
|
|
5649
5748
|
}
|
|
5749
|
+
/** True once an FT=0 has bound the track that FT=1 timing is read against. */
|
|
5750
|
+
get initialized() {
|
|
5751
|
+
return __privateGet(this, _track) !== null;
|
|
5752
|
+
}
|
|
5650
5753
|
get pendingSampleCount() {
|
|
5651
5754
|
return __privateGet(this, _pendingSamples);
|
|
5652
5755
|
}
|
|
@@ -5670,7 +5773,14 @@ var BlockcastMmt = (() => {
|
|
|
5670
5773
|
__privateSet(this, _track, timing);
|
|
5671
5774
|
return true;
|
|
5672
5775
|
}
|
|
5673
|
-
|
|
5776
|
+
/**
|
|
5777
|
+
* `recovered` marks an FEC-recovered copy. A recovered block hands back
|
|
5778
|
+
* every FT=1 it holds, the received ones included, so a recovered copy of a
|
|
5779
|
+
* fragment whose samples are all done is a duplicate: admitting it again
|
|
5780
|
+
* would charge stale timing and could displace the live MPU's. A source
|
|
5781
|
+
* copy is still admitted again (a rendition switch re-arms timing that way).
|
|
5782
|
+
*/
|
|
5783
|
+
addMovieFragment(mpuSequenceNumber, data, additionalSampleLimit = this.maxPendingSamples, recovered = false) {
|
|
5674
5784
|
__privateSet(this, _lastMovieFragmentRejection, null);
|
|
5675
5785
|
if (!Number.isInteger(additionalSampleLimit) || additionalSampleLimit < 0) {
|
|
5676
5786
|
__privateSet(this, _lastMovieFragmentRejection, "invalid");
|
|
@@ -5696,6 +5806,8 @@ var BlockcastMmt = (() => {
|
|
|
5696
5806
|
(sample, index) => sample !== null && sameSample(sample, parsed.samples[index])
|
|
5697
5807
|
);
|
|
5698
5808
|
}
|
|
5809
|
+
const delivered = recovered ? __privateGet(this, _delivered).get(key) : void 0;
|
|
5810
|
+
if (delivered && delivered.sampleCount === parsed.samples.length && sameSample(delivered.first, parsed.samples[0])) return true;
|
|
5699
5811
|
let freed = 0;
|
|
5700
5812
|
while (__privateGet(this, _fragments).size > 0 && (__privateGet(this, _pendingSamples) + parsed.samples.length > this.maxPendingSamples || parsed.samples.length - freed > additionalSampleLimit)) {
|
|
5701
5813
|
freed += __privateMethod(this, _IsoBmffTimingResolver_instances, evictOldestFragment_fn).call(this);
|
|
@@ -5709,6 +5821,7 @@ var BlockcastMmt = (() => {
|
|
|
5709
5821
|
return false;
|
|
5710
5822
|
}
|
|
5711
5823
|
__privateGet(this, _fragments).set(key, [...parsed.samples]);
|
|
5824
|
+
__privateGet(this, _firstSamples).set(key, parsed.samples[0]);
|
|
5712
5825
|
__privateSet(this, _pendingSamples, __privateGet(this, _pendingSamples) + parsed.samples.length);
|
|
5713
5826
|
return true;
|
|
5714
5827
|
}
|
|
@@ -5755,11 +5868,15 @@ var BlockcastMmt = (() => {
|
|
|
5755
5868
|
reset() {
|
|
5756
5869
|
__privateSet(this, _track, null);
|
|
5757
5870
|
__privateGet(this, _fragments).clear();
|
|
5871
|
+
__privateGet(this, _firstSamples).clear();
|
|
5872
|
+
__privateGet(this, _delivered).clear();
|
|
5758
5873
|
__privateSet(this, _pendingSamples, 0);
|
|
5759
5874
|
}
|
|
5760
5875
|
};
|
|
5761
5876
|
_track = new WeakMap();
|
|
5762
5877
|
_fragments = new WeakMap();
|
|
5878
|
+
_firstSamples = new WeakMap();
|
|
5879
|
+
_delivered = new WeakMap();
|
|
5763
5880
|
_pendingSamples = new WeakMap();
|
|
5764
5881
|
_evictedSamples = new WeakMap();
|
|
5765
5882
|
_lastMovieFragmentRejection = new WeakMap();
|
|
@@ -5778,6 +5895,7 @@ var BlockcastMmt = (() => {
|
|
|
5778
5895
|
let live = 0;
|
|
5779
5896
|
for (const sample of samples) if (sample !== null) live++;
|
|
5780
5897
|
__privateGet(this, _fragments).delete(oldest);
|
|
5898
|
+
__privateGet(this, _firstSamples).delete(oldest);
|
|
5781
5899
|
__privateSet(this, _pendingSamples, __privateGet(this, _pendingSamples) - live);
|
|
5782
5900
|
__privateSet(this, _evictedSamples, __privateGet(this, _evictedSamples) + live);
|
|
5783
5901
|
return live;
|
|
@@ -5793,7 +5911,16 @@ var BlockcastMmt = (() => {
|
|
|
5793
5911
|
if (!samples || !samples[index]) return false;
|
|
5794
5912
|
samples[index] = null;
|
|
5795
5913
|
__privateWrapper(this, _pendingSamples)._--;
|
|
5796
|
-
if (samples.every((value) => value === null))
|
|
5914
|
+
if (samples.every((value) => value === null)) {
|
|
5915
|
+
__privateGet(this, _fragments).delete(key);
|
|
5916
|
+
const first = __privateGet(this, _firstSamples).get(key);
|
|
5917
|
+
__privateGet(this, _firstSamples).delete(key);
|
|
5918
|
+
__privateGet(this, _delivered).delete(key);
|
|
5919
|
+
__privateGet(this, _delivered).set(key, { first, sampleCount: samples.length });
|
|
5920
|
+
if (__privateGet(this, _delivered).size > this.maxPendingSamples) {
|
|
5921
|
+
__privateGet(this, _delivered).delete(__privateGet(this, _delivered).keys().next().value);
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5797
5924
|
return true;
|
|
5798
5925
|
};
|
|
5799
5926
|
function fragmentKey(mpuSequenceNumber, movieFragmentSequenceNumber) {
|
|
@@ -5969,7 +6096,10 @@ var BlockcastMmt = (() => {
|
|
|
5969
6096
|
function ssIdAfter(a, b) {
|
|
5970
6097
|
return (a - b | 0) > 0;
|
|
5971
6098
|
}
|
|
5972
|
-
|
|
6099
|
+
function holdsRebuilt(stream) {
|
|
6100
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
|
|
6101
|
+
}
|
|
6102
|
+
var _streams2, _gate, _emit2, _recordStat2, _deferDepth, _deferredStreams, _FecReleaseSequencer_instances, drainUnlessDeferred_fn, streamFor_fn2, drain_fn, drainLoop_fn, unrepairableWaitOver_fn, cursorPassed_fn, release_fn;
|
|
5973
6103
|
var FecReleaseSequencer = class {
|
|
5974
6104
|
constructor(gate, emit, recordStat) {
|
|
5975
6105
|
__privateAdd(this, _FecReleaseSequencer_instances);
|
|
@@ -6029,6 +6159,7 @@ var BlockcastMmt = (() => {
|
|
|
6029
6159
|
stream.lastSbn = void 0;
|
|
6030
6160
|
stream.discontinuity = false;
|
|
6031
6161
|
stream.rapSsId = void 0;
|
|
6162
|
+
stream.sourced = false;
|
|
6032
6163
|
}
|
|
6033
6164
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
6034
6165
|
__privateGet(this, _recordStat2).call(this, "droppedStale");
|
|
@@ -6055,6 +6186,7 @@ var BlockcastMmt = (() => {
|
|
|
6055
6186
|
if (compareFrameOrder(stream.buf[mid], frame) < 0) lo = mid + 1;
|
|
6056
6187
|
else hi = mid;
|
|
6057
6188
|
}
|
|
6189
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true;
|
|
6058
6190
|
stream.buf.splice(lo, 0, frame);
|
|
6059
6191
|
__privateMethod(this, _FecReleaseSequencer_instances, drainUnlessDeferred_fn).call(this, stream);
|
|
6060
6192
|
}
|
|
@@ -6090,6 +6222,41 @@ var BlockcastMmt = (() => {
|
|
|
6090
6222
|
}
|
|
6091
6223
|
return false;
|
|
6092
6224
|
}
|
|
6225
|
+
/**
|
|
6226
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
6227
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
6228
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
6229
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
6230
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
6231
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
6232
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
6233
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
6234
|
+
* released.
|
|
6235
|
+
*/
|
|
6236
|
+
unsource(packetId, catalogTrackName) {
|
|
6237
|
+
for (const stream of __privateGet(this, _streams2).values()) {
|
|
6238
|
+
if (stream.packetId === packetId && (catalogTrackName === void 0 || stream.catalogTrackName === catalogTrackName)) {
|
|
6239
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
6240
|
+
if (__privateGet(this, _deferDepth) > 0) __privateGet(this, _deferredStreams).add(stream);
|
|
6241
|
+
else __privateMethod(this, _FecReleaseSequencer_instances, drain_fn).call(this, stream, true);
|
|
6242
|
+
}
|
|
6243
|
+
stream.sourced = false;
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
6246
|
+
}
|
|
6247
|
+
/**
|
|
6248
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
6249
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
6250
|
+
* packetId.
|
|
6251
|
+
*/
|
|
6252
|
+
holdsRebuilt(packetId, catalogTrackName) {
|
|
6253
|
+
for (const stream of __privateGet(this, _streams2).values()) {
|
|
6254
|
+
if (stream.packetId !== packetId) continue;
|
|
6255
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
6256
|
+
if (holdsRebuilt(stream)) return true;
|
|
6257
|
+
}
|
|
6258
|
+
return false;
|
|
6259
|
+
}
|
|
6093
6260
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
6094
6261
|
poke(streamKey) {
|
|
6095
6262
|
if (streamKey !== void 0) {
|
|
@@ -6193,16 +6360,32 @@ var BlockcastMmt = (() => {
|
|
|
6193
6360
|
last: null,
|
|
6194
6361
|
lastSbn: void 0,
|
|
6195
6362
|
discontinuity: false,
|
|
6196
|
-
rapSsId: void 0
|
|
6363
|
+
rapSsId: void 0,
|
|
6364
|
+
sourced: false,
|
|
6365
|
+
draining: 0
|
|
6197
6366
|
};
|
|
6198
6367
|
__privateGet(this, _streams2).set(streamKey, stream);
|
|
6199
6368
|
}
|
|
6200
6369
|
return stream;
|
|
6201
6370
|
};
|
|
6202
|
-
|
|
6371
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
6372
|
+
drain_fn = function(stream, asUnanchored = false) {
|
|
6373
|
+
stream.draining++;
|
|
6374
|
+
try {
|
|
6375
|
+
__privateMethod(this, _FecReleaseSequencer_instances, drainLoop_fn).call(this, stream, asUnanchored);
|
|
6376
|
+
} finally {
|
|
6377
|
+
stream.draining--;
|
|
6378
|
+
}
|
|
6379
|
+
};
|
|
6380
|
+
drainLoop_fn = function(stream, asUnanchored) {
|
|
6203
6381
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
6204
6382
|
const head = stream.buf[0];
|
|
6205
6383
|
const last = stream.last;
|
|
6384
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
6385
|
+
stream.buf.shift();
|
|
6386
|
+
__privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, void 0);
|
|
6387
|
+
continue;
|
|
6388
|
+
}
|
|
6206
6389
|
if (stream.discontinuity) {
|
|
6207
6390
|
stream.discontinuity = false;
|
|
6208
6391
|
stream.buf.shift();
|
|
@@ -6216,9 +6399,10 @@ var BlockcastMmt = (() => {
|
|
|
6216
6399
|
}
|
|
6217
6400
|
const headSbn = head.meta.fecSbn;
|
|
6218
6401
|
const from = stream.lastSbn ?? headSbn;
|
|
6219
|
-
const to = headSbn ?? stream.lastSbn;
|
|
6402
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn;
|
|
6220
6403
|
let lost = [];
|
|
6221
6404
|
const unanchored = from === void 0 && to === void 0;
|
|
6405
|
+
let unresolved = false;
|
|
6222
6406
|
if (from !== void 0 && to !== void 0) {
|
|
6223
6407
|
const resolved = __privateGet(this, _gate).resolvedLoss(
|
|
6224
6408
|
stream.packetId,
|
|
@@ -6227,7 +6411,8 @@ var BlockcastMmt = (() => {
|
|
|
6227
6411
|
Math.max(from, to),
|
|
6228
6412
|
from
|
|
6229
6413
|
);
|
|
6230
|
-
|
|
6414
|
+
unresolved = resolved === null;
|
|
6415
|
+
if (unresolved && !__privateMethod(this, _FecReleaseSequencer_instances, cursorPassed_fn).call(this, stream, asUnanchored) && !__privateMethod(this, _FecReleaseSequencer_instances, unrepairableWaitOver_fn).call(this, stream, last, head, from, to)) {
|
|
6231
6416
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
6232
6417
|
if (heldMs <= __privateGet(this, _gate).holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
6233
6418
|
__privateGet(this, _recordStat2).call(this, "forcedWindowFlushes");
|
|
@@ -6235,18 +6420,65 @@ var BlockcastMmt = (() => {
|
|
|
6235
6420
|
__privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, __privateGet(this, _gate).decide(last, head, [], true));
|
|
6236
6421
|
continue;
|
|
6237
6422
|
}
|
|
6238
|
-
lost = resolved;
|
|
6423
|
+
lost = resolved ?? [];
|
|
6239
6424
|
}
|
|
6240
6425
|
stream.buf.shift();
|
|
6241
|
-
__privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, lost.length > 0 || unanchored || authoredGap(last.meta, head.meta) ? __privateGet(this, _gate).decide(last, head, lost, false) : void 0);
|
|
6426
|
+
__privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta) ? __privateGet(this, _gate).decide(last, head, lost, false) : void 0);
|
|
6242
6427
|
}
|
|
6243
6428
|
};
|
|
6429
|
+
/**
|
|
6430
|
+
* The head has waited out a gap only a late source can still fill
|
|
6431
|
+
* (FecReleaseGate.unrepairableWaitMs). Not yet: the gate is asked to poke
|
|
6432
|
+
* the stream when it has (`wakeAt`), since no packet may come by then.
|
|
6433
|
+
*/
|
|
6434
|
+
unrepairableWaitOver_fn = function(stream, last, head, from, to) {
|
|
6435
|
+
const waitMs = __privateGet(this, _gate).unrepairableWaitMs?.(last, head, from, to);
|
|
6436
|
+
if (waitMs === void 0) return false;
|
|
6437
|
+
const atMs = head.arrivedAtMs + waitMs;
|
|
6438
|
+
if (performance.now() >= atMs) return true;
|
|
6439
|
+
__privateGet(this, _gate).wakeAt?.(stream.packetId, stream.catalogTrackName, atMs);
|
|
6440
|
+
return false;
|
|
6441
|
+
};
|
|
6442
|
+
/**
|
|
6443
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
6444
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
6445
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
6446
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
6447
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
6448
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
6449
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
6450
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
6451
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
6452
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
6453
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
6454
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
6455
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
6456
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
6457
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
6458
|
+
*/
|
|
6459
|
+
cursorPassed_fn = function(stream, asUnanchored) {
|
|
6460
|
+
let at = -1;
|
|
6461
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
6462
|
+
const frame = stream.buf[i];
|
|
6463
|
+
if (frame.meta.fecSbnFirst !== void 0 || frame.meta.fecSbn === void 0) {
|
|
6464
|
+
frame.passed = true;
|
|
6465
|
+
if (at < 0) at = i;
|
|
6466
|
+
} else if (frame.passed !== true) break;
|
|
6467
|
+
}
|
|
6468
|
+
if (at < 0) return false;
|
|
6469
|
+
return asUnanchored || !stream.sourced || __privateGet(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));
|
|
6470
|
+
};
|
|
6244
6471
|
release_fn = function(stream, frame, decision) {
|
|
6472
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0;
|
|
6473
|
+
if (stale) __privateGet(this, _recordStat2).call(this, "droppedStale");
|
|
6245
6474
|
if (decision) frame.meta.gapBefore = decision;
|
|
6246
6475
|
stream.last = frame;
|
|
6247
|
-
if (frame.meta.fecSbn !== void 0
|
|
6476
|
+
if (frame.meta.fecSbn !== void 0 && (frame.meta.fecSbnFirst === void 0 || stream.lastSbn !== void 0)) {
|
|
6477
|
+
stream.lastSbn = frame.meta.fecSbn;
|
|
6478
|
+
}
|
|
6479
|
+
if (frame.meta.recovered !== true) stream.sourced = true;
|
|
6248
6480
|
__privateGet(this, _gate).onReleased?.(frame.data, frame.meta);
|
|
6249
|
-
__privateGet(this, _emit2).call(this, frame.data, frame.meta);
|
|
6481
|
+
if (!stale) __privateGet(this, _emit2).call(this, frame.data, frame.meta);
|
|
6250
6482
|
};
|
|
6251
6483
|
var FMPU_BOX_TYPES = /* @__PURE__ */ new Set(["ftyp", "moov", "moof"]);
|
|
6252
6484
|
function isFmp4Box(data) {
|
|
@@ -6255,7 +6487,7 @@ var BlockcastMmt = (() => {
|
|
|
6255
6487
|
return FMPU_BOX_TYPES.has(type);
|
|
6256
6488
|
}
|
|
6257
6489
|
var MAX_AWAITING_TIMING_HEADS = 8;
|
|
6258
|
-
var _tracks, _defaultTrack, _reassembler, _sampleCombiners, _sampleCombinerOptions, _retiredSampleCombinerStats, _timingStreams, _maxPendingTimingSamples, _pendingTimingSamples, _reclaimedTimingSamples, _evictedTimingSamples, _rejectedMovieFragments, _sequencers, _fecGate, _fecSequencer, _reorderWindow, _reassemblyPolicy, _frameCb, _initCb, _sourceSymbolCb, _trackFrameCbs, _reorderStats, _reliableMoqStartupGate, _disposed, _replayingAwaitingTiming, _fedObjects, _reassemblerFragmentsFed, _reassemblerDataUnitsReturned, _feedOutcomes, _deferredFeedOutcomes, _lastOutcome, _lastOutcomeCount, _MmtpContainerParser_instances, streamKey_fn, sampleCombinerFor_fn, releaseTimingSlot_fn, dropSampleCombiner_fn, countOutcome_fn, countDeferredOutcome_fn, drop_fn, feedCounted_fn, feed_fn, emitCombinedSample_fn, passReliableMoqStartupGate_fn, timingResolver_fn, awaitTiming_fn, replayAwaitingTiming_fn, dropTimingStream_fn, validateReassemblyPolicy_fn, buildFrameMeta_fn, sequencerFor_fn, flushSequencers_fn, emitFrame_fn2, _MmtpContainerParser_static, scanForKeyframe_fn, scanLengthPrefixedHevcForKeyframe_fn, scanAnnexBForKeyframe_fn;
|
|
6490
|
+
var _tracks, _defaultTrack, _reassembler, _sampleCombiners, _sampleCombinerOptions, _retiredSampleCombinerStats, _timingStreams, _maxPendingTimingSamples, _pendingTimingSamples, _reclaimedTimingSamples, _evictedTimingSamples, _rejectedMovieFragments, _recoveredHeadsAwaitingTiming, _sequencers, _fecGate, _fecSequencer, _reorderWindow, _reassemblyPolicy, _frameCb, _initCb, _sourceSymbolCb, _trackFrameCbs, _reorderStats, _reliableMoqStartupGate, _disposed, _replayingAwaitingTiming, _fedObjects, _reassemblerFragmentsFed, _reassemblerDataUnitsReturned, _feedOutcomes, _deferredFeedOutcomes, _lastOutcome, _lastOutcomeCount, _MmtpContainerParser_instances, streamKey_fn, sampleCombinerFor_fn, releaseTimingSlot_fn, dropSampleCombiner_fn, countOutcome_fn, countDeferredOutcome_fn, drop_fn, feedCounted_fn, feed_fn, emitCombinedSample_fn, passReliableMoqStartupGate_fn, timingResolver_fn, awaitTiming_fn, leaveAwaitingTiming_fn, replayAwaitingTiming_fn, dropTimingStream_fn, validateReassemblyPolicy_fn, buildFrameMeta_fn, sequencerFor_fn, flushSequencers_fn, emitFrame_fn2, _MmtpContainerParser_static, scanForKeyframe_fn, scanLengthPrefixedHevcForKeyframe_fn, scanAnnexBForKeyframe_fn;
|
|
6259
6491
|
var _MmtpContainerParser = class _MmtpContainerParser {
|
|
6260
6492
|
constructor(config) {
|
|
6261
6493
|
__privateAdd(this, _MmtpContainerParser_instances);
|
|
@@ -6291,6 +6523,12 @@ var BlockcastMmt = (() => {
|
|
|
6291
6523
|
__privateAdd(this, _reclaimedTimingSamples, 0);
|
|
6292
6524
|
__privateAdd(this, _evictedTimingSamples, 0);
|
|
6293
6525
|
__privateAdd(this, _rejectedMovieFragments, 0);
|
|
6526
|
+
__privateAdd(this, _recoveredHeadsAwaitingTiming, {
|
|
6527
|
+
held: 0,
|
|
6528
|
+
expired: 0,
|
|
6529
|
+
discarded: 0,
|
|
6530
|
+
superseded: 0
|
|
6531
|
+
});
|
|
6294
6532
|
__privateAdd(this, _sequencers, /* @__PURE__ */ new Map());
|
|
6295
6533
|
__privateAdd(this, _fecGate, null);
|
|
6296
6534
|
__privateAdd(this, _fecSequencer, null);
|
|
@@ -6418,11 +6656,12 @@ var BlockcastMmt = (() => {
|
|
|
6418
6656
|
/**
|
|
6419
6657
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
6420
6658
|
*
|
|
6421
|
-
*
|
|
6422
|
-
*
|
|
6423
|
-
*
|
|
6424
|
-
*
|
|
6425
|
-
*
|
|
6659
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
6660
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
6661
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
6662
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
6663
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
6664
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
6426
6665
|
*/
|
|
6427
6666
|
get timingBudgetStats() {
|
|
6428
6667
|
return {
|
|
@@ -6433,6 +6672,14 @@ var BlockcastMmt = (() => {
|
|
|
6433
6672
|
rejectedMovieFragments: __privateGet(this, _rejectedMovieFragments)
|
|
6434
6673
|
};
|
|
6435
6674
|
}
|
|
6675
|
+
/** Recovered heads parked for FT=1 timing (BLO-53369). Survives dispose(). */
|
|
6676
|
+
get recoveredHeadsAwaitingTiming() {
|
|
6677
|
+
let pending = 0;
|
|
6678
|
+
for (const { awaitingTiming } of __privateGet(this, _timingStreams).values()) {
|
|
6679
|
+
for (const head of awaitingTiming) if (head.options?.recovered) pending++;
|
|
6680
|
+
}
|
|
6681
|
+
return { ...__privateGet(this, _recoveredHeadsAwaitingTiming), pending };
|
|
6682
|
+
}
|
|
6436
6683
|
get reorderStats() {
|
|
6437
6684
|
let bufferedFrames = __privateGet(this, _fecSequencer)?.buffered ?? 0;
|
|
6438
6685
|
for (const { sequencer } of __privateGet(this, _sequencers).values()) bufferedFrames += sequencer.buffered;
|
|
@@ -6474,6 +6721,14 @@ var BlockcastMmt = (() => {
|
|
|
6474
6721
|
fecReleaseRapAbove(packetId, catalogTrackName, ssId) {
|
|
6475
6722
|
return __privateGet(this, _fecSequencer)?.rapAbove(packetId, catalogTrackName, ssId) ?? false;
|
|
6476
6723
|
}
|
|
6724
|
+
/** See FecReleaseSequencer.unsource. */
|
|
6725
|
+
unsourceFecRelease(packetId, catalogTrackName) {
|
|
6726
|
+
__privateGet(this, _fecSequencer)?.unsource(packetId, catalogTrackName);
|
|
6727
|
+
}
|
|
6728
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
6729
|
+
fecReleaseHoldsRebuilt(packetId, catalogTrackName) {
|
|
6730
|
+
return __privateGet(this, _fecSequencer)?.holdsRebuilt(packetId, catalogTrackName) ?? false;
|
|
6731
|
+
}
|
|
6477
6732
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
6478
6733
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
6479
6734
|
if (!__privateGet(this, _fecSequencer)) return;
|
|
@@ -6584,7 +6839,7 @@ var BlockcastMmt = (() => {
|
|
|
6584
6839
|
const now = Date.now();
|
|
6585
6840
|
for (const { awaitingTiming } of __privateGet(this, _timingStreams).values()) {
|
|
6586
6841
|
while (awaitingTiming.length > 0 && now - awaitingTiming[0].arrivedAt > timeoutMs) {
|
|
6587
|
-
awaitingTiming.shift();
|
|
6842
|
+
__privateMethod(this, _MmtpContainerParser_instances, leaveAwaitingTiming_fn).call(this, awaitingTiming.shift(), "expired");
|
|
6588
6843
|
}
|
|
6589
6844
|
}
|
|
6590
6845
|
}
|
|
@@ -6837,6 +7092,9 @@ var BlockcastMmt = (() => {
|
|
|
6837
7092
|
for (const { sequencer } of __privateGet(this, _sequencers).values()) sequencer.discard();
|
|
6838
7093
|
__privateGet(this, _sequencers).clear();
|
|
6839
7094
|
__privateGet(this, _fecSequencer)?.discard();
|
|
7095
|
+
for (const { awaitingTiming } of __privateGet(this, _timingStreams).values()) {
|
|
7096
|
+
for (const head of awaitingTiming) __privateMethod(this, _MmtpContainerParser_instances, leaveAwaitingTiming_fn).call(this, head, "discarded");
|
|
7097
|
+
}
|
|
6840
7098
|
__privateGet(this, _timingStreams).clear();
|
|
6841
7099
|
__privateSet(this, _pendingTimingSamples, 0);
|
|
6842
7100
|
__privateGet(this, _reliableMoqStartupGate).clear();
|
|
@@ -6865,6 +7123,7 @@ var BlockcastMmt = (() => {
|
|
|
6865
7123
|
_reclaimedTimingSamples = new WeakMap();
|
|
6866
7124
|
_evictedTimingSamples = new WeakMap();
|
|
6867
7125
|
_rejectedMovieFragments = new WeakMap();
|
|
7126
|
+
_recoveredHeadsAwaitingTiming = new WeakMap();
|
|
6868
7127
|
_sequencers = new WeakMap();
|
|
6869
7128
|
_fecGate = new WeakMap();
|
|
6870
7129
|
_fecSequencer = new WeakMap();
|
|
@@ -7023,11 +7282,16 @@ var BlockcastMmt = (() => {
|
|
|
7023
7282
|
if (mpu.fragmentationIndicator !== 0 || mpu.fragmentCounter !== 0)
|
|
7024
7283
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-unexpected-fragmentation");
|
|
7025
7284
|
const resolver2 = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, false);
|
|
7026
|
-
if (!resolver2) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-no-resolver");
|
|
7285
|
+
if (!resolver2?.initialized) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-no-resolver");
|
|
7027
7286
|
const pendingBefore = resolver2.pendingSampleCount;
|
|
7028
7287
|
const evictedBefore = resolver2.evictedSampleCount;
|
|
7029
|
-
const remaining = __privateGet(this, _maxPendingTimingSamples) -
|
|
7030
|
-
const admitted = resolver2.addMovieFragment(
|
|
7288
|
+
const remaining = __privateGet(this, _maxPendingTimingSamples) - resolver2.pendingSampleCount;
|
|
7289
|
+
const admitted = resolver2.addMovieFragment(
|
|
7290
|
+
mpu.mpuSequenceNumber,
|
|
7291
|
+
data,
|
|
7292
|
+
remaining,
|
|
7293
|
+
options?.recovered === true
|
|
7294
|
+
);
|
|
7031
7295
|
__privateSet(this, _pendingTimingSamples, __privateGet(this, _pendingTimingSamples) + (resolver2.pendingSampleCount - pendingBefore));
|
|
7032
7296
|
__privateSet(this, _evictedTimingSamples, __privateGet(this, _evictedTimingSamples) + (resolver2.evictedSampleCount - evictedBefore));
|
|
7033
7297
|
if (!admitted) {
|
|
@@ -7047,7 +7311,7 @@ var BlockcastMmt = (() => {
|
|
|
7047
7311
|
};
|
|
7048
7312
|
}
|
|
7049
7313
|
if (fragmentType !== 2) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "unknown-fragment-type");
|
|
7050
|
-
const resolver = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId,
|
|
7314
|
+
const resolver = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, true);
|
|
7051
7315
|
if (!resolver) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-no-resolver");
|
|
7052
7316
|
if (!Number.isSafeInteger(data.byteLength) || data.byteLength <= 0)
|
|
7053
7317
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-empty-payload");
|
|
@@ -7068,6 +7332,7 @@ var BlockcastMmt = (() => {
|
|
|
7068
7332
|
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
7069
7333
|
movieFragmentSequenceNumber: mfuDuHeader.movieFragmentSequenceNumber,
|
|
7070
7334
|
sampleNumber: mfuDuHeader.sampleNumber,
|
|
7335
|
+
sequenceNumber: info.sequenceNumber,
|
|
7071
7336
|
arrivedAt: Date.now()
|
|
7072
7337
|
});
|
|
7073
7338
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-sample-timing-missing");
|
|
@@ -7088,7 +7353,7 @@ var BlockcastMmt = (() => {
|
|
|
7088
7353
|
headTiming.size
|
|
7089
7354
|
);
|
|
7090
7355
|
if (readyOnRegister) {
|
|
7091
|
-
const deferred = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, readyOnRegister, info, resolver, options?.recovered === true, options?.fecSbn);
|
|
7356
|
+
const deferred = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, readyOnRegister, info, resolver, options?.recovered === true, options?.fecSbn, options?.fecSbnFirst);
|
|
7092
7357
|
if (deferred.record === void 0) __privateMethod(this, _MmtpContainerParser_instances, countDeferredOutcome_fn).call(this, deferred.reason);
|
|
7093
7358
|
}
|
|
7094
7359
|
}
|
|
@@ -7175,7 +7440,7 @@ var BlockcastMmt = (() => {
|
|
|
7175
7440
|
fragmentCounter: mpu.fragmentCounter
|
|
7176
7441
|
};
|
|
7177
7442
|
}
|
|
7178
|
-
const outcome = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, combined, info, resolver, options?.recovered === true, options?.fecSbn);
|
|
7443
|
+
const outcome = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, combined, info, resolver, options?.recovered === true, options?.fecSbn, options?.fecSbnFirst);
|
|
7179
7444
|
if (outcome.record !== void 0) return outcome.record;
|
|
7180
7445
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, outcome.reason);
|
|
7181
7446
|
};
|
|
@@ -7194,7 +7459,7 @@ var BlockcastMmt = (() => {
|
|
|
7194
7459
|
* attribution exists to keep readable. Leaving the choice at the call site
|
|
7195
7460
|
* is what keeps both true.
|
|
7196
7461
|
*/
|
|
7197
|
-
emitCombinedSample_fn = function(combined, info, resolver, recovered, fecSbn) {
|
|
7462
|
+
emitCombinedSample_fn = function(combined, info, resolver, recovered, fecSbn, fecSbnFirst) {
|
|
7198
7463
|
const timing = resolver.sampleTiming(
|
|
7199
7464
|
combined.mpuSequenceNumber,
|
|
7200
7465
|
combined.movieFragmentSequenceNumber,
|
|
@@ -7205,6 +7470,7 @@ var BlockcastMmt = (() => {
|
|
|
7205
7470
|
const meta = __privateMethod(this, _MmtpContainerParser_instances, buildFrameMeta_fn).call(this, combined, info.packetId, info.sequenceNumber, timing, recovered);
|
|
7206
7471
|
if (!meta) return { reason: "combined-meta-build-failed" };
|
|
7207
7472
|
if (fecSbn !== void 0) meta.fecSbn = fecSbn;
|
|
7473
|
+
if (fecSbnFirst !== void 0) meta.fecSbnFirst = fecSbnFirst;
|
|
7208
7474
|
if (!resolver.consumeSample(
|
|
7209
7475
|
combined.mpuSequenceNumber,
|
|
7210
7476
|
combined.movieFragmentSequenceNumber,
|
|
@@ -7249,10 +7515,23 @@ var BlockcastMmt = (() => {
|
|
|
7249
7515
|
return resolver;
|
|
7250
7516
|
};
|
|
7251
7517
|
awaitTiming_fn = function(streamKey, head) {
|
|
7252
|
-
const
|
|
7253
|
-
if (!
|
|
7518
|
+
const state = __privateGet(this, _timingStreams).get(streamKey);
|
|
7519
|
+
if (!state) return;
|
|
7520
|
+
if (!head.options?.recovered) {
|
|
7521
|
+
const kept = state.awaitingTiming.filter((queued) => !queued.options?.recovered || queued.sequenceNumber !== head.sequenceNumber);
|
|
7522
|
+
__privateGet(this, _recoveredHeadsAwaitingTiming).superseded += state.awaitingTiming.length - kept.length;
|
|
7523
|
+
state.awaitingTiming = kept;
|
|
7524
|
+
}
|
|
7525
|
+
const awaitingTiming = state.awaitingTiming;
|
|
7254
7526
|
awaitingTiming.push(head);
|
|
7255
|
-
if (
|
|
7527
|
+
if (head.options?.recovered) __privateGet(this, _recoveredHeadsAwaitingTiming).held++;
|
|
7528
|
+
if (awaitingTiming.length > MAX_AWAITING_TIMING_HEADS) {
|
|
7529
|
+
__privateMethod(this, _MmtpContainerParser_instances, leaveAwaitingTiming_fn).call(this, awaitingTiming.shift(), "expired");
|
|
7530
|
+
}
|
|
7531
|
+
};
|
|
7532
|
+
/** Count a recovered head leaving the queue other than by replay or its source copy. */
|
|
7533
|
+
leaveAwaitingTiming_fn = function(head, outcome) {
|
|
7534
|
+
if (head.options?.recovered) __privateGet(this, _recoveredHeadsAwaitingTiming)[outcome]++;
|
|
7256
7535
|
};
|
|
7257
7536
|
/**
|
|
7258
7537
|
* Feed again the heads whose timing the FT=1 just admitted declares. That
|
|
@@ -7280,6 +7559,7 @@ var BlockcastMmt = (() => {
|
|
|
7280
7559
|
const state = __privateGet(this, _timingStreams).get(streamKey);
|
|
7281
7560
|
if (!state) return;
|
|
7282
7561
|
__privateGet(this, _timingStreams).delete(streamKey);
|
|
7562
|
+
for (const head of state.awaitingTiming) __privateMethod(this, _MmtpContainerParser_instances, leaveAwaitingTiming_fn).call(this, head, "discarded");
|
|
7283
7563
|
__privateSet(this, _pendingTimingSamples, __privateGet(this, _pendingTimingSamples) - state.resolver.pendingSampleCount);
|
|
7284
7564
|
if (__privateGet(this, _pendingTimingSamples) < 0) {
|
|
7285
7565
|
throw new Error("[MmtpContainerParser] pending timing sample accounting underflow");
|