mattebox 0.10.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 +39 -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 +74 -20
- 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 +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 +356 -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 +109 -30
- 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/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 +26 -93
- 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 +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 +40 -13
- 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.map +1 -1
- package/dist/kernel/reducer.js +77 -8
- 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 +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 +368 -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 +137 -12
- 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/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 +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 +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 -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 +65 -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 +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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/stages/cmsd/index.ts
|
|
2
|
+
/** Splits on commas or semicolons outside double quotes. */
|
|
3
|
+
function split(value, separator) {
|
|
4
|
+
const parts = [];
|
|
5
|
+
let current = "";
|
|
6
|
+
let quoted = false;
|
|
7
|
+
for (const char of value) {
|
|
8
|
+
if (char === "\"") quoted = !quoted;
|
|
9
|
+
if (char === separator && !quoted) {
|
|
10
|
+
parts.push(current);
|
|
11
|
+
current = "";
|
|
12
|
+
} else current += char;
|
|
13
|
+
}
|
|
14
|
+
parts.push(current);
|
|
15
|
+
return parts;
|
|
16
|
+
}
|
|
17
|
+
/** The numeric parameters of the list's last member: `"CDN-B";etp=480;mb=6000`. */
|
|
18
|
+
function cmsdParams(header) {
|
|
19
|
+
var _members;
|
|
20
|
+
const members = split(header, ",");
|
|
21
|
+
const last = (_members = members[members.length - 1]) !== null && _members !== void 0 ? _members : "";
|
|
22
|
+
const params = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const param of split(last, ";").slice(1)) {
|
|
24
|
+
const [key, value] = param.trim().split("=");
|
|
25
|
+
const number = value === void 0 ? NaN : Number(value);
|
|
26
|
+
if (Number.isFinite(number)) params.set(key, number);
|
|
27
|
+
}
|
|
28
|
+
return params;
|
|
29
|
+
}
|
|
30
|
+
function cmsd() {
|
|
31
|
+
return {
|
|
32
|
+
name: "cmsd",
|
|
33
|
+
provides: ["cmsd"],
|
|
34
|
+
requires: ["transport", "rendition-select"],
|
|
35
|
+
install(ctx) {
|
|
36
|
+
let etp = null;
|
|
37
|
+
let mb = null;
|
|
38
|
+
ctx.addResponseHook((response) => {
|
|
39
|
+
var _response$headers;
|
|
40
|
+
const header = response.outcome === "success" ? (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get("CMSD-Dynamic") : null;
|
|
41
|
+
if (header === null || header === void 0) return;
|
|
42
|
+
const params = cmsdParams(header);
|
|
43
|
+
const kbps = (key) => {
|
|
44
|
+
const value = params.get(key);
|
|
45
|
+
return value !== void 0 && value > 0 ? value * 1e3 : null;
|
|
46
|
+
};
|
|
47
|
+
const nextEtp = kbps("etp");
|
|
48
|
+
if (nextEtp !== etp) {
|
|
49
|
+
etp = nextEtp;
|
|
50
|
+
ctx.dispatch({
|
|
51
|
+
type: "THROUGHPUT_HINT",
|
|
52
|
+
bps: etp
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const nextMb = kbps("mb");
|
|
56
|
+
if (nextMb !== mb) {
|
|
57
|
+
mb = nextMb;
|
|
58
|
+
ctx.dispatch(mb === null ? {
|
|
59
|
+
type: "RELEASE_CONSTRAINT",
|
|
60
|
+
source: "cmsd"
|
|
61
|
+
} : {
|
|
62
|
+
type: "CONSTRAIN",
|
|
63
|
+
source: "cmsd",
|
|
64
|
+
constraint: { maxBitrate: mb }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { cmsdParams, cmsd as default };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { findRendition } from "../../kernel/presentation.js";
|
|
3
|
+
import { codecMismatch, probeInitSegment } from "../../containers/codec-probe/index.js";
|
|
2
4
|
//#region src/stages/codec-probe/index.ts
|
|
3
5
|
/**
|
|
4
6
|
* codec-probe as a loadable stage. The derivation itself lives in the
|
|
@@ -11,8 +13,10 @@ import { probeInitSegment } from "../../containers/codec-probe/index.js";
|
|
|
11
13
|
* It also registers the composition's type probe: a rendition the manifest
|
|
12
14
|
* left codec-less (a bare media playlist) gets its SourceBuffer typed from
|
|
13
15
|
* its first segment instead of the bare `video/mp4` Chrome refuses. A
|
|
14
|
-
* manifest that does declare codecs still creates the buffer as declared
|
|
15
|
-
*
|
|
16
|
+
* manifest that does declare codecs still creates the buffer as declared.
|
|
17
|
+
* When the init segment holds another codec or another profile, the stage
|
|
18
|
+
* reports it once per rendition as a non-fatal MEDIA_CODEC_MISMATCH error:
|
|
19
|
+
* Chrome can refuse the appends of a buffer typed with the wrong profile.
|
|
16
20
|
*/
|
|
17
21
|
/** A media segment carries a moof; only an init segment carries a moov. */
|
|
18
22
|
function isInitSegment(data) {
|
|
@@ -27,6 +31,26 @@ function codecProbe() {
|
|
|
27
31
|
install(ctx) {
|
|
28
32
|
let detected = [];
|
|
29
33
|
let mimeType = null;
|
|
34
|
+
const reported = /* @__PURE__ */ new Set();
|
|
35
|
+
/** Reports an init segment whose codec is not the one its rendition declares. */
|
|
36
|
+
function checkDeclared(codecs, renditionId) {
|
|
37
|
+
var _findRendition$rendit, _findRendition;
|
|
38
|
+
const presentation = ctx.getState().presentation;
|
|
39
|
+
const declared = (_findRendition$rendit = (_findRendition = findRendition(presentation, renditionId)) === null || _findRendition === void 0 ? void 0 : _findRendition.rendition.codecs) !== null && _findRendition$rendit !== void 0 ? _findRendition$rendit : null;
|
|
40
|
+
if (presentation === null || declared === null) return;
|
|
41
|
+
const mismatch = codecMismatch(declared, codecs);
|
|
42
|
+
if (mismatch === null) return;
|
|
43
|
+
const key = `${presentation.id}|${renditionId}|${mismatch.probed}`;
|
|
44
|
+
if (reported.has(key)) return;
|
|
45
|
+
reported.add(key);
|
|
46
|
+
ctx.emit("error", {
|
|
47
|
+
category: "media",
|
|
48
|
+
code: "MEDIA_CODEC_MISMATCH",
|
|
49
|
+
fatal: false,
|
|
50
|
+
recoverable: true,
|
|
51
|
+
context: _objectSpread2({ renditionId }, mismatch)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
30
54
|
ctx.registerNamespace("codecProbe", {
|
|
31
55
|
get detected() {
|
|
32
56
|
return detected;
|
|
@@ -54,6 +78,7 @@ function codecProbe() {
|
|
|
54
78
|
codecs: result.codecs,
|
|
55
79
|
mimeType: result.mimeType
|
|
56
80
|
});
|
|
81
|
+
checkDeclared(result.codecs, meta.renditionId);
|
|
57
82
|
}
|
|
58
83
|
return data;
|
|
59
84
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
//#region src/stages/content-steering/index.ts
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
|
|
3
3
|
import { bytesToBase64 } from "../../kernel/base64.js";
|
|
4
4
|
import { keySystemHandlers, normalizeSystemId } from "../drm-shared.js";
|
|
5
5
|
//#region src/stages/eme-core/index.ts
|
|
@@ -294,6 +294,24 @@ function emeCore(options = {}) {
|
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
296
|
element.addEventListener("play", onPlay);
|
|
297
|
+
let released = [];
|
|
298
|
+
const offSuspended = ctx.on("lifecycle:suspended", () => {
|
|
299
|
+
if (options.releaseOnSuspend !== true || open.size === 0) return;
|
|
300
|
+
released = [...open.entries()].filter(([session]) => ![...open.values()].some((r) => r.replaces === session)).map(([, record]) => ({
|
|
301
|
+
initDataType: record.initDataType,
|
|
302
|
+
initData: record.initData,
|
|
303
|
+
replaces: null,
|
|
304
|
+
usable: false
|
|
305
|
+
}));
|
|
306
|
+
for (const session of [...open.keys()]) retire(session);
|
|
307
|
+
statuses.clear();
|
|
308
|
+
ctx.emit("drm:released", { sessions: released.length });
|
|
309
|
+
});
|
|
310
|
+
const offResumed = ctx.on("lifecycle:resumed", () => {
|
|
311
|
+
const records = released;
|
|
312
|
+
released = [];
|
|
313
|
+
for (const record of records) startSession(record);
|
|
314
|
+
});
|
|
297
315
|
const onEncrypted = (event) => {
|
|
298
316
|
const e = event;
|
|
299
317
|
if (e.initData === null) return;
|
|
@@ -314,6 +332,8 @@ function emeCore(options = {}) {
|
|
|
314
332
|
element.removeEventListener("encrypted", onEncrypted);
|
|
315
333
|
element.removeEventListener("play", onPlay);
|
|
316
334
|
offManifest();
|
|
335
|
+
offSuspended();
|
|
336
|
+
offResumed();
|
|
317
337
|
for (const session of [...open.keys()]) retire(session);
|
|
318
338
|
if (mediaKeys !== null) element.setMediaKeys(null).catch(() => {});
|
|
319
339
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { base64ToBytes, bytesToBase64 } from "../../kernel/base64.js";
|
|
3
3
|
import { registerKeySystem } from "../drm-shared.js";
|
|
4
4
|
//#region src/stages/eme-fairplay/index.ts
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
|
|
2
|
+
//#region src/stages/hdr/index.ts
|
|
3
|
+
const SOURCE = "hdr";
|
|
4
|
+
/** The display's answer, or null when the browser does not know `dynamic-range`. */
|
|
5
|
+
function displayHdr() {
|
|
6
|
+
if (typeof matchMedia !== "function") return null;
|
|
7
|
+
if (matchMedia("(dynamic-range: high)").matches) return true;
|
|
8
|
+
return matchMedia("(dynamic-range: standard)").matches ? false : null;
|
|
9
|
+
}
|
|
10
|
+
function capabilities() {
|
|
11
|
+
var _mediaCapabilities;
|
|
12
|
+
return (_mediaCapabilities = navigator.mediaCapabilities) !== null && _mediaCapabilities !== void 0 ? _mediaCapabilities : null;
|
|
13
|
+
}
|
|
14
|
+
/** True when `decodingInfo` reads the HDR fields: an invalid enum value is then a TypeError. */
|
|
15
|
+
function knowsHdrFields(_x) {
|
|
16
|
+
return _knowsHdrFields.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
function _knowsHdrFields() {
|
|
19
|
+
_knowsHdrFields = _asyncToGenerator(function* (api) {
|
|
20
|
+
try {
|
|
21
|
+
yield api.decodingInfo({
|
|
22
|
+
type: "media-source",
|
|
23
|
+
video: {
|
|
24
|
+
contentType: "video/mp4; codecs=\"avc1.42E01E\"",
|
|
25
|
+
width: 640,
|
|
26
|
+
height: 360,
|
|
27
|
+
bitrate: 1e6,
|
|
28
|
+
framerate: 30,
|
|
29
|
+
hdrMetadataType: "unknown"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return false;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return error instanceof TypeError;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return _knowsHdrFields.apply(this, arguments);
|
|
38
|
+
}
|
|
39
|
+
function isHdr(rendition) {
|
|
40
|
+
return rendition.videoRange === "PQ" || rendition.videoRange === "HLG";
|
|
41
|
+
}
|
|
42
|
+
const formatOf = (rendition) => {
|
|
43
|
+
var _rendition$codecs;
|
|
44
|
+
return `${(_rendition$codecs = rendition.codecs) !== null && _rendition$codecs !== void 0 ? _rendition$codecs : ""}|${rendition.videoRange}`;
|
|
45
|
+
};
|
|
46
|
+
function hdr(options = {}) {
|
|
47
|
+
return {
|
|
48
|
+
name: "hdr",
|
|
49
|
+
provides: ["hdr"],
|
|
50
|
+
requires: ["rendition-select"],
|
|
51
|
+
install(ctx) {
|
|
52
|
+
let state = {
|
|
53
|
+
display: null,
|
|
54
|
+
formats: {},
|
|
55
|
+
source: null,
|
|
56
|
+
allowed: true
|
|
57
|
+
};
|
|
58
|
+
let seen = null;
|
|
59
|
+
let run = 0;
|
|
60
|
+
let constrained = false;
|
|
61
|
+
function videoRenditions() {
|
|
62
|
+
var _ctx$getState$present, _ctx$getState$present2;
|
|
63
|
+
const out = [];
|
|
64
|
+
for (const period of (_ctx$getState$present = (_ctx$getState$present2 = ctx.getState().presentation) === null || _ctx$getState$present2 === void 0 ? void 0 : _ctx$getState$present2.periods) !== null && _ctx$getState$present !== void 0 ? _ctx$getState$present : []) for (const track of period.tracks) if (track.contentType === "video") out.push(...track.renditions);
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
const hdrRenditions = () => videoRenditions().filter(isHdr);
|
|
68
|
+
function apply(excluded) {
|
|
69
|
+
if (excluded === "all" && videoRenditions().every(isHdr) || excluded === "none" || excluded !== "all" && excluded.length === 0) {
|
|
70
|
+
if (constrained) ctx.dispatch({
|
|
71
|
+
type: "RELEASE_CONSTRAINT",
|
|
72
|
+
source: SOURCE
|
|
73
|
+
});
|
|
74
|
+
constrained = false;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
constrained = true;
|
|
78
|
+
ctx.dispatch({
|
|
79
|
+
type: "CONSTRAIN",
|
|
80
|
+
source: SOURCE,
|
|
81
|
+
constraint: excluded === "all" ? { hdr: false } : { excludeIds: excluded.map((r) => r.id) }
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function evaluate() {
|
|
85
|
+
return _evaluate.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
function _evaluate() {
|
|
88
|
+
_evaluate = _asyncToGenerator(function* () {
|
|
89
|
+
run += 1;
|
|
90
|
+
const mine = run;
|
|
91
|
+
const renditions = hdrRenditions();
|
|
92
|
+
if (renditions.length === 0) {
|
|
93
|
+
state = {
|
|
94
|
+
display: null,
|
|
95
|
+
formats: {},
|
|
96
|
+
source: null,
|
|
97
|
+
allowed: true
|
|
98
|
+
};
|
|
99
|
+
apply("none");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const display = displayHdr();
|
|
103
|
+
if (options.supported !== void 0) {
|
|
104
|
+
const answer = typeof options.supported === "function" ? yield options.supported() : options.supported;
|
|
105
|
+
if (mine !== run) return;
|
|
106
|
+
state = {
|
|
107
|
+
display,
|
|
108
|
+
formats: {},
|
|
109
|
+
source: "option",
|
|
110
|
+
allowed: answer
|
|
111
|
+
};
|
|
112
|
+
apply(answer ? "none" : "all");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const formats = {};
|
|
116
|
+
const api = capabilities();
|
|
117
|
+
const known = api !== null && (yield knowsHdrFields(api));
|
|
118
|
+
for (const rendition of renditions) {
|
|
119
|
+
const key = formatOf(rendition);
|
|
120
|
+
if (key in formats) continue;
|
|
121
|
+
formats[key] = null;
|
|
122
|
+
if (!known || api === null) continue;
|
|
123
|
+
try {
|
|
124
|
+
var _rendition$codecs2, _rendition$width, _rendition$height, _rendition$frameRate;
|
|
125
|
+
formats[key] = (yield api.decodingInfo({
|
|
126
|
+
type: "media-source",
|
|
127
|
+
video: {
|
|
128
|
+
contentType: `video/mp4; codecs="${(_rendition$codecs2 = rendition.codecs) !== null && _rendition$codecs2 !== void 0 ? _rendition$codecs2 : ""}"`,
|
|
129
|
+
width: (_rendition$width = rendition.width) !== null && _rendition$width !== void 0 ? _rendition$width : 1920,
|
|
130
|
+
height: (_rendition$height = rendition.height) !== null && _rendition$height !== void 0 ? _rendition$height : 1080,
|
|
131
|
+
bitrate: rendition.bitrate || 5e6,
|
|
132
|
+
framerate: (_rendition$frameRate = rendition.frameRate) !== null && _rendition$frameRate !== void 0 ? _rendition$frameRate : 30,
|
|
133
|
+
transferFunction: rendition.videoRange === "HLG" ? "hlg" : "pq",
|
|
134
|
+
colorGamut: "rec2020"
|
|
135
|
+
}
|
|
136
|
+
})).supported;
|
|
137
|
+
} catch (_unused) {
|
|
138
|
+
formats[key] = false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (mine !== run) return;
|
|
142
|
+
if (display === null && !known) {
|
|
143
|
+
state = {
|
|
144
|
+
display,
|
|
145
|
+
formats,
|
|
146
|
+
source: "default",
|
|
147
|
+
allowed: false
|
|
148
|
+
};
|
|
149
|
+
apply("all");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (display === false) {
|
|
153
|
+
state = {
|
|
154
|
+
display,
|
|
155
|
+
formats,
|
|
156
|
+
source: "probe",
|
|
157
|
+
allowed: false
|
|
158
|
+
};
|
|
159
|
+
apply("all");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const unsupported = renditions.filter((r) => formats[formatOf(r)] === false);
|
|
163
|
+
state = {
|
|
164
|
+
display,
|
|
165
|
+
formats,
|
|
166
|
+
source: "probe",
|
|
167
|
+
allowed: unsupported.length < renditions.length
|
|
168
|
+
};
|
|
169
|
+
apply(unsupported.length === renditions.length ? "all" : unsupported);
|
|
170
|
+
});
|
|
171
|
+
return _evaluate.apply(this, arguments);
|
|
172
|
+
}
|
|
173
|
+
function onPresentation() {
|
|
174
|
+
const presentation = ctx.getState().presentation;
|
|
175
|
+
if (presentation === seen) return;
|
|
176
|
+
seen = presentation;
|
|
177
|
+
evaluate();
|
|
178
|
+
}
|
|
179
|
+
const query = typeof matchMedia === "function" ? matchMedia("(dynamic-range: high)") : null;
|
|
180
|
+
const onChange = () => {
|
|
181
|
+
evaluate();
|
|
182
|
+
};
|
|
183
|
+
if (query !== null) {
|
|
184
|
+
if (typeof query.addEventListener === "function") query.addEventListener("change", onChange);
|
|
185
|
+
else query.addListener(onChange);
|
|
186
|
+
}
|
|
187
|
+
const off = ctx.on("tracks:changed", onPresentation);
|
|
188
|
+
ctx.registerNamespace("hdr", {
|
|
189
|
+
get display() {
|
|
190
|
+
return state.display;
|
|
191
|
+
},
|
|
192
|
+
get formats() {
|
|
193
|
+
return state.formats;
|
|
194
|
+
},
|
|
195
|
+
get source() {
|
|
196
|
+
return state.source;
|
|
197
|
+
},
|
|
198
|
+
get allowed() {
|
|
199
|
+
return state.allowed;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
return () => {
|
|
203
|
+
run += 1;
|
|
204
|
+
off();
|
|
205
|
+
if (query !== null) {
|
|
206
|
+
if (typeof query.removeEventListener === "function") query.removeEventListener("change", onChange);
|
|
207
|
+
else query.removeListener(onChange);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
214
|
+
export { hdr as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { id3Cues } from "../../containers/id3.js";
|
|
1
|
+
import { id3Cues, id3Events } from "../../containers/id3.js";
|
|
2
|
+
import { deliverMetadata, metadataWanted } from "../../containers/metadata.js";
|
|
2
3
|
import { createMetadataSink } from "../../kernel/sinks/metadata-sink.js";
|
|
3
4
|
//#region src/stages/meta-id3/index.ts
|
|
4
5
|
/**
|
|
@@ -13,6 +14,10 @@ import { createMetadataSink } from "../../kernel/sinks/metadata-sink.js";
|
|
|
13
14
|
* legacy segments it rides in.
|
|
14
15
|
*/
|
|
15
16
|
function parseId3Segment(data, meta) {
|
|
17
|
+
if (metadataWanted()) deliverMetadata(id3Events([{
|
|
18
|
+
time: meta.start,
|
|
19
|
+
bytes: data
|
|
20
|
+
}]));
|
|
16
21
|
return id3Cues(data, meta.start);
|
|
17
22
|
}
|
|
18
23
|
function metaId3() {
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
//#region src/stages/qoe/index.ts
|
|
3
|
+
function qoe() {
|
|
4
|
+
return {
|
|
5
|
+
name: "qoe",
|
|
6
|
+
provides: ["qoe"],
|
|
7
|
+
install(ctx) {
|
|
8
|
+
const element = ctx.element;
|
|
9
|
+
let loadedAt = null;
|
|
10
|
+
let playAt = null;
|
|
11
|
+
let startupTime = null;
|
|
12
|
+
let rebuffers = 0;
|
|
13
|
+
let finished = 0;
|
|
14
|
+
let stallFrom = null;
|
|
15
|
+
let stallTime = 0;
|
|
16
|
+
let switches = 0;
|
|
17
|
+
let rendition = null;
|
|
18
|
+
const now = () => performance.now() / 1e3;
|
|
19
|
+
const metrics = () => ({
|
|
20
|
+
startupTime,
|
|
21
|
+
rebuffers,
|
|
22
|
+
rebufferDuration: finished + (stallFrom === null ? 0 : now() - stallFrom),
|
|
23
|
+
switches
|
|
24
|
+
});
|
|
25
|
+
const report = (reason) => {
|
|
26
|
+
ctx.emit("qoe:metrics", _objectSpread2(_objectSpread2({}, metrics()), {}, { reason }));
|
|
27
|
+
};
|
|
28
|
+
function reset() {
|
|
29
|
+
loadedAt = now();
|
|
30
|
+
playAt = element.paused ? null : loadedAt;
|
|
31
|
+
startupTime = null;
|
|
32
|
+
rebuffers = 0;
|
|
33
|
+
finished = 0;
|
|
34
|
+
stallFrom = null;
|
|
35
|
+
switches = 0;
|
|
36
|
+
rendition = null;
|
|
37
|
+
}
|
|
38
|
+
function stall() {
|
|
39
|
+
if (startupTime === null || stallFrom !== null || element.seeking || element.paused) return;
|
|
40
|
+
stallFrom = now();
|
|
41
|
+
stallTime = element.currentTime;
|
|
42
|
+
rebuffers += 1;
|
|
43
|
+
}
|
|
44
|
+
function resume() {
|
|
45
|
+
if (stallFrom === null) return;
|
|
46
|
+
finished += now() - stallFrom;
|
|
47
|
+
stallFrom = null;
|
|
48
|
+
report("rebuffer");
|
|
49
|
+
}
|
|
50
|
+
const onPlay = () => {
|
|
51
|
+
if (playAt === null && loadedAt !== null) playAt = now();
|
|
52
|
+
};
|
|
53
|
+
const onPlaying = () => {
|
|
54
|
+
if (startupTime === null && loadedAt !== null) {
|
|
55
|
+
var _playAt;
|
|
56
|
+
startupTime = now() - Math.max(loadedAt, (_playAt = playAt) !== null && _playAt !== void 0 ? _playAt : loadedAt);
|
|
57
|
+
report("startup");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
resume();
|
|
61
|
+
};
|
|
62
|
+
const onTime = () => {
|
|
63
|
+
if (stallFrom !== null && element.currentTime > stallTime + .1) resume();
|
|
64
|
+
};
|
|
65
|
+
const onSeeking = () => {
|
|
66
|
+
resume();
|
|
67
|
+
};
|
|
68
|
+
element.addEventListener("play", onPlay);
|
|
69
|
+
element.addEventListener("playing", onPlaying);
|
|
70
|
+
element.addEventListener("waiting", stall);
|
|
71
|
+
element.addEventListener("timeupdate", onTime);
|
|
72
|
+
element.addEventListener("seeking", onSeeking);
|
|
73
|
+
const offStalled = ctx.on("playback:stalled", stall);
|
|
74
|
+
const offTrace = ctx.on("trace", (entry) => {
|
|
75
|
+
if (entry.msg.type === "LOAD") reset();
|
|
76
|
+
const active = ctx.getState().quality.active;
|
|
77
|
+
if (active === rendition) return;
|
|
78
|
+
if (rendition !== null && active !== null) {
|
|
79
|
+
switches += 1;
|
|
80
|
+
report("switch");
|
|
81
|
+
}
|
|
82
|
+
rendition = active;
|
|
83
|
+
});
|
|
84
|
+
ctx.registerNamespace("qoe", {
|
|
85
|
+
get startupTime() {
|
|
86
|
+
return startupTime;
|
|
87
|
+
},
|
|
88
|
+
get rebuffers() {
|
|
89
|
+
return rebuffers;
|
|
90
|
+
},
|
|
91
|
+
get rebufferDuration() {
|
|
92
|
+
return metrics().rebufferDuration;
|
|
93
|
+
},
|
|
94
|
+
get switches() {
|
|
95
|
+
return switches;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return () => {
|
|
99
|
+
element.removeEventListener("play", onPlay);
|
|
100
|
+
element.removeEventListener("playing", onPlaying);
|
|
101
|
+
element.removeEventListener("waiting", stall);
|
|
102
|
+
element.removeEventListener("timeupdate", onTime);
|
|
103
|
+
element.removeEventListener("seeking", onSeeking);
|
|
104
|
+
offStalled();
|
|
105
|
+
offTrace();
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { qoe as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
import { findRendition, findTrackSite } from "../../kernel/presentation.js";
|
|
4
4
|
import { segmentAt as segmentAt$1, segmentAtTime } from "../../kernel/timeline.js";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
//#region src/stages/rendition-names/index.ts
|
|
3
|
+
const DATA_ID = "_hls.localized-rendition-names";
|
|
4
|
+
const FETCH_TOKEN = "rendition-names:dictionary";
|
|
5
|
+
const INITIAL = {
|
|
6
|
+
uri: null,
|
|
7
|
+
dictionary: null
|
|
8
|
+
};
|
|
9
|
+
/** The dictionary in a JSON document, keeping only string translations. */
|
|
10
|
+
function parseNameDictionary(text) {
|
|
11
|
+
let json;
|
|
12
|
+
try {
|
|
13
|
+
json = JSON.parse(text);
|
|
14
|
+
} catch (_unused) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (typeof json !== "object" || json === null || Array.isArray(json)) return null;
|
|
18
|
+
const out = {};
|
|
19
|
+
for (const [name, translations] of Object.entries(json)) {
|
|
20
|
+
if (typeof translations !== "object" || translations === null) continue;
|
|
21
|
+
const kept = {};
|
|
22
|
+
for (const [language, value] of Object.entries(translations)) if (typeof value === "string") kept[language.toLowerCase()] = value;
|
|
23
|
+
out[name] = kept;
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
/** Appendix E.2 base name selection. */
|
|
28
|
+
function baseName(track, locale, dictionary, languageName) {
|
|
29
|
+
var _locale$split$, _entry$subtag;
|
|
30
|
+
const subtag = ((_locale$split$ = locale.split("-")[0]) !== null && _locale$split$ !== void 0 ? _locale$split$ : "").toLowerCase();
|
|
31
|
+
const entry = track.name === void 0 ? void 0 : dictionary === null || dictionary === void 0 ? void 0 : dictionary[track.name];
|
|
32
|
+
if (entry !== void 0) return (_entry$subtag = entry[subtag]) !== null && _entry$subtag !== void 0 ? _entry$subtag : track.name;
|
|
33
|
+
if (track.autoselect === true && track.lang !== void 0 && languageName !== void 0) {
|
|
34
|
+
const localized = languageName(track.lang, locale);
|
|
35
|
+
if (localized !== void 0 && localized !== "") return localized;
|
|
36
|
+
}
|
|
37
|
+
return track.name;
|
|
38
|
+
}
|
|
39
|
+
const reduceNames = (slice, msg) => {
|
|
40
|
+
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
41
|
+
if (msg.type === "LOAD" || msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
|
|
42
|
+
if (msg.type === "MANIFEST_LOADED") {
|
|
43
|
+
var _msg$presentation$ses;
|
|
44
|
+
const uri = (_msg$presentation$ses = msg.presentation.sessionData) === null || _msg$presentation$ses === void 0 || (_msg$presentation$ses = _msg$presentation$ses.find((d) => d.id === DATA_ID)) === null || _msg$presentation$ses === void 0 ? void 0 : _msg$presentation$ses.uri;
|
|
45
|
+
if (uri === void 0 || uri === state.uri) return [state, []];
|
|
46
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, { uri }), [{
|
|
47
|
+
kind: "fetch",
|
|
48
|
+
token: FETCH_TOKEN,
|
|
49
|
+
url: uri
|
|
50
|
+
}]];
|
|
51
|
+
}
|
|
52
|
+
if (msg.type === "SEGMENT_LOADED" && msg.trackId === FETCH_TOKEN && state.uri !== null) {
|
|
53
|
+
const dictionary = parseNameDictionary(new TextDecoder().decode(msg.bytes));
|
|
54
|
+
const effects = [dictionary === null ? {
|
|
55
|
+
kind: "emit",
|
|
56
|
+
event: "rendition-names:warning",
|
|
57
|
+
payload: {
|
|
58
|
+
url: state.uri,
|
|
59
|
+
reason: "not-a-dictionary"
|
|
60
|
+
}
|
|
61
|
+
} : {
|
|
62
|
+
kind: "emit",
|
|
63
|
+
event: "rendition-names:loaded",
|
|
64
|
+
payload: { count: Object.keys(dictionary).length }
|
|
65
|
+
}];
|
|
66
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, { dictionary }), effects];
|
|
67
|
+
}
|
|
68
|
+
if (msg.type === "SEGMENT_FAILED" && msg.trackId === FETCH_TOKEN) return [state, [{
|
|
69
|
+
kind: "emit",
|
|
70
|
+
event: "rendition-names:warning",
|
|
71
|
+
payload: {
|
|
72
|
+
url: state.uri,
|
|
73
|
+
reason: "fetch-failed"
|
|
74
|
+
}
|
|
75
|
+
}]];
|
|
76
|
+
return [state, []];
|
|
77
|
+
};
|
|
78
|
+
function renditionNames() {
|
|
79
|
+
return {
|
|
80
|
+
name: "rendition-names",
|
|
81
|
+
provides: ["rendition-names"],
|
|
82
|
+
requires: ["transport"],
|
|
83
|
+
install(ctx) {
|
|
84
|
+
ctx.reduce("rendition-names", reduceNames);
|
|
85
|
+
const dictionary = () => {
|
|
86
|
+
var _ref;
|
|
87
|
+
return ((_ref = ctx.getState()["rendition-names"]) !== null && _ref !== void 0 ? _ref : INITIAL).dictionary;
|
|
88
|
+
};
|
|
89
|
+
ctx.registerNamespace("renditionNames", {
|
|
90
|
+
get dictionary() {
|
|
91
|
+
return dictionary();
|
|
92
|
+
},
|
|
93
|
+
nameOf(track, locale, languageName) {
|
|
94
|
+
return baseName(track, locale, dictionary(), languageName);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { baseName, renditionNames as default, parseNameDictionary };
|