@blockcast/mmt-container 2.2.0-main.e1bebe787bc9 → 2.2.0-main.ea9223dc11de
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/block-policy.d.ts +33 -3
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +60 -24
- package/dist/block-policy.js.map +3 -3
- package/dist/browser-runtime.js +1034 -126
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +40 -1
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +163 -10
- package/dist/carp-catalog.js.map +4 -4
- package/dist/catalog-fec-params.js +34 -0
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.js +34 -0
- package/dist/catalog-network-source.js.map +3 -3
- package/dist/datagram-leg-deadline.d.ts +138 -0
- package/dist/datagram-leg-deadline.d.ts.map +1 -0
- package/dist/datagram-leg-deadline.js +229 -0
- package/dist/datagram-leg-deadline.js.map +7 -0
- package/dist/delivery-catalog.js +68 -0
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/delta-fallback-config.js +34 -0
- package/dist/delta-fallback-config.js.map +3 -3
- package/dist/fec-manager.d.ts +117 -13
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +358 -42
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +17 -5
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +36 -0
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.js +34 -0
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/held-layer-admission.js +34 -0
- package/dist/held-layer-admission.js.map +3 -3
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +16 -0
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +62 -0
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +34 -0
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +6 -3
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +34 -0
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +167 -13
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +34 -0
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-fec-session.js +34 -0
- package/dist/mmtp-fec-session.js.map +3 -3
- package/dist/mmtp-mode-selection.d.ts +48 -0
- package/dist/mmtp-mode-selection.d.ts.map +1 -0
- package/dist/mmtp-mode-selection.js +79 -0
- package/dist/mmtp-mode-selection.js.map +7 -0
- package/dist/mmtp-router.d.ts +66 -10
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +204 -30
- package/dist/mmtp-router.js.map +4 -4
- package/dist/multicast-auth-catalog.js +42 -2
- package/dist/multicast-auth-catalog.js.map +3 -3
- package/dist/multicast-input.js +42 -2
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +95 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +613 -92
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.js +68 -0
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +34 -0
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.js +167 -13
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +2 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +69 -2
- package/dist/phase14-catalog-override.js.map +3 -3
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +50 -0
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layer-subscriptions.js +34 -0
- package/dist/repair-layer-subscriptions.js.map +3 -3
- package/dist/signaling.js +34 -0
- package/dist/signaling.js.map +3 -3
- package/dist/timestamp-codec.js +34 -0
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +34 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +34 -0
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/schemas/catalog.schema.json +2 -2
- package/src/block-policy.ts +108 -31
- package/src/carp-catalog.ts +165 -5
- package/src/datagram-leg-deadline.ts +370 -0
- package/src/fec-manager.ts +345 -33
- package/src/fec-state.ts +21 -5
- package/src/index.ts +37 -0
- package/src/iso-block-locator.ts +34 -0
- package/src/mmtp-container-parser.ts +6 -4
- package/src/mmtp-mode-selection.ts +80 -0
- package/src/mmtp-router.ts +226 -45
- package/src/multicast-manager.ts +126 -0
- package/src/phase14-catalog-override.ts +14 -3
- package/src/repair-fetch.ts +23 -0
- package/test-vectors/catalog/README.md +36 -2
- package/test-vectors/catalog/mmtp-siblings/ambiguous-sibling.json +158 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-bitrate-only.json +231 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-four-rungs.json +405 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-other-names.json +231 -0
- package/test-vectors/catalog/mmtp-siblings/mmtp-mode-unknown.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/multicast-endpoint-lists-datagram-track.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/no-sibling.json +79 -0
- package/test-vectors/catalog/mmtp-siblings/rendition-mismatch.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/stream-delivery-mode.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/timescale-mismatch.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/valid-pair.json +142 -0
- package/test-vectors/catalog/section-codes.json +3 -3
- package/test-vectors/catalog-timing.json +742 -1
- package/test-vectors/catalog-validation.json +266 -7
- package/test-vectors/moq/mmtp-mode-selection.json +259 -0
package/dist/fec-manager.js
CHANGED
|
@@ -311,6 +311,40 @@ var RUNTIME_FEC_RECEIVER = Object.freeze({
|
|
|
311
311
|
overlays: true
|
|
312
312
|
});
|
|
313
313
|
|
|
314
|
+
// ../mmt-base/dist/mmtp-siblings.js
|
|
315
|
+
var MMTP_MODES = Object.freeze(["mfu", "mfu-datagram"]);
|
|
316
|
+
var MMTP_SIBLING_HARD_FIELDS = Object.freeze([
|
|
317
|
+
"namespace",
|
|
318
|
+
"timescale",
|
|
319
|
+
"presentationAnchorTicks",
|
|
320
|
+
"groupDuration"
|
|
321
|
+
]);
|
|
322
|
+
var MMTP_SIBLING_RENDITION_FIELDS = Object.freeze([
|
|
323
|
+
"codec",
|
|
324
|
+
"width",
|
|
325
|
+
"height",
|
|
326
|
+
"framerate",
|
|
327
|
+
"bitrate",
|
|
328
|
+
"samplerate",
|
|
329
|
+
"channelConfig",
|
|
330
|
+
"lang"
|
|
331
|
+
]);
|
|
332
|
+
var MMTP_SIBLING_SOFT_FIELDS = Object.freeze([
|
|
333
|
+
"initRef",
|
|
334
|
+
"keyframeIntervalMs",
|
|
335
|
+
"keyframeIntervalTicks",
|
|
336
|
+
"isLive",
|
|
337
|
+
"altGroup"
|
|
338
|
+
]);
|
|
339
|
+
|
|
340
|
+
// ../mmt-base/dist/datagram-leg-size.js
|
|
341
|
+
var DATAGRAM_LEG_UDP_FLOOR = 1200;
|
|
342
|
+
var DATAGRAM_LEG_QUIC_WT_FRAMING = 48;
|
|
343
|
+
var DATAGRAM_LEG_OBJECT_HEADER = 13;
|
|
344
|
+
var DATAGRAM_LEG_RELAY_ROOM = 16;
|
|
345
|
+
var DATAGRAM_LEG_DATAGRAM_MAX = DATAGRAM_LEG_UDP_FLOOR - DATAGRAM_LEG_QUIC_WT_FRAMING;
|
|
346
|
+
var DATAGRAM_LEG_BODY_MAX = DATAGRAM_LEG_DATAGRAM_MAX - DATAGRAM_LEG_OBJECT_HEADER - DATAGRAM_LEG_RELAY_ROOM;
|
|
347
|
+
|
|
314
348
|
// src/iso-block-locator.ts
|
|
315
349
|
var IsoBlockLocator = class _IsoBlockLocator {
|
|
316
350
|
/**
|
|
@@ -506,6 +540,34 @@ var IsoBlockLocator = class _IsoBlockLocator {
|
|
|
506
540
|
isHeld(ssId) {
|
|
507
541
|
return this.#held.has(ssId);
|
|
508
542
|
}
|
|
543
|
+
/** The payload held unplaced for `ssId`, if any. */
|
|
544
|
+
heldSource(ssId) {
|
|
545
|
+
return this.#held.get(ssId);
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* The SS_IDs strictly between `a` and `b` that no repair has delimited a
|
|
549
|
+
* block of yet: those from the coverage end on, or all of them before the
|
|
550
|
+
* first repair. `missing` is the highest of them no source is held for;
|
|
551
|
+
* absent, every one of them arrived (C.5.2: SS_IDs are consecutive). Null
|
|
552
|
+
* when none lies past coverage. `flagged` is whether a source held among
|
|
553
|
+
* them satisfies `flag` (a RAP fragment, say): the held packets read as
|
|
554
|
+
* fec-multicast-00 Block Classification item 1 reads bounding packets.
|
|
555
|
+
*/
|
|
556
|
+
undelimitedBetween(a, b, flag) {
|
|
557
|
+
if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return null;
|
|
558
|
+
const first = a + 1 >>> 0;
|
|
559
|
+
const end = this.#coverageEnd;
|
|
560
|
+
const start = end !== void 0 && serial32Precedes(first, end) ? end : first;
|
|
561
|
+
if (!serial32Precedes(start, b)) return null;
|
|
562
|
+
const length = serial32Distance(start, b);
|
|
563
|
+
const missing = this.#highestMissing(start, length);
|
|
564
|
+
let flagged = false;
|
|
565
|
+
for (let i = 0; flag !== void 0 && !flagged && i < length; i++) {
|
|
566
|
+
const payload = this.#held.get(serial32Add(start, i));
|
|
567
|
+
flagged = payload !== void 0 && flag(payload);
|
|
568
|
+
}
|
|
569
|
+
return missing === void 0 ? { start, flagged } : { start, missing, flagged };
|
|
570
|
+
}
|
|
509
571
|
/**
|
|
510
572
|
* Apply one repair symbol's `(SS_Start, SSB_length)`. The first repair of a
|
|
511
573
|
* block states its range and places every held source in it; later repair
|
|
@@ -721,7 +783,7 @@ var INACTIVE = Object.freeze({
|
|
|
721
783
|
// src/block-policy.ts
|
|
722
784
|
import { deriveFecInterleaveDepth } from "@blockcast/mmt-fec";
|
|
723
785
|
function keyframeIntervalMediaTicks(geometry, mediaTimescale) {
|
|
724
|
-
if (geometry.trackKind !== "video" || geometry.
|
|
786
|
+
if (geometry.trackKind !== "video" || geometry.keyframeInterval === void 0) return null;
|
|
725
787
|
if (!Number.isSafeInteger(mediaTimescale) || mediaTimescale <= 0) return null;
|
|
726
788
|
const { ticks, timescale } = geometry.keyframeInterval;
|
|
727
789
|
if (!Number.isSafeInteger(ticks) || !Number.isSafeInteger(timescale)) return null;
|
|
@@ -730,9 +792,14 @@ function keyframeIntervalMediaTicks(geometry, mediaTimescale) {
|
|
|
730
792
|
if (scaled % divisor !== 0n) return null;
|
|
731
793
|
return scaled / divisor;
|
|
732
794
|
}
|
|
795
|
+
function keyframeInstantBetween(start, interval, from, to) {
|
|
796
|
+
const k = from >= start ? (from - start) / interval + 1n : 1n;
|
|
797
|
+
return start + k * interval <= to;
|
|
798
|
+
}
|
|
733
799
|
function compareDataUnitStarts(a, b) {
|
|
734
800
|
return a.movieFragment - b.movieFragment | 0 || a.idx - b.idx || a.offset - b.offset;
|
|
735
801
|
}
|
|
802
|
+
var LATE_RAP_MAX_MPUS_BACK = 64;
|
|
736
803
|
var UNPLACED = { rapNotMpuStart: false };
|
|
737
804
|
var BlockClassifier = class {
|
|
738
805
|
#geometry;
|
|
@@ -773,6 +840,7 @@ var BlockClassifier = class {
|
|
|
773
840
|
#lastAnchor = null;
|
|
774
841
|
/** Two anchors were exactly G fragments per MPU apart. */
|
|
775
842
|
#fragmentsProven = false;
|
|
843
|
+
/** The first RAP released of the latest MPU a RAP was released in, recorded in every mode. */
|
|
776
844
|
#lastRap = null;
|
|
777
845
|
constructor(geometry) {
|
|
778
846
|
this.#geometry = geometry;
|
|
@@ -843,6 +911,7 @@ var BlockClassifier = class {
|
|
|
843
911
|
noteSourceDiscontinuity() {
|
|
844
912
|
this.#clearContiguityLedger();
|
|
845
913
|
this.#clearMpuLayout();
|
|
914
|
+
this.#lastRap = null;
|
|
846
915
|
}
|
|
847
916
|
/** Register a block that exists without evidence (a vanished block). */
|
|
848
917
|
touch(sbn) {
|
|
@@ -895,18 +964,35 @@ var BlockClassifier = class {
|
|
|
895
964
|
* RAP-bearing block is the one a wrong G calls delta), because the next
|
|
896
965
|
* released RAP then belongs to m+2. Every MPU is one interval long, so the
|
|
897
966
|
* span to any later released RAP proves or refutes all MPUs in between.
|
|
967
|
+
*
|
|
968
|
+
* In every mode it keeps each MPU's first released RAP, with its decode
|
|
969
|
+
* time, as the start keyframeFreeBetween measures the catalog interval
|
|
970
|
+
* from, and a second RAP released inside one MPU refutes `mpuBoundsRaps`
|
|
971
|
+
* when it lies off the catalog lattice (not a whole number of intervals
|
|
972
|
+
* after the first; draft-ramadan-moq-mmt-02 4.4.3 binds every keyframe to
|
|
973
|
+
* it): with no repair, released RAPs are the only evidence of where they
|
|
974
|
+
* lie. Without a usable interval, or a decode time on either, any second
|
|
975
|
+
* RAP with another presentation time refutes.
|
|
898
976
|
*/
|
|
899
|
-
noteReleasedRap(mpu, presentationTime, mediaTimescale) {
|
|
900
|
-
if (this.#geometry.trackKind === "audio"
|
|
901
|
-
return [];
|
|
902
|
-
}
|
|
903
|
-
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale);
|
|
904
|
-
if (interval === null) return this.#disable("keyframe-interval-not-media-integral");
|
|
977
|
+
noteReleasedRap(mpu, presentationTime, mediaTimescale, decodeTime) {
|
|
978
|
+
if (this.#geometry.trackKind === "audio") return [];
|
|
905
979
|
const previous = this.#lastRap;
|
|
906
980
|
if (previous !== null && previous.mpu === mpu && previous.mediaTimescale === mediaTimescale) {
|
|
981
|
+
if (presentationTime === previous.presentationTime) return [];
|
|
982
|
+
const interval2 = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale);
|
|
983
|
+
if (interval2 === null || decodeTime === void 0 || previous.decodeTime === void 0 || (decodeTime - previous.decodeTime) % interval2 !== 0n) {
|
|
984
|
+
this.#mpuBoundsRaps = false;
|
|
985
|
+
}
|
|
907
986
|
return [];
|
|
908
987
|
}
|
|
909
|
-
|
|
988
|
+
if (previous !== null && previous.mediaTimescale === mediaTimescale) {
|
|
989
|
+
const back = previous.mpu - mpu >>> 0;
|
|
990
|
+
if (back !== 0 && back <= LATE_RAP_MAX_MPUS_BACK && presentationTime < previous.presentationTime) return [];
|
|
991
|
+
}
|
|
992
|
+
this.#lastRap = { mpu, presentationTime, mediaTimescale, ...decodeTime === void 0 ? {} : { decodeTime } };
|
|
993
|
+
if (this.#mode === "all-protected") return [];
|
|
994
|
+
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale);
|
|
995
|
+
if (interval === null) return this.#disable("keyframe-interval-not-media-integral");
|
|
910
996
|
if (previous === null || mpu < previous.mpu || previous.mediaTimescale !== mediaTimescale) {
|
|
911
997
|
return [];
|
|
912
998
|
}
|
|
@@ -915,6 +1001,22 @@ var BlockClassifier = class {
|
|
|
915
1001
|
}
|
|
916
1002
|
return this.#disable("rap-spacing-mismatch");
|
|
917
1003
|
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Whether a gap inside MPU `mpu`, between the decode times `from` and `to`
|
|
1006
|
+
* of the frames on either side, holds no keyframe: MPU boundaries still
|
|
1007
|
+
* bound RAPs, the catalog states an interval exact in this timescale, and
|
|
1008
|
+
* none of its instants after the MPU's first released RAP lies in
|
|
1009
|
+
* `(from, to]` (fec-multicast-00 Block Classification item 3). Anything
|
|
1010
|
+
* unknown counts as a keyframe.
|
|
1011
|
+
*/
|
|
1012
|
+
keyframeFreeBetween(mpu, from, to, mediaTimescale) {
|
|
1013
|
+
const rap = this.#lastRap;
|
|
1014
|
+
if (!this.#mpuBoundsRaps || rap?.mpu !== mpu || rap.mediaTimescale !== mediaTimescale || rap.decodeTime === void 0) {
|
|
1015
|
+
return false;
|
|
1016
|
+
}
|
|
1017
|
+
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale);
|
|
1018
|
+
return interval !== null && !keyframeInstantBetween(rap.decodeTime, interval, from, to);
|
|
1019
|
+
}
|
|
918
1020
|
#blockFor(sbn) {
|
|
919
1021
|
let block = this.#blocks.get(sbn);
|
|
920
1022
|
if (!block) {
|
|
@@ -1307,7 +1409,12 @@ var FECManager = class _FECManager {
|
|
|
1307
1409
|
this.#repairHoldUntilMs = /* @__PURE__ */ new Map();
|
|
1308
1410
|
// Receiver-measured multicast delivery gap: the late-symbol wait's jitter
|
|
1309
1411
|
// term (see DeliveryGapEstimator for the statistic and why).
|
|
1310
|
-
|
|
1412
|
+
// One estimator per lossy path, so a hybrid session never lets one leg's
|
|
1413
|
+
// stall widen the other's wait; the wait reads the larger peak.
|
|
1414
|
+
this.#deliveryGaps = {
|
|
1415
|
+
multicast: new DeliveryGapEstimator(),
|
|
1416
|
+
"moq-datagram": new DeliveryGapEstimator()
|
|
1417
|
+
};
|
|
1311
1418
|
this.#lifecycleTrace = [];
|
|
1312
1419
|
// Worker-backed timeouts enqueue cleanup behind all prior symbol messages.
|
|
1313
1420
|
// Failure remains pending until cleanupComplete acknowledges that queue drain.
|
|
@@ -1499,6 +1606,14 @@ var FECManager = class _FECManager {
|
|
|
1499
1606
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
1500
1607
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
1501
1608
|
this.#isoLocators = /* @__PURE__ */ new Map();
|
|
1609
|
+
// The ts of the run behind the gap the release gate last asked about, per
|
|
1610
|
+
// stream (isoRepairlessWaitMs), keyed on the frame before the gap: kept, as
|
|
1611
|
+
// the source it came from may retire before the run's deadline, and the
|
|
1612
|
+
// earliest found wins, so a late frame that becomes the head restarts
|
|
1613
|
+
// nothing. It stays until the next run gap: a source discontinuity drops
|
|
1614
|
+
// it, and one older than twice the hold ceiling is not this gap's.
|
|
1615
|
+
// `counted` once the deadline passed (onUndelimitedRunGap).
|
|
1616
|
+
this.#runAnchors = /* @__PURE__ */ new Map();
|
|
1502
1617
|
this.#deferIsoGaps = false;
|
|
1503
1618
|
this.#isoRepairRefusedCount = 0;
|
|
1504
1619
|
this.#isoSourceOversizeCount = 0;
|
|
@@ -1535,6 +1650,7 @@ var FECManager = class _FECManager {
|
|
|
1535
1650
|
this.#decoderUnavailableEvents = 0;
|
|
1536
1651
|
this.#repairSymbolSizeMismatchCount = 0;
|
|
1537
1652
|
this.#unlistedRepairTrackRefusals = 0;
|
|
1653
|
+
this.#unresolvedRepairOwnerDrops = { unregistered: 0, ownerAbsent: 0, ownerAmbiguous: 0 };
|
|
1538
1654
|
// Event callbacks — block lifecycle notifications for MmtpRouter wiring.
|
|
1539
1655
|
// NOTE: For sync WASM path, recovery routing is handled by MmtpRouter from
|
|
1540
1656
|
// feedSourceSymbol/feedRepairSymbol return values. For Worker path, recovery
|
|
@@ -1594,6 +1710,8 @@ var FECManager = class _FECManager {
|
|
|
1594
1710
|
this.onBlockResolved = null;
|
|
1595
1711
|
/** A stream's SBN went backwards (or jumped implausibly): the source restarted. */
|
|
1596
1712
|
this.onSourceDiscontinuity = null;
|
|
1713
|
+
/** The FEC deadline of a run no repair delimited passed, releasing the gap behind it (once per gap). */
|
|
1714
|
+
this.onUndelimitedRunGap = null;
|
|
1597
1715
|
/**
|
|
1598
1716
|
* The span and tolerance the catalog states for a keyframe overlay
|
|
1599
1717
|
* installed over a source track (draft-ramadan-moq-mmt-02 7.4.1: the
|
|
@@ -1694,6 +1812,7 @@ var FECManager = class _FECManager {
|
|
|
1694
1812
|
#highestSbn;
|
|
1695
1813
|
#sourceFrontiers;
|
|
1696
1814
|
#isoLocators;
|
|
1815
|
+
#runAnchors;
|
|
1697
1816
|
#deferIsoGaps;
|
|
1698
1817
|
#isoRepairRefusedCount;
|
|
1699
1818
|
#isoSourceOversizeCount;
|
|
@@ -1709,6 +1828,7 @@ var FECManager = class _FECManager {
|
|
|
1709
1828
|
#decoderUnavailableEvents;
|
|
1710
1829
|
#repairSymbolSizeMismatchCount;
|
|
1711
1830
|
#unlistedRepairTrackRefusals;
|
|
1831
|
+
#unresolvedRepairOwnerDrops;
|
|
1712
1832
|
#onUndelimitedLoss;
|
|
1713
1833
|
#onIsoHoleExpired;
|
|
1714
1834
|
#encodeTrackName(catalogTrackName) {
|
|
@@ -2358,6 +2478,7 @@ var FECManager = class _FECManager {
|
|
|
2358
2478
|
const discontinuity = () => {
|
|
2359
2479
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity();
|
|
2360
2480
|
this.#noSpanRaps.delete(streamKey);
|
|
2481
|
+
this.#runAnchors.delete(streamKey);
|
|
2361
2482
|
this.#highestSbn.set(streamKey, { sbn, atMs: now });
|
|
2362
2483
|
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now });
|
|
2363
2484
|
if (psn === void 0) this.#sourceAnchors.delete(streamKey);
|
|
@@ -2528,7 +2649,7 @@ var FECManager = class _FECManager {
|
|
|
2528
2649
|
consider(geometry, this.#parseStreamKey(streamKey).packetId);
|
|
2529
2650
|
}
|
|
2530
2651
|
for (const [packetId, config] of this.#trackConfigs) consider(config.geometry, packetId);
|
|
2531
|
-
this.#deliveryGaps.setWindowMs(windowMs);
|
|
2652
|
+
for (const estimator of Object.values(this.#deliveryGaps)) estimator.setWindowMs(windowMs);
|
|
2532
2653
|
}
|
|
2533
2654
|
/**
|
|
2534
2655
|
* The multicast late-symbol wait: the block span plus the larger of the
|
|
@@ -2541,14 +2662,14 @@ var FECManager = class _FECManager {
|
|
|
2541
2662
|
* stream order and never feeds the estimator.
|
|
2542
2663
|
*/
|
|
2543
2664
|
#multicastWaitMs(config) {
|
|
2544
|
-
return this.#waitForGapMs(config, this.#
|
|
2665
|
+
return this.#waitForGapMs(config, this.#peakDeliveryGapMs());
|
|
2545
2666
|
}
|
|
2546
2667
|
/**
|
|
2547
2668
|
* The widest #multicastWaitMs can become: the estimator reports at most its
|
|
2548
2669
|
* catalog window, so this is a catalog quantity that no measurement moves.
|
|
2549
2670
|
*/
|
|
2550
2671
|
#maxMulticastWaitMs(config) {
|
|
2551
|
-
return this.#waitForGapMs(config, this.#deliveryGaps.windowMs ?? 0);
|
|
2672
|
+
return this.#waitForGapMs(config, this.#deliveryGaps.multicast.windowMs ?? 0);
|
|
2552
2673
|
}
|
|
2553
2674
|
#waitForGapMs(config, gapMs) {
|
|
2554
2675
|
if (!(gapMs > 0) || !(config.interleaveDepthMs > 0)) return config.timeoutMs;
|
|
@@ -2732,6 +2853,7 @@ var FECManager = class _FECManager {
|
|
|
2732
2853
|
...(config.trackKind ?? previous.trackKind) === void 0 ? {} : { trackKind: config.trackKind ?? previous.trackKind },
|
|
2733
2854
|
...(config.codec ?? previous.codec) === void 0 ? {} : { codec: config.codec ?? previous.codec },
|
|
2734
2855
|
...(config.geometry ?? previous.geometry) === void 0 ? {} : { geometry: config.geometry ?? previous.geometry },
|
|
2856
|
+
...(config.groupDurationMs ?? previous.groupDurationMs) === void 0 ? {} : { groupDurationMs: config.groupDurationMs ?? previous.groupDurationMs },
|
|
2735
2857
|
...(config.repairLayers ?? previous.repairLayers) === void 0 ? {} : { repairLayers: config.repairLayers ?? previous.repairLayers },
|
|
2736
2858
|
...(config.heldLayers ?? previous.heldLayers) === void 0 ? {} : { heldLayers: config.heldLayers ?? previous.heldLayers }
|
|
2737
2859
|
};
|
|
@@ -2838,6 +2960,10 @@ var FECManager = class _FECManager {
|
|
|
2838
2960
|
lifecycleTrace: this.#lifecycleTrace.map((entry) => ({ ...entry }))
|
|
2839
2961
|
};
|
|
2840
2962
|
}
|
|
2963
|
+
/** Count a repair packet the router dropped for want of an owning track (BLO-55759). */
|
|
2964
|
+
countUnresolvedRepairOwner(reason) {
|
|
2965
|
+
this.#unresolvedRepairOwnerDrops[reason]++;
|
|
2966
|
+
}
|
|
2841
2967
|
get fecStats() {
|
|
2842
2968
|
const s = this.#fecStats;
|
|
2843
2969
|
const affected = s.blocksRecovered + s.blocksFailed;
|
|
@@ -2878,6 +3004,7 @@ var FECManager = class _FECManager {
|
|
|
2878
3004
|
})),
|
|
2879
3005
|
repairSymbolSizeMismatches: this.#repairSymbolSizeMismatchCount,
|
|
2880
3006
|
unlistedRepairTrackRefusals: this.#unlistedRepairTrackRefusals,
|
|
3007
|
+
unresolvedRepairOwnerDrops: { ...this.#unresolvedRepairOwnerDrops },
|
|
2881
3008
|
repairObjectRejects: [...this.#repairObjectRejects.values()].map((r) => ({ ...r })),
|
|
2882
3009
|
workerErrors: Object.fromEntries(this.#workerErrorCounts)
|
|
2883
3010
|
};
|
|
@@ -2902,6 +3029,16 @@ var FECManager = class _FECManager {
|
|
|
2902
3029
|
this.#startupRepairBoundaryCounts.clear();
|
|
2903
3030
|
this.#startupRepairFailOpenPackets.clear();
|
|
2904
3031
|
}
|
|
3032
|
+
/**
|
|
3033
|
+
* Start a new "mfu-datagram" leg (mmt-02 4.3.1) without discarding
|
|
3034
|
+
* track/decoder state: the same join-boundary rules as a multicast join,
|
|
3035
|
+
* since the leg starts at an arbitrary datagram too. It resets the whole
|
|
3036
|
+
* join boundary of this manager, a multicast ordered-relay frontier
|
|
3037
|
+
* included, so a host gives the leg a manager of its own.
|
|
3038
|
+
*/
|
|
3039
|
+
beginLegJoin() {
|
|
3040
|
+
this.beginMulticastJoin();
|
|
3041
|
+
}
|
|
2905
3042
|
/** How the multicast leg currently delivers symbols. */
|
|
2906
3043
|
get multicastSymbolDelivery() {
|
|
2907
3044
|
return this.#multicastSymbolDelivery;
|
|
@@ -2924,7 +3061,8 @@ var FECManager = class _FECManager {
|
|
|
2924
3061
|
);
|
|
2925
3062
|
}
|
|
2926
3063
|
if (delivery === this.#multicastSymbolDelivery) return;
|
|
2927
|
-
this.#deliveryGaps.reset();
|
|
3064
|
+
this.#deliveryGaps.multicast.reset();
|
|
3065
|
+
this.#runAnchors.clear();
|
|
2928
3066
|
if (delivery === "ordered-relay") {
|
|
2929
3067
|
for (const [packetId, config] of this.#trackConfigs) {
|
|
2930
3068
|
this.#orderedHorizonBlocksFor(packetId, config);
|
|
@@ -3013,6 +3151,7 @@ var FECManager = class _FECManager {
|
|
|
3013
3151
|
resetMap(this.#highestSbn);
|
|
3014
3152
|
resetMap(this.#sourceFrontiers);
|
|
3015
3153
|
resetMap(this.#isoLocators);
|
|
3154
|
+
resetMap(this.#runAnchors);
|
|
3016
3155
|
resetMap(this.#sourceAnchors);
|
|
3017
3156
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName));
|
|
3018
3157
|
this.#noSpanRaps.delete(this.#streamKey(packetId, catalogTrackName));
|
|
@@ -3122,6 +3261,7 @@ var FECManager = class _FECManager {
|
|
|
3122
3261
|
dropMap(this.#highestSbn);
|
|
3123
3262
|
dropMap(this.#sourceFrontiers);
|
|
3124
3263
|
dropMap(this.#isoLocators);
|
|
3264
|
+
dropMap(this.#runAnchors);
|
|
3125
3265
|
dropMap(this.#sourceAnchors);
|
|
3126
3266
|
dropMap(this.#classifiers);
|
|
3127
3267
|
dropMap(this.#noSpanRaps);
|
|
@@ -3189,8 +3329,8 @@ var FECManager = class _FECManager {
|
|
|
3189
3329
|
const sourceSymbols = this.#isoLocatorFor(packetId, catalogTrackName).blockAt(sbn)?.length ?? this.#trackConfig(packetId).k;
|
|
3190
3330
|
const isSourceSymbol = esi >= 0 && esi < sourceSymbols;
|
|
3191
3331
|
const isStartupPartial = this.#startupPartialBlocks.has(blockKey);
|
|
3192
|
-
const isReadyMulticastRepair = this.#startupRequireRepairReady && source
|
|
3193
|
-
const awaitingMulticastRepair = this.#startupRequireRepairReady && source
|
|
3332
|
+
const isReadyMulticastRepair = this.#startupRequireRepairReady && source !== "moq" && !isSourceSymbol && this.#startupRepairReadyPackets.has(streamKey);
|
|
3333
|
+
const awaitingMulticastRepair = this.#startupRequireRepairReady && source !== "moq" && !this.#startupRepairReadyPackets.has(streamKey) && !this.#startupRepairFailOpenPackets.has(streamKey);
|
|
3194
3334
|
if (awaitingMulticastRepair) {
|
|
3195
3335
|
if (!isSourceSymbol) {
|
|
3196
3336
|
this.#startupRepairReadyPackets.add(streamKey);
|
|
@@ -3244,12 +3384,14 @@ var FECManager = class _FECManager {
|
|
|
3244
3384
|
...catalogTrackName === void 0 ? {} : { catalogTrackName },
|
|
3245
3385
|
multicastSymbols: 0,
|
|
3246
3386
|
moqSymbols: 0,
|
|
3387
|
+
datagramSymbols: 0,
|
|
3247
3388
|
complete: false
|
|
3248
3389
|
};
|
|
3249
3390
|
const receivedAtMs = this.#receiptNow();
|
|
3250
3391
|
const anchorMs = this.#blockAnchorsMs.get(blockKey);
|
|
3251
3392
|
if (anchorMs === void 0 || receivedAtMs < anchorMs) this.#blockAnchorsMs.set(blockKey, receivedAtMs);
|
|
3252
3393
|
if (source === "multicast") counts.multicastSymbols++;
|
|
3394
|
+
else if (source === "moq-datagram") counts.datagramSymbols++;
|
|
3253
3395
|
else counts.moqSymbols++;
|
|
3254
3396
|
this.#blockPathCounts.set(blockKey, counts);
|
|
3255
3397
|
this.#observeBlockCatalogTrackName(blockKey, sbn, packetId, catalogTrackName);
|
|
@@ -3270,7 +3412,7 @@ var FECManager = class _FECManager {
|
|
|
3270
3412
|
this.#unindexBlockKey(key);
|
|
3271
3413
|
}
|
|
3272
3414
|
}
|
|
3273
|
-
if (isSourceSymbol && source
|
|
3415
|
+
if (isSourceSymbol && source !== "moq") {
|
|
3274
3416
|
this.#noteMulticastSource(this.#isoLocatorFor(packetId, catalogTrackName), sbn + esi >>> 0, packetId, catalogTrackName);
|
|
3275
3417
|
}
|
|
3276
3418
|
return true;
|
|
@@ -3359,8 +3501,22 @@ var FECManager = class _FECManager {
|
|
|
3359
3501
|
* DeliveryGapEstimator). Datagram delivery only.
|
|
3360
3502
|
*/
|
|
3361
3503
|
noteMulticastArrival(packetId, packetSequenceNumber) {
|
|
3362
|
-
|
|
3363
|
-
|
|
3504
|
+
this.noteArrival("multicast", packetId, packetSequenceNumber);
|
|
3505
|
+
}
|
|
3506
|
+
/**
|
|
3507
|
+
* Record one MMTP packet arrival on a lossy path for that path's
|
|
3508
|
+
* delivery-gap measurement: the multicast leg (datagram delivery only; an
|
|
3509
|
+
* ordered relay settles by stream order) or an "mfu-datagram" leg, whose
|
|
3510
|
+
* datagrams are always a lossy path (#lossyDatagramPath).
|
|
3511
|
+
*/
|
|
3512
|
+
noteArrival(path, packetId, packetSequenceNumber) {
|
|
3513
|
+
if (!this.#lossyDatagramPath(path)) return;
|
|
3514
|
+
this.#deliveryGaps[path].noteArrival(performance.now(), packetId, packetSequenceNumber);
|
|
3515
|
+
}
|
|
3516
|
+
/** The largest delivery gap any lossy path measured over its window. */
|
|
3517
|
+
#peakDeliveryGapMs() {
|
|
3518
|
+
const now = performance.now();
|
|
3519
|
+
return Math.max(...Object.values(this.#deliveryGaps).map((estimator) => estimator.peakGapMs(now)));
|
|
3364
3520
|
}
|
|
3365
3521
|
/**
|
|
3366
3522
|
* Resolved per-track multicast late-symbol wait in milliseconds: the span
|
|
@@ -3374,10 +3530,10 @@ var FECManager = class _FECManager {
|
|
|
3374
3530
|
* Largest multicast delivery gap measured over the current window (ms), and
|
|
3375
3531
|
* that window (undefined: held since the last reset). Diagnostics.
|
|
3376
3532
|
*/
|
|
3377
|
-
multicastDeliveryGap() {
|
|
3533
|
+
multicastDeliveryGap(path = "multicast") {
|
|
3378
3534
|
return {
|
|
3379
|
-
peakGapMs: this.#deliveryGaps.peakGapMs(performance.now()),
|
|
3380
|
-
windowMs: this.#deliveryGaps.windowMs
|
|
3535
|
+
peakGapMs: this.#deliveryGaps[path].peakGapMs(performance.now()),
|
|
3536
|
+
windowMs: this.#deliveryGaps[path].windowMs
|
|
3381
3537
|
};
|
|
3382
3538
|
}
|
|
3383
3539
|
/**
|
|
@@ -3475,6 +3631,23 @@ var FECManager = class _FECManager {
|
|
|
3475
3631
|
const config = this.#trackConfigs.get(packetId);
|
|
3476
3632
|
return config === void 0 ? void 0 : this.#blockLifetimeMs(config);
|
|
3477
3633
|
}
|
|
3634
|
+
/**
|
|
3635
|
+
* How long an "mfu-datagram" leg's duplicate ledgers must remember a packet
|
|
3636
|
+
* so a legal reorder never reads as a publisher restart: one block span,
|
|
3637
|
+
* the reorder tolerance (`timeoutMs` is span + tolerance) and one group,
|
|
3638
|
+
* since a datagram may trail the stream by a whole group behind a joining
|
|
3639
|
+
* FETCH (mmt-02 6.1 step 3). The group is the catalog group duration
|
|
3640
|
+
* (`groupDurationMs`), whatever the track kind; a video track configured
|
|
3641
|
+
* without one falls back to its keyframe interval (one GOP per group).
|
|
3642
|
+
* Undefined for an unconfigured packet id.
|
|
3643
|
+
*/
|
|
3644
|
+
datagramLegLedgerRetentionMsForPacket(packetId) {
|
|
3645
|
+
const config = this.#trackConfigs.get(packetId);
|
|
3646
|
+
if (config === void 0) return void 0;
|
|
3647
|
+
const geometry = config.geometry;
|
|
3648
|
+
const groupMs = config.groupDurationMs ?? (geometry?.trackKind === "video" && geometry.mode === "classifying" ? geometry.keyframeInterval.ticks / geometry.keyframeInterval.timescale * 1e3 : 0);
|
|
3649
|
+
return config.timeoutMs + (Number.isFinite(groupMs) ? groupMs : 0);
|
|
3650
|
+
}
|
|
3478
3651
|
/**
|
|
3479
3652
|
* How long a terminal (clean, recovered or failed) block stays authoritative,
|
|
3480
3653
|
* for late symbols and for the in-order release gate. It is also the gate's
|
|
@@ -3543,6 +3716,9 @@ var FECManager = class _FECManager {
|
|
|
3543
3716
|
for (const key of [...this.#isoLocators.keys()]) {
|
|
3544
3717
|
if (this.#belongsToPacket(key, packetId)) this.#isoLocators.delete(key);
|
|
3545
3718
|
}
|
|
3719
|
+
for (const key of [...this.#runAnchors.keys()]) {
|
|
3720
|
+
if (this.#belongsToPacket(key, packetId)) this.#runAnchors.delete(key);
|
|
3721
|
+
}
|
|
3546
3722
|
}
|
|
3547
3723
|
/**
|
|
3548
3724
|
* The iso-ssbg1-v1 locator horizon in blocks: every block the manager can
|
|
@@ -3592,9 +3768,9 @@ var FECManager = class _FECManager {
|
|
|
3592
3768
|
holdIsoSource(packetId, catalogTrackName, ssId, source) {
|
|
3593
3769
|
const locator = this.#growingIsoLocatorFor(packetId, catalogTrackName);
|
|
3594
3770
|
const evictedBefore = locator.heldEvicted;
|
|
3595
|
-
const held = locator.hold(ssId, source);
|
|
3771
|
+
const held = locator.hold(ssId, source.arrivedAtMs === void 0 ? { ...source, arrivedAtMs: this.#receiptNow() } : source);
|
|
3596
3772
|
this.#settleExpiredIsoHoles(locator, packetId, catalogTrackName);
|
|
3597
|
-
if (held && source.source
|
|
3773
|
+
if (held && source.source !== "moq") this.#noteMulticastSource(locator, ssId, packetId, catalogTrackName);
|
|
3598
3774
|
const evicted = locator.heldEvicted - evictedBefore;
|
|
3599
3775
|
if (evicted > 0) {
|
|
3600
3776
|
const before = this.#isoHeldEvictedCount;
|
|
@@ -3712,7 +3888,12 @@ var FECManager = class _FECManager {
|
|
|
3712
3888
|
* Resolution of the SS_IDs strictly between two released frames' SS_IDs on
|
|
3713
3889
|
* an iso-ssbg1-v1 stream, for in-order frame release: null while a block
|
|
3714
3890
|
* that could hold them is pending or not yet stated by a repair, else the
|
|
3715
|
-
* starts of the blocks that failed or vanished.
|
|
3891
|
+
* starts of the blocks that failed or vanished. SS_IDs no repair has
|
|
3892
|
+
* delimited yet that all arrived lost nothing and wait for no repair, only
|
|
3893
|
+
* the late-source allowance after the datagram of a lossy path that clocks
|
|
3894
|
+
* them arrived (#lossFreeRunReadyAtMs), and not even that when none of them
|
|
3895
|
+
* came as one; one missing makes a run that waits as one block
|
|
3896
|
+
* (isoRepairlessWaitMs).
|
|
3716
3897
|
*
|
|
3717
3898
|
* `untracked` reads as the release gate reads it (MmtpRouter
|
|
3718
3899
|
* #createFecReleaseGate): a block holding either released frame's SS_ID
|
|
@@ -3725,7 +3906,16 @@ var FECManager = class _FECManager {
|
|
|
3725
3906
|
isoSpanResolution(packetId, catalogTrackName, fromSsId, toSsId) {
|
|
3726
3907
|
if (!serial32Precedes(fromSsId, toSsId) || serial32Distance(fromSsId, toSsId) <= 1) return [];
|
|
3727
3908
|
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName));
|
|
3728
|
-
if (!locator
|
|
3909
|
+
if (!locator) return null;
|
|
3910
|
+
const run = locator.undelimitedBetween(fromSsId, toSsId);
|
|
3911
|
+
if (run?.missing !== void 0) return null;
|
|
3912
|
+
if (run !== null) {
|
|
3913
|
+
const config = this.#trackConfigs.get(packetId);
|
|
3914
|
+
const readyAtMs = config === void 0 ? void 0 : this.#lossFreeRunReadyAtMs(config, locator, run.start, toSsId);
|
|
3915
|
+
if (readyAtMs !== void 0 && this.#receiptNow() < readyAtMs) return null;
|
|
3916
|
+
}
|
|
3917
|
+
if (locator.coverageEnd === void 0) return [];
|
|
3918
|
+
if (!locator.coversBetween(fromSsId, run?.start ?? toSsId)) return null;
|
|
3729
3919
|
const highest = this.highestSbn(packetId, catalogTrackName);
|
|
3730
3920
|
const lost = [];
|
|
3731
3921
|
for (const block of locator.blocksBetween(fromSsId, toSsId)) {
|
|
@@ -3743,6 +3933,63 @@ var FECManager = class _FECManager {
|
|
|
3743
3933
|
}
|
|
3744
3934
|
return lost;
|
|
3745
3935
|
}
|
|
3936
|
+
/**
|
|
3937
|
+
* When undelimited SS_IDs from `runStart` up to `toSsId` that all arrived
|
|
3938
|
+
* stop holding its frame: the late-source allowance after the receipt of
|
|
3939
|
+
* a datagram of a lossy path (#lossyDatagramPath: a multicast datagram, or
|
|
3940
|
+
* one of an "mfu-datagram" leg). Until then a frame between them may still
|
|
3941
|
+
* complete from a packet with no SS_ID (an untagged FT=0/FT=1 reordered
|
|
3942
|
+
* behind the next frame), and a repair may delimit them. The receipt is
|
|
3943
|
+
* `toSsId`'s own when it is held from such a datagram. Otherwise (its
|
|
3944
|
+
* packet came only as an overlap copy or from a MoQ stream, or was evicted
|
|
3945
|
+
* or retired) it is the newest among those SS_IDs, every one of which is
|
|
3946
|
+
* held and states its path. So the time moves at most once, when the
|
|
3947
|
+
* head's own datagram copy arrives while its frame waits or its held
|
|
3948
|
+
* source is dropped, and never on a later ask.
|
|
3949
|
+
*
|
|
3950
|
+
* Undefined, so the range releases at once, when no SS_ID of it came as
|
|
3951
|
+
* such a datagram: a MoQ arrival, an ordered relay's and the frame's own
|
|
3952
|
+
* are no clock for datagram reordering (#lossyReceiptMs). Undefined too
|
|
3953
|
+
* on a track with no catalog span, which states no allowance: the local
|
|
3954
|
+
* timeout is a cleanup bound, and isoRepairlessWaitMs arms no wake there,
|
|
3955
|
+
* so a wait would hold the frame until the next packet. The cost, on
|
|
3956
|
+
* multicast and on the leg too: an untagged FT=0/FT=1 reordered behind
|
|
3957
|
+
* the next frame of such a track is dropped stale.
|
|
3958
|
+
*/
|
|
3959
|
+
#lossFreeRunReadyAtMs(config, locator, runStart, toSsId) {
|
|
3960
|
+
if (!_FECManager.#hasCatalogTiming(config)) return void 0;
|
|
3961
|
+
let clockMs = this.#lossyReceiptMs(locator.heldSource(toSsId));
|
|
3962
|
+
if (clockMs === void 0) {
|
|
3963
|
+
for (let ssId = runStart; ssId !== toSsId; ssId = ssId + 1 >>> 0) {
|
|
3964
|
+
const atMs = this.#lossyReceiptMs(locator.heldSource(ssId));
|
|
3965
|
+
if (atMs !== void 0 && (clockMs === void 0 || atMs > clockMs)) clockMs = atMs;
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
if (clockMs === void 0) return void 0;
|
|
3969
|
+
return clockMs + Math.max(0, this.#multicastWaitMs(config) - config.interleaveDepthMs);
|
|
3970
|
+
}
|
|
3971
|
+
/**
|
|
3972
|
+
* Receipt time of a held source that came as a datagram of a lossy path
|
|
3973
|
+
* (#lossyDatagramPath), else undefined: a MoQ stream and an ordered relay
|
|
3974
|
+
* deliver in order, so their arrivals clock no reorder allowance and no
|
|
3975
|
+
* FEC deadline. The path is the one the feed stated (IsoHeldSource.source,
|
|
3976
|
+
* and MulticastSymbolDelivery for a multicast source), never a guess.
|
|
3977
|
+
*/
|
|
3978
|
+
#lossyReceiptMs(held) {
|
|
3979
|
+
return held !== void 0 && this.#lossyDatagramPath(held.source) ? held.arrivedAtMs : void 0;
|
|
3980
|
+
}
|
|
3981
|
+
/**
|
|
3982
|
+
* The one path predicate of the loss gates: whether a symbol fed as
|
|
3983
|
+
* `source` reached this manager as a datagram of its own, on a path that
|
|
3984
|
+
* loses and reorders (mmt-02 Section 2, a datagram leg). A multicast
|
|
3985
|
+
* symbol does unless its provider declared an ordered relay. An
|
|
3986
|
+
* "mfu-datagram" object always does (4.3.1): MulticastSymbolDelivery is
|
|
3987
|
+
* the multicast provider's statement and is never read for the leg. A MoQ
|
|
3988
|
+
* stream object never does, a stream copy of the leg included.
|
|
3989
|
+
*/
|
|
3990
|
+
#lossyDatagramPath(source) {
|
|
3991
|
+
return source === "moq-datagram" || source === "multicast" && this.#multicastSymbolDelivery === "datagram";
|
|
3992
|
+
}
|
|
3746
3993
|
/**
|
|
3747
3994
|
* The release gate's wait, from a frame's arrival, for the SS_IDs strictly
|
|
3748
3995
|
* between two released frames' SS_IDs once only a late source can still
|
|
@@ -3750,10 +3997,11 @@ var FECManager = class _FECManager {
|
|
|
3750
3997
|
* arrived nor held) lies in a repair-less span longer than K, which no
|
|
3751
3998
|
* repair can state a block of (#openIsoSpan), or in a stated block its
|
|
3752
3999
|
* own repair group cannot complete every SS_ID of which it misses lies
|
|
3753
|
-
* between them (so the gap's decision covers all it lost), and a
|
|
3754
|
-
*
|
|
3755
|
-
*
|
|
3756
|
-
*
|
|
4000
|
+
* between them (so the gap's decision covers all it lost), and a source of
|
|
4001
|
+
* a lossy leg (multicast, or an "mfu-datagram" leg's datagram) at or past
|
|
4002
|
+
* `toSsId` arrived, so each is lost or reordered behind it (a MoQ source
|
|
4003
|
+
* shows nothing: MoQ streams overtake one another). The span or block
|
|
4004
|
+
* itself keeps its own wait.
|
|
3757
4005
|
*
|
|
3758
4006
|
* The wait is the late-symbol allowance, unless `rapMayHide`: the gap may
|
|
3759
4007
|
* hold a RAP packet an installed keyframe overlay can still rebuild (its
|
|
@@ -3764,14 +4012,56 @@ var FECManager = class _FECManager {
|
|
|
3764
4012
|
* for an overlay that states no span, the span's whole wait (undefined).
|
|
3765
4013
|
* So does `rapNext` (the gap ends at the RAP that opens the next MPU) when
|
|
3766
4014
|
* the gap holds a stated block's loss.
|
|
4015
|
+
*
|
|
4016
|
+
* A run of SS_IDs no repair has delimited yet, one of which never arrived,
|
|
4017
|
+
* is one block of its own instead (draft-ramadan-moq-fec-multicast-00,
|
|
4018
|
+
* Receiver Repair Policy; on an "mfu-datagram" leg fec-core-00 9.3 and
|
|
4019
|
+
* mmt-02 5.3.3): the frame then waits for that block's FEC deadline,
|
|
4020
|
+
* whatever the flags: ts plus the whole multicast wait (fec-core-00 9.3),
|
|
4021
|
+
* ts the receipt of the lowest held source above the run that came as a
|
|
4022
|
+
* datagram of a lossy path (#lossyDatagramPath), up to the newest
|
|
4023
|
+
* (fec-multicast-00, Deadline Anchoring; under reordering at or after the
|
|
4024
|
+
* draft's first signal, never before). The wait returned counts from
|
|
4025
|
+
* `arrivedAtMs`, the frame's arrival; without it, it is the whole wait.
|
|
4026
|
+
* With no such source held (never arrived, retired, or evicted, or every
|
|
4027
|
+
* one from a MoQ stream or an ordered relay) the frame keeps the hold
|
|
4028
|
+
* ceiling: a stream arrival is no clock for a datagram deadline.
|
|
3767
4029
|
*/
|
|
3768
|
-
isoRepairlessWaitMs(packetId, catalogTrackName, fromSsId, toSsId, rapMayHide = false, rapNext = false) {
|
|
4030
|
+
isoRepairlessWaitMs(packetId, catalogTrackName, fromSsId, toSsId, rapMayHide = false, rapNext = false, arrivedAtMs) {
|
|
3769
4031
|
const config = this.#trackConfigs.get(packetId);
|
|
3770
4032
|
if (config === void 0 || !_FECManager.#hasCatalogTiming(config)) return void 0;
|
|
3771
|
-
const
|
|
3772
|
-
|
|
4033
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
4034
|
+
const locator = this.#isoLocators.get(streamKey);
|
|
4035
|
+
if (locator === void 0) return void 0;
|
|
4036
|
+
const run = locator.undelimitedBetween(fromSsId, toSsId);
|
|
4037
|
+
const readyAtMs = run === null || run.missing !== void 0 ? void 0 : this.#lossFreeRunReadyAtMs(config, locator, run.start, toSsId);
|
|
4038
|
+
if (readyAtMs !== void 0 && this.#receiptNow() < readyAtMs) {
|
|
4039
|
+
return Math.max(0, readyAtMs - (arrivedAtMs ?? this.#receiptNow()));
|
|
4040
|
+
}
|
|
3773
4041
|
const newestSource = locator.newestSource;
|
|
3774
4042
|
if (newestSource === void 0 || serial32Precedes(newestSource, toSsId)) return void 0;
|
|
4043
|
+
if (run?.missing !== void 0) {
|
|
4044
|
+
if (this.isoSpanResolution(packetId, catalogTrackName, fromSsId, run.start) === null) return void 0;
|
|
4045
|
+
const kept = this.#runAnchors.get(streamKey);
|
|
4046
|
+
const anchor = kept?.fromSsId === fromSsId && this.#receiptNow() - kept.tsMs <= 2 * (config.interleaveDepthMs + 2 * this.#blockLifetimeMs(config)) ? kept : void 0;
|
|
4047
|
+
let tsMs = anchor?.tsMs;
|
|
4048
|
+
for (let ssId = run.missing + 1 >>> 0; !serial32Precedes(newestSource, ssId); ssId = ssId + 1 >>> 0) {
|
|
4049
|
+
const atMs = this.#lossyReceiptMs(locator.heldSource(ssId));
|
|
4050
|
+
if (atMs === void 0) continue;
|
|
4051
|
+
if (tsMs === void 0 || atMs < tsMs) tsMs = atMs;
|
|
4052
|
+
break;
|
|
4053
|
+
}
|
|
4054
|
+
if (tsMs === void 0) return void 0;
|
|
4055
|
+
const waitMs2 = this.#multicastWaitMs(config);
|
|
4056
|
+
let counted = anchor?.counted === true;
|
|
4057
|
+
if (!counted && tsMs + waitMs2 <= this.#receiptNow()) {
|
|
4058
|
+
counted = true;
|
|
4059
|
+
this.onUndelimitedRunGap?.(packetId, catalogTrackName);
|
|
4060
|
+
}
|
|
4061
|
+
this.#runAnchors.set(streamKey, { fromSsId, tsMs, counted });
|
|
4062
|
+
return arrivedAtMs === void 0 ? waitMs2 : Math.max(0, tsMs + waitMs2 - arrivedAtMs);
|
|
4063
|
+
}
|
|
4064
|
+
if (!locator.coversBetween(fromSsId, run?.start ?? toSsId)) return void 0;
|
|
3775
4065
|
let repairless = false;
|
|
3776
4066
|
let stated = false;
|
|
3777
4067
|
for (const block of locator.blocksBetween(fromSsId, toSsId)) {
|
|
@@ -3852,11 +4142,31 @@ var FECManager = class _FECManager {
|
|
|
3852
4142
|
* it does not. A stream with no classifier yet has shown nothing against it,
|
|
3853
4143
|
* and neither has a stream without catalog timing until it releases two
|
|
3854
4144
|
* RAPs inside one MPU.
|
|
4145
|
+
*
|
|
4146
|
+
* With catalog timing and a `gap` inside one MPU, between the authored
|
|
4147
|
+
* timing of the frames on either side, it also takes the catalog keyframe
|
|
4148
|
+
* interval to rule a keyframe out of the gap
|
|
4149
|
+
* (`BlockClassifier.keyframeFreeBetween`, fec-multicast-00 Block
|
|
4150
|
+
* Classification item 3), and no source held between the frames' SS_IDs
|
|
4151
|
+
* may carry the RAP flag or another MPU's number (item 1 read on the held
|
|
4152
|
+
* packets: a RAP the loss cut in two is never released, so the frames
|
|
4153
|
+
* alone cannot show it); anything unknown counts as a keyframe.
|
|
3855
4154
|
*/
|
|
3856
|
-
mpuBoundsRapsFor(packetId, catalogTrackName) {
|
|
4155
|
+
mpuBoundsRapsFor(packetId, catalogTrackName, gap) {
|
|
3857
4156
|
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
3858
4157
|
if (!this.#hasCatalogTimingForPacket(packetId)) return this.#noSpanRaps.get(streamKey)?.inside !== true;
|
|
3859
|
-
|
|
4158
|
+
const classifier = this.#classifiers.get(streamKey);
|
|
4159
|
+
if (gap === void 0) return classifier?.mpuBoundsRaps ?? true;
|
|
4160
|
+
const { mpu, from, to, fromSsId, toSsId } = gap;
|
|
4161
|
+
if (fromSsId !== void 0 && toSsId !== void 0) {
|
|
4162
|
+
const run = this.#isoLocators.get(streamKey)?.undelimitedBetween(
|
|
4163
|
+
fromSsId,
|
|
4164
|
+
toSsId,
|
|
4165
|
+
({ evidence }) => evidence.rap || evidence.mpu !== void 0 && evidence.mpu !== mpu
|
|
4166
|
+
);
|
|
4167
|
+
if (run?.flagged) return false;
|
|
4168
|
+
}
|
|
4169
|
+
return classifier !== void 0 && from !== void 0 && to !== void 0 && from.mediaTimescale === to.mediaTimescale && classifier.keyframeFreeBetween(mpu, from.decodeTime, to.decodeTime, from.mediaTimescale);
|
|
3860
4170
|
}
|
|
3861
4171
|
/** A block's class now, or frozen at its resolution. */
|
|
3862
4172
|
blockClassFor(sbn, packetId, catalogTrackName) {
|
|
@@ -3879,9 +4189,11 @@ var FECManager = class _FECManager {
|
|
|
3879
4189
|
}
|
|
3880
4190
|
/**
|
|
3881
4191
|
* Record a RAP frame released in order, for the classifier's RAP-spacing
|
|
3882
|
-
* invariant (consecutive MPUs exactly one keyframe interval apart)
|
|
4192
|
+
* invariant (consecutive MPUs exactly one keyframe interval apart) and,
|
|
4193
|
+
* with its decode time, as the MPU start gap decisions measure the catalog
|
|
4194
|
+
* keyframe interval from (mpuBoundsRapsFor).
|
|
3883
4195
|
*/
|
|
3884
|
-
noteReleasedRap(packetId, catalogTrackName, mpu, presentationTime, mediaTimescale) {
|
|
4196
|
+
noteReleasedRap(packetId, catalogTrackName, mpu, presentationTime, mediaTimescale, decodeTime) {
|
|
3885
4197
|
if (!this.#trackConfigs.has(packetId)) return;
|
|
3886
4198
|
if (!this.#hasCatalogTimingForPacket(packetId)) {
|
|
3887
4199
|
const streamKey = this.#streamKey(packetId, catalogTrackName);
|
|
@@ -3896,7 +4208,8 @@ var FECManager = class _FECManager {
|
|
|
3896
4208
|
this.#classifierFor(packetId, catalogTrackName).noteReleasedRap(
|
|
3897
4209
|
mpu,
|
|
3898
4210
|
presentationTime,
|
|
3899
|
-
mediaTimescale
|
|
4211
|
+
mediaTimescale,
|
|
4212
|
+
decodeTime
|
|
3900
4213
|
)
|
|
3901
4214
|
);
|
|
3902
4215
|
}
|
|
@@ -4599,9 +4912,11 @@ var FECManager = class _FECManager {
|
|
|
4599
4912
|
* its sources in send order, so one that moves the stream's newest source
|
|
4600
4913
|
* position past a block leaves the sources that block still misses
|
|
4601
4914
|
* reordered behind it at best: it shortens the wait of every block it
|
|
4602
|
-
* passed that only a late source can complete. MoQ is left out:
|
|
4603
|
-
* can overtake one another, so a MoQ source shows nothing
|
|
4604
|
-
* sent before it.
|
|
4915
|
+
* passed that only a late source can complete. Reliable MoQ is left out:
|
|
4916
|
+
* its streams can overtake one another, so a MoQ source shows nothing
|
|
4917
|
+
* about the sources sent before it. An "mfu-datagram" leg is in: its
|
|
4918
|
+
* datagrams leave the publisher in send order and reorder only within the
|
|
4919
|
+
* path's tolerance, as multicast does.
|
|
4605
4920
|
*/
|
|
4606
4921
|
#noteMulticastSource(locator, ssId, packetId, catalogTrackName) {
|
|
4607
4922
|
const previous = locator.newestSource;
|
|
@@ -5068,7 +5383,7 @@ var FECManager = class _FECManager {
|
|
|
5068
5383
|
blockDeliveryProvenance(sbn, packetId, catalogTrackName) {
|
|
5069
5384
|
const counts = this.blockPathCount(sbn, packetId, catalogTrackName);
|
|
5070
5385
|
if (!counts) return "unknown";
|
|
5071
|
-
if (counts.moqSymbols > 0) return "mixed";
|
|
5386
|
+
if (counts.moqSymbols > 0 || counts.datagramSymbols > 0) return "mixed";
|
|
5072
5387
|
if (counts.multicastSymbols > 0) return "multicast";
|
|
5073
5388
|
return "unknown";
|
|
5074
5389
|
}
|
|
@@ -5095,7 +5410,7 @@ var FECManager = class _FECManager {
|
|
|
5095
5410
|
this.#activeBlockDeadlinesMs.clear();
|
|
5096
5411
|
this.#blockWaitDeadlinesMs.clear();
|
|
5097
5412
|
this.#repairHoldUntilMs.clear();
|
|
5098
|
-
this.#deliveryGaps.reset();
|
|
5413
|
+
for (const estimator of Object.values(this.#deliveryGaps)) estimator.reset();
|
|
5099
5414
|
this.#pendingWorkerCleanups.clear();
|
|
5100
5415
|
this.#pendingWorkerCleanupClients.clear();
|
|
5101
5416
|
for (const bound of this.#pendingWorkerCleanupBounds.values()) clearTimeout(bound.handle);
|
|
@@ -5146,6 +5461,7 @@ var FECManager = class _FECManager {
|
|
|
5146
5461
|
this.#highestSbn.clear();
|
|
5147
5462
|
this.#sourceFrontiers.clear();
|
|
5148
5463
|
this.#isoLocators.clear();
|
|
5464
|
+
this.#runAnchors.clear();
|
|
5149
5465
|
this.#sourceAnchors.clear();
|
|
5150
5466
|
this.#trackConfigs.clear();
|
|
5151
5467
|
this.#fecDecoders.clear();
|