@blockcast/mmt-container 2.2.0-main.ea9223dc11de → 2.2.0-main.ec45bee1b9cc

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 (132) hide show
  1. package/README.md +125 -2
  2. package/dist/__tests__/ad-creative-signer.d.ts +11 -0
  3. package/dist/__tests__/ad-creative-signer.d.ts.map +1 -0
  4. package/dist/__tests__/test-utils.d.ts +1 -0
  5. package/dist/__tests__/test-utils.d.ts.map +1 -1
  6. package/dist/ad-beacon.d.ts +39 -0
  7. package/dist/ad-beacon.d.ts.map +1 -0
  8. package/dist/ad-beacon.js +23 -0
  9. package/dist/ad-beacon.js.map +7 -0
  10. package/dist/ad-creative-record.d.ts +65 -0
  11. package/dist/ad-creative-record.d.ts.map +1 -0
  12. package/dist/ad-creative-record.js +2281 -0
  13. package/dist/ad-creative-record.js.map +7 -0
  14. package/dist/ad-creative-timeline.d.ts +103 -0
  15. package/dist/ad-creative-timeline.d.ts.map +1 -0
  16. package/dist/ad-creative-timeline.js +2550 -0
  17. package/dist/ad-creative-timeline.js.map +7 -0
  18. package/dist/block-policy.d.ts +128 -14
  19. package/dist/block-policy.d.ts.map +1 -1
  20. package/dist/block-policy.js +472 -27
  21. package/dist/block-policy.js.map +2 -2
  22. package/dist/browser-runtime.js +1039 -120
  23. package/dist/browser-runtime.js.map +4 -4
  24. package/dist/carp-catalog.d.ts +1 -0
  25. package/dist/carp-catalog.d.ts.map +1 -1
  26. package/dist/carp-catalog.js +34 -0
  27. package/dist/carp-catalog.js.map +4 -4
  28. package/dist/catalog-fec-params.js.map +1 -1
  29. package/dist/catalog-network-source.d.ts +1 -17
  30. package/dist/catalog-network-source.d.ts.map +1 -1
  31. package/dist/catalog-network-source.js +25 -19
  32. package/dist/catalog-network-source.js.map +3 -3
  33. package/dist/cmaf-block-assembler.d.ts +10 -2
  34. package/dist/cmaf-block-assembler.d.ts.map +1 -1
  35. package/dist/cmaf-block-assembler.js +30 -8
  36. package/dist/cmaf-block-assembler.js.map +3 -3
  37. package/dist/codec-utils.d.ts.map +1 -1
  38. package/dist/codec-utils.js +16 -3
  39. package/dist/codec-utils.js.map +2 -2
  40. package/dist/conceal-timeline.d.ts +24 -1
  41. package/dist/conceal-timeline.d.ts.map +1 -1
  42. package/dist/conceal-timeline.js +201 -4
  43. package/dist/conceal-timeline.js.map +3 -3
  44. package/dist/datagram-leg-deadline.d.ts +4 -0
  45. package/dist/datagram-leg-deadline.d.ts.map +1 -1
  46. package/dist/datagram-leg-deadline.js.map +2 -2
  47. package/dist/event-timeline-mmtp.d.ts +17 -0
  48. package/dist/event-timeline-mmtp.d.ts.map +1 -0
  49. package/dist/event-timeline-mmtp.js +3117 -0
  50. package/dist/event-timeline-mmtp.js.map +7 -0
  51. package/dist/fec-manager.d.ts +24 -3
  52. package/dist/fec-manager.d.ts.map +1 -1
  53. package/dist/fec-manager.js +531 -38
  54. package/dist/fec-manager.js.map +2 -2
  55. package/dist/feed-gate.d.ts +114 -0
  56. package/dist/feed-gate.d.ts.map +1 -0
  57. package/dist/feed-gate.js +175 -0
  58. package/dist/feed-gate.js.map +7 -0
  59. package/dist/index.d.ts +3 -2
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +13 -1
  62. package/dist/index.js.map +2 -2
  63. package/dist/iso-bmff-timing.d.ts +16 -0
  64. package/dist/iso-bmff-timing.d.ts.map +1 -1
  65. package/dist/iso-bmff-timing.js +28 -0
  66. package/dist/iso-bmff-timing.js.map +2 -2
  67. package/dist/mfu-reassembler.d.ts +2 -0
  68. package/dist/mfu-reassembler.d.ts.map +1 -1
  69. package/dist/mfu-reassembler.js +4 -2
  70. package/dist/mfu-reassembler.js.map +2 -2
  71. package/dist/mmtp-container-parser.d.ts +12 -0
  72. package/dist/mmtp-container-parser.d.ts.map +1 -1
  73. package/dist/mmtp-container-parser.js +73 -3
  74. package/dist/mmtp-container-parser.js.map +2 -2
  75. package/dist/mmtp-container-parser.no-modules.js +103 -25
  76. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  77. package/dist/mmtp-decode-pipeline.js +73 -3
  78. package/dist/mmtp-decode-pipeline.js.map +2 -2
  79. package/dist/mmtp-router.d.ts +20 -2
  80. package/dist/mmtp-router.d.ts.map +1 -1
  81. package/dist/mmtp-router.js +150 -23
  82. package/dist/mmtp-router.js.map +3 -3
  83. package/dist/multicast-auth-catalog.js.map +1 -1
  84. package/dist/multicast-input.js.map +1 -1
  85. package/dist/multicast-manager.d.ts +23 -2
  86. package/dist/multicast-manager.d.ts.map +1 -1
  87. package/dist/multicast-manager.js +749 -87
  88. package/dist/multicast-manager.js.map +3 -3
  89. package/dist/multicast-transport.d.ts +8 -0
  90. package/dist/multicast-transport.d.ts.map +1 -1
  91. package/dist/multicast-transport.js +56 -23
  92. package/dist/multicast-transport.js.map +2 -2
  93. package/dist/no-modules.js +98 -22
  94. package/dist/no-modules.js.map +4 -4
  95. package/dist/repair-fetch.d.ts +15 -7
  96. package/dist/repair-fetch.d.ts.map +1 -1
  97. package/dist/repair-fetch.js +34 -7
  98. package/dist/repair-fetch.js.map +2 -2
  99. package/dist/wasm-mfu-reassembler.js.map +2 -2
  100. package/dist/wasm-mmtp-container-parser.js +73 -3
  101. package/dist/wasm-mmtp-container-parser.js.map +2 -2
  102. package/package.json +17 -5
  103. package/schemas/catalog.schema.json +7 -2
  104. package/src/ad-beacon.ts +54 -0
  105. package/src/ad-creative-record.ts +276 -0
  106. package/src/ad-creative-timeline.ts +410 -0
  107. package/src/block-policy.ts +673 -42
  108. package/src/carp-catalog.ts +9 -0
  109. package/src/catalog-network-source.ts +3 -37
  110. package/src/cmaf-block-assembler.ts +17 -0
  111. package/src/codec-utils.ts +19 -3
  112. package/src/conceal-timeline.ts +60 -5
  113. package/src/datagram-leg-deadline.ts +4 -0
  114. package/src/event-timeline-mmtp.ts +55 -0
  115. package/src/fec-manager.ts +84 -12
  116. package/src/feed-gate.ts +295 -0
  117. package/src/index.ts +21 -0
  118. package/src/iso-bmff-timing.ts +33 -0
  119. package/src/mfu-reassembler.ts +4 -0
  120. package/src/mmtp-container-parser.ts +51 -5
  121. package/src/mmtp-router.ts +116 -4
  122. package/src/multicast-manager.ts +31 -0
  123. package/src/multicast-transport.ts +27 -2
  124. package/src/repair-fetch.ts +70 -19
  125. package/test-vectors/catalog/README.md +1 -0
  126. package/test-vectors/catalog/negative/event-timeline-empty-event-type.json +41 -0
  127. package/test-vectors/catalog/positive/event-timeline-ad-creative.json +41 -0
  128. package/test-vectors/catalog/positive/event-timeline-wallclock-no-depends.json +38 -0
  129. package/test-vectors/catalog/positive/multicast-event-timeline.json +81 -0
  130. package/test-vectors/catalog/section-codes.json +1 -0
  131. package/test-vectors/frame-needs-v1.json +295 -0
  132. package/test-vectors/repair-policy-v1.json +98 -18
