@blockcast/mmt-container 0.1.0-main.6a2e0a347fdb → 0.1.0-main.6b674aa2ad97
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/dist/browser-runtime.js +218 -351
- package/dist/browser-runtime.js.map +3 -3
- package/dist/cmaf-block-assembler.js.map +1 -1
- package/dist/cmaf-group-batcher.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-bmff-timing.d.ts +6 -12
- package/dist/iso-bmff-timing.d.ts.map +1 -1
- package/dist/iso-bmff-timing.js +8 -40
- package/dist/iso-bmff-timing.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts +0 -101
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +199 -332
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +199 -332
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/mmtp-decode-pipeline.js +218 -351
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.js +199 -332
- package/dist/mmtp-router.js.map +2 -2
- package/dist/mmtp-to-cmaf.d.ts.map +1 -1
- package/dist/mmtp-to-cmaf.js.map +2 -2
- package/dist/multicast-manager.js +199 -332
- package/dist/multicast-manager.js.map +2 -2
- package/dist/no-modules.js +199 -332
- package/dist/no-modules.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +199 -332
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -6
- package/src/index.ts +0 -3
- package/src/iso-bmff-timing.ts +7 -62
- package/src/mmtp-container-parser.ts +48 -284
- package/src/mmtp-to-cmaf.ts +7 -15
package/dist/browser-runtime.js
CHANGED
|
@@ -11577,7 +11577,7 @@ function sameTrack(a, b) {
|
|
|
11577
11577
|
function sameSample(a, b) {
|
|
11578
11578
|
return a.decodeTime === b.decodeTime && a.presentationTime === b.presentationTime && a.duration === b.duration && a.timescale === b.timescale && a.size === b.size && a.bytePosition === b.bytePosition;
|
|
11579
11579
|
}
|
|
11580
|
-
var _track, _fragments, _pendingSamples,
|
|
11580
|
+
var _track, _fragments, _pendingSamples, _lastMovieFragmentRejection, _IsoBmffTimingResolver_instances, clearSlot_fn;
|
|
11581
11581
|
var IsoBmffTimingResolver = class {
|
|
11582
11582
|
constructor(maxPendingSamples) {
|
|
11583
11583
|
this.maxPendingSamples = maxPendingSamples;
|
|
@@ -11585,7 +11585,6 @@ var IsoBmffTimingResolver = class {
|
|
|
11585
11585
|
__privateAdd(this, _track, null);
|
|
11586
11586
|
__privateAdd(this, _fragments, /* @__PURE__ */ new Map());
|
|
11587
11587
|
__privateAdd(this, _pendingSamples, 0);
|
|
11588
|
-
__privateAdd(this, _evictedSamples, 0);
|
|
11589
11588
|
__privateAdd(this, _lastMovieFragmentRejection, null);
|
|
11590
11589
|
if (!Number.isInteger(maxPendingSamples) || maxPendingSamples <= 0) {
|
|
11591
11590
|
throw new Error("[IsoBmffTimingResolver] maxPendingSamples must be a positive integer");
|
|
@@ -11594,15 +11593,6 @@ var IsoBmffTimingResolver = class {
|
|
|
11594
11593
|
get pendingSampleCount() {
|
|
11595
11594
|
return __privateGet(this, _pendingSamples);
|
|
11596
11595
|
}
|
|
11597
|
-
/**
|
|
11598
|
-
* Slots reclaimed by window displacement rather than by delivery or
|
|
11599
|
-
* abandonment. Deliberately separate from the combiner's own release count:
|
|
11600
|
-
* "nobody ever saw this sample" and "the combiner gave up on it" are
|
|
11601
|
-
* different failures with different owners, and one number cannot say which.
|
|
11602
|
-
*/
|
|
11603
|
-
get evictedSampleCount() {
|
|
11604
|
-
return __privateGet(this, _evictedSamples);
|
|
11605
|
-
}
|
|
11606
11596
|
/** Typed reason for the most recent rejected movie fragment. */
|
|
11607
11597
|
get lastMovieFragmentRejection() {
|
|
11608
11598
|
return __privateGet(this, _lastMovieFragmentRejection);
|
|
@@ -11640,11 +11630,7 @@ var IsoBmffTimingResolver = class {
|
|
|
11640
11630
|
(sample, index) => sample !== null && sameSample(sample, parsed.samples[index])
|
|
11641
11631
|
);
|
|
11642
11632
|
}
|
|
11643
|
-
|
|
11644
|
-
while (__privateGet(this, _fragments).size > 0 && (__privateGet(this, _pendingSamples) + parsed.samples.length > this.maxPendingSamples || parsed.samples.length - freed > additionalSampleLimit)) {
|
|
11645
|
-
freed += __privateMethod(this, _IsoBmffTimingResolver_instances, evictOldestFragment_fn).call(this);
|
|
11646
|
-
}
|
|
11647
|
-
if (parsed.samples.length - freed > additionalSampleLimit) {
|
|
11633
|
+
if (parsed.samples.length > additionalSampleLimit) {
|
|
11648
11634
|
__privateSet(this, _lastMovieFragmentRejection, "budget");
|
|
11649
11635
|
return false;
|
|
11650
11636
|
}
|
|
@@ -11677,11 +11663,12 @@ var IsoBmffTimingResolver = class {
|
|
|
11677
11663
|
* Free the budget slot of a sample that will never be delivered.
|
|
11678
11664
|
*
|
|
11679
11665
|
* `consumeSample` is the delivery path and is the only decrement on a
|
|
11680
|
-
* healthy stream.
|
|
11681
|
-
* delivered
|
|
11682
|
-
*
|
|
11683
|
-
*
|
|
11684
|
-
*
|
|
11666
|
+
* healthy stream. But a sample whose data units never complete is never
|
|
11667
|
+
* delivered, and without this path its slot is held until `reset()` --
|
|
11668
|
+
* making `maxPendingSamples` a one-way ratchet. Once it saturates,
|
|
11669
|
+
* `addMovieFragment` rejects every subsequent moof and the stream is
|
|
11670
|
+
* wedged permanently: the consumer sees media stop with no error, and only
|
|
11671
|
+
* a full track reset clears it.
|
|
11685
11672
|
*
|
|
11686
11673
|
* The caller is whoever abandoned the sample, so the release is driven by
|
|
11687
11674
|
* the abandonment itself rather than by a timer, an LRU, or an age bound --
|
|
@@ -11705,27 +11692,8 @@ var IsoBmffTimingResolver = class {
|
|
|
11705
11692
|
_track = new WeakMap();
|
|
11706
11693
|
_fragments = new WeakMap();
|
|
11707
11694
|
_pendingSamples = new WeakMap();
|
|
11708
|
-
_evictedSamples = new WeakMap();
|
|
11709
11695
|
_lastMovieFragmentRejection = new WeakMap();
|
|
11710
11696
|
_IsoBmffTimingResolver_instances = new WeakSet();
|
|
11711
|
-
/**
|
|
11712
|
-
* Drop the oldest pending fragment whole and return the slots it held.
|
|
11713
|
-
*
|
|
11714
|
-
* Oldest is insertion order, which for a moof stream is arrival order, so
|
|
11715
|
-
* this is the least-recently-declared timing -- the entries least likely to
|
|
11716
|
-
* still have data units in flight.
|
|
11717
|
-
*/
|
|
11718
|
-
evictOldestFragment_fn = function() {
|
|
11719
|
-
const oldest = __privateGet(this, _fragments).keys().next().value;
|
|
11720
|
-
if (oldest === void 0) return 0;
|
|
11721
|
-
const samples = __privateGet(this, _fragments).get(oldest);
|
|
11722
|
-
let live = 0;
|
|
11723
|
-
for (const sample of samples) if (sample !== null) live++;
|
|
11724
|
-
__privateGet(this, _fragments).delete(oldest);
|
|
11725
|
-
__privateSet(this, _pendingSamples, __privateGet(this, _pendingSamples) - live);
|
|
11726
|
-
__privateSet(this, _evictedSamples, __privateGet(this, _evictedSamples) + live);
|
|
11727
|
-
return live;
|
|
11728
|
-
};
|
|
11729
11697
|
/** Null one slot, decrement the budget, and drop the fragment when empty. */
|
|
11730
11698
|
clearSlot_fn = function(mpuSequenceNumber, movieFragmentSequenceNumber, sampleNumber) {
|
|
11731
11699
|
if (!isU322(mpuSequenceNumber) || !isU322(movieFragmentSequenceNumber) || movieFragmentSequenceNumber === 0 || !isU322(sampleNumber) || sampleNumber === 0) {
|
|
@@ -11904,7 +11872,7 @@ function isFmp4Box(data) {
|
|
|
11904
11872
|
const type = String.fromCharCode(data[4], data[5], data[6], data[7]);
|
|
11905
11873
|
return FMPU_BOX_TYPES.has(type);
|
|
11906
11874
|
}
|
|
11907
|
-
var _tracks, _defaultTrack, _reassembler, _sampleCombiners, _sampleCombinerOptions, _retiredSampleCombinerStats, _timingStreams, _maxPendingTimingSamples, _pendingTimingSamples, _reclaimedTimingSamples,
|
|
11875
|
+
var _tracks, _defaultTrack, _reassembler, _sampleCombiners, _sampleCombinerOptions, _retiredSampleCombinerStats, _timingStreams, _maxPendingTimingSamples, _pendingTimingSamples, _reclaimedTimingSamples, _rejectedMovieFragments, _sequencers, _reorderWindow, _reassemblyPolicy, _frameCb, _initCb, _sourceSymbolCb, _trackFrameCbs, _reorderStats, _reliableMoqStartupGate, _disposed2, _MmtpContainerParser_instances, streamKey_fn2, sampleCombinerFor_fn, releaseTimingSlot_fn, dropSampleCombiner_fn, emitCombinedSample_fn, passReliableMoqStartupGate_fn, timingResolver_fn, dropTimingStream_fn, validateReassemblyPolicy_fn, buildFrameMeta_fn, sequencerFor_fn, flushSequencers_fn, emitFrame_fn2, _MmtpContainerParser_static, scanForKeyframe_fn, scanLengthPrefixedHevcForKeyframe_fn, scanAnnexBForKeyframe_fn;
|
|
11908
11876
|
var _MmtpContainerParser = class _MmtpContainerParser {
|
|
11909
11877
|
constructor(config) {
|
|
11910
11878
|
__privateAdd(this, _MmtpContainerParser_instances);
|
|
@@ -11938,7 +11906,6 @@ var _MmtpContainerParser = class _MmtpContainerParser {
|
|
|
11938
11906
|
__privateAdd(this, _maxPendingTimingSamples);
|
|
11939
11907
|
__privateAdd(this, _pendingTimingSamples, 0);
|
|
11940
11908
|
__privateAdd(this, _reclaimedTimingSamples, 0);
|
|
11941
|
-
__privateAdd(this, _evictedTimingSamples, 0);
|
|
11942
11909
|
__privateAdd(this, _rejectedMovieFragments, 0);
|
|
11943
11910
|
__privateAdd(this, _sequencers, /* @__PURE__ */ new Map());
|
|
11944
11911
|
__privateAdd(this, _reorderWindow, 0);
|
|
@@ -11965,11 +11932,6 @@ var _MmtpContainerParser = class _MmtpContainerParser {
|
|
|
11965
11932
|
* reordering into the parser. */
|
|
11966
11933
|
__privateAdd(this, _reliableMoqStartupGate, /* @__PURE__ */ new Map());
|
|
11967
11934
|
__privateAdd(this, _disposed2, false);
|
|
11968
|
-
__privateAdd(this, _fedObjects, 0);
|
|
11969
|
-
__privateAdd(this, _feedOutcomes, /* @__PURE__ */ new Map());
|
|
11970
|
-
__privateAdd(this, _deferredFeedOutcomes, /* @__PURE__ */ new Map());
|
|
11971
|
-
__privateAdd(this, _lastOutcome, null);
|
|
11972
|
-
__privateAdd(this, _lastOutcomeCount, 0);
|
|
11973
11935
|
/** Authored presentation timestamp of the last emitted frame, in microseconds. */
|
|
11974
11936
|
this.lastFrameTimestamp = void 0;
|
|
11975
11937
|
if (config?.reassemblyPolicy && config.mfuTimeoutMs !== void 0) {
|
|
@@ -12072,7 +12034,6 @@ var _MmtpContainerParser = class _MmtpContainerParser {
|
|
|
12072
12034
|
pending: __privateGet(this, _pendingTimingSamples),
|
|
12073
12035
|
capacity: __privateGet(this, _maxPendingTimingSamples),
|
|
12074
12036
|
reclaimed: __privateGet(this, _reclaimedTimingSamples),
|
|
12075
|
-
evicted: __privateGet(this, _evictedTimingSamples),
|
|
12076
12037
|
rejectedMovieFragments: __privateGet(this, _rejectedMovieFragments)
|
|
12077
12038
|
};
|
|
12078
12039
|
}
|
|
@@ -12081,36 +12042,6 @@ var _MmtpContainerParser = class _MmtpContainerParser {
|
|
|
12081
12042
|
for (const { sequencer } of __privateGet(this, _sequencers).values()) bufferedFrames += sequencer.buffered;
|
|
12082
12043
|
return { ...__privateGet(this, _reorderStats), bufferedFrames };
|
|
12083
12044
|
}
|
|
12084
|
-
/**
|
|
12085
|
-
* Feed tallies for this parser. A fresh snapshot per call, not a live view,
|
|
12086
|
-
* so a caller can hold one and compare it against a later read.
|
|
12087
|
-
*
|
|
12088
|
-
* Survives dispose() — the counters are the parser's own state and are not
|
|
12089
|
-
* cleared by teardown, because a wedged receive path is usually read after
|
|
12090
|
-
* the fact.
|
|
12091
|
-
*/
|
|
12092
|
-
get feedStats() {
|
|
12093
|
-
return {
|
|
12094
|
-
fedObjects: __privateGet(this, _fedObjects),
|
|
12095
|
-
outcomes: Object.fromEntries(__privateGet(this, _feedOutcomes)),
|
|
12096
|
-
deferredOutcomes: Object.fromEntries(__privateGet(this, _deferredFeedOutcomes))
|
|
12097
|
-
};
|
|
12098
|
-
}
|
|
12099
|
-
/**
|
|
12100
|
-
* Outcome token of the most recent feed(), or null before the first call.
|
|
12101
|
-
*
|
|
12102
|
-
* Exposed alongside `lastFeedOutcomeCount` as two scalars rather than one
|
|
12103
|
-
* object because a wrapper reads them on every packet, and feedStats()
|
|
12104
|
-
* allocates a fresh snapshot per call.
|
|
12105
|
-
*/
|
|
12106
|
-
get lastFeedOutcome() {
|
|
12107
|
-
return __privateGet(this, _lastOutcome);
|
|
12108
|
-
}
|
|
12109
|
-
/** How many times `lastFeedOutcome` has now been seen. 1 on its first
|
|
12110
|
-
* occurrence, which is what a caller logging once per novel outcome needs. */
|
|
12111
|
-
get lastFeedOutcomeCount() {
|
|
12112
|
-
return __privateGet(this, _lastOutcomeCount);
|
|
12113
|
-
}
|
|
12114
12045
|
get reorderDiagnostics() {
|
|
12115
12046
|
const streams = [];
|
|
12116
12047
|
for (const { packetId, sequencer } of __privateGet(this, _sequencers).values()) {
|
|
@@ -12160,16 +12091,181 @@ var _MmtpContainerParser = class _MmtpContainerParser {
|
|
|
12160
12091
|
}
|
|
12161
12092
|
/** Feed a complete MMTP packet. For two-phase use, call parseHeader() first. */
|
|
12162
12093
|
feed(packet, options) {
|
|
12163
|
-
|
|
12164
|
-
|
|
12094
|
+
var _a;
|
|
12095
|
+
if (__privateGet(this, _disposed2)) return null;
|
|
12096
|
+
this.cleanupTimeouts();
|
|
12097
|
+
const info = this.parseHeader(packet, options);
|
|
12098
|
+
if (!info) return null;
|
|
12099
|
+
if (info.packetType !== PACKET_TYPE_MPU2) {
|
|
12100
|
+
return {
|
|
12101
|
+
kind: info.isRepair ? "repair" : "non-media",
|
|
12102
|
+
packet: info,
|
|
12103
|
+
byteLength: packet.byteLength
|
|
12104
|
+
};
|
|
12105
|
+
}
|
|
12106
|
+
if (info.fecPayloadId !== null && __privateGet(this, _sourceSymbolCb)) {
|
|
12107
|
+
const rawSymbol = packet.subarray(0, packet.length - 4);
|
|
12108
|
+
const altaTrailer = extractAltaTrailer2(packet);
|
|
12109
|
+
const alta = altaTrailer ? { auth: altaTrailer.auth, payloadEnd: altaTrailer.signedEnd } : void 0;
|
|
12110
|
+
try {
|
|
12111
|
+
__privateGet(this, _sourceSymbolCb).call(this, info.packetId, info.fecPayloadId.ssId, rawSymbol, alta);
|
|
12112
|
+
} catch {
|
|
12113
|
+
}
|
|
12114
|
+
}
|
|
12115
|
+
const extraction = extractMFUPayload(packet, {
|
|
12116
|
+
skipFecId: options?.skipFecPayloadId
|
|
12117
|
+
});
|
|
12118
|
+
if (!extraction) return null;
|
|
12119
|
+
const { mpu, fragmentType, data, mfuDuHeader } = extraction;
|
|
12120
|
+
if (mpu.timedFlag !== 1) return null;
|
|
12121
|
+
const streamKey = __privateMethod(this, _MmtpContainerParser_instances, streamKey_fn2).call(this, info.packetId, options?.catalogTrackName);
|
|
12122
|
+
if (fragmentType === 0) {
|
|
12123
|
+
if (mpu.fragmentationIndicator !== 0 || mpu.fragmentCounter !== 0) return null;
|
|
12124
|
+
const normalizedInit = normalizeMmtpInitSegment(data);
|
|
12125
|
+
if (!normalizedInit) return null;
|
|
12126
|
+
const resolver2 = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, true);
|
|
12127
|
+
if (!resolver2?.addInitialization(normalizedInit)) return null;
|
|
12128
|
+
(_a = __privateGet(this, _initCb)) == null ? void 0 : _a.call(this, normalizedInit, info.packetId, options?.catalogTrackName);
|
|
12129
|
+
return {
|
|
12130
|
+
kind: "init",
|
|
12131
|
+
packet: info,
|
|
12132
|
+
data: normalizedInit,
|
|
12133
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12134
|
+
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12135
|
+
fragmentCounter: mpu.fragmentCounter
|
|
12136
|
+
};
|
|
12137
|
+
}
|
|
12138
|
+
if (fragmentType === 1) {
|
|
12139
|
+
if (mpu.fragmentationIndicator !== 0 || mpu.fragmentCounter !== 0) return null;
|
|
12140
|
+
const resolver2 = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, false);
|
|
12141
|
+
if (!resolver2) return null;
|
|
12142
|
+
const pendingBefore = resolver2.pendingSampleCount;
|
|
12143
|
+
const remaining = __privateGet(this, _maxPendingTimingSamples) - __privateGet(this, _pendingTimingSamples);
|
|
12144
|
+
if (!resolver2.addMovieFragment(mpu.mpuSequenceNumber, data, remaining)) {
|
|
12145
|
+
if (resolver2.lastMovieFragmentRejection === "budget") {
|
|
12146
|
+
__privateWrapper(this, _rejectedMovieFragments)._++;
|
|
12147
|
+
}
|
|
12148
|
+
return null;
|
|
12149
|
+
}
|
|
12150
|
+
__privateSet(this, _pendingTimingSamples, __privateGet(this, _pendingTimingSamples) + (resolver2.pendingSampleCount - pendingBefore));
|
|
12151
|
+
return {
|
|
12152
|
+
kind: "fragment",
|
|
12153
|
+
packet: info,
|
|
12154
|
+
data,
|
|
12155
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12156
|
+
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12157
|
+
fragmentCounter: mpu.fragmentCounter
|
|
12158
|
+
};
|
|
12159
|
+
}
|
|
12160
|
+
if (fragmentType !== 2) return null;
|
|
12161
|
+
const resolver = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, false);
|
|
12162
|
+
if (!resolver) return null;
|
|
12163
|
+
if (!Number.isSafeInteger(data.byteLength) || data.byteLength <= 0) return null;
|
|
12164
|
+
if (mpu.fragmentationIndicator === 0 || mpu.fragmentationIndicator === 1) {
|
|
12165
|
+
if (!mfuDuHeader || mfuDuHeader.movieFragmentSequenceNumber === 0 || mfuDuHeader.sampleNumber === 0) {
|
|
12166
|
+
return null;
|
|
12167
|
+
}
|
|
12168
|
+
const headTiming = resolver.sampleTiming(
|
|
12169
|
+
mpu.mpuSequenceNumber,
|
|
12170
|
+
mfuDuHeader.movieFragmentSequenceNumber,
|
|
12171
|
+
mfuDuHeader.sampleNumber
|
|
12172
|
+
);
|
|
12173
|
+
if (!headTiming) return null;
|
|
12174
|
+
const offset = mfuDuHeader.offset;
|
|
12175
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= headTiming.size) return null;
|
|
12176
|
+
const remaining = headTiming.size - offset;
|
|
12177
|
+
if (mpu.fragmentationIndicator === 0 && data.byteLength !== remaining) return null;
|
|
12178
|
+
if (mpu.fragmentationIndicator === 1 && data.byteLength >= remaining) return null;
|
|
12179
|
+
const readyOnRegister = __privateMethod(this, _MmtpContainerParser_instances, sampleCombinerFor_fn).call(this, streamKey).registerAuthoredSize(
|
|
12180
|
+
options?.catalogTrackName,
|
|
12181
|
+
mpu.mpuSequenceNumber,
|
|
12182
|
+
mfuDuHeader.movieFragmentSequenceNumber,
|
|
12183
|
+
mfuDuHeader.sampleNumber,
|
|
12184
|
+
headTiming.size
|
|
12185
|
+
);
|
|
12186
|
+
if (readyOnRegister) {
|
|
12187
|
+
__privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, readyOnRegister, info, resolver, options?.recovered === true);
|
|
12188
|
+
}
|
|
12189
|
+
}
|
|
12190
|
+
let assembled;
|
|
12165
12191
|
try {
|
|
12166
|
-
|
|
12192
|
+
assembled = __privateGet(this, _reassembler).addFragment({
|
|
12193
|
+
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12194
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12195
|
+
fragmentCounter: mpu.fragmentCounter,
|
|
12196
|
+
data,
|
|
12197
|
+
timestamp: info.timestamp,
|
|
12198
|
+
rapFlag: info.rapFlag,
|
|
12199
|
+
priority: mfuDuHeader?.priority,
|
|
12200
|
+
sampleNumber: mfuDuHeader?.sampleNumber,
|
|
12201
|
+
movieFragmentSequenceNumber: mfuDuHeader?.movieFragmentSequenceNumber,
|
|
12202
|
+
sampleOffset: mfuDuHeader?.offset,
|
|
12203
|
+
packetSequenceNumber: info.sequenceNumber,
|
|
12204
|
+
recovered: options?.recovered === true,
|
|
12205
|
+
source: options?.source,
|
|
12206
|
+
deliveryProvenance: options?.deliveryProvenance,
|
|
12207
|
+
catalogTrackName: options?.catalogTrackName,
|
|
12208
|
+
packetId: info.packetId
|
|
12209
|
+
});
|
|
12167
12210
|
} catch (error) {
|
|
12168
|
-
|
|
12169
|
-
|
|
12211
|
+
if (!isMfuReassemblyError(error)) throw error;
|
|
12212
|
+
console.warn(
|
|
12213
|
+
`[MmtpContainerParser] rejected MFU fragment: code=${error.code} mpu=${mpu.mpuSequenceNumber} fi=${mpu.fragmentationIndicator} counter=${mpu.fragmentCounter}`
|
|
12214
|
+
);
|
|
12215
|
+
return {
|
|
12216
|
+
kind: "rejected",
|
|
12217
|
+
packet: info,
|
|
12218
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12219
|
+
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12220
|
+
fragmentCounter: mpu.fragmentCounter,
|
|
12221
|
+
error: { code: error.code, message: error.message }
|
|
12222
|
+
};
|
|
12170
12223
|
}
|
|
12171
|
-
if (
|
|
12172
|
-
|
|
12224
|
+
if (!assembled) {
|
|
12225
|
+
return {
|
|
12226
|
+
kind: "pending",
|
|
12227
|
+
packet: info,
|
|
12228
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12229
|
+
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12230
|
+
fragmentCounter: mpu.fragmentCounter
|
|
12231
|
+
};
|
|
12232
|
+
}
|
|
12233
|
+
const movieFragmentSequenceNumber = assembled.movieFragmentSequenceNumber;
|
|
12234
|
+
const sampleNumber = assembled.sampleNumber;
|
|
12235
|
+
if (movieFragmentSequenceNumber === void 0 || sampleNumber === void 0) return null;
|
|
12236
|
+
if (!resolver.sampleTiming(
|
|
12237
|
+
assembled.mpuSequenceNumber,
|
|
12238
|
+
movieFragmentSequenceNumber,
|
|
12239
|
+
sampleNumber
|
|
12240
|
+
)) return null;
|
|
12241
|
+
if (assembled.mpuSequenceNumber !== mpu.mpuSequenceNumber) return null;
|
|
12242
|
+
let combined;
|
|
12243
|
+
try {
|
|
12244
|
+
combined = __privateMethod(this, _MmtpContainerParser_instances, sampleCombinerFor_fn).call(this, streamKey).addMfu(assembled);
|
|
12245
|
+
} catch (error) {
|
|
12246
|
+
if (!(error instanceof SampleCombineError)) throw error;
|
|
12247
|
+
console.warn(
|
|
12248
|
+
`[MmtpContainerParser] rejected subsample data unit: code=${error.code} mpu=${assembled.mpuSequenceNumber} sample=${sampleNumber} offset=${assembled.sampleOffset ?? 0}`
|
|
12249
|
+
);
|
|
12250
|
+
return {
|
|
12251
|
+
kind: "rejected",
|
|
12252
|
+
packet: info,
|
|
12253
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12254
|
+
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12255
|
+
fragmentCounter: mpu.fragmentCounter,
|
|
12256
|
+
error: { code: error.code, message: error.message }
|
|
12257
|
+
};
|
|
12258
|
+
}
|
|
12259
|
+
if (!combined) {
|
|
12260
|
+
return {
|
|
12261
|
+
kind: "pending",
|
|
12262
|
+
packet: info,
|
|
12263
|
+
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12264
|
+
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12265
|
+
fragmentCounter: mpu.fragmentCounter
|
|
12266
|
+
};
|
|
12267
|
+
}
|
|
12268
|
+
return __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, combined, info, resolver, options?.recovered === true);
|
|
12173
12269
|
}
|
|
12174
12270
|
onInit(cb) {
|
|
12175
12271
|
__privateSet(this, _initCb, cb);
|
|
@@ -12337,7 +12433,6 @@ _timingStreams = new WeakMap();
|
|
|
12337
12433
|
_maxPendingTimingSamples = new WeakMap();
|
|
12338
12434
|
_pendingTimingSamples = new WeakMap();
|
|
12339
12435
|
_reclaimedTimingSamples = new WeakMap();
|
|
12340
|
-
_evictedTimingSamples = new WeakMap();
|
|
12341
12436
|
_rejectedMovieFragments = new WeakMap();
|
|
12342
12437
|
_sequencers = new WeakMap();
|
|
12343
12438
|
_reorderWindow = new WeakMap();
|
|
@@ -12349,11 +12444,6 @@ _trackFrameCbs = new WeakMap();
|
|
|
12349
12444
|
_reorderStats = new WeakMap();
|
|
12350
12445
|
_reliableMoqStartupGate = new WeakMap();
|
|
12351
12446
|
_disposed2 = new WeakMap();
|
|
12352
|
-
_fedObjects = new WeakMap();
|
|
12353
|
-
_feedOutcomes = new WeakMap();
|
|
12354
|
-
_deferredFeedOutcomes = new WeakMap();
|
|
12355
|
-
_lastOutcome = new WeakMap();
|
|
12356
|
-
_lastOutcomeCount = new WeakMap();
|
|
12357
12447
|
_MmtpContainerParser_instances = new WeakSet();
|
|
12358
12448
|
streamKey_fn2 = function(packetId, catalogTrackName) {
|
|
12359
12449
|
return JSON.stringify([packetId, catalogTrackName ?? null]);
|
|
@@ -12372,12 +12462,12 @@ sampleCombinerFor_fn = function(streamKey) {
|
|
|
12372
12462
|
/**
|
|
12373
12463
|
* Return the timing budget slot of a sample the combiner abandoned.
|
|
12374
12464
|
*
|
|
12375
|
-
* Without this, `#pendingTimingSamples` is
|
|
12376
|
-
* declares but credited only when that sample is
|
|
12377
|
-
* lost to eviction or timeout burns a
|
|
12378
|
-
*
|
|
12379
|
-
*
|
|
12380
|
-
*
|
|
12465
|
+
* Without this, `#pendingTimingSamples` is a one-way ratchet: it is charged
|
|
12466
|
+
* for every sample a moof declares but credited only when that sample is
|
|
12467
|
+
* delivered, so each sample lost to eviction or timeout permanently burns a
|
|
12468
|
+
* slot. At saturation `addMovieFragment` rejects every subsequent moof and
|
|
12469
|
+
* every FT=2 data unit is dropped -- media stops with no error surfaced and
|
|
12470
|
+
* nothing short of a track reset recovers.
|
|
12381
12471
|
*
|
|
12382
12472
|
* The parser total is decremented only when the resolver reports it
|
|
12383
12473
|
* actually freed a slot, so a resolver already dropped by a track reset, or
|
|
@@ -12409,232 +12499,11 @@ dropSampleCombiner_fn = function(streamKey) {
|
|
|
12409
12499
|
__privateGet(this, _retiredSampleCombinerStats).evictedSamples += stats.evictedSamples;
|
|
12410
12500
|
__privateGet(this, _sampleCombiners).delete(streamKey);
|
|
12411
12501
|
};
|
|
12412
|
-
countOutcome_fn = function(token) {
|
|
12413
|
-
const count = (__privateGet(this, _feedOutcomes).get(token) ?? 0) + 1;
|
|
12414
|
-
__privateGet(this, _feedOutcomes).set(token, count);
|
|
12415
|
-
__privateSet(this, _lastOutcome, token);
|
|
12416
|
-
__privateSet(this, _lastOutcomeCount, count);
|
|
12417
|
-
};
|
|
12418
|
-
countDeferredOutcome_fn = function(reason) {
|
|
12419
|
-
__privateGet(this, _deferredFeedOutcomes).set(
|
|
12420
|
-
reason,
|
|
12421
|
-
(__privateGet(this, _deferredFeedOutcomes).get(reason) ?? 0) + 1
|
|
12422
|
-
);
|
|
12423
|
-
};
|
|
12424
|
-
/**
|
|
12425
|
-
* Count a feed() drop and return null in one expression, so every early
|
|
12426
|
-
* return inside feed() states the reason it took instead of collapsing into
|
|
12427
|
-
* a single failure bucket. Returns null so call sites stay `return this.#drop(...)`.
|
|
12428
|
-
*/
|
|
12429
|
-
drop_fn = function(reason) {
|
|
12430
|
-
__privateMethod(this, _MmtpContainerParser_instances, countOutcome_fn).call(this, `drop:${reason}`);
|
|
12431
|
-
return null;
|
|
12432
|
-
};
|
|
12433
|
-
feed_fn = function(packet, options) {
|
|
12434
|
-
var _a;
|
|
12435
|
-
if (__privateGet(this, _disposed2)) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "disposed");
|
|
12436
|
-
this.cleanupTimeouts();
|
|
12437
|
-
const info = this.parseHeader(packet, options);
|
|
12438
|
-
if (!info) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "header-parse-failed");
|
|
12439
|
-
if (info.packetType !== PACKET_TYPE_MPU2) {
|
|
12440
|
-
return {
|
|
12441
|
-
kind: info.isRepair ? "repair" : "non-media",
|
|
12442
|
-
packet: info,
|
|
12443
|
-
byteLength: packet.byteLength
|
|
12444
|
-
};
|
|
12445
|
-
}
|
|
12446
|
-
if (info.fecPayloadId !== null && __privateGet(this, _sourceSymbolCb)) {
|
|
12447
|
-
const rawSymbol = packet.subarray(0, packet.length - 4);
|
|
12448
|
-
const altaTrailer = extractAltaTrailer2(packet);
|
|
12449
|
-
const alta = altaTrailer ? { auth: altaTrailer.auth, payloadEnd: altaTrailer.signedEnd } : void 0;
|
|
12450
|
-
try {
|
|
12451
|
-
__privateGet(this, _sourceSymbolCb).call(this, info.packetId, info.fecPayloadId.ssId, rawSymbol, alta);
|
|
12452
|
-
} catch {
|
|
12453
|
-
}
|
|
12454
|
-
}
|
|
12455
|
-
const extraction = extractMFUPayload(packet, {
|
|
12456
|
-
skipFecId: options?.skipFecPayloadId
|
|
12457
|
-
});
|
|
12458
|
-
if (!extraction) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-extract-failed");
|
|
12459
|
-
const { mpu, fragmentType, data, mfuDuHeader } = extraction;
|
|
12460
|
-
if (mpu.timedFlag !== 1) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "untimed-mpu");
|
|
12461
|
-
const streamKey = __privateMethod(this, _MmtpContainerParser_instances, streamKey_fn2).call(this, info.packetId, options?.catalogTrackName);
|
|
12462
|
-
if (fragmentType === 0) {
|
|
12463
|
-
if (mpu.fragmentationIndicator !== 0 || mpu.fragmentCounter !== 0)
|
|
12464
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "init-unexpected-fragmentation");
|
|
12465
|
-
const normalizedInit = normalizeMmtpInitSegment(data);
|
|
12466
|
-
if (!normalizedInit) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "init-normalize-failed");
|
|
12467
|
-
const resolver2 = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, true);
|
|
12468
|
-
if (!resolver2?.addInitialization(normalizedInit)) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "init-timing-refused");
|
|
12469
|
-
(_a = __privateGet(this, _initCb)) == null ? void 0 : _a.call(this, normalizedInit, info.packetId, options?.catalogTrackName);
|
|
12470
|
-
return {
|
|
12471
|
-
kind: "init",
|
|
12472
|
-
packet: info,
|
|
12473
|
-
data: normalizedInit,
|
|
12474
|
-
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12475
|
-
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12476
|
-
fragmentCounter: mpu.fragmentCounter
|
|
12477
|
-
};
|
|
12478
|
-
}
|
|
12479
|
-
if (fragmentType === 1) {
|
|
12480
|
-
if (mpu.fragmentationIndicator !== 0 || mpu.fragmentCounter !== 0)
|
|
12481
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-unexpected-fragmentation");
|
|
12482
|
-
const resolver2 = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, false);
|
|
12483
|
-
if (!resolver2) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-no-resolver");
|
|
12484
|
-
const pendingBefore = resolver2.pendingSampleCount;
|
|
12485
|
-
const evictedBefore = resolver2.evictedSampleCount;
|
|
12486
|
-
const remaining = __privateGet(this, _maxPendingTimingSamples) - __privateGet(this, _pendingTimingSamples);
|
|
12487
|
-
const admitted = resolver2.addMovieFragment(mpu.mpuSequenceNumber, data, remaining);
|
|
12488
|
-
__privateSet(this, _pendingTimingSamples, __privateGet(this, _pendingTimingSamples) + (resolver2.pendingSampleCount - pendingBefore));
|
|
12489
|
-
__privateSet(this, _evictedTimingSamples, __privateGet(this, _evictedTimingSamples) + (resolver2.evictedSampleCount - evictedBefore));
|
|
12490
|
-
if (!admitted) {
|
|
12491
|
-
if (resolver2.lastMovieFragmentRejection === "budget") {
|
|
12492
|
-
__privateWrapper(this, _rejectedMovieFragments)._++;
|
|
12493
|
-
}
|
|
12494
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-timing-refused");
|
|
12495
|
-
}
|
|
12496
|
-
return {
|
|
12497
|
-
kind: "fragment",
|
|
12498
|
-
packet: info,
|
|
12499
|
-
data,
|
|
12500
|
-
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12501
|
-
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12502
|
-
fragmentCounter: mpu.fragmentCounter
|
|
12503
|
-
};
|
|
12504
|
-
}
|
|
12505
|
-
if (fragmentType !== 2) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "unknown-fragment-type");
|
|
12506
|
-
const resolver = __privateMethod(this, _MmtpContainerParser_instances, timingResolver_fn).call(this, streamKey, info.packetId, false);
|
|
12507
|
-
if (!resolver) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-no-resolver");
|
|
12508
|
-
if (!Number.isSafeInteger(data.byteLength) || data.byteLength <= 0)
|
|
12509
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-empty-payload");
|
|
12510
|
-
if (mpu.fragmentationIndicator === 0 || mpu.fragmentationIndicator === 1) {
|
|
12511
|
-
if (!mfuDuHeader || mfuDuHeader.movieFragmentSequenceNumber === 0 || mfuDuHeader.sampleNumber === 0) {
|
|
12512
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-du-header-missing");
|
|
12513
|
-
}
|
|
12514
|
-
const headTiming = resolver.sampleTiming(
|
|
12515
|
-
mpu.mpuSequenceNumber,
|
|
12516
|
-
mfuDuHeader.movieFragmentSequenceNumber,
|
|
12517
|
-
mfuDuHeader.sampleNumber
|
|
12518
|
-
);
|
|
12519
|
-
if (!headTiming) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-sample-timing-missing");
|
|
12520
|
-
const offset = mfuDuHeader.offset;
|
|
12521
|
-
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= headTiming.size)
|
|
12522
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-offset-out-of-range");
|
|
12523
|
-
const remaining = headTiming.size - offset;
|
|
12524
|
-
if (mpu.fragmentationIndicator === 0 && data.byteLength !== remaining)
|
|
12525
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-size-mismatch");
|
|
12526
|
-
if (mpu.fragmentationIndicator === 1 && data.byteLength >= remaining)
|
|
12527
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "mfu-size-mismatch");
|
|
12528
|
-
const readyOnRegister = __privateMethod(this, _MmtpContainerParser_instances, sampleCombinerFor_fn).call(this, streamKey).registerAuthoredSize(
|
|
12529
|
-
options?.catalogTrackName,
|
|
12530
|
-
mpu.mpuSequenceNumber,
|
|
12531
|
-
mfuDuHeader.movieFragmentSequenceNumber,
|
|
12532
|
-
mfuDuHeader.sampleNumber,
|
|
12533
|
-
headTiming.size
|
|
12534
|
-
);
|
|
12535
|
-
if (readyOnRegister) {
|
|
12536
|
-
const deferred = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, readyOnRegister, info, resolver, options?.recovered === true);
|
|
12537
|
-
if (deferred.record === void 0) __privateMethod(this, _MmtpContainerParser_instances, countDeferredOutcome_fn).call(this, deferred.reason);
|
|
12538
|
-
}
|
|
12539
|
-
}
|
|
12540
|
-
let assembled;
|
|
12541
|
-
try {
|
|
12542
|
-
assembled = __privateGet(this, _reassembler).addFragment({
|
|
12543
|
-
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12544
|
-
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12545
|
-
fragmentCounter: mpu.fragmentCounter,
|
|
12546
|
-
data,
|
|
12547
|
-
timestamp: info.timestamp,
|
|
12548
|
-
rapFlag: info.rapFlag,
|
|
12549
|
-
priority: mfuDuHeader?.priority,
|
|
12550
|
-
sampleNumber: mfuDuHeader?.sampleNumber,
|
|
12551
|
-
movieFragmentSequenceNumber: mfuDuHeader?.movieFragmentSequenceNumber,
|
|
12552
|
-
sampleOffset: mfuDuHeader?.offset,
|
|
12553
|
-
packetSequenceNumber: info.sequenceNumber,
|
|
12554
|
-
recovered: options?.recovered === true,
|
|
12555
|
-
source: options?.source,
|
|
12556
|
-
deliveryProvenance: options?.deliveryProvenance,
|
|
12557
|
-
catalogTrackName: options?.catalogTrackName,
|
|
12558
|
-
packetId: info.packetId
|
|
12559
|
-
});
|
|
12560
|
-
} catch (error) {
|
|
12561
|
-
if (!isMfuReassemblyError(error)) throw error;
|
|
12562
|
-
console.warn(
|
|
12563
|
-
`[MmtpContainerParser] rejected MFU fragment: code=${error.code} mpu=${mpu.mpuSequenceNumber} fi=${mpu.fragmentationIndicator} counter=${mpu.fragmentCounter}`
|
|
12564
|
-
);
|
|
12565
|
-
return {
|
|
12566
|
-
kind: "rejected",
|
|
12567
|
-
packet: info,
|
|
12568
|
-
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12569
|
-
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12570
|
-
fragmentCounter: mpu.fragmentCounter,
|
|
12571
|
-
error: { code: error.code, message: error.message }
|
|
12572
|
-
};
|
|
12573
|
-
}
|
|
12574
|
-
if (!assembled) {
|
|
12575
|
-
return {
|
|
12576
|
-
kind: "pending",
|
|
12577
|
-
packet: info,
|
|
12578
|
-
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12579
|
-
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12580
|
-
fragmentCounter: mpu.fragmentCounter
|
|
12581
|
-
};
|
|
12582
|
-
}
|
|
12583
|
-
const movieFragmentSequenceNumber = assembled.movieFragmentSequenceNumber;
|
|
12584
|
-
const sampleNumber = assembled.sampleNumber;
|
|
12585
|
-
if (movieFragmentSequenceNumber === void 0 || sampleNumber === void 0)
|
|
12586
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "assembled-identity-missing");
|
|
12587
|
-
if (!resolver.sampleTiming(
|
|
12588
|
-
assembled.mpuSequenceNumber,
|
|
12589
|
-
movieFragmentSequenceNumber,
|
|
12590
|
-
sampleNumber
|
|
12591
|
-
)) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "assembled-timing-missing");
|
|
12592
|
-
if (assembled.mpuSequenceNumber !== mpu.mpuSequenceNumber)
|
|
12593
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "assembled-mpu-mismatch");
|
|
12594
|
-
let combined;
|
|
12595
|
-
try {
|
|
12596
|
-
combined = __privateMethod(this, _MmtpContainerParser_instances, sampleCombinerFor_fn).call(this, streamKey).addMfu(assembled);
|
|
12597
|
-
} catch (error) {
|
|
12598
|
-
if (!(error instanceof SampleCombineError)) throw error;
|
|
12599
|
-
console.warn(
|
|
12600
|
-
`[MmtpContainerParser] rejected subsample data unit: code=${error.code} mpu=${assembled.mpuSequenceNumber} sample=${sampleNumber} offset=${assembled.sampleOffset ?? 0}`
|
|
12601
|
-
);
|
|
12602
|
-
return {
|
|
12603
|
-
kind: "rejected",
|
|
12604
|
-
packet: info,
|
|
12605
|
-
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12606
|
-
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12607
|
-
fragmentCounter: mpu.fragmentCounter,
|
|
12608
|
-
error: { code: error.code, message: error.message }
|
|
12609
|
-
};
|
|
12610
|
-
}
|
|
12611
|
-
if (!combined) {
|
|
12612
|
-
return {
|
|
12613
|
-
kind: "pending",
|
|
12614
|
-
packet: info,
|
|
12615
|
-
mpuSequenceNumber: mpu.mpuSequenceNumber,
|
|
12616
|
-
fragmentationIndicator: mpu.fragmentationIndicator,
|
|
12617
|
-
fragmentCounter: mpu.fragmentCounter
|
|
12618
|
-
};
|
|
12619
|
-
}
|
|
12620
|
-
const outcome = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, combined, info, resolver, options?.recovered === true);
|
|
12621
|
-
if (outcome.record !== void 0) return outcome.record;
|
|
12622
|
-
return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, outcome.reason);
|
|
12623
|
-
};
|
|
12624
12502
|
/**
|
|
12625
12503
|
* Deliver one combined sample: resolve its authored timing, build frame
|
|
12626
12504
|
* metadata, retire the timing entry, and route it. Shared by the ordinary
|
|
12627
12505
|
* completion path and by the rarer completion that falls out of registering
|
|
12628
12506
|
* an authored size for data units that arrived before it.
|
|
12629
|
-
*
|
|
12630
|
-
* Reports a refusal as a reason rather than counting it, because the two
|
|
12631
|
-
* call sites owe different accounting. On `#feed()`'s tail return the
|
|
12632
|
-
* refusal *is* that feed()'s outcome and must be attributed; on the
|
|
12633
|
-
* register-completion path it belongs to an earlier sample while this
|
|
12634
|
-
* packet's own fragment continues to its own outcome, so counting it there
|
|
12635
|
-
* would push `outcomes` past `fedObjects` — the very invariant the
|
|
12636
|
-
* attribution exists to keep readable. Leaving the choice at the call site
|
|
12637
|
-
* is what keeps both true.
|
|
12638
12507
|
*/
|
|
12639
12508
|
emitCombinedSample_fn = function(combined, info, resolver, recovered) {
|
|
12640
12509
|
const timing = resolver.sampleTiming(
|
|
@@ -12642,29 +12511,27 @@ emitCombinedSample_fn = function(combined, info, resolver, recovered) {
|
|
|
12642
12511
|
combined.movieFragmentSequenceNumber,
|
|
12643
12512
|
combined.sampleNumber
|
|
12644
12513
|
);
|
|
12645
|
-
if (!timing) return
|
|
12646
|
-
if (combined.data.byteLength !== timing.size) return
|
|
12514
|
+
if (!timing) return null;
|
|
12515
|
+
if (combined.data.byteLength !== timing.size) return null;
|
|
12647
12516
|
const meta = __privateMethod(this, _MmtpContainerParser_instances, buildFrameMeta_fn).call(this, combined, info.packetId, info.sequenceNumber, timing, recovered);
|
|
12648
|
-
if (!meta) return
|
|
12517
|
+
if (!meta) return null;
|
|
12649
12518
|
if (!resolver.consumeSample(
|
|
12650
12519
|
combined.mpuSequenceNumber,
|
|
12651
12520
|
combined.movieFragmentSequenceNumber,
|
|
12652
12521
|
combined.sampleNumber,
|
|
12653
12522
|
timing
|
|
12654
|
-
)) return
|
|
12523
|
+
)) return null;
|
|
12655
12524
|
__privateWrapper(this, _pendingTimingSamples)._--;
|
|
12656
12525
|
this.routeFrame(combined.data, meta);
|
|
12657
12526
|
return {
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
...combined.priority === void 0 ? {} : { priority: combined.priority }
|
|
12667
|
-
}
|
|
12527
|
+
kind: "frame",
|
|
12528
|
+
packet: info,
|
|
12529
|
+
data: combined.data,
|
|
12530
|
+
meta,
|
|
12531
|
+
mpuSequenceNumber: combined.mpuSequenceNumber,
|
|
12532
|
+
fragmentCount: combined.fragmentCount,
|
|
12533
|
+
rapFlag: combined.rapFlag,
|
|
12534
|
+
...combined.priority === void 0 ? {} : { priority: combined.priority }
|
|
12668
12535
|
};
|
|
12669
12536
|
};
|
|
12670
12537
|
/** Order-independent reliable-moq startup gate: discard delta frames for a
|
|
@@ -18555,7 +18422,7 @@ _readIndex = new WeakMap();
|
|
|
18555
18422
|
_stalled = new WeakMap();
|
|
18556
18423
|
|
|
18557
18424
|
// src/mmtp-decode-pipeline.ts
|
|
18558
|
-
var _parser2, _fecClient, _frameCb2, _initCb2, _needsKeyframe, _codec, _trackType, _gateDropped, _gateEmitted,
|
|
18425
|
+
var _parser2, _fecClient, _frameCb2, _initCb2, _needsKeyframe, _codec, _trackType, _gateDropped, _gateEmitted, _fedObjects, _warnedNoParser, _feedOutcomes, _MmtpDecodePipeline_instances, tag_fn, gatedEmit_fn;
|
|
18559
18426
|
var MmtpDecodePipeline = class {
|
|
18560
18427
|
constructor() {
|
|
18561
18428
|
__privateAdd(this, _MmtpDecodePipeline_instances);
|
|
@@ -18575,7 +18442,7 @@ var MmtpDecodePipeline = class {
|
|
|
18575
18442
|
* emitted. Bounded logging only — these gate nothing. */
|
|
18576
18443
|
__privateAdd(this, _gateDropped, 0);
|
|
18577
18444
|
__privateAdd(this, _gateEmitted, 0);
|
|
18578
|
-
__privateAdd(this,
|
|
18445
|
+
__privateAdd(this, _fedObjects, 0);
|
|
18579
18446
|
/** Warned-once latch for feeds arriving with no parser. Kept separate from
|
|
18580
18447
|
* #fedObjects so that counter stays a pure monotonic count. */
|
|
18581
18448
|
__privateAdd(this, _warnedNoParser, false);
|
|
@@ -18584,16 +18451,16 @@ var MmtpDecodePipeline = class {
|
|
|
18584
18451
|
* so a packet that fails header parse, fails MFU extraction, or accumulates
|
|
18585
18452
|
* forever as an unreassembled fragment is indistinguishable from one that
|
|
18586
18453
|
* produced a frame. Tally the kinds instead of guessing. */
|
|
18587
|
-
__privateAdd(this,
|
|
18454
|
+
__privateAdd(this, _feedOutcomes, /* @__PURE__ */ new Map());
|
|
18588
18455
|
}
|
|
18589
18456
|
/** Configure the inner parser. Call before feedMoqObject(). */
|
|
18590
18457
|
configure(config) {
|
|
18591
18458
|
__privateGet(this, _parser2)?.flush();
|
|
18592
18459
|
__privateGet(this, _parser2)?.dispose();
|
|
18593
|
-
__privateSet(this,
|
|
18460
|
+
__privateSet(this, _fedObjects, 0);
|
|
18594
18461
|
__privateSet(this, _gateDropped, 0);
|
|
18595
18462
|
__privateSet(this, _gateEmitted, 0);
|
|
18596
|
-
__privateGet(this,
|
|
18463
|
+
__privateGet(this, _feedOutcomes).clear();
|
|
18597
18464
|
__privateSet(this, _warnedNoParser, false);
|
|
18598
18465
|
__privateSet(this, _codec, config.codec);
|
|
18599
18466
|
const trackType = isVideoCodec(config.codec) ? "video" : "audio";
|
|
@@ -18653,10 +18520,10 @@ var MmtpDecodePipeline = class {
|
|
|
18653
18520
|
return {
|
|
18654
18521
|
trackType: __privateGet(this, _trackType),
|
|
18655
18522
|
codec: __privateGet(this, _codec),
|
|
18656
|
-
fedObjects: __privateGet(this,
|
|
18523
|
+
fedObjects: __privateGet(this, _fedObjects),
|
|
18657
18524
|
emitted: __privateGet(this, _gateEmitted),
|
|
18658
18525
|
gateDropped: __privateGet(this, _gateDropped),
|
|
18659
|
-
outcomes: Object.fromEntries(__privateGet(this,
|
|
18526
|
+
outcomes: Object.fromEntries(__privateGet(this, _feedOutcomes))
|
|
18660
18527
|
};
|
|
18661
18528
|
}
|
|
18662
18529
|
/**
|
|
@@ -18671,8 +18538,8 @@ var MmtpDecodePipeline = class {
|
|
|
18671
18538
|
}
|
|
18672
18539
|
return;
|
|
18673
18540
|
}
|
|
18674
|
-
__privateSet(this,
|
|
18675
|
-
if (__privateGet(this,
|
|
18541
|
+
__privateSet(this, _fedObjects, __privateGet(this, _fedObjects) + 1);
|
|
18542
|
+
if (__privateGet(this, _fedObjects) === 1) {
|
|
18676
18543
|
console.log(`[mmtp-pipeline] first object fed ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} bytes=${packet.length}`);
|
|
18677
18544
|
}
|
|
18678
18545
|
let outcomeKind = "threw";
|
|
@@ -18686,18 +18553,18 @@ var MmtpDecodePipeline = class {
|
|
|
18686
18553
|
const record = __privateGet(this, _parser2).feed(packet);
|
|
18687
18554
|
outcomeKind = record?.kind ?? "null(parse-or-extract-failed)";
|
|
18688
18555
|
} finally {
|
|
18689
|
-
const seen = (__privateGet(this,
|
|
18690
|
-
__privateGet(this,
|
|
18556
|
+
const seen = (__privateGet(this, _feedOutcomes).get(outcomeKind) ?? 0) + 1;
|
|
18557
|
+
__privateGet(this, _feedOutcomes).set(outcomeKind, seen);
|
|
18691
18558
|
if (seen === 1) {
|
|
18692
18559
|
console.log(
|
|
18693
|
-
`[mmtp-pipeline] feed outcome FIRST '${outcomeKind}' ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} at object #${__privateGet(this,
|
|
18560
|
+
`[mmtp-pipeline] feed outcome FIRST '${outcomeKind}' ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} at object #${__privateGet(this, _fedObjects)} bytes=${packet.length}`
|
|
18694
18561
|
);
|
|
18695
18562
|
}
|
|
18696
18563
|
}
|
|
18697
|
-
if (__privateGet(this,
|
|
18698
|
-
const hist = [...__privateGet(this,
|
|
18564
|
+
if (__privateGet(this, _fedObjects) % 200 === 0) {
|
|
18565
|
+
const hist = [...__privateGet(this, _feedOutcomes)].map(([k, v]) => `${k}=${v}`).join(" ");
|
|
18699
18566
|
console.log(
|
|
18700
|
-
`[mmtp-pipeline] feed histogram ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} @${__privateGet(this,
|
|
18567
|
+
`[mmtp-pipeline] feed histogram ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} @${__privateGet(this, _fedObjects)}: ${hist} | emitted=${__privateGet(this, _gateEmitted)} gateDropped=${__privateGet(this, _gateDropped)}`
|
|
18701
18568
|
);
|
|
18702
18569
|
}
|
|
18703
18570
|
}
|
|
@@ -18764,9 +18631,9 @@ _codec = new WeakMap();
|
|
|
18764
18631
|
_trackType = new WeakMap();
|
|
18765
18632
|
_gateDropped = new WeakMap();
|
|
18766
18633
|
_gateEmitted = new WeakMap();
|
|
18767
|
-
|
|
18634
|
+
_fedObjects = new WeakMap();
|
|
18768
18635
|
_warnedNoParser = new WeakMap();
|
|
18769
|
-
|
|
18636
|
+
_feedOutcomes = new WeakMap();
|
|
18770
18637
|
_MmtpDecodePipeline_instances = new WeakSet();
|
|
18771
18638
|
/** Identity prefix for diagnostics: one pipeline per track means two
|
|
18772
18639
|
* instances write to the same console, and unlabelled lines interleave into
|
|
@@ -18782,7 +18649,7 @@ gatedEmit_fn = function(data, meta) {
|
|
|
18782
18649
|
__privateSet(this, _gateDropped, __privateGet(this, _gateDropped) + 1);
|
|
18783
18650
|
if (__privateGet(this, _gateDropped) <= 3 || __privateGet(this, _gateDropped) % 200 === 0) {
|
|
18784
18651
|
console.warn(
|
|
18785
|
-
`[mmtp-pipeline] keyframe gate DROP #${__privateGet(this, _gateDropped)} ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} bytes=${data.length} fed=${__privateGet(this,
|
|
18652
|
+
`[mmtp-pipeline] keyframe gate DROP #${__privateGet(this, _gateDropped)} ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} bytes=${data.length} fed=${__privateGet(this, _fedObjects)} emitted=${__privateGet(this, _gateEmitted)}`
|
|
18786
18653
|
);
|
|
18787
18654
|
}
|
|
18788
18655
|
return;
|
|
@@ -18790,7 +18657,7 @@ gatedEmit_fn = function(data, meta) {
|
|
|
18790
18657
|
__privateSet(this, _needsKeyframe, false);
|
|
18791
18658
|
sourceDiscontinuity = true;
|
|
18792
18659
|
console.log(
|
|
18793
|
-
`[mmtp-pipeline] keyframe gate OPENED ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} after ${__privateGet(this, _gateDropped)} drops, fed=${__privateGet(this,
|
|
18660
|
+
`[mmtp-pipeline] keyframe gate OPENED ${__privateMethod(this, _MmtpDecodePipeline_instances, tag_fn).call(this)} after ${__privateGet(this, _gateDropped)} drops, fed=${__privateGet(this, _fedObjects)}`
|
|
18794
18661
|
);
|
|
18795
18662
|
}
|
|
18796
18663
|
__privateSet(this, _gateEmitted, __privateGet(this, _gateEmitted) + 1);
|