mattebox 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cdn/mattebox.dash-drm.min.js +3 -3
- package/dist/cdn/mattebox.dash.min.js +3 -3
- package/dist/cdn/mattebox.dual-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ts.min.js +3 -3
- package/dist/cdn/mattebox.dual.min.js +3 -3
- package/dist/cdn/mattebox.hls-drm.min.js +3 -3
- package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
- package/dist/cdn/mattebox.hls-ts.min.js +3 -3
- package/dist/cdn/mattebox.hls.min.js +3 -3
- package/dist/cdn/mattebox.kernel.min.js +1 -1
- package/dist/cdn/mattebox.min.js +6 -2
- package/dist/containers/captions.d.ts +6 -5
- package/dist/containers/captions.d.ts.map +1 -1
- package/dist/containers/captions.js +9 -9
- package/dist/containers/captions.js.map +1 -1
- package/dist/containers/codec-probe/index.d.ts +15 -0
- package/dist/containers/codec-probe/index.d.ts.map +1 -1
- package/dist/containers/codec-probe/index.js +72 -5
- package/dist/containers/codec-probe/index.js.map +1 -1
- package/dist/containers/emsg.d.ts +15 -0
- package/dist/containers/emsg.d.ts.map +1 -0
- package/dist/containers/emsg.js +91 -0
- package/dist/containers/emsg.js.map +1 -0
- package/dist/containers/id3.d.ts +12 -0
- package/dist/containers/id3.d.ts.map +1 -1
- package/dist/containers/id3.js +53 -4
- package/dist/containers/id3.js.map +1 -1
- package/dist/containers/metadata.d.ts +18 -0
- package/dist/containers/metadata.d.ts.map +1 -0
- package/dist/containers/metadata.js +20 -0
- package/dist/containers/metadata.js.map +1 -0
- package/dist/containers/mp4-box/index.d.ts +16 -0
- package/dist/containers/mp4-box/index.d.ts.map +1 -1
- package/dist/containers/mp4-box/index.js +28 -0
- package/dist/containers/mp4-box/index.js.map +1 -1
- package/dist/containers/scte35.d.ts +12 -0
- package/dist/containers/scte35.d.ts.map +1 -0
- package/dist/containers/scte35.js +116 -0
- package/dist/containers/scte35.js.map +1 -0
- package/dist/containers/ts-transmux/demux.d.ts +2 -2
- package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
- package/dist/containers/ts-transmux/demux.js +2 -18
- package/dist/containers/ts-transmux/demux.js.map +1 -1
- package/dist/containers/ts-transmux/index.d.ts.map +1 -1
- package/dist/containers/ts-transmux/index.js +14 -3
- package/dist/containers/ts-transmux/index.js.map +1 -1
- package/dist/containers/ts-transmux/module.d.ts +8 -0
- package/dist/containers/ts-transmux/module.d.ts.map +1 -0
- package/dist/containers/ts-transmux/module.js +8 -0
- package/dist/containers/ts-transmux/module.js.map +1 -0
- package/dist/containers/ts-transmux/runner.d.ts +20 -8
- package/dist/containers/ts-transmux/runner.d.ts.map +1 -1
- package/dist/containers/ts-transmux/runner.js +19 -22
- package/dist/containers/ts-transmux/runner.js.map +1 -1
- package/dist/containers/ts-transmux/serve.d.ts +35 -0
- package/dist/containers/ts-transmux/serve.d.ts.map +1 -0
- package/dist/containers/ts-transmux/serve.js +33 -0
- package/dist/containers/ts-transmux/serve.js.map +1 -0
- package/dist/containers/ts-transmux/sniff.d.ts +11 -0
- package/dist/containers/ts-transmux/sniff.d.ts.map +1 -0
- package/dist/containers/ts-transmux/sniff.js +25 -0
- package/dist/containers/ts-transmux/sniff.js.map +1 -0
- package/dist/containers/ts-transmux/source.d.ts +10 -0
- package/dist/containers/ts-transmux/source.d.ts.map +1 -0
- package/dist/containers/ts-transmux/source.js +5 -0
- package/dist/containers/ts-transmux/source.js.map +1 -0
- package/dist/containers/ts-transmux/transmux.d.ts +19 -1
- package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
- package/dist/containers/ts-transmux/transmux.js +46 -7
- package/dist/containers/ts-transmux/transmux.js.map +1 -1
- package/dist/containers/ts-transmux/transmux.worker.js +7 -28
- package/dist/containers/ts-transmux/transmux.worker.js.map +1 -1
- package/dist/containers/webvtt.d.ts +2 -0
- package/dist/containers/webvtt.d.ts.map +1 -1
- package/dist/containers/webvtt.js +4 -0
- package/dist/containers/webvtt.js.map +1 -1
- package/dist/containers/wvtt.d.ts +12 -0
- package/dist/containers/wvtt.d.ts.map +1 -0
- package/dist/containers/wvtt.js +46 -0
- package/dist/containers/wvtt.js.map +1 -0
- package/dist/eme/index.d.ts +34 -0
- package/dist/eme/index.d.ts.map +1 -0
- package/dist/eme/index.js +75 -0
- package/dist/eme/index.js.map +1 -0
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectWithoutProperties.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/containers/captions.js +8 -8
- package/dist/es2015/containers/codec-probe/index.js +105 -6
- package/dist/es2015/containers/emsg.js +81 -0
- package/dist/es2015/containers/id3.js +54 -4
- package/dist/es2015/containers/metadata.js +20 -0
- package/dist/es2015/containers/mp4-box/index.js +27 -1
- package/dist/es2015/containers/scte35.js +114 -0
- package/dist/es2015/containers/ts-transmux/demux.js +12 -24
- package/dist/es2015/containers/ts-transmux/h264.js +1 -1
- package/dist/es2015/containers/ts-transmux/index.js +12 -4
- package/dist/es2015/containers/ts-transmux/runner.js +34 -27
- package/dist/es2015/containers/ts-transmux/serve.js +36 -0
- package/dist/es2015/containers/ts-transmux/sniff.js +13 -0
- package/dist/es2015/containers/ts-transmux/source.js +7 -0
- package/dist/es2015/containers/ts-transmux/transmux.js +42 -8
- package/dist/es2015/containers/ts-transmux/transmux.worker.js +7 -26
- package/dist/es2015/containers/webvtt.js +6 -2
- package/dist/es2015/containers/wvtt.js +40 -0
- package/dist/es2015/eme/index.js +79 -0
- package/dist/es2015/index.js +40 -14
- package/dist/es2015/kernel/append-queue.js +1 -1
- package/dist/es2015/kernel/base64.js +14 -3
- package/dist/es2015/kernel/bus.js +11 -8
- package/dist/es2015/kernel/context.js +5 -0
- package/dist/es2015/kernel/lifecycle.js +1 -0
- package/dist/es2015/kernel/loader.js +2 -2
- package/dist/es2015/kernel/mime.js +12 -1
- package/dist/es2015/kernel/mse.js +39 -5
- package/dist/es2015/kernel/prepare.js +2 -2
- package/dist/es2015/kernel/reducer.js +118 -26
- package/dist/es2015/kernel/refresh.js +2 -2
- package/dist/es2015/kernel/rendition-select.js +2 -1
- package/dist/es2015/kernel/scheduler.js +1 -1
- package/dist/es2015/kernel/sinks/caption-tracks.js +82 -0
- package/dist/es2015/kernel/sinks/native-sync.js +46 -0
- package/dist/es2015/kernel/sinks/text-formats.js +64 -0
- package/dist/es2015/kernel/sinks/text-track-sink.js +15 -4
- package/dist/es2015/kernel/timeline.js +12 -8
- package/dist/es2015/kernel/trace.js +1 -1
- package/dist/es2015/kernel/track-registry.js +21 -1
- package/dist/es2015/kernel/transport.js +34 -7
- package/dist/es2015/presets/define.js +2 -2
- package/dist/es2015/presets/full/index.js +22 -2
- package/dist/es2015/protocols/dash-cmaf/index.js +61 -14
- package/dist/es2015/protocols/dash-cmaf/parse.js +389 -106
- package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +134 -0
- package/dist/es2015/protocols/dash-cmaf/periods.js +178 -0
- package/dist/es2015/protocols/dash-live/index.js +1 -1
- package/dist/es2015/protocols/hls-cmaf/index.js +41 -17
- package/dist/es2015/protocols/hls-cmaf/lexer.js +2 -1
- package/dist/es2015/protocols/hls-cmaf/parse.js +132 -22
- package/dist/es2015/protocols/hls-cmaf/unavailable.js +37 -6
- package/dist/es2015/protocols/hls-live/index.js +36 -10
- package/dist/es2015/stages/abr/index.js +10 -5
- package/dist/es2015/stages/abr-persist/index.js +1 -1
- package/dist/es2015/stages/aes-128/index.js +1 -1
- package/dist/es2015/stages/alt-audio/index.js +31 -11
- package/dist/es2015/stages/chapters/index.js +2 -2
- package/dist/es2015/stages/chapters/parse.js +2 -2
- package/dist/es2015/stages/cmcd/index.js +30 -3
- package/dist/es2015/stages/cmsd/index.js +72 -0
- package/dist/es2015/stages/codec-probe/index.js +28 -3
- package/dist/es2015/stages/content-steering/index.js +1 -1
- package/dist/es2015/stages/eme-core/index.js +22 -2
- package/dist/es2015/stages/eme-fairplay/index.js +1 -1
- package/dist/es2015/stages/hdr/index.js +214 -0
- package/dist/es2015/stages/meta-id3/index.js +6 -1
- package/dist/es2015/stages/qoe/index.js +111 -0
- package/dist/es2015/stages/recovery/index.js +1 -1
- package/dist/es2015/stages/rendition-names/index.js +101 -0
- package/dist/es2015/stages/text-cea608/decode.js +56 -5
- package/dist/es2015/stages/text-cea608/index.js +29 -27
- package/dist/es2015/stages/text-cea708/decode.js +377 -0
- package/dist/es2015/stages/text-cea708/index.js +98 -0
- package/dist/es2015/stages/text-ttml/index.js +88 -0
- package/dist/es2015/stages/text-ttml/parse.js +255 -0
- package/dist/es2015/stages/text-webvtt/index.js +31 -62
- package/dist/es2015/stages/thumbnails/index.js +1 -1
- package/dist/es2015/stages/timed-metadata/index.js +331 -0
- package/dist/es2015/stages/trick-play/index.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -11
- package/dist/index.js.map +1 -1
- package/dist/kernel/base64.d.ts +7 -2
- package/dist/kernel/base64.d.ts.map +1 -1
- package/dist/kernel/base64.js +14 -2
- package/dist/kernel/base64.js.map +1 -1
- package/dist/kernel/bus.d.ts.map +1 -1
- package/dist/kernel/bus.js +12 -9
- package/dist/kernel/bus.js.map +1 -1
- package/dist/kernel/context.d.ts +3 -1
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/context.js +5 -0
- package/dist/kernel/context.js.map +1 -1
- package/dist/kernel/lifecycle.d.ts +3 -1
- package/dist/kernel/lifecycle.d.ts.map +1 -1
- package/dist/kernel/lifecycle.js +1 -0
- package/dist/kernel/lifecycle.js.map +1 -1
- package/dist/kernel/loader.d.ts.map +1 -1
- package/dist/kernel/loader.js +3 -2
- package/dist/kernel/loader.js.map +1 -1
- package/dist/kernel/mime.d.ts +7 -0
- package/dist/kernel/mime.d.ts.map +1 -1
- package/dist/kernel/mime.js +12 -0
- package/dist/kernel/mime.js.map +1 -1
- package/dist/kernel/mse.d.ts.map +1 -1
- package/dist/kernel/mse.js +37 -2
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/reducer.d.ts +3 -0
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +117 -12
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/kernel/refresh.d.ts.map +1 -1
- package/dist/kernel/refresh.js +1 -0
- package/dist/kernel/refresh.js.map +1 -1
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +4 -2
- package/dist/kernel/rendition-select.js.map +1 -1
- package/dist/kernel/sinks/caption-tracks.d.ts +11 -0
- package/dist/kernel/sinks/caption-tracks.d.ts.map +1 -0
- package/dist/kernel/sinks/caption-tracks.js +87 -0
- package/dist/kernel/sinks/caption-tracks.js.map +1 -0
- package/dist/kernel/sinks/native-sync.d.ts +24 -0
- package/dist/kernel/sinks/native-sync.d.ts.map +1 -0
- package/dist/kernel/sinks/native-sync.js +42 -0
- package/dist/kernel/sinks/native-sync.js.map +1 -0
- package/dist/kernel/sinks/text-formats.d.ts +25 -0
- package/dist/kernel/sinks/text-formats.d.ts.map +1 -0
- package/dist/kernel/sinks/text-formats.js +69 -0
- package/dist/kernel/sinks/text-formats.js.map +1 -0
- package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
- package/dist/kernel/sinks/text-track-sink.js +22 -4
- package/dist/kernel/sinks/text-track-sink.js.map +1 -1
- package/dist/kernel/timeline.d.ts +10 -6
- package/dist/kernel/timeline.d.ts.map +1 -1
- package/dist/kernel/timeline.js +14 -6
- package/dist/kernel/timeline.js.map +1 -1
- package/dist/kernel/track-registry.d.ts +8 -8
- package/dist/kernel/track-registry.d.ts.map +1 -1
- package/dist/kernel/track-registry.js +29 -4
- package/dist/kernel/track-registry.js.map +1 -1
- package/dist/kernel/transport.d.ts +8 -0
- package/dist/kernel/transport.d.ts.map +1 -1
- package/dist/kernel/transport.js +28 -1
- package/dist/kernel/transport.js.map +1 -1
- package/dist/presets/full/index.d.ts.map +1 -1
- package/dist/presets/full/index.js +21 -1
- package/dist/presets/full/index.js.map +1 -1
- package/dist/protocols/adapter-shared.d.ts +8 -0
- package/dist/protocols/adapter-shared.d.ts.map +1 -1
- package/dist/protocols/adapter-shared.js +6 -0
- package/dist/protocols/adapter-shared.js.map +1 -1
- package/dist/protocols/dash-cmaf/index.d.ts +9 -1
- package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/index.js +78 -14
- package/dist/protocols/dash-cmaf/index.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +419 -90
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/dash-cmaf/periods-runtime.d.ts +6 -0
- package/dist/protocols/dash-cmaf/periods-runtime.d.ts.map +1 -0
- package/dist/protocols/dash-cmaf/periods-runtime.js +121 -0
- package/dist/protocols/dash-cmaf/periods-runtime.js.map +1 -0
- package/dist/protocols/dash-cmaf/periods.d.ts +24 -0
- package/dist/protocols/dash-cmaf/periods.d.ts.map +1 -0
- package/dist/protocols/dash-cmaf/periods.js +210 -0
- package/dist/protocols/dash-cmaf/periods.js.map +1 -0
- package/dist/protocols/hls-cmaf/index.d.ts +9 -1
- package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/index.js +49 -20
- package/dist/protocols/hls-cmaf/index.js.map +1 -1
- package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/lexer.js +1 -0
- package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts +3 -1
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +169 -10
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts +9 -1
- package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/unavailable.js +29 -3
- package/dist/protocols/hls-cmaf/unavailable.js.map +1 -1
- package/dist/protocols/hls-live/index.d.ts +9 -1
- package/dist/protocols/hls-live/index.d.ts.map +1 -1
- package/dist/protocols/hls-live/index.js +36 -7
- package/dist/protocols/hls-live/index.js.map +1 -1
- package/dist/stages/abr/index.d.ts.map +1 -1
- package/dist/stages/abr/index.js +10 -6
- package/dist/stages/abr/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts +5 -2
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +31 -11
- package/dist/stages/alt-audio/index.js.map +1 -1
- package/dist/stages/cmcd/index.d.ts.map +1 -1
- package/dist/stages/cmcd/index.js +39 -3
- package/dist/stages/cmcd/index.js.map +1 -1
- package/dist/stages/cmsd/index.d.ts +22 -0
- package/dist/stages/cmsd/index.d.ts.map +1 -0
- package/dist/stages/cmsd/index.js +65 -0
- package/dist/stages/cmsd/index.js.map +1 -0
- package/dist/stages/codec-probe/index.d.ts.map +1 -1
- package/dist/stages/codec-probe/index.js +30 -3
- package/dist/stages/codec-probe/index.js.map +1 -1
- package/dist/stages/eme-core/index.d.ts +7 -0
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +26 -0
- package/dist/stages/eme-core/index.js.map +1 -1
- package/dist/stages/hdr/index.d.ts +22 -0
- package/dist/stages/hdr/index.d.ts.map +1 -0
- package/dist/stages/hdr/index.js +191 -0
- package/dist/stages/hdr/index.js.map +1 -0
- package/dist/stages/meta-id3/index.d.ts.map +1 -1
- package/dist/stages/meta-id3/index.js +6 -2
- package/dist/stages/meta-id3/index.js.map +1 -1
- package/dist/stages/qoe/index.d.ts +32 -0
- package/dist/stages/qoe/index.d.ts.map +1 -0
- package/dist/stages/qoe/index.js +116 -0
- package/dist/stages/qoe/index.js.map +1 -0
- package/dist/stages/rendition-names/index.d.ts +41 -0
- package/dist/stages/rendition-names/index.d.ts.map +1 -0
- package/dist/stages/rendition-names/index.js +101 -0
- package/dist/stages/rendition-names/index.js.map +1 -0
- package/dist/stages/text-cea608/decode.d.ts +23 -2
- package/dist/stages/text-cea608/decode.d.ts.map +1 -1
- package/dist/stages/text-cea608/decode.js +55 -5
- package/dist/stages/text-cea608/decode.js.map +1 -1
- package/dist/stages/text-cea608/index.d.ts +10 -3
- package/dist/stages/text-cea608/index.d.ts.map +1 -1
- package/dist/stages/text-cea608/index.js +34 -34
- package/dist/stages/text-cea608/index.js.map +1 -1
- package/dist/stages/text-cea708/decode.d.ts +79 -0
- package/dist/stages/text-cea708/decode.d.ts.map +1 -0
- package/dist/stages/text-cea708/decode.js +404 -0
- package/dist/stages/text-cea708/decode.js.map +1 -0
- package/dist/stages/text-cea708/index.d.ts +3 -0
- package/dist/stages/text-cea708/index.d.ts.map +1 -0
- package/dist/stages/text-cea708/index.js +93 -0
- package/dist/stages/text-cea708/index.js.map +1 -0
- package/dist/stages/text-ttml/index.d.ts +3 -0
- package/dist/stages/text-ttml/index.d.ts.map +1 -0
- package/dist/stages/text-ttml/index.js +74 -0
- package/dist/stages/text-ttml/index.js.map +1 -0
- package/dist/stages/text-ttml/parse.d.ts +16 -0
- package/dist/stages/text-ttml/parse.d.ts.map +1 -0
- package/dist/stages/text-ttml/parse.js +277 -0
- package/dist/stages/text-ttml/parse.js.map +1 -0
- package/dist/stages/text-webvtt/index.d.ts +6 -10
- package/dist/stages/text-webvtt/index.d.ts.map +1 -1
- package/dist/stages/text-webvtt/index.js +22 -64
- package/dist/stages/text-webvtt/index.js.map +1 -1
- package/dist/stages/timed-metadata/index.d.ts +15 -0
- package/dist/stages/timed-metadata/index.d.ts.map +1 -0
- package/dist/stages/timed-metadata/index.js +370 -0
- package/dist/stages/timed-metadata/index.js.map +1 -0
- package/dist/types/error.d.ts +1 -1
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/facade.d.ts +14 -10
- package/dist/types/facade.d.ts.map +1 -1
- package/dist/types/ir.d.ts +71 -0
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +11 -1
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/kernel.js.map +1 -1
- package/dist/types/messages.d.ts +20 -1
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/metadata.d.ts +59 -0
- package/dist/types/metadata.d.ts.map +1 -0
- package/dist/types/metadata.js +7 -0
- package/dist/types/metadata.js.map +1 -0
- package/dist/types/quality.d.ts +3 -0
- package/dist/types/quality.d.ts.map +1 -1
- package/dist/types/stage.d.ts +17 -0
- package/dist/types/stage.d.ts.map +1 -1
- package/package.json +10 -2
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { registerCaptionConsumer } from "../../containers/captions.js";
|
|
3
|
+
import { inbandCaptions, vttCue } from "../../kernel/sinks/caption-tracks.js";
|
|
4
|
+
import { Dtvcc } from "./decode.js";
|
|
5
|
+
//#region src/stages/text-cea708/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* CEA-708 in-band captions as a stage. It registers a caption consumer
|
|
8
|
+
* beside text-cea608's, and reads the DTVCC triples (cc_type 2 and 3) that
|
|
9
|
+
* stage leaves. Each service is a text track like any subtitle: HLS
|
|
10
|
+
* `INSTREAM-ID="SERVICEn"`, DASH `urn:scte:dash:cc:cea-708:2015`, or a track
|
|
11
|
+
* added on the service's first cue (`cea708:SERVICEn`).
|
|
12
|
+
*
|
|
13
|
+
* Each visible window becomes a VTTCue on the service's native caption
|
|
14
|
+
* track, labelled SERVICEn. The window's anchor maps to `line` and
|
|
15
|
+
* `position`, its anchor point to `lineAlign` and `positionAlign`, its
|
|
16
|
+
* column count to `size`, its justification to `align`, and the pen's
|
|
17
|
+
* italics and underline to `<i>` and `<u>`. Colors, opacities, edges, and
|
|
18
|
+
* fonts are not mapped: a VTTCue carries no color without page CSS. The cue
|
|
19
|
+
* keeps the window layout in a `cea708` property the browser ignores, for a
|
|
20
|
+
* player that draws captions itself.
|
|
21
|
+
*/
|
|
22
|
+
const MIME = "application/cea-708";
|
|
23
|
+
const ALIGN = [
|
|
24
|
+
"left",
|
|
25
|
+
"right",
|
|
26
|
+
"center",
|
|
27
|
+
"left"
|
|
28
|
+
];
|
|
29
|
+
const LINE_ALIGN = [
|
|
30
|
+
"start",
|
|
31
|
+
"center",
|
|
32
|
+
"end"
|
|
33
|
+
];
|
|
34
|
+
const POSITION_ALIGN = [
|
|
35
|
+
"line-left",
|
|
36
|
+
"center",
|
|
37
|
+
"line-right"
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Places the cue where its window sits (§8.4). Relative anchors are percent;
|
|
41
|
+
* absolute ones are cells of a 75-row grid, 210 columns wide at 16:9 and 160
|
|
42
|
+
* at 4:3. A browser that rejects a value keeps its default for it.
|
|
43
|
+
*/
|
|
44
|
+
function place(target, cue, wide) {
|
|
45
|
+
const placed = target;
|
|
46
|
+
const { layout } = cue;
|
|
47
|
+
const across = wide ? 210 : 160;
|
|
48
|
+
const line = layout.relative ? layout.anchorVertical : layout.anchorVertical / 75 * 100;
|
|
49
|
+
const position = layout.relative ? layout.anchorHorizontal : layout.anchorHorizontal / across * 100;
|
|
50
|
+
const settings = [
|
|
51
|
+
["snapToLines", false],
|
|
52
|
+
["line", Math.min(100, line)],
|
|
53
|
+
["position", Math.min(100, position)],
|
|
54
|
+
["size", Math.min(100, layout.columns / (wide ? 42 : 32) * 100)],
|
|
55
|
+
["align", ALIGN[layout.justify]],
|
|
56
|
+
["lineAlign", LINE_ALIGN[Math.floor(layout.anchorPoint / 3)]],
|
|
57
|
+
["positionAlign", POSITION_ALIGN[layout.anchorPoint % 3]]
|
|
58
|
+
];
|
|
59
|
+
for (const [key, value] of settings) try {
|
|
60
|
+
placed[key] = value;
|
|
61
|
+
} catch (_unused) {}
|
|
62
|
+
placed.cea708 = _objectSpread2({ window: cue.window }, layout);
|
|
63
|
+
}
|
|
64
|
+
function textCea708() {
|
|
65
|
+
return {
|
|
66
|
+
name: "text-cea708",
|
|
67
|
+
provides: ["text-cea708", {
|
|
68
|
+
contentType: "text",
|
|
69
|
+
mimeType: MIME
|
|
70
|
+
}],
|
|
71
|
+
requires: [["nal-scan", "ts-transmux"]],
|
|
72
|
+
install(ctx) {
|
|
73
|
+
const dtvcc = new Dtvcc();
|
|
74
|
+
const captions = inbandCaptions(ctx, MIME, "cea708");
|
|
75
|
+
const unregister = registerCaptionConsumer((packets) => {
|
|
76
|
+
for (const packet of packets) for (const triple of packet.triples) if (triple.type >= 2) dtvcc.push(triple.type, triple.a, triple.b, packet.time);
|
|
77
|
+
const video = ctx.element;
|
|
78
|
+
const wide = !(video.videoHeight > 0 && video.videoWidth / video.videoHeight < 1.5);
|
|
79
|
+
for (const [service, cues] of dtvcc.drain()) {
|
|
80
|
+
const native = [];
|
|
81
|
+
for (const cue of cues) {
|
|
82
|
+
const made = vttCue(cue.start, cue.end, cue.text);
|
|
83
|
+
if (made === null) continue;
|
|
84
|
+
place(made, cue, wide);
|
|
85
|
+
native.push(made);
|
|
86
|
+
}
|
|
87
|
+
captions.show(`SERVICE${service}`, native);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return () => {
|
|
91
|
+
unregister();
|
|
92
|
+
captions.dispose();
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { textCea708 as default };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { findRendition } from "../../kernel/presentation.js";
|
|
3
|
+
import { segmentAt } from "../../kernel/timeline.js";
|
|
4
|
+
import { timedSamples, trackTimescales } from "../../containers/mp4-box/index.js";
|
|
5
|
+
import { joinTextSink } from "../../kernel/sinks/text-formats.js";
|
|
6
|
+
import { parseTtml } from "./parse.js";
|
|
7
|
+
//#region src/stages/text-ttml/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* TTML subtitles as a stage, for the IMSC1 Text Profile and EBU-TT-D. It
|
|
10
|
+
* joins the one text sink with two formats:
|
|
11
|
+
*
|
|
12
|
+
* - `application/ttml+xml`: a whole document per segment, a sidecar for the
|
|
13
|
+
* period or one file per segment, timed on the presentation timeline.
|
|
14
|
+
* - `application/mp4;stpp`: TTML in fMP4 (ISO/IEC 14496-30), one document
|
|
15
|
+
* per sample. The document's times are on the track's media timeline, so
|
|
16
|
+
* they map through the segment's decode time, which lands at the
|
|
17
|
+
* segment's start. Some packagers time each document from its sample's
|
|
18
|
+
* start instead; a document whose times fall before its sample is read
|
|
19
|
+
* that way.
|
|
20
|
+
*
|
|
21
|
+
* Italics, bold, and underline show; the region places the cue. Colors do
|
|
22
|
+
* not: a VTTCue carries them only through page CSS, which the engine does
|
|
23
|
+
* not write. Each cue's `payload` holds its resolved styles, for a player
|
|
24
|
+
* that draws captions itself.
|
|
25
|
+
*/
|
|
26
|
+
const TTML = "application/ttml+xml";
|
|
27
|
+
/** The cues with open ends closed at `end`, and an id for each, so a refetched segment adds nothing twice. */
|
|
28
|
+
function finish(cues, shift, end) {
|
|
29
|
+
return cues.map((cue) => {
|
|
30
|
+
const start = cue.start + shift;
|
|
31
|
+
const stop = Math.min(cue.end + shift, end);
|
|
32
|
+
return _objectSpread2(_objectSpread2({}, cue), {}, {
|
|
33
|
+
id: `${start.toFixed(3)}|${stop.toFixed(3)}|${cue.text}`,
|
|
34
|
+
start,
|
|
35
|
+
end: stop
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function textTtml() {
|
|
40
|
+
return {
|
|
41
|
+
name: "text-ttml",
|
|
42
|
+
provides: [
|
|
43
|
+
"text-ttml",
|
|
44
|
+
{
|
|
45
|
+
contentType: "text",
|
|
46
|
+
mimeType: TTML
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
contentType: "text",
|
|
50
|
+
mimeType: "application/mp4",
|
|
51
|
+
codecs: "stpp"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
requires: ["scheduler"],
|
|
55
|
+
install(ctx) {
|
|
56
|
+
const timescales = /* @__PURE__ */ new Map();
|
|
57
|
+
function parseStpp(data, meta) {
|
|
58
|
+
if (meta.isInit) {
|
|
59
|
+
timescales.set(meta.renditionId, trackTimescales(data));
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const cues = [];
|
|
63
|
+
for (const sample of timedSamples(data, timescales.get(meta.renditionId), meta.start)) {
|
|
64
|
+
const parsed = parseTtml(new TextDecoder().decode(sample.bytes));
|
|
65
|
+
const relative = parsed.some((cue) => cue.start + sample.shift < sample.start - .5);
|
|
66
|
+
cues.push(...finish(parsed, relative ? sample.start : sample.shift, sample.end));
|
|
67
|
+
}
|
|
68
|
+
return cues;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A whole document, timed on the presentation timeline, or from its
|
|
72
|
+
* DASH period's start when the segment carries that offset.
|
|
73
|
+
*/
|
|
74
|
+
function parseDocument(data, meta) {
|
|
75
|
+
var _segmentAt;
|
|
76
|
+
const site = findRendition(ctx.getState().presentation, meta.renditionId);
|
|
77
|
+
const offset = site === null ? void 0 : (_segmentAt = segmentAt(site.rendition.segments, meta.seq, site.period.start)) === null || _segmentAt === void 0 ? void 0 : _segmentAt.timeOffset;
|
|
78
|
+
return finish(parseTtml(new TextDecoder().decode(data)), offset !== null && offset !== void 0 ? offset : 0, meta.start + meta.duration);
|
|
79
|
+
}
|
|
80
|
+
return joinTextSink(ctx, {
|
|
81
|
+
[TTML]: parseDocument,
|
|
82
|
+
"application/mp4;stpp": parseStpp
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { textTtml as default };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { escapeCueText } from "../../containers/webvtt.js";
|
|
3
|
+
//#region src/stages/text-ttml/parse.ts
|
|
4
|
+
/**
|
|
5
|
+
* TTML to cues, for the IMSC1 Text Profile (W3C IMSC 1.0.1 to 1.2), which
|
|
6
|
+
* EBU-TT-D documents also conform to. It reads `tt`, `head` (styling and
|
|
7
|
+
* layout), `body`, `div`, `p`, `span`, and `br`, the timing attributes, the
|
|
8
|
+
* styles a cue can show, and the region a `p` is flowed into. Anything else
|
|
9
|
+
* is ignored, so a richer document still shows its text.
|
|
10
|
+
*
|
|
11
|
+
* Times come back in document time; `Infinity` marks an end the document
|
|
12
|
+
* leaves open, for the caller to close at its segment's end.
|
|
13
|
+
*/
|
|
14
|
+
const TTP = "http://www.w3.org/ns/ttml#parameter";
|
|
15
|
+
const TTS = "http://www.w3.org/ns/ttml#styling";
|
|
16
|
+
const XML = "http://www.w3.org/XML/1998/namespace";
|
|
17
|
+
/** The styles kept: what a cue shows, and what the raw form carries for a page. */
|
|
18
|
+
const STYLES = [
|
|
19
|
+
"fontStyle",
|
|
20
|
+
"fontWeight",
|
|
21
|
+
"textDecoration",
|
|
22
|
+
"textAlign",
|
|
23
|
+
"color",
|
|
24
|
+
"backgroundColor",
|
|
25
|
+
"displayAlign",
|
|
26
|
+
"origin",
|
|
27
|
+
"extent"
|
|
28
|
+
];
|
|
29
|
+
/** Region-only styles do not pass from a region or a parent to its content. */
|
|
30
|
+
const NOT_INHERITED = /* @__PURE__ */ new Set([
|
|
31
|
+
"backgroundColor",
|
|
32
|
+
"displayAlign",
|
|
33
|
+
"origin",
|
|
34
|
+
"extent"
|
|
35
|
+
]);
|
|
36
|
+
function attrNS(element, ns, prefix, name) {
|
|
37
|
+
var _element$getAttribute;
|
|
38
|
+
return (_element$getAttribute = element.getAttributeNS(ns, name)) !== null && _element$getAttribute !== void 0 ? _element$getAttribute : element.getAttribute(`${prefix}:${name}`);
|
|
39
|
+
}
|
|
40
|
+
function childElements(element, name) {
|
|
41
|
+
return [...element.children].filter((child) => name === void 0 || child.localName === name);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A TTML time expression in seconds (TTML2 §10.3.1): clock time
|
|
45
|
+
* `hh:mm:ss.fff` or `hh:mm:ss:ff.sub`, or an offset `12.5s`, `250ms`, `2m`,
|
|
46
|
+
* `1h`, `30f`, `100t`. Null for anything else.
|
|
47
|
+
*/
|
|
48
|
+
function parseTime(value, rates) {
|
|
49
|
+
if (value === null) return null;
|
|
50
|
+
const text = value.trim();
|
|
51
|
+
const clock = /^(\d+):(\d\d):(\d\d)(?:(\.\d+)|:(\d+)(?:\.(\d+))?)?$/.exec(text);
|
|
52
|
+
if (clock !== null) {
|
|
53
|
+
const [, h, m, s, fraction, frames, sub] = clock;
|
|
54
|
+
return Number(h) * 3600 + Number(m) * 60 + Number(s) + (fraction !== void 0 ? Number(fraction) : 0) + (frames !== void 0 ? Number(frames) / rates.frame : 0) + (sub !== void 0 ? Number(sub) / (rates.frame * rates.subFrame) : 0);
|
|
55
|
+
}
|
|
56
|
+
const offset = /^(\d+(?:\.\d+)?)(h|ms|m|s|f|t)$/.exec(text);
|
|
57
|
+
if (offset === null) return null;
|
|
58
|
+
const units = {
|
|
59
|
+
h: 3600,
|
|
60
|
+
m: 60,
|
|
61
|
+
s: 1,
|
|
62
|
+
ms: .001,
|
|
63
|
+
f: 1 / rates.frame,
|
|
64
|
+
t: 1 / rates.tick
|
|
65
|
+
};
|
|
66
|
+
return Number(offset[1]) * units[offset[2]];
|
|
67
|
+
}
|
|
68
|
+
/** The frame, sub-frame, and tick rates the root declares (TTML2 §7.2). */
|
|
69
|
+
function ratesOf(tt) {
|
|
70
|
+
var _attrNS, _attrNS2, _attrNS3;
|
|
71
|
+
const declared = attrNS(tt, TTP, "ttp", "frameRate");
|
|
72
|
+
const [num, den] = ((_attrNS = attrNS(tt, TTP, "ttp", "frameRateMultiplier")) !== null && _attrNS !== void 0 ? _attrNS : "1 1").split(/\s+/);
|
|
73
|
+
const frame = Number(declared !== null && declared !== void 0 ? declared : 30) * (Number(num) / Number(den) || 1);
|
|
74
|
+
const subFrame = Number((_attrNS2 = attrNS(tt, TTP, "ttp", "subFrameRate")) !== null && _attrNS2 !== void 0 ? _attrNS2 : 1);
|
|
75
|
+
return {
|
|
76
|
+
frame,
|
|
77
|
+
subFrame,
|
|
78
|
+
tick: Number((_attrNS3 = attrNS(tt, TTP, "ttp", "tickRate")) !== null && _attrNS3 !== void 0 ? _attrNS3 : declared !== null ? frame * subFrame : 1)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function inlineStyle(element) {
|
|
82
|
+
const style = {};
|
|
83
|
+
for (const key of STYLES) {
|
|
84
|
+
const value = attrNS(element, TTS, "tts", key);
|
|
85
|
+
if (value !== null) style[key] = value.trim();
|
|
86
|
+
}
|
|
87
|
+
return style;
|
|
88
|
+
}
|
|
89
|
+
/** A length as a percent of the root container: `%`, `px` against the root extent, `c` against the cell grid. */
|
|
90
|
+
function percent(value, axis, root, cells) {
|
|
91
|
+
const match = value === void 0 ? null : /^(-?[\d.]+)(%|px|c)$/.exec(value);
|
|
92
|
+
if (match === null) return null;
|
|
93
|
+
const n = Number(match[1]);
|
|
94
|
+
if (match[2] === "%") return n;
|
|
95
|
+
const whole = match[2] === "px" ? root[axis] : cells[axis];
|
|
96
|
+
return whole !== void 0 && whole > 0 ? n / whole * 100 : null;
|
|
97
|
+
}
|
|
98
|
+
/** WebVTT settings that put the cue where its region sits (IMSC1 §8, WebVTT §4.3). */
|
|
99
|
+
function settingsFor(style, root, cells) {
|
|
100
|
+
var _style$origin, _style$extent;
|
|
101
|
+
const origin = ((_style$origin = style.origin) !== null && _style$origin !== void 0 ? _style$origin : "").split(/\s+/);
|
|
102
|
+
const extent = ((_style$extent = style.extent) !== null && _style$extent !== void 0 ? _style$extent : "").split(/\s+/);
|
|
103
|
+
const x = percent(origin[0], 0, root, cells);
|
|
104
|
+
const y = percent(origin[1], 1, root, cells);
|
|
105
|
+
const w = percent(extent[0], 0, root, cells);
|
|
106
|
+
const h = percent(extent[1], 1, root, cells);
|
|
107
|
+
const out = [];
|
|
108
|
+
if (x !== null && w !== null) out.push(`position:${x + w / 2}%,center`, `size:${w}%`);
|
|
109
|
+
if (y !== null && h !== null) {
|
|
110
|
+
var _style$displayAlign;
|
|
111
|
+
const display = (_style$displayAlign = style.displayAlign) !== null && _style$displayAlign !== void 0 ? _style$displayAlign : "before";
|
|
112
|
+
out.push(display === "after" ? `line:${y + h}%,end` : display === "center" ? `line:${y + h / 2}%,center` : `line:${y}%,start`);
|
|
113
|
+
}
|
|
114
|
+
const align = style.textAlign;
|
|
115
|
+
if (align !== void 0 && [
|
|
116
|
+
"left",
|
|
117
|
+
"center",
|
|
118
|
+
"right",
|
|
119
|
+
"start",
|
|
120
|
+
"end"
|
|
121
|
+
].includes(align)) out.push(`align:${align}`);
|
|
122
|
+
return out.join(" ");
|
|
123
|
+
}
|
|
124
|
+
/** The cues of a TTML document. Throws a RangeError for bytes that are not XML. */
|
|
125
|
+
function parseTtml(xml) {
|
|
126
|
+
var _attrNS4, _attrNS5;
|
|
127
|
+
const doc = new DOMParser().parseFromString(xml, "application/xml");
|
|
128
|
+
const tt = doc.documentElement;
|
|
129
|
+
if (tt === null || tt.localName !== "tt" || doc.getElementsByTagName("parsererror").length > 0) throw new RangeError("not a TTML document");
|
|
130
|
+
const timeBase = attrNS(tt, TTP, "ttp", "timeBase");
|
|
131
|
+
if (timeBase !== null && timeBase !== "media") return [];
|
|
132
|
+
const rates = ratesOf(tt);
|
|
133
|
+
const root = ((_attrNS4 = attrNS(tt, TTS, "tts", "extent")) !== null && _attrNS4 !== void 0 ? _attrNS4 : "").split(/\s+/).map((v) => Number.parseFloat(v));
|
|
134
|
+
const cells = ((_attrNS5 = attrNS(tt, TTP, "ttp", "cellResolution")) !== null && _attrNS5 !== void 0 ? _attrNS5 : "32 15").split(/\s+/).map(Number);
|
|
135
|
+
const styles = /* @__PURE__ */ new Map();
|
|
136
|
+
const regions = /* @__PURE__ */ new Map();
|
|
137
|
+
const head = childElements(tt, "head")[0];
|
|
138
|
+
for (const styling of head === void 0 ? [] : childElements(head, "styling")) for (const style of childElements(styling, "style")) styles.set(idOf(style), style);
|
|
139
|
+
for (const layout of head === void 0 ? [] : childElements(head, "layout")) for (const region of childElements(layout, "region")) regions.set(idOf(region), region);
|
|
140
|
+
function idOf(element) {
|
|
141
|
+
var _ref, _element$getAttribute2;
|
|
142
|
+
return (_ref = (_element$getAttribute2 = element.getAttributeNS(XML, "id")) !== null && _element$getAttribute2 !== void 0 ? _element$getAttribute2 : element.getAttribute("xml:id")) !== null && _ref !== void 0 ? _ref : "";
|
|
143
|
+
}
|
|
144
|
+
/** The style an element specifies: referenced styles in order, then nested and inline ones. */
|
|
145
|
+
function specified(element, seen = /* @__PURE__ */ new Set()) {
|
|
146
|
+
var _element$getAttribute3;
|
|
147
|
+
let style = {};
|
|
148
|
+
for (const ref of ((_element$getAttribute3 = element.getAttribute("style")) !== null && _element$getAttribute3 !== void 0 ? _element$getAttribute3 : "").split(/\s+/)) {
|
|
149
|
+
const referenced = styles.get(ref);
|
|
150
|
+
if (referenced === void 0 || seen.has(referenced)) continue;
|
|
151
|
+
seen.add(referenced);
|
|
152
|
+
style = _objectSpread2(_objectSpread2({}, style), specified(referenced, seen));
|
|
153
|
+
}
|
|
154
|
+
for (const nested of childElements(element, "style")) style = _objectSpread2(_objectSpread2({}, style), inlineStyle(nested));
|
|
155
|
+
return _objectSpread2(_objectSpread2({}, style), inlineStyle(element));
|
|
156
|
+
}
|
|
157
|
+
function inherit(parent) {
|
|
158
|
+
const out = {};
|
|
159
|
+
for (const key of STYLES) if (!NOT_INHERITED.has(key) && parent[key] !== void 0) out[key] = parent[key];
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
function interval(element, parent) {
|
|
163
|
+
const begin = parseTime(element.getAttribute("begin"), rates);
|
|
164
|
+
const end = parseTime(element.getAttribute("end"), rates);
|
|
165
|
+
const dur = parseTime(element.getAttribute("dur"), rates);
|
|
166
|
+
const start = parent[0] + (begin !== null && begin !== void 0 ? begin : 0);
|
|
167
|
+
let stop = parent[1];
|
|
168
|
+
if (end !== null) stop = Math.min(stop, parent[0] + end);
|
|
169
|
+
if (dur !== null) stop = Math.min(stop, start + dur);
|
|
170
|
+
return [start, stop];
|
|
171
|
+
}
|
|
172
|
+
/** The text runs of a p's content, each with its own active interval and markup. */
|
|
173
|
+
function runs(node, style, span, out) {
|
|
174
|
+
for (const child of node.childNodes) if (child.nodeType === 3) {
|
|
175
|
+
var _child$nodeValue, _style$textDecoration;
|
|
176
|
+
const text = ((_child$nodeValue = child.nodeValue) !== null && _child$nodeValue !== void 0 ? _child$nodeValue : "").replace(/[ \t\r\n]+/g, " ");
|
|
177
|
+
if (text === "") continue;
|
|
178
|
+
let markup = escapeCueText(text);
|
|
179
|
+
if (((_style$textDecoration = style.textDecoration) === null || _style$textDecoration === void 0 ? void 0 : _style$textDecoration.includes("underline")) === true) markup = `<u>${markup}</u>`;
|
|
180
|
+
if (style.fontWeight === "bold") markup = `<b>${markup}</b>`;
|
|
181
|
+
if (style.fontStyle === "italic" || style.fontStyle === "oblique") markup = `<i>${markup}</i>`;
|
|
182
|
+
out.push({
|
|
183
|
+
text: markup,
|
|
184
|
+
start: span[0],
|
|
185
|
+
end: span[1]
|
|
186
|
+
});
|
|
187
|
+
} else if (child.nodeType === 1) {
|
|
188
|
+
const element = child;
|
|
189
|
+
if (element.localName === "br") out.push({
|
|
190
|
+
text: "\n",
|
|
191
|
+
start: span[0],
|
|
192
|
+
end: span[1]
|
|
193
|
+
});
|
|
194
|
+
else if (element.localName === "span") runs(element, _objectSpread2(_objectSpread2({}, inherit(style)), specified(element)), interval(element, span), out);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const cues = [];
|
|
198
|
+
function cuesOf(p, style, span) {
|
|
199
|
+
const content = [];
|
|
200
|
+
runs(p, style, span, content);
|
|
201
|
+
const edges = [.../* @__PURE__ */ new Set([
|
|
202
|
+
span[0],
|
|
203
|
+
span[1],
|
|
204
|
+
...content.flatMap((r) => [r.start, r.end])
|
|
205
|
+
])].filter((t) => t >= span[0] && t <= span[1]).sort((a, b) => a - b);
|
|
206
|
+
const settings = settingsFor(style, root, cells);
|
|
207
|
+
const payload = Object.fromEntries(Object.entries(style));
|
|
208
|
+
for (let i = 0; i + 1 < edges.length; i += 1) {
|
|
209
|
+
const from = edges[i];
|
|
210
|
+
const to = edges[i + 1];
|
|
211
|
+
const text = content.filter((r) => r.start <= from && r.end >= to).map((r) => r.text).join("").split("\n").map((line) => line.trim()).join("\n").trim();
|
|
212
|
+
if (text === "") continue;
|
|
213
|
+
const last = cues[cues.length - 1];
|
|
214
|
+
if (last !== void 0 && last.end === from && last.text === text && last.settings === settings) {
|
|
215
|
+
cues[cues.length - 1] = _objectSpread2(_objectSpread2({}, last), {}, { end: to });
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
cues.push(_objectSpread2(_objectSpread2({
|
|
219
|
+
start: from,
|
|
220
|
+
end: to,
|
|
221
|
+
text
|
|
222
|
+
}, settings !== "" ? { settings } : {}), {}, { payload }));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** Walks body and its divs, carrying timing, style, and region down to each p. */
|
|
226
|
+
function walk(element, parentStyle, region, span) {
|
|
227
|
+
var _element$getAttribute4;
|
|
228
|
+
const own = (_element$getAttribute4 = element.getAttribute("region")) !== null && _element$getAttribute4 !== void 0 ? _element$getAttribute4 : region;
|
|
229
|
+
const regionElement = own === null ? void 0 : regions.get(own);
|
|
230
|
+
const fromRegion = regionElement === void 0 ? {} : specified(regionElement);
|
|
231
|
+
const style = _objectSpread2(_objectSpread2(_objectSpread2({}, fromRegion), inherit(parentStyle)), specified(element));
|
|
232
|
+
const placed = _objectSpread2(_objectSpread2({}, style), pick(fromRegion));
|
|
233
|
+
const interval_ = interval(element, span);
|
|
234
|
+
if (element.localName === "p") {
|
|
235
|
+
cuesOf(element, placed, interval_);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
for (const child of childElements(element)) if (child.localName === "div" || child.localName === "p") walk(child, style, own, interval_);
|
|
239
|
+
}
|
|
240
|
+
function pick(style) {
|
|
241
|
+
const out = {};
|
|
242
|
+
for (const key of [
|
|
243
|
+
"origin",
|
|
244
|
+
"extent",
|
|
245
|
+
"displayAlign",
|
|
246
|
+
"backgroundColor"
|
|
247
|
+
]) if (style[key] !== void 0) out[key] = style[key];
|
|
248
|
+
return out;
|
|
249
|
+
}
|
|
250
|
+
const body = childElements(tt, "body")[0];
|
|
251
|
+
if (body !== void 0) walk(body, {}, null, [0, Number.POSITIVE_INFINITY]);
|
|
252
|
+
return cues.sort((a, b) => a.start - b.start);
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
export { parseTime, parseTtml };
|
|
@@ -1,80 +1,49 @@
|
|
|
1
|
+
import { timedSamples, trackTimescales } from "../../containers/mp4-box/index.js";
|
|
1
2
|
import { parseVtt } from "../../containers/webvtt.js";
|
|
2
|
-
import {
|
|
3
|
+
import { wvttCues } from "../../containers/wvtt.js";
|
|
4
|
+
import { joinTextSink } from "../../kernel/sinks/text-formats.js";
|
|
3
5
|
//#region src/stages/text-webvtt/index.ts
|
|
4
6
|
/**
|
|
5
|
-
* WebVTT as a stage:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* selection in step, both ways. Every text track exists natively from the
|
|
12
|
-
* manifest on, so the browser's caption menu lists all of them; the active
|
|
13
|
-
* one is `showing`, the rest `disabled`. A pick in that menu selects in the
|
|
14
|
-
* engine, and switching captions off there deselects.
|
|
7
|
+
* WebVTT as a stage: the parsers for `text/vtt` files and for WebVTT in
|
|
8
|
+
* fMP4 (`wvtt`, ISO/IEC 14496-30), joined to the one text sink
|
|
9
|
+
* every subtitle format shares (`kernel/sinks/text-formats.ts`). Cues become
|
|
10
|
+
* native VTTCues; the browser renders, styles, and exposes the caption UI,
|
|
11
|
+
* which is why this stage stays small. It mirrors only its own format's
|
|
12
|
+
* tracks; the in-band caption stages fill caption tracks of their own.
|
|
15
13
|
*/
|
|
14
|
+
const MIME = "text/vtt";
|
|
16
15
|
function parseSegment(data, _meta) {
|
|
17
16
|
return parseVtt(new TextDecoder().decode(data)).cues;
|
|
18
17
|
}
|
|
19
18
|
function textWebvtt() {
|
|
20
19
|
return {
|
|
21
20
|
name: "text-webvtt",
|
|
22
|
-
provides: [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
provides: [
|
|
22
|
+
"text-webvtt",
|
|
23
|
+
{
|
|
24
|
+
contentType: "text",
|
|
25
|
+
mimeType: MIME
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
contentType: "text",
|
|
29
|
+
mimeType: "application/mp4",
|
|
30
|
+
codecs: "wvtt"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
26
33
|
requires: ["scheduler"],
|
|
27
34
|
install(ctx) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ctx.registerParser("text/vtt", parseSegment);
|
|
34
|
-
ctx.registerSink("text", () => sink);
|
|
35
|
-
function textTracks() {
|
|
36
|
-
const presentation = ctx.getState().presentation;
|
|
37
|
-
if (presentation === null) return [];
|
|
38
|
-
return presentation.periods.flatMap((period) => period.tracks.filter((track) => track.contentType === "text"));
|
|
39
|
-
}
|
|
40
|
-
function activeId() {
|
|
41
|
-
return ctx.getState().tracks.active.get("text");
|
|
42
|
-
}
|
|
43
|
-
function mirror() {
|
|
44
|
-
const active = activeId();
|
|
45
|
-
const current = new Set(textTracks().map((track) => track.id));
|
|
46
|
-
for (const id of sink.trackIds()) if (!current.has(id)) sink.retire(id);
|
|
47
|
-
for (const track of textTracks()) {
|
|
48
|
-
const native = sink.declare(track.id);
|
|
49
|
-
const mode = track.id === active ? "showing" : "disabled";
|
|
50
|
-
if (native.mode !== mode) native.mode = mode;
|
|
35
|
+
const timescales = /* @__PURE__ */ new Map();
|
|
36
|
+
function parseWvtt(data, meta) {
|
|
37
|
+
if (meta.isInit) {
|
|
38
|
+
timescales.set(meta.renditionId, trackTimescales(data));
|
|
39
|
+
return [];
|
|
51
40
|
}
|
|
41
|
+
return wvttCues(timedSamples(data, timescales.get(meta.renditionId), meta.start));
|
|
52
42
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _sink$nativeTrack;
|
|
57
|
-
return ((_sink$nativeTrack = sink.nativeTrack(track.id)) === null || _sink$nativeTrack === void 0 ? void 0 : _sink$nativeTrack.mode) === "showing";
|
|
58
|
-
});
|
|
59
|
-
if (showing !== void 0) {
|
|
60
|
-
if (showing.id !== active) ctx.dispatch({
|
|
61
|
-
type: "SELECT_TRACK",
|
|
62
|
-
trackId: showing.id
|
|
63
|
-
});
|
|
64
|
-
} else if (active !== void 0) ctx.dispatch({
|
|
65
|
-
type: "DESELECT_TRACK",
|
|
66
|
-
contentType: "text"
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
ctx.on("tracks:changed", mirror);
|
|
70
|
-
ctx.on("tracks:selected", (payload) => {
|
|
71
|
-
if (payload.contentType === "text") mirror();
|
|
43
|
+
return joinTextSink(ctx, {
|
|
44
|
+
[MIME]: parseSegment,
|
|
45
|
+
"application/mp4;wvtt": parseWvtt
|
|
72
46
|
});
|
|
73
|
-
element.textTracks.addEventListener("change", onNativeChange);
|
|
74
|
-
return () => {
|
|
75
|
-
element.textTracks.removeEventListener("change", onNativeChange);
|
|
76
|
-
sink.dispose();
|
|
77
|
-
};
|
|
78
47
|
}
|
|
79
48
|
};
|
|
80
49
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { scheduled } from "../../kernel/effects.js";
|
|
2
2
|
import { isIndexed, segmentAt, segmentAtTime } from "../../kernel/timeline.js";
|
|
3
|
-
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.
|
|
3
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/asyncToGenerator.js";
|
|
4
4
|
import { parseVtt } from "../../containers/webvtt.js";
|
|
5
5
|
import { resolveUrl } from "../../kernel/url.js";
|
|
6
6
|
//#region src/stages/thumbnails/index.ts
|