@blockcast/mmt-container 0.4.0-main.bb90ce9247fa → 0.4.0-main.bbdfdbf39ded

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 (205) hide show
  1. package/README.md +36 -20
  2. package/dist/align.d.ts +24 -18
  3. package/dist/align.d.ts.map +1 -1
  4. package/dist/align.js +23 -4
  5. package/dist/align.js.map +2 -2
  6. package/dist/browser-runtime.js +1721 -705
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +72 -34
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +309 -204
  11. package/dist/carp-catalog.js.map +3 -3
  12. package/dist/catalog-fec-params.d.ts +15 -4
  13. package/dist/catalog-fec-params.d.ts.map +1 -1
  14. package/dist/catalog-fec-params.js +137 -50
  15. package/dist/catalog-fec-params.js.map +4 -4
  16. package/dist/catalog-network-source.d.ts +24 -2
  17. package/dist/catalog-network-source.d.ts.map +1 -1
  18. package/dist/catalog-network-source.js +24 -1
  19. package/dist/catalog-network-source.js.map +3 -3
  20. package/dist/catalog-validator.d.ts +4 -3
  21. package/dist/catalog-validator.d.ts.map +1 -1
  22. package/dist/catalog-validator.js +0 -29
  23. package/dist/catalog-validator.js.map +3 -3
  24. package/dist/delivery-catalog.js +100 -230
  25. package/dist/delivery-catalog.js.map +4 -4
  26. package/dist/fec-manager.d.ts +64 -1
  27. package/dist/fec-manager.d.ts.map +1 -1
  28. package/dist/fec-manager.js +275 -62
  29. package/dist/fec-manager.js.map +4 -4
  30. package/dist/fec-state.d.ts +5 -3
  31. package/dist/fec-state.d.ts.map +1 -1
  32. package/dist/fec-state.js +34 -12
  33. package/dist/fec-state.js.map +4 -4
  34. package/dist/fec-worker-setup.d.ts +2 -0
  35. package/dist/fec-worker-setup.d.ts.map +1 -1
  36. package/dist/fec-worker-setup.js +15 -3
  37. package/dist/fec-worker-setup.js.map +3 -3
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +14 -8
  41. package/dist/index.js.map +2 -2
  42. package/dist/iso-block-locator.d.ts +29 -0
  43. package/dist/iso-block-locator.d.ts.map +1 -1
  44. package/dist/iso-block-locator.js +100 -17
  45. package/dist/iso-block-locator.js.map +4 -4
  46. package/dist/manifest-auth-plan.d.ts +26 -25
  47. package/dist/manifest-auth-plan.d.ts.map +1 -1
  48. package/dist/manifest-auth-plan.js +331 -1171
  49. package/dist/manifest-auth-plan.js.map +4 -4
  50. package/dist/mfu-reassembler.js +24 -13
  51. package/dist/mfu-reassembler.js.map +3 -3
  52. package/dist/mmtp-container-parser.d.ts.map +1 -1
  53. package/dist/mmtp-container-parser.js +96 -22
  54. package/dist/mmtp-container-parser.js.map +3 -3
  55. package/dist/mmtp-container-parser.no-modules.js +1138 -325
  56. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  57. package/dist/mmtp-decode-pipeline.js +96 -22
  58. package/dist/mmtp-decode-pipeline.js.map +3 -3
  59. package/dist/mmtp-fec-session.d.ts +159 -0
  60. package/dist/mmtp-fec-session.d.ts.map +1 -0
  61. package/dist/mmtp-fec-session.js +531 -0
  62. package/dist/mmtp-fec-session.js.map +7 -0
  63. package/dist/mmtp-router.d.ts +31 -5
  64. package/dist/mmtp-router.d.ts.map +1 -1
  65. package/dist/mmtp-router.js +168 -22
  66. package/dist/mmtp-router.js.map +3 -3
  67. package/dist/multicast-auth-catalog.d.ts +86 -92
  68. package/dist/multicast-auth-catalog.d.ts.map +1 -1
  69. package/dist/multicast-auth-catalog.js +347 -132
  70. package/dist/multicast-auth-catalog.js.map +4 -4
  71. package/dist/multicast-input.d.ts +28 -6
  72. package/dist/multicast-input.d.ts.map +1 -1
  73. package/dist/multicast-input.js +293 -28
  74. package/dist/multicast-input.js.map +3 -3
  75. package/dist/multicast-manager.d.ts +89 -5
  76. package/dist/multicast-manager.d.ts.map +1 -1
  77. package/dist/multicast-manager.js +730 -356
  78. package/dist/multicast-manager.js.map +4 -4
  79. package/dist/multicast-transport.d.ts +12 -2
  80. package/dist/multicast-transport.d.ts.map +1 -1
  81. package/dist/multicast-transport.js +111 -235
  82. package/dist/multicast-transport.js.map +4 -4
  83. package/dist/multicast-unwrap.js +24 -13
  84. package/dist/multicast-unwrap.js.map +3 -3
  85. package/dist/no-modules.d.ts +4 -1
  86. package/dist/no-modules.d.ts.map +1 -1
  87. package/dist/no-modules.js +1087 -309
  88. package/dist/no-modules.js.map +4 -4
  89. package/dist/phase14-catalog-override.d.ts +1 -1
  90. package/dist/phase14-catalog-override.d.ts.map +1 -1
  91. package/dist/phase14-catalog-override.js +2 -2
  92. package/dist/phase14-catalog-override.js.map +2 -2
  93. package/dist/repair-fetch.d.ts +81 -6
  94. package/dist/repair-fetch.d.ts.map +1 -1
  95. package/dist/repair-fetch.js +159 -31
  96. package/dist/repair-fetch.js.map +3 -3
  97. package/dist/repair-layers.d.ts +2 -0
  98. package/dist/repair-layers.d.ts.map +1 -1
  99. package/dist/repair-layers.js +22 -2
  100. package/dist/repair-layers.js.map +3 -3
  101. package/dist/sample-combiner.d.ts +7 -1
  102. package/dist/sample-combiner.d.ts.map +1 -1
  103. package/dist/sample-combiner.js +14 -2
  104. package/dist/sample-combiner.js.map +2 -2
  105. package/dist/signaling.d.ts +2 -2
  106. package/dist/signaling.d.ts.map +1 -1
  107. package/dist/signaling.js +6 -3
  108. package/dist/signaling.js.map +3 -3
  109. package/dist/source-auth.js +2710 -7
  110. package/dist/source-auth.js.map +4 -4
  111. package/dist/switching-set-alignment.d.ts +1 -1
  112. package/dist/switching-set-alignment.js.map +1 -1
  113. package/dist/timestamp-codec.js +24 -13
  114. package/dist/timestamp-codec.js.map +3 -3
  115. package/dist/wasm-mfu-reassembler.js +3 -0
  116. package/dist/wasm-mfu-reassembler.js.map +3 -3
  117. package/dist/wasm-mmtp-container-parser.js +96 -22
  118. package/dist/wasm-mmtp-container-parser.js.map +3 -3
  119. package/package.json +6 -9
  120. package/schemas/catalog.schema.json +124 -37
  121. package/src/align.ts +52 -21
  122. package/src/carp-catalog.ts +163 -61
  123. package/src/catalog-fec-params.ts +66 -20
  124. package/src/catalog-network-source.ts +45 -2
  125. package/src/catalog-validator.ts +4 -11
  126. package/src/fec-manager.ts +239 -63
  127. package/src/fec-state.ts +14 -12
  128. package/src/fec-worker-setup.ts +20 -2
  129. package/src/index.ts +29 -10
  130. package/src/iso-block-locator.ts +97 -6
  131. package/src/manifest-auth-plan.ts +39 -91
  132. package/src/mmtp-container-parser.ts +75 -7
  133. package/src/mmtp-fec-session.ts +533 -0
  134. package/src/mmtp-router.ts +133 -5
  135. package/src/multicast-auth-catalog.ts +131 -238
  136. package/src/multicast-input.ts +119 -61
  137. package/src/multicast-manager.ts +258 -21
  138. package/src/multicast-transport.ts +17 -3
  139. package/src/no-modules.ts +7 -1
  140. package/src/phase14-catalog-override.ts +3 -3
  141. package/src/repair-fetch.ts +283 -39
  142. package/src/repair-layers.ts +22 -2
  143. package/src/sample-combiner.ts +15 -2
  144. package/src/signaling.ts +2 -2
  145. package/src/switching-set-alignment.ts +1 -1
  146. package/test-vectors/align.json +108 -32
  147. package/test-vectors/bc-provenance-v2.json +1526 -0
  148. package/test-vectors/catalog/README.md +65 -4
  149. package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
  150. package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
  151. package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
  152. package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
  153. package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
  154. package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
  155. package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
  156. package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
  157. package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
  158. package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
  159. package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
  160. package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
  161. package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
  162. package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
  163. package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
  164. package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
  165. package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
  166. package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
  167. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
  168. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
  169. package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
  170. package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
  171. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
  172. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
  173. package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
  174. package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
  175. package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
  176. package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
  177. package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
  178. package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
  179. package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
  180. package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
  181. package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
  182. package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
  183. package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
  184. package/test-vectors/catalog/positive/fec-multicast.json +1 -1
  185. package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
  186. package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
  187. package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
  188. package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
  189. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +2 -2
  190. package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
  191. package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
  192. package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
  193. package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
  194. package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
  195. package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
  196. package/test-vectors/catalog/section-codes.json +30 -1
  197. package/test-vectors/catalog-multicast-auth-v1.json +38 -20
  198. package/test-vectors/catalog-validation.json +101 -5
  199. package/test-vectors/catalog-validator-public-api.mjs +14 -9
  200. package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
  201. package/dist/fec-codec.d.ts +0 -32
  202. package/dist/fec-codec.d.ts.map +0 -1
  203. package/dist/fec-codec.js +0 -47
  204. package/dist/fec-codec.js.map +0 -7
  205. package/src/fec-codec.ts +0 -61
