@blockcast/mmt-container 2.2.0-main.2c4d96d3ffc2 → 2.2.0-main.34b53d33bace
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 +954 -157
- 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 +71 -14
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +300 -60
- 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 +63 -10
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +218 -18
- package/dist/mmtp-container-parser.js.map +2 -2
- package/dist/mmtp-container-parser.no-modules.js +217 -19
- package/dist/mmtp-container-parser.no-modules.js.map +3 -3
- package/dist/mmtp-decode-pipeline.js +218 -18
- package/dist/mmtp-decode-pipeline.js.map +2 -2
- package/dist/mmtp-router.d.ts +22 -9
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +384 -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 +774 -130
- 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 +218 -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 +218 -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 +316 -34
- package/src/index.ts +2 -0
- package/src/iso-block-locator.ts +114 -31
- package/src/mmtp-container-parser.ts +238 -21
- package/src/mmtp-router.ts +271 -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,22 @@ 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
|
|
245
278
|
}
|
|
246
279
|
|
|
247
280
|
/** Typed ISO-BMFF timing-sample budget counters. See `timingBudgetStats`. */
|
|
248
281
|
export interface MmtpTimingBudgetStats {
|
|
249
282
|
/** Slots currently charged to declared-but-undelivered samples. */
|
|
250
283
|
pending: number
|
|
251
|
-
/**
|
|
284
|
+
/**
|
|
285
|
+
* Slots each stream's window holds (`maxBufferedMfus`). A stream at
|
|
286
|
+
* capacity displaces its own oldest timing; `pending` sums every stream.
|
|
287
|
+
*/
|
|
252
288
|
capacity: number
|
|
253
289
|
/** Slots returned by samples the combiner abandoned (evicted or timed out). */
|
|
254
290
|
reclaimed: number
|
|
@@ -259,7 +295,13 @@ export interface MmtpTimingBudgetStats {
|
|
|
259
295
|
* up, `evicted` is loss that was never observable at all.
|
|
260
296
|
*/
|
|
261
297
|
evicted: number
|
|
262
|
-
/**
|
|
298
|
+
/**
|
|
299
|
+
* Movie fragments refused because the budget had no room for their samples.
|
|
300
|
+
* Stays 0 with a window per stream (BLO-52085): a stream at capacity
|
|
301
|
+
* displaces its own oldest timing to make room, and a moof declaring more
|
|
302
|
+
* samples than a whole window holds is refused as invalid before any budget
|
|
303
|
+
* is consulted. Kept as a guard, and because it is public.
|
|
304
|
+
*/
|
|
263
305
|
rejectedMovieFragments: number
|
|
264
306
|
}
|
|
265
307
|
|
|
@@ -367,7 +409,10 @@ export type MmtpFeedDropReason =
|
|
|
367
409
|
| 'fragment-unexpected-fragmentation'
|
|
368
410
|
/** FT=1 before an FT=0 has bound the stream's timing track. */
|
|
369
411
|
| 'fragment-no-resolver'
|
|
370
|
-
/** addMovieFragment refused
|
|
412
|
+
/** addMovieFragment refused: the moof does not parse against the stream's
|
|
413
|
+
* track, conflicts with a pending copy of itself, or repeats a pending
|
|
414
|
+
* copy whose samples are partly consumed. Never the timing budget: a full
|
|
415
|
+
* window displaces the stream's own oldest timing. */
|
|
371
416
|
| 'fragment-timing-refused'
|
|
372
417
|
| 'unknown-fragment-type'
|
|
373
418
|
/** Stable code, no longer produced: an FT=2 with no timing (before the
|
|
@@ -508,6 +553,8 @@ export interface ParseHeaderOptions {
|
|
|
508
553
|
deliveryProvenance?: MmtpDeliveryProvenance
|
|
509
554
|
/** FEC source block this packet belongs to (FEC-protected packets only). */
|
|
510
555
|
fecSbn?: number
|
|
556
|
+
/** See FrameMeta.fecSbnFirst. */
|
|
557
|
+
fecSbnFirst?: number
|
|
511
558
|
}
|
|
512
559
|
|
|
513
560
|
// ── FrameSequencer ──────────────────────────────────────────────────
|
|
@@ -721,9 +768,19 @@ function ssIdAfter(a: number, b: number): boolean {
|
|
|
721
768
|
return ((a - b) | 0) > 0
|
|
722
769
|
}
|
|
723
770
|
|
|
771
|
+
/** The stream holds a frame the keyframe overlay rebuilt (FrameMeta.fecSbnFirst). */
|
|
772
|
+
function holdsRebuilt(stream: GatedStream): boolean {
|
|
773
|
+
return stream.buf.some(({ meta }) => meta.fecSbnFirst !== undefined)
|
|
774
|
+
}
|
|
775
|
+
|
|
724
776
|
interface GatedFrame extends PendingFrame {
|
|
725
777
|
/** performance.now() at push; measures the hold against the gate's limit. */
|
|
726
778
|
arrivedAtMs: number
|
|
779
|
+
/**
|
|
780
|
+
* The unanchored path's gate is done with this frame (see #cursorPassed):
|
|
781
|
+
* it released it, or dropped it as stale.
|
|
782
|
+
*/
|
|
783
|
+
passed?: boolean
|
|
727
784
|
}
|
|
728
785
|
|
|
729
786
|
interface GatedStream {
|
|
@@ -735,6 +792,10 @@ interface GatedStream {
|
|
|
735
792
|
discontinuity: boolean
|
|
736
793
|
/** Latest (serial order) SS_ID of a complete RAP that entered the gate since the last reset. */
|
|
737
794
|
rapSsId: number | undefined
|
|
795
|
+
/** A frame that was not FEC-recovered was released since the last reset. */
|
|
796
|
+
sourced: boolean
|
|
797
|
+
/** Drains of this stream in progress: a release calls out, and back in (a stream switch's onCommit). */
|
|
798
|
+
draining: number
|
|
738
799
|
}
|
|
739
800
|
|
|
740
801
|
/**
|
|
@@ -743,7 +804,13 @@ interface GatedStream {
|
|
|
743
804
|
* to the last released frame is released immediately. A frame after a gap
|
|
744
805
|
* waits until every block between the last released frame's block and its
|
|
745
806
|
* own has resolved; a D-28 repair or a late in-band recovery can therefore
|
|
746
|
-
* still fill the gap.
|
|
807
|
+
* still fill the gap. Once only a late source or the keyframe overlay could
|
|
808
|
+
* fill it, the frame waits only the gate's `unrepairableWaitMs` from its
|
|
809
|
+
* arrival: the late-symbol allowance, or longer when the gap may hold a RAP
|
|
810
|
+
* the overlay could still rebuild. A frame the keyframe overlay rebuilt
|
|
811
|
+
* waits only for the blocks before its MPU (FrameMeta.fecSbnFirst), and no
|
|
812
|
+
* longer than the source cursor would hold it unanchored
|
|
813
|
+
* (#cursorPassed). When the resolved blocks lost media, or authored decode
|
|
747
814
|
* time shows a missing sample, the release carries the gate's stall/conceal
|
|
748
815
|
* decision as `gapBefore`.
|
|
749
816
|
*
|
|
@@ -829,6 +896,7 @@ class FecReleaseSequencer {
|
|
|
829
896
|
stream.lastSbn = undefined
|
|
830
897
|
stream.discontinuity = false
|
|
831
898
|
stream.rapSsId = undefined
|
|
899
|
+
stream.sourced = false
|
|
832
900
|
}
|
|
833
901
|
if (stream.last !== null && compareFrameOrder(frame, stream.last) <= 0) {
|
|
834
902
|
this.#recordStat('droppedStale')
|
|
@@ -857,6 +925,8 @@ class FecReleaseSequencer {
|
|
|
857
925
|
if (compareFrameOrder(stream.buf[mid]!, frame) < 0) lo = mid + 1
|
|
858
926
|
else hi = mid
|
|
859
927
|
}
|
|
928
|
+
// In front of a frame the unanchored path released, it was stale there.
|
|
929
|
+
if (stream.buf[lo]?.passed === true) frame.passed = true
|
|
860
930
|
stream.buf.splice(lo, 0, frame)
|
|
861
931
|
this.#drainUnlessDeferred(stream)
|
|
862
932
|
}
|
|
@@ -895,6 +965,54 @@ class FecReleaseSequencer {
|
|
|
895
965
|
return false
|
|
896
966
|
}
|
|
897
967
|
|
|
968
|
+
/**
|
|
969
|
+
* These streams' sink is being replaced by one that has seen no source
|
|
970
|
+
* frame yet. First, from a stream that holds a frame the overlay rebuilt,
|
|
971
|
+
* release to the sink being replaced the frames the unanchored path had
|
|
972
|
+
* already released to it (#cursorPassed): there they waited in its queue,
|
|
973
|
+
* which its replacement flushes. A stream that holds none is not drained:
|
|
974
|
+
* it holds nothing the anchor kept back, and a drain would still force out
|
|
975
|
+
* a frame held past the hold limit, which before the anchor waited for the
|
|
976
|
+
* next push. Then treat the streams as unsourced until a source frame is
|
|
977
|
+
* released.
|
|
978
|
+
*/
|
|
979
|
+
unsource(packetId: number, catalogTrackName: string | undefined): void {
|
|
980
|
+
for (const stream of this.#streams.values()) {
|
|
981
|
+
if (stream.packetId === packetId && (catalogTrackName === undefined || stream.catalogTrackName === catalogTrackName)) {
|
|
982
|
+
// From inside this stream's own drain (a sink replaced from a frame
|
|
983
|
+
// callback, as a stream switch's onCommit can), the drain under way
|
|
984
|
+
// releases the rest, in order, once the frame it is delivering is
|
|
985
|
+
// done (a commit delivers its held GOP and RAP after onCommit):
|
|
986
|
+
// released here, they would go ahead of them. Inside a deferral
|
|
987
|
+
// scope (a protected flow's record admits frames of several streams
|
|
988
|
+
// in one), the scope's drain does, for the same reason, into the
|
|
989
|
+
// replacement. With the stream unsourced, that drain lets a rebuilt
|
|
990
|
+
// frame go as unanchored did until it releases a source frame; a
|
|
991
|
+
// rebuilt frame behind that one waits for the blocks before it, as an
|
|
992
|
+
// anchored frame does (the record may hold the base frames it needs).
|
|
993
|
+
if (stream.draining === 0 && holdsRebuilt(stream)) {
|
|
994
|
+
if (this.#deferDepth > 0) this.#deferredStreams.add(stream)
|
|
995
|
+
else this.#drain(stream, true)
|
|
996
|
+
}
|
|
997
|
+
stream.sourced = false
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Whether a stream of `packetId` holds a frame the keyframe overlay rebuilt
|
|
1004
|
+
* (FrameMeta.fecSbnFirst). Without `catalogTrackName`, every stream of the
|
|
1005
|
+
* packetId.
|
|
1006
|
+
*/
|
|
1007
|
+
holdsRebuilt(packetId: number, catalogTrackName: string | undefined): boolean {
|
|
1008
|
+
for (const stream of this.#streams.values()) {
|
|
1009
|
+
if (stream.packetId !== packetId) continue
|
|
1010
|
+
if (catalogTrackName !== undefined && stream.catalogTrackName !== catalogTrackName) continue
|
|
1011
|
+
if (holdsRebuilt(stream)) return true
|
|
1012
|
+
}
|
|
1013
|
+
return false
|
|
1014
|
+
}
|
|
1015
|
+
|
|
898
1016
|
/** Re-evaluate held gaps after FEC state changed. */
|
|
899
1017
|
poke(streamKey?: string): void {
|
|
900
1018
|
if (streamKey !== undefined) {
|
|
@@ -1001,16 +1119,34 @@ class FecReleaseSequencer {
|
|
|
1001
1119
|
lastSbn: undefined,
|
|
1002
1120
|
discontinuity: false,
|
|
1003
1121
|
rapSsId: undefined,
|
|
1122
|
+
sourced: false,
|
|
1123
|
+
draining: 0,
|
|
1004
1124
|
}
|
|
1005
1125
|
this.#streams.set(streamKey, stream)
|
|
1006
1126
|
}
|
|
1007
1127
|
return stream
|
|
1008
1128
|
}
|
|
1009
1129
|
|
|
1010
|
-
#
|
|
1130
|
+
/** `asUnanchored`: release overlay-rebuilt frames when unanchored did (#cursorPassed). */
|
|
1131
|
+
#drain(stream: GatedStream, asUnanchored = false): void {
|
|
1132
|
+
stream.draining++
|
|
1133
|
+
try {
|
|
1134
|
+
this.#drainLoop(stream, asUnanchored)
|
|
1135
|
+
} finally {
|
|
1136
|
+
stream.draining--
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
#drainLoop(stream: GatedStream, asUnanchored: boolean): void {
|
|
1011
1141
|
while (stream.buf.length > 0 && stream.last !== null) {
|
|
1012
1142
|
const head = stream.buf[0]!
|
|
1013
1143
|
const last = stream.last
|
|
1144
|
+
// A second held copy of the frame just released waits on nothing.
|
|
1145
|
+
if (compareFrameOrder(head, last) <= 0) {
|
|
1146
|
+
stream.buf.shift()
|
|
1147
|
+
this.#release(stream, head, undefined)
|
|
1148
|
+
continue
|
|
1149
|
+
}
|
|
1014
1150
|
if (stream.discontinuity) {
|
|
1015
1151
|
stream.discontinuity = false
|
|
1016
1152
|
stream.buf.shift()
|
|
@@ -1024,13 +1160,19 @@ class FecReleaseSequencer {
|
|
|
1024
1160
|
}
|
|
1025
1161
|
const headSbn = head.meta.fecSbn
|
|
1026
1162
|
const from = stream.lastSbn ?? headSbn
|
|
1027
|
-
|
|
1163
|
+
// An overlay-rebuilt frame waits only for the blocks before its MPU's
|
|
1164
|
+
// first packet in that decode (fecSbnFirst): the overlay delivered the
|
|
1165
|
+
// packets from there on.
|
|
1166
|
+
const to = head.meta.fecSbnFirst ?? headSbn ?? stream.lastSbn
|
|
1028
1167
|
let lost: readonly number[] = []
|
|
1029
1168
|
// Neither side carries a Source FEC Payload ID: on a catalog-declared
|
|
1030
1169
|
// FEC track that is the trailer-stripped profile violation, and there
|
|
1031
1170
|
// are no blocks to wait on. The gap is still a gap: never release across
|
|
1032
1171
|
// it undecided (fail closed), let the gate decide with no known blocks.
|
|
1033
1172
|
const unanchored = from === undefined && to === undefined
|
|
1173
|
+
// The source cursor released it (#cursorPassed) across blocks that have
|
|
1174
|
+
// not resolved: nothing sized that gap either, so it is decided too.
|
|
1175
|
+
let unresolved = false
|
|
1034
1176
|
if (from !== undefined && to !== undefined) {
|
|
1035
1177
|
const resolved = this.#gate.resolvedLoss(
|
|
1036
1178
|
stream.packetId,
|
|
@@ -1039,7 +1181,8 @@ class FecReleaseSequencer {
|
|
|
1039
1181
|
Math.max(from, to),
|
|
1040
1182
|
from,
|
|
1041
1183
|
)
|
|
1042
|
-
|
|
1184
|
+
unresolved = resolved === null
|
|
1185
|
+
if (unresolved && !this.#cursorPassed(stream, asUnanchored) && !this.#unrepairableWaitOver(last, head, from, to)) {
|
|
1043
1186
|
const heldMs = performance.now() - head.arrivedAtMs
|
|
1044
1187
|
if (heldMs <= this.#gate.holdLimitMs(stream.packetId, stream.catalogTrackName)) return
|
|
1045
1188
|
// Past the point where these blocks must have resolved: nothing
|
|
@@ -1049,7 +1192,7 @@ class FecReleaseSequencer {
|
|
|
1049
1192
|
this.#release(stream, head, this.#gate.decide(last, head, [], true))
|
|
1050
1193
|
continue
|
|
1051
1194
|
}
|
|
1052
|
-
lost = resolved
|
|
1195
|
+
lost = resolved ?? []
|
|
1053
1196
|
}
|
|
1054
1197
|
stream.buf.shift()
|
|
1055
1198
|
// Every gap in the frame sequence gets a decision, not only one whose
|
|
@@ -1060,19 +1203,73 @@ class FecReleaseSequencer {
|
|
|
1060
1203
|
this.#release(
|
|
1061
1204
|
stream,
|
|
1062
1205
|
head,
|
|
1063
|
-
lost.length > 0 || unanchored || authoredGap(last.meta, head.meta)
|
|
1206
|
+
lost.length > 0 || unanchored || unresolved || authoredGap(last.meta, head.meta)
|
|
1064
1207
|
? this.#gate.decide(last, head, lost, false)
|
|
1065
1208
|
: undefined,
|
|
1066
1209
|
)
|
|
1067
1210
|
}
|
|
1068
1211
|
}
|
|
1069
1212
|
|
|
1213
|
+
/** The head has waited out a gap only a late source can still fill (FecReleaseGate.unrepairableWaitMs). */
|
|
1214
|
+
#unrepairableWaitOver(last: PendingFrame, head: GatedFrame, from: number, to: number): boolean {
|
|
1215
|
+
const waitMs = this.#gate.unrepairableWaitMs?.(last, head, from, to)
|
|
1216
|
+
return waitMs !== undefined && performance.now() - head.arrivedAtMs >= waitMs
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* An overlay-rebuilt frame (fecSbnFirst) waits no longer than the BLO-53342
|
|
1221
|
+
* source cursor holds it unanchored, and neither does a later frame behind
|
|
1222
|
+
* it. Unanchored, a frame that waits on no block (fecSbnFirst set, or no
|
|
1223
|
+
* fecSbn) left the gate once every frame ahead of it had: mark it `passed`,
|
|
1224
|
+
* like each frame that arrived in front of it since (stale there). The head
|
|
1225
|
+
* then goes, decided as it would be unanchored, once a frame the base path
|
|
1226
|
+
* delivered (a source frame, or one base FEC recovered) is buffered after a
|
|
1227
|
+
* marked one: the base path has passed that one, so a frame still missing
|
|
1228
|
+
* before it can only come from a repair. It also goes while no source frame
|
|
1229
|
+
* has been released, when the direct path shows a recovered frame at once.
|
|
1230
|
+
* And it goes at once while a staged switch decides on when frames arrive
|
|
1231
|
+
* (FecReleaseGate.releaseUnanchored), and when unsource releases into a
|
|
1232
|
+
* sink being replaced: unanchored, it had already reached the sink.
|
|
1233
|
+
* The scan also writes: the `passed` marks it sets stay on the frames,
|
|
1234
|
+
* and push marks a frame it inserts in front of a marked one from them.
|
|
1235
|
+
*/
|
|
1236
|
+
#cursorPassed(stream: GatedStream, asUnanchored: boolean): boolean {
|
|
1237
|
+
let at = -1
|
|
1238
|
+
for (let i = 0; i < stream.buf.length; i++) {
|
|
1239
|
+
const frame = stream.buf[i]!
|
|
1240
|
+
if (frame.meta.fecSbnFirst !== undefined || frame.meta.fecSbn === undefined) {
|
|
1241
|
+
frame.passed = true
|
|
1242
|
+
if (at < 0) at = i
|
|
1243
|
+
} else if (frame.passed !== true) break
|
|
1244
|
+
}
|
|
1245
|
+
if (at < 0) return false
|
|
1246
|
+
return asUnanchored || !stream.sourced ||
|
|
1247
|
+
this.#gate.releaseUnanchored?.(stream.packetId, stream.catalogTrackName) === true ||
|
|
1248
|
+
stream.buf.some(({ meta }, i) =>
|
|
1249
|
+
i > at && meta.fecSbnFirst === undefined && (meta.recovered !== true || meta.fecSbn !== undefined))
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1070
1252
|
#release(stream: GatedStream, frame: PendingFrame, decision: FrameGapDecision | undefined): void {
|
|
1253
|
+
// Two copies of one frame were held (its base copy and the overlay's
|
|
1254
|
+
// rebuild) and the other went out: this one is stale, as a copy pushed
|
|
1255
|
+
// after its frame was released is. It still moves the state as a release
|
|
1256
|
+
// does: only the second emission is dropped.
|
|
1257
|
+
const stale = stream.last !== null && compareFrameOrder(frame, stream.last) <= 0
|
|
1258
|
+
if (stale) this.#recordStat('droppedStale')
|
|
1071
1259
|
if (decision) frame.meta.gapBefore = decision
|
|
1072
1260
|
stream.last = frame
|
|
1073
|
-
|
|
1261
|
+
// An overlay-rebuilt frame (fecSbnFirst) released before any base frame
|
|
1262
|
+
// since the last reset leaves lastSbn unset, as it did unanchored: the
|
|
1263
|
+
// base frame after it then waits for nothing, not for the frames between.
|
|
1264
|
+
if (frame.meta.fecSbn !== undefined && (frame.meta.fecSbnFirst === undefined || stream.lastSbn !== undefined)) {
|
|
1265
|
+
stream.lastSbn = frame.meta.fecSbn
|
|
1266
|
+
}
|
|
1267
|
+
if (frame.meta.recovered !== true) stream.sourced = true
|
|
1268
|
+
// A stale copy of the frame just released (equal order) repeats an
|
|
1269
|
+
// onReleased call already made: noteReleasedRap ignores a second RAP of
|
|
1270
|
+
// an MPU it has anchored (the same MPU and presentation time).
|
|
1074
1271
|
this.#gate.onReleased?.(frame.data, frame.meta)
|
|
1075
|
-
this.#emit(frame.data, frame.meta)
|
|
1272
|
+
if (!stale) this.#emit(frame.data, frame.meta)
|
|
1076
1273
|
}
|
|
1077
1274
|
}
|
|
1078
1275
|
|
|
@@ -1366,11 +1563,12 @@ export class MmtpContainerParser {
|
|
|
1366
1563
|
/**
|
|
1367
1564
|
* Typed view of the ISO-BMFF timing-sample budget.
|
|
1368
1565
|
*
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1371
|
-
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1566
|
+
* Each stream admits timing against its own window of `capacity` slots
|
|
1567
|
+
* (BLO-52085). A stream at capacity displaces its own oldest timing to
|
|
1568
|
+
* admit the moof in hand, and `evicted` counts the slots so displaced:
|
|
1569
|
+
* timing a stream declared and never delivered shows up there. `pending`
|
|
1570
|
+
* sums every stream, so it can exceed `capacity`. Per repo policy this is
|
|
1571
|
+
* a producer-owned counter -- never infer budget state by parsing logs.
|
|
1374
1572
|
*/
|
|
1375
1573
|
get timingBudgetStats(): Readonly<MmtpTimingBudgetStats> {
|
|
1376
1574
|
return {
|
|
@@ -1439,6 +1637,16 @@ export class MmtpContainerParser {
|
|
|
1439
1637
|
return this.#fecSequencer?.rapAbove(packetId, catalogTrackName, ssId) ?? false
|
|
1440
1638
|
}
|
|
1441
1639
|
|
|
1640
|
+
/** See FecReleaseSequencer.unsource. */
|
|
1641
|
+
unsourceFecRelease(packetId: number, catalogTrackName?: string): void {
|
|
1642
|
+
this.#fecSequencer?.unsource(packetId, catalogTrackName)
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/** See FecReleaseSequencer.holdsRebuilt. */
|
|
1646
|
+
fecReleaseHoldsRebuilt(packetId: number, catalogTrackName?: string): boolean {
|
|
1647
|
+
return this.#fecSequencer?.holdsRebuilt(packetId, catalogTrackName) ?? false
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1442
1650
|
/** Re-evaluate held gaps after FEC block state changed. */
|
|
1443
1651
|
pokeFecRelease(packetId?: number, catalogTrackName?: string): void {
|
|
1444
1652
|
if (!this.#fecSequencer) return
|
|
@@ -1759,7 +1967,11 @@ export class MmtpContainerParser {
|
|
|
1759
1967
|
if (!resolver?.initialized) return this.#drop('fragment-no-resolver')
|
|
1760
1968
|
const pendingBefore = resolver.pendingSampleCount
|
|
1761
1969
|
const evictedBefore = resolver.evictedSampleCount
|
|
1762
|
-
|
|
1970
|
+
// Each stream's window is the whole budget. A resolver can displace only
|
|
1971
|
+
// its own timing, so a pool shared across streams let one stream's
|
|
1972
|
+
// unconsumed slots refuse another stream's moofs with nothing to
|
|
1973
|
+
// displace: BLO-52085 G7b, overlay-rebuilt video keyframes refusing audio.
|
|
1974
|
+
const remaining = this.#maxPendingTimingSamples - resolver.pendingSampleCount
|
|
1763
1975
|
const admitted = resolver.addMovieFragment(
|
|
1764
1976
|
mpu.mpuSequenceNumber,
|
|
1765
1977
|
data,
|
|
@@ -1767,11 +1979,12 @@ export class MmtpContainerParser {
|
|
|
1767
1979
|
options?.recovered === true,
|
|
1768
1980
|
)
|
|
1769
1981
|
// 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.
|
|
1982
|
+
// refuse the fragment in hand, and the total must count those freed slots.
|
|
1772
1983
|
this.#pendingTimingSamples += resolver.pendingSampleCount - pendingBefore
|
|
1773
1984
|
this.#evictedTimingSamples += resolver.evictedSampleCount - evictedBefore
|
|
1774
1985
|
if (!admitted) {
|
|
1986
|
+
// Never 'budget' with a window per stream (see
|
|
1987
|
+
// `rejectedMovieFragments`); kept as a guard.
|
|
1775
1988
|
if (resolver.lastMovieFragmentRejection === 'budget') {
|
|
1776
1989
|
this.#rejectedMovieFragments++
|
|
1777
1990
|
}
|
|
@@ -1858,6 +2071,7 @@ export class MmtpContainerParser {
|
|
|
1858
2071
|
resolver,
|
|
1859
2072
|
options?.recovered === true,
|
|
1860
2073
|
options?.fecSbn,
|
|
2074
|
+
options?.fecSbnFirst,
|
|
1861
2075
|
)
|
|
1862
2076
|
if (deferred.record === undefined) this.#countDeferredOutcome(deferred.reason)
|
|
1863
2077
|
}
|
|
@@ -1969,6 +2183,7 @@ export class MmtpContainerParser {
|
|
|
1969
2183
|
resolver,
|
|
1970
2184
|
options?.recovered === true,
|
|
1971
2185
|
options?.fecSbn,
|
|
2186
|
+
options?.fecSbnFirst,
|
|
1972
2187
|
)
|
|
1973
2188
|
if (outcome.record !== undefined) return outcome.record
|
|
1974
2189
|
return this.#drop(outcome.reason)
|
|
@@ -1995,6 +2210,7 @@ export class MmtpContainerParser {
|
|
|
1995
2210
|
resolver: IsoBmffTimingResolver,
|
|
1996
2211
|
recovered: boolean,
|
|
1997
2212
|
fecSbn: number | undefined,
|
|
2213
|
+
fecSbnFirst: number | undefined,
|
|
1998
2214
|
): CombinedSampleOutcome {
|
|
1999
2215
|
const timing = resolver.sampleTiming(
|
|
2000
2216
|
combined.mpuSequenceNumber,
|
|
@@ -2016,6 +2232,7 @@ export class MmtpContainerParser {
|
|
|
2016
2232
|
)
|
|
2017
2233
|
if (!meta) return { reason: 'combined-meta-build-failed' }
|
|
2018
2234
|
if (fecSbn !== undefined) meta.fecSbn = fecSbn
|
|
2235
|
+
if (fecSbnFirst !== undefined) meta.fecSbnFirst = fecSbnFirst
|
|
2019
2236
|
if (!resolver.consumeSample(
|
|
2020
2237
|
combined.mpuSequenceNumber,
|
|
2021
2238
|
combined.movieFragmentSequenceNumber,
|