@blockcast/mmt-container 2.2.0-main.f480a7ede8b1 → 2.2.0-main.fde7aee36726
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 +88 -16
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +164 -56
- package/dist/block-policy.js.map +3 -3
- package/dist/browser-runtime.js +2163 -303
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +40 -1
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +163 -10
- package/dist/carp-catalog.js.map +4 -4
- 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 +48 -1
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.js +34 -0
- package/dist/catalog-network-source.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 +68 -0
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/delta-fallback-config.js +39 -1
- package/dist/delta-fallback-config.js.map +4 -4
- package/dist/fec-manager.d.ts +222 -21
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +875 -131
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +17 -5
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +41 -1
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.js +34 -0
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/held-layer-admission.js +34 -0
- package/dist/held-layer-admission.js.map +3 -3
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +55 -13
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +142 -25
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/media-router.js.map +1 -1
- package/dist/mfu-reassembler.js +34 -0
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +72 -10
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +260 -18
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +411 -34
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +260 -18
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-fec-session.js +34 -0
- package/dist/mmtp-fec-session.js.map +3 -3
- package/dist/mmtp-mode-selection.d.ts +48 -0
- package/dist/mmtp-mode-selection.d.ts.map +1 -0
- package/dist/mmtp-mode-selection.js +79 -0
- package/dist/mmtp-mode-selection.js.map +7 -0
- package/dist/mmtp-router.d.ts +94 -16
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +754 -78
- package/dist/mmtp-router.js.map +4 -4
- package/dist/multicast-auth-catalog.js +42 -2
- package/dist/multicast-auth-catalog.js.map +3 -3
- package/dist/multicast-input.js +42 -2
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +121 -4
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1774 -248
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.js +70 -2
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +34 -0
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.d.ts +1 -0
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +415 -35
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +2 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +69 -2
- package/dist/phase14-catalog-override.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 +336 -27
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layer-subscriptions.js +34 -0
- package/dist/repair-layer-subscriptions.js.map +3 -3
- package/dist/signaling.js +34 -0
- package/dist/signaling.js.map +3 -3
- package/dist/timestamp-codec.js +34 -0
- package/dist/timestamp-codec.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-mfu-reassembler.js +34 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +260 -18
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/schemas/catalog.schema.json +2 -2
- package/src/block-policy.ts +324 -83
- package/src/carp-catalog.ts +165 -5
- package/src/catalog-fec-params.ts +1 -0
- package/src/codec-utils.ts +121 -1
- package/src/fec-manager.ts +835 -66
- package/src/fec-state.ts +21 -5
- package/src/index.ts +25 -0
- package/src/iso-block-locator.ts +148 -31
- package/src/mmtp-container-parser.ts +259 -24
- package/src/mmtp-mode-selection.ts +80 -0
- package/src/mmtp-router.ts +774 -86
- package/src/multicast-manager.ts +262 -16
- package/src/no-modules.ts +3 -0
- package/src/phase14-catalog-override.ts +14 -3
- package/src/repair-fetch.ts +389 -50
- package/src/track-session.ts +3 -0
- package/test-vectors/catalog/README.md +36 -2
- package/test-vectors/catalog/mmtp-siblings/ambiguous-sibling.json +158 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-bitrate-only.json +231 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-four-rungs.json +405 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-other-names.json +231 -0
- package/test-vectors/catalog/mmtp-siblings/mmtp-mode-unknown.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/multicast-endpoint-lists-datagram-track.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/no-sibling.json +79 -0
- package/test-vectors/catalog/mmtp-siblings/rendition-mismatch.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/stream-delivery-mode.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/timescale-mismatch.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/valid-pair.json +142 -0
- package/test-vectors/catalog/section-codes.json +3 -3
- package/test-vectors/catalog-validation.json +266 -7
- package/test-vectors/moq/mmtp-mode-selection.json +259 -0
package/dist/mmtp-router.js
CHANGED
|
@@ -370,6 +370,40 @@ var RUNTIME_FEC_RECEIVER = Object.freeze({
|
|
|
370
370
|
overlays: true
|
|
371
371
|
});
|
|
372
372
|
|
|
373
|
+
// ../mmt-base/dist/mmtp-siblings.js
|
|
374
|
+
var MMTP_MODES = Object.freeze(["mfu", "mfu-datagram"]);
|
|
375
|
+
var MMTP_SIBLING_HARD_FIELDS = Object.freeze([
|
|
376
|
+
"namespace",
|
|
377
|
+
"timescale",
|
|
378
|
+
"presentationAnchorTicks",
|
|
379
|
+
"groupDuration"
|
|
380
|
+
]);
|
|
381
|
+
var MMTP_SIBLING_RENDITION_FIELDS = Object.freeze([
|
|
382
|
+
"codec",
|
|
383
|
+
"width",
|
|
384
|
+
"height",
|
|
385
|
+
"framerate",
|
|
386
|
+
"bitrate",
|
|
387
|
+
"samplerate",
|
|
388
|
+
"channelConfig",
|
|
389
|
+
"lang"
|
|
390
|
+
]);
|
|
391
|
+
var MMTP_SIBLING_SOFT_FIELDS = Object.freeze([
|
|
392
|
+
"initRef",
|
|
393
|
+
"keyframeIntervalMs",
|
|
394
|
+
"keyframeIntervalTicks",
|
|
395
|
+
"isLive",
|
|
396
|
+
"altGroup"
|
|
397
|
+
]);
|
|
398
|
+
|
|
399
|
+
// ../mmt-base/dist/datagram-leg-size.js
|
|
400
|
+
var DATAGRAM_LEG_UDP_FLOOR = 1200;
|
|
401
|
+
var DATAGRAM_LEG_QUIC_WT_FRAMING = 48;
|
|
402
|
+
var DATAGRAM_LEG_OBJECT_HEADER = 13;
|
|
403
|
+
var DATAGRAM_LEG_RELAY_ROOM = 16;
|
|
404
|
+
var DATAGRAM_LEG_DATAGRAM_MAX = DATAGRAM_LEG_UDP_FLOOR - DATAGRAM_LEG_QUIC_WT_FRAMING;
|
|
405
|
+
var DATAGRAM_LEG_BODY_MAX = DATAGRAM_LEG_DATAGRAM_MAX - DATAGRAM_LEG_OBJECT_HEADER - DATAGRAM_LEG_RELAY_ROOM;
|
|
406
|
+
|
|
373
407
|
// node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
|
|
374
408
|
function endpointKey(endpoint) {
|
|
375
409
|
return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
|
|
@@ -620,6 +654,40 @@ var RUNTIME_FEC_RECEIVER2 = Object.freeze({
|
|
|
620
654
|
overlays: true
|
|
621
655
|
});
|
|
622
656
|
|
|
657
|
+
// node_modules/@blockcast/mmt-base/dist/mmtp-siblings.js
|
|
658
|
+
var MMTP_MODES2 = Object.freeze(["mfu", "mfu-datagram"]);
|
|
659
|
+
var MMTP_SIBLING_HARD_FIELDS2 = Object.freeze([
|
|
660
|
+
"namespace",
|
|
661
|
+
"timescale",
|
|
662
|
+
"presentationAnchorTicks",
|
|
663
|
+
"groupDuration"
|
|
664
|
+
]);
|
|
665
|
+
var MMTP_SIBLING_RENDITION_FIELDS2 = Object.freeze([
|
|
666
|
+
"codec",
|
|
667
|
+
"width",
|
|
668
|
+
"height",
|
|
669
|
+
"framerate",
|
|
670
|
+
"bitrate",
|
|
671
|
+
"samplerate",
|
|
672
|
+
"channelConfig",
|
|
673
|
+
"lang"
|
|
674
|
+
]);
|
|
675
|
+
var MMTP_SIBLING_SOFT_FIELDS2 = Object.freeze([
|
|
676
|
+
"initRef",
|
|
677
|
+
"keyframeIntervalMs",
|
|
678
|
+
"keyframeIntervalTicks",
|
|
679
|
+
"isLive",
|
|
680
|
+
"altGroup"
|
|
681
|
+
]);
|
|
682
|
+
|
|
683
|
+
// node_modules/@blockcast/mmt-base/dist/datagram-leg-size.js
|
|
684
|
+
var DATAGRAM_LEG_UDP_FLOOR2 = 1200;
|
|
685
|
+
var DATAGRAM_LEG_QUIC_WT_FRAMING2 = 48;
|
|
686
|
+
var DATAGRAM_LEG_OBJECT_HEADER2 = 13;
|
|
687
|
+
var DATAGRAM_LEG_RELAY_ROOM2 = 16;
|
|
688
|
+
var DATAGRAM_LEG_DATAGRAM_MAX2 = DATAGRAM_LEG_UDP_FLOOR2 - DATAGRAM_LEG_QUIC_WT_FRAMING2;
|
|
689
|
+
var DATAGRAM_LEG_BODY_MAX2 = DATAGRAM_LEG_DATAGRAM_MAX2 - DATAGRAM_LEG_OBJECT_HEADER2 - DATAGRAM_LEG_RELAY_ROOM2;
|
|
690
|
+
|
|
623
691
|
// node_modules/@blockcast/mmt-transport/dist/multicast-orchestrator.js
|
|
624
692
|
var DEFAULT_DWELL_MS = 3e3;
|
|
625
693
|
var DEFAULT_JOIN_DEADLINE_MS = 5e3;
|
|
@@ -4827,9 +4895,10 @@ function isH264IntraSlice(nal) {
|
|
|
4827
4895
|
const sliceType = readH264SliceType(nal);
|
|
4828
4896
|
return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
|
|
4829
4897
|
}
|
|
4898
|
+
var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
|
|
4830
4899
|
function readH264SliceType(nal) {
|
|
4831
4900
|
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
4832
|
-
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
4901
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
|
|
4833
4902
|
const state = { bitOffset: 0 };
|
|
4834
4903
|
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
4835
4904
|
return readUnsignedExpGolomb(rbsp, state);
|
|
@@ -4976,6 +5045,96 @@ if (void 0) {
|
|
|
4976
5045
|
]))).toBe(false);
|
|
4977
5046
|
});
|
|
4978
5047
|
});
|
|
5048
|
+
describe("readH264SliceType", () => {
|
|
5049
|
+
const wholeNalSliceType = (nal) => {
|
|
5050
|
+
if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
|
|
5051
|
+
const rbsp = removeEmulationPrevention(nal.subarray(1));
|
|
5052
|
+
const state = { bitOffset: 0 };
|
|
5053
|
+
if (readUnsignedExpGolomb(rbsp, state) === null) return null;
|
|
5054
|
+
return readUnsignedExpGolomb(rbsp, state);
|
|
5055
|
+
};
|
|
5056
|
+
const hex = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
|
|
5057
|
+
const ue = (value) => {
|
|
5058
|
+
const code = (value + 1).toString(2);
|
|
5059
|
+
return "0".repeat(code.length - 1) + code;
|
|
5060
|
+
};
|
|
5061
|
+
const sliceNal = (bits) => {
|
|
5062
|
+
const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
|
|
5063
|
+
const nal = [1];
|
|
5064
|
+
let zeros = 0;
|
|
5065
|
+
for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
|
|
5066
|
+
if (zeros >= 2 && byte <= 3) {
|
|
5067
|
+
nal.push(3);
|
|
5068
|
+
zeros = 0;
|
|
5069
|
+
}
|
|
5070
|
+
nal.push(byte);
|
|
5071
|
+
zeros = byte === 0 ? zeros + 1 : 0;
|
|
5072
|
+
}
|
|
5073
|
+
return Uint8Array.from(nal);
|
|
5074
|
+
};
|
|
5075
|
+
const x264Slices = [
|
|
5076
|
+
["64x48 P", hex("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
|
|
5077
|
+
["64x48 B", hex("419e414212fffeeade283707cb70f7"), 6, false],
|
|
5078
|
+
["64x48 non-IDR I", hex(
|
|
5079
|
+
"4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
|
|
5080
|
+
), 7, true],
|
|
5081
|
+
["1280x720 B, escape at byte 10", hex(
|
|
5082
|
+
"01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
|
|
5083
|
+
), 6, false],
|
|
5084
|
+
["1280x720 P, escape at byte 15", hex(
|
|
5085
|
+
"41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
|
|
5086
|
+
), 5, false],
|
|
5087
|
+
["1280x720 B, escape at byte 22", hex("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
|
|
5088
|
+
["7680x4320 IDR, first_mb_in_slice 97440", hex(
|
|
5089
|
+
"650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
|
|
5090
|
+
), null, true],
|
|
5091
|
+
["7680x4320 P, first_mb_in_slice 32640", hex(
|
|
5092
|
+
"410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
|
|
5093
|
+
), 5, false],
|
|
5094
|
+
["7680x4320 P, first_mb_in_slice 97440", hex(
|
|
5095
|
+
"410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
|
|
5096
|
+
), 5, false]
|
|
5097
|
+
];
|
|
5098
|
+
const syntheticSlices = [
|
|
5099
|
+
["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
|
|
5100
|
+
["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
|
|
5101
|
+
["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
|
|
5102
|
+
["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
|
|
5103
|
+
["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
|
|
5104
|
+
["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
|
|
5105
|
+
["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
|
|
5106
|
+
["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
|
|
5107
|
+
];
|
|
5108
|
+
test("reads the slice_type of real and synthetic slices", () => {
|
|
5109
|
+
for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
|
|
5110
|
+
expect(readH264SliceType(nal), name).toBe(sliceType);
|
|
5111
|
+
}
|
|
5112
|
+
});
|
|
5113
|
+
test("matches the whole-NAL unescape at every truncation", () => {
|
|
5114
|
+
for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
|
|
5115
|
+
for (let end = 0; end <= nal.length; end++) {
|
|
5116
|
+
const cut = nal.subarray(0, end);
|
|
5117
|
+
expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
|
|
5118
|
+
}
|
|
5119
|
+
}
|
|
5120
|
+
});
|
|
5121
|
+
test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
|
|
5122
|
+
const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
|
|
5123
|
+
let seed = 1;
|
|
5124
|
+
const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
|
|
5125
|
+
for (let i = 0; i < 5e3; i++) {
|
|
5126
|
+
const nal = new Uint8Array(2 + next() % 63);
|
|
5127
|
+
nal[0] = 65;
|
|
5128
|
+
for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
|
|
5129
|
+
expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
|
|
5130
|
+
}
|
|
5131
|
+
});
|
|
5132
|
+
test("classifies the x264 slices as keyframes or not", () => {
|
|
5133
|
+
for (const [name, nal, , keyframe] of x264Slices) {
|
|
5134
|
+
expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
|
|
5135
|
+
}
|
|
5136
|
+
});
|
|
5137
|
+
});
|
|
4979
5138
|
describe("avccToAnnexB", () => {
|
|
4980
5139
|
test("converts with SPS/PPS on keyframe", () => {
|
|
4981
5140
|
const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
|
|
@@ -8023,6 +8182,9 @@ function authoredGap(before, after) {
|
|
|
8023
8182
|
function ssIdAfter(a, b) {
|
|
8024
8183
|
return (a - b | 0) > 0;
|
|
8025
8184
|
}
|
|
8185
|
+
function holdsRebuilt(stream) {
|
|
8186
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
|
|
8187
|
+
}
|
|
8026
8188
|
var FecReleaseSequencer = class {
|
|
8027
8189
|
#streams = /* @__PURE__ */ new Map();
|
|
8028
8190
|
#gate;
|
|
@@ -8085,6 +8247,7 @@ var FecReleaseSequencer = class {
|
|
|
8085
8247
|
stream.lastSbn = void 0;
|
|
8086
8248
|
stream.discontinuity = false;
|
|
8087
8249
|
stream.rapSsId = void 0;
|
|
8250
|
+
stream.sourced = false;
|
|
8088
8251
|
}
|
|
8089
8252
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
8090
8253
|
this.#recordStat("droppedStale");
|
|
@@ -8111,6 +8274,7 @@ var FecReleaseSequencer = class {
|
|
|
8111
8274
|
if (compareFrameOrder(stream.buf[mid], frame) < 0) lo = mid + 1;
|
|
8112
8275
|
else hi = mid;
|
|
8113
8276
|
}
|
|
8277
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true;
|
|
8114
8278
|
stream.buf.splice(lo, 0, frame);
|
|
8115
8279
|
this.#drainUnlessDeferred(stream);
|
|
8116
8280
|
}
|
|
@@ -8146,6 +8310,41 @@ var FecReleaseSequencer = class {
|
|
|
8146
8310
|
}
|
|
8147
8311
|
return false;
|
|
8148
8312
|
}
|
|
8313
|
+
/**
|
|
8314
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
8315
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
8316
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
8317
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
8318
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
8319
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
8320
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
8321
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
8322
|
+
* released.
|
|
8323
|
+
*/
|
|
8324
|
+
unsource(packetId, catalogTrackName) {
|
|
8325
|
+
for (const stream of this.#streams.values()) {
|
|
8326
|
+
if (stream.packetId === packetId && (catalogTrackName === void 0 || stream.catalogTrackName === catalogTrackName)) {
|
|
8327
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
8328
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
8329
|
+
else this.#drain(stream, true);
|
|
8330
|
+
}
|
|
8331
|
+
stream.sourced = false;
|
|
8332
|
+
}
|
|
8333
|
+
}
|
|
8334
|
+
}
|
|
8335
|
+
/**
|
|
8336
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
8337
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
8338
|
+
* packetId.
|
|
8339
|
+
*/
|
|
8340
|
+
holdsRebuilt(packetId, catalogTrackName) {
|
|
8341
|
+
for (const stream of this.#streams.values()) {
|
|
8342
|
+
if (stream.packetId !== packetId) continue;
|
|
8343
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
8344
|
+
if (holdsRebuilt(stream)) return true;
|
|
8345
|
+
}
|
|
8346
|
+
return false;
|
|
8347
|
+
}
|
|
8149
8348
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
8150
8349
|
poke(streamKey) {
|
|
8151
8350
|
if (streamKey !== void 0) {
|
|
@@ -8237,16 +8436,32 @@ var FecReleaseSequencer = class {
|
|
|
8237
8436
|
last: null,
|
|
8238
8437
|
lastSbn: void 0,
|
|
8239
8438
|
discontinuity: false,
|
|
8240
|
-
rapSsId: void 0
|
|
8439
|
+
rapSsId: void 0,
|
|
8440
|
+
sourced: false,
|
|
8441
|
+
draining: 0
|
|
8241
8442
|
};
|
|
8242
8443
|
this.#streams.set(streamKey, stream);
|
|
8243
8444
|
}
|
|
8244
8445
|
return stream;
|
|
8245
8446
|
}
|
|
8246
|
-
#
|
|
8447
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
8448
|
+
#drain(stream, asUnanchored = false) {
|
|
8449
|
+
stream.draining++;
|
|
8450
|
+
try {
|
|
8451
|
+
this.#drainLoop(stream, asUnanchored);
|
|
8452
|
+
} finally {
|
|
8453
|
+
stream.draining--;
|
|
8454
|
+
}
|
|
8455
|
+
}
|
|
8456
|
+
#drainLoop(stream, asUnanchored) {
|
|
8247
8457
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
8248
8458
|
const head = stream.buf[0];
|
|
8249
8459
|
const last = stream.last;
|
|
8460
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
8461
|
+
stream.buf.shift();
|
|
8462
|
+
this.#release(stream, head, void 0);
|
|
8463
|
+
continue;
|
|
8464
|
+
}
|
|
8250
8465
|
if (stream.discontinuity) {
|
|
8251
8466
|
stream.discontinuity = false;
|
|
8252
8467
|
stream.buf.shift();
|
|
@@ -8260,9 +8475,10 @@ var FecReleaseSequencer = class {
|
|
|
8260
8475
|
}
|
|
8261
8476
|
const headSbn = head.meta.fecSbn;
|
|
8262
8477
|
const from = stream.lastSbn ?? headSbn;
|
|
8263
|
-
const to = headSbn ?? stream.lastSbn;
|
|
8478
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn;
|
|
8264
8479
|
let lost = [];
|
|
8265
8480
|
const unanchored = from === void 0 && to === void 0;
|
|
8481
|
+
let unresolved = false;
|
|
8266
8482
|
if (from !== void 0 && to !== void 0) {
|
|
8267
8483
|
const resolved = this.#gate.resolvedLoss(
|
|
8268
8484
|
stream.packetId,
|
|
@@ -8271,7 +8487,8 @@ var FecReleaseSequencer = class {
|
|
|
8271
8487
|
Math.max(from, to),
|
|
8272
8488
|
from
|
|
8273
8489
|
);
|
|
8274
|
-
|
|
8490
|
+
unresolved = resolved === null;
|
|
8491
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored) && !this.#unrepairableWaitOver(stream, last, head, from, to)) {
|
|
8275
8492
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
8276
8493
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
8277
8494
|
this.#recordStat("forcedWindowFlushes");
|
|
@@ -8279,22 +8496,69 @@ var FecReleaseSequencer = class {
|
|
|
8279
8496
|
this.#release(stream, head, this.#gate.decide(last, head, [], true));
|
|
8280
8497
|
continue;
|
|
8281
8498
|
}
|
|
8282
|
-
lost = resolved;
|
|
8499
|
+
lost = resolved ?? [];
|
|
8283
8500
|
}
|
|
8284
8501
|
stream.buf.shift();
|
|
8285
8502
|
this.#release(
|
|
8286
8503
|
stream,
|
|
8287
8504
|
head,
|
|
8288
|
-
lost.length > 0 || unanchored || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
8505
|
+
lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
8289
8506
|
);
|
|
8290
8507
|
}
|
|
8291
8508
|
}
|
|
8509
|
+
/**
|
|
8510
|
+
* The head has waited out a gap only a late source can still fill
|
|
8511
|
+
* (FecReleaseGate.unrepairableWaitMs). Not yet: the gate is asked to poke
|
|
8512
|
+
* the stream when it has (`wakeAt`), since no packet may come by then.
|
|
8513
|
+
*/
|
|
8514
|
+
#unrepairableWaitOver(stream, last, head, from, to) {
|
|
8515
|
+
const waitMs = this.#gate.unrepairableWaitMs?.(last, head, from, to);
|
|
8516
|
+
if (waitMs === void 0) return false;
|
|
8517
|
+
const atMs = head.arrivedAtMs + waitMs;
|
|
8518
|
+
if (performance.now() >= atMs) return true;
|
|
8519
|
+
this.#gate.wakeAt?.(stream.packetId, stream.catalogTrackName, atMs);
|
|
8520
|
+
return false;
|
|
8521
|
+
}
|
|
8522
|
+
/**
|
|
8523
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
8524
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
8525
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
8526
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
8527
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
8528
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
8529
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
8530
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
8531
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
8532
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
8533
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
8534
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
8535
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
8536
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
8537
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
8538
|
+
*/
|
|
8539
|
+
#cursorPassed(stream, asUnanchored) {
|
|
8540
|
+
let at = -1;
|
|
8541
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
8542
|
+
const frame = stream.buf[i];
|
|
8543
|
+
if (frame.meta.fecSbnFirst !== void 0 || frame.meta.fecSbn === void 0) {
|
|
8544
|
+
frame.passed = true;
|
|
8545
|
+
if (at < 0) at = i;
|
|
8546
|
+
} else if (frame.passed !== true) break;
|
|
8547
|
+
}
|
|
8548
|
+
if (at < 0) return false;
|
|
8549
|
+
return asUnanchored || !stream.sourced || this.#gate.releaseUnanchored?.(stream.packetId, stream.catalogTrackName) === true || stream.buf.some(({ meta }, i) => i > at && meta.fecSbnFirst === void 0 && (meta.recovered !== true || meta.fecSbn !== void 0));
|
|
8550
|
+
}
|
|
8292
8551
|
#release(stream, frame, decision) {
|
|
8552
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0;
|
|
8553
|
+
if (stale) this.#recordStat("droppedStale");
|
|
8293
8554
|
if (decision) frame.meta.gapBefore = decision;
|
|
8294
8555
|
stream.last = frame;
|
|
8295
|
-
if (frame.meta.fecSbn !== void 0
|
|
8556
|
+
if (frame.meta.fecSbn !== void 0 && (frame.meta.fecSbnFirst === void 0 || stream.lastSbn !== void 0)) {
|
|
8557
|
+
stream.lastSbn = frame.meta.fecSbn;
|
|
8558
|
+
}
|
|
8559
|
+
if (frame.meta.recovered !== true) stream.sourced = true;
|
|
8296
8560
|
this.#gate.onReleased?.(frame.data, frame.meta);
|
|
8297
|
-
this.#emit(frame.data, frame.meta);
|
|
8561
|
+
if (!stale) this.#emit(frame.data, frame.meta);
|
|
8298
8562
|
}
|
|
8299
8563
|
};
|
|
8300
8564
|
var FMPU_BOX_TYPES = /* @__PURE__ */ new Set(["ftyp", "moov", "moof"]);
|
|
@@ -8555,11 +8819,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
8555
8819
|
/**
|
|
8556
8820
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
8557
8821
|
*
|
|
8558
|
-
*
|
|
8559
|
-
*
|
|
8560
|
-
*
|
|
8561
|
-
*
|
|
8562
|
-
*
|
|
8822
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
8823
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
8824
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
8825
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
8826
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
8827
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
8563
8828
|
*/
|
|
8564
8829
|
get timingBudgetStats() {
|
|
8565
8830
|
return {
|
|
@@ -8619,6 +8884,14 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
8619
8884
|
fecReleaseRapAbove(packetId, catalogTrackName, ssId) {
|
|
8620
8885
|
return this.#fecSequencer?.rapAbove(packetId, catalogTrackName, ssId) ?? false;
|
|
8621
8886
|
}
|
|
8887
|
+
/** See FecReleaseSequencer.unsource. */
|
|
8888
|
+
unsourceFecRelease(packetId, catalogTrackName) {
|
|
8889
|
+
this.#fecSequencer?.unsource(packetId, catalogTrackName);
|
|
8890
|
+
}
|
|
8891
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
8892
|
+
fecReleaseHoldsRebuilt(packetId, catalogTrackName) {
|
|
8893
|
+
return this.#fecSequencer?.holdsRebuilt(packetId, catalogTrackName) ?? false;
|
|
8894
|
+
}
|
|
8622
8895
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
8623
8896
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
8624
8897
|
if (!this.#fecSequencer) return;
|
|
@@ -8872,7 +9145,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
8872
9145
|
if (!resolver2?.initialized) return this.#drop("fragment-no-resolver");
|
|
8873
9146
|
const pendingBefore = resolver2.pendingSampleCount;
|
|
8874
9147
|
const evictedBefore = resolver2.evictedSampleCount;
|
|
8875
|
-
const remaining = this.#maxPendingTimingSamples -
|
|
9148
|
+
const remaining = this.#maxPendingTimingSamples - resolver2.pendingSampleCount;
|
|
8876
9149
|
const admitted = resolver2.addMovieFragment(
|
|
8877
9150
|
mpu.mpuSequenceNumber,
|
|
8878
9151
|
data,
|
|
@@ -8945,7 +9218,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
8945
9218
|
info,
|
|
8946
9219
|
resolver,
|
|
8947
9220
|
options?.recovered === true,
|
|
8948
|
-
options?.fecSbn
|
|
9221
|
+
options?.fecSbn,
|
|
9222
|
+
options?.fecSbnFirst
|
|
8949
9223
|
);
|
|
8950
9224
|
if (deferred.record === void 0) this.#countDeferredOutcome(deferred.reason);
|
|
8951
9225
|
}
|
|
@@ -9038,7 +9312,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
9038
9312
|
info,
|
|
9039
9313
|
resolver,
|
|
9040
9314
|
options?.recovered === true,
|
|
9041
|
-
options?.fecSbn
|
|
9315
|
+
options?.fecSbn,
|
|
9316
|
+
options?.fecSbnFirst
|
|
9042
9317
|
);
|
|
9043
9318
|
if (outcome.record !== void 0) return outcome.record;
|
|
9044
9319
|
return this.#drop(outcome.reason);
|
|
@@ -9058,7 +9333,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
9058
9333
|
* attribution exists to keep readable. Leaving the choice at the call site
|
|
9059
9334
|
* is what keeps both true.
|
|
9060
9335
|
*/
|
|
9061
|
-
#emitCombinedSample(combined, info, resolver, recovered, fecSbn) {
|
|
9336
|
+
#emitCombinedSample(combined, info, resolver, recovered, fecSbn, fecSbnFirst) {
|
|
9062
9337
|
const timing = resolver.sampleTiming(
|
|
9063
9338
|
combined.mpuSequenceNumber,
|
|
9064
9339
|
combined.movieFragmentSequenceNumber,
|
|
@@ -9075,6 +9350,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
9075
9350
|
);
|
|
9076
9351
|
if (!meta) return { reason: "combined-meta-build-failed" };
|
|
9077
9352
|
if (fecSbn !== void 0) meta.fecSbn = fecSbn;
|
|
9353
|
+
if (fecSbnFirst !== void 0) meta.fecSbnFirst = fecSbnFirst;
|
|
9078
9354
|
if (!resolver.consumeSample(
|
|
9079
9355
|
combined.mpuSequenceNumber,
|
|
9080
9356
|
combined.movieFragmentSequenceNumber,
|
|
@@ -9914,7 +10190,18 @@ function keyframeOverlaySsId(header) {
|
|
|
9914
10190
|
if (ext?.type !== KEYFRAME_OVERLAY_EXTENSION_TYPE || ext.data.length !== 4) return void 0;
|
|
9915
10191
|
return new DataView(ext.data.buffer, ext.data.byteOffset, 4).getUint32(0);
|
|
9916
10192
|
}
|
|
10193
|
+
function overlayBaseSsId(anchor, overlaySsId, restoredPsn, headerPsn) {
|
|
10194
|
+
if (anchor.baseSsId === void 0 || headerPsn !== restoredPsn) return void 0;
|
|
10195
|
+
return serial32Add(anchor.baseSsId, overlaySsId - anchor.overlaySsId | 0);
|
|
10196
|
+
}
|
|
10197
|
+
function unstampedBaseSsId(offset, unstampedOffset, headerPsn) {
|
|
10198
|
+
if (offset === void 0 || offset !== unstampedOffset) return void 0;
|
|
10199
|
+
return headerPsn + offset >>> 0;
|
|
10200
|
+
}
|
|
10201
|
+
var OVERLAY_ROUTED_LIMIT = 1024;
|
|
10202
|
+
var OVERLAY_PENDING_LIMIT = 256;
|
|
9917
10203
|
var OVERLAY_OFFSET_MPUS = 16;
|
|
10204
|
+
var OVERLAY_REBUILT_LIMIT = 256;
|
|
9918
10205
|
var OVERLAY_MOQ_HORIZON_BLOCKS = 64;
|
|
9919
10206
|
function assertStreamIdentity(role, stream) {
|
|
9920
10207
|
if (stream === void 0 || !Number.isInteger(stream.packetId) || stream.packetId <= MMTP_SIGNALING_PACKET_ID || typeof stream.catalogTrackName !== "string" || stream.catalogTrackName.length === 0) {
|
|
@@ -10025,6 +10312,7 @@ var MmtpRouter = class {
|
|
|
10025
10312
|
#provenance = /* @__PURE__ */ new Map();
|
|
10026
10313
|
#onFlowProtected = null;
|
|
10027
10314
|
#unadmittedListedDrops = 0;
|
|
10315
|
+
#admittedSourceDatagrams = 0;
|
|
10028
10316
|
#unlistedRepairSetAside = 0;
|
|
10029
10317
|
#assistBlocks = /* @__PURE__ */ new Map();
|
|
10030
10318
|
#assistFailures = /* @__PURE__ */ new Map();
|
|
@@ -10041,6 +10329,20 @@ var MmtpRouter = class {
|
|
|
10041
10329
|
/** The flow whose receiver admitted a stream's source datagrams, by packetId then catalog track name: recovered packets answer to it. */
|
|
10042
10330
|
#provenanceStreamFlow = /* @__PURE__ */ new Map();
|
|
10043
10331
|
#unregisteredFlowDrops = 0;
|
|
10332
|
+
/** "mfu-datagram" leg packets of a packet id the ingress does not name (never the signaling flow). */
|
|
10333
|
+
#datagramLegIngressDrops = 0;
|
|
10334
|
+
/** "mfu-datagram" leg packets of the signaling flow (packet id 0): expected, one per group. */
|
|
10335
|
+
#datagramLegSignalingPackets = 0;
|
|
10336
|
+
/**
|
|
10337
|
+
* The streams a live "mfu-datagram" leg has fed, catalog track names by
|
|
10338
|
+
* packet id: their ledgers and release gate take the leg's bounds. A stream
|
|
10339
|
+
* leaves when its leg does: `endDatagramLeg`, `resetTrack`, `dispose`, or
|
|
10340
|
+
* the first multicast packet of its packet id (the ordered switch retires
|
|
10341
|
+
* the leg first). The "mfu" sibling shares the packet id, never the name.
|
|
10342
|
+
*/
|
|
10343
|
+
#datagramLegStreams = /* @__PURE__ */ new Map();
|
|
10344
|
+
/** The leg's presentation budget (setDatagramLegPresentationBudget), or null: no presentation bound. */
|
|
10345
|
+
#datagramLegPresentationBudgetMs = null;
|
|
10044
10346
|
#ambiguousRecoveredDrops = 0;
|
|
10045
10347
|
// Temp state set by #processMMTP before calling parser.feed(),
|
|
10046
10348
|
// read by the parser's onFrame callback for CMAF assembly + dedup.
|
|
@@ -10081,6 +10383,26 @@ var MmtpRouter = class {
|
|
|
10081
10383
|
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
10082
10384
|
*/
|
|
10083
10385
|
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
10386
|
+
/**
|
|
10387
|
+
* Per stream, the SS_ID offset at which a base recovery last showed the
|
|
10388
|
+
* sender's own packet_sequence_number: a recovered packet's header psn
|
|
10389
|
+
* equal to its SS_ID minus that offset. While it equals the stream's
|
|
10390
|
+
* current offset, no hop re-stamps the stream, and a packet's protected psn
|
|
10391
|
+
* names its base SS_ID within unstampedBaseSsId's limits (joint decoding of
|
|
10392
|
+
* an MPU no member of which arrived).
|
|
10393
|
+
*/
|
|
10394
|
+
#unstampedSsIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
10395
|
+
/**
|
|
10396
|
+
* The same, shown by the overlay alone, before any base recovery did: a
|
|
10397
|
+
* packet it rebuilt whose base copy carries its protected psn
|
|
10398
|
+
* (#feedOverlaySource), or whose protected psn passes overlayBaseSsId's
|
|
10399
|
+
* test at that offset (#routeOverlayRecovered). A base SS_ID placed by it
|
|
10400
|
+
* anchors the release gate only (BLO-52085 D3): fed to the base, it would
|
|
10401
|
+
* make the base drop a late base copy of a keyframe the overlay never
|
|
10402
|
+
* finished, and lift a block's late-source cut, which nothing before
|
|
10403
|
+
* this offset did.
|
|
10404
|
+
*/
|
|
10405
|
+
#overlayUnstampedSsIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
10084
10406
|
/**
|
|
10085
10407
|
* Streams whose multicast leg delivered a RAP-flagged source packet that was
|
|
10086
10408
|
* not parsed, typically because its overlap copy was parsed first
|
|
@@ -10126,6 +10448,8 @@ var MmtpRouter = class {
|
|
|
10126
10448
|
// end: a synchronous recovery completes its block BEFORE routing the
|
|
10127
10449
|
// recovered frames, and releasing a held gap in between would strand them.
|
|
10128
10450
|
#fecPokeDepth = 0;
|
|
10451
|
+
/** FecReleaseGate.wakeAt timers, by media stream key. */
|
|
10452
|
+
#fecWakes = /* @__PURE__ */ new Map();
|
|
10129
10453
|
#pendingFecPokes = /* @__PURE__ */ new Map();
|
|
10130
10454
|
// ── Phase 14: per-role packetId dispatch (D-26, D-27, D-28) ───────
|
|
10131
10455
|
/** Maps packetId → TrackRole. Default: 'single' when absent (legacy path). */
|
|
@@ -10150,7 +10474,9 @@ var MmtpRouter = class {
|
|
|
10150
10474
|
recovered: 0,
|
|
10151
10475
|
restarts: 0,
|
|
10152
10476
|
unsequencedDropped: 0,
|
|
10153
|
-
protectedDropped: 0
|
|
10477
|
+
protectedDropped: 0,
|
|
10478
|
+
baseFed: 0,
|
|
10479
|
+
baseUndetermined: 0
|
|
10154
10480
|
};
|
|
10155
10481
|
/** Callback fired when a delta-track FEC block completes or fails. */
|
|
10156
10482
|
#onDeltaBlockCompleteCb = null;
|
|
@@ -10356,13 +10682,18 @@ var MmtpRouter = class {
|
|
|
10356
10682
|
this.#onDeltaBlockCompleteCb?.(packetId, false);
|
|
10357
10683
|
}
|
|
10358
10684
|
};
|
|
10359
|
-
this.#fecManager.onBlockFailed = (sbn, packetId, catalogTrackName, blockClass) => {
|
|
10685
|
+
this.#fecManager.onBlockFailed = (sbn, packetId, catalogTrackName, blockClass, span) => {
|
|
10360
10686
|
this.#mseAssemblerFor(packetId, catalogTrackName)?.failBlock(sbn);
|
|
10361
10687
|
if (this.#isCatalogTrackUnambiguous(packetId, catalogTrackName) && this.#packetIdRoles.get(packetId) === "delta") {
|
|
10362
10688
|
this.#onDeltaBlockCompleteCb?.(packetId, true);
|
|
10363
10689
|
}
|
|
10364
|
-
|
|
10365
|
-
|
|
10690
|
+
if (span === void 0) {
|
|
10691
|
+
onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
10692
|
+
this.#onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass);
|
|
10693
|
+
} else {
|
|
10694
|
+
onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span);
|
|
10695
|
+
this.#onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span);
|
|
10696
|
+
}
|
|
10366
10697
|
};
|
|
10367
10698
|
}
|
|
10368
10699
|
}
|
|
@@ -10387,10 +10718,11 @@ var MmtpRouter = class {
|
|
|
10387
10718
|
const blockLifetimeMs = fec.blockLifetimeMsForPacket(packetId);
|
|
10388
10719
|
if (blockSpanMs === void 0 || blockLifetimeMs === void 0) return NO_FEC_GEOMETRY_HORIZON;
|
|
10389
10720
|
if (blockSpanMs === 0) return NO_BLOCK_SPAN_HORIZON;
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
retentionMs
|
|
10393
|
-
}
|
|
10721
|
+
let retentionMs = duplicateRetentionMs({ blockSpanMs, blockLifetimeMs });
|
|
10722
|
+
if (this.#datagramLegStreams.has(packetId)) {
|
|
10723
|
+
retentionMs = Math.max(retentionMs, fec.datagramLegLedgerRetentionMsForPacket?.(packetId) ?? 0);
|
|
10724
|
+
}
|
|
10725
|
+
return { kind: "fec-horizon", retentionMs };
|
|
10394
10726
|
}
|
|
10395
10727
|
/**
|
|
10396
10728
|
* Init segments rejected since construction because their packetId had no
|
|
@@ -10407,8 +10739,9 @@ var MmtpRouter = class {
|
|
|
10407
10739
|
}
|
|
10408
10740
|
/**
|
|
10409
10741
|
* FEC-recovered source symbols whose reconstructed header named a
|
|
10410
|
-
* packet_sequence_number other than the wire sequence their SS_ID maps to
|
|
10411
|
-
*
|
|
10742
|
+
* packet_sequence_number other than the wire sequence their SS_ID maps to,
|
|
10743
|
+
* or, rebuilt by the overlay, than their base copy carries: a hop
|
|
10744
|
+
* re-stamped the sequence after the sender protected the packet.
|
|
10412
10745
|
*/
|
|
10413
10746
|
get restampedRecoveredSequenceCount() {
|
|
10414
10747
|
return this.#restampedRecoveredSeqs;
|
|
@@ -10587,6 +10920,7 @@ var MmtpRouter = class {
|
|
|
10587
10920
|
enableMseAssembler(packetId, config, catalogTrackName) {
|
|
10588
10921
|
const assemblerKey = this.#mseAssemblerKey(packetId, catalogTrackName);
|
|
10589
10922
|
const previous = this.#mseAssemblers.get(assemblerKey);
|
|
10923
|
+
this.#parser.unsourceFecRelease(packetId, catalogTrackName);
|
|
10590
10924
|
if (previous) {
|
|
10591
10925
|
previous.flush();
|
|
10592
10926
|
previous.dispose();
|
|
@@ -10737,7 +11071,8 @@ var MmtpRouter = class {
|
|
|
10737
11071
|
fec,
|
|
10738
11072
|
k,
|
|
10739
11073
|
offsets: /* @__PURE__ */ new Map(),
|
|
10740
|
-
moqBlocks: /* @__PURE__ */ new Set()
|
|
11074
|
+
moqBlocks: /* @__PURE__ */ new Set(),
|
|
11075
|
+
rebuilt: /* @__PURE__ */ new Map()
|
|
10741
11076
|
};
|
|
10742
11077
|
this.#overlays.set(repairPacketId, inst);
|
|
10743
11078
|
return () => {
|
|
@@ -10767,12 +11102,18 @@ var MmtpRouter = class {
|
|
|
10767
11102
|
*/
|
|
10768
11103
|
resetKeyframeOverlays(sourcePacketId, catalogTrackName) {
|
|
10769
11104
|
for (const inst of this.#overlaysForSource(sourcePacketId, catalogTrackName)) this.#resetOverlay(inst);
|
|
11105
|
+
for (const [name, stream] of this.#streams.get(sourcePacketId) ?? []) {
|
|
11106
|
+
if (catalogTrackName !== void 0 && name !== catalogTrackName) continue;
|
|
11107
|
+
stream.overlayToBase.routed.clear();
|
|
11108
|
+
stream.overlayToBase.pending.clear();
|
|
11109
|
+
}
|
|
10770
11110
|
}
|
|
10771
11111
|
#resetOverlay(inst) {
|
|
10772
11112
|
inst.fec.resetTrack(inst.repairPacketId, inst.streamName);
|
|
10773
11113
|
inst.last = void 0;
|
|
10774
11114
|
inst.offsets.clear();
|
|
10775
11115
|
inst.moqBlocks.clear();
|
|
11116
|
+
inst.rebuilt.clear();
|
|
10776
11117
|
}
|
|
10777
11118
|
#overlaysForSource(sourcePacketId, catalogTrackName) {
|
|
10778
11119
|
return [...this.#overlays.values()].filter(({ leg }) => leg.sourcePacketId === sourcePacketId && (catalogTrackName === void 0 || leg.sourceCatalogTrackName === void 0 || leg.sourceCatalogTrackName === catalogTrackName));
|
|
@@ -10804,7 +11145,7 @@ var MmtpRouter = class {
|
|
|
10804
11145
|
const blockStart = placement.block.start;
|
|
10805
11146
|
if (placement.span !== void 0) this.#replayOverlaySources(inst, placement.span.block.start, placement.span.placed);
|
|
10806
11147
|
this.#replayOverlaySources(inst, blockStart, placement.placed);
|
|
10807
|
-
if (source
|
|
11148
|
+
if (source !== "multicast") this.#noteOverlayMoqBlock(inst, blockStart);
|
|
10808
11149
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, pid, name);
|
|
10809
11150
|
const recovered = fec.feedRepairSymbol(pid, repair.ssStart, repair.ssbLength, repair.rsId, repair.symbolData, name);
|
|
10810
11151
|
if (recovered && !alreadyCompleted) this.#routeOverlayRecovered(inst, blockStart, recovered);
|
|
@@ -10812,7 +11153,7 @@ var MmtpRouter = class {
|
|
|
10812
11153
|
#replayOverlaySources(inst, blockStart, placed) {
|
|
10813
11154
|
const { fec, repairPacketId: pid, streamName: name } = inst;
|
|
10814
11155
|
for (const { ssId, payload } of placed) {
|
|
10815
|
-
if (payload.source
|
|
11156
|
+
if (payload.source !== "multicast") this.#noteOverlayMoqBlock(inst, blockStart);
|
|
10816
11157
|
if (payload.oversized) continue;
|
|
10817
11158
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, pid, name);
|
|
10818
11159
|
const recovered = fec.feedSourceSymbol(pid, ssId, payload.symbolData, name);
|
|
@@ -10823,18 +11164,33 @@ var MmtpRouter = class {
|
|
|
10823
11164
|
* A source packet that carries a 0x8B01 overlay SS_ID is also a symbol of
|
|
10824
11165
|
* every overlay installed for its source, at that SS_ID, with the bytes the
|
|
10825
11166
|
* base protects: the packet minus its 4-byte SS_ID trailer, extension
|
|
10826
|
-
* included (7.1, 7.4.3).
|
|
10827
|
-
|
|
10828
|
-
|
|
11167
|
+
* included (7.1, 7.4.3). `baseSsId` is that trailer's SS_ID, when the base
|
|
11168
|
+
* FEC reads it.
|
|
11169
|
+
*
|
|
11170
|
+
* The base copy of a packet an overlay rebuilt with no base SS_ID shows
|
|
11171
|
+
* what a base recovery of it would (#routeProcessedFecSymbols, BLO-52085):
|
|
11172
|
+
* its wire packet_sequence_number equal to the protected one rebuilt shows
|
|
11173
|
+
* the stream unstamped at the SS_ID offset it states, for the release gate
|
|
11174
|
+
* (#overlayUnstampedSsIdSeqOffsetByStream); any other shows a hop that
|
|
11175
|
+
* re-stamps it, which is counted (restampedRecoveredSequenceCount).
|
|
11176
|
+
*/
|
|
11177
|
+
#feedOverlaySource(packetId, catalogTrackName, packet, header, sequenceNumber, rapFlag, source, baseSsId) {
|
|
10829
11178
|
if (this.#overlays.size === 0) return;
|
|
10830
11179
|
const ssId = keyframeOverlaySsId(header);
|
|
10831
11180
|
if (ssId === void 0) return;
|
|
11181
|
+
let rebuiltPsn;
|
|
10832
11182
|
for (const inst of this.#overlaysForSource(packetId, catalogTrackName)) {
|
|
10833
11183
|
this.#noteOverlaySsId(inst, ssId, sequenceNumber);
|
|
11184
|
+
rebuiltPsn ??= inst.rebuilt.get(ssId);
|
|
11185
|
+
inst.rebuilt.delete(ssId);
|
|
10834
11186
|
const identity = MmtpContainerParser.sourcePacketIdentity(packet, header);
|
|
10835
11187
|
if (identity !== null) {
|
|
10836
11188
|
inst.offsets.delete(identity.mpuSequenceNumber);
|
|
10837
|
-
inst.offsets.set(identity.mpuSequenceNumber,
|
|
11189
|
+
inst.offsets.set(identity.mpuSequenceNumber, {
|
|
11190
|
+
psnOffset: ssId - sequenceNumber >>> 0,
|
|
11191
|
+
overlaySsId: ssId,
|
|
11192
|
+
...baseSsId === void 0 ? {} : { baseSsId }
|
|
11193
|
+
});
|
|
10838
11194
|
if (inst.offsets.size > OVERLAY_OFFSET_MPUS) inst.offsets.delete(inst.offsets.keys().next().value);
|
|
10839
11195
|
}
|
|
10840
11196
|
const { fec, repairPacketId: pid, streamName: name } = inst;
|
|
@@ -10850,12 +11206,20 @@ var MmtpRouter = class {
|
|
|
10850
11206
|
});
|
|
10851
11207
|
continue;
|
|
10852
11208
|
}
|
|
10853
|
-
if (source
|
|
11209
|
+
if (source !== "multicast") this.#noteOverlayMoqBlock(inst, coords.sbn);
|
|
10854
11210
|
if (oversized) continue;
|
|
10855
11211
|
const alreadyCompleted = fec.isBlockCompleted(coords.sbn, pid, name);
|
|
10856
11212
|
const recovered = fec.feedSourceSymbol(pid, ssId, symbolData, name);
|
|
10857
11213
|
if (recovered && !alreadyCompleted) this.#routeOverlayRecovered(inst, coords.sbn, recovered);
|
|
10858
11214
|
}
|
|
11215
|
+
if (rebuiltPsn === void 0 || this.#classifyPacketId(packetId) === null) return;
|
|
11216
|
+
const streamKey = this.#mediaStreamKey(packetId, catalogTrackName);
|
|
11217
|
+
if (rebuiltPsn !== sequenceNumber) {
|
|
11218
|
+
this.#restampedRecoveredSeqs++;
|
|
11219
|
+
} else if (baseSsId !== void 0) {
|
|
11220
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
11221
|
+
if (offset === baseSsId - sequenceNumber >>> 0) this.#overlayUnstampedSsIdSeqOffsetByStream.set(streamKey, offset);
|
|
11222
|
+
}
|
|
10859
11223
|
}
|
|
10860
11224
|
#noteOverlayMoqBlock(inst, blockStart) {
|
|
10861
11225
|
inst.moqBlocks.add(blockStart);
|
|
@@ -10889,11 +11253,16 @@ var MmtpRouter = class {
|
|
|
10889
11253
|
}
|
|
10890
11254
|
/**
|
|
10891
11255
|
* Route an overlay-recovered block's packets as source media of the
|
|
10892
|
-
* overlay's source (7.2: an overlay coordinate yields no base SS_ID).
|
|
10893
|
-
*
|
|
10894
|
-
*
|
|
10895
|
-
*
|
|
10896
|
-
*
|
|
11256
|
+
* overlay's source (7.2: an overlay coordinate yields no base SS_ID). A
|
|
11257
|
+
* packet whose base SS_ID is determined independently (overlayBaseSsId,
|
|
11258
|
+
* unstampedBaseSsId) enters the release gate at that SS_ID, as a packet
|
|
11259
|
+
* base FEC recovered does, so it waits behind base frames still in flight,
|
|
11260
|
+
* though not for its own MPU's packets (FrameMeta.fecSbnFirst) and no
|
|
11261
|
+
* longer than unanchored; one whose base SS_ID is undetermined has no
|
|
11262
|
+
* release-gate anchor. No parse ledger, no base re-stamp, no block
|
|
11263
|
+
* advance. Each packet's wire sequence is restored from its keyframe's own
|
|
11264
|
+
* offset; without one, a stream the base never re-stamped keeps the
|
|
11265
|
+
* header's sequence and any other drops the packet.
|
|
10897
11266
|
*/
|
|
10898
11267
|
#routeOverlayRecovered(inst, blockStart, recovered) {
|
|
10899
11268
|
const { fec, repairPacketId: pid, streamName: name } = inst;
|
|
@@ -10913,22 +11282,139 @@ var MmtpRouter = class {
|
|
|
10913
11282
|
const streamKey = this.#mediaStreamKey(sourcePacketId, sourceName);
|
|
10914
11283
|
const restamped = this.#restampedStreams.has(streamKey);
|
|
10915
11284
|
const restored = /* @__PURE__ */ new Set();
|
|
11285
|
+
const baseSsIds = /* @__PURE__ */ new Map();
|
|
11286
|
+
const gateOnly = /* @__PURE__ */ new Set();
|
|
10916
11287
|
const symbols = result.symbols.flatMap((sym) => {
|
|
10917
|
-
const
|
|
10918
|
-
|
|
10919
|
-
|
|
11288
|
+
const overlaySsId = serial32Add(blockStart, sym.index);
|
|
11289
|
+
const anchor = inst.offsets.get(sym.fragment.mpuSequenceNumber);
|
|
11290
|
+
if (anchor !== void 0) {
|
|
11291
|
+
const packetSequenceNumber = overlaySsId - anchor.psnOffset >>> 0;
|
|
10920
11292
|
restored.add(packetSequenceNumber);
|
|
10921
|
-
|
|
11293
|
+
const out = { ...sym, packetSequenceNumber };
|
|
11294
|
+
const baseSsId = overlayBaseSsId(anchor, overlaySsId, packetSequenceNumber, sym.packetSequenceNumber);
|
|
11295
|
+
if (baseSsId !== void 0) {
|
|
11296
|
+
baseSsIds.set(sym.index, baseSsId);
|
|
11297
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
11298
|
+
if (!this.#sourceSeqReceived(sourcePacketId, packetSequenceNumber, sourceName) && offset === baseSsId - packetSequenceNumber >>> 0) {
|
|
11299
|
+
this.#overlayUnstampedSsIdSeqOffsetByStream.set(streamKey, offset);
|
|
11300
|
+
}
|
|
11301
|
+
}
|
|
11302
|
+
return [out];
|
|
11303
|
+
}
|
|
11304
|
+
if (!restamped) {
|
|
11305
|
+
const offset = this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
11306
|
+
const fedSsId = unstampedBaseSsId(offset, this.#unstampedSsIdSeqOffsetByStream.get(streamKey), sym.packetSequenceNumber);
|
|
11307
|
+
const baseSsId = fedSsId ?? unstampedBaseSsId(offset, this.#overlayUnstampedSsIdSeqOffsetByStream.get(streamKey), sym.packetSequenceNumber);
|
|
11308
|
+
if (baseSsId !== void 0) {
|
|
11309
|
+
baseSsIds.set(sym.index, baseSsId);
|
|
11310
|
+
if (fedSsId === void 0) gateOnly.add(sym.index);
|
|
11311
|
+
} else {
|
|
11312
|
+
inst.rebuilt.set(overlaySsId, sym.packetSequenceNumber);
|
|
11313
|
+
if (inst.rebuilt.size > OVERLAY_REBUILT_LIMIT) inst.rebuilt.delete(inst.rebuilt.keys().next().value);
|
|
11314
|
+
}
|
|
11315
|
+
return [sym];
|
|
10922
11316
|
}
|
|
10923
|
-
if (!restamped) return [sym];
|
|
10924
11317
|
this.#overlayStats.unsequencedDropped++;
|
|
10925
11318
|
return [];
|
|
10926
11319
|
});
|
|
10927
11320
|
this.#overlayStats.recovered++;
|
|
11321
|
+
const mpuFirst = /* @__PURE__ */ new Map();
|
|
11322
|
+
for (const sym of symbols) {
|
|
11323
|
+
const ssId = baseSsIds.get(sym.index);
|
|
11324
|
+
const mpu = sym.fragment.mpuSequenceNumber;
|
|
11325
|
+
const first = mpuFirst.get(mpu);
|
|
11326
|
+
if (ssId !== void 0 && (first === void 0 || serial32Precedes(ssId, first))) mpuFirst.set(mpu, ssId);
|
|
11327
|
+
}
|
|
11328
|
+
const firstSsIds = /* @__PURE__ */ new Map();
|
|
11329
|
+
for (const sym of symbols) {
|
|
11330
|
+
if (baseSsIds.has(sym.index)) firstSsIds.set(sym.index, mpuFirst.get(sym.fragment.mpuSequenceNumber));
|
|
11331
|
+
}
|
|
10928
11332
|
this.#routeProcessedFecSymbols(blockStart, { ...result, symbols }, sourcePacketId, sourceName, {
|
|
10929
|
-
deliveryProvenance: inst.moqBlocks.has(blockStart) ? "mixed" : "multicast"
|
|
11333
|
+
deliveryProvenance: inst.moqBlocks.has(blockStart) ? "mixed" : "multicast",
|
|
11334
|
+
baseSsIds,
|
|
11335
|
+
firstSsIds
|
|
10930
11336
|
});
|
|
10931
11337
|
this.#noteOverlayRecoveredRaps(sourcePacketId, sourceName, streamKey, symbols.filter((sym) => restored.has(sym.packetSequenceNumber)));
|
|
11338
|
+
this.#feedOverlayRecoveredToBase(inst, blockStart, symbols, gateOnly.size === 0 ? baseSsIds : new Map([...baseSsIds].filter(([index]) => !gateOnly.has(index))));
|
|
11339
|
+
}
|
|
11340
|
+
/**
|
|
11341
|
+
* Joint decoding (BLO-52085). A packet the overlay rebuilt is a source of
|
|
11342
|
+
* its base block too, once its base SS_ID is determined (overlayBaseSsId,
|
|
11343
|
+
* from a received member of its MPU, else unstampedBaseSsId at an offset a
|
|
11344
|
+
* base recovery showed; `baseSsIds` holds no other),
|
|
11345
|
+
* so it is fed to the base decoder as a rebuilt source
|
|
11346
|
+
* (FECManager.feedRebuiltSourceSymbol): the base block has one erasure
|
|
11347
|
+
* fewer to solve, and its repair can recover the block's other packets.
|
|
11348
|
+
* A base block no repair has stated yet takes it when one does
|
|
11349
|
+
* (#feedPendingRebuilt).
|
|
11350
|
+
*
|
|
11351
|
+
* The overlay route already handled each packet fed (delivered it, or
|
|
11352
|
+
* held an untimed head for its FT=1), so a base recovery routes none of
|
|
11353
|
+
* them again (#routeVerifiedFecSymbols): a second recovered copy of a
|
|
11354
|
+
* held head would wait in the parser for timing its first copy consumed.
|
|
11355
|
+
* Only an overlay block decoded from multicast symbols alone is fed: with
|
|
11356
|
+
* a MoQ symbol in it, the base block's recovery would depend on bytes
|
|
11357
|
+
* that crossed no multicast socket, which the provenance counted from the
|
|
11358
|
+
* block's own arrivals cannot show.
|
|
11359
|
+
*/
|
|
11360
|
+
#feedOverlayRecoveredToBase(inst, blockStart, symbols, baseSsIds) {
|
|
11361
|
+
const fec = this.#fecManager;
|
|
11362
|
+
const owner = inst.leg.sourcePacketId;
|
|
11363
|
+
const name = inst.leg.sourceCatalogTrackName;
|
|
11364
|
+
if (!fec?.feedRebuiltSourceSymbol || inst.moqBlocks.has(blockStart)) return;
|
|
11365
|
+
if (this.#classifyPacketId(owner) === null || fec.isTrackConfigured?.(owner) === false) return;
|
|
11366
|
+
const { duplicates, overlayToBase: { routed } } = this.#stream(owner, name);
|
|
11367
|
+
const feeds = [];
|
|
11368
|
+
for (const sym of symbols) {
|
|
11369
|
+
if (duplicates.sourceSeqs.has(sym.packetSequenceNumber)) continue;
|
|
11370
|
+
const ssId = baseSsIds.get(sym.index);
|
|
11371
|
+
if (ssId === void 0) {
|
|
11372
|
+
this.#overlayStats.baseUndetermined++;
|
|
11373
|
+
continue;
|
|
11374
|
+
}
|
|
11375
|
+
routed.delete(ssId);
|
|
11376
|
+
routed.add(ssId);
|
|
11377
|
+
if (routed.size > OVERLAY_ROUTED_LIMIT) routed.delete(routed.values().next().value);
|
|
11378
|
+
feeds.push([ssId, sym.rawSymbol]);
|
|
11379
|
+
}
|
|
11380
|
+
for (const [ssId, symbolData] of feeds) {
|
|
11381
|
+
if (this.#classifyPacketId(owner) === null) return;
|
|
11382
|
+
this.#feedRebuiltToBase(owner, name, ssId, symbolData);
|
|
11383
|
+
}
|
|
11384
|
+
}
|
|
11385
|
+
/** Feed one rebuilt source to its base block, or keep it until a repair states that block. */
|
|
11386
|
+
#feedRebuiltToBase(owner, name, ssId, symbolData) {
|
|
11387
|
+
const fec = this.#fecManager;
|
|
11388
|
+
if (!fec?.feedRebuiltSourceSymbol) return;
|
|
11389
|
+
const coords = fec.locateIsoSource?.(owner, name, ssId);
|
|
11390
|
+
if (coords == null) {
|
|
11391
|
+
const pending = this.#stream(owner, name).overlayToBase.pending;
|
|
11392
|
+
pending.delete(ssId);
|
|
11393
|
+
pending.set(ssId, symbolData.slice());
|
|
11394
|
+
if (pending.size > OVERLAY_PENDING_LIMIT) pending.delete(pending.keys().next().value);
|
|
11395
|
+
return;
|
|
11396
|
+
}
|
|
11397
|
+
const fed = fec.feedRebuiltSourceSymbol(owner, ssId, symbolData, name);
|
|
11398
|
+
if (!fed.taken) return;
|
|
11399
|
+
this.#overlayStats.baseFed++;
|
|
11400
|
+
if (fed.recovered === null) return;
|
|
11401
|
+
const sbn = coords.sbn;
|
|
11402
|
+
this.#routeRecoveredBlock(sbn, fed.recovered, owner, name, () => {
|
|
11403
|
+
fec.cancelBlockTimeout(sbn, owner, name);
|
|
11404
|
+
fec.countRecovery(owner, sbn, name);
|
|
11405
|
+
fec.markBlockCompleted(sbn, owner, name);
|
|
11406
|
+
});
|
|
11407
|
+
}
|
|
11408
|
+
/** A repair stated `block`: the rebuilt sources that waited for it join it now. */
|
|
11409
|
+
#feedPendingRebuilt(owner, name, block) {
|
|
11410
|
+
const pending = this.#streams.get(owner)?.get(name)?.overlayToBase.pending;
|
|
11411
|
+
if (pending === void 0 || pending.size === 0) return;
|
|
11412
|
+
for (const [ssId, symbolData] of [...pending]) {
|
|
11413
|
+
if (this.#classifyPacketId(owner) === null) return;
|
|
11414
|
+
if (serial32Distance(block.start, ssId) >= block.length) continue;
|
|
11415
|
+
pending.delete(ssId);
|
|
11416
|
+
this.#feedRebuiltToBase(owner, name, ssId, symbolData);
|
|
11417
|
+
}
|
|
10932
11418
|
}
|
|
10933
11419
|
/** fec-multicast-00 §6.6: report each base block whose RAP MFU fragments
|
|
10934
11420
|
* the overlay restored, when the keyframe's FT=0 and FT=1 are held too. A
|
|
@@ -11068,6 +11554,10 @@ var MmtpRouter = class {
|
|
|
11068
11554
|
get unadmittedListedDropCount() {
|
|
11069
11555
|
return this.#unadmittedListedDrops;
|
|
11070
11556
|
}
|
|
11557
|
+
/** Source datagrams (multicast or MoQ) a protected flow's bc-provenance v2 receiver released: admitted at once or held, then admitted by a record. Repair symbols and user-agent-admitted datagrams are not counted. Counted at release, before this router's own track checks: a released datagram those drop, which only a track change between hold and release can cause, still counts, so this is not a count of routed media. */
|
|
11558
|
+
get admittedSourceDatagramCount() {
|
|
11559
|
+
return this.#admittedSourceDatagrams;
|
|
11560
|
+
}
|
|
11071
11561
|
/** MoQ repair symbols of an unlisted track kept out of a governed FEC instance (7.2.7 step 2). */
|
|
11072
11562
|
get unlistedRepairSetAsideCount() {
|
|
11073
11563
|
return this.#unlistedRepairSetAside;
|
|
@@ -11305,6 +11795,46 @@ var MmtpRouter = class {
|
|
|
11305
11795
|
get unregisteredFlowDropCount() {
|
|
11306
11796
|
return this.#unregisteredFlowDrops;
|
|
11307
11797
|
}
|
|
11798
|
+
/** "mfu-datagram" leg packets dropped because the leg's ingress does not name their packet id (packet id 0 apart). */
|
|
11799
|
+
get datagramLegIngressDropCount() {
|
|
11800
|
+
return this.#datagramLegIngressDrops;
|
|
11801
|
+
}
|
|
11802
|
+
/** "mfu-datagram" leg packets of the MMTP signaling flow (packet id 0), which no track owns. */
|
|
11803
|
+
get datagramLegSignalingPacketCount() {
|
|
11804
|
+
return this.#datagramLegSignalingPackets;
|
|
11805
|
+
}
|
|
11806
|
+
/**
|
|
11807
|
+
* The "mfu-datagram" leg's presentation bound (mmt-02 6.1 step 6): how
|
|
11808
|
+
* long after a frame arrives it must leave the release gate when the gap
|
|
11809
|
+
* before it holds no RAP, FT=0 or FT=1 data (the player's presentation
|
|
11810
|
+
* delay less its decode lead). The gap is then decided at the earlier of
|
|
11811
|
+
* the FEC block deadline and this bound; a gap that may hold a RAP keeps
|
|
11812
|
+
* the block deadline. Null, or a value that is not finite and positive:
|
|
11813
|
+
* the block deadline alone, as on multicast.
|
|
11814
|
+
*/
|
|
11815
|
+
setDatagramLegPresentationBudget(budgetMs) {
|
|
11816
|
+
this.#datagramLegPresentationBudgetMs = budgetMs;
|
|
11817
|
+
}
|
|
11818
|
+
/**
|
|
11819
|
+
* The "mfu-datagram" leg is over (unsubscribed, or switched to another
|
|
11820
|
+
* path): no stream keeps its presentation bound or its ledger retention.
|
|
11821
|
+
* Parser, FEC and ledger state stay, so the packet ids continue on the
|
|
11822
|
+
* next path without an epoch. A later leg datagram starts a leg again.
|
|
11823
|
+
*/
|
|
11824
|
+
endDatagramLeg() {
|
|
11825
|
+
this.#datagramLegStreams.clear();
|
|
11826
|
+
this.#datagramLegPresentationBudgetMs = null;
|
|
11827
|
+
}
|
|
11828
|
+
#datagramLegPresentationWaitMs(packetId, catalogTrackName) {
|
|
11829
|
+
if (this.#datagramLegPresentationBudgetMs === null || this.#datagramLegStreams.get(packetId)?.has(catalogTrackName) !== true) return void 0;
|
|
11830
|
+
let budgetMs;
|
|
11831
|
+
try {
|
|
11832
|
+
budgetMs = this.#datagramLegPresentationBudgetMs(packetId, catalogTrackName);
|
|
11833
|
+
} catch {
|
|
11834
|
+
return void 0;
|
|
11835
|
+
}
|
|
11836
|
+
return Number.isFinite(budgetMs) && budgetMs > 0 ? budgetMs : void 0;
|
|
11837
|
+
}
|
|
11308
11838
|
/** Recovered packets dropped because more than one protected flow could own their stream. */
|
|
11309
11839
|
get ambiguousRecoveredDropCount() {
|
|
11310
11840
|
return this.#ambiguousRecoveredDrops;
|
|
@@ -11322,6 +11852,10 @@ var MmtpRouter = class {
|
|
|
11322
11852
|
* caller that forgot it silently attributed its bytes to a multicast socket
|
|
11323
11853
|
* they may never have crossed — and that attribution is what the physical-
|
|
11324
11854
|
* delivery evidence path is built on. Absence is not multicast; say which.
|
|
11855
|
+
* `"moq-datagram"` is an "mfu-datagram" subscription (MmtpIngestSource):
|
|
11856
|
+
* `ingress.tracks` MUST name the datagram catalog track for its packet id,
|
|
11857
|
+
* and a packet of a packet id it does not name is dropped and counted
|
|
11858
|
+
* (`datagramLegIngressDropCount`; the signaling flow, packet id 0, apart).
|
|
11325
11859
|
*/
|
|
11326
11860
|
feedPacket(packet, source, ingress) {
|
|
11327
11861
|
if (this.#disposed) return;
|
|
@@ -11371,15 +11905,18 @@ var MmtpRouter = class {
|
|
|
11371
11905
|
}
|
|
11372
11906
|
/**
|
|
11373
11907
|
* Feed a repair packet from MoQ (reliable QUIC) — parses MMTP repair
|
|
11374
|
-
* header and delegates to FECManager for FEC recovery.
|
|
11908
|
+
* header and delegates to FECManager for FEC recovery. `source` is
|
|
11909
|
+
* `"moq-datagram"` for a repair object of an "mfu-datagram" track's repair
|
|
11910
|
+
* track, which arrives as a datagram and so counts as an in-band symbol of
|
|
11911
|
+
* the leg; a FETCHed repair stays `"moq"` (RepairVia `quic`).
|
|
11375
11912
|
*/
|
|
11376
|
-
feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName) {
|
|
11913
|
+
feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName, source = "moq") {
|
|
11377
11914
|
if (this.#disposed) return;
|
|
11378
11915
|
this.#withDeferredFecPokes(() => {
|
|
11379
|
-
this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName);
|
|
11916
|
+
this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName, source);
|
|
11380
11917
|
});
|
|
11381
11918
|
}
|
|
11382
|
-
#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName, admitted = false) {
|
|
11919
|
+
#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName, source, admitted = false) {
|
|
11383
11920
|
let header;
|
|
11384
11921
|
try {
|
|
11385
11922
|
header = parseMMTPHeader(packet);
|
|
@@ -11389,7 +11926,7 @@ var MmtpRouter = class {
|
|
|
11389
11926
|
const repairPacketId = header.packetId;
|
|
11390
11927
|
const overlay = this.#overlayRepairTarget(repairPacketId, repairTrackName);
|
|
11391
11928
|
if (overlay !== void 0) {
|
|
11392
|
-
this.#routeOverlayRepair(overlay, repairPacketId, packet, header,
|
|
11929
|
+
this.#routeOverlayRepair(overlay, repairPacketId, packet, header, source);
|
|
11393
11930
|
return;
|
|
11394
11931
|
}
|
|
11395
11932
|
const hintedOwner = ownerPacketIdHint != null && this.#classifyPacketId(ownerPacketIdHint) !== null ? ownerPacketIdHint : null;
|
|
@@ -11401,7 +11938,7 @@ var MmtpRouter = class {
|
|
|
11401
11938
|
}
|
|
11402
11939
|
let unlisted = false;
|
|
11403
11940
|
if (ownerPacketId != null && !admitted) {
|
|
11404
|
-
const admit = this.#admitUnicast(repairPacketId, packet, () => this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName, true));
|
|
11941
|
+
const admit = this.#admitUnicast(repairPacketId, packet, () => this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName, source, true));
|
|
11405
11942
|
if (admit === "held" || admit === "dropped") return;
|
|
11406
11943
|
unlisted = admit === "unlisted";
|
|
11407
11944
|
}
|
|
@@ -11422,7 +11959,7 @@ var MmtpRouter = class {
|
|
|
11422
11959
|
this.#noteUnreadableFecPayloadId(ownerPacketId, "repair");
|
|
11423
11960
|
return;
|
|
11424
11961
|
}
|
|
11425
|
-
this.#handleIsoRepair(ownerPacketId, catalogTrackName, parsed,
|
|
11962
|
+
this.#handleIsoRepair(ownerPacketId, catalogTrackName, parsed, source, repairTrackName);
|
|
11426
11963
|
}
|
|
11427
11964
|
}
|
|
11428
11965
|
// ── Packet FEC geometry and block profile ───────────────────────
|
|
@@ -11554,6 +12091,8 @@ var MmtpRouter = class {
|
|
|
11554
12091
|
)) return;
|
|
11555
12092
|
fec.noteBlockActivity?.(blockStart, ownerPacketId, catalogTrackName);
|
|
11556
12093
|
fec.noteRepairGroupLength?.(blockStart, ownerPacketId, repair.rsbLength, catalogTrackName);
|
|
12094
|
+
this.#feedPendingRebuilt(ownerPacketId, catalogTrackName, placement.block);
|
|
12095
|
+
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
11557
12096
|
const alreadyCompleted = fec.isBlockCompleted(blockStart, ownerPacketId, catalogTrackName);
|
|
11558
12097
|
const recovered = fec.feedRepairSymbol(
|
|
11559
12098
|
ownerPacketId,
|
|
@@ -11604,7 +12143,7 @@ var MmtpRouter = class {
|
|
|
11604
12143
|
catalogTrackName
|
|
11605
12144
|
)) continue;
|
|
11606
12145
|
if (fec.isTrackConfigured?.(ownerPacketId) !== false) {
|
|
11607
|
-
fec.trackBlock(blockStart, ownerPacketId, catalogTrackName, esi, payload.evidence);
|
|
12146
|
+
fec.trackBlock(blockStart, ownerPacketId, catalogTrackName, esi, payload.evidence, true);
|
|
11608
12147
|
this.#requestFecPoke(ownerPacketId, catalogTrackName);
|
|
11609
12148
|
}
|
|
11610
12149
|
if (payload.oversized) continue;
|
|
@@ -11625,6 +12164,7 @@ var MmtpRouter = class {
|
|
|
11625
12164
|
debugRouter(
|
|
11626
12165
|
`[MmtpRouter] Dropping repair packet pid=${packetId}: physical PID is unregistered`
|
|
11627
12166
|
);
|
|
12167
|
+
this.#fecManager?.countUnresolvedRepairOwner?.("unregistered");
|
|
11628
12168
|
return null;
|
|
11629
12169
|
}
|
|
11630
12170
|
const registeredOwners = this.#repairOwnersByPacketId.get(packetId) ?? /* @__PURE__ */ new Set();
|
|
@@ -11633,6 +12173,7 @@ var MmtpRouter = class {
|
|
|
11633
12173
|
debugRouter(
|
|
11634
12174
|
`[MmtpRouter] Dropping repair packet pid=${packetId}: catalog owner is ${owners.length === 0 ? "absent" : "ambiguous"}`
|
|
11635
12175
|
);
|
|
12176
|
+
this.#fecManager?.countUnresolvedRepairOwner?.(owners.length === 0 ? "ownerAbsent" : "ownerAmbiguous");
|
|
11636
12177
|
return null;
|
|
11637
12178
|
}
|
|
11638
12179
|
/** Route a recovered FEC block through the parser + dedup pipeline.
|
|
@@ -11682,6 +12223,8 @@ var MmtpRouter = class {
|
|
|
11682
12223
|
}
|
|
11683
12224
|
this.#parser.resetTrack(packetId, catalogTrackName);
|
|
11684
12225
|
this.resetKeyframeOverlays(packetId, catalogTrackName);
|
|
12226
|
+
const legNames = this.#datagramLegStreams.get(packetId);
|
|
12227
|
+
if (legNames?.delete(catalogTrackName) && legNames.size === 0) this.#datagramLegStreams.delete(packetId);
|
|
11685
12228
|
this.#restampedStreams.delete(this.#mediaStreamKey(packetId, catalogTrackName));
|
|
11686
12229
|
const assistPrefix = assistKey(packetId, catalogTrackName, 0).slice(0, -1);
|
|
11687
12230
|
for (const key of this.#assistBlocks.keys()) if (key.startsWith(assistPrefix)) this.#assistBlocks.delete(key);
|
|
@@ -11691,6 +12234,8 @@ var MmtpRouter = class {
|
|
|
11691
12234
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
11692
12235
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
11693
12236
|
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
12237
|
+
this.#unstampedSsIdSeqOffsetByStream.delete(streamKey);
|
|
12238
|
+
this.#overlayUnstampedSsIdSeqOffsetByStream.delete(streamKey);
|
|
11694
12239
|
this.#multicastRapTwinByStream.delete(streamKey);
|
|
11695
12240
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
11696
12241
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
@@ -11817,6 +12362,12 @@ var MmtpRouter = class {
|
|
|
11817
12362
|
* the outgoing stream stops. The hold is bounded by the incoming stream's
|
|
11818
12363
|
* own RAP cadence, so no timer is involved.
|
|
11819
12364
|
*
|
|
12365
|
+
* While the switch is staged, the FEC release gate lets a keyframe the
|
|
12366
|
+
* overlay rebuilt reach it, on either side, when the keyframe did before
|
|
12367
|
+
* the gate anchored it (FecReleaseGate.releaseUnanchored): the switch
|
|
12368
|
+
* decides on what each side delivered, and the commit discards the gate's
|
|
12369
|
+
* frames of the outgoing stream.
|
|
12370
|
+
*
|
|
11820
12371
|
* The commit is one synchronous transition inside the frame path: the
|
|
11821
12372
|
* outgoing stream's already-admitted frames are released (its queued FEC
|
|
11822
12373
|
* gap fills only up to the RAP, since recovery can queue a frame ahead of
|
|
@@ -11867,6 +12418,9 @@ var MmtpRouter = class {
|
|
|
11867
12418
|
droppedIncomingFrames: 0
|
|
11868
12419
|
};
|
|
11869
12420
|
this.#staged = state;
|
|
12421
|
+
if (this.#parser.fecReleaseHoldsRebuilt(from.packetId, from.catalogTrackName)) {
|
|
12422
|
+
this.#requestFecPoke(from.packetId, from.catalogTrackName);
|
|
12423
|
+
}
|
|
11870
12424
|
return {
|
|
11871
12425
|
cancel: () => {
|
|
11872
12426
|
if (this.#staged !== state) return false;
|
|
@@ -11949,7 +12503,17 @@ var MmtpRouter = class {
|
|
|
11949
12503
|
*/
|
|
11950
12504
|
#routeParsedFrame(data, meta) {
|
|
11951
12505
|
if (this.#classifyPacketId(meta.packetId) === null) return;
|
|
11952
|
-
if (this.#staged !== null
|
|
12506
|
+
if (this.#staged !== null) {
|
|
12507
|
+
let consumed = false;
|
|
12508
|
+
this.#fecPokeDepth++;
|
|
12509
|
+
try {
|
|
12510
|
+
consumed = this.#interceptSwitchFrame(data, meta);
|
|
12511
|
+
} finally {
|
|
12512
|
+
this.#fecPokeDepth--;
|
|
12513
|
+
this.#flushPendingFecPokes();
|
|
12514
|
+
}
|
|
12515
|
+
if (consumed) return;
|
|
12516
|
+
}
|
|
11953
12517
|
this.#deliverParsedFrame(data, meta);
|
|
11954
12518
|
}
|
|
11955
12519
|
#commitStreamSwitch(state, rap, reason) {
|
|
@@ -11998,8 +12562,11 @@ var MmtpRouter = class {
|
|
|
11998
12562
|
this.#disposed = true;
|
|
11999
12563
|
this.#staged = null;
|
|
12000
12564
|
this.cancelKeyframeLostTimer();
|
|
12565
|
+
for (const { timer } of this.#fecWakes.values()) clearTimeout(timer);
|
|
12566
|
+
this.#fecWakes.clear();
|
|
12001
12567
|
this.#parser.dispose();
|
|
12002
12568
|
this.#streams.clear();
|
|
12569
|
+
this.endDatagramLeg();
|
|
12003
12570
|
this.#trackPacketCallbacks.clear();
|
|
12004
12571
|
this.#latestVideoSeqByStream.clear();
|
|
12005
12572
|
this.#lastDirectSourceVideoTsByStream.clear();
|
|
@@ -12101,12 +12668,16 @@ var MmtpRouter = class {
|
|
|
12101
12668
|
this.#parser.deferFecRelease(work);
|
|
12102
12669
|
} finally {
|
|
12103
12670
|
this.#fecPokeDepth--;
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
12109
|
-
|
|
12671
|
+
this.#flushPendingFecPokes();
|
|
12672
|
+
}
|
|
12673
|
+
}
|
|
12674
|
+
/** Run the pokes requested while #fecPokeDepth was raised, once it is 0. */
|
|
12675
|
+
#flushPendingFecPokes() {
|
|
12676
|
+
if (this.#fecPokeDepth === 0 && this.#pendingFecPokes.size > 0 && !this.#disposed) {
|
|
12677
|
+
const pokes = [...this.#pendingFecPokes.values()];
|
|
12678
|
+
this.#pendingFecPokes.clear();
|
|
12679
|
+
for (const poke of pokes) {
|
|
12680
|
+
this.#parser.pokeFecRelease(poke.packetId, poke.catalogTrackName);
|
|
12110
12681
|
}
|
|
12111
12682
|
}
|
|
12112
12683
|
}
|
|
@@ -12175,6 +12746,38 @@ var MmtpRouter = class {
|
|
|
12175
12746
|
if (!fec?.terminalRetentionMsForPacket) return Infinity;
|
|
12176
12747
|
return fec.terminalRetentionMsForPacket(packetId) ?? 0;
|
|
12177
12748
|
},
|
|
12749
|
+
// Once no repair can fill a gap (FECManager.isoRepairlessWaitMs: only a
|
|
12750
|
+
// late source can), its frame waits the late-symbol allowance when the
|
|
12751
|
+
// gap holds no RAP an installed keyframe overlay could still rebuild:
|
|
12752
|
+
// lost deltas of one MPU (delta-lost), the tail of the MPU before a RAP
|
|
12753
|
+
// that opens the next one while MPU boundaries bound RAPs (rap-next,
|
|
12754
|
+
// unless the gap holds a stated block's loss: the overlay may rebuild
|
|
12755
|
+
// that MPU's FT=0, and the block's group then complete it), or
|
|
12756
|
+
// an audio gap. A gap that may hold one (rap-lost, rap-unknown, or any
|
|
12757
|
+
// other rap-next, whose gap may hold a whole MPU and the keyframe the
|
|
12758
|
+
// overlay protects) waits for that overlay's repair too (BLO-52085
|
|
12759
|
+
// D4). A run no repair has delimited instead waits for its FEC
|
|
12760
|
+
// deadline, whatever the decision (FECManager.isoRepairlessWaitMs). The
|
|
12761
|
+
// FEC check comes first: most held gaps are not behind such a span, and
|
|
12762
|
+
// deciding one scans both frames' bitstreams.
|
|
12763
|
+
unrepairableWaitMs: (before, after, fromSbn, toSbn) => {
|
|
12764
|
+
const fec = this.#fecManager;
|
|
12765
|
+
const { packetId, catalogTrackName } = after.meta;
|
|
12766
|
+
const arrivedAtMs = after.arrivedAtMs;
|
|
12767
|
+
const allowanceMs = fec?.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn, false, false, arrivedAtMs);
|
|
12768
|
+
const presentationMs = this.#datagramLegPresentationWaitMs(packetId, catalogTrackName);
|
|
12769
|
+
if (!fec || allowanceMs === void 0 && presentationMs === void 0) return void 0;
|
|
12770
|
+
const decision = this.#decideGap(before, after, [], false);
|
|
12771
|
+
const mpu = before.meta.mpuSequenceNumber;
|
|
12772
|
+
const intoNextMpu = decision.reason === "rap-next" && mpu !== void 0 && after.meta.mpuSequenceNumber === mpu + 1 >>> 0 && fec.mpuBoundsRapsFor?.(packetId, catalogTrackName) === true;
|
|
12773
|
+
if (decision.action === "stall" || decision.reason === "rap-next" && !intoNextMpu) {
|
|
12774
|
+
return allowanceMs === void 0 ? void 0 : fec.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn, true, false, arrivedAtMs);
|
|
12775
|
+
}
|
|
12776
|
+
const waitMs = allowanceMs === void 0 ? void 0 : decision.reason === "rap-next" ? fec.isoRepairlessWaitMs?.(packetId, catalogTrackName, fromSbn, toSbn, false, true, arrivedAtMs) : allowanceMs;
|
|
12777
|
+
if (decision.reason === "delta-lost" && !((fec.interleaveDepthMsForPacket?.(packetId) ?? 0) > 0)) return waitMs;
|
|
12778
|
+
if (presentationMs === void 0) return waitMs;
|
|
12779
|
+
return waitMs === void 0 ? presentationMs : Math.min(waitMs, presentationMs);
|
|
12780
|
+
},
|
|
12178
12781
|
decide: (before, after, lostBlocks, discontinuity) => {
|
|
12179
12782
|
const decision = this.#decideGap(before, after, lostBlocks, discontinuity);
|
|
12180
12783
|
this.#onFrameGap?.(decision);
|
|
@@ -12184,6 +12787,28 @@ var MmtpRouter = class {
|
|
|
12184
12787
|
onRap: (packetId, catalogTrackName, ssId) => {
|
|
12185
12788
|
for (const observer of this.#fecRapObservers) observer(packetId, catalogTrackName, ssId);
|
|
12186
12789
|
},
|
|
12790
|
+
// One timer per stream, at the earliest wake asked: its drain re-arms
|
|
12791
|
+
// for the next frame still waiting.
|
|
12792
|
+
wakeAt: (packetId, catalogTrackName, atMs) => {
|
|
12793
|
+
if (this.#disposed) return;
|
|
12794
|
+
const key = this.#mediaStreamKey(packetId, catalogTrackName);
|
|
12795
|
+
const armed = this.#fecWakes.get(key);
|
|
12796
|
+
if (armed !== void 0 && armed.atMs <= atMs) return;
|
|
12797
|
+
if (armed !== void 0) clearTimeout(armed.timer);
|
|
12798
|
+
const timer = setTimeout(() => {
|
|
12799
|
+
this.#fecWakes.delete(key);
|
|
12800
|
+
this.#requestFecPoke(packetId, catalogTrackName);
|
|
12801
|
+
}, Math.max(0, Math.ceil(atMs - performance.now())));
|
|
12802
|
+
this.#fecWakes.set(key, { atMs, timer });
|
|
12803
|
+
},
|
|
12804
|
+
// A staged switch commits on when each side's frames reach it
|
|
12805
|
+
// (#interceptSwitchFrame): both sides' overlay keyframes reach it when
|
|
12806
|
+
// they did unanchored.
|
|
12807
|
+
releaseUnanchored: (packetId, catalogTrackName) => {
|
|
12808
|
+
const staged = this.#staged;
|
|
12809
|
+
const stream = { packetId, ...catalogTrackName === void 0 ? {} : { catalogTrackName } };
|
|
12810
|
+
return staged !== null && (isStream(stream, staged.from) || isStream(stream, staged.to));
|
|
12811
|
+
},
|
|
12187
12812
|
onReleased: (data, meta) => {
|
|
12188
12813
|
if (meta.trackType !== "video" || meta.mpuSequenceNumber === void 0) return;
|
|
12189
12814
|
const timing = meta.authoredTiming;
|
|
@@ -12193,7 +12818,8 @@ var MmtpRouter = class {
|
|
|
12193
12818
|
meta.catalogTrackName,
|
|
12194
12819
|
meta.mpuSequenceNumber,
|
|
12195
12820
|
timing.presentationTime,
|
|
12196
|
-
timing.mediaTimescale
|
|
12821
|
+
timing.mediaTimescale,
|
|
12822
|
+
timing.decodeTime
|
|
12197
12823
|
);
|
|
12198
12824
|
}
|
|
12199
12825
|
};
|
|
@@ -12211,8 +12837,20 @@ var MmtpRouter = class {
|
|
|
12211
12837
|
#decideGap(before, after, lostBlocks, discontinuity) {
|
|
12212
12838
|
const { packetId, catalogTrackName } = after.meta;
|
|
12213
12839
|
const trackKind = this.#classifyPacketId(packetId) === false ? "audio" : "video";
|
|
12214
|
-
const positionsTrusted = this.#fecManager?.classifierModeFor?.(packetId, catalogTrackName).mode === "classifying";
|
|
12215
|
-
const
|
|
12840
|
+
const positionsTrusted = this.#fecManager?.classifierModeFor?.(packetId, catalogTrackName).mode === "classifying" && before.meta.movieFragmentSequenceNumber === after.meta.movieFragmentSequenceNumber;
|
|
12841
|
+
const mpu = before.meta.mpuSequenceNumber;
|
|
12842
|
+
const sameMpu = trackKind === "video" && mpu !== void 0 && after.meta.mpuSequenceNumber === mpu;
|
|
12843
|
+
const mpuTrusted = this.#fecManager?.mpuBoundsRapsFor?.(
|
|
12844
|
+
packetId,
|
|
12845
|
+
catalogTrackName,
|
|
12846
|
+
sameMpu ? {
|
|
12847
|
+
mpu,
|
|
12848
|
+
from: before.meta.authoredTiming,
|
|
12849
|
+
to: after.meta.authoredTiming,
|
|
12850
|
+
fromSsId: before.meta.fecSbn,
|
|
12851
|
+
toSsId: after.meta.fecSbnFirst ?? after.meta.fecSbn
|
|
12852
|
+
} : void 0
|
|
12853
|
+
) === true;
|
|
12216
12854
|
const evidence = (frame) => {
|
|
12217
12855
|
const timing = frame.meta.authoredTiming;
|
|
12218
12856
|
const sampleNumber = frame.meta.sampleNumber;
|
|
@@ -12325,20 +12963,37 @@ var MmtpRouter = class {
|
|
|
12325
12963
|
const parsed = this.#parser.parsePacket(packet);
|
|
12326
12964
|
if (!parsed) return;
|
|
12327
12965
|
const info = parsed.info;
|
|
12966
|
+
if (manifestAdmitted && !info.isRepair && ingress?.admittedBy !== USER_AGENT_VERIFIED) this.#admittedSourceDatagrams++;
|
|
12328
12967
|
if (source === "multicast" && !manifestAdmitted) {
|
|
12329
12968
|
this.#fecManager?.noteMulticastArrival?.(info.packetId, info.sequenceNumber);
|
|
12969
|
+
} else if (source === "moq-datagram" && !manifestAdmitted) {
|
|
12970
|
+
this.#fecManager?.noteArrival?.("moq-datagram", info.packetId, info.sequenceNumber);
|
|
12330
12971
|
}
|
|
12331
|
-
if (source
|
|
12972
|
+
if (source !== "moq" && !ingressHasPacketId(ingress, info.packetId)) {
|
|
12973
|
+
if (source === "moq-datagram") {
|
|
12974
|
+
if (info.packetId === MMTP_SIGNALING_PACKET_ID) this.#datagramLegSignalingPackets++;
|
|
12975
|
+
else this.#datagramLegIngressDrops++;
|
|
12976
|
+
}
|
|
12332
12977
|
debugRouter(
|
|
12333
|
-
`[MmtpRouter] Dropping
|
|
12978
|
+
`[MmtpRouter] Dropping ${source} packet pid=${info.packetId}: absent from ingress tracks`
|
|
12334
12979
|
);
|
|
12335
12980
|
return;
|
|
12336
12981
|
}
|
|
12982
|
+
if (source === "moq-datagram") {
|
|
12983
|
+
if (!info.isRepair) {
|
|
12984
|
+
let names = this.#datagramLegStreams.get(info.packetId);
|
|
12985
|
+
if (!names) this.#datagramLegStreams.set(info.packetId, names = /* @__PURE__ */ new Set());
|
|
12986
|
+
names.add(catalogTrackNameForPacket(ingress, info.packetId));
|
|
12987
|
+
}
|
|
12988
|
+
} else if (source === "multicast") {
|
|
12989
|
+
this.#datagramLegStreams.delete(info.packetId);
|
|
12990
|
+
}
|
|
12337
12991
|
const packetRole = this.#packetIdRoles.get(info.packetId);
|
|
12338
|
-
if (source
|
|
12992
|
+
if (source !== "moq" && this.#classifyPacketId(info.packetId) === null && (!info.isRepair || packetRole !== "repair")) {
|
|
12339
12993
|
debugRouter(
|
|
12340
|
-
`[MmtpRouter] Dropping
|
|
12994
|
+
`[MmtpRouter] Dropping ${source} packet pid=${info.packetId}: physical PID is unregistered`
|
|
12341
12995
|
);
|
|
12996
|
+
if (info.isRepair) this.#fecManager?.countUnresolvedRepairOwner?.("unregistered");
|
|
12342
12997
|
return;
|
|
12343
12998
|
}
|
|
12344
12999
|
if (!info.isRepair && hasAmbiguousCatalogTrackName(ingress, info.packetId)) {
|
|
@@ -12374,7 +13029,7 @@ var MmtpRouter = class {
|
|
|
12374
13029
|
}
|
|
12375
13030
|
return;
|
|
12376
13031
|
}
|
|
12377
|
-
if (source
|
|
13032
|
+
if (source !== "multicast" && !manifestAdmitted) {
|
|
12378
13033
|
const admit = this.#admitUnicast(info.packetId, packet, () => this.#processMMTP(packet, source, true, ingress, overlapCopy, true), overlapCopy);
|
|
12379
13034
|
if (admit !== "unlisted") {
|
|
12380
13035
|
if (admit === "admitted") this.#processMMTP(packet, source, true, ingress, overlapCopy);
|
|
@@ -12403,7 +13058,7 @@ var MmtpRouter = class {
|
|
|
12403
13058
|
);
|
|
12404
13059
|
if (!repair) return;
|
|
12405
13060
|
if (ownerPacketId != null && this.#fecManager) {
|
|
12406
|
-
if ((flowless && this.#userAgentGoverns(ownerPacketId) || source
|
|
13061
|
+
if ((flowless && this.#userAgentGoverns(ownerPacketId) || source !== "multicast" && !manifestAdmitted) && this.#setAsideUnlistedRepair(ownerPacketId, catalogTrackNameForPacket(ingress, ownerPacketId), repair)) return;
|
|
12407
13062
|
this.#repairPidCounts[info.packetId] = (this.#repairPidCounts[info.packetId] || 0) + 1;
|
|
12408
13063
|
const count = this.#repairPidCounts[info.packetId];
|
|
12409
13064
|
if (count <= 2 || count % 500 === 0) {
|
|
@@ -12442,7 +13097,7 @@ var MmtpRouter = class {
|
|
|
12442
13097
|
const fecSource = this.#fecManager !== null && fecPayloadId != null;
|
|
12443
13098
|
const coords = fecSource && fecPayloadId ? this.#locateFecSource(info.packetId, catalogTrackName, fecPayloadId.ssId) ?? void 0 : void 0;
|
|
12444
13099
|
duplicates.advance(coords?.sbn);
|
|
12445
|
-
if (source
|
|
13100
|
+
if (source !== "moq" && !overlapCopy && !releasedFromQuarantine && catalogTrackName !== void 0 && duplicates.predatesHorizon(info.sequenceNumber, fecPayloadId?.ssId)) {
|
|
12446
13101
|
this.#publisherRestarts++;
|
|
12447
13102
|
console.warn(
|
|
12448
13103
|
`[MmtpRouter] publisher restart on pid=${info.packetId} track=${catalogTrackName}: packet_sequence_number=${info.sequenceNumber} predates the stream's FEC horizon; starting a new epoch`
|
|
@@ -12503,6 +13158,7 @@ var MmtpRouter = class {
|
|
|
12503
13158
|
evidence: sourceSymbolEvidence(packet, parsed.header, info.rapFlag, info.sequenceNumber),
|
|
12504
13159
|
oversized: !(this.#fecManager.isoSourceFits?.(info.packetId, rawSymbol.length) ?? false)
|
|
12505
13160
|
}) ?? false;
|
|
13161
|
+
if (held) this.#requestFecPoke(info.packetId, catalogTrackName);
|
|
12506
13162
|
parseSourceSymbol = held && !duplicates.parsedSymbols.has(ssId);
|
|
12507
13163
|
}
|
|
12508
13164
|
} else if (fecUnreadable && info.fecPayloadId) {
|
|
@@ -12606,7 +13262,8 @@ var MmtpRouter = class {
|
|
|
12606
13262
|
parsed.header,
|
|
12607
13263
|
info.sequenceNumber,
|
|
12608
13264
|
info.rapFlag,
|
|
12609
|
-
source
|
|
13265
|
+
source,
|
|
13266
|
+
fecPayloadId?.ssId
|
|
12610
13267
|
);
|
|
12611
13268
|
}
|
|
12612
13269
|
}
|
|
@@ -12629,10 +13286,13 @@ var MmtpRouter = class {
|
|
|
12629
13286
|
const feedOptions = {
|
|
12630
13287
|
skipFecPayloadId: parserOptions?.skipFecPayloadId,
|
|
12631
13288
|
recovered: parserOptions?.recovered,
|
|
12632
|
-
|
|
13289
|
+
// Frame attribution is the transport path: an "mfu-datagram" object
|
|
13290
|
+
// crossed QUIC, so its frames are 'moq' (provenance 'mixed').
|
|
13291
|
+
source: parserOptions?.source === "moq-datagram" ? "moq" : parserOptions?.source,
|
|
12633
13292
|
deliveryProvenance: parserOptions?.deliveryProvenance,
|
|
12634
13293
|
catalogTrackName: parserOptions?.catalogTrackName,
|
|
12635
|
-
...parserOptions?.fecSbn === void 0 ? {} : { fecSbn: parserOptions.fecSbn }
|
|
13294
|
+
...parserOptions?.fecSbn === void 0 ? {} : { fecSbn: parserOptions.fecSbn },
|
|
13295
|
+
...parserOptions?.fecSbnFirst === void 0 ? {} : { fecSbnFirst: parserOptions.fecSbnFirst }
|
|
12636
13296
|
};
|
|
12637
13297
|
if (parsed) this.#parser.feedParsed(packet, parsed, feedOptions);
|
|
12638
13298
|
else this.#parser.feed(packet, feedOptions);
|
|
@@ -12756,7 +13416,8 @@ var MmtpRouter = class {
|
|
|
12756
13416
|
if (stream === void 0) {
|
|
12757
13417
|
stream = {
|
|
12758
13418
|
key: JSON.stringify([packetId, catalogTrackName ?? null]),
|
|
12759
|
-
duplicates: new StreamDuplicateLedgers(() => this.duplicateHorizonFor(packetId))
|
|
13419
|
+
duplicates: new StreamDuplicateLedgers(() => this.duplicateHorizonFor(packetId)),
|
|
13420
|
+
overlayToBase: { routed: /* @__PURE__ */ new Set(), pending: /* @__PURE__ */ new Map() }
|
|
12760
13421
|
};
|
|
12761
13422
|
byName.set(catalogTrackName, stream);
|
|
12762
13423
|
}
|
|
@@ -13034,6 +13695,13 @@ var MmtpRouter = class {
|
|
|
13034
13695
|
* frames by epoch only if pre-protection input ever matters.
|
|
13035
13696
|
*/
|
|
13036
13697
|
#routeVerifiedFecSymbols(blockId, result, ownerPacketId, catalogTrackName, complete, assisted = false) {
|
|
13698
|
+
const overlayRouted = ownerPacketId == null ? void 0 : this.#streams.get(ownerPacketId)?.get(catalogTrackName)?.overlayToBase.routed;
|
|
13699
|
+
if (overlayRouted !== void 0 && overlayRouted.size > 0) {
|
|
13700
|
+
result = {
|
|
13701
|
+
...result,
|
|
13702
|
+
symbols: result.symbols.filter((sym) => !overlayRouted.has(this.#fecAnchorForRecovered(blockId, sym.index)))
|
|
13703
|
+
};
|
|
13704
|
+
}
|
|
13037
13705
|
const entry = ownerPacketId == null ? void 0 : this.#provenanceFor(ownerPacketId, catalogTrackName);
|
|
13038
13706
|
const receiver = entry === void 0 || entry === "ambiguous" ? entry : entry.receiver;
|
|
13039
13707
|
const userAgent = !assisted && entry !== void 0 && entry !== "ambiguous" && entry.protected === true && entry.userAgent === true;
|
|
@@ -13090,7 +13758,12 @@ var MmtpRouter = class {
|
|
|
13090
13758
|
#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName, overlay) {
|
|
13091
13759
|
if (ownerPacketId == null) return;
|
|
13092
13760
|
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
13093
|
-
const fecSbnOf = (index) =>
|
|
13761
|
+
const fecSbnOf = (index) => {
|
|
13762
|
+
if (!overlay) return { fecSbn: this.#fecAnchorForRecovered(blockId, index) };
|
|
13763
|
+
const fecSbn = overlay.baseSsIds.get(index);
|
|
13764
|
+
const fecSbnFirst = overlay.firstSsIds.get(index);
|
|
13765
|
+
return fecSbn === void 0 || fecSbnFirst === void 0 ? {} : { fecSbn, fecSbnFirst };
|
|
13766
|
+
};
|
|
13094
13767
|
const streamKey = this.#mediaStreamKey(ownerPacketId, catalogTrackName);
|
|
13095
13768
|
const ssIdSeqOffset = overlay ? void 0 : this.#ssIdSeqOffsetByStream.get(streamKey);
|
|
13096
13769
|
if (ssIdSeqOffset !== void 0) {
|
|
@@ -13098,7 +13771,10 @@ var MmtpRouter = class {
|
|
|
13098
13771
|
...result,
|
|
13099
13772
|
symbols: result.symbols.map((sym) => {
|
|
13100
13773
|
const wire = this.#fecAnchorForRecovered(blockId, sym.index) - ssIdSeqOffset >>> 0;
|
|
13101
|
-
if (wire === sym.packetSequenceNumber)
|
|
13774
|
+
if (wire === sym.packetSequenceNumber) {
|
|
13775
|
+
this.#unstampedSsIdSeqOffsetByStream.set(streamKey, ssIdSeqOffset);
|
|
13776
|
+
return sym;
|
|
13777
|
+
}
|
|
13102
13778
|
this.#restampedRecoveredSeqs++;
|
|
13103
13779
|
this.#restampedStreams.add(streamKey);
|
|
13104
13780
|
return { ...sym, packetSequenceNumber: wire };
|