@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/src/fec-manager.ts
CHANGED
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
|
|
56
56
|
import { HeldLayerAdmission, heldLayerAnchorHorizon, type FecFailClosedReason } from './held-layer-admission.js'
|
|
57
57
|
import type { MmtpDeliveryProvenance } from './mfu-reassembler.js'
|
|
58
|
+
import type { AuthoredTiming } from './authored-timing.js'
|
|
58
59
|
import type {
|
|
59
60
|
FecWorkerClient,
|
|
60
61
|
FecTrackStats,
|
|
@@ -144,6 +145,14 @@ export interface FecStats {
|
|
|
144
145
|
* block and anchor nothing.
|
|
145
146
|
*/
|
|
146
147
|
unlistedRepairTrackRefusals: number
|
|
148
|
+
/**
|
|
149
|
+
* Repair packets the router dropped before any FEC instance saw them,
|
|
150
|
+
* because it could not name the track they repair (BLO-55759): the physical
|
|
151
|
+
* PID is not in the catalog (`unregistered`), or no endpoint on this ingress
|
|
152
|
+
* holds its catalog owner (`ownerAbsent`) or more than one does
|
|
153
|
+
* (`ownerAmbiguous`). Cumulative.
|
|
154
|
+
*/
|
|
155
|
+
unresolvedRepairOwnerDrops: UnresolvedRepairOwnerDrops
|
|
147
156
|
/**
|
|
148
157
|
* Repair objects discarded on admission (draft-ramadan-moq-fec-core-00 7.5,
|
|
149
158
|
* draft-ramadan-moq-mmt-02 7.3), per FEC instance and reason. The instance
|
|
@@ -154,6 +163,10 @@ export interface FecStats {
|
|
|
154
163
|
workerErrors: Record<string, number>
|
|
155
164
|
}
|
|
156
165
|
|
|
166
|
+
/** Why the router could not name a repair packet's owning track. */
|
|
167
|
+
export type UnresolvedRepairOwnerReason = 'unregistered' | 'ownerAbsent' | 'ownerAmbiguous'
|
|
168
|
+
export type UnresolvedRepairOwnerDrops = Record<UnresolvedRepairOwnerReason, number>
|
|
169
|
+
|
|
157
170
|
/** One FEC instance's repair-object admission discards, by reason. */
|
|
158
171
|
export type FecRepairObjectRejects = {
|
|
159
172
|
packetId: number
|
|
@@ -175,7 +188,22 @@ export interface FecPacketStats {
|
|
|
175
188
|
packetLossRate: number
|
|
176
189
|
}
|
|
177
190
|
|
|
178
|
-
|
|
191
|
+
/**
|
|
192
|
+
* The transport a symbol arrived on: a multicast/AMT leg, a reliable MoQ
|
|
193
|
+
* subscription (unicast fallback or an overlap copy), or an "mfu-datagram"
|
|
194
|
+
* subscription (mmt-02 4.3.1), which is a lossy unicast leg. The loss rules
|
|
195
|
+
* ask one of two questions of it, and the answers differ on an ordered
|
|
196
|
+
* relay. Is the symbol in the publisher's own send order: `source !== 'moq'`
|
|
197
|
+
* (late-source shortening, startup partial blocks). Did it reach this
|
|
198
|
+
* manager as a datagram of its own, on a path that loses and reorders:
|
|
199
|
+
* FECManager #lossyDatagramPath (the late-source allowance of a loss-free
|
|
200
|
+
* range, the FEC deadline of a run no repair delimited, the delivery-gap
|
|
201
|
+
* sample). Only the ordered-relay frontier is multicast's.
|
|
202
|
+
*/
|
|
203
|
+
export type FecSymbolSource = 'multicast' | 'moq' | 'moq-datagram'
|
|
204
|
+
|
|
205
|
+
/** The lossy paths the delivery-gap estimator samples, each with its own window. */
|
|
206
|
+
export type DeliveryGapPath = 'multicast' | 'moq-datagram'
|
|
179
207
|
|
|
180
208
|
/**
|
|
181
209
|
* What feedRebuiltSourceSymbol did with a rebuilt source: whether its block
|
|
@@ -199,6 +227,13 @@ export interface IsoHeldSource {
|
|
|
199
227
|
readonly evidence: SourceSymbolEvidence
|
|
200
228
|
/** Larger than one ssbg_mode1 symbol: counted, never decoded. */
|
|
201
229
|
readonly oversized: boolean
|
|
230
|
+
/**
|
|
231
|
+
* Receipt time (performance.now() clock; holdIsoSource stamps it when
|
|
232
|
+
* absent): a run's FEC deadline is anchored at it (isoRepairlessWaitMs),
|
|
233
|
+
* and a loss-free range's late-source allowance counts from it
|
|
234
|
+
* (#lossFreeRunReadyAtMs).
|
|
235
|
+
*/
|
|
236
|
+
readonly arrivedAtMs?: number
|
|
202
237
|
}
|
|
203
238
|
|
|
204
239
|
/**
|
|
@@ -270,6 +305,8 @@ export interface FecBlockPathCount {
|
|
|
270
305
|
catalogTrackName?: string
|
|
271
306
|
multicastSymbols: number
|
|
272
307
|
moqSymbols: number
|
|
308
|
+
/** Symbols of an "mfu-datagram" leg: lossy, counted apart from reliable MoQ. */
|
|
309
|
+
datagramSymbols: number
|
|
273
310
|
complete: boolean
|
|
274
311
|
}
|
|
275
312
|
|
|
@@ -329,6 +366,8 @@ export interface FECManagerConfig {
|
|
|
329
366
|
* block `unknown` (fail-closed: protected).
|
|
330
367
|
*/
|
|
331
368
|
geometry?: BlockClassifierGeometry
|
|
369
|
+
/** The track's catalog group duration in ms: one term of an "mfu-datagram" leg's ledger retention. */
|
|
370
|
+
groupDurationMs?: number
|
|
332
371
|
/**
|
|
333
372
|
* fec-01 6.3.9: the source track's base repair layers (catalog
|
|
334
373
|
* `TrackFecParams.repairLayers`). Layer i's held total is
|
|
@@ -366,6 +405,7 @@ interface ResolvedFECTrackConfig {
|
|
|
366
405
|
trackKind?: TrackKind
|
|
367
406
|
codec?: string
|
|
368
407
|
geometry?: BlockClassifierGeometry
|
|
408
|
+
groupDurationMs?: number
|
|
369
409
|
repairLayers?: readonly FecRepairLayer[]
|
|
370
410
|
heldLayers?: readonly number[]
|
|
371
411
|
}
|
|
@@ -536,7 +576,12 @@ export class FECManager {
|
|
|
536
576
|
#repairHoldUntilMs = new Map<string, number>()
|
|
537
577
|
// Receiver-measured multicast delivery gap: the late-symbol wait's jitter
|
|
538
578
|
// term (see DeliveryGapEstimator for the statistic and why).
|
|
539
|
-
|
|
579
|
+
// One estimator per lossy path, so a hybrid session never lets one leg's
|
|
580
|
+
// stall widen the other's wait; the wait reads the larger peak.
|
|
581
|
+
#deliveryGaps: Record<DeliveryGapPath, DeliveryGapEstimator> = {
|
|
582
|
+
multicast: new DeliveryGapEstimator(),
|
|
583
|
+
'moq-datagram': new DeliveryGapEstimator(),
|
|
584
|
+
}
|
|
540
585
|
#lifecycleTrace: FecLifecycleTrace[] = []
|
|
541
586
|
// Worker-backed timeouts enqueue cleanup behind all prior symbol messages.
|
|
542
587
|
// Failure remains pending until cleanupComplete acknowledges that queue drain.
|
|
@@ -733,6 +778,14 @@ export class FECManager {
|
|
|
733
778
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
734
779
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
735
780
|
#isoLocators = new Map<string, IsoBlockLocator<IsoHeldSource>>()
|
|
781
|
+
// The ts of the run behind the gap the release gate last asked about, per
|
|
782
|
+
// stream (isoRepairlessWaitMs), keyed on the frame before the gap: kept, as
|
|
783
|
+
// the source it came from may retire before the run's deadline, and the
|
|
784
|
+
// earliest found wins, so a late frame that becomes the head restarts
|
|
785
|
+
// nothing. It stays until the next run gap: a source discontinuity drops
|
|
786
|
+
// it, and one older than twice the hold ceiling is not this gap's.
|
|
787
|
+
// `counted` once the deadline passed (onUndelimitedRunGap).
|
|
788
|
+
#runAnchors = new Map<string, { fromSsId: number; tsMs: number; counted: boolean }>()
|
|
736
789
|
#deferIsoGaps = false
|
|
737
790
|
#isoRepairRefusedCount = 0
|
|
738
791
|
#isoSourceOversizeCount = 0
|
|
@@ -772,6 +825,7 @@ export class FECManager {
|
|
|
772
825
|
#decoderUnavailableEvents = 0
|
|
773
826
|
#repairSymbolSizeMismatchCount = 0
|
|
774
827
|
#unlistedRepairTrackRefusals = 0
|
|
828
|
+
readonly #unresolvedRepairOwnerDrops: UnresolvedRepairOwnerDrops = { unregistered: 0, ownerAbsent: 0, ownerAmbiguous: 0 }
|
|
775
829
|
|
|
776
830
|
// Event callbacks — block lifecycle notifications for MmtpRouter wiring.
|
|
777
831
|
// NOTE: For sync WASM path, recovery routing is handled by MmtpRouter from
|
|
@@ -891,6 +945,10 @@ export class FECManager {
|
|
|
891
945
|
onSourceDiscontinuity:
|
|
892
946
|
| ((packetId: number, catalogTrackName: string | undefined) => void)
|
|
893
947
|
| null = null
|
|
948
|
+
/** The FEC deadline of a run no repair delimited passed, releasing the gap behind it (once per gap). */
|
|
949
|
+
onUndelimitedRunGap:
|
|
950
|
+
| ((packetId: number, catalogTrackName: string | undefined) => void)
|
|
951
|
+
| null = null
|
|
894
952
|
/**
|
|
895
953
|
* The span and tolerance the catalog states for a keyframe overlay
|
|
896
954
|
* installed over a source track (draft-ramadan-moq-mmt-02 7.4.1: the
|
|
@@ -1798,6 +1856,7 @@ export class FECManager {
|
|
|
1798
1856
|
// one continuous SBN sequence.
|
|
1799
1857
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity()
|
|
1800
1858
|
this.#noSpanRaps.delete(streamKey)
|
|
1859
|
+
this.#runAnchors.delete(streamKey)
|
|
1801
1860
|
this.#highestSbn.set(streamKey, { sbn, atMs: now })
|
|
1802
1861
|
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now })
|
|
1803
1862
|
if (psn === undefined) this.#sourceAnchors.delete(streamKey)
|
|
@@ -2027,7 +2086,7 @@ export class FECManager {
|
|
|
2027
2086
|
consider(geometry, this.#parseStreamKey(streamKey).packetId)
|
|
2028
2087
|
}
|
|
2029
2088
|
for (const [packetId, config] of this.#trackConfigs) consider(config.geometry, packetId)
|
|
2030
|
-
this.#deliveryGaps.setWindowMs(windowMs)
|
|
2089
|
+
for (const estimator of Object.values(this.#deliveryGaps)) estimator.setWindowMs(windowMs)
|
|
2031
2090
|
}
|
|
2032
2091
|
|
|
2033
2092
|
/**
|
|
@@ -2041,7 +2100,7 @@ export class FECManager {
|
|
|
2041
2100
|
* stream order and never feeds the estimator.
|
|
2042
2101
|
*/
|
|
2043
2102
|
#multicastWaitMs(config: ResolvedFECTrackConfig): number {
|
|
2044
|
-
return this.#waitForGapMs(config, this.#
|
|
2103
|
+
return this.#waitForGapMs(config, this.#peakDeliveryGapMs())
|
|
2045
2104
|
}
|
|
2046
2105
|
|
|
2047
2106
|
/**
|
|
@@ -2049,7 +2108,7 @@ export class FECManager {
|
|
|
2049
2108
|
* catalog window, so this is a catalog quantity that no measurement moves.
|
|
2050
2109
|
*/
|
|
2051
2110
|
#maxMulticastWaitMs(config: ResolvedFECTrackConfig): number {
|
|
2052
|
-
return this.#waitForGapMs(config, this.#deliveryGaps.windowMs ?? 0)
|
|
2111
|
+
return this.#waitForGapMs(config, this.#deliveryGaps.multicast.windowMs ?? 0)
|
|
2053
2112
|
}
|
|
2054
2113
|
|
|
2055
2114
|
#waitForGapMs(config: ResolvedFECTrackConfig, gapMs: number): number {
|
|
@@ -2314,6 +2373,9 @@ export class FECManager {
|
|
|
2314
2373
|
...((config.geometry ?? previous.geometry) === undefined
|
|
2315
2374
|
? {}
|
|
2316
2375
|
: { geometry: config.geometry ?? previous.geometry }),
|
|
2376
|
+
...((config.groupDurationMs ?? previous.groupDurationMs) === undefined
|
|
2377
|
+
? {}
|
|
2378
|
+
: { groupDurationMs: config.groupDurationMs ?? previous.groupDurationMs }),
|
|
2317
2379
|
...((config.repairLayers ?? previous.repairLayers) === undefined
|
|
2318
2380
|
? {}
|
|
2319
2381
|
: { repairLayers: config.repairLayers ?? previous.repairLayers }),
|
|
@@ -2470,6 +2532,11 @@ export class FECManager {
|
|
|
2470
2532
|
}
|
|
2471
2533
|
}
|
|
2472
2534
|
|
|
2535
|
+
/** Count a repair packet the router dropped for want of an owning track (BLO-55759). */
|
|
2536
|
+
countUnresolvedRepairOwner(reason: UnresolvedRepairOwnerReason): void {
|
|
2537
|
+
this.#unresolvedRepairOwnerDrops[reason]++
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2473
2540
|
get fecStats(): FecStats {
|
|
2474
2541
|
const s = this.#fecStats
|
|
2475
2542
|
const affected = s.blocksRecovered + s.blocksFailed
|
|
@@ -2516,6 +2583,7 @@ export class FECManager {
|
|
|
2516
2583
|
})),
|
|
2517
2584
|
repairSymbolSizeMismatches: this.#repairSymbolSizeMismatchCount,
|
|
2518
2585
|
unlistedRepairTrackRefusals: this.#unlistedRepairTrackRefusals,
|
|
2586
|
+
unresolvedRepairOwnerDrops: { ...this.#unresolvedRepairOwnerDrops },
|
|
2519
2587
|
repairObjectRejects: [...this.#repairObjectRejects.values()].map((r) => ({ ...r })),
|
|
2520
2588
|
workerErrors: Object.fromEntries(this.#workerErrorCounts),
|
|
2521
2589
|
}
|
|
@@ -2548,6 +2616,17 @@ export class FECManager {
|
|
|
2548
2616
|
this.#startupRepairFailOpenPackets.clear()
|
|
2549
2617
|
}
|
|
2550
2618
|
|
|
2619
|
+
/**
|
|
2620
|
+
* Start a new "mfu-datagram" leg (mmt-02 4.3.1) without discarding
|
|
2621
|
+
* track/decoder state: the same join-boundary rules as a multicast join,
|
|
2622
|
+
* since the leg starts at an arbitrary datagram too. It resets the whole
|
|
2623
|
+
* join boundary of this manager, a multicast ordered-relay frontier
|
|
2624
|
+
* included, so a host gives the leg a manager of its own.
|
|
2625
|
+
*/
|
|
2626
|
+
beginLegJoin(): void {
|
|
2627
|
+
this.beginMulticastJoin()
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2551
2630
|
/** How the multicast leg currently delivers symbols. */
|
|
2552
2631
|
get multicastSymbolDelivery(): MulticastSymbolDelivery {
|
|
2553
2632
|
return this.#multicastSymbolDelivery
|
|
@@ -2573,8 +2652,11 @@ export class FECManager {
|
|
|
2573
2652
|
}
|
|
2574
2653
|
if (delivery === this.#multicastSymbolDelivery) return
|
|
2575
2654
|
// A different delivery path: gaps measured on the old one say nothing
|
|
2576
|
-
// about it (and ordered-relay never feeds the estimator)
|
|
2577
|
-
|
|
2655
|
+
// about it (and ordered-relay never feeds the estimator), and a run
|
|
2656
|
+
// anchored on its receipts is not timed on the new one. The leg's
|
|
2657
|
+
// estimator is not the multicast provider's to reset.
|
|
2658
|
+
this.#deliveryGaps.multicast.reset()
|
|
2659
|
+
this.#runAnchors.clear()
|
|
2578
2660
|
if (delivery === 'ordered-relay') {
|
|
2579
2661
|
for (const [packetId, config] of this.#trackConfigs) {
|
|
2580
2662
|
this.#orderedHorizonBlocksFor(packetId, config)
|
|
@@ -2668,6 +2750,7 @@ export class FECManager {
|
|
|
2668
2750
|
resetMap(this.#highestSbn)
|
|
2669
2751
|
resetMap(this.#sourceFrontiers)
|
|
2670
2752
|
resetMap(this.#isoLocators)
|
|
2753
|
+
resetMap(this.#runAnchors)
|
|
2671
2754
|
resetMap(this.#sourceAnchors)
|
|
2672
2755
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName))
|
|
2673
2756
|
this.#noSpanRaps.delete(this.#streamKey(packetId, catalogTrackName))
|
|
@@ -2785,6 +2868,7 @@ export class FECManager {
|
|
|
2785
2868
|
dropMap(this.#highestSbn)
|
|
2786
2869
|
dropMap(this.#sourceFrontiers)
|
|
2787
2870
|
dropMap(this.#isoLocators)
|
|
2871
|
+
dropMap(this.#runAnchors)
|
|
2788
2872
|
dropMap(this.#sourceAnchors)
|
|
2789
2873
|
dropMap(this.#classifiers)
|
|
2790
2874
|
dropMap(this.#noSpanRaps)
|
|
@@ -2880,14 +2964,16 @@ export class FECManager {
|
|
|
2880
2964
|
this.#isoLocatorFor(packetId, catalogTrackName).blockAt(sbn)?.length ?? this.#trackConfig(packetId).k
|
|
2881
2965
|
const isSourceSymbol = esi >= 0 && esi < sourceSymbols
|
|
2882
2966
|
const isStartupPartial = this.#startupPartialBlocks.has(blockKey)
|
|
2967
|
+
// The join-boundary rules are about loss, so they hold on every lossy
|
|
2968
|
+
// path: a reliable MoQ symbol is never a join partial.
|
|
2883
2969
|
const isReadyMulticastRepair =
|
|
2884
2970
|
this.#startupRequireRepairReady &&
|
|
2885
|
-
source
|
|
2971
|
+
source !== 'moq' &&
|
|
2886
2972
|
!isSourceSymbol &&
|
|
2887
2973
|
this.#startupRepairReadyPackets.has(streamKey)
|
|
2888
2974
|
const awaitingMulticastRepair =
|
|
2889
2975
|
this.#startupRequireRepairReady &&
|
|
2890
|
-
source
|
|
2976
|
+
source !== 'moq' &&
|
|
2891
2977
|
!this.#startupRepairReadyPackets.has(streamKey) &&
|
|
2892
2978
|
!this.#startupRepairFailOpenPackets.has(streamKey)
|
|
2893
2979
|
if (awaitingMulticastRepair) {
|
|
@@ -2955,6 +3041,7 @@ export class FECManager {
|
|
|
2955
3041
|
...(catalogTrackName === undefined ? {} : { catalogTrackName }),
|
|
2956
3042
|
multicastSymbols: 0,
|
|
2957
3043
|
moqSymbols: 0,
|
|
3044
|
+
datagramSymbols: 0,
|
|
2958
3045
|
complete: false,
|
|
2959
3046
|
}
|
|
2960
3047
|
// The block's absolute anchor (fecBlockDeadlineMs): the receiver-local
|
|
@@ -2965,6 +3052,7 @@ export class FECManager {
|
|
|
2965
3052
|
const anchorMs = this.#blockAnchorsMs.get(blockKey)
|
|
2966
3053
|
if (anchorMs === undefined || receivedAtMs < anchorMs) this.#blockAnchorsMs.set(blockKey, receivedAtMs)
|
|
2967
3054
|
if (source === 'multicast') counts.multicastSymbols++
|
|
3055
|
+
else if (source === 'moq-datagram') counts.datagramSymbols++
|
|
2968
3056
|
else counts.moqSymbols++
|
|
2969
3057
|
this.#blockPathCounts.set(blockKey, counts)
|
|
2970
3058
|
this.#observeBlockCatalogTrackName(blockKey, sbn, packetId, catalogTrackName)
|
|
@@ -2990,7 +3078,7 @@ export class FECManager {
|
|
|
2990
3078
|
}
|
|
2991
3079
|
}
|
|
2992
3080
|
|
|
2993
|
-
if (isSourceSymbol && source
|
|
3081
|
+
if (isSourceSymbol && source !== 'moq') {
|
|
2994
3082
|
this.#noteMulticastSource(this.#isoLocatorFor(packetId, catalogTrackName), (sbn + esi) >>> 0, packetId, catalogTrackName)
|
|
2995
3083
|
}
|
|
2996
3084
|
|
|
@@ -3096,8 +3184,22 @@ export class FECManager {
|
|
|
3096
3184
|
* DeliveryGapEstimator). Datagram delivery only.
|
|
3097
3185
|
*/
|
|
3098
3186
|
noteMulticastArrival(packetId: number, packetSequenceNumber: number): void {
|
|
3099
|
-
|
|
3100
|
-
|
|
3187
|
+
this.noteArrival('multicast', packetId, packetSequenceNumber)
|
|
3188
|
+
}
|
|
3189
|
+
/**
|
|
3190
|
+
* Record one MMTP packet arrival on a lossy path for that path's
|
|
3191
|
+
* delivery-gap measurement: the multicast leg (datagram delivery only; an
|
|
3192
|
+
* ordered relay settles by stream order) or an "mfu-datagram" leg, whose
|
|
3193
|
+
* datagrams are always a lossy path (#lossyDatagramPath).
|
|
3194
|
+
*/
|
|
3195
|
+
noteArrival(path: DeliveryGapPath, packetId: number, packetSequenceNumber: number): void {
|
|
3196
|
+
if (!this.#lossyDatagramPath(path)) return
|
|
3197
|
+
this.#deliveryGaps[path].noteArrival(performance.now(), packetId, packetSequenceNumber)
|
|
3198
|
+
}
|
|
3199
|
+
/** The largest delivery gap any lossy path measured over its window. */
|
|
3200
|
+
#peakDeliveryGapMs(): number {
|
|
3201
|
+
const now = performance.now()
|
|
3202
|
+
return Math.max(...Object.values(this.#deliveryGaps).map((estimator) => estimator.peakGapMs(now)))
|
|
3101
3203
|
}
|
|
3102
3204
|
/**
|
|
3103
3205
|
* Resolved per-track multicast late-symbol wait in milliseconds: the span
|
|
@@ -3111,10 +3213,10 @@ export class FECManager {
|
|
|
3111
3213
|
* Largest multicast delivery gap measured over the current window (ms), and
|
|
3112
3214
|
* that window (undefined: held since the last reset). Diagnostics.
|
|
3113
3215
|
*/
|
|
3114
|
-
multicastDeliveryGap(): { peakGapMs: number; windowMs: number | undefined } {
|
|
3216
|
+
multicastDeliveryGap(path: DeliveryGapPath = 'multicast'): { peakGapMs: number; windowMs: number | undefined } {
|
|
3115
3217
|
return {
|
|
3116
|
-
peakGapMs: this.#deliveryGaps.peakGapMs(performance.now()),
|
|
3117
|
-
windowMs: this.#deliveryGaps.windowMs,
|
|
3218
|
+
peakGapMs: this.#deliveryGaps[path].peakGapMs(performance.now()),
|
|
3219
|
+
windowMs: this.#deliveryGaps[path].windowMs,
|
|
3118
3220
|
}
|
|
3119
3221
|
}
|
|
3120
3222
|
/**
|
|
@@ -3227,6 +3329,27 @@ export class FECManager {
|
|
|
3227
3329
|
const config = this.#trackConfigs.get(packetId)
|
|
3228
3330
|
return config === undefined ? undefined : this.#blockLifetimeMs(config)
|
|
3229
3331
|
}
|
|
3332
|
+
/**
|
|
3333
|
+
* How long an "mfu-datagram" leg's duplicate ledgers must remember a packet
|
|
3334
|
+
* so a legal reorder never reads as a publisher restart: one block span,
|
|
3335
|
+
* the reorder tolerance (`timeoutMs` is span + tolerance) and one group,
|
|
3336
|
+
* since a datagram may trail the stream by a whole group behind a joining
|
|
3337
|
+
* FETCH (mmt-02 6.1 step 3). The group is the catalog group duration
|
|
3338
|
+
* (`groupDurationMs`), whatever the track kind; a video track configured
|
|
3339
|
+
* without one falls back to its keyframe interval (one GOP per group).
|
|
3340
|
+
* Undefined for an unconfigured packet id.
|
|
3341
|
+
*/
|
|
3342
|
+
datagramLegLedgerRetentionMsForPacket(packetId: number): number | undefined {
|
|
3343
|
+
const config = this.#trackConfigs.get(packetId)
|
|
3344
|
+
if (config === undefined) return undefined
|
|
3345
|
+
const geometry = config.geometry
|
|
3346
|
+
const groupMs = config.groupDurationMs ?? (
|
|
3347
|
+
geometry?.trackKind === 'video' && geometry.mode === 'classifying'
|
|
3348
|
+
? (geometry.keyframeInterval.ticks / geometry.keyframeInterval.timescale) * 1000
|
|
3349
|
+
: 0
|
|
3350
|
+
)
|
|
3351
|
+
return config.timeoutMs + (Number.isFinite(groupMs) ? groupMs : 0)
|
|
3352
|
+
}
|
|
3230
3353
|
/**
|
|
3231
3354
|
* How long a terminal (clean, recovered or failed) block stays authoritative,
|
|
3232
3355
|
* for late symbols and for the in-order release gate. It is also the gate's
|
|
@@ -3305,6 +3428,9 @@ export class FECManager {
|
|
|
3305
3428
|
for (const key of [...this.#isoLocators.keys()]) {
|
|
3306
3429
|
if (this.#belongsToPacket(key, packetId)) this.#isoLocators.delete(key)
|
|
3307
3430
|
}
|
|
3431
|
+
for (const key of [...this.#runAnchors.keys()]) {
|
|
3432
|
+
if (this.#belongsToPacket(key, packetId)) this.#runAnchors.delete(key)
|
|
3433
|
+
}
|
|
3308
3434
|
}
|
|
3309
3435
|
|
|
3310
3436
|
/**
|
|
@@ -3368,9 +3494,9 @@ export class FECManager {
|
|
|
3368
3494
|
): boolean {
|
|
3369
3495
|
const locator = this.#growingIsoLocatorFor(packetId, catalogTrackName)
|
|
3370
3496
|
const evictedBefore = locator.heldEvicted
|
|
3371
|
-
const held = locator.hold(ssId, source)
|
|
3497
|
+
const held = locator.hold(ssId, source.arrivedAtMs === undefined ? { ...source, arrivedAtMs: this.#receiptNow() } : source)
|
|
3372
3498
|
this.#settleExpiredIsoHoles(locator, packetId, catalogTrackName)
|
|
3373
|
-
if (held && source.source
|
|
3499
|
+
if (held && source.source !== 'moq') this.#noteMulticastSource(locator, ssId, packetId, catalogTrackName)
|
|
3374
3500
|
const evicted = locator.heldEvicted - evictedBefore
|
|
3375
3501
|
if (evicted > 0) {
|
|
3376
3502
|
const before = this.#isoHeldEvictedCount
|
|
@@ -3527,7 +3653,12 @@ export class FECManager {
|
|
|
3527
3653
|
* Resolution of the SS_IDs strictly between two released frames' SS_IDs on
|
|
3528
3654
|
* an iso-ssbg1-v1 stream, for in-order frame release: null while a block
|
|
3529
3655
|
* that could hold them is pending or not yet stated by a repair, else the
|
|
3530
|
-
* starts of the blocks that failed or vanished.
|
|
3656
|
+
* starts of the blocks that failed or vanished. SS_IDs no repair has
|
|
3657
|
+
* delimited yet that all arrived lost nothing and wait for no repair, only
|
|
3658
|
+
* the late-source allowance after the datagram of a lossy path that clocks
|
|
3659
|
+
* them arrived (#lossFreeRunReadyAtMs), and not even that when none of them
|
|
3660
|
+
* came as one; one missing makes a run that waits as one block
|
|
3661
|
+
* (isoRepairlessWaitMs).
|
|
3531
3662
|
*
|
|
3532
3663
|
* `untracked` reads as the release gate reads it (MmtpRouter
|
|
3533
3664
|
* #createFecReleaseGate): a block holding either released frame's SS_ID
|
|
@@ -3545,7 +3676,19 @@ export class FECManager {
|
|
|
3545
3676
|
): readonly number[] | null {
|
|
3546
3677
|
if (!serial32Precedes(fromSsId, toSsId) || serial32Distance(fromSsId, toSsId) <= 1) return []
|
|
3547
3678
|
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))
|
|
3548
|
-
if (!locator
|
|
3679
|
+
if (!locator) return null
|
|
3680
|
+
// SS_IDs past coverage that all arrived lost nothing, so no repair need
|
|
3681
|
+
// delimit them; a run of them the receiver lacks is one block, which
|
|
3682
|
+
// isoRepairlessWaitMs times.
|
|
3683
|
+
const run = locator.undelimitedBetween(fromSsId, toSsId)
|
|
3684
|
+
if (run?.missing !== undefined) return null
|
|
3685
|
+
if (run !== null) {
|
|
3686
|
+
const config = this.#trackConfigs.get(packetId)
|
|
3687
|
+
const readyAtMs = config === undefined ? undefined : this.#lossFreeRunReadyAtMs(config, locator, run.start, toSsId)
|
|
3688
|
+
if (readyAtMs !== undefined && this.#receiptNow() < readyAtMs) return null
|
|
3689
|
+
}
|
|
3690
|
+
if (locator.coverageEnd === undefined) return []
|
|
3691
|
+
if (!locator.coversBetween(fromSsId, run?.start ?? toSsId)) return null
|
|
3549
3692
|
const highest = this.highestSbn(packetId, catalogTrackName)
|
|
3550
3693
|
const lost: number[] = []
|
|
3551
3694
|
for (const block of locator.blocksBetween(fromSsId, toSsId)) {
|
|
@@ -3567,6 +3710,71 @@ export class FECManager {
|
|
|
3567
3710
|
return lost
|
|
3568
3711
|
}
|
|
3569
3712
|
|
|
3713
|
+
/**
|
|
3714
|
+
* When undelimited SS_IDs from `runStart` up to `toSsId` that all arrived
|
|
3715
|
+
* stop holding its frame: the late-source allowance after the receipt of
|
|
3716
|
+
* a datagram of a lossy path (#lossyDatagramPath: a multicast datagram, or
|
|
3717
|
+
* one of an "mfu-datagram" leg). Until then a frame between them may still
|
|
3718
|
+
* complete from a packet with no SS_ID (an untagged FT=0/FT=1 reordered
|
|
3719
|
+
* behind the next frame), and a repair may delimit them. The receipt is
|
|
3720
|
+
* `toSsId`'s own when it is held from such a datagram. Otherwise (its
|
|
3721
|
+
* packet came only as an overlap copy or from a MoQ stream, or was evicted
|
|
3722
|
+
* or retired) it is the newest among those SS_IDs, every one of which is
|
|
3723
|
+
* held and states its path. So the time moves at most once, when the
|
|
3724
|
+
* head's own datagram copy arrives while its frame waits or its held
|
|
3725
|
+
* source is dropped, and never on a later ask.
|
|
3726
|
+
*
|
|
3727
|
+
* Undefined, so the range releases at once, when no SS_ID of it came as
|
|
3728
|
+
* such a datagram: a MoQ arrival, an ordered relay's and the frame's own
|
|
3729
|
+
* are no clock for datagram reordering (#lossyReceiptMs). Undefined too
|
|
3730
|
+
* on a track with no catalog span, which states no allowance: the local
|
|
3731
|
+
* timeout is a cleanup bound, and isoRepairlessWaitMs arms no wake there,
|
|
3732
|
+
* so a wait would hold the frame until the next packet. The cost, on
|
|
3733
|
+
* multicast and on the leg too: an untagged FT=0/FT=1 reordered behind
|
|
3734
|
+
* the next frame of such a track is dropped stale.
|
|
3735
|
+
*/
|
|
3736
|
+
#lossFreeRunReadyAtMs(
|
|
3737
|
+
config: ResolvedFECTrackConfig,
|
|
3738
|
+
locator: IsoBlockLocator<IsoHeldSource>,
|
|
3739
|
+
runStart: number,
|
|
3740
|
+
toSsId: number,
|
|
3741
|
+
): number | undefined {
|
|
3742
|
+
if (!FECManager.#hasCatalogTiming(config)) return undefined
|
|
3743
|
+
let clockMs = this.#lossyReceiptMs(locator.heldSource(toSsId))
|
|
3744
|
+
if (clockMs === undefined) {
|
|
3745
|
+
for (let ssId = runStart; ssId !== toSsId; ssId = (ssId + 1) >>> 0) {
|
|
3746
|
+
const atMs = this.#lossyReceiptMs(locator.heldSource(ssId))
|
|
3747
|
+
if (atMs !== undefined && (clockMs === undefined || atMs > clockMs)) clockMs = atMs
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
if (clockMs === undefined) return undefined
|
|
3751
|
+
return clockMs + Math.max(0, this.#multicastWaitMs(config) - config.interleaveDepthMs)
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3754
|
+
/**
|
|
3755
|
+
* Receipt time of a held source that came as a datagram of a lossy path
|
|
3756
|
+
* (#lossyDatagramPath), else undefined: a MoQ stream and an ordered relay
|
|
3757
|
+
* deliver in order, so their arrivals clock no reorder allowance and no
|
|
3758
|
+
* FEC deadline. The path is the one the feed stated (IsoHeldSource.source,
|
|
3759
|
+
* and MulticastSymbolDelivery for a multicast source), never a guess.
|
|
3760
|
+
*/
|
|
3761
|
+
#lossyReceiptMs(held: IsoHeldSource | undefined): number | undefined {
|
|
3762
|
+
return held !== undefined && this.#lossyDatagramPath(held.source) ? held.arrivedAtMs : undefined
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3765
|
+
/**
|
|
3766
|
+
* The one path predicate of the loss gates: whether a symbol fed as
|
|
3767
|
+
* `source` reached this manager as a datagram of its own, on a path that
|
|
3768
|
+
* loses and reorders (mmt-02 Section 2, a datagram leg). A multicast
|
|
3769
|
+
* symbol does unless its provider declared an ordered relay. An
|
|
3770
|
+
* "mfu-datagram" object always does (4.3.1): MulticastSymbolDelivery is
|
|
3771
|
+
* the multicast provider's statement and is never read for the leg. A MoQ
|
|
3772
|
+
* stream object never does, a stream copy of the leg included.
|
|
3773
|
+
*/
|
|
3774
|
+
#lossyDatagramPath(source: FecSymbolSource): boolean {
|
|
3775
|
+
return source === 'moq-datagram' || (source === 'multicast' && this.#multicastSymbolDelivery === 'datagram')
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3570
3778
|
/**
|
|
3571
3779
|
* The release gate's wait, from a frame's arrival, for the SS_IDs strictly
|
|
3572
3780
|
* between two released frames' SS_IDs once only a late source can still
|
|
@@ -3574,10 +3782,11 @@ export class FECManager {
|
|
|
3574
3782
|
* arrived nor held) lies in a repair-less span longer than K, which no
|
|
3575
3783
|
* repair can state a block of (#openIsoSpan), or in a stated block its
|
|
3576
3784
|
* 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
|
|
3578
|
-
*
|
|
3579
|
-
*
|
|
3580
|
-
*
|
|
3785
|
+
* between them (so the gap's decision covers all it lost), and a source of
|
|
3786
|
+
* a lossy leg (multicast, or an "mfu-datagram" leg's datagram) at or past
|
|
3787
|
+
* `toSsId` arrived, so each is lost or reordered behind it (a MoQ source
|
|
3788
|
+
* shows nothing: MoQ streams overtake one another). The span or block
|
|
3789
|
+
* itself keeps its own wait.
|
|
3581
3790
|
*
|
|
3582
3791
|
* The wait is the late-symbol allowance, unless `rapMayHide`: the gap may
|
|
3583
3792
|
* hold a RAP packet an installed keyframe overlay can still rebuild (its
|
|
@@ -3588,6 +3797,20 @@ export class FECManager {
|
|
|
3588
3797
|
* for an overlay that states no span, the span's whole wait (undefined).
|
|
3589
3798
|
* So does `rapNext` (the gap ends at the RAP that opens the next MPU) when
|
|
3590
3799
|
* the gap holds a stated block's loss.
|
|
3800
|
+
*
|
|
3801
|
+
* A run of SS_IDs no repair has delimited yet, one of which never arrived,
|
|
3802
|
+
* is one block of its own instead (draft-ramadan-moq-fec-multicast-00,
|
|
3803
|
+
* Receiver Repair Policy; on an "mfu-datagram" leg fec-core-00 9.3 and
|
|
3804
|
+
* mmt-02 5.3.3): the frame then waits for that block's FEC deadline,
|
|
3805
|
+
* whatever the flags: ts plus the whole multicast wait (fec-core-00 9.3),
|
|
3806
|
+
* ts the receipt of the lowest held source above the run that came as a
|
|
3807
|
+
* datagram of a lossy path (#lossyDatagramPath), up to the newest
|
|
3808
|
+
* (fec-multicast-00, Deadline Anchoring; under reordering at or after the
|
|
3809
|
+
* draft's first signal, never before). The wait returned counts from
|
|
3810
|
+
* `arrivedAtMs`, the frame's arrival; without it, it is the whole wait.
|
|
3811
|
+
* With no such source held (never arrived, retired, or evicted, or every
|
|
3812
|
+
* one from a MoQ stream or an ordered relay) the frame keeps the hold
|
|
3813
|
+
* ceiling: a stream arrival is no clock for a datagram deadline.
|
|
3591
3814
|
*/
|
|
3592
3815
|
isoRepairlessWaitMs(
|
|
3593
3816
|
packetId: number,
|
|
@@ -3596,13 +3819,63 @@ export class FECManager {
|
|
|
3596
3819
|
toSsId: number,
|
|
3597
3820
|
rapMayHide = false,
|
|
3598
3821
|
rapNext = false,
|
|
3822
|
+
arrivedAtMs?: number,
|
|
3599
3823
|
): number | undefined {
|
|
3600
3824
|
const config = this.#trackConfigs.get(packetId)
|
|
3601
3825
|
if (config === undefined || !FECManager.#hasCatalogTiming(config)) return undefined
|
|
3602
|
-
const
|
|
3603
|
-
|
|
3826
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName)
|
|
3827
|
+
const locator = this.#isoLocators.get(streamKey)
|
|
3828
|
+
if (locator === undefined) return undefined
|
|
3829
|
+
const run = locator.undelimitedBetween(fromSsId, toSsId)
|
|
3830
|
+
const readyAtMs = run === null || run.missing !== undefined ? undefined : this.#lossFreeRunReadyAtMs(config, locator, run.start, toSsId)
|
|
3831
|
+
if (readyAtMs !== undefined && this.#receiptNow() < readyAtMs) {
|
|
3832
|
+
return Math.max(0, readyAtMs - (arrivedAtMs ?? this.#receiptNow()))
|
|
3833
|
+
}
|
|
3604
3834
|
const newestSource = locator.newestSource
|
|
3605
3835
|
if (newestSource === undefined || serial32Precedes(newestSource, toSsId)) return undefined
|
|
3836
|
+
// A run past coverage the receiver lacks an SS_ID of is one block of the
|
|
3837
|
+
// instance. A repair may delimit it until its FEC deadline, so once the
|
|
3838
|
+
// delimited SS_IDs before it resolved the frame waits for that deadline,
|
|
3839
|
+
// longer than any overlay wait. Only a held datagram of a lossy path
|
|
3840
|
+
// anchors it (#lossyReceiptMs): an overlap copy is never held, and a MoQ
|
|
3841
|
+
// stream overtakes the others. A multicast source on an ordered relay is
|
|
3842
|
+
// none either, so the scan below finds no ts there and the frame keeps
|
|
3843
|
+
// the hold ceiling, as a pause there says nothing of loss. The delivery
|
|
3844
|
+
// mode is not read here on its own: it is the multicast provider's
|
|
3845
|
+
// statement, and would deny an "mfu-datagram" leg's run its deadline.
|
|
3846
|
+
// Settle a run by stream order (#withinOrderedHorizon) if a relay ever
|
|
3847
|
+
// runs without repair.
|
|
3848
|
+
if (run?.missing !== undefined) {
|
|
3849
|
+
if (this.isoSpanResolution(packetId, catalogTrackName, fromSsId, run.start) === null) return undefined
|
|
3850
|
+
// An anchor older than twice the hold ceiling is another run's: the
|
|
3851
|
+
// gate flushes a frame at the ceiling, so the same `from` SS_ID came
|
|
3852
|
+
// again (a publisher restart that reuses SS_IDs, or the 2^32 wrap).
|
|
3853
|
+
const kept = this.#runAnchors.get(streamKey)
|
|
3854
|
+
const anchor =
|
|
3855
|
+
kept?.fromSsId === fromSsId &&
|
|
3856
|
+
this.#receiptNow() - kept.tsMs <= 2 * (config.interleaveDepthMs + 2 * this.#blockLifetimeMs(config))
|
|
3857
|
+
? kept
|
|
3858
|
+
: undefined
|
|
3859
|
+
let tsMs = anchor?.tsMs
|
|
3860
|
+
for (let ssId = (run.missing + 1) >>> 0; !serial32Precedes(newestSource, ssId); ssId = (ssId + 1) >>> 0) {
|
|
3861
|
+
const atMs = this.#lossyReceiptMs(locator.heldSource(ssId))
|
|
3862
|
+
if (atMs === undefined) continue
|
|
3863
|
+
if (tsMs === undefined || atMs < tsMs) tsMs = atMs
|
|
3864
|
+
break
|
|
3865
|
+
}
|
|
3866
|
+
if (tsMs === undefined) return undefined
|
|
3867
|
+
const waitMs = this.#multicastWaitMs(config)
|
|
3868
|
+
let counted = anchor?.counted === true
|
|
3869
|
+
if (!counted && tsMs + waitMs <= this.#receiptNow()) {
|
|
3870
|
+
counted = true
|
|
3871
|
+
this.onUndelimitedRunGap?.(packetId, catalogTrackName)
|
|
3872
|
+
}
|
|
3873
|
+
this.#runAnchors.set(streamKey, { fromSsId, tsMs, counted })
|
|
3874
|
+
return arrivedAtMs === undefined ? waitMs : Math.max(0, tsMs + waitMs - arrivedAtMs)
|
|
3875
|
+
}
|
|
3876
|
+
// SS_IDs past coverage that all arrived hold no loss, so they wait for no
|
|
3877
|
+
// repair to delimit them.
|
|
3878
|
+
if (!locator.coversBetween(fromSsId, run?.start ?? toSsId)) return undefined
|
|
3606
3879
|
let repairless = false
|
|
3607
3880
|
let stated = false
|
|
3608
3881
|
for (const block of locator.blocksBetween(fromSsId, toSsId)) {
|
|
@@ -3724,11 +3997,43 @@ export class FECManager {
|
|
|
3724
3997
|
* it does not. A stream with no classifier yet has shown nothing against it,
|
|
3725
3998
|
* and neither has a stream without catalog timing until it releases two
|
|
3726
3999
|
* RAPs inside one MPU.
|
|
4000
|
+
*
|
|
4001
|
+
* With catalog timing and a `gap` inside one MPU, between the authored
|
|
4002
|
+
* timing of the frames on either side, it also takes the catalog keyframe
|
|
4003
|
+
* interval to rule a keyframe out of the gap
|
|
4004
|
+
* (`BlockClassifier.keyframeFreeBetween`, fec-multicast-00 Block
|
|
4005
|
+
* Classification item 3), and no source held between the frames' SS_IDs
|
|
4006
|
+
* may carry the RAP flag or another MPU's number (item 1 read on the held
|
|
4007
|
+
* packets: a RAP the loss cut in two is never released, so the frames
|
|
4008
|
+
* alone cannot show it); anything unknown counts as a keyframe.
|
|
3727
4009
|
*/
|
|
3728
|
-
mpuBoundsRapsFor(
|
|
4010
|
+
mpuBoundsRapsFor(
|
|
4011
|
+
packetId: number,
|
|
4012
|
+
catalogTrackName?: string,
|
|
4013
|
+
gap?: {
|
|
4014
|
+
readonly mpu: number
|
|
4015
|
+
readonly from?: AuthoredTiming
|
|
4016
|
+
readonly to?: AuthoredTiming
|
|
4017
|
+
readonly fromSsId?: number
|
|
4018
|
+
readonly toSsId?: number
|
|
4019
|
+
},
|
|
4020
|
+
): boolean {
|
|
3729
4021
|
const streamKey = this.#streamKey(packetId, catalogTrackName)
|
|
3730
4022
|
if (!this.#hasCatalogTimingForPacket(packetId)) return this.#noSpanRaps.get(streamKey)?.inside !== true
|
|
3731
|
-
|
|
4023
|
+
const classifier = this.#classifiers.get(streamKey)
|
|
4024
|
+
if (gap === undefined) return classifier?.mpuBoundsRaps ?? true
|
|
4025
|
+
const { mpu, from, to, fromSsId, toSsId } = gap
|
|
4026
|
+
if (fromSsId !== undefined && toSsId !== undefined) {
|
|
4027
|
+
const run = this.#isoLocators.get(streamKey)?.undelimitedBetween(
|
|
4028
|
+
fromSsId,
|
|
4029
|
+
toSsId,
|
|
4030
|
+
({ evidence }) => evidence.rap || (evidence.mpu !== undefined && evidence.mpu !== mpu),
|
|
4031
|
+
)
|
|
4032
|
+
if (run?.flagged) return false
|
|
4033
|
+
}
|
|
4034
|
+
return classifier !== undefined && from !== undefined && to !== undefined &&
|
|
4035
|
+
from.mediaTimescale === to.mediaTimescale &&
|
|
4036
|
+
classifier.keyframeFreeBetween(mpu, from.decodeTime, to.decodeTime, from.mediaTimescale)
|
|
3732
4037
|
}
|
|
3733
4038
|
|
|
3734
4039
|
/** A block's class now, or frozen at its resolution. */
|
|
@@ -3755,7 +4060,9 @@ export class FECManager {
|
|
|
3755
4060
|
|
|
3756
4061
|
/**
|
|
3757
4062
|
* Record a RAP frame released in order, for the classifier's RAP-spacing
|
|
3758
|
-
* invariant (consecutive MPUs exactly one keyframe interval apart)
|
|
4063
|
+
* invariant (consecutive MPUs exactly one keyframe interval apart) and,
|
|
4064
|
+
* with its decode time, as the MPU start gap decisions measure the catalog
|
|
4065
|
+
* keyframe interval from (mpuBoundsRapsFor).
|
|
3759
4066
|
*/
|
|
3760
4067
|
noteReleasedRap(
|
|
3761
4068
|
packetId: number,
|
|
@@ -3763,6 +4070,7 @@ export class FECManager {
|
|
|
3763
4070
|
mpu: number,
|
|
3764
4071
|
presentationTime: bigint,
|
|
3765
4072
|
mediaTimescale: number,
|
|
4073
|
+
decodeTime?: bigint,
|
|
3766
4074
|
): void {
|
|
3767
4075
|
if (!this.#trackConfigs.has(packetId)) return
|
|
3768
4076
|
if (!this.#hasCatalogTimingForPacket(packetId)) {
|
|
@@ -3780,6 +4088,7 @@ export class FECManager {
|
|
|
3780
4088
|
mpu,
|
|
3781
4089
|
presentationTime,
|
|
3782
4090
|
mediaTimescale,
|
|
4091
|
+
decodeTime,
|
|
3783
4092
|
),
|
|
3784
4093
|
)
|
|
3785
4094
|
}
|
|
@@ -4740,9 +5049,11 @@ export class FECManager {
|
|
|
4740
5049
|
* its sources in send order, so one that moves the stream's newest source
|
|
4741
5050
|
* position past a block leaves the sources that block still misses
|
|
4742
5051
|
* 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:
|
|
4744
|
-
* can overtake one another, so a MoQ source shows nothing
|
|
4745
|
-
* sent before it.
|
|
5052
|
+
* passed that only a late source can complete. Reliable MoQ is left out:
|
|
5053
|
+
* its streams can overtake one another, so a MoQ source shows nothing
|
|
5054
|
+
* about the sources sent before it. An "mfu-datagram" leg is in: its
|
|
5055
|
+
* datagrams leave the publisher in send order and reorder only within the
|
|
5056
|
+
* path's tolerance, as multicast does.
|
|
4746
5057
|
*/
|
|
4747
5058
|
#noteMulticastSource(
|
|
4748
5059
|
locator: IsoBlockLocator<IsoHeldSource>,
|
|
@@ -5387,7 +5698,7 @@ export class FECManager {
|
|
|
5387
5698
|
): MmtpDeliveryProvenance {
|
|
5388
5699
|
const counts = this.blockPathCount(sbn, packetId, catalogTrackName)
|
|
5389
5700
|
if (!counts) return 'unknown'
|
|
5390
|
-
if (counts.moqSymbols > 0) return 'mixed'
|
|
5701
|
+
if (counts.moqSymbols > 0 || counts.datagramSymbols > 0) return 'mixed'
|
|
5391
5702
|
if (counts.multicastSymbols > 0) return 'multicast'
|
|
5392
5703
|
return 'unknown'
|
|
5393
5704
|
}
|
|
@@ -5422,7 +5733,7 @@ export class FECManager {
|
|
|
5422
5733
|
this.#activeBlockDeadlinesMs.clear()
|
|
5423
5734
|
this.#blockWaitDeadlinesMs.clear()
|
|
5424
5735
|
this.#repairHoldUntilMs.clear()
|
|
5425
|
-
this.#deliveryGaps.reset()
|
|
5736
|
+
for (const estimator of Object.values(this.#deliveryGaps)) estimator.reset()
|
|
5426
5737
|
this.#pendingWorkerCleanups.clear()
|
|
5427
5738
|
this.#pendingWorkerCleanupClients.clear()
|
|
5428
5739
|
for (const bound of this.#pendingWorkerCleanupBounds.values()) clearTimeout(bound.handle)
|
|
@@ -5473,6 +5784,7 @@ export class FECManager {
|
|
|
5473
5784
|
this.#highestSbn.clear()
|
|
5474
5785
|
this.#sourceFrontiers.clear()
|
|
5475
5786
|
this.#isoLocators.clear()
|
|
5787
|
+
this.#runAnchors.clear()
|
|
5476
5788
|
this.#sourceAnchors.clear()
|
|
5477
5789
|
this.#trackConfigs.clear()
|
|
5478
5790
|
this.#fecDecoders.clear()
|