mattebox 0.14.0 → 0.16.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/README.md +29 -21
- package/dist/cdn/mattebox.dash-drm.min.js +3 -3
- package/dist/cdn/mattebox.dash-ll.min.js +3 -0
- package/dist/cdn/mattebox.dash.min.js +3 -3
- package/dist/cdn/mattebox.dual-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ll.min.js +3 -0
- 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 -0
- 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 +6 -6
- package/dist/containers/fmp4/writer.d.ts +7 -1
- package/dist/containers/fmp4/writer.d.ts.map +1 -1
- package/dist/containers/fmp4/writer.js +2 -1
- package/dist/containers/fmp4/writer.js.map +1 -1
- package/dist/containers/mp4-box/index.d.ts +8 -0
- package/dist/containers/mp4-box/index.d.ts.map +1 -1
- package/dist/containers/mp4-box/index.js +27 -0
- package/dist/containers/mp4-box/index.js.map +1 -1
- package/dist/containers/ts-transmux/demux.d.ts +2 -0
- package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
- package/dist/containers/ts-transmux/demux.js +3 -1
- package/dist/containers/ts-transmux/demux.js.map +1 -1
- package/dist/containers/ts-transmux/h265.d.ts +51 -0
- package/dist/containers/ts-transmux/h265.d.ts.map +1 -0
- package/dist/containers/ts-transmux/h265.js +182 -0
- package/dist/containers/ts-transmux/h265.js.map +1 -0
- package/dist/containers/ts-transmux/transmux.d.ts +3 -2
- package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
- package/dist/containers/ts-transmux/transmux.js +35 -11
- package/dist/containers/ts-transmux/transmux.js.map +1 -1
- package/dist/eme/index.d.ts +1 -10
- package/dist/eme/index.d.ts.map +1 -1
- package/dist/eme/index.js +4 -2
- package/dist/eme/index.js.map +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/containers/fmp4/writer.js +2 -1
- package/dist/es2015/containers/id3.js +1 -1
- package/dist/es2015/containers/mp4-box/index.js +24 -1
- package/dist/es2015/containers/scte35.js +1 -1
- package/dist/es2015/containers/ts-transmux/demux.js +3 -1
- package/dist/es2015/containers/ts-transmux/h264.js +1 -1
- package/dist/es2015/containers/ts-transmux/h265.js +175 -0
- package/dist/es2015/containers/ts-transmux/index.js +1 -1
- package/dist/es2015/containers/ts-transmux/runner.js +2 -2
- package/dist/es2015/containers/ts-transmux/transmux.js +39 -16
- package/dist/es2015/containers/webvtt.js +1 -1
- package/dist/es2015/containers/wvtt.js +1 -1
- package/dist/es2015/eme/index.js +7 -5
- package/dist/es2015/index.js +8 -4
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/characteristics.js +19 -1
- package/dist/es2015/kernel/context.js +7 -0
- package/dist/es2015/kernel/dry-run.js +1 -1
- package/dist/es2015/kernel/mse.js +1 -1
- package/dist/es2015/kernel/prepare.js +3 -3
- package/dist/es2015/kernel/presentation.js +10 -1
- package/dist/es2015/kernel/reducer.js +92 -33
- package/dist/es2015/kernel/refresh.js +2 -2
- package/dist/es2015/kernel/rendition-select.js +2 -2
- package/dist/es2015/kernel/scheduler.js +31 -6
- package/dist/es2015/kernel/timeline.js +1 -1
- package/dist/es2015/kernel/trace.js +1 -1
- package/dist/es2015/kernel/transport.js +154 -22
- package/dist/es2015/presets/dash-ll/index.js +15 -0
- package/dist/es2015/presets/define.js +2 -2
- package/dist/es2015/presets/dual-ll/index.js +16 -0
- package/dist/es2015/presets/full/index.js +6 -4
- package/dist/es2015/presets/hls-ll/index.js +14 -0
- package/dist/es2015/presets/tiers.js +28 -3
- package/dist/es2015/protocols/dash-cmaf/index.js +13 -8
- package/dist/es2015/protocols/dash-cmaf/parse.js +129 -41
- package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +1 -1
- package/dist/es2015/protocols/dash-cmaf/periods.js +1 -1
- package/dist/es2015/protocols/dash-live/index.js +75 -21
- package/dist/es2015/protocols/dash-ll/index.js +42 -0
- package/dist/es2015/protocols/hls-cmaf/index.js +5 -5
- package/dist/es2015/protocols/hls-cmaf/lexer.js +7 -1
- package/dist/es2015/protocols/hls-cmaf/parse.js +90 -27
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +4 -3
- package/dist/es2015/protocols/hls-live/index.js +92 -18
- package/dist/es2015/protocols/hls-ll/index.js +30 -0
- package/dist/es2015/protocols/hls-ll/parse.js +240 -0
- package/dist/es2015/stages/abr/index.js +9 -2
- package/dist/es2015/stages/aes-128/index.js +1 -1
- package/dist/es2015/stages/chapters/index.js +2 -2
- package/dist/es2015/stages/chapters/parse.js +2 -2
- package/dist/es2015/stages/cmcd/index.js +7 -1
- package/dist/es2015/stages/codec-probe/index.js +1 -1
- package/dist/es2015/stages/content-steering/index.js +1 -1
- package/dist/es2015/stages/eme-core/index.js +193 -42
- package/dist/es2015/stages/eme-fairplay/index.js +1 -1
- package/dist/es2015/stages/hdr/index.js +1 -1
- package/dist/es2015/stages/live-catchup/index.js +221 -0
- package/dist/es2015/stages/qoe/index.js +1 -1
- package/dist/es2015/stages/recovery/index.js +2 -2
- package/dist/es2015/stages/rendition-names/index.js +1 -1
- package/dist/es2015/stages/text-cea608/decode.js +1 -1
- package/dist/es2015/stages/text-cea708/decode.js +2 -2
- package/dist/es2015/stages/text-cea708/index.js +1 -1
- package/dist/es2015/stages/text-ttml/images.js +60 -0
- package/dist/es2015/stages/text-ttml/index.js +22 -6
- package/dist/es2015/stages/text-ttml/parse.js +71 -5
- package/dist/es2015/stages/thumbnails/index.js +1 -1
- package/dist/es2015/stages/timed-metadata/index.js +1 -1
- package/dist/es2015/stages/trick-play/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel/characteristics.d.ts +8 -1
- package/dist/kernel/characteristics.d.ts.map +1 -1
- package/dist/kernel/characteristics.js +23 -0
- package/dist/kernel/characteristics.js.map +1 -1
- package/dist/kernel/context.d.ts +4 -6
- 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/lifecycle.d.ts +2 -6
- package/dist/kernel/lifecycle.d.ts.map +1 -1
- package/dist/kernel/lifecycle.js.map +1 -1
- package/dist/kernel/prepare.d.ts +3 -0
- package/dist/kernel/prepare.d.ts.map +1 -1
- package/dist/kernel/prepare.js +2 -1
- package/dist/kernel/prepare.js.map +1 -1
- package/dist/kernel/presentation.d.ts +5 -0
- package/dist/kernel/presentation.d.ts.map +1 -1
- package/dist/kernel/presentation.js +9 -0
- package/dist/kernel/presentation.js.map +1 -1
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +108 -49
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/refresh.d.ts.map +1 -1
- package/dist/kernel/refresh.js +2 -0
- package/dist/kernel/refresh.js.map +1 -1
- package/dist/kernel/scheduler.d.ts.map +1 -1
- package/dist/kernel/scheduler.js +40 -3
- package/dist/kernel/scheduler.js.map +1 -1
- package/dist/kernel/transport.d.ts +34 -5
- package/dist/kernel/transport.d.ts.map +1 -1
- package/dist/kernel/transport.js +148 -11
- package/dist/kernel/transport.js.map +1 -1
- package/dist/presets/dash-ll/index.d.ts +4 -0
- package/dist/presets/dash-ll/index.d.ts.map +1 -0
- package/dist/presets/dash-ll/index.js +10 -0
- package/dist/presets/dash-ll/index.js.map +1 -0
- package/dist/presets/dual-ll/index.d.ts +4 -0
- package/dist/presets/dual-ll/index.d.ts.map +1 -0
- package/dist/presets/dual-ll/index.js +15 -0
- package/dist/presets/dual-ll/index.js.map +1 -0
- package/dist/presets/full/index.d.ts.map +1 -1
- package/dist/presets/full/index.js +6 -4
- package/dist/presets/full/index.js.map +1 -1
- package/dist/presets/hls-ll/index.d.ts +4 -0
- package/dist/presets/hls-ll/index.d.ts.map +1 -0
- package/dist/presets/hls-ll/index.js +9 -0
- package/dist/presets/hls-ll/index.js.map +1 -0
- package/dist/presets/tiers.d.ts +16 -0
- package/dist/presets/tiers.d.ts.map +1 -1
- package/dist/presets/tiers.js +25 -0
- package/dist/presets/tiers.js.map +1 -1
- package/dist/protocols/dash-cmaf/index.d.ts +29 -1
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +9 -4
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts +8 -2
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +121 -14
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/dash-live/index.d.ts +22 -0
- package/dist/protocols/dash-live/index.d.ts.map +1 -1
- package/dist/protocols/dash-live/index.js +77 -18
- package/dist/protocols/dash-live/index.js.map +1 -1
- package/dist/protocols/dash-ll/index.d.ts +27 -0
- package/dist/protocols/dash-ll/index.d.ts.map +1 -0
- package/dist/protocols/dash-ll/index.js +35 -0
- package/dist/protocols/dash-ll/index.js.map +1 -0
- package/dist/protocols/hls-cmaf/index.d.ts +23 -0
- package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/index.js +4 -4
- package/dist/protocols/hls-cmaf/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/lexer.js +7 -0
- package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts +28 -2
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +106 -11
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts +1 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.js +8 -2
- package/dist/protocols/hls-cmaf/unavailable.js.map +1 -1
- package/dist/protocols/hls-live/index.d.ts +65 -0
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js +115 -16
- package/dist/protocols/hls-live/index.js.map +1 -1
- package/dist/protocols/hls-ll/index.d.ts +22 -0
- package/dist/protocols/hls-ll/index.d.ts.map +1 -0
- package/dist/protocols/hls-ll/index.js +32 -0
- package/dist/protocols/hls-ll/index.js.map +1 -0
- package/dist/protocols/hls-ll/parse.d.ts +45 -0
- package/dist/protocols/hls-ll/parse.d.ts.map +1 -0
- package/dist/protocols/hls-ll/parse.js +300 -0
- package/dist/protocols/hls-ll/parse.js.map +1 -0
- package/dist/stages/abr/index.d.ts.map +1 -1
- package/dist/stages/abr/index.js +6 -6
- package/dist/stages/abr/index.js.map +1 -1
- package/dist/stages/cmcd/index.d.ts.map +1 -1
- package/dist/stages/cmcd/index.js +12 -3
- package/dist/stages/cmcd/index.js.map +1 -1
- package/dist/stages/eme-core/index.d.ts +67 -2
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +191 -40
- package/dist/stages/eme-core/index.js.map +1 -1
- package/dist/stages/live-catchup/index.d.ts +42 -0
- package/dist/stages/live-catchup/index.d.ts.map +1 -0
- package/dist/stages/live-catchup/index.js +217 -0
- package/dist/stages/live-catchup/index.js.map +1 -0
- package/dist/stages/recovery/index.d.ts.map +1 -1
- package/dist/stages/recovery/index.js +6 -2
- package/dist/stages/recovery/index.js.map +1 -1
- package/dist/stages/text-ttml/images.d.ts +10 -0
- package/dist/stages/text-ttml/images.d.ts.map +1 -0
- package/dist/stages/text-ttml/images.js +71 -0
- package/dist/stages/text-ttml/images.js.map +1 -0
- package/dist/stages/text-ttml/index.d.ts +13 -0
- package/dist/stages/text-ttml/index.d.ts.map +1 -1
- package/dist/stages/text-ttml/index.js +26 -6
- package/dist/stages/text-ttml/index.js.map +1 -1
- package/dist/stages/text-ttml/parse.d.ts +5 -2
- package/dist/stages/text-ttml/parse.d.ts.map +1 -1
- package/dist/stages/text-ttml/parse.js +74 -2
- package/dist/stages/text-ttml/parse.js.map +1 -1
- package/dist/types/ir.d.ts +43 -0
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +4 -0
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +40 -0
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/stage.d.ts +24 -5
- package/dist/types/stage.d.ts.map +1 -1
- package/package.json +4 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { byteToHex } from "../../kernel/base64.js";
|
|
3
3
|
import { resolveUrl } from "../../kernel/url.js";
|
|
4
4
|
import { manifestError } from "../adapter-shared.js";
|
|
@@ -163,7 +163,10 @@ function parseMediaPlaylist(text, baseUrl) {
|
|
|
163
163
|
playlist: null,
|
|
164
164
|
error: manifestError("missing #EXTM3U")
|
|
165
165
|
};
|
|
166
|
-
|
|
166
|
+
return parseMediaLines(lex(text), baseUrl);
|
|
167
|
+
}
|
|
168
|
+
/** A lexed media playlist into segments, for a caller that reads the lines itself too. */
|
|
169
|
+
function parseMediaLines(lines, baseUrl) {
|
|
167
170
|
const segments = [];
|
|
168
171
|
let init = null;
|
|
169
172
|
let targetDuration = 0;
|
|
@@ -183,6 +186,9 @@ function parseMediaPlaylist(text, baseUrl) {
|
|
|
183
186
|
let previousRangeEnd = null;
|
|
184
187
|
let start = 0;
|
|
185
188
|
let seq = 0;
|
|
189
|
+
let serverControl = null;
|
|
190
|
+
let skipped = 0;
|
|
191
|
+
let removedDateRanges = [];
|
|
186
192
|
for (const line of lines) {
|
|
187
193
|
if (line.kind === "tag") {
|
|
188
194
|
switch (line.name) {
|
|
@@ -237,6 +243,15 @@ function parseMediaPlaylist(text, baseUrl) {
|
|
|
237
243
|
case "EXT-X-TILES":
|
|
238
244
|
var _tiles;
|
|
239
245
|
tiles = (_tiles = tiles) !== null && _tiles !== void 0 ? _tiles : tileGridFrom(line.attributes);
|
|
246
|
+
break;
|
|
247
|
+
case "EXT-X-SERVER-CONTROL":
|
|
248
|
+
serverControl = line.attributes;
|
|
249
|
+
break;
|
|
250
|
+
case "EXT-X-SKIP":
|
|
251
|
+
var _line$attributes$RECE;
|
|
252
|
+
skipped = Number(line.attributes["SKIPPED-SEGMENTS"]) || 0;
|
|
253
|
+
seq += skipped;
|
|
254
|
+
removedDateRanges = ((_line$attributes$RECE = line.attributes["RECENTLY-REMOVED-DATERANGES"]) !== null && _line$attributes$RECE !== void 0 ? _line$attributes$RECE : "").split(" ").filter((id) => id !== "");
|
|
240
255
|
}
|
|
241
256
|
continue;
|
|
242
257
|
}
|
|
@@ -265,7 +280,7 @@ function parseMediaPlaylist(text, baseUrl) {
|
|
|
265
280
|
pendingDiscontinuity = false;
|
|
266
281
|
}
|
|
267
282
|
return {
|
|
268
|
-
playlist: _objectSpread2(_objectSpread2(_objectSpread2({
|
|
283
|
+
playlist: _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
269
284
|
segments,
|
|
270
285
|
init,
|
|
271
286
|
targetDuration,
|
|
@@ -273,7 +288,7 @@ function parseMediaPlaylist(text, baseUrl) {
|
|
|
273
288
|
endlist,
|
|
274
289
|
playlistType,
|
|
275
290
|
protection
|
|
276
|
-
}, dateAnchor !== void 0 ? { dateAnchor } : {}), tiles !== null ? { tiles } : {}), dateRangeTags.length > 0 ? { dateRanges: dateRangesFrom(dateRangeTags, dateAnchor) } : {}),
|
|
291
|
+
}, dateAnchor !== void 0 ? { dateAnchor } : {}), tiles !== null ? { tiles } : {}), dateRangeTags.length > 0 ? { dateRanges: dateRangesFrom(dateRangeTags, dateAnchor) } : {}), serverControl !== null ? { serverControl } : {}), Number(serverControl === null || serverControl === void 0 ? void 0 : serverControl["HOLD-BACK"]) > 0 ? { holdBack: Number(serverControl === null || serverControl === void 0 ? void 0 : serverControl["HOLD-BACK"]) } : {}), skipped > 0 ? { skipped } : {}), removedDateRanges.length > 0 ? { removedDateRanges } : {}),
|
|
277
292
|
error: null
|
|
278
293
|
};
|
|
279
294
|
}
|
|
@@ -282,6 +297,20 @@ function mediaContentType(type) {
|
|
|
282
297
|
if (type === "SUBTITLES") return "text";
|
|
283
298
|
return null;
|
|
284
299
|
}
|
|
300
|
+
function videoMembers(entries, groupId) {
|
|
301
|
+
const members = entries.filter((e) => e.type === "VIDEO" && e.groupId === groupId);
|
|
302
|
+
const declared = members.some((e) => e.attributes.DEFAULT === "YES");
|
|
303
|
+
return members.map((entry) => ({
|
|
304
|
+
key: attributeKey(entry.attributes, PER_GROUP),
|
|
305
|
+
entry,
|
|
306
|
+
main: declared ? entry.attributes.DEFAULT === "YES" : entry.uri === null
|
|
307
|
+
}));
|
|
308
|
+
}
|
|
309
|
+
/** What a VIDEO rendition says about its version, as the AUDIO and SUBTITLES ones do. */
|
|
310
|
+
function videoTrackFields({ entry, main }) {
|
|
311
|
+
const characteristics = characteristicsOf(entry);
|
|
312
|
+
return _objectSpread2(_objectSpread2({ name: entry.name }, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), {}, { role: main ? "main" : "alternate" }, characteristics.length > 0 ? { characteristics } : {});
|
|
313
|
+
}
|
|
285
314
|
/** The attributes as one string, in name order, leaving out the names `skip` matches. */
|
|
286
315
|
function attributeKey(attributes, skip) {
|
|
287
316
|
return Object.keys(attributes).filter((name) => (skip === null || skip === void 0 ? void 0 : skip.test(name)) !== true).sort().map((name) => `${name}=${attributes[name]}`).join(",");
|
|
@@ -413,14 +442,14 @@ function sessionDataFrom(attributes, baseUrl) {
|
|
|
413
442
|
return _objectSpread2(_objectSpread2(_objectSpread2({ id }, attributes.VALUE !== void 0 ? { value: attributes.VALUE } : {}), attributes.URI !== void 0 ? { uri: resolveUrl(attributes.URI, baseUrl) } : {}), attributes.LANGUAGE !== void 0 ? { lang: attributes.LANGUAGE } : {});
|
|
414
443
|
}
|
|
415
444
|
/** parse either playlist form into a Presentation. Never throws. */
|
|
416
|
-
function parse(text, baseUrl) {
|
|
445
|
+
function parse(text, baseUrl, parseMedia = parseMediaPlaylist) {
|
|
417
446
|
if (!text.trimStart().startsWith("#EXTM3U")) return {
|
|
418
447
|
presentation: null,
|
|
419
448
|
error: manifestError("missing #EXTM3U")
|
|
420
449
|
};
|
|
421
450
|
const lines = lex(text);
|
|
422
451
|
if (!lines.some((line) => line.kind === "tag" && line.name === "EXT-X-STREAM-INF")) {
|
|
423
|
-
const media =
|
|
452
|
+
const media = parseMedia(text, baseUrl);
|
|
424
453
|
if (media.playlist === null) {
|
|
425
454
|
var _media$error;
|
|
426
455
|
return {
|
|
@@ -453,7 +482,7 @@ function parse(text, baseUrl) {
|
|
|
453
482
|
presentation: _objectSpread2(_objectSpread2(_objectSpread2({
|
|
454
483
|
id: baseUrl,
|
|
455
484
|
isLive: !media.playlist.endlist
|
|
456
|
-
}, media.playlist.endlist ? { duration } : {}), media.playlist.endlist ? {} : { live: _objectSpread2({ updatePeriod: media.playlist.targetDuration || 4 }, media.playlist.dateAnchor !== void 0 ? { dateAnchor: media.playlist.dateAnchor } : {}) }), {}, {
|
|
485
|
+
}, media.playlist.endlist ? { duration } : {}), media.playlist.endlist ? {} : { live: _objectSpread2(_objectSpread2(_objectSpread2({ updatePeriod: media.playlist.targetDuration || 4 }, media.playlist.holdBack !== void 0 ? { holdBack: media.playlist.holdBack } : {}), media.playlist.lowLatency === true ? { lowLatency: true } : {}), media.playlist.dateAnchor !== void 0 ? { dateAnchor: media.playlist.dateAnchor } : {}) }), {}, {
|
|
457
486
|
periods: [{
|
|
458
487
|
id: "p0",
|
|
459
488
|
start: 0,
|
|
@@ -520,8 +549,10 @@ function parse(text, baseUrl) {
|
|
|
520
549
|
const audioOnlyVariants = [];
|
|
521
550
|
const couplings = [];
|
|
522
551
|
const declared = /* @__PURE__ */ new Map();
|
|
552
|
+
const alternateVideos = /* @__PURE__ */ new Map();
|
|
553
|
+
let mainVideo;
|
|
523
554
|
for (const variant of variants) {
|
|
524
|
-
var _dimensions;
|
|
555
|
+
var _dimensions, _variant$attributes$V;
|
|
525
556
|
const bandwidth = Number(variant.attributes.BANDWIDTH) || 0;
|
|
526
557
|
const [width, height] = (_dimensions = dimensions(variant.attributes.RESOLUTION)) !== null && _dimensions !== void 0 ? _dimensions : [];
|
|
527
558
|
const { video, audio } = splitCodecs(variant.attributes.CODECS);
|
|
@@ -544,31 +575,63 @@ function parse(text, baseUrl) {
|
|
|
544
575
|
declared.set(id, variant.attributes);
|
|
545
576
|
const average = Number(variant.attributes["AVERAGE-BANDWIDTH"]);
|
|
546
577
|
const supplemental = variant.attributes["SUPPLEMENTAL-CODECS"];
|
|
547
|
-
|
|
578
|
+
const base = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
548
579
|
id,
|
|
549
580
|
bitrate: bandwidth,
|
|
550
581
|
codecs,
|
|
551
582
|
mimeType: "video/mp4",
|
|
552
583
|
segments: [],
|
|
553
584
|
playlistUrl: variant.uri
|
|
554
|
-
}, average > 0 ? { averageBitrate: average } : {}), supplemental !== void 0 ? { supplementalCodecs: supplemental } : {}), pathway !== void 0 ? { pathway } : {}), width !== void 0 ? { width } : {}), height !== void 0 ? { height } : {}), Number.isFinite(frameRate) ? { frameRate } : {}), videoRange !== void 0 ? { videoRange } : {})
|
|
585
|
+
}, average > 0 ? { averageBitrate: average } : {}), supplemental !== void 0 ? { supplementalCodecs: supplemental } : {}), pathway !== void 0 ? { pathway } : {}), width !== void 0 ? { width } : {}), height !== void 0 ? { height } : {}), Number.isFinite(frameRate) ? { frameRate } : {}), videoRange !== void 0 ? { videoRange } : {});
|
|
555
586
|
const requires = {};
|
|
556
587
|
if (variant.attributes.AUDIO !== void 0) requires.audio = variant.attributes.AUDIO;
|
|
557
588
|
if (variant.attributes.SUBTITLES !== void 0) requires.text = variant.attributes.SUBTITLES;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
589
|
+
const members = videoMembers(mediaEntries, (_variant$attributes$V = variant.attributes.VIDEO) !== null && _variant$attributes$V !== void 0 ? _variant$attributes$V : "");
|
|
590
|
+
const versions = members.length > 0 ? members : [null];
|
|
591
|
+
for (const member of versions) {
|
|
592
|
+
var _member$entry$uri;
|
|
593
|
+
const rendition = member === null ? base : _objectSpread2(_objectSpread2({}, base), {}, {
|
|
594
|
+
id: member.main ? id : `${id}:${member.entry.name}`,
|
|
595
|
+
playlistUrl: (_member$entry$uri = member.entry.uri) !== null && _member$entry$uri !== void 0 ? _member$entry$uri : variant.uri
|
|
596
|
+
});
|
|
597
|
+
if (member === null || member.main) {
|
|
598
|
+
var _mainVideo;
|
|
599
|
+
renditions.push(rendition);
|
|
600
|
+
if (member !== null) (_mainVideo = mainVideo) !== null && _mainVideo !== void 0 || (mainVideo = member);
|
|
601
|
+
} else {
|
|
602
|
+
var _alternateVideos$get;
|
|
603
|
+
const version = (_alternateVideos$get = alternateVideos.get(member.key)) !== null && _alternateVideos$get !== void 0 ? _alternateVideos$get : {
|
|
604
|
+
member,
|
|
605
|
+
renditions: []
|
|
606
|
+
};
|
|
607
|
+
version.renditions.push(rendition);
|
|
608
|
+
alternateVideos.set(member.key, version);
|
|
609
|
+
}
|
|
610
|
+
if (Object.keys(requires).length > 0) couplings.push({
|
|
611
|
+
renditionId: rendition.id,
|
|
612
|
+
requires
|
|
613
|
+
});
|
|
614
|
+
}
|
|
562
615
|
}
|
|
563
616
|
const tracks = [];
|
|
564
|
-
if (renditions.length > 0)
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
617
|
+
if (renditions.length > 0) {
|
|
618
|
+
tracks.push(_objectSpread2(_objectSpread2({
|
|
619
|
+
id: "video-main",
|
|
620
|
+
contentType: "video",
|
|
621
|
+
mimeType: "video/mp4"
|
|
622
|
+
}, mainVideo !== void 0 ? videoTrackFields(mainVideo) : {}), {}, {
|
|
623
|
+
protection: sessionProtection,
|
|
624
|
+
renditions
|
|
625
|
+
}));
|
|
626
|
+
for (const { member, renditions: versionRenditions } of alternateVideos.values()) tracks.push(_objectSpread2(_objectSpread2({
|
|
627
|
+
id: `video:${member.entry.name}`,
|
|
628
|
+
contentType: "video",
|
|
629
|
+
mimeType: "video/mp4"
|
|
630
|
+
}, videoTrackFields(member)), {}, {
|
|
631
|
+
protection: sessionProtection,
|
|
632
|
+
renditions: versionRenditions
|
|
633
|
+
}));
|
|
634
|
+
} else if (audioOnlyVariants.length > 0) {
|
|
572
635
|
const audioRenditions = [];
|
|
573
636
|
for (const variant of audioOnlyVariants) {
|
|
574
637
|
const bandwidth = Number(variant.attributes.BANDWIDTH) || 0;
|
|
@@ -696,12 +759,12 @@ function refreshFor(presentation, renditionId, playlist) {
|
|
|
696
759
|
if (newest(candidate) > newest(sibling)) sibling = candidate;
|
|
697
760
|
}
|
|
698
761
|
}
|
|
699
|
-
const knownLast = Array.isArray(previous) ? previous
|
|
700
|
-
const incomingLast = playlist.segments
|
|
762
|
+
const knownLast = Array.isArray(previous) ? previous.filter((s) => s.preload !== true).pop() : void 0;
|
|
763
|
+
const incomingLast = playlist.segments.filter((s) => s.preload !== true).pop();
|
|
701
764
|
if (knownLast !== void 0 && incomingLast !== void 0 && !playlist.endlist && incomingLast.seq < knownLast.seq) return null;
|
|
702
765
|
const shift = timelineShift(!playlist.endlist && knownLast === void 0 && sibling.length > 0 ? sibling : previous, playlist.segments);
|
|
703
766
|
const segments = shift === 0 ? playlist.segments : playlist.segments.map((s) => _objectSpread2(_objectSpread2({}, s), {}, { start: s.start + shift }));
|
|
704
|
-
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
767
|
+
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
705
768
|
type: "PLAYLIST_REFRESHED",
|
|
706
769
|
trackId: renditionId,
|
|
707
770
|
renditionId,
|
|
@@ -710,7 +773,7 @@ function refreshFor(presentation, renditionId, playlist) {
|
|
|
710
773
|
}, playlist.init !== null ? { init: playlist.init } : {}), playlist.tiles !== void 0 ? { tiles: playlist.tiles } : {}), {}, {
|
|
711
774
|
protection: playlist.protection,
|
|
712
775
|
endlist: playlist.endlist
|
|
713
|
-
}, playlist.endlist ? {} : { updatePeriod: playlist.targetDuration || 4 }), playlist.dateAnchor !== void 0 ? { dateAnchor: {
|
|
776
|
+
}, playlist.endlist ? {} : { updatePeriod: playlist.targetDuration || 4 }), !playlist.endlist && playlist.holdBack !== void 0 ? { holdBack: playlist.holdBack } : {}), !playlist.endlist ? { lowLatency: playlist.lowLatency === true } : {}), playlist.dateAnchor !== void 0 ? { dateAnchor: {
|
|
714
777
|
wallClock: playlist.dateAnchor.wallClock,
|
|
715
778
|
presentationTime: playlist.dateAnchor.presentationTime + shift
|
|
716
779
|
} } : {}), playlist.dateRanges !== void 0 ? { dateRanges: shift === 0 ? playlist.dateRanges : playlist.dateRanges.map((range) => shiftRange(range, shift)) } : {});
|
|
@@ -719,4 +782,4 @@ function shiftRange(range, shift) {
|
|
|
719
782
|
return _objectSpread2(_objectSpread2(_objectSpread2({}, range), {}, { start: range.start + shift }, range.end !== void 0 ? { end: range.end + shift } : {}), range.plannedEnd !== void 0 ? { plannedEnd: range.plannedEnd + shift } : {});
|
|
720
783
|
}
|
|
721
784
|
//#endregion
|
|
722
|
-
export { normalizeAvcCodec, parse, parseMediaPlaylist, refreshFor };
|
|
785
|
+
export { normalizeAvcCodec, parse, parseByteRange, parseMediaLines, parseMediaPlaylist, refreshFor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { isTrick } from "../../kernel/presentation.js";
|
|
3
3
|
import { withDeadGroups } from "../../kernel/rendition-select.js";
|
|
4
4
|
//#region src/protocols/hls-cmaf/unavailable.ts
|
|
@@ -36,7 +36,7 @@ function exclusion(presentation, kernel, source, ids) {
|
|
|
36
36
|
* `source` excludes. A failed audio group takes the variants that require
|
|
37
37
|
* it, so arbitration moves to a variant on a working group and alt-audio
|
|
38
38
|
* follows. A CONSTRAIN when playback can go on; a fatal MANIFEST_FAILED
|
|
39
|
-
* when
|
|
39
|
+
* when the active video track has no rendition left, or when the active audio track
|
|
40
40
|
* has none and no variant names an audio group to move to.
|
|
41
41
|
*/
|
|
42
42
|
function unavailableMessages(kernel, source, ids, error) {
|
|
@@ -45,7 +45,8 @@ function unavailableMessages(kernel, source, ids, error) {
|
|
|
45
45
|
const { excluded, own } = exclusion(presentation, kernel, source, ids);
|
|
46
46
|
const grouped = presentation.couplings.some((c) => c.requires.audio !== void 0);
|
|
47
47
|
const activeAudio = kernel.tracks.active.get("audio");
|
|
48
|
-
|
|
48
|
+
const activeVideo = kernel.tracks.active.get("video");
|
|
49
|
+
if (presentation.periods.some((period) => period.tracks.some((track) => track.renditions.length > 0 && track.renditions.every((r) => excluded.has(r.id)) && (track.contentType === "video" && !isTrick(track) && (activeVideo === void 0 || track.id === activeVideo) || track.id === activeAudio && !grouped)))) return [{
|
|
49
50
|
type: "MANIFEST_FAILED",
|
|
50
51
|
error: _objectSpread2(_objectSpread2({}, error), {}, { fatal: true })
|
|
51
52
|
}];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
import { findRendition } from "../../kernel/presentation.js";
|
|
4
4
|
import { activeRenditions } from "../../kernel/rendition-select.js";
|
|
@@ -38,7 +38,10 @@ const INITIAL = {
|
|
|
38
38
|
awaitingTarget: false,
|
|
39
39
|
suspended: false,
|
|
40
40
|
failures: {},
|
|
41
|
-
abandoned: []
|
|
41
|
+
abandoned: [],
|
|
42
|
+
blocking: {},
|
|
43
|
+
chained: [],
|
|
44
|
+
reports: {}
|
|
42
45
|
};
|
|
43
46
|
/**
|
|
44
47
|
* Failed reloads of one playlist in a row before the loop gives up on it.
|
|
@@ -77,6 +80,11 @@ function reload(target) {
|
|
|
77
80
|
renditionId: target.renditionId
|
|
78
81
|
};
|
|
79
82
|
}
|
|
83
|
+
/** The URL a reload of `target` asks for: its blocking reload when it has one. */
|
|
84
|
+
function urlFor(state, target) {
|
|
85
|
+
var _state$blocking$targe;
|
|
86
|
+
return (_state$blocking$targe = state.blocking[target.renditionId]) !== null && _state$blocking$targe !== void 0 ? _state$blocking$targe : target.url;
|
|
87
|
+
}
|
|
80
88
|
function renditionOfToken(token) {
|
|
81
89
|
return token.startsWith(`${REFRESH_TOKEN}:`) ? token.slice(17) : null;
|
|
82
90
|
}
|
|
@@ -119,6 +127,20 @@ function companionTargets(kernel, window, abandoned) {
|
|
|
119
127
|
for (const { contentType, rendition } of activeRenditions(kernel, types, (_window$id = window === null || window === void 0 ? void 0 : window.id) !== null && _window$id !== void 0 ? _window$id : null)) add(rendition, contentType === "video");
|
|
120
128
|
return out;
|
|
121
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* The URL that loads a playlist from a rendition report: the report for
|
|
132
|
+
* that URL, else the last report whose URL begins it, as hls.js matches
|
|
133
|
+
* them, so a playlist URL with extra query parameters still finds its
|
|
134
|
+
* report. The playlist URL itself without either.
|
|
135
|
+
*/
|
|
136
|
+
function reportFor(reports, url) {
|
|
137
|
+
var _found;
|
|
138
|
+
const exact = reports[url];
|
|
139
|
+
if (exact !== void 0) return exact;
|
|
140
|
+
let found;
|
|
141
|
+
for (const [reported, reload] of Object.entries(reports)) if (url.startsWith(reported)) found = reload;
|
|
142
|
+
return (_found = found) !== null && _found !== void 0 ? _found : url;
|
|
143
|
+
}
|
|
122
144
|
/** Loops a message back into the bus through a zero-delay schedule effect. */
|
|
123
145
|
function feed(message) {
|
|
124
146
|
return scheduled("hls-live:loopback", message);
|
|
@@ -156,8 +178,8 @@ function windowRendition(presentation, kernel, abandoned) {
|
|
|
156
178
|
*/
|
|
157
179
|
function windowFact(presentation, rendition, kernel) {
|
|
158
180
|
var _presentation$live$ho, _presentation$live, _presentation$live$up, _presentation$live2;
|
|
159
|
-
|
|
160
|
-
|
|
181
|
+
if (!Array.isArray(rendition.segments)) return null;
|
|
182
|
+
const segments = rendition.segments.filter((s) => s.preload !== true);
|
|
161
183
|
const first = segments[0];
|
|
162
184
|
const last = segments[segments.length - 1];
|
|
163
185
|
if (first === void 0 || last === void 0) return null;
|
|
@@ -201,8 +223,15 @@ function reloadFailed(state, kernel, renditionId, error, retryMs) {
|
|
|
201
223
|
const count = ((_state$failures$rendi = state.failures[renditionId]) !== null && _state$failures$rendi !== void 0 ? _state$failures$rendi : 0) + 1;
|
|
202
224
|
const failures = _objectSpread2(_objectSpread2({}, state.failures), {}, { [renditionId]: count });
|
|
203
225
|
const isTarget = state.target !== null && renditionId === state.target.renditionId;
|
|
226
|
+
state = _objectSpread2(_objectSpread2({}, state), {}, { chained: state.chained.filter((id) => id !== renditionId) });
|
|
204
227
|
if (count < FAILURE_LIMIT) {
|
|
205
|
-
if (!isTarget)
|
|
228
|
+
if (!isTarget) {
|
|
229
|
+
if (state.blocking[renditionId] === void 0 || state.tickPending) return [_objectSpread2(_objectSpread2({}, state), {}, { failures }), []];
|
|
230
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
231
|
+
failures,
|
|
232
|
+
tickPending: true
|
|
233
|
+
}), [tick(2)]];
|
|
234
|
+
}
|
|
206
235
|
if (state.tickPending) return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
207
236
|
failures,
|
|
208
237
|
inflight: null
|
|
@@ -260,7 +289,7 @@ function retry(state, kernel, renditionId) {
|
|
|
260
289
|
failures
|
|
261
290
|
}), message === null ? [] : [feed(message)]];
|
|
262
291
|
}
|
|
263
|
-
const createReduceHlsLive = (retryMs) => (slice, msg, kernel) => {
|
|
292
|
+
const createReduceHlsLive = (retryMs, ll) => (slice, msg, kernel) => {
|
|
264
293
|
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
265
294
|
if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, { manifestUrl: msg.url }), []];
|
|
266
295
|
if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
|
|
@@ -274,9 +303,14 @@ const createReduceHlsLive = (retryMs) => (slice, msg, kernel) => {
|
|
|
274
303
|
kind: "abort",
|
|
275
304
|
token: refreshToken(state.inflight)
|
|
276
305
|
});
|
|
306
|
+
for (const id of state.chained) effects.push({
|
|
307
|
+
kind: "abort",
|
|
308
|
+
token: refreshToken(id)
|
|
309
|
+
});
|
|
277
310
|
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
278
311
|
tickPending: false,
|
|
279
312
|
inflight: null,
|
|
313
|
+
chained: [],
|
|
280
314
|
suspended: true
|
|
281
315
|
}), effects];
|
|
282
316
|
}
|
|
@@ -314,7 +348,7 @@ const createReduceHlsLive = (retryMs) => (slice, msg, kernel) => {
|
|
|
314
348
|
let inflight = state.inflight;
|
|
315
349
|
if (switched && target !== null) {
|
|
316
350
|
if (inflight !== target.renditionId) {
|
|
317
|
-
effects.push(reload(target));
|
|
351
|
+
effects.push(reload(_objectSpread2(_objectSpread2({}, target), {}, { url: reportFor(state.reports, target.url) })));
|
|
318
352
|
inflight = target.renditionId;
|
|
319
353
|
}
|
|
320
354
|
awaitingTarget = true;
|
|
@@ -325,7 +359,7 @@ const createReduceHlsLive = (retryMs) => (slice, msg, kernel) => {
|
|
|
325
359
|
let tickPending = state.tickPending;
|
|
326
360
|
if (!tickPending && inflight === null && target !== null) {
|
|
327
361
|
var _presentation$live$up2, _presentation$live3;
|
|
328
|
-
effects.push(tick((_presentation$live$up2 = (_presentation$live3 = presentation.live) === null || _presentation$live3 === void 0 ? void 0 : _presentation$live3.updatePeriod) !== null && _presentation$live$up2 !== void 0 ? _presentation$live$up2 : 4));
|
|
362
|
+
effects.push(tick(ll === void 0 ? (_presentation$live$up2 = (_presentation$live3 = presentation.live) === null || _presentation$live3 === void 0 ? void 0 : _presentation$live3.updatePeriod) !== null && _presentation$live$up2 !== void 0 ? _presentation$live$up2 : 4 : 0));
|
|
329
363
|
tickPending = true;
|
|
330
364
|
}
|
|
331
365
|
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
@@ -361,19 +395,24 @@ const createReduceHlsLive = (retryMs) => (slice, msg, kernel) => {
|
|
|
361
395
|
const effects = [];
|
|
362
396
|
let inflight = state.inflight;
|
|
363
397
|
if (inflight !== target.renditionId) {
|
|
364
|
-
effects.push(reload(target));
|
|
398
|
+
effects.push(reload(_objectSpread2(_objectSpread2({}, target), {}, { url: urlFor(state, target) })));
|
|
365
399
|
inflight = target.renditionId;
|
|
366
400
|
}
|
|
401
|
+
const blockingTarget = state.blocking[target.renditionId] !== void 0;
|
|
402
|
+
const chained = [...state.chained];
|
|
367
403
|
for (const companion of state.companions) {
|
|
368
|
-
if (companion.
|
|
369
|
-
|
|
404
|
+
if (chained.includes(companion.renditionId)) continue;
|
|
405
|
+
if (companion.ladder && (blockingTarget || state.round % LADDER_EVERY !== 0)) continue;
|
|
406
|
+
effects.push(reload(_objectSpread2(_objectSpread2({}, companion), {}, { url: urlFor(state, companion) })));
|
|
407
|
+
if (state.blocking[companion.renditionId] !== void 0) chained.push(companion.renditionId);
|
|
370
408
|
}
|
|
371
409
|
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
372
410
|
target,
|
|
373
411
|
awaitingTarget,
|
|
374
412
|
round: state.round + 1,
|
|
375
413
|
tickPending: false,
|
|
376
|
-
inflight
|
|
414
|
+
inflight,
|
|
415
|
+
chained
|
|
377
416
|
}), effects];
|
|
378
417
|
}
|
|
379
418
|
if (msg.type === "SEGMENT_FAILED") {
|
|
@@ -382,15 +421,37 @@ const createReduceHlsLive = (retryMs) => (slice, msg, kernel) => {
|
|
|
382
421
|
return reloadFailed(state, kernel, renditionId, msg.error, retryMs);
|
|
383
422
|
}
|
|
384
423
|
if (msg.type === "SEGMENT_LOADED") {
|
|
385
|
-
var _findRendition4, _lastSegment$seq;
|
|
424
|
+
var _site$rendition$segme, _site$rendition$dateR, _media$playlist$skipp, _findRendition4, _lastSegment$seq;
|
|
386
425
|
const renditionId = renditionOfToken(msg.trackId);
|
|
387
426
|
if (renditionId === null || kernel.presentation === null) return [state, []];
|
|
388
427
|
const isTarget = state.target !== null && renditionId === state.target.renditionId;
|
|
389
428
|
const url = playlistUrlFor(kernel.presentation, renditionId, state.target);
|
|
390
429
|
if (url === null) return [state, []];
|
|
391
430
|
const text = new TextDecoder().decode(msg.bytes);
|
|
392
|
-
const
|
|
431
|
+
const site = findRendition(kernel.presentation, renditionId);
|
|
432
|
+
const media = ll === void 0 ? parseMediaPlaylist(text, url) : ll.parse(text, url, (_site$rendition$segme = site === null || site === void 0 ? void 0 : site.rendition.segments) !== null && _site$rendition$segme !== void 0 ? _site$rendition$segme : [], (_site$rendition$dateR = site === null || site === void 0 ? void 0 : site.rendition.dateRanges) !== null && _site$rendition$dateR !== void 0 ? _site$rendition$dateR : []);
|
|
393
433
|
if (media.playlist === null) return reloadFailed(state, kernel, renditionId, media.error, retryMs);
|
|
434
|
+
const chained = state.chained.filter((id) => id !== renditionId);
|
|
435
|
+
if (ll !== void 0 && ((_media$playlist$skipp = media.playlist.skipped) !== null && _media$playlist$skipp !== void 0 ? _media$playlist$skipp : 0) > 0) {
|
|
436
|
+
var _ll$next;
|
|
437
|
+
const whole = reload({
|
|
438
|
+
renditionId,
|
|
439
|
+
url: (_ll$next = ll.next(url, media.playlist, false)) !== null && _ll$next !== void 0 ? _ll$next : url
|
|
440
|
+
});
|
|
441
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, { chained: isTarget ? chained : [...chained, renditionId] }), [whole]];
|
|
442
|
+
}
|
|
443
|
+
let blocking = state.blocking;
|
|
444
|
+
let reports = state.reports;
|
|
445
|
+
if (ll !== void 0) {
|
|
446
|
+
const next = ll.next(url, media.playlist, true);
|
|
447
|
+
const updated = _objectSpread2({}, blocking);
|
|
448
|
+
if (next === null) delete updated[renditionId];
|
|
449
|
+
else updated[renditionId] = next;
|
|
450
|
+
blocking = updated;
|
|
451
|
+
reports = _objectSpread2(_objectSpread2({}, reports), ll.reports(media.playlist));
|
|
452
|
+
}
|
|
453
|
+
const nextUrl = blocking[renditionId];
|
|
454
|
+
const chains = nextUrl !== void 0 && !media.playlist.endlist && !state.suspended && (isTarget || state.companions.some((c) => c.renditionId === renditionId && !c.ladder));
|
|
394
455
|
const failures = _objectSpread2({}, state.failures);
|
|
395
456
|
delete failures[renditionId];
|
|
396
457
|
const sharing = ((_findRendition4 = findRendition(kernel.presentation, renditionId)) === null || _findRendition4 === void 0 ? void 0 : _findRendition4.rendition.playlistUrl) === void 0 ? [renditionId] : renditionIdsAt(kernel.presentation, url);
|
|
@@ -399,21 +460,34 @@ const createReduceHlsLive = (retryMs) => (slice, msg, kernel) => {
|
|
|
399
460
|
const refresh = refreshFor(kernel.presentation, id, media.playlist);
|
|
400
461
|
if (refresh !== null) effects.push(feed(refresh));
|
|
401
462
|
}
|
|
402
|
-
if (
|
|
463
|
+
if (chains) effects.push(reload({
|
|
464
|
+
renditionId,
|
|
465
|
+
url: nextUrl
|
|
466
|
+
}));
|
|
467
|
+
if (!isTarget) return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
468
|
+
failures,
|
|
469
|
+
blocking,
|
|
470
|
+
reports,
|
|
471
|
+
chained: chains ? [...chained, renditionId] : chained
|
|
472
|
+
}), effects];
|
|
403
473
|
const lastSegment = media.playlist.segments[media.playlist.segments.length - 1];
|
|
404
474
|
const endSeq = (_lastSegment$seq = lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.seq) !== null && _lastSegment$seq !== void 0 ? _lastSegment$seq : -1;
|
|
405
475
|
const changed = endSeq !== state.lastEndSeq;
|
|
406
476
|
const cadence = media.playlist.targetDuration || 4;
|
|
477
|
+
const ticks = !chains || state.companions.some((c) => !c.ladder && blocking[c.renditionId] === void 0);
|
|
407
478
|
let tickPending = state.tickPending;
|
|
408
|
-
if (!media.playlist.endlist && !tickPending && !state.suspended) {
|
|
479
|
+
if (ticks && !media.playlist.endlist && !tickPending && !state.suspended) {
|
|
409
480
|
effects.push(tick(changed ? cadence : cadence / 2));
|
|
410
481
|
tickPending = true;
|
|
411
482
|
}
|
|
412
483
|
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
413
484
|
failures,
|
|
485
|
+
blocking,
|
|
486
|
+
reports,
|
|
487
|
+
chained,
|
|
414
488
|
lastEndSeq: endSeq,
|
|
415
489
|
tickPending,
|
|
416
|
-
inflight: null,
|
|
490
|
+
inflight: chains ? renditionId : null,
|
|
417
491
|
awaitingTarget: false
|
|
418
492
|
}), effects];
|
|
419
493
|
}
|
|
@@ -434,4 +508,4 @@ function hlsLive(options = {}) {
|
|
|
434
508
|
};
|
|
435
509
|
}
|
|
436
510
|
//#endregion
|
|
437
|
-
export { hlsLive as default };
|
|
511
|
+
export { createReduceHlsLive, hlsLive as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MANIFEST_TYPES, createReduceHls } from "../hls-cmaf/index.js";
|
|
2
|
+
import { registerLiveNamespace } from "../live-shared.js";
|
|
3
|
+
import { createReduceHlsLive } from "../hls-live/index.js";
|
|
4
|
+
import { nextReload, parseLowLatency, reportsOf } from "./parse.js";
|
|
5
|
+
//#region src/protocols/hls-ll/index.ts
|
|
6
|
+
/** The stage factory. It provides `hls-cmaf` and `hls-live`, so stages that require either compose with it. */
|
|
7
|
+
function hlsLl(options = {}) {
|
|
8
|
+
var _options$unavailableR;
|
|
9
|
+
const retryMs = ((_options$unavailableR = options.unavailableRetrySeconds) !== null && _options$unavailableR !== void 0 ? _options$unavailableR : 15) * 1e3;
|
|
10
|
+
return {
|
|
11
|
+
name: "hls-ll",
|
|
12
|
+
provides: [
|
|
13
|
+
"hls-ll",
|
|
14
|
+
"hls-cmaf",
|
|
15
|
+
"hls-live",
|
|
16
|
+
...MANIFEST_TYPES
|
|
17
|
+
],
|
|
18
|
+
install(ctx) {
|
|
19
|
+
ctx.reduce("hls", createReduceHls(retryMs, parseLowLatency));
|
|
20
|
+
ctx.reduce("hls-live", createReduceHlsLive(retryMs, {
|
|
21
|
+
parse: parseLowLatency,
|
|
22
|
+
next: nextReload,
|
|
23
|
+
reports: reportsOf
|
|
24
|
+
}));
|
|
25
|
+
registerLiveNamespace(ctx);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { hlsLl as default };
|