mattebox 0.18.0 → 0.19.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-ll.min.js +3 -3
- package/dist/cdn/mattebox.dash.min.js +2 -2
- package/dist/cdn/mattebox.dual-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ll.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-ll.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 +5 -5
- package/dist/containers/projection.d.ts +36 -0
- package/dist/containers/projection.d.ts.map +1 -0
- package/dist/containers/projection.js +68 -0
- package/dist/containers/projection.js.map +1 -0
- package/dist/containers/webm/cues.d.ts +59 -0
- package/dist/containers/webm/cues.d.ts.map +1 -0
- package/dist/containers/webm/cues.js +218 -0
- package/dist/containers/webm/cues.js.map +1 -0
- package/dist/containers/webm/index.d.ts +36 -0
- package/dist/containers/webm/index.d.ts.map +1 -0
- package/dist/containers/webm/index.js +271 -0
- package/dist/containers/webm/index.js.map +1 -0
- package/dist/es2015/containers/projection.js +68 -0
- package/dist/es2015/containers/webm/cues.js +197 -0
- package/dist/es2015/containers/webm/index.js +258 -0
- package/dist/es2015/kernel/reducer.js +31 -2
- package/dist/es2015/presets/full/index.js +6 -3
- package/dist/es2015/presets/tiers/dash-ll.js +2 -1
- package/dist/es2015/presets/tiers/dash.js +7 -2
- package/dist/es2015/protocols/dash-cmaf/index.js +11 -5
- package/dist/es2015/protocols/dash-cmaf/parse.js +40 -12
- package/dist/es2015/protocols/dash-live/index.js +7 -4
- package/dist/es2015/protocols/dash-ll/index.js +3 -2
- package/dist/es2015/stages/projection/index.js +41 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +44 -1
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/presets/full/index.d.ts.map +1 -1
- package/dist/presets/full/index.js +5 -2
- package/dist/presets/full/index.js.map +1 -1
- package/dist/presets/tiers/dash-ll.d.ts.map +1 -1
- package/dist/presets/tiers/dash-ll.js +2 -1
- package/dist/presets/tiers/dash-ll.js.map +1 -1
- package/dist/presets/tiers/dash.d.ts +7 -1
- package/dist/presets/tiers/dash.d.ts.map +1 -1
- package/dist/presets/tiers/dash.js +3 -2
- package/dist/presets/tiers/dash.js.map +1 -1
- package/dist/protocols/dash-cmaf/index.d.ts +8 -3
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +12 -5
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts +6 -1
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +54 -7
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/dash-live/index.d.ts +6 -3
- package/dist/protocols/dash-live/index.d.ts.map +1 -1
- package/dist/protocols/dash-live/index.js +7 -4
- package/dist/protocols/dash-live/index.js.map +1 -1
- package/dist/protocols/dash-ll/index.d.ts.map +1 -1
- package/dist/protocols/dash-ll/index.js +3 -2
- package/dist/protocols/dash-ll/index.js.map +1 -1
- package/dist/stages/eme-wiseplay/index.d.ts +3 -2
- package/dist/stages/eme-wiseplay/index.d.ts.map +1 -1
- package/dist/stages/eme-wiseplay/index.js.map +1 -1
- package/dist/stages/projection/index.d.ts +3 -0
- package/dist/stages/projection/index.d.ts.map +1 -0
- package/dist/stages/projection/index.js +45 -0
- package/dist/stages/projection/index.js.map +1 -0
- package/dist/types/ir.d.ts +7 -1
- 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 +13 -1
- package/dist/types/messages.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads how a 360° video's picture maps onto a sphere from the boxes of its
|
|
3
|
+
* init segment, for a stream whose manifest does not say. Two box families
|
|
4
|
+
* carry it inside the video's sample entry, and they share the fourccs
|
|
5
|
+
* `proj` and `equi` with different contents, so each is read under its own
|
|
6
|
+
* parent:
|
|
7
|
+
*
|
|
8
|
+
* - Apple's Video Extended Usage, `vexu/proj/prji` (Apple, "Stereo Video
|
|
9
|
+
* ISOBMFF Extensions"):
|
|
10
|
+
* https://developer.apple.com/av-foundation/Stereo-Video-ISOBMFF-Extensions.pdf
|
|
11
|
+
* `prji` is a FullBox holding `projection_kind`, a fourcc: `equi` for 360°,
|
|
12
|
+
* `hequ` for 180°. These are the kinds HLS `REQ-VIDEO-LAYOUT` names
|
|
13
|
+
* `PROJ-EQUI` and `PROJ-HEQU`. Shaka Player reads the same boxes:
|
|
14
|
+
* https://github.com/shaka-project/shaka-player/blob/v5.3.6/lib/media/streaming_engine.js#L2845-L2910
|
|
15
|
+
* - Google's Spherical Video V2, `sv3d/proj/equi`:
|
|
16
|
+
* https://github.com/google/spatial-media/blob/2308497c39bb604a7c3ba56ac17e302f2b1b6a96/docs/spherical-video-v2-rfc.md
|
|
17
|
+
* `equi` is a FullBox with four 0.32 fixed-point bounds, the share of the
|
|
18
|
+
* sphere cropped from the top, bottom, left and right. Media3 reads
|
|
19
|
+
* `sv3d` in the same place:
|
|
20
|
+
* https://github.com/androidx/media/blob/1.11.1/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/BoxParser.java
|
|
21
|
+
*
|
|
22
|
+
* A cube map, a mesh, a fisheye, or bounds that crop anything else read as
|
|
23
|
+
* no projection: the engine names only what a player can draw from these
|
|
24
|
+
* two kinds.
|
|
25
|
+
*/
|
|
26
|
+
import type { Rendition } from '../types/ir.js';
|
|
27
|
+
/** A projection the IR names. */
|
|
28
|
+
type Projection = NonNullable<Rendition['projection']>;
|
|
29
|
+
/**
|
|
30
|
+
* The projection the first video track's sample entry states, or null for
|
|
31
|
+
* a flat picture, another projection, or bytes that are not an init
|
|
32
|
+
* segment. Never throws.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readProjection(init: Uint8Array): Projection | null;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/containers/projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAWhD,iCAAiC;AACjC,KAAK,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;AAwCvD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAiBlE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { findBox, findBoxes, fourcc, fullBox, sampleEntries, VISUAL_ENTRY_HEADER, viewOf, } from './mp4-box/index.js';
|
|
2
|
+
/** A quarter of the sphere's width in 0.32 fixed point: 0.25 × 2³². */
|
|
3
|
+
const QUARTER = 0x40000000;
|
|
4
|
+
/** The box `type` under `parent`, or null. Each step searches one level of children. */
|
|
5
|
+
function under(parent, ...path) {
|
|
6
|
+
let at = parent;
|
|
7
|
+
for (const type of path) {
|
|
8
|
+
if (at === null)
|
|
9
|
+
return null;
|
|
10
|
+
at = findBox(at, type)?.payload ?? null;
|
|
11
|
+
}
|
|
12
|
+
return at;
|
|
13
|
+
}
|
|
14
|
+
/** Apple's `prji` kind: `equi` is 360°, `hequ` 180°. */
|
|
15
|
+
function apple(children) {
|
|
16
|
+
const prji = under(children, 'vexu', 'proj', 'prji');
|
|
17
|
+
const body = prji === null ? undefined : fullBox(prji)?.body;
|
|
18
|
+
if (body === undefined || body.byteLength < 4)
|
|
19
|
+
return null;
|
|
20
|
+
const kind = fourcc(body, 0);
|
|
21
|
+
return kind === 'equi' ? 'equirectangular' : kind === 'hequ' ? 'half-equirectangular' : null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Google's `equi` bounds. Nothing cropped is the whole sphere. A quarter
|
|
25
|
+
* cropped from the left and from the right leaves the front half, 180°
|
|
26
|
+
* wide and full height: what a half-equirectangular picture covers.
|
|
27
|
+
*/
|
|
28
|
+
function google(children) {
|
|
29
|
+
const equi = under(children, 'sv3d', 'proj', 'equi');
|
|
30
|
+
const body = equi === null ? undefined : fullBox(equi)?.body;
|
|
31
|
+
if (body === undefined || body.byteLength < 16)
|
|
32
|
+
return null;
|
|
33
|
+
const view = viewOf(body);
|
|
34
|
+
const [top, bottom, left, right] = [0, 4, 8, 12].map((at) => view.getUint32(at));
|
|
35
|
+
if (top !== 0 || bottom !== 0)
|
|
36
|
+
return null;
|
|
37
|
+
if (left === 0 && right === 0)
|
|
38
|
+
return 'equirectangular';
|
|
39
|
+
return left === QUARTER && right === QUARTER ? 'half-equirectangular' : null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The projection the first video track's sample entry states, or null for
|
|
43
|
+
* a flat picture, another projection, or bytes that are not an init
|
|
44
|
+
* segment. Never throws.
|
|
45
|
+
*/
|
|
46
|
+
export function readProjection(init) {
|
|
47
|
+
for (const trak of findBoxes(init, 'moov/trak')) {
|
|
48
|
+
// ISO/IEC 14496-12 §8.4.3: hdlr is a FullBox, then pre_defined(32), then handler_type.
|
|
49
|
+
const hdlr = findBox(trak.payload, 'mdia/hdlr');
|
|
50
|
+
const handler = hdlr === null ? undefined : fullBox(hdlr.payload)?.body;
|
|
51
|
+
if (handler === undefined || handler.byteLength < 8 || fourcc(handler, 4) !== 'vide')
|
|
52
|
+
continue;
|
|
53
|
+
const stsd = findBox(trak.payload, 'mdia/minf/stbl/stsd');
|
|
54
|
+
if (stsd === null)
|
|
55
|
+
continue;
|
|
56
|
+
for (const entry of sampleEntries(stsd.payload)) {
|
|
57
|
+
if (entry.body.byteLength < VISUAL_ENTRY_HEADER)
|
|
58
|
+
continue;
|
|
59
|
+
// An encrypted entry (encv) keeps these boxes too, beside its sinf.
|
|
60
|
+
const children = entry.body.subarray(VISUAL_ENTRY_HEADER);
|
|
61
|
+
const found = apple(children) ?? google(children);
|
|
62
|
+
if (found !== null)
|
|
63
|
+
return found;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../src/containers/projection.ts"],"names":[],"mappings":"AA0BA,OAAO,EACL,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,MAAM,GACP,MAAM,oBAAoB,CAAC;AAK5B,uEAAuE;AACvE,MAAM,OAAO,GAAG,UAAU,CAAC;AAE3B,wFAAwF;AACxF,SAAS,KAAK,CAAC,MAAkB,EAAE,GAAG,IAAc;IAClD,IAAI,EAAE,GAAsB,MAAM,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,EAAE,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC7B,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,IAAI,IAAI,CAAC;IAC1C,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,wDAAwD;AACxD,SAAS,KAAK,CAAC,QAAoB;IACjC,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C,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the two parts of a WebM file that a DASH `SegmentBase` names: the
|
|
3
|
+
* initialization range (the EBML header, the Segment header, Info and
|
|
4
|
+
* Tracks) and the index range (the Cues element). Together they give the
|
|
5
|
+
* byte range and the time of each Cluster, which is one media segment.
|
|
6
|
+
*
|
|
7
|
+
* The arithmetic follows Shaka Player's WebM segment index parser
|
|
8
|
+
* (https://github.com/shaka-project/shaka-player/blob/main/lib/dash/webm_segment_index_parser.js).
|
|
9
|
+
* Element IDs and types come from the Matroska specification, RFC 9559
|
|
10
|
+
* (https://www.rfc-editor.org/rfc/rfc9559), and the encoding from EBML,
|
|
11
|
+
* RFC 8794 (https://www.rfc-editor.org/rfc/rfc8794).
|
|
12
|
+
*
|
|
13
|
+
* Plain functions over `Uint8Array`. Malformed input never throws and never
|
|
14
|
+
* loops: a reader returns null instead.
|
|
15
|
+
*/
|
|
16
|
+
import type { ByteRange, Segment, SidxSegments } from '../../types/ir.js';
|
|
17
|
+
/** What the initialization range says about the file. Plain numbers, so it can sit in state. */
|
|
18
|
+
export interface WebmInit {
|
|
19
|
+
/** Offset of the Segment's data from the start of the init bytes: Segment Position 0, RFC 9559 §16. */
|
|
20
|
+
readonly segmentStart: number;
|
|
21
|
+
/** The Segment's declared data size in bytes, or null when it is unknown (RFC 8794 §6.2). */
|
|
22
|
+
readonly segmentSize: number | null;
|
|
23
|
+
/** Seconds per Segment Tick: TimestampScale nanoseconds over 1e9. */
|
|
24
|
+
readonly tickSeconds: number;
|
|
25
|
+
/** The Info Duration in seconds, or null when the file states none. */
|
|
26
|
+
readonly duration: number | null;
|
|
27
|
+
}
|
|
28
|
+
/** One CuePoint: its time in Segment Ticks and its Cluster's Segment Position. */
|
|
29
|
+
export interface CuePoint {
|
|
30
|
+
readonly time: number;
|
|
31
|
+
readonly position: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Reads the initialization range: the EBML header, then the Segment
|
|
35
|
+
* header and its Info. Null when the bytes do not start with an EBML
|
|
36
|
+
* header followed by a Segment, or hold no Info.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readInit(bytes: Uint8Array): WebmInit | null;
|
|
39
|
+
/**
|
|
40
|
+
* Reads the Cues element at the start of the index range. Each CuePoint
|
|
41
|
+
* gives its CueTime and the CueClusterPosition of its first
|
|
42
|
+
* CueTrackPositions. A DASH Representation carries one track, so the
|
|
43
|
+
* first is the one. Null when the bytes do not start with Cues.
|
|
44
|
+
*/
|
|
45
|
+
export declare function readCues(bytes: Uint8Array): CuePoint[] | null;
|
|
46
|
+
/**
|
|
47
|
+
* Turns the cue points into byte-range segments, one per Cluster. A
|
|
48
|
+
* segment runs from its Cluster to the byte before the next one. The last
|
|
49
|
+
* ends where the Cues start when they follow it, else at the end of the
|
|
50
|
+
* Segment when its size is known, else at the end of the file (an
|
|
51
|
+
* open-ended range). Its duration runs to the Info Duration, as in Shaka
|
|
52
|
+
* Player; without a Duration the index cannot place the last segment and
|
|
53
|
+
* no segment is returned.
|
|
54
|
+
*
|
|
55
|
+
* Several CuePoints can name one Cluster (one per track, or a
|
|
56
|
+
* CueRelativePosition inside it): only the first of them opens a segment.
|
|
57
|
+
*/
|
|
58
|
+
export declare function cuesToSegments(init: WebmInit, initRange: ByteRange, points: readonly CuePoint[], addressing: SidxSegments): Segment[];
|
|
59
|
+
//# sourceMappingURL=cues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cues.d.ts","sourceRoot":"","sources":["../../../src/containers/webm/cues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA0B1E,gGAAgG;AAChG,MAAM,WAAW,QAAQ;IACvB,uGAAuG;IACvG,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,6FAA6F;IAC7F,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,kFAAkF;AAClF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAuFD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAoB3D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,EAAE,GAAG,IAAI,CAqB7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,UAAU,EAAE,YAAY,GACvB,OAAO,EAAE,CAmCX"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/** EBML header, RFC 8794 §11.2.1. */
|
|
2
|
+
const EBML_ID = 0x1a45dfa3;
|
|
3
|
+
/** Segment, RFC 9559 §5.1. */
|
|
4
|
+
const SEGMENT_ID = 0x18538067;
|
|
5
|
+
/** Info, RFC 9559 §5.1.2. */
|
|
6
|
+
const INFO_ID = 0x1549a966;
|
|
7
|
+
/** TimestampScale (formerly TimecodeScale), RFC 9559 §5.1.2.9. */
|
|
8
|
+
const TIMESTAMP_SCALE_ID = 0x2ad7b1;
|
|
9
|
+
/** Duration, RFC 9559 §5.1.2.10. */
|
|
10
|
+
const DURATION_ID = 0x4489;
|
|
11
|
+
/** Cues, RFC 9559 §5.1.5. */
|
|
12
|
+
const CUES_ID = 0x1c53bb6b;
|
|
13
|
+
/** CuePoint, RFC 9559 §5.1.5.1. */
|
|
14
|
+
const CUE_POINT_ID = 0xbb;
|
|
15
|
+
/** CueTime, RFC 9559 §5.1.5.1.1. */
|
|
16
|
+
const CUE_TIME_ID = 0xb3;
|
|
17
|
+
/** CueTrackPositions, RFC 9559 §5.1.5.1.2. */
|
|
18
|
+
const CUE_TRACK_POSITIONS_ID = 0xb7;
|
|
19
|
+
/** CueClusterPosition, RFC 9559 §5.1.5.1.2.2. */
|
|
20
|
+
const CUE_CLUSTER_POSITION_ID = 0xf1;
|
|
21
|
+
/** The TimestampScale default: one tick is a millisecond. RFC 9559 §5.1.2.9. */
|
|
22
|
+
const DEFAULT_TIMESTAMP_SCALE = 1_000_000;
|
|
23
|
+
/**
|
|
24
|
+
* Reads a variable-size integer at `at`, RFC 8794 §4. `marker` keeps the
|
|
25
|
+
* length marker bit, as an Element ID does (§5); without it the value is
|
|
26
|
+
* a data size. Returns null when the bytes end early or the first byte is
|
|
27
|
+
* zero, which no valid VINT starts with.
|
|
28
|
+
*/
|
|
29
|
+
function readVint(bytes, at, marker) {
|
|
30
|
+
const first = bytes[at];
|
|
31
|
+
if (first === undefined || first === 0)
|
|
32
|
+
return null;
|
|
33
|
+
let length = 1;
|
|
34
|
+
while ((first & (0x80 >> (length - 1))) === 0)
|
|
35
|
+
length += 1;
|
|
36
|
+
if (at + length > bytes.byteLength)
|
|
37
|
+
return null;
|
|
38
|
+
let value = marker ? first : first & (0xff >> length);
|
|
39
|
+
// All value bits set is the reserved unknown size, RFC 8794 §6.2.
|
|
40
|
+
let unknown = value === 0xff >> length;
|
|
41
|
+
for (let i = 1; i < length; i += 1) {
|
|
42
|
+
const byte = bytes[at + i];
|
|
43
|
+
if (byte !== 0xff)
|
|
44
|
+
unknown = false;
|
|
45
|
+
// Multiplication, not a shift: a value can pass 32 bits.
|
|
46
|
+
value = value * 256 + byte;
|
|
47
|
+
}
|
|
48
|
+
return { value, length, unknown: !marker && unknown };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Reads the element header at `at`. Its data is clamped to `limit`, so a
|
|
52
|
+
* Segment whose data runs past the bytes fetched still reads as far as
|
|
53
|
+
* they go, as Shaka's EBML parser reads a partial element. An unknown
|
|
54
|
+
* size extends to `limit`.
|
|
55
|
+
*/
|
|
56
|
+
function readElement(bytes, at, limit) {
|
|
57
|
+
const id = readVint(bytes, at, true);
|
|
58
|
+
if (id === null)
|
|
59
|
+
return null;
|
|
60
|
+
const size = readVint(bytes, at + id.length, false);
|
|
61
|
+
if (size === null)
|
|
62
|
+
return null;
|
|
63
|
+
const start = at + id.length + size.length;
|
|
64
|
+
if (start > limit)
|
|
65
|
+
return null;
|
|
66
|
+
const declared = size.unknown ? null : size.value;
|
|
67
|
+
const end = declared === null ? limit : Math.min(limit, start + declared);
|
|
68
|
+
return { id: id.value, start, end, size: declared };
|
|
69
|
+
}
|
|
70
|
+
/** The child elements between `start` and `end`, in order. Stops at the first header it cannot read. */
|
|
71
|
+
function childrenOf(bytes, start, end) {
|
|
72
|
+
const found = [];
|
|
73
|
+
let at = start;
|
|
74
|
+
while (at < end) {
|
|
75
|
+
const element = readElement(bytes, at, end);
|
|
76
|
+
// An empty element still advances by its header, so the loop ends.
|
|
77
|
+
if (element === null)
|
|
78
|
+
break;
|
|
79
|
+
found.push(element);
|
|
80
|
+
at = element.end;
|
|
81
|
+
}
|
|
82
|
+
return found;
|
|
83
|
+
}
|
|
84
|
+
/** An unsigned integer element, RFC 8794 §7.2: big-endian, zero to eight bytes. */
|
|
85
|
+
function readUint(bytes, element) {
|
|
86
|
+
let value = 0;
|
|
87
|
+
for (let i = element.start; i < element.end; i += 1)
|
|
88
|
+
value = value * 256 + bytes[i];
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
/** A float element, RFC 8794 §7.3: zero, four or eight bytes, big-endian IEEE 754. */
|
|
92
|
+
function readFloat(bytes, element) {
|
|
93
|
+
const length = element.end - element.start;
|
|
94
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset + element.start, length);
|
|
95
|
+
if (length === 4)
|
|
96
|
+
return view.getFloat32(0);
|
|
97
|
+
if (length === 8)
|
|
98
|
+
return view.getFloat64(0);
|
|
99
|
+
return length === 0 ? 0 : null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Reads the initialization range: the EBML header, then the Segment
|
|
103
|
+
* header and its Info. Null when the bytes do not start with an EBML
|
|
104
|
+
* header followed by a Segment, or hold no Info.
|
|
105
|
+
*/
|
|
106
|
+
export function readInit(bytes) {
|
|
107
|
+
const header = readElement(bytes, 0, bytes.byteLength);
|
|
108
|
+
if (header === null || header.id !== EBML_ID)
|
|
109
|
+
return null;
|
|
110
|
+
const segment = readElement(bytes, header.end, bytes.byteLength);
|
|
111
|
+
if (segment === null || segment.id !== SEGMENT_ID)
|
|
112
|
+
return null;
|
|
113
|
+
const info = childrenOf(bytes, segment.start, segment.end).find((e) => e.id === INFO_ID);
|
|
114
|
+
if (info === undefined)
|
|
115
|
+
return null;
|
|
116
|
+
let scale = DEFAULT_TIMESTAMP_SCALE;
|
|
117
|
+
let ticks = null;
|
|
118
|
+
for (const element of childrenOf(bytes, info.start, info.end)) {
|
|
119
|
+
if (element.id === TIMESTAMP_SCALE_ID)
|
|
120
|
+
scale = readUint(bytes, element) || scale;
|
|
121
|
+
else if (element.id === DURATION_ID)
|
|
122
|
+
ticks = readFloat(bytes, element);
|
|
123
|
+
}
|
|
124
|
+
const tickSeconds = scale / 1e9;
|
|
125
|
+
return {
|
|
126
|
+
segmentStart: segment.start,
|
|
127
|
+
segmentSize: segment.size,
|
|
128
|
+
tickSeconds,
|
|
129
|
+
duration: ticks === null ? null : ticks * tickSeconds,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Reads the Cues element at the start of the index range. Each CuePoint
|
|
134
|
+
* gives its CueTime and the CueClusterPosition of its first
|
|
135
|
+
* CueTrackPositions. A DASH Representation carries one track, so the
|
|
136
|
+
* first is the one. Null when the bytes do not start with Cues.
|
|
137
|
+
*/
|
|
138
|
+
export function readCues(bytes) {
|
|
139
|
+
const cues = readElement(bytes, 0, bytes.byteLength);
|
|
140
|
+
if (cues === null || cues.id !== CUES_ID)
|
|
141
|
+
return null;
|
|
142
|
+
const points = [];
|
|
143
|
+
for (const point of childrenOf(bytes, cues.start, cues.end)) {
|
|
144
|
+
if (point.id !== CUE_POINT_ID)
|
|
145
|
+
continue;
|
|
146
|
+
let time = null;
|
|
147
|
+
let position = null;
|
|
148
|
+
for (const element of childrenOf(bytes, point.start, point.end)) {
|
|
149
|
+
if (element.id === CUE_TIME_ID) {
|
|
150
|
+
time = readUint(bytes, element);
|
|
151
|
+
}
|
|
152
|
+
else if (element.id === CUE_TRACK_POSITIONS_ID && position === null) {
|
|
153
|
+
const cluster = childrenOf(bytes, element.start, element.end).find((e) => e.id === CUE_CLUSTER_POSITION_ID);
|
|
154
|
+
if (cluster !== undefined)
|
|
155
|
+
position = readUint(bytes, cluster);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (time !== null && position !== null)
|
|
159
|
+
points.push({ time, position });
|
|
160
|
+
}
|
|
161
|
+
return points;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Turns the cue points into byte-range segments, one per Cluster. A
|
|
165
|
+
* segment runs from its Cluster to the byte before the next one. The last
|
|
166
|
+
* ends where the Cues start when they follow it, else at the end of the
|
|
167
|
+
* Segment when its size is known, else at the end of the file (an
|
|
168
|
+
* open-ended range). Its duration runs to the Info Duration, as in Shaka
|
|
169
|
+
* Player; without a Duration the index cannot place the last segment and
|
|
170
|
+
* no segment is returned.
|
|
171
|
+
*
|
|
172
|
+
* Several CuePoints can name one Cluster (one per track, or a
|
|
173
|
+
* CueRelativePosition inside it): only the first of them opens a segment.
|
|
174
|
+
*/
|
|
175
|
+
export function cuesToSegments(init, initRange, points, addressing) {
|
|
176
|
+
if (init.duration === null)
|
|
177
|
+
return [];
|
|
178
|
+
// CueClusterPosition counts from the Segment's data, RFC 9559 §16.
|
|
179
|
+
const base = initRange.start + init.segmentStart;
|
|
180
|
+
const clusters = [];
|
|
181
|
+
for (const point of points) {
|
|
182
|
+
const previous = clusters[clusters.length - 1];
|
|
183
|
+
if (previous !== undefined && point.position <= previous.position)
|
|
184
|
+
continue;
|
|
185
|
+
clusters.push(point);
|
|
186
|
+
}
|
|
187
|
+
const pto = addressing.presentationTimeOffset ?? 0;
|
|
188
|
+
const indexStart = addressing.indexRange.start;
|
|
189
|
+
const segments = [];
|
|
190
|
+
for (let i = 0; i < clusters.length; i += 1) {
|
|
191
|
+
const point = clusters[i];
|
|
192
|
+
const next = clusters[i + 1];
|
|
193
|
+
const start = point.time * init.tickSeconds;
|
|
194
|
+
const end = next === undefined ? init.duration : next.time * init.tickSeconds;
|
|
195
|
+
const byteStart = base + point.position;
|
|
196
|
+
let byteEnd;
|
|
197
|
+
if (next !== undefined)
|
|
198
|
+
byteEnd = base + next.position - 1;
|
|
199
|
+
else if (indexStart > byteStart)
|
|
200
|
+
byteEnd = indexStart - 1;
|
|
201
|
+
else if (init.segmentSize !== null)
|
|
202
|
+
byteEnd = base + init.segmentSize - 1;
|
|
203
|
+
// RFC 9110 §14.1.2: `bytes=N-` reads to the end. The transport sends that for Infinity.
|
|
204
|
+
else
|
|
205
|
+
byteEnd = Number.POSITIVE_INFINITY;
|
|
206
|
+
if (end <= start)
|
|
207
|
+
continue;
|
|
208
|
+
segments.push({
|
|
209
|
+
seq: segments.length,
|
|
210
|
+
start: start - pto,
|
|
211
|
+
duration: end - start,
|
|
212
|
+
url: addressing.url,
|
|
213
|
+
byteRange: { start: byteStart, end: byteEnd },
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return segments;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=cues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cues.js","sourceRoot":"","sources":["../../../src/containers/webm/c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uePoint, type WebmInit } from './cues.js';
|
|
4
|
+
/** Options of the `webm` stage. */
|
|
5
|
+
export interface WebmOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Seconds before a WebM index that failed or held no segment is tried
|
|
8
|
+
* again; its rendition sits out meanwhile. Infinity keeps it out until
|
|
9
|
+
* the next load. Defaults to 15.
|
|
10
|
+
*/
|
|
11
|
+
readonly unavailableRetrySeconds?: number;
|
|
12
|
+
}
|
|
13
|
+
/** The stage's state slice. Plain data, so a trace replays it. */
|
|
14
|
+
interface WebmSlice {
|
|
15
|
+
/** Fetches in flight, token to renditionId. */
|
|
16
|
+
readonly pending: Readonly<Record<string, string>>;
|
|
17
|
+
/** Renditions asked for and not merged yet, so none is fetched twice. */
|
|
18
|
+
readonly asked: Readonly<Record<string, true>>;
|
|
19
|
+
/** Parsed initialization ranges waiting for their Cues. */
|
|
20
|
+
readonly inits: Readonly<Record<string, WebmInit>>;
|
|
21
|
+
/** Parsed Cues waiting for their initialization range. */
|
|
22
|
+
readonly cues: Readonly<Record<string, readonly CuePoint[]>>;
|
|
23
|
+
/** Renditions whose index failed. Not fetched again until their retry. */
|
|
24
|
+
readonly failed: Readonly<Record<string, true>>;
|
|
25
|
+
/** The selection last looked at, so the index choice runs only when it changes. */
|
|
26
|
+
readonly seen: string;
|
|
27
|
+
}
|
|
28
|
+
/** The slice reducer. Pure: it reads bytes from facts and answers with effects. */
|
|
29
|
+
export declare const createReduceWebm: (retryMs: number) => SliceReducer<WebmSlice>;
|
|
30
|
+
/**
|
|
31
|
+
* The stage factory. Add it beside a DASH adapter:
|
|
32
|
+
* `mattebox({ stages: [dashCmaf(), webm()] })`.
|
|
33
|
+
*/
|
|
34
|
+
export default function webm(options?: WebmOptions): Stage;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/containers/webm/index.ts"],"names":[],"mapp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