@blockcast/mmt-container 0.4.0-main.f1e1170f2810 → 0.4.0
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 +1 -1
- package/dist/browser-runtime.js +14177 -13549
- package/dist/browser-runtime.js.map +4 -4
- package/dist/carp-catalog.d.ts.map +1 -1
- package/dist/carp-catalog.js +6 -0
- package/dist/carp-catalog.js.map +3 -3
- package/dist/catalog-fec-params.d.ts +5 -2
- package/dist/catalog-fec-params.d.ts.map +1 -1
- package/dist/catalog-fec-params.js +100 -36
- package/dist/catalog-fec-params.js.map +4 -4
- package/dist/catalog-network-source.js +3 -0
- package/dist/catalog-network-source.js.map +3 -3
- package/dist/delivery-catalog.d.ts +124 -0
- package/dist/delivery-catalog.d.ts.map +1 -0
- package/dist/delivery-catalog.js +1867 -0
- package/dist/delivery-catalog.js.map +7 -0
- package/dist/fec-manager.d.ts +16 -0
- package/dist/fec-manager.d.ts.map +1 -1
- package/dist/fec-manager.js +38 -0
- package/dist/fec-manager.js.map +3 -3
- package/dist/fec-state.d.ts +3 -2
- package/dist/fec-state.d.ts.map +1 -1
- package/dist/fec-state.js +16 -9
- package/dist/fec-state.js.map +4 -4
- package/dist/fec-worker-setup.js +3 -0
- package/dist/fec-worker-setup.js.map +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +2 -2
- package/dist/iso-block-locator.js +3 -0
- package/dist/iso-block-locator.js.map +3 -3
- package/dist/mfu-reassembler.js +3 -0
- package/dist/mfu-reassembler.js.map +3 -3
- package/dist/mmtp-container-parser.d.ts +8 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -1
- package/dist/mmtp-container-parser.js +73 -2
- package/dist/mmtp-container-parser.js.map +3 -3
- package/dist/mmtp-container-parser.no-modules.js +92 -12
- package/dist/mmtp-container-parser.no-modules.js.map +4 -4
- package/dist/mmtp-decode-pipeline.js +73 -2
- package/dist/mmtp-decode-pipeline.js.map +3 -3
- package/dist/mmtp-router.d.ts +32 -3
- package/dist/mmtp-router.d.ts.map +1 -1
- package/dist/mmtp-router.js +107 -13
- package/dist/mmtp-router.js.map +3 -3
- package/dist/multicast-input.js +3 -0
- package/dist/multicast-input.js.map +3 -3
- package/dist/multicast-manager.d.ts +38 -0
- package/dist/multicast-manager.d.ts.map +1 -1
- package/dist/multicast-manager.js +214 -26
- package/dist/multicast-manager.js.map +4 -4
- package/dist/multicast-transport.js +10 -0
- package/dist/multicast-transport.js.map +4 -4
- package/dist/multicast-unwrap.js +3 -0
- package/dist/multicast-unwrap.js.map +3 -3
- package/dist/no-modules.js +89 -11
- package/dist/no-modules.js.map +4 -4
- package/dist/repair-fetch.d.ts +86 -2
- package/dist/repair-fetch.d.ts.map +1 -1
- package/dist/repair-fetch.js +85 -11
- package/dist/repair-fetch.js.map +3 -3
- package/dist/repair-layers.js +3 -0
- package/dist/repair-layers.js.map +3 -3
- package/dist/signaling.js +3 -0
- package/dist/signaling.js.map +3 -3
- package/dist/timestamp-codec.js +3 -0
- package/dist/timestamp-codec.js.map +3 -3
- package/dist/wasm-mfu-reassembler.js +3 -0
- package/dist/wasm-mfu-reassembler.js.map +3 -3
- package/dist/wasm-mmtp-container-parser.js +73 -2
- package/dist/wasm-mmtp-container-parser.js.map +3 -3
- package/package.json +5 -5
- package/src/carp-catalog.ts +5 -0
- package/src/catalog-fec-params.ts +38 -17
- package/src/delivery-catalog.ts +498 -0
- package/src/fec-manager.ts +43 -0
- package/src/fec-state.ts +4 -9
- package/src/index.ts +27 -0
- package/src/mmtp-container-parser.ts +79 -2
- package/src/mmtp-router.ts +69 -18
- package/src/multicast-manager.ts +81 -3
- package/src/repair-fetch.ts +228 -17
- package/test-vectors/catalog/README.md +7 -1
- package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +1 -0
- package/test-vectors/catalog/section-codes.json +33 -0
- package/test-vectors/delivery-catalog/README.md +11 -0
- package/test-vectors/delivery-catalog/negative/missing-block-profile.json +58 -0
- package/test-vectors/delivery-catalog/negative/packet-id-signaling.json +59 -0
- package/test-vectors/delivery-catalog/negative/retired-k-padded-block-profile.json +59 -0
- package/test-vectors/delivery-catalog/positive/dash.json +56 -0
- package/test-vectors/delivery-catalog/positive/mmtp-source-only.json +43 -0
package/dist/repair-fetch.d.ts
CHANGED
|
@@ -57,13 +57,36 @@
|
|
|
57
57
|
* than sent and cancelled -- and an admitted FETCH holds the block open to
|
|
58
58
|
* that deadline, so the multicast span elapsing never aborts it.
|
|
59
59
|
*
|
|
60
|
+
* Keyframe late-repair budget: a block that may hold a RAP may be given a
|
|
61
|
+
* longer deadline than the playout budget (`keyframeRepairBudgetMs`). Losing
|
|
62
|
+
* such a block costs every frame up to the next keyframe, so holding it open
|
|
63
|
+
* for a FETCH that lands within the budget trades a short hold for a GOP-long
|
|
64
|
+
* freeze. At a small playout budget (a low-latency target) the presentation
|
|
65
|
+
* deadline alone leaves less than one round trip by the time the multicast
|
|
66
|
+
* wait gives up on the block, so every keyframe request would be refused
|
|
67
|
+
* (`rtt-exceeds-budget`). Eligible (`keyframeBudgetEligible`): a `keyframe`
|
|
68
|
+
* block (in-band RAP evidence), and an `unknown` block only while its
|
|
69
|
+
* stream's classifier is `classifying`, where `unknown` means the window rule
|
|
70
|
+
* could not exclude a RAP. Under `all-protected` every block reads `unknown`
|
|
71
|
+
* whatever it holds, so there only RAP evidence earns the budget. Never
|
|
72
|
+
* audio (P1) or delta (P2), and never a block its repair group cannot
|
|
73
|
+
* complete (received sources + RSB_length < K'). The hold ends when its
|
|
74
|
+
* FETCH ends without making the block decodable, not at the budget.
|
|
75
|
+
*
|
|
76
|
+
* Every deadline is capped by the release gate's hold ceiling measured the
|
|
77
|
+
* way the gate measures it: from the earliest frame it holds for the stream
|
|
78
|
+
* (a surviving frame of the block itself is routed before a repair symbol
|
|
79
|
+
* states the block, so before its anchor), never later than from the anchor.
|
|
80
|
+
* A FETCH landing after the gate forced that frame out would recover media
|
|
81
|
+
* the gate then drops as stale.
|
|
82
|
+
*
|
|
60
83
|
* The scheduler arms no timers. A fetch ends when its transport completes or
|
|
61
84
|
* throws, when it is preempted, when any later scheduling event finds it past
|
|
62
85
|
* its presentation deadline, when its block resolves (recovered, or failed at
|
|
63
86
|
* that deadline), on track reset, or on dispose.
|
|
64
87
|
*/
|
|
65
88
|
import { type FecBlockProfile } from '@blockcast/mmt-base';
|
|
66
|
-
import { type BlockClass } from './block-policy.js';
|
|
89
|
+
import { type BlockClass, type ClassifierMode, type RepairPriority } from './block-policy.js';
|
|
67
90
|
import type { RepairLifecycleObserver } from './multicast-manager.js';
|
|
68
91
|
/**
|
|
69
92
|
* The highest value in the Source Media priority range of
|
|
@@ -202,6 +225,22 @@ export type RepairFetchPriority = {
|
|
|
202
225
|
* least 192, i.e. max(repair, 192); declined when it carries none.
|
|
203
226
|
*/
|
|
204
227
|
export declare function repairFetchSubscriberPriority(blockClass: BlockClass, target: Pick<RepairTarget, 'sourcePriority' | 'repairPriority'>): RepairFetchPriority;
|
|
228
|
+
/** What `RepairFetchHost.fecManager.blockSymbolCounts` reports for one open block. */
|
|
229
|
+
export interface BlockSymbolCounts {
|
|
230
|
+
readonly sources: number;
|
|
231
|
+
readonly repairs: number;
|
|
232
|
+
readonly authoredLength: number | undefined;
|
|
233
|
+
readonly repairGroupLength: number | undefined;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Whether a block of `blockClass` may get the keyframe late-repair budget:
|
|
237
|
+
* a `keyframe` block always (in-band RAP evidence), an `unknown` block only
|
|
238
|
+
* while its stream's classifier is `classifying` (the window rule could not
|
|
239
|
+
* exclude a RAP). An `all-protected` stream reads `unknown` for every block,
|
|
240
|
+
* delta-only ones included, so there `unknown` is no evidence of a RAP and
|
|
241
|
+
* earns no hold. Audio and delta never do.
|
|
242
|
+
*/
|
|
243
|
+
export declare function keyframeBudgetEligible(blockClass: BlockClass, classifierMode: ClassifierMode | undefined): boolean;
|
|
205
244
|
export interface WireRepairFetchOptions {
|
|
206
245
|
resolveTarget: ResolveRepairTarget;
|
|
207
246
|
transport: RepairFetchTransport;
|
|
@@ -228,6 +267,20 @@ export interface WireRepairFetchOptions {
|
|
|
228
267
|
* (`presentation-delay-unavailable`).
|
|
229
268
|
*/
|
|
230
269
|
presentationDelayMs: (packetId: number, catalogTrackName?: string) => number;
|
|
270
|
+
/**
|
|
271
|
+
* How long after the first symbol of a block that may hold a RAP a repair
|
|
272
|
+
* FETCH of it may still land, in ms (optional). Such a block
|
|
273
|
+
* (`keyframeBudgetEligible`) gets the larger of this and
|
|
274
|
+
* `presentationDelayMs`, still never later than the release gate's hold
|
|
275
|
+
* ceiling and never earlier than the multicast wait; RTT admission is
|
|
276
|
+
* unchanged. Losing a keyframe block costs the rest of its GOP, so a player
|
|
277
|
+
* may hold the block (and the frames released after it) while its FETCH is
|
|
278
|
+
* in flight rather than freeze to the next keyframe. Absent, throwing, or
|
|
279
|
+
* not finite and positive: every block gets the presentation deadline
|
|
280
|
+
* alone. Never applied to audio, delta, or an `unknown` block of an
|
|
281
|
+
* `all-protected` stream.
|
|
282
|
+
*/
|
|
283
|
+
keyframeRepairBudgetMs?: (packetId: number, catalogTrackName?: string) => number;
|
|
231
284
|
}
|
|
232
285
|
/** Why the D-28 layer asked for a repair: the block's class at its deadline. */
|
|
233
286
|
export type RepairSubscribeCallback = (sbn: number, packetId: number, catalogTrackName: string | undefined, blockClass: BlockClass) => void;
|
|
@@ -246,6 +299,18 @@ export interface RepairFetchHost {
|
|
|
246
299
|
repairFetchTimeoutMsForBlock(sbn: number, packetId: number, catalogTrackName?: string): number | undefined;
|
|
247
300
|
/** Receiver-local time of the block's first accepted symbol, if any. */
|
|
248
301
|
blockAnchorAtMs(sbn: number, packetId: number, catalogTrackName?: string): number | undefined;
|
|
302
|
+
/** The stream's classifier mode (optional; absent reads as unknown). */
|
|
303
|
+
classifierModeFor?(packetId: number, catalogTrackName?: string): {
|
|
304
|
+
readonly mode: ClassifierMode;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* An open block's received sources and distinct repair symbols, its K'
|
|
308
|
+
* (SSB_length) and RSB_length (optional). The repair group carries
|
|
309
|
+
* RSB_length symbols, so it can complete the block only when
|
|
310
|
+
* sources + RSB_length >= K'; a FETCH that ended leaving fewer than K'
|
|
311
|
+
* distinct symbols cannot be decoding it.
|
|
312
|
+
*/
|
|
313
|
+
blockSymbolCounts?(sbn: number, packetId: number, catalogTrackName?: string): BlockSymbolCounts | undefined;
|
|
249
314
|
/** How long a terminal block stays authoritative: the release-gate hold ceiling. */
|
|
250
315
|
terminalRetentionMsForPacket(packetId: number): number | undefined;
|
|
251
316
|
/** Keep the block open to `untilAtMs` for an admitted FETCH. */
|
|
@@ -254,6 +319,15 @@ export interface RepairFetchHost {
|
|
|
254
319
|
releaseRepairHold(sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
255
320
|
};
|
|
256
321
|
onRepairSubscribe(cb: RepairSubscribeCallback): void;
|
|
322
|
+
/**
|
|
323
|
+
* Arrival time of the earliest frame the in-order release gate holds for
|
|
324
|
+
* the stream, or undefined (optional; absent, the block's anchor bounds the
|
|
325
|
+
* ceiling alone). The gate releases that frame `terminalRetentionMsForPacket`
|
|
326
|
+
* after it, whatever its blocks are doing.
|
|
327
|
+
*/
|
|
328
|
+
earliestGatedFrameAtMs?(packetId: number, catalogTrackName?: string): number | undefined;
|
|
329
|
+
/** The keyframe budget extended a request's deadline by `extensionMs` (optional). */
|
|
330
|
+
noteKeyframeBudgetGranted?(extensionMs: number, sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
257
331
|
addRepairLifecycleObserver(observer: RepairLifecycleObserver): () => void;
|
|
258
332
|
addTrackResetObserver(observer: (packetId: number, catalogTrackName: string) => void): () => void;
|
|
259
333
|
clearRepairForBlock(sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
@@ -261,11 +335,21 @@ export interface RepairFetchHost {
|
|
|
261
335
|
noteRepairScheduling(type: 'repair-preempted' | 'repair-deferred', sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
262
336
|
/** A request whose wire priority the catalog could not supply. */
|
|
263
337
|
noteRepairPriority(action: 'omitted' | 'declined', reason: RepairPriorityReason, blockClass: BlockClass, sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
264
|
-
/**
|
|
338
|
+
/**
|
|
339
|
+
* A request the scheduler did not send (see RepairSkipReason).
|
|
340
|
+
* `measurement.priority` is the request's repair priority (0 keyframe or
|
|
341
|
+
* unknown, 1 audio, 2 delta).
|
|
342
|
+
*/
|
|
265
343
|
noteRepairSkipped(reason: RepairSkipReason, measurement: {
|
|
266
344
|
readonly rttMs: number | null;
|
|
267
345
|
readonly budgetMs: number;
|
|
346
|
+
readonly priority?: RepairPriority;
|
|
268
347
|
}, sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
348
|
+
/**
|
|
349
|
+
* A FETCH the scheduler admitted and handed to the transport (optional):
|
|
350
|
+
* every attempt, a retry or a reprioritised restart included.
|
|
351
|
+
*/
|
|
352
|
+
noteRepairFetchSent?(priority: RepairPriority, sbn: number, packetId: number, catalogTrackName?: string): void;
|
|
269
353
|
}
|
|
270
354
|
/**
|
|
271
355
|
* Wire the D-28 repair-fetch scheduler onto a MulticastManager.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repair-fetch.d.ts","sourceRoot":"","sources":["../src/repair-fetch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"repair-fetch.d.ts","sourceRoot":"","sources":["../src/repair-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AAEH,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,cAAc,EACp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IACP,kEAAkE;IAClE,kBAAkB,CAChB,MAAM,EAAE,SAAS,GAAG,UAAU,EAC9B,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,MAAM,GACxB,IAAI,CAAA;IACP;;;;OAIG;IACH,iBAAiB,CACf,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAE,EAC7G,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,MAAM,GACxB,IAAI,CAAA;IACP;;;OAGG;IACH,mBAAmB,CAAC,CAClB,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,MAAM,GACxB,IAAI,CAAA;CACR;AAiCD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAygB7F"}
|
package/dist/repair-fetch.js
CHANGED
|
@@ -24,6 +24,9 @@ function parseFecBlockProfile(value, where) {
|
|
|
24
24
|
throw new Error(`${where} must be "iso-ssbg1-v1" (got ${JSON.stringify(value)})`);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// ../mmt-base/dist/catalog-fec-source.js
|
|
28
|
+
var ALL_ROLES = Object.freeze(["video", "audio"]);
|
|
29
|
+
|
|
27
30
|
// src/block-policy.ts
|
|
28
31
|
import { deriveFecInterleaveDepth } from "@blockcast/mmt-fec";
|
|
29
32
|
function repairPriorityForClass(blockClass) {
|
|
@@ -59,6 +62,10 @@ function repairFetchSubscriberPriority(blockClass, target) {
|
|
|
59
62
|
if (!isMoqtPriority(repair)) return { kind: "decline", reason: "repair-priority-invalid" };
|
|
60
63
|
return { kind: "carry", subscriberPriority: Math.max(repair, REPAIR_PRIORITY_MIN) };
|
|
61
64
|
}
|
|
65
|
+
function keyframeBudgetEligible(blockClass, classifierMode) {
|
|
66
|
+
if (blockClass === "keyframe") return true;
|
|
67
|
+
return blockClass === "unknown" && classifierMode === "classifying";
|
|
68
|
+
}
|
|
62
69
|
function wireRepairFetch(mc, opts) {
|
|
63
70
|
if (!Number.isSafeInteger(opts.attemptLimit) || opts.attemptLimit < 1) {
|
|
64
71
|
throw new Error(
|
|
@@ -96,6 +103,16 @@ function wireRepairFetch(mc, opts) {
|
|
|
96
103
|
run.controller.abort();
|
|
97
104
|
if (reason === "preempted") releaseHold(entry);
|
|
98
105
|
};
|
|
106
|
+
const readKeyframeBudget = (packetId, catalogTrackName) => {
|
|
107
|
+
const reader = opts.keyframeRepairBudgetMs;
|
|
108
|
+
if (reader === void 0) return null;
|
|
109
|
+
try {
|
|
110
|
+
const budgetMs = reader(packetId, catalogTrackName);
|
|
111
|
+
return Number.isFinite(budgetMs) && budgetMs > 0 ? budgetMs : null;
|
|
112
|
+
} catch {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
99
116
|
const readRtt = () => {
|
|
100
117
|
try {
|
|
101
118
|
const rtt = opts.reliableRttMs();
|
|
@@ -113,7 +130,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
113
130
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
114
131
|
mc.noteRepairSkipped(
|
|
115
132
|
rttMs === null ? "rtt-unmeasured" : "rtt-exceeds-budget",
|
|
116
|
-
{ rttMs, budgetMs },
|
|
133
|
+
{ rttMs, budgetMs, priority: entry.priority },
|
|
117
134
|
entry.sbn,
|
|
118
135
|
entry.packetId,
|
|
119
136
|
entry.catalogTrackName
|
|
@@ -152,6 +169,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
152
169
|
const start = (entry, counted = true) => {
|
|
153
170
|
if (!admit(entry, performance.now())) return;
|
|
154
171
|
if (counted) entry.attempts++;
|
|
172
|
+
mc.noteRepairFetchSent?.(entry.priority, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
155
173
|
const run = { controller: new AbortController(), stopped: null };
|
|
156
174
|
entry.running = run;
|
|
157
175
|
mc.fecManager.holdBlockForRepair(
|
|
@@ -189,6 +207,25 @@ function wireRepairFetch(mc, opts) {
|
|
|
189
207
|
if (urgentOutstanding()) return;
|
|
190
208
|
queued.filter((entry) => entry.priority === 2).sort((a, b) => a.deadlineAt - b.deadlineAt || a.order - b.order).forEach((entry) => start(entry));
|
|
191
209
|
};
|
|
210
|
+
const symbolCounts = (sbn, packetId, catalogTrackName) => {
|
|
211
|
+
try {
|
|
212
|
+
return mc.fecManager.blockSymbolCounts?.(sbn, packetId, catalogTrackName);
|
|
213
|
+
} catch {
|
|
214
|
+
return void 0;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const decodable = (entry) => {
|
|
218
|
+
const counts = symbolCounts(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
219
|
+
if (counts === void 0 || counts.authoredLength === void 0) return true;
|
|
220
|
+
return counts.sources + counts.repairs >= counts.authoredLength;
|
|
221
|
+
};
|
|
222
|
+
const groupCanComplete = (sbn, packetId, catalogTrackName) => {
|
|
223
|
+
const counts = symbolCounts(sbn, packetId, catalogTrackName);
|
|
224
|
+
if (counts === void 0 || counts.authoredLength === void 0 || counts.repairGroupLength === void 0) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
return counts.sources + counts.repairGroupLength >= counts.authoredLength;
|
|
228
|
+
};
|
|
192
229
|
const finish = (entry, run, fed, error) => {
|
|
193
230
|
if (run.stopped !== null || entry.running !== run || entries.get(entry.key) !== entry) {
|
|
194
231
|
return;
|
|
@@ -196,7 +233,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
196
233
|
entry.running = null;
|
|
197
234
|
if (error === void 0) {
|
|
198
235
|
retire(entry);
|
|
199
|
-
if (fed === 0) {
|
|
236
|
+
if (fed === 0 || !decodable(entry)) {
|
|
200
237
|
releaseHold(entry);
|
|
201
238
|
clearRepair(entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
202
239
|
}
|
|
@@ -270,6 +307,17 @@ function wireRepairFetch(mc, opts) {
|
|
|
270
307
|
if (wire === null) return;
|
|
271
308
|
entry2.priority = promoted;
|
|
272
309
|
entry2.subscriberPriority = wire.subscriberPriority;
|
|
310
|
+
const promotedDeadline = presentationDeadlineAt(
|
|
311
|
+
entry2.sbn,
|
|
312
|
+
entry2.packetId,
|
|
313
|
+
entry2.catalogTrackName,
|
|
314
|
+
performance.now(),
|
|
315
|
+
event.to
|
|
316
|
+
);
|
|
317
|
+
if (promotedDeadline !== null && promotedDeadline.deadlineAt > entry2.deadlineAt) {
|
|
318
|
+
entry2.deadlineAt = promotedDeadline.deadlineAt;
|
|
319
|
+
noteBudget(entry2, promotedDeadline.extensionMs);
|
|
320
|
+
}
|
|
273
321
|
if (entry2.running) {
|
|
274
322
|
stop(entry2, "reprioritized");
|
|
275
323
|
start(entry2, false);
|
|
@@ -288,12 +336,12 @@ function wireRepairFetch(mc, opts) {
|
|
|
288
336
|
else if (entry.priority === 2 && entry.attempts === 0) note("repair-deferred", entry);
|
|
289
337
|
dispatch();
|
|
290
338
|
});
|
|
291
|
-
const presentationDeadlineAt = (sbn, packetId, catalogTrackName, now) => {
|
|
339
|
+
const presentationDeadlineAt = (sbn, packetId, catalogTrackName, now, blockClass) => {
|
|
292
340
|
const waitMs = mc.fecManager.repairFetchTimeoutMsForBlock(sbn, packetId, catalogTrackName);
|
|
293
341
|
if (waitMs === void 0) return null;
|
|
294
342
|
const waitDeadlineAt = now + waitMs;
|
|
295
343
|
const anchor = mc.fecManager.blockAnchorAtMs(sbn, packetId, catalogTrackName);
|
|
296
|
-
if (anchor === void 0) return waitDeadlineAt;
|
|
344
|
+
if (anchor === void 0) return { deadlineAt: waitDeadlineAt, extensionMs: 0 };
|
|
297
345
|
let delayMs;
|
|
298
346
|
try {
|
|
299
347
|
delayMs = opts.presentationDelayMs(packetId, catalogTrackName);
|
|
@@ -303,8 +351,31 @@ function wireRepairFetch(mc, opts) {
|
|
|
303
351
|
if (!(Number.isFinite(delayMs) && delayMs > 0)) return null;
|
|
304
352
|
const retentionMs = mc.fecManager.terminalRetentionMsForPacket(packetId);
|
|
305
353
|
if (retentionMs === void 0) return null;
|
|
306
|
-
const ceilingAt = anchor + retentionMs;
|
|
307
|
-
|
|
354
|
+
const ceilingAt = Math.min(anchor, earliestGatedFrameAt(packetId, catalogTrackName) ?? anchor) + retentionMs;
|
|
355
|
+
const deadlineAt = (delay) => Math.max(waitDeadlineAt, Math.min(anchor + delay, ceilingAt));
|
|
356
|
+
const base = deadlineAt(delayMs);
|
|
357
|
+
const budgetMs = keyframeBudgetEligible(blockClass, classifierMode(packetId, catalogTrackName)) && groupCanComplete(sbn, packetId, catalogTrackName) ? readKeyframeBudget(packetId, catalogTrackName) : null;
|
|
358
|
+
if (budgetMs === null || budgetMs <= delayMs) return { deadlineAt: base, extensionMs: 0 };
|
|
359
|
+
const extended = deadlineAt(budgetMs);
|
|
360
|
+
return { deadlineAt: extended, extensionMs: extended - base };
|
|
361
|
+
};
|
|
362
|
+
const earliestGatedFrameAt = (packetId, catalogTrackName) => {
|
|
363
|
+
try {
|
|
364
|
+
const at = mc.earliestGatedFrameAtMs?.(packetId, catalogTrackName);
|
|
365
|
+
return at !== void 0 && Number.isFinite(at) ? at : void 0;
|
|
366
|
+
} catch {
|
|
367
|
+
return void 0;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
const classifierMode = (packetId, catalogTrackName) => {
|
|
371
|
+
try {
|
|
372
|
+
return mc.fecManager.classifierModeFor?.(packetId, catalogTrackName).mode;
|
|
373
|
+
} catch {
|
|
374
|
+
return void 0;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
const noteBudget = (entry, extensionMs) => {
|
|
378
|
+
if (extensionMs > 0) mc.noteKeyframeBudgetGranted?.(extensionMs, entry.sbn, entry.packetId, entry.catalogTrackName);
|
|
308
379
|
};
|
|
309
380
|
mc.onRepairSubscribe((sbn, packetId, catalogTrackName, blockClass) => {
|
|
310
381
|
if (disposed) {
|
|
@@ -342,12 +413,13 @@ function wireRepairFetch(mc, opts) {
|
|
|
342
413
|
return;
|
|
343
414
|
}
|
|
344
415
|
const now = performance.now();
|
|
345
|
-
const
|
|
346
|
-
|
|
416
|
+
const priority = repairPriorityForClass(blockClass);
|
|
417
|
+
const deadline = presentationDeadlineAt(sbn, packetId, catalogTrackName, now, blockClass);
|
|
418
|
+
if (deadline === null) {
|
|
347
419
|
clearRepair(sbn, packetId, catalogTrackName);
|
|
348
420
|
mc.noteRepairSkipped(
|
|
349
421
|
"presentation-delay-unavailable",
|
|
350
|
-
{ rttMs: readRtt(), budgetMs: 0 },
|
|
422
|
+
{ rttMs: readRtt(), budgetMs: 0, priority },
|
|
351
423
|
sbn,
|
|
352
424
|
packetId,
|
|
353
425
|
catalogTrackName
|
|
@@ -359,14 +431,15 @@ function wireRepairFetch(mc, opts) {
|
|
|
359
431
|
...identity,
|
|
360
432
|
repairTrack: target.repairTrack,
|
|
361
433
|
blockProfile,
|
|
362
|
-
priority
|
|
434
|
+
priority,
|
|
363
435
|
subscriberPriority: wire.subscriberPriority,
|
|
364
|
-
deadlineAt,
|
|
436
|
+
deadlineAt: deadline.deadlineAt,
|
|
365
437
|
order: enqueueOrder++,
|
|
366
438
|
attempts: 0,
|
|
367
439
|
running: null
|
|
368
440
|
};
|
|
369
441
|
entries.set(key, entry);
|
|
442
|
+
noteBudget(entry, deadline.extensionMs);
|
|
370
443
|
if (entry.priority < 2) preemptDeltas();
|
|
371
444
|
dispatch();
|
|
372
445
|
});
|
|
@@ -384,6 +457,7 @@ function wireRepairFetch(mc, opts) {
|
|
|
384
457
|
}
|
|
385
458
|
export {
|
|
386
459
|
SOURCE_MEDIA_PRIORITY_MAX,
|
|
460
|
+
keyframeBudgetEligible,
|
|
387
461
|
repairFetchSubscriberPriority,
|
|
388
462
|
wireRepairFetch
|
|
389
463
|
};
|