@blockcast/mmt-container 0.4.0 → 0.4.1-main.2e0aa69d293d
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 +37 -21
- package/dist/align.d.ts +24 -18
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js +23 -4
- package/dist/align.js.map +2 -2
- package/dist/browser-runtime.js +5070 -908
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +76 -39
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +321 -205
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +28 -7
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/cmcd-producer.d.ts +13 -1
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +14 -0
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.js +115 -235
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +113 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +464 -66
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +10 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -4
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.d.ts +58 -0
- package/dist/held-layer-admission.d.ts.map +1 -0
- package/dist/held-layer-admission.js +105 -0
- package/dist/held-layer-admission.js.map +7 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +109 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +21 -13
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +93 -22
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +3692 -1213
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +93 -22
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +192 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +640 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +101 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +422 -189
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +94 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +746 -131
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +31 -8
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +299 -35
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +140 -12
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +4104 -605
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +16 -3
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +127 -240
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +21 -13
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +5 -3
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +3643 -1197
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +90 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +160 -32
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- package/dist/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +21 -13
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js +93 -22
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -18
- package/schemas/catalog.schema.json +133 -38
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +188 -68
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +49 -7
- package/src/catalog-validator.ts +4 -11
- package/src/cmcd-producer.ts +23 -1
- package/src/fec-manager.ts +378 -63
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +30 -2
- package/src/held-layer-admission.ts +161 -0
- package/src/index.ts +32 -19
- package/src/iso-block-locator.ts +110 -7
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +606 -0
- package/src/mmtp-router.ts +453 -236
- package/src/multicast-auth-catalog.ts +196 -231
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +447 -53
- package/src/multicast-transport.ts +23 -5
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +306 -42
- package/src/repair-layers.ts +22 -2
- package/src/sample-combiner.ts +15 -2
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +71 -4
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
- package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
- package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
- package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
- package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
- package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
- package/test-vectors/catalog/positive/fec-multicast.json +1 -1
- package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
- package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
- package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
- package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
- package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
- package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
- package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
- package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
- package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +31 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +101 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/dist/manifest-auth-plan.d.ts +0 -30
- package/dist/manifest-auth-plan.d.ts.map +0 -1
- package/dist/manifest-auth-plan.js +0 -1266
- package/dist/manifest-auth-plan.js.map +0 -7
- package/dist/source-auth.d.ts +0 -2
- package/dist/source-auth.d.ts.map +0 -1
- package/dist/source-auth.js +0 -1209
- package/dist/source-auth.js.map +0 -7
- package/src/fec-codec.ts +0 -61
- package/src/manifest-auth-plan.ts +0 -107
- package/src/source-auth.ts +0 -1
- package/test-vectors/generate-source-auth-fixture.mjs +0 -114
- package/test-vectors/source-auth-v1.json +0 -61
package/dist/mmtp-router.js
CHANGED
|
@@ -149,26 +149,30 @@ function isEmptyOrExactLegacyTrailer(payload, start, end) {
|
|
|
149
149
|
const authLength = view2.getUint16(2, false);
|
|
150
150
|
return start + LEGACY_TRAILER_HEADER_SIZE + authLength === end;
|
|
151
151
|
}
|
|
152
|
-
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options) {
|
|
152
|
+
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options, rapFlag = false) {
|
|
153
153
|
if (declaredEnd > payload.length)
|
|
154
154
|
return null;
|
|
155
155
|
if (options?.skipFecId) {
|
|
156
|
-
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false } : null;
|
|
156
|
+
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false, hasOverlayFecId: false } : null;
|
|
157
157
|
}
|
|
158
|
+
const overlay = options?.overlayDeclared === true && rapFlag;
|
|
158
159
|
if (fecType === 1) {
|
|
159
|
-
const fecStart = payload.length -
|
|
160
|
+
const fecStart = payload.length - sourceFecTrailerSize(overlay);
|
|
160
161
|
if (fecStart < declaredEnd || !isEmptyOrExactLegacyTrailer(payload, declaredEnd, fecStart)) {
|
|
161
162
|
return null;
|
|
162
163
|
}
|
|
163
|
-
return { hasFecId: true };
|
|
164
|
+
return { hasFecId: true, hasOverlayFecId: overlay };
|
|
164
165
|
}
|
|
165
|
-
if (fecType !== 0)
|
|
166
|
+
if (fecType !== 0 || overlay)
|
|
166
167
|
return null;
|
|
167
168
|
if (isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)) {
|
|
168
|
-
return { hasFecId: false };
|
|
169
|
+
return { hasFecId: false, hasOverlayFecId: false };
|
|
169
170
|
}
|
|
170
171
|
return null;
|
|
171
172
|
}
|
|
173
|
+
function sourceFecTrailerSize(overlay) {
|
|
174
|
+
return overlay ? 2 * SOURCE_FEC_PAYLOAD_ID_SIZE : SOURCE_FEC_PAYLOAD_ID_SIZE;
|
|
175
|
+
}
|
|
172
176
|
function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
173
177
|
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE) {
|
|
174
178
|
return {
|
|
@@ -221,15 +225,16 @@ function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
|
221
225
|
if ("rejection" in layoutResult)
|
|
222
226
|
return layoutResult;
|
|
223
227
|
const { layout } = layoutResult;
|
|
224
|
-
const trailerLayout = resolveDeclaredTrailers(payload, layout.dataEnd, header.fecType, options);
|
|
228
|
+
const trailerLayout = resolveDeclaredTrailers(payload, layout.dataEnd, header.fecType, options, header.rapFlag);
|
|
225
229
|
if (!trailerLayout) {
|
|
226
230
|
if (!options?.skipFecId && header.fecType === 1) {
|
|
227
231
|
const observed = payload.length - layout.dataEnd;
|
|
228
|
-
|
|
232
|
+
const expected = sourceFecTrailerSize(options?.overlayDeclared === true && header.rapFlag);
|
|
233
|
+
if (observed !== expected) {
|
|
229
234
|
return {
|
|
230
235
|
rejection: {
|
|
231
236
|
gate: "source-fec-payload-id-width-mismatch",
|
|
232
|
-
detail: `producer wrote a ${observed}-byte Source FEC Payload ID, ISO/IEC 23008-1 \xA7C.5.2 requires ${
|
|
237
|
+
detail: `producer wrote a ${observed}-byte Source FEC Payload ID, ISO/IEC 23008-1 \xA7C.5.2 requires ${expected} (payload=${payload.length}, declaredEnd=${layout.dataEnd})`
|
|
233
238
|
}
|
|
234
239
|
};
|
|
235
240
|
}
|
|
@@ -256,10 +261,13 @@ function extractPlannedMfu(mmtpPacket, result) {
|
|
|
256
261
|
const mfuDuHeader = mfuDuHeaderPresent && mpu.timedFlag === 1 ? parseTimedMfuDuHeader(payload, MPU_HEADER_SIZE) : null;
|
|
257
262
|
const itemId = mfuDuHeaderPresent && mpu.timedFlag === 0 ? new DataView(payload.buffer, payload.byteOffset + MPU_HEADER_SIZE, 4).getUint32(0, false) : null;
|
|
258
263
|
const data = payload.subarray(mfuOffset, dataEnd);
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
264
|
+
const trailerStart = mmtpPacket.length - sourceFecTrailerSize(trailerLayout.hasOverlayFecId);
|
|
265
|
+
const ssIdAt = (offset) => ({
|
|
266
|
+
ssId: new DataView(mmtpPacket.buffer, mmtpPacket.byteOffset + offset, 4).getUint32(0, false)
|
|
267
|
+
});
|
|
268
|
+
const fecPayloadId = trailerLayout.hasFecId ? ssIdAt(trailerStart) : null;
|
|
269
|
+
const overlayFecPayloadId = trailerLayout.hasOverlayFecId ? ssIdAt(trailerStart + SOURCE_FEC_PAYLOAD_ID_SIZE) : null;
|
|
270
|
+
return { header, mpu, fragmentType, data, mfuDuHeader, itemId, fecPayloadId, overlayFecPayloadId };
|
|
263
271
|
}
|
|
264
272
|
function sourceFecPayloadIdOf(mmtpPacket, header) {
|
|
265
273
|
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE)
|
|
@@ -5255,8 +5263,14 @@ var SampleCombiner = class {
|
|
|
5255
5263
|
/**
|
|
5256
5264
|
* Add one reassembled data unit. Returns the combined sample once every
|
|
5257
5265
|
* constituent data unit has arrived and totals the authored size.
|
|
5266
|
+
*
|
|
5267
|
+
* `sampleSize` is the authored size the host resolves for the sample as the
|
|
5268
|
+
* data unit completes. It stands in only when no size was registered, which
|
|
5269
|
+
* happens when the data unit's FI=0/FI=1 reached the reassembler without the
|
|
5270
|
+
* host's own FT=2 parse: an FEC-recovered first fragment completed by source
|
|
5271
|
+
* fragments, or one decoded before its source copy arrived.
|
|
5258
5272
|
*/
|
|
5259
|
-
addMfu(mfu) {
|
|
5273
|
+
addMfu(mfu, sampleSize) {
|
|
5260
5274
|
if (mfu.movieFragmentSequenceNumber === void 0 || mfu.sampleNumber === void 0) {
|
|
5261
5275
|
this.#stats.passthroughSamples++;
|
|
5262
5276
|
return fromPassthrough(mfu);
|
|
@@ -5272,7 +5286,7 @@ var SampleCombiner = class {
|
|
|
5272
5286
|
return null;
|
|
5273
5287
|
}
|
|
5274
5288
|
const dataLen = mfu.data.byteLength;
|
|
5275
|
-
const authoredSize = this.#authoredSizes.get(key);
|
|
5289
|
+
const authoredSize = this.#authoredSizes.get(key) ?? sampleSize;
|
|
5276
5290
|
if (offset === 0 && !this.#pending.has(key)) {
|
|
5277
5291
|
const passesThrough = authoredSize === void 0 ? !this.#requireAuthoredSize : dataLen === authoredSize;
|
|
5278
5292
|
if (passesThrough) {
|
|
@@ -5566,6 +5580,12 @@ if (void 0) {
|
|
|
5566
5580
|
const out = c.addMfu(mfu(1, 9, 17, 5, [6, 7, 8, 9, 10], 1001n, false));
|
|
5567
5581
|
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
|
|
5568
5582
|
});
|
|
5583
|
+
test("a size handed with the data unit completes a sample no head registered", () => {
|
|
5584
|
+
const c = combiner({ requireAuthoredSize: true });
|
|
5585
|
+
const out = c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5);
|
|
5586
|
+
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5]));
|
|
5587
|
+
expect(c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5)).toBeNull();
|
|
5588
|
+
});
|
|
5569
5589
|
test("duplicate offset is rejected", () => {
|
|
5570
5590
|
const c = combiner();
|
|
5571
5591
|
c.registerAuthoredSize(void 0, 1, 9, 17, 10);
|
|
@@ -6810,6 +6830,7 @@ function isFmp4Box(data) {
|
|
|
6810
6830
|
const type = String.fromCharCode(data[4], data[5], data[6], data[7]);
|
|
6811
6831
|
return FMPU_BOX_TYPES.has(type);
|
|
6812
6832
|
}
|
|
6833
|
+
var MAX_AWAITING_TIMING_HEADS = 8;
|
|
6813
6834
|
var MmtpContainerParser = class _MmtpContainerParser {
|
|
6814
6835
|
constructor(config) {
|
|
6815
6836
|
this.#tracks = /* @__PURE__ */ new Map();
|
|
@@ -6868,6 +6889,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6868
6889
|
* reordering into the parser. */
|
|
6869
6890
|
this.#reliableMoqStartupGate = /* @__PURE__ */ new Map();
|
|
6870
6891
|
this.#disposed = false;
|
|
6892
|
+
this.#replayingAwaitingTiming = false;
|
|
6871
6893
|
this.#fedObjects = 0;
|
|
6872
6894
|
this.#reassemblerFragmentsFed = 0;
|
|
6873
6895
|
this.#reassemblerDataUnitsReturned = 0;
|
|
@@ -6960,6 +6982,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6960
6982
|
#reorderStats;
|
|
6961
6983
|
#reliableMoqStartupGate;
|
|
6962
6984
|
#disposed;
|
|
6985
|
+
#replayingAwaitingTiming;
|
|
6963
6986
|
#fedObjects;
|
|
6964
6987
|
#reassemblerFragmentsFed;
|
|
6965
6988
|
#reassemblerDataUnitsReturned;
|
|
@@ -7209,7 +7232,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
7209
7232
|
* a single failure bucket. Returns null so call sites stay `return this.#drop(...)`.
|
|
7210
7233
|
*/
|
|
7211
7234
|
#drop(reason) {
|
|
7212
|
-
this.#
|
|
7235
|
+
if (this.#replayingAwaitingTiming) this.#countDeferredOutcome(reason);
|
|
7236
|
+
else this.#countOutcome(`drop:${reason}`);
|
|
7213
7237
|
return null;
|
|
7214
7238
|
}
|
|
7215
7239
|
get reorderDiagnostics() {
|
|
@@ -7232,6 +7256,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
7232
7256
|
for (const combiner of this.#sampleCombiners.values()) {
|
|
7233
7257
|
combiner.cleanupTimeouts(timeoutMs);
|
|
7234
7258
|
}
|
|
7259
|
+
const now = Date.now();
|
|
7260
|
+
for (const { awaitingTiming } of this.#timingStreams.values()) {
|
|
7261
|
+
while (awaitingTiming.length > 0 && now - awaitingTiming[0].arrivedAt > timeoutMs) {
|
|
7262
|
+
awaitingTiming.shift();
|
|
7263
|
+
}
|
|
7264
|
+
}
|
|
7235
7265
|
}
|
|
7236
7266
|
/**
|
|
7237
7267
|
* Phase 1 of two-phase parsing. Returns structured header info for FEC feeding.
|
|
@@ -7312,7 +7342,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
7312
7342
|
byteLength: packet.byteLength
|
|
7313
7343
|
};
|
|
7314
7344
|
}
|
|
7315
|
-
if (info.fecPayloadId !== null && this.#sourceSymbolCb) {
|
|
7345
|
+
if (info.fecPayloadId !== null && this.#sourceSymbolCb && !this.#replayingAwaitingTiming) {
|
|
7316
7346
|
const rawSymbol = packet.subarray(0, packet.length - 4);
|
|
7317
7347
|
try {
|
|
7318
7348
|
this.#sourceSymbolCb(info.packetId, info.fecPayloadId.ssId, rawSymbol);
|
|
@@ -7360,6 +7390,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
7360
7390
|
}
|
|
7361
7391
|
return this.#drop("fragment-timing-refused");
|
|
7362
7392
|
}
|
|
7393
|
+
this.#replayAwaitingTiming(streamKey, resolver2);
|
|
7363
7394
|
return {
|
|
7364
7395
|
kind: "fragment",
|
|
7365
7396
|
packet: info,
|
|
@@ -7383,7 +7414,18 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
7383
7414
|
mfuDuHeader.movieFragmentSequenceNumber,
|
|
7384
7415
|
mfuDuHeader.sampleNumber
|
|
7385
7416
|
);
|
|
7386
|
-
if (!headTiming)
|
|
7417
|
+
if (!headTiming) {
|
|
7418
|
+
this.#awaitTiming(streamKey, {
|
|
7419
|
+
packet,
|
|
7420
|
+
options,
|
|
7421
|
+
parsed,
|
|
7422
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
7423
|
+
movieFragmentSequenceNumber: mfuDuHeader.movieFragmentSequenceNumber,
|
|
7424
|
+
sampleNumber: mfuDuHeader.sampleNumber,
|
|
7425
|
+
arrivedAt: Date.now()
|
|
7426
|
+
});
|
|
7427
|
+
return this.#drop("mfu-sample-timing-missing");
|
|
7428
|
+
}
|
|
7387
7429
|
const offset = mfuDuHeader.offset;
|
|
7388
7430
|
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= headTiming.size)
|
|
7389
7431
|
return this.#drop("mfu-offset-out-of-range");
|
|
@@ -7459,16 +7501,17 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
7459
7501
|
const sampleNumber = assembled.sampleNumber;
|
|
7460
7502
|
if (movieFragmentSequenceNumber === void 0 || sampleNumber === void 0)
|
|
7461
7503
|
return this.#drop("assembled-identity-missing");
|
|
7462
|
-
|
|
7504
|
+
const assembledTiming = resolver.sampleTiming(
|
|
7463
7505
|
assembled.mpuSequenceNumber,
|
|
7464
7506
|
movieFragmentSequenceNumber,
|
|
7465
7507
|
sampleNumber
|
|
7466
|
-
)
|
|
7508
|
+
);
|
|
7509
|
+
if (!assembledTiming) return this.#drop("assembled-timing-missing");
|
|
7467
7510
|
if (assembled.mpuSequenceNumber !== mpu.mpuSequenceNumber)
|
|
7468
7511
|
return this.#drop("assembled-mpu-mismatch");
|
|
7469
7512
|
let combined;
|
|
7470
7513
|
try {
|
|
7471
|
-
combined = this.#sampleCombinerFor(streamKey).addMfu(assembled);
|
|
7514
|
+
combined = this.#sampleCombinerFor(streamKey).addMfu(assembled, assembledTiming.size);
|
|
7472
7515
|
} catch (error) {
|
|
7473
7516
|
if (!(error instanceof SampleCombineError)) throw error;
|
|
7474
7517
|
console.warn(
|
|
@@ -7777,9 +7820,37 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
7777
7820
|
if (existing) return existing.resolver;
|
|
7778
7821
|
if (!create) return null;
|
|
7779
7822
|
const resolver = new IsoBmffTimingResolver(this.#maxPendingTimingSamples);
|
|
7780
|
-
this.#timingStreams.set(streamKey, { packetId, resolver });
|
|
7823
|
+
this.#timingStreams.set(streamKey, { packetId, resolver, awaitingTiming: [] });
|
|
7781
7824
|
return resolver;
|
|
7782
7825
|
}
|
|
7826
|
+
#awaitTiming(streamKey, head) {
|
|
7827
|
+
const awaitingTiming = this.#timingStreams.get(streamKey)?.awaitingTiming;
|
|
7828
|
+
if (!awaitingTiming) return;
|
|
7829
|
+
awaitingTiming.push(head);
|
|
7830
|
+
if (awaitingTiming.length > MAX_AWAITING_TIMING_HEADS) awaitingTiming.shift();
|
|
7831
|
+
}
|
|
7832
|
+
/**
|
|
7833
|
+
* Feed again the heads whose timing the FT=1 just admitted declares. That
|
|
7834
|
+
* FT=1 can be an FEC recovery landing after its sample's FI=1, and neither
|
|
7835
|
+
* FEC path routes a source symbol that already arrived a second time.
|
|
7836
|
+
*/
|
|
7837
|
+
#replayAwaitingTiming(streamKey, resolver) {
|
|
7838
|
+
const state = this.#timingStreams.get(streamKey);
|
|
7839
|
+
if (!state || state.awaitingTiming.length === 0) return;
|
|
7840
|
+
const ready = state.awaitingTiming.filter((head) => resolver.sampleTiming(
|
|
7841
|
+
head.mpuSequenceNumber,
|
|
7842
|
+
head.movieFragmentSequenceNumber,
|
|
7843
|
+
head.sampleNumber
|
|
7844
|
+
));
|
|
7845
|
+
if (ready.length === 0) return;
|
|
7846
|
+
state.awaitingTiming = state.awaitingTiming.filter((head) => !ready.includes(head));
|
|
7847
|
+
this.#replayingAwaitingTiming = true;
|
|
7848
|
+
try {
|
|
7849
|
+
for (const head of ready) this.#feed(head.packet, head.options, head.parsed);
|
|
7850
|
+
} finally {
|
|
7851
|
+
this.#replayingAwaitingTiming = false;
|
|
7852
|
+
}
|
|
7853
|
+
}
|
|
7783
7854
|
#dropTimingStream(streamKey) {
|
|
7784
7855
|
const state = this.#timingStreams.get(streamKey);
|
|
7785
7856
|
if (!state) return;
|
|
@@ -8408,11 +8479,19 @@ var MmtpRouter = class {
|
|
|
8408
8479
|
#fecManager;
|
|
8409
8480
|
#defaultFecMapper;
|
|
8410
8481
|
#fecMappersByPacketId = /* @__PURE__ */ new Map();
|
|
8411
|
-
|
|
8412
|
-
#
|
|
8413
|
-
#
|
|
8414
|
-
#
|
|
8415
|
-
|
|
8482
|
+
/** Protected flows: one 7.2.7 receiver each, and the ingress its datagrams arrive with. */
|
|
8483
|
+
#provenance = /* @__PURE__ */ new Map();
|
|
8484
|
+
#onFlowProtected = null;
|
|
8485
|
+
#unadmittedListedDrops = 0;
|
|
8486
|
+
/** The ingress a held datagram arrived with; the receiver returns the same bytes on release. */
|
|
8487
|
+
#heldIngress = /* @__PURE__ */ new WeakMap();
|
|
8488
|
+
#unicastRepair = false;
|
|
8489
|
+
/** How to route a held unicast (MoQ) datagram once a record admits it. */
|
|
8490
|
+
#heldReplay = /* @__PURE__ */ new WeakMap();
|
|
8491
|
+
/** The flow whose receiver admitted a stream's source datagrams, by packetId then catalog track name: recovered packets answer to it. */
|
|
8492
|
+
#provenanceStreamFlow = /* @__PURE__ */ new Map();
|
|
8493
|
+
#unregisteredFlowDrops = 0;
|
|
8494
|
+
#ambiguousRecoveredDrops = 0;
|
|
8416
8495
|
// Temp state set by #processMMTP before calling parser.feed(),
|
|
8417
8496
|
// read by the parser's onFrame callback for CMAF assembly + dedup.
|
|
8418
8497
|
#currentFecInfo;
|
|
@@ -8446,6 +8525,18 @@ var MmtpRouter = class {
|
|
|
8446
8525
|
// MSE recovery routes through CmafBlockAssembler and can reorder by block; the
|
|
8447
8526
|
// direct callback path has to preserve decode order before frames leave libmmt.
|
|
8448
8527
|
#latestVideoSeqByStream = /* @__PURE__ */ new Map();
|
|
8528
|
+
/**
|
|
8529
|
+
* Per stream, SS_ID - packet_sequence_number (mod 2^32) of its latest
|
|
8530
|
+
* first-arrival FEC source packet. A recovered source symbol's wire
|
|
8531
|
+
* sequence is its SS_ID minus this; see #routeProcessedFecSymbols.
|
|
8532
|
+
*/
|
|
8533
|
+
#ssIdSeqOffsetByStream = /* @__PURE__ */ new Map();
|
|
8534
|
+
/**
|
|
8535
|
+
* Streams whose multicast leg delivered a RAP-flagged source packet that was
|
|
8536
|
+
* not parsed, typically because its overlap copy was parsed first
|
|
8537
|
+
* (BLO-49179). The next video keyframe emitted on the stream consumes it.
|
|
8538
|
+
*/
|
|
8539
|
+
#multicastRapTwinByStream = /* @__PURE__ */ new Set();
|
|
8449
8540
|
#lastDirectSourceVideoTsByStream = /* @__PURE__ */ new Map();
|
|
8450
8541
|
#lastDirectEmittedVideoTsByStream = /* @__PURE__ */ new Map();
|
|
8451
8542
|
#pendingDirectRecoveredVideoByStream = /* @__PURE__ */ new Map();
|
|
@@ -8520,11 +8611,14 @@ var MmtpRouter = class {
|
|
|
8520
8611
|
*/
|
|
8521
8612
|
#onPublisherRestart;
|
|
8522
8613
|
#publisherRestarts = 0;
|
|
8614
|
+
#restampedRecoveredSeqs = 0;
|
|
8523
8615
|
/** Inits delivered with no onTrackInit handler for their packetId (MOQT-01). */
|
|
8524
8616
|
#unmappedInitDeliveries = 0;
|
|
8525
8617
|
// FEC Payload IDs left unread because their (owner) packetId had no
|
|
8526
8618
|
// configured fec.blockProfile (see #noteUnreadableFecPayloadId).
|
|
8527
8619
|
#fecPayloadIdsWithoutProfile = 0;
|
|
8620
|
+
// Repair packets discarded by the fec-01 4.5 block-length rule.
|
|
8621
|
+
#repairBlockLengthDiscards = 0;
|
|
8528
8622
|
/** The staged in-place stream switch, if any (stageStreamSwitch). */
|
|
8529
8623
|
#staged = null;
|
|
8530
8624
|
#disposed = false;
|
|
@@ -8534,10 +8628,6 @@ var MmtpRouter = class {
|
|
|
8534
8628
|
this.#fecManager = config?.fecManager ?? null;
|
|
8535
8629
|
this.#onFrameGap = config?.onFrameGap ?? null;
|
|
8536
8630
|
this.#defaultFecMapper = config?.fecMapper ?? null;
|
|
8537
|
-
this.#manifestVerifier = config?.manifestVerifier ?? null;
|
|
8538
|
-
this.#ownsManifestVerifier = config?.manifestVerifierOwnership !== "caller";
|
|
8539
|
-
this.#resolveManifestIdentity = config?.resolveManifestIdentity ?? null;
|
|
8540
|
-
this.#resolveManifestIdentityForRoute = config?.resolveManifestIdentityForRoute ?? null;
|
|
8541
8631
|
this.#parser = new MmtpContainerParser({
|
|
8542
8632
|
mfuTimeoutMs: config?.mfuTimeoutMs,
|
|
8543
8633
|
reassemblyPolicy: config?.reassemblyPolicy,
|
|
@@ -8578,6 +8668,12 @@ var MmtpRouter = class {
|
|
|
8578
8668
|
...meta.catalogTrackName === void 0 ? {} : { catalogTrackName: meta.catalogTrackName }
|
|
8579
8669
|
};
|
|
8580
8670
|
if (meta.source) frameMeta.source = meta.source;
|
|
8671
|
+
if (isVideo && frameMeta.keyframe) {
|
|
8672
|
+
const twinSeen = this.#multicastRapTwinByStream.delete(
|
|
8673
|
+
this.#mediaStreamKey(packetId, frameMeta.catalogTrackName)
|
|
8674
|
+
);
|
|
8675
|
+
if (twinSeen && frameMeta.source === "moq") frameMeta.source = "multicast";
|
|
8676
|
+
}
|
|
8581
8677
|
if (meta.deliveryProvenance !== void 0)
|
|
8582
8678
|
frameMeta.deliveryProvenance = meta.deliveryProvenance;
|
|
8583
8679
|
if (meta.recovered) frameMeta.recovered = true;
|
|
@@ -8740,6 +8836,14 @@ var MmtpRouter = class {
|
|
|
8740
8836
|
get publisherRestartCount() {
|
|
8741
8837
|
return this.#publisherRestarts;
|
|
8742
8838
|
}
|
|
8839
|
+
/**
|
|
8840
|
+
* FEC-recovered source symbols whose reconstructed header named a
|
|
8841
|
+
* packet_sequence_number other than the wire sequence their SS_ID maps to:
|
|
8842
|
+
* a hop re-stamped the sequence after the sender protected the packet.
|
|
8843
|
+
*/
|
|
8844
|
+
get restampedRecoveredSequenceCount() {
|
|
8845
|
+
return this.#restampedRecoveredSeqs;
|
|
8846
|
+
}
|
|
8743
8847
|
/**
|
|
8744
8848
|
* Packets whose Source or Repair FEC Payload ID was left unread because
|
|
8745
8849
|
* their (owner) packetId had no configured `fec.blockProfile`: FEC not
|
|
@@ -8751,6 +8855,14 @@ var MmtpRouter = class {
|
|
|
8751
8855
|
get fecPayloadIdsWithoutProfile() {
|
|
8752
8856
|
return this.#fecPayloadIdsWithoutProfile;
|
|
8753
8857
|
}
|
|
8858
|
+
/**
|
|
8859
|
+
* Repair packets discarded at admission by the fec-01 4.5 rule (RS_ID not
|
|
8860
|
+
* below RSB_length, or a reed-solomon SSB_length + RSB_length above 255),
|
|
8861
|
+
* before they touched any block state.
|
|
8862
|
+
*/
|
|
8863
|
+
get repairBlockLengthDiscards() {
|
|
8864
|
+
return this.#repairBlockLengthDiscards;
|
|
8865
|
+
}
|
|
8754
8866
|
get reassembler() {
|
|
8755
8867
|
return this.#parser.reassembler;
|
|
8756
8868
|
}
|
|
@@ -9047,29 +9159,162 @@ var MmtpRouter = class {
|
|
|
9047
9159
|
}
|
|
9048
9160
|
});
|
|
9049
9161
|
}
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
this.#
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9162
|
+
/**
|
|
9163
|
+
* Protect a flow (draft-ramadan-moq-multicast-01 7.2.7): every multicast
|
|
9164
|
+
* datagram whose ingress names `ingress.flow`, source and repair alike, is
|
|
9165
|
+
* admitted by `receiver` before anything reads it, and an unadmitted one is
|
|
9166
|
+
* held or dropped. The caller owns the receiver's configuration; the router
|
|
9167
|
+
* releases it on `releaseProvenanceFlow` and on dispose.
|
|
9168
|
+
*/
|
|
9169
|
+
registerProvenanceFlow(ingress, receiver) {
|
|
9170
|
+
this.#provenance.get(ingress.flow)?.receiver.release();
|
|
9171
|
+
this.#provenance.set(ingress.flow, { receiver, ingress });
|
|
9172
|
+
receiver.keepPendingAgeMs = () => this.#oldestOpenBlockAgeMs(ingress.flow);
|
|
9173
|
+
}
|
|
9174
|
+
/**
|
|
9175
|
+
* Declare that this receiver can request unicast repair (a repair FETCH
|
|
9176
|
+
* scheduler is wired): a protected flow then keeps the pending entries of
|
|
9177
|
+
* its open blocks for the repair to consume (7.2.7 step 2).
|
|
9178
|
+
*/
|
|
9179
|
+
setUnicastRepair(enabled) {
|
|
9180
|
+
this.#unicastRepair = enabled;
|
|
9181
|
+
}
|
|
9182
|
+
#oldestOpenBlockAgeMs(flow) {
|
|
9183
|
+
const entry = this.#provenance.get(flow);
|
|
9184
|
+
if (!this.#unicastRepair || !entry) return void 0;
|
|
9185
|
+
let age;
|
|
9186
|
+
for (const { name, packetId } of entry.ingress.tracks) {
|
|
9187
|
+
const a = name ? this.#fecManager?.oldestOpenBlockAgeMs?.(packetId, name) : void 0;
|
|
9188
|
+
if (a !== void 0 && (age === void 0 || a > age)) age = a;
|
|
9189
|
+
}
|
|
9190
|
+
return age;
|
|
9191
|
+
}
|
|
9192
|
+
/**
|
|
9193
|
+
* Replace a registered flow's ingress (a rendition switch staged, committed
|
|
9194
|
+
* or cancelled) while keeping its receiver; a no-op for an unregistered flow.
|
|
9195
|
+
*/
|
|
9196
|
+
updateProvenanceFlowIngress(ingress) {
|
|
9197
|
+
const entry = this.#provenance.get(ingress.flow);
|
|
9198
|
+
if (!entry) return;
|
|
9199
|
+
this.#provenance.set(ingress.flow, { ...entry, ingress });
|
|
9200
|
+
if (entry.protected) {
|
|
9201
|
+
for (const { name, packetId } of ingress.tracks) {
|
|
9202
|
+
if (name && !entry.ingress.tracks.some((t) => t.name === name && t.packetId === packetId)) {
|
|
9203
|
+
this.#fecManager?.resetTrack?.(packetId, name);
|
|
9068
9204
|
}
|
|
9069
9205
|
}
|
|
9070
|
-
this.#manifestRecoveryQueues.clear();
|
|
9071
9206
|
}
|
|
9072
9207
|
}
|
|
9208
|
+
/**
|
|
9209
|
+
* Called once per protection of a flow: at the admission that makes this
|
|
9210
|
+
* router's consumers protected under it (7.2.7), after their unadmitted
|
|
9211
|
+
* holdings of its listed tracks are discarded. Again after an unprotect.
|
|
9212
|
+
*/
|
|
9213
|
+
onProvenanceFlowProtected(cb) {
|
|
9214
|
+
this.#onFlowProtected = cb;
|
|
9215
|
+
}
|
|
9216
|
+
/**
|
|
9217
|
+
* The receiver ceased to hold the flow's endpoint on failover (7.2.7): drop
|
|
9218
|
+
* its state and hold queues (no expiry counted) and un-protect its tracks,
|
|
9219
|
+
* which then take MoQ again. The registration stays, so multicast resuming
|
|
9220
|
+
* protects the flow anew at its next admission.
|
|
9221
|
+
*/
|
|
9222
|
+
unprotectProvenanceFlow(flow) {
|
|
9223
|
+
const entry = this.#provenance.get(flow);
|
|
9224
|
+
if (!entry) return;
|
|
9225
|
+
entry.receiver.release();
|
|
9226
|
+
entry.protected = false;
|
|
9227
|
+
}
|
|
9228
|
+
/** MoQ packets of a track a protected flow lists, dropped on its unicast path: duplicate, overflow, or listed by more than one flow. */
|
|
9229
|
+
get unadmittedListedDropCount() {
|
|
9230
|
+
return this.#unadmittedListedDrops;
|
|
9231
|
+
}
|
|
9232
|
+
/**
|
|
9233
|
+
* The admission that makes this router protected under `flow` (7.2.7):
|
|
9234
|
+
* its FEC instances discard what they hold of the flow's listed tracks so
|
|
9235
|
+
* no unadmitted symbol stands for an admitted one, then notify. Before it
|
|
9236
|
+
* nothing of the flow was admitted, so every such symbol is unadmitted.
|
|
9237
|
+
* The playback parse ledger is kept: it records MoQ copies already played,
|
|
9238
|
+
* not holdings, and clearing it re-emits that media (audio twice).
|
|
9239
|
+
* The FEC reset is the whole 7.2.7 discard here: no keyframe-overlay
|
|
9240
|
+
* instance exists to hold anything (repair-layers.ts is the catalog
|
|
9241
|
+
* contract only, no decoder), and packet_id 0 is never a listed track
|
|
9242
|
+
* (`ingressHasPacketId`), so nothing of it is held for the flow.
|
|
9243
|
+
*/
|
|
9244
|
+
#noteFlowAdmitted(flow) {
|
|
9245
|
+
const entry = this.#provenance.get(flow);
|
|
9246
|
+
if (!entry || entry.protected) return;
|
|
9247
|
+
entry.protected = true;
|
|
9248
|
+
for (const { name, packetId } of entry.ingress.tracks) {
|
|
9249
|
+
if (name) this.#fecManager?.resetTrack?.(packetId, name);
|
|
9250
|
+
}
|
|
9251
|
+
this.#onFlowProtected?.(flow);
|
|
9252
|
+
}
|
|
9253
|
+
/**
|
|
9254
|
+
* Admit a MoQ datagram of `packetId` on the unicast path of the protected
|
|
9255
|
+
* flow that lists it (7.2.7). `unlisted`: no protected flow lists it, so it
|
|
9256
|
+
* is read as before. A held datagram is routed by `replay` when a record
|
|
9257
|
+
* admits it; one more than one protected flow lists is dropped. So is an
|
|
9258
|
+
* overlap copy: it never enters FEC accounting, so admitting it would leave
|
|
9259
|
+
* its multicast twin a duplicate and the block one symbol short.
|
|
9260
|
+
*/
|
|
9261
|
+
#admitUnicast(packetId, packet, replay, overlapCopy = false) {
|
|
9262
|
+
let receiver;
|
|
9263
|
+
for (const entry of this.#provenance.values()) {
|
|
9264
|
+
if (!entry.protected || !ingressHasPacketId(entry.ingress, packetId)) continue;
|
|
9265
|
+
if (receiver || overlapCopy) {
|
|
9266
|
+
this.#unadmittedListedDrops++;
|
|
9267
|
+
return "dropped";
|
|
9268
|
+
}
|
|
9269
|
+
receiver = entry.receiver;
|
|
9270
|
+
}
|
|
9271
|
+
if (!receiver) return "unlisted";
|
|
9272
|
+
const { verdict } = receiver.onDatagram(packet, "unicast");
|
|
9273
|
+
if (verdict === "admitted") return "admitted";
|
|
9274
|
+
if (verdict === "held") {
|
|
9275
|
+
this.#heldReplay.set(packet, replay);
|
|
9276
|
+
return "held";
|
|
9277
|
+
}
|
|
9278
|
+
this.#unadmittedListedDrops++;
|
|
9279
|
+
return "dropped";
|
|
9280
|
+
}
|
|
9281
|
+
/**
|
|
9282
|
+
* Feed one bc-provenance record of `flow`: a datagram from `manifestPort`
|
|
9283
|
+
* (`multicast`) or an object of the manifest track (`mirror`). Held
|
|
9284
|
+
* datagrams the record admits are routed before this returns.
|
|
9285
|
+
*/
|
|
9286
|
+
feedProvenanceRecord(flow, record, path) {
|
|
9287
|
+
const entry = this.#provenance.get(flow);
|
|
9288
|
+
if (!entry || this.#disposed) return "unregistered";
|
|
9289
|
+
const result = entry.receiver.onRecord(record, path);
|
|
9290
|
+
if (result.admitted.length > 0) {
|
|
9291
|
+
this.#noteFlowAdmitted(flow);
|
|
9292
|
+
this.#withDeferredFecPokes(() => {
|
|
9293
|
+
for (const datagram of result.admitted) {
|
|
9294
|
+
const replay = this.#heldReplay.get(datagram);
|
|
9295
|
+
if (replay) replay();
|
|
9296
|
+
else this.#processMMTP(datagram, "multicast", true, this.#heldIngress.get(datagram) ?? entry.ingress, false, true);
|
|
9297
|
+
}
|
|
9298
|
+
});
|
|
9299
|
+
}
|
|
9300
|
+
return result.verdict;
|
|
9301
|
+
}
|
|
9302
|
+
/** The receiver ceased to hold the flow: its hold queues are dropped, not expired. */
|
|
9303
|
+
releaseProvenanceFlow(flow) {
|
|
9304
|
+
this.#provenance.get(flow)?.receiver.release();
|
|
9305
|
+
this.#provenance.delete(flow);
|
|
9306
|
+
for (const byName of this.#provenanceStreamFlow.values()) {
|
|
9307
|
+
for (const [name, bound] of byName) if (bound === flow) byName.delete(name);
|
|
9308
|
+
}
|
|
9309
|
+
}
|
|
9310
|
+
/** Multicast datagrams dropped because their ingress names a flow with no registered receiver. */
|
|
9311
|
+
get unregisteredFlowDropCount() {
|
|
9312
|
+
return this.#unregisteredFlowDrops;
|
|
9313
|
+
}
|
|
9314
|
+
/** Recovered packets dropped because more than one protected flow could own their stream. */
|
|
9315
|
+
get ambiguousRecoveredDropCount() {
|
|
9316
|
+
return this.#ambiguousRecoveredDrops;
|
|
9317
|
+
}
|
|
9073
9318
|
/**
|
|
9074
9319
|
* Main entry point: feed a raw MMTP packet for processing.
|
|
9075
9320
|
*
|
|
@@ -9084,10 +9329,10 @@ var MmtpRouter = class {
|
|
|
9084
9329
|
* they may never have crossed — and that attribution is what the physical-
|
|
9085
9330
|
* delivery evidence path is built on. Absence is not multicast; say which.
|
|
9086
9331
|
*/
|
|
9087
|
-
feedPacket(packet, source,
|
|
9332
|
+
feedPacket(packet, source, ingress) {
|
|
9088
9333
|
if (this.#disposed) return;
|
|
9089
9334
|
this.#withDeferredFecPokes(() => {
|
|
9090
|
-
this.#processMMTP(packet, source,
|
|
9335
|
+
this.#processMMTP(packet, source, false, ingress);
|
|
9091
9336
|
});
|
|
9092
9337
|
}
|
|
9093
9338
|
/**
|
|
@@ -9122,20 +9367,20 @@ var MmtpRouter = class {
|
|
|
9122
9367
|
feedOverlapCopy(packet, ingress) {
|
|
9123
9368
|
if (this.#disposed) return;
|
|
9124
9369
|
this.#withDeferredFecPokes(() => {
|
|
9125
|
-
this.#processMMTP(packet, "moq",
|
|
9370
|
+
this.#processMMTP(packet, "moq", false, ingress, true);
|
|
9126
9371
|
});
|
|
9127
9372
|
}
|
|
9128
9373
|
/**
|
|
9129
9374
|
* Feed a repair packet from MoQ (reliable QUIC) — parses MMTP repair
|
|
9130
9375
|
* header and delegates to FECManager for FEC recovery.
|
|
9131
9376
|
*/
|
|
9132
|
-
feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName) {
|
|
9377
|
+
feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName) {
|
|
9133
9378
|
if (this.#disposed) return;
|
|
9134
9379
|
this.#withDeferredFecPokes(() => {
|
|
9135
|
-
this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName);
|
|
9380
|
+
this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName);
|
|
9136
9381
|
});
|
|
9137
9382
|
}
|
|
9138
|
-
#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName) {
|
|
9383
|
+
#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName, admitted = false) {
|
|
9139
9384
|
let header;
|
|
9140
9385
|
try {
|
|
9141
9386
|
header = parseMMTPHeader(packet);
|
|
@@ -9152,6 +9397,10 @@ var MmtpRouter = class {
|
|
|
9152
9397
|
`[MmtpRouter] Dropping MoQ repair packet pid=${repairPacketId}: owner hint is required`
|
|
9153
9398
|
);
|
|
9154
9399
|
}
|
|
9400
|
+
if (ownerPacketId != null && !admitted) {
|
|
9401
|
+
const admit = this.#admitUnicast(ownerPacketId, packet, () => this.#feedRepairPacket(packet, ownerPacketIdHint, catalogTrackName, repairTrackName, true));
|
|
9402
|
+
if (admit === "held" || admit === "dropped") return;
|
|
9403
|
+
}
|
|
9155
9404
|
if (ownerPacketId != null && this.#fecManager) {
|
|
9156
9405
|
this.#moqRepairPidCounts[repairPacketId] = (this.#moqRepairPidCounts[repairPacketId] || 0) + 1;
|
|
9157
9406
|
this.#moqRepairOwnerCounts[ownerPacketId] = (this.#moqRepairOwnerCounts[ownerPacketId] || 0) + 1;
|
|
@@ -9166,7 +9415,7 @@ var MmtpRouter = class {
|
|
|
9166
9415
|
this.#noteUnreadableFecPayloadId(ownerPacketId, "repair");
|
|
9167
9416
|
return;
|
|
9168
9417
|
}
|
|
9169
|
-
this.#handleIsoRepair(ownerPacketId, catalogTrackName, parsed, "moq");
|
|
9418
|
+
this.#handleIsoRepair(ownerPacketId, catalogTrackName, parsed, "moq", repairTrackName);
|
|
9170
9419
|
}
|
|
9171
9420
|
}
|
|
9172
9421
|
// ── Packet FEC geometry and block profile ───────────────────────
|
|
@@ -9248,13 +9497,25 @@ var MmtpRouter = class {
|
|
|
9248
9497
|
* the repair, the order they had on the wire, so a loss-free block completes
|
|
9249
9498
|
* clean on its repair. A repair contradicting a known block is dropped.
|
|
9250
9499
|
*/
|
|
9251
|
-
#handleIsoRepair(ownerPacketId, catalogTrackName, repair, source) {
|
|
9500
|
+
#handleIsoRepair(ownerPacketId, catalogTrackName, repair, source, repairTrackName) {
|
|
9252
9501
|
const fec = this.#fecManager;
|
|
9253
9502
|
if (!fec?.placeIsoRepair) {
|
|
9254
9503
|
throw new Error(
|
|
9255
9504
|
`[MmtpRouter] packetId=${ownerPacketId} is iso-ssbg1-v1 but its FEC manager cannot place ISO blocks`
|
|
9256
9505
|
);
|
|
9257
9506
|
}
|
|
9507
|
+
if (fec.admitRepairBlockLength && !fec.admitRepairBlockLength(ownerPacketId, repair.ssbLength, repair.rsbLength, repair.rsId)) {
|
|
9508
|
+
this.#repairBlockLengthDiscards++;
|
|
9509
|
+
return;
|
|
9510
|
+
}
|
|
9511
|
+
if (fec.admitRepairSymbolSize && !fec.admitRepairSymbolSize(
|
|
9512
|
+
ownerPacketId,
|
|
9513
|
+
repair.ssStart,
|
|
9514
|
+
repair.ssbLength,
|
|
9515
|
+
repair.rsId,
|
|
9516
|
+
repair.symbolData.byteLength
|
|
9517
|
+
)) return;
|
|
9518
|
+
if (fec.admitRepairLayerTotal && !fec.admitRepairLayerTotal(ownerPacketId, catalogTrackName, repairTrackName, repair.ssStart, repair.rsbLength)) return;
|
|
9258
9519
|
const placement = fec.placeIsoRepair(ownerPacketId, catalogTrackName, repair.ssStart, repair.ssbLength);
|
|
9259
9520
|
if (placement.status !== "placed") return;
|
|
9260
9521
|
const blockStart = placement.block.start;
|
|
@@ -9289,6 +9550,17 @@ var MmtpRouter = class {
|
|
|
9289
9550
|
this.#routeRecoveredBlock(blockStart, recovered, ownerPacketId, catalogTrackName);
|
|
9290
9551
|
}
|
|
9291
9552
|
}
|
|
9553
|
+
/**
|
|
9554
|
+
* The range repair FETCH for an undelimited hole ended (draft-ramadan-moq-fec
|
|
9555
|
+
* §7.5): what no repair stated becomes repair-less spans, whose held sources
|
|
9556
|
+
* are fed exactly as a span a repair closed.
|
|
9557
|
+
*/
|
|
9558
|
+
closeIsoHoles(ownerPacketId, catalogTrackName, start, length) {
|
|
9559
|
+
const spans = this.#fecManager?.closeIsoHoles?.(ownerPacketId, catalogTrackName, start, length) ?? [];
|
|
9560
|
+
for (const span of spans) {
|
|
9561
|
+
this.#replayIsoSources(ownerPacketId, catalogTrackName, span.block.start, span.placed);
|
|
9562
|
+
}
|
|
9563
|
+
}
|
|
9292
9564
|
/**
|
|
9293
9565
|
* Feed iso-ssbg1-v1 sources a repair just placed, in SS_ID order, exactly as
|
|
9294
9566
|
* a first-arrival source is fed once its block is known: transport
|
|
@@ -9384,13 +9656,14 @@ var MmtpRouter = class {
|
|
|
9384
9656
|
this.#trackSynced.delete(streamKey);
|
|
9385
9657
|
this.#droppedPreSyncVideo.delete(streamKey);
|
|
9386
9658
|
this.#latestVideoSeqByStream.delete(streamKey);
|
|
9659
|
+
this.#ssIdSeqOffsetByStream.delete(streamKey);
|
|
9660
|
+
this.#multicastRapTwinByStream.delete(streamKey);
|
|
9387
9661
|
this.#lastDirectSourceVideoTsByStream.delete(streamKey);
|
|
9388
9662
|
this.#lastDirectEmittedVideoTsByStream.delete(streamKey);
|
|
9389
9663
|
this.#pendingDirectRecoveredVideoByStream.delete(streamKey);
|
|
9390
9664
|
this.#lastDirectSourceAudioCursorByStream.delete(streamKey);
|
|
9391
9665
|
this.#lastDirectEmittedAudioCursorByStream.delete(streamKey);
|
|
9392
9666
|
this.#pendingDirectRecoveredAudioByStream.delete(streamKey);
|
|
9393
|
-
this.#manifestRecoveryQueues.delete(streamKey);
|
|
9394
9667
|
this.#deliveredVideoHighWaterByStream.delete(streamKey);
|
|
9395
9668
|
this.#stream(packetId, catalogTrackName).duplicates.clear();
|
|
9396
9669
|
const assemblersToReset = /* @__PURE__ */ new Set();
|
|
@@ -9440,7 +9713,6 @@ var MmtpRouter = class {
|
|
|
9440
9713
|
this.#lastDirectSourceAudioCursorByStream.delete(key);
|
|
9441
9714
|
this.#lastDirectEmittedAudioCursorByStream.delete(key);
|
|
9442
9715
|
this.#pendingDirectRecoveredAudioByStream.delete(key);
|
|
9443
|
-
this.#manifestRecoveryQueues.delete(key);
|
|
9444
9716
|
this.#trackInitDelivered.delete(key);
|
|
9445
9717
|
this.#parserDiagnostics.delete(key);
|
|
9446
9718
|
this.#pendingFecPokes.delete(key);
|
|
@@ -9701,8 +9973,9 @@ var MmtpRouter = class {
|
|
|
9701
9973
|
this.#parserDiagnostics.clear();
|
|
9702
9974
|
this.#catalogTrackNamesByPacketId.clear();
|
|
9703
9975
|
this.#repairOwnersByPacketId.clear();
|
|
9704
|
-
|
|
9705
|
-
this.#
|
|
9976
|
+
for (const { receiver } of this.#provenance.values()) receiver.release();
|
|
9977
|
+
this.#provenance.clear();
|
|
9978
|
+
this.#provenanceStreamFlow.clear();
|
|
9706
9979
|
for (const assembler of this.#mseAssemblers.values()) assembler.dispose();
|
|
9707
9980
|
this.#mseAssemblers.clear();
|
|
9708
9981
|
}
|
|
@@ -9979,7 +10252,7 @@ var MmtpRouter = class {
|
|
|
9979
10252
|
* 1. parseHeader() → extract packetId + fecPayloadId for FEC feeding
|
|
9980
10253
|
* 2. feed() → MFU extraction, reassembly, keyframe detection, emit via callbacks
|
|
9981
10254
|
*/
|
|
9982
|
-
#processMMTP(packet, source,
|
|
10255
|
+
#processMMTP(packet, source, manifestAdmitted = false, ingress, overlapCopy = false, releasedFromQuarantine = false) {
|
|
9983
10256
|
const parsed = this.#parser.parsePacket(packet);
|
|
9984
10257
|
if (!parsed) return;
|
|
9985
10258
|
const info = parsed.info;
|
|
@@ -10004,43 +10277,29 @@ var MmtpRouter = class {
|
|
|
10004
10277
|
}
|
|
10005
10278
|
const fecUnreadable = !info.isRepair && info.fecPayloadId != null && this.#fecManager !== null && this.#classifyPacketId(info.packetId) !== null && this.#configuredBlockProfile(info.packetId) === void 0;
|
|
10006
10279
|
if (fecUnreadable && !manifestAdmitted) this.#noteUnreadableFecPayloadId(info.packetId, "source");
|
|
10007
|
-
if (!info.isRepair &&
|
|
10008
|
-
let
|
|
10009
|
-
if (!
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
recovered: false,
|
|
10018
|
-
sourceSymbolFormat: "full-mmtp-packet"
|
|
10019
|
-
}) : this.#resolveManifestIdentity(
|
|
10020
|
-
info.packetId,
|
|
10021
|
-
coordinates.sbn,
|
|
10022
|
-
coordinates.esi,
|
|
10023
|
-
catalogTrackName
|
|
10024
|
-
)) ?? void 0;
|
|
10025
|
-
}
|
|
10026
|
-
if (identity) {
|
|
10027
|
-
identity = {
|
|
10028
|
-
...identity,
|
|
10029
|
-
packetId: info.packetId,
|
|
10030
|
-
...info.fecPayloadId ? { ssId: info.fecPayloadId.ssId } : {}
|
|
10031
|
-
};
|
|
10032
|
-
const authenticated = info.fecPayloadId ? packet.subarray(0, packet.length - 4) : packet;
|
|
10033
|
-
let quarantined = false;
|
|
10034
|
-
const admission = this.#manifestVerifier.admitObject(identity, authenticated, () => {
|
|
10035
|
-
if (!this.#disposed) {
|
|
10036
|
-
this.#processMMTP(packet, source, identity, true, ingress, overlapCopy, quarantined);
|
|
10037
|
-
}
|
|
10038
|
-
});
|
|
10039
|
-
quarantined = admission.action === "stall";
|
|
10280
|
+
if (source === "multicast" && manifestAdmitted && !info.isRepair && ingress?.flow !== void 0) {
|
|
10281
|
+
let byName = this.#provenanceStreamFlow.get(info.packetId);
|
|
10282
|
+
if (!byName) this.#provenanceStreamFlow.set(info.packetId, byName = /* @__PURE__ */ new Map());
|
|
10283
|
+
byName.set(catalogTrackNameForPacket(ingress, info.packetId), ingress.flow);
|
|
10284
|
+
}
|
|
10285
|
+
if (source === "multicast" && !manifestAdmitted && ingress?.flow !== void 0) {
|
|
10286
|
+
const protectedFlow = this.#provenance.get(ingress.flow);
|
|
10287
|
+
if (!protectedFlow) {
|
|
10288
|
+
this.#unregisteredFlowDrops++;
|
|
10289
|
+
debugRouter(`[MmtpRouter] Dropping multicast packet pid=${info.packetId}: flow ${ingress.flow} has no receiver`);
|
|
10040
10290
|
return;
|
|
10041
10291
|
}
|
|
10042
|
-
|
|
10043
|
-
|
|
10292
|
+
const { verdict } = protectedFlow.receiver.onDatagram(packet, "multicast");
|
|
10293
|
+
if (verdict === "admitted") {
|
|
10294
|
+
this.#noteFlowAdmitted(ingress.flow);
|
|
10295
|
+
this.#processMMTP(packet, source, true, ingress, overlapCopy);
|
|
10296
|
+
} else if (verdict === "held") this.#heldIngress.set(packet, ingress);
|
|
10297
|
+
return;
|
|
10298
|
+
}
|
|
10299
|
+
if (source === "moq" && !manifestAdmitted) {
|
|
10300
|
+
const admit = this.#admitUnicast(info.packetId, packet, () => this.#processMMTP(packet, source, true, ingress, overlapCopy, true), overlapCopy);
|
|
10301
|
+
if (admit !== "unlisted") {
|
|
10302
|
+
if (admit === "admitted") this.#processMMTP(packet, source, true, ingress, overlapCopy);
|
|
10044
10303
|
return;
|
|
10045
10304
|
}
|
|
10046
10305
|
}
|
|
@@ -10154,6 +10413,12 @@ var MmtpRouter = class {
|
|
|
10154
10413
|
} else if (fecUnreadable && info.fecPayloadId) {
|
|
10155
10414
|
parseSourceSymbol = !duplicates.parsedSymbols.has(info.fecPayloadId.ssId);
|
|
10156
10415
|
}
|
|
10416
|
+
if (fecPayloadId && !overlapCopy) {
|
|
10417
|
+
this.#ssIdSeqOffsetByStream.set(
|
|
10418
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName),
|
|
10419
|
+
fecPayloadId.ssId - info.sequenceNumber >>> 0
|
|
10420
|
+
);
|
|
10421
|
+
}
|
|
10157
10422
|
if (!this.#fecManager || !info.fecPayloadId || parseSourceSymbol) {
|
|
10158
10423
|
if (this.#fecManager && info.fecPayloadId) {
|
|
10159
10424
|
duplicates.parsedSymbols.add(info.fecPayloadId.ssId);
|
|
@@ -10176,6 +10441,10 @@ var MmtpRouter = class {
|
|
|
10176
10441
|
// An FEC source frame is anchored by its own SS_ID (C.5.2).
|
|
10177
10442
|
...fecSource && fecPayloadId ? { fecSbn: fecPayloadId.ssId } : {}
|
|
10178
10443
|
}, parsed);
|
|
10444
|
+
} else if (source === "multicast" && info.rapFlag) {
|
|
10445
|
+
this.#multicastRapTwinByStream.add(
|
|
10446
|
+
this.#mediaStreamKey(info.packetId, catalogTrackName)
|
|
10447
|
+
);
|
|
10179
10448
|
}
|
|
10180
10449
|
if (this.#classifyPacketId(info.packetId) === null) return;
|
|
10181
10450
|
if (this.#fecManager && fecPayloadId && coords && sourceSymbolAccepted && sourceSymbolTrackable) {
|
|
@@ -10631,105 +10900,69 @@ var MmtpRouter = class {
|
|
|
10631
10900
|
});
|
|
10632
10901
|
this.#routeVerifiedFecSymbols(blockId, result, ownerPacketId, catalogTrackName);
|
|
10633
10902
|
}
|
|
10903
|
+
/**
|
|
10904
|
+
* A recovered source packet of a protected flow is admitted on its own
|
|
10905
|
+
* digest: its bytes with the SS_ID it was sent with (SS_Start + ESI)
|
|
10906
|
+
* appended are the datagram the record listed (7.2.7). One that no record
|
|
10907
|
+
* lists is dropped; holding it would let it out later as a multicast arrival.
|
|
10908
|
+
*/
|
|
10634
10909
|
#routeVerifiedFecSymbols(blockId, result, ownerPacketId, catalogTrackName) {
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
if (
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10910
|
+
const receiver = ownerPacketId == null ? void 0 : this.#provenanceFor(ownerPacketId, catalogTrackName);
|
|
10911
|
+
if (receiver === "ambiguous") {
|
|
10912
|
+
this.#ambiguousRecoveredDrops += result.symbols.length;
|
|
10913
|
+
result = { ...result, symbols: [] };
|
|
10914
|
+
} else if (receiver) {
|
|
10915
|
+
result = {
|
|
10916
|
+
...result,
|
|
10917
|
+
symbols: result.symbols.filter((sym) => {
|
|
10918
|
+
const wire = new Uint8Array(sym.rawSymbol.byteLength + 4);
|
|
10919
|
+
wire.set(sym.rawSymbol);
|
|
10920
|
+
new DataView(wire.buffer).setUint32(sym.rawSymbol.byteLength, this.#fecAnchorForRecovered(blockId, sym.index));
|
|
10921
|
+
return receiver.admitRecovered(wire);
|
|
10922
|
+
})
|
|
10923
|
+
};
|
|
10643
10924
|
}
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10925
|
+
this.#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName);
|
|
10926
|
+
}
|
|
10927
|
+
/**
|
|
10928
|
+
* The receiver a recovered packet of `packetId` answers to: the flow that
|
|
10929
|
+
* admitted the stream's source datagrams. Before any was admitted, the one
|
|
10930
|
+
* flow whose registration lists the stream; more than one (a repair flow
|
|
10931
|
+
* also lists its owners' source tracks) cannot be told apart, so none.
|
|
10932
|
+
*/
|
|
10933
|
+
#provenanceFor(packetId, catalogTrackName) {
|
|
10934
|
+
const byName = this.#provenanceStreamFlow.get(packetId);
|
|
10935
|
+
const flows = new Set(
|
|
10936
|
+
catalogTrackName === void 0 || !byName ? byName?.values() : byName.has(catalogTrackName) ? [byName.get(catalogTrackName)] : []
|
|
10937
|
+
);
|
|
10938
|
+
if (flows.size > 1) return "ambiguous";
|
|
10939
|
+
for (const bound of flows) return this.#provenance.get(bound)?.receiver ?? "ambiguous";
|
|
10940
|
+
let match;
|
|
10941
|
+
for (const { receiver, ingress } of this.#provenance.values()) {
|
|
10942
|
+
if (ingress.tracks.some((t) => t.packetId === packetId && (catalogTrackName === void 0 || t.name === catalogTrackName))) {
|
|
10943
|
+
if (match) return "ambiguous";
|
|
10944
|
+
match = receiver;
|
|
10654
10945
|
}
|
|
10655
|
-
this.#admitRecoveredResult(
|
|
10656
|
-
next.blockId,
|
|
10657
|
-
next.result,
|
|
10658
|
-
next.ownerPacketId,
|
|
10659
|
-
next.catalogTrackName,
|
|
10660
|
-
() => {
|
|
10661
|
-
queue.shift();
|
|
10662
|
-
drain();
|
|
10663
|
-
}
|
|
10664
|
-
);
|
|
10665
|
-
};
|
|
10666
|
-
drain();
|
|
10667
|
-
}
|
|
10668
|
-
#admitRecoveredResult(blockId, result, ownerPacketId, catalogTrackName, done) {
|
|
10669
|
-
const verifier = this.#manifestVerifier;
|
|
10670
|
-
const resolveIdentity = this.#resolveManifestIdentity;
|
|
10671
|
-
const resolveIdentityForRoute = this.#resolveManifestIdentityForRoute;
|
|
10672
|
-
if (!verifier) {
|
|
10673
|
-
this.#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName);
|
|
10674
|
-
done();
|
|
10675
|
-
return;
|
|
10676
10946
|
}
|
|
10677
|
-
|
|
10678
|
-
const symbols = result.symbols;
|
|
10679
|
-
const admitNext = (index) => {
|
|
10680
|
-
const symbol = symbols[index];
|
|
10681
|
-
if (!symbol) {
|
|
10682
|
-
done();
|
|
10683
|
-
return;
|
|
10684
|
-
}
|
|
10685
|
-
const identity = resolveIdentityForRoute ? resolveIdentityForRoute({
|
|
10686
|
-
packetId: ownerPacketId,
|
|
10687
|
-
sbn: blockId,
|
|
10688
|
-
esi: symbol.index,
|
|
10689
|
-
...catalogTrackName === void 0 ? {} : { catalogTrackName },
|
|
10690
|
-
recovered: true,
|
|
10691
|
-
sourceSymbolFormat: "fec-padded-recovery"
|
|
10692
|
-
}) : resolveIdentity(ownerPacketId, blockId, symbol.index, catalogTrackName);
|
|
10693
|
-
if (!identity) {
|
|
10694
|
-
console.warn(`[MmtpRouter] manifest identity unresolved; recovered symbol is fail-open for packetId=${ownerPacketId} block=${blockId} esi=${symbol.index}`);
|
|
10695
|
-
this.#routeProcessedFecSymbols(
|
|
10696
|
-
blockId,
|
|
10697
|
-
{ ...result, symbols: [symbol] },
|
|
10698
|
-
ownerPacketId,
|
|
10699
|
-
catalogTrackName
|
|
10700
|
-
);
|
|
10701
|
-
admitNext(index + 1);
|
|
10702
|
-
return;
|
|
10703
|
-
}
|
|
10704
|
-
const admission = verifier.admitObject(
|
|
10705
|
-
{
|
|
10706
|
-
...identity,
|
|
10707
|
-
packetId: ownerPacketId
|
|
10708
|
-
},
|
|
10709
|
-
symbol.rawSymbol,
|
|
10710
|
-
() => {
|
|
10711
|
-
if (!this.#disposed) {
|
|
10712
|
-
this.#routeProcessedFecSymbols(
|
|
10713
|
-
blockId,
|
|
10714
|
-
{ ...result, symbols: [symbol] },
|
|
10715
|
-
ownerPacketId,
|
|
10716
|
-
catalogTrackName
|
|
10717
|
-
);
|
|
10718
|
-
}
|
|
10719
|
-
admitNext(index + 1);
|
|
10720
|
-
},
|
|
10721
|
-
// A stalled symbol that is later discarded instead of played must still
|
|
10722
|
-
// advance this loop; enforce mode never calls the release callback for
|
|
10723
|
-
// it (BLO-30095).
|
|
10724
|
-
() => admitNext(index + 1)
|
|
10725
|
-
);
|
|
10726
|
-
if (admission.action === "drop") admitNext(index + 1);
|
|
10727
|
-
};
|
|
10728
|
-
admitNext(0);
|
|
10947
|
+
return match;
|
|
10729
10948
|
}
|
|
10730
10949
|
#routeProcessedFecSymbols(blockId, result, ownerPacketId, catalogTrackName) {
|
|
10731
10950
|
if (ownerPacketId == null) return;
|
|
10732
10951
|
if (this.#classifyPacketId(ownerPacketId) === null) return;
|
|
10952
|
+
const ssIdSeqOffset = this.#ssIdSeqOffsetByStream.get(
|
|
10953
|
+
this.#mediaStreamKey(ownerPacketId, catalogTrackName)
|
|
10954
|
+
);
|
|
10955
|
+
if (ssIdSeqOffset !== void 0) {
|
|
10956
|
+
result = {
|
|
10957
|
+
...result,
|
|
10958
|
+
symbols: result.symbols.map((sym) => {
|
|
10959
|
+
const wire = this.#fecAnchorForRecovered(blockId, sym.index) - ssIdSeqOffset >>> 0;
|
|
10960
|
+
if (wire === sym.packetSequenceNumber) return sym;
|
|
10961
|
+
this.#restampedRecoveredSeqs++;
|
|
10962
|
+
return { ...sym, packetSequenceNumber: wire };
|
|
10963
|
+
})
|
|
10964
|
+
};
|
|
10965
|
+
}
|
|
10733
10966
|
this.#stream(ownerPacketId, catalogTrackName).duplicates.advance(blockId);
|
|
10734
10967
|
const deliveryProvenance = this.#fecManager?.blockDeliveryProvenance?.(
|
|
10735
10968
|
blockId,
|