@blockcast/mmt-container 0.4.0-main.bbd83cb48eff → 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 +31 -17
- 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 +1192 -375
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +67 -31
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +291 -199
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +12 -4
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +40 -17
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.d.ts +24 -2
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js +21 -1
- package/dist/catalog-network-source.js.map +2 -2
- package/dist/catalog-validator.d.ts +4 -3
- package/dist/catalog-validator.d.ts.map +1 -1
- package/dist/catalog-validator.js +0 -29
- package/dist/catalog-validator.js.map +3 -3
- package/dist/delivery-catalog.js +18 -12
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/fec-manager.d.ts +49 -1
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +176 -23
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-state.d.ts +2 -1
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +18 -3
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.d.ts +2 -0
- package/dist/fec-worker-setup.d.ts.map +1 -1
- package/dist/fec-worker-setup.js +2 -1
- package/dist/fec-worker-setup.js.map +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +29 -0
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +97 -17
- package/dist/iso-block-locator.js.map +3 -3
- 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.map +2 -2
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +1014 -289
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- 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 +17 -1
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +29 -0
- package/dist/mmtp-router.js.map +2 -2
- package/dist/multicast-auth-catalog.d.ts +86 -92
- package/dist/multicast-auth-catalog.d.ts.map +1 -1
- package/dist/multicast-auth-catalog.js +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 +290 -28
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +40 -5
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +293 -54
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.d.ts +6 -0
- package/dist/multicast-transport.d.ts.map +1 -1
- package/dist/multicast-transport.js +18 -11
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js.map +2 -2
- package/dist/no-modules.d.ts +4 -1
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +964 -274
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +1 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +2 -2
- package/dist/phase14-catalog-override.js.map +2 -2
- package/dist/repair-fetch.d.ts +81 -6
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +156 -31
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.d.ts +2 -0
- package/dist/repair-layers.d.ts.map +1 -1
- package/dist/repair-layers.js +19 -2
- package/dist/repair-layers.js.map +2 -2
- package/dist/signaling.d.ts +2 -2
- package/dist/signaling.d.ts.map +1 -1
- package/dist/signaling.js +3 -3
- package/dist/signaling.js.map +2 -2
- package/dist/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.map +2 -2
- package/dist/wasm-mfu-reassembler.js.map +1 -1
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +6 -9
- package/schemas/catalog.schema.json +124 -37
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +131 -52
- package/src/catalog-fec-params.ts +28 -3
- package/src/catalog-network-source.ts +45 -2
- package/src/catalog-validator.ts +4 -11
- package/src/fec-manager.ts +128 -14
- package/src/fec-state.ts +11 -4
- package/src/fec-worker-setup.ts +4 -1
- package/src/index.ts +24 -10
- package/src/iso-block-locator.ts +97 -6
- package/src/manifest-auth-plan.ts +39 -91
- package/src/mmtp-fec-session.ts +533 -0
- package/src/mmtp-router.ts +57 -0
- package/src/multicast-auth-catalog.ts +131 -238
- package/src/multicast-input.ts +119 -61
- package/src/multicast-manager.ts +115 -14
- package/src/multicast-transport.ts +3 -0
- 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/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 +60 -3
- 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 +6 -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,
|
|
@@ -164,7 +166,10 @@ export function validateSwitchingSet(
|
|
|
164
166
|
|
|
165
167
|
// ── FEC Catalog Extension (CARP §3.2) ─────────────────────────
|
|
166
168
|
|
|
167
|
-
|
|
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 & {});
|
|
168
173
|
|
|
169
174
|
export interface FecCatalogConfig {
|
|
170
175
|
/** FEC algorithm identifier (REQUIRED per §4.1, values per §3.1). */
|
|
@@ -201,9 +206,9 @@ export interface FecCatalogConfig {
|
|
|
201
206
|
* per draft-ramadan-moq-fec §6.3, never listed here. */
|
|
202
207
|
repairTrack: string;
|
|
203
208
|
/** FEC block mode: "interleaved" (default) or "object" (per-frame). */
|
|
204
|
-
//
|
|
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)
|
|
205
210
|
mode?: "interleaved" | "object";
|
|
206
|
-
/** UEP (Unequal Error Protection) —
|
|
211
|
+
/** UEP (Unequal Error Protection) — Blockcast extension, not in draft-ramadan-moq-fec-01. When present, repair count
|
|
207
212
|
* varies per frame type. repairSymbols becomes the base (P-frame) count.
|
|
208
213
|
* MUST be omitted on multi-track base/delta streams (D-08). */
|
|
209
214
|
uep?: {
|
|
@@ -245,7 +250,7 @@ export interface FecCatalogConfig {
|
|
|
245
250
|
|
|
246
251
|
/**
|
|
247
252
|
* Whether a catalog `fec` block carries the FEC instance geometry a receiver
|
|
248
|
-
* configures, its block profile aside: a
|
|
253
|
+
* configures, its block profile aside: a non-empty `algorithm` token, positive
|
|
249
254
|
* `sourceSymbols`, `repairSymbols` and `symbolSize` (8-byte aligned for
|
|
250
255
|
* RaptorQ), and a non-empty `repairTrack`. A block that fails this is
|
|
251
256
|
* malformed whatever its profile. Total: never throws.
|
|
@@ -256,8 +261,7 @@ export function isFecCatalogGeometry(obj: unknown): boolean {
|
|
|
256
261
|
const algorithm = o["algorithm"];
|
|
257
262
|
const symbolSize = o["symbolSize"];
|
|
258
263
|
return (
|
|
259
|
-
typeof algorithm === "string" &&
|
|
260
|
-
(algorithm === "none" || algorithm === "raptorq" || algorithm === "reed-solomon") &&
|
|
264
|
+
typeof algorithm === "string" && algorithm.length > 0 &&
|
|
261
265
|
typeof o["sourceSymbols"] === "number" && o["sourceSymbols"] >= 1 &&
|
|
262
266
|
typeof o["repairSymbols"] === "number" && o["repairSymbols"] >= 1 &&
|
|
263
267
|
typeof symbolSize === "number" && symbolSize >= 1 &&
|
|
@@ -282,10 +286,18 @@ export function isFecCatalogConfig(obj: unknown): obj is FecCatalogConfig {
|
|
|
282
286
|
|
|
283
287
|
// ── Multicast Catalog Extension (CARP §4.1-4.4) ───────────────
|
|
284
288
|
|
|
285
|
-
|
|
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";
|
|
286
298
|
|
|
287
299
|
/**
|
|
288
|
-
* Per-track endpoint membership, per draft-ramadan-moq-multicast-
|
|
300
|
+
* Per-track endpoint membership, per draft-ramadan-moq-multicast-01 §4.1.
|
|
289
301
|
*
|
|
290
302
|
* `packetId` is the MMTP packet_id used for packet-level demux on the
|
|
291
303
|
* multicast wire, in 1..65535: packet_id 0 (`MMTP_SIGNALING_PACKET_ID`) is
|
|
@@ -303,9 +315,9 @@ export interface MulticastTrackObject {
|
|
|
303
315
|
export type MulticastTrack = string | MulticastTrackObject;
|
|
304
316
|
|
|
305
317
|
export interface MulticastEndpoint {
|
|
306
|
-
/**
|
|
318
|
+
/** Restates the mode `sourceAddress` selects; an endpoint where it disagrees is ignored. */
|
|
307
319
|
protocol?: MulticastProtocol;
|
|
308
|
-
/** SSM source
|
|
320
|
+
/** SSM source address; its absence selects ASM. */
|
|
309
321
|
sourceAddress?: string;
|
|
310
322
|
/** Multicast group address (REQUIRED). */
|
|
311
323
|
groupAddress: string;
|
|
@@ -322,20 +334,31 @@ export interface MulticastEndpoint {
|
|
|
322
334
|
tracks: MulticastTrack[];
|
|
323
335
|
/**
|
|
324
336
|
* Aggregate bandwidth of this endpoint in bits per second.
|
|
325
|
-
* 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).
|
|
326
339
|
*/
|
|
327
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[];
|
|
328
348
|
}
|
|
329
349
|
|
|
330
|
-
export type AmtDiscovery = "driad" | "manual";
|
|
350
|
+
export type AmtDiscovery = "dns" | "driad" | "manual";
|
|
331
351
|
|
|
332
352
|
/**
|
|
333
353
|
* One `multicast.networkSource[]` entry, per draft-ramadan-moq-multicast §4.1.
|
|
334
354
|
*
|
|
335
355
|
* Mirrors moq-rs `NetworkSource` (the normative validator) and the
|
|
336
356
|
* `networkSource` `$def` in `catalog.schema.json` 1:1 — a change here needs the
|
|
337
|
-
* same change in both. `discovery
|
|
338
|
-
*
|
|
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
|
|
339
362
|
* runtime, so `relay` is OPTIONAL and, when present, only a discovery hint
|
|
340
363
|
* (e.g. the `amtFallback.relayDns` name the derived path carries over): readers
|
|
341
364
|
* do not join it (`findAmtRelay` in packages/transport
|
|
@@ -355,12 +378,25 @@ export type AmtDiscovery = "driad" | "manual";
|
|
|
355
378
|
* reject catalogs already in the wild, so when this type changes, widen the
|
|
356
379
|
* reader only if the new shape must be consumed; never narrow it to match.
|
|
357
380
|
*
|
|
358
|
-
* This is the one place a catalog declares an AMT relay
|
|
359
|
-
*
|
|
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.
|
|
360
384
|
*/
|
|
361
385
|
export type NetworkSource =
|
|
362
|
-
| { type: "amt"; discovery
|
|
363
|
-
| {
|
|
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
|
+
};
|
|
364
400
|
|
|
365
401
|
export interface MulticastCatalogConfig {
|
|
366
402
|
/** Enable/disable multicast (OPTIONAL, default true). */
|
|
@@ -368,12 +404,13 @@ export interface MulticastCatalogConfig {
|
|
|
368
404
|
/** Multicast endpoints (REQUIRED). */
|
|
369
405
|
endpoints: MulticastEndpoint[];
|
|
370
406
|
/**
|
|
371
|
-
* Relay/tuning discovery
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
* 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.
|
|
375
410
|
*/
|
|
376
411
|
networkSource?: NetworkSource[];
|
|
412
|
+
/** bc-provenance version 2 profile and keys (7.2.6). */
|
|
413
|
+
auth?: MulticastAuthConfig;
|
|
377
414
|
/**
|
|
378
415
|
* AMT fallback configuration.
|
|
379
416
|
*
|
|
@@ -425,11 +462,8 @@ export function isMulticastTrackObject(obj: unknown): obj is MulticastTrackObjec
|
|
|
425
462
|
export function isMulticastEndpoint(obj: unknown): obj is MulticastEndpoint {
|
|
426
463
|
if (typeof obj !== "object" || obj === null) return false;
|
|
427
464
|
const o = obj as Record<string, unknown>;
|
|
428
|
-
const protocol = o["protocol"] ??
|
|
429
|
-
(typeof o["sourceAddress"] === "string" && o["sourceAddress"].length > 0 ? "ssm" : undefined);
|
|
430
465
|
return (
|
|
431
|
-
|
|
432
|
-
(protocol === "ssm" || protocol === "asm" || protocol === "amt" || protocol === "atsc3") &&
|
|
466
|
+
multicastEndpointSource(o) !== undefined &&
|
|
433
467
|
typeof o["groupAddress"] === "string" && (o["groupAddress"] as string).length > 0 &&
|
|
434
468
|
typeof o["port"] === "number" && (o["port"] as number) > 0 && (o["port"] as number) <= 65535 &&
|
|
435
469
|
Array.isArray(o["tracks"]) &&
|
|
@@ -458,7 +492,7 @@ export function isMulticastCatalogConfig(obj: unknown): obj is MulticastCatalogC
|
|
|
458
492
|
);
|
|
459
493
|
}
|
|
460
494
|
|
|
461
|
-
// ── Track Timing (mmt-
|
|
495
|
+
// ── Track Timing (mmt-01 §4.4.2) ──────────────────────────────
|
|
462
496
|
|
|
463
497
|
/**
|
|
464
498
|
* Per-track group-duration signaling.
|
|
@@ -474,9 +508,9 @@ export function isMulticastCatalogConfig(obj: unknown): obj is MulticastCatalogC
|
|
|
474
508
|
* (e.g. 44 100 Hz × 333 ms = 14 685.3 ticks).
|
|
475
509
|
*
|
|
476
510
|
* If both fields are present, `groupDurationTicks` wins (matches the
|
|
477
|
-
* spec, mmt-
|
|
511
|
+
* spec, mmt-01 §4.4.2).
|
|
478
512
|
*
|
|
479
|
-
* @see draft-ramadan-moq-mmt-
|
|
513
|
+
* @see draft-ramadan-moq-mmt-01 §4.4.2
|
|
480
514
|
* @see ./align.ts groupIdForTicks
|
|
481
515
|
*/
|
|
482
516
|
export interface TrackTimingConfig {
|
|
@@ -506,7 +540,7 @@ export function isTrackTimingConfig(obj: unknown): obj is TrackTimingConfig {
|
|
|
506
540
|
/** Resolve catalog group timing to an operational wall-clock duration.
|
|
507
541
|
*
|
|
508
542
|
* `groupDurationTicks` wins when both wire fields are present, matching
|
|
509
|
-
* mmt-
|
|
543
|
+
* mmt-01 §4.4.2. The result may be fractional because exact frame cadences
|
|
510
544
|
* such as 33_333 ticks at 1 MHz cannot be represented by the wire catalog's
|
|
511
545
|
* integer `groupDurationMs` field.
|
|
512
546
|
*/
|
|
@@ -657,7 +691,6 @@ export type CmsfCatalog = {
|
|
|
657
691
|
version: number;
|
|
658
692
|
tracks: Record<string, unknown>[];
|
|
659
693
|
multicast?: Record<string, unknown>;
|
|
660
|
-
"multicast.auth"?: MulticastAuthConfig;
|
|
661
694
|
archive?: ArchiveConfig;
|
|
662
695
|
[key: string]: unknown;
|
|
663
696
|
};
|
|
@@ -674,6 +707,9 @@ export type CmsfCatalogErrorCode =
|
|
|
674
707
|
| "track_is_live"
|
|
675
708
|
| "track_codec"
|
|
676
709
|
| "track_mmtp_mode"
|
|
710
|
+
| "track_presentation_anchor"
|
|
711
|
+
| "track_init_ref"
|
|
712
|
+
| "catalog_init_data_list"
|
|
677
713
|
| "track_timescale"
|
|
678
714
|
| "track_group_duration_ms"
|
|
679
715
|
| "track_group_duration_ticks"
|
|
@@ -691,6 +727,8 @@ export type CmsfCatalogErrorCode =
|
|
|
691
727
|
| "track_repair_geometry"
|
|
692
728
|
| "track_switching_set"
|
|
693
729
|
| "multicast_auth"
|
|
730
|
+
| "multicast_endpoint"
|
|
731
|
+
| "multicast_endpoint_auth"
|
|
694
732
|
| "multicast_track"
|
|
695
733
|
| "multicast_packet_id"
|
|
696
734
|
| "multicast_relay_address"
|
|
@@ -712,8 +750,16 @@ function catalogError(code: CmsfCatalogErrorCode, path: string, message: string)
|
|
|
712
750
|
throw new CmsfCatalogValidationError(code, path, message);
|
|
713
751
|
}
|
|
714
752
|
|
|
715
|
-
/**
|
|
716
|
-
|
|
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 {
|
|
717
763
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
718
764
|
catalogError("catalog_object", "$", "catalog must be an object");
|
|
719
765
|
}
|
|
@@ -750,6 +796,26 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
750
796
|
"commonTrackFields is retired; every track carries its own fields",
|
|
751
797
|
);
|
|
752
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
|
+
}
|
|
753
819
|
const tracks = catalog["tracks"] as unknown[];
|
|
754
820
|
const trackRecords: Record<string, unknown>[] = [];
|
|
755
821
|
const positiveInteger = (input: unknown): input is number => Number.isSafeInteger(input) && (input as number) > 0;
|
|
@@ -807,6 +873,16 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
807
873
|
(keyframeIntervalTicks !== undefined && !positiveInteger(keyframeIntervalTicks))) {
|
|
808
874
|
catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
|
|
809
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
|
+
}
|
|
810
886
|
// draft-ramadan-moq-fec §6.3: repair tracks describe themselves and carry
|
|
811
887
|
// no block geometry; media tracks never carry repair-track fields.
|
|
812
888
|
if (packaging === "fec-repair") {
|
|
@@ -816,9 +892,9 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
816
892
|
rejectRepairFieldsOnMediaTrack(path, track, catalogError);
|
|
817
893
|
}
|
|
818
894
|
if (packaging === "mmtp") {
|
|
819
|
-
|
|
820
|
-
if (mmtpMode
|
|
821
|
-
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");
|
|
822
898
|
}
|
|
823
899
|
if (!positiveInteger(timescale)) {
|
|
824
900
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
@@ -843,8 +919,10 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
843
919
|
}
|
|
844
920
|
const config = fec as Record<string, unknown>;
|
|
845
921
|
const algorithm = config["algorithm"];
|
|
846
|
-
|
|
847
|
-
|
|
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");
|
|
848
926
|
}
|
|
849
927
|
if ("interleaveDepth" in config || "interleaveMs" in config) {
|
|
850
928
|
catalogError("track_fec", `${path}.fec`, "interleaveDepthMs is the only supported interleave field");
|
|
@@ -877,6 +955,11 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
877
955
|
}
|
|
878
956
|
// Required on a declared FEC instance, optional but implemented on "none".
|
|
879
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
|
+
}
|
|
880
963
|
}
|
|
881
964
|
}
|
|
882
965
|
|
|
@@ -929,7 +1012,7 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
929
1012
|
);
|
|
930
1013
|
}
|
|
931
1014
|
|
|
932
|
-
// mmt-
|
|
1015
|
+
// mmt-01 §4.4: alternates share group boundaries so a subscriber can switch
|
|
933
1016
|
// at any of them. An intra-only member (one frame per group, e.g. the demo's
|
|
934
1017
|
// forceIOnly `video/base`) has a boundary at every frame, so it switches
|
|
935
1018
|
// cleanly with any GOP peer whose group duration is a whole number of its
|
|
@@ -1018,15 +1101,11 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
1018
1101
|
}
|
|
1019
1102
|
}
|
|
1020
1103
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
"$.multicast.auth",
|
|
1027
|
-
error instanceof Error ? error.message : "invalid multicast.auth v2 block",
|
|
1028
|
-
);
|
|
1029
|
-
}
|
|
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);
|
|
1030
1109
|
|
|
1031
1110
|
validateArchive(catalog);
|
|
1032
1111
|
|
|
@@ -1035,7 +1114,7 @@ export function validateCmsfMmtpCatalog(value: unknown): CmsfCatalog {
|
|
|
1035
1114
|
|
|
1036
1115
|
/**
|
|
1037
1116
|
* Resolve a track's group duration to integer ticks using the supplied
|
|
1038
|
-
* timescale (Hz). Implements mmt-
|
|
1117
|
+
* timescale (Hz). Implements mmt-01 §4.4.2:
|
|
1039
1118
|
*
|
|
1040
1119
|
* - If `groupDurationTicks` is present, return it (override wins).
|
|
1041
1120
|
* - Else compute `groupDurationMs * timescale / 1000`. The result MUST
|
|
@@ -1070,7 +1149,7 @@ export function resolveGroupDurationTicks(
|
|
|
1070
1149
|
if (product % 1000 !== 0) {
|
|
1071
1150
|
throw new Error(
|
|
1072
1151
|
`[carp-catalog] resolveGroupDurationTicks: groupDurationMs=${timing.groupDurationMs} at timescale=${timescale} ` +
|
|
1073
|
-
`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)`,
|
|
1074
1153
|
);
|
|
1075
1154
|
}
|
|
1076
1155
|
return product / 1000;
|
|
@@ -1078,7 +1157,7 @@ export function resolveGroupDurationTicks(
|
|
|
1078
1157
|
|
|
1079
1158
|
/**
|
|
1080
1159
|
* Validate that every track in a switching set agrees on the same
|
|
1081
|
-
* wall-clock group duration (mmt-
|
|
1160
|
+
* wall-clock group duration (mmt-01 §4.4.2). Per-track timescales may
|
|
1082
1161
|
* differ, so raw tick counts cannot be compared directly.
|
|
1083
1162
|
*
|
|
1084
1163
|
* Returns `{ ok: true }` when all tracks agree (or the set is empty);
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import {
|
|
10
10
|
catalogFecAvailable,
|
|
11
11
|
catalogFecDeclaresUnconfigurableInstance,
|
|
12
|
+
fecAlgorithmUnimplemented,
|
|
13
|
+
ISO_SSBG1_MIN_SYMBOL_SIZE,
|
|
12
14
|
FEC_BLOCK_PROFILES,
|
|
13
15
|
isFecBlockProfile,
|
|
14
16
|
locateCatalogFecSource,
|
|
@@ -47,6 +49,7 @@ export { FEC_BLOCK_PROFILES, isFecBlockProfile, parseFecBlockProfile, type FecBl
|
|
|
47
49
|
export {
|
|
48
50
|
catalogFecAvailable,
|
|
49
51
|
catalogFecDeclaresUnconfigurableInstance,
|
|
52
|
+
fecAlgorithmUnimplemented,
|
|
50
53
|
locateCatalogFecSource,
|
|
51
54
|
type CatalogFecRole,
|
|
52
55
|
type CatalogFecSource,
|
|
@@ -174,7 +177,7 @@ function timescaleHz(value: unknown): number | undefined {
|
|
|
174
177
|
* carries none.
|
|
175
178
|
*
|
|
176
179
|
* `groupDurationTicks` over a timescale wins when both are present, through
|
|
177
|
-
* `resolveGroupDurationMs` (draft-ramadan-moq-mmt-
|
|
180
|
+
* `resolveGroupDurationMs` (draft-ramadan-moq-mmt-01 §4.4.2). The timescale is
|
|
178
181
|
* the MMTP container's when the rendition declares one, else the rendition's
|
|
179
182
|
* own `timescale`. Only the ticks are forwarded: a catalog `groupDurationMs`
|
|
180
183
|
* is often a rounded fraction (21.33 for 1024/48000), which the ticks path
|
|
@@ -301,7 +304,14 @@ export function catalogFecMediaUnitsPerSecond(
|
|
|
301
304
|
export type TrackFecUnavailable = {
|
|
302
305
|
/** The repair-contract code a catalog validator reports for the same field
|
|
303
306
|
* (`track_fec_block_span` excepted: an omitted span is valid shape). */
|
|
304
|
-
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";
|
|
305
315
|
/** JSON path of the offending field: `blockProfile`, or `interleaveDepthMs`. */
|
|
306
316
|
readonly path: string;
|
|
307
317
|
/** What is wrong, worded as the `RepairContractError` a validator throws. */
|
|
@@ -310,6 +320,11 @@ export type TrackFecUnavailable = {
|
|
|
310
320
|
|
|
311
321
|
export type TrackFecParams = {
|
|
312
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";
|
|
313
328
|
/** The catalog `fec.blockProfile` (BLO-35597, ISO/IEC 23008-1 Annex C).
|
|
314
329
|
* Present exactly when the track has FEC (`fecK > 0`) and absent on no
|
|
315
330
|
* FEC. The only profile is `iso-ssbg1-v1` (ssbg_mode1, K' = SSB_length,
|
|
@@ -681,6 +696,13 @@ export function catalogFecUnavailable(fec: unknown, fecPath: string): TrackFecUn
|
|
|
681
696
|
// too; this function only explains a negative one.
|
|
682
697
|
if (catalogFecAvailable(fec)) return undefined;
|
|
683
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
|
+
}
|
|
684
706
|
const declaresFecInstance = block["algorithm"] !== "none";
|
|
685
707
|
const reason =
|
|
686
708
|
blockProfileUnavailable(block["blockProfile"], `${fecPath}.blockProfile`, declaresFecInstance) ??
|
|
@@ -733,7 +755,9 @@ function fecParams(
|
|
|
733
755
|
throwRepairContractError(
|
|
734
756
|
"track_fec",
|
|
735
757
|
`${fecPath}.${kValid ? "symbolSize" : "sourceSymbols"}`,
|
|
736
|
-
|
|
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",
|
|
737
761
|
);
|
|
738
762
|
}
|
|
739
763
|
// What remains is `algorithm: "none"` (which carries no profile; a token
|
|
@@ -747,6 +771,7 @@ function fecParams(
|
|
|
747
771
|
const fecBlockProfile = readFecBlockProfile(fec.blockProfile, `${fecPath}.blockProfile`, true, throwRepairContractError);
|
|
748
772
|
return {
|
|
749
773
|
fecK: fec.sourceSymbols ?? 0,
|
|
774
|
+
fecAlgorithm: fec.algorithm === "reed-solomon" ? "reed-solomon" : "raptorq",
|
|
750
775
|
fecBlockProfile,
|
|
751
776
|
fecRepairCount: fec.repairSymbols ?? 0,
|
|
752
777
|
// The wire RSB_length: every base layer's packets carry the base total (§7.1).
|
|
@@ -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
|
}
|