@blockcast/mmt-container 0.4.0 → 0.4.1-main.22841c1f0a2d

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 (220) hide show
  1. package/README.md +37 -21
  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 +2037 -881
  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 +13 -1
  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/mfu-reassembler.js +21 -13
  55. package/dist/mfu-reassembler.js.map +2 -2
  56. package/dist/mmtp-container-parser.d.ts.map +1 -1
  57. package/dist/mmtp-container-parser.js +93 -22
  58. package/dist/mmtp-container-parser.js.map +2 -2
  59. package/dist/mmtp-container-parser.no-modules.js +3677 -1213
  60. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  61. package/dist/mmtp-decode-pipeline.js +93 -22
  62. package/dist/mmtp-decode-pipeline.js.map +2 -2
  63. package/dist/mmtp-fec-session.d.ts +192 -0
  64. package/dist/mmtp-fec-session.d.ts.map +1 -0
  65. package/dist/mmtp-fec-session.js +640 -0
  66. package/dist/mmtp-fec-session.js.map +7 -0
  67. package/dist/mmtp-router.d.ts +69 -32
  68. package/dist/mmtp-router.d.ts.map +1 -1
  69. package/dist/mmtp-router.js +296 -192
  70. package/dist/mmtp-router.js.map +2 -2
  71. package/dist/multicast-auth-catalog.d.ts +86 -92
  72. package/dist/multicast-auth-catalog.d.ts.map +1 -1
  73. package/dist/multicast-auth-catalog.js +313 -124
  74. package/dist/multicast-auth-catalog.js.map +3 -3
  75. package/dist/multicast-input.d.ts +31 -8
  76. package/dist/multicast-input.d.ts.map +1 -1
  77. package/dist/multicast-input.js +299 -35
  78. package/dist/multicast-input.js.map +3 -3
  79. package/dist/multicast-manager.d.ts +97 -11
  80. package/dist/multicast-manager.d.ts.map +1 -1
  81. package/dist/multicast-manager.js +1022 -527
  82. package/dist/multicast-manager.js.map +4 -4
  83. package/dist/multicast-transport.d.ts +12 -2
  84. package/dist/multicast-transport.d.ts.map +1 -1
  85. package/dist/multicast-transport.js +108 -238
  86. package/dist/multicast-transport.js.map +4 -4
  87. package/dist/multicast-unwrap.js +21 -13
  88. package/dist/multicast-unwrap.js.map +2 -2
  89. package/dist/no-modules.d.ts +5 -3
  90. package/dist/no-modules.d.ts.map +1 -1
  91. package/dist/no-modules.js +3625 -1194
  92. package/dist/no-modules.js.map +4 -4
  93. package/dist/phase14-catalog-override.d.ts +1 -1
  94. package/dist/phase14-catalog-override.d.ts.map +1 -1
  95. package/dist/phase14-catalog-override.js +2 -2
  96. package/dist/phase14-catalog-override.js.map +2 -2
  97. package/dist/repair-fetch.d.ts +81 -6
  98. package/dist/repair-fetch.d.ts.map +1 -1
  99. package/dist/repair-fetch.js +156 -31
  100. package/dist/repair-fetch.js.map +3 -3
  101. package/dist/repair-layers.d.ts +2 -0
  102. package/dist/repair-layers.d.ts.map +1 -1
  103. package/dist/repair-layers.js +19 -2
  104. package/dist/repair-layers.js.map +2 -2
  105. package/dist/sample-combiner.d.ts +7 -1
  106. package/dist/sample-combiner.d.ts.map +1 -1
  107. package/dist/sample-combiner.js +14 -2
  108. package/dist/sample-combiner.js.map +2 -2
  109. package/dist/signaling.d.ts +2 -2
  110. package/dist/signaling.d.ts.map +1 -1
  111. package/dist/signaling.js +3 -3
  112. package/dist/signaling.js.map +2 -2
  113. package/dist/switching-set-alignment.d.ts +1 -1
  114. package/dist/switching-set-alignment.js.map +1 -1
  115. package/dist/timestamp-codec.js +21 -13
  116. package/dist/timestamp-codec.js.map +2 -2
  117. package/dist/wasm-mfu-reassembler.js.map +1 -1
  118. package/dist/wasm-mmtp-container-parser.js +93 -22
  119. package/dist/wasm-mmtp-container-parser.js.map +2 -2
  120. package/package.json +6 -18
  121. package/schemas/catalog.schema.json +133 -38
  122. package/src/align.ts +52 -21
  123. package/src/carp-catalog.ts +188 -68
  124. package/src/catalog-fec-params.ts +28 -3
  125. package/src/catalog-network-source.ts +49 -7
  126. package/src/catalog-validator.ts +4 -11
  127. package/src/cmcd-producer.ts +23 -1
  128. package/src/fec-manager.ts +366 -63
  129. package/src/fec-state.ts +11 -4
  130. package/src/fec-worker-setup.ts +30 -2
  131. package/src/held-layer-admission.ts +161 -0
  132. package/src/index.ts +32 -19
  133. package/src/iso-block-locator.ts +110 -7
  134. package/src/mmtp-container-parser.ts +75 -7
  135. package/src/mmtp-fec-session.ts +606 -0
  136. package/src/mmtp-router.ts +301 -240
  137. package/src/multicast-auth-catalog.ts +134 -238
  138. package/src/multicast-input.ts +148 -124
  139. package/src/multicast-manager.ts +271 -40
  140. package/src/multicast-transport.ts +17 -3
  141. package/src/no-modules.ts +8 -7
  142. package/src/phase14-catalog-override.ts +3 -3
  143. package/src/repair-fetch.ts +283 -39
  144. package/src/repair-layers.ts +22 -2
  145. package/src/sample-combiner.ts +15 -2
  146. package/src/signaling.ts +2 -2
  147. package/src/switching-set-alignment.ts +1 -1
  148. package/test-vectors/align.json +108 -32
  149. package/test-vectors/bc-provenance-v2.json +1526 -0
  150. package/test-vectors/catalog/README.md +71 -4
  151. package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
  152. package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
  153. package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
  154. package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
  155. package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
  156. package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
  157. package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
  158. package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
  159. package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
  160. package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
  161. package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
  162. package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
  163. package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
  164. package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
  165. package/test-vectors/catalog/negative/multicast-amt-driad-with-relay.json +38 -0
  166. package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
  167. package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
  168. package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
  169. package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
  170. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
  171. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
  172. package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
  173. package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
  174. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
  175. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
  176. package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
  177. package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
  178. package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
  179. package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
  180. package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
  181. package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
  182. package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
  183. package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
  184. package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
  185. package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
  186. package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
  187. package/test-vectors/catalog/positive/fec-multicast.json +1 -1
  188. package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
  189. package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
  190. package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
  191. package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
  192. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +3 -3
  193. package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
  194. package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
  195. package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
  196. package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
  197. package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
  198. package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
  199. package/test-vectors/catalog/section-codes.json +31 -1
  200. package/test-vectors/catalog-multicast-auth-v1.json +38 -20
  201. package/test-vectors/catalog-validation.json +101 -5
  202. package/test-vectors/catalog-validator-public-api.mjs +14 -9
  203. package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
  204. package/dist/fec-codec.d.ts +0 -32
  205. package/dist/fec-codec.d.ts.map +0 -1
  206. package/dist/fec-codec.js +0 -47
  207. package/dist/fec-codec.js.map +0 -7
  208. package/dist/manifest-auth-plan.d.ts +0 -30
  209. package/dist/manifest-auth-plan.d.ts.map +0 -1
  210. package/dist/manifest-auth-plan.js +0 -1266
  211. package/dist/manifest-auth-plan.js.map +0 -7
  212. package/dist/source-auth.d.ts +0 -2
  213. package/dist/source-auth.d.ts.map +0 -1
  214. package/dist/source-auth.js +0 -1209
  215. package/dist/source-auth.js.map +0 -7
  216. package/src/fec-codec.ts +0 -61
  217. package/src/manifest-auth-plan.ts +0 -107
  218. package/src/source-auth.ts +0 -1
  219. package/test-vectors/generate-source-auth-fixture.mjs +0 -114
  220. package/test-vectors/source-auth-v1.json +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
  }
