@blockcast/mmt-container 2.2.0-main.e75bbd7576a6 → 2.2.0-main.ef09fa701ea8
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/browser-runtime.js +994 -162
- package/dist/browser-runtime.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/delta-fallback-config.js.map +1 -1
- package/dist/fec-manager.d.ts +75 -14
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +315 -65
- package/dist/fec-manager.js.map +2 -2
- package/dist/fec-worker-setup.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.d.ts +39 -13
- package/dist/iso-block-locator.d.ts.map +1 -1
- package/dist/iso-block-locator.js +80 -25
- package/dist/iso-block-locator.js.map +2 -2
- package/dist/media-router.js.map +1 -1
- package/dist/mmtp-container-parser.d.ts +69 -10
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +226 -18
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +225 -19
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +226 -18
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +20 -9
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +409 -51
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-manager.d.ts +26 -3
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +814 -135
- package/dist/multicast-manager.js.map +3 -3
- package/dist/multicast-transport.js +2 -2
- package/dist/multicast-transport.js.map +2 -2
- package/dist/no-modules.js +226 -18
- package/dist/no-modules.js.map +3 -3
- package/dist/repair-fetch.d.ts +38 -8
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +286 -27
- package/dist/repair-fetch.js.map +3 -3
- package/dist/track-session.d.ts.map +1 -1
- package/dist/track-session.js +1 -0
- package/dist/track-session.js.map +2 -2
- package/dist/wasm-mmtp-container-parser.js +226 -18
- package/dist/wasm-mmtp-container-parser.js.map +2 -2
- package/package.json +5 -5
- package/src/codec-utils.ts +121 -1
- package/src/fec-manager.ts +329 -39
- package/src/index.ts +2 -0
- package/src/iso-block-locator.ts +114 -31
- package/src/mmtp-container-parser.ts +257 -24
- package/src/mmtp-router.ts +287 -58
- package/src/multicast-manager.ts +136 -16
- package/src/repair-fetch.ts +366 -50
- package/src/track-session.ts +3 -0
|
@@ -173,6 +173,15 @@ export interface FrameMeta {
|
|
|
173
173
|
* on FEC-gated streams.
|
|
174
174
|
*/
|
|
175
175
|
fecSbn?: number
|
|
176
|
+
/**
|
|
177
|
+
* Set on a frame the keyframe overlay rebuilt (draft-ramadan-moq-mmt-02
|
|
178
|
+
* 7.4) whose base SS_IDs are determined: the lowest base SS_ID of its
|
|
179
|
+
* MPU's packets in that decode, its FT=0 when the decode holds it. The
|
|
180
|
+
* release gate waits only for the blocks before it, and stops waiting once
|
|
181
|
+
* a base frame after this one arrived. `fecSbn` stays the SS_ID the frame
|
|
182
|
+
* completed in.
|
|
183
|
+
*/
|
|
184
|
+
fecSbnFirst?: number
|
|
176
185
|
/**
|
|
177
186
|
* Set on the first frame released after a gap: the blocks between it and
|
|
178
187
|
* the previous release resolved with lost media, or authored decode time
|
|
@@ -197,8 +206,10 @@ export interface SourcePacketIdentity {
|
|
|
197
206
|
/**
|
|
198
207
|
* In-order release policy for FEC-protected streams. For such a stream a
|
|
199
208
|
* frame after a gap is released only once every FEC block that could hold
|
|
200
|
-
* the missing frames has resolved (completed or failed)
|
|
201
|
-
*
|
|
209
|
+
* the missing frames has resolved (completed or failed), or only a late
|
|
210
|
+
* source or the keyframe overlay could still fill the gap and the frame has
|
|
211
|
+
* waited for them (`unrepairableWaitMs`); the frame-count reorder window
|
|
212
|
+
* applies only to streams without FEC.
|
|
202
213
|
*/
|
|
203
214
|
export interface FecReleaseGate {
|
|
204
215
|
/** True when this physical stream's frames are FEC-gated. */
|
|
@@ -225,6 +236,22 @@ export interface FecReleaseGate {
|
|
|
225
236
|
* It must not exceed how long a resolved block stays readable as resolved.
|
|
226
237
|
*/
|
|
227
238
|
holdLimitMs(packetId: number, catalogTrackName?: string): number
|
|
239
|
+
/**
|
|
240
|
+
* How long a frame held behind unresolved blocks waits, from its arrival,
|
|
241
|
+
* once no repair but the keyframe overlay can still fill the gap before
|
|
242
|
+
* it: the late-symbol allowance when the gap holds no RAP that overlay
|
|
243
|
+
* could rebuild, else as long as its repair may still come. Undefined
|
|
244
|
+
* while another repair may still fill the gap, or the overlay's repair
|
|
245
|
+
* may come at any time. `fromSbn` is the anchor of the frame released
|
|
246
|
+
* before the gap, `toSbn` this frame's. Past the wait the frame goes,
|
|
247
|
+
* decided, as it would once those blocks failed.
|
|
248
|
+
*/
|
|
249
|
+
unrepairableWaitMs?(
|
|
250
|
+
before: { data: Uint8Array; meta: FrameMeta },
|
|
251
|
+
after: { data: Uint8Array; meta: FrameMeta },
|
|
252
|
+
fromSbn: number,
|
|
253
|
+
toSbn: number,
|
|
254
|
+
): number | undefined
|
|
228
255
|
/** Decide stall/conceal for the first frame released after a gap. */
|
|
229
256
|
decide(
|
|
230
257
|
before: { data: Uint8Array; meta: FrameMeta },
|
|
@@ -242,13 +269,28 @@ export interface FecReleaseGate {
|
|
|
242
269
|
isRap?(data: Uint8Array, meta: FrameMeta): boolean
|
|
243
270
|
/** A complete RAP entered the gate at SS_ID `ssId` (see `isRap`). */
|
|
244
271
|
onRap?(packetId: number, catalogTrackName: string | undefined, ssId: number): void
|
|
272
|
+
/**
|
|
273
|
+
* Whether what reads this stream decides on when its frames arrive (a
|
|
274
|
+
* staged stream switch): the gate then releases a held overlay-rebuilt
|
|
275
|
+
* frame when it did unanchored (#cursorPassed).
|
|
276
|
+
*/
|
|
277
|
+
releaseUnanchored?(packetId: number, catalogTrackName: string | undefined): boolean
|
|
278
|
+
/**
|
|
279
|
+
* A frame held only for its `unrepairableWaitMs` may go at `atMs`
|
|
280
|
+
* (performance.now()): poke the stream (pokeFecRelease) then. Absent, it
|
|
281
|
+
* goes at the next push or poke after that.
|
|
282
|
+
*/
|
|
283
|
+
wakeAt?(packetId: number, catalogTrackName: string | undefined, atMs: number): void
|
|
245
284
|
}
|
|
246
285
|
|
|
247
286
|
/** Typed ISO-BMFF timing-sample budget counters. See `timingBudgetStats`. */
|
|
248
287
|
export interface MmtpTimingBudgetStats {
|
|
249
288
|
/** Slots currently charged to declared-but-undelivered samples. */
|
|
250
289
|
pending: number
|
|
251
|
-
/**
|
|
290
|
+
/**
|
|
291
|
+
* Slots each stream's window holds (`maxBufferedMfus`). A stream at
|
|
292
|
+
* capacity displaces its own oldest timing; `pending` sums every stream.
|
|
293
|
+
*/
|
|
252
294
|
capacity: number
|
|
253
295
|
/** Slots returned by samples the combiner abandoned (evicted or timed out). */
|
|
254
296
|
reclaimed: number
|
|
@@ -259,7 +301,13 @@ export interface MmtpTimingBudgetStats {
|
|
|
259
301
|
* up, `evicted` is loss that was never observable at all.
|
|
260
302
|
*/
|
|
261
303
|
evicted: number
|
|
262
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* Movie fragments refused because the budget had no room for their samples.
|
|
306
|
+
* Stays 0 with a window per stream (BLO-52085): a stream at capacity
|
|
307
|
+
* displaces its own oldest timing to make room, and a moof declaring more
|
|
308
|
+
* samples than a whole window holds is refused as invalid before any budget
|
|
309
|
+
* is consulted. Kept as a guard, and because it is public.
|
|
310
|
+
*/
|
|
263
311
|
rejectedMovieFragments: number
|
|
264
312
|
}
|
|
265
313
|
|
|
@@ -367,7 +415,10 @@ export type MmtpFeedDropReason =
|
|
|
367
415
|
| 'fragment-unexpected-fragmentation'
|
|
368
416
|
/** FT=1 before an FT=0 has bound the stream's timing track. */
|
|
369
417
|
| 'fragment-no-resolver'
|
|
370
|
-
/** addMovieFragment refused
|
|
418
|
+
/** addMovieFragment refused: the moof does not parse against the stream's
|
|
419
|
+
* track, conflicts with a pending copy of itself, or repeats a pending
|
|
420
|
+
* copy whose samples are partly consumed. Never the timing budget: a full
|
|
421
|
+
* window displaces the stream's own oldest timing. */
|
|
371
422
|
| 'fragment-timing-refused'
|
|
372
423
|
| 'unknown-fragment-type'
|
|
373
424
|
/** Stable code, no longer produced: an FT=2 with no timing (before the
|
|
@@ -508,6 +559,8 @@ export interface ParseHeaderOptions {
|
|
|
508
559
|
deliveryProvenance?: MmtpDeliveryProvenance
|
|
509
560
|
/** FEC source block this packet belongs to (FEC-protected packets only). */
|
|
510
561
|
fecSbn?: number
|
|
562
|
+
/** See FrameMeta.fecSbnFirst. */
|
|
563
|
+
fecSbnFirst?: number
|
|
511
564
|
}
|
|
512
565
|
|
|
513
566
|
// ── FrameSequencer ──────────────────────────────────────────────────
|
|
@@ -721,9 +774,19 @@ function ssIdAfter(a: number, b: number): boolean {
|
|
|
721
774
|
return ((a - b) | 0) > 0
|
|
722
775
|
}
|
|
723
776
|
|
|
777
|
+
/** The stream holds a frame the keyframe overlay rebuilt (FrameMeta.fecSbnFirst). */
|
|
778
|
+
function holdsRebuilt(stream: GatedStream): boolean {
|
|
779
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== undefined)
|
|
780
|
+
}
|
|
781
|
+
|
|
724
782
|
interface GatedFrame extends PendingFrame {
|
|
725
783
|
/** performance.now() at push; measures the hold against the gate's limit. */
|
|
726
784
|
arrivedAtMs: number
|
|
785
|
+
/**
|
|
786
|
+
* The unanchored path's gate is done with this frame (see #cursorPassed):
|
|
787
|
+
* it released it, or dropped it as stale.
|
|
788
|
+
*/
|
|
789
|
+
passed?: boolean
|
|
727
790
|
}
|
|
728
791
|
|
|
729
792
|
interface GatedStream {
|
|
@@ -735,6 +798,10 @@ interface GatedStream {
|
|
|
735
798
|
discontinuity: boolean
|
|
736
799
|
/** Latest (serial order) SS_ID of a complete RAP that entered the gate since the last reset. */
|
|
737
800
|
rapSsId: number | undefined
|
|
801
|
+
/** A frame that was not FEC-recovered was released since the last reset. */
|
|
802
|
+
sourced: boolean
|
|
803
|
+
/** Drains of this stream in progress: a release calls out, and back in (a stream switch's onCommit). */
|
|
804
|
+
draining: number
|
|
738
805
|
}
|
|
739
806
|
|
|
740
807
|
/**
|
|
@@ -743,16 +810,24 @@ interface GatedStream {
|
|
|
743
810
|
* to the last released frame is released immediately. A frame after a gap
|
|
744
811
|
* waits until every block between the last released frame's block and its
|
|
745
812
|
* own has resolved; a D-28 repair or a late in-band recovery can therefore
|
|
746
|
-
* still fill the gap.
|
|
813
|
+
* still fill the gap. Once only a late source or the keyframe overlay could
|
|
814
|
+
* fill it, the frame waits only the gate's `unrepairableWaitMs` from its
|
|
815
|
+
* arrival: the late-symbol allowance, or longer when the gap may hold a RAP
|
|
816
|
+
* the overlay could still rebuild. A frame the keyframe overlay rebuilt
|
|
817
|
+
* waits only for the blocks before its MPU (FrameMeta.fecSbnFirst), and no
|
|
818
|
+
* longer than the source cursor would hold it unanchored
|
|
819
|
+
* (#cursorPassed). When the resolved blocks lost media, or authored decode
|
|
747
820
|
* time shows a missing sample, the release carries the gate's stall/conceal
|
|
748
821
|
* decision as `gapBefore`.
|
|
749
822
|
*
|
|
750
823
|
* The wait is bounded here, not by the blocks: a frame held longer than the
|
|
751
824
|
* gate's `holdLimitMs` since it arrived is released with the gate's
|
|
752
825
|
* discontinuity decision (a stall), so a block that never resolves cannot
|
|
753
|
-
* grow the buffer without limit.
|
|
754
|
-
* next push or poke, so after a total outage held frames are released
|
|
755
|
-
* first packet that arrives, not at the ceiling itself.
|
|
826
|
+
* grow the buffer without limit. That ceiling has no timer: the check runs
|
|
827
|
+
* on the next push or poke, so after a total outage held frames are released
|
|
828
|
+
* by the first packet that arrives, not at the ceiling itself. Only the
|
|
829
|
+
* `unrepairableWaitMs` wait is timed: the gate is asked to poke the stream
|
|
830
|
+
* when it ends (`wakeAt`), since a burst may be the last traffic for a while.
|
|
756
831
|
*/
|
|
757
832
|
class FecReleaseSequencer {
|
|
758
833
|
#streams = new Map<string, GatedStream>()
|
|
@@ -829,6 +904,7 @@ class FecReleaseSequencer {
|
|
|
829
904
|
stream.lastSbn = undefined
|
|
830
905
|
stream.discontinuity = false
|
|
831
906
|
stream.rapSsId = undefined
|
|
907
|
+
stream.sourced = false
|
|
832
908
|
}
|
|
833
909
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
834
910
|
this.#recordStat('droppedStale')
|
|
@@ -857,6 +933,8 @@ class FecReleaseSequencer {
|
|
|
857
933
|
if (compareFrameOrder(stream.buf[mid]!, frame) < 0) lo = mid + 1
|
|
858
934
|
else hi = mid
|
|
859
935
|
}
|
|
936
|
+
// In front of a frame the unanchored path released, it was stale there.
|
|
937
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true
|
|
860
938
|
stream.buf.splice(lo, 0, frame)
|
|
861
939
|
this.#drainUnlessDeferred(stream)
|
|
862
940
|
}
|
|
@@ -895,6 +973,54 @@ class FecReleaseSequencer {
|
|
|
895
973
|
return false
|
|
896
974
|
}
|
|
897
975
|
|
|
976
|
+
/**
|
|
977
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
978
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
979
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
980
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
981
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
982
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
983
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
984
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
985
|
+
* released.
|
|
986
|
+
*/
|
|
987
|
+
unsource(packetId: number, catalogTrackName: string | undefined): void {
|
|
988
|
+
for (const stream of this.#streams.values()) {
|
|
989
|
+
if (stream.packetId === packetId && (catalogTrackName === undefined || stream.catalogTrackName === catalogTrackName)) {
|
|
990
|
+
// From inside this stream's own drain (a sink replaced from a frame
|
|
991
|
+
// callback, as a stream switch's onCommit can), the drain under way
|
|
992
|
+
// releases the rest, in order, once the frame it is delivering is
|
|
993
|
+
// done (a commit delivers its held GOP and RAP after onCommit):
|
|
994
|
+
// released here, they would go ahead of them. Inside a deferral
|
|
995
|
+
// scope (a protected flow's record admits frames of several streams
|
|
996
|
+
// in one), the scope's drain does, for the same reason, into the
|
|
997
|
+
// replacement. With the stream unsourced, that drain lets a rebuilt
|
|
998
|
+
// frame go as unanchored did until it releases a source frame; a
|
|
999
|
+
// rebuilt frame behind that one waits for the blocks before it, as an
|
|
1000
|
+
// anchored frame does (the record may hold the base frames it needs).
|
|
1001
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
1002
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream)
|
|
1003
|
+
else this.#drain(stream, true)
|
|
1004
|
+
}
|
|
1005
|
+
stream.sourced = false
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
1012
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
1013
|
+
* packetId.
|
|
1014
|
+
*/
|
|
1015
|
+
holdsRebuilt(packetId: number, catalogTrackName: string | undefined): boolean {
|
|
1016
|
+
for (const stream of this.#streams.values()) {
|
|
1017
|
+
if (stream.packetId !== packetId) continue
|
|
1018
|
+
if (catalogTrackName !== undefined && stream.catalogTrackName !== catalogTrackName) continue
|
|
1019
|
+
if (holdsRebuilt(stream)) return true
|
|
1020
|
+
}
|
|
1021
|
+
return false
|
|
1022
|
+
}
|
|
1023
|
+
|
|
898
1024
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
899
1025
|
poke(streamKey?: string): void {
|
|
900
1026
|
if (streamKey !== undefined) {
|
|
@@ -1001,16 +1127,34 @@ class FecReleaseSequencer {
|
|
|
1001
1127
|
lastSbn: undefined,
|
|
1002
1128
|
discontinuity: false,
|
|
1003
1129
|
rapSsId: undefined,
|
|
1130
|
+
sourced: false,
|
|
1131
|
+
draining: 0,
|
|
1004
1132
|
}
|
|
1005
1133
|
this.#streams.set(streamKey, stream)
|
|
1006
1134
|
}
|
|
1007
1135
|
return stream
|
|
1008
1136
|
}
|
|
1009
1137
|
|
|
1010
|
-
#
|
|
1138
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
1139
|
+
#drain(stream: GatedStream, asUnanchored = false): void {
|
|
1140
|
+
stream.draining++
|
|
1141
|
+
try {
|
|
1142
|
+
this.#drainLoop(stream, asUnanchored)
|
|
1143
|
+
} finally {
|
|
1144
|
+
stream.draining--
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
#drainLoop(stream: GatedStream, asUnanchored: boolean): void {
|
|
1011
1149
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
1012
1150
|
const head = stream.buf[0]!
|
|
1013
1151
|
const last = stream.last
|
|
1152
|
+
// A second held copy of the frame just released waits on nothing.
|
|
1153
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
1154
|
+
stream.buf.shift()
|
|
1155
|
+
this.#release(stream, head, undefined)
|
|
1156
|
+
continue
|
|
1157
|
+
}
|
|
1014
1158
|
if (stream.discontinuity) {
|
|
1015
1159
|
stream.discontinuity = false
|
|
1016
1160
|
stream.buf.shift()
|
|
@@ -1024,13 +1168,19 @@ class FecReleaseSequencer {
|
|
|
1024
1168
|
}
|
|
1025
1169
|
const headSbn = head.meta.fecSbn
|
|
1026
1170
|
const from = stream.lastSbn ?? headSbn
|
|
1027
|
-
|
|
1171
|
+
// An overlay-rebuilt frame waits only for the blocks before its MPU's
|
|
1172
|
+
// first packet in that decode (fecSbnFirst): the overlay delivered the
|
|
1173
|
+
// packets from there on.
|
|
1174
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn
|
|
1028
1175
|
let lost: readonly number[] = []
|
|
1029
1176
|
// Neither side carries a Source FEC Payload ID: on a catalog-declared
|
|
1030
1177
|
// FEC track that is the trailer-stripped profile violation, and there
|
|
1031
1178
|
// are no blocks to wait on. The gap is still a gap: never release across
|
|
1032
1179
|
// it undecided (fail closed), let the gate decide with no known blocks.
|
|
1033
1180
|
const unanchored = from === undefined && to === undefined
|
|
1181
|
+
// The source cursor released it (#cursorPassed) across blocks that have
|
|
1182
|
+
// not resolved: nothing sized that gap either, so it is decided too.
|
|
1183
|
+
let unresolved = false
|
|
1034
1184
|
if (from !== undefined && to !== undefined) {
|
|
1035
1185
|
const resolved = this.#gate.resolvedLoss(
|
|
1036
1186
|
stream.packetId,
|
|
@@ -1039,7 +1189,8 @@ class FecReleaseSequencer {
|
|
|
1039
1189
|
Math.max(from, to),
|
|
1040
1190
|
from,
|
|
1041
1191
|
)
|
|
1042
|
-
|
|
1192
|
+
unresolved = resolved === null
|
|
1193
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored) && !this.#unrepairableWaitOver(stream, last, head, from, to)) {
|
|
1043
1194
|
const heldMs = performance.now() - head.arrivedAtMs
|
|
1044
1195
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return
|
|
1045
1196
|
// Past the point where these blocks must have resolved: nothing
|
|
@@ -1049,7 +1200,7 @@ class FecReleaseSequencer {
|
|
|
1049
1200
|
this.#release(stream, head, this.#gate.decide(last, head, [], true))
|
|
1050
1201
|
continue
|
|
1051
1202
|
}
|
|
1052
|
-
lost = resolved
|
|
1203
|
+
lost = resolved ?? []
|
|
1053
1204
|
}
|
|
1054
1205
|
stream.buf.shift()
|
|
1055
1206
|
// Every gap in the frame sequence gets a decision, not only one whose
|
|
@@ -1060,19 +1211,81 @@ class FecReleaseSequencer {
|
|
|
1060
1211
|
this.#release(
|
|
1061
1212
|
stream,
|
|
1062
1213
|
head,
|
|
1063
|
-
lost.length > 0 || unanchored || authoredGap(last.meta, head.meta)
|
|
1214
|
+
lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta)
|
|
1064
1215
|
? this.#gate.decide(last, head, lost, false)
|
|
1065
1216
|
: undefined,
|
|
1066
1217
|
)
|
|
1067
1218
|
}
|
|
1068
1219
|
}
|
|
1069
1220
|
|
|
1221
|
+
/**
|
|
1222
|
+
* The head has waited out a gap only a late source can still fill
|
|
1223
|
+
* (FecReleaseGate.unrepairableWaitMs). Not yet: the gate is asked to poke
|
|
1224
|
+
* the stream when it has (`wakeAt`), since no packet may come by then.
|
|
1225
|
+
*/
|
|
1226
|
+
#unrepairableWaitOver(stream: GatedStream, last: PendingFrame, head: GatedFrame, from: number, to: number): boolean {
|
|
1227
|
+
const waitMs = this.#gate.unrepairableWaitMs?.(last, head, from, to)
|
|
1228
|
+
if (waitMs === undefined) return false
|
|
1229
|
+
const atMs = head.arrivedAtMs + waitMs
|
|
1230
|
+
if (performance.now() >= atMs) return true
|
|
1231
|
+
this.#gate.wakeAt?.(stream.packetId, stream.catalogTrackName, atMs)
|
|
1232
|
+
return false
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
1237
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
1238
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
1239
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
1240
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
1241
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
1242
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
1243
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
1244
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
1245
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
1246
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
1247
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
1248
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
1249
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
1250
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
1251
|
+
*/
|
|
1252
|
+
#cursorPassed(stream: GatedStream, asUnanchored: boolean): boolean {
|
|
1253
|
+
let at = -1
|
|
1254
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
1255
|
+
const frame = stream.buf[i]!
|
|
1256
|
+
if (frame.meta.fecSbnFirst !== undefined || frame.meta.fecSbn === undefined) {
|
|
1257
|
+
frame.passed = true
|
|
1258
|
+
if (at < 0) at = i
|
|
1259
|
+
} else if (frame.passed !== true) break
|
|
1260
|
+
}
|
|
1261
|
+
if (at < 0) return false
|
|
1262
|
+
return asUnanchored || !stream.sourced ||
|
|
1263
|
+
this.#gate.releaseUnanchored?.(stream.packetId, stream.catalogTrackName) === true ||
|
|
1264
|
+
stream.buf.some(({ meta }, i) =>
|
|
1265
|
+
i > at && meta.fecSbnFirst === undefined && (meta.recovered !== true || meta.fecSbn !== undefined))
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1070
1268
|
#release(stream: GatedStream, frame: PendingFrame, decision: FrameGapDecision | undefined): void {
|
|
1269
|
+
// Two copies of one frame were held (its base copy and the overlay's
|
|
1270
|
+
// rebuild) and the other went out: this one is stale, as a copy pushed
|
|
1271
|
+
// after its frame was released is. It still moves the state as a release
|
|
1272
|
+
// does: only the second emission is dropped.
|
|
1273
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0
|
|
1274
|
+
if (stale) this.#recordStat('droppedStale')
|
|
1071
1275
|
if (decision) frame.meta.gapBefore = decision
|
|
1072
1276
|
stream.last = frame
|
|
1073
|
-
|
|
1277
|
+
// An overlay-rebuilt frame (fecSbnFirst) released before any base frame
|
|
1278
|
+
// since the last reset leaves lastSbn unset, as it did unanchored: the
|
|
1279
|
+
// base frame after it then waits for nothing, not for the frames between.
|
|
1280
|
+
if (frame.meta.fecSbn !== undefined && (frame.meta.fecSbnFirst === undefined || stream.lastSbn !== undefined)) {
|
|
1281
|
+
stream.lastSbn = frame.meta.fecSbn
|
|
1282
|
+
}
|
|
1283
|
+
if (frame.meta.recovered !== true) stream.sourced = true
|
|
1284
|
+
// A stale copy of the frame just released (equal order) repeats an
|
|
1285
|
+
// onReleased call already made: noteReleasedRap ignores a second RAP of
|
|
1286
|
+
// an MPU it has anchored (the same MPU and presentation time).
|
|
1074
1287
|
this.#gate.onReleased?.(frame.data, frame.meta)
|
|
1075
|
-
this.#emit(frame.data, frame.meta)
|
|
1288
|
+
if (!stale) this.#emit(frame.data, frame.meta)
|
|
1076
1289
|
}
|
|
1077
1290
|
}
|
|
1078
1291
|
|
|
@@ -1366,11 +1579,12 @@ export class MmtpContainerParser {
|
|
|
1366
1579
|
/**
|
|
1367
1580
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
1368
1581
|
*
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1371
|
-
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1582
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
1583
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
1584
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
1585
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
1586
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
1587
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
1374
1588
|
*/
|
|
1375
1589
|
get timingBudgetStats(): Readonly<MmtpTimingBudgetStats> {
|
|
1376
1590
|
return {
|
|
@@ -1439,6 +1653,16 @@ export class MmtpContainerParser {
|
|
|
1439
1653
|
return this.#fecSequencer?.rapAbove(packetId, catalogTrackName, ssId) ?? false
|
|
1440
1654
|
}
|
|
1441
1655
|
|
|
1656
|
+
/** See FecReleaseSequencer.unsource. */
|
|
1657
|
+
unsourceFecRelease(packetId: number, catalogTrackName?: string): void {
|
|
1658
|
+
this.#fecSequencer?.unsource(packetId, catalogTrackName)
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
1662
|
+
fecReleaseHoldsRebuilt(packetId: number, catalogTrackName?: string): boolean {
|
|
1663
|
+
return this.#fecSequencer?.holdsRebuilt(packetId, catalogTrackName) ?? false
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1442
1666
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
1443
1667
|
pokeFecRelease(packetId?: number, catalogTrackName?: string): void {
|
|
1444
1668
|
if (!this.#fecSequencer) return
|
|
@@ -1759,7 +1983,11 @@ export class MmtpContainerParser {
|
|
|
1759
1983
|
if (!resolver?.initialized) return this.#drop('fragment-no-resolver')
|
|
1760
1984
|
const pendingBefore = resolver.pendingSampleCount
|
|
1761
1985
|
const evictedBefore = resolver.evictedSampleCount
|
|
1762
|
-
|
|
1986
|
+
// Each stream's window is the whole budget. A resolver can displace only
|
|
1987
|
+
// its own timing, so a pool shared across streams let one stream's
|
|
1988
|
+
// unconsumed slots refuse another stream's moofs with nothing to
|
|
1989
|
+
// displace: BLO-52085 G7b, overlay-rebuilt video keyframes refusing audio.
|
|
1990
|
+
const remaining = this.#maxPendingTimingSamples - resolver.pendingSampleCount
|
|
1763
1991
|
const admitted = resolver.addMovieFragment(
|
|
1764
1992
|
mpu.mpuSequenceNumber,
|
|
1765
1993
|
data,
|
|
@@ -1767,11 +1995,12 @@ export class MmtpContainerParser {
|
|
|
1767
1995
|
options?.recovered === true,
|
|
1768
1996
|
)
|
|
1769
1997
|
// Sync on BOTH paths: the resolver can displace stale timing and still
|
|
1770
|
-
// refuse the fragment in hand, and
|
|
1771
|
-
// freed slots would keep refusing on a budget that is no longer full.
|
|
1998
|
+
// refuse the fragment in hand, and the total must count those freed slots.
|
|
1772
1999
|
this.#pendingTimingSamples += resolver.pendingSampleCount - pendingBefore
|
|
1773
2000
|
this.#evictedTimingSamples += resolver.evictedSampleCount - evictedBefore
|
|
1774
2001
|
if (!admitted) {
|
|
2002
|
+
// Never 'budget' with a window per stream (see
|
|
2003
|
+
// `rejectedMovieFragments`); kept as a guard.
|
|
1775
2004
|
if (resolver.lastMovieFragmentRejection === 'budget') {
|
|
1776
2005
|
this.#rejectedMovieFragments++
|
|
1777
2006
|
}
|
|
@@ -1858,6 +2087,7 @@ export class MmtpContainerParser {
|
|
|
1858
2087
|
resolver,
|
|
1859
2088
|
options?.recovered === true,
|
|
1860
2089
|
options?.fecSbn,
|
|
2090
|
+
options?.fecSbnFirst,
|
|
1861
2091
|
)
|
|
1862
2092
|
if (deferred.record === undefined) this.#countDeferredOutcome(deferred.reason)
|
|
1863
2093
|
}
|
|
@@ -1969,6 +2199,7 @@ export class MmtpContainerParser {
|
|
|
1969
2199
|
resolver,
|
|
1970
2200
|
options?.recovered === true,
|
|
1971
2201
|
options?.fecSbn,
|
|
2202
|
+
options?.fecSbnFirst,
|
|
1972
2203
|
)
|
|
1973
2204
|
if (outcome.record !== undefined) return outcome.record
|
|
1974
2205
|
return this.#drop(outcome.reason)
|
|
@@ -1995,6 +2226,7 @@ export class MmtpContainerParser {
|
|
|
1995
2226
|
resolver: IsoBmffTimingResolver,
|
|
1996
2227
|
recovered: boolean,
|
|
1997
2228
|
fecSbn: number | undefined,
|
|
2229
|
+
fecSbnFirst: number | undefined,
|
|
1998
2230
|
): CombinedSampleOutcome {
|
|
1999
2231
|
const timing = resolver.sampleTiming(
|
|
2000
2232
|
combined.mpuSequenceNumber,
|
|
@@ -2016,6 +2248,7 @@ export class MmtpContainerParser {
|
|
|
2016
2248
|
)
|
|
2017
2249
|
if (!meta) return { reason: 'combined-meta-build-failed' }
|
|
2018
2250
|
if (fecSbn !== undefined) meta.fecSbn = fecSbn
|
|
2251
|
+
if (fecSbnFirst !== undefined) meta.fecSbnFirst = fecSbnFirst
|
|
2019
2252
|
if (!resolver.consumeSample(
|
|
2020
2253
|
combined.mpuSequenceNumber,
|
|
2021
2254
|
combined.movieFragmentSequenceNumber,
|