mattebox 0.1.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/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/cdn/mattebox.dash-drm.min.js +2 -0
- package/dist/cdn/mattebox.dash.min.js +2 -0
- package/dist/cdn/mattebox.dual-drm.min.js +2 -0
- package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -0
- package/dist/cdn/mattebox.dual-ts.min.js +3 -0
- package/dist/cdn/mattebox.dual.min.js +2 -0
- package/dist/cdn/mattebox.hls-drm.min.js +2 -0
- package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -0
- package/dist/cdn/mattebox.hls-ts.min.js +3 -0
- package/dist/cdn/mattebox.hls.min.js +2 -0
- package/dist/cdn/mattebox.kernel.min.js +1 -0
- package/dist/cdn/mattebox.min.js +6 -0
- package/dist/cdn/transmux.worker.js +1 -0
- package/dist/containers/adts.d.ts +33 -0
- package/dist/containers/adts.d.ts.map +1 -0
- package/dist/containers/adts.js +66 -0
- package/dist/containers/adts.js.map +1 -0
- package/dist/containers/captions.d.ts +27 -0
- package/dist/containers/captions.d.ts.map +1 -0
- package/dist/containers/captions.js +36 -0
- package/dist/containers/captions.js.map +1 -0
- package/dist/containers/codec-probe/index.d.ts +35 -0
- package/dist/containers/codec-probe/index.d.ts.map +1 -0
- package/dist/containers/codec-probe/index.js +222 -0
- package/dist/containers/codec-probe/index.js.map +1 -0
- package/dist/containers/fmp4/writer.d.ts +62 -0
- package/dist/containers/fmp4/writer.d.ts.map +1 -0
- package/dist/containers/fmp4/writer.js +201 -0
- package/dist/containers/fmp4/writer.js.map +1 -0
- package/dist/containers/id3.d.ts +25 -0
- package/dist/containers/id3.d.ts.map +1 -0
- package/dist/containers/id3.js +75 -0
- package/dist/containers/id3.js.map +1 -0
- package/dist/containers/mp4-box/index.d.ts +79 -0
- package/dist/containers/mp4-box/index.d.ts.map +1 -0
- package/dist/containers/mp4-box/index.js +231 -0
- package/dist/containers/mp4-box/index.js.map +1 -0
- package/dist/containers/packed-audio/index.d.ts +7 -0
- package/dist/containers/packed-audio/index.d.ts.map +1 -0
- package/dist/containers/packed-audio/index.js +63 -0
- package/dist/containers/packed-audio/index.js.map +1 -0
- package/dist/containers/sei.d.ts +26 -0
- package/dist/containers/sei.d.ts.map +1 -0
- package/dist/containers/sei.js +100 -0
- package/dist/containers/sei.js.map +1 -0
- package/dist/containers/ts-transmux/demux.d.ts +49 -0
- package/dist/containers/ts-transmux/demux.d.ts.map +1 -0
- package/dist/containers/ts-transmux/demux.js +222 -0
- package/dist/containers/ts-transmux/demux.js.map +1 -0
- package/dist/containers/ts-transmux/h264.d.ts +48 -0
- package/dist/containers/ts-transmux/h264.d.ts.map +1 -0
- package/dist/containers/ts-transmux/h264.js +211 -0
- package/dist/containers/ts-transmux/h264.js.map +1 -0
- package/dist/containers/ts-transmux/index.d.ts +17 -0
- package/dist/containers/ts-transmux/index.d.ts.map +1 -0
- package/dist/containers/ts-transmux/index.js +34 -0
- package/dist/containers/ts-transmux/index.js.map +1 -0
- package/dist/containers/ts-transmux/runner.d.ts +23 -0
- package/dist/containers/ts-transmux/runner.d.ts.map +1 -0
- package/dist/containers/ts-transmux/runner.js +99 -0
- package/dist/containers/ts-transmux/runner.js.map +1 -0
- package/dist/containers/ts-transmux/transmux.d.ts +24 -0
- package/dist/containers/ts-transmux/transmux.d.ts.map +1 -0
- package/dist/containers/ts-transmux/transmux.js +212 -0
- package/dist/containers/ts-transmux/transmux.js.map +1 -0
- package/dist/containers/ts-transmux/transmux.worker.d.ts +2 -0
- package/dist/containers/ts-transmux/transmux.worker.d.ts.map +1 -0
- package/dist/containers/ts-transmux/transmux.worker.js +19 -0
- package/dist/containers/ts-transmux/transmux.worker.js.map +1 -0
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/asyncToGenerator.js +27 -0
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/defineProperty.js +12 -0
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/objectSpread2.js +25 -0
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/objectWithoutProperties.js +13 -0
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPrimitive.js +14 -0
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPropertyKey.js +9 -0
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/typeof.js +11 -0
- package/dist/es2015/containers/adts.js +77 -0
- package/dist/es2015/containers/captions.js +36 -0
- package/dist/es2015/containers/codec-probe/index.js +220 -0
- package/dist/es2015/containers/fmp4/writer.js +165 -0
- package/dist/es2015/containers/id3.js +72 -0
- package/dist/es2015/containers/mp4-box/index.js +209 -0
- package/dist/es2015/containers/packed-audio/index.js +67 -0
- package/dist/es2015/containers/sei.js +79 -0
- package/dist/es2015/containers/ts-transmux/demux.js +211 -0
- package/dist/es2015/containers/ts-transmux/h264.js +204 -0
- package/dist/es2015/containers/ts-transmux/index.js +37 -0
- package/dist/es2015/containers/ts-transmux/runner.js +95 -0
- package/dist/es2015/containers/ts-transmux/transmux.js +210 -0
- package/dist/es2015/containers/ts-transmux/transmux.worker.js +26 -0
- package/dist/es2015/index.js +356 -0
- package/dist/es2015/kernel/append-queue.js +148 -0
- package/dist/es2015/kernel/bus.js +134 -0
- package/dist/es2015/kernel/context.js +92 -0
- package/dist/es2015/kernel/effects.js +62 -0
- package/dist/es2015/kernel/evictor.js +67 -0
- package/dist/es2015/kernel/lifecycle.js +122 -0
- package/dist/es2015/kernel/loader.js +108 -0
- package/dist/es2015/kernel/mime.js +20 -0
- package/dist/es2015/kernel/mse.js +426 -0
- package/dist/es2015/kernel/reducer.js +1051 -0
- package/dist/es2015/kernel/rendition-select.js +263 -0
- package/dist/es2015/kernel/scheduler.js +82 -0
- package/dist/es2015/kernel/sinks/metadata-sink.js +7 -0
- package/dist/es2015/kernel/sinks/mse-sink.js +31 -0
- package/dist/es2015/kernel/sinks/text-track-sink.js +167 -0
- package/dist/es2015/kernel/timeline.js +127 -0
- package/dist/es2015/kernel/trace.js +134 -0
- package/dist/es2015/kernel/track-registry.js +47 -0
- package/dist/es2015/kernel/transport.js +242 -0
- package/dist/es2015/kernel/watchdog.js +38 -0
- package/dist/es2015/presets/dash/index.js +9 -0
- package/dist/es2015/presets/dash-drm/index.js +13 -0
- package/dist/es2015/presets/define.js +45 -0
- package/dist/es2015/presets/dual/index.js +14 -0
- package/dist/es2015/presets/dual-drm/index.js +14 -0
- package/dist/es2015/presets/dual-ts/index.js +14 -0
- package/dist/es2015/presets/dual-ts-drm/index.js +15 -0
- package/dist/es2015/presets/full/index.js +28 -0
- package/dist/es2015/presets/hls/index.js +9 -0
- package/dist/es2015/presets/hls-drm/index.js +13 -0
- package/dist/es2015/presets/hls-ts/index.js +13 -0
- package/dist/es2015/presets/hls-ts-drm/index.js +14 -0
- package/dist/es2015/presets/kernel/index.js +10 -0
- package/dist/es2015/presets/storage.js +24 -0
- package/dist/es2015/presets/tiers.js +93 -0
- package/dist/es2015/protocols/dash-cmaf/index.js +161 -0
- package/dist/es2015/protocols/dash-cmaf/parse.js +491 -0
- package/dist/es2015/protocols/dash-live/index.js +192 -0
- package/dist/es2015/protocols/hls-cmaf/index.js +168 -0
- package/dist/es2015/protocols/hls-cmaf/lexer.js +72 -0
- package/dist/es2015/protocols/hls-cmaf/parse.js +457 -0
- package/dist/es2015/protocols/hls-live/index.js +296 -0
- package/dist/es2015/protocols/live-shared.js +29 -0
- package/dist/es2015/stages/abr/index.js +126 -0
- package/dist/es2015/stages/abr-cap-size/index.js +22 -0
- package/dist/es2015/stages/abr-persist/index.js +52 -0
- package/dist/es2015/stages/aes-128/index.js +76 -0
- package/dist/es2015/stages/alt-audio/index.js +80 -0
- package/dist/es2015/stages/cmaf-timing/index.js +55 -0
- package/dist/es2015/stages/cmcd/index.js +70 -0
- package/dist/es2015/stages/codec-probe/index.js +65 -0
- package/dist/es2015/stages/codec-switch/index.js +48 -0
- package/dist/es2015/stages/content-steering/index.js +179 -0
- package/dist/es2015/stages/drm-shared.js +18 -0
- package/dist/es2015/stages/eme-cenc/index.js +46 -0
- package/dist/es2015/stages/eme-core/index.js +237 -0
- package/dist/es2015/stages/eme-fairplay/index.js +52 -0
- package/dist/es2015/stages/meta-id3/index.js +37 -0
- package/dist/es2015/stages/mp4-box/index.js +27 -0
- package/dist/es2015/stages/nal-scan/index.js +121 -0
- package/dist/es2015/stages/pdt/index.js +34 -0
- package/dist/es2015/stages/recovery/index.js +283 -0
- package/dist/es2015/stages/text-cea608/decode.js +201 -0
- package/dist/es2015/stages/text-cea608/index.js +71 -0
- package/dist/es2015/stages/text-webvtt/index.js +82 -0
- package/dist/es2015/stages/text-webvtt/parse.js +60 -0
- package/dist/es2015/stages/text-webvtt-segmented/index.js +57 -0
- package/dist/es2015/stages/thumbnails/index.js +73 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +423 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel/append-queue.d.ts +47 -0
- package/dist/kernel/append-queue.d.ts.map +1 -0
- package/dist/kernel/append-queue.js +180 -0
- package/dist/kernel/append-queue.js.map +1 -0
- package/dist/kernel/bus.d.ts +50 -0
- package/dist/kernel/bus.d.ts.map +1 -0
- package/dist/kernel/bus.js +147 -0
- package/dist/kernel/bus.js.map +1 -0
- package/dist/kernel/context.d.ts +45 -0
- package/dist/kernel/context.d.ts.map +1 -0
- package/dist/kernel/context.js +116 -0
- package/dist/kernel/context.js.map +1 -0
- package/dist/kernel/effects.d.ts +33 -0
- package/dist/kernel/effects.d.ts.map +1 -0
- package/dist/kernel/effects.js +65 -0
- package/dist/kernel/effects.js.map +1 -0
- package/dist/kernel/evictor.d.ts +46 -0
- package/dist/kernel/evictor.d.ts.map +1 -0
- package/dist/kernel/evictor.js +92 -0
- package/dist/kernel/evictor.js.map +1 -0
- package/dist/kernel/lifecycle.d.ts +41 -0
- package/dist/kernel/lifecycle.d.ts.map +1 -0
- package/dist/kernel/lifecycle.js +129 -0
- package/dist/kernel/lifecycle.js.map +1 -0
- package/dist/kernel/loader.d.ts +28 -0
- package/dist/kernel/loader.d.ts.map +1 -0
- package/dist/kernel/loader.js +126 -0
- package/dist/kernel/loader.js.map +1 -0
- package/dist/kernel/mime.d.ts +13 -0
- package/dist/kernel/mime.d.ts.map +1 -0
- package/dist/kernel/mime.js +18 -0
- package/dist/kernel/mime.js.map +1 -0
- package/dist/kernel/mse.d.ts +62 -0
- package/dist/kernel/mse.d.ts.map +1 -0
- package/dist/kernel/mse.js +490 -0
- package/dist/kernel/mse.js.map +1 -0
- package/dist/kernel/reducer.d.ts +39 -0
- package/dist/kernel/reducer.d.ts.map +1 -0
- package/dist/kernel/reducer.js +1316 -0
- package/dist/kernel/reducer.js.map +1 -0
- package/dist/kernel/rendition-select.d.ts +102 -0
- package/dist/kernel/rendition-select.d.ts.map +1 -0
- package/dist/kernel/rendition-select.js +295 -0
- package/dist/kernel/rendition-select.js.map +1 -0
- package/dist/kernel/scheduler.d.ts +57 -0
- package/dist/kernel/scheduler.d.ts.map +1 -0
- package/dist/kernel/scheduler.js +98 -0
- package/dist/kernel/scheduler.js.map +1 -0
- package/dist/kernel/sinks/metadata-sink.d.ts +7 -0
- package/dist/kernel/sinks/metadata-sink.d.ts.map +1 -0
- package/dist/kernel/sinks/metadata-sink.js +5 -0
- package/dist/kernel/sinks/metadata-sink.js.map +1 -0
- package/dist/kernel/sinks/mse-sink.d.ts +17 -0
- package/dist/kernel/sinks/mse-sink.d.ts.map +1 -0
- package/dist/kernel/sinks/mse-sink.js +20 -0
- package/dist/kernel/sinks/mse-sink.js.map +1 -0
- package/dist/kernel/sinks/text-track-sink.d.ts +45 -0
- package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -0
- package/dist/kernel/sinks/text-track-sink.js +184 -0
- package/dist/kernel/sinks/text-track-sink.js.map +1 -0
- package/dist/kernel/timeline.d.ts +57 -0
- package/dist/kernel/timeline.d.ts.map +1 -0
- package/dist/kernel/timeline.js +203 -0
- package/dist/kernel/timeline.js.map +1 -0
- package/dist/kernel/trace.d.ts +42 -0
- package/dist/kernel/trace.d.ts.map +1 -0
- package/dist/kernel/trace.js +165 -0
- package/dist/kernel/trace.js.map +1 -0
- package/dist/kernel/track-registry.d.ts +22 -0
- package/dist/kernel/track-registry.d.ts.map +1 -0
- package/dist/kernel/track-registry.js +42 -0
- package/dist/kernel/track-registry.js.map +1 -0
- package/dist/kernel/transport.d.ts +90 -0
- package/dist/kernel/transport.d.ts.map +1 -0
- package/dist/kernel/transport.js +256 -0
- package/dist/kernel/transport.js.map +1 -0
- package/dist/kernel/watchdog.d.ts +35 -0
- package/dist/kernel/watchdog.d.ts.map +1 -0
- package/dist/kernel/watchdog.js +43 -0
- package/dist/kernel/watchdog.js.map +1 -0
- package/dist/presets/dash/index.d.ts +4 -0
- package/dist/presets/dash/index.d.ts.map +1 -0
- package/dist/presets/dash/index.js +8 -0
- package/dist/presets/dash/index.js.map +1 -0
- package/dist/presets/dash-drm/index.d.ts +4 -0
- package/dist/presets/dash-drm/index.d.ts.map +1 -0
- package/dist/presets/dash-drm/index.js +8 -0
- package/dist/presets/dash-drm/index.js.map +1 -0
- package/dist/presets/define.d.ts +36 -0
- package/dist/presets/define.d.ts.map +1 -0
- package/dist/presets/define.js +39 -0
- package/dist/presets/define.js.map +1 -0
- package/dist/presets/dual/index.d.ts +4 -0
- package/dist/presets/dual/index.d.ts.map +1 -0
- package/dist/presets/dual/index.js +9 -0
- package/dist/presets/dual/index.js.map +1 -0
- package/dist/presets/dual-drm/index.d.ts +4 -0
- package/dist/presets/dual-drm/index.d.ts.map +1 -0
- package/dist/presets/dual-drm/index.js +13 -0
- package/dist/presets/dual-drm/index.js.map +1 -0
- package/dist/presets/dual-ts/index.d.ts +4 -0
- package/dist/presets/dual-ts/index.d.ts.map +1 -0
- package/dist/presets/dual-ts/index.js +8 -0
- package/dist/presets/dual-ts/index.js.map +1 -0
- package/dist/presets/dual-ts-drm/index.d.ts +4 -0
- package/dist/presets/dual-ts-drm/index.d.ts.map +1 -0
- package/dist/presets/dual-ts-drm/index.js +14 -0
- package/dist/presets/dual-ts-drm/index.js.map +1 -0
- package/dist/presets/full/index.d.ts +4 -0
- package/dist/presets/full/index.d.ts.map +1 -0
- package/dist/presets/full/index.js +27 -0
- package/dist/presets/full/index.js.map +1 -0
- package/dist/presets/hls/index.d.ts +4 -0
- package/dist/presets/hls/index.d.ts.map +1 -0
- package/dist/presets/hls/index.js +8 -0
- package/dist/presets/hls/index.js.map +1 -0
- package/dist/presets/hls-drm/index.d.ts +4 -0
- package/dist/presets/hls-drm/index.d.ts.map +1 -0
- package/dist/presets/hls-drm/index.js +8 -0
- package/dist/presets/hls-drm/index.js.map +1 -0
- package/dist/presets/hls-ts/index.d.ts +4 -0
- package/dist/presets/hls-ts/index.d.ts.map +1 -0
- package/dist/presets/hls-ts/index.js +8 -0
- package/dist/presets/hls-ts/index.js.map +1 -0
- package/dist/presets/hls-ts-drm/index.d.ts +4 -0
- package/dist/presets/hls-ts-drm/index.d.ts.map +1 -0
- package/dist/presets/hls-ts-drm/index.js +13 -0
- package/dist/presets/hls-ts-drm/index.js.map +1 -0
- package/dist/presets/kernel/index.d.ts +4 -0
- package/dist/presets/kernel/index.d.ts.map +1 -0
- package/dist/presets/kernel/index.js +9 -0
- package/dist/presets/kernel/index.js.map +1 -0
- package/dist/presets/storage.d.ts +9 -0
- package/dist/presets/storage.d.ts.map +1 -0
- package/dist/presets/storage.js +24 -0
- package/dist/presets/storage.js.map +1 -0
- package/dist/presets/tiers.d.ts +22 -0
- package/dist/presets/tiers.d.ts.map +1 -0
- package/dist/presets/tiers.js +78 -0
- package/dist/presets/tiers.js.map +1 -0
- package/dist/protocols/dash-cmaf/index.d.ts +20 -0
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -0
- package/dist/protocols/dash-cmaf/index.js +176 -0
- package/dist/protocols/dash-cmaf/index.js.map +1 -0
- package/dist/protocols/dash-cmaf/parse.d.ts +24 -0
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -0
- package/dist/protocols/dash-cmaf/parse.js +586 -0
- package/dist/protocols/dash-cmaf/parse.js.map +1 -0
- package/dist/protocols/dash-live/index.d.ts +4 -0
- package/dist/protocols/dash-live/index.d.ts.map +1 -0
- package/dist/protocols/dash-live/index.js +188 -0
- package/dist/protocols/dash-live/index.js.map +1 -0
- package/dist/protocols/hls-cmaf/index.d.ts +17 -0
- package/dist/protocols/hls-cmaf/index.d.ts.map +1 -0
- package/dist/protocols/hls-cmaf/index.js +189 -0
- package/dist/protocols/hls-cmaf/index.js.map +1 -0
- package/dist/protocols/hls-cmaf/lexer.d.ts +25 -0
- package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -0
- package/dist/protocols/hls-cmaf/lexer.js +81 -0
- package/dist/protocols/hls-cmaf/lexer.js.map +1 -0
- package/dist/protocols/hls-cmaf/parse.d.ts +57 -0
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -0
- package/dist/protocols/hls-cmaf/parse.js +572 -0
- package/dist/protocols/hls-cmaf/parse.js.map +1 -0
- package/dist/protocols/hls-live/index.d.ts +4 -0
- package/dist/protocols/hls-live/index.d.ts.map +1 -0
- package/dist/protocols/hls-live/index.js +309 -0
- package/dist/protocols/hls-live/index.js.map +1 -0
- package/dist/protocols/live-shared.d.ts +21 -0
- package/dist/protocols/live-shared.d.ts.map +1 -0
- package/dist/protocols/live-shared.js +32 -0
- package/dist/protocols/live-shared.js.map +1 -0
- package/dist/stages/abr/index.d.ts +16 -0
- package/dist/stages/abr/index.d.ts.map +1 -0
- package/dist/stages/abr/index.js +176 -0
- package/dist/stages/abr/index.js.map +1 -0
- package/dist/stages/abr-cap-size/index.d.ts +8 -0
- package/dist/stages/abr-cap-size/index.d.ts.map +1 -0
- package/dist/stages/abr-cap-size/index.js +21 -0
- package/dist/stages/abr-cap-size/index.js.map +1 -0
- package/dist/stages/abr-persist/index.d.ts +8 -0
- package/dist/stages/abr-persist/index.d.ts.map +1 -0
- package/dist/stages/abr-persist/index.js +44 -0
- package/dist/stages/abr-persist/index.js.map +1 -0
- package/dist/stages/aes-128/index.d.ts +15 -0
- package/dist/stages/aes-128/index.d.ts.map +1 -0
- package/dist/stages/aes-128/index.js +78 -0
- package/dist/stages/aes-128/index.js.map +1 -0
- package/dist/stages/alt-audio/index.d.ts +4 -0
- package/dist/stages/alt-audio/index.d.ts.map +1 -0
- package/dist/stages/alt-audio/index.js +90 -0
- package/dist/stages/alt-audio/index.js.map +1 -0
- package/dist/stages/cmaf-timing/index.d.ts +3 -0
- package/dist/stages/cmaf-timing/index.d.ts.map +1 -0
- package/dist/stages/cmaf-timing/index.js +56 -0
- package/dist/stages/cmaf-timing/index.js.map +1 -0
- package/dist/stages/cmcd/index.d.ts +22 -0
- package/dist/stages/cmcd/index.d.ts.map +1 -0
- package/dist/stages/cmcd/index.js +92 -0
- package/dist/stages/cmcd/index.js.map +1 -0
- package/dist/stages/codec-probe/index.d.ts +9 -0
- package/dist/stages/codec-probe/index.d.ts.map +1 -0
- package/dist/stages/codec-probe/index.js +68 -0
- package/dist/stages/codec-probe/index.js.map +1 -0
- package/dist/stages/codec-switch/index.d.ts +6 -0
- package/dist/stages/codec-switch/index.d.ts.map +1 -0
- package/dist/stages/codec-switch/index.js +59 -0
- package/dist/stages/codec-switch/index.js.map +1 -0
- package/dist/stages/content-steering/index.d.ts +4 -0
- package/dist/stages/content-steering/index.d.ts.map +1 -0
- package/dist/stages/content-steering/index.js +174 -0
- package/dist/stages/content-steering/index.js.map +1 -0
- package/dist/stages/drm-shared.d.ts +46 -0
- package/dist/stages/drm-shared.d.ts.map +1 -0
- package/dist/stages/drm-shared.js +28 -0
- package/dist/stages/drm-shared.js.map +1 -0
- package/dist/stages/eme-cenc/index.d.ts +12 -0
- package/dist/stages/eme-cenc/index.d.ts.map +1 -0
- package/dist/stages/eme-cenc/index.js +53 -0
- package/dist/stages/eme-cenc/index.js.map +1 -0
- package/dist/stages/eme-core/index.d.ts +29 -0
- package/dist/stages/eme-core/index.d.ts.map +1 -0
- package/dist/stages/eme-core/index.js +244 -0
- package/dist/stages/eme-core/index.js.map +1 -0
- package/dist/stages/eme-fairplay/index.d.ts +20 -0
- package/dist/stages/eme-fairplay/index.d.ts.map +1 -0
- package/dist/stages/eme-fairplay/index.js +59 -0
- package/dist/stages/eme-fairplay/index.js.map +1 -0
- package/dist/stages/meta-id3/index.d.ts +14 -0
- package/dist/stages/meta-id3/index.d.ts.map +1 -0
- package/dist/stages/meta-id3/index.js +30 -0
- package/dist/stages/meta-id3/index.js.map +1 -0
- package/dist/stages/mp4-box/index.d.ts +3 -0
- package/dist/stages/mp4-box/index.d.ts.map +1 -0
- package/dist/stages/mp4-box/index.js +19 -0
- package/dist/stages/mp4-box/index.js.map +1 -0
- package/dist/stages/nal-scan/index.d.ts +3 -0
- package/dist/stages/nal-scan/index.d.ts.map +1 -0
- package/dist/stages/nal-scan/index.js +123 -0
- package/dist/stages/nal-scan/index.js.map +1 -0
- package/dist/stages/pdt/index.d.ts +14 -0
- package/dist/stages/pdt/index.d.ts.map +1 -0
- package/dist/stages/pdt/index.js +34 -0
- package/dist/stages/pdt/index.js.map +1 -0
- package/dist/stages/recovery/index.d.ts +16 -0
- package/dist/stages/recovery/index.d.ts.map +1 -0
- package/dist/stages/recovery/index.js +270 -0
- package/dist/stages/recovery/index.js.map +1 -0
- package/dist/stages/text-cea608/decode.d.ts +44 -0
- package/dist/stages/text-cea608/decode.d.ts.map +1 -0
- package/dist/stages/text-cea608/decode.js +225 -0
- package/dist/stages/text-cea608/decode.js.map +1 -0
- package/dist/stages/text-cea608/index.d.ts +3 -0
- package/dist/stages/text-cea608/index.d.ts.map +1 -0
- package/dist/stages/text-cea608/index.js +84 -0
- package/dist/stages/text-cea608/index.js.map +1 -0
- package/dist/stages/text-webvtt/index.d.ts +3 -0
- package/dist/stages/text-webvtt/index.d.ts.map +1 -0
- package/dist/stages/text-webvtt/index.js +82 -0
- package/dist/stages/text-webvtt/index.js.map +1 -0
- package/dist/stages/text-webvtt/parse.d.ts +19 -0
- package/dist/stages/text-webvtt/parse.d.ts.map +1 -0
- package/dist/stages/text-webvtt/parse.js +62 -0
- package/dist/stages/text-webvtt/parse.js.map +1 -0
- package/dist/stages/text-webvtt-segmented/index.d.ts +5 -0
- package/dist/stages/text-webvtt-segmented/index.d.ts.map +1 -0
- package/dist/stages/text-webvtt-segmented/index.js +63 -0
- package/dist/stages/text-webvtt-segmented/index.js.map +1 -0
- package/dist/stages/thumbnails/index.d.ts +34 -0
- package/dist/stages/thumbnails/index.d.ts.map +1 -0
- package/dist/stages/thumbnails/index.js +58 -0
- package/dist/stages/thumbnails/index.js.map +1 -0
- package/dist/types/error.d.ts +33 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/error.js +7 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/facade.d.ts +104 -0
- package/dist/types/facade.d.ts.map +1 -0
- package/dist/types/facade.js +2 -0
- package/dist/types/facade.js.map +1 -0
- package/dist/types/ir.d.ts +238 -0
- package/dist/types/ir.d.ts.map +1 -0
- package/dist/types/ir.js +7 -0
- package/dist/types/ir.js.map +1 -0
- package/dist/types/kernel.d.ts +217 -0
- package/dist/types/kernel.d.ts.map +1 -0
- package/dist/types/kernel.js +2 -0
- package/dist/types/kernel.js.map +1 -0
- package/dist/types/messages.d.ts +288 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +2 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/quality.d.ts +108 -0
- package/dist/types/quality.d.ts.map +1 -0
- package/dist/types/quality.js +2 -0
- package/dist/types/quality.js.map +1 -0
- package/dist/types/sink.d.ts +27 -0
- package/dist/types/sink.d.ts.map +1 -0
- package/dist/types/sink.js +2 -0
- package/dist/types/sink.js.map +1 -0
- package/dist/types/stage.d.ts +139 -0
- package/dist/types/stage.d.ts.map +1 -0
- package/dist/types/stage.js +2 -0
- package/dist/types/stage.js.map +1 -0
- package/package.json +132 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
|
|
3
|
+
//#region src/protocols/dash-cmaf/parse.ts
|
|
4
|
+
/**
|
|
5
|
+
* MPD into the IR. Pure: no fetching, no state, no side effects. DOMParser
|
|
6
|
+
* carries the XML work at zero bundle cost. URLs are resolved here, against
|
|
7
|
+
* the BaseURL chain, and stored absolute; downstream code never does URL
|
|
8
|
+
* arithmetic.
|
|
9
|
+
*
|
|
10
|
+
* AdaptationSet and Representation already match the IR's Track and
|
|
11
|
+
* Rendition, so unlike HLS there is no decomposition step. The coupling
|
|
12
|
+
* table stays empty: any video representation composes with any audio
|
|
13
|
+
* adaptation set. Preselection and @dependencyId would change that; both
|
|
14
|
+
* are out of scope and noted in the register.
|
|
15
|
+
*
|
|
16
|
+
* Single-period only. Templated addressing stays lazy: SegmentTemplate
|
|
17
|
+
* becomes IndexedSegments and the kernel materializes one segment at a
|
|
18
|
+
* time, so a long window never becomes an array.
|
|
19
|
+
*/
|
|
20
|
+
function manifestError(reason) {
|
|
21
|
+
return {
|
|
22
|
+
category: "manifest",
|
|
23
|
+
code: "MANIFEST_PARSE_FAILED",
|
|
24
|
+
fatal: true,
|
|
25
|
+
recoverable: false,
|
|
26
|
+
context: { reason }
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function resolve(uri, baseUrl) {
|
|
30
|
+
try {
|
|
31
|
+
return new URL(uri, baseUrl).href;
|
|
32
|
+
} catch (_unused) {
|
|
33
|
+
return uri;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** ISO 8601 duration to seconds. Date parts use nominal day lengths. */
|
|
37
|
+
function parseDuration(value) {
|
|
38
|
+
if (value === null) return null;
|
|
39
|
+
const match = /^-?P(?:(\d+(?:\.\d+)?)Y)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/.exec(value.trim());
|
|
40
|
+
if (match === null) return null;
|
|
41
|
+
const [, years, months, days, hours, minutes, seconds] = match;
|
|
42
|
+
return Number(years !== null && years !== void 0 ? years : 0) * 31536e3 + Number(months !== null && months !== void 0 ? months : 0) * 2592e3 + Number(days !== null && days !== void 0 ? days : 0) * 86400 + Number(hours !== null && hours !== void 0 ? hours : 0) * 3600 + Number(minutes !== null && minutes !== void 0 ? minutes : 0) * 60 + Number(seconds !== null && seconds !== void 0 ? seconds : 0);
|
|
43
|
+
}
|
|
44
|
+
/** Direct children by local name; namespace-agnostic on purpose. */
|
|
45
|
+
function children(parent, name) {
|
|
46
|
+
const found = [];
|
|
47
|
+
for (const child of parent.children) if (child.localName === name) found.push(child);
|
|
48
|
+
return found;
|
|
49
|
+
}
|
|
50
|
+
function attr(element, name) {
|
|
51
|
+
return element.getAttribute(name);
|
|
52
|
+
}
|
|
53
|
+
function numberAttr(element, name) {
|
|
54
|
+
const value = element.getAttribute(name);
|
|
55
|
+
if (value === null) return null;
|
|
56
|
+
const parsed = Number(value);
|
|
57
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
58
|
+
}
|
|
59
|
+
/** @frameRate is "30" or "30000/1001". */
|
|
60
|
+
function parseFrameRate(value) {
|
|
61
|
+
if (value === null) return null;
|
|
62
|
+
const [num, den] = value.split("/").map(Number);
|
|
63
|
+
if (num === void 0 || !Number.isFinite(num)) return null;
|
|
64
|
+
if (den !== void 0) return Number.isFinite(den) && den > 0 ? num / den : null;
|
|
65
|
+
return num;
|
|
66
|
+
}
|
|
67
|
+
/** A DASH byte range is "start-end" inclusive (ISO/IEC 23009-1 §5.3.9.2.2). */
|
|
68
|
+
function parseByteRange(value) {
|
|
69
|
+
if (value === null) return null;
|
|
70
|
+
const [startText, endText] = value.split("-");
|
|
71
|
+
const start = Number(startText);
|
|
72
|
+
const end = Number(endText);
|
|
73
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start) return null;
|
|
74
|
+
return {
|
|
75
|
+
start,
|
|
76
|
+
end
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** The first BaseURL child resolved against `base`. Siblings are alternatives; the first wins. */
|
|
80
|
+
function applyBaseUrl(element, base) {
|
|
81
|
+
var _baseElements$;
|
|
82
|
+
const text = (_baseElements$ = children(element, "BaseURL")[0]) === null || _baseElements$ === void 0 || (_baseElements$ = _baseElements$.textContent) === null || _baseElements$ === void 0 ? void 0 : _baseElements$.trim();
|
|
83
|
+
return text !== void 0 && text !== "" ? resolve(text, base) : base;
|
|
84
|
+
}
|
|
85
|
+
function base64ToArrayBuffer(text) {
|
|
86
|
+
try {
|
|
87
|
+
const binary = atob(text.replace(/\s+/g, ""));
|
|
88
|
+
const bytes = new Uint8Array(binary.length);
|
|
89
|
+
for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
|
|
90
|
+
return bytes.buffer;
|
|
91
|
+
} catch (_unused2) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const MP4_PROTECTION = "urn:mpeg:dash:mp4protection:2011";
|
|
96
|
+
const UUID_URN = /^urn:uuid:([0-9a-f-]{36})$/i;
|
|
97
|
+
/**
|
|
98
|
+
* ContentProtection elements into protection schemes. The mp4protection
|
|
99
|
+
* element carries the common scheme and default key id; each urn:uuid
|
|
100
|
+
* element names one key system, optionally with manifest init data.
|
|
101
|
+
*/
|
|
102
|
+
function parseProtection(elements) {
|
|
103
|
+
let commonScheme = null;
|
|
104
|
+
let commonKeyId = null;
|
|
105
|
+
for (const element of elements) {
|
|
106
|
+
var _attr;
|
|
107
|
+
if (((_attr = attr(element, "schemeIdUri")) === null || _attr === void 0 ? void 0 : _attr.toLowerCase()) === MP4_PROTECTION) {
|
|
108
|
+
var _attr$toLowerCase, _attr2, _attr3;
|
|
109
|
+
commonScheme = (_attr$toLowerCase = (_attr2 = attr(element, "value")) === null || _attr2 === void 0 ? void 0 : _attr2.toLowerCase()) !== null && _attr$toLowerCase !== void 0 ? _attr$toLowerCase : null;
|
|
110
|
+
const kid = (_attr3 = attr(element, "cenc:default_KID")) !== null && _attr3 !== void 0 ? _attr3 : attr(element, "default_KID");
|
|
111
|
+
commonKeyId = kid !== null ? kid.replaceAll("-", "").toLowerCase() : null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const schemes = [];
|
|
115
|
+
for (const element of elements) {
|
|
116
|
+
var _attr4, _children$;
|
|
117
|
+
const schemeIdUri = (_attr4 = attr(element, "schemeIdUri")) !== null && _attr4 !== void 0 ? _attr4 : "";
|
|
118
|
+
const uuid = UUID_URN.exec(schemeIdUri);
|
|
119
|
+
if (uuid === null) continue;
|
|
120
|
+
const pssh = (_children$ = children(element, "pssh")[0]) === null || _children$ === void 0 || (_children$ = _children$.textContent) === null || _children$ === void 0 ? void 0 : _children$.trim();
|
|
121
|
+
const initData = pssh !== void 0 && pssh !== "" ? base64ToArrayBuffer(pssh) : null;
|
|
122
|
+
schemes.push({
|
|
123
|
+
systemId: uuid[1].toLowerCase(),
|
|
124
|
+
scheme: commonScheme,
|
|
125
|
+
keyId: commonKeyId,
|
|
126
|
+
licenseUrl: null,
|
|
127
|
+
initData,
|
|
128
|
+
initDataType: initData !== null ? "cenc" : null
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (schemes.length === 0 && (commonScheme !== null || commonKeyId !== null)) schemes.push({
|
|
132
|
+
systemId: null,
|
|
133
|
+
scheme: commonScheme,
|
|
134
|
+
keyId: commonKeyId,
|
|
135
|
+
licenseUrl: null,
|
|
136
|
+
initData: null,
|
|
137
|
+
initDataType: null
|
|
138
|
+
});
|
|
139
|
+
return schemes;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A trick-mode AdaptationSet: the DASH-IF trickmode EssentialProperty, or a
|
|
143
|
+
* representation declaring a playout rate other than 1. Both mark an
|
|
144
|
+
* I-frame-only set meant for scrubbing, never for normal playback.
|
|
145
|
+
*/
|
|
146
|
+
function isTrickMode(adaptationSet) {
|
|
147
|
+
for (const property of children(adaptationSet, "EssentialProperty")) {
|
|
148
|
+
var _attr5;
|
|
149
|
+
if (((_attr5 = attr(property, "schemeIdUri")) !== null && _attr5 !== void 0 ? _attr5 : "").includes("trickmode")) return true;
|
|
150
|
+
}
|
|
151
|
+
if (numberAttr(adaptationSet, "maxPlayoutRate") !== null) return true;
|
|
152
|
+
for (const representation of children(adaptationSet, "Representation")) {
|
|
153
|
+
const rate = numberAttr(representation, "maxPlayoutRate");
|
|
154
|
+
if (rate !== null && rate !== 1) return true;
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
/** Merges SegmentTemplate attributes down Period, AdaptationSet, Representation. */
|
|
159
|
+
function mergeTemplates(levels) {
|
|
160
|
+
var _timescale, _startNumber, _pto;
|
|
161
|
+
let media = null;
|
|
162
|
+
let initialization = null;
|
|
163
|
+
let timescale = null;
|
|
164
|
+
let startNumber = null;
|
|
165
|
+
let duration = null;
|
|
166
|
+
let pto = null;
|
|
167
|
+
let timelineElement = null;
|
|
168
|
+
let found = false;
|
|
169
|
+
for (const level of levels) {
|
|
170
|
+
var _attr6, _attr7, _numberAttr, _numberAttr2, _numberAttr3, _numberAttr4, _children$2;
|
|
171
|
+
const template = children(level, "SegmentTemplate")[0];
|
|
172
|
+
if (template === void 0) continue;
|
|
173
|
+
found = true;
|
|
174
|
+
media = (_attr6 = attr(template, "media")) !== null && _attr6 !== void 0 ? _attr6 : media;
|
|
175
|
+
initialization = (_attr7 = attr(template, "initialization")) !== null && _attr7 !== void 0 ? _attr7 : initialization;
|
|
176
|
+
timescale = (_numberAttr = numberAttr(template, "timescale")) !== null && _numberAttr !== void 0 ? _numberAttr : timescale;
|
|
177
|
+
startNumber = (_numberAttr2 = numberAttr(template, "startNumber")) !== null && _numberAttr2 !== void 0 ? _numberAttr2 : startNumber;
|
|
178
|
+
duration = (_numberAttr3 = numberAttr(template, "duration")) !== null && _numberAttr3 !== void 0 ? _numberAttr3 : duration;
|
|
179
|
+
pto = (_numberAttr4 = numberAttr(template, "presentationTimeOffset")) !== null && _numberAttr4 !== void 0 ? _numberAttr4 : pto;
|
|
180
|
+
timelineElement = (_children$2 = children(template, "SegmentTimeline")[0]) !== null && _children$2 !== void 0 ? _children$2 : timelineElement;
|
|
181
|
+
}
|
|
182
|
+
if (!found) return null;
|
|
183
|
+
return {
|
|
184
|
+
media,
|
|
185
|
+
initialization,
|
|
186
|
+
timescale: (_timescale = timescale) !== null && _timescale !== void 0 ? _timescale : 1,
|
|
187
|
+
startNumber: (_startNumber = startNumber) !== null && _startNumber !== void 0 ? _startNumber : 1,
|
|
188
|
+
duration,
|
|
189
|
+
presentationTimeOffset: (_pto = pto) !== null && _pto !== void 0 ? _pto : 0,
|
|
190
|
+
timelineElement
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* SegmentTimeline into compressed runs. @r repeats; a negative @r repeats
|
|
195
|
+
* until the next S@t, or the period end on the last S.
|
|
196
|
+
*/
|
|
197
|
+
function parseTimeline(timelineElement, periodEndUnits) {
|
|
198
|
+
const sElements = children(timelineElement, "S");
|
|
199
|
+
const runs = [];
|
|
200
|
+
let time = 0;
|
|
201
|
+
for (let i = 0; i < sElements.length; i += 1) {
|
|
202
|
+
var _numberAttr5, _numberAttr6;
|
|
203
|
+
const s = sElements[i];
|
|
204
|
+
const d = numberAttr(s, "d");
|
|
205
|
+
if (d === null || d <= 0) return null;
|
|
206
|
+
time = (_numberAttr5 = numberAttr(s, "t")) !== null && _numberAttr5 !== void 0 ? _numberAttr5 : time;
|
|
207
|
+
const r = (_numberAttr6 = numberAttr(s, "r")) !== null && _numberAttr6 !== void 0 ? _numberAttr6 : 0;
|
|
208
|
+
let count;
|
|
209
|
+
if (r >= 0) count = r + 1;
|
|
210
|
+
else {
|
|
211
|
+
const next = sElements[i + 1];
|
|
212
|
+
const until = next !== void 0 ? numberAttr(next, "t") : periodEndUnits;
|
|
213
|
+
if (until === null || until === void 0) return null;
|
|
214
|
+
count = Math.max(1, Math.ceil((until - time) / d));
|
|
215
|
+
}
|
|
216
|
+
runs.push({
|
|
217
|
+
start: time,
|
|
218
|
+
duration: d,
|
|
219
|
+
count
|
|
220
|
+
});
|
|
221
|
+
time += d * count;
|
|
222
|
+
}
|
|
223
|
+
return runs.length > 0 ? runs : null;
|
|
224
|
+
}
|
|
225
|
+
/** Constant substitutions: $RepresentationID$ and $Bandwidth$, with format tags, and never $$-escaped content. */
|
|
226
|
+
function substituteIdentity(template, id, bandwidth) {
|
|
227
|
+
return template.replace(/\$RepresentationID\$/g, id).replace(/\$Bandwidth(?:%0(\d+)d)?\$/g, (_, width) => {
|
|
228
|
+
const text = String(bandwidth);
|
|
229
|
+
return width === void 0 ? text : text.padStart(Number(width), "0");
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function contentTypeOf(adaptationSet, mimeType) {
|
|
233
|
+
const declared = attr(adaptationSet, "contentType");
|
|
234
|
+
if (declared === "video" || declared === "audio" || declared === "text" || declared === "image" || declared === "metadata") return declared;
|
|
235
|
+
if (mimeType.startsWith("audio/")) return "audio";
|
|
236
|
+
if (mimeType.startsWith("image/")) return "image";
|
|
237
|
+
if (mimeType.startsWith("text/") || mimeType === "application/ttml+xml") return "text";
|
|
238
|
+
return "video";
|
|
239
|
+
}
|
|
240
|
+
/** parse an MPD document into a Presentation. Never throws. */
|
|
241
|
+
function parse(text, baseUrl) {
|
|
242
|
+
var _parseDuration, _parseDuration2, _attr15;
|
|
243
|
+
let doc;
|
|
244
|
+
try {
|
|
245
|
+
doc = new DOMParser().parseFromString(text, "text/xml");
|
|
246
|
+
} catch (cause) {
|
|
247
|
+
return {
|
|
248
|
+
presentation: null,
|
|
249
|
+
error: _objectSpread2(_objectSpread2({}, manifestError("unparsable XML")), {}, { cause })
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const mpd = doc.documentElement;
|
|
253
|
+
if (mpd === null || mpd.localName !== "MPD" || doc.getElementsByTagName("parsererror").length > 0) return {
|
|
254
|
+
presentation: null,
|
|
255
|
+
error: manifestError("not an MPD document")
|
|
256
|
+
};
|
|
257
|
+
const isLive = attr(mpd, "type") === "dynamic";
|
|
258
|
+
const mpdDuration = parseDuration(attr(mpd, "mediaPresentationDuration"));
|
|
259
|
+
const mpdBase = applyBaseUrl(mpd, baseUrl);
|
|
260
|
+
let live;
|
|
261
|
+
if (isLive) {
|
|
262
|
+
var _attr8, _attr9, _attr10;
|
|
263
|
+
const availabilityStart = Date.parse((_attr8 = attr(mpd, "availabilityStartTime")) !== null && _attr8 !== void 0 ? _attr8 : "");
|
|
264
|
+
const updatePeriod = parseDuration(attr(mpd, "minimumUpdatePeriod"));
|
|
265
|
+
const timeShiftDepth = parseDuration(attr(mpd, "timeShiftBufferDepth"));
|
|
266
|
+
const holdBack = parseDuration(attr(mpd, "suggestedPresentationDelay"));
|
|
267
|
+
const timing = children(mpd, "UTCTiming")[0];
|
|
268
|
+
live = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, Number.isFinite(availabilityStart) ? { availabilityStart: availabilityStart / 1e3 } : {}), updatePeriod !== null ? { updatePeriod } : {}), timeShiftDepth !== null ? { timeShiftDepth } : {}), holdBack !== null ? { holdBack } : {}), timing !== void 0 ? { timeServer: {
|
|
269
|
+
scheme: (_attr9 = attr(timing, "schemeIdUri")) !== null && _attr9 !== void 0 ? _attr9 : "",
|
|
270
|
+
value: (_attr10 = attr(timing, "value")) !== null && _attr10 !== void 0 ? _attr10 : ""
|
|
271
|
+
} } : {});
|
|
272
|
+
}
|
|
273
|
+
let steering;
|
|
274
|
+
const steeringElement = children(mpd, "ContentSteering")[0];
|
|
275
|
+
if (steeringElement !== void 0) {
|
|
276
|
+
var _steeringElement$text, _steeringElement$text2;
|
|
277
|
+
const serverUri = (_steeringElement$text = (_steeringElement$text2 = steeringElement.textContent) === null || _steeringElement$text2 === void 0 ? void 0 : _steeringElement$text2.trim()) !== null && _steeringElement$text !== void 0 ? _steeringElement$text : "";
|
|
278
|
+
if (serverUri !== "") {
|
|
279
|
+
const bases = {};
|
|
280
|
+
for (const base of children(mpd, "BaseURL")) {
|
|
281
|
+
var _base$textContent;
|
|
282
|
+
const location = attr(base, "serviceLocation");
|
|
283
|
+
const text = (_base$textContent = base.textContent) === null || _base$textContent === void 0 ? void 0 : _base$textContent.trim();
|
|
284
|
+
if (location !== null && text !== void 0 && text !== "") bases[location] = resolve(text, baseUrl);
|
|
285
|
+
}
|
|
286
|
+
steering = _objectSpread2(_objectSpread2({ serverUri: resolve(serverUri, baseUrl) }, attr(steeringElement, "defaultServiceLocation") !== null ? { defaultPathway: attr(steeringElement, "defaultServiceLocation") } : {}), Object.keys(bases).length > 0 ? { bases } : {});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const periodElement = children(mpd, "Period")[0];
|
|
290
|
+
if (periodElement === void 0) return {
|
|
291
|
+
presentation: null,
|
|
292
|
+
error: {
|
|
293
|
+
category: "manifest",
|
|
294
|
+
code: "MANIFEST_EMPTY",
|
|
295
|
+
fatal: true,
|
|
296
|
+
recoverable: false,
|
|
297
|
+
context: { reason: "MPD with no Period" }
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
const periodStart = (_parseDuration = parseDuration(attr(periodElement, "start"))) !== null && _parseDuration !== void 0 ? _parseDuration : 0;
|
|
301
|
+
const periodDuration = (_parseDuration2 = parseDuration(attr(periodElement, "duration"))) !== null && _parseDuration2 !== void 0 ? _parseDuration2 : mpdDuration !== null ? mpdDuration - periodStart : null;
|
|
302
|
+
const periodBase = applyBaseUrl(periodElement, mpdBase);
|
|
303
|
+
const tracks = [];
|
|
304
|
+
const adaptationSets = children(periodElement, "AdaptationSet");
|
|
305
|
+
for (let asIndex = 0; asIndex < adaptationSets.length; asIndex += 1) {
|
|
306
|
+
var _children$0$getAttrib, _children$3, _trackMime2;
|
|
307
|
+
const adaptationSet = adaptationSets[asIndex];
|
|
308
|
+
if (isTrickMode(adaptationSet)) continue;
|
|
309
|
+
const asBase = applyBaseUrl(adaptationSet, periodBase);
|
|
310
|
+
const asMime = attr(adaptationSet, "mimeType");
|
|
311
|
+
const asCodecs = attr(adaptationSet, "codecs");
|
|
312
|
+
const lang = attr(adaptationSet, "lang");
|
|
313
|
+
const role = (_children$0$getAttrib = (_children$3 = children(adaptationSet, "Role")[0]) === null || _children$3 === void 0 ? void 0 : _children$3.getAttribute("value")) !== null && _children$0$getAttrib !== void 0 ? _children$0$getAttrib : null;
|
|
314
|
+
const protectionSchemes = parseProtection(children(adaptationSet, "ContentProtection"));
|
|
315
|
+
const renditions = [];
|
|
316
|
+
let trackMime = null;
|
|
317
|
+
for (const representation of children(adaptationSet, "Representation")) {
|
|
318
|
+
var _ref, _attr11, _trackMime, _parseFrameRate2, _attr14;
|
|
319
|
+
const id = attr(representation, "id");
|
|
320
|
+
const bandwidth = numberAttr(representation, "bandwidth");
|
|
321
|
+
if (id === null || bandwidth === null) continue;
|
|
322
|
+
const repBase = applyBaseUrl(representation, asBase);
|
|
323
|
+
const mimeType = (_ref = (_attr11 = attr(representation, "mimeType")) !== null && _attr11 !== void 0 ? _attr11 : asMime) !== null && _ref !== void 0 ? _ref : "video/mp4";
|
|
324
|
+
trackMime = (_trackMime = trackMime) !== null && _trackMime !== void 0 ? _trackMime : mimeType;
|
|
325
|
+
const segmentBase = children(representation, "SegmentBase")[0];
|
|
326
|
+
if (segmentBase !== void 0) {
|
|
327
|
+
var _numberAttr7, _parseFrameRate, _attr12;
|
|
328
|
+
const indexRange = parseByteRange(attr(segmentBase, "indexRange"));
|
|
329
|
+
if (indexRange === null) continue;
|
|
330
|
+
const baseTimescale = (_numberAttr7 = numberAttr(segmentBase, "timescale")) !== null && _numberAttr7 !== void 0 ? _numberAttr7 : 1;
|
|
331
|
+
const pto = numberAttr(segmentBase, "presentationTimeOffset");
|
|
332
|
+
const initElement = children(segmentBase, "Initialization")[0];
|
|
333
|
+
const initRange = initElement !== void 0 ? parseByteRange(attr(initElement, "range")) : null;
|
|
334
|
+
const sidxSegments = _objectSpread2({
|
|
335
|
+
kind: "sidx",
|
|
336
|
+
url: repBase,
|
|
337
|
+
indexRange,
|
|
338
|
+
timescale: baseTimescale
|
|
339
|
+
}, pto !== null && pto !== 0 ? { presentationTimeOffset: pto / baseTimescale } : {});
|
|
340
|
+
const sidxInit = initRange !== null ? {
|
|
341
|
+
url: repBase,
|
|
342
|
+
byteRange: initRange
|
|
343
|
+
} : null;
|
|
344
|
+
const w = numberAttr(representation, "width");
|
|
345
|
+
const h = numberAttr(representation, "height");
|
|
346
|
+
const fr = (_parseFrameRate = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate !== void 0 ? _parseFrameRate : parseFrameRate(attr(adaptationSet, "frameRate"));
|
|
347
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
348
|
+
id,
|
|
349
|
+
bitrate: bandwidth,
|
|
350
|
+
codecs: (_attr12 = attr(representation, "codecs")) !== null && _attr12 !== void 0 ? _attr12 : asCodecs,
|
|
351
|
+
mimeType,
|
|
352
|
+
segments: sidxSegments
|
|
353
|
+
}, sidxInit !== null ? { init: sidxInit } : {}), w !== null ? { width: w } : {}), h !== null ? { height: h } : {}), fr !== null ? { frameRate: fr } : {}));
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
const template = mergeTemplates([
|
|
357
|
+
periodElement,
|
|
358
|
+
adaptationSet,
|
|
359
|
+
representation
|
|
360
|
+
]);
|
|
361
|
+
if (template === null || template.media === null) {
|
|
362
|
+
if (contentTypeOf(adaptationSet, mimeType) === "text" && periodDuration !== null) {
|
|
363
|
+
var _attr13;
|
|
364
|
+
renditions.push({
|
|
365
|
+
id,
|
|
366
|
+
bitrate: bandwidth,
|
|
367
|
+
codecs: (_attr13 = attr(representation, "codecs")) !== null && _attr13 !== void 0 ? _attr13 : asCodecs,
|
|
368
|
+
mimeType,
|
|
369
|
+
segments: [{
|
|
370
|
+
seq: 0,
|
|
371
|
+
start: periodStart,
|
|
372
|
+
duration: periodDuration,
|
|
373
|
+
url: repBase
|
|
374
|
+
}]
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
const periodEndUnits = periodDuration !== null ? Math.round(template.presentationTimeOffset + periodDuration * template.timescale) : null;
|
|
380
|
+
const timeline = template.timelineElement !== null ? parseTimeline(template.timelineElement, periodEndUnits) : null;
|
|
381
|
+
if (template.timelineElement !== null && timeline === null) return {
|
|
382
|
+
presentation: null,
|
|
383
|
+
error: manifestError(`bad SegmentTimeline in '${id}'`)
|
|
384
|
+
};
|
|
385
|
+
let endSeq = null;
|
|
386
|
+
if (timeline !== null) endSeq = template.startNumber - 1 + timeline.reduce((sum, run) => sum + run.count, 0);
|
|
387
|
+
else if (template.duration !== null && periodDuration !== null) endSeq = template.startNumber - 1 + Math.ceil(periodDuration * template.timescale / template.duration);
|
|
388
|
+
else if (template.duration === null) return {
|
|
389
|
+
presentation: null,
|
|
390
|
+
error: manifestError(`no addressing for '${id}'`)
|
|
391
|
+
};
|
|
392
|
+
const segments = _objectSpread2({
|
|
393
|
+
kind: "indexed",
|
|
394
|
+
urlTemplate: resolve(substituteIdentity(template.media, id, bandwidth), repBase),
|
|
395
|
+
startSeq: template.startNumber,
|
|
396
|
+
endSeq: isLive ? null : endSeq,
|
|
397
|
+
timescale: template.timescale,
|
|
398
|
+
segmentDuration: timeline !== null ? null : template.duration,
|
|
399
|
+
timeline
|
|
400
|
+
}, template.presentationTimeOffset !== 0 ? { presentationTimeOffset: template.presentationTimeOffset } : {});
|
|
401
|
+
const init = template.initialization !== null ? { url: resolve(substituteIdentity(template.initialization, id, bandwidth), repBase) } : null;
|
|
402
|
+
const frameRate = (_parseFrameRate2 = parseFrameRate(attr(representation, "frameRate"))) !== null && _parseFrameRate2 !== void 0 ? _parseFrameRate2 : parseFrameRate(attr(adaptationSet, "frameRate"));
|
|
403
|
+
const width = numberAttr(representation, "width");
|
|
404
|
+
const height = numberAttr(representation, "height");
|
|
405
|
+
renditions.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
406
|
+
id,
|
|
407
|
+
bitrate: bandwidth,
|
|
408
|
+
codecs: (_attr14 = attr(representation, "codecs")) !== null && _attr14 !== void 0 ? _attr14 : asCodecs,
|
|
409
|
+
mimeType,
|
|
410
|
+
segments
|
|
411
|
+
}, init !== null ? { init } : {}), width !== null ? { width } : {}), height !== null ? { height } : {}), frameRate !== null ? { frameRate } : {}));
|
|
412
|
+
}
|
|
413
|
+
if (renditions.length === 0) continue;
|
|
414
|
+
const mimeType = (_trackMime2 = trackMime) !== null && _trackMime2 !== void 0 ? _trackMime2 : "video/mp4";
|
|
415
|
+
tracks.push(_objectSpread2(_objectSpread2({
|
|
416
|
+
id: attr(adaptationSet, "id") !== null ? `as-${attr(adaptationSet, "id")}` : `as-i${asIndex}`,
|
|
417
|
+
contentType: contentTypeOf(adaptationSet, mimeType),
|
|
418
|
+
mimeType,
|
|
419
|
+
protection: protectionSchemes.length > 0 ? { schemes: protectionSchemes } : null,
|
|
420
|
+
renditions
|
|
421
|
+
}, lang !== null ? { lang } : {}), role !== null ? { role } : {}));
|
|
422
|
+
}
|
|
423
|
+
if (tracks.length === 0) return {
|
|
424
|
+
presentation: null,
|
|
425
|
+
error: {
|
|
426
|
+
category: "manifest",
|
|
427
|
+
code: "MANIFEST_EMPTY",
|
|
428
|
+
fatal: true,
|
|
429
|
+
recoverable: false,
|
|
430
|
+
context: { reason: "no playable adaptation set" }
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
return {
|
|
434
|
+
presentation: _objectSpread2(_objectSpread2(_objectSpread2({
|
|
435
|
+
id: baseUrl,
|
|
436
|
+
isLive
|
|
437
|
+
}, mpdDuration !== null ? { duration: mpdDuration } : {}), {}, {
|
|
438
|
+
periods: [_objectSpread2(_objectSpread2({
|
|
439
|
+
id: (_attr15 = attr(periodElement, "id")) !== null && _attr15 !== void 0 ? _attr15 : "p0",
|
|
440
|
+
start: periodStart
|
|
441
|
+
}, periodDuration !== null ? { duration: periodDuration } : {}), {}, { tracks })],
|
|
442
|
+
couplings: []
|
|
443
|
+
}, live !== void 0 ? { live } : {}), steering !== void 0 ? { steering } : {}),
|
|
444
|
+
error: null
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Turns a fetched sidx box into explicit byte-range segments. The first media
|
|
449
|
+
* byte sits immediately after the sidx box (indexRange.end + 1) plus the box's
|
|
450
|
+
* own firstOffset; each reference then names one subsegment's byte size and
|
|
451
|
+
* duration in timescale units. ISO/IEC 14496-12 SegmentIndexBox.
|
|
452
|
+
*/
|
|
453
|
+
function sidxToSegments(sidxBytes, addressing) {
|
|
454
|
+
var _addressing$presentat;
|
|
455
|
+
const box = findBox(sidxBytes, "sidx");
|
|
456
|
+
if (box === null) return [];
|
|
457
|
+
const sidx = parseSidx(box.payload);
|
|
458
|
+
if (sidx === null) return [];
|
|
459
|
+
const timescale = sidx.timescale || addressing.timescale || 1;
|
|
460
|
+
const pto = (_addressing$presentat = addressing.presentationTimeOffset) !== null && _addressing$presentat !== void 0 ? _addressing$presentat : 0;
|
|
461
|
+
let offset = addressing.indexRange.end + 1 + sidx.firstOffset;
|
|
462
|
+
let mediaTime = sidx.earliestPresentationTime;
|
|
463
|
+
const segments = [];
|
|
464
|
+
for (let i = 0; i < sidx.references.length; i += 1) {
|
|
465
|
+
const ref = sidx.references[i];
|
|
466
|
+
if (ref === void 0) break;
|
|
467
|
+
segments.push({
|
|
468
|
+
seq: i,
|
|
469
|
+
start: mediaTime / timescale - pto,
|
|
470
|
+
duration: ref.subsegmentDuration / timescale,
|
|
471
|
+
url: addressing.url,
|
|
472
|
+
byteRange: {
|
|
473
|
+
start: offset,
|
|
474
|
+
end: offset + ref.referencedSize - 1
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
offset += ref.referencedSize;
|
|
478
|
+
mediaTime += ref.subsegmentDuration;
|
|
479
|
+
}
|
|
480
|
+
return segments;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Immutably swaps a rendition's unresolved sidx addressing for the explicit
|
|
484
|
+
* segment list parsed from its index box. Everything else about the
|
|
485
|
+
* presentation is already known from the MPD.
|
|
486
|
+
*/
|
|
487
|
+
function mergeSidx(presentation, renditionId, segments) {
|
|
488
|
+
return _objectSpread2(_objectSpread2({}, presentation), {}, { periods: presentation.periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, { tracks: period.tracks.map((track) => track.renditions.some((r) => r.id === renditionId) ? _objectSpread2(_objectSpread2({}, track), {}, { renditions: track.renditions.map((rendition) => rendition.id === renditionId ? _objectSpread2(_objectSpread2({}, rendition), {}, { segments }) : rendition) }) : track) })) });
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
491
|
+
export { mergeSidx, parse, parseDuration, sidxToSegments };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { registerLiveNamespace } from "../live-shared.js";
|
|
3
|
+
import { parse } from "../dash-cmaf/parse.js";
|
|
4
|
+
//#region src/protocols/dash-live/index.ts
|
|
5
|
+
const MPD_TOKEN = "dash:live:mpd";
|
|
6
|
+
const UTC_TOKEN = "dash:live:utc";
|
|
7
|
+
const TICK_TOKEN = "dash-live:reload";
|
|
8
|
+
const CLOCK_TOKEN = "dash-live:clock";
|
|
9
|
+
/** Fallback hold-back when the MPD suggests nothing, in seconds. */
|
|
10
|
+
const DEFAULT_HOLD_BACK = 10;
|
|
11
|
+
/** Fallback DVR depth, in seconds. */
|
|
12
|
+
const DEFAULT_TIME_SHIFT = 60;
|
|
13
|
+
/** Window movement below this is not worth a fact, in seconds. */
|
|
14
|
+
const WINDOW_QUANTUM = .5;
|
|
15
|
+
const INITIAL = {
|
|
16
|
+
manifestUrl: null,
|
|
17
|
+
skew: null,
|
|
18
|
+
utcPending: false,
|
|
19
|
+
tickPending: false,
|
|
20
|
+
clockPending: false,
|
|
21
|
+
lastWindowEnd: -1,
|
|
22
|
+
lastWallClock: null
|
|
23
|
+
};
|
|
24
|
+
/** The window arithmetic; null when it cannot move or is not worth a fact. */
|
|
25
|
+
function windowUpdate(state, live) {
|
|
26
|
+
var _state$skew, _live$timeShiftDepth, _live$holdBack;
|
|
27
|
+
if (live.availabilityStart === void 0 || state.lastWallClock === null) return null;
|
|
28
|
+
const end = state.lastWallClock + ((_state$skew = state.skew) !== null && _state$skew !== void 0 ? _state$skew : 0) - live.availabilityStart;
|
|
29
|
+
if (end <= 0 || Math.abs(end - state.lastWindowEnd) < WINDOW_QUANTUM) return null;
|
|
30
|
+
const start = Math.max(0, end - ((_live$timeShiftDepth = live.timeShiftDepth) !== null && _live$timeShiftDepth !== void 0 ? _live$timeShiftDepth : DEFAULT_TIME_SHIFT));
|
|
31
|
+
const edge = Math.max(start, end - ((_live$holdBack = live.holdBack) !== null && _live$holdBack !== void 0 ? _live$holdBack : DEFAULT_HOLD_BACK));
|
|
32
|
+
return {
|
|
33
|
+
next: _objectSpread2(_objectSpread2({}, state), {}, { lastWindowEnd: end }),
|
|
34
|
+
fact: feed({
|
|
35
|
+
type: "LIVE_WINDOW_CHANGED",
|
|
36
|
+
start,
|
|
37
|
+
end,
|
|
38
|
+
edge
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether this slice owns the presentation's live window: a dynamic MPD,
|
|
44
|
+
* which ISO 23009-1 requires to carry availabilityStartTime. An HLS live
|
|
45
|
+
* presentation is live too but has no availability start; its window is
|
|
46
|
+
* read from playlists by hls-live, and reloading its master as an MPD on
|
|
47
|
+
* a one-second clock is only noise.
|
|
48
|
+
*/
|
|
49
|
+
function drivesWindow(presentation) {
|
|
50
|
+
var _presentation$live;
|
|
51
|
+
return (presentation === null || presentation === void 0 ? void 0 : presentation.isLive) === true && ((_presentation$live = presentation.live) === null || _presentation$live === void 0 ? void 0 : _presentation$live.availabilityStart) !== void 0;
|
|
52
|
+
}
|
|
53
|
+
/** Loops a message back into the bus through a zero-delay schedule effect. */
|
|
54
|
+
function feed(message) {
|
|
55
|
+
return {
|
|
56
|
+
kind: "schedule",
|
|
57
|
+
token: "dash-live:loopback",
|
|
58
|
+
delayMs: 0,
|
|
59
|
+
then: message
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function tick(delaySeconds) {
|
|
63
|
+
return {
|
|
64
|
+
kind: "schedule",
|
|
65
|
+
token: TICK_TOKEN,
|
|
66
|
+
delayMs: Math.max(500, delaySeconds * 1e3),
|
|
67
|
+
then: {
|
|
68
|
+
type: "TICK",
|
|
69
|
+
token: TICK_TOKEN
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** The one-second clock loop that slides the window while playback stalls. */
|
|
74
|
+
function clockTick() {
|
|
75
|
+
return {
|
|
76
|
+
kind: "schedule",
|
|
77
|
+
token: CLOCK_TOKEN,
|
|
78
|
+
delayMs: 1e3,
|
|
79
|
+
then: {
|
|
80
|
+
type: "TICK",
|
|
81
|
+
token: CLOCK_TOKEN
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const reduceDashLive = (slice, msg, kernel) => {
|
|
86
|
+
let state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
87
|
+
if ((msg.type === "TIME_UPDATE" || msg.type === "SEGMENT_LOADED") && msg.wallClock !== void 0) state = _objectSpread2(_objectSpread2({}, state), {}, { lastWallClock: msg.wallClock });
|
|
88
|
+
if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, { manifestUrl: msg.url }), []];
|
|
89
|
+
if (msg.type === "UNLOAD" || msg.type === "DETACH") return [INITIAL, []];
|
|
90
|
+
if (msg.type === "MANIFEST_LOADED") {
|
|
91
|
+
if (!drivesWindow(msg.presentation)) return [state, []];
|
|
92
|
+
const effects = [];
|
|
93
|
+
let next = state;
|
|
94
|
+
const server = msg.presentation.live.timeServer;
|
|
95
|
+
if (server !== void 0 && state.skew === null && !state.utcPending) {
|
|
96
|
+
if (server.scheme.endsWith(":direct") || server.scheme.endsWith(":direct:2014")) next = _objectSpread2(_objectSpread2({}, next), {}, { skew: null });
|
|
97
|
+
else if (server.value !== "") {
|
|
98
|
+
effects.push({
|
|
99
|
+
kind: "fetch",
|
|
100
|
+
token: UTC_TOKEN,
|
|
101
|
+
url: server.value
|
|
102
|
+
});
|
|
103
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { utcPending: true });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!next.tickPending) {
|
|
107
|
+
var _msg$presentation$liv;
|
|
108
|
+
effects.push(tick((_msg$presentation$liv = msg.presentation.live.updatePeriod) !== null && _msg$presentation$liv !== void 0 ? _msg$presentation$liv : 4));
|
|
109
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { tickPending: true });
|
|
110
|
+
}
|
|
111
|
+
if (!next.clockPending) {
|
|
112
|
+
effects.push(clockTick());
|
|
113
|
+
next = _objectSpread2(_objectSpread2({}, next), {}, { clockPending: true });
|
|
114
|
+
}
|
|
115
|
+
const window = windowUpdate(next, msg.presentation.live);
|
|
116
|
+
if (window !== null) {
|
|
117
|
+
next = window.next;
|
|
118
|
+
effects.push(window.fact);
|
|
119
|
+
}
|
|
120
|
+
return [next, effects];
|
|
121
|
+
}
|
|
122
|
+
if (msg.type === "TICK" && msg.token === CLOCK_TOKEN) {
|
|
123
|
+
if (!drivesWindow(kernel.presentation)) return [_objectSpread2(_objectSpread2({}, state), {}, { clockPending: false }), []];
|
|
124
|
+
let next = _objectSpread2(_objectSpread2({}, state), {}, { clockPending: true });
|
|
125
|
+
if (msg.wallClock !== void 0) next = _objectSpread2(_objectSpread2({}, next), {}, { lastWallClock: msg.wallClock });
|
|
126
|
+
const effects = [clockTick()];
|
|
127
|
+
const live = kernel.presentation.live;
|
|
128
|
+
if (live !== void 0) {
|
|
129
|
+
const window = windowUpdate(next, live);
|
|
130
|
+
if (window !== null) {
|
|
131
|
+
next = window.next;
|
|
132
|
+
effects.push(window.fact);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return [next, effects];
|
|
136
|
+
}
|
|
137
|
+
if (msg.type === "TICK" && msg.token === TICK_TOKEN) {
|
|
138
|
+
if (state.manifestUrl === null || !drivesWindow(kernel.presentation)) return [_objectSpread2(_objectSpread2({}, state), {}, { tickPending: false }), []];
|
|
139
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, { tickPending: false }), [{
|
|
140
|
+
kind: "fetch",
|
|
141
|
+
token: MPD_TOKEN,
|
|
142
|
+
url: state.manifestUrl
|
|
143
|
+
}]];
|
|
144
|
+
}
|
|
145
|
+
if (msg.type === "SEGMENT_LOADED" && msg.trackId === UTC_TOKEN) {
|
|
146
|
+
const serverTime = Date.parse(new TextDecoder().decode(msg.bytes).trim());
|
|
147
|
+
if (!Number.isFinite(serverTime) || msg.wallClock === void 0) return [_objectSpread2(_objectSpread2({}, state), {}, { utcPending: false }), []];
|
|
148
|
+
return [_objectSpread2(_objectSpread2({}, state), {}, {
|
|
149
|
+
skew: serverTime / 1e3 - msg.wallClock,
|
|
150
|
+
utcPending: false
|
|
151
|
+
}), []];
|
|
152
|
+
}
|
|
153
|
+
if (msg.type === "SEGMENT_LOADED" && msg.trackId === MPD_TOKEN) {
|
|
154
|
+
if (state.manifestUrl === null) return [state, []];
|
|
155
|
+
const result = parse(new TextDecoder().decode(msg.bytes), state.manifestUrl);
|
|
156
|
+
const effects = [];
|
|
157
|
+
let next = state;
|
|
158
|
+
if (result.presentation !== null) {
|
|
159
|
+
effects.push(feed({
|
|
160
|
+
type: "MANIFEST_LOADED",
|
|
161
|
+
presentation: result.presentation
|
|
162
|
+
}));
|
|
163
|
+
if (result.presentation.isLive && result.presentation.live !== void 0) {
|
|
164
|
+
const window = windowUpdate(next, result.presentation.live);
|
|
165
|
+
if (window !== null) {
|
|
166
|
+
next = window.next;
|
|
167
|
+
effects.push(window.fact);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return [next, effects];
|
|
172
|
+
}
|
|
173
|
+
if ((msg.type === "TIME_UPDATE" || msg.type === "SEGMENT_LOADED") && drivesWindow(kernel.presentation)) {
|
|
174
|
+
const window = windowUpdate(state, kernel.presentation.live);
|
|
175
|
+
if (window !== null) return [window.next, [window.fact]];
|
|
176
|
+
}
|
|
177
|
+
return [state, []];
|
|
178
|
+
};
|
|
179
|
+
/** The stage factory. Requires dash-cmaf; the loader enforces it. */
|
|
180
|
+
function dashLive() {
|
|
181
|
+
return {
|
|
182
|
+
name: "dash-live",
|
|
183
|
+
provides: ["dash-live"],
|
|
184
|
+
requires: ["dash-cmaf"],
|
|
185
|
+
install(ctx) {
|
|
186
|
+
ctx.reduce("dash-live", reduceDashLive);
|
|
187
|
+
registerLiveNamespace(ctx);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
export { dashLive as default };
|