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,8 +1,10 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
1
2
|
import { concat, sequenceNumberFor, writeInitSegment, writeMediaSegment } from "../fmp4/writer.js";
|
|
2
|
-
import { demux, unrollTimestamps } from "./demux.js";
|
|
3
|
+
import { STREAM_TYPE, demux, unrollTimestamps } from "./demux.js";
|
|
3
4
|
import { ccTriplesFromSei } from "../sei.js";
|
|
4
5
|
import { adtsFragment, parseAdts } from "../adts.js";
|
|
5
6
|
import { NAL_TYPE, accessUnitFromNals, nalType, splitNalUnits, spsDimensions, toAccessUnit } from "./h264.js";
|
|
7
|
+
import { HEVC_NAL_TYPE, hevcAccessUnitFromNals, hevcDecoderConfiguration, hevcNalType, hevcSpsInfo } from "./h265.js";
|
|
6
8
|
//#region src/containers/ts-transmux/transmux.ts
|
|
7
9
|
/**
|
|
8
10
|
* The transmux core: MPEG-TS bytes to a self-contained fragmented MP4. Each
|
|
@@ -42,6 +44,18 @@ function timedTags(streams, presentationStart, anchor) {
|
|
|
42
44
|
}
|
|
43
45
|
return tags;
|
|
44
46
|
}
|
|
47
|
+
const AVC = {
|
|
48
|
+
type: nalType,
|
|
49
|
+
delimiter: NAL_TYPE.accessUnitDelimiter,
|
|
50
|
+
unit: accessUnitFromNals,
|
|
51
|
+
seiHeader: 1
|
|
52
|
+
};
|
|
53
|
+
const HEVC = {
|
|
54
|
+
type: hevcNalType,
|
|
55
|
+
delimiter: HEVC_NAL_TYPE.accessUnitDelimiter,
|
|
56
|
+
unit: hevcAccessUnitFromNals,
|
|
57
|
+
seiHeader: 2
|
|
58
|
+
};
|
|
45
59
|
/**
|
|
46
60
|
* Reframes video access units. Access units do not align with PES packet
|
|
47
61
|
* boundaries in the wild: a picture's tail spills into the next PES packet,
|
|
@@ -51,7 +65,7 @@ function timedTags(streams, presentationStart, anchor) {
|
|
|
51
65
|
* no delimiters falls back to one unit per PES, which is correct when the muxer
|
|
52
66
|
* did align them.
|
|
53
67
|
*/
|
|
54
|
-
function frameAccessUnits(packets) {
|
|
68
|
+
function frameAccessUnits(packets, syntax) {
|
|
55
69
|
let total = 0;
|
|
56
70
|
for (const p of packets) total += p.data.byteLength;
|
|
57
71
|
const es = new Uint8Array(total);
|
|
@@ -67,8 +81,8 @@ function frameAccessUnits(packets) {
|
|
|
67
81
|
offset += p.data.byteLength;
|
|
68
82
|
}
|
|
69
83
|
const nals = splitNalUnits(es);
|
|
70
|
-
if (!nals.some((n) =>
|
|
71
|
-
unit: toAccessUnit(p.data),
|
|
84
|
+
if (!nals.some((n) => syntax.type(n) === syntax.delimiter)) return packets.map((p) => ({
|
|
85
|
+
unit: syntax === AVC ? toAccessUnit(p.data) : syntax.unit(splitNalUnits(p.data)),
|
|
72
86
|
pts: p.pts,
|
|
73
87
|
dts: p.dts
|
|
74
88
|
}));
|
|
@@ -81,14 +95,14 @@ function frameAccessUnits(packets) {
|
|
|
81
95
|
while (boundaryIndex + 1 < boundaries.length && boundaries[boundaryIndex + 1].offset <= groupOffset) boundaryIndex += 1;
|
|
82
96
|
const b = boundaries[boundaryIndex];
|
|
83
97
|
framed.push({
|
|
84
|
-
unit:
|
|
98
|
+
unit: syntax.unit(group),
|
|
85
99
|
pts: b.pts,
|
|
86
100
|
dts: b.dts
|
|
87
101
|
});
|
|
88
102
|
group = [];
|
|
89
103
|
};
|
|
90
104
|
for (const nal of nals) {
|
|
91
|
-
if (
|
|
105
|
+
if (syntax.type(nal) === syntax.delimiter && group.length > 0) flush();
|
|
92
106
|
if (group.length === 0) groupOffset = nal.byteOffset - es.byteOffset;
|
|
93
107
|
group.push(nal);
|
|
94
108
|
}
|
|
@@ -96,19 +110,24 @@ function frameAccessUnits(packets) {
|
|
|
96
110
|
return framed;
|
|
97
111
|
}
|
|
98
112
|
function buildVideo(packets, presentationStart, wantCaptions, carried) {
|
|
99
|
-
var _ref, _sps, _ref2, _pps;
|
|
113
|
+
var _packets$, _ref, _sps, _ref2, _pps, _ref3, _vps;
|
|
100
114
|
if (packets.length === 0) return null;
|
|
101
|
-
const
|
|
115
|
+
const hevc = ((_packets$ = packets[0]) === null || _packets$ === void 0 ? void 0 : _packets$.streamType) === STREAM_TYPE.h265;
|
|
116
|
+
const syntax = hevc ? HEVC : AVC;
|
|
117
|
+
const framed = frameAccessUnits(packets, syntax);
|
|
102
118
|
const units = framed.map((f) => f.unit);
|
|
119
|
+
let vps = null;
|
|
103
120
|
let sps = null;
|
|
104
121
|
let pps = null;
|
|
105
122
|
for (const unit of units) {
|
|
123
|
+
if (unit.vps != null) vps = unit.vps;
|
|
106
124
|
if (unit.sps !== null) sps = unit.sps;
|
|
107
125
|
if (unit.pps !== null) pps = unit.pps;
|
|
108
126
|
}
|
|
109
127
|
sps = (_ref = (_sps = sps) !== null && _sps !== void 0 ? _sps : carried === null || carried === void 0 ? void 0 : carried.sps) !== null && _ref !== void 0 ? _ref : null;
|
|
110
128
|
pps = (_ref2 = (_pps = pps) !== null && _pps !== void 0 ? _pps : carried === null || carried === void 0 ? void 0 : carried.pps) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
111
|
-
|
|
129
|
+
vps = (_ref3 = (_vps = vps) !== null && _vps !== void 0 ? _vps : carried === null || carried === void 0 ? void 0 : carried.vps) !== null && _ref3 !== void 0 ? _ref3 : null;
|
|
130
|
+
if (sps === null || pps === null || hevc && vps === null) return null;
|
|
112
131
|
const dts = unrollTimestamps(framed.map((f) => f.dts));
|
|
113
132
|
const pts = unrollTimestamps(framed.map((f) => f.pts));
|
|
114
133
|
const base = Math.round(presentationStart * VIDEO_TIMESCALE);
|
|
@@ -119,7 +138,7 @@ function buildVideo(packets, presentationStart, wantCaptions, carried) {
|
|
|
119
138
|
for (let i = 0; i < units.length; i += 1) {
|
|
120
139
|
const unit = units[i];
|
|
121
140
|
if (unit.sei.length === 0) continue;
|
|
122
|
-
const triples = unit.sei.flatMap((nal) => ccTriplesFromSei(nal));
|
|
141
|
+
const triples = unit.sei.flatMap((nal) => ccTriplesFromSei(nal, syntax.seiHeader));
|
|
123
142
|
if (triples.length === 0) continue;
|
|
124
143
|
const time = presentationStart + (pts[i] - firstPts) / VIDEO_TIMESCALE;
|
|
125
144
|
captions.push({
|
|
@@ -138,9 +157,9 @@ function buildVideo(packets, presentationStart, wantCaptions, carried) {
|
|
|
138
157
|
isKeyframe: units[i].isKeyframe
|
|
139
158
|
});
|
|
140
159
|
}
|
|
141
|
-
const { width, height } = spsDimensions(sps);
|
|
160
|
+
const { width, height } = hevc ? hevcSpsInfo(sps) : spsDimensions(sps);
|
|
142
161
|
return {
|
|
143
|
-
config: {
|
|
162
|
+
config: _objectSpread2({
|
|
144
163
|
id: VIDEO_TRACK_ID,
|
|
145
164
|
kind: "video",
|
|
146
165
|
timescale: VIDEO_TIMESCALE,
|
|
@@ -148,14 +167,18 @@ function buildVideo(packets, presentationStart, wantCaptions, carried) {
|
|
|
148
167
|
pps,
|
|
149
168
|
width,
|
|
150
169
|
height
|
|
151
|
-
},
|
|
170
|
+
}, vps !== null ? { hvcC: hevcDecoderConfiguration(vps, sps, pps) } : {}),
|
|
152
171
|
fragment: {
|
|
153
172
|
trackId: VIDEO_TRACK_ID,
|
|
154
173
|
baseMediaDecodeTime: base,
|
|
155
174
|
samples
|
|
156
175
|
},
|
|
157
176
|
captions,
|
|
158
|
-
parameterSets: {
|
|
177
|
+
parameterSets: vps !== null ? {
|
|
178
|
+
sps,
|
|
179
|
+
pps,
|
|
180
|
+
vps
|
|
181
|
+
} : {
|
|
159
182
|
sps,
|
|
160
183
|
pps
|
|
161
184
|
}
|
|
@@ -168,7 +191,7 @@ function buildAudio(packets, presentationStart) {
|
|
|
168
191
|
return adtsFragment(adts, AUDIO_TRACK_ID, presentationStart);
|
|
169
192
|
}
|
|
170
193
|
function transmux(input, presentationStart = 0, wantCaptions = false, tracks = "all", parameterSets = null) {
|
|
171
|
-
var _video$captions,
|
|
194
|
+
var _video$captions, _ref4, _streams$video$, _streams$audio$, _video$parameterSets;
|
|
172
195
|
const streams = demux(input);
|
|
173
196
|
if (streams.notTransportStream) return {
|
|
174
197
|
bytes: null,
|
|
@@ -208,7 +231,7 @@ function transmux(input, presentationStart = 0, wantCaptions = false, tracks = "
|
|
|
208
231
|
notTransportStream: false,
|
|
209
232
|
empty: false,
|
|
210
233
|
captions: (_video$captions = video === null || video === void 0 ? void 0 : video.captions) !== null && _video$captions !== void 0 ? _video$captions : [],
|
|
211
|
-
metadata: timedTags(streams, presentationStart, (
|
|
234
|
+
metadata: timedTags(streams, presentationStart, (_ref4 = video !== null ? (_streams$video$ = streams.video[0]) === null || _streams$video$ === void 0 ? void 0 : _streams$video$.dts : (_streams$audio$ = streams.audio[0]) === null || _streams$audio$ === void 0 ? void 0 : _streams$audio$.pts) !== null && _ref4 !== void 0 ? _ref4 : null),
|
|
212
235
|
droppedAudio,
|
|
213
236
|
parameterSets: (_video$parameterSets = video === null || video === void 0 ? void 0 : video.parameterSets) !== null && _video$parameterSets !== void 0 ? _video$parameterSets : null
|
|
214
237
|
};
|
|
@@ -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/containers/webvtt.ts
|
|
3
3
|
/** `HH:MM:SS.mmm` or `MM:SS.mmm` to seconds, or null. */
|
|
4
4
|
function parseTimestamp(text) {
|
|
@@ -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 { fourcc, viewOf } from "./mp4-box/index.js";
|
|
3
3
|
//#region src/containers/wvtt.ts
|
|
4
4
|
/** The child boxes of `bytes`, as type and payload. */
|
package/dist/es2015/eme/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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
|
+
import { fetchWithin } from "../kernel/transport.js";
|
|
3
4
|
import emeCore from "../stages/eme-core/index.js";
|
|
4
5
|
//#region src/eme/index.ts
|
|
5
6
|
/**
|
|
@@ -24,16 +25,16 @@ function attachEme(element, options = {}) {
|
|
|
24
25
|
drm = api;
|
|
25
26
|
},
|
|
26
27
|
request(url, init) {
|
|
27
|
-
var _init$method;
|
|
28
|
+
var _init$method, _init$timeoutMs;
|
|
28
29
|
const draft = {
|
|
29
30
|
url,
|
|
30
31
|
headers: _objectSpread2({}, init.headers)
|
|
31
32
|
};
|
|
32
33
|
requestHook === null || requestHook === void 0 || requestHook(draft);
|
|
33
|
-
return fetch(draft.url, _objectSpread2({
|
|
34
|
+
return fetchWithin((url, request) => fetch(url, request), draft.url, _objectSpread2({
|
|
34
35
|
method: (_init$method = init.method) !== null && _init$method !== void 0 ? _init$method : init.body !== void 0 ? "POST" : "GET",
|
|
35
36
|
headers: draft.headers
|
|
36
|
-
}, init.body !== void 0 ? { body: init.body } : {}));
|
|
37
|
+
}, init.body !== void 0 ? { body: init.body } : {}), (_init$timeoutMs = init.timeoutMs) !== null && _init$timeoutMs !== void 0 ? _init$timeoutMs : null, init.signal);
|
|
37
38
|
},
|
|
38
39
|
emit(event, payload) {
|
|
39
40
|
var _listeners$get;
|
|
@@ -52,6 +53,7 @@ function attachEme(element, options = {}) {
|
|
|
52
53
|
registerSwitchPolicy: noop,
|
|
53
54
|
registerTypeProbe: noop,
|
|
54
55
|
registerTimeProbe: noop,
|
|
56
|
+
registerChunkSplitter: noop,
|
|
55
57
|
reduce: noop,
|
|
56
58
|
dispatch: noop,
|
|
57
59
|
addRequestHook: () => noop,
|
package/dist/es2015/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
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 { exportTrace, replay } from "./kernel/trace.js";
|
|
3
3
|
import { createBus } from "./kernel/bus.js";
|
|
4
4
|
import { createEffectRunner } from "./kernel/effects.js";
|
|
5
|
+
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/asyncToGenerator.js";
|
|
6
|
+
import { createSegmentPreparer } from "./kernel/prepare.js";
|
|
5
7
|
import { cueFormat, normalizeMimeType } from "./kernel/mime.js";
|
|
6
8
|
import { findTrackSite, isTrick } from "./kernel/presentation.js";
|
|
7
9
|
import { activeAudio, availableGroups, canSwitchTo, createArbiter, exclusionsOf } from "./kernel/rendition-select.js";
|
|
8
10
|
import { createMseSink } from "./kernel/sinks/mse-sink.js";
|
|
9
11
|
import { createReducer, initialState, resolveConfig } from "./kernel/reducer.js";
|
|
12
|
+
import { dryRun } from "./kernel/dry-run.js";
|
|
10
13
|
import { createLifecycle } from "./kernel/lifecycle.js";
|
|
11
14
|
import { compose } from "./kernel/loader.js";
|
|
12
15
|
import { createMseController, decodable } from "./kernel/mse.js";
|
|
13
|
-
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
|
|
14
|
-
import { createSegmentPreparer } from "./kernel/prepare.js";
|
|
15
16
|
import { createTrackRegistry } from "./kernel/track-registry.js";
|
|
16
17
|
import { createTransport } from "./kernel/transport.js";
|
|
17
18
|
import { isAudioDescription, isEnhancedSpeech, isOriginal, isSdh } from "./kernel/characteristics.js";
|
|
@@ -70,6 +71,10 @@ function mattebox(options) {
|
|
|
70
71
|
const transport = createTransport(_objectSpread2(_objectSpread2({
|
|
71
72
|
absorb: prepare,
|
|
72
73
|
inflight: (token) => bus.getState().scheduling.inflight.get(token),
|
|
74
|
+
split: () => {
|
|
75
|
+
var _hooks$chunkSplitter;
|
|
76
|
+
return (_hooks$chunkSplitter = hooks.chunkSplitter) !== null && _hooks$chunkSplitter !== void 0 ? _hooks$chunkSplitter : null;
|
|
77
|
+
},
|
|
73
78
|
acceptManifestType: (contentType) => {
|
|
74
79
|
const type = normalizeMimeType(contentType);
|
|
75
80
|
return !(type.startsWith("audio/") || type.startsWith("video/")) || accepts(type);
|
|
@@ -159,6 +164,8 @@ function mattebox(options) {
|
|
|
159
164
|
decodable
|
|
160
165
|
};
|
|
161
166
|
let lastError = null;
|
|
167
|
+
/** What each deep preload started from, by URL, for the load that follows it. */
|
|
168
|
+
const seeds = /* @__PURE__ */ new Map();
|
|
162
169
|
function accepts(mimeType) {
|
|
163
170
|
return composition.manifestTypes.has(normalizeMimeType(mimeType));
|
|
164
171
|
}
|
|
@@ -311,25 +318,54 @@ function mattebox(options) {
|
|
|
311
318
|
lastError = null;
|
|
312
319
|
const { phase } = bus.getState().lifecycle;
|
|
313
320
|
if (phase !== "idle" && phase !== "attaching") bus.dispatch({ type: "UNLOAD" });
|
|
314
|
-
|
|
321
|
+
const kept = seeds.get(absolute);
|
|
322
|
+
seeds.delete(absolute);
|
|
323
|
+
bus.dispatch(_objectSpread2(_objectSpread2({
|
|
315
324
|
type: "LOAD",
|
|
316
325
|
url: absolute
|
|
317
|
-
}, (loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.mimeType) !== void 0 ? { mimeType: loadOptions.mimeType } : {}));
|
|
326
|
+
}, (loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.mimeType) !== void 0 ? { mimeType: loadOptions.mimeType } : {}), kept !== void 0 && performance.now() < kept.expires ? { seed: kept.seed } : {}));
|
|
318
327
|
},
|
|
319
328
|
preload(url, loadOptions) {
|
|
320
329
|
return _asyncToGenerator(function* () {
|
|
330
|
+
var _loadOptions$keepSeco, _loadOptions$segments;
|
|
321
331
|
const absolute = absolutize(url);
|
|
322
332
|
if ((loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.mimeType) !== void 0 && !accepts(loadOptions.mimeType)) throw Object.assign(/* @__PURE__ */ new Error(`no protocol reads ${loadOptions.mimeType}`), {
|
|
323
333
|
category: "manifest",
|
|
324
334
|
code: "MANIFEST_UNSUPPORTED"
|
|
325
335
|
});
|
|
336
|
+
const keepMs = ((_loadOptions$keepSeco = loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.keepSeconds) !== null && _loadOptions$keepSeco !== void 0 ? _loadOptions$keepSeco : 30) * 1e3;
|
|
337
|
+
const element = lifecycle.element();
|
|
338
|
+
const segments = (_loadOptions$segments = loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.segments) !== null && _loadOptions$segments !== void 0 ? _loadOptions$segments : 0;
|
|
339
|
+
if (segments > 0 && element !== null) {
|
|
340
|
+
const state = bus.getState();
|
|
341
|
+
const seed = {
|
|
342
|
+
throughputEwma: state.stats.throughputEwma,
|
|
343
|
+
throughputFastEwma: state.stats.throughputFastEwma,
|
|
344
|
+
constraints: [...state.quality.constraints].filter(([, constraint]) => constraint.excludeIds === void 0 && constraint.filter === void 0)
|
|
345
|
+
};
|
|
346
|
+
seeds.set(absolute, {
|
|
347
|
+
seed,
|
|
348
|
+
expires: performance.now() + keepMs
|
|
349
|
+
});
|
|
350
|
+
return dryRun({
|
|
351
|
+
slices: lifecycle.slices(),
|
|
352
|
+
config,
|
|
353
|
+
hooks,
|
|
354
|
+
transport,
|
|
355
|
+
element,
|
|
356
|
+
seed
|
|
357
|
+
}, absolute, _objectSpread2(_objectSpread2({}, (loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.mimeType) !== void 0 ? { mimeType: loadOptions.mimeType } : {}), {}, {
|
|
358
|
+
segments,
|
|
359
|
+
keepMs
|
|
360
|
+
}));
|
|
361
|
+
}
|
|
326
362
|
const response = yield transport.request(absolute, { method: "GET" });
|
|
327
363
|
if (!response.ok) throw Object.assign(/* @__PURE__ */ new Error(`preload ${absolute}: HTTP ${response.status}`), {
|
|
328
364
|
category: "network",
|
|
329
365
|
code: "NETWORK_HTTP_STATUS",
|
|
330
366
|
status: response.status
|
|
331
367
|
});
|
|
332
|
-
transport.prime(absolute, yield response.arrayBuffer(), response.headers);
|
|
368
|
+
transport.prime(absolute, yield response.arrayBuffer(), response.headers, { keepMs });
|
|
333
369
|
})();
|
|
334
370
|
},
|
|
335
371
|
unload() {
|
|
@@ -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/kernel/append-queue.ts
|
|
3
3
|
function isQuotaError(err) {
|
|
4
4
|
return err instanceof DOMException && err.name === "QuotaExceededError";
|
|
@@ -13,6 +13,7 @@ function createStageContext(deps) {
|
|
|
13
13
|
let registeredPolicy = false;
|
|
14
14
|
let registeredProbe = false;
|
|
15
15
|
let registeredTimeProbe = false;
|
|
16
|
+
let registeredSplitter = false;
|
|
16
17
|
return {
|
|
17
18
|
ctx: {
|
|
18
19
|
element: deps.element,
|
|
@@ -72,6 +73,11 @@ function createStageContext(deps) {
|
|
|
72
73
|
deps.hooks.timeProbe = probe;
|
|
73
74
|
registeredTimeProbe = true;
|
|
74
75
|
},
|
|
76
|
+
registerChunkSplitter(split) {
|
|
77
|
+
if (deps.hooks.chunkSplitter != null) throw new Error("a chunk splitter is already registered");
|
|
78
|
+
deps.hooks.chunkSplitter = split;
|
|
79
|
+
registeredSplitter = true;
|
|
80
|
+
},
|
|
75
81
|
reduce(slice, reducer) {
|
|
76
82
|
deps.slices.push([slice, reducer]);
|
|
77
83
|
},
|
|
@@ -100,6 +106,7 @@ function createStageContext(deps) {
|
|
|
100
106
|
if (registeredPolicy) deps.hooks.switchPolicy = null;
|
|
101
107
|
if (registeredProbe) deps.hooks.typeProbe = null;
|
|
102
108
|
if (registeredTimeProbe) deps.hooks.timeProbe = null;
|
|
109
|
+
if (registeredSplitter) deps.hooks.chunkSplitter = null;
|
|
103
110
|
}
|
|
104
111
|
};
|
|
105
112
|
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { createBus } from "./bus.js";
|
|
3
|
+
import { createEffectRunner } from "./effects.js";
|
|
4
|
+
import { createSegmentPreparer } from "./prepare.js";
|
|
5
|
+
import { createReducer, initialState } from "./reducer.js";
|
|
6
|
+
//#region src/kernel/dry-run.ts
|
|
7
|
+
/** The whole run ends here, whatever it has fetched: a preload must not outlive its use. */
|
|
8
|
+
const LIMIT_MS = 1e4;
|
|
9
|
+
/** Ranges this close are one range, as a SourceBuffer reports them. */
|
|
10
|
+
const TOUCHING = .1;
|
|
11
|
+
function merge(ranges, added) {
|
|
12
|
+
const sorted = [...ranges, added].sort((a, b) => a.start - b.start);
|
|
13
|
+
const out = [];
|
|
14
|
+
for (const range of sorted) {
|
|
15
|
+
const last = out[out.length - 1];
|
|
16
|
+
if (last !== void 0 && range.start <= last.end + TOUCHING) out[out.length - 1] = {
|
|
17
|
+
start: last.start,
|
|
18
|
+
end: Math.max(last.end, range.end)
|
|
19
|
+
};
|
|
20
|
+
else out.push(range);
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolves when each media track has its segments, when the loop has
|
|
26
|
+
* nothing left to fetch, or at the time limit. Rejects when the manifest
|
|
27
|
+
* fails.
|
|
28
|
+
*/
|
|
29
|
+
function dryRun(deps, url, options) {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const bus = createBus({
|
|
32
|
+
reducer: createReducer(deps.slices, deps.config, deps.hooks),
|
|
33
|
+
initial: initialState(deps.config),
|
|
34
|
+
traceCapacity: 0
|
|
35
|
+
});
|
|
36
|
+
const runner = createEffectRunner();
|
|
37
|
+
bus.setEffectSink((effects) => runner.run(effects));
|
|
38
|
+
let stopped = false;
|
|
39
|
+
let failure = null;
|
|
40
|
+
const timers = /* @__PURE__ */ new Set();
|
|
41
|
+
/** Per buffer: the segments loaded and not yet appended, null for an init. */
|
|
42
|
+
const loaded = /* @__PURE__ */ new Map();
|
|
43
|
+
const ranges = /* @__PURE__ */ new Map();
|
|
44
|
+
/** Media segments loaded, per buffer. */
|
|
45
|
+
const counts = /* @__PURE__ */ new Map();
|
|
46
|
+
/**
|
|
47
|
+
* The requests still out, by token. The reducer's own record does not
|
|
48
|
+
* hold a slice's requests, a media playlist among them.
|
|
49
|
+
*/
|
|
50
|
+
const open = /* @__PURE__ */ new Set();
|
|
51
|
+
const inflight = (token) => bus.getState().scheduling.inflight.get(token);
|
|
52
|
+
function finish(error) {
|
|
53
|
+
if (stopped) return;
|
|
54
|
+
stopped = true;
|
|
55
|
+
clearTimeout(limit);
|
|
56
|
+
for (const id of timers) clearTimeout(id);
|
|
57
|
+
channel.close();
|
|
58
|
+
if (error === void 0) resolve();
|
|
59
|
+
else reject(error);
|
|
60
|
+
}
|
|
61
|
+
/** Whether the run has what it came for, or nothing left to do. */
|
|
62
|
+
function check() {
|
|
63
|
+
if (stopped) return;
|
|
64
|
+
const state = bus.getState();
|
|
65
|
+
if (state.lifecycle.phase === "error") {
|
|
66
|
+
var _failure;
|
|
67
|
+
finish((_failure = failure) !== null && _failure !== void 0 ? _failure : /* @__PURE__ */ new Error(`preload ${url} failed`));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (state.presentation === null) return;
|
|
71
|
+
const tracks = ["video", "audio"].filter((type) => state.tracks.active.has(type));
|
|
72
|
+
const full = tracks.length > 0 && tracks.every((type) => {
|
|
73
|
+
var _counts$get;
|
|
74
|
+
return ((_counts$get = counts.get(`sb:${type}`)) !== null && _counts$get !== void 0 ? _counts$get : 0) >= options.segments;
|
|
75
|
+
});
|
|
76
|
+
const idle = open.size === 0 && timers.size === 0;
|
|
77
|
+
if (full || idle) finish();
|
|
78
|
+
}
|
|
79
|
+
/** A message from outside the loop: a response, a timer. The loop is at rest when it returns. */
|
|
80
|
+
function feed(msg) {
|
|
81
|
+
if (stopped) return;
|
|
82
|
+
bus.route(msg);
|
|
83
|
+
check();
|
|
84
|
+
}
|
|
85
|
+
const probe = deps.hooks.timeProbe;
|
|
86
|
+
const prepare = createSegmentPreparer({
|
|
87
|
+
transforms: () => [],
|
|
88
|
+
timeProbe: () => probe == null ? null : (data, meta) => probe(data, _objectSpread2(_objectSpread2({}, meta), {}, { renditionId: `preload:${meta.renditionId}` })),
|
|
89
|
+
inflight,
|
|
90
|
+
absorb: (fact) => {
|
|
91
|
+
if (stopped) return;
|
|
92
|
+
if (fact.type === "SEGMENT_LOADED" && fact.token !== void 0) {
|
|
93
|
+
open.delete(fact.token);
|
|
94
|
+
const request = inflight(fact.token);
|
|
95
|
+
if ((request === null || request === void 0 ? void 0 : request.sbId) !== void 0) {
|
|
96
|
+
var _request$segmentStart, _loaded$get, _request$segmentDurat, _counts$get2;
|
|
97
|
+
const media = request.seq >= 0;
|
|
98
|
+
const start = (_request$segmentStart = request.segmentStart) !== null && _request$segmentStart !== void 0 ? _request$segmentStart : 0;
|
|
99
|
+
const queue = (_loaded$get = loaded.get(request.sbId)) !== null && _loaded$get !== void 0 ? _loaded$get : [];
|
|
100
|
+
queue.push(media ? {
|
|
101
|
+
start,
|
|
102
|
+
end: start + ((_request$segmentDurat = request.segmentDuration) !== null && _request$segmentDurat !== void 0 ? _request$segmentDurat : 0)
|
|
103
|
+
} : null);
|
|
104
|
+
loaded.set(request.sbId, queue);
|
|
105
|
+
if (media) counts.set(request.sbId, ((_counts$get2 = counts.get(request.sbId)) !== null && _counts$get2 !== void 0 ? _counts$get2 : 0) + 1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
feed(fact);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
const channel = deps.transport.channel({
|
|
112
|
+
absorb: prepare,
|
|
113
|
+
inflight,
|
|
114
|
+
keepMs: options.keepMs,
|
|
115
|
+
failed: (token) => open.delete(token)
|
|
116
|
+
});
|
|
117
|
+
runner.register("fetch", (effect) => {
|
|
118
|
+
var _bus$getState$present, _counts$get3;
|
|
119
|
+
if (stopped) return void 0;
|
|
120
|
+
const request = inflight(effect.token);
|
|
121
|
+
if (((_bus$getState$present = bus.getState().presentation) === null || _bus$getState$present === void 0 ? void 0 : _bus$getState$present.isLive) === true && (request === null || request === void 0 ? void 0 : request.sbId) !== void 0 && request.seq >= 0) {
|
|
122
|
+
finish();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if ((request === null || request === void 0 ? void 0 : request.sbId) !== void 0 && request.seq >= 0 && ((_counts$get3 = counts.get(request.sbId)) !== null && _counts$get3 !== void 0 ? _counts$get3 : 0) >= options.segments) return;
|
|
126
|
+
open.add(effect.token);
|
|
127
|
+
const cancel = channel.fetch(effect);
|
|
128
|
+
return () => {
|
|
129
|
+
open.delete(effect.token);
|
|
130
|
+
cancel();
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
runner.register("schedule", (effect) => {
|
|
134
|
+
if (stopped) return void 0;
|
|
135
|
+
const id = setTimeout(() => {
|
|
136
|
+
timers.delete(id);
|
|
137
|
+
feed(effect.then.type === "TICK" ? _objectSpread2(_objectSpread2({}, effect.then), {}, { wallClock: Date.now() / 1e3 }) : effect.then);
|
|
138
|
+
}, effect.delayMs);
|
|
139
|
+
timers.add(id);
|
|
140
|
+
return () => {
|
|
141
|
+
clearTimeout(id);
|
|
142
|
+
timers.delete(id);
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
runner.register("createSourceBuffer", (effect) => {
|
|
146
|
+
bus.absorb({
|
|
147
|
+
type: "SOURCEBUFFER_CREATED",
|
|
148
|
+
sbId: effect.sbId,
|
|
149
|
+
codecs: effect.codecs
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
runner.register("append", (effect) => {
|
|
153
|
+
var _loaded$get2, _ranges$get, _ranges$get2;
|
|
154
|
+
const segment = (_loaded$get2 = loaded.get(effect.sbId)) === null || _loaded$get2 === void 0 ? void 0 : _loaded$get2.shift();
|
|
155
|
+
if (segment != null) ranges.set(effect.sbId, merge((_ranges$get = ranges.get(effect.sbId)) !== null && _ranges$get !== void 0 ? _ranges$get : [], segment));
|
|
156
|
+
bus.absorb({
|
|
157
|
+
type: "SOURCEBUFFER_UPDATEEND",
|
|
158
|
+
sbId: effect.sbId,
|
|
159
|
+
ranges: (_ranges$get2 = ranges.get(effect.sbId)) !== null && _ranges$get2 !== void 0 ? _ranges$get2 : []
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
runner.register("emit", (effect) => {
|
|
163
|
+
const payload = effect.payload;
|
|
164
|
+
if (effect.event === "error" && (payload === null || payload === void 0 ? void 0 : payload.fatal) === true) failure = payload;
|
|
165
|
+
});
|
|
166
|
+
const limit = setTimeout(finish, LIMIT_MS);
|
|
167
|
+
bus.dispatch({
|
|
168
|
+
type: "ATTACH",
|
|
169
|
+
element: deps.element
|
|
170
|
+
});
|
|
171
|
+
feed(_objectSpread2({
|
|
172
|
+
type: "LOAD",
|
|
173
|
+
url,
|
|
174
|
+
seed: deps.seed
|
|
175
|
+
}, options.mimeType !== void 0 ? { mimeType: options.mimeType } : {}));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { dryRun };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createStageContext } from "./context.js";
|
|
2
1
|
import { createReducer } from "./reducer.js";
|
|
2
|
+
import { createStageContext } from "./context.js";
|
|
3
3
|
import { createPlaybackWatchdog } from "./watchdog.js";
|
|
4
4
|
//#region src/kernel/lifecycle.ts
|
|
5
5
|
function snapshot(ranges) {
|
|
@@ -13,6 +13,7 @@ function snapshot(ranges) {
|
|
|
13
13
|
function createLifecycle(deps) {
|
|
14
14
|
let element = null;
|
|
15
15
|
let teardowns = [];
|
|
16
|
+
let installed = [];
|
|
16
17
|
let stopWatchdog = null;
|
|
17
18
|
const elementListeners = [];
|
|
18
19
|
function listen(el, type, fn) {
|
|
@@ -46,6 +47,7 @@ function createLifecycle(deps) {
|
|
|
46
47
|
}
|
|
47
48
|
deps.bus.setReducer(createReducer(slices, deps.config, deps.hooks));
|
|
48
49
|
teardowns = stageTeardowns;
|
|
50
|
+
installed = slices;
|
|
49
51
|
deps.bus.dispatch({
|
|
50
52
|
type: "ATTACH",
|
|
51
53
|
element: el
|
|
@@ -108,6 +110,7 @@ function createLifecycle(deps) {
|
|
|
108
110
|
stopWatchdog = null;
|
|
109
111
|
for (const fn of [...teardowns].reverse()) fn();
|
|
110
112
|
teardowns = [];
|
|
113
|
+
installed = [];
|
|
111
114
|
deps.mse.detach();
|
|
112
115
|
for (const { type, fn } of elementListeners) el.removeEventListener(type, fn);
|
|
113
116
|
elementListeners.length = 0;
|
|
@@ -117,7 +120,8 @@ function createLifecycle(deps) {
|
|
|
117
120
|
return {
|
|
118
121
|
attach,
|
|
119
122
|
detach,
|
|
120
|
-
element: () => element
|
|
123
|
+
element: () => element,
|
|
124
|
+
slices: () => installed
|
|
121
125
|
};
|
|
122
126
|
}
|
|
123
127
|
//#endregion
|
|
@@ -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 { createAppendQueue } from "./append-queue.js";
|
|
3
3
|
import { createEvictor } from "./evictor.js";
|
|
4
4
|
//#region src/kernel/mse.ts
|
|
@@ -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/prepare.ts
|
|
4
4
|
/**
|
|
5
5
|
* The boundary meta a transform and the probe receive. The content type
|
|
@@ -27,7 +27,7 @@ function createSegmentPreparer(deps) {
|
|
|
27
27
|
const chains = /* @__PURE__ */ new Map();
|
|
28
28
|
return (fact) => {
|
|
29
29
|
var _chains$get;
|
|
30
|
-
if (fact.type !== "SEGMENT_LOADED" || fact.token === void 0) {
|
|
30
|
+
if (fact.type !== "SEGMENT_LOADED" && fact.type !== "SEGMENT_CHUNK" || fact.token === void 0) {
|
|
31
31
|
deps.absorb(fact);
|
|
32
32
|
return;
|
|
33
33
|
}
|