@blockcast/mmt-container 0.4.0 → 0.4.1-main.30f0611c24e8

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.
Files changed (215) hide show
  1. package/README.md +36 -20
  2. package/dist/align.d.ts +24 -18
  3. package/dist/align.d.ts.map +1 -1
  4. package/dist/align.js +23 -4
  5. package/dist/align.js.map +2 -2
  6. package/dist/browser-runtime.js +1904 -692
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +76 -39
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +321 -205
  11. package/dist/carp-catalog.js.map +3 -3
  12. package/dist/catalog-fec-params.d.ts +12 -4
  13. package/dist/catalog-fec-params.d.ts.map +1 -1
  14. package/dist/catalog-fec-params.js +40 -17
  15. package/dist/catalog-fec-params.js.map +3 -3
  16. package/dist/catalog-network-source.d.ts +28 -7
  17. package/dist/catalog-network-source.d.ts.map +1 -1
  18. package/dist/catalog-network-source.js +21 -1
  19. package/dist/catalog-network-source.js.map +2 -2
  20. package/dist/catalog-validator.d.ts +4 -3
  21. package/dist/catalog-validator.d.ts.map +1 -1
  22. package/dist/catalog-validator.js +0 -29
  23. package/dist/catalog-validator.js.map +3 -3
  24. package/dist/cmcd-producer.d.ts +8 -0
  25. package/dist/cmcd-producer.d.ts.map +1 -1
  26. package/dist/cmcd-producer.js +14 -0
  27. package/dist/cmcd-producer.js.map +2 -2
  28. package/dist/delivery-catalog.js +98 -234
  29. package/dist/delivery-catalog.js.map +4 -4
  30. package/dist/fec-manager.d.ts +108 -1
  31. package/dist/fec-manager.d.ts.map +1 -1
  32. package/dist/fec-manager.js +452 -66
  33. package/dist/fec-manager.js.map +4 -4
  34. package/dist/fec-state.d.ts +2 -1
  35. package/dist/fec-state.d.ts.map +1 -1
  36. package/dist/fec-state.js +18 -3
  37. package/dist/fec-state.js.map +3 -3
  38. package/dist/fec-worker-setup.d.ts +10 -0
  39. package/dist/fec-worker-setup.d.ts.map +1 -1
  40. package/dist/fec-worker-setup.js +15 -4
  41. package/dist/fec-worker-setup.js.map +2 -2
  42. package/dist/held-layer-admission.d.ts +58 -0
  43. package/dist/held-layer-admission.d.ts.map +1 -0
  44. package/dist/held-layer-admission.js +105 -0
  45. package/dist/held-layer-admission.js.map +7 -0
  46. package/dist/index.d.ts +5 -5
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +8 -8
  49. package/dist/index.js.map +2 -2
  50. package/dist/iso-block-locator.d.ts +39 -1
  51. package/dist/iso-block-locator.d.ts.map +1 -1
  52. package/dist/iso-block-locator.js +109 -17
  53. package/dist/iso-block-locator.js.map +3 -3
  54. package/dist/manifest-auth-plan.d.ts +26 -25
  55. package/dist/manifest-auth-plan.d.ts.map +1 -1
  56. package/dist/manifest-auth-plan.js +331 -1171
  57. package/dist/manifest-auth-plan.js.map +4 -4
  58. package/dist/mfu-reassembler.js +21 -13
  59. package/dist/mfu-reassembler.js.map +2 -2
  60. package/dist/mmtp-container-parser.d.ts.map +1 -1
  61. package/dist/mmtp-container-parser.js +93 -22
  62. package/dist/mmtp-container-parser.js.map +2 -2
  63. package/dist/mmtp-container-parser.no-modules.js +1250 -317
  64. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  65. package/dist/mmtp-decode-pipeline.js +93 -22
  66. package/dist/mmtp-decode-pipeline.js.map +2 -2
  67. package/dist/mmtp-fec-session.d.ts +192 -0
  68. package/dist/mmtp-fec-session.d.ts.map +1 -0
  69. package/dist/mmtp-fec-session.js +640 -0
  70. package/dist/mmtp-fec-session.js.map +7 -0
  71. package/dist/mmtp-router.d.ts +39 -6
  72. package/dist/mmtp-router.d.ts.map +1 -1
  73. package/dist/mmtp-router.js +184 -27
  74. package/dist/mmtp-router.js.map +2 -2
  75. package/dist/multicast-auth-catalog.d.ts +86 -92
  76. package/dist/multicast-auth-catalog.d.ts.map +1 -1
  77. package/dist/multicast-auth-catalog.js +347 -132
  78. package/dist/multicast-auth-catalog.js.map +4 -4
  79. package/dist/multicast-input.d.ts +31 -8
  80. package/dist/multicast-input.d.ts.map +1 -1
  81. package/dist/multicast-input.js +299 -35
  82. package/dist/multicast-input.js.map +3 -3
  83. package/dist/multicast-manager.d.ts +94 -5
  84. package/dist/multicast-manager.d.ts.map +1 -1
  85. package/dist/multicast-manager.js +908 -357
  86. package/dist/multicast-manager.js.map +4 -4
  87. package/dist/multicast-transport.d.ts +12 -2
  88. package/dist/multicast-transport.d.ts.map +1 -1
  89. package/dist/multicast-transport.js +108 -238
  90. package/dist/multicast-transport.js.map +4 -4
  91. package/dist/multicast-unwrap.js +21 -13
  92. package/dist/multicast-unwrap.js.map +2 -2
  93. package/dist/no-modules.d.ts +4 -1
  94. package/dist/no-modules.d.ts.map +1 -1
  95. package/dist/no-modules.js +1195 -301
  96. package/dist/no-modules.js.map +4 -4
  97. package/dist/phase14-catalog-override.d.ts +1 -1
  98. package/dist/phase14-catalog-override.d.ts.map +1 -1
  99. package/dist/phase14-catalog-override.js +2 -2
  100. package/dist/phase14-catalog-override.js.map +2 -2
  101. package/dist/repair-fetch.d.ts +81 -6
  102. package/dist/repair-fetch.d.ts.map +1 -1
  103. package/dist/repair-fetch.js +156 -31
  104. package/dist/repair-fetch.js.map +3 -3
  105. package/dist/repair-layers.d.ts +2 -0
  106. package/dist/repair-layers.d.ts.map +1 -1
  107. package/dist/repair-layers.js +19 -2
  108. package/dist/repair-layers.js.map +2 -2
  109. package/dist/sample-combiner.d.ts +7 -1
  110. package/dist/sample-combiner.d.ts.map +1 -1
  111. package/dist/sample-combiner.js +14 -2
  112. package/dist/sample-combiner.js.map +2 -2
  113. package/dist/signaling.d.ts +2 -2
  114. package/dist/signaling.d.ts.map +1 -1
  115. package/dist/signaling.js +3 -3
  116. package/dist/signaling.js.map +2 -2
  117. package/dist/source-auth.js +2710 -7
  118. package/dist/source-auth.js.map +4 -4
  119. package/dist/switching-set-alignment.d.ts +1 -1
  120. package/dist/switching-set-alignment.js.map +1 -1
  121. package/dist/timestamp-codec.js +21 -13
  122. package/dist/timestamp-codec.js.map +2 -2
  123. package/dist/wasm-mfu-reassembler.js.map +1 -1
  124. package/dist/wasm-mmtp-container-parser.js +93 -22
  125. package/dist/wasm-mmtp-container-parser.js.map +2 -2
  126. package/package.json +6 -9
  127. package/schemas/catalog.schema.json +133 -38
  128. package/src/align.ts +52 -21
  129. package/src/carp-catalog.ts +188 -68
  130. package/src/catalog-fec-params.ts +28 -3
  131. package/src/catalog-network-source.ts +49 -7
  132. package/src/catalog-validator.ts +4 -11
  133. package/src/cmcd-producer.ts +17 -0
  134. package/src/fec-manager.ts +366 -63
  135. package/src/fec-state.ts +11 -4
  136. package/src/fec-worker-setup.ts +30 -2
  137. package/src/held-layer-admission.ts +161 -0
  138. package/src/index.ts +27 -10
  139. package/src/iso-block-locator.ts +110 -7
  140. package/src/manifest-auth-plan.ts +39 -91
  141. package/src/mmtp-container-parser.ts +75 -7
  142. package/src/mmtp-fec-session.ts +606 -0
  143. package/src/mmtp-router.ts +166 -7
  144. package/src/multicast-auth-catalog.ts +131 -238
  145. package/src/multicast-input.ts +148 -124
  146. package/src/multicast-manager.ts +267 -21
  147. package/src/multicast-transport.ts +17 -3
  148. package/src/no-modules.ts +7 -1
  149. package/src/phase14-catalog-override.ts +3 -3
  150. package/src/repair-fetch.ts +283 -39
  151. package/src/repair-layers.ts +22 -2
  152. package/src/sample-combiner.ts +15 -2
  153. package/src/signaling.ts +2 -2
  154. package/src/switching-set-alignment.ts +1 -1
  155. package/test-vectors/align.json +108 -32
  156. package/test-vectors/bc-provenance-v2.json +1526 -0
  157. package/test-vectors/catalog/README.md +71 -4
  158. package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
  159. package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
  160. package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
  161. package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
  162. package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
  163. package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
  164. package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
  165. package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
  166. package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
  167. package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
  168. package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
  169. package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
  170. package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
  171. package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
  172. package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
  173. package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
  174. package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
  175. package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
  176. package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
  177. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
  178. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
  179. package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
  180. package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
  181. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
  182. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
  183. package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
  184. package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
  185. package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
  186. package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
  187. package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
  188. package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
  189. package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
  190. package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
  191. package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
  192. package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
  193. package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
  194. package/test-vectors/catalog/positive/fec-multicast.json +1 -1
  195. package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
  196. package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
  197. package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
  198. package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
  199. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
  200. package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
  201. package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
  202. package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
  203. package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
  204. package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
  205. package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
  206. package/test-vectors/catalog/section-codes.json +31 -1
  207. package/test-vectors/catalog-multicast-auth-v1.json +38 -20
  208. package/test-vectors/catalog-validation.json +101 -5
  209. package/test-vectors/catalog-validator-public-api.mjs +14 -9
  210. package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
  211. package/dist/fec-codec.d.ts +0 -32
  212. package/dist/fec-codec.d.ts.map +0 -1
  213. package/dist/fec-codec.js +0 -47
  214. package/dist/fec-codec.js.map +0 -7
  215. package/src/fec-codec.ts +0 -61
