@blockcast/mmt-container 0.4.0 → 0.4.1-main.22841c1f0a2d
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 +37 -21
- package/dist/align.d.ts +24 -18
- package/dist/align.d.ts.map +1 -1
- package/dist/align.js +23 -4
- package/dist/align.js.map +2 -2
- package/dist/browser-runtime.js +2037 -881
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +76 -39
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +321 -205
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +28 -7
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/cmcd-producer.d.ts +13 -1
- package/dist/cmcd-producer.d.ts.map +1 -1
- package/dist/cmcd-producer.js +14 -0
- package/dist/cmcd-producer.js.map +2 -2
- package/dist/delivery-catalog.js +98 -234
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +108 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +452 -66
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +10 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -4
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/held-layer-admission.d.ts +58 -0
- package/dist/held-layer-admission.d.ts.map +1 -0
- package/dist/held-layer-admission.js +105 -0
- package/dist/held-layer-admission.js.map +7 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -1
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +109 -17
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +21 -13
- package/dist/mfu-reassembler.js.map +2 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +93 -22
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +3677 -1213
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +93 -22
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-fec-session.d.ts +192 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +640 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +69 -32
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +296 -192
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +313 -124
- package/dist/multicast-auth-catalog.js.map +3 -3
- package/dist/multicast-input.d.ts +31 -8
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +299 -35
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +97 -11
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1022 -527
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +12 -2
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +108 -238
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +21 -13
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +5 -3
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +3625 -1194
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +81 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +156 -31
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- package/dist/sample-combiner.d.ts +7 -1
- package/dist/sample-combiner.d.ts.map +1 -1
- package/dist/sample-combiner.js +14 -2
- package/dist/sample-combiner.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +21 -13
- package/dist/timestamp-codec.js.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js +93 -22
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -18
- package/schemas/catalog.schema.json +133 -38
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +188 -68
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +49 -7
- package/src/catalog-validator.ts +4 -11
- package/src/cmcd-producer.ts +23 -1
- package/src/fec-manager.ts +366 -63
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +30 -2
- package/src/held-layer-admission.ts +161 -0
- package/src/index.ts +32 -19
- package/src/iso-block-locator.ts +110 -7
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +606 -0
- package/src/mmtp-router.ts +301 -240
- package/src/multicast-auth-catalog.ts +134 -238
- package/src/multicast-input.ts +148 -124
- package/src/multicast-manager.ts +271 -40
- package/src/multicast-transport.ts +17 -3
- package/src/no-modules.ts +8 -7
- package/src/phase14-catalog-override.ts +3 -3
- package/src/repair-fetch.ts +283 -39
- package/src/repair-layers.ts +22 -2
- package/src/sample-combiner.ts +15 -2
- package/src/signaling.ts +2 -2
- package/src/switching-set-alignment.ts +1 -1
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1526 -0
- package/test-vectors/catalog/README.md +71 -4
- package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
- package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
- package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
- package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
- package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
- package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
- package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
- package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
- package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
- package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
- package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
- package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
- package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
- package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
- package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
- package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
- package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
- package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
- package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
- package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
- package/test-vectors/catalog/positive/fec-multicast.json +1 -1
- package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
- package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
- package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
- package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
- package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
- package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
- package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
- package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
- package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
- package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +31 -1
- package/test-vectors/catalog-multicast-auth-v1.json +38 -20
- package/test-vectors/catalog-validation.json +101 -5
- package/test-vectors/catalog-validator-public-api.mjs +14 -9
- package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
- package/dist/fec-codec.d.ts +0 -32
- package/dist/fec-codec.d.ts.map +0 -1
- package/dist/fec-codec.js +0 -47
- package/dist/fec-codec.js.map +0 -7
- package/dist/manifest-auth-plan.d.ts +0 -30
- package/dist/manifest-auth-plan.d.ts.map +0 -1
- package/dist/manifest-auth-plan.js +0 -1266
- package/dist/manifest-auth-plan.js.map +0 -7
- package/dist/source-auth.d.ts +0 -2
- package/dist/source-auth.d.ts.map +0 -1
- package/dist/source-auth.js +0 -1209
- package/dist/source-auth.js.map +0 -7
- package/src/fec-codec.ts +0 -61
- package/src/manifest-auth-plan.ts +0 -107
- package/src/source-auth.ts +0 -1
- package/test-vectors/generate-source-auth-fixture.mjs +0 -114
- package/test-vectors/source-auth-v1.json +0 -61
package/src/fec-manager.ts
CHANGED
|
@@ -27,7 +27,12 @@ import {
|
|
|
27
27
|
ssbg1FitsSymbol,
|
|
28
28
|
type FecBlockProfile,
|
|
29
29
|
} from '@blockcast/mmt-base'
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
IsoBlockLocator,
|
|
32
|
+
type IsoBlockRange,
|
|
33
|
+
type IsoPlacedSource,
|
|
34
|
+
type IsoRepairPlacement,
|
|
35
|
+
} from './iso-block-locator.js'
|
|
31
36
|
import { MIN_INTERLEAVE_DEPTH_MS } from './fec-state.js'
|
|
32
37
|
import {
|
|
33
38
|
BlockClassifier,
|
|
@@ -41,6 +46,7 @@ import {
|
|
|
41
46
|
type TrackKind,
|
|
42
47
|
} from './block-policy.js'
|
|
43
48
|
|
|
49
|
+
import { HeldLayerAdmission, heldLayerAnchorHorizon, type FecFailClosedReason } from './held-layer-admission.js'
|
|
44
50
|
import type { MmtpDeliveryProvenance } from './mfu-reassembler.js'
|
|
45
51
|
import type {
|
|
46
52
|
FecWorkerClient,
|
|
@@ -54,6 +60,9 @@ import type {
|
|
|
54
60
|
// Constants
|
|
55
61
|
// ---------------------------------------------------------------------------
|
|
56
62
|
|
|
63
|
+
/** fec-01 4.5: a GF(2^8) reed-solomon block holds at most 255 symbols. */
|
|
64
|
+
const RS_MAX_BLOCK_SYMBOLS = 255
|
|
65
|
+
|
|
57
66
|
// MIN_INTERLEAVE_DEPTH_MS lives with the catalog FEC predicate that also
|
|
58
67
|
// needs it (fec-state.ts); re-exported here for existing importers.
|
|
59
68
|
export { MIN_INTERLEAVE_DEPTH_MS }
|
|
@@ -156,6 +165,25 @@ export interface IsoHeldSource {
|
|
|
156
165
|
readonly oversized: boolean
|
|
157
166
|
}
|
|
158
167
|
|
|
168
|
+
/**
|
|
169
|
+
* A lost SS_ID in an undelimited span (draft-ramadan-moq-fec §7.5): a repair
|
|
170
|
+
* stated a block past SS_IDs whose every repair symbol was lost and at least
|
|
171
|
+
* one source too. They wait as a pending hole `[holeStart, holeStart +
|
|
172
|
+
* holeLength)` for a range repair FETCH.
|
|
173
|
+
*/
|
|
174
|
+
export interface UndelimitedIsoLoss {
|
|
175
|
+
readonly packetId: number
|
|
176
|
+
readonly catalogTrackName: string | undefined
|
|
177
|
+
readonly holeStart: number
|
|
178
|
+
readonly holeLength: number
|
|
179
|
+
/** The highest SS_ID in the hole no source arrived for: the §7.5 x. */
|
|
180
|
+
readonly lostSsId: number
|
|
181
|
+
/** K: the catalog `sourceSymbols`, the largest SSB_length. */
|
|
182
|
+
readonly kMax: number
|
|
183
|
+
/** 32-bit SS_Start of the stated block that ends where the hole starts (S_prev). */
|
|
184
|
+
readonly previousBlockStart?: number
|
|
185
|
+
}
|
|
186
|
+
|
|
159
187
|
/**
|
|
160
188
|
* How the multicast leg hands its symbols to this manager.
|
|
161
189
|
*
|
|
@@ -224,6 +252,11 @@ export interface FECManagerConfig {
|
|
|
224
252
|
* is refused.
|
|
225
253
|
*/
|
|
226
254
|
blockProfile?: FecBlockProfile
|
|
255
|
+
/**
|
|
256
|
+
* The catalog `fec.algorithm` (`TrackFecParams.fecAlgorithm`). Defaults to
|
|
257
|
+
* RaptorQ. Reed-Solomon bounds every block to 255 symbols (fec-01 4.5).
|
|
258
|
+
*/
|
|
259
|
+
algorithm?: 'raptorq' | 'reed-solomon'
|
|
227
260
|
k?: number
|
|
228
261
|
/** Symbol size in bytes (T). NOT repair count. */
|
|
229
262
|
symbolSize?: number
|
|
@@ -241,10 +274,35 @@ export interface FECManagerConfig {
|
|
|
241
274
|
* block `unknown` (fail-closed: protected).
|
|
242
275
|
*/
|
|
243
276
|
geometry?: BlockClassifierGeometry
|
|
277
|
+
/**
|
|
278
|
+
* fec-01 6.3.9: the source track's base repair layers (catalog
|
|
279
|
+
* `TrackFecParams.repairLayers`). Layer i's held total is
|
|
280
|
+
* B_i = rsIdOffset + repairSymbols. Absent: no anchored check.
|
|
281
|
+
*/
|
|
282
|
+
repairLayers?: readonly FecRepairLayer[]
|
|
283
|
+
/** The base layers this receiver holds. Defaults to layer 0 alone. */
|
|
284
|
+
heldLayers?: readonly number[]
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** One base repair layer, as `assembleRepairLayers` resolves it. */
|
|
288
|
+
export interface FecRepairLayer {
|
|
289
|
+
layer: number
|
|
290
|
+
repairTrackName: string
|
|
291
|
+
rsIdOffset: number
|
|
292
|
+
repairSymbols: number
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export type { FecFailClosedReason } from './held-layer-admission.js'
|
|
296
|
+
|
|
297
|
+
/** A {@link FecFailClosedReason} with the stream it closed, as reported to the fail-closed handler. */
|
|
298
|
+
export interface FecFailClosedEvent extends FecFailClosedReason {
|
|
299
|
+
packetId: number
|
|
300
|
+
catalogTrackName: string | undefined
|
|
244
301
|
}
|
|
245
302
|
|
|
246
303
|
interface ResolvedFECTrackConfig {
|
|
247
304
|
blockProfile?: FecBlockProfile
|
|
305
|
+
algorithm?: 'raptorq' | 'reed-solomon'
|
|
248
306
|
k: number
|
|
249
307
|
symbolSize: number
|
|
250
308
|
interleaveDepthMs: number
|
|
@@ -253,6 +311,8 @@ interface ResolvedFECTrackConfig {
|
|
|
253
311
|
trackKind?: TrackKind
|
|
254
312
|
codec?: string
|
|
255
313
|
geometry?: BlockClassifierGeometry
|
|
314
|
+
repairLayers?: readonly FecRepairLayer[]
|
|
315
|
+
heldLayers?: readonly number[]
|
|
256
316
|
}
|
|
257
317
|
|
|
258
318
|
/** Which symbol path completed a short block. */
|
|
@@ -450,6 +510,11 @@ export class FECManager {
|
|
|
450
510
|
// RSB_length per block (C.5.3 Repair FEC Payload ID): how many repair
|
|
451
511
|
// symbols its repair group carries. Same lifecycle as #blockRepairRsIds.
|
|
452
512
|
#blockRsbLengths = new Map<string, number>()
|
|
513
|
+
/** fec-01 6.3.9 anchor state per stream key, one entry per held layer. */
|
|
514
|
+
#heldLayerStates = new Map<string, HeldLayerAdmission>()
|
|
515
|
+
/** Streams whose FEC failed closed at runtime (fec-01 6.3.9). */
|
|
516
|
+
#fecFailClosed = new Map<string, FecFailClosedReason>()
|
|
517
|
+
#onFecFailClosed: ((event: FecFailClosedEvent) => void) | null = null
|
|
453
518
|
// Blocks already recovered — prevents late source symbols from restarting timeouts.
|
|
454
519
|
// WASM removes blocks after recovery; late symbols create empty blocks returning null,
|
|
455
520
|
// which would falsely start new timeouts without this guard.
|
|
@@ -572,12 +637,17 @@ export class FECManager {
|
|
|
572
637
|
// per stream. Not only throws: the ordinary out-of-range case is detected by
|
|
573
638
|
// arithmetic and never throws at all.
|
|
574
639
|
#orderedHorizonWarnedFor = new Set<number>()
|
|
575
|
-
// Newest block start (SS_Start)
|
|
576
|
-
//
|
|
640
|
+
// Newest block start (SS_Start) any symbol carried per stream and when: the
|
|
641
|
+
// frontier isoSpanResolution reads.
|
|
577
642
|
#highestSbn = new Map<string, { sbn: number; atMs: number }>()
|
|
643
|
+
// The same from source symbols alone: the frontier a source is judged
|
|
644
|
+
// against for a discontinuity. Repairs ride their own group, which can run
|
|
645
|
+
// blocks ahead of the media they protect.
|
|
646
|
+
#sourceFrontiers = new Map<string, { sbn: number; atMs: number }>()
|
|
578
647
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
579
648
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
580
649
|
#isoLocators = new Map<string, IsoBlockLocator<IsoHeldSource>>()
|
|
650
|
+
#deferIsoGaps = false
|
|
581
651
|
#isoRepairRefusedCount = 0
|
|
582
652
|
#isoSourceOversizeCount = 0
|
|
583
653
|
// Held sources a locator's capacity cap evicted (IsoBlockLocator.heldCapacity):
|
|
@@ -592,9 +662,9 @@ export class FECManager {
|
|
|
592
662
|
// rate-limited like the other per-symbol warns here. Cumulative.
|
|
593
663
|
#isoDecoderUnplacedRetireFailed = 0
|
|
594
664
|
// The latest source symbol per stream that carried its MMTP
|
|
595
|
-
// packet_sequence_number: the anchor that bounds how
|
|
596
|
-
// producer can have
|
|
597
|
-
#sourceAnchors = new Map<string, {
|
|
665
|
+
// packet_sequence_number, by its own SS_ID: the anchor that bounds how far
|
|
666
|
+
// the producer's SS_IDs can have moved before or after another source symbol.
|
|
667
|
+
#sourceAnchors = new Map<string, { ssId: number; psn: number; atMs: number }>()
|
|
598
668
|
// Catalog/reset epoch per packetId. Gap decisions carry it for fencing.
|
|
599
669
|
#packetEpochs = new Map<number, number>()
|
|
600
670
|
|
|
@@ -708,6 +778,14 @@ export class FECManager {
|
|
|
708
778
|
reason: ClassifierReason | null,
|
|
709
779
|
) => void)
|
|
710
780
|
| null = null
|
|
781
|
+
/**
|
|
782
|
+
* A repair stated a block past a gap that is missing a source and whose
|
|
783
|
+
* every repair was lost: a lost SS_ID in an undelimited span
|
|
784
|
+
* (draft-ramadan-moq-fec §7.5). Set with `setUndelimitedLossHandler`; the
|
|
785
|
+
* receiver keeps the gap as a pending hole until `closeIsoHoles` is called
|
|
786
|
+
* for it, which it must be.
|
|
787
|
+
*/
|
|
788
|
+
#onUndelimitedLoss: ((loss: UndelimitedIsoLoss) => void) | null = null
|
|
711
789
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
712
790
|
onBlockVanished:
|
|
713
791
|
| ((sbn: number, packetId: number, catalogTrackName: string | undefined) => void)
|
|
@@ -1509,8 +1587,8 @@ export class FECManager {
|
|
|
1509
1587
|
// Deliberately one block tighter than deriveFecRetentionBlocks over the same
|
|
1510
1588
|
// inputs (that function's `+ 1`). Different question: the retention horizon
|
|
1511
1589
|
// asks how long the decoder still ACCEPTS symbols for a block, this asks how
|
|
1512
|
-
// many blocks a stream can
|
|
1513
|
-
//
|
|
1590
|
+
// many blocks a stream can jump ahead of its frontier before a source symbol
|
|
1591
|
+
// there is a discontinuity rather than loss (see #noteSbnSeen).
|
|
1514
1592
|
// The extra block of retention is slack for a block still being fed; a block
|
|
1515
1593
|
// nothing has been heard from does not get it. Not the units defect — but it
|
|
1516
1594
|
// is the next place the two can drift, so change both or neither.
|
|
@@ -1521,23 +1599,28 @@ export class FECManager {
|
|
|
1521
1599
|
|
|
1522
1600
|
/**
|
|
1523
1601
|
* Record that a symbol for block `sbn` (the block's SS_Start) arrived and
|
|
1524
|
-
* advance the stream's
|
|
1602
|
+
* advance the stream's frontiers, the newest block start seen.
|
|
1525
1603
|
*
|
|
1526
|
-
* A SOURCE symbol
|
|
1527
|
-
*
|
|
1528
|
-
*
|
|
1604
|
+
* A SOURCE symbol is judged against the newest source block alone: repairs
|
|
1605
|
+
* ride their own group, which can run blocks ahead of the media. One whose
|
|
1606
|
+
* block goes back further than the blocks this manager retains, or that
|
|
1607
|
+
* cannot have been sent before the source it lies behind, or that jumps
|
|
1608
|
+
* further than the stream could have produced since its last symbol, is a
|
|
1609
|
+
* source discontinuity, not loss. A repair symbol can only advance the
|
|
1529
1610
|
* frontier: a D-28 fetch legitimately answers for an old block, so it never
|
|
1530
1611
|
* signals a discontinuity.
|
|
1531
1612
|
*
|
|
1532
1613
|
* The producer closes a block at its Dth media-unit boundary OR when K
|
|
1533
1614
|
* source symbols filled it, so one interleave span can start several blocks
|
|
1534
|
-
* (every large keyframe does). What bounds a
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
1538
|
-
* packet_sequence_number
|
|
1539
|
-
*
|
|
1540
|
-
*
|
|
1615
|
+
* (every large keyframe does). What bounds a jump is therefore packet
|
|
1616
|
+
* evidence, not a block rate: SS_ID advances by one per FEC source packet
|
|
1617
|
+
* (ISO/IEC 23008-1 C.5.2) and the MMTP packet_sequence_number by one per
|
|
1618
|
+
* packet of the packet_id, so with both source symbols'
|
|
1619
|
+
* packet_sequence_number their SS_IDs (`ssId`, not their block starts,
|
|
1620
|
+
* which a repair-less span can put far behind) can move at most the packets
|
|
1621
|
+
* sent between them, in either direction, plus K of slack for sources lost
|
|
1622
|
+
* before a hop that renumbers packets. Without it, only the D-close rate is
|
|
1623
|
+
* known.
|
|
1541
1624
|
*
|
|
1542
1625
|
* Vanished blocks are not enumerated here: their starts are unknown until a
|
|
1543
1626
|
* repair states them. The SS_IDs between two stated blocks become one
|
|
@@ -1549,10 +1632,11 @@ export class FECManager {
|
|
|
1549
1632
|
catalogTrackName: string | undefined,
|
|
1550
1633
|
symbol: 'source' | 'repair',
|
|
1551
1634
|
packetSequenceNumber?: number,
|
|
1635
|
+
ssId = sbn,
|
|
1552
1636
|
): void {
|
|
1553
1637
|
const streamKey = this.#streamKey(packetId, catalogTrackName)
|
|
1554
1638
|
const now = performance.now()
|
|
1555
|
-
const previous = this.#highestSbn.get(streamKey)
|
|
1639
|
+
const previous = (symbol === 'source' ? this.#sourceFrontiers : this.#highestSbn).get(streamKey)
|
|
1556
1640
|
const anchor = this.#sourceAnchors.get(streamKey)
|
|
1557
1641
|
const psn = symbol === 'source' &&
|
|
1558
1642
|
packetSequenceNumber !== undefined &&
|
|
@@ -1562,29 +1646,46 @@ export class FECManager {
|
|
|
1562
1646
|
? packetSequenceNumber
|
|
1563
1647
|
: undefined
|
|
1564
1648
|
const anchorHere = (): void => {
|
|
1565
|
-
if (psn !== undefined && (anchor === undefined || !
|
|
1566
|
-
this.#sourceAnchors.set(streamKey, {
|
|
1649
|
+
if (psn !== undefined && (anchor === undefined || !serial32Precedes(ssId, anchor.ssId))) {
|
|
1650
|
+
this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now })
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
const advance = (): void => {
|
|
1654
|
+
const highest = this.#highestSbn.get(streamKey)
|
|
1655
|
+
if (highest === undefined || this.#blockPrecedes(highest.sbn, sbn)) {
|
|
1656
|
+
this.#highestSbn.set(streamKey, { sbn, atMs: now })
|
|
1567
1657
|
}
|
|
1658
|
+
if (symbol === 'source') this.#sourceFrontiers.set(streamKey, { sbn, atMs: now })
|
|
1659
|
+
anchorHere()
|
|
1568
1660
|
}
|
|
1569
1661
|
const discontinuity = (): void => {
|
|
1570
1662
|
// The classifier compares authored order with SBN order only within
|
|
1571
1663
|
// one continuous SBN sequence.
|
|
1572
1664
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity()
|
|
1573
1665
|
this.#highestSbn.set(streamKey, { sbn, atMs: now })
|
|
1666
|
+
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now })
|
|
1574
1667
|
if (psn === undefined) this.#sourceAnchors.delete(streamKey)
|
|
1575
|
-
else this.#sourceAnchors.set(streamKey, {
|
|
1668
|
+
else this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now })
|
|
1576
1669
|
this.onSourceDiscontinuity?.(packetId, catalogTrackName)
|
|
1577
1670
|
}
|
|
1578
1671
|
if (previous === undefined) {
|
|
1579
|
-
|
|
1580
|
-
anchorHere()
|
|
1672
|
+
advance()
|
|
1581
1673
|
return
|
|
1582
1674
|
}
|
|
1583
1675
|
const config = this.#trackConfig(packetId)
|
|
1584
1676
|
const window = this.#liveWindowBlocks(config)
|
|
1677
|
+
// Packets sent from `from` to `to`, serial arithmetic (RFC 1982): more
|
|
1678
|
+
// than half the space means it went backwards.
|
|
1679
|
+
const sentInOrder = (from: { ssId: number; psn: number }, to: { ssId: number; psn: number }): boolean => {
|
|
1680
|
+
const sent = (to.psn - from.psn) >>> 0
|
|
1681
|
+
return sent <= 0x7fff_ffff && serial32Distance(from.ssId, to.ssId) <= sent + config.k
|
|
1682
|
+
}
|
|
1585
1683
|
if (!this.#blockPrecedes(previous.sbn, sbn)) {
|
|
1586
|
-
if (symbol === 'source' && window !== null &&
|
|
1587
|
-
|
|
1684
|
+
if (symbol === 'source' && window !== null && this.#blockPrecedes(sbn, previous.sbn) && (
|
|
1685
|
+
this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId) ||
|
|
1686
|
+
(psn !== undefined && anchor !== undefined && serial32Precedes(ssId, anchor.ssId) &&
|
|
1687
|
+
psn !== anchor.psn && !sentInOrder({ ssId, psn }, anchor))
|
|
1688
|
+
)) {
|
|
1588
1689
|
discontinuity()
|
|
1589
1690
|
return
|
|
1590
1691
|
}
|
|
@@ -1598,15 +1699,8 @@ export class FECManager {
|
|
|
1598
1699
|
// producer that does not maintain it); only then is the D-close rate
|
|
1599
1700
|
// the whole bound.
|
|
1600
1701
|
if (psn !== undefined && anchor !== undefined &&
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
// plus the anchor's own offset into its block (< K). Packets sent
|
|
1604
|
-
// from the anchor packet to this one, serial arithmetic (RFC 1982):
|
|
1605
|
-
// more than half the space means it went backwards.
|
|
1606
|
-
const sent = (psn - anchor.psn) >>> 0
|
|
1607
|
-
plausible =
|
|
1608
|
-
sent <= 0x7fff_ffff &&
|
|
1609
|
-
serial32Distance(anchor.sbn, sbn) <= sent + config.k
|
|
1702
|
+
serial32Precedes(anchor.ssId, ssId) && psn !== anchor.psn) {
|
|
1703
|
+
plausible = sentInOrder(anchor, { ssId, psn })
|
|
1610
1704
|
} else {
|
|
1611
1705
|
plausible = missing <= window + Math.ceil((now - previous.atMs) / config.interleaveDepthMs)
|
|
1612
1706
|
}
|
|
@@ -1616,8 +1710,7 @@ export class FECManager {
|
|
|
1616
1710
|
discontinuity()
|
|
1617
1711
|
return
|
|
1618
1712
|
}
|
|
1619
|
-
|
|
1620
|
-
anchorHere()
|
|
1713
|
+
advance()
|
|
1621
1714
|
}
|
|
1622
1715
|
|
|
1623
1716
|
/*
|
|
@@ -2054,8 +2147,10 @@ export class FECManager {
|
|
|
2054
2147
|
)
|
|
2055
2148
|
}
|
|
2056
2149
|
const hasCatalogTiming = FECManager.#hasCatalogTiming({ interleaveDepthMs: ownInterleaveDepthMs })
|
|
2150
|
+
const algorithm = config.algorithm ?? previous.algorithm
|
|
2057
2151
|
const next: ResolvedFECTrackConfig = {
|
|
2058
2152
|
blockProfile,
|
|
2153
|
+
...(algorithm === undefined ? {} : { algorithm }),
|
|
2059
2154
|
k,
|
|
2060
2155
|
symbolSize:
|
|
2061
2156
|
config.symbolSize != null && config.symbolSize > 0
|
|
@@ -2073,6 +2168,23 @@ export class FECManager {
|
|
|
2073
2168
|
...((config.geometry ?? previous.geometry) === undefined
|
|
2074
2169
|
? {}
|
|
2075
2170
|
: { geometry: config.geometry ?? previous.geometry }),
|
|
2171
|
+
...((config.repairLayers ?? previous.repairLayers) === undefined
|
|
2172
|
+
? {}
|
|
2173
|
+
: { repairLayers: config.repairLayers ?? previous.repairLayers }),
|
|
2174
|
+
...((config.heldLayers ?? previous.heldLayers) === undefined
|
|
2175
|
+
? {}
|
|
2176
|
+
: { heldLayers: config.heldLayers ?? previous.heldLayers }),
|
|
2177
|
+
}
|
|
2178
|
+
if (
|
|
2179
|
+
// By content: a catalog refresh rebuilds equal arrays, and forgetting
|
|
2180
|
+
// the anchors on one would fail open.
|
|
2181
|
+
JSON.stringify(next.repairLayers) !== JSON.stringify(previous.repairLayers) ||
|
|
2182
|
+
JSON.stringify(next.heldLayers) !== JSON.stringify(previous.heldLayers)
|
|
2183
|
+
) {
|
|
2184
|
+
// A different layer set is a different set of totals to anchor.
|
|
2185
|
+
for (const key of [...this.#heldLayerStates.keys()]) {
|
|
2186
|
+
if (this.#belongsToPacket(key, packetId)) this.#heldLayerStates.delete(key)
|
|
2187
|
+
}
|
|
2076
2188
|
}
|
|
2077
2189
|
if (!hasCatalogTiming) {
|
|
2078
2190
|
// A missing/zero span has no catalog deadline. Keep an explicitly
|
|
@@ -2375,6 +2487,8 @@ export class FECManager {
|
|
|
2375
2487
|
resetMap(this.#blockAuthoredLengths)
|
|
2376
2488
|
resetMap(this.#blockRepairRsIds)
|
|
2377
2489
|
resetMap(this.#blockRsbLengths)
|
|
2490
|
+
resetMap(this.#heldLayerStates)
|
|
2491
|
+
resetMap(this.#fecFailClosed)
|
|
2378
2492
|
resetMap(this.#blockPathCounts)
|
|
2379
2493
|
resetMap(this.#blockAnchorsMs)
|
|
2380
2494
|
resetMap(this.#blockCatalogTrackNames)
|
|
@@ -2397,6 +2511,7 @@ export class FECManager {
|
|
|
2397
2511
|
resetSet(this.#materializedBlocks)
|
|
2398
2512
|
resetMap(this.#resolvedBlockClasses)
|
|
2399
2513
|
resetMap(this.#highestSbn)
|
|
2514
|
+
resetMap(this.#sourceFrontiers)
|
|
2400
2515
|
resetMap(this.#isoLocators)
|
|
2401
2516
|
resetMap(this.#sourceAnchors)
|
|
2402
2517
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName))
|
|
@@ -2510,6 +2625,7 @@ export class FECManager {
|
|
|
2510
2625
|
dropMap(this.#orderedPendingBlocks)
|
|
2511
2626
|
dropMap(this.#resolvedBlockClasses)
|
|
2512
2627
|
dropMap(this.#highestSbn)
|
|
2628
|
+
dropMap(this.#sourceFrontiers)
|
|
2513
2629
|
dropMap(this.#isoLocators)
|
|
2514
2630
|
dropMap(this.#sourceAnchors)
|
|
2515
2631
|
dropMap(this.#classifiers)
|
|
@@ -2642,7 +2758,11 @@ export class FECManager {
|
|
|
2642
2758
|
this.#startupPartialBlocks.delete(blockKey)
|
|
2643
2759
|
this.#startupAlignedPackets.add(streamKey)
|
|
2644
2760
|
} else if (
|
|
2645
|
-
|
|
2761
|
+
// A ready multicast repair opens a block the join has not seen yet, never
|
|
2762
|
+
// a join partial: its sources were refused, so its repairs alone open a
|
|
2763
|
+
// block that cannot decode and fails at its deadline, once per packet ID
|
|
2764
|
+
// per join (BLO-48308).
|
|
2765
|
+
isStartupPartial ||
|
|
2646
2766
|
(!this.#startupAlignedPackets.has(streamKey) && !isReadyMulticastRepair)
|
|
2647
2767
|
) {
|
|
2648
2768
|
this.#markStartupPartial(blockKey)
|
|
@@ -2981,6 +3101,7 @@ export class FECManager {
|
|
|
2981
3101
|
let locator = this.#isoLocators.get(streamKey)
|
|
2982
3102
|
if (!locator) {
|
|
2983
3103
|
locator = new IsoBlockLocator<IsoHeldSource>(this.#trackConfig(packetId).k, this.#isoRetentionBlocks(packetId))
|
|
3104
|
+
locator.deferIncompleteGaps = this.#deferIsoGaps
|
|
2984
3105
|
this.#isoLocators.set(streamKey, locator)
|
|
2985
3106
|
}
|
|
2986
3107
|
return locator
|
|
@@ -3028,6 +3149,11 @@ export class FECManager {
|
|
|
3028
3149
|
return blocks
|
|
3029
3150
|
}
|
|
3030
3151
|
|
|
3152
|
+
/** The iso-ssbg1-v1 locator horizon of a configured packetId, in blocks (#isoRetentionBlocks). */
|
|
3153
|
+
isoRetentionBlocksForPacket(packetId: number): number | undefined {
|
|
3154
|
+
return this.#hasBlockProfile(packetId) ? this.#isoRetentionBlocks(packetId) : undefined
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3031
3157
|
/** Whether an iso-ssbg1-v1 protected packet fits one ssbg_mode1 symbol (len + 2 <= T). */
|
|
3032
3158
|
isoSourceFits(packetId: number, packetLength: number): boolean {
|
|
3033
3159
|
const symbolSize = this.#trackConfigs.get(packetId)?.symbolSize
|
|
@@ -3095,23 +3221,74 @@ export class FECManager {
|
|
|
3095
3221
|
}
|
|
3096
3222
|
return placement
|
|
3097
3223
|
}
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
const
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3224
|
+
if (placement.span !== undefined) this.#openIsoSpan(placement.span, packetId, catalogTrackName)
|
|
3225
|
+
if (placement.hole !== undefined) {
|
|
3226
|
+
const locator = this.#isoLocatorFor(packetId, catalogTrackName)
|
|
3227
|
+
const hole = placement.hole.block
|
|
3228
|
+
const previous = locator.blockEndingAt(hole.start)
|
|
3229
|
+
const loss: UndelimitedIsoLoss = {
|
|
3230
|
+
packetId,
|
|
3231
|
+
catalogTrackName,
|
|
3232
|
+
holeStart: hole.start,
|
|
3233
|
+
holeLength: hole.length,
|
|
3234
|
+
lostSsId: placement.hole.lostSsId,
|
|
3235
|
+
kMax: this.#trackConfig(packetId).k,
|
|
3236
|
+
...(previous === undefined ? {} : { previousBlockStart: previous.start }),
|
|
3237
|
+
}
|
|
3238
|
+
this.#onUndelimitedLoss!(loss)
|
|
3111
3239
|
}
|
|
3112
3240
|
return placement
|
|
3113
3241
|
}
|
|
3114
3242
|
|
|
3243
|
+
/**
|
|
3244
|
+
* Keep an iso-ssbg1-v1 gap missing a source as a pending hole, reported to
|
|
3245
|
+
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
3246
|
+
* range repair scheduler; applies to every stream from its next gap. The
|
|
3247
|
+
* handler and the deferral are one setting, so no hole is ever created with
|
|
3248
|
+
* nobody to close it.
|
|
3249
|
+
*/
|
|
3250
|
+
setUndelimitedLossHandler(handler: ((loss: UndelimitedIsoLoss) => void) | null): void {
|
|
3251
|
+
this.#onUndelimitedLoss = handler
|
|
3252
|
+
this.#deferIsoGaps = handler !== null
|
|
3253
|
+
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
/**
|
|
3257
|
+
* The range repair for a hole ended: every hole still pending inside
|
|
3258
|
+
* `[start, start + length)` becomes a repair-less span. Returns those spans
|
|
3259
|
+
* with the held sources they placed, for the caller to feed (MmtpRouter).
|
|
3260
|
+
*/
|
|
3261
|
+
closeIsoHoles(
|
|
3262
|
+
packetId: number,
|
|
3263
|
+
catalogTrackName: string | undefined,
|
|
3264
|
+
start: number,
|
|
3265
|
+
length: number,
|
|
3266
|
+
): { block: IsoBlockRange; placed: IsoPlacedSource<IsoHeldSource>[] }[] {
|
|
3267
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))
|
|
3268
|
+
if (locator === undefined) return []
|
|
3269
|
+
const spans = locator.closeHolesWithin(start, length)
|
|
3270
|
+
for (const span of spans) this.#openIsoSpan(span, packetId, catalogTrackName)
|
|
3271
|
+
return spans
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
/**
|
|
3275
|
+
* A repair-less span has no repair to state its length, so it is known
|
|
3276
|
+
* here: its sources make it clean exactly when all of them arrived. A
|
|
3277
|
+
* stated block learns its SSB_length from its own repair symbol, fed after
|
|
3278
|
+
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
3279
|
+
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
3280
|
+
* block.
|
|
3281
|
+
*/
|
|
3282
|
+
#openIsoSpan(
|
|
3283
|
+
span: { readonly block: IsoBlockRange; readonly placed: readonly unknown[] },
|
|
3284
|
+
packetId: number,
|
|
3285
|
+
catalogTrackName: string | undefined,
|
|
3286
|
+
): void {
|
|
3287
|
+
const key = this.#blockKey(span.block.start, packetId, catalogTrackName)
|
|
3288
|
+
if (!this.#blockAuthoredLengths.has(key)) this.#blockAuthoredLengths.set(key, span.block.length)
|
|
3289
|
+
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true)
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3115
3292
|
/**
|
|
3116
3293
|
* Resolution of the SS_IDs strictly between two released frames' SS_IDs on
|
|
3117
3294
|
* an iso-ssbg1-v1 stream, for in-order frame release: null while a block
|
|
@@ -3820,6 +3997,131 @@ export class FECManager {
|
|
|
3820
3997
|
return recovered
|
|
3821
3998
|
}
|
|
3822
3999
|
|
|
4000
|
+
/**
|
|
4001
|
+
* fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
|
|
4002
|
+
* exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
|
|
4003
|
+
* block state unchanged. The router calls this before the repair places a
|
|
4004
|
+
* block or takes any other part in block bookkeeping. A RaptorQ track admits
|
|
4005
|
+
* every header that parsed (its RS_ID < RSB_length check is in the parser).
|
|
4006
|
+
*/
|
|
4007
|
+
admitRepairBlockLength(
|
|
4008
|
+
packetId: number,
|
|
4009
|
+
ssbLength: number,
|
|
4010
|
+
rsbLength: number,
|
|
4011
|
+
rsId: number,
|
|
4012
|
+
): boolean {
|
|
4013
|
+
if (rsId >= rsbLength) return false
|
|
4014
|
+
if (this.#trackConfigs.get(packetId)?.algorithm !== 'reed-solomon') return true
|
|
4015
|
+
return ssbLength + rsbLength <= RS_MAX_BLOCK_SYMBOLS
|
|
4016
|
+
}
|
|
4017
|
+
|
|
4018
|
+
/**
|
|
4019
|
+
* Whether a repair symbol of `byteLength` bytes is a valid member of a
|
|
4020
|
+
* `packetId` block: every repair symbol is exactly the track's T. A symbol of
|
|
4021
|
+
* any other size is counted on `repairSymbolSizeMismatches`, warned (rate
|
|
4022
|
+
* limited) and refused. The router calls this before the symbol takes any
|
|
4023
|
+
* other part in block state (placement, first-arrival dedup, completed-block
|
|
4024
|
+
* accounting), so a malformed repair is counted whatever its arrival order:
|
|
4025
|
+
* judged after dedup, one landing on an already-complete block, or behind a
|
|
4026
|
+
* valid copy from the other transport, was swallowed as a duplicate and never
|
|
4027
|
+
* counted (BLO-48306). A packetId with no configured block profile admits
|
|
4028
|
+
* nothing here; its repair is dropped upstream as unreadable.
|
|
4029
|
+
*/
|
|
4030
|
+
admitRepairSymbolSize(
|
|
4031
|
+
packetId: number,
|
|
4032
|
+
ssStart: number,
|
|
4033
|
+
ssbLength: number,
|
|
4034
|
+
rsId: number,
|
|
4035
|
+
byteLength: number,
|
|
4036
|
+
): boolean {
|
|
4037
|
+
if (!this.#hasBlockProfile(packetId)) return false
|
|
4038
|
+
const symbolSize = this.#trackConfig(packetId).symbolSize
|
|
4039
|
+
if (symbolSize > 0 && byteLength !== symbolSize) {
|
|
4040
|
+
this.#repairSymbolSizeMismatchCount++
|
|
4041
|
+
if (this.#repairSymbolSizeMismatchCount <= 5 || this.#repairSymbolSizeMismatchCount % 100 === 0) {
|
|
4042
|
+
console.warn(
|
|
4043
|
+
`[FECManager] Dropping repair symbol with invalid size: got ${byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`,
|
|
4044
|
+
)
|
|
4045
|
+
}
|
|
4046
|
+
return false
|
|
4047
|
+
}
|
|
4048
|
+
return true
|
|
4049
|
+
}
|
|
4050
|
+
|
|
4051
|
+
/**
|
|
4052
|
+
* fec-01 6.3.9 receiver check, run on a repair packet after the 4.5 discard
|
|
4053
|
+
* and the size check, before it places a block. For each held layer i with
|
|
4054
|
+
* total B_i = O_i + P_i: the anchor is the earliest block, in SS_Start
|
|
4055
|
+
* serial order, whose repair carried RSB_length >= B_i. The source track
|
|
4056
|
+
* fails closed on (a) a packet on layer i's own repair track (i > 0) below
|
|
4057
|
+
* B_i, or (b) any packet of the instance at or after the anchor below B_i.
|
|
4058
|
+
* Blocks before the anchor (pre-append) stay valid at the previous total. A
|
|
4059
|
+
* packet on a repair track the catalog does not list is discarded and
|
|
4060
|
+
* anchors nothing. `repairTrackName` is the subscribed repair track, never
|
|
4061
|
+
* inferred from RS_ID; without it only (b) runs. Returns false when the
|
|
4062
|
+
* repair must be dropped, including every repair once the track failed.
|
|
4063
|
+
*/
|
|
4064
|
+
admitRepairLayerTotal(
|
|
4065
|
+
packetId: number,
|
|
4066
|
+
catalogTrackName: string | undefined,
|
|
4067
|
+
repairTrackName: string | undefined,
|
|
4068
|
+
ssStart: number,
|
|
4069
|
+
rsbLength: number,
|
|
4070
|
+
): boolean {
|
|
4071
|
+
const streamKey = this.#streamKey(packetId, catalogTrackName)
|
|
4072
|
+
if (this.#fecFailClosed.has(streamKey)) return false
|
|
4073
|
+
const config = this.#trackConfigs.get(packetId)
|
|
4074
|
+
const layers = config?.repairLayers
|
|
4075
|
+
if (layers === undefined || layers.length === 0) return true
|
|
4076
|
+
let admission = this.#heldLayerStates.get(streamKey)
|
|
4077
|
+
if (admission === undefined) {
|
|
4078
|
+
admission = new HeldLayerAdmission(layers, config!.heldLayers)
|
|
4079
|
+
this.#heldLayerStates.set(streamKey, admission)
|
|
4080
|
+
}
|
|
4081
|
+
const verdict = admission.admit(
|
|
4082
|
+
repairTrackName,
|
|
4083
|
+
ssStart,
|
|
4084
|
+
rsbLength,
|
|
4085
|
+
this.#layerAnchorHorizon(packetId),
|
|
4086
|
+
this.#sourceFrontiers.get(streamKey)?.sbn,
|
|
4087
|
+
)
|
|
4088
|
+
if (verdict === 'discard') return false
|
|
4089
|
+
if (verdict !== undefined) {
|
|
4090
|
+
this.#fecFailClosed.set(streamKey, verdict)
|
|
4091
|
+
this.#onFecFailClosed?.({ ...verdict, packetId, catalogTrackName })
|
|
4092
|
+
console.warn(
|
|
4093
|
+
`[FECManager] FEC failed closed (fec-01 6.3.9) packetId=${packetId} track=${catalogTrackName ?? '-'}: ${JSON.stringify(verdict)}`,
|
|
4094
|
+
)
|
|
4095
|
+
return false
|
|
4096
|
+
}
|
|
4097
|
+
return true
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
/**
|
|
4101
|
+
* How far (in SS_Start symbols) behind the newest block a 6.3.9 anchor or
|
|
4102
|
+
* below-total block can still matter: the iso locator's retention in blocks
|
|
4103
|
+
* times K, capped at 2^30 so compared serials stay inside one half-window.
|
|
4104
|
+
*/
|
|
4105
|
+
#layerAnchorHorizon(packetId: number): number {
|
|
4106
|
+
let blocks: number | undefined
|
|
4107
|
+
try { blocks = this.isoRetentionBlocksForPacket(packetId) } catch { blocks = undefined }
|
|
4108
|
+
return heldLayerAnchorHorizon(blocks, this.#trackConfigs.get(packetId)?.k ?? 0)
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
/**
|
|
4112
|
+
* Report each stream whose FEC fails closed at runtime (fec-01 6.3.9), once,
|
|
4113
|
+
* when it does; null stops reporting. The player wiring forwards it to
|
|
4114
|
+
* CmcdProducer.updateFecFailClosed.
|
|
4115
|
+
*/
|
|
4116
|
+
setFecFailClosedHandler(handler: ((event: FecFailClosedEvent) => void) | null): void {
|
|
4117
|
+
this.#onFecFailClosed = handler
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
/** The runtime fail-closed reason of a stream's FEC (fec-01 6.3.9), if any. */
|
|
4121
|
+
fecFailClosedReason(packetId: number, catalogTrackName?: string): FecFailClosedReason | undefined {
|
|
4122
|
+
return this.#fecFailClosed.get(this.#streamKey(packetId, catalogTrackName))
|
|
4123
|
+
}
|
|
4124
|
+
|
|
3823
4125
|
/**
|
|
3824
4126
|
* Feed a repair symbol to the WASM FEC decoder.
|
|
3825
4127
|
*
|
|
@@ -3840,16 +4142,7 @@ export class FECManager {
|
|
|
3840
4142
|
// A packetId with no configured block profile has no block geometry: its
|
|
3841
4143
|
// repair names no block this manager can track or decode.
|
|
3842
4144
|
if (!this.#hasBlockProfile(packetId)) return null
|
|
3843
|
-
|
|
3844
|
-
if (symbolSize > 0 && repairData.byteLength !== symbolSize) {
|
|
3845
|
-
this.#repairSymbolSizeMismatchCount++
|
|
3846
|
-
if (this.#repairSymbolSizeMismatchCount <= 5 || this.#repairSymbolSizeMismatchCount % 100 === 0) {
|
|
3847
|
-
console.warn(
|
|
3848
|
-
`[FECManager] Dropping repair symbol with invalid size: got ${repairData.byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`,
|
|
3849
|
-
)
|
|
3850
|
-
}
|
|
3851
|
-
return null
|
|
3852
|
-
}
|
|
4145
|
+
if (!this.admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, repairData.byteLength)) return null
|
|
3853
4146
|
const fecData = repairData
|
|
3854
4147
|
|
|
3855
4148
|
// ISO/IEC 23008-1 C.5.3: the block is [SS_Start, SS_Start + SSB_length),
|
|
@@ -4072,7 +4365,14 @@ export class FECManager {
|
|
|
4072
4365
|
// Skip blocks already recovered — late source symbols must not restart timeouts
|
|
4073
4366
|
if (this.#completedBlocks.has(key)) return
|
|
4074
4367
|
|
|
4075
|
-
this.#noteSbnSeen(
|
|
4368
|
+
this.#noteSbnSeen(
|
|
4369
|
+
sbn,
|
|
4370
|
+
packetId,
|
|
4371
|
+
catalogTrackName,
|
|
4372
|
+
'source',
|
|
4373
|
+
evidence.packetSequenceNumber,
|
|
4374
|
+
Number.isInteger(esi) ? (sbn + esi) >>> 0 : sbn,
|
|
4375
|
+
)
|
|
4076
4376
|
|
|
4077
4377
|
// A source ESI at or past the block's authored SSB_length contradicts it;
|
|
4078
4378
|
// its geometry can no longer be trusted, so fail it closed.
|
|
@@ -4386,6 +4686,8 @@ export class FECManager {
|
|
|
4386
4686
|
this.#blockAuthoredLengths.clear()
|
|
4387
4687
|
this.#blockRepairRsIds.clear()
|
|
4388
4688
|
this.#blockRsbLengths.clear()
|
|
4689
|
+
this.#heldLayerStates.clear()
|
|
4690
|
+
this.#fecFailClosed.clear()
|
|
4389
4691
|
this.#completedBlocks.clear()
|
|
4390
4692
|
this.#cleanlyCompletedBlocks.clear()
|
|
4391
4693
|
this.#repairRequestedBlocks.clear()
|
|
@@ -4410,6 +4712,7 @@ export class FECManager {
|
|
|
4410
4712
|
this.#repairedBlocks.clear()
|
|
4411
4713
|
this.#materializedBlocks.clear()
|
|
4412
4714
|
this.#highestSbn.clear()
|
|
4715
|
+
this.#sourceFrontiers.clear()
|
|
4413
4716
|
this.#isoLocators.clear()
|
|
4414
4717
|
this.#sourceAnchors.clear()
|
|
4415
4718
|
this.#trackConfigs.clear()
|