@blockcast/mmt-container 2.2.0-main.cc080e5a56f2 → 2.2.0-main.cc3fe0684403
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/README.md +5 -2
- package/dist/block-policy.d.ts +88 -16
- package/dist/block-policy.d.ts.map +1 -1
- package/dist/block-policy.js +164 -56
- package/dist/block-policy.js.map +3 -3
- package/dist/browser-runtime.js +1485 -172
- 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.d.ts +1 -1
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +48 -1
- 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/cmaf-block-assembler.js +92 -1
- package/dist/cmaf-block-assembler.js.map +2 -2
- package/dist/codec-utils.d.ts.map +1 -1
- package/dist/codec-utils.js +92 -1
- package/dist/codec-utils.js.map +2 -2
- package/dist/datagram-leg-deadline.d.ts +118 -0
- package/dist/datagram-leg-deadline.d.ts.map +1 -0
- package/dist/datagram-leg-deadline.js +217 -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 +39 -1
- package/dist/delta-fallback-config.js.map +4 -4
- package/dist/fec-manager.d.ts +155 -10
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +596 -81
- 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 +41 -1
- 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 +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- 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 +30 -2
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +140 -2
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +293 -18
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +140 -2
- 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 -8
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +348 -27
- 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 +108 -1
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +1067 -138
- 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.d.ts +1 -0
- package/dist/no-modules.d.ts.map +1 -1
- package/dist/no-modules.js +295 -19
- 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 +140 -2
- 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 +324 -83
- package/src/carp-catalog.ts +165 -5
- package/src/catalog-fec-params.ts +1 -0
- package/src/codec-utils.ts +121 -1
- package/src/datagram-leg-deadline.ts +342 -0
- package/src/fec-manager.ts +534 -41
- package/src/fec-state.ts +21 -5
- package/src/index.ts +38 -0
- package/src/iso-block-locator.ts +34 -0
- package/src/mmtp-container-parser.ts +57 -11
- package/src/mmtp-mode-selection.ts +80 -0
- package/src/mmtp-router.ts +287 -42
- package/src/multicast-manager.ts +218 -10
- package/src/no-modules.ts +3 -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 +559 -1
- package/test-vectors/catalog-validation.json +266 -7
- package/test-vectors/moq/mmtp-mode-selection.json +259 -0
package/README.md
CHANGED
|
@@ -350,8 +350,11 @@ FEC blocks follow one block profile, `iso-ssbg1-v1` (ISO/IEC 23008-1 Annex C ssb
|
|
|
350
350
|
Every FEC block still gets in-band FEC decode. On top of that:
|
|
351
351
|
|
|
352
352
|
- **Classification.** Each block is `keyframe | delta | unknown | audio`, from
|
|
353
|
-
first-arrival network source evidence only (MMTP R bit, MPU number,
|
|
354
|
-
DU
|
|
353
|
+
first-arrival network source evidence only (MMTP R bit, MPU number, and
|
|
354
|
+
the MFU DU header's MPU position: `sample_number − 1` in a one-fragment
|
|
355
|
+
MPU, or, when each frame is its own movie fragment, the fragment's distance
|
|
356
|
+
from the MPU's RAP fragment once two RAPs proved G fragments per MPU, every
|
|
357
|
+
later RAP fragment held to that spacing) against catalog geometry (framerate,
|
|
355
358
|
`interleaveDepthMs`, keyframe interval). Geometry that cannot be derived
|
|
356
359
|
exactly, or any violated invariant, runs the track `all-protected` (every
|
|
357
360
|
video block `unknown`). A block every symbol of which vanished is
|
package/dist/block-policy.d.ts
CHANGED
|
@@ -49,7 +49,19 @@ export type ClassifierReason = 'framerate-absent' | 'keyframe-cadence-absent' |
|
|
|
49
49
|
* and this one was not, so no geometry provably belongs to it (ABR rungs
|
|
50
50
|
* sharing a packetId).
|
|
51
51
|
*/
|
|
52
|
-
| 'stream-geometry-absent' | 'rap-not-mpu-start' | 'mpu-longer-than-gop' | 'block-not-contiguous'
|
|
52
|
+
| 'stream-geometry-absent' | 'rap-not-mpu-start' | 'mpu-longer-than-gop' | 'block-not-contiguous'
|
|
53
|
+
/**
|
|
54
|
+
* MPU-start RAPs are not exactly one keyframe interval apart per MPU:
|
|
55
|
+
* released RAPs in the media timescale, or, once each frame is its own
|
|
56
|
+
* movie fragment, RAP fragments G fragments apart per MPU (P3).
|
|
57
|
+
*/
|
|
58
|
+
| 'rap-spacing-mismatch'
|
|
59
|
+
/**
|
|
60
|
+
* An MPU of several movie fragments whose fragments hold several samples:
|
|
61
|
+
* neither sample_number nor the fragment number states a frame's MPU
|
|
62
|
+
* position (P3).
|
|
63
|
+
*/
|
|
64
|
+
| 'mpu-multiple-fragments' | 'block-wider-than-interleave';
|
|
53
65
|
/** Raw catalog timing for one track. Never a resolved cadence. */
|
|
54
66
|
export interface BlockClassifierGeometryInput {
|
|
55
67
|
readonly trackKind: TrackKind;
|
|
@@ -85,6 +97,8 @@ export type BlockClassifierGeometry = {
|
|
|
85
97
|
readonly trackKind: 'video';
|
|
86
98
|
readonly mode: 'all-protected';
|
|
87
99
|
readonly reason: ClassifierReason;
|
|
100
|
+
/** The catalog interval when one is stated: gap decisions use it (keyframeInstantBetween). */
|
|
101
|
+
readonly keyframeInterval?: KeyframeInterval;
|
|
88
102
|
};
|
|
89
103
|
/**
|
|
90
104
|
* Derive the per-track classifier geometry from raw catalog fields.
|
|
@@ -96,10 +110,20 @@ export type BlockClassifierGeometry = {
|
|
|
96
110
|
export declare function deriveBlockClassifierGeometry(input: BlockClassifierGeometryInput): BlockClassifierGeometry;
|
|
97
111
|
/**
|
|
98
112
|
* The keyframe interval expressed in a media track's timescale, or null when
|
|
99
|
-
* the geometry
|
|
100
|
-
*
|
|
113
|
+
* the geometry states none or the interval is not an exact integer number of
|
|
114
|
+
* media ticks (fec-multicast-00 Block Classification item 3: an inexact one
|
|
115
|
+
* gives no usable interval).
|
|
101
116
|
*/
|
|
102
117
|
export declare function keyframeIntervalMediaTicks(geometry: BlockClassifierGeometry, mediaTimescale: number): bigint | null;
|
|
118
|
+
/**
|
|
119
|
+
* fec-multicast-00 Block Classification item 3 for two released frames:
|
|
120
|
+
* whether `(from, to]` holds `start + k * interval` for some k >= 1, `start`
|
|
121
|
+
* the decode time of an MPU's first RAP, all in one media timescale. `from`
|
|
122
|
+
* is exclusive: the frame at `from` is held and complete, so an instant there
|
|
123
|
+
* is that frame itself (an on-cadence RAP), not a lost one. The draft's closed
|
|
124
|
+
* interval is for bounding packets, which may be part of a RAP.
|
|
125
|
+
*/
|
|
126
|
+
export declare function keyframeInstantBetween(start: bigint, interval: bigint, from: bigint, to: bigint): boolean;
|
|
103
127
|
/**
|
|
104
128
|
* In-band evidence from ONE first-arrival source symbol received from the
|
|
105
129
|
* network. Recovered symbols and repair symbols never contribute, and the
|
|
@@ -111,13 +135,18 @@ export interface SourceSymbolEvidence {
|
|
|
111
135
|
/** MPU_sequence_number, when parsed from this packet. */
|
|
112
136
|
readonly mpu?: number;
|
|
113
137
|
/**
|
|
114
|
-
* 0-based sample position within
|
|
138
|
+
* 0-based sample position within its movie fragment: the MFU DU-header
|
|
115
139
|
* `sample_number` minus one (ISO/IEC 23008-1 numbers samples from 1, and
|
|
116
140
|
* the parser rejects `sample_number` 0). Present only when this packet
|
|
117
|
-
* carried a DU header.
|
|
141
|
+
* carried a DU header. It is the MPU position only while the MPU is one
|
|
142
|
+
* movie fragment; BlockClassifier derives MPU positions (P3).
|
|
118
143
|
*/
|
|
119
144
|
readonly idx?: number;
|
|
120
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* movie_fragment_sequence_number from the DU header, when present. When
|
|
147
|
+
* each frame is its own fragment, it positions the frame from its MPU's
|
|
148
|
+
* RAP fragment (P3).
|
|
149
|
+
*/
|
|
121
150
|
readonly movieFragment?: number;
|
|
122
151
|
/**
|
|
123
152
|
* DU-header `offset`: the data unit's authored byte position within its
|
|
@@ -167,14 +196,33 @@ export type ClassifierChange = {
|
|
|
167
196
|
* from the previous block (`block-wider-than-interleave`). The producer
|
|
168
197
|
* counts a media-unit boundary only once the open block holds a symbol.
|
|
169
198
|
* - P3: an MPU starts with its only RAP and holds at most G frames
|
|
170
|
-
* (`rap-not-mpu-start`, `mpu-longer-than-gop`, `rap-spacing-mismatch`),
|
|
171
|
-
* one
|
|
199
|
+
* (`rap-not-mpu-start`, `mpu-longer-than-gop`, `rap-spacing-mismatch`),
|
|
200
|
+
* and its DU headers state each frame's MPU position in one of two layouts
|
|
201
|
+
* (`mpu-multiple-fragments` when an MPU shows two fragments and a DU
|
|
202
|
+
* header states sample_number above 1, which is neither):
|
|
203
|
+
* - one movie fragment per MPU (ATSC 3.0): the position is
|
|
204
|
+
* sample_number − 1. This is the rule until some MPU of the sequence
|
|
205
|
+
* shows two fragments.
|
|
206
|
+
* - one fragment per frame, numbered one per frame (FFmpeg's MoQ MMT
|
|
207
|
+
* muxer, every DU header stating sample_number 1): the position is the
|
|
208
|
+
* fragment's distance from the fragment of the MPU's first RAP-flagged
|
|
209
|
+
* DU header (its anchor). The RAP's own fragment is position 0. Each
|
|
210
|
+
* anchor must lie exactly G fragments per MPU from the anchor received
|
|
211
|
+
* before it, which is kept past the horizon, and from the anchor
|
|
212
|
+
* received last (`rap-spacing-mismatch`, as after a dropped frame).
|
|
213
|
+
* Once two anchors kept that spacing, fragment numbers count frames:
|
|
214
|
+
* later fragments get positions, and an anchor arriving past the
|
|
215
|
+
* spacing is a RAP inside its MPU or follows an MPU longer than G
|
|
216
|
+
* (`rap-not-mpu-start`). An MPU whose anchor was not received has no
|
|
217
|
+
* positions; its blocks stay unknown. A second RAP-flagged fragment, or
|
|
218
|
+
* a DU header in a fragment before the anchor, refutes the MPU start
|
|
219
|
+
* (`rap-not-mpu-start`).
|
|
172
220
|
*
|
|
173
221
|
* P1 and P2 are what make a block's frames contiguous and lie within
|
|
174
|
-
* [
|
|
175
|
-
* source packets whose wire-stated authored order and SBN order
|
|
176
|
-
* a later MPU in an earlier block, a later data unit of one MPU
|
|
177
|
-
* movie_fragment_sequence_number, sample_number, then DU offset) in an
|
|
222
|
+
* [positionMax − D + 1, positionMin + D − 1] of its MPU. What refutes P1 is
|
|
223
|
+
* a pair of source packets whose wire-stated authored order and SBN order
|
|
224
|
+
* disagree: a later MPU in an earlier block, a later data unit of one MPU
|
|
225
|
+
* (by movie_fragment_sequence_number, sample_number, then DU offset) in an
|
|
178
226
|
* earlier block, or one data unit in two blocks. That is the signature of a
|
|
179
227
|
* round-robin interleave, which scatters one run over several concurrent
|
|
180
228
|
* blocks. Non-adjacency alone is not: a sample larger than K packets
|
|
@@ -203,8 +251,9 @@ export declare class BlockClassifier {
|
|
|
203
251
|
/**
|
|
204
252
|
* The stream's SBN sequence restarted (FECManager source discontinuity:
|
|
205
253
|
* a publisher restart, or the SS_ID space wrapped). Authored order and SBN
|
|
206
|
-
* order are comparable only within one continuous sequence,
|
|
207
|
-
*
|
|
254
|
+
* order are comparable only within one continuous sequence, and a
|
|
255
|
+
* restarted publisher numbers MPUs and movie fragments again, so the P1
|
|
256
|
+
* ledger and the P3 layout start again.
|
|
208
257
|
*/
|
|
209
258
|
noteSourceDiscontinuity(): void;
|
|
210
259
|
/** Register a block that exists without evidence (a vanished block). */
|
|
@@ -224,8 +273,26 @@ export declare class BlockClassifier {
|
|
|
224
273
|
* RAP-bearing block is the one a wrong G calls delta), because the next
|
|
225
274
|
* released RAP then belongs to m+2. Every MPU is one interval long, so the
|
|
226
275
|
* span to any later released RAP proves or refutes all MPUs in between.
|
|
276
|
+
*
|
|
277
|
+
* In every mode it keeps each MPU's first released RAP, with its decode
|
|
278
|
+
* time, as the start keyframeFreeBetween measures the catalog interval
|
|
279
|
+
* from, and a second RAP released inside one MPU refutes `mpuBoundsRaps`
|
|
280
|
+
* when it lies off the catalog lattice (not a whole number of intervals
|
|
281
|
+
* after the first; draft-ramadan-moq-mmt-02 4.4.3 binds every keyframe to
|
|
282
|
+
* it): with no repair, released RAPs are the only evidence of where they
|
|
283
|
+
* lie. Without a usable interval, or a decode time on either, any second
|
|
284
|
+
* RAP with another presentation time refutes.
|
|
285
|
+
*/
|
|
286
|
+
noteReleasedRap(mpu: number, presentationTime: bigint, mediaTimescale: number, decodeTime?: bigint): ClassifierChange[];
|
|
287
|
+
/**
|
|
288
|
+
* Whether a gap inside MPU `mpu`, between the decode times `from` and `to`
|
|
289
|
+
* of the frames on either side, holds no keyframe: MPU boundaries still
|
|
290
|
+
* bound RAPs, the catalog states an interval exact in this timescale, and
|
|
291
|
+
* none of its instants after the MPU's first released RAP lies in
|
|
292
|
+
* `(from, to]` (fec-multicast-00 Block Classification item 3). Anything
|
|
293
|
+
* unknown counts as a keyframe.
|
|
227
294
|
*/
|
|
228
|
-
|
|
295
|
+
keyframeFreeBetween(mpu: number, from: bigint, to: bigint, mediaTimescale: number): boolean;
|
|
229
296
|
}
|
|
230
297
|
export interface GapStreamIdentity {
|
|
231
298
|
readonly packetId: number;
|
|
@@ -245,7 +312,12 @@ export interface GapFrameEvidence {
|
|
|
245
312
|
* same-MPU then no longer proves a gap lost only deltas.
|
|
246
313
|
*/
|
|
247
314
|
readonly mpu?: number;
|
|
248
|
-
/**
|
|
315
|
+
/**
|
|
316
|
+
* 0-based sample position within its movie fragment (sample_number − 1).
|
|
317
|
+
* State it on both sides only when both frames are in one movie fragment:
|
|
318
|
+
* decideGap reads `after.idx − before.idx − 1` as the samples missed
|
|
319
|
+
* between them.
|
|
320
|
+
*/
|
|
249
321
|
readonly idx?: number;
|
|
250
322
|
/** Authored presentation time in `timescale` ticks. */
|
|
251
323
|
readonly pts?: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-policy.d.ts","sourceRoot":"","sources":["../src/block-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAA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,EAAE,iBAAiB,CAAA;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;IAChC,4EAA4E;IAC5E,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC;;;;;;;OAOG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB,CAkEjE"}
|
package/dist/block-policy.js
CHANGED
|
@@ -31,31 +31,26 @@ function deriveBlockClassifierGeometry(input) {
|
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
if (input.trackKind === "audio") return { trackKind: "audio" };
|
|
34
|
-
if (!isPositiveFinite(input.framerate)) {
|
|
35
|
-
return { trackKind: "video", mode: "all-protected", reason: "framerate-absent" };
|
|
36
|
-
}
|
|
37
|
-
const framerate = input.framerate;
|
|
38
34
|
let keyframeInterval;
|
|
39
35
|
if (isPositiveFinite(input.keyframeIntervalTicks) && isPositiveFinite(input.timescale)) {
|
|
40
36
|
keyframeInterval = { ticks: input.keyframeIntervalTicks, timescale: input.timescale };
|
|
41
37
|
} else if (isPositiveFinite(input.keyframeIntervalMs)) {
|
|
42
38
|
keyframeInterval = { ticks: input.keyframeIntervalMs, timescale: 1e3 };
|
|
43
|
-
} else {
|
|
44
|
-
return { trackKind: "video", mode: "all-protected", reason: "keyframe-cadence-absent" };
|
|
45
39
|
}
|
|
40
|
+
const protect = (reason) => ({
|
|
41
|
+
trackKind: "video",
|
|
42
|
+
mode: "all-protected",
|
|
43
|
+
reason,
|
|
44
|
+
...keyframeInterval === void 0 ? {} : { keyframeInterval }
|
|
45
|
+
});
|
|
46
|
+
if (!isPositiveFinite(input.framerate)) return protect("framerate-absent");
|
|
47
|
+
const framerate = input.framerate;
|
|
48
|
+
if (keyframeInterval === void 0) return protect("keyframe-cadence-absent");
|
|
46
49
|
const gopFrames = exactInteger(keyframeInterval.ticks * framerate, keyframeInterval.timescale);
|
|
47
|
-
if (gopFrames === null)
|
|
48
|
-
return {
|
|
49
|
-
trackKind: "video",
|
|
50
|
-
mode: "all-protected",
|
|
51
|
-
reason: "keyframe-interval-not-integral"
|
|
52
|
-
};
|
|
53
|
-
}
|
|
50
|
+
if (gopFrames === null) return protect("keyframe-interval-not-integral");
|
|
54
51
|
const frameDurationMs = 1e3 / framerate;
|
|
55
52
|
const interleaveUnits = deriveFecInterleaveDepth(input.interleaveDepthMs, frameDurationMs);
|
|
56
|
-
if (interleaveUnits >= gopFrames)
|
|
57
|
-
return { trackKind: "video", mode: "all-protected", reason: "block-spans-gop" };
|
|
58
|
-
}
|
|
53
|
+
if (interleaveUnits >= gopFrames) return protect("block-spans-gop");
|
|
59
54
|
return {
|
|
60
55
|
trackKind: "video",
|
|
61
56
|
mode: "classifying",
|
|
@@ -66,7 +61,7 @@ function deriveBlockClassifierGeometry(input) {
|
|
|
66
61
|
};
|
|
67
62
|
}
|
|
68
63
|
function keyframeIntervalMediaTicks(geometry, mediaTimescale) {
|
|
69
|
-
if (geometry.trackKind !== "video" || geometry.
|
|
64
|
+
if (geometry.trackKind !== "video" || geometry.keyframeInterval === void 0) return null;
|
|
70
65
|
if (!Number.isSafeInteger(mediaTimescale) || mediaTimescale <= 0) return null;
|
|
71
66
|
const { ticks, timescale } = geometry.keyframeInterval;
|
|
72
67
|
if (!Number.isSafeInteger(ticks) || !Number.isSafeInteger(timescale)) return null;
|
|
@@ -75,9 +70,15 @@ function keyframeIntervalMediaTicks(geometry, mediaTimescale) {
|
|
|
75
70
|
if (scaled % divisor !== 0n) return null;
|
|
76
71
|
return scaled / divisor;
|
|
77
72
|
}
|
|
73
|
+
function keyframeInstantBetween(start, interval, from, to) {
|
|
74
|
+
const k = from >= start ? (from - start) / interval + 1n : 1n;
|
|
75
|
+
return start + k * interval <= to;
|
|
76
|
+
}
|
|
78
77
|
function compareDataUnitStarts(a, b) {
|
|
79
|
-
return a.movieFragment - b.movieFragment || a.idx - b.idx || a.offset - b.offset;
|
|
78
|
+
return a.movieFragment - b.movieFragment | 0 || a.idx - b.idx || a.offset - b.offset;
|
|
80
79
|
}
|
|
80
|
+
var LATE_RAP_MAX_MPUS_BACK = 64;
|
|
81
|
+
var UNPLACED = { rapNotMpuStart: false };
|
|
81
82
|
var BlockClassifier = class {
|
|
82
83
|
#geometry;
|
|
83
84
|
#mode;
|
|
@@ -100,8 +101,24 @@ var BlockClassifier = class {
|
|
|
100
101
|
#mpuSbnSpans = /* @__PURE__ */ new Map();
|
|
101
102
|
#dataUnitStarts = /* @__PURE__ */ new Map();
|
|
102
103
|
#highestMpu = null;
|
|
103
|
-
/**
|
|
104
|
-
|
|
104
|
+
/**
|
|
105
|
+
* P3 layout, kept for the MPUs within the classification horizon and valid
|
|
106
|
+
* within one continuous SBN sequence (`noteSourceDiscontinuity`).
|
|
107
|
+
*/
|
|
108
|
+
#mpus = /* @__PURE__ */ new Map();
|
|
109
|
+
/** An MPU of this sequence showed two movie fragments: each frame is one. */
|
|
110
|
+
#fragmentPerFrame = false;
|
|
111
|
+
/** A DU header of this sequence stated sample_number above 1. */
|
|
112
|
+
#multiSampleFragment = false;
|
|
113
|
+
/**
|
|
114
|
+
* The anchor received last, whether or not its MPU is still in the
|
|
115
|
+
* horizon. Each new anchor, and the anchor of every DU header's MPU, is
|
|
116
|
+
* checked against it.
|
|
117
|
+
*/
|
|
118
|
+
#lastAnchor = null;
|
|
119
|
+
/** Two anchors were exactly G fragments per MPU apart. */
|
|
120
|
+
#fragmentsProven = false;
|
|
121
|
+
/** The first RAP released of the latest MPU a RAP was released in, recorded in every mode. */
|
|
105
122
|
#lastRap = null;
|
|
106
123
|
constructor(geometry) {
|
|
107
124
|
this.#geometry = geometry;
|
|
@@ -131,7 +148,7 @@ var BlockClassifier = class {
|
|
|
131
148
|
this.#geometry = geometry;
|
|
132
149
|
this.#blocks.clear();
|
|
133
150
|
this.#clearContiguityLedger();
|
|
134
|
-
this.#
|
|
151
|
+
this.#clearMpuLayout();
|
|
135
152
|
this.#lastRap = null;
|
|
136
153
|
this.#mpuBoundsRaps = true;
|
|
137
154
|
if (geometry.trackKind === "video" && geometry.mode === "all-protected") {
|
|
@@ -165,11 +182,14 @@ var BlockClassifier = class {
|
|
|
165
182
|
/**
|
|
166
183
|
* The stream's SBN sequence restarted (FECManager source discontinuity:
|
|
167
184
|
* a publisher restart, or the SS_ID space wrapped). Authored order and SBN
|
|
168
|
-
* order are comparable only within one continuous sequence,
|
|
169
|
-
*
|
|
185
|
+
* order are comparable only within one continuous sequence, and a
|
|
186
|
+
* restarted publisher numbers MPUs and movie fragments again, so the P1
|
|
187
|
+
* ledger and the P3 layout start again.
|
|
170
188
|
*/
|
|
171
189
|
noteSourceDiscontinuity() {
|
|
172
190
|
this.#clearContiguityLedger();
|
|
191
|
+
this.#clearMpuLayout();
|
|
192
|
+
this.#lastRap = null;
|
|
173
193
|
}
|
|
174
194
|
/** Register a block that exists without evidence (a vanished block). */
|
|
175
195
|
touch(sbn) {
|
|
@@ -188,16 +208,16 @@ var BlockClassifier = class {
|
|
|
188
208
|
if (this.#geometry.trackKind === "audio") return [];
|
|
189
209
|
const changes = [];
|
|
190
210
|
const block = this.#blockFor(sbn);
|
|
211
|
+
const placement = this.#place(evidence);
|
|
191
212
|
if (evidence.rap) block.rapSeen = true;
|
|
192
213
|
if (evidence.mpu !== void 0) block.mpus.add(evidence.mpu);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
block.
|
|
214
|
+
const { position } = placement;
|
|
215
|
+
if (position !== void 0) {
|
|
216
|
+
block.positionMin = block.positionMin === void 0 ? position : Math.min(block.positionMin, position);
|
|
217
|
+
block.positionMax = block.positionMax === void 0 ? position : Math.max(block.positionMax, position);
|
|
196
218
|
}
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
const violation = this.#checkInvariants(sbn, block, evidence);
|
|
219
|
+
if (placement.rapNotMpuStart) this.#mpuBoundsRaps = false;
|
|
220
|
+
const violation = this.#checkInvariants(sbn, block, evidence, placement);
|
|
201
221
|
if (violation !== null) changes.push(...this.#disable(violation));
|
|
202
222
|
const next = this.#classify(block);
|
|
203
223
|
if (next !== block.cls && this.#allowed(block.cls, next)) {
|
|
@@ -222,18 +242,35 @@ var BlockClassifier = class {
|
|
|
222
242
|
* RAP-bearing block is the one a wrong G calls delta), because the next
|
|
223
243
|
* released RAP then belongs to m+2. Every MPU is one interval long, so the
|
|
224
244
|
* span to any later released RAP proves or refutes all MPUs in between.
|
|
245
|
+
*
|
|
246
|
+
* In every mode it keeps each MPU's first released RAP, with its decode
|
|
247
|
+
* time, as the start keyframeFreeBetween measures the catalog interval
|
|
248
|
+
* from, and a second RAP released inside one MPU refutes `mpuBoundsRaps`
|
|
249
|
+
* when it lies off the catalog lattice (not a whole number of intervals
|
|
250
|
+
* after the first; draft-ramadan-moq-mmt-02 4.4.3 binds every keyframe to
|
|
251
|
+
* it): with no repair, released RAPs are the only evidence of where they
|
|
252
|
+
* lie. Without a usable interval, or a decode time on either, any second
|
|
253
|
+
* RAP with another presentation time refutes.
|
|
225
254
|
*/
|
|
226
|
-
noteReleasedRap(mpu, presentationTime, mediaTimescale) {
|
|
227
|
-
if (this.#geometry.trackKind === "audio"
|
|
228
|
-
return [];
|
|
229
|
-
}
|
|
230
|
-
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale);
|
|
231
|
-
if (interval === null) return this.#disable("keyframe-interval-not-media-integral");
|
|
255
|
+
noteReleasedRap(mpu, presentationTime, mediaTimescale, decodeTime) {
|
|
256
|
+
if (this.#geometry.trackKind === "audio") return [];
|
|
232
257
|
const previous = this.#lastRap;
|
|
233
258
|
if (previous !== null && previous.mpu === mpu && previous.mediaTimescale === mediaTimescale) {
|
|
259
|
+
if (presentationTime === previous.presentationTime) return [];
|
|
260
|
+
const interval2 = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale);
|
|
261
|
+
if (interval2 === null || decodeTime === void 0 || previous.decodeTime === void 0 || (decodeTime - previous.decodeTime) % interval2 !== 0n) {
|
|
262
|
+
this.#mpuBoundsRaps = false;
|
|
263
|
+
}
|
|
234
264
|
return [];
|
|
235
265
|
}
|
|
236
|
-
|
|
266
|
+
if (previous !== null && previous.mediaTimescale === mediaTimescale) {
|
|
267
|
+
const back = previous.mpu - mpu >>> 0;
|
|
268
|
+
if (back !== 0 && back <= LATE_RAP_MAX_MPUS_BACK && presentationTime < previous.presentationTime) return [];
|
|
269
|
+
}
|
|
270
|
+
this.#lastRap = { mpu, presentationTime, mediaTimescale, ...decodeTime === void 0 ? {} : { decodeTime } };
|
|
271
|
+
if (this.#mode === "all-protected") return [];
|
|
272
|
+
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale);
|
|
273
|
+
if (interval === null) return this.#disable("keyframe-interval-not-media-integral");
|
|
237
274
|
if (previous === null || mpu < previous.mpu || previous.mediaTimescale !== mediaTimescale) {
|
|
238
275
|
return [];
|
|
239
276
|
}
|
|
@@ -242,6 +279,22 @@ var BlockClassifier = class {
|
|
|
242
279
|
}
|
|
243
280
|
return this.#disable("rap-spacing-mismatch");
|
|
244
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Whether a gap inside MPU `mpu`, between the decode times `from` and `to`
|
|
284
|
+
* of the frames on either side, holds no keyframe: MPU boundaries still
|
|
285
|
+
* bound RAPs, the catalog states an interval exact in this timescale, and
|
|
286
|
+
* none of its instants after the MPU's first released RAP lies in
|
|
287
|
+
* `(from, to]` (fec-multicast-00 Block Classification item 3). Anything
|
|
288
|
+
* unknown counts as a keyframe.
|
|
289
|
+
*/
|
|
290
|
+
keyframeFreeBetween(mpu, from, to, mediaTimescale) {
|
|
291
|
+
const rap = this.#lastRap;
|
|
292
|
+
if (!this.#mpuBoundsRaps || rap?.mpu !== mpu || rap.mediaTimescale !== mediaTimescale || rap.decodeTime === void 0) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
const interval = keyframeIntervalMediaTicks(this.#geometry, mediaTimescale);
|
|
296
|
+
return interval !== null && !keyframeInstantBetween(rap.decodeTime, interval, from, to);
|
|
297
|
+
}
|
|
245
298
|
#blockFor(sbn) {
|
|
246
299
|
let block = this.#blocks.get(sbn);
|
|
247
300
|
if (!block) {
|
|
@@ -250,35 +303,89 @@ var BlockClassifier = class {
|
|
|
250
303
|
}
|
|
251
304
|
return block;
|
|
252
305
|
}
|
|
253
|
-
#checkInvariants(sbn, block, evidence) {
|
|
306
|
+
#checkInvariants(sbn, block, evidence, placement) {
|
|
254
307
|
if (this.#mode === "all-protected" || this.#geometry.trackKind !== "video") return null;
|
|
255
308
|
const geometry = this.#geometry;
|
|
256
309
|
if (geometry.mode !== "classifying") return null;
|
|
257
|
-
if (
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
if (evidence.idx !== void 0 && evidence.idx >= geometry.gopFrames) {
|
|
310
|
+
if (placement.rapNotMpuStart) return "rap-not-mpu-start";
|
|
311
|
+
if (placement.position !== void 0 && placement.position >= geometry.gopFrames) {
|
|
261
312
|
return "mpu-longer-than-gop";
|
|
262
313
|
}
|
|
263
|
-
if (block.mpus.size === 1 && block.
|
|
314
|
+
if (block.mpus.size === 1 && block.positionMin !== void 0 && block.positionMax !== void 0 && block.positionMax - block.positionMin >= geometry.interleaveUnits) {
|
|
264
315
|
return "block-wider-than-interleave";
|
|
265
316
|
}
|
|
266
|
-
if (
|
|
267
|
-
const fragment = this.#mpuFragments.get(evidence.mpu);
|
|
268
|
-
if (fragment === void 0) {
|
|
269
|
-
this.#mpuFragments.set(evidence.mpu, evidence.movieFragment);
|
|
270
|
-
for (const mpu of this.#mpuFragments.keys()) {
|
|
271
|
-
if (mpu + 1 < evidence.mpu) this.#mpuFragments.delete(mpu);
|
|
272
|
-
}
|
|
273
|
-
} else if (fragment !== evidence.movieFragment) {
|
|
274
|
-
return "mpu-multiple-fragments";
|
|
275
|
-
}
|
|
276
|
-
}
|
|
317
|
+
if (placement.violation !== void 0) return placement.violation;
|
|
277
318
|
if (evidence.mpu !== void 0 && this.#contradictsAuthoredOrder(sbn, evidence.mpu, evidence)) {
|
|
278
319
|
return "block-not-contiguous";
|
|
279
320
|
}
|
|
280
321
|
return null;
|
|
281
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* The MPU position a source symbol's DU header proves (P3), and what it
|
|
325
|
+
* refutes. Runs in every mode: mpuBoundsRaps needs its RAP verdict.
|
|
326
|
+
*/
|
|
327
|
+
#place(evidence) {
|
|
328
|
+
const { mpu, idx, movieFragment: fragment } = evidence;
|
|
329
|
+
if (idx === void 0) return UNPLACED;
|
|
330
|
+
const bySample = { position: idx, rapNotMpuStart: evidence.rap && idx !== 0 };
|
|
331
|
+
if (mpu === void 0 || fragment === void 0) {
|
|
332
|
+
return this.#fragmentPerFrame && !this.#multiSampleFragment ? { rapNotMpuStart: bySample.rapNotMpuStart } : bySample;
|
|
333
|
+
}
|
|
334
|
+
let layout = this.#mpus.get(mpu);
|
|
335
|
+
if (layout === void 0) {
|
|
336
|
+
layout = { low: fragment };
|
|
337
|
+
this.#mpus.set(mpu, layout);
|
|
338
|
+
for (const other of this.#mpus.keys()) {
|
|
339
|
+
if (other + 1 < mpu) this.#mpus.delete(other);
|
|
340
|
+
}
|
|
341
|
+
} else if (fragment !== layout.low) {
|
|
342
|
+
this.#fragmentPerFrame = true;
|
|
343
|
+
if ((fragment - layout.low | 0) < 0) layout.low = fragment;
|
|
344
|
+
}
|
|
345
|
+
if (idx !== 0) this.#multiSampleFragment = true;
|
|
346
|
+
let arrival;
|
|
347
|
+
if (evidence.rap && layout.anchor === void 0) {
|
|
348
|
+
layout.anchor = fragment;
|
|
349
|
+
arrival = this.#anchorDrift(mpu, fragment);
|
|
350
|
+
if (arrival === 0 && this.#lastAnchor?.mpu !== mpu) this.#fragmentsProven = true;
|
|
351
|
+
this.#lastAnchor = { mpu, fragment };
|
|
352
|
+
}
|
|
353
|
+
if (!this.#fragmentPerFrame) return bySample;
|
|
354
|
+
if (this.#multiSampleFragment) return { ...bySample, violation: "mpu-multiple-fragments" };
|
|
355
|
+
const { anchor } = layout;
|
|
356
|
+
if (anchor === void 0) return UNPLACED;
|
|
357
|
+
const drift = arrival ?? this.#anchorDrift(mpu, anchor);
|
|
358
|
+
const offset = fragment - anchor | 0;
|
|
359
|
+
return {
|
|
360
|
+
...offset === 0 || offset > 0 && this.#fragmentsProven ? { position: offset } : {},
|
|
361
|
+
rapNotMpuStart: evidence.rap && offset !== 0 || (layout.low - anchor | 0) < 0 || // Fragments count frames: an anchor arriving past the spacing is a
|
|
362
|
+
// RAP inside its MPU, or an earlier MPU outran G.
|
|
363
|
+
arrival !== void 0 && arrival > 0 && this.#fragmentsProven,
|
|
364
|
+
...drift === void 0 || drift === 0 ? {} : { violation: "rap-spacing-mismatch" }
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* How many fragments MPU m's anchor `fragment` lies past the start that
|
|
369
|
+
* the anchor received last predicts for MPU m: one frame per fragment and
|
|
370
|
+
* G frames per MPU put the anchors of MPUs m and m' exactly G * (m - m')
|
|
371
|
+
* fragments apart, modulo 2^32. Undefined without a last anchor, a
|
|
372
|
+
* cadence, or this layout.
|
|
373
|
+
*/
|
|
374
|
+
#anchorDrift(mpu, fragment) {
|
|
375
|
+
const geometry = this.#geometry;
|
|
376
|
+
const last = this.#lastAnchor;
|
|
377
|
+
if (last === null || !this.#fragmentPerFrame || this.#multiSampleFragment || geometry.trackKind !== "video" || geometry.mode !== "classifying") {
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
return fragment - last.fragment - geometry.gopFrames * (mpu - last.mpu) | 0;
|
|
381
|
+
}
|
|
382
|
+
#clearMpuLayout() {
|
|
383
|
+
this.#mpus.clear();
|
|
384
|
+
this.#fragmentPerFrame = false;
|
|
385
|
+
this.#multiSampleFragment = false;
|
|
386
|
+
this.#lastAnchor = null;
|
|
387
|
+
this.#fragmentsProven = false;
|
|
388
|
+
}
|
|
282
389
|
#clearContiguityLedger() {
|
|
283
390
|
this.#mpuSbnSpans.clear();
|
|
284
391
|
this.#dataUnitStarts.clear();
|
|
@@ -378,9 +485,9 @@ var BlockClassifier = class {
|
|
|
378
485
|
if (this.#mode === "all-protected") return "unknown";
|
|
379
486
|
const geometry = this.#geometry;
|
|
380
487
|
if (geometry.trackKind !== "video" || geometry.mode !== "classifying") return "unknown";
|
|
381
|
-
if (block.mpus.size === 1 && block.
|
|
488
|
+
if (block.mpus.size === 1 && block.positionMin !== void 0 && block.positionMax !== void 0) {
|
|
382
489
|
const span = geometry.interleaveUnits - 1;
|
|
383
|
-
if (block.
|
|
490
|
+
if (block.positionMax - span >= 1 && block.positionMin + span <= geometry.gopFrames - 1) {
|
|
384
491
|
return "delta";
|
|
385
492
|
}
|
|
386
493
|
}
|
|
@@ -460,6 +567,7 @@ export {
|
|
|
460
567
|
BlockClassifier,
|
|
461
568
|
decideGap,
|
|
462
569
|
deriveBlockClassifierGeometry,
|
|
570
|
+
keyframeInstantBetween,
|
|
463
571
|
keyframeIntervalMediaTicks,
|
|
464
572
|
repairPriorityForClass
|
|
465
573
|
};
|