mattebox 0.11.0 → 0.12.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.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 +3 -3
- package/dist/es2015/index.js +24 -13
- package/dist/es2015/kernel/mse.js +8 -1
- package/dist/es2015/kernel/reducer.js +10 -7
- package/dist/es2015/kernel/rendition-select.js +89 -15
- package/dist/es2015/protocols/dash-cmaf/parse.js +104 -38
- package/dist/es2015/protocols/hls-cmaf/parse.js +57 -14
- package/dist/es2015/stages/abr/index.js +8 -2
- package/dist/es2015/stages/alt-audio/index.js +7 -5
- package/dist/es2015/stages/eme-core/index.js +9 -5
- package/dist/es2015/stages/eme-fairplay/index.js +17 -8
- package/dist/es2015/stages/text-cea608/decode.js +1 -1
- package/dist/es2015/stages/text-cea708/decode.js +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/dist/kernel/mse.d.ts.map +1 -1
- package/dist/kernel/mse.js +10 -1
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +11 -4
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/rendition-select.d.ts +29 -1
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +95 -19
- package/dist/kernel/rendition-select.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +67 -0
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +72 -13
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/stages/abr/index.d.ts.map +1 -1
- package/dist/stages/abr/index.js +14 -2
- package/dist/stages/abr/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts +3 -1
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +8 -5
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/eme-core/index.d.ts +7 -0
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +12 -5
- package/dist/stages/eme-core/index.js.map +1 -1
- package/dist/stages/eme-fairplay/index.d.ts +5 -0
- package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
- package/dist/stages/eme-fairplay/index.js +17 -6
- package/dist/stages/eme-fairplay/index.js.map +1 -1
- package/dist/stages/text-cea608/decode.d.ts.map +1 -1
- package/dist/stages/text-cea608/decode.js +4 -1
- package/dist/stages/text-cea608/decode.js.map +1 -1
- package/dist/stages/text-cea708/decode.d.ts.map +1 -1
- package/dist/stages/text-cea708/decode.js +8 -2
- package/dist/stages/text-cea708/decode.js.map +1 -1
- package/dist/types/ir.d.ts +25 -0
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/quality.d.ts +7 -0
- package/dist/types/quality.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/es2015/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createBus } from "./kernel/bus.js";
|
|
|
4
4
|
import { createEffectRunner } from "./kernel/effects.js";
|
|
5
5
|
import { cueFormat, normalizeMimeType } from "./kernel/mime.js";
|
|
6
6
|
import { findTrackSite, isTrick } from "./kernel/presentation.js";
|
|
7
|
-
import { availableGroups, canSwitchTo, createArbiter } from "./kernel/rendition-select.js";
|
|
7
|
+
import { activeAudio, availableGroups, canSwitchTo, createArbiter, exclusionsOf } from "./kernel/rendition-select.js";
|
|
8
8
|
import { createMseSink } from "./kernel/sinks/mse-sink.js";
|
|
9
9
|
import { createReducer, initialState, resolveConfig } from "./kernel/reducer.js";
|
|
10
10
|
import { createLifecycle } from "./kernel/lifecycle.js";
|
|
@@ -153,6 +153,7 @@ function mattebox(options) {
|
|
|
153
153
|
plays: (contentType, format) => bus.capabilities().some((c) => typeof c !== "string" && c.contentType === contentType && cueFormat(c.mimeType, c.codecs) === format)
|
|
154
154
|
});
|
|
155
155
|
const arbiter = createArbiter();
|
|
156
|
+
const offerArbiter = createArbiter();
|
|
156
157
|
const hooks = {
|
|
157
158
|
manifestTypes: composition.manifestTypes,
|
|
158
159
|
decodable
|
|
@@ -171,24 +172,30 @@ function mattebox(options) {
|
|
|
171
172
|
}
|
|
172
173
|
return [];
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
+
/**
|
|
176
|
+
* The arbitration, or with `offer`, the same without the numeric caps and
|
|
177
|
+
* the pin: what a viewer may pick from. A cap is a preference a pin may
|
|
178
|
+
* go past; an exclusion (codecs, ids, HDR) is what cannot play.
|
|
179
|
+
*/
|
|
180
|
+
function arbitrated(offer) {
|
|
175
181
|
var _state$presentation$c, _state$presentation;
|
|
176
182
|
const state = bus.getState();
|
|
177
|
-
|
|
183
|
+
const audio = activeAudio(state);
|
|
184
|
+
const constraints = offer ? exclusionsOf(state.quality.constraints) : state.quality.constraints;
|
|
185
|
+
return (offer ? offerArbiter : arbiter).run(_objectSpread2(_objectSpread2({
|
|
178
186
|
renditions: activeVideoRenditions(),
|
|
179
|
-
constraints
|
|
180
|
-
pinned: state.quality.pinned,
|
|
187
|
+
constraints,
|
|
188
|
+
pinned: offer ? null : state.quality.pinned,
|
|
181
189
|
current: state.quality.active,
|
|
182
190
|
couplings: (_state$presentation$c = (_state$presentation = state.presentation) === null || _state$presentation === void 0 ? void 0 : _state$presentation.couplings) !== null && _state$presentation$c !== void 0 ? _state$presentation$c : [],
|
|
183
191
|
activeTracks: state.tracks.active,
|
|
184
|
-
availableGroups: availableGroups(state)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}, state.quality.version);
|
|
192
|
+
availableGroups: availableGroups(state)
|
|
193
|
+
}, audio !== void 0 ? { audio } : {}), {}, { telemetry: {
|
|
194
|
+
throughputEwma: state.stats.throughputEwma,
|
|
195
|
+
throughputFastEwma: state.stats.throughputFastEwma,
|
|
196
|
+
current: state.quality.active,
|
|
197
|
+
currentTime: state.playback.currentTime
|
|
198
|
+
} }), `${state.quality.version}:${state.quality.active}`);
|
|
192
199
|
}
|
|
193
200
|
const facadeTarget = {};
|
|
194
201
|
const MEDIA_ERR = [
|
|
@@ -228,6 +235,10 @@ function mattebox(options) {
|
|
|
228
235
|
const ids = arbitrated().result.allowed;
|
|
229
236
|
return activeVideoRenditions().filter((r) => ids.includes(r.id));
|
|
230
237
|
},
|
|
238
|
+
get selectable() {
|
|
239
|
+
const ids = arbitrated(true).result.allowed;
|
|
240
|
+
return activeVideoRenditions().filter((r) => ids.includes(r.id));
|
|
241
|
+
},
|
|
231
242
|
get active() {
|
|
232
243
|
var _activeVideoRendition;
|
|
233
244
|
const id = bus.getState().quality.active;
|
|
@@ -51,6 +51,8 @@ function createMseController(options) {
|
|
|
51
51
|
let pendingDuration = null;
|
|
52
52
|
let pendingLiveRange = null;
|
|
53
53
|
let unobserveManaged = null;
|
|
54
|
+
/** The element's remote playback flag before the managed path set it; null when it did not. */
|
|
55
|
+
let remotePlaybackBefore = null;
|
|
54
56
|
const tracked = [];
|
|
55
57
|
function listen(target, type, fn) {
|
|
56
58
|
target.addEventListener(type, fn);
|
|
@@ -219,7 +221,10 @@ function createMseController(options) {
|
|
|
219
221
|
});
|
|
220
222
|
if (managed) {
|
|
221
223
|
unobserveManaged = evictor.observeManaged(ms, trimAllBackBuffers);
|
|
222
|
-
if (airplay === void 0)
|
|
224
|
+
if (airplay === void 0) {
|
|
225
|
+
remotePlaybackBefore = el.disableRemotePlayback;
|
|
226
|
+
el.disableRemotePlayback = true;
|
|
227
|
+
}
|
|
223
228
|
}
|
|
224
229
|
if (airplay !== void 0) {
|
|
225
230
|
var _airplay$type;
|
|
@@ -271,6 +276,7 @@ function createMseController(options) {
|
|
|
271
276
|
if (el !== null) {
|
|
272
277
|
for (const node of sourceNodes) node.remove();
|
|
273
278
|
sourceNodes = [];
|
|
279
|
+
if (remotePlaybackBefore !== null) el.disableRemotePlayback = remotePlaybackBefore;
|
|
274
280
|
if ("srcObject" in el) el.srcObject = null;
|
|
275
281
|
el.removeAttribute("src");
|
|
276
282
|
if (objectUrl !== null) {
|
|
@@ -283,6 +289,7 @@ function createMseController(options) {
|
|
|
283
289
|
element = null;
|
|
284
290
|
mediaSource = null;
|
|
285
291
|
managed = false;
|
|
292
|
+
remotePlaybackBefore = null;
|
|
286
293
|
attachOptions = void 0;
|
|
287
294
|
pendingEndOfStream = null;
|
|
288
295
|
pendingDuration = null;
|
|
@@ -5,9 +5,9 @@ import { findRendition, findTrackSite, isTrick } from "./presentation.js";
|
|
|
5
5
|
import { applyRefresh } from "./refresh.js";
|
|
6
6
|
import { reconciledOffset, segmentAtTime } from "./timeline.js";
|
|
7
7
|
import { bufferedEndFrom, reachesEnd, schedule } from "./scheduler.js";
|
|
8
|
-
import { availableGroups, canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
|
|
9
|
-
import { sbIdFor } from "./sinks/mse-sink.js";
|
|
10
8
|
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
|
|
9
|
+
import { activeAudio, audioGroup, audioInGroup, availableGroups, canSwitchTo, codecFamily, createArbiter, planPinApply, withDeadGroups } from "./rendition-select.js";
|
|
10
|
+
import { sbIdFor } from "./sinks/mse-sink.js";
|
|
11
11
|
//#region src/kernel/reducer.ts
|
|
12
12
|
const _excluded = ["pendingInit"];
|
|
13
13
|
const _excluded2 = ["repeat"];
|
|
@@ -1107,14 +1107,17 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
1107
1107
|
if (((_state$buffers$get$pe = (_state$buffers$get2 = state.buffers.get(sbId)) === null || _state$buffers$get2 === void 0 ? void 0 : _state$buffers$get2.pendingAppends) !== null && _state$buffers$get$pe !== void 0 ? _state$buffers$get$pe : 0) > 0) continue;
|
|
1108
1108
|
const bufferAhead = bufferedEndFrom((_state$buffers$get$ra2 = (_state$buffers$get3 = state.buffers.get(sbId)) === null || _state$buffers$get3 === void 0 ? void 0 : _state$buffers$get3.ranges) !== null && _state$buffers$get$ra2 !== void 0 ? _state$buffers$get$ra2 : [], state.playback.currentTime, GAP_TOLERANCE) - state.playback.currentTime;
|
|
1109
1109
|
const memoKey = hooks.abr == null ? state.quality.version : `${state.quality.version}:${Math.round(state.stats.throughputEwma / 25e3)}:${Math.round(state.stats.throughputFastEwma / 25e3)}:${Math.round(((_state$stats$serverTh = state.stats.serverThroughput) !== null && _state$stats$serverTh !== void 0 ? _state$stats$serverTh : 0) / 25e3)}:${Math.round(bufferAhead)}:${state.quality.active}`;
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1110
|
+
const couplings = state.presentation.couplings;
|
|
1111
|
+
const audio = activeAudio(state);
|
|
1112
|
+
const outcome = arbiterFor(hooks, contentType).run(_objectSpread2(_objectSpread2({
|
|
1113
|
+
renditions: contentType === "audio" ? audioInGroup(found.track.renditions, audioGroup(found.track.renditions, couplings, state.quality.constraints, quality.active)) : found.track.renditions,
|
|
1112
1114
|
constraints: state.quality.constraints,
|
|
1113
1115
|
pinned: state.quality.pinned,
|
|
1114
1116
|
current: state.quality.active,
|
|
1115
|
-
couplings
|
|
1117
|
+
couplings,
|
|
1116
1118
|
activeTracks: state.tracks.active,
|
|
1117
|
-
availableGroups: availableGroups(state)
|
|
1119
|
+
availableGroups: availableGroups(state)
|
|
1120
|
+
}, audio !== void 0 ? { audio } : {}), {}, {
|
|
1118
1121
|
abr: (_hooks$abr = hooks.abr) !== null && _hooks$abr !== void 0 ? _hooks$abr : null,
|
|
1119
1122
|
telemetry: _objectSpread2(_objectSpread2({
|
|
1120
1123
|
throughputEwma: state.stats.throughputEwma,
|
|
@@ -1125,7 +1128,7 @@ function driveScheduling(state, hooks, cfg) {
|
|
|
1125
1128
|
currentTime: state.playback.currentTime,
|
|
1126
1129
|
canSwitchTo: (_hooks$switchPolicy = hooks.switchPolicy) !== null && _hooks$switchPolicy !== void 0 ? _hooks$switchPolicy : canSwitchTo
|
|
1127
1130
|
})
|
|
1128
|
-
}, memoKey);
|
|
1131
|
+
}), contentType === "audio" ? `${memoKey}:${quality.active}` : memoKey);
|
|
1129
1132
|
for (const event of outcome.events) effects.push(event);
|
|
1130
1133
|
const rendition = found.track.renditions.find((r) => r.id === outcome.result.selected);
|
|
1131
1134
|
if (rendition === void 0) continue;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
-
import { findRendition } from "./presentation.js";
|
|
2
|
+
import { findRendition, findTrackSite } from "./presentation.js";
|
|
3
3
|
import { segmentAtTime } from "./timeline.js";
|
|
4
4
|
import { bufferedEndFrom } from "./scheduler.js";
|
|
5
|
+
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectWithoutProperties.js";
|
|
5
6
|
//#region src/kernel/rendition-select.ts
|
|
7
|
+
const _excluded = [
|
|
8
|
+
"maxHeight",
|
|
9
|
+
"maxWidth",
|
|
10
|
+
"maxBitrate",
|
|
11
|
+
"minBitrate",
|
|
12
|
+
"maxFrameRate"
|
|
13
|
+
];
|
|
6
14
|
/** The lead time before which a `soon` switch never disturbs the buffer. */
|
|
7
15
|
const SOON_LEAD_SECONDS = 1.5;
|
|
8
16
|
const GAP_TOLERANCE = .25;
|
|
@@ -35,6 +43,50 @@ function lowest(allowed) {
|
|
|
35
43
|
for (const candidate of allowed) if (candidate.bitrate < best.bitrate) best = candidate;
|
|
36
44
|
return best;
|
|
37
45
|
}
|
|
46
|
+
/** Every rendition id a constraint excludes by id: undecodable, failed, on a lost pathway. */
|
|
47
|
+
function excludedIds(constraints) {
|
|
48
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
49
|
+
for (const constraint of constraints.values()) {
|
|
50
|
+
var _constraint$excludeId2;
|
|
51
|
+
for (const id of (_constraint$excludeId2 = constraint.excludeIds) !== null && _constraint$excludeId2 !== void 0 ? _constraint$excludeId2 : []) excluded.add(id);
|
|
52
|
+
}
|
|
53
|
+
return excluded;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The video stream a rendition shows: renditions that read one playlist on
|
|
57
|
+
* one pathway carry the same video and differ only by audio group.
|
|
58
|
+
*/
|
|
59
|
+
function streamOf(rendition) {
|
|
60
|
+
var _rendition$playlistUr;
|
|
61
|
+
return `${rendition.pathway}|${(_rendition$playlistUr = rendition.playlistUrl) !== null && _rendition$playlistUr !== void 0 ? _rendition$playlistUr : rendition.id}`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The audio group the engine plays from the active audio track, whose
|
|
65
|
+
* renditions are `audio`: the group the video rendition `videoId` requires
|
|
66
|
+
* when the track has a usable rendition in it, else the group of the
|
|
67
|
+
* track's first usable rendition, in manifest order. Null when no coupling
|
|
68
|
+
* names an audio group (audio muxed into the video, or audio-only, or a
|
|
69
|
+
* manifest format without groups), or when no rendition is usable.
|
|
70
|
+
*/
|
|
71
|
+
function audioGroup(audio, couplings, constraints, videoId) {
|
|
72
|
+
var _couplings$find, _groups$;
|
|
73
|
+
if (!couplings.some((c) => c.requires.audio !== void 0)) return null;
|
|
74
|
+
const excluded = excludedIds(constraints);
|
|
75
|
+
const groups = audio.filter((r) => !excluded.has(r.id)).map((r) => groupOf(r.id));
|
|
76
|
+
const required = (_couplings$find = couplings.find((c) => c.renditionId === videoId)) === null || _couplings$find === void 0 ? void 0 : _couplings$find.requires.audio;
|
|
77
|
+
return required !== void 0 && groups.includes(required) ? required : (_groups$ = groups[0]) !== null && _groups$ !== void 0 ? _groups$ : null;
|
|
78
|
+
}
|
|
79
|
+
/** The renditions of `audio` in `group`; all of them when none is. */
|
|
80
|
+
function audioInGroup(audio, group) {
|
|
81
|
+
const inGroup = audio.filter((r) => groupOf(r.id) === group);
|
|
82
|
+
return inGroup.length > 0 ? inGroup : audio;
|
|
83
|
+
}
|
|
84
|
+
/** The renditions of the active audio track, or undefined without one. */
|
|
85
|
+
function activeAudio(kernel) {
|
|
86
|
+
var _findTrackSite;
|
|
87
|
+
const trackId = kernel.tracks.active.get("audio");
|
|
88
|
+
return trackId === void 0 ? void 0 : (_findTrackSite = findTrackSite(kernel.presentation, trackId)) === null || _findTrackSite === void 0 ? void 0 : _findTrackSite.track.renditions;
|
|
89
|
+
}
|
|
38
90
|
/**
|
|
39
91
|
* The video renditions an adapter resolves ahead of need: the active one
|
|
40
92
|
* and the nearest rung below and above on its pathway. ABR moves one rung
|
|
@@ -46,11 +98,7 @@ function lowest(allowed) {
|
|
|
46
98
|
*/
|
|
47
99
|
function ladderNeighbours(renditions, activeId, constraints) {
|
|
48
100
|
var _pool$find;
|
|
49
|
-
const excluded =
|
|
50
|
-
for (const constraint of constraints.values()) {
|
|
51
|
-
var _constraint$excludeId2;
|
|
52
|
-
for (const id of (_constraint$excludeId2 = constraint.excludeIds) !== null && _constraint$excludeId2 !== void 0 ? _constraint$excludeId2 : []) excluded.add(id);
|
|
53
|
-
}
|
|
101
|
+
const excluded = excludedIds(constraints);
|
|
54
102
|
const usable = renditions.filter((r) => !excluded.has(r.id));
|
|
55
103
|
const pool = [...usable.length > 0 ? usable : renditions].sort((a, b) => a.bitrate - b.bitrate);
|
|
56
104
|
const active = (_pool$find = pool.find((r) => r.id === activeId)) !== null && _pool$find !== void 0 ? _pool$find : pool[0];
|
|
@@ -79,11 +127,14 @@ function groupOf(trackId) {
|
|
|
79
127
|
const colon = trackId.indexOf(":");
|
|
80
128
|
return colon === -1 ? trackId : trackId.slice(0, colon);
|
|
81
129
|
}
|
|
82
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* Companion groups present, as `contentType:groupId`, for the coupling
|
|
132
|
+
* filter. A track offered in several audio groups counts in each.
|
|
133
|
+
*/
|
|
83
134
|
function availableGroups(kernel) {
|
|
84
135
|
var _kernel$presentation$, _kernel$presentation;
|
|
85
136
|
const groups = /* @__PURE__ */ new Set();
|
|
86
|
-
for (const period of (_kernel$presentation$ = (_kernel$presentation = kernel.presentation) === null || _kernel$presentation === void 0 ? void 0 : _kernel$presentation.periods) !== null && _kernel$presentation$ !== void 0 ? _kernel$presentation$ : []) for (const track of period.tracks) if (track.contentType === "audio" || track.contentType === "text") groups.add(`${track.contentType}:${groupOf(
|
|
137
|
+
for (const period of (_kernel$presentation$ = (_kernel$presentation = kernel.presentation) === null || _kernel$presentation === void 0 ? void 0 : _kernel$presentation.periods) !== null && _kernel$presentation$ !== void 0 ? _kernel$presentation$ : []) for (const track of period.tracks) if (track.contentType === "audio" || track.contentType === "text") for (const r of track.renditions) groups.add(`${track.contentType}:${groupOf(r.id)}`);
|
|
87
138
|
return groups;
|
|
88
139
|
}
|
|
89
140
|
/**
|
|
@@ -101,8 +152,9 @@ function activeRenditions(kernel, types, videoId) {
|
|
|
101
152
|
const trackId = kernel.tracks.active.get(contentType);
|
|
102
153
|
if (trackId === void 0) continue;
|
|
103
154
|
for (const period of (_kernel$presentation$2 = (_kernel$presentation2 = kernel.presentation) === null || _kernel$presentation2 === void 0 ? void 0 : _kernel$presentation2.periods) !== null && _kernel$presentation$2 !== void 0 ? _kernel$presentation$2 : []) for (const track of period.tracks) {
|
|
155
|
+
var _kernel$presentation$3, _kernel$presentation3;
|
|
104
156
|
if (track.id !== trackId) continue;
|
|
105
|
-
const candidates = contentType === "video" ? ladderNeighbours(track.renditions, videoId, kernel.quality.constraints) : track.renditions;
|
|
157
|
+
const candidates = contentType === "video" ? ladderNeighbours(track.renditions, videoId, kernel.quality.constraints) : contentType === "audio" ? audioInGroup(track.renditions, audioGroup(track.renditions, (_kernel$presentation$3 = (_kernel$presentation3 = kernel.presentation) === null || _kernel$presentation3 === void 0 ? void 0 : _kernel$presentation3.couplings) !== null && _kernel$presentation$3 !== void 0 ? _kernel$presentation$3 : [], kernel.quality.constraints, videoId)) : track.renditions;
|
|
106
158
|
for (const rendition of candidates) out.push({
|
|
107
159
|
contentType,
|
|
108
160
|
rendition
|
|
@@ -132,9 +184,10 @@ function withDeadGroups(presentation, dead) {
|
|
|
132
184
|
const alive = /* @__PURE__ */ new Set();
|
|
133
185
|
for (const period of presentation.periods) for (const track of period.tracks) {
|
|
134
186
|
if (track.contentType !== "audio") continue;
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
187
|
+
for (const r of track.renditions) {
|
|
188
|
+
known.add(groupOf(r.id));
|
|
189
|
+
if (!dead.has(r.id)) alive.add(groupOf(r.id));
|
|
190
|
+
}
|
|
138
191
|
}
|
|
139
192
|
for (const { renditionId, requires } of presentation.couplings) if (requires.audio !== void 0 && known.has(requires.audio) && !alive.has(requires.audio)) out.add(renditionId);
|
|
140
193
|
return out;
|
|
@@ -183,6 +236,15 @@ function arbitrate(ctx) {
|
|
|
183
236
|
event: "quality:coupling-unsatisfiable",
|
|
184
237
|
payload: { active: Object.fromEntries(ctx.activeTracks) }
|
|
185
238
|
});
|
|
239
|
+
if (ctx.audio !== void 0) {
|
|
240
|
+
const group = audioGroup(ctx.audio, ctx.couplings, ctx.constraints, ctx.current);
|
|
241
|
+
const needs = (r) => {
|
|
242
|
+
var _ctx$couplings$find;
|
|
243
|
+
return (_ctx$couplings$find = ctx.couplings.find((c) => c.renditionId === r.id)) === null || _ctx$couplings$find === void 0 ? void 0 : _ctx$couplings$find.requires.audio;
|
|
244
|
+
};
|
|
245
|
+
const covered = new Set(allowed.filter((r) => needs(r) === group).map(streamOf));
|
|
246
|
+
allowed = allowed.filter((r) => needs(r) === group || !covered.has(streamOf(r)));
|
|
247
|
+
}
|
|
186
248
|
const allowedIds = allowed.map((r) => r.id);
|
|
187
249
|
if (ctx.pinned !== null) {
|
|
188
250
|
if (allowedIds.includes(ctx.pinned)) return {
|
|
@@ -196,8 +258,9 @@ function arbitrate(ctx) {
|
|
|
196
258
|
};
|
|
197
259
|
const target = ctx.renditions.find((r) => r.id === ctx.pinned);
|
|
198
260
|
if (target !== void 0) {
|
|
199
|
-
const
|
|
200
|
-
|
|
261
|
+
const sibling = allowed.find((r) => target.playlistUrl !== void 0 && streamOf(r) === streamOf(target));
|
|
262
|
+
const clamped = sibling !== null && sibling !== void 0 ? sibling : closestByBitrate(allowed, target);
|
|
263
|
+
if (sibling === void 0) events.push({
|
|
201
264
|
kind: "emit",
|
|
202
265
|
event: "quality:pin-unsatisfiable",
|
|
203
266
|
payload: {
|
|
@@ -255,6 +318,17 @@ function arbitrate(ctx) {
|
|
|
255
318
|
events
|
|
256
319
|
};
|
|
257
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* The constraints without their numeric caps: what cannot play (codecs,
|
|
323
|
+
* excluded ids, HDR, a filter), not what is preferred. Arbitrated, they
|
|
324
|
+
* give the renditions a viewer may pick, since a pin may go past a cap.
|
|
325
|
+
*/
|
|
326
|
+
function exclusionsOf(constraints) {
|
|
327
|
+
return new Map([...constraints].map(([source, _ref]) => {
|
|
328
|
+
let { maxHeight, maxWidth, maxBitrate, minBitrate, maxFrameRate } = _ref;
|
|
329
|
+
return [source, _objectWithoutProperties(_ref, _excluded)];
|
|
330
|
+
}));
|
|
331
|
+
}
|
|
258
332
|
function createArbiter() {
|
|
259
333
|
let lastVersion = NaN;
|
|
260
334
|
let lastOutcome = null;
|
|
@@ -367,4 +441,4 @@ function planPinApply(input) {
|
|
|
367
441
|
};
|
|
368
442
|
}
|
|
369
443
|
//#endregion
|
|
370
|
-
export { activeRenditions, arbitrate, availableGroups, canSwitchTo, codecFamily, createArbiter, groupOf, ladderNeighbours, planPinApply, withDeadGroups };
|
|
444
|
+
export { activeAudio, activeRenditions, arbitrate, audioGroup, audioInGroup, availableGroups, canSwitchTo, codecFamily, createArbiter, exclusionsOf, groupOf, ladderNeighbours, planPinApply, withDeadGroups };
|
|
@@ -236,6 +236,15 @@ const TRANSFER_CHARACTERISTICS = "urn:mpeg:mpegB:cicp:TransferCharacteristics";
|
|
|
236
236
|
* for HLG, on the Representation or its AdaptationSet; else PQ for a Dolby
|
|
237
237
|
* Vision codec; else nothing.
|
|
238
238
|
*/
|
|
239
|
+
/**
|
|
240
|
+
* `@scte214:supplementalCodecs` (ETSI TS 103 285 §5.2.3): a Dolby Vision
|
|
241
|
+
* layer over the base codec. Read by local name, since the prefix is the
|
|
242
|
+
* manifest's choice.
|
|
243
|
+
*/
|
|
244
|
+
function supplementalOf(representation, adaptationSet) {
|
|
245
|
+
for (const element of [representation, adaptationSet]) for (const attribute of Array.from(element.attributes)) if (attribute.localName === "supplementalCodecs") return { supplementalCodecs: attribute.value };
|
|
246
|
+
return {};
|
|
247
|
+
}
|
|
239
248
|
function videoRangeOf(representation, adaptationSet, codecs) {
|
|
240
249
|
for (const element of [representation, adaptationSet]) for (const property of [...children(element, "EssentialProperty"), ...children(element, "SupplementalProperty")]) {
|
|
241
250
|
if (attr(property, "schemeIdUri") !== TRANSFER_CHARACTERISTICS) continue;
|
|
@@ -245,6 +254,62 @@ function videoRangeOf(representation, adaptationSet, codecs) {
|
|
|
245
254
|
return codecs !== null && /^dv(h1|he|a1|av)/.test(codecs) ? { videoRange: "PQ" } : {};
|
|
246
255
|
}
|
|
247
256
|
/**
|
|
257
|
+
* Channel counts by ISO/IEC 23091-3 ChannelConfiguration index, from 1 to
|
|
258
|
+
* 20 (index 8 is reserved, so 0, as an unknown count).
|
|
259
|
+
*/
|
|
260
|
+
const CICP_CHANNELS = [
|
|
261
|
+
1,
|
|
262
|
+
2,
|
|
263
|
+
3,
|
|
264
|
+
4,
|
|
265
|
+
5,
|
|
266
|
+
6,
|
|
267
|
+
8,
|
|
268
|
+
0,
|
|
269
|
+
3,
|
|
270
|
+
4,
|
|
271
|
+
7,
|
|
272
|
+
8,
|
|
273
|
+
24,
|
|
274
|
+
8,
|
|
275
|
+
12,
|
|
276
|
+
10,
|
|
277
|
+
12,
|
|
278
|
+
14,
|
|
279
|
+
12,
|
|
280
|
+
14
|
|
281
|
+
];
|
|
282
|
+
/**
|
|
283
|
+
* The channel count an AudioChannelConfiguration declares, on the
|
|
284
|
+
* Representation or its AdaptationSet. The MPEG scheme
|
|
285
|
+
* (ISO/IEC 23009-1 §5.8.5.4) writes the count; the CICP scheme an index;
|
|
286
|
+
* the Dolby scheme (ETSI TS 102 366 Annex I) a 16-bit hex mask with one bit
|
|
287
|
+
* per speaker or speaker pair. Another scheme says nothing here.
|
|
288
|
+
*/
|
|
289
|
+
function channelsOf(representation, adaptationSet) {
|
|
290
|
+
for (const element of [representation, adaptationSet]) for (const config of children(element, "AudioChannelConfiguration")) {
|
|
291
|
+
var _attr10, _attr11;
|
|
292
|
+
const scheme = (_attr10 = attr(config, "schemeIdUri")) !== null && _attr10 !== void 0 ? _attr10 : "";
|
|
293
|
+
const value = (_attr11 = attr(config, "value")) !== null && _attr11 !== void 0 ? _attr11 : "";
|
|
294
|
+
let channels = 0;
|
|
295
|
+
if (scheme === "urn:mpeg:dash:23003:3:audio_channel_configuration:2011") channels = Number(value);
|
|
296
|
+
else if (scheme === "urn:mpeg:mpegB:cicp:ChannelConfiguration") {
|
|
297
|
+
var _CICP_CHANNELS;
|
|
298
|
+
channels = (_CICP_CHANNELS = CICP_CHANNELS[Number(value) - 1]) !== null && _CICP_CHANNELS !== void 0 ? _CICP_CHANNELS : 0;
|
|
299
|
+
} else if (/dolby.*audio_channel_configuration/.test(scheme)) {
|
|
300
|
+
const mask = Number.parseInt(value, 16);
|
|
301
|
+
channels = bitCount(mask) + bitCount(mask & 1652);
|
|
302
|
+
}
|
|
303
|
+
if (channels > 0) return { channels };
|
|
304
|
+
}
|
|
305
|
+
return {};
|
|
306
|
+
}
|
|
307
|
+
function bitCount(value) {
|
|
308
|
+
let count = 0;
|
|
309
|
+
for (let bits = value; bits > 0; bits >>= 1) count += bits & 1;
|
|
310
|
+
return count;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
248
313
|
* A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
|
|
249
314
|
* representation declaring a playout rate other than 1. Both mark an
|
|
250
315
|
* I-frame-only set meant for fast forward and previews, never for normal
|
|
@@ -252,8 +317,8 @@ function videoRangeOf(representation, adaptationSet, codecs) {
|
|
|
252
317
|
*/
|
|
253
318
|
function isTrickMode(adaptationSet) {
|
|
254
319
|
for (const property of children(adaptationSet, "EssentialProperty")) {
|
|
255
|
-
var
|
|
256
|
-
if (((
|
|
320
|
+
var _attr12;
|
|
321
|
+
if (((_attr12 = attr(property, "schemeIdUri")) !== null && _attr12 !== void 0 ? _attr12 : "").includes("trickmode")) return true;
|
|
257
322
|
}
|
|
258
323
|
if (numberAttr(adaptationSet, "maxPlayoutRate") !== null) return true;
|
|
259
324
|
for (const representation of children(adaptationSet, "Representation")) {
|
|
@@ -272,8 +337,8 @@ function tileGridOf(representation, adaptationSet, width, height) {
|
|
|
272
337
|
if (width === null || height === null) return null;
|
|
273
338
|
const properties = [...children(representation, "EssentialProperty"), ...children(adaptationSet, "EssentialProperty")];
|
|
274
339
|
for (const property of properties) {
|
|
275
|
-
var
|
|
276
|
-
if (!((
|
|
340
|
+
var _attr13;
|
|
341
|
+
if (!((_attr13 = attr(property, "schemeIdUri")) !== null && _attr13 !== void 0 ? _attr13 : "").includes("thumbnail_tile")) continue;
|
|
277
342
|
const grid = dimensions(attr(property, "value"));
|
|
278
343
|
if (grid === null) continue;
|
|
279
344
|
const [columns, rows] = grid;
|
|
@@ -298,12 +363,12 @@ function mergeTemplates(levels) {
|
|
|
298
363
|
let timelineElement = null;
|
|
299
364
|
let found = false;
|
|
300
365
|
for (const level of levels) {
|
|
301
|
-
var
|
|
366
|
+
var _attr14, _attr15, _numberAttr4, _numberAttr5, _numberAttr6, _numberAttr7, _children$2;
|
|
302
367
|
const template = children(level, "SegmentTemplate")[0];
|
|
303
368
|
if (template === void 0) continue;
|
|
304
369
|
found = true;
|
|
305
|
-
media = (
|
|
306
|
-
initialization = (
|
|
370
|
+
media = (_attr14 = attr(template, "media")) !== null && _attr14 !== void 0 ? _attr14 : media;
|
|
371
|
+
initialization = (_attr15 = attr(template, "initialization")) !== null && _attr15 !== void 0 ? _attr15 : initialization;
|
|
307
372
|
timescale = (_numberAttr4 = numberAttr(template, "timescale")) !== null && _numberAttr4 !== void 0 ? _numberAttr4 : timescale;
|
|
308
373
|
startNumber = (_numberAttr5 = numberAttr(template, "startNumber")) !== null && _numberAttr5 !== void 0 ? _numberAttr5 : startNumber;
|
|
309
374
|
duration = (_numberAttr6 = numberAttr(template, "duration")) !== null && _numberAttr6 !== void 0 ? _numberAttr6 : duration;
|
|
@@ -333,7 +398,7 @@ function mergeTemplates(levels) {
|
|
|
333
398
|
* level has a SegmentList.
|
|
334
399
|
*/
|
|
335
400
|
function segmentListOf(levels, base, periodStart, periodEndUnits) {
|
|
336
|
-
var
|
|
401
|
+
var _attr17;
|
|
337
402
|
let timescale = 1;
|
|
338
403
|
let duration = null;
|
|
339
404
|
let startNumber = 1;
|
|
@@ -366,20 +431,20 @@ function segmentListOf(levels, base, periodStart, periodEndUnits) {
|
|
|
366
431
|
else if (urls.length > 1) return "invalid";
|
|
367
432
|
const segments = [];
|
|
368
433
|
urls.forEach((url, i) => {
|
|
369
|
-
var _times$i,
|
|
434
|
+
var _times$i, _attr16;
|
|
370
435
|
const [time, length] = (_times$i = times[i]) !== null && _times$i !== void 0 ? _times$i : [offset, 0];
|
|
371
436
|
const range = parseByteRange(attr(url, "mediaRange"));
|
|
372
437
|
segments.push(_objectSpread2({
|
|
373
438
|
seq: startNumber + i,
|
|
374
439
|
start: periodStart + (time - offset) / timescale,
|
|
375
440
|
duration: length / timescale,
|
|
376
|
-
url: resolveUrl((
|
|
441
|
+
url: resolveUrl((_attr16 = attr(url, "media")) !== null && _attr16 !== void 0 ? _attr16 : "", base)
|
|
377
442
|
}, range !== null ? { byteRange: range } : {}));
|
|
378
443
|
});
|
|
379
444
|
const initRange = initialization === null ? null : parseByteRange(attr(initialization, "range"));
|
|
380
445
|
return {
|
|
381
446
|
segments,
|
|
382
|
-
init: initialization === null ? null : _objectSpread2({ url: resolveUrl((
|
|
447
|
+
init: initialization === null ? null : _objectSpread2({ url: resolveUrl((_attr17 = attr(initialization, "sourceURL")) !== null && _attr17 !== void 0 ? _attr17 : "", base) }, initRange !== null ? { byteRange: initRange } : {})
|
|
383
448
|
};
|
|
384
449
|
}
|
|
385
450
|
function parseTimeline(timelineElement, periodEndUnits) {
|
|
@@ -418,13 +483,13 @@ function substituteIdentity(template, id, bandwidth) {
|
|
|
418
483
|
});
|
|
419
484
|
}
|
|
420
485
|
function contentTypeOf(adaptationSet, mimeType) {
|
|
421
|
-
var
|
|
486
|
+
var _attr18, _children$5;
|
|
422
487
|
const declared = attr(adaptationSet, "contentType");
|
|
423
488
|
if (declared === "video" || declared === "audio" || declared === "text" || declared === "image" || declared === "metadata") return declared;
|
|
424
489
|
if (mimeType.startsWith("audio/")) return "audio";
|
|
425
490
|
if (mimeType.startsWith("image/")) return "image";
|
|
426
491
|
if (mimeType.startsWith("text/") || mimeType === "application/ttml+xml") return "text";
|
|
427
|
-
const codecs = (
|
|
492
|
+
const codecs = (_attr18 = attr(adaptationSet, "codecs")) !== null && _attr18 !== void 0 ? _attr18 : attr((_children$5 = children(adaptationSet, "Representation")[0]) !== null && _children$5 !== void 0 ? _children$5 : adaptationSet, "codecs");
|
|
428
493
|
if (mimeType === "application/mp4" && codecs !== null && /^(stpp|wvtt)/.test(codecs)) return "text";
|
|
429
494
|
return "video";
|
|
430
495
|
}
|
|
@@ -460,15 +525,15 @@ function periodSpans(elements, mpdDuration) {
|
|
|
460
525
|
*/
|
|
461
526
|
function followsOf(adaptationSet) {
|
|
462
527
|
return children(adaptationSet, "SupplementalProperty").filter((property) => {
|
|
463
|
-
var
|
|
464
|
-
return /^urn:mpeg:dash:period-(continuity|connectivity):2015$/.test((
|
|
528
|
+
var _attr19;
|
|
529
|
+
return /^urn:mpeg:dash:period-(continuity|connectivity):2015$/.test((_attr19 = attr(property, "schemeIdUri")) !== null && _attr19 !== void 0 ? _attr19 : "");
|
|
465
530
|
}).flatMap((property) => {
|
|
466
|
-
var
|
|
467
|
-
return ((
|
|
531
|
+
var _attr20;
|
|
532
|
+
return ((_attr20 = attr(property, "value")) !== null && _attr20 !== void 0 ? _attr20 : "").split(/[\s,]+/).filter((v) => v !== "");
|
|
468
533
|
});
|
|
469
534
|
}
|
|
470
535
|
function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
471
|
-
var
|
|
536
|
+
var _attr29;
|
|
472
537
|
const matching = /* @__PURE__ */ new Map();
|
|
473
538
|
const periodStart = span.start;
|
|
474
539
|
const periodDuration = span.duration;
|
|
@@ -490,16 +555,17 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
|
490
555
|
const renditions = [];
|
|
491
556
|
let trackMime = null;
|
|
492
557
|
for (const representation of children(adaptationSet, "Representation")) {
|
|
493
|
-
var _ref2,
|
|
558
|
+
var _ref2, _attr21, _trackMime, _parseFrameRate2, _numberAttr15, _attr27, _attr28;
|
|
494
559
|
const id = attr(representation, "id");
|
|
495
560
|
const bandwidth = numberAttr(representation, "bandwidth");
|
|
496
561
|
if (id === null || bandwidth === null) continue;
|
|
497
562
|
const repBase = applyBaseUrl(representation, asBase);
|
|
498
|
-
const mimeType = (_ref2 = (
|
|
563
|
+
const mimeType = (_ref2 = (_attr21 = attr(representation, "mimeType")) !== null && _attr21 !== void 0 ? _attr21 : asMime) !== null && _ref2 !== void 0 ? _ref2 : "video/mp4";
|
|
564
|
+
if (/\/(webm|x-matroska)$/.test(mimeType)) continue;
|
|
499
565
|
trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
|
|
500
566
|
const segmentBase = children(representation, "SegmentBase")[0];
|
|
501
567
|
if (segmentBase !== void 0) {
|
|
502
|
-
var _numberAttr14, _parseFrameRate,
|
|
568
|
+
var _numberAttr14, _parseFrameRate, _attr22, _attr23;
|
|
503
569
|
const indexRange = parseByteRange(attr(segmentBase, "indexRange"));
|
|
504
570
|
if (indexRange === null) continue;
|
|
505
571
|
const baseTimescale = (_numberAttr14 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr14 !== void 0 ? _numberAttr14 : 1;
|
|
@@ -519,13 +585,13 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
|
519
585
|
const w = numberAttr(representation, "width");
|
|
520
586
|
const h = numberAttr(representation, "height");
|
|
521
587
|
const fr = (_parseFrameRate = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate !== void 0 ? _parseFrameRate : parseFrameRate(attr(adaptationSet, "frameRate"));
|
|
522
|
-
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
588
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
523
589
|
id,
|
|
524
590
|
bitrate: bandwidth,
|
|
525
|
-
codecs: (
|
|
591
|
+
codecs: (_attr22 = attr(representation, "codecs")) !== null && _attr22 !== void 0 ? _attr22 : asCodecs,
|
|
526
592
|
mimeType,
|
|
527
593
|
segments: sidxSegments
|
|
528
|
-
}, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}), videoRangeOf(representation, adaptationSet, (
|
|
594
|
+
}, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}), videoRangeOf(representation, adaptationSet, (_attr23 = attr(representation, "codecs")) !== null && _attr23 !== void 0 ? _attr23 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
|
|
529
595
|
continue;
|
|
530
596
|
}
|
|
531
597
|
const list = segmentListOf([
|
|
@@ -535,15 +601,15 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
|
535
601
|
], repBase, periodStart, (timescale, offset) => periodDuration !== null ? Math.round(offset + periodDuration * timescale) : null);
|
|
536
602
|
if (list === "invalid") return { error: manifestError(`bad SegmentList in '${id}'`) };
|
|
537
603
|
if (list !== null) {
|
|
538
|
-
var
|
|
604
|
+
var _attr24, _attr25;
|
|
539
605
|
const segments = list.segments.map((segment) => segment.duration === 0 && periodDuration !== null ? _objectSpread2(_objectSpread2({}, segment), {}, { duration: periodDuration }) : segment);
|
|
540
|
-
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
606
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
541
607
|
id,
|
|
542
608
|
bitrate: bandwidth,
|
|
543
|
-
codecs: (
|
|
609
|
+
codecs: (_attr24 = attr(representation, "codecs")) !== null && _attr24 !== void 0 ? _attr24 : asCodecs,
|
|
544
610
|
mimeType,
|
|
545
611
|
segments
|
|
546
|
-
}, 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, (
|
|
612
|
+
}, 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, (_attr25 = attr(representation, "codecs")) !== null && _attr25 !== void 0 ? _attr25 : asCodecs)), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
|
|
547
613
|
continue;
|
|
548
614
|
}
|
|
549
615
|
const template = mergeTemplates([
|
|
@@ -553,11 +619,11 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
|
553
619
|
]);
|
|
554
620
|
if (template === null || template.media === null) {
|
|
555
621
|
if (contentTypeOf(adaptationSet, mimeType) === "text" && periodDuration !== null) {
|
|
556
|
-
var
|
|
622
|
+
var _attr26;
|
|
557
623
|
renditions.push({
|
|
558
624
|
id,
|
|
559
625
|
bitrate: bandwidth,
|
|
560
|
-
codecs: (
|
|
626
|
+
codecs: (_attr26 = attr(representation, "codecs")) !== null && _attr26 !== void 0 ? _attr26 : asCodecs,
|
|
561
627
|
mimeType,
|
|
562
628
|
segments: [{
|
|
563
629
|
seq: 0,
|
|
@@ -591,13 +657,13 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
|
591
657
|
const height = numberAttr(representation, "height");
|
|
592
658
|
const tiles = tileGridOf(representation, adaptationSet, width, height);
|
|
593
659
|
const playoutRate = trick ? (_numberAttr15 = numberAttr(representation, "maxPlayoutRate")) !== null && _numberAttr15 !== void 0 ? _numberAttr15 : asPlayoutRate : null;
|
|
594
|
-
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
660
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
595
661
|
id,
|
|
596
662
|
bitrate: bandwidth,
|
|
597
|
-
codecs: (
|
|
663
|
+
codecs: (_attr27 = attr(representation, "codecs")) !== null && _attr27 !== void 0 ? _attr27 : asCodecs,
|
|
598
664
|
mimeType,
|
|
599
665
|
segments
|
|
600
|
-
}, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), videoRangeOf(representation, adaptationSet, (
|
|
666
|
+
}, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), videoRangeOf(representation, adaptationSet, (_attr28 = attr(representation, "codecs")) !== null && _attr28 !== void 0 ? _attr28 : asCodecs)), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}), channelsOf(representation, adaptationSet)), supplementalOf(representation, adaptationSet)));
|
|
601
667
|
}
|
|
602
668
|
if (renditions.length === 0) continue;
|
|
603
669
|
const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
|
|
@@ -648,7 +714,7 @@ function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
|
648
714
|
}
|
|
649
715
|
const events = eventsOf(periodElement, periodStart);
|
|
650
716
|
return {
|
|
651
|
-
id: (
|
|
717
|
+
id: (_attr29 = attr(periodElement, "id")) !== null && _attr29 !== void 0 ? _attr29 : `p${index}`,
|
|
652
718
|
start: periodStart,
|
|
653
719
|
duration: periodDuration,
|
|
654
720
|
tracks,
|
|
@@ -678,15 +744,15 @@ function parse(text, baseUrl) {
|
|
|
678
744
|
const mpdBase = applyBaseUrl(mpd, baseUrl);
|
|
679
745
|
let live;
|
|
680
746
|
if (isLive) {
|
|
681
|
-
var
|
|
682
|
-
const availabilityStart = Date.parse((
|
|
747
|
+
var _attr30, _attr31, _attr32;
|
|
748
|
+
const availabilityStart = Date.parse((_attr30 = attr(mpd, "availabilityStartTime")) !== null && _attr30 !== void 0 ? _attr30 : "");
|
|
683
749
|
const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
|
|
684
750
|
const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
|
|
685
751
|
const holdBack = parseDuration(attr(mpd, "suggestedPresentationDelay"));
|
|
686
752
|
const timing = children(mpd, "UTCTiming")[0];
|
|
687
753
|
live = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, Number.isFinite(availabilityStart) ? { availabilityStart: availabilityStart / 1e3 } : {}), updatePeriod !== null ? { updatePeriod } : {}), timeShiftDepth !== null ? { timeShiftDepth } : {}), holdBack !== null ? { holdBack } : {}), timing !== void 0 ? { timeServer: {
|
|
688
|
-
scheme: (
|
|
689
|
-
value: (
|
|
754
|
+
scheme: (_attr31 = attr(timing, "schemeIdUri")) !== null && _attr31 !== void 0 ? _attr31 : "",
|
|
755
|
+
value: (_attr32 = attr(timing, "value")) !== null && _attr32 !== void 0 ? _attr32 : ""
|
|
690
756
|
} } : {});
|
|
691
757
|
}
|
|
692
758
|
let steering;
|