@@ -12,10 +12,15 @@
12
12
 
13
13
  import { DEFAULT_AMT_RELAY_PORT } from "@blockcast/mmt-base";
14
14
 
15
- /** One `networkSource[]` entry as published (`{type, discovery?, relay, port?}`). */
15
+ /** One `networkSource[]` entry as published (AMT `{type, discovery?, relay, port?}` or ATSC3). */
16
16
  export type CatalogNetworkSource = {
17
17
  type?: string;
18
- /** `"manual"` (or absent) names a dialable relay; `"driad"` resolves at runtime. */
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;
@@ -48,11 +53,10 @@ function normalizePort(value: unknown): number | undefined {
48
53
  * and a non-blank relay, or `undefined` when the catalog advertises none —
49
54
  * callers fall back to native multicast (or their own explicit relay config).
50
55
  *
51
- * A `discovery: "driad"` entry is skipped even when it names a `relay`: that
52
- * string is the `_amt._udp` DNS name a runtime RFC 8777 lookup resolves, not
53
- * an address to dial, and the emitter derives exactly that shape from
54
- * `amtFallback: {discovery: "driad", relayDns}`. Returning it would turn a
55
- * catalog that asked for DRIAD into a manual join against an unroutable name.
56
+ * A `discovery: "driad"` entry is skipped even when it names a `relay`. Draft
57
+ * -01 4.2.1 forbids that shape and `validateCmsfMmtpCatalog` rejects it, but
58
+ * this reader stays tolerant: returning it would turn a catalog that asked
59
+ * for DRIAD into a manual join against an unroutable name.
56
60
  * `findAmtRelay` in `@blockcast/mmt-transport` applies the same rule — the two
57
61
  * readers of one field must agree on which entries are dialable.
58
62
  *
@@ -72,3 +76,41 @@ export function catalogAmtNetworkSource(networkSource: unknown): AmtNetworkSourc
72
76
  }
73
77
  return undefined;
74
78
  }
