@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.
Files changed (191) hide show
  1. package/README.md +31 -17
  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 +1192 -375
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +67 -31
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +291 -199
  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 +24 -2
  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/delivery-catalog.js +18 -12
  25. package/dist/delivery-catalog.js.map +4 -4
  26. package/dist/fec-manager.d.ts +49 -1
  27. package/dist/fec-manager.d.ts.map +1 -1
  28. package/dist/fec-manager.js +176 -23
  29. package/dist/fec-manager.js.map +3 -3
  30. package/dist/fec-state.d.ts +2 -1
  31. package/dist/fec-state.d.ts.map +1 -1
  32. package/dist/fec-state.js +18 -3
  33. package/dist/fec-state.js.map +3 -3
  34. package/dist/fec-worker-setup.d.ts +2 -0
  35. package/dist/fec-worker-setup.d.ts.map +1 -1
  36. package/dist/fec-worker-setup.js +2 -1
  37. package/dist/fec-worker-setup.js.map +2 -2
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +8 -8
  41. package/dist/index.js.map +2 -2
  42. package/dist/iso-block-locator.d.ts +29 -0
  43. package/dist/iso-block-locator.d.ts.map +1 -1
  44. package/dist/iso-block-locator.js +97 -17
  45. package/dist/iso-block-locator.js.map +3 -3
  46. package/dist/manifest-auth-plan.d.ts +26 -25
  47. package/dist/manifest-auth-plan.d.ts.map +1 -1
  48. package/dist/manifest-auth-plan.js +331 -1171
  49. package/dist/manifest-auth-plan.js.map +4 -4
  50. package/dist/mfu-reassembler.js.map +2 -2
  51. package/dist/mmtp-container-parser.js.map +2 -2
  52. package/dist/mmtp-container-parser.no-modules.js +1014 -289
  53. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  54. package/dist/mmtp-decode-pipeline.js.map +2 -2
  55. package/dist/mmtp-fec-session.d.ts +159 -0
  56. package/dist/mmtp-fec-session.d.ts.map +1 -0
  57. package/dist/mmtp-fec-session.js +531 -0
  58. package/dist/mmtp-fec-session.js.map +7 -0
  59. package/dist/mmtp-router.d.ts +17 -1
  60. package/dist/mmtp-router.d.ts.map +1 -1
  61. package/dist/mmtp-router.js +29 -0
  62. package/dist/mmtp-router.js.map +2 -2
  63. package/dist/multicast-auth-catalog.d.ts +86 -92
  64. package/dist/multicast-auth-catalog.d.ts.map +1 -1
  65. package/dist/multicast-auth-catalog.js +347 -132
  66. package/dist/multicast-auth-catalog.js.map +4 -4
  67. package/dist/multicast-input.d.ts +28 -6
  68. package/dist/multicast-input.d.ts.map +1 -1
  69. package/dist/multicast-input.js +290 -28
  70. package/dist/multicast-input.js.map +3 -3
  71. package/dist/multicast-manager.d.ts +40 -5
  72. package/dist/multicast-manager.d.ts.map +1 -1
  73. package/dist/multicast-manager.js +293 -54
  74. package/dist/multicast-manager.js.map +4 -4
  75. package/dist/multicast-transport.d.ts +6 -0
  76. package/dist/multicast-transport.d.ts.map +1 -1
  77. package/dist/multicast-transport.js +18 -11
  78. package/dist/multicast-transport.js.map +4 -4
  79. package/dist/multicast-unwrap.js.map +2 -2
  80. package/dist/no-modules.d.ts +4 -1
  81. package/dist/no-modules.d.ts.map +1 -1
  82. package/dist/no-modules.js +964 -274
  83. package/dist/no-modules.js.map +4 -4
  84. package/dist/phase14-catalog-override.d.ts +1 -1
  85. package/dist/phase14-catalog-override.d.ts.map +1 -1
  86. package/dist/phase14-catalog-override.js +2 -2
  87. package/dist/phase14-catalog-override.js.map +2 -2
  88. package/dist/repair-fetch.d.ts +81 -6
  89. package/dist/repair-fetch.d.ts.map +1 -1
  90. package/dist/repair-fetch.js +156 -31
  91. package/dist/repair-fetch.js.map +3 -3
  92. package/dist/repair-layers.d.ts +2 -0
  93. package/dist/repair-layers.d.ts.map +1 -1
  94. package/dist/repair-layers.js +19 -2
  95. package/dist/repair-layers.js.map +2 -2
  96. package/dist/signaling.d.ts +2 -2
  97. package/dist/signaling.d.ts.map +1 -1
  98. package/dist/signaling.js +3 -3
  99. package/dist/signaling.js.map +2 -2
  100. package/dist/source-auth.js +2710 -7
  101. package/dist/source-auth.js.map +4 -4
  102. package/dist/switching-set-alignment.d.ts +1 -1
  103. package/dist/switching-set-alignment.js.map +1 -1
  104. package/dist/timestamp-codec.js.map +2 -2
  105. package/dist/wasm-mfu-reassembler.js.map +1 -1
  106. package/dist/wasm-mmtp-container-parser.js.map +2 -2
  107. package/package.json +6 -9
  108. package/schemas/catalog.schema.json +124 -37
  109. package/src/align.ts +52 -21
  110. package/src/carp-catalog.ts +131 -52
  111. package/src/catalog-fec-params.ts +28 -3
  112. package/src/catalog-network-source.ts +45 -2
  113. package/src/catalog-validator.ts +4 -11
  114. package/src/fec-manager.ts +128 -14
  115. package/src/fec-state.ts +11 -4
  116. package/src/fec-worker-setup.ts +4 -1
  117. package/src/index.ts +24 -10
  118. package/src/iso-block-locator.ts +97 -6
  119. package/src/manifest-auth-plan.ts +39 -91
  120. package/src/mmtp-fec-session.ts +533 -0
  121. package/src/mmtp-router.ts +57 -0
  122. package/src/multicast-auth-catalog.ts +131 -238
  123. package/src/multicast-input.ts +119 -61
  124. package/src/multicast-manager.ts +115 -14
  125. package/src/multicast-transport.ts +3 -0
  126. package/src/no-modules.ts +7 -1
  127. package/src/phase14-catalog-override.ts +3 -3
  128. package/src/repair-fetch.ts +283 -39
  129. package/src/repair-layers.ts +22 -2
  130. package/src/signaling.ts +2 -2
  131. package/src/switching-set-alignment.ts +1 -1
  132. package/test-vectors/align.json +108 -32
  133. package/test-vectors/bc-provenance-v2.json +1526 -0
  134. package/test-vectors/catalog/README.md +60 -3
  135. package/test-vectors/catalog/negative/fec-block-profile-missing.json +1 -1
  136. package/test-vectors/catalog/negative/fec-block-profile-retired.json +1 -1
  137. package/test-vectors/catalog/negative/fec-block-profile-unknown.json +1 -1
  138. package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
  139. package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
  140. package/test-vectors/catalog/negative/fec-reed-solomon-k-plus-p-over-255.json +39 -0
  141. package/test-vectors/catalog/negative/fec-reed-solomon-overlay-over-255.json +40 -0
  142. package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
  143. package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
  144. package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
  145. package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
  146. package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
  147. package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
  148. package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
  149. package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
  150. package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
  151. package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
  152. package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
  153. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
  154. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
  155. package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
  156. package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
  157. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-above-max.json +56 -0
  158. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-below-min.json +56 -0
  159. package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
  160. package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
  161. package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
  162. package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
  163. package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
  164. package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
  165. package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
  166. package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
  167. package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
  168. package/test-vectors/catalog/positive/fec-algorithm-unimplemented.json +29 -0
  169. package/test-vectors/catalog/positive/fec-iso-ssbg1.json +1 -1
  170. package/test-vectors/catalog/positive/fec-multicast.json +1 -1
  171. package/test-vectors/catalog/positive/fec-reed-solomon-layered.json +50 -0
  172. package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
  173. package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
  174. package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
  175. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +2 -2
  176. package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
  177. package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
  178. package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
  179. package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
  180. package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
  181. package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
  182. package/test-vectors/catalog/section-codes.json +30 -1
  183. package/test-vectors/catalog-multicast-auth-v1.json +38 -20
  184. package/test-vectors/catalog-validation.json +6 -5
  185. package/test-vectors/catalog-validator-public-api.mjs +14 -9
  186. package/test-vectors/generate-bc-provenance-v2.mjs +252 -0
  187. package/dist/fec-codec.d.ts +0 -32
  188. package/dist/fec-codec.d.ts.map +0 -1
  189. package/dist/fec-codec.js +0 -47
  190. package/dist/fec-codec.js.map +0 -7
  191. package/src/fec-codec.ts +0 -61
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockcast/mmt-container",
3
- "version": "0.4.0-main.bbd83cb48eff",
3
+ "version": "0.4.0-main.bbdfdbf39ded",
4
4
  "description": "MMTP/LOC container parsing for MMT over MoQ and SSM",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -86,10 +86,6 @@
