@blockcast/mmt-container 2.2.0-main.a88c3a0aa4f3 → 2.2.0-main.aee8d33d2cc8
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/README.md +34 -19
- package/dist/block-policy.d.ts +55 -13
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +104 -32
- package/dist/block-policy.js.map +2 -2
- package/dist/browser-runtime.js +2094 -385
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.js.map +2 -2
- package/dist/catalog-fec-params.d.ts +18 -2
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +29 -1
- package/dist/catalog-fec-params.js.map +2 -2
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/cmaf-block-assembler.js +92 -1
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/cmcd-producer.d.ts +60 -47
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +138 -109
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/codec-utils.d.ts.map +1 -1
- package/dist/codec-utils.js +92 -1
- package/dist/codec-utils.js.map +2 -2
- package/dist/delivery-catalog.js +26 -16
- package/dist/delivery-catalog.js.map +2 -2
- package/dist/delta-fallback-config.js +5 -1
- package/dist/delta-fallback-config.js.map +3 -3
- package/dist/fec-manager.d.ts +114 -15
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +639 -95
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-state.js +5 -1
- package/dist/fec-state.js.map +2 -2
- package/dist/fec-worker-setup.d.ts +1 -1
- package/dist/fec-worker-setup.js +1 -1
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.js.map +2 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +48 -13
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +97 -25
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/iso-bmff-timing.d.ts +10 -1
- package/dist/iso-bmff-timing.d.ts.map +1 -1
- package/dist/iso-bmff-timing.js +36 -2
- package/dist/iso-bmff-timing.js.map +2 -2
- package/dist/media-router.js.map +1 -1
- package/dist/mfu-reassembler.js +12 -19
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts +106 -12
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +324 -46
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +466 -66
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +323 -46
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +41 -3
- package/dist/mmtp-fec-session.d.ts.map +1 -1
- package/dist/mmtp-fec-session.js +118 -13
- package/dist/mmtp-fec-session.js.map +3 -3
- package/dist/mmtp-router.d.ts +36 -8
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +716 -100
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-auth-catalog.js.map +2 -2
- package/dist/multicast-input.js.map +2 -2
- package/dist/multicast-manager.d.ts +28 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1451 -215
- package/dist/multicast-manager.js.map +3 -3
- package/dist/multicast-transport.js +28 -18
- package/dist/multicast-transport.js.map +2 -2
- package/dist/multicast-unwrap.js +12 -19
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +1 -0
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +463 -64
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.d.ts +38 -8
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +286 -27
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layer-subscriptions.d.ts +82 -0
- package/dist/repair-layer-subscriptions.d.ts.map +1 -0
- package/dist/repair-layer-subscriptions.js +192 -0
- package/dist/repair-layer-subscriptions.js.map +7 -0
- package/dist/signaling.js.map +2 -2
- package/dist/timestamp-codec.js +12 -19
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/track-session.d.ts +1 -1
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +1 -0
- package/dist/track-session.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +323 -46
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +8 -5
- package/schemas/catalog.schema.json +4 -0
- package/src/block-policy.ts +216 -52
- package/src/catalog-fec-params.ts +37 -1
- package/src/cmcd-producer.ts +189 -179
- package/src/codec-utils.ts +121 -1
- package/src/fec-manager.ts +619 -37
- package/src/fec-worker-setup.ts +2 -2
- package/src/index.ts +22 -2
- package/src/iso-block-locator.ts +133 -31
- package/src/iso-bmff-timing.ts +40 -1
- package/src/mmtp-container-parser.ts +353 -32
- package/src/mmtp-fec-session.ts +115 -15
- package/src/mmtp-router.ts +618 -44
- package/src/multicast-manager.ts +139 -16
- package/src/no-modules.ts +3 -0
- package/src/repair-fetch.ts +366 -50
- package/src/repair-layer-subscriptions.ts +261 -0
- package/src/track-session.ts +4 -1
package/src/fec-manager.ts
CHANGED
|
@@ -22,10 +22,12 @@ import {
|
|
|
22
22
|
isoBlockContains,
|
|
23
23
|
isoBlocksBehindLowerBound,
|
|
24
24
|
parseFecBlockProfile,
|
|
25
|
+
serial32Add,
|
|
25
26
|
serial32Distance,
|
|
26
27
|
serial32Precedes,
|
|
27
28
|
ssbg1FitsSymbol,
|
|
28
29
|
type FecBlockProfile,
|
|
30
|
+
type FecInstanceGeometry,
|
|
29
31
|
admitMmtpRepairObject,
|
|
30
32
|
parseMoqRepairFrameWithHeader,
|
|
31
33
|
type MMTPHeader,
|
|
@@ -136,6 +138,12 @@ export interface FecStats {
|
|
|
136
138
|
workers: Array<FecTrackStats & { packetId: number }>
|
|
137
139
|
/** Main-thread repair symbols rejected before dispatch because their size did not match T. */
|
|
138
140
|
repairSymbolSizeMismatches: number
|
|
141
|
+
/**
|
|
142
|
+
* Repair packets discarded because they arrived on a repair track the
|
|
143
|
+
* catalog does not list for their instance (fec-01 6.3.9): they delimit no
|
|
144
|
+
* block and anchor nothing.
|
|
145
|
+
*/
|
|
146
|
+
unlistedRepairTrackRefusals: number
|
|
139
147
|
/**
|
|
140
148
|
* Repair objects discarded on admission (draft-ramadan-moq-fec-core-00 7.5,
|
|
141
149
|
* draft-ramadan-moq-mmt-02 7.3), per FEC instance and reason. The instance
|
|
@@ -169,6 +177,17 @@ export interface FecPacketStats {
|
|
|
169
177
|
|
|
170
178
|
export type FecSymbolSource = 'multicast' | 'moq'
|
|
171
179
|
|
|
180
|
+
/**
|
|
181
|
+
* What feedRebuiltSourceSymbol did with a rebuilt source: whether its block
|
|
182
|
+
* took it, and the block the synchronous decoder recovered with it, if any.
|
|
183
|
+
*/
|
|
184
|
+
export interface RebuiltSourceFeed {
|
|
185
|
+
readonly taken: boolean
|
|
186
|
+
readonly recovered: Uint8Array | null
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const NOT_TAKEN: RebuiltSourceFeed = Object.freeze({ taken: false, recovered: null })
|
|
190
|
+
|
|
172
191
|
/**
|
|
173
192
|
* One iso-ssbg1-v1 first-arrival source symbol MmtpRouter holds until a repair
|
|
174
193
|
* symbol states its block: the exact protected packet (no SS_ID, unpadded),
|
|
@@ -201,6 +220,25 @@ export interface UndelimitedIsoLoss {
|
|
|
201
220
|
readonly previousBlockStart?: number
|
|
202
221
|
}
|
|
203
222
|
|
|
223
|
+
/**
|
|
224
|
+
* A pending hole the stream ran more than the locator's horizon past before
|
|
225
|
+
* its range repair ended (BLO-52085): no repair can state its blocks any
|
|
226
|
+
* more, and the release gate no longer waits for it.
|
|
227
|
+
*/
|
|
228
|
+
export type ExpiredIsoHole = Pick<UndelimitedIsoLoss, 'packetId' | 'catalogTrackName' | 'holeStart' | 'holeLength'>
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* What a failed iso-ssbg1-v1 repair-less span was: the `length` SS_IDs from
|
|
232
|
+
* its start, between two stated blocks, of which `sources` arrived. No repair
|
|
233
|
+
* stated the blocks inside it, so the receiver cannot tell its complete
|
|
234
|
+
* blocks from the ones that lost a source: the span failed, not the block
|
|
235
|
+
* that starts it.
|
|
236
|
+
*/
|
|
237
|
+
export interface IsoSpanFailure {
|
|
238
|
+
readonly length: number
|
|
239
|
+
readonly sources: number
|
|
240
|
+
}
|
|
241
|
+
|
|
204
242
|
/**
|
|
205
243
|
* How the multicast leg hands its symbols to this manager.
|
|
206
244
|
*
|
|
@@ -510,10 +548,21 @@ export class FECManager {
|
|
|
510
548
|
// 'pending' forever, which would park every later frame of its stream in
|
|
511
549
|
// the in-order release gate. Each entry owns its handle; the callback
|
|
512
550
|
// checks it still owns the key, so a settled or reset key is never touched.
|
|
513
|
-
|
|
551
|
+
/**
|
|
552
|
+
* Per owed Worker cleanup: the bound on its acknowledgement, when its block
|
|
553
|
+
* was due, and when its cleanup was asked for (see `onCleanupComplete`).
|
|
554
|
+
*/
|
|
555
|
+
#pendingWorkerCleanupBounds = new Map<
|
|
556
|
+
string,
|
|
557
|
+
{ handle: ReturnType<typeof setTimeout>; dueAtMs: number; askedAtMs: number }
|
|
558
|
+
>()
|
|
514
559
|
// Source symbol count per track-scoped block — marks complete when K symbols arrive.
|
|
515
560
|
#blockSourceCounts = new Map<string, number>()
|
|
516
561
|
#blockSourceEsis = new Map<string, Set<number>>()
|
|
562
|
+
// Source ESIs per block that another FEC instance rebuilt and fed in
|
|
563
|
+
// (feedRebuiltSourceSymbol). Kept apart from #blockSourceEsis: they are
|
|
564
|
+
// not network arrivals and never make a block clean.
|
|
565
|
+
#blockRebuiltEsis = new Map<string, Set<number>>()
|
|
517
566
|
// Authored SSB_length per block (ISO/IEC 23008-1 §C.5.3), learned from the
|
|
518
567
|
// first repair symbol. The FFmpeg moq_mmt publisher closes a block every D
|
|
519
568
|
// media units, usually before it holds K symbols; under iso-ssbg1-v1
|
|
@@ -522,10 +571,14 @@ export class FECManager {
|
|
|
522
571
|
// SSB_length source arrivals and recoverable from SSB_length received
|
|
523
572
|
// symbols; waiting for K fails every one of them.
|
|
524
573
|
#blockAuthoredLengths = new Map<string, number>()
|
|
574
|
+
// Keys whose authored length is a repair-less span's (#openIsoSpan), until
|
|
575
|
+
// a repair states the block there or the span resolves.
|
|
576
|
+
#isoSpanKeys = new Set<string>()
|
|
525
577
|
#ssbLengthConflictCount = 0
|
|
526
578
|
#blockRepairRsIds = new Map<string, Set<number>>()
|
|
527
579
|
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
528
|
-
// symbols its repair group carries
|
|
580
|
+
// symbols its repair group carries; 0 for a repair-less span no repair can
|
|
581
|
+
// state (#openIsoSpan). Same lifecycle as #blockRepairRsIds.
|
|
529
582
|
#blockRsbLengths = new Map<string, number>()
|
|
530
583
|
/** fec-01 6.3.9 anchor state per stream key, one entry per held layer. */
|
|
531
584
|
#heldLayerStates = new Map<string, HeldLayerAdmission>()
|
|
@@ -644,6 +697,10 @@ export class FECManager {
|
|
|
644
697
|
// ── Keyframe-protected repair policy (block-policy.ts) ──
|
|
645
698
|
// One classifier per physical stream, built from that stream's geometry.
|
|
646
699
|
#classifiers = new Map<string, BlockClassifier>()
|
|
700
|
+
// A stream without catalog timing has no classifier, so the last RAP it
|
|
701
|
+
// released stands in for one: "an MPU boundary bounds its RAPs" holds until
|
|
702
|
+
// a second RAP is released inside one MPU (BLO-52085).
|
|
703
|
+
#noSpanRaps = new Map<string, { mpu: number; presentationTime: bigint; inside: boolean }>()
|
|
647
704
|
// Geometry a stream-scoped configuration gave one stream (streamKey). ABR
|
|
648
705
|
// rungs can share a packetId with a different framerate or GOP, so the
|
|
649
706
|
// packet-level geometry is only the geometry of a packet whose streams
|
|
@@ -714,6 +771,7 @@ export class FECManager {
|
|
|
714
771
|
#workerErrorCounts = new Map<string, number>()
|
|
715
772
|
#decoderUnavailableEvents = 0
|
|
716
773
|
#repairSymbolSizeMismatchCount = 0
|
|
774
|
+
#unlistedRepairTrackRefusals = 0
|
|
717
775
|
|
|
718
776
|
// Event callbacks — block lifecycle notifications for MmtpRouter wiring.
|
|
719
777
|
// NOTE: For sync WASM path, recovery routing is handled by MmtpRouter from
|
|
@@ -725,13 +783,17 @@ export class FECManager {
|
|
|
725
783
|
onBlockComplete:
|
|
726
784
|
| ((sbn: number, packetId: number, catalogTrackName?: string) => void)
|
|
727
785
|
| null = null
|
|
728
|
-
/**
|
|
786
|
+
/**
|
|
787
|
+
* A block reached its fail bound. `blockClass` is its class at failure.
|
|
788
|
+
* `span` is set when what failed is a repair-less span starting at `sbn`.
|
|
789
|
+
*/
|
|
729
790
|
onBlockFailed:
|
|
730
791
|
| ((
|
|
731
792
|
sbn: number,
|
|
732
793
|
packetId: number,
|
|
733
794
|
catalogTrackName: string | undefined,
|
|
734
795
|
blockClass: BlockClass,
|
|
796
|
+
span?: IsoSpanFailure,
|
|
735
797
|
) => void)
|
|
736
798
|
| null = null
|
|
737
799
|
/**
|
|
@@ -815,6 +877,8 @@ export class FECManager {
|
|
|
815
877
|
* for it, which it must be.
|
|
816
878
|
*/
|
|
817
879
|
#onUndelimitedLoss: ((loss: UndelimitedIsoLoss) => void) | null = null
|
|
880
|
+
/** Set with the loss handler: true takes an expired hole to close (`closeIsoHoles`). */
|
|
881
|
+
#onIsoHoleExpired: ((hole: ExpiredIsoHole) => boolean) | null = null
|
|
818
882
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
819
883
|
onBlockVanished:
|
|
820
884
|
| ((sbn: number, packetId: number, catalogTrackName: string | undefined) => void)
|
|
@@ -827,6 +891,21 @@ export class FECManager {
|
|
|
827
891
|
onSourceDiscontinuity:
|
|
828
892
|
| ((packetId: number, catalogTrackName: string | undefined) => void)
|
|
829
893
|
| null = null
|
|
894
|
+
/**
|
|
895
|
+
* The span and tolerance the catalog states for a keyframe overlay
|
|
896
|
+
* installed over a source track (draft-ramadan-moq-mmt-02 7.4.1: the
|
|
897
|
+
* overlay instance's own interleaveDepthMs and reorderToleranceMs), or
|
|
898
|
+
* undefined while none is installed. A stated block only a late source
|
|
899
|
+
* can complete, and a frame whose gap may hide a RAP behind a span only a
|
|
900
|
+
* late source can fill, also wait for that overlay's repair
|
|
901
|
+
* (#overlayLateWaitMs).
|
|
902
|
+
*/
|
|
903
|
+
keyframeOverlayTiming:
|
|
904
|
+
| ((
|
|
905
|
+
packetId: number,
|
|
906
|
+
catalogTrackName: string | undefined,
|
|
907
|
+
) => Pick<FecInstanceGeometry, 'interleaveDepthMs' | 'reorderToleranceMs'> | undefined)
|
|
908
|
+
| null = null
|
|
830
909
|
|
|
831
910
|
// Worker-path callbacks — async recovery and stats from FecWorkerClient.
|
|
832
911
|
/**
|
|
@@ -1469,7 +1548,12 @@ export class FECManager {
|
|
|
1469
1548
|
timer.handle = null
|
|
1470
1549
|
this.#requestRepair(sbn, packetId, catalogTrackName)
|
|
1471
1550
|
}
|
|
1472
|
-
timer.handle = setTimeout(
|
|
1551
|
+
timer.handle = setTimeout(
|
|
1552
|
+
onFire,
|
|
1553
|
+
this.#receiptAtMs === undefined
|
|
1554
|
+
? Math.max(0, deadlineMs - performance.now())
|
|
1555
|
+
: this.#receiptTimerDelayMs(deadlineMs, 0),
|
|
1556
|
+
)
|
|
1473
1557
|
this.#repairDeadlines.set(key, timer)
|
|
1474
1558
|
}
|
|
1475
1559
|
|
|
@@ -1663,6 +1747,12 @@ export class FECManager {
|
|
|
1663
1747
|
* Vanished blocks are not enumerated here: their starts are unknown until a
|
|
1664
1748
|
* repair states them. The SS_IDs between two stated blocks become one
|
|
1665
1749
|
* repair-less span when the later block's repair arrives (placeIsoRepair).
|
|
1750
|
+
*
|
|
1751
|
+
* A `held` source arrived before its block was known and is fed only now
|
|
1752
|
+
* that a repair, a span or a closed hole placed it: how far its block start
|
|
1753
|
+
* then lies behind the frontier measures how long the receiver held it, not
|
|
1754
|
+
* where the stream was, so only its SS_ID and packet_sequence_number judge
|
|
1755
|
+
* it (BLO-52085).
|
|
1666
1756
|
*/
|
|
1667
1757
|
#noteSbnSeen(
|
|
1668
1758
|
sbn: number,
|
|
@@ -1671,6 +1761,7 @@ export class FECManager {
|
|
|
1671
1761
|
symbol: 'source' | 'repair',
|
|
1672
1762
|
packetSequenceNumber?: number,
|
|
1673
1763
|
ssId = sbn,
|
|
1764
|
+
held = false,
|
|
1674
1765
|
): void {
|
|
1675
1766
|
const streamKey = this.#streamKey(packetId, catalogTrackName)
|
|
1676
1767
|
// Arrival at FEC, not receipt (withReceiptTime): this bounds how far SS_ID
|
|
@@ -1706,6 +1797,7 @@ export class FECManager {
|
|
|
1706
1797
|
// The classifier compares authored order with SBN order only within
|
|
1707
1798
|
// one continuous SBN sequence.
|
|
1708
1799
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity()
|
|
1800
|
+
this.#noSpanRaps.delete(streamKey)
|
|
1709
1801
|
this.#highestSbn.set(streamKey, { sbn, atMs: now })
|
|
1710
1802
|
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now })
|
|
1711
1803
|
if (psn === undefined) this.#sourceAnchors.delete(streamKey)
|
|
@@ -1726,7 +1818,7 @@ export class FECManager {
|
|
|
1726
1818
|
}
|
|
1727
1819
|
if (!this.#blockPrecedes(previous.sbn, sbn)) {
|
|
1728
1820
|
if (symbol === 'source' && window !== null && this.#blockPrecedes(sbn, previous.sbn) && (
|
|
1729
|
-
this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId) ||
|
|
1821
|
+
(!held && this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId)) ||
|
|
1730
1822
|
(psn !== undefined && anchor !== undefined && serial32Precedes(ssId, anchor.ssId) &&
|
|
1731
1823
|
psn !== anchor.psn && !sentInOrder({ ssId, psn }, anchor))
|
|
1732
1824
|
)) {
|
|
@@ -2080,21 +2172,28 @@ export class FECManager {
|
|
|
2080
2172
|
this.#blockWaitDeadlinesMs.delete(key)
|
|
2081
2173
|
this.#repairHoldUntilMs.delete(key)
|
|
2082
2174
|
this.#traceLifecycle('timeout-queued', sbn, packetId, catalogTrackName)
|
|
2083
|
-
this.#finalizeExpiredBlock(sbn, packetId, catalogTrackName)
|
|
2175
|
+
this.#finalizeExpiredBlock(sbn, packetId, catalogTrackName, currentDeadlineMs ?? firedAtMs)
|
|
2084
2176
|
}
|
|
2085
|
-
timer.handle = setTimeout(
|
|
2177
|
+
timer.handle = setTimeout(
|
|
2178
|
+
onFire,
|
|
2179
|
+
this.#receiptAtMs === undefined
|
|
2180
|
+
? Math.max(1, Math.ceil(deadlineMs - nowMs))
|
|
2181
|
+
: this.#receiptTimerDelayMs(deadlineMs, 1),
|
|
2182
|
+
)
|
|
2086
2183
|
this.#activeBlocks.set(key, timer)
|
|
2087
2184
|
this.#indexBlockKey(key, sbn, packetId)
|
|
2088
2185
|
}
|
|
2089
2186
|
|
|
2090
2187
|
/**
|
|
2091
2188
|
* Hand a block whose delivery is over to its decoder for finalization: the
|
|
2092
|
-
* datagram deadline fired, or the ordered relay moved past it.
|
|
2189
|
+
* datagram deadline fired, or the ordered relay moved past it. `dueAtMs`
|
|
2190
|
+
* is when it was due: its deadline, or now.
|
|
2093
2191
|
*/
|
|
2094
2192
|
#finalizeExpiredBlock(
|
|
2095
2193
|
sbn: number,
|
|
2096
2194
|
packetId: number,
|
|
2097
2195
|
catalogTrackName: string | undefined,
|
|
2196
|
+
dueAtMs = performance.now(),
|
|
2098
2197
|
): void {
|
|
2099
2198
|
const key = this.#blockKey(sbn, packetId, catalogTrackName)
|
|
2100
2199
|
// A vanished block that never received a symbol holds no decoder state
|
|
@@ -2118,7 +2217,7 @@ export class FECManager {
|
|
|
2118
2217
|
if (workerClient) {
|
|
2119
2218
|
this.#pendingWorkerCleanups.add(key)
|
|
2120
2219
|
this.#pendingWorkerCleanupClients.set(key, workerClient)
|
|
2121
|
-
this.#boundOwedCleanup(key, packetId, workerClient)
|
|
2220
|
+
this.#boundOwedCleanup(key, packetId, workerClient, dueAtMs)
|
|
2122
2221
|
workerClient.cleanup(sbn)
|
|
2123
2222
|
} else {
|
|
2124
2223
|
const decoder = this.#decoderForPacket(packetId, catalogTrackName)?.client
|
|
@@ -2289,6 +2388,9 @@ export class FECManager {
|
|
|
2289
2388
|
// sibling's change, but the first stream-scoped geometry on a packet
|
|
2290
2389
|
// does change the siblings that have none (stream-geometry-absent).
|
|
2291
2390
|
this.#bumpEpoch(packetId)
|
|
2391
|
+
for (const key of [...this.#noSpanRaps.keys()]) {
|
|
2392
|
+
if (this.#belongsToPacket(key, packetId)) this.#noSpanRaps.delete(key)
|
|
2393
|
+
}
|
|
2292
2394
|
for (const [key, classifier] of [...this.#classifiers]) {
|
|
2293
2395
|
if (!this.#belongsToPacket(key, packetId)) continue
|
|
2294
2396
|
const stream = this.#parseStreamKey(key)
|
|
@@ -2413,6 +2515,7 @@ export class FECManager {
|
|
|
2413
2515
|
packetId,
|
|
2414
2516
|
})),
|
|
2415
2517
|
repairSymbolSizeMismatches: this.#repairSymbolSizeMismatchCount,
|
|
2518
|
+
unlistedRepairTrackRefusals: this.#unlistedRepairTrackRefusals,
|
|
2416
2519
|
repairObjectRejects: [...this.#repairObjectRejects.values()].map((r) => ({ ...r })),
|
|
2417
2520
|
workerErrors: Object.fromEntries(this.#workerErrorCounts),
|
|
2418
2521
|
}
|
|
@@ -2532,7 +2635,9 @@ export class FECManager {
|
|
|
2532
2635
|
}
|
|
2533
2636
|
resetMap(this.#blockSourceCounts)
|
|
2534
2637
|
resetMap(this.#blockSourceEsis)
|
|
2638
|
+
resetMap(this.#blockRebuiltEsis)
|
|
2535
2639
|
resetMap(this.#blockAuthoredLengths)
|
|
2640
|
+
resetSet(this.#isoSpanKeys)
|
|
2536
2641
|
resetMap(this.#blockRepairRsIds)
|
|
2537
2642
|
resetMap(this.#blockRsbLengths)
|
|
2538
2643
|
resetMap(this.#heldLayerStates)
|
|
@@ -2565,6 +2670,7 @@ export class FECManager {
|
|
|
2565
2670
|
resetMap(this.#isoLocators)
|
|
2566
2671
|
resetMap(this.#sourceAnchors)
|
|
2567
2672
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName))
|
|
2673
|
+
this.#noSpanRaps.delete(this.#streamKey(packetId, catalogTrackName))
|
|
2568
2674
|
this.#bumpEpoch(packetId)
|
|
2569
2675
|
for (const [sbn, keys] of this.#blockKeysBySbn) {
|
|
2570
2676
|
for (const key of keys.keys()) {
|
|
@@ -2663,7 +2769,9 @@ export class FECManager {
|
|
|
2663
2769
|
dropMap(this.#pendingWorkerCleanupClients)
|
|
2664
2770
|
dropMap(this.#blockSourceCounts)
|
|
2665
2771
|
dropMap(this.#blockSourceEsis)
|
|
2772
|
+
dropMap(this.#blockRebuiltEsis)
|
|
2666
2773
|
dropMap(this.#blockAuthoredLengths)
|
|
2774
|
+
dropSet(this.#isoSpanKeys)
|
|
2667
2775
|
dropMap(this.#blockRepairRsIds)
|
|
2668
2776
|
dropMap(this.#blockRsbLengths)
|
|
2669
2777
|
dropMap(this.#blockPathCounts)
|
|
@@ -2679,6 +2787,7 @@ export class FECManager {
|
|
|
2679
2787
|
dropMap(this.#isoLocators)
|
|
2680
2788
|
dropMap(this.#sourceAnchors)
|
|
2681
2789
|
dropMap(this.#classifiers)
|
|
2790
|
+
dropMap(this.#noSpanRaps)
|
|
2682
2791
|
dropMap(this.#streamGeometries)
|
|
2683
2792
|
dropSet(this.#pendingWorkerCleanups)
|
|
2684
2793
|
dropSet(this.#completedBlocks)
|
|
@@ -2881,6 +2990,10 @@ export class FECManager {
|
|
|
2881
2990
|
}
|
|
2882
2991
|
}
|
|
2883
2992
|
|
|
2993
|
+
if (isSourceSymbol && source === 'multicast') {
|
|
2994
|
+
this.#noteMulticastSource(this.#isoLocatorFor(packetId, catalogTrackName), (sbn + esi) >>> 0, packetId, catalogTrackName)
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2884
2997
|
return true
|
|
2885
2998
|
}
|
|
2886
2999
|
|
|
@@ -3006,8 +3119,10 @@ export class FECManager {
|
|
|
3006
3119
|
}
|
|
3007
3120
|
/**
|
|
3008
3121
|
* An open block's accepted sources, distinct repair RS_IDs, authored K'
|
|
3009
|
-
* (SSB_length) and RSB_length (each undefined until a repair stated it
|
|
3010
|
-
*
|
|
3122
|
+
* (SSB_length) and RSB_length (each undefined until a repair stated it; a
|
|
3123
|
+
* repair-less span states its length, and RSB_length 0 when it is longer
|
|
3124
|
+
* than K, since no repair can reach it). Undefined for a block that is not
|
|
3125
|
+
* open.
|
|
3011
3126
|
*/
|
|
3012
3127
|
blockSymbolCounts(
|
|
3013
3128
|
sbn: number,
|
|
@@ -3090,8 +3205,9 @@ export class FECManager {
|
|
|
3090
3205
|
return true
|
|
3091
3206
|
}
|
|
3092
3207
|
/**
|
|
3093
|
-
* Drop a block's repair hold: its FETCH ended without delivering
|
|
3094
|
-
*
|
|
3208
|
+
* Drop a block's repair hold: its FETCH ended without delivering, or brought
|
|
3209
|
+
* back only a repair that cannot complete it. The block falls back to its
|
|
3210
|
+
* multicast wait, which may already have passed.
|
|
3095
3211
|
*/
|
|
3096
3212
|
releaseRepairHold(sbn: number, packetId: number, catalogTrackName?: string): void {
|
|
3097
3213
|
const key = this.#blockKey(sbn, packetId, catalogTrackName)
|
|
@@ -3141,7 +3257,7 @@ export class FECManager {
|
|
|
3141
3257
|
}
|
|
3142
3258
|
const trackConfig = this.#trackConfigs.get(packetId)
|
|
3143
3259
|
if (trackConfig === undefined) return undefined
|
|
3144
|
-
return Math.max(1, trackConfig
|
|
3260
|
+
return Math.max(1, this.#repairGraceMs(trackConfig, this.#multicastWaitMs(trackConfig)))
|
|
3145
3261
|
}
|
|
3146
3262
|
|
|
3147
3263
|
/** True once configureTrack/setFecDecoder/setFecWorker configured this packetId. */
|
|
@@ -3253,6 +3369,8 @@ export class FECManager {
|
|
|
3253
3369
|
const locator = this.#growingIsoLocatorFor(packetId, catalogTrackName)
|
|
3254
3370
|
const evictedBefore = locator.heldEvicted
|
|
3255
3371
|
const held = locator.hold(ssId, source)
|
|
3372
|
+
this.#settleExpiredIsoHoles(locator, packetId, catalogTrackName)
|
|
3373
|
+
if (held && source.source === 'multicast') this.#noteMulticastSource(locator, ssId, packetId, catalogTrackName)
|
|
3256
3374
|
const evicted = locator.heldEvicted - evictedBefore
|
|
3257
3375
|
if (evicted > 0) {
|
|
3258
3376
|
const before = this.#isoHeldEvictedCount
|
|
@@ -3280,17 +3398,26 @@ export class FECManager {
|
|
|
3280
3398
|
ssStart: number,
|
|
3281
3399
|
ssbLength: number,
|
|
3282
3400
|
): IsoRepairPlacement<IsoHeldSource> {
|
|
3283
|
-
const
|
|
3401
|
+
const locator = this.#growingIsoLocatorFor(packetId, catalogTrackName)
|
|
3402
|
+
const placement = locator.placeRepair(ssStart, ssbLength)
|
|
3403
|
+
this.#settleExpiredIsoHoles(locator, packetId, catalogTrackName)
|
|
3284
3404
|
if (placement.status !== 'placed') {
|
|
3285
3405
|
this.#isoRepairRefusedCount++
|
|
3286
3406
|
if (this.#isoRepairRefusedCount <= 5 || this.#isoRepairRefusedCount % 100 === 0) {
|
|
3287
3407
|
console.warn(`[FECManager] packetId=${packetId} iso-ssbg1-v1 repair refused (${placement.status}): ${placement.reason}`)
|
|
3288
3408
|
}
|
|
3409
|
+
// The repair FETCH of a span's first group brought back a shorter block:
|
|
3410
|
+
// the span holds more than one, so that group cannot complete it, and
|
|
3411
|
+
// holding the span (and every frame behind it) for the FETCH buys
|
|
3412
|
+
// nothing. It falls back to its multicast wait.
|
|
3413
|
+
if (placement.ofSpan !== undefined) this.releaseRepairHold(placement.ofSpan.start, packetId, catalogTrackName)
|
|
3289
3414
|
return placement
|
|
3290
3415
|
}
|
|
3416
|
+
// A repair states the block at its SS_Start: a span the locator kept
|
|
3417
|
+
// there is now that one block (IsoBlockLocator.placeRepair).
|
|
3418
|
+
this.#isoSpanKeys.delete(this.#blockKey(placement.block.start, packetId, catalogTrackName))
|
|
3291
3419
|
if (placement.span !== undefined) this.#openIsoSpan(placement.span, packetId, catalogTrackName)
|
|
3292
3420
|
if (placement.hole !== undefined) {
|
|
3293
|
-
const locator = this.#isoLocatorFor(packetId, catalogTrackName)
|
|
3294
3421
|
const hole = placement.hole.block
|
|
3295
3422
|
const previous = locator.blockEndingAt(hole.start)
|
|
3296
3423
|
const loss: UndelimitedIsoLoss = {
|
|
@@ -3312,18 +3439,38 @@ export class FECManager {
|
|
|
3312
3439
|
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
3313
3440
|
* range repair scheduler; applies to every stream from its next gap. The
|
|
3314
3441
|
* handler and the deferral are one setting, so no hole is ever created with
|
|
3315
|
-
* nobody to close it.
|
|
3442
|
+
* nobody to close it. `onExpired` is told of each pending hole the stream
|
|
3443
|
+
* runs past the locator's horizon (BLO-52085): returning true, it closes
|
|
3444
|
+
* the hole (`closeIsoHoles`), so the span it leaves still fails and is
|
|
3445
|
+
* reported; otherwise the hole is discarded with its sources.
|
|
3316
3446
|
*/
|
|
3317
|
-
setUndelimitedLossHandler(
|
|
3447
|
+
setUndelimitedLossHandler(
|
|
3448
|
+
handler: ((loss: UndelimitedIsoLoss) => void) | null,
|
|
3449
|
+
onExpired: ((hole: ExpiredIsoHole) => boolean) | null = null,
|
|
3450
|
+
): void {
|
|
3318
3451
|
this.#onUndelimitedLoss = handler
|
|
3452
|
+
this.#onIsoHoleExpired = handler === null ? null : onExpired
|
|
3319
3453
|
this.#deferIsoGaps = handler !== null
|
|
3320
3454
|
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps
|
|
3321
3455
|
}
|
|
3322
3456
|
|
|
3457
|
+
/** Hand each hole the locator's horizon passed to its owner, or discard it (setUndelimitedLossHandler). */
|
|
3458
|
+
#settleExpiredIsoHoles(
|
|
3459
|
+
locator: IsoBlockLocator<IsoHeldSource>,
|
|
3460
|
+
packetId: number,
|
|
3461
|
+
catalogTrackName: string | undefined,
|
|
3462
|
+
): void {
|
|
3463
|
+
for (const hole of locator.takeExpiredHoles()) {
|
|
3464
|
+
const expired: ExpiredIsoHole = { packetId, catalogTrackName, holeStart: hole.start, holeLength: hole.length }
|
|
3465
|
+
if (this.#onIsoHoleExpired?.(expired) !== true) locator.closeHolesWithin(hole.start, hole.length)
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3323
3469
|
/**
|
|
3324
|
-
* The range repair for a hole ended: every hole
|
|
3325
|
-
*
|
|
3326
|
-
* with the held sources they placed, for the caller to feed
|
|
3470
|
+
* The range repair for a hole ended: every hole inside `[start, start +
|
|
3471
|
+
* length)`, pending or expired, becomes a repair-less span. Returns those
|
|
3472
|
+
* spans with the held sources they placed, for the caller to feed
|
|
3473
|
+
* (MmtpRouter).
|
|
3327
3474
|
*/
|
|
3328
3475
|
closeIsoHoles(
|
|
3329
3476
|
packetId: number,
|
|
@@ -3345,6 +3492,17 @@ export class FECManager {
|
|
|
3345
3492
|
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
3346
3493
|
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
3347
3494
|
* block.
|
|
3495
|
+
*
|
|
3496
|
+
* A span longer than K holds more than one block (SSB_length <= K), and the
|
|
3497
|
+
* locator states no block inside a span, only one exactly its range
|
|
3498
|
+
* (IsoBlockLocator.placeRepair): no repair, multicast or FETCHed, can ever
|
|
3499
|
+
* reach it. Its repair group is empty, so the repair scheduler FETCHes no
|
|
3500
|
+
* Group of it (group-cannot-complete). Every span still keeps its whole
|
|
3501
|
+
* wait (#lateSourceWaitMs): failing it early released the frames behind it
|
|
3502
|
+
* past a keyframe the overlay was still rebuilding (BLO-52085). The release
|
|
3503
|
+
* gate lets those frames go once only a late source can fill the gap
|
|
3504
|
+
* before them, as long after they arrived as the gap's decision allows
|
|
3505
|
+
* (isoRepairlessWaitMs).
|
|
3348
3506
|
*/
|
|
3349
3507
|
#openIsoSpan(
|
|
3350
3508
|
span: { readonly block: IsoBlockRange; readonly placed: readonly unknown[] },
|
|
@@ -3352,7 +3510,16 @@ export class FECManager {
|
|
|
3352
3510
|
catalogTrackName: string | undefined,
|
|
3353
3511
|
): void {
|
|
3354
3512
|
const key = this.#blockKey(span.block.start, packetId, catalogTrackName)
|
|
3355
|
-
|
|
3513
|
+
// A span's key is always new here. An authored length is set only here or
|
|
3514
|
+
// from a repair stating that block (#noteAuthoredLength), and the locator
|
|
3515
|
+
// opens a span only where no repair stated a block, so none can precede
|
|
3516
|
+
// it. Were one to, the guard would skip the RSB_length 0 that keeps the
|
|
3517
|
+
// repair scheduler from FETCHing a long span's first Group.
|
|
3518
|
+
if (!this.#blockAuthoredLengths.has(key)) {
|
|
3519
|
+
this.#blockAuthoredLengths.set(key, span.block.length)
|
|
3520
|
+
this.#isoSpanKeys.add(key)
|
|
3521
|
+
if (span.block.length > this.#isoLocatorFor(packetId, catalogTrackName).kMax) this.#blockRsbLengths.set(key, 0)
|
|
3522
|
+
}
|
|
3356
3523
|
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true)
|
|
3357
3524
|
}
|
|
3358
3525
|
|
|
@@ -3400,6 +3567,90 @@ export class FECManager {
|
|
|
3400
3567
|
return lost
|
|
3401
3568
|
}
|
|
3402
3569
|
|
|
3570
|
+
/**
|
|
3571
|
+
* The release gate's wait, from a frame's arrival, for the SS_IDs strictly
|
|
3572
|
+
* between two released frames' SS_IDs once only a late source can still
|
|
3573
|
+
* fill them, else undefined. That is when every one missing (neither
|
|
3574
|
+
* arrived nor held) lies in a repair-less span longer than K, which no
|
|
3575
|
+
* repair can state a block of (#openIsoSpan), or in a stated block its
|
|
3576
|
+
* own repair group cannot complete every SS_ID of which it misses lies
|
|
3577
|
+
* between them (so the gap's decision covers all it lost), and a multicast
|
|
3578
|
+
* source at or past `toSsId` arrived, so each is lost or reordered behind
|
|
3579
|
+
* it (a MoQ source shows nothing: MoQ streams overtake one another). The
|
|
3580
|
+
* span or block itself keeps its own wait.
|
|
3581
|
+
*
|
|
3582
|
+
* The wait is the late-symbol allowance, unless `rapMayHide`: the gap may
|
|
3583
|
+
* hold a RAP packet an installed keyframe overlay can still rebuild (its
|
|
3584
|
+
* decision stalls, or it ends at a RAP that may lie past a whole MPU).
|
|
3585
|
+
* Then the frame waits as a stated block its group cannot complete does
|
|
3586
|
+
* (#overlayLateWaitMs): the allowance alone with no overlay installed, the
|
|
3587
|
+
* overlay's span plus the larger of the allowance and its tolerance, or,
|
|
3588
|
+
* for an overlay that states no span, the span's whole wait (undefined).
|
|
3589
|
+
* So does `rapNext` (the gap ends at the RAP that opens the next MPU) when
|
|
3590
|
+
* the gap holds a stated block's loss.
|
|
3591
|
+
*/
|
|
3592
|
+
isoRepairlessWaitMs(
|
|
3593
|
+
packetId: number,
|
|
3594
|
+
catalogTrackName: string | undefined,
|
|
3595
|
+
fromSsId: number,
|
|
3596
|
+
toSsId: number,
|
|
3597
|
+
rapMayHide = false,
|
|
3598
|
+
rapNext = false,
|
|
3599
|
+
): number | undefined {
|
|
3600
|
+
const config = this.#trackConfigs.get(packetId)
|
|
3601
|
+
if (config === undefined || !FECManager.#hasCatalogTiming(config)) return undefined
|
|
3602
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))
|
|
3603
|
+
if (locator === undefined || !locator.coversBetween(fromSsId, toSsId)) return undefined
|
|
3604
|
+
const newestSource = locator.newestSource
|
|
3605
|
+
if (newestSource === undefined || serial32Precedes(newestSource, toSsId)) return undefined
|
|
3606
|
+
let repairless = false
|
|
3607
|
+
let stated = false
|
|
3608
|
+
for (const block of locator.blocksBetween(fromSsId, toSsId)) {
|
|
3609
|
+
const key = this.#blockKey(block.start, packetId, catalogTrackName)
|
|
3610
|
+
if (this.#completedBlocks.has(key)) continue
|
|
3611
|
+
if (block.span && block.length > locator.kMax) {
|
|
3612
|
+
repairless = true
|
|
3613
|
+
continue
|
|
3614
|
+
}
|
|
3615
|
+
const received = this.#blockSourceEsis.get(key)
|
|
3616
|
+
const rebuilt = this.#blockRebuiltEsis.get(key)
|
|
3617
|
+
let missesInGap = false
|
|
3618
|
+
let missesOutside = false
|
|
3619
|
+
// A rebuilt source is present outside the gap but missed inside it.
|
|
3620
|
+
// Outside, the question is what the block's decoder lacks beyond this
|
|
3621
|
+
// gap, and it holds a rebuilt source (#groupCannotComplete). Inside, it
|
|
3622
|
+
// is what the base path lost between the two frames. A base recovery
|
|
3623
|
+
// does not route a rebuilt packet again (MmtpRouter
|
|
3624
|
+
// #routeVerifiedFecSymbols), so only the overlay route delivers it, and
|
|
3625
|
+
// its frame may not have reached the gate yet (a head held for its FT=1,
|
|
3626
|
+
// BLO-53369). The two differ only when every SS_ID a block misses in the
|
|
3627
|
+
// gap was rebuilt: the later frame then waits for the gap's blocks to
|
|
3628
|
+
// resolve (undefined), which is conservative.
|
|
3629
|
+
for (let esi = 0; esi < block.length; esi++) {
|
|
3630
|
+
const ssId = serial32Add(block.start, esi)
|
|
3631
|
+
if (received?.has(esi) || locator.isHeld(ssId)) continue
|
|
3632
|
+
if (serial32Precedes(fromSsId, ssId) && serial32Precedes(ssId, toSsId)) missesInGap = true
|
|
3633
|
+
else if (!rebuilt?.has(esi)) missesOutside = true
|
|
3634
|
+
}
|
|
3635
|
+
if (!missesInGap) continue
|
|
3636
|
+
// A stated block its own group cannot complete (#lateSourceWaitMs) is
|
|
3637
|
+
// one too, when every SS_ID it misses lies in this gap: the gap's
|
|
3638
|
+
// decision then covers all it lost, so the overlay can rebuild none of
|
|
3639
|
+
// it unless `rapMayHide` or `rapNext`.
|
|
3640
|
+
if (missesOutside || block.span || !this.#groupCannotComplete(key)) return undefined
|
|
3641
|
+
repairless = stated = true
|
|
3642
|
+
}
|
|
3643
|
+
if (!repairless) return undefined
|
|
3644
|
+
// A gap into the next MPU (`rapNext`) may hold that MPU's FT=0, an overlay
|
|
3645
|
+
// member; rebuilt, it is one more source of a stated block, which its group
|
|
3646
|
+
// may then complete. Such a block keeps #741's overlay wait; a span longer
|
|
3647
|
+
// than K has no group to complete and keeps #742's allowance.
|
|
3648
|
+
const waitMs = rapMayHide || (stated && rapNext)
|
|
3649
|
+
? this.#overlayLateWaitMs(packetId, catalogTrackName, config)
|
|
3650
|
+
: this.#multicastWaitMs(config) - config.interleaveDepthMs
|
|
3651
|
+
return waitMs === undefined ? undefined : Math.max(0, waitMs)
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3403
3654
|
/**
|
|
3404
3655
|
* iso-ssbg1-v1 block location: repair symbols it refused, oversize sources,
|
|
3405
3656
|
* the sources held now for a block no repair has stated yet, and the held
|
|
@@ -3470,11 +3721,14 @@ export class FECManager {
|
|
|
3470
3721
|
/**
|
|
3471
3722
|
* Whether an MPU boundary still bounds this stream's RAPs (see
|
|
3472
3723
|
* `BlockClassifier.mpuBoundsRaps`). Gap decisions drop MPU evidence once
|
|
3473
|
-
* it does not. A stream with no classifier yet has shown nothing against it
|
|
3724
|
+
* it does not. A stream with no classifier yet has shown nothing against it,
|
|
3725
|
+
* and neither has a stream without catalog timing until it releases two
|
|
3726
|
+
* RAPs inside one MPU.
|
|
3474
3727
|
*/
|
|
3475
3728
|
mpuBoundsRapsFor(packetId: number, catalogTrackName?: string): boolean {
|
|
3476
|
-
|
|
3477
|
-
return this.#
|
|
3729
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName)
|
|
3730
|
+
if (!this.#hasCatalogTimingForPacket(packetId)) return this.#noSpanRaps.get(streamKey)?.inside !== true
|
|
3731
|
+
return this.#classifiers.get(streamKey)?.mpuBoundsRaps ?? true
|
|
3478
3732
|
}
|
|
3479
3733
|
|
|
3480
3734
|
/** A block's class now, or frozen at its resolution. */
|
|
@@ -3510,7 +3764,15 @@ export class FECManager {
|
|
|
3510
3764
|
presentationTime: bigint,
|
|
3511
3765
|
mediaTimescale: number,
|
|
3512
3766
|
): void {
|
|
3513
|
-
if (!this.#trackConfigs.has(packetId)
|
|
3767
|
+
if (!this.#trackConfigs.has(packetId)) return
|
|
3768
|
+
if (!this.#hasCatalogTimingForPacket(packetId)) {
|
|
3769
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName)
|
|
3770
|
+
const last = this.#noSpanRaps.get(streamKey)
|
|
3771
|
+
const inside = last?.inside === true ||
|
|
3772
|
+
(last?.mpu === mpu && last.presentationTime !== presentationTime)
|
|
3773
|
+
this.#noSpanRaps.set(streamKey, { mpu, presentationTime, inside })
|
|
3774
|
+
return
|
|
3775
|
+
}
|
|
3514
3776
|
this.#applyClassifierChanges(
|
|
3515
3777
|
packetId,
|
|
3516
3778
|
catalogTrackName,
|
|
@@ -3820,13 +4082,27 @@ export class FECManager {
|
|
|
3820
4082
|
|
|
3821
4083
|
client.onCleanupComplete((sbn: number) => {
|
|
3822
4084
|
if (this.#releasedWorkerClients.has(client)) return
|
|
3823
|
-
const
|
|
4085
|
+
const owed = [...this.#pendingWorkerCleanups].filter((key) => this.#pendingWorkerCleanupClients.get(key) === client)
|
|
4086
|
+
const cleanupKeys = owed.filter((key) => {
|
|
3824
4087
|
const block = this.#parseBlockKey(key)
|
|
3825
|
-
return block.packetId === packetId &&
|
|
3826
|
-
block.sbn === sbn &&
|
|
3827
|
-
this.#pendingWorkerCleanupClients.get(key) === client
|
|
4088
|
+
return block.packetId === packetId && block.sbn === sbn
|
|
3828
4089
|
})
|
|
3829
|
-
|
|
4090
|
+
// A cleanup is a queue-drain barrier: the Worker took every symbol fed
|
|
4091
|
+
// before it was asked for first, so every block already due by then
|
|
4092
|
+
// is settled by this acknowledgement too, not one barrier later. The
|
|
4093
|
+
// client sends one barrier at a time, and the blocks a repair walk
|
|
4094
|
+
// stated in one span are due together (BLO-52085). That holds only
|
|
4095
|
+
// while no block is fed a symbol after its dueAtMs, which is its
|
|
4096
|
+
// receipt-scoped deadline, not when feeding stopped: a symbol fed
|
|
4097
|
+
// between that deadline and the block's timer, after another block's
|
|
4098
|
+
// barrier was asked for, would find the block settled (failed) one
|
|
4099
|
+
// barrier early. Walks end before D-28 (walkDeadlineAt), so that window
|
|
4100
|
+
// is the timer's lateness alone; whatever feeds a block past its dueAtMs
|
|
4101
|
+
// must leave it to its own barrier.
|
|
4102
|
+
const askedAtMs = Math.max(...cleanupKeys.map((key) => this.#pendingWorkerCleanupBounds.get(key)?.askedAtMs ?? -Infinity))
|
|
4103
|
+
const due = owed.filter((key) =>
|
|
4104
|
+
!cleanupKeys.includes(key) && (this.#pendingWorkerCleanupBounds.get(key)?.dueAtMs ?? Infinity) <= askedAtMs)
|
|
4105
|
+
for (const key of [...cleanupKeys, ...due]) this.#settleOwedCleanup(key, 'cleanup-ack')
|
|
3830
4106
|
})
|
|
3831
4107
|
|
|
3832
4108
|
client.onError((msg: string, code?: FecWorkerErrorCode) => {
|
|
@@ -3908,9 +4184,11 @@ export class FECManager {
|
|
|
3908
4184
|
* fail deadline already passed, so failing it is the decision that deadline
|
|
3909
4185
|
* made. A late ack then finds nothing owed and is a no-op.
|
|
3910
4186
|
*/
|
|
3911
|
-
#boundOwedCleanup(key: string, packetId: number, client: FecWorkerClient): void {
|
|
4187
|
+
#boundOwedCleanup(key: string, packetId: number, client: FecWorkerClient, dueAtMs: number): void {
|
|
3912
4188
|
this.#clearOwedCleanupBound(key)
|
|
3913
4189
|
const bound = {
|
|
4190
|
+
dueAtMs,
|
|
4191
|
+
askedAtMs: performance.now(),
|
|
3914
4192
|
handle: setTimeout(() => {
|
|
3915
4193
|
if (this.#pendingWorkerCleanupBounds.get(key) !== bound) return
|
|
3916
4194
|
this.#pendingWorkerCleanupBounds.delete(key)
|
|
@@ -4041,7 +4319,22 @@ export class FECManager {
|
|
|
4041
4319
|
this.#isoSourceOversizeCount++
|
|
4042
4320
|
return null
|
|
4043
4321
|
}
|
|
4044
|
-
|
|
4322
|
+
return this.#feedDecoderSource(packetId, ssId, symbolData, catalogTrackName, located.block.start)
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4325
|
+
/**
|
|
4326
|
+
* Hand one placed source symbol to the stream's decoder: its Worker, which
|
|
4327
|
+
* answers through onFrame (null here), or its synchronous decoder, whose
|
|
4328
|
+
* recovered block is returned. `sbn` is the SS_Start of the block a repair
|
|
4329
|
+
* stated for `ssId`.
|
|
4330
|
+
*/
|
|
4331
|
+
#feedDecoderSource(
|
|
4332
|
+
packetId: number,
|
|
4333
|
+
ssId: number,
|
|
4334
|
+
symbolData: Uint8Array,
|
|
4335
|
+
catalogTrackName: string | undefined,
|
|
4336
|
+
sbn: number,
|
|
4337
|
+
): Uint8Array | null {
|
|
4045
4338
|
const blockKey = this.#blockKey(sbn, packetId, catalogTrackName)
|
|
4046
4339
|
const syncBlockOwner = this.#syncDecoderBlockOwners.get(blockKey)
|
|
4047
4340
|
|
|
@@ -4086,6 +4379,97 @@ export class FECManager {
|
|
|
4086
4379
|
return recovered
|
|
4087
4380
|
}
|
|
4088
4381
|
|
|
4382
|
+
/**
|
|
4383
|
+
* Feed a source symbol of this stream that another FEC instance over the
|
|
4384
|
+
* same packets rebuilt: a keyframe overlay recovery whose base SS_ID the
|
|
4385
|
+
* caller determined (draft-ramadan-moq-mmt-02 7.1, 7.4.4; joint decoding,
|
|
4386
|
+
* BLO-52085). It joins its block's decoder as a received source would, so
|
|
4387
|
+
* it reduces the erasures the block still has to solve, but it is not a
|
|
4388
|
+
* network arrival: no transport accounting, no classification evidence,
|
|
4389
|
+
* no deadline refresh, and it never makes a block clean.
|
|
4390
|
+
*
|
|
4391
|
+
* Only a block a repair stated takes one (a repair-less span has no
|
|
4392
|
+
* decoder block). A block that is terminal, or already holds that source,
|
|
4393
|
+
* does not. The symbol is the exact protected packet, unpadded, as
|
|
4394
|
+
* feedSourceSymbol takes it.
|
|
4395
|
+
*
|
|
4396
|
+
* `recovered` is the block the synchronous decoder completed with it; the
|
|
4397
|
+
* caller routes it and completes the block, as for any recovery. When
|
|
4398
|
+
* every source of the block is then present, received or rebuilt, and no
|
|
4399
|
+
* decoder returned it (a Worker answers asynchronously, and reports such a
|
|
4400
|
+
* block as clean on its own side), the block is completed here as
|
|
4401
|
+
* recovered, with nothing left to route.
|
|
4402
|
+
*/
|
|
4403
|
+
feedRebuiltSourceSymbol(
|
|
4404
|
+
packetId: number,
|
|
4405
|
+
ssId: number,
|
|
4406
|
+
symbolData: Uint8Array,
|
|
4407
|
+
catalogTrackName?: string,
|
|
4408
|
+
): RebuiltSourceFeed {
|
|
4409
|
+
if (!this.#hasBlockProfile(packetId)) return NOT_TAKEN
|
|
4410
|
+
const located = this.#isoLocatorFor(packetId, catalogTrackName).locate(ssId)
|
|
4411
|
+
if (located === null || located.block.span) return NOT_TAKEN
|
|
4412
|
+
if (!ssbg1FitsSymbol(symbolData.byteLength, this.#trackConfig(packetId).symbolSize)) return NOT_TAKEN
|
|
4413
|
+
const sbn = located.block.start
|
|
4414
|
+
const key = this.#blockKey(sbn, packetId, catalogTrackName)
|
|
4415
|
+
if (this.#completedBlocks.has(key) || this.#blockSourceEsis.get(key)?.has(located.esi)) return NOT_TAKEN
|
|
4416
|
+
let rebuilt = this.#blockRebuiltEsis.get(key)
|
|
4417
|
+
if (rebuilt?.has(located.esi)) return NOT_TAKEN
|
|
4418
|
+
if (rebuilt === undefined) {
|
|
4419
|
+
rebuilt = new Set()
|
|
4420
|
+
this.#blockRebuiltEsis.set(key, rebuilt)
|
|
4421
|
+
}
|
|
4422
|
+
const config = this.#trackConfigs.get(packetId)
|
|
4423
|
+
const wasShort = config !== undefined &&
|
|
4424
|
+
this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config) !== undefined
|
|
4425
|
+
rebuilt.add(located.esi)
|
|
4426
|
+
const recovered = this.#feedDecoderSource(packetId, ssId, symbolData, catalogTrackName, sbn)
|
|
4427
|
+
if (recovered === null && !this.#completeWhenSourcesPresent(key, sbn, located.block.length, packetId, catalogTrackName)) {
|
|
4428
|
+
// The late-source cut assumed only a late source could complete this
|
|
4429
|
+
// block; with this source its group can, so it gets a full multicast
|
|
4430
|
+
// wait again, counted from now.
|
|
4431
|
+
// ponytail: from now, not from its sources, so it can close up to one
|
|
4432
|
+
// multicast wait after its uncut deadline; at most once per block, since
|
|
4433
|
+
// a rebuilt source only adds to what the block holds and the cut cannot
|
|
4434
|
+
// apply to it again. Keep the uncut deadline and re-arm to it if a lab
|
|
4435
|
+
// run shows that wait.
|
|
4436
|
+
if (wasShort && this.#activeBlocks.has(key) &&
|
|
4437
|
+
this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config!) === undefined) {
|
|
4438
|
+
this.#armBlockTimeout(sbn, packetId, catalogTrackName, this.#multicastWaitMs(config!))
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
return { taken: true, recovered }
|
|
4442
|
+
}
|
|
4443
|
+
|
|
4444
|
+
/**
|
|
4445
|
+
* A block that holds every one of its `length` sources, received or
|
|
4446
|
+
* rebuilt by another instance, with at least one rebuilt, is recovered:
|
|
4447
|
+
* every packet of it was delivered, by its own arrival or by the instance
|
|
4448
|
+
* that rebuilt it, so nothing is routed. Returns whether it completed it.
|
|
4449
|
+
*/
|
|
4450
|
+
#completeWhenSourcesPresent(
|
|
4451
|
+
key: string,
|
|
4452
|
+
sbn: number,
|
|
4453
|
+
length: number,
|
|
4454
|
+
packetId: number,
|
|
4455
|
+
catalogTrackName: string | undefined,
|
|
4456
|
+
): boolean {
|
|
4457
|
+
const rebuilt = this.#blockRebuiltEsis.get(key)
|
|
4458
|
+
if (rebuilt === undefined || this.#completedBlocks.has(key)) return false
|
|
4459
|
+
let present = rebuilt.size
|
|
4460
|
+
for (const esi of this.#blockSourceEsis.get(key) ?? []) if (!rebuilt.has(esi)) present++
|
|
4461
|
+
if (present < length) return false
|
|
4462
|
+
this.#traceLifecycle('recovered', sbn, packetId, catalogTrackName)
|
|
4463
|
+
this.countRecovery(packetId, sbn, catalogTrackName)
|
|
4464
|
+
this.cancelBlockTimeout(sbn, packetId, catalogTrackName)
|
|
4465
|
+
if (catalogTrackName === undefined) {
|
|
4466
|
+
this.onBlockComplete?.(sbn, packetId)
|
|
4467
|
+
} else {
|
|
4468
|
+
this.onBlockComplete?.(sbn, packetId, catalogTrackName)
|
|
4469
|
+
}
|
|
4470
|
+
return true
|
|
4471
|
+
}
|
|
4472
|
+
|
|
4089
4473
|
/**
|
|
4090
4474
|
* fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
|
|
4091
4475
|
* exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
|
|
@@ -4166,7 +4550,10 @@ export class FECManager {
|
|
|
4166
4550
|
this.#layerAnchorHorizon(packetId),
|
|
4167
4551
|
this.#sourceFrontiers.get(streamKey)?.sbn,
|
|
4168
4552
|
)
|
|
4169
|
-
if (verdict === 'discard')
|
|
4553
|
+
if (verdict === 'discard') {
|
|
4554
|
+
this.#unlistedRepairTrackRefusals++
|
|
4555
|
+
return false
|
|
4556
|
+
}
|
|
4170
4557
|
if (verdict !== undefined) {
|
|
4171
4558
|
this.#failClosed(streamKey, verdict, packetId, catalogTrackName)
|
|
4172
4559
|
return false
|
|
@@ -4343,9 +4730,150 @@ export class FECManager {
|
|
|
4343
4730
|
this.#completeCleanBlock(blockKey, sbn, packetId, catalogTrackName)
|
|
4344
4731
|
return null
|
|
4345
4732
|
}
|
|
4733
|
+
// Its K' is known now: a block this repair shows short of it waits less.
|
|
4734
|
+
if (recovered === null) this.#shortenUnrecoverableWait(blockKey, sbn, packetId, catalogTrackName)
|
|
4346
4735
|
return recovered
|
|
4347
4736
|
}
|
|
4348
4737
|
|
|
4738
|
+
/**
|
|
4739
|
+
* A first-arrival multicast source, held or placed. A datagram flow keeps
|
|
4740
|
+
* its sources in send order, so one that moves the stream's newest source
|
|
4741
|
+
* position past a block leaves the sources that block still misses
|
|
4742
|
+
* reordered behind it at best: it shortens the wait of every block it
|
|
4743
|
+
* passed that only a late source can complete. MoQ is left out: its streams
|
|
4744
|
+
* can overtake one another, so a MoQ source shows nothing about the sources
|
|
4745
|
+
* sent before it.
|
|
4746
|
+
*/
|
|
4747
|
+
#noteMulticastSource(
|
|
4748
|
+
locator: IsoBlockLocator<IsoHeldSource>,
|
|
4749
|
+
ssId: number,
|
|
4750
|
+
packetId: number,
|
|
4751
|
+
catalogTrackName: string | undefined,
|
|
4752
|
+
): void {
|
|
4753
|
+
const previous = locator.newestSource
|
|
4754
|
+
if (!locator.noteSource(ssId) || previous === undefined) return
|
|
4755
|
+
// The blocks whose last SS_ID lies in [previous, ssId): this source
|
|
4756
|
+
// passed them and the previous newest one had not.
|
|
4757
|
+
for (const block of locator.blocksBetween((previous - 1) >>> 0, ssId)) {
|
|
4758
|
+
if (!serial32Precedes(serial32Add(block.start, block.length - 1), ssId)) continue
|
|
4759
|
+
this.#shortenUnrecoverableWait(
|
|
4760
|
+
this.#blockKey(block.start, packetId, catalogTrackName),
|
|
4761
|
+
block.start,
|
|
4762
|
+
packetId,
|
|
4763
|
+
catalogTrackName,
|
|
4764
|
+
)
|
|
4765
|
+
}
|
|
4766
|
+
}
|
|
4767
|
+
|
|
4768
|
+
/**
|
|
4769
|
+
* The wait of a block that only a late source can complete (BLO-52085): a
|
|
4770
|
+
* repair stated it, its received sources plus every symbol its repair group
|
|
4771
|
+
* carries (RSB_length) are short of K' (the repair scheduler's
|
|
4772
|
+
* group-cannot-complete), and a later source of the stream has arrived, so
|
|
4773
|
+
* a source it misses is lost or reordered behind that one. The span, which
|
|
4774
|
+
* covers repair symbols paced after its sources, buys it nothing: it waits
|
|
4775
|
+
* the late-symbol allowance alone, the multicast wait less the span (the
|
|
4776
|
+
* catalog tolerance or the measured delivery gap). Undefined for any other
|
|
4777
|
+
* block. While a keyframe overlay is installed, the block waits for its
|
|
4778
|
+
* repair too (#overlayLateWaitMs). A repair-less span keeps its whole
|
|
4779
|
+
* wait, even one longer than K whose group is empty (#openIsoSpan): its
|
|
4780
|
+
* resolution is what releases the frames behind it, and failing it early
|
|
4781
|
+
* released them past a keyframe the overlay was still rebuilding, which
|
|
4782
|
+
* then arrived stale. The release gate lets them go instead
|
|
4783
|
+
* (isoRepairlessWaitMs).
|
|
4784
|
+
*/
|
|
4785
|
+
#lateSourceWaitMs(
|
|
4786
|
+
key: string,
|
|
4787
|
+
sbn: number,
|
|
4788
|
+
packetId: number,
|
|
4789
|
+
catalogTrackName: string | undefined,
|
|
4790
|
+
config: ResolvedFECTrackConfig,
|
|
4791
|
+
): number | undefined {
|
|
4792
|
+
if (this.#isoSpanKeys.has(key) || !this.#groupCannotComplete(key)) return undefined
|
|
4793
|
+
const authoredLength = this.#blockAuthoredLengths.get(key)!
|
|
4794
|
+
const newestSource = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))?.newestSource
|
|
4795
|
+
if (newestSource === undefined || !serial32Precedes(serial32Add(sbn, authoredLength - 1), newestSource)) {
|
|
4796
|
+
return undefined
|
|
4797
|
+
}
|
|
4798
|
+
return this.#overlayLateWaitMs(packetId, catalogTrackName, config)
|
|
4799
|
+
}
|
|
4800
|
+
|
|
4801
|
+
/**
|
|
4802
|
+
* A repair stated the block, and its sources plus every symbol its repair
|
|
4803
|
+
* group carries (RSB_length) are short of its SSB_length.
|
|
4804
|
+
*/
|
|
4805
|
+
#groupCannotComplete(key: string): boolean {
|
|
4806
|
+
const authoredLength = this.#blockAuthoredLengths.get(key)
|
|
4807
|
+
const rsbLength = this.#blockRsbLengths.get(key)
|
|
4808
|
+
if (authoredLength === undefined || rsbLength === undefined) return false
|
|
4809
|
+
// A source another instance rebuilt (feedRebuiltSourceSymbol) is one the
|
|
4810
|
+
// decoder holds: the group need only cover what neither delivered.
|
|
4811
|
+
let present = this.#blockSourceCounts.get(key) ?? 0
|
|
4812
|
+
const received = this.#blockSourceEsis.get(key)
|
|
4813
|
+
for (const esi of this.#blockRebuiltEsis.get(key) ?? []) if (!received?.has(esi)) present++
|
|
4814
|
+
return present + rsbLength < authoredLength
|
|
4815
|
+
}
|
|
4816
|
+
|
|
4817
|
+
/**
|
|
4818
|
+
* How long a loss only a late source or an installed keyframe overlay can
|
|
4819
|
+
* still fill waits once a later source passed it: the late-symbol
|
|
4820
|
+
* allowance alone (the multicast wait less the span) while no overlay is
|
|
4821
|
+
* installed. An installed one (keyframeOverlayTiming) may still rebuild a
|
|
4822
|
+
* RAP packet the loss took: a second FEC instance over the same packets
|
|
4823
|
+
* (draft-ramadan-moq-mmt-02 7.4), whose repair is paced across its own
|
|
4824
|
+
* span, unrelated to the base's. That packet can complete a stated block
|
|
4825
|
+
* (feedRebuiltSourceSymbol), or play behind a span; giving the loss up
|
|
4826
|
+
* first lets the release gate pass the keyframe, whose rebuild then lands
|
|
4827
|
+
* stale. The overlay repair of a packet the loss took goes out within the
|
|
4828
|
+
* overlay's span of that packet (fec-core-00 9.3), and the later source was
|
|
4829
|
+
* sent after it, so the loss waits that span plus the larger of the
|
|
4830
|
+
* allowance and the overlay's own tolerance. An overlay that states no
|
|
4831
|
+
* span (its block may then span keyframes), or one whose wait is not
|
|
4832
|
+
* shorter than the whole multicast wait, leaves the whole wait: undefined.
|
|
4833
|
+
*/
|
|
4834
|
+
#overlayLateWaitMs(
|
|
4835
|
+
packetId: number,
|
|
4836
|
+
catalogTrackName: string | undefined,
|
|
4837
|
+
config: ResolvedFECTrackConfig,
|
|
4838
|
+
): number | undefined {
|
|
4839
|
+
const waitMs = this.#multicastWaitMs(config)
|
|
4840
|
+
const allowanceMs = waitMs - config.interleaveDepthMs
|
|
4841
|
+
// Read live. The late-source cut only ever shortens a block's deadline
|
|
4842
|
+
// (#shortenUnrecoverableWait), so a block it armed at the bare allowance
|
|
4843
|
+
// before an overlay was installed, or between a dispose and a reinstall,
|
|
4844
|
+
// keeps that deadline until a source of its own re-arms it.
|
|
4845
|
+
const overlay = this.keyframeOverlayTiming?.(packetId, catalogTrackName)
|
|
4846
|
+
if (overlay === undefined) return allowanceMs
|
|
4847
|
+
const overlaySpanMs = overlay.interleaveDepthMs ?? 0
|
|
4848
|
+
const overlayWaitMs = overlaySpanMs + Math.max(allowanceMs, overlay.reorderToleranceMs ?? 0)
|
|
4849
|
+
return overlaySpanMs > 0 && overlayWaitMs < waitMs ? overlayWaitMs : undefined
|
|
4850
|
+
}
|
|
4851
|
+
|
|
4852
|
+
/**
|
|
4853
|
+
* Bring an open block's wait in to its late-source wait, when it has one.
|
|
4854
|
+
* Never later than it is armed: only a source can complete such a block,
|
|
4855
|
+
* so a repair of its group (paced across the span) must not keep it open.
|
|
4856
|
+
*/
|
|
4857
|
+
#shortenUnrecoverableWait(
|
|
4858
|
+
key: string,
|
|
4859
|
+
sbn: number,
|
|
4860
|
+
packetId: number,
|
|
4861
|
+
catalogTrackName: string | undefined,
|
|
4862
|
+
): void {
|
|
4863
|
+
if (!this.#activeBlocks.has(key)) return
|
|
4864
|
+
const config = this.#trackConfigs.get(packetId)
|
|
4865
|
+
if (config === undefined) return
|
|
4866
|
+
const waitMs = this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, config)
|
|
4867
|
+
if (waitMs === undefined) return
|
|
4868
|
+
const armedAtMs = this.#blockWaitDeadlinesMs.get(key)
|
|
4869
|
+
this.#armBlockTimeout(
|
|
4870
|
+
sbn,
|
|
4871
|
+
packetId,
|
|
4872
|
+
catalogTrackName,
|
|
4873
|
+
armedAtMs === undefined ? waitMs : Math.min(waitMs, armedAtMs - this.#receiptNow()),
|
|
4874
|
+
)
|
|
4875
|
+
}
|
|
4876
|
+
|
|
4349
4877
|
/**
|
|
4350
4878
|
* Record a block's authored SSB_length from a repair symbol. Returns false,
|
|
4351
4879
|
* leaving the block unchanged, when the symbol contradicts the block: a
|
|
@@ -4485,7 +5013,8 @@ export class FECManager {
|
|
|
4485
5013
|
* the inactivity deadline on each symbol, records the symbol's in-band
|
|
4486
5014
|
* classification evidence, and marks the block clean when all of its
|
|
4487
5015
|
* authored source symbols arrived: the SSB_length a repair symbol declared,
|
|
4488
|
-
* otherwise K.
|
|
5016
|
+
* otherwise K. `held` marks a source held unplaced since it arrived and
|
|
5017
|
+
* placed only now (see #noteSbnSeen).
|
|
4489
5018
|
*
|
|
4490
5019
|
* Throws for a packetId that was never configured, so a classified block
|
|
4491
5020
|
* never reads the manager-global K or timeout.
|
|
@@ -4496,6 +5025,7 @@ export class FECManager {
|
|
|
4496
5025
|
catalogTrackName: string | undefined,
|
|
4497
5026
|
esi: number,
|
|
4498
5027
|
evidence: SourceSymbolEvidence,
|
|
5028
|
+
held = false,
|
|
4499
5029
|
): void {
|
|
4500
5030
|
const trackConfig = this.#trackConfigs.get(packetId)
|
|
4501
5031
|
if (trackConfig === undefined) {
|
|
@@ -4517,6 +5047,7 @@ export class FECManager {
|
|
|
4517
5047
|
'source',
|
|
4518
5048
|
evidence.packetSequenceNumber,
|
|
4519
5049
|
Number.isInteger(esi) ? (sbn + esi) >>> 0 : sbn,
|
|
5050
|
+
held,
|
|
4520
5051
|
)
|
|
4521
5052
|
|
|
4522
5053
|
// A source ESI at or past the block's authored SSB_length contradicts it;
|
|
@@ -4561,6 +5092,20 @@ export class FECManager {
|
|
|
4561
5092
|
this.#completeCleanBlock(key, sbn, packetId, catalogTrackName)
|
|
4562
5093
|
return
|
|
4563
5094
|
}
|
|
5095
|
+
// A late arrival can be the last source a block lacked besides those
|
|
5096
|
+
// another instance rebuilt (feedRebuiltSourceSymbol).
|
|
5097
|
+
if (
|
|
5098
|
+
this.#blockRebuiltEsis.has(key) &&
|
|
5099
|
+
this.#completeWhenSourcesPresent(
|
|
5100
|
+
key,
|
|
5101
|
+
sbn,
|
|
5102
|
+
this.#isoLocatorFor(packetId, catalogTrackName).blockAt(sbn)?.length ?? authoredLength,
|
|
5103
|
+
packetId,
|
|
5104
|
+
catalogTrackName,
|
|
5105
|
+
)
|
|
5106
|
+
) {
|
|
5107
|
+
return
|
|
5108
|
+
}
|
|
4564
5109
|
|
|
4565
5110
|
this.noteBlockActivity(sbn, packetId, catalogTrackName, true)
|
|
4566
5111
|
|
|
@@ -4580,7 +5125,9 @@ export class FECManager {
|
|
|
4580
5125
|
this.cancelBlockTimeout(sbn, packetId, catalogTrackName)
|
|
4581
5126
|
this.#blockSourceCounts.delete(key)
|
|
4582
5127
|
this.#blockSourceEsis.delete(key)
|
|
5128
|
+
this.#blockRebuiltEsis.delete(key)
|
|
4583
5129
|
this.#blockAuthoredLengths.delete(key)
|
|
5130
|
+
this.#isoSpanKeys.delete(key)
|
|
4584
5131
|
this.#blockRepairRsIds.delete(key)
|
|
4585
5132
|
this.#blockRsbLengths.delete(key)
|
|
4586
5133
|
// BLO-3323 L15: track which SBNs reached K source-symbol arrivals so the
|
|
@@ -4622,6 +5169,20 @@ export class FECManager {
|
|
|
4622
5169
|
return this.#receiptAtMs ?? performance.now()
|
|
4623
5170
|
}
|
|
4624
5171
|
|
|
5172
|
+
/**
|
|
5173
|
+
* The whole-ms delay of a timer for `deadlineMs` armed inside a receipt
|
|
5174
|
+
* scope: counted from the receipt time, as the timer of a symbol fed when
|
|
5175
|
+
* it was received was, less the whole ms since. So it fires on the tick
|
|
5176
|
+
* that timer would have, never later than a delay counted from now, and
|
|
5177
|
+
* its handler still re-arms a timer that fires before its deadline.
|
|
5178
|
+
* Counted from now, a deadline set from the receipt time is rounded up
|
|
5179
|
+
* from another fraction of a ms (BLO-52085).
|
|
5180
|
+
*/
|
|
5181
|
+
#receiptTimerDelayMs(deadlineMs: number, minMs: number): number {
|
|
5182
|
+
const receivedAtMs = this.#receiptAtMs!
|
|
5183
|
+
return Math.max(minMs, Math.ceil(deadlineMs - receivedAtMs) - Math.ceil(performance.now() - receivedAtMs))
|
|
5184
|
+
}
|
|
5185
|
+
|
|
4625
5186
|
/**
|
|
4626
5187
|
* A held packet admitted late arms from its (earlier) receipt time; that
|
|
4627
5188
|
* never pulls in a deadline later activity already armed. Outside a
|
|
@@ -4693,7 +5254,18 @@ export class FECManager {
|
|
|
4693
5254
|
)
|
|
4694
5255
|
}
|
|
4695
5256
|
|
|
4696
|
-
|
|
5257
|
+
// A block only a late source can complete waits the late-symbol
|
|
5258
|
+
// allowance from its own sources' activity; nothing else moves it later.
|
|
5259
|
+
if (!sourceProgress && this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, trackConfig) !== undefined) {
|
|
5260
|
+
this.#shortenUnrecoverableWait(key, sbn, packetId, catalogTrackName)
|
|
5261
|
+
return
|
|
5262
|
+
}
|
|
5263
|
+
this.#armBlockTimeout(
|
|
5264
|
+
sbn,
|
|
5265
|
+
packetId,
|
|
5266
|
+
catalogTrackName,
|
|
5267
|
+
this.#lateSourceWaitMs(key, sbn, packetId, catalogTrackName, trackConfig) ?? timeoutMs,
|
|
5268
|
+
)
|
|
4697
5269
|
}
|
|
4698
5270
|
|
|
4699
5271
|
#failBlock(
|
|
@@ -4702,6 +5274,9 @@ export class FECManager {
|
|
|
4702
5274
|
catalogTrackName?: string,
|
|
4703
5275
|
): void {
|
|
4704
5276
|
const key = this.#blockKey(sbn, packetId, catalogTrackName)
|
|
5277
|
+
const span: IsoSpanFailure | undefined = this.#isoSpanKeys.delete(key)
|
|
5278
|
+
? { length: this.#blockAuthoredLengths.get(key) ?? 0, sources: this.#blockSourceCounts.get(key) ?? 0 }
|
|
5279
|
+
: undefined
|
|
4705
5280
|
this.#traceLifecycle('failed', sbn, packetId, catalogTrackName)
|
|
4706
5281
|
this.#clearRepairDeadline(key)
|
|
4707
5282
|
this.#clearBlockTimer(key)
|
|
@@ -4711,6 +5286,7 @@ export class FECManager {
|
|
|
4711
5286
|
}
|
|
4712
5287
|
this.#blockSourceCounts.delete(key)
|
|
4713
5288
|
this.#blockSourceEsis.delete(key)
|
|
5289
|
+
this.#blockRebuiltEsis.delete(key)
|
|
4714
5290
|
this.#blockAuthoredLengths.delete(key)
|
|
4715
5291
|
this.#blockRepairRsIds.delete(key)
|
|
4716
5292
|
this.#blockRsbLengths.delete(key)
|
|
@@ -4720,7 +5296,8 @@ export class FECManager {
|
|
|
4720
5296
|
this.#markPathBlockComplete(sbn, packetId, catalogTrackName)
|
|
4721
5297
|
this.#fecStats.blocksFailed++
|
|
4722
5298
|
this.#statsForPacket(packetId).blocksFailed++
|
|
4723
|
-
this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass)
|
|
5299
|
+
if (span === undefined) this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass)
|
|
5300
|
+
else this.onBlockFailed?.(sbn, packetId, catalogTrackName, blockClass, span)
|
|
4724
5301
|
this.onBlockResolved?.(sbn, packetId, catalogTrackName)
|
|
4725
5302
|
}
|
|
4726
5303
|
|
|
@@ -4750,7 +5327,9 @@ export class FECManager {
|
|
|
4750
5327
|
this.#retireBlockClass(key, block.sbn, block.packetId, block.catalogTrackName)
|
|
4751
5328
|
this.#blockSourceCounts.delete(key)
|
|
4752
5329
|
this.#blockSourceEsis.delete(key)
|
|
5330
|
+
this.#blockRebuiltEsis.delete(key)
|
|
4753
5331
|
this.#blockAuthoredLengths.delete(key)
|
|
5332
|
+
this.#isoSpanKeys.delete(key)
|
|
4754
5333
|
this.#blockRepairRsIds.delete(key)
|
|
4755
5334
|
this.#blockRsbLengths.delete(key)
|
|
4756
5335
|
this.#clearBlockTimer(key)
|
|
@@ -4858,7 +5437,9 @@ export class FECManager {
|
|
|
4858
5437
|
this.#blockKeysBySbn.clear()
|
|
4859
5438
|
this.#blockSourceCounts.clear()
|
|
4860
5439
|
this.#blockSourceEsis.clear()
|
|
5440
|
+
this.#blockRebuiltEsis.clear()
|
|
4861
5441
|
this.#blockAuthoredLengths.clear()
|
|
5442
|
+
this.#isoSpanKeys.clear()
|
|
4862
5443
|
this.#blockRepairRsIds.clear()
|
|
4863
5444
|
this.#blockRsbLengths.clear()
|
|
4864
5445
|
this.#heldLayerStates.clear()
|
|
@@ -4883,6 +5464,7 @@ export class FECManager {
|
|
|
4883
5464
|
this.#blockAnchorsMs.clear()
|
|
4884
5465
|
this.#blockCatalogTrackNames.clear()
|
|
4885
5466
|
this.#classifiers.clear()
|
|
5467
|
+
this.#noSpanRaps.clear()
|
|
4886
5468
|
this.#streamGeometries.clear()
|
|
4887
5469
|
this.#failedBlocks.clear()
|
|
4888
5470
|
this.#resolvedBlockClasses.clear()
|