@blockcast/mmt-container 0.4.0-main.bbd83cb48eff → 0.4.0-main.c7ae84be5039

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 (152) hide show
  1. package/README.md +28 -14
  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 +778 -272
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +58 -26
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +270 -194
  11. package/dist/carp-catalog.js.map +3 -3
  12. package/dist/catalog-fec-params.d.ts +1 -1
  13. package/dist/catalog-fec-params.d.ts.map +1 -1
  14. package/dist/catalog-fec-params.js +6 -13
  15. package/dist/catalog-fec-params.js.map +3 -3
  16. package/dist/catalog-network-source.d.ts +1 -1
  17. package/dist/catalog-network-source.d.ts.map +1 -1
  18. package/dist/catalog-network-source.js.map +1 -1
  19. package/dist/catalog-validator.d.ts +4 -3
  20. package/dist/catalog-validator.d.ts.map +1 -1
  21. package/dist/catalog-validator.js +0 -29
  22. package/dist/catalog-validator.js.map +3 -3
  23. package/dist/delivery-catalog.js +4 -12
  24. package/dist/delivery-catalog.js.map +4 -4
  25. package/dist/fec-manager.js.map +1 -1
  26. package/dist/fec-state.d.ts.map +1 -1
  27. package/dist/fec-state.js +14 -2
  28. package/dist/fec-state.js.map +3 -3
  29. package/dist/fec-worker-setup.js.map +1 -1
  30. package/dist/index.d.ts +2 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +4 -0
  33. package/dist/index.js.map +2 -2
  34. package/dist/iso-block-locator.js.map +1 -1
  35. package/dist/manifest-auth-plan.d.ts +26 -25
  36. package/dist/manifest-auth-plan.d.ts.map +1 -1
  37. package/dist/manifest-auth-plan.js +315 -1163
  38. package/dist/manifest-auth-plan.js.map +4 -4
  39. package/dist/mfu-reassembler.js.map +2 -2
  40. package/dist/mmtp-container-parser.js.map +2 -2
  41. package/dist/mmtp-container-parser.no-modules.js +947 -278
  42. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  43. package/dist/mmtp-decode-pipeline.js.map +2 -2
  44. package/dist/mmtp-fec-session.d.ts +156 -0
  45. package/dist/mmtp-fec-session.d.ts.map +1 -0
  46. package/dist/mmtp-fec-session.js +522 -0
  47. package/dist/mmtp-fec-session.js.map +7 -0
  48. package/dist/mmtp-router.d.ts.map +1 -1
  49. package/dist/mmtp-router.js +17 -0
  50. package/dist/mmtp-router.js.map +2 -2
  51. package/dist/multicast-auth-catalog.d.ts +86 -92
  52. package/dist/multicast-auth-catalog.d.ts.map +1 -1
  53. package/dist/multicast-auth-catalog.js +331 -124
  54. package/dist/multicast-auth-catalog.js.map +3 -3
  55. package/dist/multicast-input.d.ts +26 -4
  56. package/dist/multicast-input.d.ts.map +1 -1
  57. package/dist/multicast-input.js +283 -23
  58. package/dist/multicast-input.js.map +3 -3
  59. package/dist/multicast-manager.d.ts +23 -4
  60. package/dist/multicast-manager.d.ts.map +1 -1
  61. package/dist/multicast-manager.js +59 -29
  62. package/dist/multicast-manager.js.map +4 -4
  63. package/dist/multicast-transport.js +2 -10
  64. package/dist/multicast-transport.js.map +4 -4
  65. package/dist/multicast-unwrap.js.map +2 -2
  66. package/dist/no-modules.d.ts +2 -0
  67. package/dist/no-modules.d.ts.map +1 -1
  68. package/dist/no-modules.js +899 -267
  69. package/dist/no-modules.js.map +4 -4
  70. package/dist/phase14-catalog-override.d.ts +1 -1
  71. package/dist/phase14-catalog-override.d.ts.map +1 -1
  72. package/dist/phase14-catalog-override.js +2 -2
  73. package/dist/phase14-catalog-override.js.map +2 -2
  74. package/dist/repair-fetch.d.ts +23 -1
  75. package/dist/repair-fetch.d.ts.map +1 -1
  76. package/dist/repair-fetch.js +35 -10
  77. package/dist/repair-fetch.js.map +2 -2
  78. package/dist/repair-layers.js.map +1 -1
  79. package/dist/signaling.d.ts +2 -2
  80. package/dist/signaling.d.ts.map +1 -1
  81. package/dist/signaling.js +3 -3
  82. package/dist/signaling.js.map +2 -2
  83. package/dist/source-auth.js +22 -6
  84. package/dist/source-auth.js.map +2 -2
  85. package/dist/switching-set-alignment.d.ts +1 -1
  86. package/dist/switching-set-alignment.js.map +1 -1
  87. package/dist/timestamp-codec.js.map +2 -2
  88. package/dist/wasm-mfu-reassembler.js.map +1 -1
  89. package/dist/wasm-mmtp-container-parser.js.map +2 -2
  90. package/package.json +5 -5
  91. package/schemas/catalog.schema.json +117 -34
  92. package/src/align.ts +52 -21
  93. package/src/carp-catalog.ts +120 -46
  94. package/src/catalog-fec-params.ts +5 -2
  95. package/src/catalog-network-source.ts +1 -1
  96. package/src/catalog-validator.ts +4 -11
  97. package/src/fec-state.ts +3 -2
  98. package/src/index.ts +18 -2
  99. package/src/manifest-auth-plan.ts +39 -91
  100. package/src/mmtp-fec-session.ts +514 -0
  101. package/src/mmtp-router.ts +25 -0
  102. package/src/multicast-auth-catalog.ts +131 -238
  103. package/src/multicast-input.ts +109 -54
  104. package/src/multicast-manager.ts +88 -14
  105. package/src/no-modules.ts +2 -0
  106. package/src/phase14-catalog-override.ts +3 -3
  107. package/src/repair-fetch.ts +79 -14
  108. package/src/signaling.ts +2 -2
  109. package/src/switching-set-alignment.ts +1 -1
  110. package/test-vectors/align.json +108 -32
  111. package/test-vectors/catalog/README.md +55 -3
  112. package/test-vectors/catalog/negative/fec-iso-symbol-size-below-floor.json +28 -0
  113. package/test-vectors/catalog/negative/fec-reed-solomon-iso-symbol-size-13.json +28 -0
  114. package/test-vectors/catalog/negative/fec-repair-overlay-source-symbols-zero.json +43 -0
  115. package/test-vectors/catalog/negative/fec-repair-symbols-zero.json +28 -0
  116. package/test-vectors/catalog/negative/fec-source-symbols-zero.json +28 -0
  117. package/test-vectors/catalog/negative/fec-symbol-size-zero.json +28 -0
  118. package/test-vectors/catalog/negative/init-data-inline-without-data.json +22 -0
  119. package/test-vectors/catalog/negative/mmtp-mode-mpu.json +15 -0
  120. package/test-vectors/catalog/negative/multicast-amt-dns-without-relay.json +37 -0
  121. package/test-vectors/catalog/negative/multicast-auth-asm-missing-sender-address.json +77 -0
  122. package/test-vectors/catalog/negative/multicast-auth-duplicate-first-epoch.json +56 -0
  123. package/test-vectors/catalog/negative/multicast-auth-duplicate-kid.json +56 -0
  124. package/test-vectors/catalog/negative/multicast-auth-endpoint-auth-without-object-auth.json +38 -0
  125. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-auth.json +49 -0
  126. package/test-vectors/catalog/negative/multicast-auth-endpoint-missing-bandwidth.json +55 -0
  127. package/test-vectors/catalog/negative/multicast-auth-manifest-port-equals-port.json +56 -0
  128. package/test-vectors/catalog/negative/multicast-auth-manifest-timer-out-of-range.json +56 -0
  129. package/test-vectors/catalog/negative/multicast-auth-max-auth-delay-out-of-range.json +56 -0
  130. package/test-vectors/catalog/negative/multicast-auth-root-dotted-key.json +55 -0
  131. package/test-vectors/catalog/negative/multicast-auth-sender-address-on-ssm.json +57 -0
  132. package/test-vectors/catalog/negative/multicast-auth-version-1.json +56 -0
  133. package/test-vectors/catalog/negative/multicast-auth-version-3.json +56 -0
  134. package/test-vectors/catalog/negative/multicast-auth-version-missing.json +55 -0
  135. package/test-vectors/catalog/negative/multicast-endpoint-foreign-namespace-track.json +44 -0
  136. package/test-vectors/catalog/negative/multicast-endpoint-protocol-amt.json +38 -0
  137. package/test-vectors/catalog/negative/multicast-endpoint-protocol-atsc3.json +38 -0
  138. package/test-vectors/catalog/negative/presentation-anchor-unsafe.json +16 -0
  139. package/test-vectors/catalog/positive/mmt01-12-1-init-ref-anchor.json +29 -0
  140. package/test-vectors/catalog/positive/multicast-amt-discovery-omitted.json +37 -0
  141. package/test-vectors/catalog/positive/multicast-amt-dns-relay.json +38 -0
  142. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +2 -2
  143. package/test-vectors/catalog/{negative/multicast-endpoint-missing-protocol-and-source.json → positive/multicast-asm-unprotected.json} +10 -5
  144. package/test-vectors/catalog/positive/multicast-auth-asm-sender.json +78 -0
  145. package/test-vectors/catalog/positive/multicast-auth-rotation.json +39 -38
  146. package/test-vectors/catalog/positive/multicast-draft01-4-1-example.json +81 -0
  147. package/test-vectors/catalog/positive/multicast-draft01-7-2-6-example.json +70 -0
  148. package/test-vectors/catalog/positive/presentation-anchor-negative.json +27 -0
  149. package/test-vectors/catalog/section-codes.json +27 -1
  150. package/test-vectors/catalog-multicast-auth-v1.json +38 -20
  151. package/test-vectors/catalog-validation.json +3 -2
  152. package/test-vectors/catalog-validator-public-api.mjs +14 -9
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.c7ae84be5039",
4
4
  "description": "MMTP/LOC container parsing for MMT over MoQ and SSM",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -178,10 +178,10 @@
