@blockcast/mmt-container 2.2.0-main.a5b276c121d4 → 2.2.0-main.aee8d33d2cc8
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 +420 -55
- package/dist/browser-runtime.js.map +3 -3
- package/dist/carp-catalog.js.map +2 -2
- package/dist/catalog-fec-params.d.ts +1 -1
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +14 -1
- package/dist/catalog-fec-params.js.map +2 -2
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/cmaf-block-assembler.js +92 -1
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/codec-utils.d.ts.map +1 -1
- package/dist/codec-utils.js +92 -1
- package/dist/codec-utils.js.map +2 -2
- package/dist/delivery-catalog.js.map +2 -2
- package/dist/delta-fallback-config.js +5 -1
- package/dist/delta-fallback-config.js.map +3 -3
- package/dist/fec-manager.d.ts +44 -3
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +245 -46
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-state.js +5 -1
- package/dist/fec-state.js.map +2 -2
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts +27 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +106 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +126 -5
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +106 -2
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.js.map +2 -2
- package/dist/mmtp-router.d.ts +2 -0
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +150 -3
- 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.map +1 -1
- package/dist/multicast-manager.js +409 -53
- package/dist/multicast-manager.js.map +3 -3
- package/dist/multicast-transport.js.map +2 -2
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +1 -0
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +128 -6
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.d.ts +2 -0
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +2 -2
- package/dist/repair-fetch.js.map +2 -2
- package/dist/repair-layer-subscriptions.js.map +2 -2
- package/dist/signaling.js.map +2 -2
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +106 -2
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/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 +195 -14
- package/src/index.ts +2 -0
- package/src/mmtp-container-parser.ts +55 -11
- package/src/mmtp-router.ts +70 -6
- package/src/multicast-manager.ts +19 -3
- package/src/no-modules.ts +3 -0
- package/src/repair-fetch.ts +4 -2
|
@@ -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]);
|
|
@@ -6008,7 +6113,7 @@ var BlockcastMmt = (() => {
|
|
|
6008
6113
|
function holdsRebuilt(stream) {
|
|
6009
6114
|
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
|
|
6010
6115
|
}
|
|
6011
|
-
var _streams2, _gate, _emit2, _recordStat2, _deferDepth, _deferredStreams, _FecReleaseSequencer_instances, drainUnlessDeferred_fn, streamFor_fn2, drain_fn, drainLoop_fn, cursorPassed_fn, release_fn;
|
|
6116
|
+
var _streams2, _gate, _emit2, _recordStat2, _deferDepth, _deferredStreams, _FecReleaseSequencer_instances, drainUnlessDeferred_fn, streamFor_fn2, drain_fn, drainLoop_fn, unrepairableWaitOver_fn, cursorPassed_fn, release_fn;
|
|
6012
6117
|
var FecReleaseSequencer = class {
|
|
6013
6118
|
constructor(gate, emit, recordStat) {
|
|
6014
6119
|
__privateAdd(this, _FecReleaseSequencer_instances);
|
|
@@ -6321,7 +6426,7 @@ var BlockcastMmt = (() => {
|
|
|
6321
6426
|
from
|
|
6322
6427
|
);
|
|
6323
6428
|
unresolved = resolved === null;
|
|
6324
|
-
if (unresolved && !__privateMethod(this, _FecReleaseSequencer_instances, cursorPassed_fn).call(this, stream, asUnanchored)) {
|
|
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)) {
|
|
6325
6430
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
6326
6431
|
if (heldMs <= __privateGet(this, _gate).holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
6327
6432
|
__privateGet(this, _recordStat2).call(this, "forcedWindowFlushes");
|
|
@@ -6335,6 +6440,19 @@ var BlockcastMmt = (() => {
|
|
|
6335
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);
|
|
6336
6441
|
}
|
|
6337
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
|
+
};
|
|
6338
6456
|
/**
|
|
6339
6457
|
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
6340
6458
|
* source cursor holds it unanchored, and neither does a later frame behind
|
|
@@ -8334,6 +8452,9 @@ var BlockcastMmt = (() => {
|
|
|
8334
8452
|
return INACTIVE["reliable-moq"];
|
|
8335
8453
|
}
|
|
8336
8454
|
|
|
8455
|
+
// src/catalog-fec-params.ts
|
|
8456
|
+
var MAX_SAFE_TICKS_PER_HZ = Number.MAX_SAFE_INTEGER / 1e3;
|
|
8457
|
+
|
|
8337
8458
|
// src/held-layer-admission.ts
|
|
8338
8459
|
var HORIZON_CAP = 1073741824;
|
|
8339
8460
|
function heldLayerAnchorHorizon(retentionBlocks, k) {
|