mattebox 0.8.2 → 0.10.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/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 +2 -2
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.151.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/containers/id3.js +1 -1
- package/dist/es2015/containers/ts-transmux/h264.js +1 -1
- package/dist/es2015/containers/ts-transmux/index.js +1 -1
- package/dist/es2015/containers/webvtt.js +1 -1
- package/dist/es2015/index.js +6 -4
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/characteristics.js +27 -0
- package/dist/es2015/kernel/context.js +3 -0
- package/dist/es2015/kernel/mse.js +1 -1
- package/dist/es2015/kernel/prepare.js +2 -2
- package/dist/es2015/kernel/reducer.js +46 -8
- package/dist/es2015/kernel/refresh.js +1 -1
- package/dist/es2015/kernel/rendition-select.js +1 -1
- package/dist/es2015/kernel/scheduler.js +1 -1
- package/dist/es2015/kernel/trace.js +1 -1
- package/dist/es2015/kernel/track-registry.js +18 -1
- package/dist/es2015/kernel/transport.js +2 -2
- package/dist/es2015/presets/define.js +2 -2
- package/dist/es2015/presets/tiers.js +2 -0
- package/dist/es2015/protocols/dash-cmaf/index.js +1 -1
- package/dist/es2015/protocols/dash-cmaf/parse.js +98 -26
- package/dist/es2015/protocols/dash-live/index.js +1 -1
- package/dist/es2015/protocols/hls-cmaf/index.js +1 -1
- package/dist/es2015/protocols/hls-cmaf/parse.js +35 -3
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +1 -1
- package/dist/es2015/protocols/hls-live/index.js +1 -1
- 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 +31 -11
- package/dist/es2015/stages/chapters/index.js +2 -2
- package/dist/es2015/stages/chapters/parse.js +2 -2
- package/dist/es2015/stages/content-steering/index.js +1 -1
- package/dist/es2015/stages/eme-core/index.js +78 -9
- package/dist/es2015/stages/eme-fairplay/index.js +1 -1
- package/dist/es2015/stages/forced-subtitles/index.js +82 -0
- package/dist/es2015/stages/recovery/index.js +1 -1
- package/dist/es2015/stages/text-cea608/decode.js +1 -1
- package/dist/es2015/stages/text-cea608/index.js +84 -15
- package/dist/es2015/stages/text-webvtt/index.js +8 -4
- package/dist/es2015/stages/thumbnails/index.js +1 -1
- package/dist/es2015/stages/trick-play/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel/characteristics.d.ts +20 -0
- package/dist/kernel/characteristics.d.ts.map +1 -0
- package/dist/kernel/characteristics.js +25 -0
- package/dist/kernel/characteristics.js.map +1 -0
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/context.js +3 -0
- package/dist/kernel/context.js.map +1 -1
- package/dist/kernel/reducer.d.ts +3 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +40 -4
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/track-registry.d.ts +8 -8
- package/dist/kernel/track-registry.d.ts.map +1 -1
- package/dist/kernel/track-registry.js +27 -4
- package/dist/kernel/track-registry.js.map +1 -1
- package/dist/presets/tiers.d.ts.map +1 -1
- package/dist/presets/tiers.js +2 -0
- package/dist/presets/tiers.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +90 -4
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +41 -0
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts +5 -2
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +31 -11
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +82 -8
- package/dist/stages/eme-core/index.js.map +1 -1
- package/dist/stages/forced-subtitles/index.d.ts +40 -0
- package/dist/stages/forced-subtitles/index.d.ts.map +1 -0
- package/dist/stages/forced-subtitles/index.js +80 -0
- package/dist/stages/forced-subtitles/index.js.map +1 -0
- package/dist/stages/text-cea608/index.d.ts +9 -2
- package/dist/stages/text-cea608/index.d.ts.map +1 -1
- package/dist/stages/text-cea608/index.js +90 -16
- package/dist/stages/text-cea608/index.js.map +1 -1
- package/dist/stages/text-webvtt/index.d.ts +3 -0
- package/dist/stages/text-webvtt/index.d.ts.map +1 -1
- package/dist/stages/text-webvtt/index.js +9 -4
- package/dist/stages/text-webvtt/index.js.map +1 -1
- package/dist/types/facade.d.ts +6 -0
- package/dist/types/facade.d.ts.map +1 -1
- package/dist/types/ir.d.ts +20 -0
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +3 -1
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +11 -1
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/stage.d.ts +2 -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.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
|
|
3
3
|
import { resolveUrl } from "../../kernel/url.js";
|
|
4
4
|
import { base64ToBytes } from "../../kernel/base64.js";
|
|
@@ -117,6 +117,59 @@ function parseProtection(elements) {
|
|
|
117
117
|
return schemes;
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
|
+
* DVB-DASH (ETSI TS 103 285, A168 Table 5) audio purposes, as the HLS
|
|
121
|
+
* characteristic tags that mean the same, so players read one vocabulary.
|
|
122
|
+
*/
|
|
123
|
+
const AUDIO_PURPOSE_SCHEME = "urn:tva:metadata:cs:AudioPurposeCS:2007";
|
|
124
|
+
const AUDIO_PURPOSES = {
|
|
125
|
+
"1": "public.accessibility.describes-video",
|
|
126
|
+
"2": "public.accessibility.enhances-speech-intelligibility"
|
|
127
|
+
};
|
|
128
|
+
/** The characteristic tags an audio AdaptationSet's Accessibility descriptors declare. */
|
|
129
|
+
function audioCharacteristics(adaptationSet) {
|
|
130
|
+
const tags = [];
|
|
131
|
+
for (const descriptor of children(adaptationSet, "Accessibility")) {
|
|
132
|
+
var _attr5;
|
|
133
|
+
if (attr(descriptor, "schemeIdUri") !== AUDIO_PURPOSE_SCHEME) continue;
|
|
134
|
+
const tag = AUDIO_PURPOSES[(_attr5 = attr(descriptor, "value")) !== null && _attr5 !== void 0 ? _attr5 : ""];
|
|
135
|
+
if (tag !== void 0 && !tags.includes(tag)) tags.push(tag);
|
|
136
|
+
}
|
|
137
|
+
return tags;
|
|
138
|
+
}
|
|
139
|
+
const CEA608_SCHEME = "urn:scte:dash:cc:cea-608:2015";
|
|
140
|
+
/**
|
|
141
|
+
* SCTE 214-1: an Accessibility descriptor with the CEA-608 scheme names the
|
|
142
|
+
* in-band caption channels of a video AdaptationSet, as "CC1=eng;CC3=fre",
|
|
143
|
+
* "1=eng", or bare languages. Bare languages take CC1 and CC3 when there
|
|
144
|
+
* are two, else CC1 to CC4 in order; an empty value means CC1. This is the
|
|
145
|
+
* reading Shaka Player applies.
|
|
146
|
+
*/
|
|
147
|
+
function captionChannels(adaptationSet) {
|
|
148
|
+
const out = [];
|
|
149
|
+
for (const descriptor of children(adaptationSet, "Accessibility")) {
|
|
150
|
+
var _attr6;
|
|
151
|
+
if (attr(descriptor, "schemeIdUri") !== CEA608_SCHEME) continue;
|
|
152
|
+
const value = ((_attr6 = attr(descriptor, "value")) !== null && _attr6 !== void 0 ? _attr6 : "").trim();
|
|
153
|
+
if (value === "") {
|
|
154
|
+
out.push(["CC1", null]);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const entries = value.split(";");
|
|
158
|
+
let next = 1;
|
|
159
|
+
for (const entry of entries) {
|
|
160
|
+
const [left, right] = entry.split("=");
|
|
161
|
+
if (right === void 0) {
|
|
162
|
+
out.push([`CC${next}`, left.trim() || null]);
|
|
163
|
+
next += entries.length === 2 ? 2 : 1;
|
|
164
|
+
} else {
|
|
165
|
+
const channel = left.trim().startsWith("CC") ? left.trim() : `CC${left.trim()}`;
|
|
166
|
+
out.push([channel, right.trim() || null]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
120
173
|
* A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
|
|
121
174
|
* representation declaring a playout rate other than 1. Both mark an
|
|
122
175
|
* I-frame-only set meant for fast forward and previews, never for normal
|
|
@@ -124,8 +177,8 @@ function parseProtection(elements) {
|
|
|
124
177
|
*/
|
|
125
178
|
function isTrickMode(adaptationSet) {
|
|
126
179
|
for (const property of children(adaptationSet, "EssentialProperty")) {
|
|
127
|
-
var
|
|
128
|
-
if (((
|
|
180
|
+
var _attr7;
|
|
181
|
+
if (((_attr7 = attr(property, "schemeIdUri")) !== null && _attr7 !== void 0 ? _attr7 : "").includes("trickmode")) return true;
|
|
129
182
|
}
|
|
130
183
|
if (numberAttr(adaptationSet, "maxPlayoutRate") !== null) return true;
|
|
131
184
|
for (const representation of children(adaptationSet, "Representation")) {
|
|
@@ -144,8 +197,8 @@ function tileGridOf(representation, adaptationSet, width, height) {
|
|
|
144
197
|
if (width === null || height === null) return null;
|
|
145
198
|
const properties = [...children(representation, "EssentialProperty"), ...children(adaptationSet, "EssentialProperty")];
|
|
146
199
|
for (const property of properties) {
|
|
147
|
-
var
|
|
148
|
-
if (!((
|
|
200
|
+
var _attr8;
|
|
201
|
+
if (!((_attr8 = attr(property, "schemeIdUri")) !== null && _attr8 !== void 0 ? _attr8 : "").includes("thumbnail_tile")) continue;
|
|
149
202
|
const grid = dimensions(attr(property, "value"));
|
|
150
203
|
if (grid === null) continue;
|
|
151
204
|
const [columns, rows] = grid;
|
|
@@ -170,12 +223,12 @@ function mergeTemplates(levels) {
|
|
|
170
223
|
let timelineElement = null;
|
|
171
224
|
let found = false;
|
|
172
225
|
for (const level of levels) {
|
|
173
|
-
var
|
|
226
|
+
var _attr9, _attr10, _numberAttr, _numberAttr2, _numberAttr3, _numberAttr4, _children$2;
|
|
174
227
|
const template = children(level, "SegmentTemplate")[0];
|
|
175
228
|
if (template === void 0) continue;
|
|
176
229
|
found = true;
|
|
177
|
-
media = (
|
|
178
|
-
initialization = (
|
|
230
|
+
media = (_attr9 = attr(template, "media")) !== null && _attr9 !== void 0 ? _attr9 : media;
|
|
231
|
+
initialization = (_attr10 = attr(template, "initialization")) !== null && _attr10 !== void 0 ? _attr10 : initialization;
|
|
179
232
|
timescale = (_numberAttr = numberAttr(template, "timescale")) !== null && _numberAttr !== void 0 ? _numberAttr : timescale;
|
|
180
233
|
startNumber = (_numberAttr2 = numberAttr(template, "startNumber")) !== null && _numberAttr2 !== void 0 ? _numberAttr2 : startNumber;
|
|
181
234
|
duration = (_numberAttr3 = numberAttr(template, "duration")) !== null && _numberAttr3 !== void 0 ? _numberAttr3 : duration;
|
|
@@ -242,7 +295,7 @@ function contentTypeOf(adaptationSet, mimeType) {
|
|
|
242
295
|
}
|
|
243
296
|
/** parse an MPD document into a Presentation. Never throws. */
|
|
244
297
|
function parse(text, baseUrl) {
|
|
245
|
-
var _parseDuration, _parseDuration2,
|
|
298
|
+
var _parseDuration, _parseDuration2, _attr18;
|
|
246
299
|
let doc;
|
|
247
300
|
try {
|
|
248
301
|
doc = new DOMParser().parseFromString(text, "text/xml");
|
|
@@ -262,15 +315,15 @@ function parse(text, baseUrl) {
|
|
|
262
315
|
const mpdBase = applyBaseUrl(mpd, baseUrl);
|
|
263
316
|
let live;
|
|
264
317
|
if (isLive) {
|
|
265
|
-
var
|
|
266
|
-
const availabilityStart = Date.parse((
|
|
318
|
+
var _attr11, _attr12, _attr13;
|
|
319
|
+
const availabilityStart = Date.parse((_attr11 = attr(mpd, "availabilityStartTime")) !== null && _attr11 !== void 0 ? _attr11 : "");
|
|
267
320
|
const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
|
|
268
321
|
const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
|
|
269
322
|
const holdBack = parseDuration(attr(mpd, "suggestedPresentationDelay"));
|
|
270
323
|
const timing = children(mpd, "UTCTiming")[0];
|
|
271
324
|
live = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, Number.isFinite(availabilityStart) ? { availabilityStart: availabilityStart / 1e3 } : {}), updatePeriod !== null ? { updatePeriod } : {}), timeShiftDepth !== null ? { timeShiftDepth } : {}), holdBack !== null ? { holdBack } : {}), timing !== void 0 ? { timeServer: {
|
|
272
|
-
scheme: (
|
|
273
|
-
value: (
|
|
325
|
+
scheme: (_attr12 = attr(timing, "schemeIdUri")) !== null && _attr12 !== void 0 ? _attr12 : "",
|
|
326
|
+
value: (_attr13 = attr(timing, "value")) !== null && _attr13 !== void 0 ? _attr13 : ""
|
|
274
327
|
} } : {});
|
|
275
328
|
}
|
|
276
329
|
let steering;
|
|
@@ -306,7 +359,7 @@ function parse(text, baseUrl) {
|
|
|
306
359
|
const tracks = [];
|
|
307
360
|
const adaptationSets = children(periodElement, "AdaptationSet");
|
|
308
361
|
for (let asIndex = 0; asIndex < adaptationSets.length; asIndex += 1) {
|
|
309
|
-
var
|
|
362
|
+
var _roles$, _trackMime2;
|
|
310
363
|
const adaptationSet = adaptationSets[asIndex];
|
|
311
364
|
const trick = isTrickMode(adaptationSet);
|
|
312
365
|
const asPlayoutRate = numberAttr(adaptationSet, "maxPlayoutRate");
|
|
@@ -314,21 +367,22 @@ function parse(text, baseUrl) {
|
|
|
314
367
|
const asMime = attr(adaptationSet, "mimeType");
|
|
315
368
|
const asCodecs = attr(adaptationSet, "codecs");
|
|
316
369
|
const lang = attr(adaptationSet, "lang");
|
|
317
|
-
const
|
|
370
|
+
const roles = children(adaptationSet, "Role").map((element) => attr(element, "value")).filter((value) => value !== null);
|
|
371
|
+
const role = trick ? "trick" : (_roles$ = roles[0]) !== null && _roles$ !== void 0 ? _roles$ : null;
|
|
318
372
|
const protectionSchemes = parseProtection(children(adaptationSet, "ContentProtection"));
|
|
319
373
|
const renditions = [];
|
|
320
374
|
let trackMime = null;
|
|
321
375
|
for (const representation of children(adaptationSet, "Representation")) {
|
|
322
|
-
var _ref,
|
|
376
|
+
var _ref, _attr14, _trackMime, _parseFrameRate2, _numberAttr8, _attr17;
|
|
323
377
|
const id = attr(representation, "id");
|
|
324
378
|
const bandwidth = numberAttr(representation, "bandwidth");
|
|
325
379
|
if (id === null || bandwidth === null) continue;
|
|
326
380
|
const repBase = applyBaseUrl(representation, asBase);
|
|
327
|
-
const mimeType = (_ref = (
|
|
381
|
+
const mimeType = (_ref = (_attr14 = attr(representation, "mimeType")) !== null && _attr14 !== void 0 ? _attr14 : asMime) !== null && _ref !== void 0 ? _ref : "video/mp4";
|
|
328
382
|
trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
|
|
329
383
|
const segmentBase = children(representation, "SegmentBase")[0];
|
|
330
384
|
if (segmentBase !== void 0) {
|
|
331
|
-
var _numberAttr7, _parseFrameRate,
|
|
385
|
+
var _numberAttr7, _parseFrameRate, _attr15;
|
|
332
386
|
const indexRange = parseByteRange(attr(segmentBase, "indexRange"));
|
|
333
387
|
if (indexRange === null) continue;
|
|
334
388
|
const baseTimescale = (_numberAttr7 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr7 !== void 0 ? _numberAttr7 : 1;
|
|
@@ -351,7 +405,7 @@ function parse(text, baseUrl) {
|
|
|
351
405
|
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
352
406
|
id,
|
|
353
407
|
bitrate: bandwidth,
|
|
354
|
-
codecs: (
|
|
408
|
+
codecs: (_attr15 = attr(representation, "codecs")) !== null && _attr15 !== void 0 ? _attr15 : asCodecs,
|
|
355
409
|
mimeType,
|
|
356
410
|
segments: sidxSegments
|
|
357
411
|
}, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}));
|
|
@@ -364,11 +418,11 @@ function parse(text, baseUrl) {
|
|
|
364
418
|
]);
|
|
365
419
|
if (template === null || template.media === null) {
|
|
366
420
|
if (contentTypeOf(adaptationSet, mimeType) === "text" && periodDuration !== null) {
|
|
367
|
-
var
|
|
421
|
+
var _attr16;
|
|
368
422
|
renditions.push({
|
|
369
423
|
id,
|
|
370
424
|
bitrate: bandwidth,
|
|
371
|
-
codecs: (
|
|
425
|
+
codecs: (_attr16 = attr(representation, "codecs")) !== null && _attr16 !== void 0 ? _attr16 : asCodecs,
|
|
372
426
|
mimeType,
|
|
373
427
|
segments: [{
|
|
374
428
|
seq: 0,
|
|
@@ -411,20 +465,38 @@ function parse(text, baseUrl) {
|
|
|
411
465
|
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
412
466
|
id,
|
|
413
467
|
bitrate: bandwidth,
|
|
414
|
-
codecs: (
|
|
468
|
+
codecs: (_attr17 = attr(representation, "codecs")) !== null && _attr17 !== void 0 ? _attr17 : asCodecs,
|
|
415
469
|
mimeType,
|
|
416
470
|
segments
|
|
417
471
|
}, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}));
|
|
418
472
|
}
|
|
419
473
|
if (renditions.length === 0) continue;
|
|
420
474
|
const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
|
|
421
|
-
|
|
475
|
+
const contentType = contentTypeOf(adaptationSet, mimeType);
|
|
476
|
+
const characteristics = contentType === "audio" ? audioCharacteristics(adaptationSet) : [];
|
|
477
|
+
const forced = contentType === "text" && (roles.includes("forced-subtitle") || roles.includes("forced_subtitle"));
|
|
478
|
+
tracks.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
422
479
|
id: attr(adaptationSet, "id") !== null ? `as-${attr(adaptationSet, "id")}` : `as-i${asIndex}`,
|
|
423
|
-
contentType
|
|
480
|
+
contentType,
|
|
424
481
|
mimeType,
|
|
425
482
|
protection: protectionSchemes.length > 0 ? { schemes: protectionSchemes } : null,
|
|
426
483
|
renditions
|
|
427
|
-
}, lang !== null ? { lang } : {}), role !== null ? { role } : {}));
|
|
484
|
+
}, lang !== null ? { lang } : {}), role !== null ? { role } : {}), roles.length > 0 ? { roles } : {}), characteristics.length > 0 ? { characteristics } : {}), forced ? { forced: true } : {}));
|
|
485
|
+
}
|
|
486
|
+
const hasVideo = tracks.some((t) => t.contentType === "video");
|
|
487
|
+
for (const adaptationSet of hasVideo ? adaptationSets : []) for (const [instreamId, lang] of captionChannels(adaptationSet)) {
|
|
488
|
+
const id = `cea608:${instreamId}`;
|
|
489
|
+
if (!/^CC[1-4]$/.test(instreamId) || tracks.some((t) => t.id === id)) continue;
|
|
490
|
+
tracks.push(_objectSpread2(_objectSpread2({
|
|
491
|
+
id,
|
|
492
|
+
contentType: "text",
|
|
493
|
+
mimeType: "application/cea-608",
|
|
494
|
+
protection: null
|
|
495
|
+
}, lang !== null ? { lang } : {}), {}, {
|
|
496
|
+
role: "caption",
|
|
497
|
+
instreamId,
|
|
498
|
+
renditions: []
|
|
499
|
+
}));
|
|
428
500
|
}
|
|
429
501
|
if (tracks.length === 0) return {
|
|
430
502
|
presentation: null,
|
|
@@ -442,7 +514,7 @@ function parse(text, baseUrl) {
|
|
|
442
514
|
isLive
|
|
443
515
|
}, mpdDuration !== null ? { duration: mpdDuration } : {}), {}, {
|
|
444
516
|
periods: [_objectSpread2(_objectSpread2({
|
|
445
|
-
id: (
|
|
517
|
+
id: (_attr18 = attr(periodElement, "id")) !== null && _attr18 !== void 0 ? _attr18 : "p0",
|
|
446
518
|
start: periodStart
|
|
447
519
|
}, periodDuration !== null ? { duration: periodDuration } : {}), {}, { tracks })],
|
|
448
520
|
couplings: []
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
import { registerLiveNamespace } from "../live-shared.js";
|
|
4
4
|
import { parse } from "../dash-cmaf/parse.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled } from "../../kernel/effects.js";
|
|
3
3
|
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
4
4
|
import { activeRenditions } from "../../kernel/rendition-select.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { resolveUrl } from "../../kernel/url.js";
|
|
3
3
|
import { manifestError } from "../adapter-shared.js";
|
|
4
4
|
import { dimensions } from "../dimensions.js";
|
|
@@ -211,6 +211,32 @@ function mediaContentType(type) {
|
|
|
211
211
|
if (type === "SUBTITLES") return "text";
|
|
212
212
|
return null;
|
|
213
213
|
}
|
|
214
|
+
/** The CHARACTERISTICS tags of a rendition, as written, in order. */
|
|
215
|
+
function characteristicsOf(entry) {
|
|
216
|
+
var _entry$attributes$CHA;
|
|
217
|
+
return ((_entry$attributes$CHA = entry.attributes.CHARACTERISTICS) !== null && _entry$attributes$CHA !== void 0 ? _entry$attributes$CHA : "").split(",").map((tag) => tag.trim()).filter((tag) => tag !== "");
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* RFC 8216bis §4.4.6.1: a CLOSED-CAPTIONS rendition names an in-band
|
|
221
|
+
* CEA-608 channel (INSTREAM-ID CC1 to CC4) inside the video. It becomes a
|
|
222
|
+
* text track with no segments; the caption stage reads the cues from the
|
|
223
|
+
* video. CEA-708 services (SERVICEn) are left out until a stage decodes them.
|
|
224
|
+
*/
|
|
225
|
+
function captionTrack(entry) {
|
|
226
|
+
if (entry.type !== "CLOSED-CAPTIONS") return null;
|
|
227
|
+
const instreamId = entry.attributes["INSTREAM-ID"];
|
|
228
|
+
if (instreamId === void 0 || !/^CC[1-4]$/.test(instreamId)) return null;
|
|
229
|
+
const characteristics = characteristicsOf(entry);
|
|
230
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
231
|
+
id: `${entry.groupId}:${entry.name}`,
|
|
232
|
+
contentType: "text",
|
|
233
|
+
mimeType: "application/cea-608",
|
|
234
|
+
protection: null
|
|
235
|
+
}, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), {}, { role: "caption" }, characteristics.length > 0 ? { characteristics } : {}), {}, {
|
|
236
|
+
instreamId,
|
|
237
|
+
renditions: []
|
|
238
|
+
});
|
|
239
|
+
}
|
|
214
240
|
/**
|
|
215
241
|
* The rendition fields a tag with a URI attribute declares: the Roku
|
|
216
242
|
* EXT-X-IMAGE-STREAM-INF and the RFC 8216 §4.3.4.3 EXT-X-I-FRAME-STREAM-INF.
|
|
@@ -464,16 +490,22 @@ function parse(text, baseUrl) {
|
|
|
464
490
|
}
|
|
465
491
|
for (const entry of mediaEntries) {
|
|
466
492
|
var _variants$find;
|
|
493
|
+
const caption = captionTrack(entry);
|
|
494
|
+
if (caption !== null) {
|
|
495
|
+
tracks.push(caption);
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
467
498
|
const contentType = mediaContentType(entry.type);
|
|
468
499
|
if (contentType === null || entry.uri === null) continue;
|
|
469
500
|
const { audio } = splitCodecs((_variants$find = variants.find((v) => v.attributes.AUDIO === entry.groupId)) === null || _variants$find === void 0 ? void 0 : _variants$find.attributes.CODECS);
|
|
470
501
|
const mimeType = contentType === "audio" ? "audio/mp4" : "text/vtt";
|
|
471
|
-
|
|
502
|
+
const characteristics = characteristicsOf(entry);
|
|
503
|
+
tracks.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
472
504
|
id: `${entry.groupId}:${entry.name}`,
|
|
473
505
|
contentType,
|
|
474
506
|
mimeType,
|
|
475
507
|
protection: sessionProtection
|
|
476
|
-
}, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), entry.attributes.DEFAULT === "YES" ? { role: "main" } : { role: "alternate" }), {}, { renditions: [{
|
|
508
|
+
}, entry.attributes.LANGUAGE !== void 0 ? { lang: entry.attributes.LANGUAGE } : {}), entry.attributes.DEFAULT === "YES" ? { role: "main" } : { role: "alternate" }), characteristics.length > 0 ? { characteristics } : {}), contentType === "text" && entry.attributes.FORCED === "YES" ? { forced: true } : {}), {}, { renditions: [{
|
|
477
509
|
id: `${entry.groupId}:${entry.name}`,
|
|
478
510
|
bitrate: 0,
|
|
479
511
|
codecs: contentType === "audio" ? audio : null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { isTrick } from "../../kernel/presentation.js";
|
|
3
3
|
import { withDeadGroups } from "../../kernel/rendition-select.js";
|
|
4
4
|
//#region src/protocols/hls-cmaf/unavailable.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
import { findRendition } from "../../kernel/presentation.js";
|
|
4
4
|
import { activeRenditions } from "../../kernel/rendition-select.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled } from "../../kernel/effects.js";
|
|
3
3
|
import { findRendition, isTrick } from "../../kernel/presentation.js";
|
|
4
4
|
import { canSwitchTo } from "../../kernel/rendition-select.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled } from "../../kernel/effects.js";
|
|
3
3
|
//#region src/stages/abr-persist/index.ts
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findRendition } from "../../kernel/presentation.js";
|
|
2
|
-
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.
|
|
2
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/asyncToGenerator.js";
|
|
3
3
|
//#region src/stages/aes-128/index.ts
|
|
4
4
|
/**
|
|
5
5
|
* aes-128 as a stage: full-segment AES-CBC decryption for HLS EXT-X-KEY
|
|
@@ -14,21 +14,28 @@ import { groupOf } from "../../kernel/rendition-select.js";
|
|
|
14
14
|
* that group — preferring the current language so a group switch does not
|
|
15
15
|
* silently change languages.
|
|
16
16
|
*
|
|
17
|
-
* A user
|
|
18
|
-
* group switch, so `alt-audio` never fights
|
|
17
|
+
* A user choice is remembered as its language and its characteristics, and
|
|
18
|
+
* re-applied on top of every group switch, so `alt-audio` never fights
|
|
19
|
+
* `engine.tracks.select`: an audio description track chosen in one group
|
|
20
|
+
* stays an audio description track in the next, not the regular track in
|
|
21
|
+
* the same language.
|
|
19
22
|
*/
|
|
20
|
-
const INITIAL = {
|
|
23
|
+
const INITIAL = {
|
|
24
|
+
preferredLang: null,
|
|
25
|
+
preferredCharacteristics: []
|
|
26
|
+
};
|
|
21
27
|
/** Audio tracks with their group parsed from the `group:name` id convention. */
|
|
22
28
|
function audioTracks(kernel) {
|
|
23
29
|
var _kernel$presentation$, _kernel$presentation;
|
|
24
30
|
const out = [];
|
|
25
31
|
for (const period of (_kernel$presentation$ = (_kernel$presentation = kernel.presentation) === null || _kernel$presentation === void 0 ? void 0 : _kernel$presentation.periods) !== null && _kernel$presentation$ !== void 0 ? _kernel$presentation$ : []) for (const track of period.tracks) {
|
|
26
|
-
var _track$lang;
|
|
32
|
+
var _track$lang, _track$characteristic;
|
|
27
33
|
if (track.contentType !== "audio") continue;
|
|
28
34
|
out.push({
|
|
29
35
|
id: track.id,
|
|
30
36
|
group: groupOf(track.id),
|
|
31
37
|
lang: (_track$lang = track.lang) !== null && _track$lang !== void 0 ? _track$lang : null,
|
|
38
|
+
characteristics: (_track$characteristic = track.characteristics) !== null && _track$characteristic !== void 0 ? _track$characteristic : [],
|
|
32
39
|
isDefault: track.role === "main"
|
|
33
40
|
});
|
|
34
41
|
}
|
|
@@ -42,12 +49,21 @@ function requiredGroup(kernel) {
|
|
|
42
49
|
const coupling = (_kernel$presentation2 = kernel.presentation) === null || _kernel$presentation2 === void 0 ? void 0 : _kernel$presentation2.couplings.find((c) => c.renditionId === activeVideo);
|
|
43
50
|
return (_coupling$requires$au = coupling === null || coupling === void 0 ? void 0 : coupling.requires.audio) !== null && _coupling$requires$au !== void 0 ? _coupling$requires$au : null;
|
|
44
51
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
function sameTags(a, b) {
|
|
53
|
+
return a.length === b.length && a.every((tag) => b.includes(tag));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Picks the audio track in `group`: the preferred language with the
|
|
57
|
+
* preferred characteristics, then the language alone, then default, then
|
|
58
|
+
* first.
|
|
59
|
+
*/
|
|
60
|
+
function pickInGroup(tracks, group, preference) {
|
|
61
|
+
var _ref, _ref2, _sameLang$find;
|
|
48
62
|
const inGroup = tracks.filter((t) => t.group === group);
|
|
49
63
|
if (inGroup.length === 0) return null;
|
|
50
|
-
|
|
64
|
+
const { preferredLang, preferredCharacteristics } = preference;
|
|
65
|
+
const sameLang = preferredLang !== null ? inGroup.filter((t) => t.lang === preferredLang) : [];
|
|
66
|
+
return (_ref = (_ref2 = (_sameLang$find = sameLang.find((t) => sameTags(t.characteristics, preferredCharacteristics))) !== null && _sameLang$find !== void 0 ? _sameLang$find : sameLang[0]) !== null && _ref2 !== void 0 ? _ref2 : inGroup.find((t) => t.isDefault)) !== null && _ref !== void 0 ? _ref : inGroup[0];
|
|
51
67
|
}
|
|
52
68
|
/** Loops a command back into the bus through a zero-delay schedule effect. */
|
|
53
69
|
function select(trackId) {
|
|
@@ -61,9 +77,13 @@ const reduceAltAudio = (slice, msg, kernel) => {
|
|
|
61
77
|
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
62
78
|
if (msg.type === "LOAD" || msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
|
|
63
79
|
if (msg.type === "SELECT_TRACK") {
|
|
80
|
+
var _chosen$lang;
|
|
64
81
|
const chosen = audioTracks(kernel).find((t) => t.id === msg.trackId);
|
|
65
|
-
if (
|
|
66
|
-
return [
|
|
82
|
+
if (chosen === void 0) return [state, []];
|
|
83
|
+
return [{
|
|
84
|
+
preferredLang: (_chosen$lang = chosen.lang) !== null && _chosen$lang !== void 0 ? _chosen$lang : state.preferredLang,
|
|
85
|
+
preferredCharacteristics: chosen.characteristics
|
|
86
|
+
}, []];
|
|
67
87
|
}
|
|
68
88
|
if (msg.type === "MANIFEST_LOADED" || msg.type === "PLAYLIST_REFRESHED" || msg.type === "SEGMENT_LOADED") {
|
|
69
89
|
const group = requiredGroup(kernel);
|
|
@@ -72,7 +92,7 @@ const reduceAltAudio = (slice, msg, kernel) => {
|
|
|
72
92
|
const tracks = audioTracks(kernel);
|
|
73
93
|
const activeInfo = tracks.find((t) => t.id === active);
|
|
74
94
|
if (activeInfo !== void 0 && activeInfo.group === group) return [state, []];
|
|
75
|
-
const target = pickInGroup(tracks, group, state
|
|
95
|
+
const target = pickInGroup(tracks, group, state);
|
|
76
96
|
if (target === void 0 || target === null || target.id === active) return [state, []];
|
|
77
97
|
return [state, [select(target.id)]];
|
|
78
98
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { findTrackSite } from "../../kernel/presentation.js";
|
|
3
|
-
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.
|
|
3
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/asyncToGenerator.js";
|
|
4
4
|
import { chaptersFromInput, parseAppleChapters, parseChapterTrack } from "./parse.js";
|
|
5
5
|
//#region src/stages/chapters/index.ts
|
|
6
6
|
/**
|
|
@@ -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.151.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _objectWithoutProperties from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectWithoutProperties.js";
|
|
3
3
|
import { parseVtt } from "../../containers/webvtt.js";
|
|
4
4
|
import { resolveUrl } from "../../kernel/url.js";
|
|
5
5
|
//#region src/stages/chapters/parse.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
//#region src/stages/content-steering/index.ts
|
|
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.151.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/asyncToGenerator.js";
|
|
3
3
|
import { bytesToBase64 } from "../../kernel/base64.js";
|
|
4
4
|
import { keySystemHandlers, normalizeSystemId } from "../drm-shared.js";
|
|
5
5
|
//#region src/stages/eme-core/index.ts
|
|
@@ -16,6 +16,12 @@ import { keySystemHandlers, normalizeSystemId } from "../drm-shared.js";
|
|
|
16
16
|
* 'error' event that reaches engine.error) and exposes engine.drm; the
|
|
17
17
|
* trace stays complete for everything the reducer can see.
|
|
18
18
|
*
|
|
19
|
+
* An expired key renews: eme-core opens a new session with the same init
|
|
20
|
+
* data, which fetches a fresh license, and closes the old session once the
|
|
21
|
+
* new key is usable. Renewal waits for playback, so a paused or suspended
|
|
22
|
+
* element makes no license request. A renewal message the CDM sends on
|
|
23
|
+
* its own (Widevine `license-renewal`) takes the normal license path.
|
|
24
|
+
*
|
|
19
25
|
* ClearKey is built in — it is the only key system testable headlessly.
|
|
20
26
|
* Widevine, PlayReady, and FairPlay arrive as handlers eme-cenc and
|
|
21
27
|
* eme-fairplay register through drm-shared.
|
|
@@ -77,9 +83,10 @@ function emeCore(options = {}) {
|
|
|
77
83
|
let keySystem = null;
|
|
78
84
|
let handler = null;
|
|
79
85
|
let licenseUrl = (_options$licenseUrl = options.licenseUrl) !== null && _options$licenseUrl !== void 0 ? _options$licenseUrl : null;
|
|
80
|
-
const sessionsByKey = /* @__PURE__ */ new Map();
|
|
81
86
|
const statuses = /* @__PURE__ */ new Map();
|
|
82
87
|
const initDataSeen = /* @__PURE__ */ new Set();
|
|
88
|
+
const open = /* @__PURE__ */ new Map();
|
|
89
|
+
const pendingRenewals = /* @__PURE__ */ new Set();
|
|
83
90
|
let disposed = false;
|
|
84
91
|
ctx.registerNamespace("drm", {
|
|
85
92
|
get keySystem() {
|
|
@@ -154,6 +161,22 @@ function emeCore(options = {}) {
|
|
|
154
161
|
const fingerprint = `${initDataType}:${bytesToBase64(new Uint8Array(initData), true)}`;
|
|
155
162
|
if (initDataSeen.has(fingerprint)) return;
|
|
156
163
|
initDataSeen.add(fingerprint);
|
|
164
|
+
yield startSession({
|
|
165
|
+
initDataType,
|
|
166
|
+
initData,
|
|
167
|
+
replaces: null,
|
|
168
|
+
usable: false
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
return _openSession.apply(this, arguments);
|
|
172
|
+
}
|
|
173
|
+
/** Creates a session and sends its license request. */
|
|
174
|
+
function startSession(_x4) {
|
|
175
|
+
return _startSession.apply(this, arguments);
|
|
176
|
+
}
|
|
177
|
+
function _startSession() {
|
|
178
|
+
_startSession = _asyncToGenerator(function* (record) {
|
|
179
|
+
if (mediaKeys === null || disposed) return;
|
|
157
180
|
let session;
|
|
158
181
|
try {
|
|
159
182
|
session = mediaKeys.createSession("temporary");
|
|
@@ -161,19 +184,43 @@ function emeCore(options = {}) {
|
|
|
161
184
|
fail("DRM_SESSION_FAILED", false, err);
|
|
162
185
|
return;
|
|
163
186
|
}
|
|
187
|
+
open.set(session, record);
|
|
164
188
|
session.addEventListener("message", (event) => {
|
|
165
189
|
onMessage(session, event);
|
|
166
190
|
});
|
|
167
191
|
session.addEventListener("keystatuseschange", () => onKeyStatus(session));
|
|
168
192
|
try {
|
|
169
|
-
yield session.generateRequest(initDataType, initData);
|
|
193
|
+
yield session.generateRequest(record.initDataType, record.initData);
|
|
170
194
|
} catch (err) {
|
|
171
195
|
fail("DRM_INIT_DATA_INVALID", false, err);
|
|
172
196
|
}
|
|
173
197
|
});
|
|
174
|
-
return
|
|
198
|
+
return _startSession.apply(this, arguments);
|
|
175
199
|
}
|
|
176
|
-
|
|
200
|
+
/** Replaces an expired session with a new one on the same init data. */
|
|
201
|
+
function renew(session) {
|
|
202
|
+
const record = open.get(session);
|
|
203
|
+
if (record === void 0 || record.renewing === true) return;
|
|
204
|
+
record.renewing = true;
|
|
205
|
+
const keyIds = [];
|
|
206
|
+
session.keyStatuses.forEach((_status, keyIdBuffer) => {
|
|
207
|
+
keyIds.push(bytesToBase64(new Uint8Array(keyIdBuffer), true));
|
|
208
|
+
});
|
|
209
|
+
ctx.emit("drm:renewing", { keyIds });
|
|
210
|
+
startSession({
|
|
211
|
+
initDataType: record.initDataType,
|
|
212
|
+
initData: record.initData,
|
|
213
|
+
replaces: session,
|
|
214
|
+
usable: false
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/** Closes a session and forgets it; its later events are ignored. */
|
|
218
|
+
function retire(session) {
|
|
219
|
+
open.delete(session);
|
|
220
|
+
pendingRenewals.delete(session);
|
|
221
|
+
session.close().catch(() => {});
|
|
222
|
+
}
|
|
223
|
+
function onMessage(_x5, _x6) {
|
|
177
224
|
return _onMessage.apply(this, arguments);
|
|
178
225
|
}
|
|
179
226
|
function _onMessage() {
|
|
@@ -213,19 +260,40 @@ function emeCore(options = {}) {
|
|
|
213
260
|
return _onMessage.apply(this, arguments);
|
|
214
261
|
}
|
|
215
262
|
function onKeyStatus(session) {
|
|
263
|
+
const record = open.get(session);
|
|
264
|
+
if (record === void 0) return;
|
|
265
|
+
let expired = false;
|
|
216
266
|
session.keyStatuses.forEach((status, keyIdBuffer) => {
|
|
217
267
|
const keyId = bytesToBase64(new Uint8Array(keyIdBuffer), true);
|
|
218
268
|
statuses.set(keyId, status);
|
|
219
|
-
sessionsByKey.set(keyId, session);
|
|
220
269
|
ctx.emit("drm:keystatus", {
|
|
221
270
|
keyId,
|
|
222
271
|
status
|
|
223
272
|
});
|
|
224
|
-
if (status === "
|
|
273
|
+
if (status === "usable") record.usable = true;
|
|
274
|
+
else if (status === "expired") expired = true;
|
|
225
275
|
else if (status === "output-restricted") fail("DRM_OUTPUT_RESTRICTED", false);
|
|
226
276
|
else if (status === "internal-error") fail("DRM_KEY_STATUS_ERROR", false);
|
|
227
277
|
});
|
|
278
|
+
if (record.usable && record.replaces !== null) {
|
|
279
|
+
retire(record.replaces);
|
|
280
|
+
record.replaces = null;
|
|
281
|
+
}
|
|
282
|
+
if (!expired) return;
|
|
283
|
+
if (!record.usable) {
|
|
284
|
+
fail("DRM_KEY_EXPIRED", true);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (element.paused) pendingRenewals.add(session);
|
|
288
|
+
else renew(session);
|
|
228
289
|
}
|
|
290
|
+
const onPlay = () => {
|
|
291
|
+
for (const session of [...pendingRenewals]) {
|
|
292
|
+
pendingRenewals.delete(session);
|
|
293
|
+
renew(session);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
element.addEventListener("play", onPlay);
|
|
229
297
|
const onEncrypted = (event) => {
|
|
230
298
|
const e = event;
|
|
231
299
|
if (e.initData === null) return;
|
|
@@ -244,8 +312,9 @@ function emeCore(options = {}) {
|
|
|
244
312
|
return () => {
|
|
245
313
|
disposed = true;
|
|
246
314
|
element.removeEventListener("encrypted", onEncrypted);
|
|
315
|
+
element.removeEventListener("play", onPlay);
|
|
247
316
|
offManifest();
|
|
248
|
-
for (const session of
|
|
317
|
+
for (const session of [...open.keys()]) retire(session);
|
|
249
318
|
if (mediaKeys !== null) element.setMediaKeys(null).catch(() => {});
|
|
250
319
|
};
|
|
251
320
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { base64ToBytes, bytesToBase64 } from "../../kernel/base64.js";
|
|
3
3
|
import { registerKeySystem } from "../drm-shared.js";
|
|
4
4
|
//#region src/stages/eme-fairplay/index.ts
|