@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
package/src/carp-catalog.ts
CHANGED
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
import {
|
|
12
12
|
MMTP_PACKET_ID_MAX,
|
|
13
13
|
MMTP_SIGNALING_PACKET_ID,
|
|
14
|
+
ISO_SSBG1_MIN_SYMBOL_SIZE,
|
|
14
15
|
isFecBlockProfile,
|
|
15
16
|
type FecBlockProfile,
|
|
16
17
|
} from "@blockcast/mmt-base";
|
|
17
|
-
import {
|
|
18
|
+
import { multicastCatalogIssues, multicastEndpointSource } from "@blockcast/mmt-base";
|
|
19
|
+
import type { EndpointAuthConfig, MulticastAuthConfig } from "./multicast-auth-catalog.js";
|
|
18
20
|
import {
|
|
19
21
|
assembleRepairLayers,
|
|
20
22
|
assertRepairTrackReachable,
|
|
@@ -126,13 +128,15 @@ export function hasSwitchingSetRole(names: string[]): boolean {
|
|
|
126
128
|
* Validate that a set of track names forms a complete switching set.
|
|
127
129
|
*
|
|
128
130
|
* - Empty or single-track sets (all parsing to `"single"`) → `{ ok: true }`.
|
|
129
|
-
* - Multi-track sets (any name has a role suffix) MUST include
|
|
130
|
-
*
|
|
131
|
+
* - Multi-track sets (any name has a role suffix) MUST include `base` and
|
|
132
|
+
* `repair`. `delta` is optional (BLO-49199): base is the self-decodable leg,
|
|
133
|
+
* so a base-only set plays in base-only mode; a delta without base cannot.
|
|
134
|
+
* Missing roles are listed.
|
|
131
135
|
*
|
|
132
136
|
* Propagates throws from `parseTrackRole` (non-ASCII, unknown suffix, etc.).
|
|
133
137
|
*
|
|
134
138
|
* D-04: Legacy single-track streams pass without enforcement.
|
|
135
|
-
* D-04: Once any suffix appears, the set is multi-track and
|
|
139
|
+
* D-04: Once any suffix appears, the set is multi-track and needs base + repair.
|
|
136
140
|
*/
|
|
137
141
|
export function validateSwitchingSet(
|
|
138
142
|
trackNames: string[],
|
|
@@ -147,11 +151,11 @@ export function validateSwitchingSet(
|
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
// Multi-track: at least one name has a role suffix.
|
|
150
|
-
// The set MUST contain
|
|
154
|
+
// The set MUST contain base and repair; delta is optional (BLO-49199).
|
|
151
155
|
// Explicit Set<TrackRole> so the TrackRole-typed `required.filter`
|
|
152
156
|
// callback can call .has(r) without a narrow-mismatch complaint.
|
|
153
157
|
const presentRoles: Set<TrackRole> = new Set(roles.filter((r) => r !== "single"));
|
|
154
|
-
const required: TrackRole[] = ["base", "
|
|
158
|
+
const required: TrackRole[] = ["base", "repair"];
|
|
155
159
|
const missing = required.filter((r) => !presentRoles.has(r));
|
|
156
160
|
|
|
157
161
|
if (missing.length > 0) {
|
|
@@ -162,7 +166,10 @@ export function validateSwitchingSet(
|
|
|
162
166
|
|
|
163
167
|
// ── FEC Catalog Extension (CARP §3.2) ─────────────────────────
|
|
164
168
|
|
|
165
|
-
|
|
169
|
+
/** draft-ramadan-moq-fec-01 4: `none` and the two specified schemes, or any
|
|
170
|
+
* other registered token, which a receiver that does not implement it
|
|
171
|
+
* consumes without FEC (`fecAlgorithmUnimplemented`). */
|
|
172
|
+
export type FecAlgorithm = "none" | "raptorq" | "reed-solomon" | (string & {});
|
|
166
173
|
|
|
167
174
|
export interface FecCatalogConfig {
|
|
168
175
|
/** FEC algorithm identifier (REQUIRED per §4.1, values per §3.1). */
|
|
@@ -199,9 +206,9 @@ export interface FecCatalogConfig {
|
|
|
199
206
|
* per draft-ramadan-moq-fec §6.3, never listed here. */
|
|
200
207
|
repairTrack: string;
|
|
201
208
|
/** FEC block mode: "interleaved" (default) or "object" (per-frame). */
|
|
202
|
-
//
|
|
209
|
+
// Blockcast extension, not in draft-ramadan-moq-fec-01 (its public object protection is the moq-object-v1 block profile, Section 7.6, which libmmt does not implement)
|
|
203
210
|
mode?: "interleaved" | "object";
|
|
204
|
-
/** UEP (Unequal Error Protection) —
|
|
211
|
+
/** UEP (Unequal Error Protection) — Blockcast extension, not in draft-ramadan-moq-fec-01. When present, repair count
|
|
205
212
|
* varies per frame type. repairSymbols becomes the base (P-frame) count.
|
|
206
213
|
* MUST be omitted on multi-track base/delta streams (D-08). */
|
|
207
214
|
uep?: {
|
|
@@ -243,7 +250,7 @@ export interface FecCatalogConfig {
|
|
|
243
250
|
|
|
244
251
|
/**
|
|
245
252
|
* Whether a catalog `fec` block carries the FEC instance geometry a receiver
|
|
246
|
-
* configures, its block profile aside: a
|
|
253
|
+
* configures, its block profile aside: a non-empty `algorithm` token, positive
|
|
247
254
|
* `sourceSymbols`, `repairSymbols` and `symbolSize` (8-byte aligned for
|
|
248
255
|
* RaptorQ), and a non-empty `repairTrack`. A block that fails this is
|
|
249
256
|
* malformed whatever its profile. Total: never throws.
|
|
@@ -254,8 +261,7 @@ export function isFecCatalogGeometry(obj: unknown): boolean {
|
|
|
254
261
|
const algorithm = o["algorithm"];
|
|
255
262
|
const symbolSize = o["symbolSize"];
|
|
256
263
|
return (
|
|
257
|
-
typeof algorithm === "string" &&
|
|
258
|
-
(algorithm === "none" || algorithm === "raptorq" || algorithm === "reed-solomon") &&
|
|
264
|
+
typeof algorithm === "string" && algorithm.length > 0 &&
|
|
259
265
|
typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 &&
|
|
260
266
|
typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 &&
|
|
261
267
|
typeof symbolSize === "number" && symbolSize >= 1 &&
|
|
@@ -280,10 +286,18 @@ export function isFecCatalogConfig(obj: unknown): obj is FecCatalogConfig {
|
|
|
280
286
|
|
|
281
287
|
// ── Multicast Catalog Extension (CARP §4.1-4.4) ───────────────
|
|
282
288
|
|
|
283
|
-
|
|
289
|
+
/**
|
|
290
|
+
* An endpoint's join mode, per draft-ramadan-moq-multicast-01 4.1 at
|
|
291
|
+
* Blockcast/moqcast-draft@fd962fd73d21ed281b60219c11ea61cc9e4e91c4.
|
|
292
|
+
* `sourceAddress` selects it (present: SSM, absent: ASM) and `protocol` only
|
|
293
|
+
* restates it. A bearer (AMT, ATSC 3.0) is a `networkSource` entry, never a
|
|
294
|
+
* protocol; `multicastEndpointSource` in `@blockcast/mmt-base` derives the
|
|
295
|
+
* mode and `S` for every reader.
|
|
296
|
+
*/
|
|
297
|
+
export type MulticastProtocol = "ssm" | "asm";
|
|
284
298
|
|
|
285
299
|
/**
|
|
286
|
-
* Per-track endpoint membership, per draft-ramadan-moq-multicast-
|
|
300
|
+
* Per-track endpoint membership, per draft-ramadan-moq-multicast-01 §4.1.
|
|
287
301
|
*
|
|
288
302
|
* `packetId` is the MMTP packet_id used for packet-level demux on the
|
|
289
303
|
* multicast wire, in 1..65535: packet_id 0 (`MMTP_SIGNALING_PACKET_ID`) is
|
|
@@ -301,9 +315,9 @@ export interface MulticastTrackObject {
|
|
|
301
315
|
export type MulticastTrack = string | MulticastTrackObject;
|
|
302
316
|
|
|
303
317
|
export interface MulticastEndpoint {
|
|
304
|
-
/**
|
|
318
|
+
/** Restates the mode `sourceAddress` selects; an endpoint where it disagrees is ignored. */
|
|
305
319
|
protocol?: MulticastProtocol;
|
|
306
|
-
/** SSM source
|
|
320
|
+
/** SSM source address; its absence selects ASM. */
|
|
307
321
|
sourceAddress?: string;
|
|
308
322
|
/** Multicast group address (REQUIRED). */
|
|
309
323
|
groupAddress: string;
|
|
@@ -320,20 +334,31 @@ export interface MulticastEndpoint {
|
|
|
320
334
|
tracks: MulticastTrack[];
|
|
321
335
|
/**
|
|
322
336
|
* Aggregate bandwidth of this endpoint in bits per second.
|
|
323
|
-
* RECOMMENDED per draft §4.1 — enables capacity-aware joins
|
|
337
|
+
* RECOMMENDED per draft §4.1 — enables capacity-aware joins; REQUIRED on a
|
|
338
|
+
* protected endpoint, where it bounds the receiver's hold queues (7.2.6).
|
|
324
339
|
*/
|
|
325
340
|
bandwidth?: number;
|
|
341
|
+
/**
|
|
342
|
+
* Marks the endpoint's flow protected (7.2.6). REQUIRED when the
|
|
343
|
+
* `multicast` object carries `auth`, forbidden when it does not.
|
|
344
|
+
*/
|
|
345
|
+
auth?: EndpointAuthConfig;
|
|
346
|
+
/** Bearers for this endpoint alone (4.2); readers prefer it to the catalog-level array. */
|
|
347
|
+
networkSource?: NetworkSource[];
|
|
326
348
|
}
|
|
327
349
|
|
|
328
|
-
export type AmtDiscovery = "driad" | "manual";
|
|
350
|
+
export type AmtDiscovery = "dns" | "driad" | "manual";
|
|
329
351
|
|
|
330
352
|
/**
|
|
331
353
|
* One `multicast.networkSource[]` entry, per draft-ramadan-moq-multicast §4.1.
|
|
332
354
|
*
|
|
333
355
|
* Mirrors moq-rs `NetworkSource` (the normative validator) and the
|
|
334
356
|
* `networkSource` `$def` in `catalog.schema.json` 1:1 — a change here needs the
|
|
335
|
-
* same change in both. `discovery
|
|
336
|
-
*
|
|
357
|
+
* same change in both. `discovery` is OPTIONAL (draft -01 4.2.1): `"dns"`
|
|
358
|
+
* names a relay service hostname whose A/AAAA answers are candidates,
|
|
359
|
+
* `"manual"` a literal relay, and omitted means `"dns"` when `relay` is a
|
|
360
|
+
* hostname (DRIAD when `relay` is absent too). `"dns"` and `"manual"` require
|
|
361
|
+
* `relay`; that relay is the one the player joins. Under `discovery: "driad"` the relay is resolved at
|
|
337
362
|
* runtime, so `relay` is OPTIONAL and, when present, only a discovery hint
|
|
338
363
|
* (e.g. the `amtFallback.relayDns` name the derived path carries over): readers
|
|
339
364
|
* do not join it (`findAmtRelay` in packages/transport
|
|
@@ -353,12 +378,25 @@ export type AmtDiscovery = "driad" | "manual";
|
|
|
353
378
|
* reject catalogs already in the wild, so when this type changes, widen the
|
|
354
379
|
* reader only if the new shape must be consumed; never narrow it to match.
|
|
355
380
|
*
|
|
356
|
-
* This is the one place a catalog declares an AMT relay
|
|
357
|
-
*
|
|
381
|
+
* This is the one place a catalog declares an AMT relay: in the `multicast`
|
|
382
|
+
* object for every endpoint, or in one endpoint's own `networkSource`
|
|
383
|
+
* (draft -01 4.2). The endpoint model carries no relay field.
|
|
358
384
|
*/
|
|
359
385
|
export type NetworkSource =
|
|
360
|
-
| { type: "amt"; discovery
|
|
361
|
-
| {
|
|
386
|
+
| { type: "amt"; discovery?: AmtDiscovery; relay?: string; port?: number }
|
|
387
|
+
| {
|
|
388
|
+
type: "atsc3";
|
|
389
|
+
/** RF centre frequency in kHz (draft -01 4.2.2). The only REQUIRED tuning field. */
|
|
390
|
+
frequency: number;
|
|
391
|
+
plpId?: number;
|
|
392
|
+
serviceId?: number;
|
|
393
|
+
/**
|
|
394
|
+
* SLS of the MMTP service, MP table included (A/331:2026-04 7.2). It
|
|
395
|
+
* describes the MMTP session and nothing of this profile: manifestPort
|
|
396
|
+
* and keys come from provisioning. libmmt does not fetch it.
|
|
397
|
+
*/
|
|
398
|
+
slsUri?: string;
|
|
399
|
+
};
|
|
362
400
|
|
|
363
401
|
export interface MulticastCatalogConfig {
|
|
364
402
|
/** Enable/disable multicast (OPTIONAL, default true). */
|
|
@@ -366,12 +404,13 @@ export interface MulticastCatalogConfig {
|
|
|
366
404
|
/** Multicast endpoints (REQUIRED). */
|
|
367
405
|
endpoints: MulticastEndpoint[];
|
|
368
406
|
/**
|
|
369
|
-
* Relay/tuning discovery
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* the whole join.
|
|
407
|
+
* Relay/tuning discovery applying to every endpoint (4.2); omitted for
|
|
408
|
+
* native joins, whose endpoint tuple is the whole join. An endpoint's own
|
|
409
|
+
* `networkSource` takes precedence for that endpoint.
|
|
373
410
|
*/
|
|
374
411
|
networkSource?: NetworkSource[];
|
|
412
|
+
/** bc-provenance version 2 profile and keys (7.2.6). */
|
|
413
|
+
auth?: MulticastAuthConfig;
|
|
375
414
|
/**
|
|
376
415
|
* AMT fallback configuration.
|
|
377
416
|
*
|
|
@@ -423,11 +462,8 @@ export function isMulticastTrackObject(obj: unknown): obj is MulticastTrackObjec
|
|
|
423
462
|
export function isMulticastEndpoint(obj: unknown): obj is MulticastEndpoint {
|
|
424
463
|
if (typeof obj !== "object" || obj === null) return false;
|
|
425
464
|
const o = obj as Record<string, unknown>;
|
|
426
|
-
const protocol = o["protocol"] ??
|
|
427
|
-
(typeof o["sourceAddress"] === "string" && o["sourceAddress"].length > 0 ? "ssm" : undefined);
|
|
428
465
|
return (
|
|
429
|
-
|
|
430
|
-
(protocol === "ssm" || protocol === "asm" || protocol === "amt" || protocol === "atsc3") &&
|
|
466
|
+
multicastEndpointSource(o) !== undefined &&
|
|
431
467
|
typeof o["groupAddress"] === "string" && (o["groupAddress"] as string).length > 0 &&
|
|
432
468
|
typeof o["port"] === "number" && (o["port"] as number) > 0 && (o["port"] as number) <= 65535 &&
|
|
433
469
|
Array.isArray(o["tracks"]) &&
|
|
@@ -456,7 +492,7 @@ export function isMulticastCatalogConfig(obj: unknown): obj is MulticastCatalogC
|
|
|
456
492
|
);
|
|
457
493
|
}
|
|
458
494
|
|
|
459
|
-
// ── Track Timing (mmt-
|
|
495
|
+
// ── Track Timing (mmt-01 §4.4.2) ──────────────────────────────
|
|
460
496
|
|
|
461
497
|
/**
|
|
462
498
|
* Per-track group-duration signaling.
|
|
@@ -472,9 +508,9 @@ export function isMulticastCatalogConfig(obj: unknown): obj is MulticastCatalogC
|
|
|
472
508
|
* (e.g. 44 100 Hz × 333 ms = 14 685.3 ticks).
|
|
473
509
|
*
|
|
474
510
|
* If both fields are present, `groupDurationTicks` wins (matches the
|
|
475
|
-
* spec, mmt-
|
|
511
|
+
* spec, mmt-01 §4.4.2).
|
|
476
512
|
*
|
|
477
|
-
* @see draft-ramadan-moq-mmt-
|
|
513
|
+
* @see draft-ramadan-moq-mmt-01 §4.4.2
|
|
478
514
|
* @see ./align.ts groupIdForTicks
|
|
479
515
|
*/
|
|
480
516
|
export interface TrackTimingConfig {
|
|
@@ -504,7 +540,7 @@ export function isTrackTimingConfig(obj: unknown): obj is TrackTimingConfig {
|
|
|
504
540
|
/** Resolve catalog group timing to an operational wall-clock duration.
|
|
505
541
|
*
|
|
506
542
|
* `groupDurationTicks` wins when both wire fields are present, matching
|
|
507
|
-
* mmt-
|
|
543
|
+
* mmt-01 §4.4.2. The result may be fractional because exact frame cadences
|
|
508
544
|
* such as 33_333 ticks at 1 MHz cannot be represented by the wire catalog's
|
|
509
545
|
* integer `groupDurationMs` field.
|
|
510
546
|
*/
|
|
@@ -655,7 +691,6 @@ export type CmsfCatalog = {
|
|
|
655
691
|
version: number;
|
|
656
692
|
tracks: Record<string, unknown>[];
|
|
657
693
|
multicast?: Record<string, unknown>;
|
|
658
|
-
"multicast.auth"?: MulticastAuthConfig;
|
|
659
694
|
archive?: ArchiveConfig;
|
|
660
695
|
[key: string]: unknown;
|
|
661
696
|
};
|
|
@@ -672,6 +707,9 @@ export type CmsfCatalogErrorCode =
|
|
|
672
707
|
| "track_is_live"
|
|
673
708
|
| "track_codec"
|
|
674
709
|
| "track_mmtp_mode"
|
|
710
|
+
| "track_presentation_anchor"
|
|
711
|
+
| "track_init_ref"
|
|
712
|
+
| "catalog_init_data_list"
|
|
675
713
|
| "track_timescale"
|
|
676
714
|
| "track_group_duration_ms"
|
|
677
715
|
| "track_group_duration_ticks"
|
|
@@ -689,6 +727,8 @@ export type CmsfCatalogErrorCode =
|
|
|
689
727
|
| "track_repair_geometry"
|
|
690
728
|
| "track_switching_set"
|
|
691
729
|
| "multicast_auth"
|
|
730
|
+
| "multicast_endpoint"
|
|
731
|
+
| "multicast_endpoint_auth"
|
|
692
732
|
| "multicast_track"
|
|
693
733
|
| "multicast_packet_id"
|
|
694
734
|
| "multicast_relay_address"
|
|
@@ -710,8 +750,16 @@ function catalogError(code: CmsfCatalogErrorCode, path: string, message: string)
|
|
|
710
750
|
throw new CmsfCatalogValidationError(code, path, message);
|
|
711
751
|
}
|
|
712
752
|
|
|
713
|
-
/**
|
|
714
|
-
|
|
753
|
+
/**
|
|
754
|
+
* Validate the common CMSF shape and the MMTP required-field profile.
|
|
755
|
+
* `catalogNamespace`, the namespace of the catalog track, sharpens the
|
|
756
|
+
* foreign-namespace rule of draft -01 4.1; without it listed tracks are only
|
|
757
|
+
* compared with each other.
|
|
758
|
+
*/
|
|
759
|
+
export function validateCmsfMmtpCatalog(
|
|
760
|
+
value: unknown,
|
|
761
|
+
options: { catalogNamespace?: string } = {},
|
|
762
|
+
): CmsfCatalog {
|
|
715
763
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
716
764
|
catalogError("catalog_object", "$", "catalog must be an object");
|
|
717
765
|
}
|
|
@@ -748,6 +796,26 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
748
796
|
"commonTrackFields is retired; every track carries its own fields",
|
|
749
797
|
);
|
|
750
798
|
}
|
|
799
|
+
// mmt-01 4.5 / MSF 5.1.7: entries carry an id and a type; an "inline"
|
|
800
|
+
// entry carries its base64 init segment in data.
|
|
801
|
+
const initDataList = catalog["initDataList"];
|
|
802
|
+
if (initDataList !== undefined) {
|
|
803
|
+
if (!Array.isArray(initDataList)) {
|
|
804
|
+
catalogError("catalog_init_data_list", "$.initDataList", "initDataList must be an array");
|
|
805
|
+
}
|
|
806
|
+
initDataList.forEach((entry: unknown, i: number) => {
|
|
807
|
+
const e = entry as Record<string, unknown> | null;
|
|
808
|
+
const entryPath = `$.initDataList[${i}]`;
|
|
809
|
+
if (typeof e !== "object" || e === null || Array.isArray(e) ||
|
|
810
|
+
typeof e["id"] !== "string" || e["id"].length === 0 ||
|
|
811
|
+
typeof e["type"] !== "string" || e["type"].length === 0) {
|
|
812
|
+
catalogError("catalog_init_data_list", entryPath, "entry needs a non-empty string id and type");
|
|
813
|
+
}
|
|
814
|
+
if (e["type"] === "inline" && (typeof e["data"] !== "string" || e["data"].length === 0)) {
|
|
815
|
+
catalogError("catalog_init_data_list", `${entryPath}.data`, 'an "inline" entry needs non-empty data');
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}
|
|
751
819
|
const tracks = catalog["tracks"] as unknown[];
|
|
752
820
|
const trackRecords: Record<string, unknown>[] = [];
|
|
753
821
|
const positiveInteger = (input: unknown): input is number => Number.isSafeInteger(input) && (input as number) > 0;
|
|
@@ -805,6 +873,16 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
805
873
|
(keyframeIntervalTicks !== undefined && !positiveInteger(keyframeIntervalTicks))) {
|
|
806
874
|
catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
|
|
807
875
|
}
|
|
876
|
+
// mmt-01 4.4.1: a signed integer in the track's timescale.
|
|
877
|
+
const anchor = track["presentationAnchorTicks"];
|
|
878
|
+
if (anchor !== undefined && !Number.isSafeInteger(anchor)) {
|
|
879
|
+
catalogError("track_presentation_anchor", `${path}.presentationAnchorTicks`, "must be a safe integer");
|
|
880
|
+
}
|
|
881
|
+
// mmt-01 4.5: the id of a root initDataList entry.
|
|
882
|
+
const initRef = track["initRef"];
|
|
883
|
+
if (initRef !== undefined && (typeof initRef !== "string" || initRef.length === 0)) {
|
|
884
|
+
catalogError("track_init_ref", `${path}.initRef`, "must be a non-empty string");
|
|
885
|
+
}
|
|
808
886
|
// draft-ramadan-moq-fec §6.3: repair tracks describe themselves and carry
|
|
809
887
|
// no block geometry; media tracks never carry repair-track fields.
|
|
810
888
|
if (packaging === "fec-repair") {
|
|
@@ -814,9 +892,9 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
814
892
|
rejectRepairFieldsOnMediaTrack(path, track, catalogError);
|
|
815
893
|
}
|
|
816
894
|
if (packaging === "mmtp") {
|
|
817
|
-
|
|
818
|
-
if (mmtpMode
|
|
819
|
-
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be
|
|
895
|
+
// mmt-01 12.1: MUST be "mfu"; a subscriber rejects anything else.
|
|
896
|
+
if (track["mmtpMode"] !== "mfu") {
|
|
897
|
+
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mfu");
|
|
820
898
|
}
|
|
821
899
|
if (!positiveInteger(timescale)) {
|
|
822
900
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
@@ -841,8 +919,10 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
841
919
|
}
|
|
842
920
|
const config = fec as Record<string, unknown>;
|
|
843
921
|
const algorithm = config["algorithm"];
|
|
844
|
-
|
|
845
|
-
|
|
922
|
+
// Any token is valid (fec-01 4): a receiver that does not implement it
|
|
923
|
+
// plays the track without FEC (`fecAlgorithmUnimplemented`).
|
|
924
|
+
if (typeof algorithm !== "string" || algorithm.length === 0) {
|
|
925
|
+
catalogError("track_fec", `${path}.fec.algorithm`, "must be a non-empty string");
|
|
846
926
|
}
|
|
847
927
|
if ("interleaveDepth" in config || "interleaveMs" in config) {
|
|
848
928
|
catalogError("track_fec", `${path}.fec`, "interleaveDepthMs is the only supported interleave field");
|
|
@@ -875,6 +955,11 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
875
955
|
}
|
|
876
956
|
// Required on a declared FEC instance, optional but implemented on "none".
|
|
877
957
|
readFecBlockProfile(config["blockProfile"], `${path}.fec.blockProfile`, algorithm !== "none", catalogError);
|
|
958
|
+
// draft-ramadan-moq-fec-01 6.3.4 rule 13: an iso-ssbg1-v1 symbol shorter
|
|
959
|
+
// than 14 octets carries no protected MMTP packet (7.3).
|
|
960
|
+
if (algorithm !== "none" && (config["symbolSize"] as number) < ISO_SSBG1_MIN_SYMBOL_SIZE) {
|
|
961
|
+
catalogError("track_fec", `${path}.fec.symbolSize`, "iso-ssbg1-v1 symbolSize must be at least 14");
|
|
962
|
+
}
|
|
878
963
|
}
|
|
879
964
|
}
|
|
880
965
|
|
|
@@ -927,7 +1012,14 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
927
1012
|
);
|
|
928
1013
|
}
|
|
929
1014
|
|
|
930
|
-
|
|
1015
|
+
// mmt-01 §4.4: alternates share group boundaries so a subscriber can switch
|
|
1016
|
+
// at any of them. An intra-only member (one frame per group, e.g. the demo's
|
|
1017
|
+
// forceIOnly `video/base`) has a boundary at every frame, so it switches
|
|
1018
|
+
// cleanly with any GOP peer whose group duration is a whole number of its
|
|
1019
|
+
// groups. Such a member is checked for divisibility against the first GOP
|
|
1020
|
+
// member; every GOP member must still match that anchor exactly (BLO-49202).
|
|
1021
|
+
type SwitchingMember = { index: number; name: string; ticks: bigint; timescale: bigint; intraOnly: boolean };
|
|
1022
|
+
const switchingSets = new Map<number, SwitchingMember[]>();
|
|
931
1023
|
for (let index = 0; index < trackRecords.length; index++) {
|
|
932
1024
|
const track = trackRecords[index]!;
|
|
933
1025
|
if (track["packaging"] !== "mmtp") continue;
|
|
@@ -938,11 +1030,25 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
938
1030
|
const ticks = durationTicks !== undefined
|
|
939
1031
|
? BigInt(durationTicks as number)
|
|
940
1032
|
: BigInt(track["groupDurationMs"] as number) * timescale / 1000n;
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
|
|
1033
|
+
const framerate = track["framerate"];
|
|
1034
|
+
// Group duration == one frame period. `framerate` is a float (29.97), so
|
|
1035
|
+
// compare within 0.1%; a GOP track is off by a factor of >= 2.
|
|
1036
|
+
const intraOnly = positiveNumber(framerate) &&
|
|
1037
|
+
Math.abs(Number(ticks) * framerate - Number(timescale)) <= Number(timescale) * 1e-3;
|
|
1038
|
+
const members = switchingSets.get(altGroup as number) ?? [];
|
|
1039
|
+
members.push({ index, name: track["name"] as string, ticks, timescale, intraOnly });
|
|
1040
|
+
switchingSets.set(altGroup as number, members);
|
|
1041
|
+
}
|
|
1042
|
+
for (const [altGroup, members] of switchingSets) {
|
|
1043
|
+
const anchor = members.find((member) => !member.intraOnly) ?? members[0]!;
|
|
1044
|
+
for (const member of members) {
|
|
1045
|
+
if (member === anchor || member.ticks * anchor.timescale === anchor.ticks * member.timescale) continue;
|
|
1046
|
+
const nests = member.intraOnly && !anchor.intraOnly &&
|
|
1047
|
+
(anchor.ticks * member.timescale) % (member.ticks * anchor.timescale) === 0n;
|
|
1048
|
+
if (!nests) {
|
|
1049
|
+
catalogError("track_switching_set", `$.tracks[${member.index}]`, `group duration does not match ${JSON.stringify(anchor.name)} in altGroup ${altGroup}`);
|
|
1050
|
+
}
|
|
944
1051
|
}
|
|
945
|
-
if (!anchor) switchingSets.set(altGroup as number, { name: track["name"] as string, ticks, timescale });
|
|
946
1052
|
}
|
|
947
1053
|
|
|
948
1054
|
const multicast = catalog["multicast"];
|
|
@@ -995,15 +1101,11 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
995
1101
|
}
|
|
996
1102
|
}
|
|
997
1103
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
"$.multicast.auth",
|
|
1004
|
-
error instanceof Error ? error.message : "invalid multicast.auth v2 block",
|
|
1005
|
-
);
|
|
1006
|
-
}
|
|
1104
|
+
// draft -01 4.1 / 7.2.6: protocol and S, auth all-or-nothing, the key set,
|
|
1105
|
+
// tuple and manifestPort uniqueness, foreign-namespace tracks. Receivers
|
|
1106
|
+
// ignore what this rejects (`admittedMulticastEndpoints`).
|
|
1107
|
+
const [multicastIssue] = multicastCatalogIssues(catalog, options);
|
|
1108
|
+
if (multicastIssue) catalogError(multicastIssue.code, multicastIssue.path, multicastIssue.message);
|
|
1007
1109
|
|
|
1008
1110
|
validateArchive(catalog);
|
|
1009
1111
|
|
|
@@ -1012,7 +1114,7 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
1012
1114
|
|
|
1013
1115
|
/**
|
|
1014
1116
|
* Resolve a track's group duration to integer ticks using the supplied
|
|
1015
|
-
* timescale (Hz). Implements mmt-
|
|
1117
|
+
* timescale (Hz). Implements mmt-01 §4.4.2:
|
|
1016
1118
|
*
|
|
1017
1119
|
* - If `groupDurationTicks` is present, return it (override wins).
|
|
1018
1120
|
* - Else compute `groupDurationMs * timescale / 1000`. The result MUST
|
|
@@ -1047,7 +1149,7 @@ export function resolveGroupDurationTicks(
|
|
|
1047
1149
|
if (product % 1000 !== 0) {
|
|
1048
1150
|
throw new Error(
|
|
1049
1151
|
`[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} ` +
|
|
1050
|
-
`produces non-integer ticks (${product / 1000}); publisher must use groupDurationTicks override (mmt-
|
|
1152
|
+
`produces non-integer ticks (${product / 1000}); publisher must use groupDurationTicks override (mmt-01 §4.4.2)`,
|
|
1051
1153
|
);
|
|
1052
1154
|
}
|
|
1053
1155
|
return product / 1000;
|
|
@@ -1055,7 +1157,7 @@ export function resolveGroupDurationTicks(
|
|
|
1055
1157
|
|
|
1056
1158
|
/**
|
|
1057
1159
|
* Validate that every track in a switching set agrees on the same
|
|
1058
|
-
* wall-clock group duration (mmt-
|
|
1160
|
+
* wall-clock group duration (mmt-01 §4.4.2). Per-track timescales may
|
|
1059
1161
|
* differ, so raw tick counts cannot be compared directly.
|
|
1060
1162
|
*
|
|
1061
1163
|
* Returns `{ ok: true }` when all tracks agree (or the set is empty);
|
|
@@ -7,9 +7,16 @@
|
|
|
7
7
|
// player-agnostic.
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
+
catalogFecAvailable,
|
|
11
|
+
catalogFecDeclaresUnconfigurableInstance,
|
|
12
|
+
fecAlgorithmUnimplemented,
|
|
13
|
+
ISO_SSBG1_MIN_SYMBOL_SIZE,
|
|
10
14
|
FEC_BLOCK_PROFILES,
|
|
11
15
|
isFecBlockProfile,
|
|
16
|
+
locateCatalogFecSource,
|
|
12
17
|
parseFecBlockProfile,
|
|
18
|
+
type CatalogFecRole,
|
|
19
|
+
type CatalogFecSource,
|
|
13
20
|
type FecBlockProfile,
|
|
14
21
|
} from "@blockcast/mmt-base";
|
|
15
22
|
import { catalogFecInterleaveMs, type FecInterleaveCatalog } from "@blockcast/mmt-fec";
|
|
@@ -37,6 +44,16 @@ import type { RepairTarget } from "./repair-fetch.js";
|
|
|
37
44
|
|
|
38
45
|
export { catalogFecInterleaveMs, type FecInterleaveCatalog };
|
|
39
46
|
export { FEC_BLOCK_PROFILES, isFecBlockProfile, parseFecBlockProfile, type FecBlockProfile };
|
|
47
|
+
// The shared catalog FEC source rules (BLO-40851): one copy, in the leaf
|
|
48
|
+
// package transport and every player also read.
|
|
49
|
+
export {
|
|
50
|
+
catalogFecAvailable,
|
|
51
|
+
catalogFecDeclaresUnconfigurableInstance,
|
|
52
|
+
fecAlgorithmUnimplemented,
|
|
53
|
+
locateCatalogFecSource,
|
|
54
|
+
type CatalogFecRole,
|
|
55
|
+
type CatalogFecSource,
|
|
56
|
+
};
|
|
40
57
|
export {
|
|
41
58
|
assembleRepairLayers,
|
|
42
59
|
assertRepairTrackReachable,
|
|
@@ -160,7 +177,7 @@ function timescaleHz(value: unknown): number | undefined {
|
|
|
160
177
|
* carries none.
|
|
161
178
|
*
|
|
162
179
|
* `groupDurationTicks` over a timescale wins when both are present, through
|
|
163
|
-
* `resolveGroupDurationMs` (draft-ramadan-moq-mmt-
|
|
180
|
+
* `resolveGroupDurationMs` (draft-ramadan-moq-mmt-01 §4.4.2). The timescale is
|
|
164
181
|
* the MMTP container's when the rendition declares one, else the rendition's
|
|
165
182
|
* own `timescale`. Only the ticks are forwarded: a catalog `groupDurationMs`
|
|
166
183
|
* is often a rounded fraction (21.33 for 1024/48000), which the ticks path
|
|
@@ -287,7 +304,14 @@ export function catalogFecMediaUnitsPerSecond(
|
|
|
287
304
|
export type TrackFecUnavailable = {
|
|
288
305
|
/** The repair-contract code a catalog validator reports for the same field
|
|
289
306
|
* (`track_fec_block_span` excepted: an omitted span is valid shape). */
|
|
290
|
-
readonly code:
|
|
307
|
+
readonly code:
|
|
308
|
+
| "track_fec_block_profile"
|
|
309
|
+
| "track_fec_block_profile_unimplemented"
|
|
310
|
+
| "track_fec_block_span"
|
|
311
|
+
| "track_fec"
|
|
312
|
+
/** draft-ramadan-moq-fec-01 4: an `algorithm` this receiver does not
|
|
313
|
+
* implement. No validator reports it: such a catalog is valid. */
|
|
314
|
+
| "track_fec_algorithm_unimplemented";
|
|
291
315
|
/** JSON path of the offending field: `blockProfile`, or `interleaveDepthMs`. */
|
|
292
316
|
readonly path: string;
|
|
293
317
|
/** What is wrong, worded as the `RepairContractError` a validator throws. */
|
|
@@ -296,6 +320,11 @@ export type TrackFecUnavailable = {
|
|
|
296
320
|
|
|
297
321
|
export type TrackFecParams = {
|
|
298
322
|
fecK: number;
|
|
323
|
+
/** The FEC scheme the track's decoder runs (draft-ramadan-moq-fec-01 4):
|
|
324
|
+
* present exactly when the track has FEC. An absent catalog `algorithm`
|
|
325
|
+
* (the hang dialect) is RaptorQ; a token this receiver does not implement
|
|
326
|
+
* leaves the track without FEC (`track_fec_algorithm_unimplemented`). */
|
|
327
|
+
fecAlgorithm?: "raptorq" | "reed-solomon";
|
|
299
328
|
/** The catalog `fec.blockProfile` (BLO-35597, ISO/IEC 23008-1 Annex C).
|
|
300
329
|
* Present exactly when the track has FEC (`fecK > 0`) and absent on no
|
|
301
330
|
* FEC. The only profile is `iso-ssbg1-v1` (ssbg_mode1, K' = SSB_length,
|
|
@@ -416,8 +445,10 @@ export function resolveRepairLayers(
|
|
|
416
445
|
// beside a tracks[] switching-set index (the unified ABR ladder catalog),
|
|
417
446
|
// the rendition blocks are authoritative, exactly as they are for hang's own
|
|
418
447
|
// catalog decode. A typed ref resolves only within its own role.
|
|
448
|
+
// `locateCatalogFecSource` is that precedence rule, shared with transport's
|
|
449
|
+
// endpoint selection and the players' repair inventories.
|
|
419
450
|
const hang = catalog as CatalogWithRenditions;
|
|
420
|
-
const roles:
|
|
451
|
+
const roles: CatalogFecRole[] =
|
|
421
452
|
typeof source === "string"
|
|
422
453
|
? ["video", "audio"]
|
|
423
454
|
: source.type === "audio"
|
|
@@ -425,10 +456,10 @@ export function resolveRepairLayers(
|
|
|
425
456
|
: source.type === "video"
|
|
426
457
|
? ["video"]
|
|
427
458
|
: ["video", "audio"];
|
|
428
|
-
const
|
|
429
|
-
if (
|
|
430
|
-
const renditionPath = `$.${role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
431
|
-
const rendition =
|
|
459
|
+
const located = locateCatalogFecSource(catalog, sourceName, roles);
|
|
460
|
+
if (located?.dialect === "hang") {
|
|
461
|
+
const renditionPath = `$.${located.role}.renditions[${JSON.stringify(sourceName)}]`;
|
|
462
|
+
const rendition = located.entry;
|
|
432
463
|
rejectRepairFieldsOnMediaTrack(renditionPath, rendition, throwRepairContractError);
|
|
433
464
|
const repairRenditions = recordOf(hang.repair?.renditions) ?? {};
|
|
434
465
|
const descriptors: RepairTrackDescriptor[] = Object.entries(repairRenditions).map(([name, entry]) => {
|
|
@@ -473,8 +504,8 @@ export function resolveRepairLayers(
|
|
|
473
504
|
}
|
|
474
505
|
|
|
475
506
|
const msf = msfTracks(catalog);
|
|
476
|
-
|
|
477
|
-
|
|
507
|
+
if (!msf || located?.dialect !== "msf") return undefined;
|
|
508
|
+
const msfIndex = located.index;
|
|
478
509
|
const track = msf.tracks[msfIndex]!;
|
|
479
510
|
const fec = recordOf(track["fec"]);
|
|
480
511
|
const packagingOf = (t: Record<string, unknown>): unknown => t["packaging"];
|
|
@@ -653,19 +684,33 @@ function isoSpanUnavailable(
|
|
|
653
684
|
* `iso-ssbg1-v1` instance, carries no usable block span. Returns undefined for
|
|
654
685
|
* a non-object and for every block whose FEC is available. It reads only the
|
|
655
686
|
* profile and the span: malformed geometry (`sourceSymbols`, `symbolSize`, ...)
|
|
656
|
-
* is the caller's to reject, and takes precedence. Never throws
|
|
687
|
+
* is the caller's to reject, and takes precedence. Never throws on catalog
|
|
688
|
+
* input: whether FEC is available is `catalogFecAvailable` (mmt-base), and a
|
|
689
|
+
* test pins that every unavailable block gets a reason here.
|
|
657
690
|
*
|
|
658
691
|
* @param fec the track's catalog `fec` value.
|
|
659
692
|
* @param fecPath JSON path of that `fec` block; the reason's `path` extends it.
|
|
660
693
|
*/
|
|
661
694
|
export function catalogFecUnavailable(fec: unknown, fecPath: string): TrackFecUnavailable | undefined {
|
|
662
|
-
|
|
663
|
-
|
|
695
|
+
// The decision is mmt-base's `catalogFecAvailable`, which transport reads
|
|
696
|
+
// too; this function only explains a negative one.
|
|
697
|
+
if (catalogFecAvailable(fec)) return undefined;
|
|
698
|
+
const block = recordOf(fec)!;
|
|
699
|
+
if (fecAlgorithmUnimplemented(block["algorithm"])) {
|
|
700
|
+
return Object.freeze({
|
|
701
|
+
code: "track_fec_algorithm_unimplemented",
|
|
702
|
+
path: `${fecPath}.algorithm`,
|
|
703
|
+
message: `algorithm ${JSON.stringify(block["algorithm"])} is not implemented: the track plays without FEC`,
|
|
704
|
+
});
|
|
705
|
+
}
|
|
664
706
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
665
|
-
|
|
707
|
+
const reason =
|
|
666
708
|
blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ??
|
|
667
|
-
isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance)
|
|
668
|
-
)
|
|
709
|
+
isoSpanUnavailable(block, `${fecPath}.interleaveDepthMs`, declaresFecInstance);
|
|
710
|
+
if (reason === undefined) {
|
|
711
|
+
throw new Error(`catalogFecUnavailable: ${fecPath} is unavailable but no reason applies (rule drift)`);
|
|
712
|
+
}
|
|
713
|
+
return reason;
|
|
669
714
|
}
|
|
670
715
|
|
|
671
716
|
/**
|
|
@@ -701,10 +746,8 @@ function fecParams(
|
|
|
701
746
|
// and T are positive integers, the algorithm is not `none`, and the block
|
|
702
747
|
// profile is known.
|
|
703
748
|
if (!catalogDeclaresFec(fec)) {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const tValid = Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0;
|
|
707
|
-
if (declaresFecInstance && !(kValid && tValid)) {
|
|
749
|
+
if (catalogFecDeclaresUnconfigurableInstance(fec)) {
|
|
750
|
+
const kValid = Number.isSafeInteger(fec.sourceSymbols) && (fec.sourceSymbols ?? 0) > 0;
|
|
708
751
|
// Any algorithm but `none` declares an FEC instance, so geometry a
|
|
709
752
|
// decoder cannot configure is a malformed catalog, not "no FEC".
|
|
710
753
|
// Returning NO_FEC would silently drop the track's repair
|
|
@@ -712,7 +755,9 @@ function fecParams(
|
|
|
712
755
|
throwRepairContractError(
|
|
713
756
|
"track_fec",
|
|
714
757
|
`${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
|
|
715
|
-
|
|
758
|
+
kValid && Number.isSafeInteger(fec.symbolSize) && (fec.symbolSize ?? 0) > 0
|
|
759
|
+
? `iso-ssbg1-v1 symbolSize must be at least ${ISO_SSBG1_MIN_SYMBOL_SIZE}`
|
|
760
|
+
: "must be a positive integer",
|
|
716
761
|
);
|
|
717
762
|
}
|
|
718
763
|
// What remains is `algorithm: "none"` (which carries no profile; a token
|
|
@@ -726,6 +771,7 @@ function fecParams(
|
|
|
726
771
|
const fecBlockProfile = readFecBlockProfile(fec.blockProfile, `${fecPath}.blockProfile`, true, throwRepairContractError);
|
|
727
772
|
return {
|
|
728
773
|
fecK: fec.sourceSymbols ?? 0,
|
|
774
|
+
fecAlgorithm: fec.algorithm === "reed-solomon" ? "reed-solomon" : "raptorq",
|
|
729
775
|
fecBlockProfile,
|
|
730
776
|
fecRepairCount: fec.repairSymbols ?? 0,
|
|
731
777
|
// The wire RSB_length: every base layer's packets carry the base total (§7.1).
|