79
+
80
+ /** Resolved ATSC 3.0 tuning (draft -01 4.2.2/4.2.3). Only `frequency` is REQUIRED. */
81
+ export type Atsc3NetworkSource = {
82
+ /** RF centre frequency in kHz. */
83
+ frequency: number;
84
+ plpId?: number;
85
+ serviceId?: number;
86
+ /** SLS of the MMTP service; libmmt does not fetch it. */
87
+ slsUri?: string;
88
+ };
89
+
90
+ function intIn(value: unknown, min: number, max: number): value is number {
91
+ return Number.isInteger(value) && (value as number) >= min && (value as number) <= max;
92
+ }
93
+
94
+ /**
95
+ * Resolve ATSC 3.0 tuning from a catalog `networkSource` (array or bare-object
96
+ * form): the first `type: "atsc3"` entry with a positive integer `frequency`
97
+ * (kHz). Optional fields are carried only when in range; an entry with no
98
+ * usable frequency is skipped, since it names nothing a tuner can lock to.
99
+ * Draft -01 3 puts the tuner first, so callers prefer this over AMT.
100
+ */
101
+ export function catalogAtsc3NetworkSource(networkSource: unknown): Atsc3NetworkSource | undefined {
102
+ const entries = Array.isArray(networkSource) ? networkSource : networkSource ? [networkSource] : [];
103
+ for (const raw of entries) {
104
+ if (!raw || typeof raw !== "object") continue;
105
+ const ns = raw as CatalogNetworkSource;
106
+ if (ns.type !== "atsc3" || !intIn(ns.frequency, 1, Number.MAX_SAFE_INTEGER)) continue;
107
+ const slsUri = typeof ns.slsUri === "string" ? ns.slsUri.trim() : "";
108
+ return {
109
+ frequency: ns.frequency,
110
+ ...(intIn(ns.plpId, 0, 63) ? { plpId: ns.plpId } : {}),
111
+ ...(intIn(ns.serviceId, 0, 65535) ? { serviceId: ns.serviceId } : {}),
112
+ ...(slsUri ? { slsUri } : {}),
113
+ };
114
+ }
115
+ return undefined;
116
+ }
@@ -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 with every package-defined semantic
20
- * keyword installed. Consumers must use this entry point instead of compiling
21
- * `catalog.schema.json` with a bare JSON Schema validator.
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
  }
