@blockcast/mmt-container 2.2.0-main.2c4d96d3ffc2 → 2.2.0-main.34b53d33bace

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.
Files changed (60) hide show
  1. package/dist/browser-runtime.js +954 -157
  2. package/dist/browser-runtime.js.map +3 -3
  3. package/dist/cmaf-block-assembler.js +92 -1
  4. package/dist/cmaf-block-assembler.js.map +2 -2
  5. package/dist/codec-utils.d.ts.map +1 -1
  6. package/dist/codec-utils.js +92 -1
  7. package/dist/codec-utils.js.map +2 -2
  8. package/dist/delta-fallback-config.js.map +1 -1
  9. package/dist/fec-manager.d.ts +71 -14
  10. package/dist/fec-manager.d.ts.map +1 -1
  11. package/dist/fec-manager.js +300 -60
  12. package/dist/fec-manager.js.map +2 -2
  13. package/dist/fec-worker-setup.js.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js.map +2 -2
  17. package/dist/iso-block-locator.d.ts +39 -13
  18. package/dist/iso-block-locator.d.ts.map +1 -1
  19. package/dist/iso-block-locator.js +80 -25
  20. package/dist/iso-block-locator.js.map +2 -2
  21. package/dist/media-router.js.map +1 -1
  22. package/dist/mmtp-container-parser.d.ts +63 -10
  23. package/dist/mmtp-container-parser.d.ts.map +1 -1
  24. package/dist/mmtp-container-parser.js +218 -18
  25. package/dist/mmtp-container-parser.js.map +2 -2
  26. package/dist/mmtp-container-parser.no-modules.js +217 -19
  27. package/dist/mmtp-container-parser.no-modules.js.map +3 -3
  28. package/dist/mmtp-decode-pipeline.js +218 -18
  29. package/dist/mmtp-decode-pipeline.js.map +2 -2
  30. package/dist/mmtp-router.d.ts +22 -9
  31. package/dist/mmtp-router.d.ts.map +1 -1
  32. package/dist/mmtp-router.js +384 -51
  33. package/dist/mmtp-router.js.map +3 -3
  34. package/dist/multicast-manager.d.ts +26 -3
  35. package/dist/multicast-manager.d.ts.map +1 -1
  36. package/dist/multicast-manager.js +774 -130
  37. package/dist/multicast-manager.js.map +3 -3
  38. package/dist/multicast-transport.js +2 -2
  39. package/dist/multicast-transport.js.map +2 -2
  40. package/dist/no-modules.js +218 -18
  41. package/dist/no-modules.js.map +3 -3
  42. package/dist/repair-fetch.d.ts +38 -8
  43. package/dist/repair-fetch.d.ts.map +1 -1
  44. package/dist/repair-fetch.js +286 -27
  45. package/dist/repair-fetch.js.map +3 -3
  46. package/dist/track-session.d.ts.map +1 -1
  47. package/dist/track-session.js +1 -0
  48. package/dist/track-session.js.map +2 -2
  49. package/dist/wasm-mmtp-container-parser.js +218 -18
  50. package/dist/wasm-mmtp-container-parser.js.map +2 -2
  51. package/package.json +5 -5
  52. package/src/codec-utils.ts +121 -1
  53. package/src/fec-manager.ts +316 -34
  54. package/src/index.ts +2 -0
  55. package/src/iso-block-locator.ts +114 -31
  56. package/src/mmtp-container-parser.ts +238 -21
  57. package/src/mmtp-router.ts +271 -58
  58. package/src/multicast-manager.ts +136 -16
  59. package/src/repair-fetch.ts +366 -50
  60. package/src/track-session.ts +3 -0
@@ -4650,9 +4650,10 @@ var BlockcastMmt = (() => {
4650
4650
  const sliceType = readH264SliceType(nal);
4651
4651
  return sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9;
4652
4652
  }
4653
+ var H264_SLICE_TYPE_ESCAPED_BYTES = 32;
4653
4654
  function readH264SliceType(nal) {
4654
4655
  if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
4655
- const rbsp = removeEmulationPrevention(nal.subarray(1));
4656
+ const rbsp = removeEmulationPrevention(nal.subarray(1, 1 + H264_SLICE_TYPE_ESCAPED_BYTES));
4656
4657
  const state = { bitOffset: 0 };
4657
4658
  if (readUnsignedExpGolomb(rbsp, state) === null) return null;
4658
4659
  return readUnsignedExpGolomb(rbsp, state);
@@ -4799,6 +4800,96 @@ var BlockcastMmt = (() => {
4799
4800
  ]))).toBe(false);
