@blockcast/mmt-container 2.2.0-main.f480a7ede8b1 → 2.2.0-main.fb5c7dfbe2de
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 +891 -141
- package/dist/browser-runtime.js.map +3 -3
- package/dist/delta-fallback-config.js.map +1 -1
- package/dist/fec-manager.d.ts +67 -11
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +283 -54
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-worker-setup.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-block-locator.d.ts +39 -13
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +80 -25
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/media-router.js.map +1 -1
- package/dist/mmtp-container-parser.d.ts +42 -8
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +121 -17
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +120 -18
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/mmtp-decode-pipeline.js +121 -17
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +28 -8
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +407 -52
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-manager.d.ts +13 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +712 -115
- package/dist/multicast-manager.js.map +2 -2
- package/dist/multicast-transport.js +2 -2
- package/dist/multicast-transport.js.map +2 -2
- package/dist/no-modules.js +121 -17
- package/dist/no-modules.js.map +2 -2
- package/dist/repair-fetch.d.ts +36 -8
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +285 -26
- package/dist/repair-fetch.js.map +3 -3
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +1 -0
- package/dist/track-session.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +121 -17
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/fec-manager.ts +304 -28
- package/src/index.ts +2 -0
- package/src/iso-block-locator.ts +114 -31
- package/src/mmtp-container-parser.ts +210 -21
- package/src/mmtp-router.ts +488 -45
- package/src/multicast-manager.ts +44 -6
- package/src/repair-fetch.ts +363 -49
- package/src/track-session.ts +3 -0
|
@@ -5197,6 +5197,9 @@ function authoredGap(before, after) {
|
|
|
5197
5197
|
function ssIdAfter(a, b) {
|
|
5198
5198
|
return (a - b | 0) > 0;
|
|
5199
5199
|
}
|
|
5200
|
+
function holdsRebuilt(stream) {
|
|
5201
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
|
|
5202
|
+
}
|
|
5200
5203
|
var FecReleaseSequencer = class {
|
|
5201
5204
|
#streams = /* @__PURE__ */ new Map();
|
|
5202
5205
|
#gate;
|
|
@@ -5259,6 +5262,7 @@ var FecReleaseSequencer = class {
|
|
|
5259
5262
|
stream.lastSbn = void 0;
|
|
5260
5263
|
stream.discontinuity = false;
|
|
5261
5264
|
stream.rapSsId = void 0;
|
|
5265
|
+
stream.sourced = false;
|
|
5262
5266
|
}
|
|
5263
5267
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
5264
5268
|
this.#recordStat("droppedStale");
|
|
@@ -5285,6 +5289,7 @@ var FecReleaseSequencer = class {
|
|
|
5285
5289
|
if (compareFrameOrder(stream.buf[mid], frame) < 0) lo = mid + 1;
|
|
5286
5290
|
else hi = mid;
|
|
5287
5291
|
}
|
|
5292
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true;
|
|
5288
5293
|
stream.buf.splice(lo, 0, frame);
|
|
5289
5294
|
this.#drainUnlessDeferred(stream);
|
|
5290
5295
|
}
|
|
@@ -5320,6 +5325,41 @@ var FecReleaseSequencer = class {
|
|
|
5320
5325
|
}
|
|
5321
5326
|
return false;
|
|
5322
5327
|
}
|
|
5328
|
+
/**
|
|
5329
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
5330
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
5331
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
5332
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
5333
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
5334
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
5335
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
5336
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
5337
|
+
* released.
|
|
5338
|
+
*/
|
|
5339
|
+
unsource(packetId, catalogTrackName) {
|
|
5340
|
+
for (const stream of this.#streams.values()) {
|
|
5341
|
+
if (stream.packetId === packetId && (catalogTrackName === void 0 || stream.catalogTrackName === catalogTrackName)) {
|
|
5342
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
5343
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream);
|
|
5344
|
+
else this.#drain(stream, true);
|
|
5345
|
+
}
|
|
5346
|
+
stream.sourced = false;
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5350
|
+
/**
|
|
5351
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
5352
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
5353
|
+
* packetId.
|
|
5354
|
+
*/
|
|
5355
|
+
holdsRebuilt(packetId, catalogTrackName) {
|
|
5356
|
+
for (const stream of this.#streams.values()) {
|
|
5357
|
+
if (stream.packetId !== packetId) continue;
|
|
5358
|
+
if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
|
|
5359
|
+
if (holdsRebuilt(stream)) return true;
|
|
5360
|
+
}
|
|
5361
|
+
return false;
|
|
5362
|
+
}
|
|
5323
5363
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
5324
5364
|
poke(streamKey) {
|
|
5325
5365
|
if (streamKey !== void 0) {
|
|
@@ -5411,16 +5451,32 @@ var FecReleaseSequencer = class {
|
|
|
5411
5451
|
last: null,
|
|
5412
5452
|
lastSbn: void 0,
|
|
5413
5453
|
discontinuity: false,
|
|
5414
|
-
rapSsId: void 0
|
|
5454
|
+
rapSsId: void 0,
|
|
5455
|
+
sourced: false,
|
|
5456
|
+
draining: 0
|
|
5415
5457
|
};
|
|
5416
5458
|
this.#streams.set(streamKey, stream);
|
|
5417
5459
|
}
|
|
5418
5460
|
return stream;
|
|
5419
5461
|
}
|
|
5420
|
-
#
|
|
5462
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
5463
|
+
#drain(stream, asUnanchored = false) {
|
|
5464
|
+
stream.draining++;
|
|
5465
|
+
try {
|
|
5466
|
+
this.#drainLoop(stream, asUnanchored);
|
|
5467
|
+
} finally {
|
|
5468
|
+
stream.draining--;
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5471
|
+
#drainLoop(stream, asUnanchored) {
|
|
5421
5472
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
5422
5473
|
const head = stream.buf[0];
|
|
5423
5474
|
const last = stream.last;
|
|
5475
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
5476
|
+
stream.buf.shift();
|
|
5477
|
+
this.#release(stream, head, void 0);
|
|
5478
|
+
continue;
|
|
5479
|
+
}
|
|
5424
5480
|
if (stream.discontinuity) {
|
|
5425
5481
|
stream.discontinuity = false;
|
|
5426
5482
|
stream.buf.shift();
|
|
@@ -5434,9 +5490,10 @@ var FecReleaseSequencer = class {
|
|
|
5434
5490
|
}
|
|
5435
5491
|
const headSbn = head.meta.fecSbn;
|
|
5436
5492
|
const from = stream.lastSbn ?? headSbn;
|
|
5437
|
-
const to = headSbn ?? stream.lastSbn;
|
|
5493
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn;
|
|
5438
5494
|
let lost = [];
|
|
5439
5495
|
const unanchored = from === void 0 && to === void 0;
|
|
5496
|
+
let unresolved = false;
|
|
5440
5497
|
if (from !== void 0 && to !== void 0) {
|
|
5441
5498
|
const resolved = this.#gate.resolvedLoss(
|
|
5442
5499
|
stream.packetId,
|
|
@@ -5445,7 +5502,8 @@ var FecReleaseSequencer = class {
|
|
|
5445
5502
|
Math.max(from, to),
|
|
5446
5503
|
from
|
|
5447
5504
|
);
|
|
5448
|
-
|
|
5505
|
+
unresolved = resolved === null;
|
|
5506
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored)) {
|
|
5449
5507
|
const heldMs = performance.now() - head.arrivedAtMs;
|
|
5450
5508
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
|
|
5451
5509
|
this.#recordStat("forcedWindowFlushes");
|
|
@@ -5453,22 +5511,56 @@ var FecReleaseSequencer = class {
|
|
|
5453
5511
|
this.#release(stream, head, this.#gate.decide(last, head, [], true));
|
|
5454
5512
|
continue;
|
|
5455
5513
|
}
|
|
5456
|
-
lost = resolved;
|
|
5514
|
+
lost = resolved ?? [];
|
|
5457
5515
|
}
|
|
5458
5516
|
stream.buf.shift();
|
|
5459
5517
|
this.#release(
|
|
5460
5518
|
stream,
|
|
5461
5519
|
head,
|
|
5462
|
-
lost.length > 0 || unanchored || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
5520
|
+
lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta) ? this.#gate.decide(last, head, lost, false) : void 0
|
|
5463
5521
|
);
|
|
5464
5522
|
}
|
|
5465
5523
|
}
|
|
5524
|
+
/**
|
|
5525
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
5526
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
5527
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
5528
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
5529
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
5530
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
5531
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
5532
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
5533
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
5534
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
5535
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
5536
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
5537
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
5538
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
5539
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
5540
|
+
*/
|
|
5541
|
+
#cursorPassed(stream, asUnanchored) {
|
|
5542
|
+
let at = -1;
|
|
5543
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
5544
|
+
const frame = stream.buf[i];
|
|
5545
|
+
if (frame.meta.fecSbnFirst !== void 0 || frame.meta.fecSbn === void 0) {
|
|
5546
|
+
frame.passed = true;
|
|
5547
|
+
if (at < 0) at = i;
|
|
5548
|
+
} else if (frame.passed !== true) break;
|
|
5549
|
+
}
|
|
5550
|
+
if (at < 0) return false;
|
|
5551
|
+
return asUnanchored || !stream.sourced || this.#gate.releaseUnanchored?.(stream.packetId, stream.catalogTrackName) === true || stream.buf.some(({ meta }, i) => i > at && meta.fecSbnFirst === void 0 && (meta.recovered !== true || meta.fecSbn !== void 0));
|
|
5552
|
+
}
|
|
5466
5553
|
#release(stream, frame, decision) {
|
|
5554
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0;
|
|
5555
|
+
if (stale) this.#recordStat("droppedStale");
|
|
5467
5556
|
if (decision) frame.meta.gapBefore = decision;
|
|
5468
5557
|
stream.last = frame;
|
|
5469
|
-
if (frame.meta.fecSbn !== void 0
|
|
5558
|
+
if (frame.meta.fecSbn !== void 0 && (frame.meta.fecSbnFirst === void 0 || stream.lastSbn !== void 0)) {
|
|
5559
|
+
stream.lastSbn = frame.meta.fecSbn;
|
|
5560
|
+
}
|
|
5561
|
+
if (frame.meta.recovered !== true) stream.sourced = true;
|
|
5470
5562
|
this.#gate.onReleased?.(frame.data, frame.meta);
|
|
5471
|
-
this.#emit(frame.data, frame.meta);
|
|
5563
|
+
if (!stale) this.#emit(frame.data, frame.meta);
|
|
5472
5564
|
}
|
|
5473
5565
|
};
|
|
5474
5566
|
var FMPU_BOX_TYPES = /* @__PURE__ */ new Set(["ftyp", "moov", "moof"]);
|
|
@@ -5729,11 +5821,12 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5729
5821
|
/**
|
|
5730
5822
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
5731
5823
|
*
|
|
5732
|
-
*
|
|
5733
|
-
*
|
|
5734
|
-
*
|
|
5735
|
-
*
|
|
5736
|
-
*
|
|
5824
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
5825
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
5826
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
5827
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
5828
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
5829
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
5737
5830
|
*/
|
|
5738
5831
|
get timingBudgetStats() {
|
|
5739
5832
|
return {
|
|
@@ -5793,6 +5886,14 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
5793
5886
|
fecReleaseRapAbove(packetId, catalogTrackName, ssId) {
|
|
5794
5887
|
return this.#fecSequencer?.rapAbove(packetId, catalogTrackName, ssId) ?? false;
|
|
5795
5888
|
}
|
|
5889
|
+
/** See FecReleaseSequencer.unsource. */
|
|
5890
|
+
unsourceFecRelease(packetId, catalogTrackName) {
|
|
5891
|
+
this.#fecSequencer?.unsource(packetId, catalogTrackName);
|
|
5892
|
+
}
|
|
5893
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
5894
|
+
fecReleaseHoldsRebuilt(packetId, catalogTrackName) {
|
|
5895
|
+
return this.#fecSequencer?.holdsRebuilt(packetId, catalogTrackName) ?? false;
|
|
5896
|
+
}
|
|
5796
5897
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
5797
5898
|
pokeFecRelease(packetId, catalogTrackName) {
|
|
5798
5899
|
if (!this.#fecSequencer) return;
|
|
@@ -6046,7 +6147,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6046
6147
|
if (!resolver2?.initialized) return this.#drop("fragment-no-resolver");
|
|
6047
6148
|
const pendingBefore = resolver2.pendingSampleCount;
|
|
6048
6149
|
const evictedBefore = resolver2.evictedSampleCount;
|
|
6049
|
-
const remaining = this.#maxPendingTimingSamples -
|
|
6150
|
+
const remaining = this.#maxPendingTimingSamples - resolver2.pendingSampleCount;
|
|
6050
6151
|
const admitted = resolver2.addMovieFragment(
|
|
6051
6152
|
mpu.mpuSequenceNumber,
|
|
6052
6153
|
data,
|
|
@@ -6119,7 +6220,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6119
6220
|
info,
|
|
6120
6221
|
resolver,
|
|
6121
6222
|
options?.recovered === true,
|
|
6122
|
-
options?.fecSbn
|
|
6223
|
+
options?.fecSbn,
|
|
6224
|
+
options?.fecSbnFirst
|
|
6123
6225
|
);
|
|
6124
6226
|
if (deferred.record === void 0) this.#countDeferredOutcome(deferred.reason);
|
|
6125
6227
|
}
|
|
@@ -6212,7 +6314,8 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6212
6314
|
info,
|
|
6213
6315
|
resolver,
|
|
6214
6316
|
options?.recovered === true,
|
|
6215
|
-
options?.fecSbn
|
|
6317
|
+
options?.fecSbn,
|
|
6318
|
+
options?.fecSbnFirst
|
|
6216
6319
|
);
|
|
6217
6320
|
if (outcome.record !== void 0) return outcome.record;
|
|
6218
6321
|
return this.#drop(outcome.reason);
|
|
@@ -6232,7 +6335,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6232
6335
|
* attribution exists to keep readable. Leaving the choice at the call site
|
|
6233
6336
|
* is what keeps both true.
|
|
6234
6337
|
*/
|
|
6235
|
-
#emitCombinedSample(combined, info, resolver, recovered, fecSbn) {
|
|
6338
|
+
#emitCombinedSample(combined, info, resolver, recovered, fecSbn, fecSbnFirst) {
|
|
6236
6339
|
const timing = resolver.sampleTiming(
|
|
6237
6340
|
combined.mpuSequenceNumber,
|
|
6238
6341
|
combined.movieFragmentSequenceNumber,
|
|
@@ -6249,6 +6352,7 @@ var MmtpContainerParser = class _MmtpContainerParser {
|
|
|
6249
6352
|
);
|
|
6250
6353
|
if (!meta) return { reason: "combined-meta-build-failed" };
|
|
6251
6354
|
if (fecSbn !== void 0) meta.fecSbn = fecSbn;
|
|
6355
|
+
if (fecSbnFirst !== void 0) meta.fecSbnFirst = fecSbnFirst;
|
|
6252
6356
|
if (!resolver.consumeSample(
|
|
6253
6357
|
combined.mpuSequenceNumber,
|
|
6254
6358
|
combined.movieFragmentSequenceNumber,
|