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,134 @@
|
|
|
1
|
+
import { findRendition } from "../../kernel/presentation.js";
|
|
2
|
+
import { segmentAt } from "../../kernel/timeline.js";
|
|
3
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
|
|
4
|
+
//#region src/protocols/dash-cmaf/periods-runtime.ts
|
|
5
|
+
/**
|
|
6
|
+
* What a flattened multi-period presentation needs at playback time, kept
|
|
7
|
+
* in the dash-cmaf stage so the kernel stays unaware of periods:
|
|
8
|
+
*
|
|
9
|
+
* - A segment whose period has another init than its rendition's gets that
|
|
10
|
+
* init in front of it before the append. MSE takes an init and a media
|
|
11
|
+
* segment in one append, and the time probe reads the timescale from the
|
|
12
|
+
* same bytes. The kernel only ever appends the rendition's own init, which
|
|
13
|
+
* this transform sees go by, so it knows which init each buffer holds.
|
|
14
|
+
* - A WebVTT document whose cues count from its period's start gets an
|
|
15
|
+
* `X-TIMESTAMP-MAP` header with that start, which text-webvtt-segmented
|
|
16
|
+
* applies, as for HLS.
|
|
17
|
+
* - A period left out for its codec family is seeked past when playback
|
|
18
|
+
* reaches it.
|
|
19
|
+
*
|
|
20
|
+
* Single-period content takes none of these paths.
|
|
21
|
+
*/
|
|
22
|
+
/** Before ts-transmux and caption extraction; decrypt-class steps run first. */
|
|
23
|
+
const PERIODS_ORDER = 10;
|
|
24
|
+
const MPEGTS_CLOCK = 9e4;
|
|
25
|
+
const keyOf = (ref) => {
|
|
26
|
+
var _ref$byteRange$start, _ref$byteRange, _ref$byteRange$end, _ref$byteRange2;
|
|
27
|
+
return `${ref.url}|${(_ref$byteRange$start = (_ref$byteRange = ref.byteRange) === null || _ref$byteRange === void 0 ? void 0 : _ref$byteRange.start) !== null && _ref$byteRange$start !== void 0 ? _ref$byteRange$start : ""}-${(_ref$byteRange$end = (_ref$byteRange2 = ref.byteRange) === null || _ref$byteRange2 === void 0 ? void 0 : _ref$byteRange2.end) !== null && _ref$byteRange$end !== void 0 ? _ref$byteRange$end : ""}`;
|
|
28
|
+
};
|
|
29
|
+
/** Whether any segment of the presentation carries its own init. */
|
|
30
|
+
function hasPeriodInits(presentation) {
|
|
31
|
+
return presentation.periods.some((period) => period.tracks.some((track) => track.renditions.some((rendition) => Array.isArray(rendition.segments) && rendition.segments.some((segment) => segment.init !== void 0))));
|
|
32
|
+
}
|
|
33
|
+
function installPeriods(ctx, skips) {
|
|
34
|
+
const element = ctx.element;
|
|
35
|
+
/** By buffer (content type): the init it last received. Null after a seek: unknown. */
|
|
36
|
+
const holds = /* @__PURE__ */ new Map();
|
|
37
|
+
const inits = /* @__PURE__ */ new Map();
|
|
38
|
+
let seen = null;
|
|
39
|
+
let periodInits = false;
|
|
40
|
+
function initBytes(ref) {
|
|
41
|
+
const key = keyOf(ref);
|
|
42
|
+
let bytes = inits.get(key);
|
|
43
|
+
if (bytes === void 0) {
|
|
44
|
+
const headers = ref.byteRange === void 0 ? {} : { Range: `bytes=${ref.byteRange.start}-${ref.byteRange.end}` };
|
|
45
|
+
bytes = ctx.request(ref.url, { headers }).then(function() {
|
|
46
|
+
var _ref = _asyncToGenerator(function* (response) {
|
|
47
|
+
if (!response.ok) throw new Error(`period init ${ref.url}: HTTP ${response.status}`);
|
|
48
|
+
return new Uint8Array(yield response.arrayBuffer());
|
|
49
|
+
});
|
|
50
|
+
return function(_x) {
|
|
51
|
+
return _ref.apply(this, arguments);
|
|
52
|
+
};
|
|
53
|
+
}());
|
|
54
|
+
bytes.catch(() => inits.delete(key));
|
|
55
|
+
inits.set(key, bytes);
|
|
56
|
+
}
|
|
57
|
+
return bytes;
|
|
58
|
+
}
|
|
59
|
+
function transform(_x2, _x3) {
|
|
60
|
+
return _transform.apply(this, arguments);
|
|
61
|
+
}
|
|
62
|
+
function _transform() {
|
|
63
|
+
_transform = _asyncToGenerator(function* (data, meta) {
|
|
64
|
+
var _segmentAt$init, _segmentAt2;
|
|
65
|
+
const presentation = ctx.getState().presentation;
|
|
66
|
+
if (presentation !== seen) {
|
|
67
|
+
seen = presentation;
|
|
68
|
+
periodInits = presentation !== null && hasPeriodInits(presentation);
|
|
69
|
+
holds.clear();
|
|
70
|
+
inits.clear();
|
|
71
|
+
}
|
|
72
|
+
const site = findRendition(presentation, meta.renditionId);
|
|
73
|
+
if (site === null) return data;
|
|
74
|
+
const { rendition, period } = site;
|
|
75
|
+
if (meta.contentType === "text") {
|
|
76
|
+
var _segmentAt;
|
|
77
|
+
if (meta.isInit || site.track.mimeType !== "text/vtt") return data;
|
|
78
|
+
const offset = (_segmentAt = segmentAt(rendition.segments, meta.seq, period.start)) === null || _segmentAt === void 0 ? void 0 : _segmentAt.timeOffset;
|
|
79
|
+
if (offset === void 0) return data;
|
|
80
|
+
const text = new TextDecoder().decode(data);
|
|
81
|
+
if (text.includes("X-TIMESTAMP-MAP")) return data;
|
|
82
|
+
const map = `X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:${Math.round(offset * MPEGTS_CLOCK)}`;
|
|
83
|
+
return new TextEncoder().encode(text.replace(/^([^\r\n]*)(\r?\n)/, `$1$2${map}$2`));
|
|
84
|
+
}
|
|
85
|
+
if (!periodInits || meta.contentType !== "video" && meta.contentType !== "audio") return data;
|
|
86
|
+
if (meta.isInit) {
|
|
87
|
+
if (rendition.init !== void 0) holds.set(meta.contentType, keyOf(rendition.init));
|
|
88
|
+
return data;
|
|
89
|
+
}
|
|
90
|
+
const need = (_segmentAt$init = (_segmentAt2 = segmentAt(rendition.segments, meta.seq, period.start)) === null || _segmentAt2 === void 0 ? void 0 : _segmentAt2.init) !== null && _segmentAt$init !== void 0 ? _segmentAt$init : rendition.init;
|
|
91
|
+
if (need === void 0 || holds.get(meta.contentType) === keyOf(need)) return data;
|
|
92
|
+
const init = yield initBytes(need);
|
|
93
|
+
holds.set(meta.contentType, keyOf(need));
|
|
94
|
+
const joined = new Uint8Array(init.byteLength + data.byteLength);
|
|
95
|
+
joined.set(init, 0);
|
|
96
|
+
joined.set(data, init.byteLength);
|
|
97
|
+
return joined;
|
|
98
|
+
});
|
|
99
|
+
return _transform.apply(this, arguments);
|
|
100
|
+
}
|
|
101
|
+
ctx.registerTransform({
|
|
102
|
+
name: "dash-periods",
|
|
103
|
+
order: PERIODS_ORDER,
|
|
104
|
+
transform
|
|
105
|
+
});
|
|
106
|
+
const onSeeking = () => {
|
|
107
|
+
for (const type of holds.keys()) holds.set(type, null);
|
|
108
|
+
};
|
|
109
|
+
const skipPast = () => {
|
|
110
|
+
if (element.seeking) return;
|
|
111
|
+
const time = element.currentTime;
|
|
112
|
+
const skip = skips().find((span) => time >= span.start - .5 && time < span.end);
|
|
113
|
+
if (skip !== void 0) ctx.dispatch({
|
|
114
|
+
type: "SEEK",
|
|
115
|
+
to: skip.end + .05
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
element.addEventListener("seeking", onSeeking);
|
|
119
|
+
for (const name of [
|
|
120
|
+
"timeupdate",
|
|
121
|
+
"waiting",
|
|
122
|
+
"seeked"
|
|
123
|
+
]) element.addEventListener(name, skipPast);
|
|
124
|
+
return () => {
|
|
125
|
+
element.removeEventListener("seeking", onSeeking);
|
|
126
|
+
for (const name of [
|
|
127
|
+
"timeupdate",
|
|
128
|
+
"waiting",
|
|
129
|
+
"seeked"
|
|
130
|
+
]) element.removeEventListener(name, skipPast);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { installPeriods };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { isIndexed, isUnresolved, segmentAt } from "../../kernel/timeline.js";
|
|
3
|
+
//#region src/protocols/dash-cmaf/periods.ts
|
|
4
|
+
/**
|
|
5
|
+
* Several DASH Periods as one continuous presentation, the way Shaka
|
|
6
|
+
* Player combines periods. Each logical track keeps one id for the whole
|
|
7
|
+
* presentation, and its renditions list every period's segments in order.
|
|
8
|
+
* A period boundary is a discontinuity, so the kernel's epoch model, the
|
|
9
|
+
* same one HLS discontinuities use, settles each period's timestamp offset
|
|
10
|
+
* from the media's own decode times. Nothing about periods reaches the
|
|
11
|
+
* kernel.
|
|
12
|
+
*
|
|
13
|
+
* Tracks match across periods by, in order: the period continuity or
|
|
14
|
+
* connectivity descriptor (ISO/IEC 23009-1 §5.3.2.4), the AdaptationSet id,
|
|
15
|
+
* then content type, language, role, and codec family. A period without a
|
|
16
|
+
* match fills an audio or video track with its closest track (same
|
|
17
|
+
* language, then same codec family, then the first), so playback never
|
|
18
|
+
* meets a hole; a text track simply has nothing there. Renditions pair by
|
|
19
|
+
* the nearest bitrate.
|
|
20
|
+
*
|
|
21
|
+
* A segment whose period has another init than its rendition's carries it
|
|
22
|
+
* (`Segment.init`): the dash-cmaf stage puts it in front of the segment
|
|
23
|
+
* before the append. A period whose codec family differs from the first
|
|
24
|
+
* period's is left out, with a warning: switching families needs a
|
|
25
|
+
* `changeType()`, which only the kernel can call. Text whose times count
|
|
26
|
+
* from its period's start carries that start (`Segment.timeOffset`).
|
|
27
|
+
*/
|
|
28
|
+
/** The codec family, as `changeType()` cares: avc1 and avc3 are one, hvc1 and hev1 are one. */
|
|
29
|
+
function family(codecs) {
|
|
30
|
+
var _split$0$trim$split$, _split$;
|
|
31
|
+
const first = (_split$0$trim$split$ = (_split$ = (codecs !== null && codecs !== void 0 ? codecs : "").split(",")[0]) === null || _split$ === void 0 || (_split$ = _split$.trim().split(".")[0]) === null || _split$ === void 0 ? void 0 : _split$.toLowerCase()) !== null && _split$0$trim$split$ !== void 0 ? _split$0$trim$split$ : "";
|
|
32
|
+
if (first === "avc3") return "avc1";
|
|
33
|
+
if (first === "hev1") return "hvc1";
|
|
34
|
+
if (first === "dvhe") return "dvh1";
|
|
35
|
+
return first;
|
|
36
|
+
}
|
|
37
|
+
/** Text whose cue times count from its period's start: whole documents, not fMP4 samples. */
|
|
38
|
+
function periodRelative(track) {
|
|
39
|
+
return track.mimeType === "text/vtt" || track.mimeType === "application/ttml+xml";
|
|
40
|
+
}
|
|
41
|
+
/** A rendition's segments as a list, or null when only an index would tell (SegmentBase). */
|
|
42
|
+
function listed(rendition, periodStart) {
|
|
43
|
+
const addressing = rendition.segments;
|
|
44
|
+
if (isUnresolved(addressing)) return null;
|
|
45
|
+
if (!isIndexed(addressing)) return [...addressing];
|
|
46
|
+
if (addressing.endSeq === null) return null;
|
|
47
|
+
const out = [];
|
|
48
|
+
for (let seq = addressing.startSeq; seq <= addressing.endSeq; seq += 1) {
|
|
49
|
+
const segment = segmentAt(addressing, seq, periodStart);
|
|
50
|
+
if (segment !== null) out.push(segment);
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
function sameRef(a, b) {
|
|
55
|
+
var _a$byteRange, _b$byteRange, _a$byteRange2, _b$byteRange2;
|
|
56
|
+
return (a === null || a === void 0 ? void 0 : a.url) === (b === null || b === void 0 ? void 0 : b.url) && (a === null || a === void 0 || (_a$byteRange = a.byteRange) === null || _a$byteRange === void 0 ? void 0 : _a$byteRange.start) === (b === null || b === void 0 || (_b$byteRange = b.byteRange) === null || _b$byteRange === void 0 ? void 0 : _b$byteRange.start) && (a === null || a === void 0 || (_a$byteRange2 = a.byteRange) === null || _a$byteRange2 === void 0 ? void 0 : _a$byteRange2.end) === (b === null || b === void 0 || (_b$byteRange2 = b.byteRange) === null || _b$byteRange2 === void 0 ? void 0 : _b$byteRange2.end);
|
|
57
|
+
}
|
|
58
|
+
function nearest(renditions, bitrate) {
|
|
59
|
+
let best;
|
|
60
|
+
for (const rendition of renditions) if (best === void 0 || Math.abs(rendition.bitrate - bitrate) < Math.abs(best.bitrate - bitrate)) best = rendition;
|
|
61
|
+
return best;
|
|
62
|
+
}
|
|
63
|
+
/** Combines the periods, or null when one of them lists no segments (SegmentBase). */
|
|
64
|
+
function flattenPeriods(periods) {
|
|
65
|
+
const logical = [];
|
|
66
|
+
const captions = /* @__PURE__ */ new Map();
|
|
67
|
+
periods.forEach((period, index) => {
|
|
68
|
+
for (const track of period.tracks) {
|
|
69
|
+
var _ref, _open$find, _meta$asId;
|
|
70
|
+
if (track.renditions.length === 0) {
|
|
71
|
+
if (!captions.has(track.id)) captions.set(track.id, track);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const meta = period.matching.get(track.id);
|
|
75
|
+
const open = logical.filter((l) => !l.byPeriod.has(index) && l.base.contentType === track.contentType);
|
|
76
|
+
const earlier = new Set(periods.slice(0, index).map((p) => p.id));
|
|
77
|
+
const match = (_ref = (_open$find = open.find((l) => meta !== void 0 && l.asId === meta.asId && meta.follows.some((id) => earlier.has(id)))) !== null && _open$find !== void 0 ? _open$find : open.find((l) => (meta === null || meta === void 0 ? void 0 : meta.asId) != null && l.asId === meta.asId)) !== null && _ref !== void 0 ? _ref : open.find((l) => {
|
|
78
|
+
var _l$base$renditions$0$, _l$base$renditions$, _track$renditions$0$c, _track$renditions$;
|
|
79
|
+
return l.base.lang === track.lang && l.base.role === track.role && family((_l$base$renditions$0$ = (_l$base$renditions$ = l.base.renditions[0]) === null || _l$base$renditions$ === void 0 ? void 0 : _l$base$renditions$.codecs) !== null && _l$base$renditions$0$ !== void 0 ? _l$base$renditions$0$ : null) === family((_track$renditions$0$c = (_track$renditions$ = track.renditions[0]) === null || _track$renditions$ === void 0 ? void 0 : _track$renditions$.codecs) !== null && _track$renditions$0$c !== void 0 ? _track$renditions$0$c : null);
|
|
80
|
+
});
|
|
81
|
+
if (match !== void 0) {
|
|
82
|
+
match.byPeriod.set(index, track);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (track.contentType === "video" && logical.some((l) => l.base.contentType === "video")) continue;
|
|
86
|
+
const taken = logical.some((l) => l.id === track.id);
|
|
87
|
+
logical.push({
|
|
88
|
+
id: taken ? `${period.id}/${track.id}` : track.id,
|
|
89
|
+
base: track,
|
|
90
|
+
baseIndex: index,
|
|
91
|
+
asId: (_meta$asId = meta === null || meta === void 0 ? void 0 : meta.asId) !== null && _meta$asId !== void 0 ? _meta$asId : null,
|
|
92
|
+
byPeriod: /* @__PURE__ */ new Map([[index, track]])
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
for (const l of logical) {
|
|
97
|
+
if (l.base.contentType !== "audio" && l.base.contentType !== "video") continue;
|
|
98
|
+
periods.forEach((period, index) => {
|
|
99
|
+
var _ref2, _ref3, _candidates$find;
|
|
100
|
+
if (l.byPeriod.has(index)) return;
|
|
101
|
+
const candidates = period.tracks.filter((t) => t.contentType === l.base.contentType && t.renditions.length > 0 && t.role !== "trick");
|
|
102
|
+
const sameFamily = (t) => {
|
|
103
|
+
var _t$renditions$0$codec, _t$renditions$, _l$base$renditions$0$2, _l$base$renditions$2;
|
|
104
|
+
return family((_t$renditions$0$codec = (_t$renditions$ = t.renditions[0]) === null || _t$renditions$ === void 0 ? void 0 : _t$renditions$.codecs) !== null && _t$renditions$0$codec !== void 0 ? _t$renditions$0$codec : null) === family((_l$base$renditions$0$2 = (_l$base$renditions$2 = l.base.renditions[0]) === null || _l$base$renditions$2 === void 0 ? void 0 : _l$base$renditions$2.codecs) !== null && _l$base$renditions$0$2 !== void 0 ? _l$base$renditions$0$2 : null);
|
|
105
|
+
};
|
|
106
|
+
const sameLanguage = (t) => t.lang !== void 0 && t.lang === l.base.lang;
|
|
107
|
+
const closest = (_ref2 = (_ref3 = (_candidates$find = candidates.find((t) => sameLanguage(t) && sameFamily(t))) !== null && _candidates$find !== void 0 ? _candidates$find : candidates.find(sameFamily)) !== null && _ref3 !== void 0 ? _ref3 : candidates.find(sameLanguage)) !== null && _ref2 !== void 0 ? _ref2 : candidates[0];
|
|
108
|
+
if (closest !== void 0) l.byPeriod.set(index, closest);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const warnings = [];
|
|
112
|
+
const skipped = /* @__PURE__ */ new Set();
|
|
113
|
+
periods.forEach((period, index) => {
|
|
114
|
+
for (const l of logical) {
|
|
115
|
+
var _l$base$renditions$0$3, _l$base$renditions$3, _track$renditions$0$c2, _track$renditions$2;
|
|
116
|
+
if (l.baseIndex !== 0) continue;
|
|
117
|
+
if (l.base.contentType !== "audio" && l.base.contentType !== "video") continue;
|
|
118
|
+
const track = l.byPeriod.get(index);
|
|
119
|
+
const declared = (_l$base$renditions$0$3 = (_l$base$renditions$3 = l.base.renditions[0]) === null || _l$base$renditions$3 === void 0 ? void 0 : _l$base$renditions$3.codecs) !== null && _l$base$renditions$0$3 !== void 0 ? _l$base$renditions$0$3 : null;
|
|
120
|
+
const actual = (_track$renditions$0$c2 = track === null || track === void 0 || (_track$renditions$2 = track.renditions[0]) === null || _track$renditions$2 === void 0 ? void 0 : _track$renditions$2.codecs) !== null && _track$renditions$0$c2 !== void 0 ? _track$renditions$0$c2 : null;
|
|
121
|
+
if (track === void 0 || family(declared) === family(actual) || skipped.has(index)) continue;
|
|
122
|
+
skipped.add(index);
|
|
123
|
+
warnings.push({
|
|
124
|
+
category: "media",
|
|
125
|
+
code: "MEDIA_CODEC_MISMATCH",
|
|
126
|
+
fatal: false,
|
|
127
|
+
recoverable: true,
|
|
128
|
+
context: {
|
|
129
|
+
kind: "family",
|
|
130
|
+
declared: declared !== null && declared !== void 0 ? declared : "",
|
|
131
|
+
probed: actual !== null && actual !== void 0 ? actual : "",
|
|
132
|
+
period: period.id,
|
|
133
|
+
start: period.start,
|
|
134
|
+
end: period.duration === null ? period.start : period.start + period.duration
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const tracks = [];
|
|
140
|
+
for (const l of logical) {
|
|
141
|
+
const renditions = [];
|
|
142
|
+
for (const base of l.base.renditions) {
|
|
143
|
+
const segments = [];
|
|
144
|
+
for (let index = 0; index < periods.length; index += 1) {
|
|
145
|
+
var _track$renditions$0$c3, _track$renditions$3;
|
|
146
|
+
const period = periods[index];
|
|
147
|
+
const track = l.byPeriod.get(index);
|
|
148
|
+
if (track === void 0 || skipped.has(index)) continue;
|
|
149
|
+
if ((track.contentType === "audio" || track.contentType === "video") && family((_track$renditions$0$c3 = (_track$renditions$3 = track.renditions[0]) === null || _track$renditions$3 === void 0 ? void 0 : _track$renditions$3.codecs) !== null && _track$renditions$0$c3 !== void 0 ? _track$renditions$0$c3 : null) !== family(base.codecs)) continue;
|
|
150
|
+
const rendition = track === l.base ? base : nearest(track.renditions, base.bitrate);
|
|
151
|
+
if (rendition === void 0) continue;
|
|
152
|
+
const list = listed(rendition, period.start);
|
|
153
|
+
if (list === null) return null;
|
|
154
|
+
const init = sameRef(rendition.init, base.init) ? void 0 : rendition.init;
|
|
155
|
+
const offset = periodRelative(track) && period.start !== 0 ? period.start : 0;
|
|
156
|
+
list.forEach((segment, i) => {
|
|
157
|
+
segments.push(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, segment), {}, { seq: segments.length }, i === 0 ? {
|
|
158
|
+
discontinuity: index > 0,
|
|
159
|
+
discontinuitySequence: index
|
|
160
|
+
} : {}), init !== void 0 ? { init } : {}), offset !== 0 ? { timeOffset: offset } : {}));
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
renditions.push(_objectSpread2(_objectSpread2({}, base), {}, { segments }));
|
|
164
|
+
}
|
|
165
|
+
tracks.push(_objectSpread2(_objectSpread2({}, l.base), {}, {
|
|
166
|
+
id: l.id,
|
|
167
|
+
renditions
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
for (const caption of captions.values()) tracks.push(caption);
|
|
171
|
+
return {
|
|
172
|
+
tracks,
|
|
173
|
+
events: periods.flatMap((period) => period.events),
|
|
174
|
+
warnings
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { flattenPeriods };
|
|
@@ -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 { registerLiveNamespace } from "../live-shared.js";
|
|
4
4
|
import { parse } from "../dash-cmaf/parse.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { scheduled } from "../../kernel/effects.js";
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { scheduled, tickAfter } from "../../kernel/effects.js";
|
|
3
3
|
import { normalizeMimeType } from "../../kernel/mime.js";
|
|
4
4
|
import { activeRenditions } from "../../kernel/rendition-select.js";
|
|
5
5
|
import { manifestFact } from "../adapter-shared.js";
|
|
6
6
|
import { parse, parseMediaPlaylist, refreshFor } from "./parse.js";
|
|
7
|
-
import { LOAD_FAILED, unavailableMessages } from "./unavailable.js";
|
|
7
|
+
import { LOAD_FAILED, readmitMessage, unavailableMessages } from "./unavailable.js";
|
|
8
8
|
//#region src/protocols/hls-cmaf/index.ts
|
|
9
9
|
/**
|
|
10
10
|
* The hls-cmaf protocol adapter as a stage. Inert module: exports a
|
|
@@ -18,6 +18,8 @@ import { LOAD_FAILED, unavailableMessages } from "./unavailable.js";
|
|
|
18
18
|
* fetch under `hls:pl:` tokens the transport correlates back by token.
|
|
19
19
|
*/
|
|
20
20
|
const PLAYLIST_TOKEN = "hls:pl:";
|
|
21
|
+
/** A failed playlist's retry, by URL: `hls:retry:<url>`. */
|
|
22
|
+
const RETRY_TOKEN = "hls:retry:";
|
|
21
23
|
/** The playlist MIME types, RFC 8216 §4: the registered type and the three in common use. */
|
|
22
24
|
const MANIFEST_TYPES = [
|
|
23
25
|
"application/vnd.apple.mpegurl",
|
|
@@ -76,22 +78,41 @@ function renditionsAt(presentation, url) {
|
|
|
76
78
|
function feed(message) {
|
|
77
79
|
return scheduled("hls:loopback", message);
|
|
78
80
|
}
|
|
81
|
+
/** The renditions of every playlist that failed and is not being retried yet. */
|
|
82
|
+
function failedRenditions(state, presentation) {
|
|
83
|
+
const failed = [];
|
|
84
|
+
for (const [url, ok] of Object.entries(state.answered)) if (!ok) for (const rendition of renditionsAt(presentation, url)) failed.push(rendition.id);
|
|
85
|
+
return failed;
|
|
86
|
+
}
|
|
79
87
|
/**
|
|
80
88
|
* A playlist that failed to load or parse. Its renditions are excluded,
|
|
81
|
-
* so arbitration moves off them and nothing asks for the playlist again
|
|
82
|
-
* When that leaves a media track with no rendition at
|
|
83
|
-
* fails: the stream cannot play, and waiting would only stall.
|
|
89
|
+
* so arbitration moves off them and nothing asks for the playlist again
|
|
90
|
+
* until its retry. When that leaves a media track with no rendition at
|
|
91
|
+
* all, the load fails: the stream cannot play, and waiting would only stall.
|
|
84
92
|
*/
|
|
85
|
-
function unavailable(state, kernel, url, error) {
|
|
86
|
-
const
|
|
87
|
-
const next = _objectSpread2(_objectSpread2({}, state), {}, { answered });
|
|
93
|
+
function unavailable(state, kernel, url, error, retryMs) {
|
|
94
|
+
const next = _objectSpread2(_objectSpread2({}, state), {}, { answered: _objectSpread2(_objectSpread2({}, state.answered), {}, { [url]: false }) });
|
|
88
95
|
const presentation = kernel.presentation;
|
|
89
96
|
if (presentation === null) return [next, []];
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
const messages = unavailableMessages(kernel, LOAD_FAILED, failedRenditions(next, presentation), error);
|
|
98
|
+
const effects = messages.map(feed);
|
|
99
|
+
if (Number.isFinite(retryMs) && !messages.some((m) => m.type === "MANIFEST_FAILED")) effects.push(tickAfter(`${RETRY_TOKEN}${url}`, retryMs));
|
|
100
|
+
return [next, effects];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The retry of a failed playlist: forget the failure, so its renditions
|
|
104
|
+
* return to arbitration and the selection fetches the playlist again when
|
|
105
|
+
* it needs it. Another failure excludes it again for another wait.
|
|
106
|
+
*/
|
|
107
|
+
function retry(state, kernel, url) {
|
|
108
|
+
if (state.answered[url] !== false || kernel.presentation === null) return [state, []];
|
|
109
|
+
const answered = _objectSpread2({}, state.answered);
|
|
110
|
+
delete answered[url];
|
|
111
|
+
const next = _objectSpread2(_objectSpread2({}, state), {}, { answered });
|
|
112
|
+
const message = readmitMessage(kernel, LOAD_FAILED, failedRenditions(next, kernel.presentation));
|
|
113
|
+
return [next, message === null ? [] : [feed(message)]];
|
|
93
114
|
}
|
|
94
|
-
const
|
|
115
|
+
const createReduceHls = (retryMs) => (slice, msg, kernel) => {
|
|
95
116
|
const state = slice !== null && slice !== void 0 ? slice : INITIAL;
|
|
96
117
|
if (msg.type === "LOAD") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, {
|
|
97
118
|
manifestUrl: msg.url,
|
|
@@ -102,6 +123,7 @@ const reduceHls = (slice, msg, kernel) => {
|
|
|
102
123
|
const fact = manifestFact(msg.bytes, state.manifestUrl, (text) => claims(state, text), parse);
|
|
103
124
|
return [state, fact === null ? [] : [feed(fact)]];
|
|
104
125
|
}
|
|
126
|
+
if (msg.type === "TICK" && msg.token.startsWith(RETRY_TOKEN)) return retry(state, kernel, msg.token.slice(10));
|
|
105
127
|
let next = state;
|
|
106
128
|
const effects = [];
|
|
107
129
|
if (msg.type === "SEGMENT_LOADED" && msg.trackId in state.pending) {
|
|
@@ -130,7 +152,7 @@ const reduceHls = (slice, msg, kernel) => {
|
|
|
130
152
|
url
|
|
131
153
|
}
|
|
132
154
|
});
|
|
133
|
-
const [failed, failEffects] = unavailable(next, kernel, url, error);
|
|
155
|
+
const [failed, failEffects] = unavailable(next, kernel, url, error, retryMs);
|
|
134
156
|
return [failed, [...effects, ...failEffects]];
|
|
135
157
|
}
|
|
136
158
|
next = _objectSpread2(_objectSpread2({}, next), {}, { answered: _objectSpread2(_objectSpread2({}, next.answered), {}, { [url]: true }) });
|
|
@@ -144,7 +166,7 @@ const reduceHls = (slice, msg, kernel) => {
|
|
|
144
166
|
const url = state.pending[msg.trackId];
|
|
145
167
|
const pending = _objectSpread2({}, state.pending);
|
|
146
168
|
delete pending[msg.trackId];
|
|
147
|
-
return unavailable(_objectSpread2(_objectSpread2({}, next), {}, { pending }), kernel, url, msg.error);
|
|
169
|
+
return unavailable(_objectSpread2(_objectSpread2({}, next), {}, { pending }), kernel, url, msg.error, retryMs);
|
|
148
170
|
}
|
|
149
171
|
if (kernel.lifecycle.phase !== "ready" || kernel.presentation === null) return [next, effects];
|
|
150
172
|
const key = `${kernel.quality.version}:${kernel.quality.active}`;
|
|
@@ -168,12 +190,14 @@ const reduceHls = (slice, msg, kernel) => {
|
|
|
168
190
|
* The stage factory. `mattebox({ stages: [hlsCmaf()] })` is all a consumer
|
|
169
191
|
* needs for HLS-CMAF VOD.
|
|
170
192
|
*/
|
|
171
|
-
function hlsCmaf() {
|
|
193
|
+
function hlsCmaf(options = {}) {
|
|
194
|
+
var _options$unavailableR;
|
|
195
|
+
const retryMs = ((_options$unavailableR = options.unavailableRetrySeconds) !== null && _options$unavailableR !== void 0 ? _options$unavailableR : 15) * 1e3;
|
|
172
196
|
return {
|
|
173
197
|
name: "hls-cmaf",
|
|
174
198
|
provides: ["hls-cmaf", ...MANIFEST_TYPES],
|
|
175
199
|
install(ctx) {
|
|
176
|
-
ctx.reduce("hls",
|
|
200
|
+
ctx.reduce("hls", createReduceHls(retryMs));
|
|
177
201
|
}
|
|
178
202
|
};
|
|
179
203
|
}
|
|
@@ -10,7 +10,8 @@ const ATTRIBUTE_TAGS = /* @__PURE__ */ new Set([
|
|
|
10
10
|
"EXT-X-I-FRAME-STREAM-INF",
|
|
11
11
|
"EXT-X-IMAGE-STREAM-INF",
|
|
12
12
|
"EXT-X-TILES",
|
|
13
|
-
"EXT-X-CONTENT-STEERING"
|
|
13
|
+
"EXT-X-CONTENT-STEERING",
|
|
14
|
+
"EXT-X-DATERANGE"
|
|
14
15
|
]);
|
|
15
16
|
/**
|
|
16
17
|
* RFC 8216 §4.2: comma-separated KEY=VALUE pairs where a quoted-string
|