@@ -65,6 +65,7 @@ import {
65
65
  type GapFrameEvidence,
66
66
  type SourceSymbolEvidence,
67
67
  } from "./block-policy.js";
68
+ import type { FrameNeeds } from "./feed-gate.js";
68
69
  import {
69
70
  duplicateRetentionMs,
70
71
  StreamDuplicateLedgers,
@@ -176,6 +177,13 @@ export type RoutedFrameMeta = {
176
177
  * object the manager emits as its `gap` event.
177
178
  */
178
179
  gapBefore?: FrameGapDecision;
180
+ /**
181
+ * What this video frame states it needs, read from its MFU data-unit
182
+ * header. Opaque to a sink: forward it to `VideoFeedGate` like `gapBefore`.
183
+ * Absent on audio, on a frame with no timed DU header, and on a frame whose
184
+ * movie fragment is not known to hold exactly one sample.
185
+ */
186
+ needs?: FrameNeeds;
179
187
  };
180
188
 
181
189
  /** A keyframe-overlay repair leg: the source its FEC instance protects. */
@@ -860,7 +868,8 @@ export interface FECManagerLike {
860
868
 
861
869
  /** Track a first-arrival network source symbol for block completion and
862
870
  * classification. Refreshes the inactivity deadline and marks clean when
863
- * K arrive. `held`: a source held unplaced since it arrived, placed now. */
871
+ * K arrive. `held`: a source held unplaced since it arrived, placed now.
872
+ * `inSpan`: placed in a repair-less span, which is no block. */
864
873
  trackBlock(
865
874
  sbn: number,
866
875
  packetId: number,
@@ -868,6 +877,16 @@ export interface FECManagerLike {
868
877
  esi: number,
869
878
  evidence: SourceSymbolEvidence,
870
879
  held?: boolean,
880
+ inSpan?: boolean,
881
+ ): void;
882
+
883
+ /** The DU header of a source symbol a decode rebuilt in block `sbn`: it
884
+ * bounds the blocks around that block for the MPU rule, nothing else. */
885
+ noteRecoveredSource?(
886
+ sbn: number,
887
+ packetId: number,
888
+ catalogTrackName: string | undefined,
889
+ evidence: SourceSymbolEvidence,
871
890
  ): void;
872
891
 
873
892
  /** True once the packetId has a per-track FEC configuration. */
@@ -934,6 +953,20 @@ export interface FECManagerLike {
934
953
  decodeTime?: bigint,
935
954
  ): void;
936
955
 
956
+ /**
957
+ * Decode times of the first and last sample that one held movie fragment's
958
+ * metadata times, in MPU `mpu`: the block classifier looks among them for
959
+ * an MPU longer than the catalog keyframe interval.
960
+ */
961
+ noteSampleDecodeTimes?(
962
+ packetId: number,
963
+ catalogTrackName: string | undefined,
964
+ mpu: number,
965
+ first: bigint,
966
+ last: bigint,
967
+ mediaTimescale: number,
968
+ ): void;
969
+
937
970
  /** Refresh the block inactivity deadline after accepted repair progress. */
938
971
  noteBlockActivity?(sbn: number, packetId: number, catalogTrackName?: string): void;
939
972
 
@@ -1111,6 +1144,34 @@ function sourceSymbolEvidence(
1111
1144
  ? { movieFragment: identity.movieFragmentSequenceNumber }
1112
1145
  : {}),
1113
1146
  ...(identity?.offset !== undefined ? { offset: identity.offset } : {}),
1147
+ ...(identity?.dependencyCounter ? { depCounter: identity.dependencyCounter } : {}),
1148
+ };
1149
+ }
1150
+
1151
+ /**
1152
+ * The DU header of one FEC-recovered source packet, as the block processor
1153
+ * read it. Null for a packet that carries none: only a DU header bounds a
1154
+ * block, and a recovered packet is no other evidence (BlockClassifier).
1155
+ */
1156
+ function recoveredHeaderEvidence(
1157
+ sym: ProcessFecBlockResult["symbols"][number],
1158
+ ): SourceSymbolEvidence | null {
1159
+ const { fragment } = sym;
1160
+ if (
1161
+ sym.fragmentType !== 2 ||
1162
+ fragment.sampleNumber === undefined ||
1163
+ fragment.sampleNumber < 1 ||
1164
+ fragment.movieFragmentSequenceNumber === undefined
1165
+ ) {
1166
+ return null;
1167
+ }
1168
+ return {
1169
+ rap: fragment.rapFlag,
1170
+ mpu: fragment.mpuSequenceNumber,
1171
+ idx: fragment.sampleNumber - 1,
1172
+ movieFragment: fragment.movieFragmentSequenceNumber,
1173
+ ...(fragment.sampleOffset === undefined ? {} : { offset: fragment.sampleOffset }),
1174
+ ...(fragment.dependencyCounter ? { depCounter: fragment.dependencyCounter } : {}),
1114
1175
  };
1115
1176
  }
1116
1177
 
@@ -1423,6 +1484,13 @@ export class MmtpRouter {
1423
1484
  this.#deliverInit(packetId, data, catalogTrackName);
1424
1485
  });