86
86
  "import": "./dist/wasm-mmtp-container-parser.js",
87
87
  "types": "./dist/wasm-mmtp-container-parser.d.ts"
88
88
  },
89
- "./fec-codec": {
90
- "import": "./dist/fec-codec.js",
91
- "types": "./dist/fec-codec.d.ts"
92
- },
93
89
  "./cmcd-producer": {
94
90
  "import": "./dist/cmcd-producer.js",
95
91
  "types": "./dist/cmcd-producer.d.ts"
@@ -177,11 +173,12 @@
177
173
  "test:watch": "vitest"
178
174
  },
179
175
  "dependencies": {
176
+ "@blockcast/fec-worker": "0.4.0-main.bbdfdbf39ded",
177
+ "@blockcast/mmt-base": "0.4.0-main.bbdfdbf39ded",
178
+ "@blockcast/mmt-fec": "0.4.0-main.bbdfdbf39ded",
179
+ "@blockcast/mmt-manifest-verify": "0.4.0-main.bbdfdbf39ded",
180
+ "@noble/curves": "^1.9.7",
180
181
  "@noble/hashes": "^1.8.0",
181
- "@blockcast/mmt-fec": "0.4.0-main.bbd83cb48eff",
182
- "@blockcast/mmt-manifest-verify": "0.4.0-main.bbd83cb48eff",
183
- "@blockcast/fec-worker": "0.4.0-main.bbd83cb48eff",
184
- "@blockcast/mmt-base": "0.4.0-main.bbd83cb48eff",
185
182
  "ajv": "^8.17.1",
186
183
  "ajv-formats": "^3.0.1"
187
184
  },
