mattebox 0.13.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 +42 -6
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/context.js +7 -0
- package/dist/es2015/kernel/dry-run.js +179 -0
- package/dist/es2015/kernel/lifecycle.js +6 -2
- package/dist/es2015/kernel/mse.js +1 -1
- package/dist/es2015/kernel/prepare.js +3 -3
- package/dist/es2015/kernel/reducer.js +105 -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 +235 -49
- 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 +8 -8
- package/dist/es2015/presets/hls-ll/index.js +14 -0
- package/dist/es2015/presets/tiers.js +29 -5
- 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 +28 -1
- 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/dry-run.d.ts +27 -0
- package/dist/kernel/dry-run.d.ts.map +1 -0
- package/dist/kernel/dry-run.js +198 -0
- package/dist/kernel/dry-run.js.map +1 -0
- package/dist/kernel/lifecycle.d.ts +5 -7
- package/dist/kernel/lifecycle.d.ts.map +1 -1
- package/dist/kernel/lifecycle.js +4 -0
- 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 +117 -42
- 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 +68 -10
- package/dist/kernel/transport.d.ts.map +1 -1
- package/dist/kernel/transport.js +232 -37
- 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.js +8 -8
- 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 +17 -2
- package/dist/presets/tiers.d.ts.map +1 -1
- package/dist/presets/tiers.js +26 -2
- 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/facade.d.ts +15 -3
- package/dist/types/facade.d.ts.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 +55 -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
|
//#region src/kernel/transport.ts
|
|
4
4
|
const DEFAULT_RETRY_POLICY = {
|
|
5
5
|
maxAttempts: 3,
|
|
@@ -19,8 +19,127 @@ const DEFAULT_RETRY_POLICY = {
|
|
|
19
19
|
function backoffDelayMs(policy, attempt) {
|
|
20
20
|
return Math.min(policy.maxDelayMs, policy.baseDelayMs * Math.pow(policy.factor, attempt - 1));
|
|
21
21
|
}
|
|
22
|
-
const PRIMED_LIMIT =
|
|
22
|
+
const PRIMED_LIMIT = 32;
|
|
23
|
+
const PRIMED_BYTES = 48e6;
|
|
23
24
|
const PRIMED_TTL_MS = 3e4;
|
|
25
|
+
/** A primed response answers one URL and one byte range. */
|
|
26
|
+
function primedKey(url, range) {
|
|
27
|
+
return range === void 0 ? url : `${url} ${range.start}-${range.end}`;
|
|
28
|
+
}
|
|
29
|
+
/** The two byte arrays as one. */
|
|
30
|
+
function join(head, tail) {
|
|
31
|
+
if (head.byteLength === 0) return tail;
|
|
32
|
+
const out = new Uint8Array(head.byteLength + tail.byteLength);
|
|
33
|
+
out.set(head);
|
|
34
|
+
out.set(tail, head.byteLength);
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The throughput of chunked delivery, by moof timing, the default of the
|
|
39
|
+
* reference low-latency player: each chunk's bytes over the time from its
|
|
40
|
+
* first bytes to its end, so the encoder's pauses between chunks do not
|
|
41
|
+
* count. The last chunk is left out, chunks that took under a millisecond
|
|
42
|
+
* join the next ones, and at least two must remain. The sample is their
|
|
43
|
+
* mean, as bytes and milliseconds; null without enough chunks, and the
|
|
44
|
+
* segment then measures its whole time, as that player falls back to.
|
|
45
|
+
*/
|
|
46
|
+
function chunkedTransfer(chunks) {
|
|
47
|
+
const rates = [];
|
|
48
|
+
let bytes = 0;
|
|
49
|
+
let pending = {
|
|
50
|
+
bytes: 0,
|
|
51
|
+
ms: 0
|
|
52
|
+
};
|
|
53
|
+
for (const chunk of chunks.slice(0, -1)) {
|
|
54
|
+
pending = {
|
|
55
|
+
bytes: pending.bytes + chunk.bytes,
|
|
56
|
+
ms: pending.ms + chunk.end - chunk.start
|
|
57
|
+
};
|
|
58
|
+
if (pending.ms <= 1) continue;
|
|
59
|
+
rates.push(pending.bytes / pending.ms);
|
|
60
|
+
bytes += pending.bytes;
|
|
61
|
+
pending = {
|
|
62
|
+
bytes: 0,
|
|
63
|
+
ms: 0
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (rates.length < 2) return null;
|
|
67
|
+
const mean = rates.reduce((sum, rate) => sum + rate, 0) / rates.length;
|
|
68
|
+
return {
|
|
69
|
+
bytes,
|
|
70
|
+
ms: bytes / mean
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reads a body as it arrives and hands on each run of complete chunks,
|
|
75
|
+
* timing each from the read that brought its first bytes to the read that
|
|
76
|
+
* completed it.
|
|
77
|
+
*/
|
|
78
|
+
function readChunks(_x, _x2, _x3, _x4) {
|
|
79
|
+
return _readChunks.apply(this, arguments);
|
|
80
|
+
}
|
|
81
|
+
function _readChunks() {
|
|
82
|
+
_readChunks = _asyncToGenerator(function* (body, split, onChunk, now) {
|
|
83
|
+
const reader = body.getReader();
|
|
84
|
+
let held = /* @__PURE__ */ new Uint8Array(0);
|
|
85
|
+
let size = 0;
|
|
86
|
+
let began = 0;
|
|
87
|
+
const timed = [];
|
|
88
|
+
for (;;) {
|
|
89
|
+
const read = yield reader.read();
|
|
90
|
+
if (read.done) break;
|
|
91
|
+
const at = now();
|
|
92
|
+
if (held.byteLength === 0) began = at;
|
|
93
|
+
size += read.value.byteLength;
|
|
94
|
+
held = join(held, read.value);
|
|
95
|
+
const ready = split(held);
|
|
96
|
+
if (ready > 0) {
|
|
97
|
+
onChunk(held.slice(0, ready).buffer);
|
|
98
|
+
timed.push({
|
|
99
|
+
bytes: ready,
|
|
100
|
+
start: began,
|
|
101
|
+
end: at
|
|
102
|
+
});
|
|
103
|
+
held = held.slice(ready);
|
|
104
|
+
began = at;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
rest: held.slice().buffer,
|
|
109
|
+
size,
|
|
110
|
+
transfer: chunkedTransfer(timed)
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
return _readChunks.apply(this, arguments);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Fetches with a deadline for the response headers. Past `timeoutMs` the
|
|
117
|
+
* request aborts and the promise rejects with a TimeoutError; `signal`
|
|
118
|
+
* aborts it too, with an AbortError.
|
|
119
|
+
*/
|
|
120
|
+
function fetchWithin(fetchImpl, url, init, timeoutMs, signal) {
|
|
121
|
+
if (timeoutMs === null && signal === void 0) return fetchImpl(url, init);
|
|
122
|
+
const controller = new AbortController();
|
|
123
|
+
const abort = () => controller.abort();
|
|
124
|
+
if ((signal === null || signal === void 0 ? void 0 : signal.aborted) === true) abort();
|
|
125
|
+
signal === null || signal === void 0 || signal.addEventListener("abort", abort);
|
|
126
|
+
let timedOut = false;
|
|
127
|
+
const timer = timeoutMs === null ? null : setTimeout(() => {
|
|
128
|
+
timedOut = true;
|
|
129
|
+
abort();
|
|
130
|
+
}, timeoutMs);
|
|
131
|
+
const done = () => {
|
|
132
|
+
if (timer !== null) clearTimeout(timer);
|
|
133
|
+
signal === null || signal === void 0 || signal.removeEventListener("abort", abort);
|
|
134
|
+
};
|
|
135
|
+
return fetchImpl(url, _objectSpread2(_objectSpread2({}, init), {}, { signal: controller.signal })).then((response) => {
|
|
136
|
+
done();
|
|
137
|
+
return response;
|
|
138
|
+
}, (error) => {
|
|
139
|
+
done();
|
|
140
|
+
throw timedOut ? new DOMException(`${url}: no response in ${timeoutMs} ms`, "TimeoutError") : error;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
24
143
|
function createTransport(options) {
|
|
25
144
|
var _options$fetchImpl, _options$now;
|
|
26
145
|
const policy = _objectSpread2(_objectSpread2({}, DEFAULT_RETRY_POLICY), options.retry);
|
|
@@ -30,25 +149,47 @@ function createTransport(options) {
|
|
|
30
149
|
const requestHooks = /* @__PURE__ */ new Set();
|
|
31
150
|
const responseHooks = /* @__PURE__ */ new Set();
|
|
32
151
|
const live = /* @__PURE__ */ new Map();
|
|
152
|
+
let channels = 0;
|
|
33
153
|
const primed = /* @__PURE__ */ new Map();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
154
|
+
const main = {
|
|
155
|
+
id: "",
|
|
156
|
+
absorb: options.absorb
|
|
157
|
+
};
|
|
158
|
+
/** The primed entry for a URL and range, once; null when none or expired. */
|
|
159
|
+
function takePrimed(url, range) {
|
|
160
|
+
const key = primedKey(url, range);
|
|
161
|
+
const entry = primed.get(key);
|
|
37
162
|
if (entry === void 0) return null;
|
|
38
|
-
primed.delete(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
163
|
+
primed.delete(key);
|
|
164
|
+
return now() > entry.expires ? null : entry;
|
|
165
|
+
}
|
|
166
|
+
function prime(url, bytes, headers, kept = {}) {
|
|
167
|
+
var _kept$keepMs, _kept$rtt;
|
|
168
|
+
const key = primedKey(url, kept.range);
|
|
169
|
+
primed.delete(key);
|
|
170
|
+
primed.set(key, {
|
|
171
|
+
bytes,
|
|
172
|
+
headers,
|
|
173
|
+
expires: now() + ((_kept$keepMs = kept.keepMs) !== null && _kept$keepMs !== void 0 ? _kept$keepMs : PRIMED_TTL_MS),
|
|
174
|
+
rtt: (_kept$rtt = kept.rtt) !== null && _kept$rtt !== void 0 ? _kept$rtt : 0
|
|
43
175
|
});
|
|
176
|
+
let total = 0;
|
|
177
|
+
for (const entry of primed.values()) total += entry.bytes.byteLength;
|
|
178
|
+
while (primed.size > 1 && (primed.size > PRIMED_LIMIT || total > PRIMED_BYTES)) {
|
|
179
|
+
const oldest = primed.keys().next().value;
|
|
180
|
+
total -= primed.get(oldest).bytes.byteLength;
|
|
181
|
+
primed.delete(oldest);
|
|
182
|
+
}
|
|
44
183
|
}
|
|
45
|
-
function fail(token, request, code, status) {
|
|
46
|
-
|
|
47
|
-
|
|
184
|
+
function fail(sink, token, request, code, status) {
|
|
185
|
+
var _sink$failed;
|
|
186
|
+
live.delete(sink.id + token);
|
|
187
|
+
(_sink$failed = sink.failed) === null || _sink$failed === void 0 || _sink$failed.call(sink, token);
|
|
188
|
+
sink.absorb(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
48
189
|
type: "SEGMENT_FAILED",
|
|
49
190
|
trackId: request.trackId,
|
|
50
191
|
seq: request.seq
|
|
51
|
-
}, request.renditionId !== void 0 ? { renditionId: request.renditionId } : {}), status !== void 0 ? { status } : {}), {}, { error: {
|
|
192
|
+
}, request.renditionId !== void 0 ? { renditionId: request.renditionId } : {}), request.preload === true ? { preload: true } : {}), status !== void 0 ? { status } : {}), {}, { error: {
|
|
52
193
|
category: "network",
|
|
53
194
|
code,
|
|
54
195
|
fatal: false,
|
|
@@ -64,7 +205,7 @@ function createTransport(options) {
|
|
|
64
205
|
hook(info);
|
|
65
206
|
} catch (_unused) {}
|
|
66
207
|
}
|
|
67
|
-
function attempt(token, request, effectUrl, range, timeoutFromEffect, attemptNo) {
|
|
208
|
+
function attempt(sink, token, request, effectUrl, range, timeoutFromEffect, head, attemptNo) {
|
|
68
209
|
const state = {
|
|
69
210
|
controller: new AbortController(),
|
|
70
211
|
timedOut: false,
|
|
@@ -72,7 +213,7 @@ function createTransport(options) {
|
|
|
72
213
|
timeoutId: null,
|
|
73
214
|
retryId: null
|
|
74
215
|
};
|
|
75
|
-
live.set(token, state);
|
|
216
|
+
live.set(sink.id + token, state);
|
|
76
217
|
const draft = {
|
|
77
218
|
url: effectUrl,
|
|
78
219
|
headers: {},
|
|
@@ -94,22 +235,26 @@ function createTransport(options) {
|
|
|
94
235
|
const startedAt = now();
|
|
95
236
|
const retryOrFail = (code, status) => {
|
|
96
237
|
if (!(attemptNo < policy.maxAttempts && (code !== "NETWORK_HTTP_STATUS" || status !== void 0 && policy.retryStatuses.includes(status)))) {
|
|
97
|
-
fail(token, request, code, status);
|
|
238
|
+
fail(sink, token, request, code, status);
|
|
98
239
|
return;
|
|
99
240
|
}
|
|
100
241
|
state.retryId = setTimeout(() => {
|
|
101
242
|
state.retryId = null;
|
|
102
|
-
attempt(token, request, effectUrl, range, timeoutFromEffect, attemptNo + 1);
|
|
243
|
+
attempt(sink, token, request, effectUrl, range, timeoutFromEffect, head, attemptNo + 1);
|
|
103
244
|
}, backoffDelayMs(policy, attemptNo));
|
|
104
245
|
};
|
|
105
|
-
const answer = takePrimed(effectUrl);
|
|
106
|
-
(answer !== null ? Promise.resolve(
|
|
246
|
+
const answer = takePrimed(effectUrl, range);
|
|
247
|
+
(answer !== null ? Promise.resolve(new Response(answer.bytes, {
|
|
248
|
+
status: 200,
|
|
249
|
+
headers: answer.headers
|
|
250
|
+
})) : fetchImpl(draft.url, _objectSpread2(_objectSpread2({}, head ? { method: "HEAD" } : {}), {}, {
|
|
107
251
|
headers: draft.headers,
|
|
108
252
|
signal: state.controller.signal
|
|
109
|
-
})).then(function() {
|
|
253
|
+
}))).then(function() {
|
|
110
254
|
var _ref = _asyncToGenerator(function* (response) {
|
|
111
|
-
var _options$acceptManife, _response$body;
|
|
255
|
+
var _options$acceptManife, _response$body, _options$split, _options$split2, _streamed$size, _streamed$transfer, _response$headers$get;
|
|
112
256
|
if (state.timeoutId !== null) clearTimeout(state.timeoutId);
|
|
257
|
+
const wait = now() - startedAt;
|
|
113
258
|
if (!response.ok) {
|
|
114
259
|
notifyResponse({
|
|
115
260
|
token,
|
|
@@ -127,25 +272,39 @@ function createTransport(options) {
|
|
|
127
272
|
const contentType = response.headers.get("content-type");
|
|
128
273
|
const refused = request.trackId === "manifest" && contentType !== null && ((_options$acceptManife = options.acceptManifestType) === null || _options$acceptManife === void 0 ? void 0 : _options$acceptManife.call(options, contentType)) === false;
|
|
129
274
|
if (refused) yield (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.cancel();
|
|
130
|
-
const
|
|
275
|
+
const split = request.chunked === true && sink === main && answer === null ? (_options$split = (_options$split2 = options.split) === null || _options$split2 === void 0 ? void 0 : _options$split2.call(options)) !== null && _options$split !== void 0 ? _options$split : null : null;
|
|
276
|
+
const streamed = split !== null && response.body != null ? yield readChunks(response.body, split, (chunk) => sink.absorb({
|
|
277
|
+
type: "SEGMENT_CHUNK",
|
|
278
|
+
trackId: request.trackId,
|
|
279
|
+
seq: request.seq,
|
|
280
|
+
token,
|
|
281
|
+
bytes: chunk
|
|
282
|
+
}), now) : null;
|
|
283
|
+
let bytes;
|
|
284
|
+
if (refused) bytes = /* @__PURE__ */ new ArrayBuffer(0);
|
|
285
|
+
else if (streamed !== null) bytes = streamed.rest;
|
|
286
|
+
else bytes = yield response.arrayBuffer();
|
|
287
|
+
const size = (_streamed$size = streamed === null || streamed === void 0 ? void 0 : streamed.size) !== null && _streamed$size !== void 0 ? _streamed$size : bytes.byteLength;
|
|
131
288
|
if (state.userAborted) {
|
|
132
|
-
live.delete(token);
|
|
289
|
+
live.delete(sink.id + token);
|
|
133
290
|
return;
|
|
134
291
|
}
|
|
135
|
-
const rtt = now() - startedAt;
|
|
292
|
+
const rtt = answer !== null ? answer.rtt : now() - startedAt;
|
|
136
293
|
notifyResponse({
|
|
137
294
|
token,
|
|
138
295
|
url: draft.url,
|
|
139
296
|
status: response.status,
|
|
140
297
|
rtt,
|
|
141
|
-
size
|
|
298
|
+
size,
|
|
142
299
|
outcome: refused ? "failure" : "success",
|
|
143
300
|
attempt: attemptNo,
|
|
144
301
|
headers: response.headers
|
|
145
302
|
});
|
|
146
|
-
live.delete(token);
|
|
303
|
+
live.delete(sink.id + token);
|
|
147
304
|
if (refused) {
|
|
148
|
-
|
|
305
|
+
var _sink$failed2;
|
|
306
|
+
(_sink$failed2 = sink.failed) === null || _sink$failed2 === void 0 || _sink$failed2.call(sink, token);
|
|
307
|
+
sink.absorb({
|
|
149
308
|
type: "SEGMENT_FAILED",
|
|
150
309
|
trackId: request.trackId,
|
|
151
310
|
seq: request.seq,
|
|
@@ -164,24 +323,33 @@ function createTransport(options) {
|
|
|
164
323
|
});
|
|
165
324
|
return;
|
|
166
325
|
}
|
|
167
|
-
|
|
326
|
+
if (sink.keepMs !== void 0) prime(effectUrl, bytes, response.headers, _objectSpread2(_objectSpread2({}, range !== void 0 ? { range } : {}), {}, {
|
|
327
|
+
keepMs: sink.keepMs,
|
|
328
|
+
rtt
|
|
329
|
+
}));
|
|
330
|
+
let transfer = (_streamed$transfer = streamed === null || streamed === void 0 ? void 0 : streamed.transfer) !== null && _streamed$transfer !== void 0 ? _streamed$transfer : void 0;
|
|
331
|
+
if (transfer === void 0 && request.preload === true && answer === null) transfer = {
|
|
332
|
+
bytes: size,
|
|
333
|
+
ms: rtt - wait
|
|
334
|
+
};
|
|
335
|
+
const date = head || request.seq < 0 ? Date.parse((_response$headers$get = response.headers.get("date")) !== null && _response$headers$get !== void 0 ? _response$headers$get : "") : NaN;
|
|
336
|
+
sink.absorb(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
168
337
|
type: "SEGMENT_LOADED",
|
|
169
338
|
trackId: request.trackId,
|
|
170
339
|
seq: request.seq,
|
|
171
340
|
token,
|
|
172
341
|
bytes,
|
|
173
342
|
rtt,
|
|
174
|
-
size
|
|
175
|
-
|
|
176
|
-
});
|
|
343
|
+
size
|
|
344
|
+
}, transfer !== void 0 ? { transfer } : {}), Number.isFinite(date) ? { serverDate: date / 1e3 } : {}), {}, { wallClock: Date.now() / 1e3 }));
|
|
177
345
|
});
|
|
178
|
-
return function(
|
|
346
|
+
return function(_x5) {
|
|
179
347
|
return _ref.apply(this, arguments);
|
|
180
348
|
};
|
|
181
349
|
}()).catch(() => {
|
|
182
350
|
if (state.timeoutId !== null) clearTimeout(state.timeoutId);
|
|
183
351
|
if (state.userAborted) {
|
|
184
|
-
live.delete(token);
|
|
352
|
+
live.delete(sink.id + token);
|
|
185
353
|
return;
|
|
186
354
|
}
|
|
187
355
|
const outcome = state.timedOut ? "timeout" : "failure";
|
|
@@ -220,27 +388,53 @@ function createTransport(options) {
|
|
|
220
388
|
seq: -1,
|
|
221
389
|
url: effect.url
|
|
222
390
|
}, effect.renditionId !== void 0 ? { renditionId: effect.renditionId } : {});
|
|
223
|
-
attempt(effect.token, request, effect.url, effect.range, effect.timeout, 1);
|
|
391
|
+
attempt(main, effect.token, request, effect.url, effect.range, effect.timeout, effect.method === "HEAD", 1);
|
|
224
392
|
return () => cancel(effect.token);
|
|
225
393
|
});
|
|
226
394
|
},
|
|
395
|
+
channel(deps) {
|
|
396
|
+
channels += 1;
|
|
397
|
+
const sink = _objectSpread2({
|
|
398
|
+
id: `c${channels}:`,
|
|
399
|
+
absorb: deps.absorb,
|
|
400
|
+
keepMs: deps.keepMs
|
|
401
|
+
}, deps.failed !== void 0 ? { failed: deps.failed } : {});
|
|
402
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
403
|
+
return {
|
|
404
|
+
fetch(effect) {
|
|
405
|
+
var _deps$inflight;
|
|
406
|
+
const request = (_deps$inflight = deps.inflight(effect.token)) !== null && _deps$inflight !== void 0 ? _deps$inflight : _objectSpread2({
|
|
407
|
+
token: effect.token,
|
|
408
|
+
trackId: effect.token,
|
|
409
|
+
seq: -1,
|
|
410
|
+
url: effect.url
|
|
411
|
+
}, effect.renditionId !== void 0 ? { renditionId: effect.renditionId } : {});
|
|
412
|
+
tokens.add(effect.token);
|
|
413
|
+
attempt(sink, effect.token, request, effect.url, effect.range, effect.timeout, effect.method === "HEAD", 1);
|
|
414
|
+
return () => cancel(sink.id + effect.token);
|
|
415
|
+
},
|
|
416
|
+
close() {
|
|
417
|
+
for (const token of tokens) cancel(sink.id + token);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
},
|
|
227
421
|
request(url, init) {
|
|
228
422
|
return _asyncToGenerator(function* () {
|
|
229
423
|
var _init$headers, _init$method;
|
|
230
424
|
const draft = {
|
|
231
425
|
url,
|
|
232
426
|
headers: _objectSpread2({}, (_init$headers = init.headers) !== null && _init$headers !== void 0 ? _init$headers : {}),
|
|
233
|
-
timeoutMs: defaultTimeout,
|
|
427
|
+
timeoutMs: init.timeoutMs === void 0 ? defaultTimeout : init.timeoutMs,
|
|
234
428
|
token: `req:${url}`,
|
|
235
429
|
attempt: 1
|
|
236
430
|
};
|
|
237
431
|
for (const hook of [...requestHooks]) try {
|
|
238
432
|
hook(draft);
|
|
239
433
|
} catch (_unused3) {}
|
|
240
|
-
return fetchImpl
|
|
434
|
+
return fetchWithin(fetchImpl, draft.url, _objectSpread2({
|
|
241
435
|
method: (_init$method = init.method) !== null && _init$method !== void 0 ? _init$method : init.body !== void 0 ? "POST" : "GET",
|
|
242
436
|
headers: draft.headers
|
|
243
|
-
}, init.body !== void 0 ? { body: init.body } : {}));
|
|
437
|
+
}, init.body !== void 0 ? { body: init.body } : {}), draft.timeoutMs, init.signal);
|
|
244
438
|
})();
|
|
245
439
|
},
|
|
246
440
|
addRequestHook(hook) {
|
|
@@ -254,16 +448,8 @@ function createTransport(options) {
|
|
|
254
448
|
pending() {
|
|
255
449
|
return [...live.keys()];
|
|
256
450
|
},
|
|
257
|
-
prime
|
|
258
|
-
primed.delete(url);
|
|
259
|
-
primed.set(url, {
|
|
260
|
-
bytes,
|
|
261
|
-
headers,
|
|
262
|
-
at: now()
|
|
263
|
-
});
|
|
264
|
-
while (primed.size > PRIMED_LIMIT) primed.delete(primed.keys().next().value);
|
|
265
|
-
}
|
|
451
|
+
prime
|
|
266
452
|
};
|
|
267
453
|
}
|
|
268
454
|
//#endregion
|
|
269
|
-
export { DEFAULT_RETRY_POLICY, backoffDelayMs, createTransport };
|
|
455
|
+
export { DEFAULT_RETRY_POLICY, backoffDelayMs, chunkedTransfer, createTransport, fetchWithin };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { definePreset } from "../define.js";
|
|
2
|
+
import { base, dashLlLine, lowLatencyTier } from "../tiers.js";
|
|
3
|
+
//#region src/presets/dash-ll/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* The `dash-ll` preset: low-latency DASH on demand and live, CMAF segments,
|
|
6
|
+
* live catch-up, the base. An MPD without low-latency signalling plays as
|
|
7
|
+
* in `dash`.
|
|
8
|
+
*/
|
|
9
|
+
const preset = definePreset("dash-ll", () => [
|
|
10
|
+
...dashLlLine(),
|
|
11
|
+
...lowLatencyTier(),
|
|
12
|
+
...base()
|
|
13
|
+
]);
|
|
14
|
+
//#endregion
|
|
15
|
+
export { preset as default };
|
|
@@ -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 { mattebox } from "../index.js";
|
|
4
4
|
//#region src/presets/define.ts
|
|
5
5
|
const _excluded = ["stages", "without"];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { definePreset } from "../define.js";
|
|
2
|
+
import { base, dashLlLine, hlsLlLine, lowLatencyTier } from "../tiers.js";
|
|
3
|
+
//#region src/presets/dual-ll/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* The `dual-ll` preset: low-latency HLS and low-latency DASH, CMAF
|
|
6
|
+
* segments, live catch-up, the base. One engine for a catalogue that mixes
|
|
7
|
+
* HLS and DASH live channels.
|
|
8
|
+
*/
|
|
9
|
+
const preset = definePreset("dual-ll", () => [
|
|
10
|
+
...hlsLlLine(),
|
|
11
|
+
...dashLlLine(),
|
|
12
|
+
...lowLatencyTier(),
|
|
13
|
+
...base()
|
|
14
|
+
]);
|
|
15
|
+
//#endregion
|
|
16
|
+
export { preset as default };
|
|
@@ -7,15 +7,13 @@ import renditionNames from "../../stages/rendition-names/index.js";
|
|
|
7
7
|
import qoe from "../../stages/qoe/index.js";
|
|
8
8
|
import hdr from "../../stages/hdr/index.js";
|
|
9
9
|
import cmsd from "../../stages/cmsd/index.js";
|
|
10
|
-
import cmcd from "../../stages/cmcd/index.js";
|
|
11
10
|
import chapters from "../../stages/chapters/index.js";
|
|
12
11
|
import { definePreset } from "../define.js";
|
|
13
|
-
import { base,
|
|
12
|
+
import { base, dashLlLine, drmTier, hlsLlLine, lowLatencyTier, tsTier } from "../tiers.js";
|
|
14
13
|
//#region src/presets/full/index.ts
|
|
15
14
|
/**
|
|
16
|
-
* The `full` preset:
|
|
17
|
-
* the accessories:
|
|
18
|
-
* thumbnails (fetches image playlists, so opt-in elsewhere), chapters
|
|
15
|
+
* The `full` preset: `dual-ts-drm` with low-latency HLS, low-latency DASH
|
|
16
|
+
* and live catch-up (`hls-ll` and `dash-ll` in place of the plain lines), plus the accessories: thumbnails (fetches image playlists, so opt-in elsewhere), chapters
|
|
19
17
|
* (loads a file the app names), trick play (a UI control drives it),
|
|
20
18
|
* timed metadata (a page reads it), CEA-708 captions (US broadcast
|
|
21
19
|
* streams carry 608 beside them, which the base reads), TTML subtitles
|
|
@@ -23,17 +21,19 @@ import { base, dashLine, drmTier, hlsLine, tsTier } from "../tiers.js";
|
|
|
23
21
|
* where nothing is known, which a page may not want by default), local
|
|
24
22
|
* QoE metrics, CMSD (it acts on response headers a CDN must expose), and
|
|
25
23
|
* localized rendition names (a menu reads them).
|
|
24
|
+
* CMCD is in no preset: it changes every request, which costs a page that
|
|
25
|
+
* never asked for it. A page adds the stage.
|
|
26
26
|
* Feature parity with
|
|
27
27
|
* videojs-http-streaming; the modularity claim is measured against it, and
|
|
28
28
|
* the main CDN bundle exposes it.
|
|
29
29
|
*/
|
|
30
30
|
const preset = definePreset("full", () => [
|
|
31
|
-
...
|
|
32
|
-
...
|
|
31
|
+
...hlsLlLine(),
|
|
32
|
+
...dashLlLine(),
|
|
33
|
+
...lowLatencyTier(),
|
|
33
34
|
...base(),
|
|
34
35
|
...tsTier(),
|
|
35
36
|
...drmTier(),
|
|
36
|
-
cmcd(),
|
|
37
37
|
thumbnails(),
|
|
38
38
|
chapters(),
|
|
39
39
|
trickPlay(),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { definePreset } from "../define.js";
|
|
2
|
+
import { base, hlsLlLine, lowLatencyTier } from "../tiers.js";
|
|
3
|
+
//#region src/presets/hls-ll/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* The `hls-ll` preset: low-latency HLS on demand and live, CMAF segments,
|
|
6
|
+
* live catch-up, the base. A stream without parts plays as in `hls`.
|
|
7
|
+
*/
|
|
8
|
+
const preset = definePreset("hls-ll", () => [
|
|
9
|
+
...hlsLlLine(),
|
|
10
|
+
...lowLatencyTier(),
|
|
11
|
+
...base()
|
|
12
|
+
]);
|
|
13
|
+
//#endregion
|
|
14
|
+
export { preset as default };
|
|
@@ -6,6 +6,7 @@ import pdt from "../stages/pdt/index.js";
|
|
|
6
6
|
import nalScan from "../stages/nal-scan/index.js";
|
|
7
7
|
import mp4Box from "../stages/mp4-box/index.js";
|
|
8
8
|
import metaId3 from "../stages/meta-id3/index.js";
|
|
9
|
+
import liveCatchup from "../stages/live-catchup/index.js";
|
|
9
10
|
import forcedSubtitles from "../stages/forced-subtitles/index.js";
|
|
10
11
|
import emeFairplay from "../stages/eme-fairplay/index.js";
|
|
11
12
|
import emeCore from "../stages/eme-core/index.js";
|
|
@@ -18,10 +19,12 @@ import altAudio from "../stages/alt-audio/index.js";
|
|
|
18
19
|
import aes128 from "../stages/aes-128/index.js";
|
|
19
20
|
import abrCapSize from "../stages/abr-cap-size/index.js";
|
|
20
21
|
import abr from "../stages/abr/index.js";
|
|
21
|
-
import hlsLive from "../protocols/hls-live/index.js";
|
|
22
22
|
import hlsCmaf from "../protocols/hls-cmaf/index.js";
|
|
23
|
-
import
|
|
23
|
+
import hlsLive from "../protocols/hls-live/index.js";
|
|
24
|
+
import hlsLl from "../protocols/hls-ll/index.js";
|
|
24
25
|
import dashCmaf from "../protocols/dash-cmaf/index.js";
|
|
26
|
+
import dashLive from "../protocols/dash-live/index.js";
|
|
27
|
+
import dashLl from "../protocols/dash-ll/index.js";
|
|
25
28
|
import packedAudio from "../containers/packed-audio/index.js";
|
|
26
29
|
import tsTransmux from "../containers/ts-transmux/index.js";
|
|
27
30
|
//#region src/presets/tiers.ts
|
|
@@ -42,13 +45,34 @@ function hlsLine() {
|
|
|
42
45
|
aes128()
|
|
43
46
|
];
|
|
44
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Low-latency HLS: hls-ll in place of hls-cmaf and hls-live, which it
|
|
50
|
+
* contains. A playlist without parts plays as the HLS line plays it.
|
|
51
|
+
*/
|
|
52
|
+
function hlsLlLine() {
|
|
53
|
+
return [hlsLl(), aes128()];
|
|
54
|
+
}
|
|
45
55
|
/** DASH on demand and live. */
|
|
46
56
|
function dashLine() {
|
|
47
57
|
return [dashCmaf(), dashLive()];
|
|
48
58
|
}
|
|
49
59
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
60
|
+
* Low-latency DASH: dash-ll in place of dash-cmaf and dash-live, which it
|
|
61
|
+
* contains. An MPD without low-latency signalling plays as the DASH line
|
|
62
|
+
* plays it.
|
|
63
|
+
*/
|
|
64
|
+
function dashLlLine() {
|
|
65
|
+
return [dashLl()];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* What a low-latency line needs beside it: the catch-up that holds the
|
|
69
|
+
* latency. It holds any live stream at its hold-back.
|
|
70
|
+
*/
|
|
71
|
+
function lowLatencyTier() {
|
|
72
|
+
return [liveCatchup()];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* What every preset carries: adaptive quality with a size cap, recovery, content steering (inert until a manifest asks for it),
|
|
52
76
|
* alternate audio with codec switching, WebVTT subtitles, CMAF timing (reads
|
|
53
77
|
* each segment's decode time so the kernel lands it at its playlist time,
|
|
54
78
|
* whatever clock the packager wrote), program date time from either
|
|
@@ -97,4 +121,4 @@ function drmTier() {
|
|
|
97
121
|
];
|
|
98
122
|
}
|
|
99
123
|
//#endregion
|
|
100
|
-
export { base, dashLine, drmTier, hlsLine, tsTier };
|
|
124
|
+
export { base, dashLine, dashLlLine, drmTier, hlsLine, hlsLlLine, lowLatencyTier, tsTier };
|
|
@@ -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 { normalizeMimeType } from "../../kernel/mime.js";
|
|
4
4
|
import { findRendition } from "../../kernel/presentation.js";
|
|
@@ -119,7 +119,8 @@ function retry(state, renditionId) {
|
|
|
119
119
|
constraint: { excludeIds: Object.keys(failed) }
|
|
120
120
|
})]];
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
/** The slice reducer. `lowLatency` reads the MPD as dash-ll does. */
|
|
123
|
+
const createReduceDash = (retryMs, lowLatency = false) => (slice, msg, kernel) => {
|
|
123
124
|
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
124
125
|
if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
|
|
125
126
|
manifestUrl: msg.url,
|
|
@@ -131,7 +132,7 @@ const createReduceDash = (retryMs) => (slice, msg, kernel) => {
|
|
|
131
132
|
let warnings = [];
|
|
132
133
|
const fact = manifestFact(msg.bytes, state.manifestUrl, (text) => claims(state, text), (text, url) => {
|
|
133
134
|
var _result$warnings;
|
|
134
|
-
const result = parse(text, url);
|
|
135
|
+
const result = parse(text, url, lowLatency);
|
|
135
136
|
if (result.presentation !== null) warnings = (_result$warnings = result.warnings) !== null && _result$warnings !== void 0 ? _result$warnings : [];
|
|
136
137
|
return result;
|
|
137
138
|
});
|
|
@@ -233,6 +234,13 @@ const createReduceDash = (retryMs) => (slice, msg, kernel) => {
|
|
|
233
234
|
* The stage factory. `mattebox({ stages: [dashCmaf()] })` is all a consumer
|
|
234
235
|
* needs for DASH-CMAF VOD, templated or on-demand.
|
|
235
236
|
*/
|
|
237
|
+
/** Installs the period runtime, which reads the slice this stage or dash-ll keeps. */
|
|
238
|
+
function installDashPeriods(ctx) {
|
|
239
|
+
return installPeriods(ctx, () => {
|
|
240
|
+
var _skips, _ctx$getState$dash;
|
|
241
|
+
return (_skips = (_ctx$getState$dash = ctx.getState().dash) === null || _ctx$getState$dash === void 0 ? void 0 : _ctx$getState$dash.skips) !== null && _skips !== void 0 ? _skips : [];
|
|
242
|
+
});
|
|
243
|
+
}
|
|
236
244
|
function dashCmaf(options = {}) {
|
|
237
245
|
var _options$unavailableR;
|
|
238
246
|
const retryMs = ((_options$unavailableR = options.unavailableRetrySeconds) !== null && _options$unavailableR !== void 0 ? _options$unavailableR : 15) * 1e3;
|
|
@@ -241,12 +249,9 @@ function dashCmaf(options = {}) {
|
|
|
241
249
|
provides: ["dash-cmaf", ...MANIFEST_TYPES],
|
|
242
250
|
install(ctx) {
|
|
243
251
|
ctx.reduce("dash", createReduceDash(retryMs));
|
|
244
|
-
return
|
|
245
|
-
var _skips, _ctx$getState$dash;
|
|
246
|
-
return (_skips = (_ctx$getState$dash = ctx.getState().dash) === null || _ctx$getState$dash === void 0 ? void 0 : _ctx$getState$dash.skips) !== null && _skips !== void 0 ? _skips : [];
|
|
247
|
-
});
|
|
252
|
+
return installDashPeriods(ctx);
|
|
248
253
|
}
|
|
249
254
|
};
|
|
250
255
|
}
|
|
251
256
|
//#endregion
|
|
252
|
-
export { dashCmaf as default };
|
|
257
|
+
export { MANIFEST_TYPES, createReduceDash, dashCmaf as default, installDashPeriods };
|