mattebox 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/mattebox.dash-drm.min.js +3 -3
- package/dist/cdn/mattebox.dash.min.js +3 -3
- package/dist/cdn/mattebox.dual-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ts.min.js +3 -3
- package/dist/cdn/mattebox.dual.min.js +3 -3
- package/dist/cdn/mattebox.hls-drm.min.js +3 -3
- package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
- package/dist/cdn/mattebox.hls-ts.min.js +3 -3
- package/dist/cdn/mattebox.hls.min.js +3 -3
- package/dist/cdn/mattebox.kernel.min.js +1 -1
- package/dist/cdn/mattebox.min.js +4 -4
- package/dist/containers/mp4-box/index.d.ts +9 -7
- package/dist/containers/mp4-box/index.d.ts.map +1 -1
- package/dist/containers/mp4-box/index.js +20 -28
- package/dist/containers/mp4-box/index.js.map +1 -1
- package/dist/containers/packed-audio/index.d.ts.map +1 -1
- package/dist/containers/packed-audio/index.js +5 -1
- package/dist/containers/packed-audio/index.js.map +1 -1
- package/dist/containers/ts-transmux/index.d.ts.map +1 -1
- package/dist/containers/ts-transmux/index.js +2 -1
- package/dist/containers/ts-transmux/index.js.map +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/containers/id3.js +1 -1
- package/dist/es2015/containers/mp4-box/index.js +19 -22
- package/dist/es2015/containers/packed-audio/index.js +2 -5
- package/dist/es2015/containers/ts-transmux/h264.js +1 -1
- package/dist/es2015/containers/ts-transmux/index.js +3 -6
- package/dist/es2015/index.js +34 -27
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/context.js +7 -0
- package/dist/es2015/kernel/loader.js +5 -4
- package/dist/es2015/kernel/mse.js +27 -71
- package/dist/es2015/kernel/prepare.js +77 -0
- package/dist/es2015/kernel/reducer.js +233 -64
- package/dist/es2015/kernel/refresh.js +35 -0
- package/dist/es2015/kernel/rendition-select.js +62 -2
- package/dist/es2015/kernel/scheduler.js +23 -5
- package/dist/es2015/kernel/timeline.js +22 -1
- package/dist/es2015/kernel/trace.js +1 -1
- package/dist/es2015/kernel/transport.js +4 -4
- package/dist/es2015/presets/define.js +2 -2
- package/dist/es2015/presets/tiers.js +7 -6
- package/dist/es2015/protocols/dash-cmaf/index.js +136 -55
- package/dist/es2015/protocols/dash-cmaf/parse.js +2 -10
- package/dist/es2015/protocols/dash-live/index.js +54 -14
- package/dist/es2015/protocols/hls-cmaf/index.js +119 -71
- package/dist/es2015/protocols/hls-cmaf/parse.js +35 -25
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +42 -0
- package/dist/es2015/protocols/hls-live/index.js +191 -85
- package/dist/es2015/stages/abr/index.js +1 -1
- package/dist/es2015/stages/abr-persist/index.js +1 -1
- package/dist/es2015/stages/aes-128/index.js +1 -1
- package/dist/es2015/stages/alt-audio/index.js +1 -1
- package/dist/es2015/stages/cmaf-timing/index.js +24 -39
- package/dist/es2015/stages/cmcd/index.js +15 -2
- package/dist/es2015/stages/content-steering/index.js +1 -1
- package/dist/es2015/stages/eme-core/index.js +2 -2
- package/dist/es2015/stages/eme-fairplay/index.js +1 -1
- package/dist/es2015/stages/recovery/index.js +1 -1
- package/dist/es2015/stages/text-cea608/decode.js +1 -1
- package/dist/es2015/stages/text-webvtt/parse.js +1 -1
- package/dist/es2015/stages/thumbnails/index.js +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -32
- package/dist/index.js.map +1 -1
- package/dist/kernel/context.d.ts +5 -1
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/context.js +10 -0
- package/dist/kernel/context.js.map +1 -1
- package/dist/kernel/loader.d.ts.map +1 -1
- package/dist/kernel/loader.js +5 -7
- package/dist/kernel/loader.js.map +1 -1
- package/dist/kernel/mse.d.ts +6 -10
- package/dist/kernel/mse.d.ts.map +1 -1
- package/dist/kernel/mse.js +20 -73
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/prepare.d.ts +28 -0
- package/dist/kernel/prepare.d.ts.map +1 -0
- package/dist/kernel/prepare.js +89 -0
- package/dist/kernel/prepare.js.map +1 -0
- package/dist/kernel/reducer.d.ts +15 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +317 -82
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/refresh.d.ts +14 -0
- package/dist/kernel/refresh.d.ts.map +1 -0
- package/dist/kernel/refresh.js +50 -0
- package/dist/kernel/refresh.js.map +1 -0
- package/dist/kernel/rendition-select.d.ts +19 -1
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +69 -0
- package/dist/kernel/rendition-select.js.map +1 -1
- package/dist/kernel/scheduler.d.ts +18 -3
- package/dist/kernel/scheduler.d.ts.map +1 -1
- package/dist/kernel/scheduler.js +32 -7
- package/dist/kernel/scheduler.js.map +1 -1
- package/dist/kernel/timeline.d.ts +18 -6
- package/dist/kernel/timeline.d.ts.map +1 -1
- package/dist/kernel/timeline.js +19 -5
- package/dist/kernel/timeline.js.map +1 -1
- package/dist/kernel/transport.d.ts.map +1 -1
- package/dist/kernel/transport.js +1 -0
- package/dist/kernel/transport.js.map +1 -1
- package/dist/presets/tiers.d.ts +7 -6
- package/dist/presets/tiers.d.ts.map +1 -1
- package/dist/presets/tiers.js +7 -6
- package/dist/presets/tiers.js.map +1 -1
- package/dist/protocols/dash-cmaf/index.d.ts +2 -2
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +166 -57
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-live/index.d.ts.map +1 -1
- package/dist/protocols/dash-live/index.js +55 -9
- package/dist/protocols/dash-live/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/index.d.ts +3 -2
- package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/index.js +140 -88
- package/dist/protocols/hls-cmaf/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts +9 -5
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +50 -47
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts +17 -0
- package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -0
- package/dist/protocols/hls-cmaf/unavailable.js +36 -0
- package/dist/protocols/hls-cmaf/unavailable.js.map +1 -0
- package/dist/protocols/hls-live/index.d.ts +17 -0
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js +213 -82
- package/dist/protocols/hls-live/index.js.map +1 -1
- package/dist/stages/aes-128/index.js +2 -2
- package/dist/stages/aes-128/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +5 -3
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/cmaf-timing/index.d.ts.map +1 -1
- package/dist/stages/cmaf-timing/index.js +33 -42
- package/dist/stages/cmaf-timing/index.js.map +1 -1
- package/dist/stages/cmcd/index.d.ts.map +1 -1
- package/dist/stages/cmcd/index.js +15 -3
- package/dist/stages/cmcd/index.js.map +1 -1
- package/dist/types/kernel.d.ts +39 -13
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js +2 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +50 -10
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/stage.d.ts +18 -0
- package/dist/types/stage.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ladderNeighbours } from "../../kernel/rendition-select.js";
|
|
4
|
+
import { parse, parseMediaPlaylist, refreshFor } from "./parse.js";
|
|
5
|
+
import { LOAD_FAILED, unavailableMessages } from "./unavailable.js";
|
|
4
6
|
//#region src/protocols/hls-cmaf/index.ts
|
|
5
7
|
/**
|
|
6
8
|
* The hls-cmaf protocol adapter as a stage. Inert module: exports a
|
|
@@ -9,8 +11,9 @@ import { mergePlaylist, parse, parseMediaPlaylist } from "./parse.js";
|
|
|
9
11
|
* The choreography is a slice reducer, so the whole protocol lives inside
|
|
10
12
|
* the message loop and the trace: manifest bytes arrive as SEGMENT_LOADED
|
|
11
13
|
* facts, parsing is pure, and results loop back through zero-delay
|
|
12
|
-
* schedule effects
|
|
13
|
-
*
|
|
14
|
+
* schedule effects: MANIFEST_LOADED for the multivariant playlist, one
|
|
15
|
+
* PLAYLIST_REFRESHED per rendition for a media playlist. Media playlists
|
|
16
|
+
* fetch under `hls:pl:` tokens the transport correlates back by token.
|
|
14
17
|
*/
|
|
15
18
|
const PLAYLIST_TOKEN = "hls:pl:";
|
|
16
19
|
/** The playlist MIME types, RFC 8216 §4: the registered type and the three in common use. */
|
|
@@ -23,7 +26,9 @@ const MANIFEST_TYPES = [
|
|
|
23
26
|
const INITIAL = {
|
|
24
27
|
manifestUrl: null,
|
|
25
28
|
mimeType: null,
|
|
26
|
-
pending: {}
|
|
29
|
+
pending: {},
|
|
30
|
+
answered: {},
|
|
31
|
+
seen: ""
|
|
27
32
|
};
|
|
28
33
|
/**
|
|
29
34
|
* Whether this adapter owns the manifest bytes. An explicit mimeType
|
|
@@ -36,37 +41,44 @@ function claims(state, text) {
|
|
|
36
41
|
if (state.mimeType !== null) return MANIFEST_TYPES.includes(state.mimeType);
|
|
37
42
|
return text.trimStart().startsWith("#EXTM3U");
|
|
38
43
|
}
|
|
39
|
-
function findRendition(presentation, renditionId) {
|
|
40
|
-
for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return {
|
|
41
|
-
rendition,
|
|
42
|
-
track
|
|
43
|
-
};
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
44
|
/**
|
|
47
|
-
* The
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* once the buffer drains. Fetching all of an active track's playlists means the
|
|
53
|
-
* rendition ABR lands on is already loaded, and a switch never stalls.
|
|
45
|
+
* The playlist URLs the selection needs and this slice has not asked for:
|
|
46
|
+
* the playing video rendition and its ladder neighbours, and every
|
|
47
|
+
* rendition of the active audio and text tracks (one each in practice; an
|
|
48
|
+
* audio-only ladder is short). Fetching the whole ladder up front costs one
|
|
49
|
+
* request per variant, hundreds on a large multivariant playlist.
|
|
54
50
|
*/
|
|
55
|
-
function neededPlaylists(kernel) {
|
|
51
|
+
function neededPlaylists(state, kernel) {
|
|
56
52
|
const presentation = kernel.presentation;
|
|
57
53
|
if (presentation === null) return [];
|
|
58
|
-
const
|
|
54
|
+
const asked = new Set(Object.values(state.pending));
|
|
55
|
+
const needed = [];
|
|
56
|
+
for (const contentType of [
|
|
59
57
|
"video",
|
|
60
58
|
"audio",
|
|
61
59
|
"text"
|
|
62
|
-
]
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
]) {
|
|
61
|
+
const trackId = kernel.tracks.active.get(contentType);
|
|
62
|
+
if (trackId === void 0) continue;
|
|
63
|
+
for (const period of presentation.periods) for (const track of period.tracks) {
|
|
64
|
+
if (track.id !== trackId) continue;
|
|
65
|
+
const candidates = contentType === "video" ? ladderNeighbours(track.renditions, kernel.quality.active, kernel.quality.constraints) : track.renditions;
|
|
66
|
+
for (const rendition of candidates) {
|
|
67
|
+
const url = rendition.playlistUrl;
|
|
68
|
+
if (url === void 0 || url in state.answered || asked.has(url)) continue;
|
|
69
|
+
if (needed.some((r) => r.playlistUrl === url)) continue;
|
|
70
|
+
needed.push(rendition);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
67
73
|
}
|
|
68
74
|
return needed;
|
|
69
75
|
}
|
|
76
|
+
/** Every rendition that reads the playlist at `url`. */
|
|
77
|
+
function renditionsAt(presentation, url) {
|
|
78
|
+
const out = [];
|
|
79
|
+
for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.playlistUrl === url) out.push(rendition);
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
70
82
|
/** Loops a message back into the bus through a zero-delay schedule effect. */
|
|
71
83
|
function feed(message) {
|
|
72
84
|
return {
|
|
@@ -76,19 +88,27 @@ function feed(message) {
|
|
|
76
88
|
then: message
|
|
77
89
|
};
|
|
78
90
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
/**
|
|
92
|
+
* A playlist that failed to load or parse. Its renditions are excluded,
|
|
93
|
+
* so arbitration moves off them and nothing asks for the playlist again.
|
|
94
|
+
* When that leaves a media track with no rendition at all, the load
|
|
95
|
+
* fails: the stream cannot play, and waiting would only stall.
|
|
96
|
+
*/
|
|
97
|
+
function unavailable(state, kernel, url, error) {
|
|
98
|
+
const answered = _objectSpread2(_objectSpread2({}, state.answered), {}, { [url]: false });
|
|
99
|
+
const next = _objectSpread2(_objectSpread2({}, state), {}, { answered });
|
|
100
|
+
const presentation = kernel.presentation;
|
|
101
|
+
if (presentation === null) return [next, []];
|
|
102
|
+
const failed = [];
|
|
103
|
+
for (const [failedUrl, ok] of Object.entries(answered)) if (!ok) for (const rendition of renditionsAt(presentation, failedUrl)) failed.push(rendition.id);
|
|
104
|
+
return [next, unavailableMessages(kernel, LOAD_FAILED, failed, error).map(feed)];
|
|
84
105
|
}
|
|
85
106
|
const reduceHls = (slice, msg, kernel) => {
|
|
86
107
|
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
87
|
-
if (msg.type === "LOAD") return [{
|
|
108
|
+
if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
|
|
88
109
|
manifestUrl: msg.url,
|
|
89
|
-
mimeType: msg.mimeType === void 0 ? null : normalizeMimeType(msg.mimeType)
|
|
90
|
-
|
|
91
|
-
}, []];
|
|
110
|
+
mimeType: msg.mimeType === void 0 ? null : normalizeMimeType(msg.mimeType)
|
|
111
|
+
}), []];
|
|
92
112
|
if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
|
|
93
113
|
if (msg.type === "SEGMENT_LOADED" && msg.trackId === "manifest" && state.manifestUrl !== null) {
|
|
94
114
|
const text = new TextDecoder().decode(msg.bytes);
|
|
@@ -106,50 +126,78 @@ const reduceHls = (slice, msg, kernel) => {
|
|
|
106
126
|
}
|
|
107
127
|
})]];
|
|
108
128
|
}
|
|
109
|
-
return [state, [
|
|
129
|
+
return [state, [feed({
|
|
130
|
+
type: "MANIFEST_LOADED",
|
|
131
|
+
presentation: result.presentation
|
|
132
|
+
})]];
|
|
110
133
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
134
|
+
let next = state;
|
|
135
|
+
const effects = [];
|
|
136
|
+
if (msg.type === "SEGMENT_LOADED" && msg.trackId in state.pending) {
|
|
137
|
+
var _media$error;
|
|
138
|
+
const url = state.pending[msg.trackId];
|
|
115
139
|
const pending = _objectSpread2({}, state.pending);
|
|
116
140
|
delete pending[msg.trackId];
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
141
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { pending });
|
|
142
|
+
const media = parseMediaPlaylist(new TextDecoder().decode(msg.bytes), url);
|
|
143
|
+
const playlist = media.playlist;
|
|
144
|
+
const error = playlist === null ? (_media$error = media.error) !== null && _media$error !== void 0 ? _media$error : {
|
|
145
|
+
category: "manifest",
|
|
146
|
+
code: "MANIFEST_PARSE_FAILED",
|
|
147
|
+
fatal: false,
|
|
148
|
+
recoverable: false
|
|
149
|
+
} : playlist.endlist && playlist.segments.length === 0 ? {
|
|
150
|
+
category: "manifest",
|
|
151
|
+
code: "MANIFEST_EMPTY",
|
|
152
|
+
fatal: false,
|
|
153
|
+
recoverable: false
|
|
154
|
+
} : null;
|
|
155
|
+
if (error !== null || playlist === null || kernel.presentation === null) {
|
|
156
|
+
if (error === null) return [next, effects];
|
|
157
|
+
effects.push({
|
|
158
|
+
kind: "emit",
|
|
159
|
+
event: "error",
|
|
160
|
+
payload: {
|
|
161
|
+
category: error.category,
|
|
162
|
+
code: error.code,
|
|
163
|
+
fatal: false,
|
|
164
|
+
recoverable: false,
|
|
165
|
+
url
|
|
129
166
|
}
|
|
130
|
-
})
|
|
167
|
+
});
|
|
168
|
+
const [failed, failEffects] = unavailable(next, kernel, url, error);
|
|
169
|
+
return [failed, [...effects, ...failEffects]];
|
|
131
170
|
}
|
|
132
|
-
|
|
133
|
-
|
|
171
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { answered: _objectSpread2(_objectSpread2({}, next.answered), {}, { [url]: true }) });
|
|
172
|
+
for (const rendition of renditionsAt(kernel.presentation, url)) {
|
|
173
|
+
const refresh = refreshFor(kernel.presentation, rendition.id, playlist);
|
|
174
|
+
if (refresh !== null) effects.push(feed(refresh));
|
|
175
|
+
}
|
|
176
|
+
return [next, effects];
|
|
134
177
|
}
|
|
135
|
-
if (
|
|
136
|
-
const
|
|
137
|
-
if (needed.length === 0) return [state, []];
|
|
138
|
-
const effects = [];
|
|
178
|
+
if (msg.type === "SEGMENT_FAILED" && msg.trackId in state.pending) {
|
|
179
|
+
const url = state.pending[msg.trackId];
|
|
139
180
|
const pending = _objectSpread2({}, state.pending);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
181
|
+
delete pending[msg.trackId];
|
|
182
|
+
return unavailable(_objectSpread2(_objectSpread2({}, next), {}, { pending }), kernel, url, msg.error);
|
|
183
|
+
}
|
|
184
|
+
if (kernel.lifecycle.phase !== "ready" || kernel.presentation === null) return [next, effects];
|
|
185
|
+
const key = `${kernel.quality.version}:${kernel.quality.active}`;
|
|
186
|
+
if (key === state.seen && msg.type !== "RESUME") return [next, effects];
|
|
187
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { seen: key });
|
|
188
|
+
const pending = _objectSpread2({}, next.pending);
|
|
189
|
+
for (const rendition of neededPlaylists(next, kernel)) {
|
|
190
|
+
const url = rendition.playlistUrl;
|
|
191
|
+
const token = `${PLAYLIST_TOKEN}${url}`;
|
|
192
|
+
pending[token] = url;
|
|
193
|
+
effects.push({
|
|
194
|
+
kind: "fetch",
|
|
195
|
+
token,
|
|
196
|
+
url,
|
|
197
|
+
renditionId: rendition.id
|
|
198
|
+
});
|
|
151
199
|
}
|
|
152
|
-
return [
|
|
200
|
+
return [_objectSpread2(_objectSpread2({}, next), {}, { pending }), effects];
|
|
153
201
|
};
|
|
154
202
|
/**
|
|
155
203
|
* The stage factory. `mattebox({ stages: [hlsCmaf()] })` is all a consumer
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { lex } from "./lexer.js";
|
|
3
3
|
//#region src/protocols/hls-cmaf/parse.ts
|
|
4
4
|
function manifestError(reason) {
|
|
@@ -422,36 +422,46 @@ function timelineShift(previous, next) {
|
|
|
422
422
|
return last.start + (first.seq - last.seq) * average - first.start;
|
|
423
423
|
}
|
|
424
424
|
/**
|
|
425
|
-
*
|
|
426
|
-
* referenced it
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
425
|
+
* The PLAYLIST_REFRESHED fact that merges a fetched media playlist into the
|
|
426
|
+
* rendition that referenced it, or null when the playlist is older than
|
|
427
|
+
* what the rendition holds. On a live refresh the new window is rebased
|
|
428
|
+
* onto the running timeline first, so segment start times stay absolute
|
|
429
|
+
* across reloads. The kernel merges the fact into the presentation it
|
|
430
|
+
* holds when the fact lands (applyRefresh).
|
|
430
431
|
*/
|
|
431
|
-
function
|
|
432
|
-
var _presentation$duratio;
|
|
432
|
+
function refreshFor(presentation, renditionId, playlist) {
|
|
433
433
|
let previous = [];
|
|
434
|
-
|
|
434
|
+
let sibling = [];
|
|
435
|
+
for (const period of presentation.periods) for (const track of period.tracks) {
|
|
436
|
+
if (!track.renditions.some((r) => r.id === renditionId)) continue;
|
|
437
|
+
for (const rendition of track.renditions) if (rendition.id === renditionId) previous = rendition.segments;
|
|
438
|
+
else if (Array.isArray(rendition.segments) && rendition.segments.length > 0) {
|
|
439
|
+
const candidate = rendition.segments;
|
|
440
|
+
const newest = (list) => {
|
|
441
|
+
var _list$seq, _list;
|
|
442
|
+
return (_list$seq = (_list = list[list.length - 1]) === null || _list === void 0 ? void 0 : _list.seq) !== null && _list$seq !== void 0 ? _list$seq : -1;
|
|
443
|
+
};
|
|
444
|
+
if (newest(candidate) > newest(sibling)) sibling = candidate;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
435
447
|
const knownLast = Array.isArray(previous) ? previous[previous.length - 1] : void 0;
|
|
436
448
|
const incomingLast = playlist.segments[playlist.segments.length - 1];
|
|
437
|
-
if (knownLast !== void 0 && incomingLast !== void 0 && !playlist.endlist && incomingLast.seq < knownLast.seq) return
|
|
438
|
-
const shift = timelineShift(previous, playlist.segments);
|
|
449
|
+
if (knownLast !== void 0 && incomingLast !== void 0 && !playlist.endlist && incomingLast.seq < knownLast.seq) return null;
|
|
450
|
+
const shift = timelineShift(!playlist.endlist && knownLast === void 0 && sibling.length > 0 ? sibling : previous, playlist.segments);
|
|
439
451
|
const segments = shift === 0 ? playlist.segments : playlist.segments.map((s) => _objectSpread2(_objectSpread2({}, s), {}, { start: s.start + shift }));
|
|
440
|
-
|
|
441
|
-
|
|
452
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
453
|
+
type: "PLAYLIST_REFRESHED",
|
|
454
|
+
trackId: renditionId,
|
|
455
|
+
renditionId,
|
|
456
|
+
mediaSequence: playlist.mediaSequence,
|
|
457
|
+
segments
|
|
458
|
+
}, playlist.init !== null ? { init: playlist.init } : {}), {}, {
|
|
459
|
+
protection: playlist.protection,
|
|
460
|
+
endlist: playlist.endlist
|
|
461
|
+
}, playlist.endlist ? {} : { updatePeriod: playlist.targetDuration || 4 }), playlist.dateAnchor !== void 0 ? { dateAnchor: {
|
|
442
462
|
wallClock: playlist.dateAnchor.wallClock,
|
|
443
463
|
presentationTime: playlist.dateAnchor.presentationTime + shift
|
|
444
|
-
} :
|
|
445
|
-
const periods = presentation.periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, { tracks: period.tracks.map((track) => {
|
|
446
|
-
var _track$protection;
|
|
447
|
-
if (!track.renditions.some((r) => r.id === renditionId)) return track;
|
|
448
|
-
return _objectSpread2(_objectSpread2({}, track), {}, {
|
|
449
|
-
protection: (_track$protection = track.protection) !== null && _track$protection !== void 0 ? _track$protection : playlist.protection,
|
|
450
|
-
renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2({}, rendition), {}, { segments }, playlist.init !== null ? { init: playlist.init } : {}) : rendition)
|
|
451
|
-
});
|
|
452
|
-
}) }));
|
|
453
|
-
const knownDuration = (_presentation$duratio = presentation.duration) !== null && _presentation$duratio !== void 0 ? _presentation$duratio : 0;
|
|
454
|
-
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, presentation), {}, { isLive: !playlist.endlist }, playlist.endlist ? { duration: Math.max(knownDuration, duration) } : {}), playlist.endlist ? {} : { live: _objectSpread2(_objectSpread2({}, presentation.live), {}, { updatePeriod: playlist.targetDuration || 4 }, dateAnchor !== void 0 ? { dateAnchor } : {}) }), {}, { periods });
|
|
464
|
+
} } : {});
|
|
455
465
|
}
|
|
456
466
|
//#endregion
|
|
457
|
-
export {
|
|
467
|
+
export { normalizeAvcCodec, parse, parseMediaPlaylist, refreshFor };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { withDeadGroups } from "../../kernel/rendition-select.js";
|
|
3
|
+
//#region src/protocols/hls-cmaf/unavailable.ts
|
|
4
|
+
/**
|
|
5
|
+
* What a playlist that cannot be used means for playback. Pure; shared by
|
|
6
|
+
* hls-cmaf (a playlist that fails to load) and hls-live (a playlist that
|
|
7
|
+
* keeps failing to reload). Each keeps its own constraint source, because
|
|
8
|
+
* CONSTRAIN replaces a source's constraint and two slices writing one source
|
|
9
|
+
* in the same turn would erase each other's exclusions.
|
|
10
|
+
*/
|
|
11
|
+
/** Renditions whose playlist failed to load (hls-cmaf). */
|
|
12
|
+
const LOAD_FAILED = "hls:unavailable";
|
|
13
|
+
/** Renditions whose playlist kept failing to reload (hls-live). */
|
|
14
|
+
const RELOAD_FAILED = "hls-live:unavailable";
|
|
15
|
+
/**
|
|
16
|
+
* The messages that stop relying on the renditions in `ids`, the whole list
|
|
17
|
+
* `source` excludes. A failed audio group takes the variants that require
|
|
18
|
+
* it, so arbitration moves to a variant on a working group and alt-audio
|
|
19
|
+
* follows. A CONSTRAIN when playback can go on; a fatal MANIFEST_FAILED
|
|
20
|
+
* when a video track has no rendition left, or when the active audio track
|
|
21
|
+
* has none and no variant names an audio group to move to.
|
|
22
|
+
*/
|
|
23
|
+
function unavailableMessages(kernel, source, ids, error) {
|
|
24
|
+
var _kernel$quality$const, _kernel$quality$const2;
|
|
25
|
+
const presentation = kernel.presentation;
|
|
26
|
+
if (presentation === null) return [];
|
|
27
|
+
const other = source === "hls:unavailable" ? RELOAD_FAILED : LOAD_FAILED;
|
|
28
|
+
const excluded = withDeadGroups(presentation, /* @__PURE__ */ new Set([...ids, ...(_kernel$quality$const = (_kernel$quality$const2 = kernel.quality.constraints.get(other)) === null || _kernel$quality$const2 === void 0 ? void 0 : _kernel$quality$const2.excludeIds) !== null && _kernel$quality$const !== void 0 ? _kernel$quality$const : []]));
|
|
29
|
+
const grouped = presentation.couplings.some((c) => c.requires.audio !== void 0);
|
|
30
|
+
const activeAudio = kernel.tracks.active.get("audio");
|
|
31
|
+
if (presentation.periods.some((period) => period.tracks.some((track) => track.renditions.length > 0 && track.renditions.every((r) => excluded.has(r.id)) && (track.contentType === "video" || track.id === activeAudio && !grouped)))) return [{
|
|
32
|
+
type: "MANIFEST_FAILED",
|
|
33
|
+
error: _objectSpread2(_objectSpread2({}, error), {}, { fatal: true })
|
|
34
|
+
}];
|
|
35
|
+
return [{
|
|
36
|
+
type: "CONSTRAIN",
|
|
37
|
+
source,
|
|
38
|
+
constraint: { excludeIds: [...excluded] }
|
|
39
|
+
}];
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { LOAD_FAILED, RELOAD_FAILED, unavailableMessages };
|