@blockcast/mmt-container 0.4.0-main.69dc82f179f9 → 0.4.0-main.6bb81fa1d59e
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 +3 -2
- 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 +64 -19
- package/dist/browser-runtime.js.map +2 -2
- package/dist/carp-catalog.d.ts +8 -5
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +26 -3
- package/dist/carp-catalog.js.map +2 -2
- package/dist/catalog-fec-params.js.map +2 -2
- package/dist/catalog-network-source.d.ts +1 -1
- package/dist/catalog-network-source.d.ts.map +1 -1
- package/dist/catalog-network-source.js.map +1 -1
- package/dist/mmtp-container-parser.no-modules.js +26 -3
- package/dist/mmtp-container-parser.no-modules.js.map +2 -2
- package/dist/multicast-input.d.ts +1 -1
- package/dist/multicast-input.d.ts.map +1 -1
- package/dist/multicast-input.js +13 -10
- package/dist/multicast-input.js.map +2 -2
- package/dist/multicast-manager.js.map +1 -1
- package/dist/no-modules.js +26 -3
- package/dist/no-modules.js.map +2 -2
- 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/package.json +5 -5
- package/schemas/catalog.schema.json +36 -6
- package/src/align.ts +52 -21
- package/src/carp-catalog.ts +43 -7
- package/src/catalog-network-source.ts +1 -1
- package/src/multicast-input.ts +21 -17
- package/src/phase14-catalog-override.ts +3 -3
- package/test-vectors/align.json +108 -32
- package/test-vectors/bc-provenance-v2.json +1374 -0
- package/test-vectors/catalog/README.md +17 -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/presentation-anchor-unsafe.json +16 -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/presentation-anchor-negative.json +27 -0
- package/test-vectors/catalog/section-codes.json +4 -0
- package/test-vectors/generate-bc-provenance-v2.mjs +233 -0
package/README.md
CHANGED
|
@@ -203,9 +203,10 @@ interface MulticastEndpoint {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
// Relay/tuning discovery is catalog-level, not per-endpoint:
|
|
206
|
-
// multicast.networkSource: [{ type: "amt", discovery
|
|
206
|
+
// multicast.networkSource: [{ type: "amt", discovery?: "dns" | "driad" | "manual",
|
|
207
207
|
// relay?: string, port?: number }]
|
|
208
|
-
// `relay` is REQUIRED for
|
|
208
|
+
// `relay` is REQUIRED for "dns" and "manual"; "driad" resolves it at runtime.
|
|
209
|
+
// An omitted `discovery` with a hostname relay is "dns" (multicast-01 4.2.1).
|
|
209
210
|
// An endpoint-level `relayAddress` is retired — the schema, moq-rs and
|
|
210
211
|
// `validateCmsfMmtpCatalog` (`multicast_relay_address`) all reject it.
|
|
211
212
|
|
package/dist/align.d.ts
CHANGED
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
* ──────────────────────────────────────────────────────────────────────────
|
|
9
9
|
* Contract (integer-ticks form, authoritative):
|
|
10
10
|
*
|
|
11
|
-
* groupId =
|
|
11
|
+
* groupId = floor((ticks - presentationAnchorTicks) / groupDurationTicks)
|
|
12
12
|
*
|
|
13
13
|
* Where `ticks` is a media timestamp expressed at the catalog's `timescale`
|
|
14
|
-
* (Hz),
|
|
14
|
+
* (Hz), `groupDurationTicks = groupDurationSec * timescale`, and
|
|
15
|
+
* `presentationAnchorTicks` is the track's signed catalog anchor
|
|
16
|
+
* (draft-ramadan-moq-mmt-01 Section 4.4.1; zero when the track omits it).
|
|
17
|
+
* There is no clamp: a `ticks` earlier than the anchor is an error the
|
|
18
|
+
* publisher must reject, never group 0.
|
|
15
19
|
*
|
|
16
20
|
* Integer math means there is no epsilon and no float rounding to reason
|
|
17
21
|
* about. The seconds-form wrapper `groupIdFor(Seconds, seconds)` exists for
|
|
@@ -30,13 +34,13 @@
|
|
|
30
34
|
* sender/relay/receiver is worse than any formula change.
|
|
31
35
|
*
|
|
32
36
|
* Canonical implementations:
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* TS: THIS FILE (libmmt) — consumed via @blockcast/mmt-container.
|
|
38
|
+
* Rust: libmmt `mmt-core/src/align.rs` (`group_id_for_ticks`) — consumed
|
|
39
|
+
* by FFmpeg / hang-mmt-fec libmoq, which re-pin to this fixture.
|
|
40
|
+
* Go: Blockcast/multicast `cmd/caddy/sender/group_align.go` is the CMAF
|
|
41
|
+
* (cmafpackaging) sender, not an mmtp implementation; it loads this
|
|
42
|
+
* fixture only when LIBMMT_ALIGN_VECTORS is set and must follow the
|
|
43
|
+
* version-2 vectors before it does.
|
|
40
44
|
* ──────────────────────────────────────────────────────────────────────────
|
|
41
45
|
*/
|
|
42
46
|
/**
|
|
@@ -67,17 +71,18 @@ export declare function asSeconds(n: number): Seconds;
|
|
|
67
71
|
* Deterministic groupId from integer ticks. Authoritative form of the
|
|
68
72
|
* contract (see module docstring).
|
|
69
73
|
*
|
|
70
|
-
* @param ticks
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
+
* @param ticks — media presentation time in ticks (integer).
|
|
75
|
+
* @param groupDurationTicks — group duration in ticks (positive integer).
|
|
76
|
+
* @param presentationAnchorTicks — catalog `presentationAnchorTicks` (signed
|
|
77
|
+
* integer); defaults to 0, the local origin
|
|
78
|
+
* of a track that omits the field.
|
|
74
79
|
* @returns non-negative integer groupId.
|
|
75
80
|
*
|
|
76
|
-
* Throws on non-integer/non-finite inputs
|
|
77
|
-
*
|
|
78
|
-
*
|
|
81
|
+
* Throws on non-integer/non-finite inputs, non-positive duration, or
|
|
82
|
+
* `ticks < presentationAnchorTicks` (moq-mmt-01 4.4.1: the publisher MUST
|
|
83
|
+
* reject that MPU and MUST NOT clamp it to group 0).
|
|
79
84
|
*/
|
|
80
|
-
export declare function groupIdForTicks(ticks: number, groupDurationTicks: number): number;
|
|
85
|
+
export declare function groupIdForTicks(ticks: number, groupDurationTicks: number, presentationAnchorTicks?: number): number;
|
|
81
86
|
/**
|
|
82
87
|
* Seconds-form wrapper around `groupIdForTicks`. Kept for backwards
|
|
83
88
|
* compatibility with existing callers that hold `Seconds` (or a raw
|
|
@@ -88,7 +93,8 @@ export declare function groupIdForTicks(ticks: number, groupDurationTicks: numbe
|
|
|
88
93
|
* branch of the parameter type is a migration ramp — new code should
|
|
89
94
|
* pass `Seconds` explicitly (via `secondsFromTicks` or `asSeconds`).
|
|
90
95
|
*
|
|
91
|
-
* @param mediaTimeSec — finite
|
|
96
|
+
* @param mediaTimeSec — finite non-negative seconds (anchor 0); a
|
|
97
|
+
* negative value throws, it is never clamped.
|
|
92
98
|
* @param groupDurationSec — positive finite seconds.
|
|
93
99
|
*
|
|
94
100
|
* @deprecated Use `groupIdForTicks(ticks, groupDurationTicks)` with
|
package/dist/align.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"align.d.ts","sourceRoot":"","sources":["../src/align.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"align.d.ts","sourceRoot":"","sources":["../src/align.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;CAAE,CAAA;AAE9D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAU1E;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAK5C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,kBAAkB,EAAE,MAAM,EAC1B,uBAAuB,SAAI,GAC1B,MAAM,CA4BR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,OAAO,GAAG,MAAM,EAC9B,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAqCR;AAED;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAS7E;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;CAAE,GACjC;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAA;IAC5C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC9B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAgBlE"}
|
package/dist/align.js
CHANGED
|
@@ -16,7 +16,7 @@ function asSeconds(n) {
|
|
|
16
16
|
}
|
|
17
17
|
return n;
|
|
18
18
|
}
|
|
19
|
-
function groupIdForTicks(ticks, groupDurationTicks) {
|
|
19
|
+
function groupIdForTicks(ticks, groupDurationTicks, presentationAnchorTicks = 0) {
|
|
20
20
|
if (!Number.isInteger(ticks)) {
|
|
21
21
|
throw new Error(
|
|
22
22
|
`[align] groupIdForTicks: ticks must be an integer, got ${ticks}`
|
|
@@ -27,8 +27,23 @@ function groupIdForTicks(ticks, groupDurationTicks) {
|
|
|
27
27
|
`[align] groupIdForTicks: groupDurationTicks must be a positive integer, got ${groupDurationTicks}`
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
31
|
-
|
|
30
|
+
if (!Number.isInteger(presentationAnchorTicks)) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`[align] groupIdForTicks: presentationAnchorTicks must be an integer, got ${presentationAnchorTicks}`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const relativeTicks = ticks - presentationAnchorTicks;
|
|
36
|
+
if (!Number.isSafeInteger(relativeTicks)) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`[align] groupIdForTicks: ticks - presentationAnchorTicks = ${relativeTicks} is not a safe integer`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if (relativeTicks < 0) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`[align] groupIdForTicks: ticks ${ticks} precede presentationAnchorTicks ${presentationAnchorTicks}; the publisher must reject this MPU (moq-mmt-01 4.4.1)`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return Math.floor(relativeTicks / groupDurationTicks);
|
|
32
47
|
}
|
|
33
48
|
function groupIdFor(mediaTimeSec, groupDurationSec) {
|
|
34
49
|
if (!Number.isFinite(mediaTimeSec)) {
|
|
@@ -41,7 +56,11 @@ function groupIdFor(mediaTimeSec, groupDurationSec) {
|
|
|
41
56
|
`[align] groupIdFor: groupDurationSec must be a positive finite number, got ${groupDurationSec}`
|
|
42
57
|
);
|
|
43
58
|
}
|
|
44
|
-
if (mediaTimeSec < 0)
|
|
59
|
+
if (mediaTimeSec < 0) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`[align] groupIdFor: mediaTimeSec ${mediaTimeSec} precedes presentationAnchorTicks 0; the publisher must reject this MPU (moq-mmt-01 4.4.1)`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
45
64
|
const TS = 1e9;
|
|
46
65
|
const ticks = Math.round(mediaTimeSec * TS);
|
|
47
66
|
const durTicks = Math.round(groupDurationSec * TS);
|
package/dist/align.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/align.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared group-alignment primitive for MMT over MoQ switching sets.\n *\n * Pure math \u2014 no MMT wire parsing, no CMCD, no I/O. Callers wire the output\n * into their own drift-observation plumbing (see media-router.ts for the\n * libmmt wiring).\n *\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n * Contract (integer-ticks form, authoritative):\n *\n * groupId = ticks < 0 ? 0 : floor(ticks / groupDurationTicks)\n *\n * Where `ticks` is a media timestamp expressed at the catalog's `timescale`\n * (Hz), and `groupDurationTicks = groupDurationSec * timescale`.\n *\n * Integer math means there is no epsilon and no float rounding to reason\n * about. The seconds-form wrapper `groupIdFor(Seconds, seconds)` exists for\n * legacy callers but converts to ticks internally.\n *\n * Every sender/receiver that emits or consumes MoQ groups from an MMT or\n * CMAF switching set MUST derive groupId from this formula so that base,\n * delta, and repair tracks agree on the group boundary for a given media\n * timestamp across languages and processes.\n *\n * Test vectors that exercise the contract live at\n * `packages/container/test-vectors/align.json`; the Go and Rust siblings\n * load the same fixture so cross-language agreement is executable, not\n * prose. **Formula changes require updating the fixture AND all three\n * sibling implementations in the same release** \u2014 divergence between\n * sender/relay/receiver is worse than any formula change.\n *\n * Canonical implementations:\n * Go: Blockcast/multicast `cmd/caddy/sender/group_align.go`\n * (commit 104eeff) \u2014 sender-side groupId stamping on egress.\n * Rust: moqtail/moqtail `apps/relay/src/server/abr.rs`\n * (commit 39accbf; experimental branch, may be rebased \u2014 rely\n * on the SHA, not the branch name) \u2014 relay-side check.\n * TS: THIS FILE (libmmt) \u2014 consumed by moq-lib + moqtail-ts via\n * @blockcast/mmt-container.\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n */\n\n/**\n * Branded seconds type. Construct only via `secondsFromTicks(ticks, timescale)`\n * or `asSeconds(n)` (the latter exists solely for tests and bring-up). The\n * brand prevents accidentally passing a raw tick count \u2014 or a Date.now()\n * millisecond \u2014 to an API that expects a media-time in seconds.\n */\nexport type Seconds = number & { readonly __brand: 'Seconds' }\n\n/**\n * Explicit conversion constructor: ticks at `timescale` Hz \u2192 Seconds.\n *\n * Call this at the wire/catalog boundary so the brand flows with the value\n * through the rest of the system. Throws on non-finite inputs or\n * non-positive timescale (CLAUDE.md \u00A7Architectural Principles: error on\n * bad init).\n */\nexport function secondsFromTicks(ticks: number, timescale: number): Seconds {\n if (!Number.isFinite(ticks)) {\n throw new Error(`[align] secondsFromTicks: ticks must be finite, got ${ticks}`)\n }\n if (!Number.isFinite(timescale) || timescale <= 0) {\n throw new Error(\n `[align] secondsFromTicks: timescale must be positive and finite, got ${timescale}`,\n )\n }\n return (ticks / timescale) as Seconds\n}\n\n/**\n * Escape hatch for tests / bring-up code that holds a raw seconds number\n * (e.g. a catalog field that ships as float seconds). Production code\n * should prefer `secondsFromTicks` so the conversion site is explicit.\n */\nexport function asSeconds(n: number): Seconds {\n if (!Number.isFinite(n)) {\n throw new Error(`[align] asSeconds: value must be finite, got ${n}`)\n }\n return n as Seconds\n}\n\n/**\n * Deterministic groupId from integer ticks. Authoritative form of the\n * contract (see module docstring).\n *\n * @param ticks \u2014 media presentation time in ticks (integer).\n * Negative values clamp to group 0 (matches\n * the Go sibling's base-clamp).\n * @param groupDurationTicks \u2014 group duration in ticks (positive integer).\n * @returns non-negative integer groupId.\n *\n * Throws on non-integer/non-finite inputs or non-positive duration. These\n * are init-time errors, not packet-hot-path errors \u2014 callers ingesting\n * wire data should validate once at catalog load, not once per packet.\n */\nexport function groupIdForTicks(ticks: number, groupDurationTicks: number): number {\n if (!Number.isInteger(ticks)) {\n throw new Error(\n `[align] groupIdForTicks: ticks must be an integer, got ${ticks}`,\n )\n }\n if (!Number.isInteger(groupDurationTicks) || groupDurationTicks <= 0) {\n throw new Error(\n `[align] groupIdForTicks: groupDurationTicks must be a positive integer, got ${groupDurationTicks}`,\n )\n }\n if (ticks < 0) return 0\n return Math.floor(ticks / groupDurationTicks)\n}\n\n/**\n * Seconds-form wrapper around `groupIdForTicks`. Kept for backwards\n * compatibility with existing callers that hold `Seconds` (or a raw\n * `number` that semantically represents seconds).\n *\n * Internally converts to ticks using a synthetic 1e9 Hz timescale so the\n * integer-math contract is the single source of truth. The `| number`\n * branch of the parameter type is a migration ramp \u2014 new code should\n * pass `Seconds` explicitly (via `secondsFromTicks` or `asSeconds`).\n *\n * @param mediaTimeSec \u2014 finite number of seconds; negatives clamp to 0.\n * @param groupDurationSec \u2014 positive finite seconds.\n *\n * @deprecated Use `groupIdForTicks(ticks, groupDurationTicks)` with\n * tick-space inputs from the catalog. The seconds wrapper rounds to the\n * nearest nanosecond and throws above ~104 days of media time; the\n * integer-ticks form has no rounding and a much wider safe range.\n *\n * The rounding is not benign: when `groupDurationTicks / timescale` is not\n * ns-exact (33333@90k, 1001@30k, 1024@44.1k \u2014 all real catalog cadences)\n * the quantized duration under-counts and `expected` slips a whole group.\n * See the divergence fixture in `__tests__/align.test.ts`.\n *\n * No non-test caller remains in this package: `MediaRouter` took tick-space\n * inputs from PCL-2211, and its group-alignment observer was then removed\n * outright as unwired telemetry (BLO-34141). Removal of this wrapper is\n * tracked by BLO-21176; the exported `groupIdForTicks` / `driftCheck` stay\n * regardless \u2014 they are the formula shared with the Go sender and the Rust\n * relay, not internals of the deleted observer.\n */\nexport function groupIdFor(\n mediaTimeSec: Seconds | number,\n groupDurationSec: number,\n): number {\n if (!Number.isFinite(mediaTimeSec as number)) {\n throw new Error(\n `[align] groupIdFor: mediaTimeSec must be a finite number, got ${mediaTimeSec}`,\n )\n }\n if (!Number.isFinite(groupDurationSec) || groupDurationSec <= 0) {\n throw new Error(\n `[align] groupIdFor: groupDurationSec must be a positive finite number, got ${groupDurationSec}`,\n )\n }\n if ((mediaTimeSec as number) < 0) return 0\n // 1e9 Hz keeps both operands inside Number.MAX_SAFE_INTEGER (2^53-1)\n // for ~104 days of media time. Beyond that, Math.round returns a\n // non-safe-integer float that Number.isInteger still accepts \u2014 throw\n // explicitly so the caller picks a narrower timescale rather than\n // silently quantizing.\n const TS = 1_000_000_000\n const ticks = Math.round((mediaTimeSec as number) * TS)\n const durTicks = Math.round(groupDurationSec * TS)\n if (durTicks <= 0) {\n throw new Error(\n `[align] groupIdFor: groupDurationSec=${groupDurationSec} rounds to <1 tick at 1e9 Hz; pass groupIdForTicks directly for sub-nanosecond durations`,\n )\n }\n if (!Number.isSafeInteger(ticks)) {\n throw new Error(\n `[align] groupIdFor: mediaTimeSec=${mediaTimeSec} overflows safe-integer ticks at 1e9 Hz (>~104 days); use groupIdForTicks with a narrower timescale`,\n )\n }\n return groupIdForTicks(ticks, durTicks)\n}\n\n/**\n * Result of a drift check between expected and actual groupIds.\n *\n * Discriminated on `kind` so callers must handle both outcomes explicitly\n * (the previous `{ drifted: boolean, deltaGroups: number }` shape let a\n * drifted result slip through with a silent `if (result.drifted)` gate).\n */\nexport type DriftCheckResult =\n | { readonly kind: 'aligned'; readonly deltaGroups: 0 }\n | { readonly kind: 'drifted'; readonly deltaGroups: number }\n\n/**\n * Compare a packet-stamped groupId against the formula-derived expectation.\n *\n * Pure observer \u2014 does not throw on drift, does not mutate anything.\n * Callers decide how to react (e.g. bump a CMCD counter, log, ignore).\n *\n * @param expected \u2014 groupId as derived via `groupIdForTicks` or `groupIdFor`.\n * @param actual \u2014 groupId as stamped on the incoming packet/group.\n */\nexport function driftCheck(expected: number, actual: number): DriftCheckResult {\n if (!Number.isInteger(expected) || !Number.isInteger(actual)) {\n throw new Error(\n `[align] driftCheck: both arguments must be integer groupIds, got expected=${expected} actual=${actual}`,\n )\n }\n const deltaGroups = actual - expected\n if (deltaGroups === 0) return { kind: 'aligned', deltaGroups: 0 }\n return { kind: 'drifted', deltaGroups }\n}\n\nexport type MmtpSubgroupKeyInput =\n | { readonly kind: 'mpu-metadata' }\n | {\n readonly kind: 'timed'\n readonly movieFragmentSequenceNumber: number\n readonly sampleNumber: number\n }\n | { readonly kind: 'non-timed'; readonly itemId: number }\n\n/**\n * Canonical, domain-separated key for MMTP payloads sharing one MoQ subgroup.\n * This is a map/storage key, not the scalar MoQ subgroup ID. MPU metadata is\n * carried in subgroup 0; media identity remains explicit and collision-free.\n */\nexport function subgroupKeyFor(input: MmtpSubgroupKeyInput): string {\n if (input.kind === 'mpu-metadata') return 'metadata:0'\n\n const values =\n input.kind === 'timed'\n ? [input.movieFragmentSequenceNumber, input.sampleNumber]\n : [input.itemId]\n for (const value of values) {\n if (!Number.isInteger(value) || value < 0 || value > 0xffff_ffff) {\n throw new Error(`[align] subgroup key coordinates must be uint32, got ${value}`)\n }\n }\n\n return input.kind === 'timed'\n ? `timed:${input.movieFragmentSequenceNumber}:${input.sampleNumber}`\n : `non-timed:${input.itemId}`\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * Shared group-alignment primitive for MMT over MoQ switching sets.\n *\n * Pure math \u2014 no MMT wire parsing, no CMCD, no I/O. Callers wire the output\n * into their own drift-observation plumbing (see media-router.ts for the\n * libmmt wiring).\n *\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n * Contract (integer-ticks form, authoritative):\n *\n * groupId = floor((ticks - presentationAnchorTicks) / groupDurationTicks)\n *\n * Where `ticks` is a media timestamp expressed at the catalog's `timescale`\n * (Hz), `groupDurationTicks = groupDurationSec * timescale`, and\n * `presentationAnchorTicks` is the track's signed catalog anchor\n * (draft-ramadan-moq-mmt-01 Section 4.4.1; zero when the track omits it).\n * There is no clamp: a `ticks` earlier than the anchor is an error the\n * publisher must reject, never group 0.\n *\n * Integer math means there is no epsilon and no float rounding to reason\n * about. The seconds-form wrapper `groupIdFor(Seconds, seconds)` exists for\n * legacy callers but converts to ticks internally.\n *\n * Every sender/receiver that emits or consumes MoQ groups from an MMT or\n * CMAF switching set MUST derive groupId from this formula so that base,\n * delta, and repair tracks agree on the group boundary for a given media\n * timestamp across languages and processes.\n *\n * Test vectors that exercise the contract live at\n * `packages/container/test-vectors/align.json`; the Go and Rust siblings\n * load the same fixture so cross-language agreement is executable, not\n * prose. **Formula changes require updating the fixture AND all three\n * sibling implementations in the same release** \u2014 divergence between\n * sender/relay/receiver is worse than any formula change.\n *\n * Canonical implementations:\n * TS: THIS FILE (libmmt) \u2014 consumed via @blockcast/mmt-container.\n * Rust: libmmt `mmt-core/src/align.rs` (`group_id_for_ticks`) \u2014 consumed\n * by FFmpeg / hang-mmt-fec libmoq, which re-pin to this fixture.\n * Go: Blockcast/multicast `cmd/caddy/sender/group_align.go` is the CMAF\n * (cmafpackaging) sender, not an mmtp implementation; it loads this\n * fixture only when LIBMMT_ALIGN_VECTORS is set and must follow the\n * version-2 vectors before it does.\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n */\n\n/**\n * Branded seconds type. Construct only via `secondsFromTicks(ticks, timescale)`\n * or `asSeconds(n)` (the latter exists solely for tests and bring-up). The\n * brand prevents accidentally passing a raw tick count \u2014 or a Date.now()\n * millisecond \u2014 to an API that expects a media-time in seconds.\n */\nexport type Seconds = number & { readonly __brand: 'Seconds' }\n\n/**\n * Explicit conversion constructor: ticks at `timescale` Hz \u2192 Seconds.\n *\n * Call this at the wire/catalog boundary so the brand flows with the value\n * through the rest of the system. Throws on non-finite inputs or\n * non-positive timescale (CLAUDE.md \u00A7Architectural Principles: error on\n * bad init).\n */\nexport function secondsFromTicks(ticks: number, timescale: number): Seconds {\n if (!Number.isFinite(ticks)) {\n throw new Error(`[align] secondsFromTicks: ticks must be finite, got ${ticks}`)\n }\n if (!Number.isFinite(timescale) || timescale <= 0) {\n throw new Error(\n `[align] secondsFromTicks: timescale must be positive and finite, got ${timescale}`,\n )\n }\n return (ticks / timescale) as Seconds\n}\n\n/**\n * Escape hatch for tests / bring-up code that holds a raw seconds number\n * (e.g. a catalog field that ships as float seconds). Production code\n * should prefer `secondsFromTicks` so the conversion site is explicit.\n */\nexport function asSeconds(n: number): Seconds {\n if (!Number.isFinite(n)) {\n throw new Error(`[align] asSeconds: value must be finite, got ${n}`)\n }\n return n as Seconds\n}\n\n/**\n * Deterministic groupId from integer ticks. Authoritative form of the\n * contract (see module docstring).\n *\n * @param ticks \u2014 media presentation time in ticks (integer).\n * @param groupDurationTicks \u2014 group duration in ticks (positive integer).\n * @param presentationAnchorTicks \u2014 catalog `presentationAnchorTicks` (signed\n * integer); defaults to 0, the local origin\n * of a track that omits the field.\n * @returns non-negative integer groupId.\n *\n * Throws on non-integer/non-finite inputs, non-positive duration, or\n * `ticks < presentationAnchorTicks` (moq-mmt-01 4.4.1: the publisher MUST\n * reject that MPU and MUST NOT clamp it to group 0).\n */\nexport function groupIdForTicks(\n ticks: number,\n groupDurationTicks: number,\n presentationAnchorTicks = 0,\n): number {\n if (!Number.isInteger(ticks)) {\n throw new Error(\n `[align] groupIdForTicks: ticks must be an integer, got ${ticks}`,\n )\n }\n if (!Number.isInteger(groupDurationTicks) || groupDurationTicks <= 0) {\n throw new Error(\n `[align] groupIdForTicks: groupDurationTicks must be a positive integer, got ${groupDurationTicks}`,\n )\n }\n if (!Number.isInteger(presentationAnchorTicks)) {\n throw new Error(\n `[align] groupIdForTicks: presentationAnchorTicks must be an integer, got ${presentationAnchorTicks}`,\n )\n }\n const relativeTicks = ticks - presentationAnchorTicks\n if (!Number.isSafeInteger(relativeTicks)) {\n throw new Error(\n `[align] groupIdForTicks: ticks - presentationAnchorTicks = ${relativeTicks} is not a safe integer`,\n )\n }\n if (relativeTicks < 0) {\n throw new Error(\n `[align] groupIdForTicks: ticks ${ticks} precede presentationAnchorTicks ${presentationAnchorTicks}; the publisher must reject this MPU (moq-mmt-01 4.4.1)`,\n )\n }\n return Math.floor(relativeTicks / groupDurationTicks)\n}\n\n/**\n * Seconds-form wrapper around `groupIdForTicks`. Kept for backwards\n * compatibility with existing callers that hold `Seconds` (or a raw\n * `number` that semantically represents seconds).\n *\n * Internally converts to ticks using a synthetic 1e9 Hz timescale so the\n * integer-math contract is the single source of truth. The `| number`\n * branch of the parameter type is a migration ramp \u2014 new code should\n * pass `Seconds` explicitly (via `secondsFromTicks` or `asSeconds`).\n *\n * @param mediaTimeSec \u2014 finite non-negative seconds (anchor 0); a\n * negative value throws, it is never clamped.\n * @param groupDurationSec \u2014 positive finite seconds.\n *\n * @deprecated Use `groupIdForTicks(ticks, groupDurationTicks)` with\n * tick-space inputs from the catalog. The seconds wrapper rounds to the\n * nearest nanosecond and throws above ~104 days of media time; the\n * integer-ticks form has no rounding and a much wider safe range.\n *\n * The rounding is not benign: when `groupDurationTicks / timescale` is not\n * ns-exact (33333@90k, 1001@30k, 1024@44.1k \u2014 all real catalog cadences)\n * the quantized duration under-counts and `expected` slips a whole group.\n * See the divergence fixture in `__tests__/align.test.ts`.\n *\n * No non-test caller remains in this package: `MediaRouter` took tick-space\n * inputs from PCL-2211, and its group-alignment observer was then removed\n * outright as unwired telemetry (BLO-34141). Removal of this wrapper is\n * tracked by BLO-21176; the exported `groupIdForTicks` / `driftCheck` stay\n * regardless \u2014 they are the formula shared with the Go sender and the Rust\n * relay, not internals of the deleted observer.\n */\nexport function groupIdFor(\n mediaTimeSec: Seconds | number,\n groupDurationSec: number,\n): number {\n if (!Number.isFinite(mediaTimeSec as number)) {\n throw new Error(\n `[align] groupIdFor: mediaTimeSec must be a finite number, got ${mediaTimeSec}`,\n )\n }\n if (!Number.isFinite(groupDurationSec) || groupDurationSec <= 0) {\n throw new Error(\n `[align] groupIdFor: groupDurationSec must be a positive finite number, got ${groupDurationSec}`,\n )\n }\n // No clamp (moq-mmt-01 4.4.1). Checked before rounding: a tiny negative\n // rounds to -0 ticks, which `groupIdForTicks` would accept as 0.\n if ((mediaTimeSec as number) < 0) {\n throw new Error(\n `[align] groupIdFor: mediaTimeSec ${mediaTimeSec} precedes presentationAnchorTicks 0; the publisher must reject this MPU (moq-mmt-01 4.4.1)`,\n )\n }\n // 1e9 Hz keeps both operands inside Number.MAX_SAFE_INTEGER (2^53-1)\n // for ~104 days of media time. Beyond that, Math.round returns a\n // non-safe-integer float that Number.isInteger still accepts \u2014 throw\n // explicitly so the caller picks a narrower timescale rather than\n // silently quantizing.\n const TS = 1_000_000_000\n const ticks = Math.round((mediaTimeSec as number) * TS)\n const durTicks = Math.round(groupDurationSec * TS)\n if (durTicks <= 0) {\n throw new Error(\n `[align] groupIdFor: groupDurationSec=${groupDurationSec} rounds to <1 tick at 1e9 Hz; pass groupIdForTicks directly for sub-nanosecond durations`,\n )\n }\n if (!Number.isSafeInteger(ticks)) {\n throw new Error(\n `[align] groupIdFor: mediaTimeSec=${mediaTimeSec} overflows safe-integer ticks at 1e9 Hz (>~104 days); use groupIdForTicks with a narrower timescale`,\n )\n }\n return groupIdForTicks(ticks, durTicks)\n}\n\n/**\n * Result of a drift check between expected and actual groupIds.\n *\n * Discriminated on `kind` so callers must handle both outcomes explicitly\n * (the previous `{ drifted: boolean, deltaGroups: number }` shape let a\n * drifted result slip through with a silent `if (result.drifted)` gate).\n */\nexport type DriftCheckResult =\n | { readonly kind: 'aligned'; readonly deltaGroups: 0 }\n | { readonly kind: 'drifted'; readonly deltaGroups: number }\n\n/**\n * Compare a packet-stamped groupId against the formula-derived expectation.\n *\n * Pure observer \u2014 does not throw on drift, does not mutate anything.\n * Callers decide how to react (e.g. bump a CMCD counter, log, ignore).\n *\n * @param expected \u2014 groupId as derived via `groupIdForTicks` or `groupIdFor`.\n * @param actual \u2014 groupId as stamped on the incoming packet/group.\n */\nexport function driftCheck(expected: number, actual: number): DriftCheckResult {\n if (!Number.isInteger(expected) || !Number.isInteger(actual)) {\n throw new Error(\n `[align] driftCheck: both arguments must be integer groupIds, got expected=${expected} actual=${actual}`,\n )\n }\n const deltaGroups = actual - expected\n if (deltaGroups === 0) return { kind: 'aligned', deltaGroups: 0 }\n return { kind: 'drifted', deltaGroups }\n}\n\nexport type MmtpSubgroupKeyInput =\n | { readonly kind: 'mpu-metadata' }\n | {\n readonly kind: 'timed'\n readonly movieFragmentSequenceNumber: number\n readonly sampleNumber: number\n }\n | { readonly kind: 'non-timed'; readonly itemId: number }\n\n/**\n * Canonical, domain-separated key for MMTP payloads sharing one MoQ subgroup.\n * This is a map/storage key, not the scalar MoQ subgroup ID. MPU metadata is\n * carried in subgroup 0; media identity remains explicit and collision-free.\n */\nexport function subgroupKeyFor(input: MmtpSubgroupKeyInput): string {\n if (input.kind === 'mpu-metadata') return 'metadata:0'\n\n const values =\n input.kind === 'timed'\n ? [input.movieFragmentSequenceNumber, input.sampleNumber]\n : [input.itemId]\n for (const value of values) {\n if (!Number.isInteger(value) || value < 0 || value > 0xffff_ffff) {\n throw new Error(`[align] subgroup key coordinates must be uint32, got ${value}`)\n }\n }\n\n return input.kind === 'timed'\n ? `timed:${input.movieFragmentSequenceNumber}:${input.sampleNumber}`\n : `non-timed:${input.itemId}`\n}\n"],
|
|
5
|
+
"mappings": ";AA8DO,SAAS,iBAAiB,OAAe,WAA4B;AAC1E,MAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3B,UAAM,IAAI,MAAM,uDAAuD,KAAK,EAAE;AAAA,EAChF;AACA,MAAI,CAAC,OAAO,SAAS,SAAS,KAAK,aAAa,GAAG;AACjD,UAAM,IAAI;AAAA,MACR,wEAAwE,SAAS;AAAA,IACnF;AAAA,EACF;AACA,SAAQ,QAAQ;AAClB;AAOO,SAAS,UAAU,GAAoB;AAC5C,MAAI,CAAC,OAAO,SAAS,CAAC,GAAG;AACvB,UAAM,IAAI,MAAM,gDAAgD,CAAC,EAAE;AAAA,EACrE;AACA,SAAO;AACT;AAiBO,SAAS,gBACd,OACA,oBACA,0BAA0B,GAClB;AACR,MAAI,CAAC,OAAO,UAAU,KAAK,GAAG;AAC5B,UAAM,IAAI;AAAA,MACR,0DAA0D,KAAK;AAAA,IACjE;AAAA,EACF;AACA,MAAI,CAAC,OAAO,UAAU,kBAAkB,KAAK,sBAAsB,GAAG;AACpE,UAAM,IAAI;AAAA,MACR,+EAA+E,kBAAkB;AAAA,IACnG;AAAA,EACF;AACA,MAAI,CAAC,OAAO,UAAU,uBAAuB,GAAG;AAC9C,UAAM,IAAI;AAAA,MACR,4EAA4E,uBAAuB;AAAA,IACrG;AAAA,EACF;AACA,QAAM,gBAAgB,QAAQ;AAC9B,MAAI,CAAC,OAAO,cAAc,aAAa,GAAG;AACxC,UAAM,IAAI;AAAA,MACR,8DAA8D,aAAa;AAAA,IAC7E;AAAA,EACF;AACA,MAAI,gBAAgB,GAAG;AACrB,UAAM,IAAI;AAAA,MACR,kCAAkC,KAAK,oCAAoC,uBAAuB;AAAA,IACpG;AAAA,EACF;AACA,SAAO,KAAK,MAAM,gBAAgB,kBAAkB;AACtD;AAiCO,SAAS,WACd,cACA,kBACQ;AACR,MAAI,CAAC,OAAO,SAAS,YAAsB,GAAG;AAC5C,UAAM,IAAI;AAAA,MACR,iEAAiE,YAAY;AAAA,IAC/E;AAAA,EACF;AACA,MAAI,CAAC,OAAO,SAAS,gBAAgB,KAAK,oBAAoB,GAAG;AAC/D,UAAM,IAAI;AAAA,MACR,8EAA8E,gBAAgB;AAAA,IAChG;AAAA,EACF;AAGA,MAAK,eAA0B,GAAG;AAChC,UAAM,IAAI;AAAA,MACR,oCAAoC,YAAY;AAAA,IAClD;AAAA,EACF;AAMA,QAAM,KAAK;AACX,QAAM,QAAQ,KAAK,MAAO,eAA0B,EAAE;AACtD,QAAM,WAAW,KAAK,MAAM,mBAAmB,EAAE;AACjD,MAAI,YAAY,GAAG;AACjB,UAAM,IAAI;AAAA,MACR,wCAAwC,gBAAgB;AAAA,IAC1D;AAAA,EACF;AACA,MAAI,CAAC,OAAO,cAAc,KAAK,GAAG;AAChC,UAAM,IAAI;AAAA,MACR,oCAAoC,YAAY;AAAA,IAClD;AAAA,EACF;AACA,SAAO,gBAAgB,OAAO,QAAQ;AACxC;AAsBO,SAAS,WAAW,UAAkB,QAAkC;AAC7E,MAAI,CAAC,OAAO,UAAU,QAAQ,KAAK,CAAC,OAAO,UAAU,MAAM,GAAG;AAC5D,UAAM,IAAI;AAAA,MACR,6EAA6E,QAAQ,WAAW,MAAM;AAAA,IACxG;AAAA,EACF;AACA,QAAM,cAAc,SAAS;AAC7B,MAAI,gBAAgB,EAAG,QAAO,EAAE,MAAM,WAAW,aAAa,EAAE;AAChE,SAAO,EAAE,MAAM,WAAW,YAAY;AACxC;AAgBO,SAAS,eAAe,OAAqC;AAClE,MAAI,MAAM,SAAS,eAAgB,QAAO;AAE1C,QAAM,SACJ,MAAM,SAAS,UACX,CAAC,MAAM,6BAA6B,MAAM,YAAY,IACtD,CAAC,MAAM,MAAM;AACnB,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,QAAQ,YAAa;AAChE,YAAM,IAAI,MAAM,wDAAwD,KAAK,EAAE;AAAA,IACjF;AAAA,EACF;AAEA,SAAO,MAAM,SAAS,UAClB,SAAS,MAAM,2BAA2B,IAAI,MAAM,YAAY,KAChE,aAAa,MAAM,MAAM;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/browser-runtime.js
CHANGED
|
@@ -6757,6 +6757,22 @@ function validateCmsfMmtpCatalog(value, options = {}) {
|
|
|
6757
6757
|
"commonTrackFields is retired; every track carries its own fields"
|
|
6758
6758
|
);
|
|
6759
6759
|
}
|
|
6760
|
+
const initDataList = catalog["initDataList"];
|
|
6761
|
+
if (initDataList !== void 0) {
|
|
6762
|
+
if (!Array.isArray(initDataList)) {
|
|
6763
|
+
catalogError("catalog_init_data_list", "$.initDataList", "initDataList must be an array");
|
|
6764
|
+
}
|
|
6765
|
+
initDataList.forEach((entry, i) => {
|
|
6766
|
+
const e = entry;
|
|
6767
|
+
const entryPath = `$.initDataList[${i}]`;
|
|
6768
|
+
if (typeof e !== "object" || e === null || Array.isArray(e) || typeof e["id"] !== "string" || e["id"].length === 0 || typeof e["type"] !== "string" || e["type"].length === 0) {
|
|
6769
|
+
catalogError("catalog_init_data_list", entryPath, "entry needs a non-empty string id and type");
|
|
6770
|
+
}
|
|
6771
|
+
if (e["type"] === "inline" && (typeof e["data"] !== "string" || e["data"].length === 0)) {
|
|
6772
|
+
catalogError("catalog_init_data_list", `${entryPath}.data`, 'an "inline" entry needs non-empty data');
|
|
6773
|
+
}
|
|
6774
|
+
});
|
|
6775
|
+
}
|
|
6760
6776
|
const tracks = catalog["tracks"];
|
|
6761
6777
|
const trackRecords = [];
|
|
6762
6778
|
const positiveInteger3 = (input) => Number.isSafeInteger(input) && input > 0;
|
|
@@ -6808,6 +6824,14 @@ function validateCmsfMmtpCatalog(value, options = {}) {
|
|
|
6808
6824
|
if (keyframeIntervalMs !== void 0 && !positiveNumber2(keyframeIntervalMs) || keyframeIntervalTicks !== void 0 && !positiveInteger3(keyframeIntervalTicks)) {
|
|
6809
6825
|
catalogError("track_keyframe_interval", path, "keyframe interval fields must be positive numbers");
|
|
6810
6826
|
}
|
|
6827
|
+
const anchor = track["presentationAnchorTicks"];
|
|
6828
|
+
if (anchor !== void 0 && !Number.isSafeInteger(anchor)) {
|
|
6829
|
+
catalogError("track_presentation_anchor", `${path}.presentationAnchorTicks`, "must be a safe integer");
|
|
6830
|
+
}
|
|
6831
|
+
const initRef = track["initRef"];
|
|
6832
|
+
if (initRef !== void 0 && (typeof initRef !== "string" || initRef.length === 0)) {
|
|
6833
|
+
catalogError("track_init_ref", `${path}.initRef`, "must be a non-empty string");
|
|
6834
|
+
}
|
|
6811
6835
|
if (packaging === "fec-repair") {
|
|
6812
6836
|
rejectRepairTrackGeometry(path, track, catalogError);
|
|
6813
6837
|
validateRepairTrackFields(describeRepairTrack(name, path, track), catalogError);
|
|
@@ -6815,9 +6839,8 @@ function validateCmsfMmtpCatalog(value, options = {}) {
|
|
|
6815
6839
|
rejectRepairFieldsOnMediaTrack(path, track, catalogError);
|
|
6816
6840
|
}
|
|
6817
6841
|
if (packaging === "mmtp") {
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mpu or mfu");
|
|
6842
|
+
if (track["mmtpMode"] !== "mfu") {
|
|
6843
|
+
catalogError("track_mmtp_mode", `${path}.mmtpMode`, "must be mfu");
|
|
6821
6844
|
}
|
|
6822
6845
|
if (!positiveInteger3(timescale)) {
|
|
6823
6846
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
@@ -8819,10 +8842,10 @@ function resolveNetworkSource(input) {
|
|
|
8819
8842
|
}
|
|
8820
8843
|
const relayDns = input.amtFallback?.relayDns?.trim();
|
|
8821
8844
|
const relay = relayDns || input.endpoints.map((ep) => ep.relayAddress?.trim()).find((r) => !!r);
|
|
8822
|
-
const discovery = input.amtFallback?.discovery
|
|
8823
|
-
if (discovery === void 0) return { entries: [], relayFrom: null };
|
|
8845
|
+
const discovery = input.amtFallback?.discovery;
|
|
8846
|
+
if (discovery === void 0 && !relay) return { entries: [], relayFrom: null };
|
|
8824
8847
|
return {
|
|
8825
|
-
entries: [{ type: "amt", discovery, ...relay ? { relay } : {} }],
|
|
8848
|
+
entries: [{ type: "amt", ...discovery ? { discovery } : {}, ...relay ? { relay } : {} }],
|
|
8826
8849
|
relayFrom: !relay ? null : relayDns ? "amtFallback.relayDns" : "endpoint.relayAddress"
|
|
8827
8850
|
};
|
|
8828
8851
|
}
|
|
@@ -8835,8 +8858,11 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
8835
8858
|
const extra = Object.keys(s).filter((k) => !keys.has(k) && s[k] !== void 0);
|
|
8836
8859
|
if (extra.length > 0) throw err("invalid_network_source", `has keys the schema rejects: ${extra.join(", ")}`);
|
|
8837
8860
|
if (s.type === "amt") {
|
|
8838
|
-
if (s.discovery !== "driad" && s.discovery !== "manual") {
|
|
8839
|
-
throw err(
|
|
8861
|
+
if (s.discovery !== void 0 && s.discovery !== "dns" && s.discovery !== "driad" && s.discovery !== "manual") {
|
|
8862
|
+
throw err(
|
|
8863
|
+
"invalid_amt_discovery",
|
|
8864
|
+
`discovery must be "dns", "driad" or "manual" when present; got ${JSON.stringify(s.discovery)}`
|
|
8865
|
+
);
|
|
8840
8866
|
}
|
|
8841
8867
|
if (s.relay !== void 0) {
|
|
8842
8868
|
const relay = typeof s.relay === "string" ? s.relay.trim() : "";
|
|
@@ -8845,8 +8871,8 @@ function validateNetworkSourceEntry(s, i) {
|
|
|
8845
8871
|
}
|
|
8846
8872
|
s.relay = relay;
|
|
8847
8873
|
}
|
|
8848
|
-
if (s.discovery === "manual" && s.relay === void 0) {
|
|
8849
|
-
throw err("amt_requires_relay", `discovery="
|
|
8874
|
+
if ((s.discovery === "dns" || s.discovery === "manual") && s.relay === void 0) {
|
|
8875
|
+
throw err("amt_requires_relay", `discovery="${s.discovery}" requires a relay ("driad" resolves it at runtime)`);
|
|
8850
8876
|
}
|
|
8851
8877
|
if (s.port !== void 0 && (!Number.isInteger(s.port) || s.port < 1 || s.port > 65535)) {
|
|
8852
8878
|
throw err("invalid_port", `port must be 1..65535; got ${s.port}`);
|
|
@@ -8998,9 +9024,9 @@ function multicastFromEnv(env = globalThis.process?.env ?? {}) {
|
|
|
8998
9024
|
endpoints,
|
|
8999
9025
|
...hasCatalogAmt ? {
|
|
9000
9026
|
amtFallback: {
|
|
9001
|
-
//
|
|
9002
|
-
//
|
|
9003
|
-
discovery: amtDiscovery
|
|
9027
|
+
// No default: an omitted discovery with a relay hostname is
|
|
9028
|
+
// "dns" (draft-ramadan-moq-multicast-01 4.2.1).
|
|
9029
|
+
...amtDiscovery ? { discovery: amtDiscovery } : {},
|
|
9004
9030
|
...amtRelayDns ? { relayDns: amtRelayDns } : {}
|
|
9005
9031
|
}
|
|
9006
9032
|
} : {}
|
|
@@ -9168,7 +9194,7 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
|
|
|
9168
9194
|
if (ot.role !== void 0 && existing.role === void 0) existing.role = ot.role;
|
|
9169
9195
|
if (existing.packaging === "mmtp") {
|
|
9170
9196
|
const mode = existing.mmtpMode ?? ot.mmtpMode;
|
|
9171
|
-
if (mode !== "
|
|
9197
|
+
if (mode !== "mfu") {
|
|
9172
9198
|
throw new Error(
|
|
9173
9199
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
|
|
9174
9200
|
);
|
|
@@ -9205,7 +9231,7 @@ function mergeOverrideIntoCmsfTracks(tracks, override) {
|
|
|
9205
9231
|
);
|
|
9206
9232
|
}
|
|
9207
9233
|
const mmtpMode = ot.mmtpMode;
|
|
9208
|
-
if (packaging === "mmtp" && mmtpMode !== "
|
|
9234
|
+
if (packaging === "mmtp" && mmtpMode !== "mfu") {
|
|
9209
9235
|
throw new Error(
|
|
9210
9236
|
`[phase14-catalog-override] track "${ot.name}" has packaging='mmtp' but no valid mmtpMode`
|
|
9211
9237
|
);
|
|
@@ -25816,7 +25842,7 @@ function asSeconds(n) {
|
|
|
25816
25842
|
}
|
|
25817
25843
|
return n;
|
|
25818
25844
|
}
|
|
25819
|
-
function groupIdForTicks(ticks, groupDurationTicks) {
|
|
25845
|
+
function groupIdForTicks(ticks, groupDurationTicks, presentationAnchorTicks = 0) {
|
|
25820
25846
|
if (!Number.isInteger(ticks)) {
|
|
25821
25847
|
throw new Error(
|
|
25822
25848
|
`[align] groupIdForTicks: ticks must be an integer, got ${ticks}`
|
|
@@ -25827,8 +25853,23 @@ function groupIdForTicks(ticks, groupDurationTicks) {
|
|
|
25827
25853
|
`[align] groupIdForTicks: groupDurationTicks must be a positive integer, got ${groupDurationTicks}`
|
|
25828
25854
|
);
|
|
25829
25855
|
}
|
|
25830
|
-
if (
|
|
25831
|
-
|
|
25856
|
+
if (!Number.isInteger(presentationAnchorTicks)) {
|
|
25857
|
+
throw new Error(
|
|
25858
|
+
`[align] groupIdForTicks: presentationAnchorTicks must be an integer, got ${presentationAnchorTicks}`
|
|
25859
|
+
);
|
|
25860
|
+
}
|
|
25861
|
+
const relativeTicks = ticks - presentationAnchorTicks;
|
|
25862
|
+
if (!Number.isSafeInteger(relativeTicks)) {
|
|
25863
|
+
throw new Error(
|
|
25864
|
+
`[align] groupIdForTicks: ticks - presentationAnchorTicks = ${relativeTicks} is not a safe integer`
|
|
25865
|
+
);
|
|
25866
|
+
}
|
|
25867
|
+
if (relativeTicks < 0) {
|
|
25868
|
+
throw new Error(
|
|
25869
|
+
`[align] groupIdForTicks: ticks ${ticks} precede presentationAnchorTicks ${presentationAnchorTicks}; the publisher must reject this MPU (moq-mmt-01 4.4.1)`
|
|
25870
|
+
);
|
|
25871
|
+
}
|
|
25872
|
+
return Math.floor(relativeTicks / groupDurationTicks);
|
|
25832
25873
|
}
|
|
25833
25874
|
function groupIdFor(mediaTimeSec, groupDurationSec) {
|
|
25834
25875
|
if (!Number.isFinite(mediaTimeSec)) {
|
|
@@ -25841,7 +25882,11 @@ function groupIdFor(mediaTimeSec, groupDurationSec) {
|
|
|
25841
25882
|
`[align] groupIdFor: groupDurationSec must be a positive finite number, got ${groupDurationSec}`
|
|
25842
25883
|
);
|
|
25843
25884
|
}
|
|
25844
|
-
if (mediaTimeSec < 0)
|
|
25885
|
+
if (mediaTimeSec < 0) {
|
|
25886
|
+
throw new Error(
|
|
25887
|
+
`[align] groupIdFor: mediaTimeSec ${mediaTimeSec} precedes presentationAnchorTicks 0; the publisher must reject this MPU (moq-mmt-01 4.4.1)`
|
|
25888
|
+
);
|
|
25889
|
+
}
|
|
25845
25890
|
const TS = 1e9;
|
|
25846
25891
|
const ticks = Math.round(mediaTimeSec * TS);
|
|
25847
25892
|
const durTicks = Math.round(groupDurationSec * TS);
|