mattebox 0.2.2 → 0.4.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 +15 -2
- package/dist/cdn/mattebox.dash-drm.min.js +3 -2
- package/dist/cdn/mattebox.dash.min.js +3 -2
- package/dist/cdn/mattebox.dual-drm.min.js +3 -2
- 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 -2
- package/dist/cdn/mattebox.hls-drm.min.js +3 -2
- 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 -2
- package/dist/cdn/mattebox.kernel.min.js +1 -1
- package/dist/cdn/mattebox.min.js +4 -4
- package/dist/containers/sei.d.ts +3 -2
- package/dist/containers/sei.d.ts.map +1 -1
- package/dist/containers/sei.js +7 -4
- package/dist/containers/sei.js.map +1 -1
- package/dist/es2015/containers/sei.js +5 -3
- package/dist/es2015/index.js +1 -1
- package/dist/es2015/kernel/bus.js +8 -6
- package/dist/es2015/kernel/reducer.js +42 -19
- package/dist/es2015/kernel/rendition-select.js +9 -8
- package/dist/es2015/kernel/trace.js +31 -3
- package/dist/es2015/presets/full/index.js +4 -9
- package/dist/es2015/presets/tiers.js +18 -11
- package/dist/es2015/protocols/dash-cmaf/index.js +1 -1
- package/dist/es2015/protocols/hls-cmaf/index.js +1 -1
- package/dist/es2015/stages/alt-audio/index.js +2 -1
- package/dist/es2015/stages/codec-switch/index.js +7 -8
- package/dist/es2015/stages/eme-core/index.js +1 -1
- package/dist/es2015/stages/nal-scan/index.js +197 -92
- package/dist/es2015/stages/text-cea608/index.js +1 -1
- package/dist/kernel/bus.d.ts.map +1 -1
- package/dist/kernel/bus.js +11 -2
- package/dist/kernel/bus.js.map +1 -1
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +62 -26
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/rendition-select.d.ts +5 -6
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +17 -10
- package/dist/kernel/rendition-select.js.map +1 -1
- package/dist/kernel/trace.d.ts +17 -2
- package/dist/kernel/trace.d.ts.map +1 -1
- package/dist/kernel/trace.js +33 -2
- package/dist/kernel/trace.js.map +1 -1
- package/dist/presets/full/index.d.ts.map +1 -1
- package/dist/presets/full/index.js +4 -9
- package/dist/presets/full/index.js.map +1 -1
- package/dist/presets/tiers.d.ts +10 -7
- package/dist/presets/tiers.d.ts.map +1 -1
- package/dist/presets/tiers.js +19 -9
- package/dist/presets/tiers.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +3 -1
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/codec-probe/index.d.ts +5 -0
- package/dist/stages/codec-probe/index.d.ts.map +1 -1
- package/dist/stages/codec-probe/index.js.map +1 -1
- package/dist/stages/codec-switch/index.d.ts.map +1 -1
- package/dist/stages/codec-switch/index.js +9 -10
- package/dist/stages/codec-switch/index.js.map +1 -1
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +4 -1
- package/dist/stages/eme-core/index.js.map +1 -1
- package/dist/stages/nal-scan/index.d.ts.map +1 -1
- package/dist/stages/nal-scan/index.js +225 -95
- package/dist/stages/nal-scan/index.js.map +1 -1
- package/dist/stages/text-cea608/index.d.ts.map +1 -1
- package/dist/stages/text-cea608/index.js +2 -1
- package/dist/stages/text-cea608/index.js.map +1 -1
- package/dist/types/facade.d.ts +5 -1
- package/dist/types/facade.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +10 -2
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/messages.d.ts +8 -0
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/stage.d.ts +1 -1
- package/package.json +2 -3
package/dist/containers/sei.d.ts
CHANGED
|
@@ -18,9 +18,10 @@ export interface CcTriple {
|
|
|
18
18
|
readonly b: number;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Extracts every CEA-608/708 cc_data triple from one SEI NAL.
|
|
21
|
+
* Extracts every CEA-608/708 cc_data triple from one SEI NAL. `headerLength`
|
|
22
|
+
* is the NAL header size: 1 byte for H.264, 2 for HEVC. Returns an empty
|
|
22
23
|
* array for a SEI that carries no ATSC caption user data, and never reads past
|
|
23
24
|
* the buffer: a malformed message stops the walk.
|
|
24
25
|
*/
|
|
25
|
-
export declare function ccTriplesFromSei(seiNal: Uint8Array): CcTriple[];
|
|
26
|
+
export declare function ccTriplesFromSei(seiNal: Uint8Array, headerLength?: number): CcTriple[];
|
|
26
27
|
//# sourceMappingURL=sei.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sei.d.ts","sourceRoot":"","sources":["../../src/containers/sei.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAoBD
|
|
1
|
+
{"version":3,"file":"sei.d.ts","sourceRoot":"","sources":["../../src/containers/sei.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAoBD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,SAAI,GAAG,QAAQ,EAAE,CAiCjF"}
|
package/dist/containers/sei.js
CHANGED
|
@@ -28,13 +28,16 @@ function toRbsp(nal, start) {
|
|
|
28
28
|
return out.subarray(0, count);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Extracts every CEA-608/708 cc_data triple from one SEI NAL.
|
|
31
|
+
* Extracts every CEA-608/708 cc_data triple from one SEI NAL. `headerLength`
|
|
32
|
+
* is the NAL header size: 1 byte for H.264, 2 for HEVC. Returns an empty
|
|
32
33
|
* array for a SEI that carries no ATSC caption user data, and never reads past
|
|
33
34
|
* the buffer: a malformed message stops the walk.
|
|
34
35
|
*/
|
|
35
|
-
export function ccTriplesFromSei(seiNal) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
export function ccTriplesFromSei(seiNal, headerLength = 1) {
|
|
37
|
+
if (seiNal.byteLength <= headerLength)
|
|
38
|
+
return [];
|
|
39
|
+
// SEI RBSP begins after the NAL header.
|
|
40
|
+
const rbsp = toRbsp(seiNal, headerLength);
|
|
38
41
|
const triples = [];
|
|
39
42
|
let offset = 0;
|
|
40
43
|
const length = rbsp.byteLength;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sei.js","sourceRoot":"","sources":["../../src/containers/sei.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,wFAAwF;AACxF,SAAS,MAAM,CAAC,GAAe,EAAE,KAAa;IAC5C,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;IACnD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAW,CAAC;QAC9B,IAAI,KAAK,IAAI,CAAC,IA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,MAAM,GAAG,CAAC,CAAW,CAAC;QACxC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAW,CAAC;QACxC,MAAM,IAAI,CAAC,CAAC;QACZ,IAAI,OAAO;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -17,12 +17,14 @@ function toRbsp(nal, start) {
|
|
|
17
17
|
return out.subarray(0, count);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Extracts every CEA-608/708 cc_data triple from one SEI NAL.
|
|
20
|
+
* Extracts every CEA-608/708 cc_data triple from one SEI NAL. `headerLength`
|
|
21
|
+
* is the NAL header size: 1 byte for H.264, 2 for HEVC. Returns an empty
|
|
21
22
|
* array for a SEI that carries no ATSC caption user data, and never reads past
|
|
22
23
|
* the buffer: a malformed message stops the walk.
|
|
23
24
|
*/
|
|
24
|
-
function ccTriplesFromSei(seiNal) {
|
|
25
|
-
|
|
25
|
+
function ccTriplesFromSei(seiNal, headerLength = 1) {
|
|
26
|
+
if (seiNal.byteLength <= headerLength) return [];
|
|
27
|
+
const rbsp = toRbsp(seiNal, headerLength);
|
|
26
28
|
const triples = [];
|
|
27
29
|
let offset = 0;
|
|
28
30
|
const length = rbsp.byteLength;
|
package/dist/es2015/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
|
|
1
2
|
import { exportTrace, replay } from "./kernel/trace.js";
|
|
2
3
|
import { createBus } from "./kernel/bus.js";
|
|
3
4
|
import { createEffectRunner } from "./kernel/effects.js";
|
|
4
5
|
import { normalizeMimeType } from "./kernel/mime.js";
|
|
5
|
-
import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
|
|
6
6
|
import { canSwitchTo, createArbiter } from "./kernel/rendition-select.js";
|
|
7
7
|
import { createMseSink } from "./kernel/sinks/mse-sink.js";
|
|
8
8
|
import { createReducer, initialState, resolveConfig } from "./kernel/reducer.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createTraceBuffer, digest } from "./trace.js";
|
|
1
|
+
import { createTraceBuffer, digest, lighten } from "./trace.js";
|
|
2
2
|
//#region src/kernel/bus.ts
|
|
3
3
|
function createBus(options) {
|
|
4
4
|
var _options$now, _options$traceCapacit;
|
|
5
5
|
let reducer = options.reducer;
|
|
6
6
|
const now = (_options$now = options.now) !== null && _options$now !== void 0 ? _options$now : (() => globalThis.performance.now());
|
|
7
|
-
const traceBuffer = createTraceBuffer((_options$traceCapacit = options.traceCapacity) !== null && _options$traceCapacit !== void 0 ? _options$traceCapacit :
|
|
7
|
+
const traceBuffer = createTraceBuffer((_options$traceCapacit = options.traceCapacity) !== null && _options$traceCapacit !== void 0 ? _options$traceCapacit : 0);
|
|
8
8
|
let state = options.initial;
|
|
9
9
|
let effectSink = () => void 0;
|
|
10
10
|
const queue = [];
|
|
@@ -23,12 +23,14 @@ function createBus(options) {
|
|
|
23
23
|
while (msg !== void 0) {
|
|
24
24
|
const [next, effects] = reducer(state, msg);
|
|
25
25
|
state = next;
|
|
26
|
-
|
|
26
|
+
const entry = {
|
|
27
27
|
t: now(),
|
|
28
|
-
msg,
|
|
29
|
-
effects,
|
|
28
|
+
msg: lighten(msg),
|
|
29
|
+
effects: effects.map(lighten),
|
|
30
30
|
digest: digest(state)
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
|
+
traceBuffer.push(entry);
|
|
33
|
+
emitEvent("trace", entry);
|
|
32
34
|
effectSink(effects);
|
|
33
35
|
msg = queue.shift();
|
|
34
36
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { normalizeMimeType } from "./mime.js";
|
|
2
1
|
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { normalizeMimeType } from "./mime.js";
|
|
3
|
+
import { segmentAtTime } from "./timeline.js";
|
|
3
4
|
import { bufferedEndFrom, schedule } from "./scheduler.js";
|
|
4
5
|
import { canSwitchTo, codecFamily, createArbiter, planPinApply } from "./rendition-select.js";
|
|
5
6
|
import { sbIdFor } from "./sinks/mse-sink.js";
|
|
@@ -21,7 +22,7 @@ const DEFAULT_KERNEL_CONFIG = {
|
|
|
21
22
|
backBufferSeconds: 30,
|
|
22
23
|
bufferGoalSeconds: 30,
|
|
23
24
|
manifestTimeoutMs: 1e4,
|
|
24
|
-
traceCapacity:
|
|
25
|
+
traceCapacity: 0,
|
|
25
26
|
baseRetryDelayMs: 400,
|
|
26
27
|
mediaTimeNormalized: false
|
|
27
28
|
};
|
|
@@ -163,6 +164,17 @@ function findTrackSite(presentation, trackId) {
|
|
|
163
164
|
};
|
|
164
165
|
return null;
|
|
165
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* The first candidate whose segment list places a boundary around `time`.
|
|
169
|
+
* A flush is planned on segment boundaries, and a rendition selected for
|
|
170
|
+
* the first time may have no segments yet, its media playlist still on its
|
|
171
|
+
* way: planned on it, the flush would start at the playhead itself and
|
|
172
|
+
* leave a segment head under the seek. The rendition playing always has
|
|
173
|
+
* its segments.
|
|
174
|
+
*/
|
|
175
|
+
function segmentedAt(candidates, time, periodStart) {
|
|
176
|
+
return candidates.find((rendition) => rendition !== void 0 && segmentAtTime(rendition.segments, time, periodStart) !== null);
|
|
177
|
+
}
|
|
166
178
|
function findRendition(presentation, renditionId) {
|
|
167
179
|
if (presentation === null) return null;
|
|
168
180
|
for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return {
|
|
@@ -280,6 +292,7 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
280
292
|
}]];
|
|
281
293
|
}
|
|
282
294
|
case "SELECT_TRACK": {
|
|
295
|
+
var _segmentedAt, _previousTrack$rendit;
|
|
283
296
|
const track = findTrack(state.presentation, msg.trackId);
|
|
284
297
|
if (track === null) return reject(state, msg.type, `unknown track: ${msg.trackId}`);
|
|
285
298
|
const previous = state.tracks.active.get(track.contentType);
|
|
@@ -288,22 +301,30 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
288
301
|
const effects = [];
|
|
289
302
|
let buffers = state.buffers;
|
|
290
303
|
let inflight = state.scheduling.inflight;
|
|
291
|
-
|
|
304
|
+
const site = state.presentation === null ? null : findTrackSite(state.presentation, track.id);
|
|
305
|
+
const previousTrack = previous === void 0 ? null : findTrack(state.presentation, previous);
|
|
306
|
+
const flushRendition = site === null ? void 0 : (_segmentedAt = segmentedAt([...track.renditions, ...(_previousTrack$rendit = previousTrack === null || previousTrack === void 0 ? void 0 : previousTrack.renditions) !== null && _previousTrack$rendit !== void 0 ? _previousTrack$rendit : []], state.playback.currentTime, site.period.start)) !== null && _segmentedAt !== void 0 ? _segmentedAt : track.renditions[0];
|
|
307
|
+
if (previous !== void 0 && previous !== track.id && (track.contentType === "audio" || track.contentType === "video") && site !== null && flushRendition !== void 0) {
|
|
292
308
|
const sbId = sbIdFor(track.contentType);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
309
|
+
const buffer = state.buffers.get(sbId);
|
|
310
|
+
if (buffer !== void 0) {
|
|
311
|
+
var _msg$apply;
|
|
312
|
+
const plan = planPinApply({
|
|
313
|
+
strategy: (_msg$apply = msg.apply) !== null && _msg$apply !== void 0 ? _msg$apply : "now",
|
|
314
|
+
currentTime: state.playback.currentTime,
|
|
315
|
+
ranges: buffer.ranges,
|
|
296
316
|
sbId,
|
|
297
|
-
|
|
298
|
-
|
|
317
|
+
trackId: track.id,
|
|
318
|
+
inflightTokens: [],
|
|
319
|
+
period: site.period,
|
|
320
|
+
rendition: flushRendition,
|
|
321
|
+
tokenSeq: state.scheduling.tokenSeq
|
|
299
322
|
});
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
buffers = next;
|
|
306
|
-
}
|
|
323
|
+
for (const effect of plan.effects) if (effect.kind !== "seekElement" || track.contentType === "video") effects.push(effect);
|
|
324
|
+
const next = new Map(state.buffers);
|
|
325
|
+
const { initFor: _initFor } = buffer, rest = _objectWithoutProperties(buffer, _excluded2);
|
|
326
|
+
next.set(sbId, rest);
|
|
327
|
+
buffers = next;
|
|
307
328
|
const pruned = new Map(state.scheduling.inflight);
|
|
308
329
|
for (const [token, request] of state.scheduling.inflight) if (request.trackId === previous) {
|
|
309
330
|
effects.push({
|
|
@@ -362,7 +383,7 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
362
383
|
]];
|
|
363
384
|
}
|
|
364
385
|
case "PIN_RENDITION": {
|
|
365
|
-
var _state$buffers$get$ra, _state$buffers$get;
|
|
386
|
+
var _state$buffers$get$ra, _state$buffers$get, _segmentedAt2;
|
|
366
387
|
const site = findRendition(state.presentation, msg.renditionId);
|
|
367
388
|
if (site === null) return reject(state, msg.type, `unknown rendition: ${msg.renditionId}`);
|
|
368
389
|
const pinnedState = _objectSpread2(_objectSpread2({}, state), {}, { quality: bumped(_objectSpread2(_objectSpread2({}, state.quality), {}, {
|
|
@@ -373,6 +394,7 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
373
394
|
const sbId = sbIdFor(site.track.contentType);
|
|
374
395
|
const inflightTokens = [];
|
|
375
396
|
for (const request of state.scheduling.inflight.values()) if (request.trackId === site.track.id) inflightTokens.push(request.token);
|
|
397
|
+
const active = state.quality.active === null ? null : findRendition(state.presentation, state.quality.active);
|
|
376
398
|
const plan = planPinApply({
|
|
377
399
|
strategy: msg.apply,
|
|
378
400
|
currentTime: state.playback.currentTime,
|
|
@@ -381,7 +403,7 @@ function reduceCommand(state, msg, cfg, hooks) {
|
|
|
381
403
|
trackId: site.track.id,
|
|
382
404
|
inflightTokens,
|
|
383
405
|
period: site.period,
|
|
384
|
-
rendition: site.rendition,
|
|
406
|
+
rendition: (_segmentedAt2 = segmentedAt([site.rendition, active === null || active === void 0 ? void 0 : active.rendition], state.playback.currentTime, site.period.start)) !== null && _segmentedAt2 !== void 0 ? _segmentedAt2 : site.rendition,
|
|
385
407
|
tokenSeq: state.scheduling.tokenSeq
|
|
386
408
|
});
|
|
387
409
|
const inflight = new Map(state.scheduling.inflight);
|
|
@@ -516,8 +538,9 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
516
538
|
if (buffer !== void 0) {
|
|
517
539
|
var _targetSite$rendition;
|
|
518
540
|
const targetSite = findRendition(state.presentation, matched.renditionId);
|
|
519
|
-
const
|
|
520
|
-
const
|
|
541
|
+
const declared = (_targetSite$rendition = targetSite === null || targetSite === void 0 ? void 0 : targetSite.rendition.codecs) !== null && _targetSite$rendition !== void 0 ? _targetSite$rendition : null;
|
|
542
|
+
const targetCodecs = targetSite === null || declared === null ? buffer.codecs : `${targetSite.rendition.mimeType}; codecs="${declared}"`;
|
|
543
|
+
const familyChanged = declared !== null && codecFamily(declared) !== codecFamily(bufferCodecString(buffer.codecs));
|
|
521
544
|
const nextBuffers = new Map(state.buffers);
|
|
522
545
|
if (targetCodecs !== buffer.codecs && familyChanged) effects.push({
|
|
523
546
|
kind: "changeType",
|
|
@@ -188,18 +188,17 @@ function codecFamily(codecs) {
|
|
|
188
188
|
return dot === -1 ? first : first.slice(0, dot);
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
|
-
* The kernel's default answer to entanglement #2. codec
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* change reloads.
|
|
191
|
+
* The kernel's default answer to entanglement #2. One codec family is
|
|
192
|
+
* seamless: every ladder rung carries its own profile or level string,
|
|
193
|
+
* browsers accept a new in-family init in the same SourceBuffer, and the
|
|
194
|
+
* reducer appends it bare. A family change reloads until codec-switch,
|
|
195
|
+
* which knows whether the browser has `changeType`, says otherwise.
|
|
197
196
|
*/
|
|
198
197
|
function canSwitchTo(current, target) {
|
|
199
198
|
if (current === null) return "seamless";
|
|
200
199
|
if (current.codecs !== null && current.codecs === target.codecs) return "seamless";
|
|
201
200
|
const family = codecFamily(current.codecs);
|
|
202
|
-
if (family !== null && family === codecFamily(target.codecs)) return "
|
|
201
|
+
if (family !== null && family === codecFamily(target.codecs)) return "seamless";
|
|
203
202
|
return "reload";
|
|
204
203
|
}
|
|
205
204
|
/**
|
|
@@ -243,10 +242,12 @@ function planPinApply(input) {
|
|
|
243
242
|
tokenSeq: input.tokenSeq
|
|
244
243
|
};
|
|
245
244
|
}
|
|
245
|
+
const current = segmentAtTime(input.rendition.segments, input.currentTime, input.period.start);
|
|
246
|
+
const from = current === null ? input.currentTime : Math.min(current.start, input.currentTime);
|
|
246
247
|
effects.push({
|
|
247
248
|
kind: "remove",
|
|
248
249
|
sbId: input.sbId,
|
|
249
|
-
start:
|
|
250
|
+
start: from,
|
|
250
251
|
end: Infinity
|
|
251
252
|
});
|
|
252
253
|
effects.push({
|
|
@@ -1,10 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
function isBytes(value) {
|
|
3
|
+
return value instanceof ArrayBuffer || ArrayBuffer.isView(value);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A message or an effect as the ring records it: every byte payload
|
|
7
|
+
* replaced by its length, one level down and through a scheduled
|
|
8
|
+
* message, everything else by reference. The ring would otherwise keep
|
|
9
|
+
* every segment's bytes alive for as long as the entry lasts, which at
|
|
10
|
+
* five hundred entries is the media of a whole session. The reducer never
|
|
11
|
+
* reads the bytes, only forwards them, so a lightened entry replays the
|
|
12
|
+
* same. Object identity is not kept: a recorded message is a copy.
|
|
13
|
+
*/
|
|
14
|
+
function lighten(value) {
|
|
15
|
+
var _copy;
|
|
16
|
+
let copy = null;
|
|
17
|
+
for (const [key, field] of Object.entries(value)) {
|
|
18
|
+
let next = field;
|
|
19
|
+
if (isBytes(field)) next = { $bytes: field.byteLength };
|
|
20
|
+
else if (key === "then" && typeof field === "object" && field !== null) next = lighten(field);
|
|
21
|
+
if (next !== field) {
|
|
22
|
+
if (copy === null) copy = _objectSpread2({}, value);
|
|
23
|
+
copy[key] = next;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return (_copy = copy) !== null && _copy !== void 0 ? _copy : value;
|
|
27
|
+
}
|
|
28
|
+
/** Fixed capacity, overwriting, and nothing at all at zero. Roughly 200 bytes of code for the whole payoff. */
|
|
29
|
+
function createTraceBuffer(capacity = 0) {
|
|
3
30
|
const entries = [];
|
|
4
31
|
let head = 0;
|
|
5
32
|
return {
|
|
6
33
|
capacity,
|
|
7
34
|
push(entry) {
|
|
35
|
+
if (capacity <= 0) return;
|
|
8
36
|
if (entries.length < capacity) entries.push(entry);
|
|
9
37
|
else {
|
|
10
38
|
entries[head] = entry;
|
|
@@ -131,4 +159,4 @@ function replay(entries, reducer, initial) {
|
|
|
131
159
|
return { ok: true };
|
|
132
160
|
}
|
|
133
161
|
//#endregion
|
|
134
|
-
export { createTraceBuffer, digest, exportTrace, replay };
|
|
162
|
+
export { createTraceBuffer, digest, exportTrace, lighten, replay };
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import thumbnails from "../../stages/thumbnails/index.js";
|
|
2
|
-
import mp4Box from "../../stages/mp4-box/index.js";
|
|
3
|
-
import codecProbe from "../../stages/codec-probe/index.js";
|
|
4
2
|
import cmcd from "../../stages/cmcd/index.js";
|
|
5
3
|
import { definePreset } from "../define.js";
|
|
6
4
|
import { base, dashLine, drmTier, hlsLine, tsTier } from "../tiers.js";
|
|
7
5
|
//#region src/presets/full/index.ts
|
|
8
6
|
/**
|
|
9
7
|
* The `full` preset: every stage the catalogue ships. `dual-ts-drm` plus
|
|
10
|
-
* the accessories:
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* the
|
|
14
|
-
* exposes it.
|
|
8
|
+
* the accessories: CMCD (changes every request, so opt-in elsewhere) and
|
|
9
|
+
* thumbnails (needs an app-supplied sprite track). Feature parity with
|
|
10
|
+
* videojs-http-streaming; the modularity claim is measured against it, and
|
|
11
|
+
* the main CDN bundle exposes it.
|
|
15
12
|
*/
|
|
16
13
|
const preset = definePreset("full", () => [
|
|
17
14
|
...hlsLine(),
|
|
@@ -19,8 +16,6 @@ const preset = definePreset("full", () => [
|
|
|
19
16
|
...base(),
|
|
20
17
|
...tsTier(),
|
|
21
18
|
...drmTier(),
|
|
22
|
-
mp4Box(),
|
|
23
|
-
codecProbe(),
|
|
24
19
|
cmcd(),
|
|
25
20
|
thumbnails()
|
|
26
21
|
]);
|
|
@@ -4,12 +4,14 @@ import textCea608 from "../stages/text-cea608/index.js";
|
|
|
4
4
|
import recovery from "../stages/recovery/index.js";
|
|
5
5
|
import pdt from "../stages/pdt/index.js";
|
|
6
6
|
import nalScan from "../stages/nal-scan/index.js";
|
|
7
|
+
import mp4Box from "../stages/mp4-box/index.js";
|
|
7
8
|
import metaId3 from "../stages/meta-id3/index.js";
|
|
8
9
|
import emeFairplay from "../stages/eme-fairplay/index.js";
|
|
9
10
|
import emeCore from "../stages/eme-core/index.js";
|
|
10
11
|
import emeCenc from "../stages/eme-cenc/index.js";
|
|
11
12
|
import contentSteering from "../stages/content-steering/index.js";
|
|
12
13
|
import codecSwitch from "../stages/codec-switch/index.js";
|
|
14
|
+
import codecProbe from "../stages/codec-probe/index.js";
|
|
13
15
|
import cmafTiming from "../stages/cmaf-timing/index.js";
|
|
14
16
|
import altAudio from "../stages/alt-audio/index.js";
|
|
15
17
|
import aes128 from "../stages/aes-128/index.js";
|
|
@@ -33,12 +35,11 @@ import { localThroughputStorage } from "./storage.js";
|
|
|
33
35
|
* preset gets fresh stage instances, and a group a preset never calls
|
|
34
36
|
* tree-shakes out of it with the stages it imports.
|
|
35
37
|
*/
|
|
36
|
-
/** HLS on demand and live, with
|
|
38
|
+
/** HLS on demand and live, with AES-128 segment decryption. */
|
|
37
39
|
function hlsLine() {
|
|
38
40
|
return [
|
|
39
41
|
hlsCmaf(),
|
|
40
42
|
hlsLive(),
|
|
41
|
-
pdt(),
|
|
42
43
|
aes128()
|
|
43
44
|
];
|
|
44
45
|
}
|
|
@@ -49,9 +50,12 @@ function dashLine() {
|
|
|
49
50
|
/**
|
|
50
51
|
* What every preset carries: adaptive quality with a size cap and bandwidth
|
|
51
52
|
* memory, recovery, content steering (inert until a manifest asks for it),
|
|
52
|
-
* alternate audio with codec switching, WebVTT subtitles,
|
|
53
|
-
*
|
|
54
|
-
*
|
|
53
|
+
* alternate audio with codec switching, WebVTT subtitles, CMAF live timing
|
|
54
|
+
* (corrects the broadcast-clock tfdt some live packagers write, leaves VOD
|
|
55
|
+
* untouched), program date time from either protocol's anchor, the codec
|
|
56
|
+
* probe (types a SourceBuffer whose playlist declares no codecs, which Chrome
|
|
57
|
+
* otherwise refuses), and CEA-608 captions from fMP4 video. The caption scan
|
|
58
|
+
* costs per NAL unit, not per byte, and only when a segment has H.264 or HEVC.
|
|
55
59
|
*/
|
|
56
60
|
function base() {
|
|
57
61
|
return [
|
|
@@ -64,20 +68,23 @@ function base() {
|
|
|
64
68
|
altAudio(),
|
|
65
69
|
textWebvtt(),
|
|
66
70
|
textWebvttSegmented(),
|
|
67
|
-
cmafTiming()
|
|
71
|
+
cmafTiming(),
|
|
72
|
+
pdt(),
|
|
73
|
+
mp4Box(),
|
|
74
|
+
codecProbe(),
|
|
75
|
+
nalScan(),
|
|
76
|
+
textCea608()
|
|
68
77
|
];
|
|
69
78
|
}
|
|
70
79
|
/**
|
|
71
|
-
* Legacy MPEG-TS: the transmuxer and packed audio, plus
|
|
72
|
-
* transport stream
|
|
73
|
-
*
|
|
80
|
+
* Legacy MPEG-TS: the transmuxer and packed audio, plus ID3 metadata, which
|
|
81
|
+
* rides on the transport stream. The transmuxer is also a caption source for
|
|
82
|
+
* the base's text-cea608, next to nal-scan.
|
|
74
83
|
*/
|
|
75
84
|
function tsTier() {
|
|
76
85
|
return [
|
|
77
86
|
tsTransmux(),
|
|
78
87
|
packedAudio(),
|
|
79
|
-
nalScan(),
|
|
80
|
-
textCea608(),
|
|
81
88
|
metaId3()
|
|
82
89
|
];
|
|
83
90
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
2
1
|
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
3
3
|
import { mergeSidx, parse, sidxToSegments } from "./parse.js";
|
|
4
4
|
//#region src/protocols/dash-cmaf/index.ts
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
2
1
|
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
3
3
|
import { mergePlaylist, parse, parseMediaPlaylist } from "./parse.js";
|
|
4
4
|
//#region src/protocols/hls-cmaf/index.ts
|
|
5
5
|
/**
|
|
@@ -3,12 +3,12 @@ import { canSwitchTo } from "../../kernel/rendition-select.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* codec-switch: the real answer to entanglement #2's query. It registers a
|
|
5
5
|
* switch policy the kernel injects into abr's telemetry; abr consumes it
|
|
6
|
-
* without importing this stage. The refinement over the kernel default
|
|
7
|
-
*
|
|
8
|
-
* the two codecs, which needs both a
|
|
9
|
-
* SourceBuffer.changeType itself
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* without importing this stage. The refinement over the kernel default,
|
|
7
|
+
* which reloads across codec families: a family change is a changeType
|
|
8
|
+
* when the browser can actually bridge the two codecs, which needs both a
|
|
9
|
+
* supported target type and SourceBuffer.changeType itself, and a reload
|
|
10
|
+
* where it cannot. Changes inside one family stay seamless, as the kernel
|
|
11
|
+
* says: the reducer appends the new init bare and browsers accept it.
|
|
12
12
|
*
|
|
13
13
|
* codec-probe (declared in `requires`, resolved by the loader, never
|
|
14
14
|
* imported) is the future source of exact codec strings when a manifest
|
|
@@ -29,8 +29,7 @@ function changeTypeSupported(target) {
|
|
|
29
29
|
}
|
|
30
30
|
function createPolicy() {
|
|
31
31
|
return (current, target) => {
|
|
32
|
-
|
|
33
|
-
if (base !== "changeType") return base;
|
|
32
|
+
if (canSwitchTo(current, target) === "seamless") return "seamless";
|
|
34
33
|
return changeTypeSupported(target) ? "changeType" : "reload";
|
|
35
34
|
};
|
|
36
35
|
}
|
|
@@ -228,7 +228,7 @@ function emeCore(options = {}) {
|
|
|
228
228
|
element.removeEventListener("encrypted", onEncrypted);
|
|
229
229
|
offManifest();
|
|
230
230
|
for (const session of sessionsByKey.values()) session.close().catch(() => {});
|
|
231
|
-
element.setMediaKeys(null).catch(() => {});
|
|
231
|
+
if (mediaKeys !== null) element.setMediaKeys(null).catch(() => {});
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
};
|