mattebox 0.7.0 → 0.8.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 +2 -2
- package/dist/es2015/kernel/reducer.js +5 -5
- package/dist/es2015/kernel/scheduler.js +26 -5
- package/dist/es2015/stages/chapters/index.js +27 -8
- package/dist/es2015/stages/chapters/parse.js +28 -1
- package/dist/es2015/stages/trick-play/index.js +71 -11
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +10 -8
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/scheduler.d.ts +17 -0
- package/dist/kernel/scheduler.d.ts.map +1 -1
- package/dist/kernel/scheduler.js +26 -4
- package/dist/kernel/scheduler.js.map +1 -1
- package/dist/protocols/dash-live/index.d.ts +1 -0
- package/dist/protocols/dash-live/index.d.ts.map +1 -1
- package/dist/protocols/dash-live/index.js.map +1 -1
- package/dist/protocols/hls-live/index.d.ts +1 -0
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js.map +1 -1
- package/dist/stages/chapters/index.d.ts +8 -2
- package/dist/stages/chapters/index.d.ts.map +1 -1
- package/dist/stages/chapters/index.js +21 -6
- package/dist/stages/chapters/index.js.map +1 -1
- package/dist/stages/chapters/parse.d.ts +19 -1
- package/dist/stages/chapters/parse.d.ts.map +1 -1
- package/dist/stages/chapters/parse.js +33 -0
- package/dist/stages/chapters/parse.js.map +1 -1
- package/dist/stages/trick-play/index.d.ts +7 -0
- package/dist/stages/trick-play/index.d.ts.map +1 -1
- package/dist/stages/trick-play/index.js +70 -11
- package/dist/stages/trick-play/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { normalizeMimeType, typeString } from "./mime.js";
|
|
|
4
4
|
import { findRendition, findTrackSite, isTrick } from "./presentation.js";
|
|
5
5
|
import { applyRefresh } from "./refresh.js";
|
|
6
6
|
import { reconciledOffset, segmentAtTime } from "./timeline.js";
|
|
7
|
-
import { bufferedEndFrom, schedule } from "./scheduler.js";
|
|
7
|
+
import { bufferedEndFrom, reachesEnd, schedule } from "./scheduler.js";
|
|
8
8
|
import { availableGroups, canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
|
|
9
9
|
import { sbIdFor } from "./sinks/mse-sink.js";
|
|
10
10
|
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectWithoutProperties.js";
|
|
@@ -1095,8 +1095,8 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
1095
1095
|
}
|
|
1096
1096
|
const leadSbId = sbIdFor(state.tracks.active.has("video") ? "video" : "audio");
|
|
1097
1097
|
const leadPending = initFetches.some((pending) => pending.sbId === leadSbId) || [...state.scheduling.inflight.values()].some((request) => request.sbId === leadSbId);
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1098
|
+
const vodDuration = state.presentation.isLive ? void 0 : state.presentation.duration;
|
|
1099
|
+
const result = schedule(_objectSpread2(_objectSpread2({ currentTime: state.playback.currentTime }, vodDuration === void 0 ? {} : { duration: vodDuration }), {}, {
|
|
1100
1100
|
bufferGoal: state.scheduling.bufferGoal,
|
|
1101
1101
|
tokenSeq: state.scheduling.tokenSeq + initFetches.length,
|
|
1102
1102
|
tracks,
|
|
@@ -1105,7 +1105,7 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
1105
1105
|
leadSbId,
|
|
1106
1106
|
reconciled: state.timeline.reconciled,
|
|
1107
1107
|
leadPending
|
|
1108
|
-
});
|
|
1108
|
+
}));
|
|
1109
1109
|
const decisionKey = [...initFetches.map((p) => `${p.trackId}:init:${p.rendition}`), ...result.requests.map((r) => {
|
|
1110
1110
|
var _r$renditionId;
|
|
1111
1111
|
return `${r.trackId}:${r.seq}:${(_r$renditionId = r.renditionId) !== null && _r$renditionId !== void 0 ? _r$renditionId : ""}`;
|
|
@@ -1165,7 +1165,7 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
1165
1165
|
const mediaTracks = tracks.filter((track) => track.sbId !== void 0);
|
|
1166
1166
|
if (state.presentation.duration !== void 0 && initFetches.length === 0 && result.effects.length === 0 && mediaTracks.length > 0 && mediaTracks.every((track) => {
|
|
1167
1167
|
var _state$presentation$d, _state$presentation2;
|
|
1168
|
-
return
|
|
1168
|
+
return track.inflight.length === 0 && reachesEnd(track.ranges, state.playback.currentTime, (_state$presentation$d = (_state$presentation2 = state.presentation) === null || _state$presentation2 === void 0 ? void 0 : _state$presentation2.duration) !== null && _state$presentation$d !== void 0 ? _state$presentation$d : 0, .25);
|
|
1169
1169
|
})) effects.push({ kind: "endOfStream" });
|
|
1170
1170
|
if (effects.length === 0 && quality === state.quality) return [state, []];
|
|
1171
1171
|
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
@@ -3,6 +3,26 @@ import { buildEpochs, epochForSeq, epochKey, segmentAtTime, timestampOffsetFor }
|
|
|
3
3
|
//#region src/kernel/scheduler.ts
|
|
4
4
|
const DEFAULT_GAP_TOLERANCE = .25;
|
|
5
5
|
/**
|
|
6
|
+
* A playhead this close to the end counts as inside the last segment. No
|
|
7
|
+
* segment starts at the duration itself, so a seek to the very end would
|
|
8
|
+
* otherwise find nothing to fetch there.
|
|
9
|
+
*/
|
|
10
|
+
const END_SLACK = .5;
|
|
11
|
+
/** Where the buffer is measured from: the playhead, or just inside the last segment when it sits at the end. */
|
|
12
|
+
function measuredFrom(time, duration) {
|
|
13
|
+
return duration === void 0 ? time : Math.min(time, duration - END_SLACK);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether `ranges` hold media from the playhead through to `duration`. The
|
|
17
|
+
* playhead alone never counts: a seek to the end with nothing buffered there
|
|
18
|
+
* has not reached it, and ending the stream then would cut the duration
|
|
19
|
+
* down to what is buffered (W3C Media Source Extensions, endOfStream).
|
|
20
|
+
*/
|
|
21
|
+
function reachesEnd(ranges, time, duration, tolerance) {
|
|
22
|
+
const from = measuredFrom(time, duration);
|
|
23
|
+
return ranges.some((range) => range.start <= from + tolerance && range.end > from) && bufferedEndFrom(ranges, from, tolerance) >= duration - .5;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
6
26
|
* The end of continuous buffer from `time`, merging gaps below the
|
|
7
27
|
* tolerance. Returns `time` itself when nothing is buffered there.
|
|
8
28
|
*/
|
|
@@ -47,9 +67,10 @@ function schedule(input) {
|
|
|
47
67
|
for (const track of input.tracks) {
|
|
48
68
|
var _input$reconciled;
|
|
49
69
|
if (track.inflight.length > 0) continue;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
const now = measuredFrom(input.currentTime, input.duration);
|
|
71
|
+
const bufferedEnd = bufferedEndFrom(track.ranges, now, tolerance);
|
|
72
|
+
if (bufferedEnd - now >= input.bufferGoal) continue;
|
|
73
|
+
let target = Math.max(bufferedEnd, now);
|
|
53
74
|
if (input.liveWindow != null && target < input.liveWindow.start) target = input.liveWindow.start;
|
|
54
75
|
let segment = segmentAtTime(track.rendition.segments, target + tolerance, track.period.start);
|
|
55
76
|
let frontier = bufferedEnd;
|
|
@@ -66,7 +87,7 @@ function schedule(input) {
|
|
|
66
87
|
}
|
|
67
88
|
if (covering === null) break;
|
|
68
89
|
frontier = Math.max(frontier, covering.end);
|
|
69
|
-
if (frontier -
|
|
90
|
+
if (frontier - now >= input.bufferGoal) {
|
|
70
91
|
segment = null;
|
|
71
92
|
break;
|
|
72
93
|
}
|
|
@@ -105,4 +126,4 @@ function schedule(input) {
|
|
|
105
126
|
};
|
|
106
127
|
}
|
|
107
128
|
//#endregion
|
|
108
|
-
export { bufferedEndFrom, schedule };
|
|
129
|
+
export { END_SLACK, bufferedEndFrom, measuredFrom, reachesEnd, schedule };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { findTrackSite } from "../../kernel/presentation.js";
|
|
3
3
|
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/asyncToGenerator.js";
|
|
4
|
-
import { parseAppleChapters, parseChapterTrack } from "./parse.js";
|
|
4
|
+
import { chaptersFromInput, parseAppleChapters, parseChapterTrack } from "./parse.js";
|
|
5
5
|
//#region src/stages/chapters/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* Chapters: named spans of the presentation, answered through
|
|
@@ -11,9 +11,10 @@ import { parseAppleChapters, parseChapterTrack } from "./parse.js";
|
|
|
11
11
|
* `com.apple.hls.chapters` names Apple's JSON chapters document. The
|
|
12
12
|
* stage's reducer fetches it once per load and parses it; the list lives
|
|
13
13
|
* in the stage's slice.
|
|
14
|
-
* -
|
|
15
|
-
* engine defines
|
|
16
|
-
*
|
|
14
|
+
* - The app: a file it loads (a WebVTT chapters track, the metadata track
|
|
15
|
+
* this engine defines, or Apple's JSON), or chapters it sets from data it
|
|
16
|
+
* already holds. They win over the manifest until the next LOAD, UNLOAD,
|
|
17
|
+
* or DETACH.
|
|
17
18
|
*
|
|
18
19
|
* Both fetches go through the transport, so request hooks (auth, cmcd,
|
|
19
20
|
* steering) apply. A load counter in the slice ties the app's list, which
|
|
@@ -34,12 +35,12 @@ function preferredLanguage(kernel) {
|
|
|
34
35
|
if (textId === void 0) return null;
|
|
35
36
|
return (_findTrackSite$track$ = (_findTrackSite = findTrackSite(kernel.presentation, textId)) === null || _findTrackSite === void 0 ? void 0 : _findTrackSite.track.lang) !== null && _findTrackSite$track$ !== void 0 ? _findTrackSite$track$ : null;
|
|
36
37
|
}
|
|
37
|
-
/** A parse's warnings and the list-changed event, as emit effects. */
|
|
38
|
+
/** A parse's warnings and the list-changed event, as emit effects. `url` is null for app data. */
|
|
38
39
|
function report(url, result, source) {
|
|
39
40
|
return [...result.warnings.map((warning) => ({
|
|
40
41
|
kind: "emit",
|
|
41
42
|
event: "chapters:warning",
|
|
42
|
-
payload: _objectSpread2({ url }, warning)
|
|
43
|
+
payload: url === null ? _objectSpread2({}, warning) : _objectSpread2({ url }, warning)
|
|
43
44
|
})), {
|
|
44
45
|
kind: "emit",
|
|
45
46
|
event: "chapters:changed",
|
|
@@ -110,7 +111,7 @@ function chapters() {
|
|
|
110
111
|
if (duration === void 0) return chosen;
|
|
111
112
|
return chosen.map((c) => c.end === Number.POSITIVE_INFINITY ? _objectSpread2(_objectSpread2({}, c), {}, { end: duration }) : c);
|
|
112
113
|
};
|
|
113
|
-
|
|
114
|
+
const api = {
|
|
114
115
|
load(url) {
|
|
115
116
|
return _asyncToGenerator(function* () {
|
|
116
117
|
const at = slice().loads;
|
|
@@ -132,6 +133,23 @@ function chapters() {
|
|
|
132
133
|
return result.chapters.length;
|
|
133
134
|
})();
|
|
134
135
|
},
|
|
136
|
+
set(chapters) {
|
|
137
|
+
if (chapters.length === 0) {
|
|
138
|
+
list = null;
|
|
139
|
+
ctx.emit("chapters:changed", {
|
|
140
|
+
count: current().length,
|
|
141
|
+
source: api.source
|
|
142
|
+
});
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
const result = chaptersFromInput(chapters);
|
|
146
|
+
list = {
|
|
147
|
+
loads: slice().loads,
|
|
148
|
+
chapters: result.chapters
|
|
149
|
+
};
|
|
150
|
+
for (const effect of report(null, result, "app")) if (effect.kind === "emit") ctx.emit(effect.event, effect.payload);
|
|
151
|
+
return result.chapters.length;
|
|
152
|
+
},
|
|
135
153
|
at(time) {
|
|
136
154
|
var _current$find;
|
|
137
155
|
return (_current$find = current().find((c) => time >= c.start && time < c.end)) !== null && _current$find !== void 0 ? _current$find : null;
|
|
@@ -143,7 +161,8 @@ function chapters() {
|
|
|
143
161
|
if (app() !== null) return "app";
|
|
144
162
|
return slice().manifest === null ? "none" : "manifest";
|
|
145
163
|
}
|
|
146
|
-
}
|
|
164
|
+
};
|
|
165
|
+
ctx.registerNamespace("chapters", api);
|
|
147
166
|
}
|
|
148
167
|
};
|
|
149
168
|
}
|
|
@@ -145,5 +145,32 @@ function parseAppleChapters(text, baseUrl, preferredLanguage = null) {
|
|
|
145
145
|
warnings
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Chapters an app built itself, as the record every source produces. An
|
|
150
|
+
* entry without a finite, non-negative start is skipped; an end that is
|
|
151
|
+
* missing or not after the start runs to the next chapter's start.
|
|
152
|
+
*/
|
|
153
|
+
function chaptersFromInput(inputs) {
|
|
154
|
+
const warnings = [];
|
|
155
|
+
const valid = inputs.filter((input) => {
|
|
156
|
+
const ok = Number.isFinite(input.start) && input.start >= 0;
|
|
157
|
+
if (!ok) warnings.push(_objectSpread2({ reason: "invalid-chapter" }, input.id !== void 0 ? { id: input.id } : {}));
|
|
158
|
+
return ok;
|
|
159
|
+
});
|
|
160
|
+
const starts = valid.map((input) => input.start).sort((a, b) => a - b);
|
|
161
|
+
return {
|
|
162
|
+
chapters: orderChapters(valid.map((input) => {
|
|
163
|
+
var _input$id, _starts$find2, _input$title;
|
|
164
|
+
const given = input.end !== void 0 && Number.isFinite(input.end) && input.end > input.start;
|
|
165
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
166
|
+
id: (_input$id = input.id) !== null && _input$id !== void 0 ? _input$id : String(Math.round(input.start * 1e3)),
|
|
167
|
+
start: input.start,
|
|
168
|
+
end: given ? input.end : (_starts$find2 = starts.find((s) => s > input.start)) !== null && _starts$find2 !== void 0 ? _starts$find2 : Number.POSITIVE_INFINITY,
|
|
169
|
+
title: (_input$title = input.title) !== null && _input$title !== void 0 ? _input$title : ""
|
|
170
|
+
}, input.lang !== void 0 ? { lang: input.lang } : {}), input.image !== void 0 ? { image: input.image } : {}), input.data !== void 0 ? { data: input.data } : {});
|
|
171
|
+
}), warnings),
|
|
172
|
+
warnings
|
|
173
|
+
};
|
|
174
|
+
}
|
|
148
175
|
//#endregion
|
|
149
|
-
export { orderChapters, parseAppleChapters, parseChapterTrack };
|
|
176
|
+
export { chaptersFromInput, orderChapters, parseAppleChapters, parseChapterTrack };
|
|
@@ -195,8 +195,13 @@ function trickPlay() {
|
|
|
195
195
|
apply: "now"
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
|
-
/**
|
|
199
|
-
|
|
198
|
+
/**
|
|
199
|
+
* The normal stream and mute from before scanning or scrubbing, and a
|
|
200
|
+
* play state: the one from before, or the one the page asked for when
|
|
201
|
+
* it took playback over (`page`).
|
|
202
|
+
*/
|
|
203
|
+
function restore(page) {
|
|
204
|
+
var _page$rate;
|
|
200
205
|
const was = saved;
|
|
201
206
|
saved = null;
|
|
202
207
|
if (was === null) return;
|
|
@@ -209,22 +214,33 @@ function trickPlay() {
|
|
|
209
214
|
type: "SET_BUFFER_GOAL",
|
|
210
215
|
seconds: was.bufferGoal
|
|
211
216
|
});
|
|
212
|
-
element.playbackRate = 1;
|
|
217
|
+
element.playbackRate = (_page$rate = page === null || page === void 0 ? void 0 : page.rate) !== null && _page$rate !== void 0 ? _page$rate : 1;
|
|
213
218
|
element.muted = was.muted;
|
|
214
|
-
if (was.playing) element.play().catch(() => void 0);
|
|
219
|
+
if (page === void 0 ? was.playing : !page.paused) element.play().catch(() => void 0);
|
|
215
220
|
}
|
|
216
|
-
/**
|
|
217
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Ends a scan. `resume` is false when a new source took over. Through
|
|
223
|
+
* a kernel SEEK first: the kernel's time trails the element's by up to
|
|
224
|
+
* a timeupdate interval, seconds of media at a scan rate, and the
|
|
225
|
+
* switch back plans around the kernel's time.
|
|
226
|
+
*/
|
|
227
|
+
function end(reason, resume = true, page) {
|
|
218
228
|
stopTimer();
|
|
219
229
|
const was = rate;
|
|
220
230
|
rate = 1;
|
|
221
231
|
if (saved === null) return;
|
|
222
|
-
if (resume)
|
|
223
|
-
|
|
232
|
+
if (resume) {
|
|
233
|
+
ctx.dispatch({
|
|
234
|
+
type: "SEEK",
|
|
235
|
+
to: element.currentTime
|
|
236
|
+
});
|
|
237
|
+
restore(page);
|
|
238
|
+
} else saved = null;
|
|
224
239
|
ctx.emit("trick:stopped", {
|
|
225
240
|
rate: was,
|
|
226
241
|
reason
|
|
227
242
|
});
|
|
243
|
+
if (was !== 1) ctx.emit("trick:rate", { rate: 1 });
|
|
228
244
|
}
|
|
229
245
|
/** True when a new source loaded since scanning or scrubbing began; both just stop. */
|
|
230
246
|
function stale() {
|
|
@@ -256,6 +272,31 @@ function trickPlay() {
|
|
|
256
272
|
if (live !== null && element.currentTime >= live.edge - EDGE_MARGIN) end("edge");
|
|
257
273
|
};
|
|
258
274
|
element.addEventListener("timeupdate", onTimeUpdate);
|
|
275
|
+
/**
|
|
276
|
+
* The page took playback over during a scan: a play, a pause, or a
|
|
277
|
+
* rate the scan did not set, such as a speed menu or a play button.
|
|
278
|
+
* The scan ends and the normal stream plays in the state the page
|
|
279
|
+
* asked for; without this the I-frame track would play at that rate.
|
|
280
|
+
* The events arrive after the fact, so each is judged by the state it
|
|
281
|
+
* finds: forward scans play at `rate`, rewinding pauses at rate 1.
|
|
282
|
+
*/
|
|
283
|
+
const onTakeover = () => {
|
|
284
|
+
if (rate === 1 || scrubbing || stale()) return;
|
|
285
|
+
const forward = rate > 0;
|
|
286
|
+
if (forward ? !element.paused && element.playbackRate === rate : element.paused && element.playbackRate === 1) return;
|
|
287
|
+
const own = element.ended || forward && element.playbackRate === rate;
|
|
288
|
+
const page = {
|
|
289
|
+
paused: element.paused,
|
|
290
|
+
rate: own ? 1 : element.playbackRate
|
|
291
|
+
};
|
|
292
|
+
end(element.ended ? "end" : "page", true, page);
|
|
293
|
+
};
|
|
294
|
+
const TAKEOVER = [
|
|
295
|
+
"play",
|
|
296
|
+
"pause",
|
|
297
|
+
"ratechange"
|
|
298
|
+
];
|
|
299
|
+
for (const name of TAKEOVER) element.addEventListener(name, onTakeover);
|
|
259
300
|
function scrubStart() {
|
|
260
301
|
stale();
|
|
261
302
|
if (trickTrack(ctx.getState()) === null) throw new Error("this presentation has no I-frame track to scrub with");
|
|
@@ -266,6 +307,7 @@ function trickPlay() {
|
|
|
266
307
|
rate,
|
|
267
308
|
reason: "scrub"
|
|
268
309
|
});
|
|
310
|
+
ctx.emit("trick:rate", { rate: 1 });
|
|
269
311
|
rate = 1;
|
|
270
312
|
} else begin();
|
|
271
313
|
const was = saved;
|
|
@@ -340,6 +382,8 @@ function trickPlay() {
|
|
|
340
382
|
});
|
|
341
383
|
return job;
|
|
342
384
|
}
|
|
385
|
+
/** The load on which frameAt found the I-frame track undecodable, or null. */
|
|
386
|
+
let undecodable = null;
|
|
343
387
|
function decodeFrameAt(_x7, _x8) {
|
|
344
388
|
return _decodeFrameAt.apply(this, arguments);
|
|
345
389
|
}
|
|
@@ -362,7 +406,11 @@ function trickPlay() {
|
|
|
362
406
|
return null;
|
|
363
407
|
}
|
|
364
408
|
const segment = segmentAtTime(addressing, time, period.start);
|
|
365
|
-
if (
|
|
409
|
+
if (rendition.init === void 0 || rendition.codecs === null) {
|
|
410
|
+
undecodable = currentLoads();
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
if (segment === null) return null;
|
|
366
414
|
const width = (_options$width = options.width) !== null && _options$width !== void 0 ? _options$width : DEFAULT_FRAME_WIDTH;
|
|
367
415
|
const key = `${segment.url}@${(_segment$byteRange$st2 = (_segment$byteRange2 = segment.byteRange) === null || _segment$byteRange2 === void 0 ? void 0 : _segment$byteRange2.start) !== null && _segment$byteRange$st2 !== void 0 ? _segment$byteRange$st2 : 0}:${width}`;
|
|
368
416
|
const cached = frames.get(key);
|
|
@@ -380,11 +428,17 @@ function trickPlay() {
|
|
|
380
428
|
const [head, bytes] = yield Promise.all([initBytes, fetchBytes(segment.url, segment.byteRange).catch(() => null)]);
|
|
381
429
|
if (head === null || bytes === null) return null;
|
|
382
430
|
const config = decoderConfigBox(head);
|
|
383
|
-
if (config === null || looksLikeTransportStream(bytes))
|
|
431
|
+
if (config === null || looksLikeTransportStream(bytes)) {
|
|
432
|
+
undecodable = currentLoads();
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
384
435
|
const key0 = (_fragmentSamples$ = fragmentSamples(bytes, trexDefaults(head))[0]) === null || _fragmentSamples$ === void 0 ? void 0 : _fragmentSamples$.samples.find((s) => s.isKeyframe && s.offset + s.size <= bytes.byteLength);
|
|
385
436
|
if (key0 === void 0) return null;
|
|
386
437
|
const frame = yield decodeKeyFrame(rendition.codecs, config.description, bytes.subarray(key0.offset, key0.offset + key0.size));
|
|
387
|
-
if (frame === null)
|
|
438
|
+
if (frame === null) {
|
|
439
|
+
undecodable = currentLoads();
|
|
440
|
+
return null;
|
|
441
|
+
}
|
|
388
442
|
try {
|
|
389
443
|
const bitmap = yield createImageBitmap(frame, {
|
|
390
444
|
resizeWidth: width,
|
|
@@ -411,6 +465,10 @@ function trickPlay() {
|
|
|
411
465
|
stale();
|
|
412
466
|
return rate;
|
|
413
467
|
},
|
|
468
|
+
get previews() {
|
|
469
|
+
if (typeof VideoDecoder === "undefined" || undecodable === currentLoads()) return false;
|
|
470
|
+
return previewSite(ctx.getState()) !== null;
|
|
471
|
+
},
|
|
414
472
|
get scrubbing() {
|
|
415
473
|
stale();
|
|
416
474
|
return scrubbing;
|
|
@@ -447,6 +505,7 @@ function trickPlay() {
|
|
|
447
505
|
timer = setInterval(rewindStep, REWIND_STEP_MS);
|
|
448
506
|
}
|
|
449
507
|
if (was === 1) ctx.emit("trick:started", { rate: next });
|
|
508
|
+
if (was !== next) ctx.emit("trick:rate", { rate: next });
|
|
450
509
|
}
|
|
451
510
|
};
|
|
452
511
|
ctx.registerNamespace("trick", api);
|
|
@@ -455,6 +514,7 @@ function trickPlay() {
|
|
|
455
514
|
for (const bitmap of frames.values()) bitmap.close();
|
|
456
515
|
frames.clear();
|
|
457
516
|
element.removeEventListener("timeupdate", onTimeUpdate);
|
|
517
|
+
for (const name of TAKEOVER) element.removeEventListener(name, onTakeover);
|
|
458
518
|
};
|
|
459
519
|
}
|
|
460
520
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/kernel/reducer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,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;AAgBtE;;;;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,CAgBxE;AAo3CD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC5C;
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/kernel/reducer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,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;AAgBtE;;;;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,CAgBxE;AAo3CD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC5C;AAoTD,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,MAAM,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,EAClD,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAC9B,KAAK,GAAE,YAAiB,GACvB,OAAO,CA6FT"}
|
package/dist/kernel/reducer.js
CHANGED
|
@@ -13,7 +13,7 @@ import { normalizeMimeType, typeString } from './mime.js';
|
|
|
13
13
|
import { findRendition, findTrackSite, isTrick } from './presentation.js';
|
|
14
14
|
import { applyRefresh } from './refresh.js';
|
|
15
15
|
import { availableGroups, canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups, } from './rendition-select.js';
|
|
16
|
-
import { bufferedEndFrom, schedule } from './scheduler.js';
|
|
16
|
+
import { bufferedEndFrom, reachesEnd, schedule } from './scheduler.js';
|
|
17
17
|
import { sbIdFor } from './sinks/mse-sink.js';
|
|
18
18
|
import { reconciledOffset, segmentAtTime } from './timeline.js';
|
|
19
19
|
import { DEFAULT_TRACE_CAPACITY } from './trace.js';
|
|
@@ -1430,8 +1430,10 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
1430
1430
|
const leadSbId = sbIdFor(state.tracks.active.has('video') ? 'video' : 'audio');
|
|
1431
1431
|
const leadPending = initFetches.some((pending) => pending.sbId === leadSbId) ||
|
|
1432
1432
|
[...state.scheduling.inflight.values()].some((request) => request.sbId === leadSbId);
|
|
1433
|
+
const vodDuration = state.presentation.isLive ? undefined : state.presentation.duration;
|
|
1433
1434
|
const result = schedule({
|
|
1434
1435
|
currentTime: state.playback.currentTime,
|
|
1436
|
+
...(vodDuration === undefined ? {} : { duration: vodDuration }),
|
|
1435
1437
|
bufferGoal: state.scheduling.bufferGoal,
|
|
1436
1438
|
tokenSeq: state.scheduling.tokenSeq + initFetches.length,
|
|
1437
1439
|
tracks,
|
|
@@ -1502,9 +1504,9 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
1502
1504
|
for (const request of result.requests) {
|
|
1503
1505
|
inflight.set(request.token, request);
|
|
1504
1506
|
}
|
|
1505
|
-
// VOD end: every track has nothing left to fetch and
|
|
1506
|
-
// the announced duration. endOfStream is safe
|
|
1507
|
-
// no-ops once the source has left 'open'.
|
|
1507
|
+
// VOD end: every track has nothing left to fetch and its buffer holds
|
|
1508
|
+
// media from the playhead to the announced duration. endOfStream is safe
|
|
1509
|
+
// to re-emit; the handler no-ops once the source has left 'open'.
|
|
1508
1510
|
// Only SourceBuffer tracks gate the end: a subtitle playlist shorter
|
|
1509
1511
|
// than the video must not hold the stream open.
|
|
1510
1512
|
const mediaTracks = tracks.filter((track) => track.sbId !== undefined);
|
|
@@ -1512,10 +1514,10 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
1512
1514
|
initFetches.length === 0 &&
|
|
1513
1515
|
result.effects.length === 0 &&
|
|
1514
1516
|
mediaTracks.length > 0 &&
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1517
|
+
// A fetch still in flight would append past the end, reopen the source,
|
|
1518
|
+
// and leave the stream open with nothing left to end it.
|
|
1519
|
+
mediaTracks.every((track) => track.inflight.length === 0 &&
|
|
1520
|
+
reachesEnd(track.ranges, state.playback.currentTime, state.presentation?.duration ?? 0, 0.25))) {
|
|
1519
1521
|
effects.push({ kind: 'endOfStream' });
|
|
1520
1522
|
}
|
|
1521
1523
|
if (effects.length === 0 && quality === state.quality)
|