mattebox 0.3.0 → 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/kernel/reducer.js +3 -2
- package/dist/es2015/presets/full/index.js +4 -9
- package/dist/es2015/presets/tiers.js +18 -11
- 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/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +9 -6
- package/dist/kernel/reducer.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/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/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/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,C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EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,IAAI,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU;YAAE,MAAM;QAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAW,CAAC;QACxC,MAAM,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;QAC5B,MAAM,CAAC,GAAG,OAAO,CAAC,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;
|
|
@@ -538,8 +538,9 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
538
538
|
if (buffer !== void 0) {
|
|
539
539
|
var _targetSite$rendition;
|
|
540
540
|
const targetSite = findRendition(state.presentation, matched.renditionId);
|
|
541
|
-
const
|
|
542
|
-
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));
|
|
543
544
|
const nextBuffers = new Map(state.buffers);
|
|
544
545
|
if (targetCodecs !== buffer.codecs && familyChanged) effects.push({
|
|
545
546
|
kind: "changeType",
|
|
@@ -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
|
}
|
|
@@ -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
|
};
|
|
@@ -1,78 +1,208 @@
|
|
|
1
1
|
import { captionsWanted, deliverCaptions } from "../../containers/captions.js";
|
|
2
|
-
import { findBox, parseTfdt } from "../../containers/mp4-box/index.js";
|
|
2
|
+
import { findBox, findBoxes, fullBox, parseTfdt } from "../../containers/mp4-box/index.js";
|
|
3
3
|
import { ccTriplesFromSei } from "../../containers/sei.js";
|
|
4
4
|
//#region src/stages/nal-scan/index.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* from the fragment's tfdt and trun, and delivers the caption bytes to the
|
|
10
|
-
* same seam ts-transmux uses. It imports mp4-box for the box reads and the
|
|
11
|
-
* shared SEI decoder; it never imports text-cea608.
|
|
12
|
-
*
|
|
13
|
-
* It is not cheap and does not pretend to be: per entanglement #1 it loads
|
|
14
|
-
* only when a caption stage needs an fMP4 SEI source, and it does zero work
|
|
15
|
-
* when no caption consumer is registered.
|
|
6
|
+
* After aes-128 decryption (1), before ts-transmux (100). An MPEG-TS segment
|
|
7
|
+
* has no moof at this point and is skipped, because the transmuxer delivers
|
|
8
|
+
* its own captions.
|
|
16
9
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
10
|
+
const SCAN_ORDER = 50;
|
|
11
|
+
/** SampleEntry (8 bytes) plus VisualSampleEntry (70 bytes). ISO/IEC 14496-12 §12.1.3. */
|
|
12
|
+
const VISUAL_ENTRY_HEADER = 78;
|
|
13
|
+
/** H.264 SEI. ITU-T H.264 Table 7-1. */
|
|
14
|
+
const AVC_SEI = 6;
|
|
15
|
+
/** HEVC prefix and suffix SEI. ITU-T H.265 Table 7-1. */
|
|
16
|
+
const HEVC_PREFIX_SEI = 39;
|
|
17
|
+
const HEVC_SUFFIX_SEI = 40;
|
|
18
|
+
const TFHD_BASE_DATA_OFFSET = 1;
|
|
19
|
+
const TFHD_SAMPLE_DESCRIPTION = 2;
|
|
20
|
+
const TFHD_DEFAULT_DURATION = 8;
|
|
21
|
+
const TFHD_DEFAULT_SIZE = 16;
|
|
22
|
+
const TFHD_DEFAULT_BASE_IS_MOOF = 131072;
|
|
23
|
+
const TRUN_DATA_OFFSET = 1;
|
|
24
|
+
const TRUN_FIRST_SAMPLE_FLAGS = 4;
|
|
25
|
+
const TRUN_DURATION = 256;
|
|
26
|
+
const TRUN_SIZE = 512;
|
|
27
|
+
const TRUN_FLAGS = 1024;
|
|
28
|
+
const TRUN_CTS = 2048;
|
|
29
|
+
function view(bytes) {
|
|
30
|
+
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
31
|
+
}
|
|
32
|
+
function fourcc(bytes, at) {
|
|
33
|
+
var _bytes$at, _bytes, _bytes2, _bytes3;
|
|
34
|
+
return String.fromCharCode((_bytes$at = bytes[at]) !== null && _bytes$at !== void 0 ? _bytes$at : 0, (_bytes = bytes[at + 1]) !== null && _bytes !== void 0 ? _bytes : 0, (_bytes2 = bytes[at + 2]) !== null && _bytes2 !== void 0 ? _bytes2 : 0, (_bytes3 = bytes[at + 3]) !== null && _bytes3 !== void 0 ? _bytes3 : 0);
|
|
35
|
+
}
|
|
36
|
+
/** The format and body of the first stsd sample entry. */
|
|
37
|
+
function sampleEntry(stsd) {
|
|
38
|
+
var _fullBox;
|
|
39
|
+
const body = (_fullBox = fullBox(stsd)) === null || _fullBox === void 0 ? void 0 : _fullBox.body;
|
|
40
|
+
if (body === void 0 || body.byteLength < 12) return null;
|
|
41
|
+
const size = view(body).getUint32(4);
|
|
42
|
+
if (size < 8 || 4 + size > body.byteLength) return null;
|
|
43
|
+
return {
|
|
44
|
+
format: fourcc(body, 8),
|
|
45
|
+
body: body.subarray(12, 4 + size)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** The H.264 and HEVC tracks of an init segment, by track ID. Other codecs carry no SEI. */
|
|
49
|
+
function videoTracks(init) {
|
|
50
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
51
|
+
const mvex = findBox(init, "moov/mvex");
|
|
52
|
+
for (const trex of mvex === null ? [] : findBoxes(mvex.payload, "trex")) {
|
|
53
|
+
var _fullBox2;
|
|
54
|
+
const body = (_fullBox2 = fullBox(trex.payload)) === null || _fullBox2 === void 0 ? void 0 : _fullBox2.body;
|
|
55
|
+
if (body === void 0 || body.byteLength < 16) continue;
|
|
56
|
+
const v = view(body);
|
|
57
|
+
defaults.set(v.getUint32(0), {
|
|
58
|
+
duration: v.getUint32(8),
|
|
59
|
+
size: v.getUint32(12)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const tracks = /* @__PURE__ */ new Map();
|
|
63
|
+
for (const trak of findBoxes(init, "moov/trak")) {
|
|
64
|
+
var _fallback$duration, _fallback$size;
|
|
65
|
+
const tkhd = findBox(trak.payload, "tkhd");
|
|
66
|
+
const mdhd = findBox(trak.payload, "mdia/mdhd");
|
|
67
|
+
const stsd = findBox(trak.payload, "mdia/minf/stbl/stsd");
|
|
68
|
+
const entry = stsd === null ? null : sampleEntry(stsd.payload);
|
|
69
|
+
if (tkhd === null || mdhd === null || entry === null) continue;
|
|
70
|
+
if (entry.body.byteLength < VISUAL_ENTRY_HEADER) continue;
|
|
71
|
+
const children = entry.body.subarray(VISUAL_ENTRY_HEADER);
|
|
72
|
+
let format = entry.format;
|
|
73
|
+
if (format === "encv") {
|
|
74
|
+
const sinf = findBox(children, "sinf");
|
|
75
|
+
const frma = sinf === null ? null : findBox(sinf.payload, "frma");
|
|
76
|
+
if (frma === null || frma.payload.byteLength < 4) continue;
|
|
77
|
+
format = fourcc(frma.payload, 0);
|
|
44
78
|
}
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
79
|
+
const hevc = format === "hvc1" || format === "hev1";
|
|
80
|
+
if (!hevc && format !== "avc1" && format !== "avc3") continue;
|
|
81
|
+
const config = findBox(children, hevc ? "hvcC" : "avcC");
|
|
82
|
+
const lengthAt = hevc ? 21 : 4;
|
|
83
|
+
const lengthSize = config !== null && config.payload.byteLength > lengthAt ? (config.payload[lengthAt] & 3) + 1 : 4;
|
|
84
|
+
const trackAt = tkhd.payload[0] === 1 ? 20 : 12;
|
|
85
|
+
const scaleAt = mdhd.payload[0] === 1 ? 20 : 12;
|
|
86
|
+
if (tkhd.payload.byteLength < trackAt + 4 || mdhd.payload.byteLength < scaleAt + 4) continue;
|
|
87
|
+
const trackId = view(tkhd.payload).getUint32(trackAt);
|
|
88
|
+
const timescale = view(mdhd.payload).getUint32(scaleAt);
|
|
89
|
+
if (timescale === 0) continue;
|
|
90
|
+
const fallback = defaults.get(trackId);
|
|
91
|
+
tracks.set(trackId, {
|
|
92
|
+
timescale,
|
|
93
|
+
hevc,
|
|
94
|
+
lengthSize,
|
|
95
|
+
defaultDuration: (_fallback$duration = fallback === null || fallback === void 0 ? void 0 : fallback.duration) !== null && _fallback$duration !== void 0 ? _fallback$duration : 0,
|
|
96
|
+
defaultSize: (_fallback$size = fallback === null || fallback === void 0 ? void 0 : fallback.size) !== null && _fallback$size !== void 0 ? _fallback$size : 0
|
|
51
97
|
});
|
|
52
98
|
}
|
|
53
|
-
return
|
|
54
|
-
samples,
|
|
55
|
-
defaultDuration: DEFAULT_TIMESCALE / 30
|
|
56
|
-
};
|
|
99
|
+
return tracks;
|
|
57
100
|
}
|
|
58
|
-
/**
|
|
59
|
-
function
|
|
60
|
-
const view = new DataView(sample.buffer, sample.byteOffset, sample.byteLength);
|
|
61
|
-
const sei = [];
|
|
101
|
+
/** Appends the SEI NAL units of one sample to `out`. */
|
|
102
|
+
function seiUnits(sample, track, out) {
|
|
62
103
|
let offset = 0;
|
|
63
|
-
while (offset +
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
offset +=
|
|
67
|
-
if (length === 0 || offset + length > sample.byteLength)
|
|
68
|
-
const
|
|
69
|
-
|
|
104
|
+
while (offset + track.lengthSize <= sample.byteLength) {
|
|
105
|
+
let length = 0;
|
|
106
|
+
for (let i = 0; i < track.lengthSize; i += 1) length = length * 256 + sample[offset + i];
|
|
107
|
+
offset += track.lengthSize;
|
|
108
|
+
if (length === 0 || offset + length > sample.byteLength) return;
|
|
109
|
+
const header = sample[offset];
|
|
110
|
+
const hevcType = header >> 1 & 63;
|
|
111
|
+
if (track.hevc ? hevcType === HEVC_PREFIX_SEI || hevcType === HEVC_SUFFIX_SEI : (header & 31) === AVC_SEI) out.push(sample.subarray(offset, offset + length));
|
|
70
112
|
offset += length;
|
|
71
113
|
}
|
|
72
|
-
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The caption packets of one media segment. A sample's time is the segment's
|
|
117
|
+
* presentation start plus its presentation offset from the first decode time
|
|
118
|
+
* of its track in the segment, the timeline cmaf-timing and the transmuxer
|
|
119
|
+
* produce. The tfdt itself may carry a broadcast clock.
|
|
120
|
+
*/
|
|
121
|
+
function captionPackets(data, tracks, start) {
|
|
122
|
+
const packets = [];
|
|
123
|
+
const firstDecode = /* @__PURE__ */ new Map();
|
|
124
|
+
const nextDecode = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const moof of findBoxes(data, "moof")) {
|
|
126
|
+
let previousEnd = moof.start;
|
|
127
|
+
for (const traf of findBoxes(moof.payload, "traf")) {
|
|
128
|
+
var _track$defaultDuratio, _track$defaultSize, _parseTfdt, _ref, _firstDecode$get;
|
|
129
|
+
const tfhdBox = findBox(traf.payload, "tfhd");
|
|
130
|
+
const tfhd = tfhdBox === null ? null : fullBox(tfhdBox.payload);
|
|
131
|
+
if (tfhd === null || tfhd.body.byteLength < 4) continue;
|
|
132
|
+
const tfhdView = view(tfhd.body);
|
|
133
|
+
const trackId = tfhdView.getUint32(0);
|
|
134
|
+
const track = tracks.get(trackId);
|
|
135
|
+
let at = 4;
|
|
136
|
+
let base = tfhd.flags & TFHD_DEFAULT_BASE_IS_MOOF ? moof.start : previousEnd;
|
|
137
|
+
if (tfhd.flags & TFHD_BASE_DATA_OFFSET) {
|
|
138
|
+
base = Number(tfhdView.getBigUint64(at));
|
|
139
|
+
at += 8;
|
|
140
|
+
}
|
|
141
|
+
if (tfhd.flags & TFHD_SAMPLE_DESCRIPTION) at += 4;
|
|
142
|
+
let defaultDuration = (_track$defaultDuratio = track === null || track === void 0 ? void 0 : track.defaultDuration) !== null && _track$defaultDuratio !== void 0 ? _track$defaultDuratio : 0;
|
|
143
|
+
let defaultSize = (_track$defaultSize = track === null || track === void 0 ? void 0 : track.defaultSize) !== null && _track$defaultSize !== void 0 ? _track$defaultSize : 0;
|
|
144
|
+
if (tfhd.flags & TFHD_DEFAULT_DURATION) {
|
|
145
|
+
defaultDuration = tfhdView.getUint32(at);
|
|
146
|
+
at += 4;
|
|
147
|
+
}
|
|
148
|
+
if (tfhd.flags & TFHD_DEFAULT_SIZE) defaultSize = tfhdView.getUint32(at);
|
|
149
|
+
const tfdt = findBox(traf.payload, "tfdt");
|
|
150
|
+
const tfdtTime = tfdt === null ? void 0 : (_parseTfdt = parseTfdt(tfdt.payload)) === null || _parseTfdt === void 0 ? void 0 : _parseTfdt.baseMediaDecodeTime;
|
|
151
|
+
let decode = (_ref = tfdtTime !== null && tfdtTime !== void 0 ? tfdtTime : nextDecode.get(trackId)) !== null && _ref !== void 0 ? _ref : 0;
|
|
152
|
+
const first = (_firstDecode$get = firstDecode.get(trackId)) !== null && _firstDecode$get !== void 0 ? _firstDecode$get : decode;
|
|
153
|
+
firstDecode.set(trackId, first);
|
|
154
|
+
let cursor = base;
|
|
155
|
+
for (const trunBox of findBoxes(traf.payload, "trun")) {
|
|
156
|
+
const trun = fullBox(trunBox.payload);
|
|
157
|
+
if (trun === null || trun.body.byteLength < 4) continue;
|
|
158
|
+
const trunView = view(trun.body);
|
|
159
|
+
const count = trunView.getUint32(0);
|
|
160
|
+
let p = 4;
|
|
161
|
+
if (trun.flags & TRUN_DATA_OFFSET) {
|
|
162
|
+
cursor = base + trunView.getInt32(p);
|
|
163
|
+
p += 4;
|
|
164
|
+
}
|
|
165
|
+
if (trun.flags & TRUN_FIRST_SAMPLE_FLAGS) p += 4;
|
|
166
|
+
const samples = Math.min(count, data.byteLength);
|
|
167
|
+
for (let i = 0; i < samples; i += 1) {
|
|
168
|
+
let duration = defaultDuration;
|
|
169
|
+
let size = defaultSize;
|
|
170
|
+
let cts = 0;
|
|
171
|
+
if (trun.flags & TRUN_DURATION) {
|
|
172
|
+
duration = trunView.getUint32(p);
|
|
173
|
+
p += 4;
|
|
174
|
+
}
|
|
175
|
+
if (trun.flags & TRUN_SIZE) {
|
|
176
|
+
size = trunView.getUint32(p);
|
|
177
|
+
p += 4;
|
|
178
|
+
}
|
|
179
|
+
if (trun.flags & TRUN_FLAGS) p += 4;
|
|
180
|
+
if (trun.flags & TRUN_CTS) {
|
|
181
|
+
cts = trun.version === 1 ? trunView.getInt32(p) : trunView.getUint32(p);
|
|
182
|
+
p += 4;
|
|
183
|
+
}
|
|
184
|
+
if (track !== void 0) {
|
|
185
|
+
const units = [];
|
|
186
|
+
seiUnits(data.subarray(cursor, cursor + size), track, units);
|
|
187
|
+
const triples = [];
|
|
188
|
+
for (const unit of units) triples.push(...ccTriplesFromSei(unit, track.hevc ? 2 : 1));
|
|
189
|
+
if (triples.length > 0) packets.push({
|
|
190
|
+
time: start + (decode - first + cts) / track.timescale,
|
|
191
|
+
triples
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
cursor += size;
|
|
195
|
+
decode += duration;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
previousEnd = cursor;
|
|
199
|
+
nextDecode.set(trackId, decode);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return packets;
|
|
73
203
|
}
|
|
74
204
|
function nalScan() {
|
|
75
|
-
let
|
|
205
|
+
let tracks = /* @__PURE__ */ new Map();
|
|
76
206
|
return {
|
|
77
207
|
name: "nal-scan",
|
|
78
208
|
provides: ["nal-scan"],
|
|
@@ -80,37 +210,12 @@ function nalScan() {
|
|
|
80
210
|
ctx.registerTransform({
|
|
81
211
|
name: "nal-scan",
|
|
82
212
|
order: SCAN_ORDER,
|
|
83
|
-
transform(data,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
timescale = view.getUint8(0) === 1 ? view.getUint32(20) : view.getUint32(12);
|
|
90
|
-
}
|
|
91
|
-
const mdat = findBox(data, "mdat");
|
|
92
|
-
const trunBox = findBox(data, "moof/traf/trun");
|
|
93
|
-
if (mdat === null || trunBox === null) return data;
|
|
94
|
-
const tfdtBox = findBox(data, "moof/traf/tfdt");
|
|
95
|
-
const base = tfdtBox !== null ? (_parseTfdt$baseMediaD = (_parseTfdt = parseTfdt(tfdtBox.payload)) === null || _parseTfdt === void 0 ? void 0 : _parseTfdt.baseMediaDecodeTime) !== null && _parseTfdt$baseMediaD !== void 0 ? _parseTfdt$baseMediaD : 0 : 0;
|
|
96
|
-
const { samples } = parseTrun(trunBox.payload);
|
|
97
|
-
const packets = [];
|
|
98
|
-
let cursor = 0;
|
|
99
|
-
let decodeTime = base;
|
|
100
|
-
for (const sample of samples) {
|
|
101
|
-
const bytes = mdat.payload.subarray(cursor, cursor + sample.size);
|
|
102
|
-
cursor += sample.size;
|
|
103
|
-
const time = decodeTime / (timescale || DEFAULT_TIMESCALE);
|
|
104
|
-
decodeTime += sample.duration;
|
|
105
|
-
for (const sei of seiOfSample(bytes)) {
|
|
106
|
-
const triples = ccTriplesFromSei(sei);
|
|
107
|
-
if (triples.length > 0) packets.push({
|
|
108
|
-
time,
|
|
109
|
-
triples
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
deliverCaptions(packets);
|
|
213
|
+
transform(data, meta) {
|
|
214
|
+
if (!captionsWanted() || meta.contentType !== "video") return data;
|
|
215
|
+
try {
|
|
216
|
+
if (findBox(data, "moov") !== null) tracks = videoTracks(data);
|
|
217
|
+
if (tracks.size > 0) deliverCaptions(captionPackets(data, tracks, meta.start));
|
|
218
|
+
} catch (_unused) {}
|
|
114
219
|
return data;
|
|
115
220
|
}
|
|
116
221
|
});
|
|
@@ -19,7 +19,7 @@ function textCea608() {
|
|
|
19
19
|
contentType: "text",
|
|
20
20
|
mimeType: "application/cea-608"
|
|
21
21
|
}],
|
|
22
|
-
requires: [["
|
|
22
|
+
requires: [["nal-scan", "ts-transmux"]],
|
|
23
23
|
install(ctx) {
|
|
24
24
|
const decoder = new Cea608Decoder();
|
|
25
25
|
const element = ctx.element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/kernel/reducer.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAgB,OAAO,EAAgB,MAAM,sBAAsB,CAAC;AAEzF,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAStE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAqBnC,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAE1E;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,WAAW,CAgBxE;
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/kernel/reducer.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAgB,OAAO,EAAgB,MAAM,sBAAsB,CAAC;AAEzF,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAStE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAqBnC,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAE1E;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,WAAW,CAgBxE;AA6lCD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9C;AAwRD,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,MAAM,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,EAClD,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAC9B,KAAK,GAAE,YAAiB,GACvB,OAAO,CAkET"}
|
package/dist/kernel/reducer.js
CHANGED
|
@@ -666,14 +666,17 @@ function reduceFact(state, msg, cfg, hooks) {
|
|
|
666
666
|
// practice, and forcing changeType there breaks WebKit. The
|
|
667
667
|
// reducer emits the mechanism; codec-switch's policy governed
|
|
668
668
|
// whether abr proposed the switch at all.
|
|
669
|
+
// A rendition that declares no codecs (a bare media playlist)
|
|
670
|
+
// cannot name a family change. The buffer keeps the type it was
|
|
671
|
+
// opened with, which codec-probe may have read from the init;
|
|
672
|
+
// a changeType back to the bare type fails in Chrome and WebKit.
|
|
669
673
|
const targetSite = findRendition(state.presentation, matched.renditionId);
|
|
670
|
-
const
|
|
674
|
+
const declared = targetSite?.rendition.codecs ?? null;
|
|
675
|
+
const targetCodecs = targetSite === null || declared === null
|
|
671
676
|
? buffer.codecs
|
|
672
|
-
: targetSite.rendition.codecs
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const familyChanged = codecFamily(targetSite?.rendition.codecs ?? null) !==
|
|
676
|
-
codecFamily(bufferCodecString(buffer.codecs));
|
|
677
|
+
: `${targetSite.rendition.mimeType}; codecs="${declared}"`;
|
|
678
|
+
const familyChanged = declared !== null &&
|
|
679
|
+
codecFamily(declared) !== codecFamily(bufferCodecString(buffer.codecs));
|
|
677
680
|
const nextBuffers = new Map(state.buffers);
|
|
678
681
|
if (targetCodecs !== buffer.codecs && familyChanged) {
|
|
679
682
|
effects.push({ kind: 'changeType', sbId: matched.sbId, codecs: targetCodecs });
|