1425
1486
 
1487
+ // Each movie fragment the parser admits times its samples. The block
1488
+ // classifier reads those decode times before the packet's own block is
1489
+ // tracked: the parser is fed first.
1490
+ this.#parser.onMovieFragmentTiming((packetId, catalogTrackName, mpu, first, last, mediaTimescale) => {
1491
+ this.#fecManager?.noteSampleDecodeTimes?.(packetId, catalogTrackName, mpu, first, last, mediaTimescale);
1492
+ });
1493
+
1426
1494
  // Wire parser frame callback → router's callback routing + CMAF assembly.
1427
1495
  this.#parser.onFrame((data, meta) => this.#routeParsedFrame(data, meta));
1428
1496
 
@@ -1432,6 +1500,23 @@ export class MmtpRouter {
1432
1500
  this.#wireFecLifecycle(config?.onBlockFailed);
1433
1501
  }
1434
1502
 
1503
+ /**
1504
+ * The `needs` field of a video frame whose DU header places it, or nothing.
1505
+ * Fragment numbers count frames in decode order only where each movie
1506
+ * fragment holds one sample, so a frame gets one only when FT=1 said so.
1507
+ */
1508
+ #frameNeeds(
1509
+ isVideo: boolean,
1510
+ packetId: number,
1511
+ catalogTrackName: string | undefined,
1512
+ frame: { mpuSequenceNumber?: number; movieFragmentSequenceNumber?: number; priority?: number },
1513
+ ): { needs?: FrameNeeds } {
1514
+ const { mpuSequenceNumber: mpu, movieFragmentSequenceNumber: position, priority: code } = frame;
1515
+ if (!isVideo || mpu === undefined || position === undefined || code === undefined) return {};
1516
+ if (!this.#parser.movieFragmentHoldsOneSample(packetId, mpu, position, catalogTrackName)) return {};
1517
+ return { needs: { mpu, position, code } };
1518
+ }
1519
+
1435
1520
  /**
1436
1521
  * Deliver one parser frame: MSE assembly, sync gating, and callback
1437
1522
  * routing. Reads #currentFecInfo, the FEC coordinates of the packet the
@@ -1472,6 +1557,7 @@ export class MmtpRouter {
1472
1557
  ...(meta.catalogTrackName === undefined
1473
1558
  ? {}
1474
1559
  : { catalogTrackName: meta.catalogTrackName }),
1560
+ ...this.#frameNeeds(isVideo, packetId, meta.catalogTrackName, meta),
1475
1561
  };
1476
1562
  if (meta.source) frameMeta.source = meta.source;
1477
1563
  // During make-before-break the overlap copy usually wins the parse ledger,
@@ -1528,6 +1614,7 @@ export class MmtpRouter {
1528
1614
  ? {}
1529
1615
  : { deliveryProvenance: frameMeta.deliveryProvenance }),
1530
1616
  ...(frameMeta.gapBefore === undefined ? {} : { gapBefore: frameMeta.gapBefore }),
1617
+ ...(frameMeta.needs === undefined ? {} : { needs: frameMeta.needs }),
1531
1618
  }]);
1532
1619
  } else if (assembler) {
1533
1620
  const fecInfo = this.#currentFecInfo;
@@ -1549,6 +1636,7 @@ export class MmtpRouter {
1549
1636
  frameMeta.movieFragmentSequenceNumber,
1550
1637
  frameMeta.sampleNumber,
1551
1638
  frameMeta.gapBefore,
1639
+ frameMeta.needs,
1552
1640
  );
1553
1641
  } else {
1554
1642
  assembler.addBypassFrame(
@@ -1566,6 +1654,7 @@ export class MmtpRouter {
1566
1654
  frameMeta.movieFragmentSequenceNumber,
1567
1655
  frameMeta.sampleNumber,
1568
1656
  frameMeta.gapBefore,
1657
+ frameMeta.needs,
1569
1658
  );
1570
1659
  }
1571
1660
  }
@@ -3464,7 +3553,7 @@ export class MmtpRouter {
3464
3553
  const blockStart = placement.block.start;
3465
3554
  this.#openAssistBlock(ownerPacketId, catalogTrackName, blockStart, repair.ssbLength);
3466
3555
  if (placement.span !== undefined) {
3467
- this.#replayIsoSources(ownerPacketId, catalogTrackName, placement.span.block.start, placement.span.placed);
3556
+ this.#replayIsoSources(ownerPacketId, catalogTrackName, placement.span.block.start, placement.span.placed, true);
3468
3557
  }
3469
3558
  this.#replayIsoSources(ownerPacketId, catalogTrackName, blockStart, placement.placed);
3470
3559
  if (this.#classifyPacketId(ownerPacketId) === null) return;
@@ -3516,7 +3605,7 @@ export class MmtpRouter {
3516
3605
  ): void {
3517
3606
  const spans = this.#fecManager?.closeIsoHoles?.(ownerPacketId, catalogTrackName, start, length) ?? [];
3518
3607
  for (const span of spans) {
3519
- this.#replayIsoSources(ownerPacketId, catalogTrackName, span.block.start, span.placed);
3608
+ this.#replayIsoSources(ownerPacketId, catalogTrackName, span.block.start, span.placed, true);
3520
3609
  }
3521
3610
  }
3522
3611
 
@@ -3531,6 +3620,7 @@ export class MmtpRouter {
3531
3620
  catalogTrackName: string | undefined,
3532
3621
  blockStart: number,
3533
3622
  placed: readonly IsoPlacedSource<IsoHeldSource>[],
3623
+ inSpan = false,
3534
3624
  ): void {
3535
3625
  const fec = this.#fecManager;
3536
3626
  if (!fec) return;
@@ -3545,7 +3635,7 @@ export class MmtpRouter {
3545
3635
  catalogTrackName,
3546
3636
  )) continue;
3547
3637
  if (fec.isTrackConfigured?.(ownerPacketId) !== false) {
3548
- fec.trackBlock(blockStart, ownerPacketId, catalogTrackName, esi, payload.evidence, true);
3638
+ fec.trackBlock(blockStart, ownerPacketId, catalogTrackName, esi, payload.evidence, true, inSpan);
3549
3639
  this.#requestFecPoke(ownerPacketId, catalogTrackName);
3550
3640
  }
3551
3641
  if (payload.oversized) continue;
@@ -5924,6 +6014,20 @@ export class MmtpRouter {
5924
6014
  );
5925
6015
  }
5926
6016
 
6017
+ // A rebuilt DU header bounds the blocks around its own for the MPU rule
6018
+ // (BlockClassifier). An overlay recovery names no base block. It comes
6019
+ // after the block's rebuilt FT=1 was fed: the classifier looks among the
6020
+ // decode times for an MPU longer than the keyframe interval before it
6021
+ // classes a block, for a rebuilt packet as for one that arrived.
6022
+ if (!overlay && this.#fecManager?.noteRecoveredSource) {
6023
+ for (const sym of result.symbols) {
6024
+ const evidence = recoveredHeaderEvidence(sym);
6025
+ if (evidence !== null) {
6026
+ this.#fecManager.noteRecoveredSource(blockId, ownerPacketId, catalogTrackName, evidence);
6027
+ }
6028
+ }
6029
+ }
6030
+
5927
6031
  // A recovered head whose sample FT=1 has not named yet (an overlay that
5928
6032
  // outran the source path) would complete its data unit untimed: the unit
5929
6033
  // is dropped, marked completed, and the timed source copy is then refused
@@ -6005,6 +6109,7 @@ export class MmtpRouter {
6005
6109
  catalogTrackName?: string;
6006
6110
  deliveryProvenance?: MmtpDeliveryProvenance;
6007
6111
  sourceDiscontinuity?: boolean;
6112
+ needs?: FrameNeeds;
6008
6113
  }> = [];
6009
6114
  let dedupedAgainstSource = 0;
6010
6115
  let droppedBeforeSync = 0;
@@ -6062,6 +6167,7 @@ export class MmtpRouter {
6062
6167
  ? {}
6063
6168
  : { sampleNumber: sym.fragment.sampleNumber }),
6064
6169
  rapFlag: sym.fragment.rapFlag,
6170
+ ...(sym.fragment.priority === undefined ? {} : { priority: sym.fragment.priority }),
6065
6171
  recovered: true,
6066
6172
  deliveryProvenance,
6067
6173
  ...fecSbnOf(sym.index),
@@ -6111,6 +6217,7 @@ export class MmtpRouter {
6111
6217
  // verdict directly or the sample reaches MSE unattributed.
6112
6218
  deliveryProvenance,
6113
6219
  ...(sourceDiscontinuity ? { sourceDiscontinuity: true } : {}),
6220
+ ...this.#frameNeeds(isVideoTrack, ownerPacketId, catalogTrackName, sym.fragment),
6114
6221
  });
6115
6222
  this.#noteEmittedKeyframe(ownerPacketId, keyframe);
6116
6223
  } else {
@@ -6196,6 +6303,7 @@ export class MmtpRouter {
6196
6303
  ? {}
6197
6304
  : { sampleNumber: assembled.sampleNumber }),
6198
6305
  rapFlag: assembled.rapFlag,
6306
+ ...(assembled.priority === undefined ? {} : { priority: assembled.priority }),
6199
6307
  recovered: true,
6200
6308
  ...(assembled.deliveryProvenance === undefined
6201
6309
  ? {}
@@ -6259,6 +6367,7 @@ export class MmtpRouter {
6259
6367
  : { catalogTrackName: assembled.catalogTrackName }),
6260
6368
  deliveryProvenance: assembled.deliveryProvenance,
6261
6369
  ...(sourceDiscontinuity ? { sourceDiscontinuity: true } : {}),
6370
+ ...this.#frameNeeds(isVideoTrack, ownerPacketId, recoveredCatalogTrackName, assembled),
6262
6371
  });
6263
6372
  this.#noteEmittedKeyframe(ownerPacketId, keyframe);
6264
6373
  }
@@ -6297,6 +6406,7 @@ export class MmtpRouter {
6297
6406
  recovered: true,
6298
6407
  deliveryProvenance: frame.deliveryProvenance,
6299
6408
  ...(frame.sourceDiscontinuity ? { sourceDiscontinuity: true } : {}),
6409
+ ...(frame.needs === undefined ? {} : { needs: frame.needs }),
6300
6410
  });
6301
6411
  }
6302
6412
  debugRouter(
@@ -6383,6 +6493,7 @@ export class MmtpRouter {
6383
6493
  ? {}
6384
6494
  : { sampleNumber: sym.fragment.sampleNumber }),
6385
6495
  rapFlag: sym.fragment.rapFlag,
6496
+ ...(sym.fragment.priority === undefined ? {} : { priority: sym.fragment.priority }),
6386
6497
  recovered: true,
6387
6498
  deliveryProvenance,
6388
6499
  ...fecSbnOf(sym.index),
@@ -6473,6 +6584,7 @@ export class MmtpRouter {
6473
6584
  ? {}
6474
6585
  : { sampleNumber: assembled.sampleNumber }),
6475
6586
  rapFlag: assembled.rapFlag,
6587
+ ...(assembled.priority === undefined ? {} : { priority: assembled.priority }),
6476
6588
  recovered: true,
6477
6589
  deliveryProvenance,
6478
6590
  ...fecSbnOf(sym.index),
@@ -29,6 +29,7 @@ import {
29
29
  type BlockClass,
30
30
  type ClassifierMode,
31
31
  type ClassifierReason,
32
+ type MpuRuleOffReason,
32
33
  type FrameGapDecision,
33
34
  type ReclassificationEvidence,
34
35
  type RepairPriority,
@@ -102,6 +103,8 @@ export interface MulticastRepairEndpoint {
102
103
  amtRelayPort?: number;
103
104
  /** The media join's `'driad'` discovery (no relay pinned), carried so the repair group rides the same relay. */
104
105
  amtDiscovery?: 'driad';
106
+ /** The media join's ATSC 3.0 tuning, carried so the repair group rides the same RF channel. */
107
+ atsc3?: MulticastTransportConfig["atsc3"];
105
108
  /** The repair packet IDs this group carries. */
106
109
  packetIds: number[];
107
110
  /** Each repair packet ID bound to the media packet ID it repairs. */
@@ -174,6 +177,12 @@ export interface MulticastEndpointConfig {
174
177
  * Ignored when `amtRelay` is set.
175
178
  */
176
179
  amtDiscovery?: 'driad';
180
+ /**
181
+ * ATSC 3.0 tuning from the catalog's `atsc3` networkSource
182
+ * (`endpointToMulticastConfig` → `PlayerMulticastConfig.atsc3`). Set, the
183
+ * join is the tuner member (draft -01 3) and relay/mode are not consulted.
184
+ */
185
+ atsc3?: MulticastTransportConfig["atsc3"];
177
186
  /** MMTP packet IDs to forward before data enters the page transport queue. */
178
187
  packetIds?: number[];
179
188
  /** Exact catalog tracks carried by this physical multicast endpoint. */
@@ -220,6 +229,12 @@ export interface MulticastEndpointConfig {
220
229
  * "mfu-datagram" leg's duplicate ledgers remember a packet for the block
221
230
  * span, the reorder tolerance and one group; pass it for every leg track,
222
231
  * audio included, which has no keyframe interval to stand in for it.
232
+ *
233
+ * Pass it for every FEC-protected video track too. The block classifier
234
+ * compares it with the keyframe interval, and a block is classed `delta`,
235
+ * by the MPU rule or by the window rule, only where the two are equal:
236
+ * without it no block of the track is `delta`, and every short block is
237
+ * repaired as `unknown`.
223
238
  */
224
239
  groupDurationMs?: number;
225
240
  /** Catalog-derived lower bound for packet-silence failback (for example, keyframe repair cadence). */
@@ -522,6 +537,13 @@ export interface BlockPolicyStats {
522
537
  readonly epoch: number;
523
538
  classifierMode: ClassifierMode | null;
524
539
  classifierReason: ClassifierReason | null;
540
+ /**
541
+ * Why the MPU rule classes no block on this video track now
542
+ * (`MpuRuleOffReason`): what the catalog does not state, or what the stream
543
+ * showed. Null while it can. Absent before the track is heard, on audio and
544
+ * without catalog timing. Read when the stats are taken.
545
+ */
546
+ mpuRuleOff?: MpuRuleOffReason | null;
525
547
  keyframeBlocksProtected: number;
526
548
  unknownBlocksProtected: number;
527
549
  keyframeBlocksRecoveredInband: number;
@@ -752,6 +774,9 @@ const RECLASSIFICATION_EVIDENCE: ReadonlySet<unknown> = new Set([
752
774
  "rap",
753
775
  "mpu-span",
754
776
  "window",
777
+ "mpu-rule",
778
+ // Never emitted now (block-policy.ts); an event recorded earlier still validates.
779
+ "dependent-run",
755
780
  "classifier-disabled",
756
781
  ]);
757
782
  const CLASSIFIER_MODES: ReadonlySet<unknown> = new Set(["classifying", "all-protected"]);
@@ -2005,6 +2030,8 @@ export class MulticastManager {
2005
2030
  timescale: config.timescale,
2006
2031
  keyframeIntervalTicks: config.keyframeIntervalTicks,
2007
2032
  keyframeIntervalMs: config.keyframeIntervalMs,
2033
+ // The MPU rule classes a block only where this equals the keyframe interval.
2034
+ groupDurationMs: config.groupDurationMs,
2008
2035
  });
2009
2036
  const fecConfig: FECManagerConfig = {
2010
2037
  blockProfile,
@@ -2401,6 +2428,7 @@ export class MulticastManager {
2401
2428
  config.relayPort ??
2402
2429
  (amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : undefined),
2403
2430
  amtDiscovery: config.amtDiscovery,
2431
+ atsc3: config.atsc3,
2404
2432
  packetIds: config.packetIds,
2405
2433
  tracks: catalogTracks?.map(({ name, packetId }) => ({ name, packetId })),
2406
2434
  ...(provenance === undefined ? {} : { protected: true }),
@@ -2586,6 +2614,7 @@ export class MulticastManager {
2586
2614
  amtRelay: endpoint.amtRelay,
2587
2615
  amtRelayPort: endpoint.amtRelayPort ?? (endpoint.amtRelay?.trim() ? DEFAULT_AMT_RELAY_PORT : undefined),
2588
2616
  amtDiscovery: endpoint.amtDiscovery,
2617
+ atsc3: endpoint.atsc3,
2589
2618
  packetIds: endpoint.packetIds,
2590
2619
  tracks: endpoint.tracks.map(({ name, packetId }) => ({ name, packetId })),
2591
2620
  // A protected repair group's records ride in band on its port (7.2.3).
@@ -3626,8 +3655,10 @@ export class MulticastManager {
3626
3655
  const out: Record<string, BlockPolicyStats> = {};
3627
3656
  for (const [key, stats] of this.#blockPolicyStats) {
3628
3657
  if (stats.epoch !== this.#fec.epochFor(stats.packetId)) continue;
3658
+ const mpuRuleOff = this.#fec.mpuRuleOffFor(stats.packetId, stats.catalogTrackName ?? undefined);
3629
3659
  out[key] = {
3630
3660
  ...stats,
3661
+ ...(mpuRuleOff === undefined ? {} : { mpuRuleOff }),
3631
3662
  repairStops: { ...stats.repairStops },
3632
3663
  lastRepairSkip: stats.lastRepairSkip === null ? null : { ...stats.lastRepairSkip },
3633
3664
  };
@@ -118,6 +118,14 @@ export interface MulticastJoinProviderError {
118
118
  readonly message: string
119
119
  /** Present only when the provider's error carries a string `code`. */
120
120
  readonly code?: string
121
+ /**
122
+ * How a receiver ended without delivering (libmmt transport's
123
+ * MulticastReceiverFailure); present only when the error carries a string
124
+ * `failure`.
125
+ */
126
+ readonly failure?: string
127
+ /** The `name` of the error's `cause`, when it has a string one. */
128
+ readonly causeName?: string
121
129
  }
122
130
 
123
131
  /**
@@ -194,21 +202,38 @@ const JOIN_SUCCEEDED: MulticastJoinOutcome = Object.freeze({ ok: true })
194
202
  */
195
203
  function providerErrorOf(error: unknown): MulticastJoinProviderError | undefined {
196
204
  if (typeof error !== 'object' || error === null) return undefined
197
- const fields = error as { readonly name?: unknown; readonly message?: unknown; readonly code?: unknown }
205
+ const fields = error as {
206
+ readonly name?: unknown
207
+ readonly message?: unknown
208
+ readonly code?: unknown
209
+ readonly failure?: unknown
210
+ readonly cause?: unknown
211
+ }
198
212
  let name: unknown
199
213
  let message: unknown
200
214
  let code: unknown
215
+ let failure: unknown
216
+ let causeName: unknown
201
217
  try {
202
218
  name = fields.name
203
219
  message = fields.message
204
220
  code = fields.code
221
+ failure = fields.failure
222
+ const cause = fields.cause
223
+ causeName = typeof cause === 'object' && cause !== null ? (cause as { readonly name?: unknown }).name : undefined
205
224
  } catch {
206
225
  // A rejection value whose fields throw on read (a revoked Proxy) types
207
226
  // nothing. Reading it must not turn a declined join into a rejected one.
208
227
  return undefined
209
228
  }
210
229
  if (typeof name !== 'string' || typeof message !== 'string') return undefined
211
- return Object.freeze(typeof code === 'string' ? { name, message, code } : { name, message })
230
+ return Object.freeze({
231
+ name,
232
+ message,
233
+ ...(typeof code === 'string' ? { code } : {}),
234
+ ...(typeof failure === 'string' ? { failure } : {}),
235
+ ...(typeof causeName === 'string' ? { causeName } : {}),
236
+ })
212
237
  }
213
238
 
214
239
  /**
@@ -29,9 +29,10 @@
29
29
  * below a RAP the receiver already holds complete is not requested at
30
30
  * all (`moot-rap`), and a P0 FETCH still running when such a RAP
31
31
  * arrives is cancelled (`repair-stopped`, `moot`): the receiver resumes
32
- * from that RAP (draft-ramadan-moq-fec §11.4.2). Only a repair that
33
- * could not land by the block's playout deadline (it relies on the
34
- * keyframe budget's extension) is moot: one that can stalls nothing.
32
+ * from that RAP (draft-ramadan-moq-fec-multicast-01 §6.2.1). Only a
33
+ * repair that cannot land by the block's playout deadline (it relies on
34
+ * the keyframe budget's extension, or that deadline has passed) is
35
+ * moot: one that can stalls nothing.
35
36
  * - P1 (audio) dispatches, uncapped, while no P0 is queued or in flight;
36
37
  * P2 (delta) only while no P0/P1 is, earliest absolute fail deadline
37
38
  * first (§11.4.5 item 3).
@@ -90,7 +91,10 @@
90
91
  * block (in-band RAP evidence), and an `unknown` block only while its
91
92
  * stream's classifier is `classifying`, where `unknown` means the window rule
92
93
  * could not exclude a RAP. Under `all-protected` every block reads `unknown`
93
- * whatever it holds, so there only RAP evidence earns the budget. Never
94
+ * whatever it holds, so there only RAP evidence earns the budget. The mode
95
+ * also reads `classifying` on a track where no block is classed `delta`
96
+ * (`BlockClassifier.mpuRuleOff` names a catalog reason or a thing found):
97
+ * every short block of it is `unknown` whatever it holds, and is eligible. Never
94
98
  * audio (P1) or delta (P2), and never a block its repair group cannot
95
99
  * complete (received sources + RSB_length < K'). The hold ends when its
96
100
  * FETCH ends without making the block decodable, not at the budget.
@@ -102,7 +106,9 @@
102
106
  * A FETCH landing after the gate forced that frame out would recover media
103
107
  * the gate then drops as stale.
104
108
  *
105
- * The scheduler arms no timers for block requests. A fetch ends when its
109
+ * The scheduler arms no timers for block requests but one: a running P0
110
+ * FETCH below a RAP held complete gets a timer at its playout deadline, when
111
+ * it turns moot (§6.2.1). A fetch ends when its
106
112
  * transport completes or throws, when it is preempted, when any later
107
113
  * scheduling event finds it past its presentation deadline, when its block
108
114
  * resolves (recovered, or failed at that deadline), on track reset, or on
@@ -346,7 +352,9 @@ export interface BlockSymbolCounts {
346
352
  * while its stream's classifier is `classifying` (the window rule could not
347
353
  * exclude a RAP). An `all-protected` stream reads `unknown` for every block,
348
354
  * delta-only ones included, so there `unknown` is no evidence of a RAP and
349
- * earns no hold. Audio and delta never do.
355
+ * earns no hold. Audio and delta never do. The mode alone is read: a
356
+ * `classifying` track on which `mpuRuleOff` leaves every block `unknown`
357
+ * gets the hold for each short block.
350
358
  */
351
359
  export function keyframeBudgetEligible(
352
360
  blockClass: BlockClass,
@@ -445,7 +453,7 @@ export type RepairSkipReason =
445
453
  | 'group-cannot-complete'
446
454
  /**
447
455
  * The keyframe-bearing block lies below a RAP the receiver already holds
448
- * complete, so its repair would be moot (draft-ramadan-moq-fec §11.4.2).
456
+ * complete, so its repair would be moot (draft-ramadan-moq-fec-multicast-01 §6.2.1).
449
457
  */
450
458
  | 'moot-rap'
451
459
 
@@ -637,6 +645,8 @@ interface FetchRun {
637
645
  /** When this FETCH went out: it lands around `sentAt + rtt`. */
638
646
  readonly sentAt: number
639
647
  stopped: StopReason | null
648
+ /** Set while a RAP above the block is held complete: fires at the playout deadline (mootAtPlayout). */
649
+ mootTimer?: ReturnType<typeof setTimeout>
640
650
  }
641
651
 
642
652
  interface RepairEntry {
@@ -659,7 +669,8 @@ interface RepairEntry {
659
669
  deadlineAt: number
660
670
  /**
661
671
  * `deadlineAt` without the keyframe budget's extension: the block's playout
662
- * deadline. A FETCH landing by it costs no stall, so it is never moot.
672
+ * deadline. A FETCH landing by it costs no stall, so it is not moot
673
+ * while this deadline is still ahead.
663
674
  */
664
675
  playoutDeadlineAt: number
665
676
  /** Inputs `deadlineAt` was computed from; they move with it. */
@@ -783,6 +794,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
783
794
  const run = entry.running
784
795
  if (!run) return
785
796
  entry.running = null
797
+ if (run.mootTimer !== undefined) clearTimeout(run.mootTimer)
786
798
  run.stopped = reason
787
799
  run.controller.abort(reason)
788
800
  // A preempted request returns to the queue; until it runs again nothing is
@@ -800,16 +812,20 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
800
812
 
801
813
  /**
802
814
  * A keyframe request whose whole block lies below a RAP already held
803
- * complete, and whose repair can only land on the keyframe budget's
804
- * extension. One that lands by the playout deadline stalls nothing, and
805
- * skipping it only throws away the block's frames (BLO-51635).
815
+ * complete, and whose repair cannot land by the block's playout deadline
816
+ * (draft-ramadan-moq-fec-multicast-01 §6.2.1): the deadline has passed,
817
+ * or send time + RTT is not before it, or no RTT is measured. One that
818
+ * lands by the playout deadline stalls nothing, and skipping it only
819
+ * throws away the block's frames (BLO-51635).
806
820
  */
807
821
  const moot = (entry: RepairEntry): boolean => {
808
822
  if (entry.priority !== 0) return false
809
823
  const rttMs = readRtt()
810
- // A running FETCH lands relative to when it was sent, not to now.
811
- const sentAt = entry.running?.sentAt ?? performance.now()
812
- if (rttMs !== null && sentAt + rttMs < entry.playoutDeadlineAt) return false
824
+ const now = performance.now()
825
+ // A running FETCH lands relative to when it was sent, not to now; once
826
+ // the playout deadline has passed it can no longer land by it.
827
+ const sentAt = entry.running?.sentAt ?? now
828
+ if (rttMs !== null && now < entry.playoutDeadlineAt && sentAt + rttMs < entry.playoutDeadlineAt) return false
813
829
  const last = lastSsId(entry)
814
830
  if (last === undefined) return false
815
831
  try {
@@ -819,6 +835,41 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
819
835
  }
820
836
  }
821
837
 
838
+ /** Cancel a running FETCH that turned moot. */
839
+ const dropMoot = (entry: RepairEntry): void => {
840
+ stop(entry, 'moot')
841
+ retire(entry)
842
+ releaseHold(entry)
843
+ clearEntry(entry)
844
+ }
845
+
846
+ /**
847
+ * Moot is a state (§6.2.1 condition 1: a RAP already admitted complete), so
848
+ * a running keyframe FETCH kept only because it could land by playout turns
849
+ * moot when that deadline passes, with no newer RAP: arm one timer for it
850
+ * then. None is armed while no RAP above the block is held complete.
851
+ */
852
+ const mootAtPlayout = (entry: RepairEntry): void => {
853
+ const run = entry.running
854
+ if (run === null || run.mootTimer !== undefined || entry.priority !== 0) return
855
+ const last = lastSsId(entry)
856
+ if (last === undefined) return
857
+ try {
858
+ if (mc.rapCompleteAbove?.(entry.packetId, entry.catalogTrackName, last) !== true) return
859
+ } catch {
860
+ return
861
+ }
862
+ run.mootTimer = setTimeout(() => {
863
+ run.mootTimer = undefined
864
+ if (disposed || entry.running !== run) return
865
+ // The deadline moved later (a reclassified block), or the timer ran early.
866
+ if (performance.now() < entry.playoutDeadlineAt) return mootAtPlayout(entry)
867
+ if (!moot(entry)) return
868
+ dropMoot(entry)
869
+ dispatch()
870
+ }, Math.max(0, entry.playoutDeadlineAt - performance.now()))
871
+ }
872
+
822
873
  /** Drop a request no FETCH will be sent for, and say why. */
823
874
  const skip = (entry: RepairEntry, reason: RepairSkipReason, rttMs: number | null, budgetMs: number): void => {
824
875
  retire(entry)
@@ -994,6 +1045,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
994
1045
  })
995
1046
  const run: FetchRun = { controller: new AbortController(), sentAt: now, stopped: null }
996
1047
  entry.running = run
1048
+ mootAtPlayout(entry)
997
1049
  // Hold the block open to the presentation deadline while this FETCH can
998
1050
  // still land: the multicast span elapsing must not abort it.
999
1051
  if (!entry.range) {
@@ -1126,6 +1178,7 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
1126
1178
  return
1127
1179
  }
1128
1180
  entry.running = null
1181
+ if (run.mootTimer !== undefined) clearTimeout(run.mootTimer)
1129
1182
  if (error === undefined) {
1130
1183
  retire(entry)
1131
1184
  // A fetch that ended without feeding anything cannot resolve the block;
@@ -1712,11 +1765,9 @@ export function wireRepairFetch(mc: RepairFetchHost, opts: WireRepairFetchOption
1712
1765
  queueMicrotask(() => {
1713
1766
  if (disposed) return
1714
1767
  for (const entry of [...entries.values()]) {
1715
- if (entry.packetId !== packetId || !entry.running || !moot(entry)) continue
1716
- stop(entry, 'moot')
1717
- retire(entry)
1718
- releaseHold(entry)
1719
- clearEntry(entry)
1768
+ if (entry.packetId !== packetId || !entry.running) continue
1769
+ if (moot(entry)) dropMoot(entry)
1770
+ else mootAtPlayout(entry)
1720
1771
  }
1721
1772
  dispatch()
1722
1773
  })
@@ -25,6 +25,7 @@ runtime resolver still reads live in `fec-01-runtime/`.
25
25
 
26
26
  The negatives:
27
27
 
28
+ - `event-timeline-empty-event-type.json`: an eventtimeline track's `eventType` is a non-empty string (msf-01 8.2).
28
29
  - `legacy-selection-params.json`: rendition fields must be flat.
29
30
  - `missing-mmtp-fields.json`: MMTP tracks require a timescale and a duration
30
31
  (the section's `track_timescale`); the missing `mmtpMode` is the track
@@ -0,0 +1,41 @@
1
+ {
2
+ "version": 1,
3
+ "streamingFormat": "mmtp",
4
+ "streamingFormatVersion": "draft-ramadan-moq-mmt-00",
5
+ "tracks": [
6
+ {
7
+ "name": "video",
8
+ "packaging": "mmtp",
9
+ "isLive": true,
10
+ "codec": "avc1.640028",
11
+ "framerate": 30,
12
+ "width": 1920,
13
+ "height": 1080,
14
+ "mmtpMode": "mfu",
15
+ "timescale": 90000,
16
+ "groupDurationMs": 1000
17
+ },
18
+ {
19
+ "name": "audio",
20
+ "packaging": "mmtp",
21
+ "isLive": true,
22
+ "codec": "mp4a.40.2",
23
+ "samplerate": 48000,
24
+ "channelConfig": "2",
25
+ "mmtpMode": "mfu",
26
+ "timescale": 48000,
27
+ "groupDurationMs": 1000
28
+ },
29
+ {
30
+ "name": "ad-creative",
31
+ "packaging": "eventtimeline",
32
+ "isLive": true,
33
+ "role": "eventtimeline",
34
+ "eventType": "",
35
+ "mimeType": "application/json",
36
+ "depends": [
37
+ "video"
38
+ ]
39
+ }
40
+ ]
41
+ }