mattebox 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +2 -2
- 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/containers/projection.d.ts +36 -0
- package/dist/containers/projection.d.ts.map +1 -0
- package/dist/containers/projection.js +68 -0
- package/dist/containers/projection.js.map +1 -0
- package/dist/containers/webm/cues.d.ts +59 -0
- package/dist/containers/webm/cues.d.ts.map +1 -0
- package/dist/containers/webm/cues.js +218 -0
- package/dist/containers/webm/cues.js.map +1 -0
- package/dist/containers/webm/index.d.ts +36 -0
- package/dist/containers/webm/index.d.ts.map +1 -0
- package/dist/containers/webm/index.js +271 -0
- package/dist/containers/webm/index.js.map +1 -0
- package/dist/es2015/containers/projection.js +68 -0
- package/dist/es2015/containers/webm/cues.js +197 -0
- package/dist/es2015/containers/webm/index.js +258 -0
- package/dist/es2015/kernel/reducer.js +31 -2
- package/dist/es2015/presets/full/index.js +6 -3
- package/dist/es2015/presets/tiers/dash-ll.js +2 -1
- package/dist/es2015/presets/tiers/dash.js +7 -2
- package/dist/es2015/protocols/dash-cmaf/index.js +11 -5
- package/dist/es2015/protocols/dash-cmaf/parse.js +40 -12
- package/dist/es2015/protocols/dash-live/index.js +7 -4
- package/dist/es2015/protocols/dash-ll/index.js +3 -2
- package/dist/es2015/stages/projection/index.js +41 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +44 -1
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/presets/full/index.d.ts.map +1 -1
- package/dist/presets/full/index.js +5 -2
- package/dist/presets/full/index.js.map +1 -1
- package/dist/presets/tiers/dash-ll.d.ts.map +1 -1
- package/dist/presets/tiers/dash-ll.js +2 -1
- package/dist/presets/tiers/dash-ll.js.map +1 -1
- package/dist/presets/tiers/dash.d.ts +7 -1
- package/dist/presets/tiers/dash.d.ts.map +1 -1
- package/dist/presets/tiers/dash.js +3 -2
- package/dist/presets/tiers/dash.js.map +1 -1
- package/dist/protocols/dash-cmaf/index.d.ts +8 -3
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +12 -5
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts +6 -1
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +54 -7
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/dash-live/index.d.ts +6 -3
- package/dist/protocols/dash-live/index.d.ts.map +1 -1
- package/dist/protocols/dash-live/index.js +7 -4
- package/dist/protocols/dash-live/index.js.map +1 -1
- package/dist/protocols/dash-ll/index.d.ts.map +1 -1
- package/dist/protocols/dash-ll/index.js +3 -2
- package/dist/protocols/dash-ll/index.js.map +1 -1
- package/dist/stages/eme-wiseplay/index.d.ts +3 -2
- package/dist/stages/eme-wiseplay/index.d.ts.map +1 -1
- package/dist/stages/eme-wiseplay/index.js.map +1 -1
- package/dist/stages/projection/index.d.ts +3 -0
- package/dist/stages/projection/index.d.ts.map +1 -0
- package/dist/stages/projection/index.js +45 -0
- package/dist/stages/projection/index.js.map +1 -0
- package/dist/types/ir.d.ts +7 -1
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +3 -1
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +13 -1
- package/dist/types/messages.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
2
|
+
import { findRendition } from "../../kernel/presentation.js";
|
|
3
|
+
import { activeRenditions } from "../../kernel/rendition-select.js";
|
|
4
|
+
import { isUnresolved } from "../../kernel/timeline.js";
|
|
5
|
+
import { cuesToSegments, readCues, readInit } from "./cues.js";
|
|
6
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
|
|
7
|
+
// src/containers/webm/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* WebM segments in DASH. MSE takes `video/webm` and `audio/webm` as they
|
|
10
|
+
* are (W3C WebM Byte Stream Format,
|
|
11
|
+
* https://www.w3.org/TR/mse-byte-stream-format-webm/), so nothing is
|
|
12
|
+
* rewrapped. The stage does two things:
|
|
13
|
+
*
|
|
14
|
+
* - It provides the `video/webm` and `audio/webm` content handlers, so the
|
|
15
|
+
* DASH adapters keep WebM Representations instead of leaving them out.
|
|
16
|
+
* - It resolves a WebM `SegmentBase`: it fetches the initialization range
|
|
17
|
+
* and the Cues at `indexRange`, and turns them into one byte-range
|
|
18
|
+
* segment per Cluster, as Shaka Player and dash.js do.
|
|
19
|
+
*
|
|
20
|
+
* A `SegmentTemplate` WebM Representation needs no index and plays from
|
|
21
|
+
* the MPD alone. Inert module: exports a factory, registers nothing at
|
|
22
|
+
* import time.
|
|
23
|
+
*/
|
|
24
|
+
/** The fetch of a rendition's initialization range: `webm:init:<renditionId>`. */
|
|
25
|
+
const INIT_TOKEN = "webm:init:";
|
|
26
|
+
/** The fetch of a rendition's Cues: `webm:cues:<renditionId>`. */
|
|
27
|
+
const CUES_TOKEN = "webm:cues:";
|
|
28
|
+
/** A failed index's retry: `webm:retry:<renditionId>`. */
|
|
29
|
+
const RETRY_TOKEN = "webm:retry:";
|
|
30
|
+
/** The constraint source that excludes renditions whose index failed. */
|
|
31
|
+
const UNAVAILABLE = "webm:unavailable";
|
|
32
|
+
/** The default wait before a failed index is tried again, as the DASH adapter waits. */
|
|
33
|
+
const RETRY_SECONDS = 15;
|
|
34
|
+
/** The slice before any load. */
|
|
35
|
+
const INITIAL = {
|
|
36
|
+
pending: {},
|
|
37
|
+
asked: {},
|
|
38
|
+
inits: {},
|
|
39
|
+
cues: {},
|
|
40
|
+
failed: {},
|
|
41
|
+
seen: ""
|
|
42
|
+
};
|
|
43
|
+
/** WebM `SegmentBase` addressing not resolved yet, or null for anything else. */
|
|
44
|
+
function asWebm(addressing) {
|
|
45
|
+
return addressing !== void 0 && isUnresolved(addressing) && addressing.format === "webm" ? addressing : null;
|
|
46
|
+
}
|
|
47
|
+
/** Loops a message back into the bus through a zero-delay schedule effect. */
|
|
48
|
+
function feed(message) {
|
|
49
|
+
return scheduled("webm:loopback", message);
|
|
50
|
+
}
|
|
51
|
+
/** A copy of `record` without `key`. */
|
|
52
|
+
function without(record, key) {
|
|
53
|
+
const copy = _objectSpread2({}, record);
|
|
54
|
+
delete copy[key];
|
|
55
|
+
return copy;
|
|
56
|
+
}
|
|
57
|
+
/** The slice with every trace of one rendition's index gone, its in-flight tokens too. */
|
|
58
|
+
function forget(state, renditionId) {
|
|
59
|
+
const pending = _objectSpread2({}, state.pending);
|
|
60
|
+
delete pending[`${INIT_TOKEN}${renditionId}`];
|
|
61
|
+
delete pending[`${CUES_TOKEN}${renditionId}`];
|
|
62
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
63
|
+
pending,
|
|
64
|
+
asked: without(state.asked, renditionId),
|
|
65
|
+
inits: without(state.inits, renditionId),
|
|
66
|
+
cues: without(state.cues, renditionId)
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** The error a WebM index that cannot be read reports. */
|
|
70
|
+
function invalid(renditionId, reason) {
|
|
71
|
+
return {
|
|
72
|
+
category: "media",
|
|
73
|
+
code: "MEDIA_CONTAINER_INVALID",
|
|
74
|
+
fatal: false,
|
|
75
|
+
recoverable: false,
|
|
76
|
+
context: {
|
|
77
|
+
renditionId,
|
|
78
|
+
reason
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* An index that failed to load or could not be read. The rendition is
|
|
84
|
+
* excluded until its retry, as the DASH adapter does for a `sidx`. When
|
|
85
|
+
* that leaves a media track with no rendition, the load fails.
|
|
86
|
+
*/
|
|
87
|
+
function unavailable(state, kernel, renditionId, error, retryMs) {
|
|
88
|
+
var _findRendition;
|
|
89
|
+
const failed = _objectSpread2(_objectSpread2({}, state.failed), {}, { [renditionId]: true });
|
|
90
|
+
const next = _objectSpread2(_objectSpread2({}, forget(state, renditionId)), {}, { failed });
|
|
91
|
+
const effects = [{
|
|
92
|
+
kind: "emit",
|
|
93
|
+
event: "error",
|
|
94
|
+
payload: {
|
|
95
|
+
category: error.category,
|
|
96
|
+
code: error.code,
|
|
97
|
+
fatal: false,
|
|
98
|
+
recoverable: false,
|
|
99
|
+
renditionId
|
|
100
|
+
}
|
|
101
|
+
}];
|
|
102
|
+
const track = kernel.presentation === null ? null : (_findRendition = findRendition(kernel.presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.track;
|
|
103
|
+
const media = (track === null || track === void 0 ? void 0 : track.contentType) === "video" || (track === null || track === void 0 ? void 0 : track.contentType) === "audio";
|
|
104
|
+
if (track != null && media && track.renditions.every((r) => r.id in failed)) return [next, [...effects, feed({
|
|
105
|
+
type: "MANIFEST_FAILED",
|
|
106
|
+
error: _objectSpread2(_objectSpread2({}, error), {}, { fatal: true })
|
|
107
|
+
})]];
|
|
108
|
+
effects.push(feed({
|
|
109
|
+
type: "CONSTRAIN",
|
|
110
|
+
source: UNAVAILABLE,
|
|
111
|
+
constraint: { excludeIds: Object.keys(failed) }
|
|
112
|
+
}));
|
|
113
|
+
if (Number.isFinite(retryMs)) effects.push(tickAfter(`${RETRY_TOKEN}${renditionId}`, retryMs));
|
|
114
|
+
return [next, effects];
|
|
115
|
+
}
|
|
116
|
+
/** The retry of a failed index: the rendition returns to arbitration and is fetched when needed. */
|
|
117
|
+
function retry(state, renditionId) {
|
|
118
|
+
if (!(renditionId in state.failed)) return [state, []];
|
|
119
|
+
const failed = without(state.failed, renditionId);
|
|
120
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, { failed }), [feed({
|
|
121
|
+
type: "CONSTRAIN",
|
|
122
|
+
source: UNAVAILABLE,
|
|
123
|
+
constraint: { excludeIds: Object.keys(failed) }
|
|
124
|
+
})]];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* One fetched part of an index. Once both parts of a rendition are read,
|
|
128
|
+
* its segments go to the kernel as a PLAYLIST_REFRESHED, which merges them
|
|
129
|
+
* as it merges a resolved `sidx`.
|
|
130
|
+
*/
|
|
131
|
+
function received(state, kernel, token, bytes, retryMs) {
|
|
132
|
+
var _rendition$rendition$;
|
|
133
|
+
const renditionId = state.pending[token];
|
|
134
|
+
let next = _objectSpread2(_objectSpread2({}, state), {}, { pending: without(state.pending, token) });
|
|
135
|
+
const rendition = kernel.presentation === null ? null : findRendition(kernel.presentation, renditionId);
|
|
136
|
+
const addressing = asWebm(rendition === null || rendition === void 0 ? void 0 : rendition.rendition.segments);
|
|
137
|
+
const initRange = rendition === null || rendition === void 0 || (_rendition$rendition$ = rendition.rendition.init) === null || _rendition$rendition$ === void 0 ? void 0 : _rendition$rendition$.byteRange;
|
|
138
|
+
if (addressing === null || initRange === void 0) return [forget(next, renditionId), []];
|
|
139
|
+
const data = new Uint8Array(bytes);
|
|
140
|
+
if (token.startsWith(INIT_TOKEN)) {
|
|
141
|
+
const init = readInit(data);
|
|
142
|
+
if (init === null) return unavailable(next, kernel, renditionId, invalid(renditionId, "no WebM Info"), retryMs);
|
|
143
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { inits: _objectSpread2(_objectSpread2({}, next.inits), {}, { [renditionId]: init }) });
|
|
144
|
+
} else {
|
|
145
|
+
const cues = readCues(data);
|
|
146
|
+
if (cues === null) return unavailable(next, kernel, renditionId, invalid(renditionId, "no WebM Cues"), retryMs);
|
|
147
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { cues: _objectSpread2(_objectSpread2({}, next.cues), {}, { [renditionId]: cues }) });
|
|
148
|
+
}
|
|
149
|
+
const init = next.inits[renditionId];
|
|
150
|
+
const cues = next.cues[renditionId];
|
|
151
|
+
if (init === void 0 || cues === void 0) return [next, []];
|
|
152
|
+
const segments = cuesToSegments(init, initRange, cues, addressing);
|
|
153
|
+
if (segments.length === 0) return unavailable(next, kernel, renditionId, invalid(renditionId, "WebM Cues hold no segment"), retryMs);
|
|
154
|
+
return [_objectSpread2(_objectSpread2({}, next), {}, {
|
|
155
|
+
inits: without(next.inits, renditionId),
|
|
156
|
+
cues: without(next.cues, renditionId)
|
|
157
|
+
}), [feed({
|
|
158
|
+
type: "PLAYLIST_REFRESHED",
|
|
159
|
+
trackId: renditionId,
|
|
160
|
+
renditionId,
|
|
161
|
+
mediaSequence: 0,
|
|
162
|
+
segments
|
|
163
|
+
})]];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The renditions whose index the selection needs and this slice has not
|
|
167
|
+
* asked for: the same set the DASH adapter resolves for a `sidx`, the
|
|
168
|
+
* playing video rendition and its ladder neighbours, and every rendition
|
|
169
|
+
* of the active audio and text tracks.
|
|
170
|
+
*/
|
|
171
|
+
function needed(state, kernel) {
|
|
172
|
+
const out = [];
|
|
173
|
+
for (const { rendition } of activeRenditions(kernel, [
|
|
174
|
+
"video",
|
|
175
|
+
"audio",
|
|
176
|
+
"text"
|
|
177
|
+
], kernel.quality.active)) {
|
|
178
|
+
var _rendition$init;
|
|
179
|
+
if (asWebm(rendition.segments) === null || ((_rendition$init = rendition.init) === null || _rendition$init === void 0 ? void 0 : _rendition$init.byteRange) === void 0) continue;
|
|
180
|
+
if (rendition.id in state.asked || rendition.id in state.failed) continue;
|
|
181
|
+
out.push(rendition);
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
/** The slice reducer. Pure: it reads bytes from facts and answers with effects. */
|
|
186
|
+
const createReduceWebm = (retryMs) => (slice, msg, kernel) => {
|
|
187
|
+
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
188
|
+
if (msg.type === "LOAD" || msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
|
|
189
|
+
if (msg.type === "TICK" && msg.token.startsWith(RETRY_TOKEN)) return retry(state, msg.token.slice(11));
|
|
190
|
+
if (msg.type === "PLAYLIST_REFRESHED" && msg.renditionId !== void 0) {
|
|
191
|
+
if (msg.renditionId in state.asked) return [forget(state, msg.renditionId), []];
|
|
192
|
+
}
|
|
193
|
+
if (msg.type === "SEGMENT_LOADED" && msg.trackId in state.pending) return received(state, kernel, msg.trackId, msg.bytes, retryMs);
|
|
194
|
+
if (msg.type === "SEGMENT_FAILED" && msg.trackId in state.pending) {
|
|
195
|
+
const renditionId = state.pending[msg.trackId];
|
|
196
|
+
return unavailable(state, kernel, renditionId, msg.error, retryMs);
|
|
197
|
+
}
|
|
198
|
+
if (kernel.lifecycle.phase !== "ready" || kernel.presentation === null) return [state, []];
|
|
199
|
+
const key = `${kernel.quality.version}:${kernel.quality.active}`;
|
|
200
|
+
if (key === state.seen && msg.type !== "RESUME") return [state, []];
|
|
201
|
+
const effects = [];
|
|
202
|
+
const pending = _objectSpread2({}, state.pending);
|
|
203
|
+
const asked = _objectSpread2({}, state.asked);
|
|
204
|
+
for (const rendition of needed(state, kernel)) {
|
|
205
|
+
const addressing = asWebm(rendition.segments);
|
|
206
|
+
const init = rendition.init;
|
|
207
|
+
asked[rendition.id] = true;
|
|
208
|
+
for (const [prefix, url, range] of [[
|
|
209
|
+
INIT_TOKEN,
|
|
210
|
+
init.url,
|
|
211
|
+
init.byteRange
|
|
212
|
+
], [
|
|
213
|
+
CUES_TOKEN,
|
|
214
|
+
addressing.url,
|
|
215
|
+
addressing.indexRange
|
|
216
|
+
]]) {
|
|
217
|
+
const token = `${prefix}${rendition.id}`;
|
|
218
|
+
pending[token] = rendition.id;
|
|
219
|
+
effects.push(_objectSpread2(_objectSpread2({
|
|
220
|
+
kind: "fetch",
|
|
221
|
+
token,
|
|
222
|
+
url
|
|
223
|
+
}, range !== void 0 ? { range } : {}), {}, { renditionId: rendition.id }));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
227
|
+
pending,
|
|
228
|
+
asked,
|
|
229
|
+
seen: key
|
|
230
|
+
}), effects];
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* The stage factory. Add it beside a DASH adapter:
|
|
234
|
+
* `mattebox({ stages: [dashCmaf(), webm()] })`.
|
|
235
|
+
*/
|
|
236
|
+
function webm(options = {}) {
|
|
237
|
+
var _options$unavailableR;
|
|
238
|
+
const retryMs = ((_options$unavailableR = options.unavailableRetrySeconds) !== null && _options$unavailableR !== void 0 ? _options$unavailableR : RETRY_SECONDS) * 1e3;
|
|
239
|
+
return {
|
|
240
|
+
name: "webm",
|
|
241
|
+
provides: [
|
|
242
|
+
"webm",
|
|
243
|
+
{
|
|
244
|
+
contentType: "video",
|
|
245
|
+
mimeType: "video/webm"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
contentType: "audio",
|
|
249
|
+
mimeType: "audio/webm"
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
requires: ["dash-cmaf"],
|
|
253
|
+
install(ctx) {
|
|
254
|
+
ctx.reduce("webm", createReduceWebm(retryMs));
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
export { createReduceWebm, webm as default };
|
|
@@ -642,9 +642,37 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
642
642
|
payload: { available }
|
|
643
643
|
}]];
|
|
644
644
|
}
|
|
645
|
+
case "SET_PROJECTION": {
|
|
646
|
+
if (state.presentation === null) return reject(state, msg.type, "no source");
|
|
647
|
+
const site = findRendition(state.presentation, msg.renditionId);
|
|
648
|
+
if (site === null) return reject(state, msg.type, `unknown rendition: ${msg.renditionId}`);
|
|
649
|
+
if (site.rendition.projection !== void 0) return reject(state, msg.type, `projection exists: ${msg.renditionId}`);
|
|
650
|
+
const projections = new Map(state.tracks.projections).set(msg.renditionId, msg.projection);
|
|
651
|
+
const presentation = withProjections(state.presentation, projections);
|
|
652
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
653
|
+
presentation,
|
|
654
|
+
tracks: _objectSpread2(_objectSpread2({}, state.tracks), {}, { projections })
|
|
655
|
+
}), [{
|
|
656
|
+
kind: "emit",
|
|
657
|
+
event: "presentation:changed",
|
|
658
|
+
payload: { id: presentation.id }
|
|
659
|
+
}]];
|
|
660
|
+
}
|
|
645
661
|
}
|
|
646
662
|
}
|
|
647
663
|
/**
|
|
664
|
+
* Gives every rendition SET_PROJECTION named its projection, where the
|
|
665
|
+
* presentation states none. A playlist merge hands the reducer the
|
|
666
|
+
* adapter's presentation, which knows nothing of them.
|
|
667
|
+
*/
|
|
668
|
+
function withProjections(presentation, projections) {
|
|
669
|
+
if (projections === void 0 || projections.size === 0) return presentation;
|
|
670
|
+
return _objectSpread2(_objectSpread2({}, presentation), {}, { periods: presentation.periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, { tracks: period.tracks.map((track) => _objectSpread2(_objectSpread2({}, track), {}, { renditions: track.renditions.map((rendition) => {
|
|
671
|
+
const projection = projections.get(rendition.id);
|
|
672
|
+
return projection === void 0 || rendition.projection !== void 0 ? rendition : _objectSpread2(_objectSpread2({}, rendition), {}, { projection });
|
|
673
|
+
}) })) })) });
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
648
676
|
* Joins the tracks ADD_TRACK added to every period that lacks them. A
|
|
649
677
|
* playlist merge hands the reducer the adapter's presentation, which knows
|
|
650
678
|
* nothing of them.
|
|
@@ -696,7 +724,7 @@ function behindTrick(tracks, track, previous) {
|
|
|
696
724
|
* merged into it. Activates default tracks and reports what changed.
|
|
697
725
|
*/
|
|
698
726
|
function loadPresentation(state, merged, undecodableIds = /* @__PURE__ */ new Set()) {
|
|
699
|
-
const presentation = withAdded(merged, state.tracks.added);
|
|
727
|
+
const presentation = withProjections(withAdded(merged, state.tracks.added), state.tracks.projections);
|
|
700
728
|
const available = [];
|
|
701
729
|
for (const period of presentation.periods) for (const track of period.tracks) available.push(track.id);
|
|
702
730
|
const inflight = new Map(state.scheduling.inflight);
|
|
@@ -1441,7 +1469,8 @@ const COMMAND_TYPES = {
|
|
|
1441
1469
|
THROUGHPUT_HINT: true,
|
|
1442
1470
|
RESOLVE_RENDITION: true,
|
|
1443
1471
|
ABORT_INFLIGHT: true,
|
|
1444
|
-
ADD_TRACK: true
|
|
1472
|
+
ADD_TRACK: true,
|
|
1473
|
+
SET_PROJECTION: true
|
|
1445
1474
|
};
|
|
1446
1475
|
function isCommand(msg) {
|
|
1447
1476
|
return msg.type in COMMAND_TYPES;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chapters from "../../stages/chapters/index.js";
|
|
2
2
|
import cmsd from "../../stages/cmsd/index.js";
|
|
3
3
|
import hdr from "../../stages/hdr/index.js";
|
|
4
|
+
import projection from "../../stages/projection/index.js";
|
|
4
5
|
import qoe from "../../stages/qoe/index.js";
|
|
5
6
|
import renditionNames from "../../stages/rendition-names/index.js";
|
|
6
7
|
import textCea708 from "../../stages/text-cea708/index.js";
|
|
@@ -24,8 +25,9 @@ import { tsTier } from "../tiers/ts.js";
|
|
|
24
25
|
* streams carry 608 beside them, which the base reads), TTML subtitles
|
|
25
26
|
* (opt-in by the owner's decision), HDR by capability (it excludes HDR
|
|
26
27
|
* where nothing is known, which a page may not want by default), local
|
|
27
|
-
* QoE metrics, CMSD (it acts on response headers a CDN must expose),
|
|
28
|
-
* localized rendition names (a menu reads them)
|
|
28
|
+
* QoE metrics, CMSD (it acts on response headers a CDN must expose),
|
|
29
|
+
* localized rendition names (a menu reads them), and the projection of a
|
|
30
|
+
* 360° init segment (most programmes are flat).
|
|
29
31
|
* CMCD is in no preset: it changes every request, which costs a page that
|
|
30
32
|
* never asked for it. A page adds the stage.
|
|
31
33
|
* Feature parity with
|
|
@@ -48,6 +50,7 @@ const preset = definePreset("full", () => [
|
|
|
48
50
|
hdr(),
|
|
49
51
|
qoe(),
|
|
50
52
|
cmsd(),
|
|
51
|
-
renditionNames()
|
|
53
|
+
renditionNames(),
|
|
54
|
+
projection()
|
|
52
55
|
]);
|
|
53
56
|
export { preset as default };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import webm from "../../containers/webm/index.js";
|
|
1
2
|
import dashLl from "../../protocols/dash-ll/index.js";
|
|
2
3
|
// src/presets/tiers/dash-ll.ts
|
|
3
4
|
/**
|
|
@@ -12,6 +13,6 @@ import dashLl from "../../protocols/dash-ll/index.js";
|
|
|
12
13
|
* plays it.
|
|
13
14
|
*/
|
|
14
15
|
function dashLlLine() {
|
|
15
|
-
return [dashLl()];
|
|
16
|
+
return [dashLl(), webm()];
|
|
16
17
|
}
|
|
17
18
|
export { dashLlLine };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import webm from "../../containers/webm/index.js";
|
|
1
2
|
import dashCmaf from "../../protocols/dash-cmaf/index.js";
|
|
2
3
|
import dashLive from "../../protocols/dash-live/index.js";
|
|
3
4
|
// src/presets/tiers/dash.ts
|
|
@@ -7,8 +8,12 @@ import dashLive from "../../protocols/dash-live/index.js";
|
|
|
7
8
|
* lazy chunks then gives each preset its stages and no others. Each group is
|
|
8
9
|
* a function so a preset gets fresh stage instances.
|
|
9
10
|
*/
|
|
10
|
-
/** DASH on demand and live. */
|
|
11
|
+
/** DASH on demand and live, with WebM next to MP4, as dash.js and Shaka Player play it. */
|
|
11
12
|
function dashLine() {
|
|
12
|
-
return [
|
|
13
|
+
return [
|
|
14
|
+
dashCmaf(),
|
|
15
|
+
dashLive(),
|
|
16
|
+
webm()
|
|
17
|
+
];
|
|
13
18
|
}
|
|
14
19
|
export { dashLine };
|
|
@@ -67,7 +67,8 @@ function neededIndexes(state, kernel) {
|
|
|
67
67
|
"audio",
|
|
68
68
|
"text"
|
|
69
69
|
], kernel.quality.active)) {
|
|
70
|
-
|
|
70
|
+
const sidx = asSidx(rendition.segments);
|
|
71
|
+
if (sidx === null || sidx.format === "webm") continue;
|
|
71
72
|
if (asked.has(rendition.id) || rendition.id in state.failed) continue;
|
|
72
73
|
needed.push(rendition);
|
|
73
74
|
}
|
|
@@ -119,8 +120,13 @@ function retry(state, renditionId) {
|
|
|
119
120
|
constraint: { excludeIds: Object.keys(failed) }
|
|
120
121
|
})]];
|
|
121
122
|
}
|
|
122
|
-
/**
|
|
123
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The slice reducer. `lowLatency` reads the MPD as dash-ll does.
|
|
125
|
+
* `capabilities` is the composition's, read once at install: they are
|
|
126
|
+
* fixed when the engine is built. A stage that provides `video/webm` keeps
|
|
127
|
+
* WebM Representations in.
|
|
128
|
+
*/
|
|
129
|
+
const createReduceDash = (retryMs, lowLatency = false, capabilities = []) => (slice, msg, kernel) => {
|
|
124
130
|
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
125
131
|
if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
|
|
126
132
|
manifestUrl: msg.url,
|
|
@@ -133,7 +139,7 @@ const createReduceDash = (retryMs, lowLatency = false) => (slice, msg, kernel) =
|
|
|
133
139
|
let warnings = [];
|
|
134
140
|
const fact = manifestFact(msg.bytes, (_msg$url = msg.url) !== null && _msg$url !== void 0 ? _msg$url : state.manifestUrl, (text) => claims(state, text), (text, url) => {
|
|
135
141
|
var _result$warnings;
|
|
136
|
-
const result = parse(text, url, lowLatency);
|
|
142
|
+
const result = parse(text, url, lowLatency, capabilities);
|
|
137
143
|
if (result.presentation !== null) warnings = (_result$warnings = result.warnings) !== null && _result$warnings !== void 0 ? _result$warnings : [];
|
|
138
144
|
return result;
|
|
139
145
|
});
|
|
@@ -249,7 +255,7 @@ function dashCmaf(options = {}) {
|
|
|
249
255
|
name: "dash-cmaf",
|
|
250
256
|
provides: ["dash-cmaf", ...MANIFEST_TYPES],
|
|
251
257
|
install(ctx) {
|
|
252
|
-
ctx.reduce("dash", createReduceDash(retryMs));
|
|
258
|
+
ctx.reduce("dash", createReduceDash(retryMs, false, ctx.capabilities()));
|
|
253
259
|
return installDashPeriods(ctx);
|
|
254
260
|
}
|
|
255
261
|
};
|
|
@@ -260,6 +260,28 @@ function supplementalOf(representation, adaptationSet) {
|
|
|
260
260
|
for (const element of [representation, adaptationSet]) for (const attribute of Array.from(element.attributes)) if (attribute.localName === "supplementalCodecs") return { supplementalCodecs: attribute.value };
|
|
261
261
|
return {};
|
|
262
262
|
}
|
|
263
|
+
const OMAF_PROJECTION = "urn:mpeg:mpegI:omaf:2017:pf";
|
|
264
|
+
/**
|
|
265
|
+
* The OMAF projection format descriptor (ISO/IEC 23090-2 §8.3.2), on the
|
|
266
|
+
* Representation or its AdaptationSet, as EssentialProperty or
|
|
267
|
+
* SupplementalProperty: 3GPP TS 26.118 §5.2.2.3 uses the second, its
|
|
268
|
+
* advanced profile and the OMAF reference software the first.
|
|
269
|
+
* `omaf:projection_type` 0 is equirectangular, 1 a cube map, which the IR
|
|
270
|
+
* does not name. Read by local name, since the prefix is the manifest's
|
|
271
|
+
* choice. OMAF has no half-equirectangular type. Sources:
|
|
272
|
+
* https://www.etsi.org/deliver/etsi_ts/126100_126199/126118/17.00.00_60/ts_126118v170000p.pdf
|
|
273
|
+
* https://github.com/nokiatech/omaf/blob/d08ad5b82e021696483bc6fece804f915b5b389c/Player/Sources/Player/DashProvider/NVRMPDExtension.cpp#L25-L34
|
|
274
|
+
*/
|
|
275
|
+
function projectionOf(representation, adaptationSet) {
|
|
276
|
+
for (const element of [representation, adaptationSet]) for (const property of [...children(element, "EssentialProperty"), ...children(element, "SupplementalProperty")]) {
|
|
277
|
+
if (attr(property, "schemeIdUri") !== OMAF_PROJECTION) continue;
|
|
278
|
+
for (const attribute of Array.from(property.attributes)) {
|
|
279
|
+
if (attribute.localName !== "projection_type") continue;
|
|
280
|
+
return attribute.value.trim().split(/\s+/)[0] === "0" ? { projection: "equirectangular" } : {};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return {};
|
|
284
|
+
}
|
|
263
285
|
function videoRangeOf(representation, adaptationSet, codecs) {
|
|
264
286
|
for (const element of [representation, adaptationSet]) for (const property of [...children(element, "EssentialProperty"), ...children(element, "SupplementalProperty")]) {
|
|
265
287
|
if (attr(property, "schemeIdUri") !== TRANSFER_CHARACTERISTICS) continue;
|
|
@@ -557,7 +579,7 @@ function followsOf(adaptationSet) {
|
|
|
557
579
|
return ((_attr21 = attr(property, "value")) !== null && _attr21 !== void 0 ? _attr21 : "").split(/[\s,]+/).filter((v) => v !== "");
|
|
558
580
|
});
|
|
559
581
|
}
|
|
560
|
-
function parsePeriod(periodElement, span, index, mpdBase, isLive, availability) {
|
|
582
|
+
function parsePeriod(periodElement, span, index, mpdBase, isLive, availability, capabilities) {
|
|
561
583
|
var _attr30;
|
|
562
584
|
const matching = /* @__PURE__ */ new Map();
|
|
563
585
|
const periodStart = span.start;
|
|
@@ -586,7 +608,8 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
|
|
|
586
608
|
if (id === null || bandwidth === null) continue;
|
|
587
609
|
const repBase = applyBaseUrl(representation, asBase);
|
|
588
610
|
const mimeType = (_ref2 = (_attr22 = attr(representation, "mimeType")) !== null && _attr22 !== void 0 ? _attr22 : asMime) !== null && _ref2 !== void 0 ? _ref2 : "video/mp4";
|
|
589
|
-
|
|
611
|
+
const webm = /\/(webm|x-matroska)$/.test(mimeType);
|
|
612
|
+
if (webm && !capabilities.some((c) => typeof c !== "string" && c.mimeType === mimeType)) continue;
|
|
590
613
|
trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
|
|
591
614
|
const segmentBase = children(representation, "SegmentBase")[0];
|
|
592
615
|
if (segmentBase !== void 0) {
|
|
@@ -597,12 +620,13 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
|
|
|
597
620
|
const pto = numberAttr(segmentBase, "presentationTimeOffset");
|
|
598
621
|
const initElement = children(segmentBase, "Initialization")[0];
|
|
599
622
|
const initRange = initElement !== void 0 ? parseByteRange(attr(initElement, "range")) : null;
|
|
600
|
-
|
|
623
|
+
if (webm && initRange === null) continue;
|
|
624
|
+
const sidxSegments = _objectSpread2(_objectSpread2({
|
|
601
625
|
kind: "sidx",
|
|
602
626
|
url: repBase,
|
|
603
627
|
indexRange,
|
|
604
628
|
timescale: baseTimescale
|
|
605
|
-
}, pto !== null && pto !== 0 ? { presentationTimeOffset: pto / baseTimescale } : {});
|
|
629
|
+
}, pto !== null && pto !== 0 ? { presentationTimeOffset: pto / baseTimescale } : {}), webm ? { format: "webm" } : {});
|
|
606
630
|
const sidxInit = initRange !== null ? {
|
|
607
631
|
url: repBase,
|
|
608
632
|
byteRange: initRange
|
|
@@ -610,13 +634,13 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
|
|
|
610
634
|
const w = numberAttr(representation, "width");
|
|
611
635
|
const h = numberAttr(representation, "height");
|
|
612
636
|
const fr = (_parseFrameRate = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate !== void 0 ? _parseFrameRate : parseFrameRate(attr(adaptationSet, "frameRate"));
|
|
613
|
-
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
637
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
614
638
|
id,
|
|
615
639
|
bitrate: bandwidth,
|
|
616
640
|
codecs: (_attr23 = attr(representation, "codecs")) !== null && _attr23 !== void 0 ? _attr23 : asCodecs,
|
|
617
641
|
mimeType,
|
|
618
642
|
segments: sidxSegments
|
|
619
|
-
}, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}), videoRangeOf(representation, adaptationSet, (_attr24 = attr(representation, "codecs")) !== null && _attr24 !== void 0 ? _attr24 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
|
|
643
|
+
}, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}), videoRangeOf(representation, adaptationSet, (_attr24 = attr(representation, "codecs")) !== null && _attr24 !== void 0 ? _attr24 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)), projectionOf(representation, adaptationSet)));
|
|
620
644
|
continue;
|
|
621
645
|
}
|
|
622
646
|
const list = segmentListOf([
|
|
@@ -628,13 +652,13 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
|
|
|
628
652
|
if (list !== null) {
|
|
629
653
|
var _attr25, _attr26;
|
|
630
654
|
const segments = list.segments.map((segment) => segment.duration === 0 && periodDuration !== null ? _objectSpread2(_objectSpread2({}, segment), {}, { duration: periodDuration }) : segment);
|
|
631
|
-
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
655
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
632
656
|
id,
|
|
633
657
|
bitrate: bandwidth,
|
|
634
658
|
codecs: (_attr25 = attr(representation, "codecs")) !== null && _attr25 !== void 0 ? _attr25 : asCodecs,
|
|
635
659
|
mimeType,
|
|
636
660
|
segments
|
|
637
|
-
}, list.init !== null ? { init: list.init } : {}), numberAttr(representation, "width") !== null ? { width: numberAttr(representation, "width") } : {}), numberAttr(representation, "height") !== null ? { height: numberAttr(representation, "height") } : {}), videoRangeOf(representation, adaptationSet, (_attr26 = attr(representation, "codecs")) !== null && _attr26 !== void 0 ? _attr26 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
|
|
661
|
+
}, list.init !== null ? { init: list.init } : {}), numberAttr(representation, "width") !== null ? { width: numberAttr(representation, "width") } : {}), numberAttr(representation, "height") !== null ? { height: numberAttr(representation, "height") } : {}), videoRangeOf(representation, adaptationSet, (_attr26 = attr(representation, "codecs")) !== null && _attr26 !== void 0 ? _attr26 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)), projectionOf(representation, adaptationSet)));
|
|
638
662
|
continue;
|
|
639
663
|
}
|
|
640
664
|
const template = mergeTemplates([
|
|
@@ -682,13 +706,13 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive, availability)
|
|
|
682
706
|
const height = numberAttr(representation, "height");
|
|
683
707
|
const tiles = tileGridOf(representation, adaptationSet, width, height);
|
|
684
708
|
const playoutRate = trick ? (_numberAttr15 = numberAttr(representation, "maxPlayoutRate")) !== null && _numberAttr15 !== void 0 ? _numberAttr15 : asPlayoutRate : null;
|
|
685
|
-
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
709
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
686
710
|
id,
|
|
687
711
|
bitrate: bandwidth,
|
|
688
712
|
codecs: (_attr28 = attr(representation, "codecs")) !== null && _attr28 !== void 0 ? _attr28 : asCodecs,
|
|
689
713
|
mimeType,
|
|
690
714
|
segments
|
|
691
|
-
}, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), videoRangeOf(representation, adaptationSet, (_attr29 = attr(representation, "codecs")) !== null && _attr29 !== void 0 ? _attr29 : asCodecs)), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
|
|
715
|
+
}, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), videoRangeOf(representation, adaptationSet, (_attr29 = attr(representation, "codecs")) !== null && _attr29 !== void 0 ? _attr29 : asCodecs)), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)), projectionOf(representation, adaptationSet)));
|
|
692
716
|
}
|
|
693
717
|
if (renditions.length === 0) continue;
|
|
694
718
|
const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
|
|
@@ -814,8 +838,12 @@ function serviceOf(mpd) {
|
|
|
814
838
|
* dash.js's live delay: the ServiceDescription target, else
|
|
815
839
|
* `@suggestedPresentationDelay`, else four `@maxSegmentDuration`, else four
|
|
816
840
|
* `@minBufferTime`.
|
|
841
|
+
*
|
|
842
|
+
* `capabilities` is the composition's. A WebM Representation is kept
|
|
843
|
+
* only when a stage provides its MIME type as a content handler, as the
|
|
844
|
+
* `webm` container does.
|
|
817
845
|
*/
|
|
818
|
-
function parse(text, baseUrl, lowLatency = false) {
|
|
846
|
+
function parse(text, baseUrl, lowLatency = false, capabilities = []) {
|
|
819
847
|
var _flat$tracks, _flat$events;
|
|
820
848
|
let doc;
|
|
821
849
|
try {
|
|
@@ -887,7 +915,7 @@ function parse(text, baseUrl, lowLatency = false) {
|
|
|
887
915
|
const parsed = [];
|
|
888
916
|
for (let i = 0; i < periodElements.length; i += 1) {
|
|
889
917
|
if (i > 0 && isLive) break;
|
|
890
|
-
const result = parsePeriod(periodElements[i], spans[i], i, mpdBase, isLive, availability);
|
|
918
|
+
const result = parsePeriod(periodElements[i], spans[i], i, mpdBase, isLive, availability, capabilities);
|
|
891
919
|
if ("error" in result) return {
|
|
892
920
|
presentation: null,
|
|
893
921
|
error: result.error
|
|
@@ -143,8 +143,11 @@ function reloadFailed(state, presentation, cause) {
|
|
|
143
143
|
tickPending: true
|
|
144
144
|
}), [tick((_presentation$live$up = presentation.live.updatePeriod) !== null && _presentation$live$up !== void 0 ? _presentation$live$up : 4)]];
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
147
|
-
|
|
146
|
+
/**
|
|
147
|
+
* The slice reducer. `lowLatency` reloads the MPD as dash-ll reads it.
|
|
148
|
+
* `capabilities` is the composition's, which the MPD parse reads.
|
|
149
|
+
*/
|
|
150
|
+
const createReduceDashLive = (lowLatency = false, capabilities = []) => (slice, msg, kernel) => {
|
|
148
151
|
let state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
149
152
|
if ((msg.type === "TIME_UPDATE" || msg.type === "SEGMENT_LOADED") && msg.wallClock !== void 0) state = _objectSpread2(_objectSpread2({}, state), {}, { lastWallClock: msg.wallClock });
|
|
150
153
|
if (msg.type === "SEGMENT_LOADED" && (msg.trackId === "manifest" || msg.trackId === MPD_TOKEN) && msg.serverDate !== void 0 && msg.wallClock !== void 0) state = _objectSpread2(_objectSpread2({}, state), {}, { mpdSkew: msg.serverDate - msg.wallClock });
|
|
@@ -256,7 +259,7 @@ const createReduceDashLive = (lowLatency = false) => (slice, msg, kernel) => {
|
|
|
256
259
|
var _msg$url;
|
|
257
260
|
if (state.manifestUrl === null) return [state, []];
|
|
258
261
|
const base = (_msg$url = msg.url) !== null && _msg$url !== void 0 ? _msg$url : state.manifestUrl;
|
|
259
|
-
const result = parse(new TextDecoder().decode(msg.bytes), base, lowLatency);
|
|
262
|
+
const result = parse(new TextDecoder().decode(msg.bytes), base, lowLatency, capabilities);
|
|
260
263
|
if (result.presentation === null) return reloadFailed(state, kernel.presentation, result.error.code);
|
|
261
264
|
const effects = [];
|
|
262
265
|
const hash = hashOf(msg.bytes);
|
|
@@ -296,7 +299,7 @@ function dashLive() {
|
|
|
296
299
|
provides: ["dash-live"],
|
|
297
300
|
requires: ["dash-cmaf"],
|
|
298
301
|
install(ctx) {
|
|
299
|
-
ctx.reduce("dash-live", createReduceDashLive());
|
|
302
|
+
ctx.reduce("dash-live", createReduceDashLive(false, ctx.capabilities()));
|
|
300
303
|
registerLiveNamespace(ctx);
|
|
301
304
|
}
|
|
302
305
|
};
|
|
@@ -30,8 +30,9 @@ function dashLl(options = {}) {
|
|
|
30
30
|
...MANIFEST_TYPES
|
|
31
31
|
],
|
|
32
32
|
install(ctx) {
|
|
33
|
-
ctx.
|
|
34
|
-
ctx.reduce("dash
|
|
33
|
+
const capabilities = ctx.capabilities();
|
|
34
|
+
ctx.reduce("dash", createReduceDash(retryMs, true, capabilities));
|
|
35
|
+
ctx.reduce("dash-live", createReduceDashLive(true, capabilities));
|
|
35
36
|
ctx.registerChunkSplitter(completeChunks);
|
|
36
37
|
registerLiveNamespace(ctx);
|
|
37
38
|
return installDashPeriods(ctx);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readProjection } from "../../containers/projection.js";
|
|
2
|
+
import { findRendition } from "../../kernel/presentation.js";
|
|
3
|
+
// src/stages/projection/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* projection as a loadable stage: a 360° video's projection from its init
|
|
6
|
+
* segment, for a rendition whose manifest states none. The boxes it reads
|
|
7
|
+
* are in `containers/projection`. It hands what it finds to the kernel with
|
|
8
|
+
* SET_PROJECTION, so the rendition carries `projection` as if the manifest
|
|
9
|
+
* had said it, and a player reads one field whatever the source.
|
|
10
|
+
*
|
|
11
|
+
* The init segment arrives before the video has its first frame, so the
|
|
12
|
+
* rendition carries the projection by the time the element fires
|
|
13
|
+
* `loadedmetadata`. A projection the manifest states wins: the stage reads
|
|
14
|
+
* nothing for that rendition.
|
|
15
|
+
*/
|
|
16
|
+
function projection() {
|
|
17
|
+
return {
|
|
18
|
+
name: "projection",
|
|
19
|
+
provides: ["projection"],
|
|
20
|
+
requires: ["mp4-box"],
|
|
21
|
+
install(ctx) {
|
|
22
|
+
ctx.registerTransform({
|
|
23
|
+
name: "projection",
|
|
24
|
+
order: 5,
|
|
25
|
+
transform(data, meta) {
|
|
26
|
+
if (meta.contentType !== "video" || !meta.isInit) return data;
|
|
27
|
+
const site = findRendition(ctx.getState().presentation, meta.renditionId);
|
|
28
|
+
if (site === null || site.rendition.projection !== void 0) return data;
|
|
29
|
+
const found = readProjection(data);
|
|
30
|
+
if (found !== null) ctx.dispatch({
|
|
31
|
+
type: "SET_PROJECTION",
|
|
32
|
+
renditionId: meta.renditionId,
|
|
33
|
+
projection: found
|
|
34
|
+
});
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export { projection as default };
|
|
@@ -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,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;AA+zBD,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAGjF;AA42BD;;;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;AA4VD,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,MAAM,GAAE,YAAiB,GACxB,OAAO,CAkGT"}
|