mattebox 0.5.0 → 0.6.1
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/dist/cdn/mattebox.dash-drm.min.js +3 -3
- package/dist/cdn/mattebox.dash.min.js +3 -3
- package/dist/cdn/mattebox.dual-drm.min.js +3 -3
- 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-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 +4 -4
- package/dist/containers/mp4-box/index.d.ts +9 -7
- package/dist/containers/mp4-box/index.d.ts.map +1 -1
- package/dist/containers/mp4-box/index.js +20 -28
- package/dist/containers/mp4-box/index.js.map +1 -1
- package/dist/containers/packed-audio/index.d.ts.map +1 -1
- package/dist/containers/packed-audio/index.js +5 -1
- package/dist/containers/packed-audio/index.js.map +1 -1
- package/dist/containers/ts-transmux/index.d.ts.map +1 -1
- package/dist/containers/ts-transmux/index.js +2 -1
- package/dist/containers/ts-transmux/index.js.map +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/containers/id3.js +1 -1
- package/dist/es2015/containers/mp4-box/index.js +19 -22
- package/dist/es2015/containers/packed-audio/index.js +2 -5
- package/dist/es2015/containers/ts-transmux/h264.js +1 -1
- package/dist/es2015/containers/ts-transmux/index.js +3 -6
- package/dist/es2015/index.js +40 -27
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/context.js +7 -0
- package/dist/es2015/kernel/loader.js +5 -4
- package/dist/es2015/kernel/mse.js +48 -74
- package/dist/es2015/kernel/prepare.js +77 -0
- package/dist/es2015/kernel/reducer.js +284 -73
- package/dist/es2015/kernel/refresh.js +35 -0
- package/dist/es2015/kernel/rendition-select.js +62 -2
- package/dist/es2015/kernel/scheduler.js +23 -5
- package/dist/es2015/kernel/timeline.js +22 -1
- package/dist/es2015/kernel/trace.js +1 -1
- package/dist/es2015/kernel/transport.js +4 -4
- package/dist/es2015/presets/define.js +2 -2
- package/dist/es2015/presets/tiers.js +7 -6
- package/dist/es2015/protocols/dash-cmaf/index.js +136 -55
- package/dist/es2015/protocols/dash-cmaf/parse.js +2 -10
- package/dist/es2015/protocols/dash-live/index.js +88 -16
- package/dist/es2015/protocols/hls-cmaf/index.js +119 -71
- package/dist/es2015/protocols/hls-cmaf/parse.js +35 -25
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +42 -0
- package/dist/es2015/protocols/hls-live/index.js +221 -78
- package/dist/es2015/stages/abr/index.js +1 -1
- package/dist/es2015/stages/abr-persist/index.js +1 -1
- package/dist/es2015/stages/aes-128/index.js +1 -1
- package/dist/es2015/stages/alt-audio/index.js +1 -1
- package/dist/es2015/stages/cmaf-timing/index.js +24 -39
- package/dist/es2015/stages/cmcd/index.js +15 -2
- package/dist/es2015/stages/content-steering/index.js +30 -3
- package/dist/es2015/stages/eme-core/index.js +2 -2
- package/dist/es2015/stages/eme-fairplay/index.js +1 -1
- package/dist/es2015/stages/recovery/index.js +1 -1
- package/dist/es2015/stages/text-cea608/decode.js +1 -1
- package/dist/es2015/stages/text-webvtt/parse.js +1 -1
- package/dist/es2015/stages/thumbnails/index.js +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -32
- package/dist/index.js.map +1 -1
- package/dist/kernel/context.d.ts +5 -1
- 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/loader.d.ts.map +1 -1
- package/dist/kernel/loader.js +5 -7
- package/dist/kernel/loader.js.map +1 -1
- package/dist/kernel/mse.d.ts +6 -10
- package/dist/kernel/mse.d.ts.map +1 -1
- package/dist/kernel/mse.js +45 -76
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/prepare.d.ts +28 -0
- package/dist/kernel/prepare.d.ts.map +1 -0
- package/dist/kernel/prepare.js +89 -0
- package/dist/kernel/prepare.js.map +1 -0
- package/dist/kernel/reducer.d.ts +15 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +399 -88
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/refresh.d.ts +14 -0
- package/dist/kernel/refresh.d.ts.map +1 -0
- package/dist/kernel/refresh.js +50 -0
- package/dist/kernel/refresh.js.map +1 -0
- package/dist/kernel/rendition-select.d.ts +19 -1
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +69 -0
- package/dist/kernel/rendition-select.js.map +1 -1
- package/dist/kernel/scheduler.d.ts +18 -3
- package/dist/kernel/scheduler.d.ts.map +1 -1
- package/dist/kernel/scheduler.js +32 -7
- package/dist/kernel/scheduler.js.map +1 -1
- package/dist/kernel/timeline.d.ts +18 -6
- package/dist/kernel/timeline.d.ts.map +1 -1
- package/dist/kernel/timeline.js +19 -5
- package/dist/kernel/timeline.js.map +1 -1
- package/dist/kernel/transport.d.ts.map +1 -1
- package/dist/kernel/transport.js +1 -0
- package/dist/kernel/transport.js.map +1 -1
- package/dist/presets/tiers.d.ts +7 -6
- package/dist/presets/tiers.d.ts.map +1 -1
- package/dist/presets/tiers.js +7 -6
- package/dist/presets/tiers.js.map +1 -1
- package/dist/protocols/dash-cmaf/index.d.ts +2 -2
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +166 -55
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-live/index.d.ts.map +1 -1
- package/dist/protocols/dash-live/index.js +83 -11
- package/dist/protocols/dash-live/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/index.d.ts +3 -2
- package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/index.js +140 -82
- package/dist/protocols/hls-cmaf/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts +9 -5
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +50 -47
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts +17 -0
- package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -0
- package/dist/protocols/hls-cmaf/unavailable.js +36 -0
- package/dist/protocols/hls-cmaf/unavailable.js.map +1 -0
- package/dist/protocols/hls-live/index.d.ts +17 -0
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js +239 -76
- package/dist/protocols/hls-live/index.js.map +1 -1
- package/dist/stages/aes-128/index.js +2 -2
- package/dist/stages/aes-128/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +5 -3
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/cmaf-timing/index.d.ts.map +1 -1
- package/dist/stages/cmaf-timing/index.js +33 -42
- package/dist/stages/cmaf-timing/index.js.map +1 -1
- package/dist/stages/cmcd/index.d.ts.map +1 -1
- package/dist/stages/cmcd/index.js +15 -3
- package/dist/stages/cmcd/index.js.map +1 -1
- package/dist/stages/content-steering/index.d.ts.map +1 -1
- package/dist/stages/content-steering/index.js +23 -1
- package/dist/stages/content-steering/index.js.map +1 -1
- package/dist/types/facade.d.ts +12 -0
- package/dist/types/facade.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +54 -15
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js +2 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +58 -10
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/stage.d.ts +18 -0
- package/dist/types/stage.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { segmentAtTime } from "./timeline.js";
|
|
3
3
|
import { bufferedEndFrom } from "./scheduler.js";
|
|
4
4
|
//#region src/kernel/rendition-select.ts
|
|
@@ -33,6 +33,66 @@ function lowest(allowed) {
|
|
|
33
33
|
for (const candidate of allowed) if (candidate.bitrate < best.bitrate) best = candidate;
|
|
34
34
|
return best;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The video renditions an adapter resolves ahead of need: the active one
|
|
38
|
+
* and the nearest rung below and above on its pathway. ABR moves one rung
|
|
39
|
+
* at a time from a full buffer, so its next pick is resolved before it is
|
|
40
|
+
* chosen; a longer jump resolves when it happens, while the buffer plays.
|
|
41
|
+
* Renditions a constraint excludes by id (another pathway, a failed
|
|
42
|
+
* playlist) are skipped, and renditions that share a playlist count once.
|
|
43
|
+
* Without a usable active rendition the lowest stands in, as arbitration picks it.
|
|
44
|
+
*/
|
|
45
|
+
function ladderNeighbours(renditions, activeId, constraints) {
|
|
46
|
+
var _pool$find;
|
|
47
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
48
|
+
for (const constraint of constraints.values()) {
|
|
49
|
+
var _constraint$excludeId2;
|
|
50
|
+
for (const id of (_constraint$excludeId2 = constraint.excludeIds) !== null && _constraint$excludeId2 !== void 0 ? _constraint$excludeId2 : []) excluded.add(id);
|
|
51
|
+
}
|
|
52
|
+
const usable = renditions.filter((r) => !excluded.has(r.id));
|
|
53
|
+
const pool = [...usable.length > 0 ? usable : renditions].sort((a, b) => a.bitrate - b.bitrate);
|
|
54
|
+
const active = (_pool$find = pool.find((r) => r.id === activeId)) !== null && _pool$find !== void 0 ? _pool$find : pool[0];
|
|
55
|
+
if (active === void 0) return [];
|
|
56
|
+
const key = (r) => {
|
|
57
|
+
var _r$playlistUrl;
|
|
58
|
+
return (_r$playlistUrl = r.playlistUrl) !== null && _r$playlistUrl !== void 0 ? _r$playlistUrl : r.id;
|
|
59
|
+
};
|
|
60
|
+
const ladder = [];
|
|
61
|
+
const seen = /* @__PURE__ */ new Set();
|
|
62
|
+
for (const rendition of pool) {
|
|
63
|
+
if (rendition.pathway !== active.pathway || seen.has(key(rendition))) continue;
|
|
64
|
+
seen.add(key(rendition));
|
|
65
|
+
ladder.push(rendition);
|
|
66
|
+
}
|
|
67
|
+
const at = ladder.findIndex((r) => key(r) === key(active));
|
|
68
|
+
if (at === -1) return [active];
|
|
69
|
+
return [
|
|
70
|
+
...at > 0 ? [ladder[at - 1]] : [],
|
|
71
|
+
active,
|
|
72
|
+
...at + 1 < ladder.length ? [ladder[at + 1]] : []
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* `dead` plus the video variants that require an audio group none of whose
|
|
77
|
+
* renditions is left. A variant names its audio by group, and the group
|
|
78
|
+
* carries the audio playlist and codec, so a group that cannot play takes
|
|
79
|
+
* its variants with it, the way videojs-http-streaming excludes them.
|
|
80
|
+
* Another track in the group (another language) keeps it alive.
|
|
81
|
+
*/
|
|
82
|
+
function withDeadGroups(presentation, dead) {
|
|
83
|
+
const out = new Set(dead);
|
|
84
|
+
const known = /* @__PURE__ */ new Set();
|
|
85
|
+
const alive = /* @__PURE__ */ new Set();
|
|
86
|
+
for (const period of presentation.periods) for (const track of period.tracks) {
|
|
87
|
+
if (track.contentType !== "audio") continue;
|
|
88
|
+
const colon = track.id.indexOf(":");
|
|
89
|
+
const group = colon === -1 ? track.id : track.id.slice(0, colon);
|
|
90
|
+
known.add(group);
|
|
91
|
+
if (track.renditions.some((r) => !dead.has(r.id))) alive.add(group);
|
|
92
|
+
}
|
|
93
|
+
for (const { renditionId, requires } of presentation.couplings) if (requires.audio !== void 0 && known.has(requires.audio) && !alive.has(requires.audio)) out.add(renditionId);
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
36
96
|
/** The strict arbitration order from docs/08. Never deviate; never return zero renditions. */
|
|
37
97
|
function arbitrate(ctx) {
|
|
38
98
|
const events = [];
|
|
@@ -261,4 +321,4 @@ function planPinApply(input) {
|
|
|
261
321
|
};
|
|
262
322
|
}
|
|
263
323
|
//#endregion
|
|
264
|
-
export { arbitrate, canSwitchTo, codecFamily, createArbiter, planPinApply };
|
|
324
|
+
export { arbitrate, canSwitchTo, codecFamily, createArbiter, ladderNeighbours, planPinApply, withDeadGroups };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { buildEpochs, epochForSeq, segmentAtTime, timestampOffsetFor } from "./timeline.js";
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { buildEpochs, epochForSeq, epochKey, segmentAtTime, timestampOffsetFor } from "./timeline.js";
|
|
3
3
|
//#region src/kernel/scheduler.ts
|
|
4
4
|
const DEFAULT_GAP_TOLERANCE = .25;
|
|
5
5
|
/**
|
|
@@ -32,6 +32,12 @@ function coveringSegment(ranges, segment, tolerance) {
|
|
|
32
32
|
const tail = Math.max(mid, segment.start + segment.duration - tolerance);
|
|
33
33
|
return (_ranges$find = ranges.find((range) => range.start <= mid && range.end > mid || range.start <= tail && range.end >= tail)) !== null && _ranges$find !== void 0 ? _ranges$find : null;
|
|
34
34
|
}
|
|
35
|
+
/** Whether the track's buffer received `seq` of the track's rendition since the last seek. */
|
|
36
|
+
function received(track, seq) {
|
|
37
|
+
var _track$appended;
|
|
38
|
+
const id = track.rendition.id;
|
|
39
|
+
return ((_track$appended = track.appended) === null || _track$appended === void 0 ? void 0 : _track$appended.some((entry) => entry.seq === seq && entry.renditionId === id)) === true;
|
|
40
|
+
}
|
|
35
41
|
function schedule(input) {
|
|
36
42
|
var _input$gapToleranceSe;
|
|
37
43
|
const tolerance = (_input$gapToleranceSe = input.gapToleranceSeconds) !== null && _input$gapToleranceSe !== void 0 ? _input$gapToleranceSe : DEFAULT_GAP_TOLERANCE;
|
|
@@ -39,6 +45,7 @@ function schedule(input) {
|
|
|
39
45
|
const requests = [];
|
|
40
46
|
let tokenSeq = input.tokenSeq;
|
|
41
47
|
for (const track of input.tracks) {
|
|
48
|
+
var _input$reconciled;
|
|
42
49
|
if (track.inflight.length > 0) continue;
|
|
43
50
|
const bufferedEnd = bufferedEndFrom(track.ranges, input.currentTime, tolerance);
|
|
44
51
|
if (bufferedEnd - input.currentTime >= input.bufferGoal) continue;
|
|
@@ -47,7 +54,16 @@ function schedule(input) {
|
|
|
47
54
|
let segment = segmentAtTime(track.rendition.segments, target + tolerance, track.period.start);
|
|
48
55
|
let frontier = bufferedEnd;
|
|
49
56
|
while (segment !== null) {
|
|
50
|
-
|
|
57
|
+
let covering = coveringSegment(track.ranges, segment, tolerance);
|
|
58
|
+
if (covering === null && received(track, segment.seq)) {
|
|
59
|
+
var _left$end;
|
|
60
|
+
const { start, duration } = segment;
|
|
61
|
+
const left = track.ranges.find((range) => range.start >= start && range.start < start + duration);
|
|
62
|
+
covering = {
|
|
63
|
+
start,
|
|
64
|
+
end: (_left$end = left === null || left === void 0 ? void 0 : left.end) !== null && _left$end !== void 0 ? _left$end : start + duration
|
|
65
|
+
};
|
|
66
|
+
}
|
|
51
67
|
if (covering === null) break;
|
|
52
68
|
frontier = Math.max(frontier, covering.end);
|
|
53
69
|
if (frontier - input.currentTime >= input.bufferGoal) {
|
|
@@ -63,6 +79,8 @@ function schedule(input) {
|
|
|
63
79
|
rendition: track.rendition
|
|
64
80
|
}]);
|
|
65
81
|
const epoch = epochForSeq(epochs, segment.seq);
|
|
82
|
+
const key = epoch === null ? void 0 : epochKey(epochs, epoch);
|
|
83
|
+
if (input.reconciles === true && key !== void 0 && track.sbId !== void 0 && track.sbId !== input.leadSbId && ((_input$reconciled = input.reconciled) === null || _input$reconciled === void 0 ? void 0 : _input$reconciled.has(key)) !== true && (input.leadPending === true || requests.some((r) => r.sbId === input.leadSbId))) continue;
|
|
66
84
|
tokenSeq += 1;
|
|
67
85
|
const token = `t${tokenSeq}:${track.trackId}:${segment.seq}`;
|
|
68
86
|
effects.push(_objectSpread2({
|
|
@@ -70,7 +88,7 @@ function schedule(input) {
|
|
|
70
88
|
token,
|
|
71
89
|
url: segment.url
|
|
72
90
|
}, segment.byteRange !== void 0 ? { range: segment.byteRange } : {}));
|
|
73
|
-
requests.push(_objectSpread2(_objectSpread2({
|
|
91
|
+
requests.push(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
74
92
|
token,
|
|
75
93
|
trackId: track.trackId,
|
|
76
94
|
seq: segment.seq,
|
|
@@ -78,7 +96,7 @@ function schedule(input) {
|
|
|
78
96
|
renditionId: track.rendition.id,
|
|
79
97
|
segmentStart: segment.start,
|
|
80
98
|
segmentDuration: segment.duration
|
|
81
|
-
}, track.sbId !== void 0 ? { sbId: track.sbId } : {}),
|
|
99
|
+
}, track.sbId !== void 0 ? { sbId: track.sbId } : {}), epoch !== null ? { timestampOffset: timestampOffsetFor(epoch) } : {}), key !== void 0 ? { epoch: key } : {}));
|
|
82
100
|
}
|
|
83
101
|
return {
|
|
84
102
|
effects,
|
|
@@ -55,6 +55,27 @@ function epochForSeq(epochs, seq) {
|
|
|
55
55
|
function timestampOffsetFor(epoch) {
|
|
56
56
|
return epoch.presentationStart - epoch.mediaStart;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* The name every track of a period shares for one epoch: the period alone
|
|
60
|
+
* for the epoch that opens it, the period and the discontinuity's
|
|
61
|
+
* presentation start after that. Sequence numbers are no part of it,
|
|
62
|
+
* because each rendition numbers its own playlist (RFC 8216 §6.2.2 aligns
|
|
63
|
+
* discontinuities across renditions in time, not in sequence). The start
|
|
64
|
+
* is rounded to the second, since each playlist sums its own durations.
|
|
65
|
+
*/
|
|
66
|
+
function epochKey(epochs, epoch) {
|
|
67
|
+
return epochs[0] === epoch ? epoch.periodId : `${epoch.periodId}:${Math.round(epoch.presentationStart)}`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The timestampOffset that lands a segment at its presentation start,
|
|
71
|
+
* given the decode time its bytes report. Manifests promise timing; the
|
|
72
|
+
* bytes tell the truth, so this replaces the epoch prediction the moment
|
|
73
|
+
* a segment lands. Same arithmetic as videojs-http-streaming's segment
|
|
74
|
+
* loader, which subtracts the probed start from the segment's start.
|
|
75
|
+
*/
|
|
76
|
+
function reconciledOffset(segmentStart, mediaStart) {
|
|
77
|
+
return segmentStart - mediaStart;
|
|
78
|
+
}
|
|
58
79
|
/** Materializes one segment from an indexed form. Null outside the window. */
|
|
59
80
|
function segmentAt(addressing, seq, periodStart = 0) {
|
|
60
81
|
var _addressing$presentat2;
|
|
@@ -124,4 +145,4 @@ function segmentAtTime(addressing, time, periodStart = 0) {
|
|
|
124
145
|
return null;
|
|
125
146
|
}
|
|
126
147
|
//#endregion
|
|
127
|
-
export { buildEpochs, epochForSeq, segmentAt, segmentAtTime, timestampOffsetFor };
|
|
148
|
+
export { buildEpochs, epochForSeq, epochKey, reconciledOffset, segmentAt, segmentAtTime, timestampOffsetFor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.150.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.150.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/asyncToGenerator.js";
|
|
3
3
|
//#region src/kernel/transport.ts
|
|
4
4
|
const DEFAULT_RETRY_POLICY = {
|
|
5
5
|
maxAttempts: 3,
|
|
@@ -196,12 +196,12 @@ function createTransport(options) {
|
|
|
196
196
|
registerHandlers(runner) {
|
|
197
197
|
runner.register("fetch", (effect) => {
|
|
198
198
|
var _options$inflight;
|
|
199
|
-
const request = (_options$inflight = options.inflight(effect.token)) !== null && _options$inflight !== void 0 ? _options$inflight : {
|
|
199
|
+
const request = (_options$inflight = options.inflight(effect.token)) !== null && _options$inflight !== void 0 ? _options$inflight : _objectSpread2({
|
|
200
200
|
token: effect.token,
|
|
201
201
|
trackId: effect.token,
|
|
202
202
|
seq: -1,
|
|
203
203
|
url: effect.url
|
|
204
|
-
};
|
|
204
|
+
}, effect.renditionId !== void 0 ? { renditionId: effect.renditionId } : {});
|
|
205
205
|
attempt(effect.token, request, effect.url, effect.range, effect.timeout, 1);
|
|
206
206
|
return () => cancel(effect.token);
|
|
207
207
|
});
|
|
@@ -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.150.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.150.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"];
|
|
@@ -50,12 +50,13 @@ function dashLine() {
|
|
|
50
50
|
/**
|
|
51
51
|
* What every preset carries: adaptive quality with a size cap and bandwidth
|
|
52
52
|
* memory, recovery, content steering (inert until a manifest asks for it),
|
|
53
|
-
* alternate audio with codec switching, WebVTT subtitles, CMAF
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* probe (types a SourceBuffer whose playlist
|
|
57
|
-
* otherwise refuses), and CEA-608 captions
|
|
58
|
-
* costs per NAL unit, not per byte, and
|
|
53
|
+
* alternate audio with codec switching, WebVTT subtitles, CMAF timing (reads
|
|
54
|
+
* each segment's decode time so the kernel lands it at its playlist time,
|
|
55
|
+
* whatever clock the packager wrote), program date time from either
|
|
56
|
+
* protocol's anchor, the codec probe (types a SourceBuffer whose playlist
|
|
57
|
+
* declares no codecs, which Chrome otherwise refuses), and CEA-608 captions
|
|
58
|
+
* from fMP4 video. The caption scan costs per NAL unit, not per byte, and
|
|
59
|
+
* only when a segment has H.264 or HEVC.
|
|
59
60
|
*/
|
|
60
61
|
function base() {
|
|
61
62
|
return [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ladderNeighbours } from "../../kernel/rendition-select.js";
|
|
4
|
+
import { parse, sidxToSegments } from "./parse.js";
|
|
4
5
|
//#region src/protocols/dash-cmaf/index.ts
|
|
5
6
|
/**
|
|
6
7
|
* The dash-cmaf protocol adapter as a stage. Inert module: exports a
|
|
@@ -12,8 +13,8 @@ import { mergeSidx, parse, sidxToSegments } from "./parse.js";
|
|
|
12
13
|
* indexed by a `sidx` box, so the concrete segments are unknown until that box
|
|
13
14
|
* is fetched. That second phase mirrors HLS's media-playlist fetch: the parse
|
|
14
15
|
* emits `sidx` addressing, this slice fetches the index byte range under a
|
|
15
|
-
* `dash:idx:` token the transport correlates back, parses it, and
|
|
16
|
-
* resolved segments
|
|
16
|
+
* `dash:idx:` token the transport correlates back, parses it, and feeds the
|
|
17
|
+
* resolved segments back as a PLAYLIST_REFRESHED the kernel merges.
|
|
17
18
|
*/
|
|
18
19
|
const INDEX_TOKEN = "dash:idx:";
|
|
19
20
|
/** The MPD MIME type, ISO 23009-1 §C.2. */
|
|
@@ -27,8 +28,12 @@ function asSidx(addressing) {
|
|
|
27
28
|
const INITIAL = {
|
|
28
29
|
manifestUrl: null,
|
|
29
30
|
mimeType: null,
|
|
30
|
-
pending: {}
|
|
31
|
+
pending: {},
|
|
32
|
+
failed: {},
|
|
33
|
+
seen: ""
|
|
31
34
|
};
|
|
35
|
+
/** The constraint source that excludes renditions whose index failed. */
|
|
36
|
+
const UNAVAILABLE = "dash:unavailable";
|
|
32
37
|
/**
|
|
33
38
|
* Whether this adapter owns the manifest bytes. An explicit mimeType
|
|
34
39
|
* decides alone; without one, an MPD is an XML document and starts with
|
|
@@ -42,29 +47,41 @@ function findRendition(presentation, renditionId) {
|
|
|
42
47
|
for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return rendition;
|
|
43
48
|
return null;
|
|
44
49
|
}
|
|
50
|
+
function findTrackOf(presentation, renditionId) {
|
|
51
|
+
for (const period of presentation.periods) for (const track of period.tracks) if (track.renditions.some((r) => r.id === renditionId)) return track;
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
45
54
|
/**
|
|
46
|
-
* The renditions whose sidx index
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* each, so the cost is negligible.
|
|
55
|
+
* The renditions whose sidx index the selection needs and this slice has
|
|
56
|
+
* not asked for: the playing video rendition and its ladder neighbours, and
|
|
57
|
+
* every rendition of the active audio and text tracks. The kernel selects
|
|
58
|
+
* the audio rendition on its own (an audio adaptation set often has several
|
|
59
|
+
* bitrates) and keeps no record of the pick, so all of them resolve; an
|
|
60
|
+
* unresolved one would never fill the audio buffer. The whole video ladder
|
|
61
|
+
* does not: ABR steps one rung at a time, and a longer jump resolves when
|
|
62
|
+
* it happens, while the buffer plays.
|
|
55
63
|
*/
|
|
56
|
-
function neededIndexes(kernel) {
|
|
64
|
+
function neededIndexes(state, kernel) {
|
|
57
65
|
const presentation = kernel.presentation;
|
|
58
66
|
if (presentation === null) return [];
|
|
59
|
-
const
|
|
67
|
+
const asked = new Set(Object.values(state.pending));
|
|
68
|
+
const needed = [];
|
|
69
|
+
for (const contentType of [
|
|
60
70
|
"video",
|
|
61
71
|
"audio",
|
|
62
72
|
"text"
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
]) {
|
|
74
|
+
const trackId = kernel.tracks.active.get(contentType);
|
|
75
|
+
if (trackId === void 0) continue;
|
|
76
|
+
for (const period of presentation.periods) for (const track of period.tracks) {
|
|
77
|
+
if (track.id !== trackId) continue;
|
|
78
|
+
const candidates = contentType === "video" ? ladderNeighbours(track.renditions, kernel.quality.active, kernel.quality.constraints) : track.renditions;
|
|
79
|
+
for (const rendition of candidates) {
|
|
80
|
+
if (asSidx(rendition.segments) === null) continue;
|
|
81
|
+
if (asked.has(rendition.id) || rendition.id in state.failed) continue;
|
|
82
|
+
needed.push(rendition);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
68
85
|
}
|
|
69
86
|
return needed;
|
|
70
87
|
}
|
|
@@ -77,13 +94,35 @@ function feed(message) {
|
|
|
77
94
|
then: message
|
|
78
95
|
};
|
|
79
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* An index that failed to load or held no segment. The rendition is
|
|
99
|
+
* excluded, so arbitration moves off it and nothing asks for the index
|
|
100
|
+
* again. When that leaves a media track with no rendition at all, the load
|
|
101
|
+
* fails: the stream cannot play, and waiting would only stall.
|
|
102
|
+
*/
|
|
103
|
+
function unavailable(state, kernel, renditionId, error) {
|
|
104
|
+
const failed = _objectSpread2(_objectSpread2({}, state.failed), {}, { [renditionId]: true });
|
|
105
|
+
const next = _objectSpread2(_objectSpread2({}, state), {}, { failed });
|
|
106
|
+
const presentation = kernel.presentation;
|
|
107
|
+
if (presentation === null) return [next, []];
|
|
108
|
+
const track = findTrackOf(presentation, renditionId);
|
|
109
|
+
const media = (track === null || track === void 0 ? void 0 : track.contentType) === "video" || (track === null || track === void 0 ? void 0 : track.contentType) === "audio";
|
|
110
|
+
if (track !== null && media && track.renditions.every((r) => r.id in failed)) return [next, [feed({
|
|
111
|
+
type: "MANIFEST_FAILED",
|
|
112
|
+
error: _objectSpread2(_objectSpread2({}, error), {}, { fatal: true })
|
|
113
|
+
})]];
|
|
114
|
+
return [next, [feed({
|
|
115
|
+
type: "CONSTRAIN",
|
|
116
|
+
source: UNAVAILABLE,
|
|
117
|
+
constraint: { excludeIds: Object.keys(failed) }
|
|
118
|
+
})]];
|
|
119
|
+
}
|
|
80
120
|
const reduceDash = (slice, msg, kernel) => {
|
|
81
121
|
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
82
|
-
if (msg.type === "LOAD") return [{
|
|
122
|
+
if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
|
|
83
123
|
manifestUrl: msg.url,
|
|
84
|
-
mimeType: msg.mimeType === void 0 ? null : normalizeMimeType(msg.mimeType)
|
|
85
|
-
|
|
86
|
-
}, []];
|
|
124
|
+
mimeType: msg.mimeType === void 0 ? null : normalizeMimeType(msg.mimeType)
|
|
125
|
+
}), []];
|
|
87
126
|
if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
|
|
88
127
|
if (msg.type === "SEGMENT_LOADED" && msg.trackId === "manifest" && state.manifestUrl !== null) {
|
|
89
128
|
const text = new TextDecoder().decode(msg.bytes);
|
|
@@ -106,43 +145,85 @@ const reduceDash = (slice, msg, kernel) => {
|
|
|
106
145
|
presentation: result.presentation
|
|
107
146
|
})]];
|
|
108
147
|
}
|
|
109
|
-
|
|
148
|
+
let next = state;
|
|
149
|
+
if (msg.type === "PLAYLIST_REFRESHED" && msg.renditionId !== void 0) {
|
|
150
|
+
const renditionId = msg.renditionId;
|
|
151
|
+
const token = `${INDEX_TOKEN}${renditionId}`;
|
|
152
|
+
if (token in next.pending) {
|
|
153
|
+
const pending = _objectSpread2({}, next.pending);
|
|
154
|
+
delete pending[token];
|
|
155
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { pending });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (msg.type === "SEGMENT_LOADED" && msg.trackId in state.pending) {
|
|
159
|
+
var _findRendition;
|
|
110
160
|
const renditionId = state.pending[msg.trackId];
|
|
111
|
-
|
|
112
|
-
const
|
|
161
|
+
const sidx = kernel.presentation === null ? null : asSidx((_findRendition = findRendition(kernel.presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.segments);
|
|
162
|
+
const segments = sidx === null ? [] : sidxToSegments(new Uint8Array(msg.bytes), sidx);
|
|
163
|
+
if (sidx !== null && segments.length > 0) {
|
|
164
|
+
var _segments$0$seq, _segments$;
|
|
165
|
+
return [state, [feed({
|
|
166
|
+
type: "PLAYLIST_REFRESHED",
|
|
167
|
+
trackId: renditionId,
|
|
168
|
+
renditionId,
|
|
169
|
+
mediaSequence: (_segments$0$seq = (_segments$ = segments[0]) === null || _segments$ === void 0 ? void 0 : _segments$.seq) !== null && _segments$0$seq !== void 0 ? _segments$0$seq : 0,
|
|
170
|
+
segments
|
|
171
|
+
})]];
|
|
172
|
+
}
|
|
113
173
|
const pending = _objectSpread2({}, state.pending);
|
|
114
174
|
delete pending[msg.trackId];
|
|
115
|
-
const sidx = asSidx(rendition === null || rendition === void 0 ? void 0 : rendition.segments);
|
|
116
175
|
if (sidx === null) return [_objectSpread2(_objectSpread2({}, state), {}, { pending }), []];
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
176
|
+
const error = {
|
|
177
|
+
category: "media",
|
|
178
|
+
code: "MEDIA_CONTAINER_INVALID",
|
|
179
|
+
fatal: false,
|
|
180
|
+
recoverable: false,
|
|
181
|
+
context: {
|
|
182
|
+
renditionId,
|
|
183
|
+
reason: "sidx holds no segment"
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
const [failed, failEffects] = unavailable(_objectSpread2(_objectSpread2({}, state), {}, { pending }), kernel, renditionId, error);
|
|
187
|
+
return [failed, [{
|
|
188
|
+
kind: "emit",
|
|
189
|
+
event: "error",
|
|
190
|
+
payload: {
|
|
191
|
+
category: error.category,
|
|
192
|
+
code: error.code,
|
|
193
|
+
fatal: false,
|
|
194
|
+
recoverable: false,
|
|
195
|
+
renditionId
|
|
196
|
+
}
|
|
197
|
+
}, ...failEffects]];
|
|
124
198
|
}
|
|
125
|
-
if (msg.type === "
|
|
126
|
-
const
|
|
127
|
-
if (needed.length === 0) return [state, []];
|
|
128
|
-
const effects = [];
|
|
199
|
+
if (msg.type === "SEGMENT_FAILED" && msg.trackId in state.pending) {
|
|
200
|
+
const renditionId = state.pending[msg.trackId];
|
|
129
201
|
const pending = _objectSpread2({}, state.pending);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
202
|
+
delete pending[msg.trackId];
|
|
203
|
+
return unavailable(_objectSpread2(_objectSpread2({}, state), {}, { pending }), kernel, renditionId, msg.error);
|
|
204
|
+
}
|
|
205
|
+
if (kernel.lifecycle.phase !== "ready" || kernel.presentation === null) return [next, []];
|
|
206
|
+
const key = `${kernel.quality.version}:${kernel.quality.active}`;
|
|
207
|
+
if (key === next.seen && msg.type !== "RESUME") return [next, []];
|
|
208
|
+
const effects = [];
|
|
209
|
+
const pending = _objectSpread2({}, next.pending);
|
|
210
|
+
for (const rendition of neededIndexes(next, kernel)) {
|
|
211
|
+
const sidx = asSidx(rendition.segments);
|
|
212
|
+
if (sidx === null) continue;
|
|
213
|
+
const token = `${INDEX_TOKEN}${rendition.id}`;
|
|
214
|
+
pending[token] = rendition.id;
|
|
215
|
+
effects.push({
|
|
216
|
+
kind: "fetch",
|
|
217
|
+
token,
|
|
218
|
+
url: sidx.url,
|
|
219
|
+
range: sidx.indexRange,
|
|
220
|
+
renditionId: rendition.id
|
|
221
|
+
});
|
|
144
222
|
}
|
|
145
|
-
return [
|
|
223
|
+
return [_objectSpread2(_objectSpread2({}, next), {}, {
|
|
224
|
+
pending,
|
|
225
|
+
seen: key
|
|
226
|
+
}), effects];
|
|
146
227
|
};
|
|
147
228
|
/**
|
|
148
229
|
* The stage factory. `mattebox({ stages: [dashCmaf()] })` is all a consumer
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
|
|
3
3
|
//#region src/protocols/dash-cmaf/parse.ts
|
|
4
4
|
/**
|
|
@@ -479,13 +479,5 @@ function sidxToSegments(sidxBytes, addressing) {
|
|
|
479
479
|
}
|
|
480
480
|
return segments;
|
|
481
481
|
}
|
|
482
|
-
/**
|
|
483
|
-
* Immutably swaps a rendition's unresolved sidx addressing for the explicit
|
|
484
|
-
* segment list parsed from its index box. Everything else about the
|
|
485
|
-
* presentation is already known from the MPD.
|
|
486
|
-
*/
|
|
487
|
-
function mergeSidx(presentation, renditionId, segments) {
|
|
488
|
-
return _objectSpread2(_objectSpread2({}, presentation), {}, { periods: presentation.periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, { tracks: period.tracks.map((track) => track.renditions.some((r) => r.id === renditionId) ? _objectSpread2(_objectSpread2({}, track), {}, { renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2({}, rendition), {}, { segments }) : rendition) }) : track) })) });
|
|
489
|
-
}
|
|
490
482
|
//#endregion
|
|
491
|
-
export {
|
|
483
|
+
export { parse, parseDuration, sidxToSegments };
|