178
178
  },
179
179
  "dependencies": {
180
180
  "@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",
181
+ "@blockcast/mmt-fec": "0.4.0-main.c7ae84be5039",
182
+ "@blockcast/mmt-manifest-verify": "0.4.0-main.c7ae84be5039",
183
+ "@blockcast/fec-worker": "0.4.0-main.c7ae84be5039",
184
+ "@blockcast/mmt-base": "0.4.0-main.c7ae84be5039",
185
185
  "ajv": "^8.17.1",
186
186
  "ajv-formats": "^3.0.1"
187
187
  },
@@ -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
  },
@@ -223,6 +249,11 @@
223
249
  "if": { "properties": { "algorithm": { "const": "none" } }, "required": ["algorithm"] },
224
250
  "else": { "properties": { "blockProfile": true }, "required": ["blockProfile"] }
225
251
  },
252
+ {
253
+ "$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.",
254
+ "if": { "properties": { "blockProfile": { "const": "iso-ssbg1-v1" } }, "required": ["blockProfile"] },
255
+ "then": { "properties": { "symbolSize": { "type": "integer", "minimum": 14 } } }
256
+ },
226
257
  {
227
258
  "if": { "properties": { "algorithm": { "const": "raptorq" } }, "required": ["algorithm"] },
228
259
  "then": {
@@ -248,8 +279,9 @@
248
279
  "type": "object",
249
280
  "additionalProperties": false,
250
281
  "required": ["groupAddress", "port", "tracks"],
282
+ "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
283
  "properties": {
252
- "protocol": { "enum": ["ssm", "asm", "amt", "atsc3"] },
284
+ "protocol": { "enum": ["ssm", "asm"] },
253
285
  "sourceAddress": { "type": "string", "minLength": 1 },
254
286
  "groupAddress": { "type": "string", "minLength": 1 },
255
287
  "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
@@ -258,39 +290,83 @@
258
290
  "minItems": 1,
259
291
  "items": { "$ref": "#/$defs/endpointTrack" }
260
292
  },
261
- "bandwidth": { "$ref": "#/$defs/positiveInteger" }
293
+ "bandwidth": { "$ref": "#/$defs/positiveInteger" },
294
+ "auth": { "$ref": "#/$defs/endpointAuth" },
295
+ "networkSource": {
296
+ "type": "array",
297
+ "minItems": 1,
298
+ "items": { "$ref": "#/$defs/networkSource" }
299
+ }
262
300
  },
263
301
  "allOf": [
264
- {
265
- "anyOf": [
266
- { "properties": { "protocol": true }, "required": ["protocol"] },
267
- { "properties": { "sourceAddress": true }, "required": ["sourceAddress"] }
268
- ]
269
- },
270
302
  {
271
303
  "if": { "properties": { "protocol": { "const": "ssm" } }, "required": ["protocol"] },
272
304
  "then": {
273
305
  "required": ["sourceAddress"],
274
306
  "properties": { "sourceAddress": { "type": "string", "minLength": 1 } }
275
307
  }
308
+ },
309
+ {
310
+ "if": { "properties": { "protocol": { "const": "asm" } }, "required": ["protocol"] },
311
+ "then": { "not": { "properties": { "sourceAddress": true }, "required": ["sourceAddress"] } }
312
+ },
313
+ {
314
+ "if": { "properties": { "auth": true }, "required": ["auth"] },
315
+ "then": {
316
+ "properties": { "bandwidth": true },
317
+ "required": ["bandwidth"],
318
+ "if": { "properties": { "sourceAddress": true }, "required": ["sourceAddress"] },
319
+ "then": {
320
+ "properties": {
321
+ "auth": { "not": { "type": "object", "properties": { "senderAddress": true }, "required": ["senderAddress"] } }
322
+ }
323
+ },
324
+ "else": {
325
+ "properties": {
326
+ "auth": { "type": "object", "properties": { "senderAddress": true }, "required": ["senderAddress"] }
327
+ }
328
+ }
329
+ }
276
330
  }
277
331
  ]
278
332
  },