@@ -16,10 +16,25 @@
16
16
  "items": { "$ref": "#/$defs/track" }
17
17
  },
18
18
  "multicast": { "$ref": "#/$defs/multicast" },
19
- "multicast.auth": { "$ref": "#/$defs/multicastAuth" },
20
- "archive": { "$ref": "#/$defs/archive" }
19
+ "archive": { "$ref": "#/$defs/archive" },
20
+ "initDataList": {
21
+ "type": "array",
22
+ "description": "MSF 5.1.7 initialization data, profiled by draft-ramadan-moq-mmt-01 4.5: a track's initRef names an entry; an \"inline\" entry carries a base64 ftyp+moov in data.",
23
+ "items": { "$ref": "#/$defs/initDataEntry" }
24
+ }
21
25
  },
22
26
  "$defs": {
27
+ "initDataEntry": {
28
+ "type": "object",
29
+ "required": ["id", "type"],
30
+ "properties": {
31
+ "id": { "type": "string", "minLength": 1 },
32
+ "type": { "type": "string", "minLength": 1 },
33
+ "data": { "type": "string", "minLength": 1 }
34
+ },
35
+ "if": { "properties": { "type": { "const": "inline" } }, "required": ["type"] },
36
+ "then": { "properties": { "data": true }, "required": ["data"] }
37
+ },
23
38
  "archive": {
24
39
  "type": "object",
25
40
  "additionalProperties": false,
@@ -78,6 +93,17 @@
78
93
  "items": { "type": "string", "minLength": 1 }
79
94
  },
80
95
  "initData": { "type": "string", "minLength": 1 },
96
+ "initRef": {
97
+ "type": "string",
98
+ "minLength": 1,
99
+ "description": "id of the root initDataList entry holding this track's init segment (draft-ramadan-moq-mmt-01 4.5). Preferred over initData when both are present."
100
+ },
101
+ "presentationAnchorTicks": {
102
+ "type": "integer",
103
+ "minimum": -9007199254740991,
104
+ "maximum": 9007199254740991,
105
+ "description": "Signed track timestamp of shared presentation time zero (draft-ramadan-moq-mmt-01 4.4.1); group_number = floor((ticks - presentationAnchorTicks) / groupDurationTicks). REQUIRED for synchronized audio/video tracks; omitted means a local origin of 0."
106
+ },
81
107
  "initTrack": { "type": "string", "minLength": 1 },
82
108
  "priority": { "type": "integer", "minimum": 0, "maximum": 255 },
83
109
  "repairLayer": {
@@ -102,7 +128,7 @@
102
128
  "const": "keyframe",
103
129
  "description": "fec-repair only. Marks a keyframe overlay: a separate FEC instance over random access point fragments."
104
130
  },
105
- "mmtpMode": { "enum": ["mpu", "mfu"] },
131
+ "mmtpMode": { "const": "mfu" },
106
132
  "timescale": { "$ref": "#/$defs/positiveInteger" },
107
133
  "groupDurationMs": { "$ref": "#/$defs/positiveInteger" },
108
134
  "groupDurationTicks": { "$ref": "#/$defs/positiveInteger" },
@@ -119,7 +145,7 @@
119
145
  "then": {
120
146
  "required": ["mmtpMode", "timescale"],
121
147
  "properties": {
122
- "mmtpMode": { "enum": ["mpu", "mfu"] },
148
+ "mmtpMode": { "const": "mfu" },
123
149
  "timescale": { "$ref": "#/$defs/positiveInteger" },
124
150
  "groupDurationMs": { "$ref": "#/$defs/positiveInteger" }
125
151
  },
@@ -204,7 +230,11 @@
204
230
  "additionalProperties": false,
205
231
  "required": ["algorithm", "sourceSymbols", "repairSymbols", "symbolSize", "repairTrack"],
206
232
  "properties": {
207
- "algorithm": { "enum": ["raptorq", "reed-solomon"] },
233
+ "algorithm": {
234
+ "type": "string",
235
+ "minLength": 1,
236
+ "description": "FEC scheme token (draft-ramadan-moq-fec-01 4): raptorq, reed-solomon, none, or another registered value. A receiver that does not implement the token consumes the track without FEC; it is not a catalog error."
237
+ },
208
238
  "blockProfile": {
209
239
  "enum": ["iso-ssbg1-v1"],
210
240
  "description": "FEC block profile (ISO/IEC 23008-1 Annex C, draft-ramadan-moq-fec 5.1). Required whenever algorithm declares an FEC instance (anything but \"none\"); never defaulted or inferred. The only profile is iso-ssbg1-v1: ssbg_mode1, K' = SSB_length, consecutive SS_IDs. Any other token, the retired k-padded-v1 included, is invalid; a receiver treats such a track as having no FEC."
@@ -223,6 +253,11 @@
223
253
  "if": { "properties": { "algorithm": { "const": "none" } }, "required": ["algorithm"] },
224
254
  "else": { "properties": { "blockProfile": true }, "required": ["blockProfile"] }
225
255
  },
256
+ {
257
+ "$comment": "draft-ramadan-moq-fec-01 6.3.4 rule 13: under iso-ssbg1-v1 a symbol is at least 14 octets (Section 7.3); a shorter symbol carries no protected MMTP packet.",
258
+ "if": { "properties": { "blockProfile": { "const": "iso-ssbg1-v1" } }, "required": ["blockProfile"] },
259
+ "then": { "properties": { "symbolSize": { "type": "integer", "minimum": 14 } } }
260
+ },
226
261
  {
227
262
  "if": { "properties": { "algorithm": { "const": "raptorq" } }, "required": ["algorithm"] },
228
263
  "then": {
@@ -248,8 +283,9 @@
248
283
  "type": "object",
249
284
  "additionalProperties": false,
250
285
  "required": ["groupAddress", "port", "tracks"],
286
+ "description": "draft-ramadan-moq-multicast-01 4.1 (Blockcast/moqcast-draft@fd962fd7). sourceAddress selects SSM, its absence ASM; protocol only restates that mode. A bearer such as AMT or ATSC 3.0 is a networkSource entry, never a protocol.",
251
287
  "properties": {
252
- "protocol": { "enum": ["ssm", "asm", "amt", "atsc3"] },
288
+ "protocol": { "enum": ["ssm", "asm"] },
253
289
  "sourceAddress": { "type": "string", "minLength": 1 },
254
290
  "groupAddress": { "type": "string", "minLength": 1 },
255
291
  "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
@@ -258,82 +294,121 @@
258
294
  "minItems": 1,
259
295
  "items": { "$ref": "#/$defs/endpointTrack" }
260
296
  },
261
- "bandwidth": { "$ref": "#/$defs/positiveInteger" }
297
+ "bandwidth": { "$ref": "#/$defs/positiveInteger" },
298
+ "auth": { "$ref": "#/$defs/endpointAuth" },
299
+ "networkSource": {
300
+ "type": "array",
301
+ "minItems": 1,
302
+ "items": { "$ref": "#/$defs/networkSource" }
303
+ }
262
304
  },
263
305
  "allOf": [
264
- {
265
- "anyOf": [
266
- { "properties": { "protocol": true }, "required": ["protocol"] },
267
- { "properties": { "sourceAddress": true }, "required": ["sourceAddress"] }
268
- ]
269
- },
270
306
  {
271
307
  "if": { "properties": { "protocol": { "const": "ssm" } }, "required": ["protocol"] },
272
308
  "then": {
273
309
  "required": ["sourceAddress"],
274
310
  "properties": { "sourceAddress": { "type": "string", "minLength": 1 } }
275
311
  }
312
+ },
313
+ {
314
+ "if": { "properties": { "protocol": { "const": "asm" } }, "required": ["protocol"] },
315
+ "then": { "not": { "properties": { "sourceAddress": true }, "required": ["sourceAddress"] } }
316
+ },
317
+ {
318
+ "if": { "properties": { "auth": true }, "required": ["auth"] },
319
+ "then": {
320
+ "properties": { "bandwidth": true },
321
+ "required": ["bandwidth"],
322
+ "if": { "properties": { "sourceAddress": true }, "required": ["sourceAddress"] },
323
+ "then": {
324
+ "properties": {
325
+ "auth": { "not": { "type": "object", "properties": { "senderAddress": true }, "required": ["senderAddress"] } }
326
+ }
327
+ },
328
+ "else": {
329
+ "properties": {
330
+ "auth": { "type": "object", "properties": { "senderAddress": true }, "required": ["senderAddress"] }
331
+ }
332
+ }
333
+ }
276
334
  }
277
335
  ]
278
336
  },
337
+ "endpointAuth": {
338
+ "type": "object",
339
+ "additionalProperties": false,
340
+ "required": ["manifestPort", "streamId"],
341
+ "description": "draft-ramadan-moq-multicast-01 7.2.6: marks the endpoint's flow protected. Required on every endpoint when multicast.auth is present and forbidden otherwise; port clashes on one (S, G) are validateCmsfMmtpCatalog's.",
342
+ "properties": {
343
+ "manifestPort": { "type": "integer", "minimum": 1, "maximum": 65535 },
344
+ "streamId": { "type": "integer", "minimum": 0, "maximum": 4294967295 },
345
+ "senderAddress": {
346
+ "type": "string",
347
+ "minLength": 1,
348
+ "description": "S of a protected ASM endpoint; must not appear on an SSM endpoint."
349
+ },
350
+ "maxAuthDelayMs": { "type": "integer", "minimum": 50, "maximum": 1000, "default": 200 },
351
+ "manifestTimerMs": { "type": "integer", "minimum": 1, "maximum": 9007199254740991, "default": 20 },
352
+ "manifestTrack": { "type": "string", "minLength": 1 }
353
+ }
354
+ },
279
355
  "networkSource": {
280
356
  "oneOf": [
281
357
  {
282
358
  "type": "object",
283
359
  "additionalProperties": false,
284
- "required": ["type", "discovery"],
360
+ "required": ["type"],
361
+ "description": "draft-ramadan-moq-multicast-01 4.2.1. discovery is OPTIONAL: omitted with a hostname relay means dns, omitted with no relay means DRIAD. dns and manual name their relay.",
285
362
  "properties": {
286
363
  "type": { "const": "amt" },
287
- "discovery": { "enum": ["driad", "manual"] },
364
+ "discovery": { "enum": ["dns", "driad", "manual"] },
288
365
  "relay": { "type": "string", "minLength": 1 },
289
366
  "port": { "type": "integer", "minimum": 1, "maximum": 65535 }
290
- }
367
+ },
368
+ "if": { "properties": { "discovery": { "enum": ["dns", "manual"] } }, "required": ["discovery"] },
369
+ "then": { "properties": { "relay": true }, "required": ["relay"] }
291
370
  },
292
371
  {
293
372
  "type": "object",
373
+ "description": "ATSC 3.0 broadcast tuning for an MMTP service (draft-multicast-01 Sections 4.2.2-4.2.3). frequency is REQUIRED; plpId, serviceId and slsUri are OPTIONAL.",
294
374
  "additionalProperties": false,
295
- "required": ["type", "frequency", "plpId", "serviceId", "slsUri"],
375
+ "required": ["type", "frequency"],
296
376
  "properties": {
297
377
  "type": { "const": "atsc3" },
298
- "frequency": { "$ref": "#/$defs/positiveInteger" },
378
+ "frequency": { "$ref": "#/$defs/positiveInteger", "description": "RF centre frequency in kHz (e.g. 587000 for 587 MHz)." },
299
379
  "plpId": { "type": "integer", "minimum": 0, "maximum": 63 },
300
380
  "serviceId": { "type": "integer", "minimum": 0, "maximum": 65535 },
301
- "slsUri": { "type": "string", "format": "uri" }
381
+ "slsUri": { "type": "string", "format": "uri", "description": "SLS of an MMTP service, MP table included (A/331:2026-04 7.2). The SLS describes the MMTP session and nothing of this profile, so manifestPort and keys come from provisioning, not from the SLS." }
302
382
  }
303
383
  }
304
384
  ]
305
385
  },
306
- "multicastAuthTrack": {
386
+ "multicastAuthKey": {
307
387
  "type": "object",
308
388
  "additionalProperties": false,
309
- "required": ["mediaTrack", "manifestTrack", "authScope", "sourceSymbolFormat"],
389
+ "required": ["kid", "publicKey", "firstEpoch"],
310
390
  "properties": {
311
- "mediaTrack": { "type": "string", "minLength": 1 },
312
- "manifestTrack": { "type": "string", "minLength": 1 },
313
- "authScope": { "type": "string", "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$" },
314
- "sourceSymbolFormat": { "type": "string", "minLength": 1 }
391
+ "kid": { "type": "integer", "minimum": 0, "maximum": 4294967295 },
392
+ "publicKey": { "type": "string", "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$" },
393
+ "firstEpoch": { "type": "integer", "minimum": 0, "maximum": 4294967295 }
315
394
  }
316
395
  },
317
396
  "multicastAuth": {
318
397
  "type": "object",
319
398
  "additionalProperties": false,
320
- "required": ["scheme", "hash", "sig", "publicKey", "keyId", "compaction", "tracks"],
399
+ "required": ["scheme", "version", "sig", "keys", "minEpoch"],
400
+ "description": "bc-provenance version 2, draft-ramadan-moq-multicast-01 7.2.6. A keys array repeating a kid or a firstEpoch holds no key set; validateCmsfMmtpCatalog rejects it.",
321
401
  "properties": {
322
402
  "scheme": { "const": "bc-provenance" },
323
- "hash": { "const": "blake3" },
403
+ "version": { "const": 2 },
324
404
  "sig": { "const": "ed25519" },
325
- "publicKey": { "type": "string", "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$" },
326
- "keyId": { "type": "string", "minLength": 1 },
327
- "previousKey": { "type": "string", "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$" },
328
- "compaction": { "enum": ["merkle", "none"] },
329
- "enforcement": { "enum": ["shadow", "enforce"] },
330
- "tracks": {
405
+ "keys": {
331
406
  "type": "array",
332
407
  "minItems": 1,
333
- "uniqueItems": true,
334
- "uniqueMulticastAuthTrackBindings": true,
335
- "items": { "$ref": "#/$defs/multicastAuthTrack" }
336
- }
408
+ "maxItems": 4,
409
+ "items": { "$ref": "#/$defs/multicastAuthKey" }
410
+ },
411
+ "minEpoch": { "type": "integer", "minimum": 0, "maximum": 4294967295 }
337
412
  }
338
413
  },
339
414
  "multicast": {
@@ -350,6 +425,18 @@
350
425
  "type": "array",
351
426
  "minItems": 1,
352
427
  "items": { "$ref": "#/$defs/networkSource" }
428
+ },
429
+ "auth": { "$ref": "#/$defs/multicastAuth" }
430
+ },
431
+ "if": { "properties": { "auth": true }, "required": ["auth"] },
432
+ "then": {
433
+ "properties": {
434
+ "endpoints": { "type": "array", "items": { "type": "object", "properties": { "auth": true }, "required": ["auth"] } }
435
+ }
436
+ },
437
+ "else": {
438
+ "properties": {
439
+ "endpoints": { "type": "array", "items": { "not": { "type": "object", "properties": { "auth": true }, "required": ["auth"] } } }
353
440
  }
354
441
  }
355
442
  }
package/src/align.ts CHANGED
@@ -8,10 +8,14 @@
8
8
  * ──────────────────────────────────────────────────────────────────────────
9
9
  * Contract (integer-ticks form, authoritative):
10
10
  *
11
- * groupId = ticks < 0 ? 0 : floor(ticks / groupDurationTicks)
11
+ * groupId = floor((ticks - presentationAnchorTicks) / groupDurationTicks)
12
12
  *
13
13
  * Where `ticks` is a media timestamp expressed at the catalog's `timescale`
14
- * (Hz), and `groupDurationTicks = groupDurationSec * timescale`.
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
- * Go: Blockcast/multicast `cmd/caddy/sender/group_align.go`
34
- * (commit 104eeff) — sender-side groupId stamping on egress.
35
- * Rust: moqtail/moqtail `apps/relay/src/server/abr.rs`
36
- * (commit 39accbf; experimental branch, may be rebased — rely
37
- * on the SHA, not the branch name) — relay-side check.
38
- * TS: THIS FILE (libmmt) — consumed by moq-lib + moqtail-ts via
39
- * @blockcast/mmt-container.
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
 
@@ -84,17 +88,22 @@ export function asSeconds(n: number): Seconds {
84
88
  * Deterministic groupId from integer ticks. Authoritative form of the
85
89
  * contract (see module docstring).
86
90
  *
87
- * @param ticks — media presentation time in ticks (integer).
88
- * Negative values clamp to group 0 (matches
89
- * the Go sibling's base-clamp).
90
- * @param groupDurationTicks — group duration in ticks (positive integer).
91
+ * @param ticks — media presentation time in ticks (integer).
92
+ * @param groupDurationTicks — group duration in ticks (positive integer).
93
+ * @param presentationAnchorTicks — catalog `presentationAnchorTicks` (signed
94
+ * integer); defaults to 0, the local origin
95
+ * of a track that omits the field.
91
96
  * @returns non-negative integer groupId.
92
97
  *
93
- * Throws on non-integer/non-finite inputs or non-positive duration. These
94
- * are init-time errors, not packet-hot-path errors — callers ingesting
95
- * wire data should validate once at catalog load, not once per packet.
98
+ * Throws on non-integer/non-finite inputs, non-positive duration, or
99
+ * `ticks < presentationAnchorTicks` (moq-mmt-01 4.4.1: the publisher MUST
100
+ * reject that MPU and MUST NOT clamp it to group 0).
96
101
  */
97
- export function groupIdForTicks(ticks: number, groupDurationTicks: number): number {
102
+ export function groupIdForTicks(
103
+ ticks: number,
104
+ groupDurationTicks: number,
105
+ presentationAnchorTicks = 0,
106
+ ): number {
98
107
  if (!Number.isInteger(ticks)) {
99
108
  throw new Error(
100
109
  `[align] groupIdForTicks: ticks must be an integer, got ${ticks}`,
@@ -105,8 +114,23 @@ export function groupIdForTicks(ticks: number, groupDurationTicks: number): numb
105
114
  `[align] groupIdForTicks: groupDurationTicks must be a positive integer, got ${groupDurationTicks}`,
106
115
  )
107
116
  }
108
- if (ticks < 0) return 0
109
- return Math.floor(ticks / groupDurationTicks)
117
+ if (!Number.isInteger(presentationAnchorTicks)) {
118
+ throw new Error(
119
+ `[align] groupIdForTicks: presentationAnchorTicks must be an integer, got ${presentationAnchorTicks}`,
120
+ )
121
+ }
122
+ const relativeTicks = ticks - presentationAnchorTicks
123
+ if (!Number.isSafeInteger(relativeTicks)) {
124
+ throw new Error(
125
+ `[align] groupIdForTicks: ticks - presentationAnchorTicks = ${relativeTicks} is not a safe integer`,
126
+ )
127
+ }
128
+ if (relativeTicks < 0) {
129
+ throw new Error(
130
+ `[align] groupIdForTicks: ticks ${ticks} precede presentationAnchorTicks ${presentationAnchorTicks}; the publisher must reject this MPU (moq-mmt-01 4.4.1)`,
131
+ )
132
+ }
133
+ return Math.floor(relativeTicks / groupDurationTicks)
110
134
  }
111
135
 
112
136
  /**
@@ -119,7 +143,8 @@ export function groupIdForTicks(ticks: number, groupDurationTicks: number): numb
119
143
  * branch of the parameter type is a migration ramp — new code should
120
144
  * pass `Seconds` explicitly (via `secondsFromTicks` or `asSeconds`).
121
145
  *
122
- * @param mediaTimeSec — finite number of seconds; negatives clamp to 0.
146
+ * @param mediaTimeSec — finite non-negative seconds (anchor 0); a
147
+ * negative value throws, it is never clamped.
123
148
  * @param groupDurationSec — positive finite seconds.
124
149
  *
125
150
  * @deprecated Use `groupIdForTicks(ticks, groupDurationTicks)` with
@@ -153,7 +178,13 @@ export function groupIdFor(
153
178
  `[align] groupIdFor: groupDurationSec must be a positive finite number, got ${groupDurationSec}`,
154
179
  )
155
180
  }
156
- if ((mediaTimeSec as number) < 0) return 0
181
+ // No clamp (moq-mmt-01 4.4.1). Checked before rounding: a tiny negative
182
+ // rounds to -0 ticks, which `groupIdForTicks` would accept as 0.
183
+ if ((mediaTimeSec as number) < 0) {
184
+ throw new Error(
185
+ `[align] groupIdFor: mediaTimeSec ${mediaTimeSec} precedes presentationAnchorTicks 0; the publisher must reject this MPU (moq-mmt-01 4.4.1)`,
186
+ )
187
+ }
157
188
  // 1e9 Hz keeps both operands inside Number.MAX_SAFE_INTEGER (2^53-1)
158
189
  // for ~104 days of media time. Beyond that, Math.round returns a
159
190
  // non-safe-integer float that Number.isInteger still accepts — throw