@blockcast/mmt-container 0.4.0 → 0.4.1-main.22841c1f0a2d
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 +2037 -881
- 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 +98 -234
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +108 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +452 -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 +3677 -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 +69 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +296 -192
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +313 -124
- package/dist/multicast-auth-catalog.js.map +3 -3
- 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 +97 -11
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1022 -527
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +12 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +108 -238
- 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 +3625 -1194
- 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 +81 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +156 -31
- 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 +366 -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 +301 -240
- package/src/multicast-auth-catalog.ts +134 -238
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +271 -40
- package/src/multicast-transport.ts +17 -3
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +283 -39
- 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
|
@@ -148,26 +148,30 @@ function isEmptyOrExactLegacyTrailer(payload, start, end) {
|
|
|
148
148
|
const authLength = view2.getUint16(2, false);
|
|
149
149
|
return start + LEGACY_TRAILER_HEADER_SIZE + authLength === end;
|
|
150
150
|
}
|
|
151
|
-
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options) {
|
|
151
|
+
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options, rapFlag = false) {
|
|
152
152
|
if (declaredEnd > payload.length)
|
|
153
153
|
return null;
|
|
154
154
|
if (options?.skipFecId) {
|
|
155
|
-
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false } : null;
|
|
155
|
+
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false, hasOverlayFecId: false } : null;
|
|
156
156
|
}
|
|
157
|
+
const overlay = options?.overlayDeclared === true && rapFlag;
|
|
157
158
|
if (fecType === 1) {
|
|
158
|
-
const fecStart = payload.length -
|
|
159
|
+
const fecStart = payload.length - sourceFecTrailerSize(overlay);
|
|
159
160
|
if (fecStart < declaredEnd || !isEmptyOrExactLegacyTrailer(payload, declaredEnd, fecStart)) {
|
|
160
161
|
return null;
|
|
161
162
|
}
|
|
162
|
-
return { hasFecId: true };
|
|
163
|
+
return { hasFecId: true, hasOverlayFecId: overlay };
|
|
163
164
|
}
|
|
164
|
-
if (fecType !== 0)
|
|
165
|
+
if (fecType !== 0 || overlay)
|
|
165
166
|
return null;
|
|
166
167
|
if (isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)) {
|
|
167
|
-
return { hasFecId: false };
|
|
168
|
+
return { hasFecId: false, hasOverlayFecId: false };
|
|
168
169
|
}
|
|
169
170
|
return null;
|
|
170
171
|
}
|
|
172
|
+
function sourceFecTrailerSize(overlay) {
|
|
173
|
+
return overlay ? 2 * SOURCE_FEC_PAYLOAD_ID_SIZE : SOURCE_FEC_PAYLOAD_ID_SIZE;
|
|
174
|
+
}
|
|
171
175
|
function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
172
176
|
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE) {
|
|
173
177
|
return {
|
|
@@ -220,15 +224,16 @@ function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
|
220
224
|
if ("rejection" in layoutResult)
|
|
221
225
|
return layoutResult;
|
|
222
226
|
const { layout } = layoutResult;
|
|
223
|
-
const trailerLayout = resolveDeclaredTrailers(payload, layout.dataEnd, header.fecType, options);
|
|
227
|
+
const trailerLayout = resolveDeclaredTrailers(payload, layout.dataEnd, header.fecType, options, header.rapFlag);
|
|
224
228
|
if (!trailerLayout) {
|
|
225
229
|
if (!options?.skipFecId && header.fecType === 1) {
|
|
226
230
|
const observed = payload.length - layout.dataEnd;
|
|
227
|
-
|
|
231
|
+
const expected = sourceFecTrailerSize(options?.overlayDeclared === true && header.rapFlag);
|
|
232
|
+
if (observed !== expected) {
|
|
228
233
|
return {
|
|
229
234
|
rejection: {
|
|
230
235
|
gate: "source-fec-payload-id-width-mismatch",
|
|
231
|
-
detail: `producer wrote a ${observed}-byte Source FEC Payload ID, ISO/IEC 23008-1 \xA7C.5.2 requires ${
|
|
236
|
+
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})`
|
|
232
237
|
}
|
|
233
238
|
};
|
|
234
239
|
}
|
|
@@ -255,10 +260,13 @@ function extractPlannedMfu(mmtpPacket, result) {
|
|
|
255
260
|
const mfuDuHeader = mfuDuHeaderPresent && mpu.timedFlag === 1 ? parseTimedMfuDuHeader(payload, MPU_HEADER_SIZE) : null;
|
|
256
261
|
const itemId = mfuDuHeaderPresent && mpu.timedFlag === 0 ? new DataView(payload.buffer, payload.byteOffset + MPU_HEADER_SIZE, 4).getUint32(0, false) : null;
|
|
257
262
|
const data = payload.subarray(mfuOffset, dataEnd);
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
const trailerStart = mmtpPacket.length - sourceFecTrailerSize(trailerLayout.hasOverlayFecId);
|
|
264
|
+
const ssIdAt = (offset) => ({
|
|
265
|
+
ssId: new DataView(mmtpPacket.buffer, mmtpPacket.byteOffset + offset, 4).getUint32(0, false)
|
|
266
|
+
});
|
|
267
|
+
const fecPayloadId = trailerLayout.hasFecId ? ssIdAt(trailerStart) : null;
|
|
268
|
+
const overlayFecPayloadId = trailerLayout.hasOverlayFecId ? ssIdAt(trailerStart + SOURCE_FEC_PAYLOAD_ID_SIZE) : null;
|
|
269
|
+
return { header, mpu, fragmentType, data, mfuDuHeader, itemId, fecPayloadId, overlayFecPayloadId };
|
|
262
270
|
}
|
|
263
271
|
function sourceFecPayloadIdOf(mmtpPacket, header) {
|
|
264
272
|
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE)
|
|
@@ -3138,8 +3146,14 @@ var SampleCombiner = class {
|
|
|
3138
3146
|
/**
|
|
3139
3147
|
* Add one reassembled data unit. Returns the combined sample once every
|
|
3140
3148
|
* constituent data unit has arrived and totals the authored size.
|
|
3149
|
+
*
|
|
3150
|
+
* `sampleSize` is the authored size the host resolves for the sample as the
|
|
3151
|
+
* data unit completes. It stands in only when no size was registered, which
|
|
3152
|
+
* happens when the data unit's FI=0/FI=1 reached the reassembler without the
|
|
3153
|
+
* host's own FT=2 parse: an FEC-recovered first fragment completed by source
|
|
3154
|
+
* fragments, or one decoded before its source copy arrived.
|
|
3141
3155
|
*/
|
|
3142
|
-
addMfu(mfu) {
|
|
3156
|
+
addMfu(mfu, sampleSize) {
|
|
3143
3157
|
if (mfu.movieFragmentSequenceNumber === void 0 || mfu.sampleNumber === void 0) {
|
|
3144
3158
|
this.#stats.passthroughSamples++;
|
|
3145
3159
|
return fromPassthrough(mfu);
|
|
@@ -3155,7 +3169,7 @@ var SampleCombiner = class {
|
|
|
3155
3169
|
return null;
|
|
3156
3170
|
}
|
|
3157
3171
|
const dataLen = mfu.data.byteLength;
|
|
3158
|
-
const authoredSize = this.#authoredSizes.get(key);
|
|
3172
|
+
const authoredSize = this.#authoredSizes.get(key) ?? sampleSize;
|
|
3159
3173
|
if (offset === 0 && !this.#pending.has(key)) {
|
|
3160
3174
|
const passesThrough = authoredSize === void 0 ? !this.#requireAuthoredSize : dataLen === authoredSize;
|
|
3161
3175
|
if (passesThrough) {
|
|
@@ -3449,6 +3463,12 @@ if (void 0) {
|
|
|
3449
3463
|
const out = c.addMfu(mfu(1, 9, 17, 5, [6, 7, 8, 9, 10], 1001n, false));
|
|
3450
3464
|
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
|
|
3451
3465
|
});
|
|
3466
|
+
test("a size handed with the data unit completes a sample no head registered", () => {
|
|
3467
|
+
const c = combiner({ requireAuthoredSize: true });
|
|
3468
|
+
const out = c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5);
|
|
3469
|
+
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5]));
|
|
3470
|
+
expect(c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5)).toBeNull();
|
|
3471
|
+
});
|
|
3452
3472
|
test("duplicate offset is rejected", () => {
|
|
3453
3473
|
const c = combiner();
|
|
3454
3474
|
c.registerAuthoredSize(void 0, 1, 9, 17, 10);
|
|
@@ -5400,6 +5420,7 @@ function isFmp4Box(data) {
|
|
|
5400
5420
|
const type = String.fromCharCode(data[4], data[5], data[6], data[7]);
|
|
5401
5421
|
return FMPU_BOX_TYPES.has(type);
|
|
5402
5422
|
}
|
|
5423
|
+
var MAX_AWAITING_TIMING_HEADS = 8;
|
|
5403
5424
|
var MmtpContainerParser = class _MmtpContainerParser {
|
|
5404
5425
|
constructor(config) {
|
|
5405
5426
|
this.#tracks = /* @__PURE__ */ new Map();
|
|
@@ -5458,6 +5479,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5458
5479
|
* reordering into the parser. */
|
|
5459
5480
|
this.#reliableMoqStartupGate = /* @__PURE__ */ new Map();
|
|
5460
5481
|
this.#disposed = false;
|
|
5482
|
+
this.#replayingAwaitingTiming = false;
|
|
5461
5483
|
this.#fedObjects = 0;
|
|
5462
5484
|
this.#reassemblerFragmentsFed = 0;
|
|
5463
5485
|
this.#reassemblerDataUnitsReturned = 0;
|
|
@@ -5550,6 +5572,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5550
5572
|
#reorderStats;
|
|
5551
5573
|
#reliableMoqStartupGate;
|
|
5552
5574
|
#disposed;
|
|
5575
|
+
#replayingAwaitingTiming;
|
|
5553
5576
|
#fedObjects;
|
|
5554
5577
|
#reassemblerFragmentsFed;
|
|
5555
5578
|
#reassemblerDataUnitsReturned;
|
|
@@ -5799,7 +5822,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5799
5822
|
* a single failure bucket. Returns null so call sites stay `return this.#drop(...)`.
|
|
5800
5823
|
*/
|
|
5801
5824
|
#drop(reason) {
|
|
5802
|
-
this.#
|
|
5825
|
+
if (this.#replayingAwaitingTiming) this.#countDeferredOutcome(reason);
|
|
5826
|
+
else this.#countOutcome(`drop:${reason}`);
|
|
5803
5827
|
return null;
|
|
5804
5828
|
}
|
|
5805
5829
|
get reorderDiagnostics() {
|
|
@@ -5822,6 +5846,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5822
5846
|
for (const combiner of this.#sampleCombiners.values()) {
|
|
5823
5847
|
combiner.cleanupTimeouts(timeoutMs);
|
|
5824
5848
|
}
|
|
5849
|
+
const now = Date.now();
|
|
5850
|
+
for (const { awaitingTiming } of this.#timingStreams.values()) {
|
|
5851
|
+
while (awaitingTiming.length > 0 && now - awaitingTiming[0].arrivedAt > timeoutMs) {
|
|
5852
|
+
awaitingTiming.shift();
|
|
5853
|
+
}
|
|
5854
|
+
}
|
|
5825
5855
|
}
|
|
5826
5856
|
/**
|
|
5827
5857
|
* Phase 1 of two-phase parsing. Returns structured header info for FEC feeding.
|
|
@@ -5902,7 +5932,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5902
5932
|
byteLength: packet.byteLength
|
|
5903
5933
|
};
|
|
5904
5934
|
}
|
|
5905
|
-
if (info.fecPayloadId !== null && this.#sourceSymbolCb) {
|
|
5935
|
+
if (info.fecPayloadId !== null && this.#sourceSymbolCb && !this.#replayingAwaitingTiming) {
|
|
5906
5936
|
const rawSymbol = packet.subarray(0, packet.length - 4);
|
|
5907
5937
|
try {
|
|
5908
5938
|
this.#sourceSymbolCb(info.packetId, info.fecPayloadId.ssId, rawSymbol);
|
|
@@ -5950,6 +5980,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5950
5980
|
}
|
|
5951
5981
|
return this.#drop("fragment-timing-refused");
|
|
5952
5982
|
}
|
|
5983
|
+
this.#replayAwaitingTiming(streamKey, resolver2);
|
|
5953
5984
|
return {
|
|
5954
5985
|
kind: "fragment",
|
|
5955
5986
|
packet: info,
|
|
@@ -5973,7 +6004,18 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5973
6004
|
mfuDuHeader.movieFragmentSequenceNumber,
|
|
5974
6005
|
mfuDuHeader.sampleNumber
|
|
5975
6006
|
);
|
|
5976
|
-
if (!headTiming)
|
|
6007
|
+
if (!headTiming) {
|
|
6008
|
+
this.#awaitTiming(streamKey, {
|
|
6009
|
+
packet,
|
|
6010
|
+
options,
|
|
6011
|
+
parsed,
|
|
6012
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
6013
|
+
movieFragmentSequenceNumber: mfuDuHeader.movieFragmentSequenceNumber,
|
|
6014
|
+
sampleNumber: mfuDuHeader.sampleNumber,
|
|
6015
|
+
arrivedAt: Date.now()
|
|
6016
|
+
});
|
|
6017
|
+
return this.#drop("mfu-sample-timing-missing");
|
|
6018
|
+
}
|
|
5977
6019
|
const offset = mfuDuHeader.offset;
|
|
5978
6020
|
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= headTiming.size)
|
|
5979
6021
|
return this.#drop("mfu-offset-out-of-range");
|
|
@@ -6049,16 +6091,17 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6049
6091
|
const sampleNumber = assembled.sampleNumber;
|
|
6050
6092
|
if (movieFragmentSequenceNumber === void 0 || sampleNumber === void 0)
|
|
6051
6093
|
return this.#drop("assembled-identity-missing");
|
|
6052
|
-
|
|
6094
|
+
const assembledTiming = resolver.sampleTiming(
|
|
6053
6095
|
assembled.mpuSequenceNumber,
|
|
6054
6096
|
movieFragmentSequenceNumber,
|
|
6055
6097
|
sampleNumber
|
|
6056
|
-
)
|
|
6098
|
+
);
|
|
6099
|
+
if (!assembledTiming) return this.#drop("assembled-timing-missing");
|
|
6057
6100
|
if (assembled.mpuSequenceNumber !== mpu.mpuSequenceNumber)
|
|
6058
6101
|
return this.#drop("assembled-mpu-mismatch");
|
|
6059
6102
|
let combined;
|
|
6060
6103
|
try {
|
|
6061
|
-
combined = this.#sampleCombinerFor(streamKey).addMfu(assembled);
|
|
6104
|
+
combined = this.#sampleCombinerFor(streamKey).addMfu(assembled, assembledTiming.size);
|
|
6062
6105
|
} catch (error) {
|
|
6063
6106
|
if (!(error instanceof SampleCombineError)) throw error;
|
|
6064
6107
|
console.warn(
|
|
@@ -6367,9 +6410,37 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6367
6410
|
if (existing) return existing.resolver;
|
|
6368
6411
|
if (!create) return null;
|
|
6369
6412
|
const resolver = new IsoBmffTimingResolver(this.#maxPendingTimingSamples);
|
|
6370
|
-
this.#timingStreams.set(streamKey, { packetId, resolver });
|
|
6413
|
+
this.#timingStreams.set(streamKey, { packetId, resolver, awaitingTiming: [] });
|
|
6371
6414
|
return resolver;
|
|
6372
6415
|
}
|
|
6416
|
+
#awaitTiming(streamKey, head) {
|
|
6417
|
+
const awaitingTiming = this.#timingStreams.get(streamKey)?.awaitingTiming;
|
|
6418
|
+
if (!awaitingTiming) return;
|
|
6419
|
+
awaitingTiming.push(head);
|
|
6420
|
+
if (awaitingTiming.length > MAX_AWAITING_TIMING_HEADS) awaitingTiming.shift();
|
|
6421
|
+
}
|
|
6422
|
+
/**
|
|
6423
|
+
* Feed again the heads whose timing the FT=1 just admitted declares. That
|
|
6424
|
+
* FT=1 can be an FEC recovery landing after its sample's FI=1, and neither
|
|
6425
|
+
* FEC path routes a source symbol that already arrived a second time.
|
|
6426
|
+
*/
|
|
6427
|
+
#replayAwaitingTiming(streamKey, resolver) {
|
|
6428
|
+
const state = this.#timingStreams.get(streamKey);
|
|
6429
|
+
if (!state || state.awaitingTiming.length === 0) return;
|
|
6430
|
+
const ready = state.awaitingTiming.filter((head) => resolver.sampleTiming(
|
|
6431
|
+
head.mpuSequenceNumber,
|
|
6432
|
+
head.movieFragmentSequenceNumber,
|
|
6433
|
+
head.sampleNumber
|
|
6434
|
+
));
|
|
6435
|
+
if (ready.length === 0) return;
|
|
6436
|
+
state.awaitingTiming = state.awaitingTiming.filter((head) => !ready.includes(head));
|
|
6437
|
+
this.#replayingAwaitingTiming = true;
|
|
6438
|
+
try {
|
|
6439
|
+
for (const head of ready) this.#feed(head.packet, head.options, head.parsed);
|
|
6440
|
+
} finally {
|
|
6441
|
+
this.#replayingAwaitingTiming = false;
|
|
6442
|
+
}
|
|
6443
|
+
}
|
|
6373
6444
|
#dropTimingStream(streamKey) {
|
|
6374
6445
|
const state = this.#timingStreams.get(streamKey);
|
|
6375
6446
|
if (!state) return;
|