mattebox 0.6.0 → 0.7.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 +3 -6
- package/dist/containers/adts.d.ts +10 -0
- package/dist/containers/adts.d.ts.map +1 -1
- package/dist/containers/adts.js +27 -7
- package/dist/containers/adts.js.map +1 -1
- package/dist/containers/codec-probe/index.d.ts +0 -6
- package/dist/containers/codec-probe/index.d.ts.map +1 -1
- package/dist/containers/codec-probe/index.js +14 -23
- package/dist/containers/codec-probe/index.js.map +1 -1
- package/dist/containers/fmp4/fit.d.ts +26 -0
- package/dist/containers/fmp4/fit.d.ts.map +1 -0
- package/dist/containers/fmp4/fit.js +49 -0
- package/dist/containers/fmp4/fit.js.map +1 -0
- package/dist/containers/fmp4/writer.d.ts +7 -0
- package/dist/containers/fmp4/writer.d.ts.map +1 -1
- package/dist/containers/fmp4/writer.js +9 -1
- package/dist/containers/fmp4/writer.js.map +1 -1
- package/dist/containers/id3.d.ts.map +1 -1
- package/dist/containers/id3.js +2 -1
- package/dist/containers/id3.js.map +1 -1
- package/dist/containers/mp4-box/index.d.ts +75 -7
- package/dist/containers/mp4-box/index.d.ts.map +1 -1
- package/dist/containers/mp4-box/index.js +225 -49
- package/dist/containers/mp4-box/index.js.map +1 -1
- package/dist/containers/packed-audio/index.d.ts.map +1 -1
- package/dist/containers/packed-audio/index.js +9 -27
- package/dist/containers/packed-audio/index.js.map +1 -1
- package/dist/containers/sei.d.ts +5 -0
- package/dist/containers/sei.d.ts.map +1 -1
- package/dist/containers/sei.js +5 -2
- package/dist/containers/sei.js.map +1 -1
- package/dist/containers/ts-transmux/demux.d.ts +7 -1
- package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
- package/dist/containers/ts-transmux/demux.js +38 -17
- package/dist/containers/ts-transmux/demux.js.map +1 -1
- package/dist/containers/ts-transmux/h264.d.ts.map +1 -1
- package/dist/containers/ts-transmux/h264.js +1 -17
- package/dist/containers/ts-transmux/h264.js.map +1 -1
- package/dist/containers/ts-transmux/index.d.ts.map +1 -1
- package/dist/containers/ts-transmux/index.js +11 -2
- package/dist/containers/ts-transmux/index.js.map +1 -1
- package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
- package/dist/containers/ts-transmux/transmux.js +6 -36
- package/dist/containers/ts-transmux/transmux.js.map +1 -1
- package/dist/{stages/text-webvtt/parse.d.ts → containers/webvtt.d.ts} +4 -3
- package/dist/containers/webvtt.d.ts.map +1 -0
- package/dist/{stages/text-webvtt/parse.js → containers/webvtt.js} +1 -1
- package/dist/containers/webvtt.js.map +1 -0
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/containers/adts.js +28 -8
- package/dist/es2015/containers/codec-probe/index.js +17 -26
- package/dist/es2015/containers/fmp4/fit.js +46 -0
- package/dist/es2015/containers/fmp4/writer.js +9 -1
- package/dist/es2015/containers/id3.js +3 -3
- package/dist/es2015/containers/mp4-box/index.js +224 -39
- package/dist/es2015/containers/packed-audio/index.js +6 -33
- package/dist/es2015/containers/sei.js +6 -3
- package/dist/es2015/containers/ts-transmux/demux.js +41 -22
- package/dist/es2015/containers/ts-transmux/h264.js +2 -18
- package/dist/es2015/containers/ts-transmux/index.js +9 -9
- package/dist/es2015/containers/ts-transmux/transmux.js +8 -39
- package/dist/es2015/{stages/text-webvtt/parse.js → containers/webvtt.js} +2 -2
- package/dist/es2015/index.js +40 -42
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/base64.js +25 -0
- package/dist/es2015/kernel/context.js +7 -0
- package/dist/es2015/kernel/effects.js +21 -1
- package/dist/es2015/kernel/loader.js +5 -4
- package/dist/es2015/kernel/mime.js +5 -1
- package/dist/es2015/kernel/mse.js +27 -71
- package/dist/es2015/kernel/prepare.js +77 -0
- package/dist/es2015/kernel/presentation.js +24 -0
- package/dist/es2015/kernel/reducer.js +279 -124
- package/dist/es2015/kernel/refresh.js +35 -0
- package/dist/es2015/kernel/rendition-select.js +109 -4
- package/dist/es2015/kernel/scheduler.js +23 -5
- package/dist/es2015/kernel/sinks/text-track-sink.js +27 -26
- package/dist/es2015/kernel/timeline.js +22 -1
- package/dist/es2015/kernel/trace.js +1 -1
- package/dist/es2015/kernel/track-registry.js +10 -2
- package/dist/es2015/kernel/transport.js +4 -4
- package/dist/es2015/kernel/url.js +12 -0
- package/dist/es2015/presets/define.js +2 -2
- package/dist/es2015/presets/full/index.js +9 -3
- package/dist/es2015/presets/tiers.js +7 -6
- package/dist/es2015/protocols/adapter-shared.js +28 -0
- package/dist/es2015/protocols/dash-cmaf/index.js +132 -88
- package/dist/es2015/protocols/dash-cmaf/parse.js +62 -64
- package/dist/es2015/protocols/dash-live/index.js +62 -37
- package/dist/es2015/protocols/dimensions.js +15 -0
- package/dist/es2015/protocols/hls-cmaf/index.js +108 -95
- package/dist/es2015/protocols/hls-cmaf/lexer.js +3 -0
- package/dist/es2015/protocols/hls-cmaf/parse.js +167 -56
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +43 -0
- package/dist/es2015/protocols/hls-live/index.js +187 -109
- package/dist/es2015/stages/abr/index.js +8 -11
- package/dist/es2015/stages/abr-persist/index.js +18 -11
- package/dist/es2015/stages/aes-128/index.js +15 -8
- package/dist/es2015/stages/alt-audio/index.js +25 -13
- package/dist/es2015/stages/chapters/index.js +151 -0
- package/dist/es2015/stages/chapters/parse.js +149 -0
- package/dist/es2015/stages/cmaf-timing/index.js +24 -39
- package/dist/es2015/stages/cmcd/index.js +29 -6
- package/dist/es2015/stages/codec-switch/index.js +2 -5
- package/dist/es2015/stages/content-steering/index.js +13 -16
- package/dist/es2015/stages/eme-cenc/index.js +10 -4
- package/dist/es2015/stages/eme-core/index.js +31 -13
- package/dist/es2015/stages/eme-fairplay/index.js +12 -8
- package/dist/es2015/stages/nal-scan/index.js +30 -140
- package/dist/es2015/stages/recovery/index.js +47 -54
- package/dist/es2015/stages/text-cea608/decode.js +1 -1
- package/dist/es2015/stages/text-cea608/index.js +3 -17
- package/dist/es2015/stages/text-webvtt/index.js +1 -1
- package/dist/es2015/stages/text-webvtt-segmented/index.js +15 -8
- package/dist/es2015/stages/thumbnails/index.js +213 -43
- package/dist/es2015/stages/trick-play/index.js +463 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -53
- package/dist/index.js.map +1 -1
- package/dist/kernel/base64.d.ts +9 -0
- package/dist/kernel/base64.d.ts.map +1 -0
- package/dist/kernel/base64.js +26 -0
- package/dist/kernel/base64.js.map +1 -0
- package/dist/kernel/context.d.ts +5 -1
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/context.js +10 -0
- package/dist/kernel/context.js.map +1 -1
- package/dist/kernel/effects.d.ts +9 -1
- package/dist/kernel/effects.d.ts.map +1 -1
- package/dist/kernel/effects.js +12 -0
- package/dist/kernel/effects.js.map +1 -1
- package/dist/kernel/lifecycle.js +1 -1
- package/dist/kernel/lifecycle.js.map +1 -1
- package/dist/kernel/loader.d.ts.map +1 -1
- package/dist/kernel/loader.js +5 -7
- package/dist/kernel/loader.js.map +1 -1
- package/dist/kernel/mime.d.ts +2 -0
- package/dist/kernel/mime.d.ts.map +1 -1
- package/dist/kernel/mime.js +4 -0
- package/dist/kernel/mime.js.map +1 -1
- package/dist/kernel/mse.d.ts +6 -10
- package/dist/kernel/mse.d.ts.map +1 -1
- package/dist/kernel/mse.js +20 -73
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/prepare.d.ts +28 -0
- package/dist/kernel/prepare.d.ts.map +1 -0
- package/dist/kernel/prepare.js +89 -0
- package/dist/kernel/prepare.js.map +1 -0
- package/dist/kernel/presentation.d.ts +20 -0
- package/dist/kernel/presentation.d.ts.map +1 -0
- package/dist/kernel/presentation.js +25 -0
- package/dist/kernel/presentation.js.map +1 -0
- package/dist/kernel/reducer.d.ts +24 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +375 -152
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/refresh.d.ts +14 -0
- package/dist/kernel/refresh.d.ts.map +1 -0
- package/dist/kernel/refresh.js +51 -0
- package/dist/kernel/refresh.js.map +1 -0
- package/dist/kernel/rendition-select.d.ts +38 -5
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +134 -2
- package/dist/kernel/rendition-select.js.map +1 -1
- package/dist/kernel/scheduler.d.ts +18 -3
- package/dist/kernel/scheduler.d.ts.map +1 -1
- package/dist/kernel/scheduler.js +32 -7
- package/dist/kernel/scheduler.js.map +1 -1
- package/dist/kernel/sinks/text-track-sink.d.ts +9 -0
- package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
- package/dist/kernel/sinks/text-track-sink.js +29 -29
- package/dist/kernel/sinks/text-track-sink.js.map +1 -1
- package/dist/kernel/timeline.d.ts +26 -7
- package/dist/kernel/timeline.d.ts.map +1 -1
- package/dist/kernel/timeline.js +21 -7
- package/dist/kernel/timeline.js.map +1 -1
- package/dist/kernel/track-registry.d.ts.map +1 -1
- package/dist/kernel/track-registry.js +17 -1
- package/dist/kernel/track-registry.js.map +1 -1
- package/dist/kernel/transport.d.ts.map +1 -1
- package/dist/kernel/transport.js +1 -0
- package/dist/kernel/transport.js.map +1 -1
- package/dist/kernel/url.d.ts +4 -0
- package/dist/kernel/url.d.ts.map +1 -0
- package/dist/kernel/url.js +11 -0
- package/dist/kernel/url.js.map +1 -0
- package/dist/presets/full/index.d.ts.map +1 -1
- package/dist/presets/full/index.js +8 -2
- package/dist/presets/full/index.js.map +1 -1
- package/dist/presets/tiers.d.ts +7 -6
- package/dist/presets/tiers.d.ts.map +1 -1
- package/dist/presets/tiers.js +7 -6
- package/dist/presets/tiers.js.map +1 -1
- package/dist/protocols/adapter-shared.d.ts +23 -0
- package/dist/protocols/adapter-shared.d.ts.map +1 -0
- package/dist/protocols/adapter-shared.js +23 -0
- package/dist/protocols/adapter-shared.js.map +1 -0
- package/dist/protocols/dash-cmaf/index.d.ts +2 -2
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +150 -97
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts +2 -5
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +46 -39
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/dash-live/index.d.ts.map +1 -1
- package/dist/protocols/dash-live/index.js +67 -25
- package/dist/protocols/dash-live/index.js.map +1 -1
- package/dist/protocols/dimensions.d.ts +8 -0
- package/dist/protocols/dimensions.d.ts.map +1 -0
- package/dist/protocols/dimensions.js +13 -0
- package/dist/protocols/dimensions.js.map +1 -0
- package/dist/protocols/hls-cmaf/index.d.ts +3 -2
- package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/index.js +127 -114
- package/dist/protocols/hls-cmaf/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/lexer.js +3 -0
- package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts +22 -14
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +196 -69
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts +17 -0
- package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -0
- package/dist/protocols/hls-cmaf/unavailable.js +38 -0
- package/dist/protocols/hls-cmaf/unavailable.js.map +1 -0
- package/dist/protocols/hls-live/index.d.ts +17 -0
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js +202 -106
- package/dist/protocols/hls-live/index.js.map +1 -1
- package/dist/stages/abr/index.d.ts.map +1 -1
- package/dist/stages/abr/index.js +8 -14
- package/dist/stages/abr/index.js.map +1 -1
- package/dist/stages/abr-cap-size/index.d.ts +1 -1
- package/dist/stages/abr-persist/index.d.ts.map +1 -1
- package/dist/stages/abr-persist/index.js +17 -7
- package/dist/stages/abr-persist/index.js.map +1 -1
- package/dist/stages/aes-128/index.d.ts +0 -9
- package/dist/stages/aes-128/index.d.ts.map +1 -1
- package/dist/stages/aes-128/index.js +15 -13
- package/dist/stages/aes-128/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts +16 -0
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +28 -15
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/chapters/index.d.ts +20 -0
- package/dist/stages/chapters/index.d.ts.map +1 -0
- package/dist/stages/chapters/index.js +141 -0
- package/dist/stages/chapters/index.js.map +1 -0
- package/dist/stages/chapters/parse.d.ts +47 -0
- package/dist/stages/chapters/parse.d.ts.map +1 -0
- package/dist/stages/chapters/parse.js +168 -0
- package/dist/stages/chapters/parse.js.map +1 -0
- package/dist/stages/cmaf-timing/index.d.ts.map +1 -1
- package/dist/stages/cmaf-timing/index.js +33 -42
- package/dist/stages/cmaf-timing/index.js.map +1 -1
- package/dist/stages/cmcd/index.d.ts +0 -11
- package/dist/stages/cmcd/index.d.ts.map +1 -1
- package/dist/stages/cmcd/index.js +30 -12
- package/dist/stages/cmcd/index.js.map +1 -1
- package/dist/stages/codec-switch/index.d.ts.map +1 -1
- package/dist/stages/codec-switch/index.js +3 -8
- package/dist/stages/codec-switch/index.js.map +1 -1
- package/dist/stages/content-steering/index.d.ts.map +1 -1
- package/dist/stages/content-steering/index.js +12 -9
- package/dist/stages/content-steering/index.js.map +1 -1
- package/dist/stages/eme-cenc/index.d.ts +0 -7
- package/dist/stages/eme-cenc/index.d.ts.map +1 -1
- package/dist/stages/eme-cenc/index.js +9 -5
- package/dist/stages/eme-cenc/index.js.map +1 -1
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +31 -15
- package/dist/stages/eme-core/index.js.map +1 -1
- package/dist/stages/eme-fairplay/index.d.ts +0 -7
- package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
- package/dist/stages/eme-fairplay/index.js +11 -9
- package/dist/stages/eme-fairplay/index.js.map +1 -1
- package/dist/stages/nal-scan/index.d.ts.map +1 -1
- package/dist/stages/nal-scan/index.js +32 -145
- package/dist/stages/nal-scan/index.js.map +1 -1
- package/dist/stages/recovery/index.d.ts.map +1 -1
- package/dist/stages/recovery/index.js +42 -56
- package/dist/stages/recovery/index.js.map +1 -1
- package/dist/stages/text-cea608/index.d.ts +11 -0
- package/dist/stages/text-cea608/index.d.ts.map +1 -1
- package/dist/stages/text-cea608/index.js +3 -23
- package/dist/stages/text-cea608/index.js.map +1 -1
- package/dist/stages/text-webvtt/index.d.ts +12 -0
- package/dist/stages/text-webvtt/index.d.ts.map +1 -1
- package/dist/stages/text-webvtt/index.js +1 -1
- package/dist/stages/text-webvtt/index.js.map +1 -1
- package/dist/stages/text-webvtt-segmented/index.d.ts.map +1 -1
- package/dist/stages/text-webvtt-segmented/index.js +11 -8
- package/dist/stages/text-webvtt-segmented/index.js.map +1 -1
- package/dist/stages/thumbnails/index.d.ts +39 -10
- package/dist/stages/thumbnails/index.d.ts.map +1 -1
- package/dist/stages/thumbnails/index.js +220 -30
- package/dist/stages/thumbnails/index.js.map +1 -1
- package/dist/stages/trick-play/index.d.ts +51 -0
- package/dist/stages/trick-play/index.d.ts.map +1 -0
- package/dist/stages/trick-play/index.js +480 -0
- package/dist/stages/trick-play/index.js.map +1 -0
- package/dist/types/ir.d.ts +40 -1
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +41 -13
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js +2 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +61 -10
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/stage.d.ts +18 -0
- package/dist/types/stage.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/stages/text-webvtt/parse.d.ts.map +0 -1
- package/dist/stages/text-webvtt/parse.js.map +0 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { scheduled } from "../../kernel/effects.js";
|
|
2
3
|
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
3
|
-
import {
|
|
4
|
+
import { findRendition } from "../../kernel/presentation.js";
|
|
5
|
+
import { isUnresolved } from "../../kernel/timeline.js";
|
|
6
|
+
import { activeRenditions } from "../../kernel/rendition-select.js";
|
|
7
|
+
import { manifestFact } from "../adapter-shared.js";
|
|
8
|
+
import { parse, sidxToSegments } from "./parse.js";
|
|
4
9
|
//#region src/protocols/dash-cmaf/index.ts
|
|
5
10
|
/**
|
|
6
11
|
* The dash-cmaf protocol adapter as a stage. Inert module: exports a
|
|
@@ -12,23 +17,25 @@ import { mergeSidx, parse, sidxToSegments } from "./parse.js";
|
|
|
12
17
|
* indexed by a `sidx` box, so the concrete segments are unknown until that box
|
|
13
18
|
* is fetched. That second phase mirrors HLS's media-playlist fetch: the parse
|
|
14
19
|
* emits `sidx` addressing, this slice fetches the index byte range under a
|
|
15
|
-
* `dash:idx:` token the transport correlates back, parses it, and
|
|
16
|
-
* resolved segments
|
|
20
|
+
* `dash:idx:` token the transport correlates back, parses it, and feeds the
|
|
21
|
+
* resolved segments back as a PLAYLIST_REFRESHED the kernel merges.
|
|
17
22
|
*/
|
|
18
23
|
const INDEX_TOKEN = "dash:idx:";
|
|
19
24
|
/** The MPD MIME type, ISO 23009-1 §C.2. */
|
|
20
25
|
const MANIFEST_TYPES = ["application/dash+xml"];
|
|
21
26
|
/** Unresolved on-demand addressing, or null for an explicit list or template. */
|
|
22
27
|
function asSidx(addressing) {
|
|
23
|
-
|
|
24
|
-
const candidate = addressing;
|
|
25
|
-
return candidate.kind === "sidx" ? candidate : null;
|
|
28
|
+
return addressing !== void 0 && isUnresolved(addressing) ? addressing : null;
|
|
26
29
|
}
|
|
27
30
|
const INITIAL = {
|
|
28
31
|
manifestUrl: null,
|
|
29
32
|
mimeType: null,
|
|
30
|
-
pending: {}
|
|
33
|
+
pending: {},
|
|
34
|
+
failed: {},
|
|
35
|
+
seen: ""
|
|
31
36
|
};
|
|
37
|
+
/** The constraint source that excludes renditions whose index failed. */
|
|
38
|
+
const UNAVAILABLE = "dash:unavailable";
|
|
32
39
|
/**
|
|
33
40
|
* Whether this adapter owns the manifest bytes. An explicit mimeType
|
|
34
41
|
* decides alone; without one, an MPD is an XML document and starts with
|
|
@@ -38,111 +45,148 @@ function claims(state, text) {
|
|
|
38
45
|
if (state.mimeType !== null) return MANIFEST_TYPES.includes(state.mimeType);
|
|
39
46
|
return text.trimStart().startsWith("<");
|
|
40
47
|
}
|
|
41
|
-
function findRendition(presentation, renditionId) {
|
|
42
|
-
for (const period of presentation.periods) for (const track of period.tracks) for (const rendition of track.renditions) if (rendition.id === renditionId) return rendition;
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
48
|
/**
|
|
46
|
-
* The renditions whose sidx index
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* each, so the cost is negligible.
|
|
49
|
+
* The renditions whose sidx index the selection needs and this slice has
|
|
50
|
+
* not asked for: the playing video rendition and its ladder neighbours, and
|
|
51
|
+
* every rendition of the active audio and text tracks. The kernel selects
|
|
52
|
+
* the audio rendition on its own (an audio adaptation set often has several
|
|
53
|
+
* bitrates) and keeps no record of the pick, so all of them resolve; an
|
|
54
|
+
* unresolved one would never fill the audio buffer. The whole video ladder
|
|
55
|
+
* does not: ABR steps one rung at a time, and a longer jump resolves when
|
|
56
|
+
* it happens, while the buffer plays.
|
|
55
57
|
*/
|
|
56
|
-
function neededIndexes(kernel) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const
|
|
58
|
+
function neededIndexes(state, kernel) {
|
|
59
|
+
const asked = new Set(Object.values(state.pending));
|
|
60
|
+
const needed = [];
|
|
61
|
+
for (const { rendition } of activeRenditions(kernel, [
|
|
60
62
|
"video",
|
|
61
63
|
"audio",
|
|
62
64
|
"text"
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for (const rendition of track.renditions) if (asSidx(rendition.segments) !== null) needed.push(rendition);
|
|
65
|
+
], kernel.quality.active)) {
|
|
66
|
+
if (asSidx(rendition.segments) === null) continue;
|
|
67
|
+
if (asked.has(rendition.id) || rendition.id in state.failed) continue;
|
|
68
|
+
needed.push(rendition);
|
|
68
69
|
}
|
|
69
70
|
return needed;
|
|
70
71
|
}
|
|
71
72
|
/** Loops a message back into the bus through a zero-delay schedule effect. */
|
|
72
73
|
function feed(message) {
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
return scheduled("dash:loopback", message);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* An index that failed to load or held no segment. The rendition is
|
|
78
|
+
* excluded, so arbitration moves off it and nothing asks for the index
|
|
79
|
+
* again. When that leaves a media track with no rendition at all, the load
|
|
80
|
+
* fails: the stream cannot play, and waiting would only stall.
|
|
81
|
+
*/
|
|
82
|
+
function unavailable(state, kernel, renditionId, error) {
|
|
83
|
+
var _findRendition$track, _findRendition;
|
|
84
|
+
const failed = _objectSpread2(_objectSpread2({}, state.failed), {}, { [renditionId]: true });
|
|
85
|
+
const next = _objectSpread2(_objectSpread2({}, state), {}, { failed });
|
|
86
|
+
const presentation = kernel.presentation;
|
|
87
|
+
if (presentation === null) return [next, []];
|
|
88
|
+
const track = (_findRendition$track = (_findRendition = findRendition(presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.track) !== null && _findRendition$track !== void 0 ? _findRendition$track : null;
|
|
89
|
+
const media = (track === null || track === void 0 ? void 0 : track.contentType) === "video" || (track === null || track === void 0 ? void 0 : track.contentType) === "audio";
|
|
90
|
+
if (track !== null && media && track.renditions.every((r) => r.id in failed)) return [next, [feed({
|
|
91
|
+
type: "MANIFEST_FAILED",
|
|
92
|
+
error: _objectSpread2(_objectSpread2({}, error), {}, { fatal: true })
|
|
93
|
+
})]];
|
|
94
|
+
return [next, [feed({
|
|
95
|
+
type: "CONSTRAIN",
|
|
96
|
+
source: UNAVAILABLE,
|
|
97
|
+
constraint: { excludeIds: Object.keys(failed) }
|
|
98
|
+
})]];
|
|
79
99
|
}
|
|
80
100
|
const reduceDash = (slice, msg, kernel) => {
|
|
81
101
|
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
82
|
-
if (msg.type === "LOAD") return [{
|
|
102
|
+
if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
|
|
83
103
|
manifestUrl: msg.url,
|
|
84
|
-
mimeType: msg.mimeType === void 0 ? null : normalizeMimeType(msg.mimeType)
|
|
85
|
-
|
|
86
|
-
}, []];
|
|
104
|
+
mimeType: msg.mimeType === void 0 ? null : normalizeMimeType(msg.mimeType)
|
|
105
|
+
}), []];
|
|
87
106
|
if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
|
|
88
107
|
if (msg.type === "SEGMENT_LOADED" && msg.trackId === "manifest" && state.manifestUrl !== null) {
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
recoverable: false
|
|
101
|
-
}
|
|
102
|
-
})]];
|
|
108
|
+
const fact = manifestFact(msg.bytes, state.manifestUrl, (text) => claims(state, text), parse);
|
|
109
|
+
return [state, fact === null ? [] : [feed(fact)]];
|
|
110
|
+
}
|
|
111
|
+
let next = state;
|
|
112
|
+
if (msg.type === "PLAYLIST_REFRESHED" && msg.renditionId !== void 0) {
|
|
113
|
+
const renditionId = msg.renditionId;
|
|
114
|
+
const token = `${INDEX_TOKEN}${renditionId}`;
|
|
115
|
+
if (token in next.pending) {
|
|
116
|
+
const pending = _objectSpread2({}, next.pending);
|
|
117
|
+
delete pending[token];
|
|
118
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { pending });
|
|
103
119
|
}
|
|
104
|
-
return [state, [feed({
|
|
105
|
-
type: "MANIFEST_LOADED",
|
|
106
|
-
presentation: result.presentation
|
|
107
|
-
})]];
|
|
108
120
|
}
|
|
109
|
-
if (msg.type === "SEGMENT_LOADED" && msg.trackId.
|
|
121
|
+
if (msg.type === "SEGMENT_LOADED" && msg.trackId in state.pending) {
|
|
122
|
+
var _findRendition2;
|
|
110
123
|
const renditionId = state.pending[msg.trackId];
|
|
111
|
-
|
|
112
|
-
const
|
|
124
|
+
const sidx = kernel.presentation === null ? null : asSidx((_findRendition2 = findRendition(kernel.presentation, renditionId)) === null || _findRendition2 === void 0 ? void 0 : _findRendition2.rendition.segments);
|
|
125
|
+
const segments = sidx === null ? [] : sidxToSegments(new Uint8Array(msg.bytes), sidx);
|
|
126
|
+
if (sidx !== null && segments.length > 0) {
|
|
127
|
+
var _segments$0$seq, _segments$;
|
|
128
|
+
return [state, [feed({
|
|
129
|
+
type: "PLAYLIST_REFRESHED",
|
|
130
|
+
trackId: renditionId,
|
|
131
|
+
renditionId,
|
|
132
|
+
mediaSequence: (_segments$0$seq = (_segments$ = segments[0]) === null || _segments$ === void 0 ? void 0 : _segments$.seq) !== null && _segments$0$seq !== void 0 ? _segments$0$seq : 0,
|
|
133
|
+
segments
|
|
134
|
+
})]];
|
|
135
|
+
}
|
|
113
136
|
const pending = _objectSpread2({}, state.pending);
|
|
114
137
|
delete pending[msg.trackId];
|
|
115
|
-
const sidx = asSidx(rendition === null || rendition === void 0 ? void 0 : rendition.segments);
|
|
116
138
|
if (sidx === null) return [_objectSpread2(_objectSpread2({}, state), {}, { pending }), []];
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
const error = {
|
|
140
|
+
category: "media",
|
|
141
|
+
code: "MEDIA_CONTAINER_INVALID",
|
|
142
|
+
fatal: false,
|
|
143
|
+
recoverable: false,
|
|
144
|
+
context: {
|
|
145
|
+
renditionId,
|
|
146
|
+
reason: "sidx holds no segment"
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const [failed, failEffects] = unavailable(_objectSpread2(_objectSpread2({}, state), {}, { pending }), kernel, renditionId, error);
|
|
150
|
+
return [failed, [{
|
|
151
|
+
kind: "emit",
|
|
152
|
+
event: "error",
|
|
153
|
+
payload: {
|
|
154
|
+
category: error.category,
|
|
155
|
+
code: error.code,
|
|
156
|
+
fatal: false,
|
|
157
|
+
recoverable: false,
|
|
158
|
+
renditionId
|
|
159
|
+
}
|
|
160
|
+
}, ...failEffects]];
|
|
124
161
|
}
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
if (needed.length === 0) return [state, []];
|
|
128
|
-
const effects = [];
|
|
162
|
+
if (msg.type === "SEGMENT_FAILED" && msg.trackId in state.pending) {
|
|
163
|
+
const renditionId = state.pending[msg.trackId];
|
|
129
164
|
const pending = _objectSpread2({}, state.pending);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
165
|
+
delete pending[msg.trackId];
|
|
166
|
+
return unavailable(_objectSpread2(_objectSpread2({}, state), {}, { pending }), kernel, renditionId, msg.error);
|
|
167
|
+
}
|
|
168
|
+
if (kernel.lifecycle.phase !== "ready" || kernel.presentation === null) return [next, []];
|
|
169
|
+
const key = `${kernel.quality.version}:${kernel.quality.active}`;
|
|
170
|
+
if (key === next.seen && msg.type !== "RESUME") return [next, []];
|
|
171
|
+
const effects = [];
|
|
172
|
+
const pending = _objectSpread2({}, next.pending);
|
|
173
|
+
for (const rendition of neededIndexes(next, kernel)) {
|
|
174
|
+
const sidx = asSidx(rendition.segments);
|
|
175
|
+
if (sidx === null) continue;
|
|
176
|
+
const token = `${INDEX_TOKEN}${rendition.id}`;
|
|
177
|
+
pending[token] = rendition.id;
|
|
178
|
+
effects.push({
|
|
179
|
+
kind: "fetch",
|
|
180
|
+
token,
|
|
181
|
+
url: sidx.url,
|
|
182
|
+
range: sidx.indexRange,
|
|
183
|
+
renditionId: rendition.id
|
|
184
|
+
});
|
|
144
185
|
}
|
|
145
|
-
return [
|
|
186
|
+
return [_objectSpread2(_objectSpread2({}, next), {}, {
|
|
187
|
+
pending,
|
|
188
|
+
seen: key
|
|
189
|
+
}), effects];
|
|
146
190
|
};
|
|
147
191
|
/**
|
|
148
192
|
* The stage factory. `mattebox({ stages: [dashCmaf()] })` is all a consumer
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
|
|
3
|
+
import { resolveUrl } from "../../kernel/url.js";
|
|
4
|
+
import { base64ToBytes } from "../../kernel/base64.js";
|
|
5
|
+
import { manifestError } from "../adapter-shared.js";
|
|
6
|
+
import { dimensions } from "../dimensions.js";
|
|
3
7
|
//#region src/protocols/dash-cmaf/parse.ts
|
|
4
8
|
/**
|
|
5
9
|
* MPD into the IR. Pure: no fetching, no state, no side effects. DOMParser
|
|
@@ -17,22 +21,6 @@ import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
|
|
|
17
21
|
* becomes IndexedSegments and the kernel materializes one segment at a
|
|
18
22
|
* time, so a long window never becomes an array.
|
|
19
23
|
*/
|
|
20
|
-
function manifestError(reason) {
|
|
21
|
-
return {
|
|
22
|
-
category: "manifest",
|
|
23
|
-
code: "MANIFEST_PARSE_FAILED",
|
|
24
|
-
fatal: true,
|
|
25
|
-
recoverable: false,
|
|
26
|
-
context: { reason }
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function resolve(uri, baseUrl) {
|
|
30
|
-
try {
|
|
31
|
-
return new URL(uri, baseUrl).href;
|
|
32
|
-
} catch (_unused) {
|
|
33
|
-
return uri;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
24
|
/** ISO 8601 duration to seconds. Date parts use nominal day lengths. */
|
|
37
25
|
function parseDuration(value) {
|
|
38
26
|
if (value === null) return null;
|
|
@@ -80,17 +68,7 @@ function parseByteRange(value) {
|
|
|
80
68
|
function applyBaseUrl(element, base) {
|
|
81
69
|
var _baseElements$;
|
|
82
70
|
const text = (_baseElements$ = children(element, "BaseURL")[0]) === null || _baseElements$ === void 0 || (_baseElements$ = _baseElements$.textContent) === null || _baseElements$ === void 0 ? void 0 : _baseElements$.trim();
|
|
83
|
-
return text !== void 0 && text !== "" ?
|
|
84
|
-
}
|
|
85
|
-
function base64ToArrayBuffer(text) {
|
|
86
|
-
try {
|
|
87
|
-
const binary = atob(text.replace(/\s+/g, ""));
|
|
88
|
-
const bytes = new Uint8Array(binary.length);
|
|
89
|
-
for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
|
|
90
|
-
return bytes.buffer;
|
|
91
|
-
} catch (_unused2) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
71
|
+
return text !== void 0 && text !== "" ? resolveUrl(text, base) : base;
|
|
94
72
|
}
|
|
95
73
|
const MP4_PROTECTION = "urn:mpeg:dash:mp4protection:2011";
|
|
96
74
|
const UUID_URN = /^urn:uuid:([0-9a-f-]{36})$/i;
|
|
@@ -113,12 +91,12 @@ function parseProtection(elements) {
|
|
|
113
91
|
}
|
|
114
92
|
const schemes = [];
|
|
115
93
|
for (const element of elements) {
|
|
116
|
-
var _attr4, _children
|
|
94
|
+
var _attr4, _children$, _base64ToBytes$buffer, _base64ToBytes;
|
|
117
95
|
const schemeIdUri = (_attr4 = attr(element, "schemeIdUri")) !== null && _attr4 !== void 0 ? _attr4 : "";
|
|
118
96
|
const uuid = UUID_URN.exec(schemeIdUri);
|
|
119
97
|
if (uuid === null) continue;
|
|
120
98
|
const pssh = (_children$ = children(element, "pssh")[0]) === null || _children$ === void 0 || (_children$ = _children$.textContent) === null || _children$ === void 0 ? void 0 : _children$.trim();
|
|
121
|
-
const initData = pssh !== void 0 && pssh !== "" ?
|
|
99
|
+
const initData = pssh !== void 0 && pssh !== "" ? (_base64ToBytes$buffer = (_base64ToBytes = base64ToBytes(pssh)) === null || _base64ToBytes === void 0 ? void 0 : _base64ToBytes.buffer) !== null && _base64ToBytes$buffer !== void 0 ? _base64ToBytes$buffer : null : null;
|
|
122
100
|
schemes.push({
|
|
123
101
|
systemId: uuid[1].toLowerCase(),
|
|
124
102
|
scheme: commonScheme,
|
|
@@ -141,7 +119,8 @@ function parseProtection(elements) {
|
|
|
141
119
|
/**
|
|
142
120
|
* A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
|
|
143
121
|
* representation declaring a playout rate other than 1. Both mark an
|
|
144
|
-
* I-frame-only set meant for
|
|
122
|
+
* I-frame-only set meant for fast forward and previews, never for normal
|
|
123
|
+
* playback.
|
|
145
124
|
*/
|
|
146
125
|
function isTrickMode(adaptationSet) {
|
|
147
126
|
for (const property of children(adaptationSet, "EssentialProperty")) {
|
|
@@ -155,6 +134,30 @@ function isTrickMode(adaptationSet) {
|
|
|
155
134
|
}
|
|
156
135
|
return false;
|
|
157
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* The DASH-IF IOP thumbnail grid: an EssentialProperty with the
|
|
139
|
+
* thumbnail_tile scheme and value `CxR`, on the Representation or its
|
|
140
|
+
* AdaptationSet. The Representation's width and height are the whole image,
|
|
141
|
+
* so one tile is that size divided by the grid.
|
|
142
|
+
*/
|
|
143
|
+
function tileGridOf(representation, adaptationSet, width, height) {
|
|
144
|
+
if (width === null || height === null) return null;
|
|
145
|
+
const properties = [...children(representation, "EssentialProperty"), ...children(adaptationSet, "EssentialProperty")];
|
|
146
|
+
for (const property of properties) {
|
|
147
|
+
var _attr6;
|
|
148
|
+
if (!((_attr6 = attr(property, "schemeIdUri")) !== null && _attr6 !== void 0 ? _attr6 : "").includes("thumbnail_tile")) continue;
|
|
149
|
+
const grid = dimensions(attr(property, "value"));
|
|
150
|
+
if (grid === null) continue;
|
|
151
|
+
const [columns, rows] = grid;
|
|
152
|
+
return {
|
|
153
|
+
columns,
|
|
154
|
+
rows,
|
|
155
|
+
width: width / columns,
|
|
156
|
+
height: height / rows
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
158
161
|
/** Merges SegmentTemplate attributes down Period, AdaptationSet, Representation. */
|
|
159
162
|
function mergeTemplates(levels) {
|
|
160
163
|
var _timescale, _startNumber, _pto;
|
|
@@ -167,12 +170,12 @@ function mergeTemplates(levels) {
|
|
|
167
170
|
let timelineElement = null;
|
|
168
171
|
let found = false;
|
|
169
172
|
for (const level of levels) {
|
|
170
|
-
var
|
|
173
|
+
var _attr7, _attr8, _numberAttr, _numberAttr2, _numberAttr3, _numberAttr4, _children$2;
|
|
171
174
|
const template = children(level, "SegmentTemplate")[0];
|
|
172
175
|
if (template === void 0) continue;
|
|
173
176
|
found = true;
|
|
174
|
-
media = (
|
|
175
|
-
initialization = (
|
|
177
|
+
media = (_attr7 = attr(template, "media")) !== null && _attr7 !== void 0 ? _attr7 : media;
|
|
178
|
+
initialization = (_attr8 = attr(template, "initialization")) !== null && _attr8 !== void 0 ? _attr8 : initialization;
|
|
176
179
|
timescale = (_numberAttr = numberAttr(template, "timescale")) !== null && _numberAttr !== void 0 ? _numberAttr : timescale;
|
|
177
180
|
startNumber = (_numberAttr2 = numberAttr(template, "startNumber")) !== null && _numberAttr2 !== void 0 ? _numberAttr2 : startNumber;
|
|
178
181
|
duration = (_numberAttr3 = numberAttr(template, "duration")) !== null && _numberAttr3 !== void 0 ? _numberAttr3 : duration;
|
|
@@ -239,7 +242,7 @@ function contentTypeOf(adaptationSet, mimeType) {
|
|
|
239
242
|
}
|
|
240
243
|
/** parse an MPD document into a Presentation. Never throws. */
|
|
241
244
|
function parse(text, baseUrl) {
|
|
242
|
-
var _parseDuration, _parseDuration2,
|
|
245
|
+
var _parseDuration, _parseDuration2, _attr16;
|
|
243
246
|
let doc;
|
|
244
247
|
try {
|
|
245
248
|
doc = new DOMParser().parseFromString(text, "text/xml");
|
|
@@ -259,15 +262,15 @@ function parse(text, baseUrl) {
|
|
|
259
262
|
const mpdBase = applyBaseUrl(mpd, baseUrl);
|
|
260
263
|
let live;
|
|
261
264
|
if (isLive) {
|
|
262
|
-
var
|
|
263
|
-
const availabilityStart = Date.parse((
|
|
265
|
+
var _attr9, _attr10, _attr11;
|
|
266
|
+
const availabilityStart = Date.parse((_attr9 = attr(mpd, "availabilityStartTime")) !== null && _attr9 !== void 0 ? _attr9 : "");
|
|
264
267
|
const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
|
|
265
268
|
const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
|
|
266
269
|
const holdBack = parseDuration(attr(mpd, "suggestedPresentationDelay"));
|
|
267
270
|
const timing = children(mpd, "UTCTiming")[0];
|
|
268
271
|
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: {
|
|
269
|
-
scheme: (
|
|
270
|
-
value: (
|
|
272
|
+
scheme: (_attr10 = attr(timing, "schemeIdUri")) !== null && _attr10 !== void 0 ? _attr10 : "",
|
|
273
|
+
value: (_attr11 = attr(timing, "value")) !== null && _attr11 !== void 0 ? _attr11 : ""
|
|
271
274
|
} } : {});
|
|
272
275
|
}
|
|
273
276
|
let steering;
|
|
@@ -281,9 +284,9 @@ function parse(text, baseUrl) {
|
|
|
281
284
|
var _base$textContent;
|
|
282
285
|
const location = attr(base, "serviceLocation");
|
|
283
286
|
const text = (_base$textContent = base.textContent) === null || _base$textContent === void 0 ? void 0 : _base$textContent.trim();
|
|
284
|
-
if (location !== null && text !== void 0 && text !== "") bases[location] =
|
|
287
|
+
if (location !== null && text !== void 0 && text !== "") bases[location] = resolveUrl(text, baseUrl);
|
|
285
288
|
}
|
|
286
|
-
steering = _objectSpread2(_objectSpread2({ serverUri:
|
|
289
|
+
steering = _objectSpread2(_objectSpread2({ serverUri: resolveUrl(serverUri, baseUrl) }, attr(steeringElement, "defaultServiceLocation") !== null ? { defaultPathway: attr(steeringElement, "defaultServiceLocation") } : {}), Object.keys(bases).length > 0 ? { bases } : {});
|
|
287
290
|
}
|
|
288
291
|
}
|
|
289
292
|
const periodElement = children(mpd, "Period")[0];
|
|
@@ -305,26 +308,27 @@ function parse(text, baseUrl) {
|
|
|
305
308
|
for (let asIndex = 0; asIndex < adaptationSets.length; asIndex += 1) {
|
|
306
309
|
var _children$0$getAttrib, _children$3, _trackMime2;
|
|
307
310
|
const adaptationSet = adaptationSets[asIndex];
|
|
308
|
-
|
|
311
|
+
const trick = isTrickMode(adaptationSet);
|
|
312
|
+
const asPlayoutRate = numberAttr(adaptationSet, "maxPlayoutRate");
|
|
309
313
|
const asBase = applyBaseUrl(adaptationSet, periodBase);
|
|
310
314
|
const asMime = attr(adaptationSet, "mimeType");
|
|
311
315
|
const asCodecs = attr(adaptationSet, "codecs");
|
|
312
316
|
const lang = attr(adaptationSet, "lang");
|
|
313
|
-
const role = (_children$0$getAttrib = (_children$3 = children(adaptationSet, "Role")[0]) === null || _children$3 === void 0 ? void 0 : _children$3.getAttribute("value")) !== null && _children$0$getAttrib !== void 0 ? _children$0$getAttrib : null;
|
|
317
|
+
const role = trick ? "trick" : (_children$0$getAttrib = (_children$3 = children(adaptationSet, "Role")[0]) === null || _children$3 === void 0 ? void 0 : _children$3.getAttribute("value")) !== null && _children$0$getAttrib !== void 0 ? _children$0$getAttrib : null;
|
|
314
318
|
const protectionSchemes = parseProtection(children(adaptationSet, "ContentProtection"));
|
|
315
319
|
const renditions = [];
|
|
316
320
|
let trackMime = null;
|
|
317
321
|
for (const representation of children(adaptationSet, "Representation")) {
|
|
318
|
-
var _ref,
|
|
322
|
+
var _ref, _attr12, _trackMime, _parseFrameRate2, _numberAttr8, _attr15;
|
|
319
323
|
const id = attr(representation, "id");
|
|
320
324
|
const bandwidth = numberAttr(representation, "bandwidth");
|
|
321
325
|
if (id === null || bandwidth === null) continue;
|
|
322
326
|
const repBase = applyBaseUrl(representation, asBase);
|
|
323
|
-
const mimeType = (_ref = (
|
|
327
|
+
const mimeType = (_ref = (_attr12 = attr(representation, "mimeType")) !== null && _attr12 !== void 0 ? _attr12 : asMime) !== null && _ref !== void 0 ? _ref : "video/mp4";
|
|
324
328
|
trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
|
|
325
329
|
const segmentBase = children(representation, "SegmentBase")[0];
|
|
326
330
|
if (segmentBase !== void 0) {
|
|
327
|
-
var _numberAttr7, _parseFrameRate,
|
|
331
|
+
var _numberAttr7, _parseFrameRate, _attr13;
|
|
328
332
|
const indexRange = parseByteRange(attr(segmentBase, "indexRange"));
|
|
329
333
|
if (indexRange === null) continue;
|
|
330
334
|
const baseTimescale = (_numberAttr7 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr7 !== void 0 ? _numberAttr7 : 1;
|
|
@@ -347,7 +351,7 @@ function parse(text, baseUrl) {
|
|
|
347
351
|
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
348
352
|
id,
|
|
349
353
|
bitrate: bandwidth,
|
|
350
|
-
codecs: (
|
|
354
|
+
codecs: (_attr13 = attr(representation, "codecs")) !== null && _attr13 !== void 0 ? _attr13 : asCodecs,
|
|
351
355
|
mimeType,
|
|
352
356
|
segments: sidxSegments
|
|
353
357
|
}, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}));
|
|
@@ -360,11 +364,11 @@ function parse(text, baseUrl) {
|
|
|
360
364
|
]);
|
|
361
365
|
if (template === null || template.media === null) {
|
|
362
366
|
if (contentTypeOf(adaptationSet, mimeType) === "text" && periodDuration !== null) {
|
|
363
|
-
var
|
|
367
|
+
var _attr14;
|
|
364
368
|
renditions.push({
|
|
365
369
|
id,
|
|
366
370
|
bitrate: bandwidth,
|
|
367
|
-
codecs: (
|
|
371
|
+
codecs: (_attr14 = attr(representation, "codecs")) !== null && _attr14 !== void 0 ? _attr14 : asCodecs,
|
|
368
372
|
mimeType,
|
|
369
373
|
segments: [{
|
|
370
374
|
seq: 0,
|
|
@@ -391,24 +395,26 @@ function parse(text, baseUrl) {
|
|
|
391
395
|
};
|
|
392
396
|
const segments = _objectSpread2({
|
|
393
397
|
kind: "indexed",
|
|
394
|
-
urlTemplate:
|
|
398
|
+
urlTemplate: resolveUrl(substituteIdentity(template.media, id, bandwidth), repBase),
|
|
395
399
|
startSeq: template.startNumber,
|
|
396
400
|
endSeq: isLive ? null : endSeq,
|
|
397
401
|
timescale: template.timescale,
|
|
398
402
|
segmentDuration: timeline !== null ? null : template.duration,
|
|
399
403
|
timeline
|
|
400
404
|
}, template.presentationTimeOffset !== 0 ? { presentationTimeOffset: template.presentationTimeOffset } : {});
|
|
401
|
-
const init = template.initialization !== null ? { url:
|
|
405
|
+
const init = template.initialization !== null ? { url: resolveUrl(substituteIdentity(template.initialization, id, bandwidth), repBase) } : null;
|
|
402
406
|
const frameRate = (_parseFrameRate2 = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate2 !== void 0 ? _parseFrameRate2 : parseFrameRate(attr(adaptationSet, "frameRate"));
|
|
403
407
|
const width = numberAttr(representation, "width");
|
|
404
408
|
const height = numberAttr(representation, "height");
|
|
405
|
-
|
|
409
|
+
const tiles = tileGridOf(representation, adaptationSet, width, height);
|
|
410
|
+
const playoutRate = trick ? (_numberAttr8 = numberAttr(representation, "maxPlayoutRate")) !== null && _numberAttr8 !== void 0 ? _numberAttr8 : asPlayoutRate : null;
|
|
411
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
406
412
|
id,
|
|
407
413
|
bitrate: bandwidth,
|
|
408
|
-
codecs: (
|
|
414
|
+
codecs: (_attr15 = attr(representation, "codecs")) !== null && _attr15 !== void 0 ? _attr15 : asCodecs,
|
|
409
415
|
mimeType,
|
|
410
416
|
segments
|
|
411
|
-
}, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}));
|
|
417
|
+
}, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}), tiles !== null ? { tiles } : {}), playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}));
|
|
412
418
|
}
|
|
413
419
|
if (renditions.length === 0) continue;
|
|
414
420
|
const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
|
|
@@ -436,7 +442,7 @@ function parse(text, baseUrl) {
|
|
|
436
442
|
isLive
|
|
437
443
|
}, mpdDuration !== null ? { duration: mpdDuration } : {}), {}, {
|
|
438
444
|
periods: [_objectSpread2(_objectSpread2({
|
|
439
|
-
id: (
|
|
445
|
+
id: (_attr16 = attr(periodElement, "id")) !== null && _attr16 !== void 0 ? _attr16 : "p0",
|
|
440
446
|
start: periodStart
|
|
441
447
|
}, periodDuration !== null ? { duration: periodDuration } : {}), {}, { tracks })],
|
|
442
448
|
couplings: []
|
|
@@ -479,13 +485,5 @@ function sidxToSegments(sidxBytes, addressing) {
|
|
|
479
485
|
}
|
|
480
486
|
return segments;
|
|
481
487
|
}
|
|
482
|
-
/**
|
|
483
|
-
* Immutably swaps a rendition's unresolved sidx addressing for the explicit
|
|
484
|
-
* segment list parsed from its index box. Everything else about the
|
|
485
|
-
* presentation is already known from the MPD.
|
|
486
|
-
*/
|
|
487
|
-
function mergeSidx(presentation, renditionId, segments) {
|
|
488
|
-
return _objectSpread2(_objectSpread2({}, presentation), {}, { periods: presentation.periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, { tracks: period.tracks.map((track) => track.renditions.some((r) => r.id === renditionId) ? _objectSpread2(_objectSpread2({}, track), {}, { renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2({}, rendition), {}, { segments }) : rendition) }) : track) })) });
|
|
489
|
-
}
|
|
490
488
|
//#endregion
|
|
491
|
-
export {
|
|
489
|
+
export { parse, parseDuration, sidxToSegments };
|