@blockcast/mmt-container 2.2.0-main.e1bebe787bc9 → 2.2.0-main.ea9223dc11de
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/block-policy.d.ts +33 -3
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +60 -24
- package/dist/block-policy.js.map +3 -3
- package/dist/browser-runtime.js +1034 -126
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts +40 -1
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +163 -10
- package/dist/carp-catalog.js.map +4 -4
- package/dist/catalog-fec-params.js +34 -0
- package/dist/catalog-fec-params.js.map +3 -3
- package/dist/catalog-network-source.js +34 -0
- package/dist/catalog-network-source.js.map +3 -3
- package/dist/datagram-leg-deadline.d.ts +138 -0
- package/dist/datagram-leg-deadline.d.ts.map +1 -0
- package/dist/datagram-leg-deadline.js +229 -0
- package/dist/datagram-leg-deadline.js.map +7 -0
- package/dist/delivery-catalog.js +68 -0
- package/dist/delivery-catalog.js.map +4 -4
- package/dist/delta-fallback-config.js +34 -0
- package/dist/delta-fallback-config.js.map +3 -3
- package/dist/fec-manager.d.ts +117 -13
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +358 -42
- package/dist/fec-manager.js.map +4 -4
- package/dist/fec-state.d.ts +17 -5
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +36 -0
- package/dist/fec-state.js.map +3 -3
- package/dist/fec-worker-setup.js +34 -0
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/held-layer-admission.js +34 -0
- package/dist/held-layer-admission.js.map +3 -3
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +16 -0
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +62 -0
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +34 -0
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +6 -3
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +34 -0
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +167 -13
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +34 -0
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-fec-session.js +34 -0
- package/dist/mmtp-fec-session.js.map +3 -3
- package/dist/mmtp-mode-selection.d.ts +48 -0
- package/dist/mmtp-mode-selection.d.ts.map +1 -0
- package/dist/mmtp-mode-selection.js +79 -0
- package/dist/mmtp-mode-selection.js.map +7 -0
- package/dist/mmtp-router.d.ts +66 -10
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +204 -30
- package/dist/mmtp-router.js.map +4 -4
- package/dist/multicast-auth-catalog.js +42 -2
- package/dist/multicast-auth-catalog.js.map +3 -3
- package/dist/multicast-input.js +42 -2
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +95 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +613 -92
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.js +68 -0
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +34 -0
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.js +167 -13
- package/dist/no-modules.js.map +4 -4
- package/dist/phase14-catalog-override.d.ts +2 -1
- package/dist/phase14-catalog-override.d.ts.map +1 -1
- package/dist/phase14-catalog-override.js +69 -2
- package/dist/phase14-catalog-override.js.map +3 -3
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +50 -0
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layer-subscriptions.js +34 -0
- package/dist/repair-layer-subscriptions.js.map +3 -3
- package/dist/signaling.js +34 -0
- package/dist/signaling.js.map +3 -3
- package/dist/timestamp-codec.js +34 -0
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +34 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +34 -0
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/schemas/catalog.schema.json +2 -2
- package/src/block-policy.ts +108 -31
- package/src/carp-catalog.ts +165 -5
- package/src/datagram-leg-deadline.ts +370 -0
- package/src/fec-manager.ts +345 -33
- package/src/fec-state.ts +21 -5
- package/src/index.ts +37 -0
- package/src/iso-block-locator.ts +34 -0
- package/src/mmtp-container-parser.ts +6 -4
- package/src/mmtp-mode-selection.ts +80 -0
- package/src/mmtp-router.ts +226 -45
- package/src/multicast-manager.ts +126 -0
- package/src/phase14-catalog-override.ts +14 -3
- package/src/repair-fetch.ts +23 -0
- package/test-vectors/catalog/README.md +36 -2
- package/test-vectors/catalog/mmtp-siblings/ambiguous-sibling.json +158 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-bitrate-only.json +231 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-four-rungs.json +405 -0
- package/test-vectors/catalog/mmtp-siblings/ladder-other-names.json +231 -0
- package/test-vectors/catalog/mmtp-siblings/mmtp-mode-unknown.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/multicast-endpoint-lists-datagram-track.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/no-sibling.json +79 -0
- package/test-vectors/catalog/mmtp-siblings/rendition-mismatch.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/stream-delivery-mode.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/timescale-mismatch.json +143 -0
- package/test-vectors/catalog/mmtp-siblings/valid-pair.json +142 -0
- package/test-vectors/catalog/section-codes.json +3 -3
- package/test-vectors/catalog-timing.json +742 -1
- package/test-vectors/catalog-validation.json +266 -7
- package/test-vectors/moq/mmtp-mode-selection.json +259 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockcast/mmt-container",
|
|
3
|
-
"version": "2.2.0-main.
|
|
3
|
+
"version": "2.2.0-main.ea9223dc11de",
|
|
4
4
|
"description": "MMTP/LOC container parsing for MMT over MoQ and SSM",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -169,10 +169,10 @@
|
|
|
169
169
|
"test:watch": "vitest"
|
|
170
170
|
},
|
|
171
171
|
"dependencies": {
|
|
172
|
-
"@blockcast/fec-worker": "2.2.0-main.
|
|
173
|
-
"@blockcast/mmt-base": "2.2.0-main.
|
|
174
|
-
"@blockcast/mmt-fec": "2.2.0-main.
|
|
175
|
-
"@blockcast/mmt-manifest-verify": "2.2.0-main.
|
|
172
|
+
"@blockcast/fec-worker": "2.2.0-main.ea9223dc11de",
|
|
173
|
+
"@blockcast/mmt-base": "2.2.0-main.ea9223dc11de",
|
|
174
|
+
"@blockcast/mmt-fec": "2.2.0-main.ea9223dc11de",
|
|
175
|
+
"@blockcast/mmt-manifest-verify": "2.2.0-main.ea9223dc11de",
|
|
176
176
|
"@noble/curves": "^1.9.7",
|
|
177
177
|
"@noble/hashes": "^1.8.0",
|
|
178
178
|
"ajv": "^8.17.1",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"maximum": 16777215,
|
|
130
130
|
"description": "fec-repair only. Repair symbols per block carried by this layer (P_i)."
|
|
131
131
|
},
|
|
132
|
-
"mmtpMode": { "
|
|
132
|
+
"mmtpMode": { "type": "string", "minLength": 1 },
|
|
133
133
|
"timescale": { "$ref": "#/$defs/positiveInteger" },
|
|
134
134
|
"groupDurationMs": { "$ref": "#/$defs/positiveInteger" },
|
|
135
135
|
"groupDurationTicks": { "$ref": "#/$defs/positiveInteger" },
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"then": {
|
|
151
151
|
"required": ["mmtpMode", "timescale"],
|
|
152
152
|
"properties": {
|
|
153
|
-
"mmtpMode": { "
|
|
153
|
+
"mmtpMode": { "type": "string", "minLength": 1 },
|
|
154
154
|
"timescale": { "$ref": "#/$defs/positiveInteger" },
|
|
155
155
|
"groupDurationMs": { "$ref": "#/$defs/positiveInteger" }
|
|
156
156
|
},
|
package/src/block-policy.ts
CHANGED
|
@@ -133,6 +133,8 @@ export type BlockClassifierGeometry =
|
|
|
133
133
|
readonly trackKind: 'video'
|
|
134
134
|
readonly mode: 'all-protected'
|
|
135
135
|
readonly reason: ClassifierReason
|
|
136
|
+
/** The catalog interval when one is stated: gap decisions use it (keyframeInstantBetween). */
|
|
137
|
+
readonly keyframeInterval?: KeyframeInterval
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
/**
|
|
@@ -176,34 +178,31 @@ export function deriveBlockClassifierGeometry(
|
|
|
176
178
|
}
|
|
177
179
|
if (input.trackKind === 'audio') return { trackKind: 'audio' }
|
|
178
180
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const framerate = input.framerate
|
|
183
|
-
|
|
184
|
-
let keyframeInterval: KeyframeInterval
|
|
181
|
+
// Every video geometry keeps the catalog interval: gap decisions need it in
|
|
182
|
+
// either mode (fec-multicast-00 Block Classification item 3).
|
|
183
|
+
let keyframeInterval: KeyframeInterval | undefined
|
|
185
184
|
if (isPositiveFinite(input.keyframeIntervalTicks) && isPositiveFinite(input.timescale)) {
|
|
186
185
|
keyframeInterval = { ticks: input.keyframeIntervalTicks, timescale: input.timescale }
|
|
187
186
|
} else if (isPositiveFinite(input.keyframeIntervalMs)) {
|
|
188
187
|
keyframeInterval = { ticks: input.keyframeIntervalMs, timescale: 1000 }
|
|
189
|
-
} else {
|
|
190
|
-
return { trackKind: 'video', mode: 'all-protected', reason: 'keyframe-cadence-absent' }
|
|
191
188
|
}
|
|
189
|
+
const protect = (reason: ClassifierReason): BlockClassifierGeometry => ({
|
|
190
|
+
trackKind: 'video',
|
|
191
|
+
mode: 'all-protected',
|
|
192
|
+
reason,
|
|
193
|
+
...(keyframeInterval === undefined ? {} : { keyframeInterval }),
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
if (!isPositiveFinite(input.framerate)) return protect('framerate-absent')
|
|
197
|
+
const framerate = input.framerate
|
|
198
|
+
if (keyframeInterval === undefined) return protect('keyframe-cadence-absent')
|
|
192
199
|
|
|
193
200
|
const gopFrames = exactInteger(keyframeInterval.ticks * framerate, keyframeInterval.timescale)
|
|
194
|
-
if (gopFrames === null)
|
|
195
|
-
return {
|
|
196
|
-
trackKind: 'video',
|
|
197
|
-
mode: 'all-protected',
|
|
198
|
-
reason: 'keyframe-interval-not-integral',
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
+
if (gopFrames === null) return protect('keyframe-interval-not-integral')
|
|
201
202
|
|
|
202
203
|
const frameDurationMs = 1000 / framerate
|
|
203
204
|
const interleaveUnits = deriveFecInterleaveDepth(input.interleaveDepthMs, frameDurationMs)
|
|
204
|
-
if (interleaveUnits >= gopFrames)
|
|
205
|
-
return { trackKind: 'video', mode: 'all-protected', reason: 'block-spans-gop' }
|
|
206
|
-
}
|
|
205
|
+
if (interleaveUnits >= gopFrames) return protect('block-spans-gop')
|
|
207
206
|
|
|
208
207
|
return {
|
|
209
208
|
trackKind: 'video',
|
|
@@ -217,14 +216,15 @@ export function deriveBlockClassifierGeometry(
|
|
|
217
216
|
|
|
218
217
|
/**
|
|
219
218
|
* The keyframe interval expressed in a media track's timescale, or null when
|
|
220
|
-
* the geometry
|
|
221
|
-
*
|
|
219
|
+
* the geometry states none or the interval is not an exact integer number of
|
|
220
|
+
* media ticks (fec-multicast-00 Block Classification item 3: an inexact one
|
|
221
|
+
* gives no usable interval).
|
|
222
222
|
*/
|
|
223
223
|
export function keyframeIntervalMediaTicks(
|
|
224
224
|
geometry: BlockClassifierGeometry,
|
|
225
225
|
mediaTimescale: number,
|
|
226
226
|
): bigint | null {
|
|
227
|
-
if (geometry.trackKind !== 'video' || geometry.
|
|
227
|
+
if (geometry.trackKind !== 'video' || geometry.keyframeInterval === undefined) return null
|
|
228
228
|
if (!Number.isSafeInteger(mediaTimescale) || mediaTimescale <= 0) return null
|
|
229
229
|
const { ticks, timescale } = geometry.keyframeInterval
|
|
230
230
|
if (!Number.isSafeInteger(ticks) || !Number.isSafeInteger(timescale)) return null
|
|
@@ -234,6 +234,19 @@ export function keyframeIntervalMediaTicks(
|
|
|
234
234
|
return scaled / divisor
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* fec-multicast-00 Block Classification item 3 for two released frames:
|
|
239
|
+
* whether `(from, to]` holds `start + k * interval` for some k >= 1, `start`
|
|
240
|
+
* the decode time of an MPU's first RAP, all in one media timescale. `from`
|
|
241
|
+
* is exclusive: the frame at `from` is held and complete, so an instant there
|
|
242
|
+
* is that frame itself (an on-cadence RAP), not a lost one. The draft's closed
|
|
243
|
+
* interval is for bounding packets, which may be part of a RAP.
|
|
244
|
+
*/
|
|
245
|
+
export function keyframeInstantBetween(start: bigint, interval: bigint, from: bigint, to: bigint): boolean {
|
|
246
|
+
const k = from >= start ? (from - start) / interval + 1n : 1n
|
|
247
|
+
return start + k * interval <= to
|
|
248
|
+
}
|
|
249
|
+
|
|
237
250
|
// ─── Evidence ───────────────────────────────────────────────────────
|
|
238
251
|
|
|
239
252
|
/**
|
|
@@ -319,6 +332,15 @@ function compareDataUnitStarts(
|
|
|
319
332
|
return ((a.movieFragment - b.movieFragment) | 0) || a.idx - b.idx || a.offset - b.offset
|
|
320
333
|
}
|
|
321
334
|
|
|
335
|
+
/**
|
|
336
|
+
* How many MPUs behind the newest released RAP a stale release can be. The
|
|
337
|
+
* release gate holds a frame for seconds at most, so a late copy is a few
|
|
338
|
+
* MPUs back; anything further is another MPU sequence. With MPUs so short
|
|
339
|
+
* that a late copy lies further back, it re-anchors there: the newest MPU's
|
|
340
|
+
* gaps read rap-unknown until the next MPU's RAP, never a wrong measure.
|
|
341
|
+
*/
|
|
342
|
+
const LATE_RAP_MAX_MPUS_BACK = 64
|
|
343
|
+
|
|
322
344
|
/** One MPU's movie fragments (P3). */
|
|
323
345
|
interface MpuLayout {
|
|
324
346
|
/** Serial-earliest movie_fragment_sequence_number of its DU headers. */
|
|
@@ -435,7 +457,8 @@ export class BlockClassifier {
|
|
|
435
457
|
#lastAnchor: { mpu: number; fragment: number } | null = null
|
|
436
458
|
/** Two anchors were exactly G fragments per MPU apart. */
|
|
437
459
|
#fragmentsProven = false
|
|
438
|
-
|
|
460
|
+
/** The first RAP released of the latest MPU a RAP was released in, recorded in every mode. */
|
|
461
|
+
#lastRap: { mpu: number; presentationTime: bigint; mediaTimescale: number; decodeTime?: bigint } | null = null
|
|
439
462
|
|
|
440
463
|
constructor(geometry: BlockClassifierGeometry) {
|
|
441
464
|
this.#geometry = geometry
|
|
@@ -513,6 +536,9 @@ export class BlockClassifier {
|
|
|
513
536
|
noteSourceDiscontinuity(): void {
|
|
514
537
|
this.#clearContiguityLedger()
|
|
515
538
|
this.#clearMpuLayout()
|
|
539
|
+
// A restarted publisher numbers MPUs again: its first RAP is no second
|
|
540
|
+
// RAP of the MPU the old sequence last released one in.
|
|
541
|
+
this.#lastRap = null
|
|
516
542
|
}
|
|
517
543
|
|
|
518
544
|
/** Register a block that exists without evidence (a vanished block). */
|
|
@@ -578,29 +604,63 @@ export class BlockClassifier {
|
|
|
578
604
|
* RAP-bearing block is the one a wrong G calls delta), because the next
|
|
579
605
|
* released RAP then belongs to m+2. Every MPU is one interval long, so the
|
|
580
606
|
* span to any later released RAP proves or refutes all MPUs in between.
|
|
607
|
+
*
|
|
608
|
+
* In every mode it keeps each MPU's first released RAP, with its decode
|
|
609
|
+
* time, as the start keyframeFreeBetween measures the catalog interval
|
|
610
|
+
* from, and a second RAP released inside one MPU refutes `mpuBoundsRaps`
|
|
611
|
+
* when it lies off the catalog lattice (not a whole number of intervals
|
|
612
|
+
* after the first; draft-ramadan-moq-mmt-02 4.4.3 binds every keyframe to
|
|
613
|
+
* it): with no repair, released RAPs are the only evidence of where they
|
|
614
|
+
* lie. Without a usable interval, or a decode time on either, any second
|
|
615
|
+
* RAP with another presentation time refutes.
|
|
581
616
|
*/
|
|
582
617
|
noteReleasedRap(
|
|
583
618
|
mpu: number,
|
|
584
619
|
presentationTime: bigint,
|
|
585
620
|
mediaTimescale: number,
|
|
621
|
+
decodeTime?: bigint,
|
|
586
622
|
): ClassifierChange[] {
|
|
587
|
-
if (this.#geometry.trackKind === 'audio'
|
|
623
|
+
if (this.#geometry.trackKind === 'audio') return []
|
|
624
|
+
const previous = this.#lastRap
|
|
625
|
+
// A further RAP inside an already-anchored MPU is not an MPU start; the
|
|
626
|
+
// MPU keeps its first RAP as the spacing anchor (rap-not-mpu-start owns
|
|
627
|
+
// mid-MPU RAPs). The same RAP released again is no further one.
|
|
628
|
+
if (previous !== null && previous.mpu === mpu && previous.mediaTimescale === mediaTimescale) {
|
|
629
|
+
if (presentationTime === previous.presentationTime) return []
|
|
630
|
+
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale)
|
|
631
|
+
if (
|
|
632
|
+
interval === null ||
|
|
633
|
+
decodeTime === undefined ||
|
|
634
|
+
previous.decodeTime === undefined ||
|
|
635
|
+
(decodeTime - previous.decodeTime) % interval !== 0n
|
|
636
|
+
) {
|
|
637
|
+
this.#mpuBoundsRaps = false
|
|
638
|
+
}
|
|
588
639
|
return []
|
|
589
640
|
}
|
|
641
|
+
// A late copy of an earlier MPU's RAP (the gate reports stale releases
|
|
642
|
+
// too) moves no anchor back: the newest MPU's gaps are measured from its
|
|
643
|
+
// own. MPU sequence numbers wrap at 2^32, so "earlier" is serial; it is
|
|
644
|
+
// bounded, and a late copy is older in presentation time than the anchor.
|
|
645
|
+
// Any other RAP behind the anchor is a restarted MPU sequence nothing
|
|
646
|
+
// signalled, which re-anchors, or no same-MPU gap could ever be measured
|
|
647
|
+
// again. A restart inside the bound whose presentation time went back
|
|
648
|
+
// too still reads as late, and fails closed: its same-MPU gaps stay
|
|
649
|
+
// rap-unknown until its MPU numbers pass the old newest, and unless it
|
|
650
|
+
// repeats the old timeline the spacing checks then end the epoch
|
|
651
|
+
// all-protected.
|
|
652
|
+
if (previous !== null && previous.mediaTimescale === mediaTimescale) {
|
|
653
|
+
const back = (previous.mpu - mpu) >>> 0
|
|
654
|
+
if (back !== 0 && back <= LATE_RAP_MAX_MPUS_BACK && presentationTime < previous.presentationTime) return []
|
|
655
|
+
}
|
|
656
|
+
this.#lastRap = { mpu, presentationTime, mediaTimescale, ...(decodeTime === undefined ? {} : { decodeTime }) }
|
|
657
|
+
if (this.#mode === 'all-protected') return []
|
|
590
658
|
// Verification compares integers in the media timescale. When the
|
|
591
659
|
// catalog interval is not an exact tick count there, spacing is
|
|
592
660
|
// unprovable: fail closed, naming the cause, rather than blaming the
|
|
593
661
|
// encoder with rap-spacing-mismatch on a perfectly spaced RAP.
|
|
594
662
|
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale)
|
|
595
663
|
if (interval === null) return this.#disable('keyframe-interval-not-media-integral')
|
|
596
|
-
const previous = this.#lastRap
|
|
597
|
-
// A further RAP inside an already-anchored MPU is not an MPU start; the
|
|
598
|
-
// MPU keeps its first RAP as the spacing anchor (rap-not-mpu-start owns
|
|
599
|
-
// mid-MPU RAPs).
|
|
600
|
-
if (previous !== null && previous.mpu === mpu && previous.mediaTimescale === mediaTimescale) {
|
|
601
|
-
return []
|
|
602
|
-
}
|
|
603
|
-
this.#lastRap = { mpu, presentationTime, mediaTimescale }
|
|
604
664
|
if (
|
|
605
665
|
previous === null ||
|
|
606
666
|
mpu < previous.mpu ||
|
|
@@ -616,6 +676,23 @@ export class BlockClassifier {
|
|
|
616
676
|
return this.#disable('rap-spacing-mismatch')
|
|
617
677
|
}
|
|
618
678
|
|
|
679
|
+
/**
|
|
680
|
+
* Whether a gap inside MPU `mpu`, between the decode times `from` and `to`
|
|
681
|
+
* of the frames on either side, holds no keyframe: MPU boundaries still
|
|
682
|
+
* bound RAPs, the catalog states an interval exact in this timescale, and
|
|
683
|
+
* none of its instants after the MPU's first released RAP lies in
|
|
684
|
+
* `(from, to]` (fec-multicast-00 Block Classification item 3). Anything
|
|
685
|
+
* unknown counts as a keyframe.
|
|
686
|
+
*/
|
|
687
|
+
keyframeFreeBetween(mpu: number, from: bigint, to: bigint, mediaTimescale: number): boolean {
|
|
688
|
+
const rap = this.#lastRap
|
|
689
|
+
if (!this.#mpuBoundsRaps || rap?.mpu !== mpu || rap.mediaTimescale !== mediaTimescale || rap.decodeTime === undefined) {
|
|
690
|
+
return false
|
|
691
|
+
}
|
|
692
|
+
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale)
|
|
693
|
+
return interval !== null && !keyframeInstantBetween(rap.decodeTime, interval, from, to)
|
|
694
|
+
}
|
|
695
|
+
|
|
619
696
|
#blockFor(sbn: number): BlockEvidence {
|
|
620
697
|
let block = this.#blocks.get(sbn)
|
|
621
698
|
if (!block) {
|
package/src/carp-catalog.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
MMTP_SIGNALING_PACKET_ID,
|
|
14
14
|
type FecBlockProfile,
|
|
15
15
|
} from "@blockcast/mmt-base";
|
|
16
|
-
import { multicastEndpointSource } from "@blockcast/mmt-base";
|
|
16
|
+
import { MMTP_SIBLING_RENDITION_FIELDS, isMmtpMode, mmtpSiblingCandidates, multicastEndpointSource } from "@blockcast/mmt-base";
|
|
17
17
|
import type { EndpointAuthConfig, MulticastAuthConfig } from "./multicast-auth-catalog.js";
|
|
18
18
|
|
|
19
19
|
// ── Track Role (Phase 14, D-02..D-05) ─────────────────────────
|
|
@@ -602,6 +602,11 @@ function validateArchive(catalog: Record<string, unknown>): void {
|
|
|
602
602
|
export type CmsfCatalog = {
|
|
603
603
|
version: number;
|
|
604
604
|
tracks: Record<string, unknown>[];
|
|
605
|
+
/**
|
|
606
|
+
* The mmtp tracks `validateCmsfMmtpCatalog` removed from `tracks`, and why
|
|
607
|
+
* (mmt-02 13.1 / 4.3.1). Absent when it removed none; not enumerable.
|
|
608
|
+
*/
|
|
609
|
+
rejectedTracks?: MmtpTrackIssue[];
|
|
605
610
|
multicast?: Record<string, unknown>;
|
|
606
611
|
archive?: ArchiveConfig;
|
|
607
612
|
[key: string]: unknown;
|
|
@@ -619,6 +624,8 @@ export type CmsfCatalogErrorCode =
|
|
|
619
624
|
| "track_is_live"
|
|
620
625
|
| "track_codec"
|
|
621
626
|
| "track_mmtp_mode"
|
|
627
|
+
| "track_mmtp_sibling"
|
|
628
|
+
| "track_delivery_mode_conflict"
|
|
622
629
|
| "track_presentation_anchor"
|
|
623
630
|
| "track_init_ref"
|
|
624
631
|
| "catalog_init_data_list"
|
|
@@ -814,10 +821,10 @@ export function validateCmsfMmtpCatalog(
|
|
|
814
821
|
// here throws on `fec` or on a repair or symbol track. A -01 single-object
|
|
815
822
|
// `fec` therefore costs only that track's FEC (BLO-50171).
|
|
816
823
|
if (packaging === "mmtp") {
|
|
817
|
-
// mmt-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
824
|
+
// mmt-02 13.1: `mmtpMode` is "mfu" or "mfu-datagram"; absent or
|
|
825
|
+
// unknown rejects the track, never the catalog: no throw here,
|
|
826
|
+
// `dropRejectedMmtpTracks` removes it from the result, with the
|
|
827
|
+
// sibling and delivery-mode rejections of 4.3.1.
|
|
821
828
|
if (!positiveInteger(timescale)) {
|
|
822
829
|
catalogError("track_timescale", `${path}.timescale`, "must be a positive integer");
|
|
823
830
|
}
|
|
@@ -938,9 +945,162 @@ export function validateCmsfMmtpCatalog(
|
|
|
938
945
|
|
|
939
946
|
validateArchive(catalog);
|
|
940
947
|
|
|
948
|
+
dropRejectedMmtpTracks(catalog);
|
|
941
949
|
return catalog as CmsfCatalog;
|
|
942
950
|
}
|
|
943
951
|
|
|
952
|
+
// mmt-02 13.1 / 4.3.1: a rejected mmtp track leaves the validated catalog,
|
|
953
|
+
// with the `fec-repair` tracks and endpoint references that name it, so a
|
|
954
|
+
// caller that relies on the validator alone never subscribes it. In place,
|
|
955
|
+
// like the `version` normalization: a caller that keeps its own reference
|
|
956
|
+
// sees the same tracks. A catalog with no rejected track is untouched.
|
|
957
|
+
function dropRejectedMmtpTracks(catalog: Record<string, unknown>): void {
|
|
958
|
+
const rejected = mmtpTrackIssues(catalog);
|
|
959
|
+
if (rejected.length === 0) return;
|
|
960
|
+
const tracks = catalog["tracks"] as unknown[];
|
|
961
|
+
const rejectedIndexes = new Set(rejected.map((issue) => issue.index));
|
|
962
|
+
const nameOf = (track: unknown) => (track as Record<string, unknown> | null)?.["name"];
|
|
963
|
+
const mediaNames = new Set(tracks.filter((_, index) => !rejectedIndexes.has(index)).map(nameOf));
|
|
964
|
+
const kept = tracks.filter((track, index) => {
|
|
965
|
+
if (rejectedIndexes.has(index)) return false;
|
|
966
|
+
const t = track as Record<string, unknown> | null;
|
|
967
|
+
return !(t?.["packaging"] === "fec-repair" && typeof t["source"] === "string" && !mediaNames.has(t["source"]) &&
|
|
968
|
+
rejected.some((issue) => issue.name === t["source"]));
|
|
969
|
+
});
|
|
970
|
+
catalog["tracks"] = kept;
|
|
971
|
+
const keptNames = new Set(kept.map(nameOf));
|
|
972
|
+
const endpoints = (catalog["multicast"] as Record<string, unknown> | undefined)?.["endpoints"];
|
|
973
|
+
if (Array.isArray(endpoints)) {
|
|
974
|
+
for (const endpoint of endpoints as (Record<string, unknown> | null)[]) {
|
|
975
|
+
const refs = endpoint?.["tracks"];
|
|
976
|
+
if (!endpoint || !Array.isArray(refs)) continue;
|
|
977
|
+
// A reference to a dropped track would read as "unknown catalog
|
|
978
|
+
// track" and fail the whole catalog on a second validation.
|
|
979
|
+
endpoint["tracks"] = refs.filter((ref) => keptNames.has(typeof ref === "object" ? nameOf(ref) : ref));
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
// Not enumerable: the catalog serializes and schema-validates as before.
|
|
983
|
+
Object.defineProperty(catalog, "rejectedTracks", { value: rejected, enumerable: false, configurable: true, writable: true });
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/** The mmtp track admission rules of draft-ramadan-moq-mmt-02 13.1 and 4.3.1. */
|
|
987
|
+
export type MmtpTrackIssueCode = "track_mmtp_mode" | "track_mmtp_sibling" | "track_delivery_mode_conflict";
|
|
988
|
+
|
|
989
|
+
export interface MmtpTrackIssue {
|
|
990
|
+
code: MmtpTrackIssueCode;
|
|
991
|
+
/** JSONPath of the offending field. */
|
|
992
|
+
path: string;
|
|
993
|
+
message: string;
|
|
994
|
+
/** The mmtp track a subscriber rejects; every other track stays usable. */
|
|
995
|
+
name: string;
|
|
996
|
+
index: number;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Every mmtp track a subscriber rejects, in document order, and why. These
|
|
1001
|
+
* are track-level: `validateCmsfMmtpCatalog` never throws on them, it removes
|
|
1002
|
+
* each named track from the catalog it returns and lists them in
|
|
1003
|
+
* `rejectedTracks`, so one bad track costs nothing else (mmt-02 13.1: "a
|
|
1004
|
+
* subscriber MUST reject a track whose mmtpMode is absent or unknown"). Call
|
|
1005
|
+
* this on a catalog that has not been validated yet. Never throws.
|
|
1006
|
+
*
|
|
1007
|
+
* - `track_mmtp_mode`: `mmtpMode` is absent or neither "mfu" nor "mfu-datagram".
|
|
1008
|
+
* - `track_delivery_mode_conflict`: an "mfu-datagram" track, or a `fec-repair`
|
|
1009
|
+
* track whose `source` it is, declares `deliveryMode: "stream"`; libmmt
|
|
1010
|
+
* would subscribe no repair (`catalogTrackDeliveryMode`) on the one track
|
|
1011
|
+
* whose point is repair.
|
|
1012
|
+
* - `track_mmtp_sibling`: an "mfu-datagram" track equals no "mfu" track on
|
|
1013
|
+
* the whole identity set (namespace, `timescale`,
|
|
1014
|
+
* `presentationAnchorTicks`, group duration and the 13.1 rendition fields,
|
|
1015
|
+
* `MMTP_SIBLING_RENDITION_FIELDS`), or more than one: the two carry one
|
|
1016
|
+
* payload, so one description (mmt-02 4.3.1). Or it shares its "mfu" track
|
|
1017
|
+
* with another "mfu-datagram" track: the catalog does not say which one
|
|
1018
|
+
* mirrors it. A track with a `track_delivery_mode_conflict` is dropped, so
|
|
1019
|
+
* it is not counted as that other track.
|
|
1020
|
+
*/
|
|
1021
|
+
export function mmtpTrackIssues(catalog: unknown): MmtpTrackIssue[] {
|
|
1022
|
+
if (typeof catalog !== "object" || catalog === null || Array.isArray(catalog)) return [];
|
|
1023
|
+
const tracks = (catalog as Record<string, unknown>)["tracks"];
|
|
1024
|
+
if (!Array.isArray(tracks)) return [];
|
|
1025
|
+
const records = tracks.filter(
|
|
1026
|
+
(track): track is Record<string, unknown> => typeof track === "object" && track !== null && !Array.isArray(track),
|
|
1027
|
+
);
|
|
1028
|
+
const issues: MmtpTrackIssue[] = [];
|
|
1029
|
+
// Where an "mfu-datagram" track, or a repair track whose source it is, says deliveryMode "stream".
|
|
1030
|
+
const streamPaths = (track: Record<string, unknown>): string[] => {
|
|
1031
|
+
const name = typeof track["name"] === "string" ? track["name"] : "";
|
|
1032
|
+
return [track, ...records.filter((repair) => repair["packaging"] === "fec-repair" && repair["source"] === name)]
|
|
1033
|
+
.filter((declaring) => declaring["deliveryMode"] === "stream")
|
|
1034
|
+
.map((declaring) => `$.tracks[${tracks.indexOf(declaring)}]`);
|
|
1035
|
+
};
|
|
1036
|
+
// The "mfu" tracks each "mfu-datagram" track could mirror, and for each "mfu"
|
|
1037
|
+
// track with exactly such a match, the datagram tracks that claim it. A track
|
|
1038
|
+
// rejected for its delivery mode is dropped, so it claims none.
|
|
1039
|
+
const candidatesOf = new Map<Record<string, unknown>, Record<string, unknown>[]>();
|
|
1040
|
+
const mirrorsOf = new Map<Record<string, unknown>, Record<string, unknown>[]>();
|
|
1041
|
+
for (const track of records) {
|
|
1042
|
+
if (track["packaging"] !== "mmtp" || track["mmtpMode"] !== "mfu-datagram") continue;
|
|
1043
|
+
const candidates = mmtpSiblingCandidates(records, track);
|
|
1044
|
+
candidatesOf.set(track, candidates);
|
|
1045
|
+
if (candidates.length === 1 && streamPaths(track).length === 0) {
|
|
1046
|
+
mirrorsOf.set(candidates[0]!, [...(mirrorsOf.get(candidates[0]!) ?? []), track]);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
for (const track of records) {
|
|
1050
|
+
const index = tracks.indexOf(track);
|
|
1051
|
+
const path = `$.tracks[${index}]`;
|
|
1052
|
+
const name = typeof track["name"] === "string" ? track["name"] : "";
|
|
1053
|
+
if (track["packaging"] !== "mmtp") continue;
|
|
1054
|
+
const mode = track["mmtpMode"];
|
|
1055
|
+
if (!isMmtpMode(mode)) {
|
|
1056
|
+
issues.push({
|
|
1057
|
+
code: "track_mmtp_mode",
|
|
1058
|
+
path: `${path}.mmtpMode`,
|
|
1059
|
+
message: `mmtpMode must be "mfu" or "mfu-datagram", got ${JSON.stringify(mode)}; a subscriber rejects the track (draft-ramadan-moq-mmt-02 13.1)`,
|
|
1060
|
+
name,
|
|
1061
|
+
index,
|
|
1062
|
+
});
|
|
1063
|
+
continue;
|
|
1064
|
+
}
|
|
1065
|
+
if (mode !== "mfu-datagram") continue;
|
|
1066
|
+
const conflict = (at: string) => issues.push({
|
|
1067
|
+
code: "track_delivery_mode_conflict",
|
|
1068
|
+
path: `${at}.deliveryMode`,
|
|
1069
|
+
message: `"mfu-datagram" track ${JSON.stringify(name)} and its repair tracks are sent as datagrams; deliveryMode "stream" would subscribe no repair (draft-ramadan-moq-mmt-02 4.3.1)`,
|
|
1070
|
+
name,
|
|
1071
|
+
index,
|
|
1072
|
+
});
|
|
1073
|
+
const streams = streamPaths(track);
|
|
1074
|
+
for (const at of streams) conflict(at);
|
|
1075
|
+
const candidates = candidatesOf.get(track) ?? [];
|
|
1076
|
+
// Two datagram tracks that mirror one "mfu" track: pairMmtpSiblings pairs
|
|
1077
|
+
// neither, so each is rejected here and the fallback to "mfu" has a reason.
|
|
1078
|
+
const rivals = candidates.length === 1 && streams.length === 0
|
|
1079
|
+
? (mirrorsOf.get(candidates[0]!) ?? []).filter((other) => other !== track)
|
|
1080
|
+
: [];
|
|
1081
|
+
if (rivals.length > 0) {
|
|
1082
|
+
issues.push({
|
|
1083
|
+
code: "track_mmtp_sibling",
|
|
1084
|
+
path,
|
|
1085
|
+
message: `"mfu-datagram" track ${JSON.stringify(name)} mirrors "mfu" track ${JSON.stringify(candidates[0]!["name"])}, and so ${rivals.length === 1 ? "does" : "do"} ${rivals.map((rival) => JSON.stringify(rival["name"])).join(", ")}; the catalog does not say which one mirrors it, so a subscriber pairs none (draft-ramadan-moq-mmt-02 4.3.1)`,
|
|
1086
|
+
name,
|
|
1087
|
+
index,
|
|
1088
|
+
});
|
|
1089
|
+
} else if (candidates.length !== 1) {
|
|
1090
|
+
issues.push({
|
|
1091
|
+
code: "track_mmtp_sibling",
|
|
1092
|
+
path,
|
|
1093
|
+
message: candidates.length === 0
|
|
1094
|
+
? `"mfu-datagram" track ${JSON.stringify(name)} mirrors no "mfu" track of its namespace with the same timescale, presentationAnchorTicks, group duration and rendition fields (${MMTP_SIBLING_RENDITION_FIELDS.join(", ")}), each equal or absent on both (draft-ramadan-moq-mmt-02 4.3.1, 13.1)`
|
|
1095
|
+
: `"mfu-datagram" track ${JSON.stringify(name)} could mirror ${candidates.length} "mfu" tracks (${candidates.map((c) => JSON.stringify(c["name"])).join(", ")}) that carry one description; the pair is ambiguous`,
|
|
1096
|
+
name,
|
|
1097
|
+
index,
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
return issues;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
944
1104
|
/**
|
|
945
1105
|
* Resolve a track's group duration to integer ticks using the supplied
|
|
946
1106
|
* timescale (Hz). Implements mmt-01 §4.4.2:
|