4800
4801
  });
4801
4802
  });
4803
+ describe("readH264SliceType", () => {
4804
+ const wholeNalSliceType = (nal) => {
4805
+ if (nal.length < 2 || (nal[0] & 31) !== 1) return null;
4806
+ const rbsp = removeEmulationPrevention(nal.subarray(1));
4807
+ const state = { bitOffset: 0 };
4808
+ if (readUnsignedExpGolomb(rbsp, state) === null) return null;
4809
+ return readUnsignedExpGolomb(rbsp, state);
4810
+ };
4811
+ const hex2 = (text2) => Uint8Array.from(text2.match(/../g), (byte) => parseInt(byte, 16));
4812
+ const ue = (value) => {
4813
+ const code = (value + 1).toString(2);
4814
+ return "0".repeat(code.length - 1) + code;
4815
+ };
4816
+ const sliceNal = (bits) => {
4817
+ const rbsp = `${bits}1`.padEnd(Math.ceil((bits.length + 1) / 8) * 8, "0").match(/.{8}/g);
4818
+ const nal = [1];
4819
+ let zeros = 0;
4820
+ for (const byte of rbsp.map((bits8) => parseInt(bits8, 2))) {
4821
+ if (zeros >= 2 && byte <= 3) {
4822
+ nal.push(3);
4823
+ zeros = 0;
4824
+ }
4825
+ nal.push(byte);
4826
+ zeros = byte === 0 ? zeros + 1 : 0;
4827
+ }
4828
+ return Uint8Array.from(nal);
4829
+ };
4830
+ const x264Slices = [
4831
+ ["64x48 P", hex2("419a231885bfd53888f63ef5b1e1e39b9ff2eabf03fd3f4d7d4317ffcbf75176"), 5, false],
4832
+ ["64x48 B", hex2("419e414212fffeeade283707cb70f7"), 6, false],
4833
+ ["64x48 non-IDR I", hex2(
4834
+ "4128899037f384db2be0cfe48aa23558781dd429f7db8e8a6ae44f7ca2333ba1029477da6ddfeac61843c5680cbf66247469d64549b0f5f7ca6acc529f5cf032b35d8dedc6b2412ece24f42f80b593fc0f3ff47a08c84799ff2ada18ac39a527e23eb34c8167fd"
4835
+ ), 7, true],
4836
+ ["1280x720 B, escape at byte 10", hex2(
4837
+ "01006e27a81109ff000003016b662ea5ea46000f57880f3fb0d3f03ff7dac0546fc9966a5f6d86cb795db178882f6e19b75d92170917306190f262fd58268702db2eff86a9651e48"
4838
+ ), 6, false],
4839
+ ["1280x720 P, escape at byte 15", hex2(
4840
+ "41006e26a8cd1329e1bffea784000003002b5ef096f0320bd99f00037f22327e886223b7996bb04acd35ad9a0385f02c1801eb6226bc94993d1880172ffbb23db74729569b6f3934cba0cba17b7c29ce0e216080cb7b18e5876df59e85302da9cba203fe6769178a2e02eeaa54a6f87568cbaa019a3442eae19c8a7adc8cd02441bee573c5408b6552abd2d9d3"
4841
+ ), 5, false],
4842
+ ["1280x720 B, escape at byte 22", hex2("01006e27da9109ff01a4c1dbc27ed915a3172ec80000030352"), 6, false],
4843
+ ["7680x4320 IDR, first_mb_in_slice 97440", hex2(
4844
+ "650000be5088843a118a000218f1c00040f63800087949c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9c9"
4845
+ ), null, true],
4846
+ ["7680x4320 P, first_mb_in_slice 32640", hex2(
4847
+ "410003fc09a20a806ff0ae0085a611cc7ad5f2020e25900ba4c3398016b57e100011021220200020"
4848
+ ), 5, false],
4849
+ ["7680x4320 P, first_mb_in_slice 97440", hex2(
4850
+ "410000be509a20a8078f5a83cc40d800783b017f5c6d7e4883fb4801a9c569245bd04135f7c00806"
4851
+ ), 5, false]
4852
+ ];
4853
+ const syntheticSlices = [
4854
+ ["an escape inside first_mb_in_slice", sliceNal(ue(2 ** 24 - 1) + ue(2)), 2],
4855
+ ["an escape between the fields", sliceNal(ue(2 ** 21 - 1) + ue(7)), 7],
4856
+ ["an escape inside slice_type", sliceNal(ue(0) + ue(2 ** 22 - 1)), 2 ** 22 - 1],
4857
+ ["the longest fields, five escapes", sliceNal(ue(2 ** 30 - 1) + ue(2 ** 30 - 1)), 2 ** 30 - 1],
4858
+ ["the largest values", sliceNal(ue(2 ** 31 - 2) + ue(2 ** 31 - 2)), 2 ** 31 - 2],
4859
+ ["31 leading zeros in first_mb_in_slice", sliceNal(`${"0".repeat(31)}1`), null],
4860
+ ["31 leading zeros in slice_type", sliceNal(`1${"0".repeat(31)}1`), null],
4861
+ ["escapes running past the slice header", sliceNal(ue(0) + ue(5) + "0".repeat(400)), 5]
4862
+ ];
4863
+ test("reads the slice_type of real and synthetic slices", () => {
4864
+ for (const [name, nal, sliceType] of [...x264Slices, ...syntheticSlices]) {
4865
+ expect(readH264SliceType(nal), name).toBe(sliceType);
4866
+ }
4867
+ });
4868
+ test("matches the whole-NAL unescape at every truncation", () => {
4869
+ for (const [name, nal] of [...x264Slices, ...syntheticSlices]) {
4870
+ for (let end = 0; end <= nal.length; end++) {
4871
+ const cut = nal.subarray(0, end);
4872
+ expect(readH264SliceType(cut), `${name}, first ${end} bytes`).toBe(wholeNalSliceType(cut));
4873
+ }
4874
+ }
4875
+ });
4876
+ test("matches the whole-NAL unescape on zero-heavy NAL units", () => {
4877
+ const bytes = [0, 0, 0, 3, 1, 2, 128, 255];
4878
+ let seed = 1;
4879
+ const next = () => (seed = Math.imul(seed, 1103515245) + 12345 >>> 0) >>> 16;
4880
+ for (let i = 0; i < 5e3; i++) {
4881
+ const nal = new Uint8Array(2 + next() % 63);
4882
+ nal[0] = 65;
4883
+ for (let j = 1; j < nal.length; j++) nal[j] = bytes[next() % bytes.length];
4884
+ expect(readH264SliceType(nal), Array.from(nal).join()).toBe(wholeNalSliceType(nal));
4885
+ }
4886
+ });
4887
+ test("classifies the x264 slices as keyframes or not", () => {
4888
+ for (const [name, nal, , keyframe] of x264Slices) {
4889
+ expect(classifyH264Keyframe(rawH264NalToAvcc(nal), { allowPartialAvcc: true }), name).toBe(keyframe);
4890
+ }
4891
+ });
4892
+ });
4802
4893
  describe("avccToAnnexB", () => {
4803
4894
  test("converts with SPS/PPS on keyframe", () => {
4804
4895
  const avcc = new Uint8Array([0, 0, 0, 3, 101, 170, 187]);
@@ -6005,7 +6096,10 @@ var BlockcastMmt = (() => {
6005
6096
  function ssIdAfter(a, b) {
6006
6097
  return (a - b | 0) > 0;
6007
6098
  }
6008
- var _streams2, _gate, _emit2, _recordStat2, _deferDepth, _deferredStreams, _FecReleaseSequencer_instances, drainUnlessDeferred_fn, streamFor_fn2, drain_fn, release_fn;
6099
+ function holdsRebuilt(stream) {
6100
+ return stream.buf.some(({ meta }) => meta.fecSbnFirst !== void 0);
6101
+ }
6102
+ var _streams2, _gate, _emit2, _recordStat2, _deferDepth, _deferredStreams, _FecReleaseSequencer_instances, drainUnlessDeferred_fn, streamFor_fn2, drain_fn, drainLoop_fn, unrepairableWaitOver_fn, cursorPassed_fn, release_fn;
6009
6103
  var FecReleaseSequencer = class {
6010
6104
  constructor(gate, emit, recordStat) {
6011
6105
  __privateAdd(this, _FecReleaseSequencer_instances);
@@ -6065,6 +6159,7 @@ var BlockcastMmt = (() => {
6065
6159
  stream.lastSbn = void 0;
6066
6160
  stream.discontinuity = false;
6067
6161
  stream.rapSsId = void 0;
6162
+ stream.sourced = false;
6068
6163
  }
6069
6164
  if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
6070
6165
  __privateGet(this, _recordStat2).call(this, "droppedStale");
@@ -6091,6 +6186,7 @@ var BlockcastMmt = (() => {
6091
6186
  if (compareFrameOrder(stream.buf[mid], frame) < 0) lo = mid + 1;
6092
6187
  else hi = mid;
6093
6188
  }
6189
+ if (stream.buf[lo]?.passed === true) frame.passed = true;
6094
6190
  stream.buf.splice(lo, 0, frame);
6095
6191
  __privateMethod(this, _FecReleaseSequencer_instances, drainUnlessDeferred_fn).call(this, stream);
6096
6192
  }
@@ -6126,6 +6222,41 @@ var BlockcastMmt = (() => {
6126
6222
  }
6127
6223
  return false;
6128
6224
  }
6225
+ /**
6226
+ * These streams' sink is being replaced by one that has seen no source
6227
+ * frame yet. First, from a stream that holds a frame the overlay rebuilt,
6228
+ * release to the sink being replaced the frames the unanchored path had
6229
+ * already released to it (#cursorPassed): there they waited in its queue,
6230
+ * which its replacement flushes. A stream that holds none is not drained:
6231
+ * it holds nothing the anchor kept back, and a drain would still force out
6232
+ * a frame held past the hold limit, which before the anchor waited for the
6233
+ * next push. Then treat the streams as unsourced until a source frame is
6234
+ * released.
6235
+ */
6236
+ unsource(packetId, catalogTrackName) {
6237
+ for (const stream of __privateGet(this, _streams2).values()) {
6238
+ if (stream.packetId === packetId && (catalogTrackName === void 0 || stream.catalogTrackName === catalogTrackName)) {
6239
+ if (stream.draining === 0 && holdsRebuilt(stream)) {
6240
+ if (__privateGet(this, _deferDepth) > 0) __privateGet(this, _deferredStreams).add(stream);
6241
+ else __privateMethod(this, _FecReleaseSequencer_instances, drain_fn).call(this, stream, true);
6242
+ }
6243
+ stream.sourced = false;
6244
+ }
6245
+ }
6246
+ }
6247
+ /**
6248
+ * Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
6249
+ * (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
6250
+ * packetId.
6251
+ */
6252
+ holdsRebuilt(packetId, catalogTrackName) {
6253
+ for (const stream of __privateGet(this, _streams2).values()) {
6254
+ if (stream.packetId !== packetId) continue;
6255
+ if (catalogTrackName !== void 0 && stream.catalogTrackName !== catalogTrackName) continue;
6256
+ if (holdsRebuilt(stream)) return true;
6257
+ }
6258
+ return false;
6259
+ }
6129
6260
  /** Re-evaluate held gaps after FEC state changed. */
6130
6261
  poke(streamKey) {
6131
6262
  if (streamKey !== void 0) {
@@ -6229,16 +6360,32 @@ var BlockcastMmt = (() => {
6229
6360
  last: null,
6230
6361
  lastSbn: void 0,
6231
6362
  discontinuity: false,
6232
- rapSsId: void 0
6363
+ rapSsId: void 0,
6364
+ sourced: false,
6365
+ draining: 0
6233
6366
  };
6234
6367
  __privateGet(this, _streams2).set(streamKey, stream);
6235
6368
  }
6236
6369
  return stream;
6237
6370
  };
6238
- drain_fn = function(stream) {
6371
+ /** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
6372
+ drain_fn = function(stream, asUnanchored = false) {
6373
+ stream.draining++;
6374
+ try {
6375
+ __privateMethod(this, _FecReleaseSequencer_instances, drainLoop_fn).call(this, stream, asUnanchored);
6376
+ } finally {
6377
+ stream.draining--;
6378
+ }
6379
+ };
6380
+ drainLoop_fn = function(stream, asUnanchored) {
6239
6381
  while (stream.buf.length > 0 && stream.last !== null) {
6240
6382
  const head = stream.buf[0];
6241
6383
  const last = stream.last;
6384
+ if (compareFrameOrder(head, last) <= 0) {
6385
+ stream.buf.shift();
6386
+ __privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, void 0);
6387
+ continue;
6388
+ }
6242
6389
  if (stream.discontinuity) {
6243
6390
  stream.discontinuity = false;
6244
6391
  stream.buf.shift();
@@ -6252,9 +6399,10 @@ var BlockcastMmt = (() => {
6252
6399
  }
6253
6400
  const headSbn = head.meta.fecSbn;
6254
6401
  const from = stream.lastSbn ?? headSbn;
6255
- const to = headSbn ?? stream.lastSbn;
6402
+ const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn;
6256
6403
  let lost = [];
6257
6404
  const unanchored = from === void 0 && to === void 0;
6405
+ let unresolved = false;
6258
6406
  if (from !== void 0 && to !== void 0) {
6259
6407
  const resolved = __privateGet(this, _gate).resolvedLoss(
6260
6408
  stream.packetId,
@@ -6263,7 +6411,8 @@ var BlockcastMmt = (() => {
6263
6411
  Math.max(from, to),
6264
6412
  from
6265
6413
  );
6266
- if (resolved === null) {
6414
+ unresolved = resolved === null;
6415
+ if (unresolved && !__privateMethod(this, _FecReleaseSequencer_instances, cursorPassed_fn).call(this, stream, asUnanchored) && !__privateMethod(this, _FecReleaseSequencer_instances, unrepairableWaitOver_fn).call(this, last, head, from, to)) {
6267
6416
  const heldMs = performance.now() - head.arrivedAtMs;
6268
6417
  if (heldMs <= __privateGet(this, _gate).holdLimitMs(stream.packetId, stream.catalogTrackName)) return;
6269
6418
  __privateGet(this, _recordStat2).call(this, "forcedWindowFlushes");
@@ -6271,18 +6420,57 @@ var BlockcastMmt = (() => {
6271
6420
  __privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, __privateGet(this, _gate).decide(last, head, [], true));
6272
6421
  continue;
6273
6422
  }
6274
- lost = resolved;
6423
+ lost = resolved ?? [];
6275
6424
  }
6276
6425
  stream.buf.shift();
6277
- __privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, lost.length > 0 || unanchored || authoredGap(last.meta, head.meta) ? __privateGet(this, _gate).decide(last, head, lost, false) : void 0);
6426
+ __privateMethod(this, _FecReleaseSequencer_instances, release_fn).call(this, stream, head, lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta) ? __privateGet(this, _gate).decide(last, head, lost, false) : void 0);
6278
6427
  }
6279
6428
  };
6429
+ /** The head has waited out a gap only a late source can still fill (FecReleaseGate.unrepairableWaitMs). */
6430
+ unrepairableWaitOver_fn = function(last, head, from, to) {
6431
+ const waitMs = __privateGet(this, _gate).unrepairableWaitMs?.(last, head, from, to);
6432
+ return waitMs !== void 0 && performance.now() - head.arrivedAtMs >= waitMs;
6433
+ };
6434
+ /**
6435
+ * An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
6436
+ * source cursor holds it unanchored, and neither does a later frame behind
6437
+ * it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
6438
+ * fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
6439
+ * like each frame that arrived in front of it since (stale there). The head
6440
+ * then goes, decided as it would be unanchored, once a frame the base path
6441
+ * delivered (a source frame, or one base FEC recovered) is buffered after a
6442
+ * marked one: the base path has passed that one, so a frame still missing
6443
+ * before it can only come from a repair. It also goes while no source frame
6444
+ * has been released, when the direct path shows a recovered frame at once.
6445
+ * And it goes at once while a staged switch decides on when frames arrive
6446
+ * (FecReleaseGate.releaseUnanchored), and when unsource releases into a
6447
+ * sink being replaced: unanchored, it had already reached the sink.
6448
+ * The scan also writes: the `passed` marks it sets stay on the frames,
6449
+ * and push marks a frame it inserts in front of a marked one from them.
6450
+ */
6451
+ cursorPassed_fn = function(stream, asUnanchored) {
6452
+ let at = -1;
6453
+ for (let i = 0; i < stream.buf.length; i++) {
6454
+ const frame = stream.buf[i];
6455
+ if (frame.meta.fecSbnFirst !== void 0 || frame.meta.fecSbn === void 0) {
6456
+ frame.passed = true;
6457
+ if (at < 0) at = i;
6458
+ } else if (frame.passed !== true) break;
6459
+ }
6460
+ if (at < 0) return false;
6461
+ return asUnanchored || !stream.sourced || __privateGet(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));
6462
+ };
6280
6463
  release_fn = function(stream, frame, decision) {
6464
+ const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0;
6465
+ if (stale) __privateGet(this, _recordStat2).call(this, "droppedStale");
6281
6466
  if (decision) frame.meta.gapBefore = decision;
6282
6467
  stream.last = frame;
6283
- if (frame.meta.fecSbn !== void 0) stream.lastSbn = frame.meta.fecSbn;
6468
+ if (frame.meta.fecSbn !== void 0 && (frame.meta.fecSbnFirst === void 0 || stream.lastSbn !== void 0)) {
6469
+ stream.lastSbn = frame.meta.fecSbn;
6470
+ }
6471
+ if (frame.meta.recovered !== true) stream.sourced = true;
6284
6472
  __privateGet(this, _gate).onReleased?.(frame.data, frame.meta);
6285
- __privateGet(this, _emit2).call(this, frame.data, frame.meta);
6473
+ if (!stale) __privateGet(this, _emit2).call(this, frame.data, frame.meta);
6286
6474
  };
6287
6475
  var FMPU_BOX_TYPES = /* @__PURE__ */ new Set(["ftyp", "moov", "moof"]);
6288
6476
  function isFmp4Box(data) {
@@ -6460,11 +6648,12 @@ var BlockcastMmt = (() => {
6460
6648
  /**
6461
6649
  * Typed view of the ISO-BMFF timing-sample budget.
6462
6650
  *
6463
- * This is the acceptance signal for the budget ratchet: `pending` walking
6464
- * to `capacity` while `rejectedMovieFragments` climbs is the stream wedging,
6465
- * and it is observable here rather than only as media silently stopping.
6466
- * Per repo policy this is a producer-owned counter -- never infer budget
6467
- * state by parsing logs.
6651
+ * Each stream admits timing against its own window of `capacity` slots
6652
+ * (BLO-52085). A stream at capacity displaces its own oldest timing to
6653
+ * admit the moof in hand, and `evicted` counts the slots so displaced:
6654
+ * timing a stream declared and never delivered shows up there. `pending`
6655
+ * sums every stream, so it can exceed `capacity`. Per repo policy this is
6656
+ * a producer-owned counter -- never infer budget state by parsing logs.
6468
6657
  */
6469
6658
  get timingBudgetStats() {
6470
6659
  return {
@@ -6524,6 +6713,14 @@ var BlockcastMmt = (() => {
6524
6713
  fecReleaseRapAbove(packetId, catalogTrackName, ssId) {
6525
6714
  return __privateGet(this, _fecSequencer)?.rapAbove(packetId, catalogTrackName, ssId) ?? false;
6526
6715
  }
6716
+ /** See FecReleaseSequencer.unsource. */
6717
+ unsourceFecRelease(packetId, catalogTrackName) {
6718
+ __privateGet(this, _fecSequencer)?.unsource(packetId, catalogTrackName);
6719
+ }
6720
+ /** See FecReleaseSequencer.holdsRebuilt. */
6721
+ fecReleaseHoldsRebuilt(packetId, catalogTrackName) {
6722
+ return __privateGet(this, _fecSequencer)?.holdsRebuilt(packetId, catalogTrackName) ?? false;
6723
+ }
6527
6724
  /** Re-evaluate held gaps after FEC block state changed. */
6528
6725
  pokeFecRelease(packetId, catalogTrackName) {
6529
6726
  if (!__privateGet(this, _fecSequencer)) return;
@@ -7080,7 +7277,7 @@ var BlockcastMmt = (() => {
7080
7277
  if (!resolver2?.initialized) return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, "fragment-no-resolver");
7081
7278
  const pendingBefore = resolver2.pendingSampleCount;
7082
7279
  const evictedBefore = resolver2.evictedSampleCount;
7083
- const remaining = __privateGet(this, _maxPendingTimingSamples) - __privateGet(this, _pendingTimingSamples);
7280
+ const remaining = __privateGet(this, _maxPendingTimingSamples) - resolver2.pendingSampleCount;
7084
7281
  const admitted = resolver2.addMovieFragment(
7085
7282
  mpu.mpuSequenceNumber,
7086
7283
  data,
@@ -7148,7 +7345,7 @@ var BlockcastMmt = (() => {
7148
7345
  headTiming.size
7149
7346
  );
7150
7347
  if (readyOnRegister) {
7151
- const deferred = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, readyOnRegister, info, resolver, options?.recovered === true, options?.fecSbn);
7348
+ const deferred = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, readyOnRegister, info, resolver, options?.recovered === true, options?.fecSbn, options?.fecSbnFirst);
7152
7349
  if (deferred.record === void 0) __privateMethod(this, _MmtpContainerParser_instances, countDeferredOutcome_fn).call(this, deferred.reason);
7153
7350
  }
7154
7351
  }
@@ -7235,7 +7432,7 @@ var BlockcastMmt = (() => {
7235
7432
  fragmentCounter: mpu.fragmentCounter
7236
7433
  };
7237
7434
  }
7238
- const outcome = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, combined, info, resolver, options?.recovered === true, options?.fecSbn);
7435
+ const outcome = __privateMethod(this, _MmtpContainerParser_instances, emitCombinedSample_fn).call(this, combined, info, resolver, options?.recovered === true, options?.fecSbn, options?.fecSbnFirst);
7239
7436
  if (outcome.record !== void 0) return outcome.record;
7240
7437
  return __privateMethod(this, _MmtpContainerParser_instances, drop_fn).call(this, outcome.reason);
7241
7438
  };
@@ -7254,7 +7451,7 @@ var BlockcastMmt = (() => {
7254
7451
  * attribution exists to keep readable. Leaving the choice at the call site
7255
7452
  * is what keeps both true.
7256
7453
  */
7257
- emitCombinedSample_fn = function(combined, info, resolver, recovered, fecSbn) {
7454
+ emitCombinedSample_fn = function(combined, info, resolver, recovered, fecSbn, fecSbnFirst) {
7258
7455
  const timing = resolver.sampleTiming(
7259
7456
  combined.mpuSequenceNumber,
7260
7457
  combined.movieFragmentSequenceNumber,
@@ -7265,6 +7462,7 @@ var BlockcastMmt = (() => {
7265
7462
  const meta = __privateMethod(this, _MmtpContainerParser_instances, buildFrameMeta_fn).call(this, combined, info.packetId, info.sequenceNumber, timing, recovered);
7266
7463
  if (!meta) return { reason: "combined-meta-build-failed" };
7267
7464
  if (fecSbn !== void 0) meta.fecSbn = fecSbn;
7465
+ if (fecSbnFirst !== void 0) meta.fecSbnFirst = fecSbnFirst;
7268
7466
  if (!resolver.consumeSample(
7269
7467
  combined.mpuSequenceNumber,
7270
7468
  combined.movieFragmentSequenceNumber,