mattebox 0.9.0 → 0.11.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 +40 -14
- 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 +39 -5
- package/dist/es2015/kernel/prepare.js +2 -2
- package/dist/es2015/kernel/reducer.js +118 -26
- package/dist/es2015/kernel/refresh.js +2 -2
- package/dist/es2015/kernel/rendition-select.js +2 -1
- 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 +21 -1
- 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 +389 -106
- 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 +132 -22
- 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 +10 -5
- package/dist/es2015/stages/abr-persist/index.js +1 -1
- package/dist/es2015/stages/aes-128/index.js +1 -1
- package/dist/es2015/stages/alt-audio/index.js +31 -11
- package/dist/es2015/stages/chapters/index.js +2 -2
- package/dist/es2015/stages/chapters/parse.js +2 -2
- package/dist/es2015/stages/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 +22 -2
- package/dist/es2015/stages/eme-fairplay/index.js +1 -1
- 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 +56 -5
- package/dist/es2015/stages/text-cea608/index.js +29 -27
- package/dist/es2015/stages/text-cea708/decode.js +377 -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 +31 -62
- 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 +41 -11
- 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 +37 -2
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/reducer.d.ts +3 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +117 -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.map +1 -1
- package/dist/kernel/rendition-select.js +4 -2
- 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 +8 -8
- package/dist/kernel/track-registry.d.ts.map +1 -1
- package/dist/kernel/track-registry.js +29 -4
- 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 +419 -90
- 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 +169 -10
- 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 +10 -6
- package/dist/stages/abr/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts +5 -2
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +31 -11
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/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 +7 -0
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +26 -0
- package/dist/stages/eme-core/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 +55 -5
- package/dist/stages/text-cea608/decode.js.map +1 -1
- package/dist/stages/text-cea608/index.d.ts +10 -3
- package/dist/stages/text-cea608/index.d.ts.map +1 -1
- package/dist/stages/text-cea608/index.js +34 -34
- 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 +404 -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 -10
- package/dist/stages/text-webvtt/index.d.ts.map +1 -1
- package/dist/stages/text-webvtt/index.js +22 -64
- 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 +14 -10
- package/dist/types/facade.d.ts.map +1 -1
- package/dist/types/ir.d.ts +71 -0
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +11 -1
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +20 -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 +3 -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,124 @@ 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
|
+
}
|
|
186
|
+
const CEA608_SCHEME = 'urn:scte:dash:cc:cea-608:2015';
|
|
187
|
+
/**
|
|
188
|
+
* SCTE 214-1: an Accessibility descriptor with the CEA-608 scheme names the
|
|
189
|
+
* in-band caption channels of a video AdaptationSet, as "CC1=eng;CC3=fre",
|
|
190
|
+
* "1=eng", or bare languages. Bare languages take CC1 and CC3 when there
|
|
191
|
+
* are two, else CC1 to CC4 in order; an empty value means CC1. This is the
|
|
192
|
+
* reading Shaka Player applies.
|
|
193
|
+
*/
|
|
194
|
+
function captionChannels(adaptationSet) {
|
|
195
|
+
const out = [];
|
|
196
|
+
for (const descriptor of children(adaptationSet, 'Accessibility')) {
|
|
197
|
+
if (attr(descriptor, 'schemeIdUri') !== CEA608_SCHEME)
|
|
198
|
+
continue;
|
|
199
|
+
const value = (attr(descriptor, 'value') ?? '').trim();
|
|
200
|
+
if (value === '') {
|
|
201
|
+
out.push(['CC1', null]);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const entries = value.split(';');
|
|
205
|
+
let next = 1;
|
|
206
|
+
for (const entry of entries) {
|
|
207
|
+
const [left, right] = entry.split('=');
|
|
208
|
+
if (right === undefined) {
|
|
209
|
+
out.push([`CC${next}`, left.trim() || null]);
|
|
210
|
+
next += entries.length === 2 ? 2 : 1;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const channel = left.trim().startsWith('CC') ? left.trim() : `CC${left.trim()}`;
|
|
214
|
+
out.push([channel, right.trim() || null]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
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
|
+
function videoRangeOf(representation, adaptationSet, codecs) {
|
|
257
|
+
for (const element of [representation, adaptationSet]) {
|
|
258
|
+
for (const property of [
|
|
259
|
+
...children(element, 'EssentialProperty'),
|
|
260
|
+
...children(element, 'SupplementalProperty'),
|
|
261
|
+
]) {
|
|
262
|
+
if (attr(property, 'schemeIdUri') !== TRANSFER_CHARACTERISTICS)
|
|
263
|
+
continue;
|
|
264
|
+
const value = attr(property, 'value');
|
|
265
|
+
return { videoRange: value === '16' ? 'PQ' : value === '18' ? 'HLG' : 'SDR' };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return codecs !== null && /^dv(h1|he|a1|av)/.test(codecs) ? { videoRange: 'PQ' } : {};
|
|
269
|
+
}
|
|
151
270
|
/**
|
|
152
271
|
* A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
|
|
153
272
|
* representation declaring a playout rate other than 1. Both mark an
|
|
@@ -231,6 +350,79 @@ function mergeTemplates(levels) {
|
|
|
231
350
|
* SegmentTimeline into compressed runs. @r repeats; a negative @r repeats
|
|
232
351
|
* until the next S@t, or the period end on the last S.
|
|
233
352
|
*/
|
|
353
|
+
/**
|
|
354
|
+
* ISO/IEC 23009-1 §5.3.9.3: a SegmentList names each segment by URL and
|
|
355
|
+
* optional byte range, timed by @duration or a SegmentTimeline. The
|
|
356
|
+
* attributes and the Initialization inherit from Period to Representation;
|
|
357
|
+
* the SegmentURLs come from the deepest level that has them. Null when no
|
|
358
|
+
* level has a SegmentList.
|
|
359
|
+
*/
|
|
360
|
+
function segmentListOf(levels, base, periodStart, periodEndUnits) {
|
|
361
|
+
let timescale = 1;
|
|
362
|
+
let duration = null;
|
|
363
|
+
let startNumber = 1;
|
|
364
|
+
let offset = 0;
|
|
365
|
+
let initialization = null;
|
|
366
|
+
let timelineElement = null;
|
|
367
|
+
let urls = [];
|
|
368
|
+
let found = false;
|
|
369
|
+
for (const level of levels) {
|
|
370
|
+
const list = children(level, 'SegmentList')[0];
|
|
371
|
+
if (list === undefined)
|
|
372
|
+
continue;
|
|
373
|
+
found = true;
|
|
374
|
+
timescale = numberAttr(list, 'timescale') ?? timescale;
|
|
375
|
+
duration = numberAttr(list, 'duration') ?? duration;
|
|
376
|
+
startNumber = numberAttr(list, 'startNumber') ?? startNumber;
|
|
377
|
+
offset = numberAttr(list, 'presentationTimeOffset') ?? offset;
|
|
378
|
+
initialization = children(list, 'Initialization')[0] ?? initialization;
|
|
379
|
+
timelineElement = children(list, 'SegmentTimeline')[0] ?? timelineElement;
|
|
380
|
+
const here = children(list, 'SegmentURL');
|
|
381
|
+
if (here.length > 0)
|
|
382
|
+
urls = here;
|
|
383
|
+
}
|
|
384
|
+
if (!found)
|
|
385
|
+
return null;
|
|
386
|
+
// Start and duration of each listed segment, in timescale units.
|
|
387
|
+
const times = [];
|
|
388
|
+
if (timelineElement !== null) {
|
|
389
|
+
const runs = parseTimeline(timelineElement, periodEndUnits(timescale, offset));
|
|
390
|
+
if (runs === null)
|
|
391
|
+
return 'invalid';
|
|
392
|
+
for (const run of runs) {
|
|
393
|
+
for (let i = 0; i < run.count; i += 1)
|
|
394
|
+
times.push([run.start + i * run.duration, run.duration]);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
else if (duration !== null) {
|
|
398
|
+
for (let i = 0; i < urls.length; i += 1)
|
|
399
|
+
times.push([offset + i * duration, duration]);
|
|
400
|
+
}
|
|
401
|
+
else if (urls.length > 1) {
|
|
402
|
+
// Several segments need a duration; a single one spans the period.
|
|
403
|
+
return 'invalid';
|
|
404
|
+
}
|
|
405
|
+
const segments = [];
|
|
406
|
+
urls.forEach((url, i) => {
|
|
407
|
+
const [time, length] = times[i] ?? [offset, 0];
|
|
408
|
+
const range = parseByteRange(attr(url, 'mediaRange'));
|
|
409
|
+
segments.push({
|
|
410
|
+
seq: startNumber + i,
|
|
411
|
+
start: periodStart + (time - offset) / timescale,
|
|
412
|
+
duration: length / timescale,
|
|
413
|
+
url: resolve(attr(url, 'media') ?? '', base),
|
|
414
|
+
...(range !== null ? { byteRange: range } : {}),
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
const initRange = initialization === null ? null : parseByteRange(attr(initialization, 'range'));
|
|
418
|
+
const init = initialization === null
|
|
419
|
+
? null
|
|
420
|
+
: {
|
|
421
|
+
url: resolve(attr(initialization, 'sourceURL') ?? '', base),
|
|
422
|
+
...(initRange !== null ? { byteRange: initRange } : {}),
|
|
423
|
+
};
|
|
424
|
+
return { segments, init };
|
|
425
|
+
}
|
|
234
426
|
function parseTimeline(timelineElement, periodEndUnits) {
|
|
235
427
|
const sElements = children(timelineElement, 'S');
|
|
236
428
|
const runs = [];
|
|
@@ -282,93 +474,53 @@ function contentTypeOf(adaptationSet, mimeType) {
|
|
|
282
474
|
return 'image';
|
|
283
475
|
if (mimeType.startsWith('text/') || mimeType === 'application/ttml+xml')
|
|
284
476
|
return 'text';
|
|
477
|
+
// Subtitles in fMP4 share video's MIME type; the codec tells them apart.
|
|
478
|
+
const codecs = attr(adaptationSet, 'codecs') ??
|
|
479
|
+
attr(children(adaptationSet, 'Representation')[0] ?? adaptationSet, 'codecs');
|
|
480
|
+
if (mimeType === 'application/mp4' && codecs !== null && /^(stpp|wvtt)/.test(codecs))
|
|
481
|
+
return 'text';
|
|
285
482
|
return 'video';
|
|
286
483
|
}
|
|
287
|
-
/**
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return { presentation: null, error: manifestError('not an MPD document') };
|
|
301
|
-
}
|
|
302
|
-
const isLive = attr(mpd, 'type') === 'dynamic';
|
|
303
|
-
const mpdDuration = parseDuration(attr(mpd, 'mediaPresentationDuration'));
|
|
304
|
-
const mpdBase = applyBaseUrl(mpd, baseUrl);
|
|
305
|
-
// Live delivery metadata, normalized for the dash-live stage. The parser
|
|
306
|
-
// only records; wall-clock arithmetic happens in the stage, from facts.
|
|
307
|
-
let live;
|
|
308
|
-
if (isLive) {
|
|
309
|
-
const availabilityStart = Date.parse(attr(mpd, 'availabilityStartTime') ?? '');
|
|
310
|
-
const updatePeriod = parseDuration(attr(mpd, 'minimumUpdatePeriod'));
|
|
311
|
-
const timeShiftDepth = parseDuration(attr(mpd, 'timeShiftBufferDepth'));
|
|
312
|
-
const holdBack = parseDuration(attr(mpd, 'suggestedPresentationDelay'));
|
|
313
|
-
const timing = children(mpd, 'UTCTiming')[0];
|
|
314
|
-
live = {
|
|
315
|
-
...(Number.isFinite(availabilityStart)
|
|
316
|
-
? { availabilityStart: availabilityStart / 1000 }
|
|
317
|
-
: {}),
|
|
318
|
-
...(updatePeriod !== null ? { updatePeriod } : {}),
|
|
319
|
-
...(timeShiftDepth !== null ? { timeShiftDepth } : {}),
|
|
320
|
-
...(holdBack !== null ? { holdBack } : {}),
|
|
321
|
-
...(timing !== undefined
|
|
322
|
-
? {
|
|
323
|
-
timeServer: {
|
|
324
|
-
scheme: attr(timing, 'schemeIdUri') ?? '',
|
|
325
|
-
value: attr(timing, 'value') ?? '',
|
|
326
|
-
},
|
|
327
|
-
}
|
|
328
|
-
: {}),
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
// ContentSteering plus BaseURL@serviceLocation alternatives: the bases
|
|
332
|
-
// map is the DASH pathway table the steering stage switches between.
|
|
333
|
-
let steering;
|
|
334
|
-
const steeringElement = children(mpd, 'ContentSteering')[0];
|
|
335
|
-
if (steeringElement !== undefined) {
|
|
336
|
-
const serverUri = steeringElement.textContent?.trim() ?? '';
|
|
337
|
-
if (serverUri !== '') {
|
|
338
|
-
const bases = {};
|
|
339
|
-
for (const base of children(mpd, 'BaseURL')) {
|
|
340
|
-
const location = attr(base, 'serviceLocation');
|
|
341
|
-
const text = base.textContent?.trim();
|
|
342
|
-
if (location !== null && text !== undefined && text !== '') {
|
|
343
|
-
bases[location] = resolve(text, baseUrl);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
steering = {
|
|
347
|
-
serverUri: resolve(serverUri, baseUrl),
|
|
348
|
-
...(attr(steeringElement, 'defaultServiceLocation') !== null
|
|
349
|
-
? { defaultPathway: attr(steeringElement, 'defaultServiceLocation') }
|
|
350
|
-
: {}),
|
|
351
|
-
...(Object.keys(bases).length > 0 ? { bases } : {}),
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
const periodElements = children(mpd, 'Period');
|
|
356
|
-
const periodElement = periodElements[0];
|
|
357
|
-
if (periodElement === undefined) {
|
|
358
|
-
return {
|
|
359
|
-
presentation: null,
|
|
360
|
-
error: {
|
|
361
|
-
category: 'manifest',
|
|
362
|
-
code: 'MANIFEST_EMPTY',
|
|
363
|
-
fatal: true,
|
|
364
|
-
recoverable: false,
|
|
365
|
-
context: { reason: 'MPD with no Period' },
|
|
366
|
-
},
|
|
367
|
-
};
|
|
484
|
+
/**
|
|
485
|
+
* Each Period's start and duration (ISO/IEC 23009-1 §5.3.2.1): `@start`, or
|
|
486
|
+
* where the previous period ends; `@duration`, or up to the next period's
|
|
487
|
+
* start, or up to the presentation's end.
|
|
488
|
+
*/
|
|
489
|
+
function periodSpans(elements, mpdDuration) {
|
|
490
|
+
const starts = [];
|
|
491
|
+
let previousEnd = 0;
|
|
492
|
+
for (const element of elements) {
|
|
493
|
+
const start = parseDuration(attr(element, 'start')) ?? previousEnd;
|
|
494
|
+
const duration = parseDuration(attr(element, 'duration'));
|
|
495
|
+
starts.push(start);
|
|
496
|
+
previousEnd = start !== null && duration !== null ? start + duration : null;
|
|
368
497
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
498
|
+
return elements.map((element, i) => {
|
|
499
|
+
const start = starts[i] ?? 0;
|
|
500
|
+
const next = starts[i + 1];
|
|
501
|
+
const duration = parseDuration(attr(element, 'duration')) ??
|
|
502
|
+
(next !== null && next !== undefined
|
|
503
|
+
? next - start
|
|
504
|
+
: mpdDuration !== null
|
|
505
|
+
? mpdDuration - start
|
|
506
|
+
: null);
|
|
507
|
+
return { start, duration };
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* The earlier periods an AdaptationSet continues: DASH-IF IOP period
|
|
512
|
+
* continuity and connectivity (ISO/IEC 23009-1 §5.3.2.4), whose value names
|
|
513
|
+
* the earlier Period's id.
|
|
514
|
+
*/
|
|
515
|
+
function followsOf(adaptationSet) {
|
|
516
|
+
return children(adaptationSet, 'SupplementalProperty')
|
|
517
|
+
.filter((property) => /^urn:mpeg:dash:period-(continuity|connectivity):2015$/.test(attr(property, 'schemeIdUri') ?? ''))
|
|
518
|
+
.flatMap((property) => (attr(property, 'value') ?? '').split(/[\s,]+/).filter((v) => v !== ''));
|
|
519
|
+
}
|
|
520
|
+
function parsePeriod(periodElement, span, index, mpdBase, isLive) {
|
|
521
|
+
const matching = new Map();
|
|
522
|
+
const periodStart = span.start;
|
|
523
|
+
const periodDuration = span.duration;
|
|
372
524
|
const periodBase = applyBaseUrl(periodElement, mpdBase);
|
|
373
525
|
const tracks = [];
|
|
374
526
|
const adaptationSets = children(periodElement, 'AdaptationSet');
|
|
@@ -434,6 +586,33 @@ export function parse(text, baseUrl) {
|
|
|
434
586
|
...(w !== null ? { width: w } : {}),
|
|
435
587
|
...(h !== null ? { height: h } : {}),
|
|
436
588
|
...(fr !== null ? { frameRate: fr } : {}),
|
|
589
|
+
...videoRangeOf(representation, adaptationSet, attr(representation, 'codecs') ?? asCodecs),
|
|
590
|
+
});
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
const list = segmentListOf([periodElement, adaptationSet, representation], repBase, periodStart, (timescale, offset) => periodDuration !== null ? Math.round(offset + periodDuration * timescale) : null);
|
|
594
|
+
if (list === 'invalid') {
|
|
595
|
+
return { error: manifestError(`bad SegmentList in '${id}'`) };
|
|
596
|
+
}
|
|
597
|
+
if (list !== null) {
|
|
598
|
+
// A single segment with no duration spans the period.
|
|
599
|
+
const segments = list.segments.map((segment) => segment.duration === 0 && periodDuration !== null
|
|
600
|
+
? { ...segment, duration: periodDuration }
|
|
601
|
+
: segment);
|
|
602
|
+
renditions.push({
|
|
603
|
+
id,
|
|
604
|
+
bitrate: bandwidth,
|
|
605
|
+
codecs: attr(representation, 'codecs') ?? asCodecs,
|
|
606
|
+
mimeType,
|
|
607
|
+
segments,
|
|
608
|
+
...(list.init !== null ? { init: list.init } : {}),
|
|
609
|
+
...(numberAttr(representation, 'width') !== null
|
|
610
|
+
? { width: numberAttr(representation, 'width') }
|
|
611
|
+
: {}),
|
|
612
|
+
...(numberAttr(representation, 'height') !== null
|
|
613
|
+
? { height: numberAttr(representation, 'height') }
|
|
614
|
+
: {}),
|
|
615
|
+
...videoRangeOf(representation, adaptationSet, attr(representation, 'codecs') ?? asCodecs),
|
|
437
616
|
});
|
|
438
617
|
continue;
|
|
439
618
|
}
|
|
@@ -461,7 +640,7 @@ export function parse(text, baseUrl) {
|
|
|
461
640
|
? parseTimeline(template.timelineElement, periodEndUnits)
|
|
462
641
|
: null;
|
|
463
642
|
if (template.timelineElement !== null && timeline === null) {
|
|
464
|
-
return {
|
|
643
|
+
return { error: manifestError(`bad SegmentTimeline in '${id}'`) };
|
|
465
644
|
}
|
|
466
645
|
let endSeq = null;
|
|
467
646
|
if (timeline !== null) {
|
|
@@ -474,7 +653,7 @@ export function parse(text, baseUrl) {
|
|
|
474
653
|
Math.ceil((periodDuration * template.timescale) / template.duration);
|
|
475
654
|
}
|
|
476
655
|
else if (template.duration === null) {
|
|
477
|
-
return {
|
|
656
|
+
return { error: manifestError(`no addressing for '${id}'`) };
|
|
478
657
|
}
|
|
479
658
|
const segments = {
|
|
480
659
|
kind: 'indexed',
|
|
@@ -509,6 +688,7 @@ export function parse(text, baseUrl) {
|
|
|
509
688
|
...(width !== null ? { width } : {}),
|
|
510
689
|
...(height !== null ? { height } : {}),
|
|
511
690
|
...(frameRate !== null ? { frameRate } : {}),
|
|
691
|
+
...videoRangeOf(representation, adaptationSet, attr(representation, 'codecs') ?? asCodecs),
|
|
512
692
|
...(tiles !== null ? { tiles } : {}),
|
|
513
693
|
...(playoutRate !== null ? { maxPlayoutRate: playoutRate } : {}),
|
|
514
694
|
});
|
|
@@ -522,10 +702,15 @@ export function parse(text, baseUrl) {
|
|
|
522
702
|
// forced_subtitle, which Shaka Player also accepts.
|
|
523
703
|
const forced = contentType === 'text' &&
|
|
524
704
|
(roles.includes('forced-subtitle') || roles.includes('forced_subtitle'));
|
|
705
|
+
// ISO/IEC 23009-1 §5.3.10: the first Label is the display name.
|
|
706
|
+
const label = children(adaptationSet, 'Label')[0]?.textContent?.trim();
|
|
707
|
+
const trackId = attr(adaptationSet, 'id') !== null ? `as-${attr(adaptationSet, 'id')}` : `as-i${asIndex}`;
|
|
708
|
+
matching.set(trackId, { asId: attr(adaptationSet, 'id'), follows: followsOf(adaptationSet) });
|
|
525
709
|
tracks.push({
|
|
526
|
-
id:
|
|
710
|
+
id: trackId,
|
|
527
711
|
contentType,
|
|
528
712
|
mimeType,
|
|
713
|
+
...(label !== undefined && label !== '' ? { name: label } : {}),
|
|
529
714
|
protection: protectionSchemes.length > 0 ? { schemes: protectionSchemes } : null,
|
|
530
715
|
renditions,
|
|
531
716
|
...(lang !== null ? { lang } : {}),
|
|
@@ -535,6 +720,148 @@ export function parse(text, baseUrl) {
|
|
|
535
720
|
...(forced ? { forced: true } : {}),
|
|
536
721
|
});
|
|
537
722
|
}
|
|
723
|
+
// In-band captions ride the video: one text track per channel the
|
|
724
|
+
// AdaptationSets declare, with no segments; the caption stage reads them.
|
|
725
|
+
// Without a video track there is nothing to carry them.
|
|
726
|
+
const hasVideo = tracks.some((t) => t.contentType === 'video');
|
|
727
|
+
for (const adaptationSet of hasVideo ? adaptationSets : []) {
|
|
728
|
+
const channels = [
|
|
729
|
+
...captionChannels(adaptationSet).map(([channel, lang]) => ['608', channel, lang]),
|
|
730
|
+
...captionServices(adaptationSet).map(([service, lang]) => ['708', service, lang]),
|
|
731
|
+
];
|
|
732
|
+
for (const [format, instreamId, lang] of channels) {
|
|
733
|
+
const id = `cea${format}:${instreamId}`;
|
|
734
|
+
if (format === '608' && !/^CC[1-4]$/.test(instreamId))
|
|
735
|
+
continue;
|
|
736
|
+
if (tracks.some((t) => t.id === id))
|
|
737
|
+
continue;
|
|
738
|
+
tracks.push({
|
|
739
|
+
id,
|
|
740
|
+
contentType: 'text',
|
|
741
|
+
mimeType: `application/cea-${format}`,
|
|
742
|
+
protection: null,
|
|
743
|
+
...(lang !== null ? { lang } : {}),
|
|
744
|
+
role: 'caption',
|
|
745
|
+
instreamId,
|
|
746
|
+
renditions: [],
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
const events = eventsOf(periodElement, periodStart);
|
|
751
|
+
return {
|
|
752
|
+
id: attr(periodElement, 'id') ?? `p${index}`,
|
|
753
|
+
start: periodStart,
|
|
754
|
+
duration: periodDuration,
|
|
755
|
+
tracks,
|
|
756
|
+
events,
|
|
757
|
+
matching,
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
/** parse an MPD document into a Presentation. Never throws. */
|
|
761
|
+
export function parse(text, baseUrl) {
|
|
762
|
+
let doc;
|
|
763
|
+
try {
|
|
764
|
+
doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
765
|
+
}
|
|
766
|
+
catch (cause) {
|
|
767
|
+
return { presentation: null, error: { ...manifestError('unparsable XML'), cause } };
|
|
768
|
+
}
|
|
769
|
+
const mpd = doc.documentElement;
|
|
770
|
+
if (mpd === null ||
|
|
771
|
+
mpd.localName !== 'MPD' ||
|
|
772
|
+
doc.getElementsByTagName('parsererror').length > 0) {
|
|
773
|
+
return { presentation: null, error: manifestError('not an MPD document') };
|
|
774
|
+
}
|
|
775
|
+
const isLive = attr(mpd, 'type') === 'dynamic';
|
|
776
|
+
const mpdDuration = parseDuration(attr(mpd, 'mediaPresentationDuration'));
|
|
777
|
+
const mpdBase = applyBaseUrl(mpd, baseUrl);
|
|
778
|
+
// Live delivery metadata, normalized for the dash-live stage. The parser
|
|
779
|
+
// only records; wall-clock arithmetic happens in the stage, from facts.
|
|
780
|
+
let live;
|
|
781
|
+
if (isLive) {
|
|
782
|
+
const availabilityStart = Date.parse(attr(mpd, 'availabilityStartTime') ?? '');
|
|
783
|
+
const updatePeriod = parseDuration(attr(mpd, 'minimumUpdatePeriod'));
|
|
784
|
+
const timeShiftDepth = parseDuration(attr(mpd, 'timeShiftBufferDepth'));
|
|
785
|
+
const holdBack = parseDuration(attr(mpd, 'suggestedPresentationDelay'));
|
|
786
|
+
const timing = children(mpd, 'UTCTiming')[0];
|
|
787
|
+
live = {
|
|
788
|
+
...(Number.isFinite(availabilityStart)
|
|
789
|
+
? { availabilityStart: availabilityStart / 1000 }
|
|
790
|
+
: {}),
|
|
791
|
+
...(updatePeriod !== null ? { updatePeriod } : {}),
|
|
792
|
+
...(timeShiftDepth !== null ? { timeShiftDepth } : {}),
|
|
793
|
+
...(holdBack !== null ? { holdBack } : {}),
|
|
794
|
+
...(timing !== undefined
|
|
795
|
+
? {
|
|
796
|
+
timeServer: {
|
|
797
|
+
scheme: attr(timing, 'schemeIdUri') ?? '',
|
|
798
|
+
value: attr(timing, 'value') ?? '',
|
|
799
|
+
},
|
|
800
|
+
}
|
|
801
|
+
: {}),
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
// ContentSteering plus BaseURL@serviceLocation alternatives: the bases
|
|
805
|
+
// map is the DASH pathway table the steering stage switches between.
|
|
806
|
+
let steering;
|
|
807
|
+
const steeringElement = children(mpd, 'ContentSteering')[0];
|
|
808
|
+
if (steeringElement !== undefined) {
|
|
809
|
+
const serverUri = steeringElement.textContent?.trim() ?? '';
|
|
810
|
+
if (serverUri !== '') {
|
|
811
|
+
const bases = {};
|
|
812
|
+
for (const base of children(mpd, 'BaseURL')) {
|
|
813
|
+
const location = attr(base, 'serviceLocation');
|
|
814
|
+
const text = base.textContent?.trim();
|
|
815
|
+
if (location !== null && text !== undefined && text !== '') {
|
|
816
|
+
bases[location] = resolve(text, baseUrl);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
steering = {
|
|
820
|
+
serverUri: resolve(serverUri, baseUrl),
|
|
821
|
+
...(attr(steeringElement, 'defaultServiceLocation') !== null
|
|
822
|
+
? { defaultPathway: attr(steeringElement, 'defaultServiceLocation') }
|
|
823
|
+
: {}),
|
|
824
|
+
...(Object.keys(bases).length > 0 ? { bases } : {}),
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
const periodElements = children(mpd, 'Period');
|
|
829
|
+
if (periodElements.length === 0) {
|
|
830
|
+
return {
|
|
831
|
+
presentation: null,
|
|
832
|
+
error: {
|
|
833
|
+
category: 'manifest',
|
|
834
|
+
code: 'MANIFEST_EMPTY',
|
|
835
|
+
fatal: true,
|
|
836
|
+
recoverable: false,
|
|
837
|
+
context: { reason: 'MPD with no Period' },
|
|
838
|
+
},
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
const spans = periodSpans(periodElements, mpdDuration);
|
|
842
|
+
const parsed = [];
|
|
843
|
+
for (let i = 0; i < periodElements.length; i += 1) {
|
|
844
|
+
// A live MPD keeps its first period: listing a later period's segments
|
|
845
|
+
// needs the clock, which the parser does not have.
|
|
846
|
+
if (i > 0 && isLive)
|
|
847
|
+
break;
|
|
848
|
+
const result = parsePeriod(periodElements[i], spans[i], i, mpdBase, isLive);
|
|
849
|
+
if ('error' in result)
|
|
850
|
+
return { presentation: null, error: result.error };
|
|
851
|
+
parsed.push(result);
|
|
852
|
+
}
|
|
853
|
+
// Several periods play as one: tracks matched across them, each boundary a
|
|
854
|
+
// discontinuity. A period the flattening cannot take keeps the first alone.
|
|
855
|
+
const flat = parsed.length > 1 ? flattenPeriods(parsed) : null;
|
|
856
|
+
const first = parsed[0];
|
|
857
|
+
const tracks = flat?.tracks ?? first.tracks;
|
|
858
|
+
const events = flat?.events ?? first.events;
|
|
859
|
+
const lastSpan = flat === null ? first : parsed[parsed.length - 1];
|
|
860
|
+
const total = flat === null
|
|
861
|
+
? first.duration
|
|
862
|
+
: lastSpan.duration === null
|
|
863
|
+
? null
|
|
864
|
+
: lastSpan.start + lastSpan.duration - first.start;
|
|
538
865
|
if (tracks.length === 0) {
|
|
539
866
|
return {
|
|
540
867
|
presentation: null,
|
|
@@ -554,10 +881,11 @@ export function parse(text, baseUrl) {
|
|
|
554
881
|
...(mpdDuration !== null ? { duration: mpdDuration } : {}),
|
|
555
882
|
periods: [
|
|
556
883
|
{
|
|
557
|
-
id:
|
|
558
|
-
start:
|
|
559
|
-
...(
|
|
884
|
+
id: first.id,
|
|
885
|
+
start: first.start,
|
|
886
|
+
...(total !== null ? { duration: total } : {}),
|
|
560
887
|
tracks,
|
|
888
|
+
...(events.length > 0 ? { events } : {}),
|
|
561
889
|
},
|
|
562
890
|
],
|
|
563
891
|
couplings: [],
|
|
@@ -565,6 +893,7 @@ export function parse(text, baseUrl) {
|
|
|
565
893
|
...(steering !== undefined ? { steering } : {}),
|
|
566
894
|
},
|
|
567
895
|
error: null,
|
|
896
|
+
...(flat !== null && flat.warnings.length > 0 ? { warnings: flat.warnings } : {}),
|
|
568
897
|
};
|
|
569
898
|
}
|
|
570
899
|
/**
|