@blockcast/mmt-container 0.4.0-main.bb90ce9247fa → 0.4.0-main.bbd83cb48eff
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 -3
- package/dist/browser-runtime.js +532 -333
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +5 -3
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +18 -5
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +5 -2
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +100 -36
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/catalog-network-source.js +3 -0
- package/dist/catalog-network-source.js.map +3 -3
- package/dist/delivery-catalog.js +84 -220
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +15 -0
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +99 -39
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-state.d.ts +3 -2
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +16 -9
- package/dist/fec-state.js.map +4 -4
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +13 -2
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.js +3 -0
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +24 -13
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +96 -22
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +124 -36
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +96 -22
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +14 -4
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +139 -22
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-input.js +3 -0
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +49 -0
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +437 -302
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +6 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +93 -224
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +24 -13
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.js +123 -35
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.js +3 -0
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.js +3 -0
- package/dist/repair-layers.js.map +3 -3
- 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.js +3 -0
- package/dist/signaling.js.map +3 -3
- package/dist/timestamp-codec.js +24 -13
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +3 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +96 -22
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/src/carp-catalog.ts +33 -10
- package/src/catalog-fec-params.ts +38 -17
- package/src/fec-manager.ts +111 -49
- package/src/fec-state.ts +4 -9
- package/src/fec-worker-setup.ts +16 -1
- package/src/index.ts +5 -0
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-router.ts +76 -5
- package/src/multicast-manager.ts +143 -7
- package/src/multicast-transport.ts +14 -3
- package/src/sample-combiner.ts +15 -2
- package/test-vectors/catalog/README.md +5 -1
- package/test-vectors/catalog-validation.json +95 -0
|
@@ -209,26 +209,30 @@ var BlockcastMmt = (() => {
|
|
|
209
209
|
const authLength = view2.getUint16(2, false);
|
|
210
210
|
return start + LEGACY_TRAILER_HEADER_SIZE + authLength === end;
|
|
211
211
|
}
|
|
212
|
-
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options) {
|
|
212
|
+
function resolveDeclaredTrailers(payload, declaredEnd, fecType, options, rapFlag = false) {
|
|
213
213
|
if (declaredEnd > payload.length)
|
|
214
214
|
return null;
|
|
215
215
|
if (options?.skipFecId) {
|
|
216
|
-
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false } : null;
|
|
216
|
+
return isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length) ? { hasFecId: false, hasOverlayFecId: false } : null;
|
|
217
217
|
}
|
|
218
|
+
const overlay = options?.overlayDeclared === true && rapFlag;
|
|
218
219
|
if (fecType === 1) {
|
|
219
|
-
const fecStart = payload.length -
|
|
220
|
+
const fecStart = payload.length - sourceFecTrailerSize(overlay);
|
|
220
221
|
if (fecStart < declaredEnd || !isEmptyOrExactLegacyTrailer(payload, declaredEnd, fecStart)) {
|
|
221
222
|
return null;
|
|
222
223
|
}
|
|
223
|
-
return { hasFecId: true };
|
|
224
|
+
return { hasFecId: true, hasOverlayFecId: overlay };
|
|
224
225
|
}
|
|
225
|
-
if (fecType !== 0)
|
|
226
|
+
if (fecType !== 0 || overlay)
|
|
226
227
|
return null;
|
|
227
228
|
if (isEmptyOrExactLegacyTrailer(payload, declaredEnd, payload.length)) {
|
|
228
|
-
return { hasFecId: false };
|
|
229
|
+
return { hasFecId: false, hasOverlayFecId: false };
|
|
229
230
|
}
|
|
230
231
|
return null;
|
|
231
232
|
}
|
|
233
|
+
function sourceFecTrailerSize(overlay) {
|
|
234
|
+
return overlay ? 2 * SOURCE_FEC_PAYLOAD_ID_SIZE : SOURCE_FEC_PAYLOAD_ID_SIZE;
|
|
235
|
+
}
|
|
232
236
|
function planMfuExtraction(mmtpPacket, options, parsedHeader) {
|
|
233
237
|
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE) {
|
|
234
238
|
return {
|
|
@@ -281,15 +285,16 @@ var BlockcastMmt = (() => {
|
|
|
281
285
|
if ("rejection" in layoutResult)
|
|
282
286
|
return layoutResult;
|
|
283
287
|
const { layout } = layoutResult;
|
|
284
|
-
const trailerLayout = resolveDeclaredTrailers(payload, layout.dataEnd, header.fecType, options);
|
|
288
|
+
const trailerLayout = resolveDeclaredTrailers(payload, layout.dataEnd, header.fecType, options, header.rapFlag);
|
|
285
289
|
if (!trailerLayout) {
|
|
286
290
|
if (!options?.skipFecId && header.fecType === 1) {
|
|
287
291
|
const observed = payload.length - layout.dataEnd;
|
|
288
|
-
|
|
292
|
+
const expected = sourceFecTrailerSize(options?.overlayDeclared === true && header.rapFlag);
|
|
293
|
+
if (observed !== expected) {
|
|
289
294
|
return {
|
|
290
295
|
rejection: {
|
|
291
296
|
gate: "source-fec-payload-id-width-mismatch",
|
|
292
|
-
detail: `producer wrote a ${observed}-byte Source FEC Payload ID, ISO/IEC 23008-1 \xA7C.5.2 requires ${
|
|
297
|
+
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})`
|
|
293
298
|
}
|
|
294
299
|
};
|
|
295
300
|
}
|
|
@@ -316,10 +321,13 @@ var BlockcastMmt = (() => {
|
|
|
316
321
|
const mfuDuHeader = mfuDuHeaderPresent && mpu.timedFlag === 1 ? parseTimedMfuDuHeader(payload, MPU_HEADER_SIZE) : null;
|
|
317
322
|
const itemId = mfuDuHeaderPresent && mpu.timedFlag === 0 ? new DataView(payload.buffer, payload.byteOffset + MPU_HEADER_SIZE, 4).getUint32(0, false) : null;
|
|
318
323
|
const data = payload.subarray(mfuOffset, dataEnd);
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
324
|
+
const trailerStart = mmtpPacket.length - sourceFecTrailerSize(trailerLayout.hasOverlayFecId);
|
|
325
|
+
const ssIdAt = (offset) => ({
|
|
326
|
+
ssId: new DataView(mmtpPacket.buffer, mmtpPacket.byteOffset + offset, 4).getUint32(0, false)
|
|
327
|
+
});
|
|
328
|
+
const fecPayloadId = trailerLayout.hasFecId ? ssIdAt(trailerStart) : null;
|
|
329
|
+
const overlayFecPayloadId = trailerLayout.hasOverlayFecId ? ssIdAt(trailerStart + SOURCE_FEC_PAYLOAD_ID_SIZE) : null;
|
|
330
|
+
return { header, mpu, fragmentType, data, mfuDuHeader, itemId, fecPayloadId, overlayFecPayloadId };
|
|
323
331
|
}
|
|
324
332
|
function sourceFecPayloadIdOf(mmtpPacket, header) {
|
|
325
333
|
if (mmtpPacket.length < MMTP_HEADER_SIZE + MPU_HEADER_SIZE)
|
|
@@ -365,6 +373,19 @@ var BlockcastMmt = (() => {
|
|
|
365
373
|
throw new Error(`${where} must be "iso-ssbg1-v1" (got ${JSON.stringify(value)})`);
|
|
366
374
|
}
|
|
367
375
|
|
|
376
|
+
// ../mmt-base/dist/catalog-fec-source.js
|
|
377
|
+
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
378
|
+
function recordOf(value) {
|
|
379
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
380
|
+
}
|
|
381
|
+
function isoBlockSpanUsable(fec) {
|
|
382
|
+
const block = recordOf(fec);
|
|
383
|
+
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1")
|
|
384
|
+
return true;
|
|
385
|
+
const ms = block["interleaveDepthMs"];
|
|
386
|
+
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
387
|
+
}
|
|
388
|
+
|
|
368
389
|
// src/mfu-reassembler.ts
|
|
369
390
|
function fragmentProvenance(fragment) {
|
|
370
391
|
if (fragment.deliveryProvenance !== void 0) return fragment.deliveryProvenance;
|
|
@@ -3207,8 +3228,14 @@ var BlockcastMmt = (() => {
|
|
|
3207
3228
|
/**
|
|
3208
3229
|
* Add one reassembled data unit. Returns the combined sample once every
|
|
3209
3230
|
* constituent data unit has arrived and totals the authored size.
|
|
3231
|
+
*
|
|
3232
|
+
* `sampleSize` is the authored size the host resolves for the sample as the
|
|
3233
|
+
* data unit completes. It stands in only when no size was registered, which
|
|
3234
|
+
* happens when the data unit's FI=0/FI=1 reached the reassembler without the
|
|
3235
|
+
* host's own FT=2 parse: an FEC-recovered first fragment completed by source
|
|
3236
|
+
* fragments, or one decoded before its source copy arrived.
|
|
3210
3237
|
*/
|
|
3211
|
-
addMfu(mfu) {
|
|
3238
|
+
addMfu(mfu, sampleSize) {
|
|
3212
3239
|
if (mfu.movieFragmentSequenceNumber === void 0 || mfu.sampleNumber === void 0) {
|
|
3213
3240
|
__privateGet(this, _stats).passthroughSamples++;
|
|
3214
3241
|
return fromPassthrough(mfu);
|
|
@@ -3224,7 +3251,7 @@ var BlockcastMmt = (() => {
|
|
|
3224
3251
|
return null;
|
|
3225
3252
|
}
|
|
3226
3253
|
const dataLen = mfu.data.byteLength;
|
|
3227
|
-
const authoredSize = __privateGet(this, _authoredSizes).get(key);
|
|
3254
|
+
const authoredSize = __privateGet(this, _authoredSizes).get(key) ?? sampleSize;
|
|
3228
3255
|
if (offset === 0 && !__privateGet(this, _pending).has(key)) {
|
|
3229
3256
|
const passesThrough = authoredSize === void 0 ? !__privateGet(this, _requireAuthoredSize) : dataLen === authoredSize;
|
|
3230
3257
|
if (passesThrough) {
|
|
@@ -3532,6 +3559,12 @@ var BlockcastMmt = (() => {
|
|
|
3532
3559
|
const out = c.addMfu(mfu(1, 9, 17, 5, [6, 7, 8, 9, 10], 1001n, false));
|
|
3533
3560
|
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
|
|
3534
3561
|
});
|
|
3562
|
+
test("a size handed with the data unit completes a sample no head registered", () => {
|
|
3563
|
+
const c = combiner({ requireAuthoredSize: true });
|
|
3564
|
+
const out = c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5);
|
|
3565
|
+
expect(out?.data).toEqual(new Uint8Array([1, 2, 3, 4, 5]));
|
|
3566
|
+
expect(c.addMfu(mfu(1, 9, 17, 0, [1, 2, 3, 4, 5], 1000n, true), 5)).toBeNull();
|
|
3567
|
+
});
|
|
3535
3568
|
test("duplicate offset is rejected", () => {
|
|
3536
3569
|
const c = combiner();
|
|
3537
3570
|
c.registerAuthoredSize(void 0, 1, 9, 17, 10);
|
|
@@ -5519,7 +5552,8 @@ var BlockcastMmt = (() => {
|
|
|
5519
5552
|
const type = String.fromCharCode(data[4], data[5], data[6], data[7]);
|
|
5520
5553
|
return FMPU_BOX_TYPES.has(type);
|
|
5521
5554
|
}
|
|
5522
|
-
var
|
|
5555
|
+
var MAX_AWAITING_TIMING_HEADS = 8;
|
|
5556
|
+
var _tracks, _defaultTrack, _reassembler, _sampleCombiners, _sampleCombinerOptions, _retiredSampleCombinerStats, _timingStreams, _maxPendingTimingSamples, _pendingTimingSamples, _reclaimedTimingSamples, _evictedTimingSamples, _rejectedMovieFragments, _sequencers, _fecGate, _fecSequencer, _reorderWindow, _reassemblyPolicy, _frameCb, _initCb, _sourceSymbolCb, _trackFrameCbs, _reorderStats, _reliableMoqStartupGate, _disposed, _replayingAwaitingTiming, _fedObjects, _reassemblerFragmentsFed, _reassemblerDataUnitsReturned, _feedOutcomes, _deferredFeedOutcomes, _lastOutcome, _lastOutcomeCount, _MmtpContainerParser_instances, streamKey_fn, sampleCombinerFor_fn, releaseTimingSlot_fn, dropSampleCombiner_fn, countOutcome_fn, countDeferredOutcome_fn, drop_fn, feedCounted_fn, feed_fn, emitCombinedSample_fn, passReliableMoqStartupGate_fn, timingResolver_fn, awaitTiming_fn, replayAwaitingTiming_fn, dropTimingStream_fn, validateReassemblyPolicy_fn, buildFrameMeta_fn, sequencerFor_fn, flushSequencers_fn, emitFrame_fn2, _MmtpContainerParser_static, scanForKeyframe_fn, scanLengthPrefixedHevcForKeyframe_fn, scanAnnexBForKeyframe_fn;
|
|
5523
5557
|
var _MmtpContainerParser = class _MmtpContainerParser {
|
|
5524
5558
|
constructor(config) {
|
|
5525
5559
|
__privateAdd(this, _MmtpContainerParser_instances);
|
|
@@ -5582,6 +5616,7 @@ var BlockcastMmt = (() => {
|
|
|
5582
5616
|
* reordering into the parser. */
|
|
5583
5617
|
__privateAdd(this, _reliableMoqStartupGate, /* @__PURE__ */ new Map());
|
|
5584
5618
|
__privateAdd(this, _disposed, false);
|
|
5619
|
+
__privateAdd(this, _replayingAwaitingTiming, false);
|
|
5585
5620
|
__privateAdd(this, _fedObjects, 0);
|
|
5586
5621
|
__privateAdd(this, _reassemblerFragmentsFed, 0);
|
|
5587
5622
|
__privateAdd(this, _reassemblerDataUnitsReturned, 0);
|
|
@@ -5840,6 +5875,12 @@ var BlockcastMmt = (() => {
|
|
|
5840
5875
|
for (const combiner of __privateGet(this, _sampleCombiners).values()) {
|
|
5841
5876
|
combiner.cleanupTimeouts(timeoutMs);
|
|
5842
5877
|
}
|
|
5878
|
+
const now = Date.now();
|
|
5879
|
+
for (const { awaitingTiming } of __privateGet(this, _timingStreams).values()) {
|
|
5880
|
+
while (awaitingTiming.length > 0 && now - awaitingTiming[0].arrivedAt > timeoutMs) {
|
|
5881
|
+
awaitingTiming.shift();
|
|
5882
|
+
}
|
|
5883
|
+
}
|
|
5843
5884
|
}
|
|
5844
5885
|
/**
|
|
5845
5886
|
* Phase 1 of two-phase parsing. Returns structured header info for FEC feeding.
|
|
@@ -6126,6 +6167,7 @@ var BlockcastMmt = (() => {
|
|
|
6126
6167
|
_reorderStats = new WeakMap();
|
|
6127
6168
|
_reliableMoqStartupGate = new WeakMap();
|
|
6128
6169
|
_disposed = new WeakMap();
|
|
6170
|
+
_replayingAwaitingTiming = new WeakMap();
|
|
6129
6171
|
_fedObjects = new WeakMap();
|
|
6130
6172
|
_reassemblerFragmentsFed = new WeakMap();
|
|
6131
6173
|
_reassemblerDataUnitsReturned = new WeakMap();
|
|
@@ -6206,7 +6248,8 @@ var BlockcastMmt = (() => {
|
|
|
6206
6248
|
* a single failure bucket. Returns null so call sites stay `return this.#drop(...)`.
|
|
6207
6249
|
*/
|
|
6208
6250
|
drop_fn = function(reason) {
|
|
6209
|
-
__privateMethod(this, _MmtpContainerParser_instances,
|
|
6251
|
+
if (__privateGet(this, _replayingAwaitingTiming)) __privateMethod(this, _MmtpContainerParser_instances, countDeferredOutcome_fn).call(this, reason);
|
|
6252
|
+
else __privateMethod(this, _MmtpContainerParser_instances, countOutcome_fn).call(this, `drop:${reason}`);
|
|
6210
6253
|
return null;
|
|
6211
6254
|
};
|
|
6212
6255
|
feedCounted_fn = function(packet, options, parsed) {
|
|
@@ -6235,7 +6278,7 @@ var BlockcastMmt = (() => {
|
|
|
6235
6278
|
byteLength: packet.byteLength
|
|
6236
6279
|
};
|
|
6237
6280
|
}
|
|
6238
|
-
if (info.fecPayloadId !== null && __privateGet(this, _sourceSymbolCb)) {
|
|
6281
|
+
if (info.fecPayloadId !== null && __privateGet(this, _sourceSymbolCb) && !__privateGet(this, _replayingAwaitingTiming)) {
|
|
6239
6282
|
const rawSymbol = packet.subarray(0, packet.length - 4);
|
|
6240
6283
|
try {
|
|
6241
6284
|
__privateGet(this, _sourceSymbolCb).call(this, info.packetId, info.fecPayloadId.ssId, rawSymbol);
|
|
@@ -6283,6 +6326,7 @@ var BlockcastMmt = (() => {
|
|
|
6283
6326
|
}
|
|
6284
6327
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-timing-refused");
|
|
6285
6328
|
}
|
|
6329
|
+
__privateMethod(this, _MmtpContainerParser_instances, replayAwaitingTiming_fn).call(this, streamKey, resolver2);
|
|
6286
6330
|
return {
|
|
6287
6331
|
kind: "fragment",
|
|
6288
6332
|
packet: info,
|
|
@@ -6306,7 +6350,18 @@ var BlockcastMmt = (() => {
|
|
|
6306
6350
|
mfuDuHeader.movieFragmentSequenceNumber,
|
|
6307
6351
|
mfuDuHeader.sampleNumber
|
|
6308
6352
|
);
|
|
6309
|
-
if (!headTiming)
|
|
6353
|
+
if (!headTiming) {
|
|
6354
|
+
__privateMethod(this, _MmtpContainerParser_instances, awaitTiming_fn).call(this, streamKey, {
|
|
6355
|
+
packet,
|
|
6356
|
+
options,
|
|
6357
|
+
parsed,
|
|
6358
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
6359
|
+
movieFragmentSequenceNumber: mfuDuHeader.movieFragmentSequenceNumber,
|
|
6360
|
+
sampleNumber: mfuDuHeader.sampleNumber,
|
|
6361
|
+
arrivedAt: Date.now()
|
|
6362
|
+
});
|
|
6363
|
+
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-sample-timing-missing");
|
|
6364
|
+
}
|
|
6310
6365
|
const offset = mfuDuHeader.offset;
|
|
6311
6366
|
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= headTiming.size)
|
|
6312
6367
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-offset-out-of-range");
|
|
@@ -6376,16 +6431,17 @@ var BlockcastMmt = (() => {
|
|
|
6376
6431
|
const sampleNumber = assembled.sampleNumber;
|
|
6377
6432
|
if (movieFragmentSequenceNumber === void 0 || sampleNumber === void 0)
|
|
6378
6433
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "assembled-identity-missing");
|
|
6379
|
-
|
|
6434
|
+
const assembledTiming = resolver.sampleTiming(
|
|
6380
6435
|
assembled.mpuSequenceNumber,
|
|
6381
6436
|
movieFragmentSequenceNumber,
|
|
6382
6437
|
sampleNumber
|
|
6383
|
-
)
|
|
6438
|
+
);
|
|
6439
|
+
if (!assembledTiming) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "assembled-timing-missing");
|
|
6384
6440
|
if (assembled.mpuSequenceNumber !== mpu.mpuSequenceNumber)
|
|
6385
6441
|
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "assembled-mpu-mismatch");
|
|
6386
6442
|
let combined;
|
|
6387
6443
|
try {
|
|
6388
|
-
combined = __privateMethod(this, _MmtpContainerParser_instances, sampleCombinerFor_fn).call(this, streamKey).addMfu(assembled);
|
|
6444
|
+
combined = __privateMethod(this, _MmtpContainerParser_instances, sampleCombinerFor_fn).call(this, streamKey).addMfu(assembled, assembledTiming.size);
|
|
6389
6445
|
} catch (error) {
|
|
6390
6446
|
if (!(error instanceof SampleCombineError)) throw error;
|
|
6391
6447
|
console.warn(
|
|
@@ -6479,9 +6535,37 @@ var BlockcastMmt = (() => {
|
|
|
6479
6535
|
if (existing) return existing.resolver;
|
|
6480
6536
|
if (!create) return null;
|
|
6481
6537
|
const resolver = new IsoBmffTimingResolver(__privateGet(this, _maxPendingTimingSamples));
|
|
6482
|
-
__privateGet(this, _timingStreams).set(streamKey, { packetId, resolver });
|
|
6538
|
+
__privateGet(this, _timingStreams).set(streamKey, { packetId, resolver, awaitingTiming: [] });
|
|
6483
6539
|
return resolver;
|
|
6484
6540
|
};
|
|
6541
|
+
awaitTiming_fn = function(streamKey, head) {
|
|
6542
|
+
const awaitingTiming = __privateGet(this, _timingStreams).get(streamKey)?.awaitingTiming;
|
|
6543
|
+
if (!awaitingTiming) return;
|
|
6544
|
+
awaitingTiming.push(head);
|
|
6545
|
+
if (awaitingTiming.length > MAX_AWAITING_TIMING_HEADS) awaitingTiming.shift();
|
|
6546
|
+
};
|
|
6547
|
+
/**
|
|
6548
|
+
* Feed again the heads whose timing the FT=1 just admitted declares. That
|
|
6549
|
+
* FT=1 can be an FEC recovery landing after its sample's FI=1, and neither
|
|
6550
|
+
* FEC path routes a source symbol that already arrived a second time.
|
|
6551
|
+
*/
|
|
6552
|
+
replayAwaitingTiming_fn = function(streamKey, resolver) {
|
|
6553
|
+
const state = __privateGet(this, _timingStreams).get(streamKey);
|
|
6554
|
+
if (!state || state.awaitingTiming.length === 0) return;
|
|
6555
|
+
const ready = state.awaitingTiming.filter((head) => resolver.sampleTiming(
|
|
6556
|
+
head.mpuSequenceNumber,
|
|
6557
|
+
head.movieFragmentSequenceNumber,
|
|
6558
|
+
head.sampleNumber
|
|
6559
|
+
));
|
|
6560
|
+
if (ready.length === 0) return;
|
|
6561
|
+
state.awaitingTiming = state.awaitingTiming.filter((head) => !ready.includes(head));
|
|
6562
|
+
__privateSet(this, _replayingAwaitingTiming, true);
|
|
6563
|
+
try {
|
|
6564
|
+
for (const head of ready) __privateMethod(this, _MmtpContainerParser_instances, feed_fn).call(this, head.packet, head.options, head.parsed);
|
|
6565
|
+
} finally {
|
|
6566
|
+
__privateSet(this, _replayingAwaitingTiming, false);
|
|
6567
|
+
}
|
|
6568
|
+
};
|
|
6485
6569
|
dropTimingStream_fn = function(streamKey) {
|
|
6486
6570
|
const state = __privateGet(this, _timingStreams).get(streamKey);
|
|
6487
6571
|
if (!state) return;
|
|
@@ -7740,11 +7824,21 @@ var BlockcastMmt = (() => {
|
|
|
7740
7824
|
const timescale = BigInt(track["timescale"]);
|
|
7741
7825
|
const durationTicks = track["groupDurationTicks"];
|
|
7742
7826
|
const ticks = durationTicks !== void 0 ? BigInt(durationTicks) : BigInt(track["groupDurationMs"]) * timescale / 1000n;
|
|
7743
|
-
const
|
|
7744
|
-
|
|
7745
|
-
|
|
7827
|
+
const framerate = track["framerate"];
|
|
7828
|
+
const intraOnly = positiveNumber(framerate) && Math.abs(Number(ticks) * framerate - Number(timescale)) <= Number(timescale) * 1e-3;
|
|
7829
|
+
const members = switchingSets.get(altGroup) ?? [];
|
|
7830
|
+
members.push({ index, name: track["name"], ticks, timescale, intraOnly });
|
|
7831
|
+
switchingSets.set(altGroup, members);
|
|
7832
|
+
}
|
|
7833
|
+
for (const [altGroup, members] of switchingSets) {
|
|
7834
|
+
const anchor = members.find((member) => !member.intraOnly) ?? members[0];
|
|
7835
|
+
for (const member of members) {
|
|
7836
|
+
if (member === anchor || member.ticks * anchor.timescale === anchor.ticks * member.timescale) continue;
|
|
7837
|
+
const nests = member.intraOnly && !anchor.intraOnly && anchor.ticks * member.timescale % (member.ticks * anchor.timescale) === 0n;
|
|
7838
|
+
if (!nests) {
|
|
7839
|
+
catalogError("track_switching_set", `$.tracks[${member.index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
|
|
7840
|
+
}
|
|
7746
7841
|
}
|
|
7747
|
-
if (!anchor) switchingSets.set(altGroup, { name: track["name"], ticks, timescale });
|
|
7748
7842
|
}
|
|
7749
7843
|
const multicast = catalog["multicast"];
|
|
7750
7844
|
if (typeof multicast === "object" && multicast !== null && !Array.isArray(multicast)) {
|
|
@@ -7838,23 +7932,17 @@ var BlockcastMmt = (() => {
|
|
|
7838
7932
|
"reliable-moq": Object.freeze({ state: "inactive", reason: "reliable-moq" }),
|
|
7839
7933
|
"no-multicast-bridge": Object.freeze({ state: "inactive", reason: "no-multicast-bridge" })
|
|
7840
7934
|
});
|
|
7841
|
-
function
|
|
7935
|
+
function recordOf2(value) {
|
|
7842
7936
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
7843
7937
|
}
|
|
7844
7938
|
function isPositiveSafeInteger(value) {
|
|
7845
7939
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
7846
7940
|
}
|
|
7847
7941
|
function catalogDeclaresFec(fec) {
|
|
7848
|
-
const block =
|
|
7942
|
+
const block = recordOf2(fec);
|
|
7849
7943
|
if (block === void 0 || block["algorithm"] === "none") return false;
|
|
7850
7944
|
return isPositiveSafeInteger(block["sourceSymbols"]) && isPositiveSafeInteger(block["symbolSize"]) && isFecBlockProfile(block["blockProfile"]) && isoBlockSpanUsable(block);
|
|
7851
7945
|
}
|
|
7852
|
-
function isoBlockSpanUsable(fec) {
|
|
7853
|
-
const block = recordOf(fec);
|
|
7854
|
-
if (block === void 0 || block["blockProfile"] !== "iso-ssbg1-v1") return true;
|
|
7855
|
-
const ms = block["interleaveDepthMs"];
|
|
7856
|
-
return ms === void 0 || typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0;
|
|
7857
|
-
}
|
|
7858
7946
|
function requireBoolean(value, field) {
|
|
7859
7947
|
if (typeof value !== "boolean") {
|
|
7860
7948
|
throw new TypeError(`resolveFecState: ${field} must be a boolean, got ${typeof value}`);
|
|
@@ -7869,7 +7957,7 @@ var BlockcastMmt = (() => {
|
|
|
7869
7957
|
if (typeof transportPolicy !== "string" || !TRANSPORT_POLICIES.has(transportPolicy)) {
|
|
7870
7958
|
throw new TypeError(`resolveFecState: unsupported transportPolicy ${JSON.stringify(transportPolicy)}`);
|
|
7871
7959
|
}
|
|
7872
|
-
if (stats !== null && stats !== void 0 &&
|
|
7960
|
+
if (stats !== null && stats !== void 0 && recordOf2(stats) === void 0) {
|
|
7873
7961
|
throw new TypeError("resolveFecState: stats must be a plain object, null or undefined");
|
|
7874
7962
|
}
|
|
7875
7963
|
if (!catalogFec) return INACTIVE["no-catalog-fec"];
|