@@ -15,6 +15,7 @@
15
15
 
16
16
  import type { FecTrackStats } from '@blockcast/fec-worker'
17
17
  import type { ManifestVerificationStats } from '@blockcast/mmt-manifest-verify'
18
+ import type { FecFailClosedReason } from './fec-manager.js'
18
19
 
19
20
  // ---------------------------------------------------------------------------
20
21
  // Types
@@ -153,6 +154,7 @@ export class CmcdProducer {
153
154
  #deltaFailRate: number | null = null
154
155
  #switchMiscount = 0
155
156
  #manifestStats: ManifestVerificationStats | null = null
157
+ #fecFailClosed: FecFailClosedReason | null = null
156
158
 
157
159
  constructor(options: CmcdProducerOptions) {
158
160
  this.#onCmcdParams = options.onCmcdParams
@@ -200,6 +202,16 @@ export class CmcdProducer {
200
202
  this.#switchMiscount += 1
201
203
  }
202
204
 
205
+ /**
206
+ * Record that FEC failed closed at runtime (fec-01 6.3.9). Every later
207
+ * snapshot carries `x-bc-fec-fail-closed` (the reason code) and
208
+ * `x-bc-fec-fail-layer` (the held layer i whose total B_i was undercut), so a
209
+ * stream playing without FEC is told apart from one with no loss.
210
+ */
211
+ updateFecFailClosed(reason: FecFailClosedReason): void {
212
+ this.#fecFailClosed = reason
213
+ }
214
+
203
215
  updateManifestVerification(stats: ManifestVerificationStats): void {
204
216
  this.#manifestStats = stats
205
217
  }
@@ -248,6 +260,11 @@ export class CmcdProducer {
248
260
  params['x-bc-play-mode'] = this.#playMode
249
261
  }
250
262
 
263
+ if (this.#fecFailClosed) {
264
+ params['x-bc-fec-fail-closed'] = this.#fecFailClosed.code
265
+ params['x-bc-fec-fail-layer'] = this.#fecFailClosed.layer
266
+ }
267
+
251
268
  // Delta-fail-rate is only meaningful when a delta track exists.
252
269
  if (
253
270
  this.#playMode !== null &&