@blockcast/mmt-container 2.2.0-main.da2e7cd1dd5d → 2.2.0-main.e1bebe787bc9
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/README.md +5 -2
- package/dist/block-policy.d.ts +55 -13
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +104 -32
- package/dist/block-policy.js.map +2 -2
- package/dist/browser-runtime.js +1573 -214
- package/dist/browser-runtime.js.map +3 -3
- package/dist/carp-catalog.js.map +2 -2
- package/dist/catalog-fec-params.d.ts +1 -1
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +14 -1
- package/dist/catalog-fec-params.js.map +2 -2
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/cmaf-block-assembler.js +92 -1
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/codec-utils.d.ts.map +1 -1
- package/dist/codec-utils.js +92 -1
- package/dist/codec-utils.js.map +2 -2
- package/dist/delivery-catalog.js +2 -1
- package/dist/delivery-catalog.js.map +2 -2
- package/dist/delta-fallback-config.js +5 -1
- package/dist/delta-fallback-config.js.map +3 -3
- package/dist/fec-manager.d.ts +111 -14
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +613 -91
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-state.js +5 -1
- package/dist/fec-state.js.map +2 -2
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.js.map +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.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/mfu-reassembler.js.map +2 -2
- 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 +329 -32
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +307 -27
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.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 +676 -76
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-auth-catalog.js.map +2 -2
- package/dist/multicast-input.js.map +2 -2
- package/dist/multicast-manager.d.ts +26 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1384 -187
- 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/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +1 -0
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +329 -31
- package/dist/no-modules.js.map +4 -4
- 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/repair-layer-subscriptions.js.map +2 -2
- package/dist/signaling.js.map +2 -2
- package/dist/timestamp-codec.js.map +2 -2
- 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-mfu-reassembler.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/block-policy.ts +216 -52
- package/src/catalog-fec-params.ts +1 -0
- package/src/codec-utils.ts +121 -1
- package/src/fec-manager.ts +593 -33
- package/src/index.ts +5 -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 +614 -61
- package/src/multicast-manager.ts +136 -16
- package/src/no-modules.ts +3 -0
- package/src/repair-fetch.ts +366 -50
- package/src/track-session.ts +3 -0
|
@@ -58,7 +58,9 @@ var BlockcastMmt = (() => {
|
|
|
58
58
|
reliableMoqMfuReassembly: () => reliableMoqMfuReassembly,
|
|
59
59
|
resolveFecState: () => resolveFecState,
|
|
60
60
|
resolveGroupDurationMs: () => resolveGroupDurationMs,
|
|
61
|
-
|
|
61
|
+
runtimeFecCatalogReport: () => runtimeFecCatalogReport,
|
|
62
|
+
validateCmsfMmtpCatalog: () => validateCmsfMmtpCatalog,
|
|
63
|
+
validateFecCatalog: () => validateFecCatalog
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
// ../mmt-base/dist/mmtp.js
|
|
@@ -958,13 +960,25 @@ var BlockcastMmt = (() => {
|
|
|
958
960
|
});
|
|
959
961
|
return { tracks, pointers };
|
|
960
962
|
}
|
|
961
|
-
function
|
|
963
|
+
function runtimeView(catalog, receiver) {
|
|
962
964
|
const { tracks, pointers } = fecCatalogTracks(catalog);
|
|
963
965
|
const report = validateFecCatalog({ tracks }, receiver);
|
|
964
966
|
const at = (path) => {
|
|
965
967
|
const m = /^\/tracks\/(\d+)(.*)$/.exec(path);
|
|
966
968
|
return m ? pointers[Number(m[1])] + m[2] : path;
|
|
967
969
|
};
|
|
970
|
+
return { tracks, pointers, report, at };
|
|
971
|
+
}
|
|
972
|
+
function runtimeFecCatalogReport(catalog, receiver = RUNTIME_FEC_RECEIVER) {
|
|
973
|
+
const { report, at } = runtimeView(catalog, receiver);
|
|
974
|
+
const issue = (i) => Object.freeze({ code: i.code, path: at(i.path) });
|
|
975
|
+
return Object.freeze({
|
|
976
|
+
instances: Object.freeze(report.instances.map((i) => Object.freeze({ ...i, path: at(i.path), issues: Object.freeze(i.issues.map(issue)) }))),
|
|
977
|
+
issues: Object.freeze(report.issues.map(issue))
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
function resolveFecBindings(catalog, receiver = RUNTIME_FEC_RECEIVER) {
|
|
981
|
+
const { tracks, pointers, report, at } = runtimeView(catalog, receiver);
|
|
968
982
|
const trackAt = (i) => recordOf(tracks[i]) ?? {};
|
|
969
983
|
const nameAt = (i) => i === null ? void 0 : trackAt(i)["name"];
|
|
970
984
|
const why = (i) => Object.freeze({
|
|
@@ -4650,9 +4664,10 @@ var BlockcastMmt = (() => {
|
|
|
4650
4664
|
const sliceType = readH264SliceType(nal);
|
|
4651
4665
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
4652
4666
|
}
|
|
4667
|
+
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
4653
4668
|
function readH264SliceType(nal) {
|
|
4654
4669
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4655
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4670
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
|
|
4656
4671
|
const state = { bitOffset: 0 };
|
|
4657
4672
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4658
4673
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -4799,6 +4814,96 @@ var BlockcastMmt = (() => {
|
|
|
4799
4814
|
]))).toBe(false);
|
|
4800
4815
|
});
|
|
4801
4816
|
});
|
|
4817
|
+
describe("readH264SliceType", () => {
|
|
4818
|
+
const wholeNalSliceType = (nal) => {
|
|
4819
|
+
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4820
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4821
|
+
const state = { bitOffset: 0 };
|
|
4822
|
+
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4823
|
+
return readUnsignedExpGolomb(rbsp, state);
|
|
4824
|
+
};
|
|
4825
|
+
const hex2 = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
|
|
4826
|
+
const ue = (value) => {
|
|
4827
|
+
const code = (value + 1).toString(2);
|
|
4828
|
+
return "0".repeat(code.length - 1) + code;
|
|
4829
|
+
};
|
|
4830
|
+
const sliceNal = (bits) => {
|
|
4831
|
+
const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
|
|
4832
|
+
const nal = [1];
|
|
4833
|
+
let zeros = 0;
|
|
4834
|
+
for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
|
|
4835
|
+
if (zeros >= 2 && byte <= 3) {
|
|
4836
|
+
nal.push(3);
|
|
4837
|
+
zeros = 0;
|
|
4838
|
+
}
|
|
4839
|
+
nal.push(byte);
|
|
4840
|
+
zeros = byte === 0 ? zeros + 1 : 0;
|
|
4841
|
+
}
|
|
4842
|
+
return Uint8Array.from(nal);
|
|
4843
|
+
};
|
|
4844
|
+
const x264Slices = [
|
|
4845
|
+
["64x48 P", hex2("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
|
|
4846
|
+
["64x48 B", hex2("419e414212fffeeade283707cb70f7"), 6, false],
|
|
4847
|
+
["64x48 non-IDR I", hex2(
|
|
4848
|
+
"4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
|
|
4849
|
+
), 7, true],
|
|
4850
|
+
["1280x720 B, escape at byte 10", hex2(
|
|
4851
|
+
"01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
|
|
4852
|
+
), 6, false],
|
|
4853
|
+
["1280x720 P, escape at byte 15", hex2(
|
|
4854
|
+
"41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
|
|
4855
|
+
), 5, false],
|
|
4856
|
+
["1280x720 B, escape at byte 22", hex2("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
|
|
4857
|
+
["7680x4320 IDR, first_mb_in_slice 97440", hex2(
|
|
4858
|
+
"650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
|
|
4859
|
+
), null, true],
|
|
4860
|
+
["7680x4320 P, first_mb_in_slice 32640", hex2(
|
|
4861
|
+
"410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
|
|
4862
|
+
), 5, false],
|
|
4863
|
+
["7680x4320 P, first_mb_in_slice 97440", hex2(
|
|
4864
|
+
"410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
|
|
4865
|
+
), 5, false]
|
|
4866
|
+
];
|
|
4867
|
+
const syntheticSlices = [
|
|
4868
|
+
["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
|
|
4869
|
+
["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
|
|
4870
|
+
["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
|
|
4871
|
+
["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
|
|
4872
|
+
["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
|
|
4873
|
+
["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
|
|
4874
|
+
["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
|
|
4875
|
+
["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
|
|
4876
|
+
];
|
|
4877
|
+
test("reads the slice_type of real and synthetic slices", () => {
|
|
4878
|
+
for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
|
|
4879
|
+
expect(readH264SliceType(nal), name).toBe(sliceType);
|
|
4880
|
+
}
|
|
4881
|
+
});
|
|
4882
|
+
test("matches the whole-NAL unescape at every truncation", () => {
|
|
4883
|
+
for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
|
|
4884
|
+
for (let end = 0; end <= nal.length; end++) {
|
|
4885
|
+
const cut = nal.subarray(0, end);
|
|
4886
|
+
expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
|
|
4887
|
+
}
|
|
4888
|
+
}
|
|
4889
|
+
});
|
|
4890
|
+
test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
|
|
4891
|
+
const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
|
|
4892
|
+
let seed = 1;
|
|
4893
|
+
const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
|
|
4894
|
+
for (let i = 0; i < 5e3; i++) {
|
|
4895
|
+
const nal = new Uint8Array(2 + next() % 63);
|
|
4896
|
+
nal[0] = 65;
|
|
4897
|
+
for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
|
|
4898
|
+
expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
|
|
4899
|
+
}
|
|
4900
|
+
});
|
|
4901
|
+
test("classifies the x264 slices as keyframes or not", () => {
|
|
4902
|
+
for (const [name, nal, , keyframe] of x264Slices) {
|
|
4903
|
+
expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
|
|
4904
|
+
}
|
|
4905
|
+
});
|
|
4906
|
+
});
|
|
4802
4907
|
describe("avccToAnnexB", () => {
|
|
4803
4908
|
test("converts with SPS/PPS on keyframe", () => {
|
|
4804
4909
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|
|
@@ -5633,13 +5738,21 @@ var BlockcastMmt = (() => {
|
|
|
5633
5738
|
function sameSample(a, b) {
|
|
5634
5739
|
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
5740
|
}
|
|
5636
|
-
var _track, _fragments, _pendingSamples, _evictedSamples, _lastMovieFragmentRejection, _IsoBmffTimingResolver_instances, evictOldestFragment_fn, clearSlot_fn;
|
|
5741
|
+
var _track, _fragments, _firstSamples, _delivered, _pendingSamples, _evictedSamples, _lastMovieFragmentRejection, _IsoBmffTimingResolver_instances, evictOldestFragment_fn, clearSlot_fn;
|
|
5637
5742
|
var IsoBmffTimingResolver = class {
|
|
5638
5743
|
constructor(maxPendingSamples) {
|
|
5639
5744
|
this.maxPendingSamples = maxPendingSamples;
|
|
5640
5745
|
__privateAdd(this, _IsoBmffTimingResolver_instances);
|
|
5641
5746
|
__privateAdd(this, _track, null);
|
|
5642
5747
|
__privateAdd(this, _fragments, /* @__PURE__ */ new Map());
|
|
5748
|
+
/** First sample of each pending fragment, kept in `#delivered` with its sample count. */
|
|
5749
|
+
__privateAdd(this, _firstSamples, /* @__PURE__ */ new Map());
|
|
5750
|
+
/**
|
|
5751
|
+
* First sample and sample count of the newest fragments whose every slot was
|
|
5752
|
+
* cleared. Abandonment counts: `releaseSample` clears a slot too, which
|
|
5753
|
+
* matches the combiner, since it retires an abandoned sample as well.
|
|
5754
|
+
*/
|
|
5755
|
+
__privateAdd(this, _delivered, /* @__PURE__ */ new Map());
|
|
5643
5756
|
__privateAdd(this, _pendingSamples, 0);
|
|
5644
5757
|
__privateAdd(this, _evictedSamples, 0);
|
|
5645
5758
|
__privateAdd(this, _lastMovieFragmentRejection, null);
|
|
@@ -5647,6 +5760,10 @@ var BlockcastMmt = (() => {
|
|
|
5647
5760
|
throw new Error("[IsoBmffTimingResolver] maxPendingSamples must be a positive integer");
|
|
5648
5761
|
}
|
|
5649
5762
|
}
|
|
5763
|
+
/** True once an FT=0 has bound the track that FT=1 timing is read against. */
|
|
5764
|
+
get initialized() {
|
|
5765
|
+
return __privateGet(this, _track) !== null;
|
|
5766
|
+
}
|
|
5650
5767
|
get pendingSampleCount() {
|
|
5651
5768
|
return __privateGet(this, _pendingSamples);
|
|
5652
5769
|
}
|
|
@@ -5670,7 +5787,14 @@ var BlockcastMmt = (() => {
|
|
|
5670
5787
|
__privateSet(this, _track, timing);
|
|
5671
5788
|
return true;
|
|
5672
5789
|
}
|
|
5673
|
-
|
|
5790
|
+
/**
|
|
5791
|
+
* `recovered` marks an FEC-recovered copy. A recovered block hands back
|
|
5792
|
+
* every FT=1 it holds, the received ones included, so a recovered copy of a
|
|
5793
|
+
* fragment whose samples are all done is a duplicate: admitting it again
|
|
5794
|
+
* would charge stale timing and could displace the live MPU's. A source
|
|
5795
|
+
* copy is still admitted again (a rendition switch re-arms timing that way).
|
|
5796
|
+
*/
|
|
5797
|
+
addMovieFragment(mpuSequenceNumber, data, additionalSampleLimit = this.maxPendingSamples, recovered = false) {
|
|
5674
5798
|
__privateSet(this, _lastMovieFragmentRejection, null);
|
|
5675
5799
|
if (!Number.isInteger(additionalSampleLimit) || additionalSampleLimit < 0) {
|
|
5676
5800
|
__privateSet(this, _lastMovieFragmentRejection, "invalid");
|
|
@@ -5696,6 +5820,8 @@ var BlockcastMmt = (() => {
|
|
|
5696
5820
|
(sample, index) => sample !== null && sameSample(sample, parsed.samples[index])
|
|
5697
5821
|
);
|
|
5698
5822
|
}
|
|
5823
|
+
const delivered = recovered ? __privateGet(this, _delivered).get(key) : void 0;
|
|
5824
|
+
if (delivered && delivered.sampleCount === parsed.samples.length && sameSample(delivered.first, parsed.samples[0])) return true;
|
|
5699
5825
|
let freed = 0;
|
|
5700
5826
|
while (__privateGet(this, _fragments).size > 0 && (__privateGet(this, _pendingSamples) + parsed.samples.length > this.maxPendingSamples || parsed.samples.length - freed > additionalSampleLimit)) {
|
|
5701
5827
|
freed += __privateMethod(this, _IsoBmffTimingResolver_instances, evictOldestFragment_fn).call(this);
|
|
@@ -5709,6 +5835,7 @@ var BlockcastMmt = (() => {
|
|
|
5709
5835
|
return false;
|
|
5710
5836
|
}
|
|
5711
5837
|
__privateGet(this, _fragments).set(key, [...parsed.samples]);
|
|
5838
|
+
__privateGet(this, _firstSamples).set(key, parsed.samples[0]);
|
|
5712
5839
|
__privateSet(this, _pendingSamples, __privateGet(this, _pendingSamples) + parsed.samples.length);
|
|
5713
5840
|
return true;
|
|
5714
5841
|
}
|
|
@@ -5755,11 +5882,15 @@ var BlockcastMmt = (() => {
|
|
|
5755
5882
|
reset() {
|
|
5756
5883
|
__privateSet(this, _track, null);
|
|
5757
5884
|
__privateGet(this, _fragments).clear();
|
|
5885
|
+
__privateGet(this, _firstSamples).clear();
|
|
5886
|
+
__privateGet(this, _delivered).clear();
|
|
5758
5887
|
__privateSet(this, _pendingSamples, 0);
|
|
5759
5888
|
}
|
|
5760
5889
|
};
|
|
5761
5890
|
_track = new WeakMap();
|
|
5762
5891
|
_fragments = new WeakMap();
|
|
5892
|
+
_firstSamples = new WeakMap();
|
|
5893
|
+
_delivered = new WeakMap();
|
|
5763
5894
|
_pendingSamples = new WeakMap();
|
|
5764
5895
|
_evictedSamples = new WeakMap();
|
|
5765
5896
|
_lastMovieFragmentRejection = new WeakMap();
|
|
@@ -5778,6 +5909,7 @@ var BlockcastMmt = (() => {
|
|
|
5778
5909
|
let live = 0;
|
|
5779
5910
|
for (const sample of samples) if (sample !== null) live++;
|
|
5780
5911
|
__privateGet(this, _fragments).delete(oldest);
|
|
5912
|
+
__privateGet(this, _firstSamples).delete(oldest);
|
|
5781
5913
|
__privateSet(this, _pendingSamples, __privateGet(this, _pendingSamples) - live);
|
|
5782
5914
|
__privateSet(this, _evictedSamples, __privateGet(this, _evictedSamples) + live);
|
|
5783
5915
|
return live;
|
|
@@ -5793,7 +5925,16 @@ var BlockcastMmt = (() => {
|
|
|
5793
5925
|
if (!samples || !samples[index]) return false;
|
|
5794
5926
|
samples[index] = null;
|
|
5795
5927
|
__privateWrapper(this, _pendingSamples)._--;
|
|
5796
|
-
if (samples.every((value) => value === null))
|
|
5928
|
+
if (samples.every((value) => value === null)) {
|
|
5929
|
+
__privateGet(this, _fragments).delete(key);
|
|
5930
|
+
const first = __privateGet(this, _firstSamples).get(key);
|
|
5931
|
+
__privateGet(this, _firstSamples).delete(key);
|
|
5932
|
+
__privateGet(this, _delivered).delete(key);
|
|
5933
|
+
__privateGet(this, _delivered).set(key, { first, sampleCount: samples.length });
|
|
5934
|
+
if (__privateGet(this, _delivered).size > this.maxPendingSamples) {
|
|
5935
|
+
__privateGet(this, _delivered).delete(__privateGet(this, _delivered).keys().next().value);
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5797
5938
|
return true;
|
|
5798
5939
|
};
|
|
5799
5940
|
function fragmentKey(mpuSequenceNumber, movieFragmentSequenceNumber) {
|
|
@@ -5969,7 +6110,10 @@ var BlockcastMmt = (() => {
|
|
|
5969
6110
|
function ssIdAfter(a, b) {
|
|
5970
6111
|
return (a - b | 0) > 0;
|
|
5971
6112
|
}
|
|
5972
|
-
|
|
6113
|
+
function holdsRebuilt(stream) {
|
|
6114
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
|
|
6115
|
+
}
|
|
6116
|
+
var _streams2, _gate, _emit2, _recordStat2, _deferDepth, _deferredStreams, _FecReleaseSequencer_instances, drainUnlessDeferred_fn, streamFor_fn2, drain_fn, drainLoop_fn, unrepairableWaitOver_fn, cursorPassed_fn, release_fn;
|
|
5973
6117
|
var FecReleaseSequencer = class {
|
|
5974
6118
|
constructor(gate, emit, recordStat) {
|
|
5975
6119
|
__privateAdd(this, _FecReleaseSequencer_instances);
|
|
@@ -6029,6 +6173,7 @@ var BlockcastMmt = (() => {
|
|
|
6029
6173
|
stream.lastSbn = void 0;
|
|
6030
6174
|
stream.discontinuity = false;
|
|
6031
6175
|
stream.rapSsId = void 0;
|
|
6176
|
+
stream.sourced = false;
|
|
6032
6177
|
}
|
|
6033
6178
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
6034
6179
|
__privateGet(this, _recordStat2).call(this, "droppedStale");
|
|
@@ -6055,6 +6200,7 @@ var BlockcastMmt = (() => {
|
|
|
6055
6200
|
if (compareFrameOrder(stream.buf[mid], frame) < 0) lo = mid + 1;
|
|
6056
6201
|
else hi = mid;
|
|
6057
6202
|
}
|
|
6203
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true;
|
|
6058
6204
|
stream.buf.splice(lo, 0, frame);
|
|
6059
6205
|
__privateMethod(this, _FecReleaseSequencer_instances, drainUnlessDeferred_fn).call(this, stream);
|
|
6060
6206
|
}
|
|
@@ -6090,6 +6236,41 @@ var BlockcastMmt = (() => {
|
|
|
6090
6236
|
}
|
|
6091
6237
|
return false;
|
|
6092
6238
|
}
|
|
6239
|
+
/**
|
|
6240
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
6241
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
6242
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
6243
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
6244
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
6245
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
6246
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
6247
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
6248
|
+
* released.
|
|
6249
|
+
*/
|
|
6250
|
+
unsource(packetId, catalogTrackName) {
|
|
6251
|
+
for (const stream of __privateGet(this, _streams2).values()) {
|
|
6252
|
+
if (stream.packetId === packetId && (catalogTrackName === void 0 || stream.catalogTrackName === catalogTrackName)) {
|
|
6253
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
6254
|
+
if (__privateGet(this, _deferDepth) > 0) __privateGet(this, _deferredStreams).add(stream);
|
|
6255
|
+
else __privateMethod(this, _FecReleaseSequencer_instances, drain_fn).call(this, stream, true);
|
|
6256
|
+
}
|
|
6257
|
+
stream.sourced = false;
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6260
|
+
}
|
|
6261
|
+
/**
|
|
6262
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
6263
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
6264
|
+
* packetId.
|
|
6265
|
+
*/
|
|
6266
|
+
holdsRebuilt(packetId, catalogTrackName) {
|
|
6267
|
+
for (const stream of __privateGet(this, _streams2).values()) {
|
|
6268
|
+
if (stream.packetId !== packetId) continue;
|
|
6269
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
6270
|
+
if (holdsRebuilt(stream)) return true;
|
|
6271
|
+
}
|
|
6272
|
+
return false;
|
|
6273
|
+
}
|
|
6093
6274
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
6094
6275
|
poke(streamKey) {
|
|
6095
6276
|
if (streamKey !== void 0) {
|
|
@@ -6193,16 +6374,32 @@ var BlockcastMmt = (() => {
|
|
|
6193
6374
|
last: null,
|
|
6194
6375
|
lastSbn: void 0,
|
|
6195
6376
|
discontinuity: false,
|
|
6196
|
-
rapSsId: void 0
|
|
6377
|
+
rapSsId: void 0,
|
|
6378
|
+
sourced: false,
|
|
6379
|
+
draining: 0
|
|
6197
6380
|
};
|
|
6198
6381
|
__privateGet(this, _streams2).set(streamKey, stream);
|
|
6199
6382
|
}
|
|
6200
6383
|
return stream;
|
|
6201
6384
|
};
|
|
6202
|
-
|
|
6385
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
6386
|
+
drain_fn = function(stream, asUnanchored = false) {
|
|
6387
|
+
stream.draining++;
|
|
6388
|
+
try {
|
|
6389
|
+
__privateMethod(this, _FecReleaseSequencer_instances, drainLoop_fn).call(this, stream, asUnanchored);
|
|
6390
|
+
} finally {
|
|
6391
|
+
stream.draining--;
|
|
6392
|
+
}
|
|
6393
|
+
};
|
|
6394
|
+
drainLoop_fn = function(stream, asUnanchored) {
|
|
6203
6395
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
6204
6396
|
const head = stream.buf[0];
|
|
6205
6397
|
const last = stream.last;
|
|
6398
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
6399
|
+
stream.buf.shift();
|
|
6400
|
+
__privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, void 0);
|
|
6401
|
+
continue;
|
|
6402
|
+
}
|
|
6206
6403
|
if (stream.discontinuity) {
|
|
6207
6404
|
stream.discontinuity = false;
|
|
6208
6405
|
stream.buf.shift();
|
|
@@ -6216,9 +6413,10 @@ var BlockcastMmt = (() => {
|
|
|
6216
6413
|
}
|
|
6217
6414
|
const headSbn = head.meta.fecSbn;
|
|
6218
6415
|
const from = stream.lastSbn ?? headSbn;
|
|
6219
|
-
const to = headSbn ?? stream.lastSbn;
|
|
6416
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn;
|
|
6220
6417
|
let lost = [];
|
|
6221
6418
|
const unanchored = from === void 0 && to === void 0;
|
|
6419
|
+
let unresolved = false;
|
|
6222
6420
|
if (from !== void 0 && to !== void 0) {
|
|
6223
6421
|
const resolved = __privateGet(this, _gate).resolvedLoss(
|
|
6224
6422
|
stream.packetId,
|
|
@@ -6227,7 +6425,8 @@ var BlockcastMmt = (() => {
|
|
|
6227
6425
|
Math.max(from, to),
|
|
6228
6426
|
from
|
|
6229
6427
|
);
|
|
6230
|
-
|
|
6428
|
+
unresolved = resolved === null;
|
|
6429
|
+
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
6430
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
6232
6431
|
if (heldMs <= __privateGet(this, _gate).holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
6233
6432
|
__privateGet(this, _recordStat2).call(this, "forcedWindowFlushes");
|
|
@@ -6235,18 +6434,65 @@ var BlockcastMmt = (() => {
|
|
|
6235
6434
|
__privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, __privateGet(this, _gate).decide(last, head, [], true));
|
|
6236
6435
|
continue;
|
|
6237
6436
|
}
|
|
6238
|
-
lost = resolved;
|
|
6437
|
+
lost = resolved ?? [];
|
|
6239
6438
|
}
|
|
6240
6439
|
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);
|
|
6440
|
+
__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
6441
|
}
|
|
6243
6442
|
};
|
|
6443
|
+
/**
|
|
6444
|
+
* The head has waited out a gap only a late source can still fill
|
|
6445
|
+
* (FecReleaseGate.unrepairableWaitMs). Not yet: the gate is asked to poke
|
|
6446
|
+
* the stream when it has (`wakeAt`), since no packet may come by then.
|
|
6447
|
+
*/
|
|
6448
|
+
unrepairableWaitOver_fn = function(stream, last, head, from, to) {
|
|
6449
|
+
const waitMs = __privateGet(this, _gate).unrepairableWaitMs?.(last, head, from, to);
|
|
6450
|
+
if (waitMs === void 0) return false;
|
|
6451
|
+
const atMs = head.arrivedAtMs + waitMs;
|
|
6452
|
+
if (performance.now() >= atMs) return true;
|
|
6453
|
+
__privateGet(this, _gate).wakeAt?.(stream.packetId, stream.catalogTrackName, atMs);
|
|
6454
|
+
return false;
|
|
6455
|
+
};
|
|
6456
|
+
/**
|
|
6457
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
6458
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
6459
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
6460
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
6461
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
6462
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
6463
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
6464
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
6465
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
6466
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
6467
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
6468
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
6469
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
6470
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
6471
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
6472
|
+
*/
|
|
6473
|
+
cursorPassed_fn = function(stream, asUnanchored) {
|
|
6474
|
+
let at = -1;
|
|
6475
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
6476
|
+
const frame = stream.buf[i];
|
|
6477
|
+
if (frame.meta.fecSbnFirst !== void 0 || frame.meta.fecSbn === void 0) {
|
|
6478
|
+
frame.passed = true;
|
|
6479
|
+
if (at < 0) at = i;
|
|
6480
|
+
} else if (frame.passed !== true) break;
|
|
6481
|
+
}
|
|
6482
|
+
if (at < 0) return false;
|
|
6483
|
+
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));
|
|
6484
|
+
};
|
|
6244
6485
|
release_fn = function(stream, frame, decision) {
|
|
6486
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0;
|
|
6487
|
+
if (stale) __privateGet(this, _recordStat2).call(this, "droppedStale");
|
|
6245
6488
|
if (decision) frame.meta.gapBefore = decision;
|
|
6246
6489
|
stream.last = frame;
|
|
6247
|
-
if (frame.meta.fecSbn !== void 0
|
|
6490
|
+
if (frame.meta.fecSbn !== void 0 && (frame.meta.fecSbnFirst === void 0 || stream.lastSbn !== void 0)) {
|
|
6491
|
+
stream.lastSbn = frame.meta.fecSbn;
|
|
6492
|
+
}
|
|
6493
|
+
if (frame.meta.recovered !== true) stream.sourced = true;
|
|
6248
6494
|
__privateGet(this, _gate).onReleased?.(frame.data, frame.meta);
|
|
6249
|
-
__privateGet(this, _emit2).call(this, frame.data, frame.meta);
|
|
6495
|
+
if (!stale) __privateGet(this, _emit2).call(this, frame.data, frame.meta);
|
|
6250
6496
|
};
|
|
6251
6497
|
var FMPU_BOX_TYPES = /* @__PURE__ */ new Set(["ftyp", "moov", "moof"]);
|
|
6252
6498
|
function isFmp4Box(data) {
|
|
@@ -6255,7 +6501,7 @@ var BlockcastMmt = (() => {
|
|
|
6255
6501
|
return FMPU_BOX_TYPES.has(type);
|
|
6256
6502
|
}
|
|
6257
6503
|
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;
|
|
6504
|
+
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
6505
|
var _MmtpContainerParser = class _MmtpContainerParser {
|
|
6260
6506
|
constructor(config) {
|
|
6261
6507
|
__privateAdd(this, _MmtpContainerParser_instances);
|
|
@@ -6291,6 +6537,12 @@ var BlockcastMmt = (() => {
|
|
|
6291
6537
|
__privateAdd(this, _reclaimedTimingSamples, 0);
|
|
6292
6538
|
__privateAdd(this, _evictedTimingSamples, 0);
|
|
6293
6539
|
__privateAdd(this, _rejectedMovieFragments, 0);
|
|
6540
|
+
__privateAdd(this, _recoveredHeadsAwaitingTiming, {
|
|
6541
|
+
held: 0,
|
|
6542
|
+
expired: 0,
|
|
6543
|
+
discarded: 0,
|
|
6544
|
+
superseded: 0
|
|
6545
|
+
});
|
|
6294
6546
|
__privateAdd(this, _sequencers, /* @__PURE__ */ new Map());
|
|
6295
6547
|
__privateAdd(this, _fecGate, null);
|
|
6296
6548
|
__privateAdd(this, _fecSequencer, null);
|
|
@@ -6418,11 +6670,12 @@ var BlockcastMmt = (() => {
|
|
|
6418
6670
|
/**
|
|
6419
6671
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
6420
6672
|
*
|
|
6421
|
-
*
|
|
6422
|
-
*
|
|
6423
|
-
*
|
|
6424
|
-
*
|
|
6425
|
-
*
|
|
6673
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
6674
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
6675
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
6676
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
6677
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
6678
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
6426
6679
|
*/
|
|
6427
6680
|
get timingBudgetStats() {
|
|
6428
6681
|
return {
|
|
@@ -6433,6 +6686,14 @@ var BlockcastMmt = (() => {
|
|
|
6433
6686
|
rejectedMovieFragments: __privateGet(this, _rejectedMovieFragments)
|
|
6434
6687
|
};
|
|
6435
6688
|
}
|
|
6689
|
+
/** Recovered heads parked for FT=1 timing (BLO-53369). Survives dispose(). */
|
|
6690
|
+
get recoveredHeadsAwaitingTiming() {
|
|
6691
|
+
let pending = 0;
|
|
6692
|
+
for (const { awaitingTiming } of __privateGet(this, _timingStreams).values()) {
|
|
6693
|
+
for (const head of awaitingTiming) if (head.options?.recovered) pending++;
|
|
6694
|
+
}
|
|
6695
|
+
return { ...__privateGet(this, _recoveredHeadsAwaitingTiming), pending };
|
|
6696
|
+
}
|
|
6436
6697
|
get reorderStats() {
|
|
6437
6698
|
let bufferedFrames = __privateGet(this, _fecSequencer)?.buffered ?? 0;
|
|
6438
6699
|
for (const { sequencer } of __privateGet(this, _sequencers).values()) bufferedFrames += sequencer.buffered;
|
|
@@ -6474,6 +6735,14 @@ var BlockcastMmt = (() => {
|
|
|
6474
6735
|
fecReleaseRapAbove(packetId, catalogTrackName, ssId) {
|
|
6475
6736
|
return __privateGet(this, _fecSequencer)?.rapAbove(packetId, catalogTrackName, ssId) ?? false;
|
|
6476
6737
|
}
|
|
6738
|
+
/** See FecReleaseSequencer.unsource. */
|
|
6739
|
+
unsourceFecRelease(packetId, catalogTrackName) {
|
|
6740
|
+
__privateGet(this, _fecSequencer)?.unsource(packetId, catalogTrackName);
|
|
6741
|
+
}
|
|
6742
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
6743
|
+
fecReleaseHoldsRebuilt(packetId, catalogTrackName) {
|
|
6744
|
+
return __privateGet(this, _fecSequencer)?.holdsRebuilt(packetId, catalogTrackName) ?? false;
|
|
6745
|
+
}
|
|
6477
6746
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
6478
6747
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
6479
6748
|
if (!__privateGet(this, _fecSequencer)) return;
|
|
@@ -6584,7 +6853,7 @@ var BlockcastMmt = (() => {
|
|
|
6584
6853
|
const now = Date.now();
|
|
6585
6854
|
for (const { awaitingTiming } of __privateGet(this, _timingStreams).values()) {
|
|
6586
6855
|
while (awaitingTiming.length > 0 && now - awaitingTiming[0].arrivedAt > timeoutMs) {
|
|
6587
|
-
awaitingTiming.shift();
|
|
6856
|
+
__privateMethod(this, _MmtpContainerParser_instances, leaveAwaitingTiming_fn).call(this, awaitingTiming.shift(), "expired");
|
|
6588
6857
|
}
|
|
6589
6858
|
}
|
|
6590
6859
|
}
|
|
@@ -6837,6 +7106,9 @@ var BlockcastMmt = (() => {
|
|
|
6837
7106
|
for (const { sequencer } of __privateGet(this, _sequencers).values()) sequencer.discard();
|
|
6838
7107
|
__privateGet(this, _sequencers).clear();
|
|
6839
7108
|
__privateGet(this, _fecSequencer)?.discard();
|
|
7109
|
+
for (const { awaitingTiming } of __privateGet(this, _timingStreams).values()) {
|
|
7110
|
+
for (const head of awaitingTiming) __privateMethod(this, _MmtpContainerParser_instances, leaveAwaitingTiming_fn).call(this, head, "discarded");
|
|
7111
|
+
}
|
|
6840
7112
|
__privateGet(this, _timingStreams).clear();
|
|
6841
7113
|
__privateSet(this, _pendingTimingSamples, 0);
|
|
6842
7114
|
__privateGet(this, _reliableMoqStartupGate).clear();
|
|
@@ -6865,6 +7137,7 @@ var BlockcastMmt = (() => {
|
|
|
6865
7137
|
_reclaimedTimingSamples = new WeakMap();
|
|
6866
7138
|
_evictedTimingSamples = new WeakMap();
|
|
6867
7139
|
_rejectedMovieFragments = new WeakMap();
|
|
7140
|
+
_recoveredHeadsAwaitingTiming = new WeakMap();
|
|
6868
7141
|
_sequencers = new WeakMap();
|
|
6869
7142
|
_fecGate = new WeakMap();
|
|
6870
7143
|
_fecSequencer = new WeakMap();
|
|
@@ -7023,11 +7296,16 @@ var BlockcastMmt = (() => {
|
|
|
7023
7296
|
if (mpu.fragmentationIndicator !== 0 || mpu.fragmentCounter !== 0)
|
|
7024
7297
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-unexpected-fragmentation");
|
|
7025
7298
|
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");
|
|
7299
|
+
if (!resolver2?.initialized) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-no-resolver");
|
|
7027
7300
|
const pendingBefore = resolver2.pendingSampleCount;
|
|
7028
7301
|
const evictedBefore = resolver2.evictedSampleCount;
|
|
7029
|
-
const remaining = __privateGet(this, _maxPendingTimingSamples) -
|
|
7030
|
-
const admitted = resolver2.addMovieFragment(
|
|
7302
|
+
const remaining = __privateGet(this, _maxPendingTimingSamples) - resolver2.pendingSampleCount;
|
|
7303
|
+
const admitted = resolver2.addMovieFragment(
|
|
7304
|
+
mpu.mpuSequenceNumber,
|
|
7305
|
+
data,
|
|
7306
|
+
remaining,
|
|
7307
|
+
options?.recovered === true
|
|
7308
|
+
);
|
|
7031
7309
|
__privateSet(this, _pendingTimingSamples, __privateGet(this, _pendingTimingSamples) + (resolver2.pendingSampleCount - pendingBefore));
|
|
7032
7310
|
__privateSet(this, _evictedTimingSamples, __privateGet(this, _evictedTimingSamples) + (resolver2.evictedSampleCount - evictedBefore));
|
|
7033
7311
|
if (!admitted) {
|
|
@@ -7047,7 +7325,7 @@ var BlockcastMmt = (() => {
|
|
|
7047
7325
|
};
|
|
7048
7326
|
}
|
|
7049
7327
|
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,
|
|
7328
|
+
const resolver = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, true);
|
|
7051
7329
|
if (!resolver) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-no-resolver");
|
|
7052
7330
|
if (!Number.isSafeInteger(data.byteLength) || data.byteLength <= 0)
|
|
7053
7331
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-empty-payload");
|
|
@@ -7068,6 +7346,7 @@ var BlockcastMmt = (() => {
|
|
|
7068
7346
|
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
7069
7347
|
movieFragmentSequenceNumber: mfuDuHeader.movieFragmentSequenceNumber,
|
|
7070
7348
|
sampleNumber: mfuDuHeader.sampleNumber,
|
|
7349
|
+
sequenceNumber: info.sequenceNumber,
|
|
7071
7350
|
arrivedAt: Date.now()
|
|
7072
7351
|
});
|
|
7073
7352
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-sample-timing-missing");
|
|
@@ -7088,7 +7367,7 @@ var BlockcastMmt = (() => {
|
|
|
7088
7367
|
headTiming.size
|
|
7089
7368
|
);
|
|
7090
7369
|
if (readyOnRegister) {
|
|
7091
|
-
const deferred = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, readyOnRegister, info, resolver, options?.recovered === true, options?.fecSbn);
|
|
7370
|
+
const deferred = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, readyOnRegister, info, resolver, options?.recovered === true, options?.fecSbn, options?.fecSbnFirst);
|
|
7092
7371
|
if (deferred.record === void 0) __privateMethod(this, _MmtpContainerParser_instances, countDeferredOutcome_fn).call(this, deferred.reason);
|
|
7093
7372
|
}
|
|
7094
7373
|
}
|
|
@@ -7175,7 +7454,7 @@ var BlockcastMmt = (() => {
|
|
|
7175
7454
|
fragmentCounter: mpu.fragmentCounter
|
|
7176
7455
|
};
|
|
7177
7456
|
}
|
|
7178
|
-
const outcome = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, combined, info, resolver, options?.recovered === true, options?.fecSbn);
|
|
7457
|
+
const outcome = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, combined, info, resolver, options?.recovered === true, options?.fecSbn, options?.fecSbnFirst);
|
|
7179
7458
|
if (outcome.record !== void 0) return outcome.record;
|
|
7180
7459
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, outcome.reason);
|
|
7181
7460
|
};
|
|
@@ -7194,7 +7473,7 @@ var BlockcastMmt = (() => {
|
|
|
7194
7473
|
* attribution exists to keep readable. Leaving the choice at the call site
|
|
7195
7474
|
* is what keeps both true.
|
|
7196
7475
|
*/
|
|
7197
|
-
emitCombinedSample_fn = function(combined, info, resolver, recovered, fecSbn) {
|
|
7476
|
+
emitCombinedSample_fn = function(combined, info, resolver, recovered, fecSbn, fecSbnFirst) {
|
|
7198
7477
|
const timing = resolver.sampleTiming(
|
|
7199
7478
|
combined.mpuSequenceNumber,
|
|
7200
7479
|
combined.movieFragmentSequenceNumber,
|
|
@@ -7205,6 +7484,7 @@ var BlockcastMmt = (() => {
|
|
|
7205
7484
|
const meta = __privateMethod(this, _MmtpContainerParser_instances, buildFrameMeta_fn).call(this, combined, info.packetId, info.sequenceNumber, timing, recovered);
|
|
7206
7485
|
if (!meta) return { reason: "combined-meta-build-failed" };
|
|
7207
7486
|
if (fecSbn !== void 0) meta.fecSbn = fecSbn;
|
|
7487
|
+
if (fecSbnFirst !== void 0) meta.fecSbnFirst = fecSbnFirst;
|
|
7208
7488
|
if (!resolver.consumeSample(
|
|
7209
7489
|
combined.mpuSequenceNumber,
|
|
7210
7490
|
combined.movieFragmentSequenceNumber,
|
|
@@ -7249,10 +7529,23 @@ var BlockcastMmt = (() => {
|
|
|
7249
7529
|
return resolver;
|
|
7250
7530
|
};
|
|
7251
7531
|
awaitTiming_fn = function(streamKey, head) {
|
|
7252
|
-
const
|
|
7253
|
-
if (!
|
|
7532
|
+
const state = __privateGet(this, _timingStreams).get(streamKey);
|
|
7533
|
+
if (!state) return;
|
|
7534
|
+
if (!head.options?.recovered) {
|
|
7535
|
+
const kept = state.awaitingTiming.filter((queued) => !queued.options?.recovered || queued.sequenceNumber !== head.sequenceNumber);
|
|
7536
|
+
__privateGet(this, _recoveredHeadsAwaitingTiming).superseded += state.awaitingTiming.length - kept.length;
|
|
7537
|
+
state.awaitingTiming = kept;
|
|
7538
|
+
}
|
|
7539
|
+
const awaitingTiming = state.awaitingTiming;
|
|
7254
7540
|
awaitingTiming.push(head);
|
|
7255
|
-
if (
|
|
7541
|
+
if (head.options?.recovered) __privateGet(this, _recoveredHeadsAwaitingTiming).held++;
|
|
7542
|
+
if (awaitingTiming.length > MAX_AWAITING_TIMING_HEADS) {
|
|
7543
|
+
__privateMethod(this, _MmtpContainerParser_instances, leaveAwaitingTiming_fn).call(this, awaitingTiming.shift(), "expired");
|
|
7544
|
+
}
|
|
7545
|
+
};
|
|
7546
|
+
/** Count a recovered head leaving the queue other than by replay or its source copy. */
|
|
7547
|
+
leaveAwaitingTiming_fn = function(head, outcome) {
|
|
7548
|
+
if (head.options?.recovered) __privateGet(this, _recoveredHeadsAwaitingTiming)[outcome]++;
|
|
7256
7549
|
};
|
|
7257
7550
|
/**
|
|
7258
7551
|
* Feed again the heads whose timing the FT=1 just admitted declares. That
|
|
@@ -7280,6 +7573,7 @@ var BlockcastMmt = (() => {
|
|
|
7280
7573
|
const state = __privateGet(this, _timingStreams).get(streamKey);
|
|
7281
7574
|
if (!state) return;
|
|
7282
7575
|
__privateGet(this, _timingStreams).delete(streamKey);
|
|
7576
|
+
for (const head of state.awaitingTiming) __privateMethod(this, _MmtpContainerParser_instances, leaveAwaitingTiming_fn).call(this, head, "discarded");
|
|
7283
7577
|
__privateSet(this, _pendingTimingSamples, __privateGet(this, _pendingTimingSamples) - state.resolver.pendingSampleCount);
|
|
7284
7578
|
if (__privateGet(this, _pendingTimingSamples) < 0) {
|
|
7285
7579
|
throw new Error("[MmtpContainerParser] pending timing sample accounting underflow");
|
|
@@ -8158,6 +8452,9 @@ var BlockcastMmt = (() => {
|
|
|
8158
8452
|
return INACTIVE["reliable-moq"];
|
|
8159
8453
|
}
|
|
8160
8454
|
|
|
8455
|
+
// src/catalog-fec-params.ts
|
|
8456
|
+
var MAX_SAFE_TICKS_PER_HZ = Number.MAX_SAFE_INTEGER / 1e3;
|
|
8457
|
+
|
|
8161
8458
|
// src/held-layer-admission.ts
|
|
8162
8459
|
var HORIZON_CAP = 1073741824;
|
|
8163
8460
|
function heldLayerAnchorHorizon(retentionBlocks, k) {
|