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,5 +1,5 @@
|
|
|
1
|
-
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { buildEpochs, epochForSeq, epochKey, segmentAtTime, timestampOffsetFor } from "./timeline.js";
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { buildEpochs, epochForSeq, epochKey, isIndexed, segmentAtTime, timestampOffsetFor } from "./timeline.js";
|
|
3
3
|
//#region src/kernel/scheduler.ts
|
|
4
4
|
const DEFAULT_GAP_TOLERANCE = .25;
|
|
5
5
|
/**
|
|
@@ -58,6 +58,27 @@ function received(track, seq) {
|
|
|
58
58
|
const id = track.rendition.id;
|
|
59
59
|
return ((_track$appended = track.appended) === null || _track$appended === void 0 ? void 0 : _track$appended.some((entry) => entry.seq === seq && entry.renditionId === id)) === true;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The entry to fetch for `segment` so the decoder gets a frame it can start
|
|
63
|
+
* from. An entry marked not independent (a low-latency part that starts
|
|
64
|
+
* without a key frame, RFC 8216bis §4.4.4.9) only continues the entry
|
|
65
|
+
* before it. When this rendition's buffer did not receive that entry (a
|
|
66
|
+
* switch, a seek, the start), the run begins at the latest independent
|
|
67
|
+
* entry before it, and then continues entry by entry, over media another
|
|
68
|
+
* rendition already buffered.
|
|
69
|
+
*/
|
|
70
|
+
function startable(track, segment) {
|
|
71
|
+
const list = track.rendition.segments;
|
|
72
|
+
if (segment.independent !== false || !Array.isArray(list)) return segment;
|
|
73
|
+
const entries = list;
|
|
74
|
+
const index = entries.findIndex((entry) => entry.seq === segment.seq);
|
|
75
|
+
for (let i = index - 1; i >= 0; i -= 1) {
|
|
76
|
+
const entry = entries[i];
|
|
77
|
+
if (received(track, entry.seq)) return entries[i + 1];
|
|
78
|
+
if (entry.independent !== false) return entry;
|
|
79
|
+
}
|
|
80
|
+
return segment;
|
|
81
|
+
}
|
|
61
82
|
function schedule(input) {
|
|
62
83
|
var _input$gapToleranceSe;
|
|
63
84
|
const tolerance = (_input$gapToleranceSe = input.gapToleranceSeconds) !== null && _input$gapToleranceSe !== void 0 ? _input$gapToleranceSe : DEFAULT_GAP_TOLERANCE;
|
|
@@ -65,7 +86,7 @@ function schedule(input) {
|
|
|
65
86
|
const requests = [];
|
|
66
87
|
let tokenSeq = input.tokenSeq;
|
|
67
88
|
for (const track of input.tracks) {
|
|
68
|
-
var _input$reconciled;
|
|
89
|
+
var _addressing$availabil, _input$reconciled;
|
|
69
90
|
if (track.inflight.length > 0) continue;
|
|
70
91
|
const now = measuredFrom(input.currentTime, input.duration);
|
|
71
92
|
const bufferedEnd = bufferedEndFrom(track.ranges, now, tolerance);
|
|
@@ -94,7 +115,11 @@ function schedule(input) {
|
|
|
94
115
|
segment = segmentAtTime(track.rendition.segments, segment.start + segment.duration + tolerance, track.period.start);
|
|
95
116
|
}
|
|
96
117
|
if (segment === null) continue;
|
|
97
|
-
|
|
118
|
+
segment = startable(track, segment);
|
|
119
|
+
const addressing = track.rendition.segments;
|
|
120
|
+
const early = isIndexed(addressing) ? Math.min((_addressing$availabil = addressing.availabilityOffset) !== null && _addressing$availabil !== void 0 ? _addressing$availabil : 0, segment.duration) : 0;
|
|
121
|
+
if (input.liveWindow != null && segment.preload !== true && segment.start + segment.duration - early > input.liveWindow.end) continue;
|
|
122
|
+
const chunked = early > 0 && isIndexed(addressing) && addressing.chunked === true;
|
|
98
123
|
const epochs = buildEpochs([{
|
|
99
124
|
period: track.period,
|
|
100
125
|
rendition: track.rendition
|
|
@@ -109,7 +134,7 @@ function schedule(input) {
|
|
|
109
134
|
token,
|
|
110
135
|
url: segment.url
|
|
111
136
|
}, segment.byteRange !== void 0 ? { range: segment.byteRange } : {}));
|
|
112
|
-
requests.push(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
137
|
+
requests.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
113
138
|
token,
|
|
114
139
|
trackId: track.trackId,
|
|
115
140
|
seq: segment.seq,
|
|
@@ -117,7 +142,7 @@ function schedule(input) {
|
|
|
117
142
|
renditionId: track.rendition.id,
|
|
118
143
|
segmentStart: segment.start,
|
|
119
144
|
segmentDuration: segment.duration
|
|
120
|
-
}, track.sbId !== void 0 ? { sbId: track.sbId } : {}), epoch !== null ? { timestampOffset: timestampOffsetFor(epoch) } : {}), key !== void 0 ? { epoch: key } : {}));
|
|
145
|
+
}, segment.preload === true ? { preload: true } : {}), chunked ? { chunked: true } : {}), track.sbId !== void 0 ? { sbId: track.sbId } : {}), epoch !== null ? { timestampOffset: timestampOffsetFor(epoch) } : {}), key !== void 0 ? { epoch: key } : {}));
|
|
121
146
|
}
|
|
122
147
|
return {
|
|
123
148
|
effects,
|
|
@@ -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
|
//#region src/kernel/timeline.ts
|
|
3
3
|
function isIndexed(addressing) {
|
|
4
4
|
return !Array.isArray(addressing) && addressing.kind === "indexed";
|
|
@@ -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
|
function isBytes(value) {
|
|
3
3
|
return value instanceof ArrayBuffer || ArrayBuffer.isView(value);
|
|
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.154.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/asyncToGenerator.js";
|
|
3
3
|
//#region src/kernel/transport.ts
|
|
4
4
|
const DEFAULT_RETRY_POLICY = {
|
|
5
5
|
maxAttempts: 3,
|
|
@@ -26,6 +26,120 @@ const PRIMED_TTL_MS = 3e4;
|
|
|
26
26
|
function primedKey(url, range) {
|
|
27
27
|
return range === void 0 ? url : `${url} ${range.start}-${range.end}`;
|
|
28
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
|
+
}
|
|
29
143
|
function createTransport(options) {
|
|
30
144
|
var _options$fetchImpl, _options$now;
|
|
31
145
|
const policy = _objectSpread2(_objectSpread2({}, DEFAULT_RETRY_POLICY), options.retry);
|
|
@@ -71,11 +185,11 @@ function createTransport(options) {
|
|
|
71
185
|
var _sink$failed;
|
|
72
186
|
live.delete(sink.id + token);
|
|
73
187
|
(_sink$failed = sink.failed) === null || _sink$failed === void 0 || _sink$failed.call(sink, token);
|
|
74
|
-
sink.absorb(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
188
|
+
sink.absorb(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
75
189
|
type: "SEGMENT_FAILED",
|
|
76
190
|
trackId: request.trackId,
|
|
77
191
|
seq: request.seq
|
|
78
|
-
}, 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: {
|
|
79
193
|
category: "network",
|
|
80
194
|
code,
|
|
81
195
|
fatal: false,
|
|
@@ -91,7 +205,7 @@ function createTransport(options) {
|
|
|
91
205
|
hook(info);
|
|
92
206
|
} catch (_unused) {}
|
|
93
207
|
}
|
|
94
|
-
function attempt(sink, token, request, effectUrl, range, timeoutFromEffect, attemptNo) {
|
|
208
|
+
function attempt(sink, token, request, effectUrl, range, timeoutFromEffect, head, attemptNo) {
|
|
95
209
|
const state = {
|
|
96
210
|
controller: new AbortController(),
|
|
97
211
|
timedOut: false,
|
|
@@ -126,20 +240,21 @@ function createTransport(options) {
|
|
|
126
240
|
}
|
|
127
241
|
state.retryId = setTimeout(() => {
|
|
128
242
|
state.retryId = null;
|
|
129
|
-
attempt(sink, token, request, effectUrl, range, timeoutFromEffect, attemptNo + 1);
|
|
243
|
+
attempt(sink, token, request, effectUrl, range, timeoutFromEffect, head, attemptNo + 1);
|
|
130
244
|
}, backoffDelayMs(policy, attemptNo));
|
|
131
245
|
};
|
|
132
246
|
const answer = takePrimed(effectUrl, range);
|
|
133
247
|
(answer !== null ? Promise.resolve(new Response(answer.bytes, {
|
|
134
248
|
status: 200,
|
|
135
249
|
headers: answer.headers
|
|
136
|
-
})) : fetchImpl(draft.url, {
|
|
250
|
+
})) : fetchImpl(draft.url, _objectSpread2(_objectSpread2({}, head ? { method: "HEAD" } : {}), {}, {
|
|
137
251
|
headers: draft.headers,
|
|
138
252
|
signal: state.controller.signal
|
|
139
|
-
})).then(function() {
|
|
253
|
+
}))).then(function() {
|
|
140
254
|
var _ref = _asyncToGenerator(function* (response) {
|
|
141
|
-
var _options$acceptManife, _response$body;
|
|
255
|
+
var _options$acceptManife, _response$body, _options$split, _options$split2, _streamed$size, _streamed$transfer, _response$headers$get;
|
|
142
256
|
if (state.timeoutId !== null) clearTimeout(state.timeoutId);
|
|
257
|
+
const wait = now() - startedAt;
|
|
143
258
|
if (!response.ok) {
|
|
144
259
|
notifyResponse({
|
|
145
260
|
token,
|
|
@@ -157,7 +272,19 @@ function createTransport(options) {
|
|
|
157
272
|
const contentType = response.headers.get("content-type");
|
|
158
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;
|
|
159
274
|
if (refused) yield (_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.cancel();
|
|
160
|
-
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;
|
|
161
288
|
if (state.userAborted) {
|
|
162
289
|
live.delete(sink.id + token);
|
|
163
290
|
return;
|
|
@@ -168,7 +295,7 @@ function createTransport(options) {
|
|
|
168
295
|
url: draft.url,
|
|
169
296
|
status: response.status,
|
|
170
297
|
rtt,
|
|
171
|
-
size
|
|
298
|
+
size,
|
|
172
299
|
outcome: refused ? "failure" : "success",
|
|
173
300
|
attempt: attemptNo,
|
|
174
301
|
headers: response.headers
|
|
@@ -200,18 +327,23 @@ function createTransport(options) {
|
|
|
200
327
|
keepMs: sink.keepMs,
|
|
201
328
|
rtt
|
|
202
329
|
}));
|
|
203
|
-
|
|
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({
|
|
204
337
|
type: "SEGMENT_LOADED",
|
|
205
338
|
trackId: request.trackId,
|
|
206
339
|
seq: request.seq,
|
|
207
340
|
token,
|
|
208
341
|
bytes,
|
|
209
342
|
rtt,
|
|
210
|
-
size
|
|
211
|
-
|
|
212
|
-
});
|
|
343
|
+
size
|
|
344
|
+
}, transfer !== void 0 ? { transfer } : {}), Number.isFinite(date) ? { serverDate: date / 1e3 } : {}), {}, { wallClock: Date.now() / 1e3 }));
|
|
213
345
|
});
|
|
214
|
-
return function(
|
|
346
|
+
return function(_x5) {
|
|
215
347
|
return _ref.apply(this, arguments);
|
|
216
348
|
};
|
|
217
349
|
}()).catch(() => {
|
|
@@ -256,7 +388,7 @@ function createTransport(options) {
|
|
|
256
388
|
seq: -1,
|
|
257
389
|
url: effect.url
|
|
258
390
|
}, effect.renditionId !== void 0 ? { renditionId: effect.renditionId } : {});
|
|
259
|
-
attempt(main, 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);
|
|
260
392
|
return () => cancel(effect.token);
|
|
261
393
|
});
|
|
262
394
|
},
|
|
@@ -278,7 +410,7 @@ function createTransport(options) {
|
|
|
278
410
|
url: effect.url
|
|
279
411
|
}, effect.renditionId !== void 0 ? { renditionId: effect.renditionId } : {});
|
|
280
412
|
tokens.add(effect.token);
|
|
281
|
-
attempt(sink, effect.token, request, effect.url, effect.range, effect.timeout, 1);
|
|
413
|
+
attempt(sink, effect.token, request, effect.url, effect.range, effect.timeout, effect.method === "HEAD", 1);
|
|
282
414
|
return () => cancel(sink.id + effect.token);
|
|
283
415
|
},
|
|
284
416
|
close() {
|
|
@@ -292,17 +424,17 @@ function createTransport(options) {
|
|
|
292
424
|
const draft = {
|
|
293
425
|
url,
|
|
294
426
|
headers: _objectSpread2({}, (_init$headers = init.headers) !== null && _init$headers !== void 0 ? _init$headers : {}),
|
|
295
|
-
timeoutMs: defaultTimeout,
|
|
427
|
+
timeoutMs: init.timeoutMs === void 0 ? defaultTimeout : init.timeoutMs,
|
|
296
428
|
token: `req:${url}`,
|
|
297
429
|
attempt: 1
|
|
298
430
|
};
|
|
299
431
|
for (const hook of [...requestHooks]) try {
|
|
300
432
|
hook(draft);
|
|
301
433
|
} catch (_unused3) {}
|
|
302
|
-
return fetchImpl
|
|
434
|
+
return fetchWithin(fetchImpl, draft.url, _objectSpread2({
|
|
303
435
|
method: (_init$method = init.method) !== null && _init$method !== void 0 ? _init$method : init.body !== void 0 ? "POST" : "GET",
|
|
304
436
|
headers: draft.headers
|
|
305
|
-
}, init.body !== void 0 ? { body: init.body } : {}));
|
|
437
|
+
}, init.body !== void 0 ? { body: init.body } : {}), draft.timeoutMs, init.signal);
|
|
306
438
|
})();
|
|
307
439
|
},
|
|
308
440
|
addRequestHook(hook) {
|
|
@@ -320,4 +452,4 @@ function createTransport(options) {
|
|
|
320
452
|
};
|
|
321
453
|
}
|
|
322
454
|
//#endregion
|
|
323
|
-
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.154.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.154.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 };
|
|
@@ -9,10 +9,11 @@ import hdr from "../../stages/hdr/index.js";
|
|
|
9
9
|
import cmsd from "../../stages/cmsd/index.js";
|
|
10
10
|
import chapters from "../../stages/chapters/index.js";
|
|
11
11
|
import { definePreset } from "../define.js";
|
|
12
|
-
import { base,
|
|
12
|
+
import { base, dashLlLine, drmTier, hlsLlLine, lowLatencyTier, tsTier } from "../tiers.js";
|
|
13
13
|
//#region src/presets/full/index.ts
|
|
14
14
|
/**
|
|
15
|
-
* The `full` preset: `dual-ts-drm`
|
|
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
|
|
16
17
|
* (loads a file the app names), trick play (a UI control drives it),
|
|
17
18
|
* timed metadata (a page reads it), CEA-708 captions (US broadcast
|
|
18
19
|
* streams carry 608 beside them, which the base reads), TTML subtitles
|
|
@@ -27,8 +28,9 @@ import { base, dashLine, drmTier, hlsLine, tsTier } from "../tiers.js";
|
|
|
27
28
|
* the main CDN bundle exposes it.
|
|
28
29
|
*/
|
|
29
30
|
const preset = definePreset("full", () => [
|
|
30
|
-
...
|
|
31
|
-
...
|
|
31
|
+
...hlsLlLine(),
|
|
32
|
+
...dashLlLine(),
|
|
33
|
+
...lowLatencyTier(),
|
|
32
34
|
...base(),
|
|
33
35
|
...tsTier(),
|
|
34
36
|
...drmTier(),
|
|
@@ -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,11 +45,33 @@ 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
|
/**
|
|
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
|
+
/**
|
|
50
75
|
* What every preset carries: adaptive quality with a size cap, recovery, content steering (inert until a manifest asks for it),
|
|
51
76
|
* alternate audio with codec switching, WebVTT subtitles, CMAF timing (reads
|
|
52
77
|
* each segment's decode time so the kernel lands it at its playlist time,
|
|
@@ -96,4 +121,4 @@ function drmTier() {
|
|
|
96
121
|
];
|
|
97
122
|
}
|
|
98
123
|
//#endregion
|
|
99
|
-
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.154.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 };
|