mattebox 0.14.0 → 0.15.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 +5 -5
- 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.153.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.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 +6 -2
- package/dist/es2015/kernel/append-queue.js +1 -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/reducer.js +90 -31
- 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 +27 -12
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +1 -1
- 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.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.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/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +95 -40
- 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 +42 -6
- package/dist/protocols/hls-cmaf/parse.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 +36 -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,5 +1,5 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/asyncToGenerator.js";
|
|
3
3
|
import { findTrackSite } from "../../kernel/presentation.js";
|
|
4
4
|
import { chaptersFromInput, parseAppleChapters, parseChapterTrack } from "./parse.js";
|
|
5
5
|
//#region src/stages/chapters/index.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import _objectWithoutProperties from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _objectWithoutProperties from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectWithoutProperties.js";
|
|
3
3
|
import { parseVtt } from "../../containers/webvtt.js";
|
|
4
4
|
import { resolveUrl } from "../../kernel/url.js";
|
|
5
5
|
//#region src/stages/chapters/parse.ts
|
|
@@ -95,7 +95,13 @@ function cmcd(options = {}) {
|
|
|
95
95
|
const request = state.scheduling.inflight.get(req.token);
|
|
96
96
|
if (request !== void 0 && request.seq >= 0 && request.renditionId !== void 0) {
|
|
97
97
|
const site = findRendition(state.presentation, request.renditionId);
|
|
98
|
-
|
|
98
|
+
let next = null;
|
|
99
|
+
if (site !== null && Array.isArray(site.rendition.segments)) {
|
|
100
|
+
const list = site.rendition.segments;
|
|
101
|
+
const at = list.findIndex((segment) => segment.seq === request.seq);
|
|
102
|
+
const after = at < 0 ? void 0 : list[at + 1];
|
|
103
|
+
next = after !== void 0 && after.preload !== true ? after : null;
|
|
104
|
+
} else if (site !== null) next = segmentAt(site.rendition.segments, request.seq + 1, site.period.start);
|
|
99
105
|
if (next !== null) {
|
|
100
106
|
if (next.url !== request.url) keys.nor = encodeURIComponent(relativePath(request.url, next.url));
|
|
101
107
|
if (next.byteRange !== void 0) keys.nrr = `${next.byteRange.start}-${next.byteRange.end}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { findRendition } from "../../kernel/presentation.js";
|
|
3
3
|
import { codecMismatch, probeInitSegment } from "../../containers/codec-probe/index.js";
|
|
4
4
|
//#region src/stages/codec-probe/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
//#region src/stages/content-steering/index.ts
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/asyncToGenerator.js";
|
|
3
3
|
import { bytesToBase64 } from "../../kernel/base64.js";
|
|
4
4
|
import { keySystemHandlers, normalizeSystemId } from "../drm-shared.js";
|
|
5
5
|
//#region src/stages/eme-core/index.ts
|
|
@@ -25,8 +25,48 @@ import { keySystemHandlers, normalizeSystemId } from "../drm-shared.js";
|
|
|
25
25
|
* ClearKey is built in — it is the only key system testable headlessly.
|
|
26
26
|
* Widevine, PlayReady, and FairPlay arrive as handlers eme-cenc and
|
|
27
27
|
* eme-fairplay register through drm-shared.
|
|
28
|
+
*
|
|
29
|
+
* A license request follows hls.js's key-load policy: a network error or
|
|
30
|
+
* an HTTP status outside 4xx retries up to 8 times, a timeout (20 s) once,
|
|
31
|
+
* each after 1 s. A 401 or 403 calls `onUnauthorized` once and sends the
|
|
32
|
+
* request again, so a page can refresh an expired token. `getLicense`
|
|
33
|
+
* replaces the built-in request, as `getLicense` does in videojs-contrib-eme:
|
|
34
|
+
* it takes the CDM message and returns the bytes for `MediaKeySession.update`
|
|
35
|
+
* (W3C EME §6.6.2), with the same retries.
|
|
28
36
|
*/
|
|
29
37
|
const CLEARKEY = "org.w3.clearkey";
|
|
38
|
+
function licenseFailure(status, timeout, cause) {
|
|
39
|
+
return {
|
|
40
|
+
failure: "license",
|
|
41
|
+
status,
|
|
42
|
+
timeout,
|
|
43
|
+
cause
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function isLicenseFailure(value) {
|
|
47
|
+
return (value === null || value === void 0 ? void 0 : value.failure) === "license";
|
|
48
|
+
}
|
|
49
|
+
function isTimeout(error) {
|
|
50
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "TimeoutError";
|
|
51
|
+
}
|
|
52
|
+
/** The bytes a response filter returned, as the ArrayBuffer a handler parses. */
|
|
53
|
+
function bufferOf(bytes) {
|
|
54
|
+
return bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength ? bytes.buffer : bytes.slice().buffer;
|
|
55
|
+
}
|
|
56
|
+
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
57
|
+
/**
|
|
58
|
+
* A ClearKey handler with a license server: the server answers the JSON
|
|
59
|
+
* request (W3C EME §9.1.3) with the JSON license.
|
|
60
|
+
*/
|
|
61
|
+
function remoteClearKeyHandler() {
|
|
62
|
+
return {
|
|
63
|
+
keySystem: CLEARKEY,
|
|
64
|
+
systemIds: ["1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"],
|
|
65
|
+
initDataTypes: ["cenc", "keyids"],
|
|
66
|
+
buildLicenseRequest: (message) => message,
|
|
67
|
+
parseLicenseResponse: (response) => response
|
|
68
|
+
};
|
|
69
|
+
}
|
|
30
70
|
/** A ClearKey handler: the license is a JSON the app answers from its keys. */
|
|
31
71
|
function clearKeyHandler(clearKeys) {
|
|
32
72
|
return {
|
|
@@ -77,7 +117,7 @@ function emeCore(options = {}) {
|
|
|
77
117
|
provides: ["eme-core"],
|
|
78
118
|
requires: ["mse"],
|
|
79
119
|
install(ctx) {
|
|
80
|
-
var _options$licenseUrl;
|
|
120
|
+
var _options$licenseUrl, _options$licenseRetry, _options$licenseRetry2, _options$licenseRetry3, _options$licenseRetry4, _options$licenseRetry5, _options$licenseRetry6, _options$licenseRetry7, _options$licenseRetry8, _options$licenseRetry9, _options$licenseRetry10, _options$licenseRetry11;
|
|
81
121
|
const element = ctx.element;
|
|
82
122
|
let mediaKeys = null;
|
|
83
123
|
let keySystem = null;
|
|
@@ -90,6 +130,15 @@ function emeCore(options = {}) {
|
|
|
90
130
|
const open = /* @__PURE__ */ new Map();
|
|
91
131
|
const pendingRenewals = /* @__PURE__ */ new Set();
|
|
92
132
|
let disposed = false;
|
|
133
|
+
const aborter = new AbortController();
|
|
134
|
+
const retry = {
|
|
135
|
+
errorRetries: (_options$licenseRetry = (_options$licenseRetry2 = options.licenseRetry) === null || _options$licenseRetry2 === void 0 ? void 0 : _options$licenseRetry2.errorRetries) !== null && _options$licenseRetry !== void 0 ? _options$licenseRetry : 8,
|
|
136
|
+
timeoutRetries: (_options$licenseRetry3 = (_options$licenseRetry4 = options.licenseRetry) === null || _options$licenseRetry4 === void 0 ? void 0 : _options$licenseRetry4.timeoutRetries) !== null && _options$licenseRetry3 !== void 0 ? _options$licenseRetry3 : 1,
|
|
137
|
+
timeoutMs: (_options$licenseRetry5 = (_options$licenseRetry6 = options.licenseRetry) === null || _options$licenseRetry6 === void 0 ? void 0 : _options$licenseRetry6.timeoutMs) !== null && _options$licenseRetry5 !== void 0 ? _options$licenseRetry5 : 2e4,
|
|
138
|
+
delayMs: (_options$licenseRetry7 = (_options$licenseRetry8 = options.licenseRetry) === null || _options$licenseRetry8 === void 0 ? void 0 : _options$licenseRetry8.delayMs) !== null && _options$licenseRetry7 !== void 0 ? _options$licenseRetry7 : 1e3,
|
|
139
|
+
maxDelayMs: (_options$licenseRetry9 = (_options$licenseRetry10 = options.licenseRetry) === null || _options$licenseRetry10 === void 0 ? void 0 : _options$licenseRetry10.maxDelayMs) !== null && _options$licenseRetry9 !== void 0 ? _options$licenseRetry9 : 2e4,
|
|
140
|
+
exponential: ((_options$licenseRetry11 = options.licenseRetry) === null || _options$licenseRetry11 === void 0 ? void 0 : _options$licenseRetry11.backoff) === "exponential"
|
|
141
|
+
};
|
|
93
142
|
ctx.registerNamespace("drm", {
|
|
94
143
|
get keySystem() {
|
|
95
144
|
return keySystem;
|
|
@@ -118,33 +167,58 @@ function emeCore(options = {}) {
|
|
|
118
167
|
recoverable
|
|
119
168
|
}, cause !== void 0 ? { context: { message: String(cause) } } : {}));
|
|
120
169
|
}
|
|
121
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* All handlers eme-core can use: whatever registered, plus ClearKey
|
|
172
|
+
* with the app's keys, or with a license server when the options name
|
|
173
|
+
* ClearKey.
|
|
174
|
+
*/
|
|
122
175
|
function allHandlers() {
|
|
176
|
+
var _options$preferredKey;
|
|
123
177
|
const registered = keySystemHandlers();
|
|
124
178
|
const clearKeys = options.clearKeys;
|
|
125
|
-
|
|
179
|
+
if (clearKeys !== void 0) return [clearKeyHandler(clearKeys), ...registered];
|
|
180
|
+
return ((_options$preferredKey = options.preferredKeySystems) === null || _options$preferredKey === void 0 ? void 0 : _options$preferredKey.includes(CLEARKEY)) === true || (licenseUrls === null || licenseUrls === void 0 ? void 0 : licenseUrls[CLEARKEY]) !== void 0 ? [remoteClearKeyHandler(), ...registered] : [...registered];
|
|
181
|
+
}
|
|
182
|
+
/** The server certificate for a candidate, or null for none. */
|
|
183
|
+
function certificateFor(_x) {
|
|
184
|
+
return _certificateFor.apply(this, arguments);
|
|
185
|
+
}
|
|
186
|
+
function _certificateFor() {
|
|
187
|
+
_certificateFor = _asyncToGenerator(function* (candidate) {
|
|
188
|
+
var _options$getCertifica, _candidate$fairplay$c;
|
|
189
|
+
const provided = yield (_options$getCertifica = options.getCertificate) === null || _options$getCertifica === void 0 ? void 0 : _options$getCertifica.call(options, candidate.keySystem);
|
|
190
|
+
if (provided !== void 0 && provided !== null) return provided;
|
|
191
|
+
if (candidate.fairplay === void 0) return null;
|
|
192
|
+
const url = (_candidate$fairplay$c = candidate.fairplay.certificateUrl) !== null && _candidate$fairplay$c !== void 0 ? _candidate$fairplay$c : certificateUrl;
|
|
193
|
+
if (url === void 0) return null;
|
|
194
|
+
const response = yield ctx.request(url, { signal: aborter.signal });
|
|
195
|
+
if (!response.ok) throw new Error(`certificate ${url}: HTTP ${response.status}`);
|
|
196
|
+
return response.arrayBuffer();
|
|
197
|
+
});
|
|
198
|
+
return _certificateFor.apply(this, arguments);
|
|
126
199
|
}
|
|
127
200
|
/** Chooses and initializes a key system for the given systemIds. */
|
|
128
|
-
function ensureKeys(
|
|
201
|
+
function ensureKeys(_x2) {
|
|
129
202
|
return _ensureKeys.apply(this, arguments);
|
|
130
203
|
}
|
|
131
204
|
function _ensureKeys() {
|
|
132
205
|
_ensureKeys = _asyncToGenerator(function* (preferredSystemIds) {
|
|
206
|
+
var _options$preferredKey2;
|
|
133
207
|
if (mediaKeys !== null) return true;
|
|
134
|
-
const
|
|
135
|
-
const
|
|
208
|
+
const preferred = (_options$preferredKey2 = options.preferredKeySystems) !== null && _options$preferredKey2 !== void 0 ? _options$preferredKey2 : [];
|
|
209
|
+
const rank = (h) => {
|
|
210
|
+
const i = preferred.indexOf(h.keySystem);
|
|
211
|
+
return i === -1 ? preferred.length : i;
|
|
212
|
+
};
|
|
213
|
+
const ordered = allHandlers().sort((a, b) => rank(a) - rank(b));
|
|
136
214
|
const candidates = preferredSystemIds.length > 0 ? ordered.filter((h) => h.systemIds.some((id) => preferredSystemIds.includes(id))) : ordered;
|
|
137
215
|
let lastError;
|
|
138
216
|
for (const candidate of candidates.length > 0 ? candidates : ordered) try {
|
|
139
|
-
var _candidate$fairplay$c;
|
|
140
217
|
const keys = yield (yield navigator.requestMediaKeySystemAccess(candidate.keySystem, accessConfig(candidate))).createMediaKeys();
|
|
141
218
|
if (disposed) return false;
|
|
142
|
-
const certificate =
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
if (!response.ok) throw new Error(`certificate ${certificate}: HTTP ${response.status}`);
|
|
146
|
-
yield keys.setServerCertificate(yield response.arrayBuffer());
|
|
147
|
-
}
|
|
219
|
+
const certificate = yield certificateFor(candidate);
|
|
220
|
+
if (disposed) return false;
|
|
221
|
+
if (certificate !== null) yield keys.setServerCertificate(certificate instanceof Uint8Array ? new Uint8Array(certificate) : certificate);
|
|
148
222
|
yield element.setMediaKeys(keys);
|
|
149
223
|
mediaKeys = keys;
|
|
150
224
|
keySystem = candidate.keySystem;
|
|
@@ -160,7 +234,7 @@ function emeCore(options = {}) {
|
|
|
160
234
|
return _ensureKeys.apply(this, arguments);
|
|
161
235
|
}
|
|
162
236
|
/** Opens a session for one init data blob, deduped by key id. */
|
|
163
|
-
function openSession(
|
|
237
|
+
function openSession(_x3, _x4) {
|
|
164
238
|
return _openSession.apply(this, arguments);
|
|
165
239
|
}
|
|
166
240
|
function _openSession() {
|
|
@@ -179,7 +253,7 @@ function emeCore(options = {}) {
|
|
|
179
253
|
return _openSession.apply(this, arguments);
|
|
180
254
|
}
|
|
181
255
|
/** Creates a session and sends its license request. */
|
|
182
|
-
function startSession(
|
|
256
|
+
function startSession(_x5) {
|
|
183
257
|
return _startSession.apply(this, arguments);
|
|
184
258
|
}
|
|
185
259
|
function _startSession() {
|
|
@@ -228,41 +302,117 @@ function emeCore(options = {}) {
|
|
|
228
302
|
pendingRenewals.delete(session);
|
|
229
303
|
session.close().catch(() => {});
|
|
230
304
|
}
|
|
231
|
-
|
|
305
|
+
/** One license request: the page's `getLicense`, else a POST to the license URL. */
|
|
306
|
+
function requestLicense(_x6, _x7, _x8, _x9, _x10) {
|
|
307
|
+
return _requestLicense.apply(this, arguments);
|
|
308
|
+
}
|
|
309
|
+
function _requestLicense() {
|
|
310
|
+
_requestLicense = _asyncToGenerator(function* (session, record, active, message, attempt) {
|
|
311
|
+
var _keySystem, _licenseUrls$system;
|
|
312
|
+
const system = (_keySystem = keySystem) !== null && _keySystem !== void 0 ? _keySystem : "";
|
|
313
|
+
if (options.getLicense !== void 0) try {
|
|
314
|
+
return yield options.getLicense(new Uint8Array(message), {
|
|
315
|
+
keySystem: system,
|
|
316
|
+
sessionId: session.sessionId,
|
|
317
|
+
initDataType: record.initDataType,
|
|
318
|
+
initData: new Uint8Array(record.initData),
|
|
319
|
+
attempt
|
|
320
|
+
});
|
|
321
|
+
} catch (err) {
|
|
322
|
+
const status = err === null || err === void 0 ? void 0 : err.status;
|
|
323
|
+
throw licenseFailure(typeof status === "number" ? status : null, false, err);
|
|
324
|
+
}
|
|
325
|
+
const url = (_licenseUrls$system = licenseUrls === null || licenseUrls === void 0 ? void 0 : licenseUrls[system]) !== null && _licenseUrls$system !== void 0 ? _licenseUrls$system : licenseUrl;
|
|
326
|
+
if (url === null || url === void 0) throw new Error("no license url");
|
|
327
|
+
const draft = {
|
|
328
|
+
url,
|
|
329
|
+
headers: _objectSpread2({}, active.licenseHeaders),
|
|
330
|
+
attempt
|
|
331
|
+
};
|
|
332
|
+
let body = new Uint8Array(active.buildLicenseRequest(message));
|
|
333
|
+
if (options.requestFilter !== void 0) body = yield options.requestFilter(body, system, draft);
|
|
334
|
+
let response;
|
|
335
|
+
let bytes;
|
|
336
|
+
try {
|
|
337
|
+
response = yield ctx.request(draft.url, {
|
|
338
|
+
method: "POST",
|
|
339
|
+
headers: draft.headers,
|
|
340
|
+
body,
|
|
341
|
+
timeoutMs: retry.timeoutMs,
|
|
342
|
+
signal: aborter.signal
|
|
343
|
+
});
|
|
344
|
+
if (!response.ok) throw licenseFailure(response.status, false, `status ${response.status}`);
|
|
345
|
+
bytes = new Uint8Array(yield response.arrayBuffer());
|
|
346
|
+
} catch (err) {
|
|
347
|
+
throw isLicenseFailure(err) ? err : licenseFailure(null, isTimeout(err), err);
|
|
348
|
+
}
|
|
349
|
+
if (options.responseFilter !== void 0) bytes = yield options.responseFilter(bytes, system, {
|
|
350
|
+
url: draft.url,
|
|
351
|
+
status: response.status,
|
|
352
|
+
headers: response.headers
|
|
353
|
+
});
|
|
354
|
+
return active.parseLicenseResponse(bufferOf(bytes));
|
|
355
|
+
});
|
|
356
|
+
return _requestLicense.apply(this, arguments);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Gets a license with retries, or null when the session went away
|
|
360
|
+
* first. A failure past the retries throws.
|
|
361
|
+
*/
|
|
362
|
+
function fetchLicense(_x11, _x12, _x13) {
|
|
363
|
+
return _fetchLicense.apply(this, arguments);
|
|
364
|
+
}
|
|
365
|
+
function _fetchLicense() {
|
|
366
|
+
_fetchLicense = _asyncToGenerator(function* (session, active, message) {
|
|
367
|
+
let errors = 0;
|
|
368
|
+
let timeouts = 0;
|
|
369
|
+
let refreshed = false;
|
|
370
|
+
for (let attempt = 1;; attempt += 1) {
|
|
371
|
+
const record = open.get(session);
|
|
372
|
+
if (record === void 0 || disposed) return null;
|
|
373
|
+
let failure;
|
|
374
|
+
try {
|
|
375
|
+
return yield requestLicense(session, record, active, message, attempt);
|
|
376
|
+
} catch (err) {
|
|
377
|
+
if (!isLicenseFailure(err)) throw err;
|
|
378
|
+
failure = err;
|
|
379
|
+
}
|
|
380
|
+
if (disposed || !open.has(session)) return null;
|
|
381
|
+
const status = failure.status;
|
|
382
|
+
if ((status === 401 || status === 403) && !refreshed && options.onUnauthorized) {
|
|
383
|
+
var _keySystem2;
|
|
384
|
+
refreshed = true;
|
|
385
|
+
yield options.onUnauthorized({
|
|
386
|
+
keySystem: (_keySystem2 = keySystem) !== null && _keySystem2 !== void 0 ? _keySystem2 : "",
|
|
387
|
+
status
|
|
388
|
+
});
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (!(failure.timeout ? timeouts++ < retry.timeoutRetries : (status === null || status < 400 || status > 499) && errors++ < retry.errorRetries)) throw failure.cause;
|
|
392
|
+
const factor = retry.exponential ? Math.pow(2, errors + timeouts - 1) : 1;
|
|
393
|
+
yield wait(Math.min(retry.delayMs * factor, retry.maxDelayMs));
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
return _fetchLicense.apply(this, arguments);
|
|
397
|
+
}
|
|
398
|
+
function onMessage(_x14, _x15) {
|
|
232
399
|
return _onMessage.apply(this, arguments);
|
|
233
400
|
}
|
|
234
401
|
function _onMessage() {
|
|
235
402
|
_onMessage = _asyncToGenerator(function* (session, event) {
|
|
236
|
-
|
|
403
|
+
const active = handler;
|
|
404
|
+
if (active === null) return;
|
|
237
405
|
try {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (handler.localLicense === true) {
|
|
406
|
+
if (active.localLicense === true) {
|
|
407
|
+
const body = active.buildLicenseRequest(event.message);
|
|
241
408
|
yield session.update(body instanceof Uint8Array ? new Uint8Array(body) : body);
|
|
242
409
|
return;
|
|
243
410
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
body = options.requestFilter(new Uint8Array(body), (_keySystem = keySystem) !== null && _keySystem !== void 0 ? _keySystem : "");
|
|
247
|
-
}
|
|
248
|
-
const url = (_licenseUrls = licenseUrls === null || licenseUrls === void 0 ? void 0 : licenseUrls[(_keySystem2 = keySystem) !== null && _keySystem2 !== void 0 ? _keySystem2 : ""]) !== null && _licenseUrls !== void 0 ? _licenseUrls : licenseUrl;
|
|
249
|
-
if (url === null || url === void 0) {
|
|
250
|
-
fail("DRM_LICENSE_FAILED", false, "no license url");
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const response = yield ctx.request(url, {
|
|
254
|
-
method: "POST",
|
|
255
|
-
headers: _objectSpread2({}, handler.licenseHeaders),
|
|
256
|
-
body
|
|
257
|
-
});
|
|
258
|
-
if (!response.ok) {
|
|
259
|
-
fail("DRM_LICENSE_FAILED", true, `status ${response.status}`);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const raw = handler.parseLicenseResponse(yield response.arrayBuffer());
|
|
411
|
+
const raw = yield fetchLicense(session, active, event.message);
|
|
412
|
+
if (raw === null || disposed || !open.has(session)) return;
|
|
263
413
|
yield session.update(raw instanceof Uint8Array ? new Uint8Array(raw) : raw);
|
|
264
414
|
} catch (err) {
|
|
265
|
-
fail("DRM_LICENSE_FAILED",
|
|
415
|
+
fail("DRM_LICENSE_FAILED", false, err);
|
|
266
416
|
}
|
|
267
417
|
});
|
|
268
418
|
return _onMessage.apply(this, arguments);
|
|
@@ -337,6 +487,7 @@ function emeCore(options = {}) {
|
|
|
337
487
|
});
|
|
338
488
|
return () => {
|
|
339
489
|
disposed = true;
|
|
490
|
+
aborter.abort();
|
|
340
491
|
element.removeEventListener("encrypted", onEncrypted);
|
|
341
492
|
element.removeEventListener("play", onPlay);
|
|
342
493
|
offManifest();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { base64ToBytes, bytesToBase64 } from "../../kernel/base64.js";
|
|
3
3
|
import { registerKeySystem } from "../drm-shared.js";
|
|
4
4
|
//#region src/stages/eme-fairplay/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/asyncToGenerator.js";
|
|
2
2
|
//#region src/stages/hdr/index.ts
|
|
3
3
|
const SOURCE = "hdr";
|
|
4
4
|
/** The display's answer, or null when the browser does not know `dynamic-range`. */
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
//#region src/stages/live-catchup/index.ts
|
|
2
|
+
/** dash.js limits the rates to 0.5 and 2. */
|
|
3
|
+
const RATE_FLOOR = .5;
|
|
4
|
+
const RATE_CEILING = 2;
|
|
5
|
+
/**
|
|
6
|
+
* The rate for a drift, pure: dash.js's default catch-up curve. It is 1 on
|
|
7
|
+
* target and approaches the bound as the drift grows.
|
|
8
|
+
*/
|
|
9
|
+
function catchupRate(latency, target, bounds) {
|
|
10
|
+
const drift = latency - target;
|
|
11
|
+
const reach = drift < 0 ? 1 - bounds.minRate : bounds.maxRate - 1;
|
|
12
|
+
return 1 - reach + 2 * reach / (1 + Math.exp(-5 * drift));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The smallest rate change worth writing: dash.js's 0.02, scaled to the
|
|
16
|
+
* fastest rate, so 0.02 for a bound of 1.5 and less for a narrower one.
|
|
17
|
+
*/
|
|
18
|
+
function rateStep(bounds) {
|
|
19
|
+
return .02 * (bounds.maxRate - 1) / .5;
|
|
20
|
+
}
|
|
21
|
+
/** HTMLMediaElement HAVE_FUTURE_DATA. */
|
|
22
|
+
const HAVE_FUTURE_DATA = 3;
|
|
23
|
+
/** Seconds of drift past which the stage seeks, without a manifest value (dash.js). */
|
|
24
|
+
const DEFAULT_MAX_DRIFT = 12;
|
|
25
|
+
/** A viewer's seek that lands this close to the target counts as a return to it. */
|
|
26
|
+
const NEAR_TARGET = .5;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the page had a user interaction. Browsers without
|
|
29
|
+
* `navigator.userActivation` (before Safari 16.4) count as yes.
|
|
30
|
+
*/
|
|
31
|
+
function activated() {
|
|
32
|
+
var _globalThis$navigator;
|
|
33
|
+
const activation = (_globalThis$navigator = globalThis.navigator) === null || _globalThis$navigator === void 0 ? void 0 : _globalThis$navigator.userActivation;
|
|
34
|
+
return activation === void 0 || activation.hasBeenActive;
|
|
35
|
+
}
|
|
36
|
+
function clampRate(rate) {
|
|
37
|
+
return Math.min(RATE_CEILING, Math.max(RATE_FLOOR, rate));
|
|
38
|
+
}
|
|
39
|
+
function liveCatchup(options = {}) {
|
|
40
|
+
return {
|
|
41
|
+
name: "live-catchup",
|
|
42
|
+
provides: ["live-catchup"],
|
|
43
|
+
install(ctx) {
|
|
44
|
+
var _options$targetLatenc;
|
|
45
|
+
const element = ctx.element;
|
|
46
|
+
let chosen = (_options$targetLatenc = options.targetLatency) !== null && _options$targetLatenc !== void 0 ? _options$targetLatenc : null;
|
|
47
|
+
/** The latency the viewer moved to, which the stage holds instead of the target. */
|
|
48
|
+
let moved = null;
|
|
49
|
+
/** The rate this stage set last, or null when it set none. */
|
|
50
|
+
let ours = null;
|
|
51
|
+
let selfSeek = false;
|
|
52
|
+
/** A stall happened; the rate stays 1 until the buffer recovers. */
|
|
53
|
+
let stalled = false;
|
|
54
|
+
/** Playback started: the start-up seek and first play are the engine's, not the viewer's. */
|
|
55
|
+
let started = false;
|
|
56
|
+
let knownEnd = null;
|
|
57
|
+
let movedAt = 0;
|
|
58
|
+
const now = () => performance.now() / 1e3;
|
|
59
|
+
function live() {
|
|
60
|
+
var _state$presentation;
|
|
61
|
+
const state = ctx.getState();
|
|
62
|
+
if (state.live === null || ((_state$presentation = state.presentation) === null || _state$presentation === void 0 ? void 0 : _state$presentation.isLive) !== true) return null;
|
|
63
|
+
return {
|
|
64
|
+
end: state.live.span.end,
|
|
65
|
+
edge: state.live.edge,
|
|
66
|
+
info: state.presentation.live
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function latency() {
|
|
70
|
+
const window = live();
|
|
71
|
+
if (window === null) return null;
|
|
72
|
+
if (window.end !== knownEnd) {
|
|
73
|
+
knownEnd = window.end;
|
|
74
|
+
movedAt = now();
|
|
75
|
+
}
|
|
76
|
+
return window.end + (now() - movedAt) - element.currentTime;
|
|
77
|
+
}
|
|
78
|
+
/** The manifest's or the page's target. */
|
|
79
|
+
function baseTarget() {
|
|
80
|
+
var _chosen;
|
|
81
|
+
const window = live();
|
|
82
|
+
if (window === null) return null;
|
|
83
|
+
return (_chosen = chosen) !== null && _chosen !== void 0 ? _chosen : Math.max(0, window.end - window.edge);
|
|
84
|
+
}
|
|
85
|
+
function target() {
|
|
86
|
+
var _moved;
|
|
87
|
+
const base = baseTarget();
|
|
88
|
+
return base === null ? null : (_moved = moved) !== null && _moved !== void 0 ? _moved : base;
|
|
89
|
+
}
|
|
90
|
+
function bounds() {
|
|
91
|
+
var _live, _ref, _options$minRate, _ref2, _options$maxRate;
|
|
92
|
+
const rates = (_live = live()) === null || _live === void 0 || (_live = _live.info) === null || _live === void 0 ? void 0 : _live.playbackRate;
|
|
93
|
+
return {
|
|
94
|
+
minRate: clampRate((_ref = (_options$minRate = options.minRate) !== null && _options$minRate !== void 0 ? _options$minRate : rates === null || rates === void 0 ? void 0 : rates.min) !== null && _ref !== void 0 ? _ref : .5),
|
|
95
|
+
maxRate: clampRate((_ref2 = (_options$maxRate = options.maxRate) !== null && _options$maxRate !== void 0 ? _options$maxRate : rates === null || rates === void 0 ? void 0 : rates.max) !== null && _ref2 !== void 0 ? _ref2 : 1.5)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function maxDrift() {
|
|
99
|
+
var _live2;
|
|
100
|
+
if (options.maxDrift !== void 0) return options.maxDrift;
|
|
101
|
+
const max = (_live2 = live()) === null || _live2 === void 0 || (_live2 = _live2.info) === null || _live2 === void 0 ? void 0 : _live2.maxLatency;
|
|
102
|
+
const base = baseTarget();
|
|
103
|
+
if (max !== void 0 && base !== null && max > base) return max - base + .5;
|
|
104
|
+
return DEFAULT_MAX_DRIFT;
|
|
105
|
+
}
|
|
106
|
+
function bufferAhead() {
|
|
107
|
+
const time = element.currentTime;
|
|
108
|
+
const ranges = element.buffered;
|
|
109
|
+
for (let i = 0; i < ranges.length; i += 1) if (ranges.start(i) <= time + .1 && ranges.end(i) > time) return ranges.end(i) - time;
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
function setRate(rate, current, goal) {
|
|
113
|
+
if (element.playbackRate === rate) return;
|
|
114
|
+
element.playbackRate = rate;
|
|
115
|
+
ours = rate;
|
|
116
|
+
ctx.emit("catchup:rate", {
|
|
117
|
+
rate,
|
|
118
|
+
latency: current,
|
|
119
|
+
target: goal
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** Gives the element back its normal rate, when the stage set another. */
|
|
123
|
+
function release() {
|
|
124
|
+
if (ours !== null && ours !== 1) setRate(1, latency(), target());
|
|
125
|
+
ours = null;
|
|
126
|
+
}
|
|
127
|
+
/** Whether catch-up applies to the stream playing. */
|
|
128
|
+
function applies() {
|
|
129
|
+
var _options$enabled, _live3;
|
|
130
|
+
return (_options$enabled = options.enabled) !== null && _options$enabled !== void 0 ? _options$enabled : ((_live3 = live()) === null || _live3 === void 0 || (_live3 = _live3.info) === null || _live3 === void 0 ? void 0 : _live3.lowLatency) === true;
|
|
131
|
+
}
|
|
132
|
+
const onTime = () => {
|
|
133
|
+
const current = latency();
|
|
134
|
+
const goal = target();
|
|
135
|
+
if (current === null || goal === null || !applies()) {
|
|
136
|
+
release();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (element.paused || element.seeking) return;
|
|
140
|
+
if (current - goal > maxDrift()) {
|
|
141
|
+
selfSeek = true;
|
|
142
|
+
release();
|
|
143
|
+
ctx.emit("catchup:seek", {
|
|
144
|
+
latency: current,
|
|
145
|
+
target: goal
|
|
146
|
+
});
|
|
147
|
+
ctx.dispatch({ type: "SEEK_TO_LIVE_EDGE" });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (stalled && bufferAhead() > goal / 2) stalled = false;
|
|
151
|
+
if (!activated() || element.readyState < HAVE_FUTURE_DATA) return;
|
|
152
|
+
const range = bounds();
|
|
153
|
+
const rate = stalled ? 1 : catchupRate(current, goal, range);
|
|
154
|
+
if (rate === 1 || Math.abs(element.playbackRate - rate) >= rateStep(range)) setRate(rate, current, goal);
|
|
155
|
+
};
|
|
156
|
+
/** The viewer moved the playhead: hold the latency there, or the target when it is near. */
|
|
157
|
+
const onSettle = () => {
|
|
158
|
+
if (selfSeek || !started) {
|
|
159
|
+
selfSeek = false;
|
|
160
|
+
moved = null;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const current = latency();
|
|
164
|
+
const base = baseTarget();
|
|
165
|
+
if (current === null || base === null) return;
|
|
166
|
+
moved = Math.abs(current - base) <= NEAR_TARGET ? null : current;
|
|
167
|
+
};
|
|
168
|
+
const onWaiting = () => {
|
|
169
|
+
stalled = true;
|
|
170
|
+
};
|
|
171
|
+
const onPlaying = () => {
|
|
172
|
+
started = true;
|
|
173
|
+
};
|
|
174
|
+
element.addEventListener("timeupdate", onTime);
|
|
175
|
+
element.addEventListener("seeked", onSettle);
|
|
176
|
+
element.addEventListener("play", onSettle);
|
|
177
|
+
element.addEventListener("waiting", onWaiting);
|
|
178
|
+
element.addEventListener("playing", onPlaying);
|
|
179
|
+
const offTrace = ctx.on("trace", (entry) => {
|
|
180
|
+
const type = entry.msg.type;
|
|
181
|
+
if (type === "LOAD" || type === "UNLOAD") {
|
|
182
|
+
release();
|
|
183
|
+
moved = null;
|
|
184
|
+
stalled = false;
|
|
185
|
+
started = false;
|
|
186
|
+
knownEnd = null;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
ctx.registerNamespace("catchup", {
|
|
190
|
+
get target() {
|
|
191
|
+
return target();
|
|
192
|
+
},
|
|
193
|
+
get latency() {
|
|
194
|
+
return latency();
|
|
195
|
+
},
|
|
196
|
+
get rate() {
|
|
197
|
+
var _ours;
|
|
198
|
+
return (_ours = ours) !== null && _ours !== void 0 ? _ours : 1;
|
|
199
|
+
},
|
|
200
|
+
get active() {
|
|
201
|
+
return moved === null && live() !== null && applies();
|
|
202
|
+
},
|
|
203
|
+
setTarget(seconds) {
|
|
204
|
+
chosen = seconds;
|
|
205
|
+
moved = null;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return () => {
|
|
209
|
+
element.removeEventListener("timeupdate", onTime);
|
|
210
|
+
element.removeEventListener("seeked", onSettle);
|
|
211
|
+
element.removeEventListener("play", onSettle);
|
|
212
|
+
element.removeEventListener("waiting", onWaiting);
|
|
213
|
+
element.removeEventListener("playing", onPlaying);
|
|
214
|
+
offTrace();
|
|
215
|
+
release();
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
export { catchupRate, liveCatchup as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
//#region src/stages/qoe/index.ts
|
|
3
3
|
function qoe() {
|
|
4
4
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
import { findRendition, findTrackSite } from "../../kernel/presentation.js";
|
|
4
4
|
import { segmentAt as segmentAt$1, segmentAtTime } from "../../kernel/timeline.js";
|
|
@@ -87,7 +87,7 @@ function createRecoveryReducer(options) {
|
|
|
87
87
|
if (msg.type === "DETACH" || msg.type === "UNLOAD" || msg.type === "LOAD") return [INITIAL, msg.type === "LOAD" ? [] : []];
|
|
88
88
|
if (msg.type === "SEGMENT_FAILED") {
|
|
89
89
|
var _state$renditionFails, _state$seqFails$seqKe;
|
|
90
|
-
if (msg.renditionId === void 0 || isCueTrack(kernel, msg.trackId)) return [state, []];
|
|
90
|
+
if (msg.renditionId === void 0 || msg.preload === true || isCueTrack(kernel, msg.trackId)) return [state, []];
|
|
91
91
|
const effects = [];
|
|
92
92
|
const renditionFails = _objectSpread2(_objectSpread2({}, state.renditionFails), {}, { [msg.renditionId]: ((_state$renditionFails = state.renditionFails[msg.renditionId]) !== null && _state$renditionFails !== void 0 ? _state$renditionFails : 0) + 1 });
|
|
93
93
|
const seqKey = `${msg.trackId}:${msg.seq}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
//#region src/stages/rendition-names/index.ts
|
|
3
3
|
const DATA_ID = "_hls.localized-rendition-names";
|
|
4
4
|
const FETCH_TOKEN = "rendition-names:dictionary";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.js";
|
|
2
2
|
//#region src/stages/text-cea608/decode.ts
|
|
3
3
|
const ROWS = 15;
|
|
4
4
|
/** The basic CEA-608 character set: ASCII with a handful of substitutions. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.js";
|
|
2
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
3
3
|
import { escapeCueText } from "../../containers/webvtt.js";
|
|
4
4
|
//#region src/stages/text-cea708/decode.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { registerCaptionConsumer } from "../../containers/captions.js";
|
|
3
3
|
import { inbandCaptions, vttCue } from "../../kernel/sinks/caption-tracks.js";
|
|
4
4
|
import { Dtvcc } from "./decode.js";
|