@@ -14,12 +14,18 @@
14
14
  */
15
15
 
16
16
  import type { FecTrackStats } from '@blockcast/fec-worker'
17
- import type { ManifestVerificationStats } from '@blockcast/mmt-manifest-verify'
17
+ import type { FecFailClosedReason } from './fec-manager.js'
18
18
 
19
19
  // ---------------------------------------------------------------------------
20
20
  // Types
21
21
  // ---------------------------------------------------------------------------
22
22
 
23
+ /** Source-auth counters for CMCD: records verified, and drops per reason. */
24
+ export interface ManifestVerificationStats {
25
+ verified: number
26
+ failures: Record<string, number>
27
+ }
28
+
23
29
  /** Transport state snapshot, built by the player wiring layer from SocketPool. */
24
30
  export interface TransportSnapshot {
25
31
  transport: 'native' | 'amt' | 'moq'
@@ -153,6 +159,7 @@ export class CmcdProducer {
153
159
  #deltaFailRate: number | null = null
154
160
  #switchMiscount = 0
155
161
  #manifestStats: ManifestVerificationStats | null = null
162
+ #fecFailClosed: FecFailClosedReason | null = null
156
163
 
157
164
  constructor(options: CmcdProducerOptions) {
158
165
  this.#onCmcdParams = options.onCmcdParams
@@ -200,6 +207,16 @@ export class CmcdProducer {
200
207
  this.#switchMiscount += 1
201
208
  }
202
209
 
210
+ /**
211
+ * Record that FEC failed closed at runtime (fec-01 6.3.9). Every later
212
+ * snapshot carries `x-bc-fec-fail-closed` (the reason code) and
213
+ * `x-bc-fec-fail-layer` (the held layer i whose total B_i was undercut), so a
214
+ * stream playing without FEC is told apart from one with no loss.
215
+ */
216
+ updateFecFailClosed(reason: FecFailClosedReason): void {
217
+ this.#fecFailClosed = reason
218
+ }
219
+
203
220
  updateManifestVerification(stats: ManifestVerificationStats): void {
204
221
  this.#manifestStats = stats
205
222
  }
@@ -248,6 +265,11 @@ export class CmcdProducer {
248
265
  params['x-bc-play-mode'] = this.#playMode
249
266
  }
250
267
 
268
+ if (this.#fecFailClosed) {
269
+ params['x-bc-fec-fail-closed'] = this.#fecFailClosed.code
270
+ params['x-bc-fec-fail-layer'] = this.#fecFailClosed.layer
271
+ }
272
+
251
273
  // Delta-fail-rate is only meaningful when a delta track exists.
252
274
  if (
253
275
  this.#playMode !== null &&