@blockcast/mmt-container 0.4.0-main.bb90ce9247fa → 0.4.0-main.bbdfdbf39ded
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 +36 -20
- 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 +1721 -705
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +72 -34
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +309 -204
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +15 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +137 -50
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/catalog-network-source.d.ts +24 -2
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +24 -1
- package/dist/catalog-network-source.js.map +3 -3
- 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/delivery-catalog.js +100 -230
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +64 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +275 -62
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +5 -3
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +34 -12
- package/dist/fec-state.js.map +4 -4
- package/dist/fec-worker-setup.d.ts +2 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +15 -3
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +29 -0
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +100 -17
- package/dist/iso-block-locator.js.map +4 -4
- package/dist/manifest-auth-plan.d.ts +26 -25
- package/dist/manifest-auth-plan.d.ts.map +1 -1
- package/dist/manifest-auth-plan.js +331 -1171
- package/dist/manifest-auth-plan.js.map +4 -4
- package/dist/mfu-reassembler.js +24 -13
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +96 -22
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +1138 -325
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +96 -22
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-fec-session.d.ts +159 -0
- package/dist/mmtp-fec-session.d.ts.map +1 -0
- package/dist/mmtp-fec-session.js +531 -0
- package/dist/mmtp-fec-session.js.map +7 -0
- package/dist/mmtp-router.d.ts +31 -5
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +168 -22
- package/dist/mmtp-router.js.map +3 -3
- 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 +347 -132
- package/dist/multicast-auth-catalog.js.map +4 -4
- package/dist/multicast-input.d.ts +28 -6
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +293 -28
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +89 -5
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +730 -356
- 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 +111 -235
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +24 -13
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.d.ts +4 -1
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +1087 -309
- 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 +159 -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 +22 -2
- package/dist/repair-layers.js.map +3 -3
- 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 +6 -3
- package/dist/signaling.js.map +3 -3
- package/dist/source-auth.js +2710 -7
- package/dist/source-auth.js.map +4 -4
- package/dist/switching-set-alignment.d.ts +1 -1
- package/dist/switching-set-alignment.js.map +1 -1
- package/dist/timestamp-codec.js +24 -13
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +3 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +96 -22
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +6 -9
- package/schemas/catalog.schema.json +124 -37
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +163 -61
- package/src/catalog-fec-params.ts +66 -20
- package/src/catalog-network-source.ts +45 -2
- package/src/catalog-validator.ts +4 -11
- package/src/fec-manager.ts +239 -63
- package/src/fec-state.ts +14 -12
- package/src/fec-worker-setup.ts +20 -2
- package/src/index.ts +29 -10
- package/src/iso-block-locator.ts +97 -6
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-container-parser.ts +75 -7
- package/src/mmtp-fec-session.ts +533 -0
- package/src/mmtp-router.ts +133 -5
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +119 -61
- package/src/multicast-manager.ts +258 -21
- package/src/multicast-transport.ts +17 -3
- package/src/no-modules.ts +7 -1
- 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 +65 -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-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 +2 -2
- 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 +30 -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/src/fec-codec.ts +0 -61
|
@@ -12,10 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
import { DEFAULT_AMT_RELAY_PORT } from "@blockcast/mmt-base";
|
|
14
14
|
|
|
15
|
-
/** One `networkSource[]` entry as published (`{type, discovery?, relay, port?}`). */
|
|
15
|
+
/** One `networkSource[]` entry as published (AMT `{type, discovery?, relay, port?}` or ATSC3). */
|
|
16
16
|
export type CatalogNetworkSource = {
|
|
17
17
|
type?: string;
|
|
18
|
-
/**
|
|
18
|
+
/** ATSC3: RF centre frequency in kHz (draft -01 4.2.2). */
|
|
19
|
+
frequency?: number;
|
|
20
|
+
plpId?: number;
|
|
21
|
+
serviceId?: number;
|
|
22
|
+
slsUri?: string;
|
|
23
|
+
/** `"dns"`, `"manual"` (or absent) name a dialable relay; `"driad"` resolves at runtime. */
|
|
19
24
|
discovery?: string;
|
|
20
25
|
relay?: string;
|
|
21
26
|
port?: number;
|
|
@@ -72,3 +77,41 @@ export function catalogAmtNetworkSource(networkSource: unknown): AmtNetworkSourc
|
|
|
72
77
|
}
|
|
73
78
|
return undefined;
|
|
74
79
|
}
|
|
80
|
+
|
|
81
|
+
/** Resolved ATSC 3.0 tuning (draft -01 4.2.2/4.2.3). Only `frequency` is REQUIRED. */
|
|
82
|
+
export type Atsc3NetworkSource = {
|
|
83
|
+
/** RF centre frequency in kHz. */
|
|
84
|
+
frequency: number;
|
|
85
|
+
plpId?: number;
|
|
86
|
+
serviceId?: number;
|
|
87
|
+
/** SLS of the MMTP service; libmmt does not fetch it. */
|
|
88
|
+
slsUri?: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
function intIn(value: unknown, min: number, max: number): value is number {
|
|
92
|
+
return Number.isInteger(value) && (value as number) >= min && (value as number) <= max;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Resolve ATSC 3.0 tuning from a catalog `networkSource` (array or bare-object
|
|
97
|
+
* form): the first `type: "atsc3"` entry with a positive integer `frequency`
|
|
98
|
+
* (kHz). Optional fields are carried only when in range; an entry with no
|
|
99
|
+
* usable frequency is skipped, since it names nothing a tuner can lock to.
|
|
100
|
+
* Draft -01 3 puts the tuner first, so callers prefer this over AMT.
|
|
101
|
+
*/
|
|
102
|
+
export function catalogAtsc3NetworkSource(networkSource: unknown): Atsc3NetworkSource | undefined {
|
|
103
|
+
const entries = Array.isArray(networkSource) ? networkSource : networkSource ? [networkSource] : [];
|
|
104
|
+
for (const raw of entries) {
|
|
105
|
+
if (!raw || typeof raw !== "object") continue;
|
|
106
|
+
const ns = raw as CatalogNetworkSource;
|
|
107
|
+
if (ns.type !== "atsc3" || !intIn(ns.frequency, 1, Number.MAX_SAFE_INTEGER)) continue;
|
|
108
|
+
const slsUri = typeof ns.slsUri === "string" ? ns.slsUri.trim() : "";
|
|
109
|
+
return {
|
|
110
|
+
frequency: ns.frequency,
|
|
111
|
+
...(intIn(ns.plpId, 0, 63) ? { plpId: ns.plpId } : {}),
|
|
112
|
+
...(intIn(ns.serviceId, 0, 65535) ? { serviceId: ns.serviceId } : {}),
|
|
113
|
+
...(slsUri ? { slsUri } : {}),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
package/src/catalog-validator.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Ajv2020 from 'ajv/dist/2020.js'
|
|
2
2
|
import addFormats from 'ajv-formats'
|
|
3
|
-
import { hasUniqueMulticastAuthTrackBindings } from './multicast-auth-catalog.js'
|
|
4
3
|
|
|
5
4
|
export interface CatalogSchemaValidationError {
|
|
6
5
|
instancePath: string
|
|
@@ -16,19 +15,13 @@ export interface CatalogSchemaValidator {
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
|
-
* Compile the published catalog schema
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* Compile the published catalog schema the way the package tests it: strict
|
|
19
|
+
* 2020-12 with formats. The schema carries no package-defined keyword; the
|
|
20
|
+
* cross-object rules JSON Schema cannot state (repeated `kid`/`firstEpoch`,
|
|
21
|
+
* port clashes, foreign-namespace tracks) are `validateCmsfMmtpCatalog`'s.
|
|
22
22
|
*/
|
|
23
23
|
export function createCatalogSchemaValidator(schema: object): CatalogSchemaValidator {
|
|
24
24
|
const ajv = new Ajv2020({ allErrors: true, strict: true })
|
|
25
25
|
addFormats(ajv)
|
|
26
|
-
ajv.addKeyword({
|
|
27
|
-
keyword: 'uniqueMulticastAuthTrackBindings',
|
|
28
|
-
type: 'array',
|
|
29
|
-
schemaType: 'boolean',
|
|
30
|
-
validate: (enabled: boolean, tracks: unknown[]) =>
|
|
31
|
-
!enabled || hasUniqueMulticastAuthTrackBindings(tracks),
|
|
32
|
-
})
|
|
33
26
|
return ajv.compile(schema) as CatalogSchemaValidator
|
|
34
27
|
}
|
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,
|
|
@@ -54,6 +59,9 @@ import type {
|
|
|
54
59
|
// Constants
|
|
55
60
|
// ---------------------------------------------------------------------------
|
|
56
61
|
|
|
62
|
+
/** fec-01 4.5: a GF(2^8) reed-solomon block holds at most 255 symbols. */
|
|
63
|
+
const RS_MAX_BLOCK_SYMBOLS = 255
|
|
64
|
+
|
|
57
65
|
// MIN_INTERLEAVE_DEPTH_MS lives with the catalog FEC predicate that also
|
|
58
66
|
// needs it (fec-state.ts); re-exported here for existing importers.
|
|
59
67
|
export { MIN_INTERLEAVE_DEPTH_MS }
|
|
@@ -156,6 +164,25 @@ export interface IsoHeldSource {
|
|
|
156
164
|
readonly oversized: boolean
|
|
157
165
|
}
|
|
158
166
|
|
|
167
|
+
/**
|
|
168
|
+
* A lost SS_ID in an undelimited span (draft-ramadan-moq-fec §7.5): a repair
|
|
169
|
+
* stated a block past SS_IDs whose every repair symbol was lost and at least
|
|
170
|
+
* one source too. They wait as a pending hole `[holeStart, holeStart +
|
|
171
|
+
* holeLength)` for a range repair FETCH.
|
|
172
|
+
*/
|
|
173
|
+
export interface UndelimitedIsoLoss {
|
|
174
|
+
readonly packetId: number
|
|
175
|
+
readonly catalogTrackName: string | undefined
|
|
176
|
+
readonly holeStart: number
|
|
177
|
+
readonly holeLength: number
|
|
178
|
+
/** The highest SS_ID in the hole no source arrived for: the §7.5 x. */
|
|
179
|
+
readonly lostSsId: number
|
|
180
|
+
/** K: the catalog `sourceSymbols`, the largest SSB_length. */
|
|
181
|
+
readonly kMax: number
|
|
182
|
+
/** 32-bit SS_Start of the stated block that ends where the hole starts (S_prev). */
|
|
183
|
+
readonly previousBlockStart?: number
|
|
184
|
+
}
|
|
185
|
+
|
|
159
186
|
/**
|
|
160
187
|
* How the multicast leg hands its symbols to this manager.
|
|
161
188
|
*
|
|
@@ -224,6 +251,11 @@ export interface FECManagerConfig {
|
|
|
224
251
|
* is refused.
|
|
225
252
|
*/
|
|
226
253
|
blockProfile?: FecBlockProfile
|
|
254
|
+
/**
|
|
255
|
+
* The catalog `fec.algorithm` (`TrackFecParams.fecAlgorithm`). Defaults to
|
|
256
|
+
* RaptorQ. Reed-Solomon bounds every block to 255 symbols (fec-01 4.5).
|
|
257
|
+
*/
|
|
258
|
+
algorithm?: 'raptorq' | 'reed-solomon'
|
|
227
259
|
k?: number
|
|
228
260
|
/** Symbol size in bytes (T). NOT repair count. */
|
|
229
261
|
symbolSize?: number
|
|
@@ -245,6 +277,7 @@ export interface FECManagerConfig {
|
|
|
245
277
|
|
|
246
278
|
interface ResolvedFECTrackConfig {
|
|
247
279
|
blockProfile?: FecBlockProfile
|
|
280
|
+
algorithm?: 'raptorq' | 'reed-solomon'
|
|
248
281
|
k: number
|
|
249
282
|
symbolSize: number
|
|
250
283
|
interleaveDepthMs: number
|
|
@@ -572,12 +605,17 @@ export class FECManager {
|
|
|
572
605
|
// per stream. Not only throws: the ordinary out-of-range case is detected by
|
|
573
606
|
// arithmetic and never throws at all.
|
|
574
607
|
#orderedHorizonWarnedFor = new Set<number>()
|
|
575
|
-
// Newest block start (SS_Start)
|
|
576
|
-
//
|
|
608
|
+
// Newest block start (SS_Start) any symbol carried per stream and when: the
|
|
609
|
+
// frontier isoSpanResolution reads.
|
|
577
610
|
#highestSbn = new Map<string, { sbn: number; atMs: number }>()
|
|
611
|
+
// The same from source symbols alone: the frontier a source is judged
|
|
612
|
+
// against for a discontinuity. Repairs ride their own group, which can run
|
|
613
|
+
// blocks ahead of the media they protect.
|
|
614
|
+
#sourceFrontiers = new Map<string, { sbn: number; atMs: number }>()
|
|
578
615
|
// iso-ssbg1-v1 block location per stream (streamKey). A source belongs to a
|
|
579
616
|
// block only once a repair symbol stated the block's (SS_Start, SSB_length).
|
|
580
617
|
#isoLocators = new Map<string, IsoBlockLocator<IsoHeldSource>>()
|
|
618
|
+
#deferIsoGaps = false
|
|
581
619
|
#isoRepairRefusedCount = 0
|
|
582
620
|
#isoSourceOversizeCount = 0
|
|
583
621
|
// Held sources a locator's capacity cap evicted (IsoBlockLocator.heldCapacity):
|
|
@@ -592,9 +630,9 @@ export class FECManager {
|
|
|
592
630
|
// rate-limited like the other per-symbol warns here. Cumulative.
|
|
593
631
|
#isoDecoderUnplacedRetireFailed = 0
|
|
594
632
|
// 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, {
|
|
633
|
+
// packet_sequence_number, by its own SS_ID: the anchor that bounds how far
|
|
634
|
+
// the producer's SS_IDs can have moved before or after another source symbol.
|
|
635
|
+
#sourceAnchors = new Map<string, { ssId: number; psn: number; atMs: number }>()
|
|
598
636
|
// Catalog/reset epoch per packetId. Gap decisions carry it for fencing.
|
|
599
637
|
#packetEpochs = new Map<number, number>()
|
|
600
638
|
|
|
@@ -708,6 +746,14 @@ export class FECManager {
|
|
|
708
746
|
reason: ClassifierReason | null,
|
|
709
747
|
) => void)
|
|
710
748
|
| null = null
|
|
749
|
+
/**
|
|
750
|
+
* A repair stated a block past a gap that is missing a source and whose
|
|
751
|
+
* every repair was lost: a lost SS_ID in an undelimited span
|
|
752
|
+
* (draft-ramadan-moq-fec §7.5). Set with `setUndelimitedLossHandler`; the
|
|
753
|
+
* receiver keeps the gap as a pending hole until `closeIsoHoles` is called
|
|
754
|
+
* for it, which it must be.
|
|
755
|
+
*/
|
|
756
|
+
#onUndelimitedLoss: ((loss: UndelimitedIsoLoss) => void) | null = null
|
|
711
757
|
/** A block every symbol of which vanished was created by SBN evidence. */
|
|
712
758
|
onBlockVanished:
|
|
713
759
|
| ((sbn: number, packetId: number, catalogTrackName: string | undefined) => void)
|
|
@@ -1509,8 +1555,8 @@ export class FECManager {
|
|
|
1509
1555
|
// Deliberately one block tighter than deriveFecRetentionBlocks over the same
|
|
1510
1556
|
// inputs (that function's `+ 1`). Different question: the retention horizon
|
|
1511
1557
|
// asks how long the decoder still ACCEPTS symbols for a block, this asks how
|
|
1512
|
-
// many blocks a stream can
|
|
1513
|
-
//
|
|
1558
|
+
// many blocks a stream can jump ahead of its frontier before a source symbol
|
|
1559
|
+
// there is a discontinuity rather than loss (see #noteSbnSeen).
|
|
1514
1560
|
// The extra block of retention is slack for a block still being fed; a block
|
|
1515
1561
|
// nothing has been heard from does not get it. Not the units defect — but it
|
|
1516
1562
|
// is the next place the two can drift, so change both or neither.
|
|
@@ -1521,23 +1567,28 @@ export class FECManager {
|
|
|
1521
1567
|
|
|
1522
1568
|
/**
|
|
1523
1569
|
* Record that a symbol for block `sbn` (the block's SS_Start) arrived and
|
|
1524
|
-
* advance the stream's
|
|
1570
|
+
* advance the stream's frontiers, the newest block start seen.
|
|
1525
1571
|
*
|
|
1526
|
-
* A SOURCE symbol
|
|
1527
|
-
*
|
|
1528
|
-
*
|
|
1572
|
+
* A SOURCE symbol is judged against the newest source block alone: repairs
|
|
1573
|
+
* ride their own group, which can run blocks ahead of the media. One whose
|
|
1574
|
+
* block goes back further than the blocks this manager retains, or that
|
|
1575
|
+
* cannot have been sent before the source it lies behind, or that jumps
|
|
1576
|
+
* further than the stream could have produced since its last symbol, is a
|
|
1577
|
+
* source discontinuity, not loss. A repair symbol can only advance the
|
|
1529
1578
|
* frontier: a D-28 fetch legitimately answers for an old block, so it never
|
|
1530
1579
|
* signals a discontinuity.
|
|
1531
1580
|
*
|
|
1532
1581
|
* The producer closes a block at its Dth media-unit boundary OR when K
|
|
1533
1582
|
* 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
|
-
*
|
|
1583
|
+
* (every large keyframe does). What bounds a jump is therefore packet
|
|
1584
|
+
* evidence, not a block rate: SS_ID advances by one per FEC source packet
|
|
1585
|
+
* (ISO/IEC 23008-1 C.5.2) and the MMTP packet_sequence_number by one per
|
|
1586
|
+
* packet of the packet_id, so with both source symbols'
|
|
1587
|
+
* packet_sequence_number their SS_IDs (`ssId`, not their block starts,
|
|
1588
|
+
* which a repair-less span can put far behind) can move at most the packets
|
|
1589
|
+
* sent between them, in either direction, plus K of slack for sources lost
|
|
1590
|
+
* before a hop that renumbers packets. Without it, only the D-close rate is
|
|
1591
|
+
* known.
|
|
1541
1592
|
*
|
|
1542
1593
|
* Vanished blocks are not enumerated here: their starts are unknown until a
|
|
1543
1594
|
* repair states them. The SS_IDs between two stated blocks become one
|
|
@@ -1549,10 +1600,11 @@ export class FECManager {
|
|
|
1549
1600
|
catalogTrackName: string | undefined,
|
|
1550
1601
|
symbol: 'source' | 'repair',
|
|
1551
1602
|
packetSequenceNumber?: number,
|
|
1603
|
+
ssId = sbn,
|
|
1552
1604
|
): void {
|
|
1553
1605
|
const streamKey = this.#streamKey(packetId, catalogTrackName)
|
|
1554
1606
|
const now = performance.now()
|
|
1555
|
-
const previous = this.#highestSbn.get(streamKey)
|
|
1607
|
+
const previous = (symbol === 'source' ? this.#sourceFrontiers : this.#highestSbn).get(streamKey)
|
|
1556
1608
|
const anchor = this.#sourceAnchors.get(streamKey)
|
|
1557
1609
|
const psn = symbol === 'source' &&
|
|
1558
1610
|
packetSequenceNumber !== undefined &&
|
|
@@ -1562,29 +1614,46 @@ export class FECManager {
|
|
|
1562
1614
|
? packetSequenceNumber
|
|
1563
1615
|
: undefined
|
|
1564
1616
|
const anchorHere = (): void => {
|
|
1565
|
-
if (psn !== undefined && (anchor === undefined || !
|
|
1566
|
-
this.#sourceAnchors.set(streamKey, {
|
|
1617
|
+
if (psn !== undefined && (anchor === undefined || !serial32Precedes(ssId, anchor.ssId))) {
|
|
1618
|
+
this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now })
|
|
1567
1619
|
}
|
|
1568
1620
|
}
|
|
1621
|
+
const advance = (): void => {
|
|
1622
|
+
const highest = this.#highestSbn.get(streamKey)
|
|
1623
|
+
if (highest === undefined || this.#blockPrecedes(highest.sbn, sbn)) {
|
|
1624
|
+
this.#highestSbn.set(streamKey, { sbn, atMs: now })
|
|
1625
|
+
}
|
|
1626
|
+
if (symbol === 'source') this.#sourceFrontiers.set(streamKey, { sbn, atMs: now })
|
|
1627
|
+
anchorHere()
|
|
1628
|
+
}
|
|
1569
1629
|
const discontinuity = (): void => {
|
|
1570
1630
|
// The classifier compares authored order with SBN order only within
|
|
1571
1631
|
// one continuous SBN sequence.
|
|
1572
1632
|
this.#classifiers.get(streamKey)?.noteSourceDiscontinuity()
|
|
1573
1633
|
this.#highestSbn.set(streamKey, { sbn, atMs: now })
|
|
1634
|
+
this.#sourceFrontiers.set(streamKey, { sbn, atMs: now })
|
|
1574
1635
|
if (psn === undefined) this.#sourceAnchors.delete(streamKey)
|
|
1575
|
-
else this.#sourceAnchors.set(streamKey, {
|
|
1636
|
+
else this.#sourceAnchors.set(streamKey, { ssId, psn, atMs: now })
|
|
1576
1637
|
this.onSourceDiscontinuity?.(packetId, catalogTrackName)
|
|
1577
1638
|
}
|
|
1578
1639
|
if (previous === undefined) {
|
|
1579
|
-
|
|
1580
|
-
anchorHere()
|
|
1640
|
+
advance()
|
|
1581
1641
|
return
|
|
1582
1642
|
}
|
|
1583
1643
|
const config = this.#trackConfig(packetId)
|
|
1584
1644
|
const window = this.#liveWindowBlocks(config)
|
|
1645
|
+
// Packets sent from `from` to `to`, serial arithmetic (RFC 1982): more
|
|
1646
|
+
// than half the space means it went backwards.
|
|
1647
|
+
const sentInOrder = (from: { ssId: number; psn: number }, to: { ssId: number; psn: number }): boolean => {
|
|
1648
|
+
const sent = (to.psn - from.psn) >>> 0
|
|
1649
|
+
return sent <= 0x7fff_ffff && serial32Distance(from.ssId, to.ssId) <= sent + config.k
|
|
1650
|
+
}
|
|
1585
1651
|
if (!this.#blockPrecedes(previous.sbn, sbn)) {
|
|
1586
|
-
if (symbol === 'source' && window !== null &&
|
|
1587
|
-
|
|
1652
|
+
if (symbol === 'source' && window !== null && this.#blockPrecedes(sbn, previous.sbn) && (
|
|
1653
|
+
this.#blocksBehind(sbn, previous.sbn, packetId) > this.#isoRetentionBlocks(packetId) ||
|
|
1654
|
+
(psn !== undefined && anchor !== undefined && serial32Precedes(ssId, anchor.ssId) &&
|
|
1655
|
+
psn !== anchor.psn && !sentInOrder({ ssId, psn }, anchor))
|
|
1656
|
+
)) {
|
|
1588
1657
|
discontinuity()
|
|
1589
1658
|
return
|
|
1590
1659
|
}
|
|
@@ -1598,15 +1667,8 @@ export class FECManager {
|
|
|
1598
1667
|
// producer that does not maintain it); only then is the D-close rate
|
|
1599
1668
|
// the whole bound.
|
|
1600
1669
|
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
|
|
1670
|
+
serial32Precedes(anchor.ssId, ssId) && psn !== anchor.psn) {
|
|
1671
|
+
plausible = sentInOrder(anchor, { ssId, psn })
|
|
1610
1672
|
} else {
|
|
1611
1673
|
plausible = missing <= window + Math.ceil((now - previous.atMs) / config.interleaveDepthMs)
|
|
1612
1674
|
}
|
|
@@ -1616,8 +1678,7 @@ export class FECManager {
|
|
|
1616
1678
|
discontinuity()
|
|
1617
1679
|
return
|
|
1618
1680
|
}
|
|
1619
|
-
|
|
1620
|
-
anchorHere()
|
|
1681
|
+
advance()
|
|
1621
1682
|
}
|
|
1622
1683
|
|
|
1623
1684
|
/*
|
|
@@ -2054,8 +2115,10 @@ export class FECManager {
|
|
|
2054
2115
|
)
|
|
2055
2116
|
}
|
|
2056
2117
|
const hasCatalogTiming = FECManager.#hasCatalogTiming({ interleaveDepthMs: ownInterleaveDepthMs })
|
|
2118
|
+
const algorithm = config.algorithm ?? previous.algorithm
|
|
2057
2119
|
const next: ResolvedFECTrackConfig = {
|
|
2058
2120
|
blockProfile,
|
|
2121
|
+
...(algorithm === undefined ? {} : { algorithm }),
|
|
2059
2122
|
k,
|
|
2060
2123
|
symbolSize:
|
|
2061
2124
|
config.symbolSize != null && config.symbolSize > 0
|
|
@@ -2397,6 +2460,7 @@ export class FECManager {
|
|
|
2397
2460
|
resetSet(this.#materializedBlocks)
|
|
2398
2461
|
resetMap(this.#resolvedBlockClasses)
|
|
2399
2462
|
resetMap(this.#highestSbn)
|
|
2463
|
+
resetMap(this.#sourceFrontiers)
|
|
2400
2464
|
resetMap(this.#isoLocators)
|
|
2401
2465
|
resetMap(this.#sourceAnchors)
|
|
2402
2466
|
this.#classifiers.delete(this.#streamKey(packetId, catalogTrackName))
|
|
@@ -2510,6 +2574,7 @@ export class FECManager {
|
|
|
2510
2574
|
dropMap(this.#orderedPendingBlocks)
|
|
2511
2575
|
dropMap(this.#resolvedBlockClasses)
|
|
2512
2576
|
dropMap(this.#highestSbn)
|
|
2577
|
+
dropMap(this.#sourceFrontiers)
|
|
2513
2578
|
dropMap(this.#isoLocators)
|
|
2514
2579
|
dropMap(this.#sourceAnchors)
|
|
2515
2580
|
dropMap(this.#classifiers)
|
|
@@ -2642,7 +2707,11 @@ export class FECManager {
|
|
|
2642
2707
|
this.#startupPartialBlocks.delete(blockKey)
|
|
2643
2708
|
this.#startupAlignedPackets.add(streamKey)
|
|
2644
2709
|
} else if (
|
|
2645
|
-
|
|
2710
|
+
// A ready multicast repair opens a block the join has not seen yet, never
|
|
2711
|
+
// a join partial: its sources were refused, so its repairs alone open a
|
|
2712
|
+
// block that cannot decode and fails at its deadline, once per packet ID
|
|
2713
|
+
// per join (BLO-48308).
|
|
2714
|
+
isStartupPartial ||
|
|
2646
2715
|
(!this.#startupAlignedPackets.has(streamKey) && !isReadyMulticastRepair)
|
|
2647
2716
|
) {
|
|
2648
2717
|
this.#markStartupPartial(blockKey)
|
|
@@ -2981,6 +3050,7 @@ export class FECManager {
|
|
|
2981
3050
|
let locator = this.#isoLocators.get(streamKey)
|
|
2982
3051
|
if (!locator) {
|
|
2983
3052
|
locator = new IsoBlockLocator<IsoHeldSource>(this.#trackConfig(packetId).k, this.#isoRetentionBlocks(packetId))
|
|
3053
|
+
locator.deferIncompleteGaps = this.#deferIsoGaps
|
|
2984
3054
|
this.#isoLocators.set(streamKey, locator)
|
|
2985
3055
|
}
|
|
2986
3056
|
return locator
|
|
@@ -3028,6 +3098,11 @@ export class FECManager {
|
|
|
3028
3098
|
return blocks
|
|
3029
3099
|
}
|
|
3030
3100
|
|
|
3101
|
+
/** The iso-ssbg1-v1 locator horizon of a configured packetId, in blocks (#isoRetentionBlocks). */
|
|
3102
|
+
isoRetentionBlocksForPacket(packetId: number): number | undefined {
|
|
3103
|
+
return this.#hasBlockProfile(packetId) ? this.#isoRetentionBlocks(packetId) : undefined
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3031
3106
|
/** Whether an iso-ssbg1-v1 protected packet fits one ssbg_mode1 symbol (len + 2 <= T). */
|
|
3032
3107
|
isoSourceFits(packetId: number, packetLength: number): boolean {
|
|
3033
3108
|
const symbolSize = this.#trackConfigs.get(packetId)?.symbolSize
|
|
@@ -3095,23 +3170,74 @@ export class FECManager {
|
|
|
3095
3170
|
}
|
|
3096
3171
|
return placement
|
|
3097
3172
|
}
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
const
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3173
|
+
if (placement.span !== undefined) this.#openIsoSpan(placement.span, packetId, catalogTrackName)
|
|
3174
|
+
if (placement.hole !== undefined) {
|
|
3175
|
+
const locator = this.#isoLocatorFor(packetId, catalogTrackName)
|
|
3176
|
+
const hole = placement.hole.block
|
|
3177
|
+
const previous = locator.blockEndingAt(hole.start)
|
|
3178
|
+
const loss: UndelimitedIsoLoss = {
|
|
3179
|
+
packetId,
|
|
3180
|
+
catalogTrackName,
|
|
3181
|
+
holeStart: hole.start,
|
|
3182
|
+
holeLength: hole.length,
|
|
3183
|
+
lostSsId: placement.hole.lostSsId,
|
|
3184
|
+
kMax: this.#trackConfig(packetId).k,
|
|
3185
|
+
...(previous === undefined ? {} : { previousBlockStart: previous.start }),
|
|
3186
|
+
}
|
|
3187
|
+
this.#onUndelimitedLoss!(loss)
|
|
3111
3188
|
}
|
|
3112
3189
|
return placement
|
|
3113
3190
|
}
|
|
3114
3191
|
|
|
3192
|
+
/**
|
|
3193
|
+
* Keep an iso-ssbg1-v1 gap missing a source as a pending hole, reported to
|
|
3194
|
+
* `handler`, instead of a repair-less span; null restores spans. Set by the
|
|
3195
|
+
* range repair scheduler; applies to every stream from its next gap. The
|
|
3196
|
+
* handler and the deferral are one setting, so no hole is ever created with
|
|
3197
|
+
* nobody to close it.
|
|
3198
|
+
*/
|
|
3199
|
+
setUndelimitedLossHandler(handler: ((loss: UndelimitedIsoLoss) => void) | null): void {
|
|
3200
|
+
this.#onUndelimitedLoss = handler
|
|
3201
|
+
this.#deferIsoGaps = handler !== null
|
|
3202
|
+
for (const locator of this.#isoLocators.values()) locator.deferIncompleteGaps = this.#deferIsoGaps
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
/**
|
|
3206
|
+
* The range repair for a hole ended: every hole still pending inside
|
|
3207
|
+
* `[start, start + length)` becomes a repair-less span. Returns those spans
|
|
3208
|
+
* with the held sources they placed, for the caller to feed (MmtpRouter).
|
|
3209
|
+
*/
|
|
3210
|
+
closeIsoHoles(
|
|
3211
|
+
packetId: number,
|
|
3212
|
+
catalogTrackName: string | undefined,
|
|
3213
|
+
start: number,
|
|
3214
|
+
length: number,
|
|
3215
|
+
): { block: IsoBlockRange; placed: IsoPlacedSource<IsoHeldSource>[] }[] {
|
|
3216
|
+
const locator = this.#isoLocators.get(this.#streamKey(packetId, catalogTrackName))
|
|
3217
|
+
if (locator === undefined) return []
|
|
3218
|
+
const spans = locator.closeHolesWithin(start, length)
|
|
3219
|
+
for (const span of spans) this.#openIsoSpan(span, packetId, catalogTrackName)
|
|
3220
|
+
return spans
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
/**
|
|
3224
|
+
* A repair-less span has no repair to state its length, so it is known
|
|
3225
|
+
* here: its sources make it clean exactly when all of them arrived. A
|
|
3226
|
+
* stated block learns its SSB_length from its own repair symbol, fed after
|
|
3227
|
+
* its placed sources exactly as on the wire (feedRepairSymbol). A span every
|
|
3228
|
+
* SS_ID of which vanished resolves through its deadline like any vanished
|
|
3229
|
+
* block.
|
|
3230
|
+
*/
|
|
3231
|
+
#openIsoSpan(
|
|
3232
|
+
span: { readonly block: IsoBlockRange; readonly placed: readonly unknown[] },
|
|
3233
|
+
packetId: number,
|
|
3234
|
+
catalogTrackName: string | undefined,
|
|
3235
|
+
): void {
|
|
3236
|
+
const key = this.#blockKey(span.block.start, packetId, catalogTrackName)
|
|
3237
|
+
if (!this.#blockAuthoredLengths.has(key)) this.#blockAuthoredLengths.set(key, span.block.length)
|
|
3238
|
+
if (span.placed.length === 0) this.#materializeBlock(span.block.start, packetId, catalogTrackName, true)
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3115
3241
|
/**
|
|
3116
3242
|
* Resolution of the SS_IDs strictly between two released frames' SS_IDs on
|
|
3117
3243
|
* an iso-ssbg1-v1 stream, for in-order frame release: null while a block
|
|
@@ -3827,6 +3953,57 @@ export class FECManager {
|
|
|
3827
3953
|
* Caller is responsible for routing recovered data and updating
|
|
3828
3954
|
* block completion state via `markBlockCompleted()`.
|
|
3829
3955
|
*/
|
|
3956
|
+
/**
|
|
3957
|
+
* Whether a repair symbol of `byteLength` bytes is a valid member of a
|
|
3958
|
+
* `packetId` block: every repair symbol is exactly the track's T. A symbol of
|
|
3959
|
+
* any other size is counted on `repairSymbolSizeMismatches`, warned (rate
|
|
3960
|
+
* limited) and refused. The router calls this before the symbol takes any
|
|
3961
|
+
* other part in block state (placement, first-arrival dedup, completed-block
|
|
3962
|
+
* accounting), so a malformed repair is counted whatever its arrival order:
|
|
3963
|
+
* judged after dedup, one landing on an already-complete block, or behind a
|
|
3964
|
+
* valid copy from the other transport, was swallowed as a duplicate and never
|
|
3965
|
+
* counted (BLO-48306). A packetId with no configured block profile admits
|
|
3966
|
+
* nothing here; its repair is dropped upstream as unreadable.
|
|
3967
|
+
*/
|
|
3968
|
+
/**
|
|
3969
|
+
* fec-01 4.5: a reed-solomon repair packet whose SSB_length + RSB_length
|
|
3970
|
+
* exceeds 255, or whose RS_ID is not below RSB_length, is discarded with the
|
|
3971
|
+
* block state unchanged. The router calls this before the repair places a
|
|
3972
|
+
* block or takes any other part in block bookkeeping. A RaptorQ track admits
|
|
3973
|
+
* every header that parsed (its RS_ID < RSB_length check is in the parser).
|
|
3974
|
+
*/
|
|
3975
|
+
admitRepairBlockLength(
|
|
3976
|
+
packetId: number,
|
|
3977
|
+
ssbLength: number,
|
|
3978
|
+
rsbLength: number,
|
|
3979
|
+
rsId: number,
|
|
3980
|
+
): boolean {
|
|
3981
|
+
if (rsId >= rsbLength) return false
|
|
3982
|
+
if (this.#trackConfigs.get(packetId)?.algorithm !== 'reed-solomon') return true
|
|
3983
|
+
return ssbLength + rsbLength <= RS_MAX_BLOCK_SYMBOLS
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3986
|
+
admitRepairSymbolSize(
|
|
3987
|
+
packetId: number,
|
|
3988
|
+
ssStart: number,
|
|
3989
|
+
ssbLength: number,
|
|
3990
|
+
rsId: number,
|
|
3991
|
+
byteLength: number,
|
|
3992
|
+
): boolean {
|
|
3993
|
+
if (!this.#hasBlockProfile(packetId)) return false
|
|
3994
|
+
const symbolSize = this.#trackConfig(packetId).symbolSize
|
|
3995
|
+
if (symbolSize > 0 && byteLength !== symbolSize) {
|
|
3996
|
+
this.#repairSymbolSizeMismatchCount++
|
|
3997
|
+
if (this.#repairSymbolSizeMismatchCount <= 5 || this.#repairSymbolSizeMismatchCount % 100 === 0) {
|
|
3998
|
+
console.warn(
|
|
3999
|
+
`[FECManager] Dropping repair symbol with invalid size: got ${byteLength}B, expected ${symbolSize}B (packetId=${packetId}, ssStart=${ssStart}, ssbLength=${ssbLength}, rsId=${rsId})`,
|
|
4000
|
+
)
|
|
4001
|
+
}
|
|
4002
|
+
return false
|
|
4003
|
+
}
|
|
4004
|
+
return true
|
|
4005
|
+
}
|
|
4006
|
+
|
|
3830
4007
|
feedRepairSymbol(
|
|
3831
4008
|
packetId: number,
|
|
3832
4009
|
ssStart: number,
|
|
@@ -3840,16 +4017,7 @@ export class FECManager {
|
|
|
3840
4017
|
// A packetId with no configured block profile has no block geometry: its
|
|
3841
4018
|
// repair names no block this manager can track or decode.
|
|
3842
4019
|
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
|
-
}
|
|
4020
|
+
if (!this.admitRepairSymbolSize(packetId, ssStart, ssbLength, rsId, repairData.byteLength)) return null
|
|
3853
4021
|
const fecData = repairData
|
|
3854
4022
|
|
|
3855
4023
|
// ISO/IEC 23008-1 C.5.3: the block is [SS_Start, SS_Start + SSB_length),
|
|
@@ -4072,7 +4240,14 @@ export class FECManager {
|
|
|
4072
4240
|
// Skip blocks already recovered — late source symbols must not restart timeouts
|
|
4073
4241
|
if (this.#completedBlocks.has(key)) return
|
|
4074
4242
|
|
|
4075
|
-
this.#noteSbnSeen(
|
|
4243
|
+
this.#noteSbnSeen(
|
|
4244
|
+
sbn,
|
|
4245
|
+
packetId,
|
|
4246
|
+
catalogTrackName,
|
|
4247
|
+
'source',
|
|
4248
|
+
evidence.packetSequenceNumber,
|
|
4249
|
+
Number.isInteger(esi) ? (sbn + esi) >>> 0 : sbn,
|
|
4250
|
+
)
|
|
4076
4251
|
|
|
4077
4252
|
// A source ESI at or past the block's authored SSB_length contradicts it;
|
|
4078
4253
|
// its geometry can no longer be trusted, so fail it closed.
|
|
@@ -4410,6 +4585,7 @@ export class FECManager {
|
|
|
4410
4585
|
this.#repairedBlocks.clear()
|
|
4411
4586
|
this.#materializedBlocks.clear()
|
|
4412
4587
|
this.#highestSbn.clear()
|
|
4588
|
+
this.#sourceFrontiers.clear()
|
|
4413
4589
|
this.#isoLocators.clear()
|
|
4414
4590
|
this.#sourceAnchors.clear()
|
|
4415
4591
|
this.#trackConfigs.clear()
|
package/src/fec-state.ts
CHANGED
|
@@ -13,7 +13,15 @@
|
|
|
13
13
|
// timers or elapsed time. The rules live here so the three players cannot
|
|
14
14
|
// disagree about precedence.
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
catalogFecDeclaresUnconfigurableInstance,
|
|
18
|
+
fecAlgorithmUnimplemented,
|
|
19
|
+
isFecBlockProfile,
|
|
20
|
+
isoBlockSpanUsable,
|
|
21
|
+
} from '@blockcast/mmt-base'
|
|
22
|
+
|
|
23
|
+
/** The optional elapsed-span rule lives in mmt-base beside the other catalog FEC rules. */
|
|
24
|
+
export { isoBlockSpanUsable }
|
|
17
25
|
|
|
18
26
|
/** Smallest positive catalog elapsed span; zero/absence means no elapsed deadline. */
|
|
19
27
|
export const MIN_INTERLEAVE_DEPTH_MS = 1
|
|
@@ -100,7 +108,8 @@ function isPositiveSafeInteger(value: unknown): boolean {
|
|
|
100
108
|
* Whether one catalog `fec` block (a hang rendition's `fec` or an MSF/CMSF
|
|
101
109
|
* track's `fec`) declares an FEC instance a receiver can configure: source
|
|
102
110
|
* symbols per block (K) and a symbol size (T) are both positive integers, the
|
|
103
|
-
* algorithm is
|
|
111
|
+
* algorithm is neither `none` nor a token this receiver does not implement
|
|
112
|
+
* (`fecAlgorithmUnimplemented`, draft-ramadan-moq-fec-01 4), `blockProfile` names the implemented profile
|
|
104
113
|
* `iso-ssbg1-v1` (BLO-35597), and the block carries that profile's usable
|
|
105
114
|
* span field (`isoBlockSpanUsable`); zero/absence still permits in-band FEC. Total: it never throws, and answers false for
|
|
106
115
|
* any other value.
|
|
@@ -138,23 +147,16 @@ function isPositiveSafeInteger(value: unknown): boolean {
|
|
|
138
147
|
*/
|
|
139
148
|
export function catalogDeclaresFec(fec: unknown): boolean {
|
|
140
149
|
const block = recordOf(fec)
|
|
141
|
-
if (block === undefined || block['algorithm'] === 'none') return false
|
|
150
|
+
if (block === undefined || block['algorithm'] === 'none' || fecAlgorithmUnimplemented(block['algorithm'])) return false
|
|
142
151
|
return (
|
|
143
152
|
isPositiveSafeInteger(block['sourceSymbols']) &&
|
|
144
153
|
isPositiveSafeInteger(block['symbolSize']) &&
|
|
145
154
|
isFecBlockProfile(block['blockProfile']) &&
|
|
146
|
-
isoBlockSpanUsable(block)
|
|
155
|
+
isoBlockSpanUsable(block) &&
|
|
156
|
+
!catalogFecDeclaresUnconfigurableInstance(block)
|
|
147
157
|
)
|
|
148
158
|
}
|
|
149
159
|
|
|
150
|
-
/** Validate the optional elapsed span without requiring one for in-band FEC. */
|
|
151
|
-
export function isoBlockSpanUsable(fec: unknown): boolean {
|
|
152
|
-
const block = recordOf(fec)
|
|
153
|
-
if (block === undefined || block['blockProfile'] !== 'iso-ssbg1-v1') return true
|
|
154
|
-
const ms = block['interleaveDepthMs']
|
|
155
|
-
return ms === undefined || (typeof ms === 'number' && Number.isSafeInteger(ms) && ms >= 0)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
160
|
function requireBoolean(value: unknown, field: string): boolean {
|
|
159
161
|
if (typeof value !== 'boolean') {
|
|
160
162
|
throw new TypeError(`resolveFecState: ${field} must be a boolean, got ${typeof value}`)
|