333
+ "endpointAuth": {
334
+ "type": "object",
335
+ "additionalProperties": false,
336
+ "required": ["manifestPort", "streamId"],
337
+ "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.",
338
+ "properties": {
339
+ "manifestPort": { "type": "integer", "minimum": 1, "maximum": 65535 },
340
+ "streamId": { "type": "integer", "minimum": 0, "maximum": 4294967295 },
341
+ "senderAddress": {
342
+ "type": "string",
343
+ "minLength": 1,
344
+ "description": "S of a protected ASM endpoint; must not appear on an SSM endpoint."
345
+ },
346
+ "maxAuthDelayMs": { "type": "integer", "minimum": 50, "maximum": 1000, "default": 200 },
347
+ "manifestTimerMs": { "type": "integer", "minimum": 1, "maximum": 9007199254740991, "default": 20 },
348
+ "manifestTrack": { "type": "string", "minLength": 1 }
349
+ }
350
+ },
279
351
  "networkSource": {
280
352
  "oneOf": [
281
353
  {
282
354
  "type": "object",
283
355
  "additionalProperties": false,
284
- "required": ["type", "discovery"],
356
+ "required": ["type"],
357
+ "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
358
  "properties": {
286
359
  "type": { "const": "amt" },
287
- "discovery": { "enum": ["driad", "manual"] },
360
+ "discovery": { "enum": ["dns", "driad", "manual"] },
288
361
  "relay": { "type": "string", "minLength": 1 },
289
362
  "port": { "type": "integer", "minimum": 1, "maximum": 65535 }
290
- }
363
+ },
364
+ "if": { "properties": { "discovery": { "enum": ["dns", "manual"] } }, "required": ["discovery"] },
365
+ "then": { "properties": { "relay": true }, "required": ["relay"] }
291
366
  },
292
367
  {
293
368
  "type": "object",
369
+ "description": "ATSC 3.0 broadcast tuning for an MMTP service (draft-multicast-01 Section 4.2.2). Divergences recorded, not changed: the draft marks plpId, serviceId and slsUri OPTIONAL where this schema requires them, and states frequency in kHz where existing vectors carry Hz (587000000).",
294
370
  "additionalProperties": false,
295
371
  "required": ["type", "frequency", "plpId", "serviceId", "slsUri"],
296
372
  "properties": {
@@ -298,42 +374,37 @@
298
374
  "frequency": { "$ref": "#/$defs/positiveInteger" },
299
375
  "plpId": { "type": "integer", "minimum": 0, "maximum": 63 },
300
376
  "serviceId": { "type": "integer", "minimum": 0, "maximum": 65535 },
301
- "slsUri": { "type": "string", "format": "uri" }
377
+ "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
378
  }
303
379
  }
304
380
  ]