@@ -181,18 +181,11 @@ function isoBlocksBehindLowerBound(a, b, kMax) {
181
181
  return serial32Precedes(a, b) ? Math.floor(serial32Distance(a, b) / kMax) : 0;
182
182
  }
183
183
 
184
+ // ../mmt-base/dist/catalog-fec-source.js
185
+ var ALL_ROLES = Object.freeze(["video", "audio"]);
186
+
184
187
  // src/iso-block-locator.ts
185
188
  var IsoBlockLocator = class _IsoBlockLocator {
186
- /** Known blocks and spans, in serial order of their start. */
187
- #blocks = [];
188
- /** Held first-arrival sources whose block no repair has stated yet. */
189
- #held = /* @__PURE__ */ new Map();
190
- /** End of contiguous coverage: the SS_ID the next unknown block starts at. */
191
- #coverageEnd;
192
- #kMax;
193
- #retentionBlocks;
194
- #heldEvicted = 0;
195
- #newest;
196
189
  /**
197
190
  * @param kMax the catalog maximum K (`sourceSymbols`), the bound on SSB_length.
198
191
  * @param retentionBlocks how many blocks behind the newest position the
@@ -200,12 +193,35 @@ var IsoBlockLocator = class _IsoBlockLocator {
200
193
  * no locator exists without retention.
201
194
  */
202
195
  constructor(kMax, retentionBlocks) {
196
+ /** Known blocks and spans, in serial order of their start. */
197
+ this.#blocks = [];
198
+ /** Held first-arrival sources whose block no repair has stated yet. */
199
+ this.#held = /* @__PURE__ */ new Map();
200
+ this.#heldEvicted = 0;
201
+ /** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
202
+ this.#holes = [];
203
+ /**
204
+ * Keep a gap that is missing a source as a pending hole rather than a span,
205
+ * so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
206
+ * its blocks. Set only while a range repair scheduler is wired; its owner
207
+ * must close every hole it is told about (`closeHolesWithin`).
208
+ */
209
+ this.deferIncompleteGaps = false;
203
210
  if (!Number.isSafeInteger(kMax) || kMax <= 0) {
204
211
  throw new Error(`[IsoBlockLocator] maximum K must be a positive integer (got ${kMax})`);
205
212
  }
206
213
  this.#kMax = kMax;
207
214
  this.#retentionBlocks = _IsoBlockLocator.#checkedRetention(retentionBlocks);
208
215
  }
216
+ #blocks;
217
+ #held;
218
+ /** End of contiguous coverage: the SS_ID the next unknown block starts at. */
219
+ #coverageEnd;
220
+ #kMax;
221
+ #retentionBlocks;
222
+ #heldEvicted;
223
+ #newest;
224
+ #holes;
209
225
  static #checkedRetention(retentionBlocks) {
210
226
  if (!Number.isSafeInteger(retentionBlocks) || retentionBlocks <= 0) {
211
227
  throw new Error(
@@ -268,6 +284,14 @@ var IsoBlockLocator = class _IsoBlockLocator {
268
284
  }
269
285
  return null;
270
286
  }
287
+ /** Number of pending holes. */
288
+ get holeCount() {
289
+ return this.#holes.length;
290
+ }
291
+ /** The stated block (never a span) ending exactly at `end`. */
292
+ blockEndingAt(end) {
293
+ return this.#blocks.find((block) => !block.span && isoBlockEnd(block.start, block.length) === end);
294
+ }
271
295
  /** The known block or span starting exactly at `start`. */
272
296
  blockAt(start) {
273
297
  return this.#blocks.find((block) => block.start === start);
@@ -290,6 +314,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
290
314
  coversBetween(a, b) {
291
315
  if (this.#coverageEnd === void 0) return false;
292
316
  if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return true;
317
+ const first = a + 1 >>> 0;
318
+ const count = serial32Distance(a, b) - 1;
319
+ if (this.#holes.some((hole) => isoRangesOverlap(first, count, hole.start, hole.length))) return false;
293
320
  return serial32Precedes(b - 1 >>> 0, this.#coverageEnd);
294
321
  }
295
322
  /**
@@ -337,6 +364,22 @@ var IsoBlockLocator = class _IsoBlockLocator {
337
364
  }
338
365
  return { status: "placed", block: known, placed: [] };
339
366
  }
367
+ const pending = this.#holes.find((h) => isoBlockContains(h.start, h.length, start));
368
+ if (pending !== void 0) {
369
+ if (!isoBlockContains(pending.start, pending.length, serial32Add(start, length - 1))) {
370
+ return { status: "overlap", reason: `repair block ${start}+${length} runs past pending hole ${pending.start}+${pending.length}` };
371
+ }
372
+ this.#holes.splice(this.#holes.indexOf(pending), 1);
373
+ const before = serial32Distance(pending.start, start);
374
+ const afterStart = isoBlockEnd(start, length);
375
+ const after = pending.length - before - length;
376
+ if (before > 0) this.#holes.push({ start: pending.start, length: before, span: false });
377
+ if (after > 0) this.#holes.push({ start: afterStart, length: after, span: false });
378
+ const block2 = { start, length, span: false };
379
+ const placed2 = this.#claim(block2);
380
+ this.#blocks.push(block2);
381
+ return { status: "placed", block: block2, placed: placed2 };
382
+ }
340
383
  for (const block2 of this.#blocks) {
341
384
  if (isoBlockContains(block2.start, block2.length, start) || isoBlockContains(start, length, block2.start)) {
342
385
  return {
@@ -346,6 +389,7 @@ var IsoBlockLocator = class _IsoBlockLocator {
346
389
  }
347
390
  }
348
391
  let span;
392
+ let hole;
349
393
  if (this.#coverageEnd === void 0) {
350
394
  for (const ssId of this.#held.keys()) {
351
395
  if (serial32Precedes(ssId, start)) this.#held.delete(ssId);
@@ -354,21 +398,51 @@ var IsoBlockLocator = class _IsoBlockLocator {
354
398
  } else if (serial32Precedes(start, this.#coverageEnd)) {
355
399
  return { status: "stale", reason: `repair block ${start}+${length} precedes known coverage` };
356
400
  } else if (start !== this.#coverageEnd) {
357
- const spanBlock = {
358
- start: this.#coverageEnd,
359
- length: serial32Distance(this.#coverageEnd, start),
360
- span: true
361
- };
362
- span = { block: spanBlock, placed: this.#claim(spanBlock) };
363
- this.#blocks.push(spanBlock);
401
+ const gap = { start: this.#coverageEnd, length: serial32Distance(this.#coverageEnd, start) };
402
+ const lostSsId = this.deferIncompleteGaps ? this.#highestMissing(gap.start, gap.length) : void 0;
403
+ if (lostSsId !== void 0) {
404
+ const holeBlock = { ...gap, span: false };
405
+ this.#holes.push(holeBlock);
406
+ hole = { block: holeBlock, lostSsId };
407
+ } else {
408
+ const spanBlock = { ...gap, span: true };
409
+ span = { block: spanBlock, placed: this.#claim(spanBlock) };
410
+ this.#blocks.push(spanBlock);
411
+ }
364
412
  }
365
413
  const block = { start, length, span: false };
366
414
  const placed = this.#claim(block);
367
415
  this.#blocks.push(block);
368
416
  this.#coverageEnd = isoBlockEnd(start, length);
369
417
  this.retireBehind(start);
418
+ if (hole !== void 0) return { status: "placed", block, placed, hole };
370
419
  return span === void 0 ? { status: "placed", block, placed } : { status: "placed", block, placed, span };
371
420
  }
421
+ /**
422
+ * Turn every pending hole inside `[start, start + length)` into a
423
+ * repair-less span, claiming its held sources: its range FETCH ended, so
424
+ * nothing more will state its blocks. Returns the spans, in SS_ID order.
425
+ */
426
+ closeHolesWithin(start, length) {
427
+ const closed = [];
428
+ for (const hole of [...this.#holes]) {
429
+ if (!isoBlockContains(start, length, hole.start)) continue;
430
+ this.#holes.splice(this.#holes.indexOf(hole), 1);
431
+ const spanBlock = { start: hole.start, length: hole.length, span: true };
432
+ closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
433
+ this.#blocks.push(spanBlock);
434
+ }
435
+ return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start));
436
+ }
437
+ /** The highest SS_ID in the range no source is held for, or undefined when all are. */
438
+ #highestMissing(start, length) {
439
+ const steps = Math.min(length, this.#held.size + 1);
440
+ for (let i = 1; i <= steps; i++) {
441
+ const ssId = serial32Add(start, length - i);
442
+ if (!this.#held.has(ssId)) return ssId;
443
+ }
444
+ return void 0;
445
+ }
372
446
  /**
373
447
  * Retire every block and span whose last SS_ID, and every held source,
374
448
  * lies more than `retentionBlocks` blocks behind `position`, with the shared
@@ -387,6 +461,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
387
461
  this.#blocks.splice(i, 1);
388
462
  }
389
463
  }
464
+ for (let i = this.#holes.length - 1; i >= 0; i--) {
465
+ const hole = this.#holes[i];
466
+ const last = serial32Add(hole.start, hole.length - 1);
467
+ if (isoBlocksBehindLowerBound(last, position, this.#kMax) > horizon) this.#holes.splice(i, 1);
468
+ }
390
469
  for (const ssId of [...this.#held.keys()]) {
391
470
  if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#held.delete(ssId);
392
471
  }
@@ -395,6 +474,7 @@ var IsoBlockLocator = class _IsoBlockLocator {
395
474
  /** Forget everything (publisher restart, track reset). */
396
475
  reset() {
397
476
  this.#blocks.length = 0;
477
+ this.#holes.length = 0;
398
478
  this.#held.clear();
399
479
  this.#coverageEnd = void 0;
400
480
  this.#newest = void 0;
@@ -410,6 +490,9 @@ var IsoBlockLocator = class _IsoBlockLocator {
410
490
  return placed;
411
491
  }
412
492
  };
493
+ function isoRangesOverlap(aStart, aLength, bStart, bLength) {
494
+ return serial32Distance(aStart, bStart) < aLength || serial32Distance(bStart, aStart) < bLength;
495
+ }
413
496
 
414
497
  // src/fec-state.ts
415
498
  var MIN_INTERLEAVE_DEPTH_MS = 1;
@@ -760,6 +843,7 @@ var BlockClassifier = class {
760
843
  };
761
844
 
762
845
  // src/fec-manager.ts
846
+ var RS_MAX_BLOCK_SYMBOLS = 255;
763
847
  var WORKER_ERROR_LOG_CAP = 5;
764
848
  var WORKER_ERROR_KIND_CAP = 32;
765
849
  var WORKER_ERROR_OVERFLOW_KIND = "other";
@@ -994,12 +1078,17 @@ var FECManager = class _FECManager {
994
1078
  // per stream. Not only throws: the ordinary out-of-range case is detected by
995
1079
  // arithmetic and never throws at all.
996
1080
  this.#orderedHorizonWarnedFor = /* @__PURE__ */ new Set();
997
- // Newest block start (SS_Start) seen per stream and when: the frontier for
998
- // source-discontinuity detection and isoSpanResolution.
1081
+ // Newest block start (SS_Start) any symbol carried per stream and when: the
1082
+ // frontier isoSpanResolution reads.
999
1083
  this.#highestSbn = /* @__PURE__ */ new Map();
1084
+ // The same from source symbols alone: the frontier a source is judged
1085
+ // against for a discontinuity. Repairs ride their own group, which can run
1086
+ // blocks ahead of the media they protect.
1087
+ this.#sourceFrontiers = /* @__PURE__ */ new Map();
1000
1088
  // iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
1001
1089
  // block only once a repair symbol stated the block's (SS_Start, SSB_length).
1002
1090
  this.#isoLocators = /* @__PURE__ */ new Map();
1091
+ this.#deferIsoGaps = false;
1003
1092
  this.#isoRepairRefusedCount = 0;
1004
1093
  this.#isoSourceOversizeCount = 0;
1005
1094
  // Held sources a locator's capacity cap evicted (IsoBlockLocator.heldCapacity):
@@ -1014,8 +1103,8 @@ var FECManager = class _FECManager {
1014
1103
  // rate-limited like the other per-symbol warns here. Cumulative.
1015
1104
  this.#isoDecoderUnplacedRetireFailed = 0;
1016
1105
  // The latest source symbol per stream that carried its MMTP
1017
- // packet_sequence_number: the anchor that bounds how many blocks the
1018
- // producer can have started before a later source symbol.
1106
+ // packet_sequence_number, by its own SS_ID: the anchor that bounds how far
1107
+ // the producer's SS_IDs can have moved before or after another source symbol.
1019
1108
  this.#sourceAnchors = /* @__PURE__ */ new Map();
1020
1109
  // Catalog/reset epoch per packetId. Gap decisions carry it for fencing.
1021
1110
  this.#packetEpochs = /* @__PURE__ */ new Map();
@@ -1074,6 +1163,14 @@ var FECManager = class _FECManager {
1074
1163
  this.onBlockReclassified = null;
1075
1164
  /** A video stream's classifier mode was established or changed. */
1076
1165
  this.onClassifierMode = null;
1166
+ /**
1167
+ * A repair stated a block past a gap that is missing a source and whose
1168
+ * every repair was lost: a lost SS_ID in an undelimited span
1169
+ * (draft-ramadan-moq-fec §7.5). Set with `setUndelimitedLossHandler`; the
1170
+ * receiver keeps the gap as a pending hole until `closeIsoHoles` is called
1171
+ * for it, which it must be.
1172
+ */
1173
+ this.#onUndelimitedLoss = null;
1077
1174
  /** A block every symbol of which vanished was created by SBN evidence. */
1078
1175
  this.onBlockVanished = null;
1079
1176
  /** A block reached a terminal state (completed, recovered, or failed). */
@@ -1153,7 +1250,9 @@ var FECManager = class _FECManager {
1153
1250
  #materializedBlocks;
1154
1251
  #orderedHorizonWarnedFor;
1155
1252
  #highestSbn;
1253
+ #sourceFrontiers;
1156
1254
  #isoLocators;
1255
+ #deferIsoGaps;
1157
1256
  #isoRepairRefusedCount;
1158
1257
  #isoSourceOversizeCount;
1159
1258
  #isoHeldEvictedCount;
@@ -1167,6 +1266,7 @@ var FECManager = class _FECManager {
1167
1266
  #workerErrorCounts;
1168
1267
  #decoderUnavailableEvents;
1169
1268
  #repairSymbolSizeMismatchCount;
1269
+ #onUndelimitedLoss;
1170
1270
  #encodeTrackName(catalogTrackName) {
1171
1271
  let encoded = this.#encodedTrackNames.get(catalogTrackName);
1172
1272
  if (encoded === void 0) {
@@ -1743,8 +1843,8 @@ var FECManager = class _FECManager {
1743
1843
  // Deliberately one block tighter than deriveFecRetentionBlocks over the same
1744
1844
  // inputs (that function's `+ 1`). Different question: the retention horizon
1745
1845
  // asks how long the decoder still ACCEPTS symbols for a block, this asks how
1746
- // many blocks a stream can live behind (or ahead of) its frontier before a
1747
- // source symbol there is a discontinuity rather than loss (see #noteSbnSeen).
1846
+ // many blocks a stream can jump ahead of its frontier before a source symbol
1847
+ // there is a discontinuity rather than loss (see #noteSbnSeen).
1748
1848
  // The extra block of retention is slack for a block still being fed; a block
1749
1849
  // nothing has been heard from does not get it. Not the units defect — but it
1750
1850
  // is the next place the two can drift, so change both or neither.
@@ -1754,55 +1854,72 @@ var FECManager = class _FECManager {
1754
1854
  }
1755
1855
  /**
1756
1856
  * Record that a symbol for block `sbn` (the block's SS_Start) arrived and
1757
- * advance the stream's frontier, the newest block start seen.
1857
+ * advance the stream's frontiers, the newest block start seen.
1758
1858
  *
1759
- * A SOURCE symbol whose block goes back further than one live window, or
1760
- * jumps further than the stream could have produced since its last symbol,
1761
- * is a source discontinuity, not loss. A repair symbol can only advance the
1859
+ * A SOURCE symbol is judged against the newest source block alone: repairs
1860
+ * ride their own group, which can run blocks ahead of the media. One whose
1861
+ * block goes back further than the blocks this manager retains, or that
1862
+ * cannot have been sent before the source it lies behind, or that jumps
1863
+ * further than the stream could have produced since its last symbol, is a
1864
+ * source discontinuity, not loss. A repair symbol can only advance the
1762
1865
  * frontier: a D-28 fetch legitimately answers for an old block, so it never
1763
1866
  * signals a discontinuity.
1764
1867
  *
1765
1868
  * The producer closes a block at its Dth media-unit boundary OR when K
1766
1869
  * source symbols filled it, so one interleave span can start several blocks
1767
- * (every large keyframe does). What bounds a forward jump is therefore
1768
- * packet evidence, not a block rate: SS_ID advances by one per FEC source
1769
- * packet (ISO/IEC 23008-1 C.5.2) and the MMTP packet_sequence_number by one
1770
- * per packet of the packet_id, so with both source symbols'
1771
- * packet_sequence_number a block start can move at most the packets sent
1772
- * between them plus the anchor's own offset into its block (< K). Without
1773
- * it, only the D-close rate is known.
1870
+ * (every large keyframe does). What bounds a jump is therefore packet
1871
+ * evidence, not a block rate: SS_ID advances by one per FEC source packet
1872
+ * (ISO/IEC 23008-1 C.5.2) and the MMTP packet_sequence_number by one per
1873
+ * packet of the packet_id, so with both source symbols'
1874
+ * packet_sequence_number their SS_IDs (`ssId`, not their block starts,
1875
+ * which a repair-less span can put far behind) can move at most the packets
1876
+ * sent between them, in either direction, plus K of slack for sources lost
1877
+ * before a hop that renumbers packets. Without it, only the D-close rate is
1878
+ * known.
1774
1879
  *
1775
1880
  * Vanished blocks are not enumerated here: their starts are unknown until a
1776
1881
  * repair states them. The SS_IDs between two stated blocks become one
1777
1882
  * repair-less span when the later block's repair arrives (placeIsoRepair).
1778
1883
  */
1779
- #noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber) {
1884
+ #noteSbnSeen(sbn, packetId, catalogTrackName, symbol, packetSequenceNumber, ssId = sbn) {
1780
1885
  const streamKey = this.#streamKey(packetId, catalogTrackName);
1781
1886
  const now = performance.now();
1782
- const previous = this.#highestSbn.get(streamKey);
1887
+ const previous = (symbol === "source" ? this.#sourceFrontiers : this.#highestSbn).get(streamKey);
1783
1888
  const anchor = this.#sourceAnchors.get(streamKey);
1784
1889
  const psn = symbol === "source" && packetSequenceNumber !== void 0 && Number.isSafeInteger(packetSequenceNumber) && packetSequenceNumber >= 0 && packetSequenceNumber <= 4294967295 ? packetSequenceNumber : void 0;
1785
1890
  const anchorHere = () => {
1786
- if (psn !== void 0 && (anchor === void 0 || !this.#blockPrecedes(sbn, anchor.sbn))) {
1787
- this.#sourceAnchors.set(streamKey, { sbn, psn, atMs: now });
1891
+ if (psn !== void 0 && (anchor === void 0 || !serial32Precedes(ssId, anchor.ssId))) {
1892
+ this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now });
1788
1893
  }
1789
1894
  };
1895
+ const advance = () => {
1896
+ const highest = this.#highestSbn.get(streamKey);
1897
+ if (highest === void 0 || this.#blockPrecedes(highest.sbn, sbn)) {
1898
+ this.#highestSbn.set(streamKey, { sbn, atMs: now });
1899
+ }
1900
+ if (symbol === "source") this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
1901
+ anchorHere();
1902
+ };
1790
1903
  const discontinuity = () => {
1791
1904
  this.#classifiers.get(streamKey)?.noteSourceDiscontinuity();
1792
1905
  this.#highestSbn.set(streamKey, { sbn, atMs: now });
1906
+ this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
1793
1907
  if (psn === void 0) this.#sourceAnchors.delete(streamKey);
1794
- else this.#sourceAnchors.set(streamKey, { sbn, psn, atMs: now });
1908
+ else this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now });
1795
1909
  this.onSourceDiscontinuity?.(packetId, catalogTrackName);
1796
1910
  };
1797
1911
  if (previous === void 0) {
1798
- this.#highestSbn.set(streamKey, { sbn, atMs: now });
1799
- anchorHere();
1912
+ advance();
1800
1913
  return;
1801
1914
  }
1802
1915
  const config = this.#trackConfig(packetId);
1803
1916
  const window = this.#liveWindowBlocks(config);
1917
+ const sentInOrder = (from, to) => {
1918
+ const sent = to.psn - from.psn >>> 0;
1919
+ return sent <= 2147483647 && serial32Distance(from.ssId, to.ssId) <= sent + config.k;
1920
+ };
1804
1921
  if (!this.#blockPrecedes(previous.sbn, sbn)) {
1805
- if (symbol === "source" && window !== null && this.#blocksBehind(sbn, previous.sbn, packetId) > window) {
1922
+ if (symbol === "source" && window !== null && this.#blockPrecedes(sbn, previous.sbn) && (this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId) || psn !== void 0 && anchor !== void 0 && serial32Precedes(ssId, anchor.ssId) && psn !== anchor.psn && !sentInOrder({ ssId, psn }, anchor))) {
1806
1923
  discontinuity();
1807
1924
  return;
1808
1925
  }
@@ -1812,9 +1929,8 @@ var FECManager = class _FECManager {
1812
1929
  const missing = this.#blocksBehind(previous.sbn, sbn, packetId) - 1;
1813
1930
  let plausible = true;
1814
1931
  if (window !== null) {
1815
- if (psn !== void 0 && anchor !== void 0 && this.#blockPrecedes(anchor.sbn, sbn) && psn !== anchor.psn) {
1816
- const sent = psn - anchor.psn >>> 0;
1817
- plausible = sent <= 2147483647 && serial32Distance(anchor.sbn, sbn) <= sent + config.k;
1932
+ if (psn !== void 0 && anchor !== void 0 && serial32Precedes(anchor.ssId, ssId) && psn !== anchor.psn) {
1933
+ plausible = sentInOrder(anchor, { ssId, psn });
1818
1934
  } else {
1819
1935
  plausible = missing <= window + Math.ceil((now - previous.atMs) / config.interleaveDepthMs);
1820
1936
  }
@@ -1824,8 +1940,7 @@ var FECManager = class _FECManager {
1824
1940
  discontinuity();
1825
1941
  return;
1826
1942
  }
1827
- this.#highestSbn.set(streamKey, { sbn, atMs: now });
1828
- anchorHere();
1943
+ advance();
1829
1944
  }
1830
1945
  /*
1831
1946
  * Block order for one stream (BLO-35597 iso:5). A block is keyed by its
@@ -2142,8 +2257,10 @@ var FECManager = class _FECManager {
2142
2257
  );
2143
2258
  }
2144
2259
  const hasCatalogTiming = _FECManager.#hasCatalogTiming({ interleaveDepthMs: ownInterleaveDepthMs });
2260
+ const algorithm = config.algorithm ?? previous.algorithm;
2145
2261
  const next = {
2146
2262
  blockProfile,
2263
+ ...algorithm === void 0 ? {} : { algorithm },
2147
2264
  k,
2148
2265
  symbolSize: config.symbolSize != null && config.symbolSize > 0 ? config.symbolSize : previousTrack?.symbolSize ?? 0,
2149
2266
  interleaveDepthMs: ownInterleaveDepthMs,
@@ -2409,6 +2526,7 @@ var FECManager = class _FECManager {
2409
2526
  resetSet(this.#materializedBlocks);
2410
2527
  resetMap(this.#resolvedBlockClasses);
2411
2528
  resetMap(this.#highestSbn);
2529
+ resetMap(this.#sourceFrontiers);
2412
2530
  resetMap(this.#isoLocators);
2413
2531
  resetMap(this.#sourceAnchors);
2414
2532
  this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName));
@@ -2514,6 +2632,7 @@ var FECManager = class _FECManager {
2514
2632
  dropMap(this.#orderedPendingBlocks);
2515
2633
  dropMap(this.#resolvedBlockClasses);
2516
2634
  dropMap(this.#highestSbn);
2635
+ dropMap(this.#sourceFrontiers);
2517
2636
  dropMap(this.#isoLocators);
2518
2637
  dropMap(this.#sourceAnchors);
2519
2638
  dropMap(this.#classifiers);
@@ -2606,7 +2725,13 @@ var FECManager = class _FECManager {
2606
2725
  if (isSourceSymbol && esi === 0) {
2607
2726
  this.#startupPartialBlocks.delete(blockKey);
2608
2727
  this.#startupAlignedPackets.add(streamKey);
2609
- } else if (isStartupPartial && !isReadyMulticastRepair || !this.#startupAlignedPackets.has(streamKey) && !isReadyMulticastRepair) {
2728
+ } else if (
2729
+ // A ready multicast repair opens a block the join has not seen yet, never
2730
+ // a join partial: its sources were refused, so its repairs alone open a
2731
+ // block that cannot decode and fails at its deadline, once per packet ID
2732
+ // per join (BLO-48308).
2733
+ isStartupPartial || !this.#startupAlignedPackets.has(streamKey) && !isReadyMulticastRepair
2734
+ ) {
2610
2735
  this.#markStartupPartial(blockKey);
2611
2736
  return false;
2612
2737
  }
@@ -2888,6 +3013,7 @@ var FECManager = class _FECManager {
2888
3013
  let locator = this.#isoLocators.get(streamKey);
2889
3014
  if (!locator) {
2890
3015
  locator = new IsoBlockLocator(this.#trackConfig(packetId).k, this.#isoRetentionBlocks(packetId));
3016
+ locator.deferIncompleteGaps = this.#deferIsoGaps;
2891
3017
  this.#isoLocators.set(streamKey, locator);
2892
3018
  }
2893
3019
  return locator;
@@ -2931,6 +3057,10 @@ var FECManager = class _FECManager {
2931
3057
  }
2932
3058
  return blocks;
2933
3059
  }
3060
+ /** The iso-ssbg1-v1 locator horizon of a configured packetId, in blocks (#isoRetentionBlocks). */
3061
+ isoRetentionBlocksForPacket(packetId) {
3062
+ return this.#hasBlockProfile(packetId) ? this.#isoRetentionBlocks(packetId) : void 0;
3063
+ }
2934
3064
  /** Whether an iso-ssbg1-v1 protected packet fits one ssbg_mode1 symbol (len + 2 <= T). */
2935
3065
  isoSourceFits(packetId, packetLength) {
2936
3066
  const symbolSize = this.#trackConfigs.get(packetId)?.symbolSize;
@@ -2980,15 +3110,61 @@ var FECManager = class _FECManager {
2980
3110
  }
2981
3111
  return placement;
2982
3112
  }
2983
- if (placement.span !== void 0) {
2984
- const key = this.#blockKey(placement.span.block.start, packetId, catalogTrackName);
2985
- if (!this.#blockAuthoredLengths.has(key)) this.#blockAuthoredLengths.set(key, placement.span.block.length);
2986
- }
2987
- if (placement.span !== void 0 && placement.span.placed.length === 0) {
2988
- this.#materializeBlock(placement.span.block.start, packetId, catalogTrackName, true);
3113
+ if (placement.span !== void 0) this.#openIsoSpan(placement.span, packetId, catalogTrackName);
3114
+ if (placement.hole !== void 0) {
3115
+ const locator = this.#isoLocatorFor(packetId, catalogTrackName);
3116
+ const hole = placement.hole.block;
3117
+ const previous = locator.blockEndingAt(hole.start);
3118
+ const loss = {
3119
+ packetId,
3120
+ catalogTrackName,
3121
+ holeStart: hole.start,
3122
+ holeLength: hole.length,
3123
+ lostSsId: placement.hole.lostSsId,
3124
+ kMax: this.#trackConfig(packetId).k,
3125
+ ...previous === void 0 ? {} : { previousBlockStart: previous.start }
3126
+ };
3127
+ this.#onUndelimitedLoss(loss);
2989
3128
  }
2990
3129
  return placement;
2991
3130
  }
3131
+ /**
3132
+ * Keep an iso-ssbg1-v1 gap missing a source as a pending hole, reported to
3133
+ * `handler`, instead of a repair-less span; null restores spans. Set by the
3134
+ * range repair scheduler; applies to every stream from its next gap. The
3135
+ * handler and the deferral are one setting, so no hole is ever created with
3136
+ * nobody to close it.
3137
+ */
3138
+ setUndelimitedLossHandler(handler) {
3139
+ this.#onUndelimitedLoss = handler;
3140
+ this.#deferIsoGaps = handler !== null;
3141
+ for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps;
3142
+ }
3143
+ /**
3144
+ * The range repair for a hole ended: every hole still pending inside
3145
+ * `[start, start + length)` becomes a repair-less span. Returns those spans
3146
+ * with the held sources they placed, for the caller to feed (MmtpRouter).
3147
+ */
3148
+ closeIsoHoles(packetId, catalogTrackName, start, length) {
3149
+ const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
3150
+ if (locator === void 0) return [];
3151
+ const spans = locator.closeHolesWithin(start, length);
3152
+ for (const span of spans) this.#openIsoSpan(span, packetId, catalogTrackName);
3153
+ return spans;
3154
+ }
3155
+ /**
3156
+ * A repair-less span has no repair to state its length, so it is known
3157
+ * here: its sources make it clean exactly when all of them arrived. A
3158
+ * stated block learns its SSB_length from its own repair symbol, fed after
3159
+ * its placed sources exactly as on the wire (feedRepairSymbol). A span every
3160
+ * SS_ID of which vanished resolves through its deadline like any vanished
3161
+ * block.
3162
+ */
3163
+ #openIsoSpan(span, packetId, catalogTrackName) {
3164
+ const key = this.#blockKey(span.block.start, packetId, catalogTrackName);
3165
+ if (!this.#blockAuthoredLengths.has(key)) this.#blockAuthoredLengths.set(key, span.block.length);
3166
+ if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true);
3167
+ }
2992
3168
  /**
2993
3169
  * Resolution of the SS_IDs strictly between two released frames' SS_IDs on
2994
3170
  * an iso-ssbg1-v1 stream, for in-order frame release: null while a block
@@ -3512,20 +3688,49 @@ var FECManager = class _FECManager {
3512
3688
  * Caller is responsible for routing recovered data and updating
3513
3689
  * block completion state via `markBlockCompleted()`.
3514
3690
  */
3515
- feedRepairSymbol(packetId, ssStart, ssbLength, rsId, repairData, catalogTrackName) {
3516
- this.#fecStats.repairPackets++;
3517
- this.#statsForPacket(packetId).repairPackets++;
3518
- if (!this.#hasBlockProfile(packetId)) return null;
3691
+ /**
3692
+ * Whether a repair symbol of `byteLength` bytes is a valid member of a
3693
+ * `packetId` block: every repair symbol is exactly the track's T. A symbol of
3694
+ * any other size is counted on `repairSymbolSizeMismatches`, warned (rate
3695
+ * limited) and refused. The router calls this before the symbol takes any
3696
+ * other part in block state (placement, first-arrival dedup, completed-block
3697
+ * accounting), so a malformed repair is counted whatever its arrival order:
3698
+ * judged after dedup, one landing on an already-complete block, or behind a
3699
+ * valid copy from the other transport, was swallowed as a duplicate and never
3700
+ * counted (BLO-48306). A packetId with no configured block profile admits
3701
+ * nothing here; its repair is dropped upstream as unreadable.
3702
+ */
3703
+ /**
3704
+ * fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
3705
+ * exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
3706
+ * block state unchanged. The router calls this before the repair places a
3707
+ * block or takes any other part in block bookkeeping. A RaptorQ track admits
3708
+ * every header that parsed (its RS_ID < RSB_length check is in the parser).
3709
+ */
3710
+ admitRepairBlockLength(packetId, ssbLength, rsbLength, rsId) {
3711
+ if (rsId >= rsbLength) return false;
3712
+ if (this.#trackConfigs.get(packetId)?.algorithm !== "reed-solomon") return true;
3713
+ return ssbLength + rsbLength <= RS_MAX_BLOCK_SYMBOLS;
3714
+ }
3715
+ admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, byteLength) {
3716
+ if (!this.#hasBlockProfile(packetId)) return false;
3519
3717
  const symbolSize = this.#trackConfig(packetId).symbolSize;
3520
- if (symbolSize > 0 && repairData.byteLength !== symbolSize) {
3718
+ if (symbolSize > 0 && byteLength !== symbolSize) {
3521
3719
  this.#repairSymbolSizeMismatchCount++;
3522
3720
  if (this.#repairSymbolSizeMismatchCount <= 5 || this.#repairSymbolSizeMismatchCount % 100 === 0) {
3523
3721
  console.warn(
3524
- `[FECManager] Dropping repair symbol with invalid size: got ${repairData.byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`
3722
+ `[FECManager] Dropping repair symbol with invalid size: got ${byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`
3525
3723
  );
3526
3724
  }
3527
- return null;
3725
+ return false;
3528
3726
  }
3727
+ return true;
3728
+ }
3729
+ feedRepairSymbol(packetId, ssStart, ssbLength, rsId, repairData, catalogTrackName) {
3730
+ this.#fecStats.repairPackets++;
3731
+ this.#statsForPacket(packetId).repairPackets++;
3732
+ if (!this.#hasBlockProfile(packetId)) return null;
3733
+ if (!this.admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, repairData.byteLength)) return null;
3529
3734
  const fecData = repairData;
3530
3735
  const k = this.#trackConfig(packetId).k;
3531
3736
  const block = this.#isoLocatorFor(packetId, catalogTrackName).blockAt(ssStart);
@@ -3678,7 +3883,14 @@ var FECManager = class _FECManager {
3678
3883
  const key = this.#blockKey(sbn, packetId, catalogTrackName);
3679
3884
  const k = trackConfig.k;
3680
3885
  if (this.#completedBlocks.has(key)) return;
3681
- this.#noteSbnSeen(sbn, packetId, catalogTrackName, "source", evidence.packetSequenceNumber);
3886
+ this.#noteSbnSeen(
3887
+ sbn,
3888
+ packetId,
3889
+ catalogTrackName,
3890
+ "source",
3891
+ evidence.packetSequenceNumber,
3892
+ Number.isInteger(esi) ? sbn + esi >>> 0 : sbn
3893
+ );
3682
3894
  const authoredLength = this.#blockAuthoredLengths.get(key) ?? k;
3683
3895
  if (Number.isInteger(esi) && esi >= authoredLength) {
3684
3896
  this.#failBlock(sbn, packetId, catalogTrackName);
@@ -3929,6 +4141,7 @@ var FECManager = class _FECManager {
3929
4141
  this.#repairedBlocks.clear();
3930
4142
  this.#materializedBlocks.clear();
3931
4143
  this.#highestSbn.clear();
4144
+ this.#sourceFrontiers.clear();
3932
4145
  this.#isoLocators.clear();
3933
4146
  this.#sourceAnchors.clear();
3934
4147
  this.#trackConfigs.clear();