mattebox 0.5.0 → 0.6.1
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/cdn/mattebox.dash-drm.min.js +3 -3
- package/dist/cdn/mattebox.dash.min.js +3 -3
- package/dist/cdn/mattebox.dual-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ts.min.js +3 -3
- package/dist/cdn/mattebox.dual.min.js +3 -3
- package/dist/cdn/mattebox.hls-drm.min.js +3 -3
- package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
- package/dist/cdn/mattebox.hls-ts.min.js +3 -3
- package/dist/cdn/mattebox.hls.min.js +3 -3
- package/dist/cdn/mattebox.kernel.min.js +1 -1
- package/dist/cdn/mattebox.min.js +4 -4
- package/dist/containers/mp4-box/index.d.ts +9 -7
- package/dist/containers/mp4-box/index.d.ts.map +1 -1
- package/dist/containers/mp4-box/index.js +20 -28
- package/dist/containers/mp4-box/index.js.map +1 -1
- package/dist/containers/packed-audio/index.d.ts.map +1 -1
- package/dist/containers/packed-audio/index.js +5 -1
- package/dist/containers/packed-audio/index.js.map +1 -1
- package/dist/containers/ts-transmux/index.d.ts.map +1 -1
- package/dist/containers/ts-transmux/index.js +2 -1
- package/dist/containers/ts-transmux/index.js.map +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/containers/id3.js +1 -1
- package/dist/es2015/containers/mp4-box/index.js +19 -22
- package/dist/es2015/containers/packed-audio/index.js +2 -5
- package/dist/es2015/containers/ts-transmux/h264.js +1 -1
- package/dist/es2015/containers/ts-transmux/index.js +3 -6
- package/dist/es2015/index.js +40 -27
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/context.js +7 -0
- package/dist/es2015/kernel/loader.js +5 -4
- package/dist/es2015/kernel/mse.js +48 -74
- package/dist/es2015/kernel/prepare.js +77 -0
- package/dist/es2015/kernel/reducer.js +284 -73
- package/dist/es2015/kernel/refresh.js +35 -0
- package/dist/es2015/kernel/rendition-select.js +62 -2
- package/dist/es2015/kernel/scheduler.js +23 -5
- package/dist/es2015/kernel/timeline.js +22 -1
- package/dist/es2015/kernel/trace.js +1 -1
- package/dist/es2015/kernel/transport.js +4 -4
- package/dist/es2015/presets/define.js +2 -2
- package/dist/es2015/presets/tiers.js +7 -6
- package/dist/es2015/protocols/dash-cmaf/index.js +136 -55
- package/dist/es2015/protocols/dash-cmaf/parse.js +2 -10
- package/dist/es2015/protocols/dash-live/index.js +88 -16
- package/dist/es2015/protocols/hls-cmaf/index.js +119 -71
- package/dist/es2015/protocols/hls-cmaf/parse.js +35 -25
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +42 -0
- package/dist/es2015/protocols/hls-live/index.js +221 -78
- package/dist/es2015/stages/abr/index.js +1 -1
- package/dist/es2015/stages/abr-persist/index.js +1 -1
- package/dist/es2015/stages/aes-128/index.js +1 -1
- package/dist/es2015/stages/alt-audio/index.js +1 -1
- package/dist/es2015/stages/cmaf-timing/index.js +24 -39
- package/dist/es2015/stages/cmcd/index.js +15 -2
- package/dist/es2015/stages/content-steering/index.js +30 -3
- package/dist/es2015/stages/eme-core/index.js +2 -2
- package/dist/es2015/stages/eme-fairplay/index.js +1 -1
- package/dist/es2015/stages/recovery/index.js +1 -1
- package/dist/es2015/stages/text-cea608/decode.js +1 -1
- package/dist/es2015/stages/text-webvtt/parse.js +1 -1
- package/dist/es2015/stages/thumbnails/index.js +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -32
- package/dist/index.js.map +1 -1
- package/dist/kernel/context.d.ts +5 -1
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/context.js +10 -0
- package/dist/kernel/context.js.map +1 -1
- package/dist/kernel/loader.d.ts.map +1 -1
- package/dist/kernel/loader.js +5 -7
- package/dist/kernel/loader.js.map +1 -1
- package/dist/kernel/mse.d.ts +6 -10
- package/dist/kernel/mse.d.ts.map +1 -1
- package/dist/kernel/mse.js +45 -76
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/prepare.d.ts +28 -0
- package/dist/kernel/prepare.d.ts.map +1 -0
- package/dist/kernel/prepare.js +89 -0
- package/dist/kernel/prepare.js.map +1 -0
- package/dist/kernel/reducer.d.ts +15 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +399 -88
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/refresh.d.ts +14 -0
- package/dist/kernel/refresh.d.ts.map +1 -0
- package/dist/kernel/refresh.js +50 -0
- package/dist/kernel/refresh.js.map +1 -0
- package/dist/kernel/rendition-select.d.ts +19 -1
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +69 -0
- package/dist/kernel/rendition-select.js.map +1 -1
- package/dist/kernel/scheduler.d.ts +18 -3
- package/dist/kernel/scheduler.d.ts.map +1 -1
- package/dist/kernel/scheduler.js +32 -7
- package/dist/kernel/scheduler.js.map +1 -1
- package/dist/kernel/timeline.d.ts +18 -6
- package/dist/kernel/timeline.d.ts.map +1 -1
- package/dist/kernel/timeline.js +19 -5
- package/dist/kernel/timeline.js.map +1 -1
- package/dist/kernel/transport.d.ts.map +1 -1
- package/dist/kernel/transport.js +1 -0
- package/dist/kernel/transport.js.map +1 -1
- package/dist/presets/tiers.d.ts +7 -6
- package/dist/presets/tiers.d.ts.map +1 -1
- package/dist/presets/tiers.js +7 -6
- package/dist/presets/tiers.js.map +1 -1
- package/dist/protocols/dash-cmaf/index.d.ts +2 -2
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +166 -55
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-live/index.d.ts.map +1 -1
- package/dist/protocols/dash-live/index.js +83 -11
- package/dist/protocols/dash-live/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/index.d.ts +3 -2
- package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/index.js +140 -82
- package/dist/protocols/hls-cmaf/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts +9 -5
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +50 -47
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts +17 -0
- package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -0
- package/dist/protocols/hls-cmaf/unavailable.js +36 -0
- package/dist/protocols/hls-cmaf/unavailable.js.map +1 -0
- package/dist/protocols/hls-live/index.d.ts +17 -0
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js +239 -76
- package/dist/protocols/hls-live/index.js.map +1 -1
- package/dist/stages/aes-128/index.js +2 -2
- package/dist/stages/aes-128/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +5 -3
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/cmaf-timing/index.d.ts.map +1 -1
- package/dist/stages/cmaf-timing/index.js +33 -42
- package/dist/stages/cmaf-timing/index.js.map +1 -1
- package/dist/stages/cmcd/index.d.ts.map +1 -1
- package/dist/stages/cmcd/index.js +15 -3
- package/dist/stages/cmcd/index.js.map +1 -1
- package/dist/stages/content-steering/index.d.ts.map +1 -1
- package/dist/stages/content-steering/index.js +23 -1
- package/dist/stages/content-steering/index.js.map +1 -1
- package/dist/types/facade.d.ts +12 -0
- package/dist/types/facade.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +54 -15
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js +2 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +58 -10
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/stage.d.ts +18 -0
- package/dist/types/stage.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { normalizeMimeType } from "./mime.js";
|
|
3
|
-
import {
|
|
3
|
+
import { applyRefresh } from "./refresh.js";
|
|
4
|
+
import { reconciledOffset, segmentAtTime } from "./timeline.js";
|
|
4
5
|
import { bufferedEndFrom, schedule } from "./scheduler.js";
|
|
5
|
-
import { canSwitchTo, codecFamily, createArbiter, planPinApply } from "./rendition-select.js";
|
|
6
|
+
import { canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
|
|
6
7
|
import { sbIdFor } from "./sinks/mse-sink.js";
|
|
7
|
-
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.
|
|
8
|
+
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectWithoutProperties.js";
|
|
8
9
|
//#region src/kernel/reducer.ts
|
|
9
|
-
const _excluded = ["
|
|
10
|
-
const _excluded2 = ["
|
|
10
|
+
const _excluded = ["pendingInit"];
|
|
11
|
+
const _excluded2 = ["repeat"];
|
|
12
|
+
const _excluded3 = ["appended"];
|
|
13
|
+
const _excluded4 = ["initFor"];
|
|
11
14
|
/**
|
|
12
15
|
* The default tuning. Every value is overridable through the `config`
|
|
13
16
|
* parameters of `initialState` and `createReducer`; these are starting
|
|
@@ -23,8 +26,7 @@ const DEFAULT_KERNEL_CONFIG = {
|
|
|
23
26
|
bufferGoalSeconds: 30,
|
|
24
27
|
manifestTimeoutMs: 1e4,
|
|
25
28
|
traceCapacity: 0,
|
|
26
|
-
baseRetryDelayMs: 400
|
|
27
|
-
mediaTimeNormalized: false
|
|
29
|
+
baseRetryDelayMs: 400
|
|
28
30
|
};
|
|
29
31
|
function resolveConfig(config) {
|
|
30
32
|
return _objectSpread2(_objectSpread2({}, DEFAULT_KERNEL_CONFIG), config);
|
|
@@ -36,7 +38,8 @@ function initialState(config) {
|
|
|
36
38
|
presentation: null,
|
|
37
39
|
timeline: {
|
|
38
40
|
periodOffsets: /* @__PURE__ */ new Map(),
|
|
39
|
-
discontinuitySeq: 0
|
|
41
|
+
discontinuitySeq: 0,
|
|
42
|
+
reconciled: /* @__PURE__ */ new Map()
|
|
40
43
|
},
|
|
41
44
|
buffers: /* @__PURE__ */ new Map(),
|
|
42
45
|
bufferErrors: /* @__PURE__ */ new Map(),
|
|
@@ -71,6 +74,19 @@ function initialState(config) {
|
|
|
71
74
|
}
|
|
72
75
|
/** Gap width treated as continuous when measuring buffered spans. */
|
|
73
76
|
const GAP_TOLERANCE = .25;
|
|
77
|
+
/** Drops one buffer's held init. */
|
|
78
|
+
function withoutPendingInit(pending, sbId) {
|
|
79
|
+
if (pending === void 0 || !pending.has(sbId)) return pending;
|
|
80
|
+
const next = new Map(pending);
|
|
81
|
+
next.delete(sbId);
|
|
82
|
+
return next.size === 0 ? void 0 : next;
|
|
83
|
+
}
|
|
84
|
+
/** Writes held inits back into a scheduling slice; the field stays absent while empty. */
|
|
85
|
+
function withPendingInit(scheduling, pending) {
|
|
86
|
+
if (pending !== void 0 && pending.size > 0) return _objectSpread2(_objectSpread2({}, scheduling), {}, { pendingInit: pending });
|
|
87
|
+
const { pendingInit: _pendingInit } = scheduling;
|
|
88
|
+
return _objectWithoutProperties(scheduling, _excluded);
|
|
89
|
+
}
|
|
74
90
|
/** The codecs part of an MSE type string ('video/mp4; codecs="avc1.42c00d"' -> 'avc1.42c00d'). */
|
|
75
91
|
function bufferCodecString(type) {
|
|
76
92
|
var _match$;
|
|
@@ -123,7 +139,7 @@ function bumped(quality) {
|
|
|
123
139
|
function clearRepeat(scheduling) {
|
|
124
140
|
if (scheduling.repeat === void 0) return scheduling;
|
|
125
141
|
const { repeat: _repeat } = scheduling;
|
|
126
|
-
return _objectWithoutProperties(scheduling,
|
|
142
|
+
return _objectWithoutProperties(scheduling, _excluded2);
|
|
127
143
|
}
|
|
128
144
|
function ewma(previous, sample, alpha) {
|
|
129
145
|
return previous === 0 ? sample : alpha * sample + (1 - alpha) * previous;
|
|
@@ -152,6 +168,61 @@ function mergeCoverage(coverage, added) {
|
|
|
152
168
|
merged.push(pending);
|
|
153
169
|
return merged.sort((a, b) => a.start - b.start);
|
|
154
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* The spans `before` holds and `after` does not. Browsers round the ranges
|
|
173
|
+
* they report, so a loss narrower than the gap tolerance is that rounding.
|
|
174
|
+
*/
|
|
175
|
+
function lostSpans(before, after) {
|
|
176
|
+
const held = [...after].sort((a, b) => a.start - b.start);
|
|
177
|
+
const lost = [];
|
|
178
|
+
for (const range of before) {
|
|
179
|
+
let cursor = range.start;
|
|
180
|
+
for (const kept of held) {
|
|
181
|
+
if (kept.end <= cursor) continue;
|
|
182
|
+
if (kept.start >= range.end) break;
|
|
183
|
+
if (kept.start - cursor >= GAP_TOLERANCE) lost.push({
|
|
184
|
+
start: cursor,
|
|
185
|
+
end: kept.start
|
|
186
|
+
});
|
|
187
|
+
cursor = kept.end;
|
|
188
|
+
}
|
|
189
|
+
if (range.end - cursor >= GAP_TOLERANCE) lost.push({
|
|
190
|
+
start: cursor,
|
|
191
|
+
end: range.end
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return lost;
|
|
195
|
+
}
|
|
196
|
+
/** The buffers without what they remember receiving: one buffer, or all of them. */
|
|
197
|
+
function forgetAppended(buffers, only) {
|
|
198
|
+
const next = new Map(buffers);
|
|
199
|
+
for (const [sbId, buffer] of buffers) {
|
|
200
|
+
if (buffer.appended === void 0 || only !== void 0 && sbId !== only) continue;
|
|
201
|
+
const { appended: _appended } = buffer, rest = _objectWithoutProperties(buffer, _excluded3);
|
|
202
|
+
next.set(sbId, rest);
|
|
203
|
+
}
|
|
204
|
+
return next;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The buffers after the flushes among `effects`. A flush is an unbounded
|
|
208
|
+
* remove, and it forgets every segment that ends past its start: the next
|
|
209
|
+
* append there starts a new run, so a segment that left nothing the first
|
|
210
|
+
* time can land whole the second time. Lost content cannot say this, a
|
|
211
|
+
* segment that left nothing has none to lose. A bounded remove is eviction
|
|
212
|
+
* and reports through its updateend.
|
|
213
|
+
*/
|
|
214
|
+
function forgetFlushed(buffers, effects) {
|
|
215
|
+
let next = buffers;
|
|
216
|
+
for (const effect of effects) {
|
|
217
|
+
if (effect.kind !== "remove" || effect.end !== Number.POSITIVE_INFINITY) continue;
|
|
218
|
+
const buffer = next.get(effect.sbId);
|
|
219
|
+
if ((buffer === null || buffer === void 0 ? void 0 : buffer.appended) === void 0) continue;
|
|
220
|
+
const appended = buffer.appended.filter((seg) => seg.end <= effect.start);
|
|
221
|
+
if (appended.length === buffer.appended.length) continue;
|
|
222
|
+
next = new Map(next).set(effect.sbId, _objectSpread2(_objectSpread2({}, buffer), {}, { appended }));
|
|
223
|
+
}
|
|
224
|
+
return next;
|
|
225
|
+
}
|
|
155
226
|
function findTrack(presentation, trackId) {
|
|
156
227
|
if (presentation === null) return null;
|
|
157
228
|
for (const period of presentation.periods) for (const track of period.tracks) if (track.id === trackId) return track;
|
|
@@ -273,6 +344,17 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
273
344
|
...reset
|
|
274
345
|
]];
|
|
275
346
|
}
|
|
347
|
+
case "SUSPEND": {
|
|
348
|
+
if (state.lifecycle.phase !== "ready") return reject(state, msg.type, "not ready");
|
|
349
|
+
const [next, aborts] = abortInflight(state);
|
|
350
|
+
return [_objectSpread2(_objectSpread2({}, next), {}, {
|
|
351
|
+
lifecycle: { phase: "suspended" },
|
|
352
|
+
live: null
|
|
353
|
+
}), aborts];
|
|
354
|
+
}
|
|
355
|
+
case "RESUME":
|
|
356
|
+
if (state.lifecycle.phase !== "suspended") return reject(state, msg.type, "not suspended");
|
|
357
|
+
return driveScheduling(_objectSpread2(_objectSpread2({}, state), {}, { lifecycle: { phase: "ready" } }), hooks, cfg);
|
|
276
358
|
case "SEEK": {
|
|
277
359
|
if (state.presentation === null) return reject(state, msg.type, "no source");
|
|
278
360
|
const [next, aborts] = abortInflight(state);
|
|
@@ -292,9 +374,11 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
292
374
|
}]];
|
|
293
375
|
}
|
|
294
376
|
case "SELECT_TRACK": {
|
|
295
|
-
var _segmentedAt, _previousTrack$rendit;
|
|
377
|
+
var _state$quality$constr, _state$quality$constr2, _segmentedAt, _previousTrack$rendit;
|
|
296
378
|
const track = findTrack(state.presentation, msg.trackId);
|
|
297
379
|
if (track === null) return reject(state, msg.type, `unknown track: ${msg.trackId}`);
|
|
380
|
+
const undecodableIds = (_state$quality$constr = (_state$quality$constr2 = state.quality.constraints.get(CODECS)) === null || _state$quality$constr2 === void 0 ? void 0 : _state$quality$constr2.excludeIds) !== null && _state$quality$constr !== void 0 ? _state$quality$constr : [];
|
|
381
|
+
if (track.renditions.length > 0 && track.renditions.every((r) => undecodableIds.includes(r.id))) return reject(state, msg.type, `undecodable track: ${msg.trackId}`);
|
|
298
382
|
const previous = state.tracks.active.get(track.contentType);
|
|
299
383
|
const active = new Map(state.tracks.active);
|
|
300
384
|
active.set(track.contentType, track.id);
|
|
@@ -322,7 +406,7 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
322
406
|
});
|
|
323
407
|
for (const effect of plan.effects) if (effect.kind !== "seekElement" || track.contentType === "video") effects.push(effect);
|
|
324
408
|
const next = new Map(state.buffers);
|
|
325
|
-
const { initFor: _initFor } = buffer, rest = _objectWithoutProperties(buffer,
|
|
409
|
+
const { initFor: _initFor } = buffer, rest = _objectWithoutProperties(buffer, _excluded4);
|
|
326
410
|
next.set(sbId, rest);
|
|
327
411
|
buffers = next;
|
|
328
412
|
const pruned = new Map(state.scheduling.inflight);
|
|
@@ -438,51 +522,105 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
438
522
|
case "ABORT_INFLIGHT": return abortInflight(state, msg.trackId);
|
|
439
523
|
}
|
|
440
524
|
}
|
|
525
|
+
/** The constraint source for renditions this browser cannot decode. */
|
|
526
|
+
const CODECS = "codecs";
|
|
527
|
+
/**
|
|
528
|
+
* The renditions this browser cannot play: a declared codec it does not
|
|
529
|
+
* decode, and a video variant whose audio group it cannot decode at all.
|
|
530
|
+
* VHS drops these when the manifest loads; left in, ABR climbs onto one and
|
|
531
|
+
* its buffer fails to open or to append. A rendition that declares no
|
|
532
|
+
* codec counts as decodable.
|
|
533
|
+
*/
|
|
534
|
+
function undecodable(presentation, decodable) {
|
|
535
|
+
const out = /* @__PURE__ */ new Set();
|
|
536
|
+
for (const period of presentation.periods) for (const track of period.tracks) {
|
|
537
|
+
if (track.contentType !== "video" && track.contentType !== "audio") continue;
|
|
538
|
+
for (const r of track.renditions) if (r.codecs !== null && !decodable(`${r.mimeType}; codecs="${r.codecs}"`)) out.add(r.id);
|
|
539
|
+
}
|
|
540
|
+
return withDeadGroups(presentation, out);
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* A presentation replaces the one held: a manifest landed, or a playlist
|
|
544
|
+
* merged into it. Activates default tracks and reports what changed.
|
|
545
|
+
*/
|
|
546
|
+
function loadPresentation(state, presentation, undecodableIds = /* @__PURE__ */ new Set()) {
|
|
547
|
+
const available = [];
|
|
548
|
+
for (const period of presentation.periods) for (const track of period.tracks) available.push(track.id);
|
|
549
|
+
const inflight = new Map(state.scheduling.inflight);
|
|
550
|
+
for (const [token, request] of inflight) if (request.trackId === "manifest") inflight.delete(token);
|
|
551
|
+
const phase = state.lifecycle.phase === "loading" ? "ready" : state.lifecycle.phase;
|
|
552
|
+
const active = new Map(state.tracks.active);
|
|
553
|
+
for (const period of presentation.periods) for (const track of period.tracks) if ((track.contentType === "video" || track.contentType === "audio") && !active.has(track.contentType) && track.renditions.some((r) => !undecodableIds.has(r.id))) active.set(track.contentType, track.id);
|
|
554
|
+
const loaded = _objectSpread2(_objectSpread2({}, state), {}, {
|
|
555
|
+
lifecycle: { phase },
|
|
556
|
+
presentation,
|
|
557
|
+
scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }),
|
|
558
|
+
tracks: {
|
|
559
|
+
active,
|
|
560
|
+
available
|
|
561
|
+
},
|
|
562
|
+
quality: bumped(state.quality)
|
|
563
|
+
});
|
|
564
|
+
const manifestEffects = available.length === state.tracks.available.length && available.every((id, index) => id === state.tracks.available[index]) ? [] : [{
|
|
565
|
+
kind: "emit",
|
|
566
|
+
event: "tracks:changed",
|
|
567
|
+
payload: { available }
|
|
568
|
+
}];
|
|
569
|
+
const schemes = presentation.periods.flatMap((period) => period.tracks.flatMap((track) => {
|
|
570
|
+
var _track$protection$sch, _track$protection;
|
|
571
|
+
return (_track$protection$sch = (_track$protection = track.protection) === null || _track$protection === void 0 ? void 0 : _track$protection.schemes) !== null && _track$protection$sch !== void 0 ? _track$protection$sch : [];
|
|
572
|
+
}));
|
|
573
|
+
if (schemes.length > 0) manifestEffects.push({
|
|
574
|
+
kind: "emit",
|
|
575
|
+
event: "presentation:protection",
|
|
576
|
+
payload: schemes
|
|
577
|
+
});
|
|
578
|
+
if (!presentation.isLive && presentation.duration !== void 0) manifestEffects.push({
|
|
579
|
+
kind: "setDuration",
|
|
580
|
+
seconds: presentation.duration
|
|
581
|
+
});
|
|
582
|
+
return [loaded, manifestEffects];
|
|
583
|
+
}
|
|
441
584
|
function reduceFact(state, msg, cfg, hooks) {
|
|
442
585
|
switch (msg.type) {
|
|
443
586
|
case "ELEMENT_ATTACHED":
|
|
444
587
|
case "MEDIASOURCE_OPEN":
|
|
445
588
|
case "MEDIASOURCE_CLOSED": return [state, []];
|
|
446
589
|
case "MANIFEST_LOADED": {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}];
|
|
469
|
-
const schemes = msg.presentation.periods.flatMap((period) => period.tracks.flatMap((track) => {
|
|
470
|
-
var _track$protection$sch, _track$protection;
|
|
471
|
-
return (_track$protection$sch = (_track$protection = track.protection) === null || _track$protection === void 0 ? void 0 : _track$protection.schemes) !== null && _track$protection$sch !== void 0 ? _track$protection$sch : [];
|
|
472
|
-
}));
|
|
473
|
-
if (schemes.length > 0) manifestEffects.push({
|
|
474
|
-
kind: "emit",
|
|
475
|
-
event: "presentation:protection",
|
|
476
|
-
payload: schemes
|
|
477
|
-
});
|
|
478
|
-
if (!msg.presentation.isLive && msg.presentation.duration !== void 0) manifestEffects.push({
|
|
479
|
-
kind: "setDuration",
|
|
480
|
-
seconds: msg.presentation.duration
|
|
481
|
-
});
|
|
482
|
-
return [loaded, manifestEffects];
|
|
590
|
+
if (hooks.decodable === void 0) return loadPresentation(state, msg.presentation);
|
|
591
|
+
const excluded = undecodable(msg.presentation, hooks.decodable);
|
|
592
|
+
const tracks = msg.presentation.periods.flatMap((period) => period.tracks);
|
|
593
|
+
const lead = ["video", "audio"].find((c) => tracks.some((t) => t.contentType === c));
|
|
594
|
+
if (lead !== void 0 && !tracks.some((t) => t.contentType === lead && t.renditions.some((r) => !excluded.has(r.id)))) {
|
|
595
|
+
const codecs = new Set(tracks.flatMap((t) => t.renditions.map((r) => {
|
|
596
|
+
var _r$codecs;
|
|
597
|
+
return (_r$codecs = r.codecs) !== null && _r$codecs !== void 0 ? _r$codecs : "";
|
|
598
|
+
})));
|
|
599
|
+
codecs.delete("");
|
|
600
|
+
return failManifest(state, {
|
|
601
|
+
category: "media",
|
|
602
|
+
code: "MEDIA_CODEC_UNSUPPORTED",
|
|
603
|
+
fatal: true,
|
|
604
|
+
recoverable: false
|
|
605
|
+
}, { codecs: [...codecs] });
|
|
606
|
+
}
|
|
607
|
+
const constraints = new Map(state.quality.constraints);
|
|
608
|
+
if (excluded.size > 0) constraints.set(CODECS, { excludeIds: [...excluded] });
|
|
609
|
+
else constraints.delete(CODECS);
|
|
610
|
+
return loadPresentation(_objectSpread2(_objectSpread2({}, state), {}, { quality: _objectSpread2(_objectSpread2({}, state.quality), {}, { constraints }) }), msg.presentation, excluded);
|
|
483
611
|
}
|
|
484
612
|
case "MANIFEST_FAILED": return failManifest(state, msg.error);
|
|
485
|
-
case "PLAYLIST_REFRESHED":
|
|
613
|
+
case "PLAYLIST_REFRESHED": {
|
|
614
|
+
const merged = state.presentation === null ? null : applyRefresh(state.presentation, msg);
|
|
615
|
+
if (merged === null) return [state, []];
|
|
616
|
+
return loadPresentation(state, merged);
|
|
617
|
+
}
|
|
618
|
+
case "MEDIA_ERROR": {
|
|
619
|
+
if (state.lifecycle.phase === "error") return [state, []];
|
|
620
|
+
const [stopped, aborts] = abortInflight(state);
|
|
621
|
+
const [failed, report] = failManifest(stopped, _objectSpread2(_objectSpread2({}, msg.error), {}, { fatal: true }), { context: msg.error.context });
|
|
622
|
+
return [failed, [...aborts, ...report]];
|
|
623
|
+
}
|
|
486
624
|
case "SEGMENT_LOADED": {
|
|
487
625
|
let matched = null;
|
|
488
626
|
if (msg.token !== void 0) {
|
|
@@ -501,6 +639,7 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
501
639
|
throughputFastEwma: ewma(state.stats.throughputFastEwma, sampleBps, cfg.ewmaFastAlpha)
|
|
502
640
|
};
|
|
503
641
|
let buffers = state.buffers;
|
|
642
|
+
let pendingInit = state.scheduling.pendingInit;
|
|
504
643
|
let timeline = state.timeline;
|
|
505
644
|
let quality = state.quality;
|
|
506
645
|
let cues = state.cues;
|
|
@@ -552,11 +691,15 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
552
691
|
codecs: targetCodecs
|
|
553
692
|
}));
|
|
554
693
|
buffers = nextBuffers;
|
|
694
|
+
pendingInit = withoutPendingInit(pendingInit, matched.sbId);
|
|
695
|
+
} else {
|
|
696
|
+
var _pendingInit2;
|
|
697
|
+
pendingInit = new Map((_pendingInit2 = pendingInit) !== null && _pendingInit2 !== void 0 ? _pendingInit2 : []).set(matched.sbId, matched.renditionId);
|
|
555
698
|
}
|
|
556
699
|
}
|
|
557
700
|
const initFor = (_buffers$get = buffers.get(matched.sbId)) === null || _buffers$get === void 0 ? void 0 : _buffers$get.initFor;
|
|
558
701
|
if (matched.seq >= 0 && matched.renditionId !== void 0 && initFor !== void 0 && initFor !== matched.renditionId) return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
559
|
-
scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }),
|
|
702
|
+
scheduling: withPendingInit(_objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }), pendingInit),
|
|
560
703
|
stats,
|
|
561
704
|
buffers,
|
|
562
705
|
cues
|
|
@@ -569,33 +712,58 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
569
712
|
initFor
|
|
570
713
|
}
|
|
571
714
|
}]];
|
|
572
|
-
|
|
715
|
+
let reconciled = state.timeline.reconciled;
|
|
716
|
+
let offset = matched.epoch === void 0 ? void 0 : reconciled.get(matched.epoch);
|
|
717
|
+
if (offset === void 0 && matched.epoch !== void 0 && matched.seq >= 0 && matched.segmentStart !== void 0) {
|
|
718
|
+
const settled = msg.mediaStart !== void 0 ? reconciledOffset(matched.segmentStart, msg.mediaStart) : matched.timestampOffset;
|
|
719
|
+
if (settled !== void 0) {
|
|
720
|
+
offset = settled;
|
|
721
|
+
reconciled = new Map(reconciled).set(matched.epoch, settled);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (offset === void 0) offset = matched.timestampOffset;
|
|
725
|
+
let periodOffsets = state.timeline.periodOffsets;
|
|
726
|
+
if (offset !== void 0 && periodOffsets.get(matched.sbId) !== offset) {
|
|
573
727
|
effects.push({
|
|
574
728
|
kind: "setTimestampOffset",
|
|
575
729
|
sbId: matched.sbId,
|
|
576
|
-
offset
|
|
730
|
+
offset
|
|
577
731
|
});
|
|
578
|
-
|
|
579
|
-
periodOffsets.set(matched.sbId, matched.timestampOffset);
|
|
580
|
-
timeline = _objectSpread2(_objectSpread2({}, state.timeline), {}, { periodOffsets });
|
|
732
|
+
periodOffsets = new Map(periodOffsets).set(matched.sbId, offset);
|
|
581
733
|
}
|
|
582
|
-
|
|
734
|
+
if (periodOffsets !== state.timeline.periodOffsets || reconciled !== state.timeline.reconciled) timeline = _objectSpread2(_objectSpread2({}, state.timeline), {}, {
|
|
735
|
+
periodOffsets,
|
|
736
|
+
reconciled
|
|
737
|
+
});
|
|
738
|
+
effects.push({
|
|
583
739
|
kind: "append",
|
|
584
740
|
sbId: matched.sbId,
|
|
585
741
|
data: msg.bytes
|
|
586
|
-
}
|
|
742
|
+
});
|
|
587
743
|
const buffer = buffers.get(matched.sbId);
|
|
588
744
|
if (buffer !== void 0) {
|
|
589
745
|
const nextBuffers = new Map(buffers);
|
|
590
|
-
|
|
746
|
+
let appended = buffer.appended;
|
|
747
|
+
const { renditionId, seq, segmentStart } = matched;
|
|
748
|
+
if (seq >= 0 && renditionId !== void 0 && segmentStart !== void 0) {
|
|
749
|
+
var _matched$segmentDurat3, _appended2;
|
|
750
|
+
const entry = {
|
|
751
|
+
renditionId,
|
|
752
|
+
seq,
|
|
753
|
+
start: segmentStart,
|
|
754
|
+
end: segmentStart + ((_matched$segmentDurat3 = matched.segmentDuration) !== null && _matched$segmentDurat3 !== void 0 ? _matched$segmentDurat3 : 0)
|
|
755
|
+
};
|
|
756
|
+
appended = [...((_appended2 = appended) !== null && _appended2 !== void 0 ? _appended2 : []).filter((seg) => seg.seq !== seq || seg.renditionId !== renditionId).slice(-31), entry];
|
|
757
|
+
}
|
|
758
|
+
nextBuffers.set(matched.sbId, _objectSpread2(_objectSpread2({}, buffer), {}, { pendingAppends: buffer.pendingAppends + 1 }, appended !== void 0 ? { appended } : {}));
|
|
591
759
|
buffers = nextBuffers;
|
|
592
760
|
}
|
|
593
761
|
if (matched.sbId === sbIdFor("video") && matched.renditionId !== void 0 && matched.segmentStart !== void 0) {
|
|
594
|
-
var _matched$
|
|
762
|
+
var _matched$segmentDurat4;
|
|
595
763
|
const watermark = state.playback.currentTime - cfg.backBufferSeconds;
|
|
596
764
|
const appendLog = [...state.quality.appendLog.filter(([range]) => range.end > watermark), [{
|
|
597
765
|
start: matched.segmentStart,
|
|
598
|
-
end: matched.segmentStart + ((_matched$
|
|
766
|
+
end: matched.segmentStart + ((_matched$segmentDurat4 = matched.segmentDuration) !== null && _matched$segmentDurat4 !== void 0 ? _matched$segmentDurat4 : 0)
|
|
599
767
|
}, matched.renditionId]];
|
|
600
768
|
quality = _objectSpread2(_objectSpread2({}, quality), {}, { appendLog });
|
|
601
769
|
}
|
|
@@ -605,7 +773,7 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
605
773
|
timeline,
|
|
606
774
|
quality,
|
|
607
775
|
cues,
|
|
608
|
-
scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }),
|
|
776
|
+
scheduling: withPendingInit(_objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }), pendingInit),
|
|
609
777
|
stats
|
|
610
778
|
}), effects];
|
|
611
779
|
}
|
|
@@ -664,19 +832,30 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
664
832
|
}), failEffects];
|
|
665
833
|
}
|
|
666
834
|
case "SOURCEBUFFER_CREATED": {
|
|
835
|
+
var _state$scheduling$pen;
|
|
667
836
|
const buffers = new Map(state.buffers);
|
|
668
|
-
|
|
837
|
+
const held = (_state$scheduling$pen = state.scheduling.pendingInit) === null || _state$scheduling$pen === void 0 ? void 0 : _state$scheduling$pen.get(msg.sbId);
|
|
838
|
+
buffers.set(msg.sbId, _objectSpread2({
|
|
669
839
|
codecs: msg.codecs,
|
|
670
840
|
ranges: [],
|
|
671
841
|
pendingAppends: 0
|
|
672
|
-
});
|
|
673
|
-
|
|
842
|
+
}, held !== void 0 ? { initFor: held } : {}));
|
|
843
|
+
const scheduling = withPendingInit(state.scheduling, withoutPendingInit(state.scheduling.pendingInit, msg.sbId));
|
|
844
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
845
|
+
buffers,
|
|
846
|
+
scheduling
|
|
847
|
+
}), []];
|
|
674
848
|
}
|
|
675
849
|
case "SOURCEBUFFER_UPDATEEND": {
|
|
676
850
|
const buffer = state.buffers.get(msg.sbId);
|
|
677
851
|
if (buffer === void 0) return [state, []];
|
|
852
|
+
let appended = buffer.appended;
|
|
853
|
+
if (appended !== void 0 && msg.ranges !== void 0) {
|
|
854
|
+
const lost = lostSpans(buffer.ranges, msg.ranges);
|
|
855
|
+
if (lost.length > 0) appended = appended.filter((seg) => !lost.some((span) => span.start <= seg.end && span.end >= seg.start));
|
|
856
|
+
}
|
|
678
857
|
const buffers = new Map(state.buffers);
|
|
679
|
-
buffers.set(msg.sbId, _objectSpread2(_objectSpread2(_objectSpread2({}, buffer), msg.ranges !== void 0 ? { ranges: msg.ranges } : {}), {}, { pendingAppends: Math.max(0, buffer.pendingAppends - 1) }));
|
|
858
|
+
buffers.set(msg.sbId, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, buffer), msg.ranges !== void 0 ? { ranges: msg.ranges } : {}), appended !== void 0 ? { appended } : {}), {}, { pendingAppends: Math.max(0, buffer.pendingAppends - 1) }));
|
|
680
859
|
let bufferErrors = state.bufferErrors;
|
|
681
860
|
if (bufferErrors.has(msg.sbId)) {
|
|
682
861
|
bufferErrors = new Map(bufferErrors);
|
|
@@ -692,8 +871,13 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
692
871
|
const count = ((_state$bufferErrors$g = state.bufferErrors.get(msg.sbId)) !== null && _state$bufferErrors$g !== void 0 ? _state$bufferErrors$g : 0) + 1;
|
|
693
872
|
const bufferErrors = new Map(state.bufferErrors);
|
|
694
873
|
bufferErrors.set(msg.sbId, count);
|
|
874
|
+
const scheduling = withPendingInit(state.scheduling, withoutPendingInit(state.scheduling.pendingInit, msg.sbId));
|
|
875
|
+
let buffers = forgetAppended(state.buffers, msg.sbId);
|
|
695
876
|
const fatal = msg.error.fatal || count >= cfg.bufferErrorLimit;
|
|
696
877
|
const phase = fatal ? "error" : state.lifecycle.phase;
|
|
878
|
+
const neverAppended = msg.error.code === "MEDIA_CONTAINER_INVALID";
|
|
879
|
+
const waiting = buffers.get(msg.sbId);
|
|
880
|
+
if (neverAppended && waiting !== void 0 && waiting.pendingAppends > 0) buffers = new Map(buffers).set(msg.sbId, _objectSpread2(_objectSpread2({}, waiting), {}, { pendingAppends: waiting.pendingAppends - 1 }));
|
|
697
881
|
const effects = [{
|
|
698
882
|
kind: "emit",
|
|
699
883
|
event: "error",
|
|
@@ -705,6 +889,15 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
705
889
|
sbId: msg.sbId
|
|
706
890
|
}, fatal && !msg.error.fatal ? { consecutiveFailures: count } : {})
|
|
707
891
|
}];
|
|
892
|
+
if (neverAppended && !fatal) effects.push({
|
|
893
|
+
kind: "schedule",
|
|
894
|
+
token: "kernel:retry",
|
|
895
|
+
delayMs: cfg.baseRetryDelayMs,
|
|
896
|
+
then: {
|
|
897
|
+
type: "TICK",
|
|
898
|
+
token: "kernel:retry"
|
|
899
|
+
}
|
|
900
|
+
});
|
|
708
901
|
let inflight = state.scheduling.inflight;
|
|
709
902
|
if (fatal) {
|
|
710
903
|
const pruned = new Map(state.scheduling.inflight);
|
|
@@ -718,9 +911,10 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
718
911
|
inflight = pruned;
|
|
719
912
|
}
|
|
720
913
|
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
914
|
+
buffers,
|
|
721
915
|
bufferErrors,
|
|
722
916
|
lifecycle: { phase },
|
|
723
|
-
scheduling: _objectSpread2(_objectSpread2({},
|
|
917
|
+
scheduling: _objectSpread2(_objectSpread2({}, scheduling), {}, { inflight })
|
|
724
918
|
}), effects];
|
|
725
919
|
}
|
|
726
920
|
case "QUOTA_EXCEEDED": {
|
|
@@ -745,6 +939,7 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
745
939
|
const phase = state.lifecycle.phase === "ended" ? "ready" : state.lifecycle.phase;
|
|
746
940
|
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
747
941
|
lifecycle: { phase },
|
|
942
|
+
buffers: forgetAppended(state.buffers),
|
|
748
943
|
playback: _objectSpread2(_objectSpread2({}, state.playback), {}, {
|
|
749
944
|
currentTime: msg.to,
|
|
750
945
|
seeking: true
|
|
@@ -835,7 +1030,7 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
835
1030
|
const initFetches = [];
|
|
836
1031
|
let quality = state.quality;
|
|
837
1032
|
for (const contentType of ["video", "audio"]) {
|
|
838
|
-
var _state$buffers$get$pe, _state$buffers$get2, _state$buffers$get$ra2, _state$buffers$get3, _hooks$abr, _hooks$switchPolicy, _state$buffers$get4, _state$buffers$get$ra3, _state$buffers$
|
|
1033
|
+
var _state$buffers$get$pe, _state$buffers$get2, _state$buffers$get$ra2, _state$buffers$get3, _hooks$abr, _hooks$switchPolicy, _state$buffers$get4, _state$buffers$get5, _state$buffers$get$ra3, _state$buffers$get6;
|
|
839
1034
|
const trackId = state.tracks.active.get(contentType);
|
|
840
1035
|
if (trackId === void 0) continue;
|
|
841
1036
|
const found = findTrackSite(state.presentation, trackId);
|
|
@@ -877,7 +1072,8 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
877
1072
|
});
|
|
878
1073
|
}
|
|
879
1074
|
if (rendition.init !== void 0 && ((_state$buffers$get4 = state.buffers.get(sbId)) === null || _state$buffers$get4 === void 0 ? void 0 : _state$buffers$get4.initFor) !== rendition.id && inflight.length === 0) {
|
|
880
|
-
|
|
1075
|
+
var _state$scheduling$pen2;
|
|
1076
|
+
if (((_state$scheduling$pen2 = state.scheduling.pendingInit) === null || _state$scheduling$pen2 === void 0 ? void 0 : _state$scheduling$pen2.get(sbId)) !== rendition.id) initFetches.push({
|
|
881
1077
|
trackId,
|
|
882
1078
|
sbId,
|
|
883
1079
|
rendition: rendition.id,
|
|
@@ -885,14 +1081,15 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
885
1081
|
});
|
|
886
1082
|
continue;
|
|
887
1083
|
}
|
|
888
|
-
|
|
1084
|
+
const appended = (_state$buffers$get5 = state.buffers.get(sbId)) === null || _state$buffers$get5 === void 0 ? void 0 : _state$buffers$get5.appended;
|
|
1085
|
+
tracks.push(_objectSpread2({
|
|
889
1086
|
trackId,
|
|
890
1087
|
period: found.period,
|
|
891
1088
|
rendition,
|
|
892
|
-
ranges: (_state$buffers$get$ra3 = (_state$buffers$
|
|
1089
|
+
ranges: (_state$buffers$get$ra3 = (_state$buffers$get6 = state.buffers.get(sbId)) === null || _state$buffers$get6 === void 0 ? void 0 : _state$buffers$get6.ranges) !== null && _state$buffers$get$ra3 !== void 0 ? _state$buffers$get$ra3 : [],
|
|
893
1090
|
sbId,
|
|
894
1091
|
inflight
|
|
895
|
-
});
|
|
1092
|
+
}, appended !== void 0 ? { appended } : {}));
|
|
896
1093
|
}
|
|
897
1094
|
for (const contentType of ["text", "metadata"]) {
|
|
898
1095
|
var _state$cues$get;
|
|
@@ -911,13 +1108,18 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
911
1108
|
inflight
|
|
912
1109
|
});
|
|
913
1110
|
}
|
|
1111
|
+
const leadSbId = sbIdFor(state.tracks.active.has("video") ? "video" : "audio");
|
|
1112
|
+
const leadPending = initFetches.some((pending) => pending.sbId === leadSbId) || [...state.scheduling.inflight.values()].some((request) => request.sbId === leadSbId);
|
|
914
1113
|
const result = schedule({
|
|
915
1114
|
currentTime: state.playback.currentTime,
|
|
916
1115
|
bufferGoal: state.scheduling.bufferGoal,
|
|
917
1116
|
tokenSeq: state.scheduling.tokenSeq + initFetches.length,
|
|
918
1117
|
tracks,
|
|
919
1118
|
liveWindow: state.presentation.isLive ? (_state$live$span = (_state$live = state.live) === null || _state$live === void 0 ? void 0 : _state$live.span) !== null && _state$live$span !== void 0 ? _state$live$span : null : null,
|
|
920
|
-
|
|
1119
|
+
reconciles: hooks.timeProbe != null,
|
|
1120
|
+
leadSbId,
|
|
1121
|
+
reconciled: state.timeline.reconciled,
|
|
1122
|
+
leadPending
|
|
921
1123
|
});
|
|
922
1124
|
const decisionKey = [...initFetches.map((p) => `${p.trackId}:init:${p.rendition}`), ...result.requests.map((r) => {
|
|
923
1125
|
var _r$renditionId;
|
|
@@ -1006,6 +1208,8 @@ const COMMAND_TYPES = {
|
|
|
1006
1208
|
DETACH: true,
|
|
1007
1209
|
LOAD: true,
|
|
1008
1210
|
UNLOAD: true,
|
|
1211
|
+
SUSPEND: true,
|
|
1212
|
+
RESUME: true,
|
|
1009
1213
|
SEEK: true,
|
|
1010
1214
|
SEEK_TO_LIVE_EDGE: true,
|
|
1011
1215
|
DESELECT_TRACK: true,
|
|
@@ -1032,7 +1236,9 @@ function createReducer(slices, config, hooks = {}) {
|
|
|
1032
1236
|
const cfg = resolveConfig(config);
|
|
1033
1237
|
const DRIVING_FACTS = /* @__PURE__ */ new Set([
|
|
1034
1238
|
"MANIFEST_LOADED",
|
|
1239
|
+
"PLAYLIST_REFRESHED",
|
|
1035
1240
|
"SEGMENT_LOADED",
|
|
1241
|
+
"SOURCEBUFFER_CREATED",
|
|
1036
1242
|
"SOURCEBUFFER_UPDATEEND",
|
|
1037
1243
|
"SEEKING",
|
|
1038
1244
|
"SEEKED",
|
|
@@ -1042,7 +1248,9 @@ function createReducer(slices, config, hooks = {}) {
|
|
|
1042
1248
|
return (state, msg) => {
|
|
1043
1249
|
const manifestRequest = !isCommand(msg) && msg.type === "SEGMENT_LOADED" ? manifestRequestFor(state, msg) : null;
|
|
1044
1250
|
let [next, effects] = isCommand(msg) ? reduceCommand(state, msg, cfg, hooks) : reduceFact(state, msg, cfg, hooks);
|
|
1045
|
-
if (
|
|
1251
|
+
if (isCommand(msg) && effects.some((effect) => effect.kind === "emit" && effect.event === "command:rejected")) return [next, effects];
|
|
1252
|
+
const merged = msg.type !== "PLAYLIST_REFRESHED" || next.presentation !== state.presentation;
|
|
1253
|
+
if (!isCommand(msg) && DRIVING_FACTS.has(msg.type) && merged) {
|
|
1046
1254
|
const [driven, driveEffects] = driveScheduling(next, hooks, cfg);
|
|
1047
1255
|
next = driven;
|
|
1048
1256
|
if (driveEffects.length > 0) effects = [...effects, ...driveEffects];
|
|
@@ -1075,6 +1283,9 @@ function createReducer(slices, config, hooks = {}) {
|
|
|
1075
1283
|
next = failed;
|
|
1076
1284
|
effects = [...effects, ...failEffects];
|
|
1077
1285
|
}
|
|
1286
|
+
const buffers = forgetFlushed(next.buffers, effects);
|
|
1287
|
+
if (buffers !== next.buffers) next = _objectSpread2(_objectSpread2({}, next), {}, { buffers });
|
|
1288
|
+
if (next.lifecycle.phase === "error") effects = effects.filter((effect) => effect.kind === "emit" || effect.kind === "abort");
|
|
1078
1289
|
return [next, effects];
|
|
1079
1290
|
};
|
|
1080
1291
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
//#region src/kernel/refresh.ts
|
|
3
|
+
/** The presentation with the refresh merged, or null when it names no rendition the presentation holds. */
|
|
4
|
+
function applyRefresh(presentation, refresh) {
|
|
5
|
+
const renditionId = refresh.renditionId;
|
|
6
|
+
if (renditionId === void 0) return null;
|
|
7
|
+
let found = false;
|
|
8
|
+
const periods = presentation.periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, { tracks: period.tracks.map((track) => {
|
|
9
|
+
var _ref, _track$protection;
|
|
10
|
+
if (!track.renditions.some((r) => r.id === renditionId)) return track;
|
|
11
|
+
found = true;
|
|
12
|
+
return _objectSpread2(_objectSpread2({}, track), {}, {
|
|
13
|
+
protection: (_ref = (_track$protection = track.protection) !== null && _track$protection !== void 0 ? _track$protection : refresh.protection) !== null && _ref !== void 0 ? _ref : null,
|
|
14
|
+
renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2({}, rendition), {}, { segments: refresh.segments }, refresh.init !== void 0 ? { init: refresh.init } : {}) : rendition)
|
|
15
|
+
});
|
|
16
|
+
}) }));
|
|
17
|
+
if (!found) return null;
|
|
18
|
+
if (refresh.endlist === void 0) return _objectSpread2(_objectSpread2({}, presentation), {}, { periods });
|
|
19
|
+
if (refresh.endlist) {
|
|
20
|
+
var _presentation$duratio;
|
|
21
|
+
const duration = refresh.segments.reduce((sum, s) => sum + s.duration, 0);
|
|
22
|
+
return _objectSpread2(_objectSpread2({}, presentation), {}, {
|
|
23
|
+
isLive: false,
|
|
24
|
+
duration: Math.max((_presentation$duratio = presentation.duration) !== null && _presentation$duratio !== void 0 ? _presentation$duratio : 0, duration),
|
|
25
|
+
periods
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return _objectSpread2(_objectSpread2({}, presentation), {}, {
|
|
29
|
+
isLive: true,
|
|
30
|
+
live: _objectSpread2(_objectSpread2(_objectSpread2({}, presentation.live), refresh.updatePeriod !== void 0 ? { updatePeriod: refresh.updatePeriod } : {}), refresh.dateAnchor !== void 0 ? { dateAnchor: refresh.dateAnchor } : {}),
|
|
31
|
+
periods
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { applyRefresh };
|