305
381
  },
306
- "multicastAuthTrack": {
382
+ "multicastAuthKey": {
307
383
  "type": "object",
308
384
  "additionalProperties": false,
309
- "required": ["mediaTrack", "manifestTrack", "authScope", "sourceSymbolFormat"],
385
+ "required": ["kid", "publicKey", "firstEpoch"],
310
386
  "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 }
387
+ "kid": { "type": "integer", "minimum": 0, "maximum": 4294967295 },
388
+ "publicKey": { "type": "string", "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$" },
389
+ "firstEpoch": { "type": "integer", "minimum": 0, "maximum": 4294967295 }
315
390
  }
316
391
  },
317
392
  "multicastAuth": {
318
393
  "type": "object",
319
394
  "additionalProperties": false,
320
- "required": ["scheme", "hash", "sig", "publicKey", "keyId", "compaction", "tracks"],
395
+ "required": ["scheme", "version", "sig", "keys", "minEpoch"],
396
+ "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
397
  "properties": {
322
398
  "scheme": { "const": "bc-provenance" },
323
- "hash": { "const": "blake3" },
399
+ "version": { "const": 2 },
324
400
  "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": {
401
+ "keys": {
331
402
  "type": "array",
332
403
  "minItems": 1,
333
- "uniqueItems": true,
334
- "uniqueMulticastAuthTrackBindings": true,
335
- "items": { "$ref": "#/$defs/multicastAuthTrack" }
336
- }
404
+ "maxItems": 4,
405
+ "items": { "$ref": "#/$defs/multicastAuthKey" }
406
+ },
407
+ "minEpoch": { "type": "integer", "minimum": 0, "maximum": 4294967295 }
337
408
  }
338
409
  },
339
410
  "multicast": {
@@ -350,6 +421,18 @@
350
421
  "type": "array",
351
422
  "minItems": 1,
352
423
  "items": { "$ref": "#/$defs/networkSource" }
424
+ },
425
+ "auth": { "$ref": "#/$defs/multicastAuth" }
426
+ },
427
+ "if": { "properties": { "auth": true }, "required": ["auth"] },
428
+ "then": {
429
+ "properties": {
430
+ "endpoints": { "type": "array", "items": { "type": "object", "properties": { "auth": true }, "required": ["auth"] } }
431
+ }
432
+ },
433
+ "else": {
434
+ "properties": {
435
+ "endpoints": { "type": "array", "items": { "not": { "type": "object", "properties": { "auth": true }, "required": ["auth"] } } }
353
436
  }
354
437
  }
355
438
  }
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