mattebox 0.10.0 → 0.12.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 +1 -1
- 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 +6 -2
- package/dist/containers/captions.d.ts +6 -5
- package/dist/containers/captions.d.ts.map +1 -1
- package/dist/containers/captions.js +9 -9
- package/dist/containers/captions.js.map +1 -1
- package/dist/containers/codec-probe/index.d.ts +15 -0
- package/dist/containers/codec-probe/index.d.ts.map +1 -1
- package/dist/containers/codec-probe/index.js +72 -5
- package/dist/containers/codec-probe/index.js.map +1 -1
- package/dist/containers/emsg.d.ts +15 -0
- package/dist/containers/emsg.d.ts.map +1 -0
- package/dist/containers/emsg.js +91 -0
- package/dist/containers/emsg.js.map +1 -0
- package/dist/containers/id3.d.ts +12 -0
- package/dist/containers/id3.d.ts.map +1 -1
- package/dist/containers/id3.js +53 -4
- package/dist/containers/id3.js.map +1 -1
- package/dist/containers/metadata.d.ts +18 -0
- package/dist/containers/metadata.d.ts.map +1 -0
- package/dist/containers/metadata.js +20 -0
- package/dist/containers/metadata.js.map +1 -0
- package/dist/containers/mp4-box/index.d.ts +16 -0
- package/dist/containers/mp4-box/index.d.ts.map +1 -1
- package/dist/containers/mp4-box/index.js +28 -0
- package/dist/containers/mp4-box/index.js.map +1 -1
- package/dist/containers/scte35.d.ts +12 -0
- package/dist/containers/scte35.d.ts.map +1 -0
- package/dist/containers/scte35.js +116 -0
- package/dist/containers/scte35.js.map +1 -0
- package/dist/containers/ts-transmux/demux.d.ts +2 -2
- package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
- package/dist/containers/ts-transmux/demux.js +2 -18
- package/dist/containers/ts-transmux/demux.js.map +1 -1
- package/dist/containers/ts-transmux/index.d.ts.map +1 -1
- package/dist/containers/ts-transmux/index.js +14 -3
- package/dist/containers/ts-transmux/index.js.map +1 -1
- package/dist/containers/ts-transmux/module.d.ts +8 -0
- package/dist/containers/ts-transmux/module.d.ts.map +1 -0
- package/dist/containers/ts-transmux/module.js +8 -0
- package/dist/containers/ts-transmux/module.js.map +1 -0
- package/dist/containers/ts-transmux/runner.d.ts +20 -8
- package/dist/containers/ts-transmux/runner.d.ts.map +1 -1
- package/dist/containers/ts-transmux/runner.js +19 -22
- package/dist/containers/ts-transmux/runner.js.map +1 -1
- package/dist/containers/ts-transmux/serve.d.ts +35 -0
- package/dist/containers/ts-transmux/serve.d.ts.map +1 -0
- package/dist/containers/ts-transmux/serve.js +33 -0
- package/dist/containers/ts-transmux/serve.js.map +1 -0
- package/dist/containers/ts-transmux/sniff.d.ts +11 -0
- package/dist/containers/ts-transmux/sniff.d.ts.map +1 -0
- package/dist/containers/ts-transmux/sniff.js +25 -0
- package/dist/containers/ts-transmux/sniff.js.map +1 -0
- package/dist/containers/ts-transmux/source.d.ts +10 -0
- package/dist/containers/ts-transmux/source.d.ts.map +1 -0
- package/dist/containers/ts-transmux/source.js +5 -0
- package/dist/containers/ts-transmux/source.js.map +1 -0
- package/dist/containers/ts-transmux/transmux.d.ts +19 -1
- package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
- package/dist/containers/ts-transmux/transmux.js +46 -7
- package/dist/containers/ts-transmux/transmux.js.map +1 -1
- package/dist/containers/ts-transmux/transmux.worker.js +7 -28
- package/dist/containers/ts-transmux/transmux.worker.js.map +1 -1
- package/dist/containers/webvtt.d.ts +2 -0
- package/dist/containers/webvtt.d.ts.map +1 -1
- package/dist/containers/webvtt.js +4 -0
- package/dist/containers/webvtt.js.map +1 -1
- package/dist/containers/wvtt.d.ts +12 -0
- package/dist/containers/wvtt.d.ts.map +1 -0
- package/dist/containers/wvtt.js +46 -0
- package/dist/containers/wvtt.js.map +1 -0
- package/dist/eme/index.d.ts +34 -0
- package/dist/eme/index.d.ts.map +1 -0
- package/dist/eme/index.js +75 -0
- package/dist/eme/index.js.map +1 -0
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/containers/captions.js +8 -8
- package/dist/es2015/containers/codec-probe/index.js +105 -6
- package/dist/es2015/containers/emsg.js +81 -0
- package/dist/es2015/containers/id3.js +54 -4
- package/dist/es2015/containers/metadata.js +20 -0
- package/dist/es2015/containers/mp4-box/index.js +27 -1
- package/dist/es2015/containers/scte35.js +114 -0
- package/dist/es2015/containers/ts-transmux/demux.js +12 -24
- package/dist/es2015/containers/ts-transmux/h264.js +1 -1
- package/dist/es2015/containers/ts-transmux/index.js +12 -4
- package/dist/es2015/containers/ts-transmux/runner.js +34 -27
- package/dist/es2015/containers/ts-transmux/serve.js +36 -0
- package/dist/es2015/containers/ts-transmux/sniff.js +13 -0
- package/dist/es2015/containers/ts-transmux/source.js +7 -0
- package/dist/es2015/containers/ts-transmux/transmux.js +42 -8
- package/dist/es2015/containers/ts-transmux/transmux.worker.js +7 -26
- package/dist/es2015/containers/webvtt.js +6 -2
- package/dist/es2015/containers/wvtt.js +40 -0
- package/dist/es2015/eme/index.js +79 -0
- package/dist/es2015/index.js +63 -27
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/base64.js +14 -3
- package/dist/es2015/kernel/bus.js +11 -8
- package/dist/es2015/kernel/context.js +5 -0
- package/dist/es2015/kernel/lifecycle.js +1 -0
- package/dist/es2015/kernel/loader.js +2 -2
- package/dist/es2015/kernel/mime.js +12 -1
- package/dist/es2015/kernel/mse.js +47 -6
- package/dist/es2015/kernel/prepare.js +2 -2
- package/dist/es2015/kernel/reducer.js +83 -26
- package/dist/es2015/kernel/refresh.js +2 -2
- package/dist/es2015/kernel/rendition-select.js +91 -16
- package/dist/es2015/kernel/scheduler.js +1 -1
- package/dist/es2015/kernel/sinks/caption-tracks.js +82 -0
- package/dist/es2015/kernel/sinks/native-sync.js +46 -0
- package/dist/es2015/kernel/sinks/text-formats.js +64 -0
- package/dist/es2015/kernel/sinks/text-track-sink.js +15 -4
- package/dist/es2015/kernel/timeline.js +12 -8
- package/dist/es2015/kernel/trace.js +1 -1
- package/dist/es2015/kernel/track-registry.js +6 -3
- package/dist/es2015/kernel/transport.js +34 -7
- package/dist/es2015/presets/define.js +2 -2
- package/dist/es2015/presets/full/index.js +22 -2
- package/dist/es2015/protocols/dash-cmaf/index.js +61 -14
- package/dist/es2015/protocols/dash-cmaf/parse.js +421 -121
- package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +134 -0
- package/dist/es2015/protocols/dash-cmaf/periods.js +178 -0
- package/dist/es2015/protocols/dash-live/index.js +1 -1
- package/dist/es2015/protocols/hls-cmaf/index.js +41 -17
- package/dist/es2015/protocols/hls-cmaf/lexer.js +2 -1
- package/dist/es2015/protocols/hls-cmaf/parse.js +161 -39
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +37 -6
- package/dist/es2015/protocols/hls-live/index.js +36 -10
- package/dist/es2015/stages/abr/index.js +18 -7
- package/dist/es2015/stages/abr-persist/index.js +1 -1
- package/dist/es2015/stages/aes-128/index.js +1 -1
- package/dist/es2015/stages/alt-audio/index.js +7 -5
- package/dist/es2015/stages/chapters/index.js +2 -2
- package/dist/es2015/stages/chapters/parse.js +2 -2
- package/dist/es2015/stages/cmcd/index.js +30 -3
- package/dist/es2015/stages/cmsd/index.js +72 -0
- package/dist/es2015/stages/codec-probe/index.js +28 -3
- package/dist/es2015/stages/content-steering/index.js +1 -1
- package/dist/es2015/stages/eme-core/index.js +31 -7
- package/dist/es2015/stages/eme-fairplay/index.js +18 -9
- package/dist/es2015/stages/hdr/index.js +214 -0
- package/dist/es2015/stages/meta-id3/index.js +6 -1
- package/dist/es2015/stages/qoe/index.js +111 -0
- package/dist/es2015/stages/recovery/index.js +1 -1
- package/dist/es2015/stages/rendition-names/index.js +101 -0
- package/dist/es2015/stages/text-cea608/decode.js +57 -6
- package/dist/es2015/stages/text-cea608/index.js +26 -93
- package/dist/es2015/stages/text-cea708/decode.js +379 -0
- package/dist/es2015/stages/text-cea708/index.js +98 -0
- package/dist/es2015/stages/text-ttml/index.js +88 -0
- package/dist/es2015/stages/text-ttml/parse.js +255 -0
- package/dist/es2015/stages/text-webvtt/index.js +30 -65
- package/dist/es2015/stages/thumbnails/index.js +1 -1
- package/dist/es2015/stages/timed-metadata/index.js +331 -0
- package/dist/es2015/stages/trick-play/index.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -19
- package/dist/index.js.map +1 -1
- package/dist/kernel/base64.d.ts +7 -2
- package/dist/kernel/base64.d.ts.map +1 -1
- package/dist/kernel/base64.js +14 -2
- package/dist/kernel/base64.js.map +1 -1
- package/dist/kernel/bus.d.ts.map +1 -1
- package/dist/kernel/bus.js +12 -9
- package/dist/kernel/bus.js.map +1 -1
- package/dist/kernel/context.d.ts +3 -1
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/context.js +5 -0
- package/dist/kernel/context.js.map +1 -1
- package/dist/kernel/lifecycle.d.ts +3 -1
- package/dist/kernel/lifecycle.d.ts.map +1 -1
- package/dist/kernel/lifecycle.js +1 -0
- package/dist/kernel/lifecycle.js.map +1 -1
- package/dist/kernel/loader.d.ts.map +1 -1
- package/dist/kernel/loader.js +3 -2
- package/dist/kernel/loader.js.map +1 -1
- package/dist/kernel/mime.d.ts +7 -0
- package/dist/kernel/mime.d.ts.map +1 -1
- package/dist/kernel/mime.js +12 -0
- package/dist/kernel/mime.js.map +1 -1
- package/dist/kernel/mse.d.ts.map +1 -1
- package/dist/kernel/mse.js +47 -3
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +88 -12
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/refresh.d.ts.map +1 -1
- package/dist/kernel/refresh.js +1 -0
- package/dist/kernel/refresh.js.map +1 -1
- package/dist/kernel/rendition-select.d.ts +29 -1
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +99 -21
- package/dist/kernel/rendition-select.js.map +1 -1
- package/dist/kernel/sinks/caption-tracks.d.ts +11 -0
- package/dist/kernel/sinks/caption-tracks.d.ts.map +1 -0
- package/dist/kernel/sinks/caption-tracks.js +87 -0
- package/dist/kernel/sinks/caption-tracks.js.map +1 -0
- package/dist/kernel/sinks/native-sync.d.ts +24 -0
- package/dist/kernel/sinks/native-sync.d.ts.map +1 -0
- package/dist/kernel/sinks/native-sync.js +42 -0
- package/dist/kernel/sinks/native-sync.js.map +1 -0
- package/dist/kernel/sinks/text-formats.d.ts +25 -0
- package/dist/kernel/sinks/text-formats.d.ts.map +1 -0
- package/dist/kernel/sinks/text-formats.js +69 -0
- package/dist/kernel/sinks/text-formats.js.map +1 -0
- package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
- package/dist/kernel/sinks/text-track-sink.js +22 -4
- package/dist/kernel/sinks/text-track-sink.js.map +1 -1
- package/dist/kernel/timeline.d.ts +10 -6
- package/dist/kernel/timeline.d.ts.map +1 -1
- package/dist/kernel/timeline.js +14 -6
- package/dist/kernel/timeline.js.map +1 -1
- package/dist/kernel/track-registry.d.ts +2 -2
- package/dist/kernel/track-registry.d.ts.map +1 -1
- package/dist/kernel/track-registry.js +5 -3
- package/dist/kernel/track-registry.js.map +1 -1
- package/dist/kernel/transport.d.ts +8 -0
- package/dist/kernel/transport.d.ts.map +1 -1
- package/dist/kernel/transport.js +28 -1
- package/dist/kernel/transport.js.map +1 -1
- package/dist/presets/full/index.d.ts.map +1 -1
- package/dist/presets/full/index.js +21 -1
- package/dist/presets/full/index.js.map +1 -1
- package/dist/protocols/adapter-shared.d.ts +8 -0
- package/dist/protocols/adapter-shared.d.ts.map +1 -1
- package/dist/protocols/adapter-shared.js +6 -0
- package/dist/protocols/adapter-shared.js.map +1 -1
- package/dist/protocols/dash-cmaf/index.d.ts +9 -1
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +78 -14
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +430 -94
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/dash-cmaf/periods-runtime.d.ts +6 -0
- package/dist/protocols/dash-cmaf/periods-runtime.d.ts.map +1 -0
- package/dist/protocols/dash-cmaf/periods-runtime.js +121 -0
- package/dist/protocols/dash-cmaf/periods-runtime.js.map +1 -0
- package/dist/protocols/dash-cmaf/periods.d.ts +24 -0
- package/dist/protocols/dash-cmaf/periods.d.ts.map +1 -0
- package/dist/protocols/dash-cmaf/periods.js +210 -0
- package/dist/protocols/dash-cmaf/periods.js.map +1 -0
- package/dist/protocols/hls-cmaf/index.d.ts +9 -1
- package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/index.js +49 -20
- 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 +1 -0
- package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts +3 -1
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +208 -24
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts +9 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.js +29 -3
- package/dist/protocols/hls-cmaf/unavailable.js.map +1 -1
- package/dist/protocols/hls-live/index.d.ts +9 -1
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js +36 -7
- 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 +24 -8
- package/dist/stages/abr/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts +3 -1
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +8 -5
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/cmcd/index.d.ts.map +1 -1
- package/dist/stages/cmcd/index.js +39 -3
- package/dist/stages/cmcd/index.js.map +1 -1
- package/dist/stages/cmsd/index.d.ts +22 -0
- package/dist/stages/cmsd/index.d.ts.map +1 -0
- package/dist/stages/cmsd/index.js +65 -0
- package/dist/stages/cmsd/index.js.map +1 -0
- package/dist/stages/codec-probe/index.d.ts.map +1 -1
- package/dist/stages/codec-probe/index.js +30 -3
- package/dist/stages/codec-probe/index.js.map +1 -1
- package/dist/stages/eme-core/index.d.ts +14 -0
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +38 -5
- package/dist/stages/eme-core/index.js.map +1 -1
- package/dist/stages/eme-fairplay/index.d.ts +5 -0
- package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
- package/dist/stages/eme-fairplay/index.js +17 -6
- package/dist/stages/eme-fairplay/index.js.map +1 -1
- package/dist/stages/hdr/index.d.ts +22 -0
- package/dist/stages/hdr/index.d.ts.map +1 -0
- package/dist/stages/hdr/index.js +191 -0
- package/dist/stages/hdr/index.js.map +1 -0
- package/dist/stages/meta-id3/index.d.ts.map +1 -1
- package/dist/stages/meta-id3/index.js +6 -2
- package/dist/stages/meta-id3/index.js.map +1 -1
- package/dist/stages/qoe/index.d.ts +32 -0
- package/dist/stages/qoe/index.d.ts.map +1 -0
- package/dist/stages/qoe/index.js +116 -0
- package/dist/stages/qoe/index.js.map +1 -0
- package/dist/stages/rendition-names/index.d.ts +41 -0
- package/dist/stages/rendition-names/index.d.ts.map +1 -0
- package/dist/stages/rendition-names/index.js +101 -0
- package/dist/stages/rendition-names/index.js.map +1 -0
- package/dist/stages/text-cea608/decode.d.ts +23 -2
- package/dist/stages/text-cea608/decode.d.ts.map +1 -1
- package/dist/stages/text-cea608/decode.js +59 -6
- package/dist/stages/text-cea608/decode.js.map +1 -1
- package/dist/stages/text-cea608/index.d.ts +9 -9
- package/dist/stages/text-cea608/index.d.ts.map +1 -1
- package/dist/stages/text-cea608/index.js +31 -105
- package/dist/stages/text-cea608/index.js.map +1 -1
- package/dist/stages/text-cea708/decode.d.ts +79 -0
- package/dist/stages/text-cea708/decode.d.ts.map +1 -0
- package/dist/stages/text-cea708/decode.js +410 -0
- package/dist/stages/text-cea708/decode.js.map +1 -0
- package/dist/stages/text-cea708/index.d.ts +3 -0
- package/dist/stages/text-cea708/index.d.ts.map +1 -0
- package/dist/stages/text-cea708/index.js +93 -0
- package/dist/stages/text-cea708/index.js.map +1 -0
- package/dist/stages/text-ttml/index.d.ts +3 -0
- package/dist/stages/text-ttml/index.d.ts.map +1 -0
- package/dist/stages/text-ttml/index.js +74 -0
- package/dist/stages/text-ttml/index.js.map +1 -0
- package/dist/stages/text-ttml/parse.d.ts +16 -0
- package/dist/stages/text-ttml/parse.d.ts.map +1 -0
- package/dist/stages/text-ttml/parse.js +277 -0
- package/dist/stages/text-ttml/parse.js.map +1 -0
- package/dist/stages/text-webvtt/index.d.ts +6 -13
- package/dist/stages/text-webvtt/index.d.ts.map +1 -1
- package/dist/stages/text-webvtt/index.js +21 -68
- package/dist/stages/text-webvtt/index.js.map +1 -1
- package/dist/stages/timed-metadata/index.d.ts +15 -0
- package/dist/stages/timed-metadata/index.d.ts.map +1 -0
- package/dist/stages/timed-metadata/index.js +370 -0
- package/dist/stages/timed-metadata/index.js.map +1 -0
- package/dist/types/error.d.ts +1 -1
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/facade.d.ts +8 -10
- package/dist/types/facade.d.ts.map +1 -1
- package/dist/types/ir.d.ts +90 -0
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +8 -0
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/messages.d.ts +10 -1
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/metadata.d.ts +59 -0
- package/dist/types/metadata.d.ts.map +1 -0
- package/dist/types/metadata.js +7 -0
- package/dist/types/metadata.js.map +1 -0
- package/dist/types/quality.d.ts +10 -0
- package/dist/types/quality.d.ts.map +1 -1
- package/dist/types/stage.d.ts +17 -0
- package/dist/types/stage.d.ts.map +1 -1
- package/package.json +10 -2
|
@@ -19,6 +19,7 @@ import { base64ToBytes } from '../../kernel/base64.js';
|
|
|
19
19
|
import { resolveUrl as resolve } from '../../kernel/url.js';
|
|
20
20
|
import { manifestError } from '../adapter-shared.js';
|
|
21
21
|
import { dimensions } from '../dimensions.js';
|
|
22
|
+
import { flattenPeriods } from './periods.js';
|
|
22
23
|
/** ISO 8601 duration to seconds. Date parts use nominal day lengths. */
|
|
23
24
|
export function parseDuration(value) {
|
|
24
25
|
if (value === null)
|
|
@@ -148,6 +149,40 @@ function audioCharacteristics(adaptationSet) {
|
|
|
148
149
|
}
|
|
149
150
|
return tags;
|
|
150
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* ISO/IEC 23009-1 §5.10.2: a Period's EventStreams. Each Event's
|
|
154
|
+
* presentationTime counts in the stream's timescale from its
|
|
155
|
+
* presentationTimeOffset, relative to the Period start. The body is the
|
|
156
|
+
* messageData attribute, or else the element's text. Events carry the
|
|
157
|
+
* scheme as written; nothing here decides what one means.
|
|
158
|
+
*/
|
|
159
|
+
function eventsOf(periodElement, periodStart) {
|
|
160
|
+
const out = [];
|
|
161
|
+
for (const stream of children(periodElement, 'EventStream')) {
|
|
162
|
+
const scheme = attr(stream, 'schemeIdUri');
|
|
163
|
+
if (scheme === null)
|
|
164
|
+
continue;
|
|
165
|
+
const value = attr(stream, 'value');
|
|
166
|
+
const timescale = numberAttr(stream, 'timescale') ?? 1;
|
|
167
|
+
const offset = numberAttr(stream, 'presentationTimeOffset') ?? 0;
|
|
168
|
+
let index = 0;
|
|
169
|
+
for (const event of children(stream, 'Event')) {
|
|
170
|
+
const time = numberAttr(event, 'presentationTime') ?? 0;
|
|
171
|
+
const duration = numberAttr(event, 'duration');
|
|
172
|
+
const data = attr(event, 'messageData') ?? event.textContent?.trim() ?? '';
|
|
173
|
+
out.push({
|
|
174
|
+
scheme,
|
|
175
|
+
...(value !== null ? { value } : {}),
|
|
176
|
+
id: attr(event, 'id') ?? `${scheme}:${index}`,
|
|
177
|
+
start: periodStart + (time - offset) / timescale,
|
|
178
|
+
...(duration !== null ? { duration: duration / timescale } : {}),
|
|
179
|
+
...(data !== '' ? { data } : {}),
|
|
180
|
+
});
|
|
181
|
+
index += 1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return out.sort((a, b) => a.start - b.start);
|
|
185
|
+
}
|
|
151
186
|
const CEA608_SCHEME = 'urn:scte:dash:cc:cea-608:2015';
|
|
152
187
|
/**
|
|
153
188
|
* SCTE 214-1: an Accessibility descriptor with the CEA-608 scheme names the
|
|
@@ -182,6 +217,112 @@ function captionChannels(adaptationSet) {
|
|
|
182
217
|
}
|
|
183
218
|
return out;
|
|
184
219
|
}
|
|
220
|
+
const CEA708_SCHEME = 'urn:scte:dash:cc:cea-708:2015';
|
|
221
|
+
/**
|
|
222
|
+
* SCTE 214-1: an Accessibility descriptor with the CEA-708 scheme names the
|
|
223
|
+
* caption services of a video AdaptationSet, as "1=lang:eng;2=lang:spa"
|
|
224
|
+
* (other keys such as `war` and `er` beside `lang` are ignored), "1=eng", or
|
|
225
|
+
* bare languages in service order. An empty value means service 1.
|
|
226
|
+
*/
|
|
227
|
+
function captionServices(adaptationSet) {
|
|
228
|
+
const out = [];
|
|
229
|
+
for (const descriptor of children(adaptationSet, 'Accessibility')) {
|
|
230
|
+
if (attr(descriptor, 'schemeIdUri') !== CEA708_SCHEME)
|
|
231
|
+
continue;
|
|
232
|
+
const value = (attr(descriptor, 'value') ?? '').trim();
|
|
233
|
+
if (value === '') {
|
|
234
|
+
out.push(['SERVICE1', null]);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
value.split(';').forEach((entry, index) => {
|
|
238
|
+
const [left, right] = entry.split('=');
|
|
239
|
+
const service = right === undefined ? index + 1 : Number.parseInt(left, 10);
|
|
240
|
+
const keys = (right ?? left).split(',');
|
|
241
|
+
const lang = keys.find((key) => key.trim().startsWith('lang:'))?.split(':')[1] ??
|
|
242
|
+
(keys.length === 1 && !keys[0]?.includes(':') ? keys[0] : undefined);
|
|
243
|
+
if (service >= 1 && service <= 63)
|
|
244
|
+
out.push([`SERVICE${service}`, lang?.trim() || null]);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
const TRANSFER_CHARACTERISTICS = 'urn:mpeg:mpegB:cicp:TransferCharacteristics';
|
|
250
|
+
/**
|
|
251
|
+
* The video range a representation signals: the CICP transfer
|
|
252
|
+
* characteristics property (ISO/IEC 23001-8; DASH-IF IOP), 16 for PQ and 18
|
|
253
|
+
* for HLG, on the Representation or its AdaptationSet; else PQ for a Dolby
|
|
254
|
+
* Vision codec; else nothing.
|
|
255
|
+
*/
|
|
256
|
+
/**
|
|
257
|
+
* `@scte214:supplementalCodecs` (ETSI TS 103 285 §5.2.3): a Dolby Vision
|
|
258
|
+
* layer over the base codec. Read by local name, since the prefix is the
|
|
259
|
+
* manifest's choice.
|
|
260
|
+
*/
|
|
261
|
+
function supplementalOf(representation, adaptationSet) {
|
|
262
|
+
for (const element of [representation, adaptationSet]) {
|
|
263
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
264
|
+
if (attribute.localName === 'supplementalCodecs') {
|
|
265
|
+
return { supplementalCodecs: attribute.value };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return {};
|
|
270
|
+
}
|
|
271
|
+
function videoRangeOf(representation, adaptationSet, codecs) {
|
|
272
|
+
for (const element of [representation, adaptationSet]) {
|
|
273
|
+
for (const property of [
|
|
274
|
+
...children(element, 'EssentialProperty'),
|
|
275
|
+
...children(element, 'SupplementalProperty'),
|
|
276
|
+
]) {
|
|
277
|
+
if (attr(property, 'schemeIdUri') !== TRANSFER_CHARACTERISTICS)
|
|
278
|
+
continue;
|
|
279
|
+
const value = attr(property, 'value');
|
|
280
|
+
return { videoRange: value === '16' ? 'PQ' : value === '18' ? 'HLG' : 'SDR' };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return codecs !== null && /^dv(h1|he|a1|av)/.test(codecs) ? { videoRange: 'PQ' } : {};
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Channel counts by ISO/IEC 23091-3 ChannelConfiguration index, from 1 to
|
|
287
|
+
* 20 (index 8 is reserved, so 0, as an unknown count).
|
|
288
|
+
*/
|
|
289
|
+
const CICP_CHANNELS = [1, 2, 3, 4, 5, 6, 8, 0, 3, 4, 7, 8, 24, 8, 12, 10, 12, 14, 12, 14];
|
|
290
|
+
/**
|
|
291
|
+
* The channel count an AudioChannelConfiguration declares, on the
|
|
292
|
+
* Representation or its AdaptationSet. The MPEG scheme
|
|
293
|
+
* (ISO/IEC 23009-1 §5.8.5.4) writes the count; the CICP scheme an index;
|
|
294
|
+
* the Dolby scheme (ETSI TS 102 366 Annex I) a 16-bit hex mask with one bit
|
|
295
|
+
* per speaker or speaker pair. Another scheme says nothing here.
|
|
296
|
+
*/
|
|
297
|
+
function channelsOf(representation, adaptationSet) {
|
|
298
|
+
for (const element of [representation, adaptationSet]) {
|
|
299
|
+
for (const config of children(element, 'AudioChannelConfiguration')) {
|
|
300
|
+
const scheme = attr(config, 'schemeIdUri') ?? '';
|
|
301
|
+
const value = attr(config, 'value') ?? '';
|
|
302
|
+
let channels = 0;
|
|
303
|
+
if (scheme === 'urn:mpeg:dash:23003:3:audio_channel_configuration:2011') {
|
|
304
|
+
channels = Number(value);
|
|
305
|
+
}
|
|
306
|
+
else if (scheme === 'urn:mpeg:mpegB:cicp:ChannelConfiguration') {
|
|
307
|
+
channels = CICP_CHANNELS[Number(value) - 1] ?? 0;
|
|
308
|
+
}
|
|
309
|
+
else if (/dolby.*audio_channel_configuration/.test(scheme)) {
|
|
310
|
+
// Bits 10, 9, 6, 5, 4, and 2 (mask 0x674) each name a speaker pair.
|
|
311
|
+
const mask = Number.parseInt(value, 16);
|
|
312
|
+
channels = bitCount(mask) + bitCount(mask & 0x674);
|
|
313
|
+
}
|
|
314
|
+
if (channels > 0)
|
|
315
|
+
return { channels };
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return {};
|
|
319
|
+
}
|
|
320
|
+
function bitCount(value) {
|
|
321
|
+
let count = 0;
|
|
322
|
+
for (let bits = value; bits > 0; bits >>= 1)
|
|
323
|
+
count += bits & 1;
|
|
324
|
+
return count;
|
|
325
|
+
}
|
|
185
326
|
/**
|
|
186
327
|
* A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
|
|
187
328
|
* representation declaring a playout rate other than 1. Both mark an
|
|
@@ -265,6 +406,79 @@ function mergeTemplates(levels) {
|
|
|
265
406
|
* SegmentTimeline into compressed runs. @r repeats; a negative @r repeats
|
|
266
407
|
* until the next S@t, or the period end on the last S.
|
|
267
408
|
*/
|
|
409
|
+
/**
|
|
410
|
+
* ISO/IEC 23009-1 §5.3.9.3: a SegmentList names each segment by URL and
|
|
411
|
+
* optional byte range, timed by @duration or a SegmentTimeline. The
|
|
412
|
+
* attributes and the Initialization inherit from Period to Representation;
|
|
413
|
+
* the SegmentURLs come from the deepest level that has them. Null when no
|
|
414
|
+
* level has a SegmentList.
|
|
415
|
+
*/
|
|
416
|
+
function segmentListOf(levels, base, periodStart, periodEndUnits) {
|
|
417
|
+
let timescale = 1;
|
|
418
|
+
let duration = null;
|
|
419
|
+
let startNumber = 1;
|
|
420
|
+
let offset = 0;
|
|
421
|
+
let initialization = null;
|
|
422
|
+
let timelineElement = null;
|
|
423
|
+
let urls = [];
|
|
424
|
+
let found = false;
|
|
425
|
+
for (const level of levels) {
|
|
426
|
+
const list = children(level, 'SegmentList')[0];
|
|
427
|
+
if (list === undefined)
|
|
428
|
+
continue;
|
|
429
|
+
found = true;
|
|
430
|
+
timescale = numberAttr(list, 'timescale') ?? timescale;
|
|
431
|
+
duration = numberAttr(list, 'duration') ?? duration;
|
|
432
|
+
startNumber = numberAttr(list, 'startNumber') ?? startNumber;
|
|
433
|
+
offset = numberAttr(list, 'presentationTimeOffset') ?? offset;
|
|
434
|
+
initialization = children(list, 'Initialization')[0] ?? initialization;
|
|
435
|
+
timelineElement = children(list, 'SegmentTimeline')[0] ?? timelineElement;
|
|
436
|
+
const here = children(list, 'SegmentURL');
|
|
437
|
+
if (here.length > 0)
|
|
438
|
+
urls = here;
|
|
439
|
+
}
|
|
440
|
+
if (!found)
|
|
441
|
+
return null;
|
|
442
|
+
// Start and duration of each listed segment, in timescale units.
|
|
443
|
+
const times = [];
|
|
444
|
+
if (timelineElement !== null) {
|
|
445
|
+
const runs = parseTimeline(timelineElement, periodEndUnits(timescale, offset));
|
|
446
|
+
if (runs === null)
|
|
447
|
+
return 'invalid';
|
|
448
|
+
for (const run of runs) {
|
|
449
|
+
for (let i = 0; i < run.count; i += 1)
|
|
450
|
+
times.push([run.start + i * run.duration, run.duration]);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
else if (duration !== null) {
|
|
454
|
+
for (let i = 0; i < urls.length; i += 1)
|
|
455
|
+
times.push([offset + i * duration, duration]);
|
|
456
|
+
}
|
|
457
|
+
else if (urls.length > 1) {
|
|
458
|
+
// Several segments need a duration; a single one spans the period.
|
|
459
|
+
return 'invalid';
|
|
460
|
+
}
|
|
461
|
+
const segments = [];
|
|
462
|
+
urls.forEach((url, i) => {
|
|
463
|
+
const [time, length] = times[i] ?? [offset, 0];
|
|
464
|
+
const range = parseByteRange(attr(url, 'mediaRange'));
|
|
465
|
+
segments.push({
|
|
466
|
+
seq: startNumber + i,
|
|
467
|
+
start: periodStart + (time - offset) / timescale,
|
|
468
|
+
duration: length / timescale,
|
|
469
|
+
url: resolve(attr(url, 'media') ?? '', base),
|
|
470
|
+
...(range !== null ? { byteRange: range } : {}),
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
const initRange = initialization === null ? null : parseByteRange(attr(initialization, 'range'));
|
|
474
|
+
const init = initialization === null
|
|
475
|
+
? null
|
|
476
|
+
: {
|
|
477
|
+
url: resolve(attr(initialization, 'sourceURL') ?? '', base),
|
|
478
|
+
...(initRange !== null ? { byteRange: initRange } : {}),
|
|
479
|
+
};
|
|
480
|
+
return { segments, init };
|
|
481
|
+
}
|
|
268
482
|
function parseTimeline(timelineElement, periodEndUnits) {
|
|
269
483
|
const sElements = children(timelineElement, 'S');
|
|
270
484
|
const runs = [];
|
|
@@ -316,93 +530,53 @@ function contentTypeOf(adaptationSet, mimeType) {
|
|
|
316
530
|
return 'image';
|
|
317
531
|
if (mimeType.startsWith('text/') || mimeType === 'application/ttml+xml')
|
|
318
532
|
return 'text';
|
|
533
|
+
// Subtitles in fMP4 share video's MIME type; the codec tells them apart.
|
|
534
|
+
const codecs = attr(adaptationSet, 'codecs') ??
|
|
535
|
+
attr(children(adaptationSet, 'Representation')[0] ?? adaptationSet, 'codecs');
|
|
536
|
+
if (mimeType === 'application/mp4' && codecs !== null && /^(stpp|wvtt)/.test(codecs))
|
|
537
|
+
return 'text';
|
|
319
538
|
return 'video';
|
|
320
539
|
}
|
|
321
|
-
/**
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return { presentation: null, error: manifestError('not an MPD document') };
|
|
335
|
-
}
|
|
336
|
-
const isLive = attr(mpd, 'type') === 'dynamic';
|
|
337
|
-
const mpdDuration = parseDuration(attr(mpd, 'mediaPresentationDuration'));
|
|
338
|
-
const mpdBase = applyBaseUrl(mpd, baseUrl);
|
|
339
|
-
// Live delivery metadata, normalized for the dash-live stage. The parser
|
|
340
|
-
// only records; wall-clock arithmetic happens in the stage, from facts.
|
|
341
|
-
let live;
|
|
342
|
-
if (isLive) {
|
|
343
|
-
const availabilityStart = Date.parse(attr(mpd, 'availabilityStartTime') ?? '');
|
|
344
|
-
const updatePeriod = parseDuration(attr(mpd, 'minimumUpdatePeriod'));
|
|
345
|
-
const timeShiftDepth = parseDuration(attr(mpd, 'timeShiftBufferDepth'));
|
|
346
|
-
const holdBack = parseDuration(attr(mpd, 'suggestedPresentationDelay'));
|
|
347
|
-
const timing = children(mpd, 'UTCTiming')[0];
|
|
348
|
-
live = {
|
|
349
|
-
...(Number.isFinite(availabilityStart)
|
|
350
|
-
? { availabilityStart: availabilityStart / 1000 }
|
|
351
|
-
: {}),
|
|
352
|
-
...(updatePeriod !== null ? { updatePeriod } : {}),
|
|
353
|
-
...(timeShiftDepth !== null ? { timeShiftDepth } : {}),
|
|
354
|
-
...(holdBack !== null ? { holdBack } : {}),
|
|
355
|
-
...(timing !== undefined
|
|
356
|
-
? {
|
|
357
|
-
timeServer: {
|
|
358
|
-
scheme: attr(timing, 'schemeIdUri') ?? '',
|
|
359
|
-
value: attr(timing, 'value') ?? '',
|
|
360
|
-
},
|
|
361
|
-
}
|
|
362
|
-
: {}),
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
// ContentSteering plus BaseURL@serviceLocation alternatives: the bases
|
|
366
|
-
// map is the DASH pathway table the steering stage switches between.
|
|
367
|
-
let steering;
|
|
368
|
-
const steeringElement = children(mpd, 'ContentSteering')[0];
|
|
369
|
-
if (steeringElement !== undefined) {
|
|
370
|
-
const serverUri = steeringElement.textContent?.trim() ?? '';
|
|
371
|
-
if (serverUri !== '') {
|
|
372
|
-
const bases = {};
|
|
373
|
-
for (const base of children(mpd, 'BaseURL')) {
|
|
374
|
-
const location = attr(base, 'serviceLocation');
|
|
375
|
-
const text = base.textContent?.trim();
|
|
376
|
-
if (location !== null && text !== undefined && text !== '') {
|
|
377
|
-
bases[location] = resolve(text, baseUrl);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
steering = {
|
|
381
|
-
serverUri: resolve(serverUri, baseUrl),
|
|
382
|
-
...(attr(steeringElement, 'defaultServiceLocation') !== null
|
|
383
|
-
? { defaultPathway: attr(steeringElement, 'defaultServiceLocation') }
|
|
384
|
-
: {}),
|
|
385
|
-
...(Object.keys(bases).length > 0 ? { bases } : {}),
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
const periodElements = children(mpd, 'Period');
|
|
390
|
-
const periodElement = periodElements[0];
|
|
391
|
-
if (periodElement === undefined) {
|
|
392
|
-
return {
|
|
393
|
-
presentation: null,
|
|
394
|
-
error: {
|
|
395
|
-
category: 'manifest',
|
|
396
|
-
code: 'MANIFEST_EMPTY',
|
|
397
|
-
fatal: true,
|
|
398
|
-
recoverable: false,
|
|
399
|
-
context: { reason: 'MPD with no Period' },
|
|
400
|
-
},
|
|
401
|
-
};
|
|
540
|
+
/**
|
|
541
|
+
* Each Period's start and duration (ISO/IEC 23009-1 §5.3.2.1): `@start`, or
|
|
542
|
+
* where the previous period ends; `@duration`, or up to the next period's
|
|
543
|
+
* start, or up to the presentation's end.
|
|
544
|
+
*/
|
|
545
|
+
function periodSpans(elements, mpdDuration) {
|
|
546
|
+
const starts = [];
|
|
547
|
+
let previousEnd = 0;
|
|
548
|
+
for (const element of elements) {
|
|
549
|
+
const start = parseDuration(attr(element, 'start')) ?? previousEnd;
|
|
550
|
+
const duration = parseDuration(attr(element, 'duration'));
|
|
551
|
+
starts.push(start);
|
|
552
|
+
previousEnd = start !== null && duration !== null ? start + duration : null;
|
|
402
553
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
554
|
+
return elements.map((element, i) => {
|
|
555
|
+
const start = starts[i] ?? 0;
|
|
556
|
+
const next = starts[i + 1];
|
|
557
|
+
const duration = parseDuration(attr(element, 'duration')) ??
|
|
558
|
+
(next !== null && next !== undefined
|
|
559
|
+
? next - start
|
|
560
|
+
: mpdDuration !== null
|
|
561
|
+
? mpdDuration - start
|
|
562
|
+
: null);
|
|
563
|
+
return { start, duration };
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* The earlier periods an AdaptationSet continues: DASH-IF IOP period
|
|
568
|
+
* continuity and connectivity (ISO/IEC 23009-1 §5.3.2.4), whose value names
|
|
569
|
+
* the earlier Period's id.
|
|
570
|
+
*/
|
|
571
|
+
function followsOf(adaptationSet) {
|
|
572
|
+
return children(adaptationSet, 'SupplementalProperty')
|
|
573
|
+
.filter((property) => /^urn:mpeg:dash:period-(continuity|connectivity):2015$/.test(attr(property, 'schemeIdUri') ?? ''))
|
|
574
|
+
.flatMap((property) => (attr(property, 'value') ?? '').split(/[\s,]+/).filter((v) => v !== ''));
|
|
575
|
+
}
|
|
576
|
+
function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
577
|
+
const matching = new Map();
|
|
578
|
+
const periodStart = span.start;
|
|
579
|
+
const periodDuration = span.duration;
|
|
406
580
|
const periodBase = applyBaseUrl(periodElement, mpdBase);
|
|
407
581
|
const tracks = [];
|
|
408
582
|
const adaptationSets = children(periodElement, 'AdaptationSet');
|
|
@@ -468,6 +642,37 @@ export function parse(text, baseUrl) {
|
|
|
468
642
|
...(w !== null ? { width: w } : {}),
|
|
469
643
|
...(h !== null ? { height: h } : {}),
|
|
470
644
|
...(fr !== null ? { frameRate: fr } : {}),
|
|
645
|
+
...videoRangeOf(representation, adaptationSet, attr(representation, 'codecs') ?? asCodecs),
|
|
646
|
+
...channelsOf(representation, adaptationSet),
|
|
647
|
+
...supplementalOf(representation, adaptationSet),
|
|
648
|
+
});
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
const list = segmentListOf([periodElement, adaptationSet, representation], repBase, periodStart, (timescale, offset) => periodDuration !== null ? Math.round(offset + periodDuration * timescale) : null);
|
|
652
|
+
if (list === 'invalid') {
|
|
653
|
+
return { error: manifestError(`bad SegmentList in '${id}'`) };
|
|
654
|
+
}
|
|
655
|
+
if (list !== null) {
|
|
656
|
+
// A single segment with no duration spans the period.
|
|
657
|
+
const segments = list.segments.map((segment) => segment.duration === 0 && periodDuration !== null
|
|
658
|
+
? { ...segment, duration: periodDuration }
|
|
659
|
+
: segment);
|
|
660
|
+
renditions.push({
|
|
661
|
+
id,
|
|
662
|
+
bitrate: bandwidth,
|
|
663
|
+
codecs: attr(representation, 'codecs') ?? asCodecs,
|
|
664
|
+
mimeType,
|
|
665
|
+
segments,
|
|
666
|
+
...(list.init !== null ? { init: list.init } : {}),
|
|
667
|
+
...(numberAttr(representation, 'width') !== null
|
|
668
|
+
? { width: numberAttr(representation, 'width') }
|
|
669
|
+
: {}),
|
|
670
|
+
...(numberAttr(representation, 'height') !== null
|
|
671
|
+
? { height: numberAttr(representation, 'height') }
|
|
672
|
+
: {}),
|
|
673
|
+
...videoRangeOf(representation, adaptationSet, attr(representation, 'codecs') ?? asCodecs),
|
|
674
|
+
...channelsOf(representation, adaptationSet),
|
|
675
|
+
...supplementalOf(representation, adaptationSet),
|
|
471
676
|
});
|
|
472
677
|
continue;
|
|
473
678
|
}
|
|
@@ -495,7 +700,7 @@ export function parse(text, baseUrl) {
|
|
|
495
700
|
? parseTimeline(template.timelineElement, periodEndUnits)
|
|
496
701
|
: null;
|
|
497
702
|
if (template.timelineElement !== null && timeline === null) {
|
|
498
|
-
return {
|
|
703
|
+
return { error: manifestError(`bad SegmentTimeline in '${id}'`) };
|
|
499
704
|
}
|
|
500
705
|
let endSeq = null;
|
|
501
706
|
if (timeline !== null) {
|
|
@@ -508,7 +713,7 @@ export function parse(text, baseUrl) {
|
|
|
508
713
|
Math.ceil((periodDuration * template.timescale) / template.duration);
|
|
509
714
|
}
|
|
510
715
|
else if (template.duration === null) {
|
|
511
|
-
return {
|
|
716
|
+
return { error: manifestError(`no addressing for '${id}'`) };
|
|
512
717
|
}
|
|
513
718
|
const segments = {
|
|
514
719
|
kind: 'indexed',
|
|
@@ -543,8 +748,11 @@ export function parse(text, baseUrl) {
|
|
|
543
748
|
...(width !== null ? { width } : {}),
|
|
544
749
|
...(height !== null ? { height } : {}),
|
|
545
750
|
...(frameRate !== null ? { frameRate } : {}),
|
|
751
|
+
...videoRangeOf(representation, adaptationSet, attr(representation, 'codecs') ?? asCodecs),
|
|
546
752
|
...(tiles !== null ? { tiles } : {}),
|
|
547
753
|
...(playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}),
|
|
754
|
+
...channelsOf(representation, adaptationSet),
|
|
755
|
+
...supplementalOf(representation, adaptationSet),
|
|
548
756
|
});
|
|
549
757
|
}
|
|
550
758
|
if (renditions.length === 0)
|
|
@@ -556,10 +764,15 @@ export function parse(text, baseUrl) {
|
|
|
556
764
|
// forced_subtitle, which Shaka Player also accepts.
|
|
557
765
|
const forced = contentType === 'text' &&
|
|
558
766
|
(roles.includes('forced-subtitle') || roles.includes('forced_subtitle'));
|
|
767
|
+
// ISO/IEC 23009-1 §5.3.10: the first Label is the display name.
|
|
768
|
+
const label = children(adaptationSet, 'Label')[0]?.textContent?.trim();
|
|
769
|
+
const trackId = attr(adaptationSet, 'id') !== null ? `as-${attr(adaptationSet, 'id')}` : `as-i${asIndex}`;
|
|
770
|
+
matching.set(trackId, { asId: attr(adaptationSet, 'id'), follows: followsOf(adaptationSet) });
|
|
559
771
|
tracks.push({
|
|
560
|
-
id:
|
|
772
|
+
id: trackId,
|
|
561
773
|
contentType,
|
|
562
774
|
mimeType,
|
|
775
|
+
...(label !== undefined && label !== '' ? { name: label } : {}),
|
|
563
776
|
protection: protectionSchemes.length > 0 ? { schemes: protectionSchemes } : null,
|
|
564
777
|
renditions,
|
|
565
778
|
...(lang !== null ? { lang } : {}),
|
|
@@ -574,14 +787,20 @@ export function parse(text, baseUrl) {
|
|
|
574
787
|
// Without a video track there is nothing to carry them.
|
|
575
788
|
const hasVideo = tracks.some((t) => t.contentType === 'video');
|
|
576
789
|
for (const adaptationSet of hasVideo ? adaptationSets : []) {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
790
|
+
const channels = [
|
|
791
|
+
...captionChannels(adaptationSet).map(([channel, lang]) => ['608', channel, lang]),
|
|
792
|
+
...captionServices(adaptationSet).map(([service, lang]) => ['708', service, lang]),
|
|
793
|
+
];
|
|
794
|
+
for (const [format, instreamId, lang] of channels) {
|
|
795
|
+
const id = `cea${format}:${instreamId}`;
|
|
796
|
+
if (format === '608' && !/^CC[1-4]$/.test(instreamId))
|
|
797
|
+
continue;
|
|
798
|
+
if (tracks.some((t) => t.id === id))
|
|
580
799
|
continue;
|
|
581
800
|
tracks.push({
|
|
582
801
|
id,
|
|
583
802
|
contentType: 'text',
|
|
584
|
-
mimeType:
|
|
803
|
+
mimeType: `application/cea-${format}`,
|
|
585
804
|
protection: null,
|
|
586
805
|
...(lang !== null ? { lang } : {}),
|
|
587
806
|
role: 'caption',
|
|
@@ -590,6 +809,121 @@ export function parse(text, baseUrl) {
|
|
|
590
809
|
});
|
|
591
810
|
}
|
|
592
811
|
}
|
|
812
|
+
const events = eventsOf(periodElement, periodStart);
|
|
813
|
+
return {
|
|
814
|
+
id: attr(periodElement, 'id') ?? `p${index}`,
|
|
815
|
+
start: periodStart,
|
|
816
|
+
duration: periodDuration,
|
|
817
|
+
tracks,
|
|
818
|
+
events,
|
|
819
|
+
matching,
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
/** parse an MPD document into a Presentation. Never throws. */
|
|
823
|
+
export function parse(text, baseUrl) {
|
|
824
|
+
let doc;
|
|
825
|
+
try {
|
|
826
|
+
doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
827
|
+
}
|
|
828
|
+
catch (cause) {
|
|
829
|
+
return { presentation: null, error: { ...manifestError('unparsable XML'), cause } };
|
|
830
|
+
}
|
|
831
|
+
const mpd = doc.documentElement;
|
|
832
|
+
if (mpd === null ||
|
|
833
|
+
mpd.localName !== 'MPD' ||
|
|
834
|
+
doc.getElementsByTagName('parsererror').length > 0) {
|
|
835
|
+
return { presentation: null, error: manifestError('not an MPD document') };
|
|
836
|
+
}
|
|
837
|
+
const isLive = attr(mpd, 'type') === 'dynamic';
|
|
838
|
+
const mpdDuration = parseDuration(attr(mpd, 'mediaPresentationDuration'));
|
|
839
|
+
const mpdBase = applyBaseUrl(mpd, baseUrl);
|
|
840
|
+
// Live delivery metadata, normalized for the dash-live stage. The parser
|
|
841
|
+
// only records; wall-clock arithmetic happens in the stage, from facts.
|
|
842
|
+
let live;
|
|
843
|
+
if (isLive) {
|
|
844
|
+
const availabilityStart = Date.parse(attr(mpd, 'availabilityStartTime') ?? '');
|
|
845
|
+
const updatePeriod = parseDuration(attr(mpd, 'minimumUpdatePeriod'));
|
|
846
|
+
const timeShiftDepth = parseDuration(attr(mpd, 'timeShiftBufferDepth'));
|
|
847
|
+
const holdBack = parseDuration(attr(mpd, 'suggestedPresentationDelay'));
|
|
848
|
+
const timing = children(mpd, 'UTCTiming')[0];
|
|
849
|
+
live = {
|
|
850
|
+
...(Number.isFinite(availabilityStart)
|
|
851
|
+
? { availabilityStart: availabilityStart / 1000 }
|
|
852
|
+
: {}),
|
|
853
|
+
...(updatePeriod !== null ? { updatePeriod } : {}),
|
|
854
|
+
...(timeShiftDepth !== null ? { timeShiftDepth } : {}),
|
|
855
|
+
...(holdBack !== null ? { holdBack } : {}),
|
|
856
|
+
...(timing !== undefined
|
|
857
|
+
? {
|
|
858
|
+
timeServer: {
|
|
859
|
+
scheme: attr(timing, 'schemeIdUri') ?? '',
|
|
860
|
+
value: attr(timing, 'value') ?? '',
|
|
861
|
+
},
|
|
862
|
+
}
|
|
863
|
+
: {}),
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
// ContentSteering plus BaseURL@serviceLocation alternatives: the bases
|
|
867
|
+
// map is the DASH pathway table the steering stage switches between.
|
|
868
|
+
let steering;
|
|
869
|
+
const steeringElement = children(mpd, 'ContentSteering')[0];
|
|
870
|
+
if (steeringElement !== undefined) {
|
|
871
|
+
const serverUri = steeringElement.textContent?.trim() ?? '';
|
|
872
|
+
if (serverUri !== '') {
|
|
873
|
+
const bases = {};
|
|
874
|
+
for (const base of children(mpd, 'BaseURL')) {
|
|
875
|
+
const location = attr(base, 'serviceLocation');
|
|
876
|
+
const text = base.textContent?.trim();
|
|
877
|
+
if (location !== null && text !== undefined && text !== '') {
|
|
878
|
+
bases[location] = resolve(text, baseUrl);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
steering = {
|
|
882
|
+
serverUri: resolve(serverUri, baseUrl),
|
|
883
|
+
...(attr(steeringElement, 'defaultServiceLocation') !== null
|
|
884
|
+
? { defaultPathway: attr(steeringElement, 'defaultServiceLocation') }
|
|
885
|
+
: {}),
|
|
886
|
+
...(Object.keys(bases).length > 0 ? { bases } : {}),
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
const periodElements = children(mpd, 'Period');
|
|
891
|
+
if (periodElements.length === 0) {
|
|
892
|
+
return {
|
|
893
|
+
presentation: null,
|
|
894
|
+
error: {
|
|
895
|
+
category: 'manifest',
|
|
896
|
+
code: 'MANIFEST_EMPTY',
|
|
897
|
+
fatal: true,
|
|
898
|
+
recoverable: false,
|
|
899
|
+
context: { reason: 'MPD with no Period' },
|
|
900
|
+
},
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
const spans = periodSpans(periodElements, mpdDuration);
|
|
904
|
+
const parsed = [];
|
|
905
|
+
for (let i = 0; i < periodElements.length; i += 1) {
|
|
906
|
+
// A live MPD keeps its first period: listing a later period's segments
|
|
907
|
+
// needs the clock, which the parser does not have.
|
|
908
|
+
if (i > 0 && isLive)
|
|
909
|
+
break;
|
|
910
|
+
const result = parsePeriod(periodElements[i], spans[i], i, mpdBase, isLive);
|
|
911
|
+
if ('error' in result)
|
|
912
|
+
return { presentation: null, error: result.error };
|
|
913
|
+
parsed.push(result);
|
|
914
|
+
}
|
|
915
|
+
// Several periods play as one: tracks matched across them, each boundary a
|
|
916
|
+
// discontinuity. A period the flattening cannot take keeps the first alone.
|
|
917
|
+
const flat = parsed.length > 1 ? flattenPeriods(parsed) : null;
|
|
918
|
+
const first = parsed[0];
|
|
919
|
+
const tracks = flat?.tracks ?? first.tracks;
|
|
920
|
+
const events = flat?.events ?? first.events;
|
|
921
|
+
const lastSpan = flat === null ? first : parsed[parsed.length - 1];
|
|
922
|
+
const total = flat === null
|
|
923
|
+
? first.duration
|
|
924
|
+
: lastSpan.duration === null
|
|
925
|
+
? null
|
|
926
|
+
: lastSpan.start + lastSpan.duration - first.start;
|
|
593
927
|
if (tracks.length === 0) {
|
|
594
928
|
return {
|
|
595
929
|
presentation: null,
|
|
@@ -609,10 +943,11 @@ export function parse(text, baseUrl) {
|
|
|
609
943
|
...(mpdDuration !== null ? { duration: mpdDuration } : {}),
|
|
610
944
|
periods: [
|
|
611
945
|
{
|
|
612
|
-
id:
|
|
613
|
-
start:
|
|
614
|
-
...(
|
|
946
|
+
id: first.id,
|
|
947
|
+
start: first.start,
|
|
948
|
+
...(total !== null ? { duration: total } : {}),
|
|
615
949
|
tracks,
|
|
950
|
+
...(events.length > 0 ? { events } : {}),
|
|
616
951
|
},
|
|
617
952
|
],
|
|
618
953
|
couplings: [],
|
|
@@ -620,6 +955,7 @@ export function parse(text, baseUrl) {
|
|
|
620
955
|
...(steering !== undefined ? { steering } : {}),
|
|
621
956
|
},
|
|
622
957
|
error: null,
|
|
958
|
+
...(flat !== null && flat.warnings.length > 0 ? { warnings: flat.warnings } : {}),
|
|
623
959
|
};
|
|
624
960
|
}
|
|
625
961
|
/**
|