mattebox 0.21.0 → 0.21.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/README.md +1 -1
- package/dist/cdn/mattebox.dash-drm.min.js +3 -3
- package/dist/cdn/mattebox.dash-ll.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-ll.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-ll.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 +5 -5
- package/dist/es2015/kernel/bus.js +26 -6
- package/dist/es2015/kernel/reducer.js +43 -2
- package/dist/es2015/protocols/hls-live/index.js +2 -1
- package/dist/es2015/stages/live-catchup/index.js +21 -10
- package/dist/es2015/stages/qoe/index.js +28 -12
- package/dist/kernel/bus.d.ts.map +1 -1
- package/dist/kernel/bus.js +26 -7
- package/dist/kernel/bus.js.map +1 -1
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +53 -1
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js +11 -1
- package/dist/protocols/hls-live/index.js.map +1 -1
- package/dist/stages/live-catchup/index.d.ts.map +1 -1
- package/dist/stages/live-catchup/index.js +21 -11
- package/dist/stages/live-catchup/index.js.map +1 -1
- package/dist/stages/qoe/index.d.ts +0 -15
- package/dist/stages/qoe/index.d.ts.map +1 -1
- package/dist/stages/qoe/index.js +27 -15
- package/dist/stages/qoe/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import { createTraceBuffer, digest, lighten } from "./trace.js";
|
|
2
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
|
|
2
3
|
// src/kernel/bus.ts
|
|
4
|
+
/**
|
|
5
|
+
* One trace entry. The digest walks the state, which on every message is
|
|
6
|
+
* the cost of tracing. The ring pays it at once: its entries outlive the
|
|
7
|
+
* state they describe. An entry only handed to listeners computes it when
|
|
8
|
+
* one reads it, from the state it holds until then, so a listener that
|
|
9
|
+
* reads the message alone pays nothing for the digest.
|
|
10
|
+
*/
|
|
11
|
+
function traceEntry(t, msg, effects, state, kept) {
|
|
12
|
+
const light = {
|
|
13
|
+
t,
|
|
14
|
+
msg: lighten(msg),
|
|
15
|
+
effects: effects.map(lighten)
|
|
16
|
+
};
|
|
17
|
+
if (kept) return _objectSpread2(_objectSpread2({}, light), {}, { digest: digest(state) });
|
|
18
|
+
let pending = state;
|
|
19
|
+
let value = "";
|
|
20
|
+
return _objectSpread2(_objectSpread2({}, light), {}, { get digest() {
|
|
21
|
+
if (pending !== null) {
|
|
22
|
+
value = digest(pending);
|
|
23
|
+
pending = null;
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
} });
|
|
27
|
+
}
|
|
3
28
|
function createBus(options) {
|
|
4
29
|
var _options$now, _options$traceCapacit;
|
|
5
30
|
let reducer = options.reducer;
|
|
@@ -25,12 +50,7 @@ function createBus(options) {
|
|
|
25
50
|
const [next, effects] = reducer(state, msg);
|
|
26
51
|
state = next;
|
|
27
52
|
if (traceBuffer.capacity > 0 || ((_listeners$get$size = (_listeners$get = listeners.get("trace")) === null || _listeners$get === void 0 ? void 0 : _listeners$get.size) !== null && _listeners$get$size !== void 0 ? _listeners$get$size : 0) > 0) {
|
|
28
|
-
const entry =
|
|
29
|
-
t: now(),
|
|
30
|
-
msg: lighten(msg),
|
|
31
|
-
effects: effects.map(lighten),
|
|
32
|
-
digest: digest(state)
|
|
33
|
-
};
|
|
53
|
+
const entry = traceEntry(now(), msg, effects, state, traceBuffer.capacity > 0);
|
|
34
54
|
traceBuffer.push(entry);
|
|
35
55
|
emitEvent("trace", entry);
|
|
36
56
|
}
|
|
@@ -299,6 +299,36 @@ const EDGE_INSET = .05;
|
|
|
299
299
|
function edgeStart(spanStart, edge) {
|
|
300
300
|
return Math.max(spanStart, edge - EDGE_INSET);
|
|
301
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Seconds past the start of a buffered range that a seek to it lands. A
|
|
304
|
+
* browser reports the start rounded, so a seek to the reported value can
|
|
305
|
+
* fall just before the media. The playback watcher in
|
|
306
|
+
* videojs-http-streaming lands past the start for the same reason.
|
|
307
|
+
*/
|
|
308
|
+
const RANGE_INSET = .05;
|
|
309
|
+
/**
|
|
310
|
+
* Where a pending seek has to move for the element to complete it, or null
|
|
311
|
+
* when it can stay. The scheduler counts a range that starts within the gap
|
|
312
|
+
* tolerance of the playhead as covering it, and fetches nothing before it.
|
|
313
|
+
* A seek to just before a segment boundary therefore gets a buffer that
|
|
314
|
+
* starts at the boundary, and the live start is such a seek. An element
|
|
315
|
+
* completes a seek only with media at the target itself: Chrome waits
|
|
316
|
+
* there, Firefox plays across. The seek moves to where every buffer has
|
|
317
|
+
* media, because no fetch will fill what lies before.
|
|
318
|
+
*/
|
|
319
|
+
function seekIntoBuffered(buffers, time) {
|
|
320
|
+
let start = time;
|
|
321
|
+
let end = Number.POSITIVE_INFINITY;
|
|
322
|
+
for (const buffer of buffers.values()) {
|
|
323
|
+
const range = buffer.ranges.find((r) => r.start <= time + GAP_TOLERANCE && r.end > time);
|
|
324
|
+
if (range === void 0) return null;
|
|
325
|
+
start = Math.max(start, range.start);
|
|
326
|
+
end = Math.min(end, range.end);
|
|
327
|
+
}
|
|
328
|
+
if (start <= time) return null;
|
|
329
|
+
const to = start + RANGE_INSET;
|
|
330
|
+
return to < end ? to : null;
|
|
331
|
+
}
|
|
302
332
|
/** Abort effects for every matching in-flight request, plus the state with them removed. */
|
|
303
333
|
function abortInflight(state, trackId) {
|
|
304
334
|
const effects = [];
|
|
@@ -1098,10 +1128,21 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
1098
1128
|
bufferErrors = new Map(bufferErrors);
|
|
1099
1129
|
bufferErrors.delete(msg.sbId);
|
|
1100
1130
|
}
|
|
1101
|
-
|
|
1131
|
+
const updated = _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1102
1132
|
buffers,
|
|
1103
1133
|
bufferErrors
|
|
1104
|
-
})
|
|
1134
|
+
});
|
|
1135
|
+
if (state.lifecycle.phase === "ready" && state.playback.seeking) {
|
|
1136
|
+
const to = seekIntoBuffered(buffers, state.playback.currentTime);
|
|
1137
|
+
if (to !== null) {
|
|
1138
|
+
const [scheduled, effects] = driveScheduling(_objectSpread2(_objectSpread2({}, updated), {}, { playback: _objectSpread2(_objectSpread2({}, updated.playback), {}, { currentTime: to }) }), hooks, cfg);
|
|
1139
|
+
return [scheduled, [{
|
|
1140
|
+
kind: "seekElement",
|
|
1141
|
+
to
|
|
1142
|
+
}, ...effects]];
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
return driveScheduling(updated, hooks, cfg);
|
|
1105
1146
|
}
|
|
1106
1147
|
case "SOURCEBUFFER_ERROR": {
|
|
1107
1148
|
var _state$bufferErrors$g;
|
|
@@ -346,7 +346,8 @@ const createReduceHlsLive = (retryMs, ll) => (slice, msg, kernel) => {
|
|
|
346
346
|
const switched = state.target !== null && target !== null && target.renditionId !== state.target.renditionId;
|
|
347
347
|
let awaitingTarget = state.awaitingTarget;
|
|
348
348
|
let inflight = state.inflight;
|
|
349
|
-
|
|
349
|
+
const landed = msg.type === "PLAYLIST_REFRESHED" && target !== null && msg.renditionId === target.renditionId && inflight === null && !awaitingTarget;
|
|
350
|
+
if (switched && target !== null && !landed) {
|
|
350
351
|
if (inflight !== target.renditionId) {
|
|
351
352
|
effects.push(reload(_objectSpread2(_objectSpread2({}, target), {}, { url: reportFor(state.reports, target.url) })));
|
|
352
353
|
inflight = target.renditionId;
|
|
@@ -36,6 +36,19 @@ function activated() {
|
|
|
36
36
|
function clampRate(rate) {
|
|
37
37
|
return Math.min(RATE_CEILING, Math.max(RATE_FLOOR, rate));
|
|
38
38
|
}
|
|
39
|
+
const QUIET = [null, []];
|
|
40
|
+
const SOURCE = [null, [{
|
|
41
|
+
kind: "emit",
|
|
42
|
+
event: "catchup:source",
|
|
43
|
+
payload: {}
|
|
44
|
+
}]];
|
|
45
|
+
/**
|
|
46
|
+
* Says when the source goes or another comes, as `catchup:source`. It keeps
|
|
47
|
+
* no state: the reducer is where a stage sees a load and an unload. The
|
|
48
|
+
* message trace shows them too, but an engine with a trace listener builds
|
|
49
|
+
* an entry for every message.
|
|
50
|
+
*/
|
|
51
|
+
const reduceCatchup = (_slice, msg) => msg.type === "LOAD" || msg.type === "UNLOAD" ? SOURCE : QUIET;
|
|
39
52
|
function liveCatchup(options = {}) {
|
|
40
53
|
return {
|
|
41
54
|
name: "live-catchup",
|
|
@@ -176,15 +189,13 @@ function liveCatchup(options = {}) {
|
|
|
176
189
|
element.addEventListener("play", onSettle);
|
|
177
190
|
element.addEventListener("waiting", onWaiting);
|
|
178
191
|
element.addEventListener("playing", onPlaying);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
knownEnd = null;
|
|
187
|
-
}
|
|
192
|
+
ctx.reduce("live-catchup", reduceCatchup);
|
|
193
|
+
const offSource = ctx.on("catchup:source", () => {
|
|
194
|
+
release();
|
|
195
|
+
moved = null;
|
|
196
|
+
stalled = false;
|
|
197
|
+
started = false;
|
|
198
|
+
knownEnd = null;
|
|
188
199
|
});
|
|
189
200
|
ctx.registerNamespace("catchup", {
|
|
190
201
|
get target() {
|
|
@@ -211,7 +222,7 @@ function liveCatchup(options = {}) {
|
|
|
211
222
|
element.removeEventListener("play", onSettle);
|
|
212
223
|
element.removeEventListener("waiting", onWaiting);
|
|
213
224
|
element.removeEventListener("playing", onPlaying);
|
|
214
|
-
|
|
225
|
+
offSource();
|
|
215
226
|
release();
|
|
216
227
|
};
|
|
217
228
|
}
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
// src/stages/qoe/index.ts
|
|
3
|
+
const INITIAL = { rendition: null };
|
|
4
|
+
const NONE = [];
|
|
5
|
+
/**
|
|
6
|
+
* Reports a change from one rendition to another. The first selection of
|
|
7
|
+
* a load is no switch, and neither is the one after an unload: the kernel
|
|
8
|
+
* holds no rendition in between.
|
|
9
|
+
*/
|
|
10
|
+
const reduceQoe = (slice, _msg, kernel) => {
|
|
11
|
+
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
12
|
+
const active = kernel.quality.active;
|
|
13
|
+
if (active === state.rendition) return [state, NONE];
|
|
14
|
+
const switched = state.rendition !== null && active !== null;
|
|
15
|
+
return [{ rendition: active }, switched ? [{
|
|
16
|
+
kind: "emit",
|
|
17
|
+
event: "qoe:switch",
|
|
18
|
+
payload: {
|
|
19
|
+
from: state.rendition,
|
|
20
|
+
to: active
|
|
21
|
+
}
|
|
22
|
+
}] : NONE];
|
|
23
|
+
};
|
|
3
24
|
function qoe() {
|
|
4
25
|
return {
|
|
5
26
|
name: "qoe",
|
|
@@ -14,7 +35,6 @@ function qoe() {
|
|
|
14
35
|
let stallFrom = null;
|
|
15
36
|
let stallTime = 0;
|
|
16
37
|
let switches = 0;
|
|
17
|
-
let rendition = null;
|
|
18
38
|
const now = () => performance.now() / 1e3;
|
|
19
39
|
const metrics = () => ({
|
|
20
40
|
startupTime,
|
|
@@ -33,7 +53,6 @@ function qoe() {
|
|
|
33
53
|
finished = 0;
|
|
34
54
|
stallFrom = null;
|
|
35
55
|
switches = 0;
|
|
36
|
-
rendition = null;
|
|
37
56
|
}
|
|
38
57
|
function stall() {
|
|
39
58
|
if (startupTime === null || stallFrom !== null || element.seeking || element.paused) return;
|
|
@@ -71,15 +90,11 @@ function qoe() {
|
|
|
71
90
|
element.addEventListener("timeupdate", onTime);
|
|
72
91
|
element.addEventListener("seeking", onSeeking);
|
|
73
92
|
const offStalled = ctx.on("playback:stalled", stall);
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
switches += 1;
|
|
80
|
-
report("switch");
|
|
81
|
-
}
|
|
82
|
-
rendition = active;
|
|
93
|
+
const offLoading = ctx.on("lifecycle:loading", reset);
|
|
94
|
+
ctx.reduce("qoe", reduceQoe);
|
|
95
|
+
const offSwitch = ctx.on("qoe:switch", () => {
|
|
96
|
+
switches += 1;
|
|
97
|
+
report("switch");
|
|
83
98
|
});
|
|
84
99
|
ctx.registerNamespace("qoe", {
|
|
85
100
|
get startupTime() {
|
|
@@ -102,7 +117,8 @@ function qoe() {
|
|
|
102
117
|
element.removeEventListener("timeupdate", onTime);
|
|
103
118
|
element.removeEventListener("seeking", onSeeking);
|
|
104
119
|
offStalled();
|
|
105
|
-
|
|
120
|
+
offLoading();
|
|
121
|
+
offSwitch();
|
|
106
122
|
};
|
|
107
123
|
}
|
|
108
124
|
};
|
package/dist/kernel/bus.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bus.d.ts","sourceRoot":"","sources":["../../src/kernel/bus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EAAW,MAAM,EAAQ,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC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iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnD,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAgCD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CA4J9D"}
|
package/dist/kernel/bus.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { createTraceBuffer, DEFAULT_TRACE_CAPACITY, digest, lighten } from './trace.js';
|
|
2
|
+
/**
|
|
3
|
+
* One trace entry. The digest walks the state, which on every message is
|
|
4
|
+
* the cost of tracing. The ring pays it at once: its entries outlive the
|
|
5
|
+
* state they describe. An entry only handed to listeners computes it when
|
|
6
|
+
* one reads it, from the state it holds until then, so a listener that
|
|
7
|
+
* reads the message alone pays nothing for the digest.
|
|
8
|
+
*/
|
|
9
|
+
function traceEntry(t, msg, effects, state, kept) {
|
|
10
|
+
const light = { t, msg: lighten(msg), effects: effects.map(lighten) };
|
|
11
|
+
if (kept)
|
|
12
|
+
return { ...light, digest: digest(state) };
|
|
13
|
+
let pending = state;
|
|
14
|
+
let value = '';
|
|
15
|
+
return {
|
|
16
|
+
...light,
|
|
17
|
+
get digest() {
|
|
18
|
+
if (pending !== null) {
|
|
19
|
+
value = digest(pending);
|
|
20
|
+
pending = null;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
2
26
|
export function createBus(options) {
|
|
3
27
|
let reducer = options.reducer;
|
|
4
28
|
const now = options.now ?? (() => globalThis.performance.now());
|
|
@@ -24,14 +48,9 @@ export function createBus(options) {
|
|
|
24
48
|
state = next;
|
|
25
49
|
// Without its bytes, so nothing here keeps the media alive; kept only
|
|
26
50
|
// when a ring was asked for, and handed to whoever listens. With
|
|
27
|
-
// neither, nothing is built
|
|
51
|
+
// neither, nothing is built.
|
|
28
52
|
if (traceBuffer.capacity > 0 || (listeners.get('trace')?.size ?? 0) > 0) {
|
|
29
|
-
const entry =
|
|
30
|
-
t: now(),
|
|
31
|
-
msg: lighten(msg),
|
|
32
|
-
effects: effects.map(lighten),
|
|
33
|
-
digest: digest(state),
|
|
34
|
-
};
|
|
53
|
+
const entry = traceEntry(now(), msg, effects, state, traceBuffer.capacity > 0);
|
|
35
54
|
traceBuffer.push(entry);
|
|
36
55
|
emitEvent('trace', entry);
|
|
37
56
|
}
|
package/dist/kernel/bus.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bus.js","sourceRoot":"","sources":["../../src/kernel/bus.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA6CxF,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,aAAa,IAAI,sBAAsB,CAAC,CAAC;IAEvF,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IAC5B,IAAI,UAAU,GAAe,GAAG,EAAE,CAAC,SAAS,CAAC;IAE7C,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,IAAI,UAAU,GAAG,KAAK,CAAC;IAEvB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAC;IAClD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC5C,MAAM,cAAc,GAA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CAAC;QACD,UAAU;YACR,OAAO,YAAY,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/kernel/reducer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAwC,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,KAAK,EAIV,YAAY,EACZ,WAAW,EACX,OAAO,EAEP,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,OAAO,EAAgB,OAAO,EAAgB,MAAM,sBAAsB,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKxD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAmBtE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAoBnC,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAE1E;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,WAAW,CAiBxE;
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/kernel/reducer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAwC,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,KAAK,EAIV,YAAY,EACZ,WAAW,EACX,OAAO,EAEP,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,OAAO,EAAgB,OAAO,EAAgB,MAAM,sBAAsB,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKxD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB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
|
return Math.max(spanStart, edge - EDGE_INSET);
|
|
294
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Seconds past the start of a buffered range that a seek to it lands. A
|
|
297
|
+
* browser reports the start rounded, so a seek to the reported value can
|
|
298
|
+
* fall just before the media. The playback watcher in
|
|
299
|
+
* videojs-http-streaming lands past the start for the same reason.
|
|
300
|
+
*/
|
|
301
|
+
const RANGE_INSET = 0.05;
|
|
302
|
+
/**
|
|
303
|
+
* Where a pending seek has to move for the element to complete it, or null
|
|
304
|
+
* when it can stay. The scheduler counts a range that starts within the gap
|
|
305
|
+
* tolerance of the playhead as covering it, and fetches nothing before it.
|
|
306
|
+
* A seek to just before a segment boundary therefore gets a buffer that
|
|
307
|
+
* starts at the boundary, and the live start is such a seek. An element
|
|
308
|
+
* completes a seek only with media at the target itself: Chrome waits
|
|
309
|
+
* there, Firefox plays across. The seek moves to where every buffer has
|
|
310
|
+
* media, because no fetch will fill what lies before.
|
|
311
|
+
*/
|
|
312
|
+
function seekIntoBuffered(buffers, time) {
|
|
313
|
+
let start = time;
|
|
314
|
+
let end = Number.POSITIVE_INFINITY;
|
|
315
|
+
for (const buffer of buffers.values()) {
|
|
316
|
+
const range = buffer.ranges.find((r) => r.start <= time + GAP_TOLERANCE && r.end > time);
|
|
317
|
+
// A buffer with nothing here yet: its segment is still on its way.
|
|
318
|
+
if (range === undefined)
|
|
319
|
+
return null;
|
|
320
|
+
start = Math.max(start, range.start);
|
|
321
|
+
end = Math.min(end, range.end);
|
|
322
|
+
}
|
|
323
|
+
// Every buffer holds the target: the element completes the seek itself.
|
|
324
|
+
if (start <= time)
|
|
325
|
+
return null;
|
|
326
|
+
const to = start + RANGE_INSET;
|
|
327
|
+
return to < end ? to : null;
|
|
328
|
+
}
|
|
295
329
|
/** Abort effects for every matching in-flight request, plus the state with them removed. */
|
|
296
330
|
function abortInflight(state, trackId) {
|
|
297
331
|
const effects = [];
|
|
@@ -1380,10 +1414,28 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
1380
1414
|
bufferErrors = new Map(bufferErrors);
|
|
1381
1415
|
bufferErrors.delete(msg.sbId);
|
|
1382
1416
|
}
|
|
1417
|
+
const updated = { ...state, buffers, bufferErrors };
|
|
1418
|
+
// A seek that waits just before what the buffers hold moves into it
|
|
1419
|
+
// now. The playback watchdog reports such a seek too, but only after
|
|
1420
|
+
// a second, and recovery acts on its second report: two seconds
|
|
1421
|
+
// before the first frame of a live stream.
|
|
1422
|
+
if (state.lifecycle.phase === 'ready' && state.playback.seeking) {
|
|
1423
|
+
const to = seekIntoBuffered(buffers, state.playback.currentTime);
|
|
1424
|
+
if (to !== null) {
|
|
1425
|
+
// The target is the position from now on, so the appends that
|
|
1426
|
+
// follow in the same turn do not move the seek again.
|
|
1427
|
+
const moved = {
|
|
1428
|
+
...updated,
|
|
1429
|
+
playback: { ...updated.playback, currentTime: to },
|
|
1430
|
+
};
|
|
1431
|
+
const [scheduled, effects] = driveScheduling(moved, hooks, cfg);
|
|
1432
|
+
return [scheduled, [{ kind: 'seekElement', to }, ...effects]];
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1383
1435
|
// An append completing is the natural moment to decide the next fetch,
|
|
1384
1436
|
// so the buffer keeps filling toward the goal without waiting for the
|
|
1385
1437
|
// next time update.
|
|
1386
|
-
return driveScheduling(
|
|
1438
|
+
return driveScheduling(updated, hooks, cfg);
|
|
1387
1439
|
}
|
|
1388
1440
|
case 'SOURCEBUFFER_ERROR': {
|
|
1389
1441
|
// The circuit breaker: repeated failures on one buffer can never make
|