mattebox 0.10.0 → 0.12.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 +63 -27
- 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 +47 -6
- package/dist/es2015/kernel/prepare.js +2 -2
- package/dist/es2015/kernel/reducer.js +83 -26
- package/dist/es2015/kernel/refresh.js +2 -2
- package/dist/es2015/kernel/rendition-select.js +91 -16
- 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 +421 -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 +161 -39
- 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 +18 -7
- 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 +7 -5
- 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 +31 -7
- package/dist/es2015/stages/eme-fairplay/index.js +18 -9
- 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 +57 -6
- package/dist/es2015/stages/text-cea608/index.js +26 -93
- package/dist/es2015/stages/text-cea708/decode.js +379 -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 +62 -19
- 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 +47 -3
- package/dist/kernel/mse.js.map +1 -1
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +88 -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 +29 -1
- package/dist/kernel/rendition-select.d.ts.map +1 -1
- package/dist/kernel/rendition-select.js +99 -21
- 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 +430 -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 +208 -24
- 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 +24 -8
- package/dist/stages/abr/index.js.map +1 -1
- package/dist/stages/alt-audio/index.d.ts +3 -1
- package/dist/stages/alt-audio/index.d.ts.map +1 -1
- package/dist/stages/alt-audio/index.js +8 -5
- 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 +14 -0
- package/dist/stages/eme-core/index.d.ts.map +1 -1
- package/dist/stages/eme-core/index.js +38 -5
- package/dist/stages/eme-core/index.js.map +1 -1
- package/dist/stages/eme-fairplay/index.d.ts +5 -0
- package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
- package/dist/stages/eme-fairplay/index.js +17 -6
- package/dist/stages/eme-fairplay/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 +59 -6
- 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 +410 -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 +90 -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 +10 -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,379 @@
|
|
|
1
|
+
import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/defineProperty.js";
|
|
2
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/objectSpread2.js";
|
|
3
|
+
import { escapeCueText } from "../../containers/webvtt.js";
|
|
4
|
+
//#region src/stages/text-cea708/decode.ts
|
|
5
|
+
/**
|
|
6
|
+
* A CEA-708 caption decoder (CTA-708-E): DTVCC packets to cue text per
|
|
7
|
+
* window. The packet layer joins the cc_data pairs of cc_type 3 (packet
|
|
8
|
+
* start) and 2 (packet data); the service layer splits a packet into service
|
|
9
|
+
* blocks; each service keeps its eight windows, its current window and pen,
|
|
10
|
+
* and applies the C0, C1, G0, G1, G2, and G3 code sets. C2 and C3 carry no
|
|
11
|
+
* defined commands and are skipped by their length.
|
|
12
|
+
*
|
|
13
|
+
* Like the 608 decoder, it emits a cue only when a visible window's text or
|
|
14
|
+
* layout changes, never per character. A cue is complete once it closes, so
|
|
15
|
+
* `drain` returns closed cues.
|
|
16
|
+
*/
|
|
17
|
+
/** The widest row a 16:9 service may write (§8.4.10). */
|
|
18
|
+
const MAX_COLUMNS = 42;
|
|
19
|
+
/** G2 characters (§7.1.8); others are not defined and are skipped. */
|
|
20
|
+
const G2 = {
|
|
21
|
+
32: " ",
|
|
22
|
+
33: "\xA0",
|
|
23
|
+
37: "…",
|
|
24
|
+
42: "Š",
|
|
25
|
+
44: "Œ",
|
|
26
|
+
48: "█",
|
|
27
|
+
49: "‘",
|
|
28
|
+
50: "’",
|
|
29
|
+
51: "“",
|
|
30
|
+
52: "”",
|
|
31
|
+
53: "•",
|
|
32
|
+
57: "™",
|
|
33
|
+
58: "š",
|
|
34
|
+
60: "œ",
|
|
35
|
+
61: "℠",
|
|
36
|
+
63: "Ÿ",
|
|
37
|
+
118: "⅛",
|
|
38
|
+
119: "⅜",
|
|
39
|
+
120: "⅝",
|
|
40
|
+
121: "⅞",
|
|
41
|
+
122: "│",
|
|
42
|
+
123: "┐",
|
|
43
|
+
124: "└",
|
|
44
|
+
125: "─",
|
|
45
|
+
126: "┘",
|
|
46
|
+
127: "┌"
|
|
47
|
+
};
|
|
48
|
+
/** The predefined window styles that center their text (§8.4.11, styles 3 and 6). */
|
|
49
|
+
const CENTERED_STYLES = /* @__PURE__ */ new Set([3, 6]);
|
|
50
|
+
/** One row as cue text, with tags where the pen's italics or underline change. */
|
|
51
|
+
function rowText(row) {
|
|
52
|
+
let out = "";
|
|
53
|
+
let italic = false;
|
|
54
|
+
let underline = false;
|
|
55
|
+
const blank = (cell) => cell === void 0 || cell.char === " ";
|
|
56
|
+
let end = row.length;
|
|
57
|
+
while (end > 0 && blank(row[end - 1])) end -= 1;
|
|
58
|
+
let start = 0;
|
|
59
|
+
while (start < end && blank(row[start])) start += 1;
|
|
60
|
+
for (let i = start; i < end; i += 1) {
|
|
61
|
+
var _row$i;
|
|
62
|
+
const cell = (_row$i = row[i]) !== null && _row$i !== void 0 ? _row$i : {
|
|
63
|
+
char: " ",
|
|
64
|
+
italic: false,
|
|
65
|
+
underline: false
|
|
66
|
+
};
|
|
67
|
+
if (underline && !cell.underline) out += "</u>";
|
|
68
|
+
if (italic && !cell.italic) out += "</i>";
|
|
69
|
+
if (cell.italic && !italic) out += "<i>";
|
|
70
|
+
if (cell.underline && !underline) out += "<u>";
|
|
71
|
+
italic = cell.italic;
|
|
72
|
+
underline = cell.underline;
|
|
73
|
+
out += escapeCueText(cell.char);
|
|
74
|
+
}
|
|
75
|
+
if (underline) out += "</u>";
|
|
76
|
+
if (italic) out += "</i>";
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
function windowText(window) {
|
|
80
|
+
const lines = window.rows.map(rowText);
|
|
81
|
+
while (lines.length > 0 && lines[0] === "") lines.shift();
|
|
82
|
+
while (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
|
|
83
|
+
return lines.join("\n");
|
|
84
|
+
}
|
|
85
|
+
/** One caption service: its windows, the current window, and its cues. */
|
|
86
|
+
var Cea708Service = class {
|
|
87
|
+
constructor() {
|
|
88
|
+
_defineProperty(this, "windows", new Array(8).fill(null));
|
|
89
|
+
_defineProperty(this, "current", -1);
|
|
90
|
+
_defineProperty(this, "delayUntil", 0);
|
|
91
|
+
_defineProperty(this, "open", /* @__PURE__ */ new Map());
|
|
92
|
+
_defineProperty(this, "cues", []);
|
|
93
|
+
}
|
|
94
|
+
/** Decodes one service block received at `time`, in seconds. */
|
|
95
|
+
decode(block, time) {
|
|
96
|
+
if (time >= this.delayUntil) this.delayUntil = 0;
|
|
97
|
+
let i = 0;
|
|
98
|
+
while (i < block.length) {
|
|
99
|
+
const code = block[i];
|
|
100
|
+
const at = Math.max(time, this.delayUntil);
|
|
101
|
+
if (code === 16) i = this.extended(block, i + 1);
|
|
102
|
+
else if (code < 32) i += this.c0(code, at);
|
|
103
|
+
else if (code < 128) {
|
|
104
|
+
this.write(code === 127 ? "♪" : String.fromCharCode(code));
|
|
105
|
+
i += 1;
|
|
106
|
+
} else if (code < 160) i += this.c1(code, block, i, time);
|
|
107
|
+
else {
|
|
108
|
+
this.write(String.fromCharCode(code));
|
|
109
|
+
i += 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this.update(Math.max(time, this.delayUntil));
|
|
113
|
+
}
|
|
114
|
+
/** Closes the open cues at `time` and returns every closed cue. */
|
|
115
|
+
flush(time) {
|
|
116
|
+
for (const id of [...this.open.keys()]) this.close(id, time);
|
|
117
|
+
return this.drain();
|
|
118
|
+
}
|
|
119
|
+
/** Returns the cues closed since the last drain and forgets them. */
|
|
120
|
+
drain() {
|
|
121
|
+
const out = this.cues;
|
|
122
|
+
this.cues = [];
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
/** C0 (§7.1.4): the length of the code, after applying it. */
|
|
126
|
+
c0(code, time) {
|
|
127
|
+
var _this$windows$this$cu;
|
|
128
|
+
const window = (_this$windows$this$cu = this.windows[this.current]) !== null && _this$windows$this$cu !== void 0 ? _this$windows$this$cu : null;
|
|
129
|
+
if (window !== null) {
|
|
130
|
+
if (code === 8 && window.column > 0) {
|
|
131
|
+
window.column -= 1;
|
|
132
|
+
window.rows[window.row][window.column] = void 0;
|
|
133
|
+
} else if (code === 12) {
|
|
134
|
+
window.rows = window.rows.map(() => []);
|
|
135
|
+
window.row = 0;
|
|
136
|
+
window.column = 0;
|
|
137
|
+
} else if (code === 13) this.carriageReturn(window);
|
|
138
|
+
else if (code === 14) {
|
|
139
|
+
window.rows[window.row] = [];
|
|
140
|
+
window.column = 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (code === 3) this.update(time);
|
|
144
|
+
return code < 16 ? 1 : code < 24 ? 2 : 3;
|
|
145
|
+
}
|
|
146
|
+
/** A code after EXT1 (§7.1.7): C2, G2, C3, or G3. Returns the next offset. */
|
|
147
|
+
extended(block, i) {
|
|
148
|
+
const code = block[i];
|
|
149
|
+
if (code === void 0) return i;
|
|
150
|
+
if (code < 32) return i + 1 + (code < 8 ? 0 : code < 16 ? 1 : code < 24 ? 2 : 3);
|
|
151
|
+
if (code < 128) {
|
|
152
|
+
const char = G2[code];
|
|
153
|
+
if (char !== void 0) this.write(char);
|
|
154
|
+
return i + 1;
|
|
155
|
+
}
|
|
156
|
+
if (code < 160) {
|
|
157
|
+
var _block;
|
|
158
|
+
if (code < 136) return i + 5;
|
|
159
|
+
if (code < 144) return i + 6;
|
|
160
|
+
return i + 2 + (((_block = block[i + 1]) !== null && _block !== void 0 ? _block : 0) & 63);
|
|
161
|
+
}
|
|
162
|
+
this.write(code === 160 ? "[CC]" : "_");
|
|
163
|
+
return i + 1;
|
|
164
|
+
}
|
|
165
|
+
/** C1 (§7.1.5): window and pen commands. Returns the length of the command. */
|
|
166
|
+
c1(code, block, i, time) {
|
|
167
|
+
var _this$windows$this$cu2;
|
|
168
|
+
const arg = (n) => {
|
|
169
|
+
var _block2;
|
|
170
|
+
return (_block2 = block[i + n]) !== null && _block2 !== void 0 ? _block2 : 0;
|
|
171
|
+
};
|
|
172
|
+
if (code <= 135) {
|
|
173
|
+
if (this.windows[code - 128] !== null) this.current = code - 128;
|
|
174
|
+
return 1;
|
|
175
|
+
}
|
|
176
|
+
if (code <= 140) {
|
|
177
|
+
const bits = arg(1);
|
|
178
|
+
for (let id = 0; id < 8; id += 1) {
|
|
179
|
+
const window = this.windows[id];
|
|
180
|
+
if ((bits & 1 << id) === 0 || window === null || window === void 0) continue;
|
|
181
|
+
if (code === 136) window.rows = window.rows.map(() => []);
|
|
182
|
+
else if (code === 137) window.visible = true;
|
|
183
|
+
else if (code === 138) window.visible = false;
|
|
184
|
+
else if (code === 139) window.visible = !window.visible;
|
|
185
|
+
else {
|
|
186
|
+
this.windows[id] = null;
|
|
187
|
+
if (this.current === id) this.current = -1;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return 2;
|
|
191
|
+
}
|
|
192
|
+
if (code === 141) {
|
|
193
|
+
this.delayUntil = time + arg(1) / 10;
|
|
194
|
+
return 2;
|
|
195
|
+
}
|
|
196
|
+
if (code === 142) {
|
|
197
|
+
this.delayUntil = 0;
|
|
198
|
+
return 1;
|
|
199
|
+
}
|
|
200
|
+
if (code === 143) {
|
|
201
|
+
this.windows = new Array(8).fill(null);
|
|
202
|
+
this.current = -1;
|
|
203
|
+
this.delayUntil = 0;
|
|
204
|
+
return 1;
|
|
205
|
+
}
|
|
206
|
+
const window = (_this$windows$this$cu2 = this.windows[this.current]) !== null && _this$windows$this$cu2 !== void 0 ? _this$windows$this$cu2 : null;
|
|
207
|
+
if (code === 144) {
|
|
208
|
+
if (window !== null) {
|
|
209
|
+
window.italic = (arg(2) & 128) !== 0;
|
|
210
|
+
window.underline = (arg(2) & 64) !== 0;
|
|
211
|
+
}
|
|
212
|
+
return 3;
|
|
213
|
+
}
|
|
214
|
+
if (code === 145) return 4;
|
|
215
|
+
if (code === 146) {
|
|
216
|
+
if (window !== null) {
|
|
217
|
+
window.row = Math.min(arg(1) & 15, window.rows.length - 1);
|
|
218
|
+
window.column = Math.min(arg(2) & 63, 41);
|
|
219
|
+
}
|
|
220
|
+
return 3;
|
|
221
|
+
}
|
|
222
|
+
if (code <= 150) return 1;
|
|
223
|
+
if (code === 151) {
|
|
224
|
+
if (window !== null) window.layout = _objectSpread2(_objectSpread2({}, window.layout), {}, { justify: arg(3) & 3 });
|
|
225
|
+
return 5;
|
|
226
|
+
}
|
|
227
|
+
this.define(code - 152, block.subarray(i + 1, i + 7));
|
|
228
|
+
return 7;
|
|
229
|
+
}
|
|
230
|
+
/** DFn (§8.10.5.12): creates a window, or updates one and keeps its text. */
|
|
231
|
+
define(id, params) {
|
|
232
|
+
var _this$windows$id;
|
|
233
|
+
const p = (n) => {
|
|
234
|
+
var _params$n;
|
|
235
|
+
return (_params$n = params[n]) !== null && _params$n !== void 0 ? _params$n : 0;
|
|
236
|
+
};
|
|
237
|
+
const known = (_this$windows$id = this.windows[id]) !== null && _this$windows$id !== void 0 ? _this$windows$id : null;
|
|
238
|
+
const style = p(5) >> 3 & 7;
|
|
239
|
+
const rows = (p(3) & 15) + 1;
|
|
240
|
+
const layout = {
|
|
241
|
+
priority: p(0) & 7,
|
|
242
|
+
relative: (p(1) & 128) !== 0,
|
|
243
|
+
anchorVertical: p(1) & 127,
|
|
244
|
+
anchorHorizontal: p(2),
|
|
245
|
+
anchorPoint: p(3) >> 4,
|
|
246
|
+
rows,
|
|
247
|
+
columns: (p(4) & 63) + 1,
|
|
248
|
+
justify: style === 0 && known !== null ? known.layout.justify : CENTERED_STYLES.has(style) ? 2 : 0
|
|
249
|
+
};
|
|
250
|
+
const visible = (p(0) & 32) !== 0;
|
|
251
|
+
if (known === null) this.windows[id] = {
|
|
252
|
+
layout,
|
|
253
|
+
visible,
|
|
254
|
+
rows: Array.from({ length: rows }, () => []),
|
|
255
|
+
row: 0,
|
|
256
|
+
column: 0,
|
|
257
|
+
italic: false,
|
|
258
|
+
underline: false
|
|
259
|
+
};
|
|
260
|
+
else {
|
|
261
|
+
known.layout = layout;
|
|
262
|
+
known.visible = visible;
|
|
263
|
+
while (known.rows.length > rows) known.rows.shift();
|
|
264
|
+
while (known.rows.length < rows) known.rows.push([]);
|
|
265
|
+
known.row = Math.min(known.row, rows - 1);
|
|
266
|
+
}
|
|
267
|
+
this.current = id;
|
|
268
|
+
}
|
|
269
|
+
write(char) {
|
|
270
|
+
var _this$windows$this$cu3;
|
|
271
|
+
const window = (_this$windows$this$cu3 = this.windows[this.current]) !== null && _this$windows$this$cu3 !== void 0 ? _this$windows$this$cu3 : null;
|
|
272
|
+
if (window === null || window.column >= MAX_COLUMNS) return;
|
|
273
|
+
const row = window.rows[window.row];
|
|
274
|
+
row[window.column] = {
|
|
275
|
+
char,
|
|
276
|
+
italic: window.italic,
|
|
277
|
+
underline: window.underline
|
|
278
|
+
};
|
|
279
|
+
window.column += 1;
|
|
280
|
+
}
|
|
281
|
+
/** CR: the next row, scrolling the window up from its last one. */
|
|
282
|
+
carriageReturn(window) {
|
|
283
|
+
window.column = 0;
|
|
284
|
+
if (window.row + 1 < window.rows.length) {
|
|
285
|
+
window.row += 1;
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
window.rows.shift();
|
|
289
|
+
window.rows.push([]);
|
|
290
|
+
}
|
|
291
|
+
/** Closes and opens cues for every window whose shown text or layout changed. */
|
|
292
|
+
update(time) {
|
|
293
|
+
for (let id = 0; id < 8; id += 1) {
|
|
294
|
+
var _this$open$get$key, _this$open$get;
|
|
295
|
+
const window = this.windows[id];
|
|
296
|
+
const text = (window === null || window === void 0 ? void 0 : window.visible) === true ? windowText(window) : "";
|
|
297
|
+
const key = text === "" ? "" : `${text}|${JSON.stringify(window === null || window === void 0 ? void 0 : window.layout)}`;
|
|
298
|
+
if (key === ((_this$open$get$key = (_this$open$get = this.open.get(id)) === null || _this$open$get === void 0 ? void 0 : _this$open$get.key) !== null && _this$open$get$key !== void 0 ? _this$open$get$key : "")) continue;
|
|
299
|
+
this.close(id, time);
|
|
300
|
+
if (key !== "" && window !== null && window !== void 0) this.open.set(id, {
|
|
301
|
+
key,
|
|
302
|
+
text,
|
|
303
|
+
start: time,
|
|
304
|
+
layout: window.layout
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
close(id, time) {
|
|
309
|
+
const open = this.open.get(id);
|
|
310
|
+
if (open === void 0) return;
|
|
311
|
+
this.open.delete(id);
|
|
312
|
+
if (time > open.start) this.cues.push({
|
|
313
|
+
start: open.start,
|
|
314
|
+
end: time,
|
|
315
|
+
text: open.text,
|
|
316
|
+
window: id,
|
|
317
|
+
layout: open.layout
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* The DTVCC transport (§5, §6): cc_type 3 starts a packet whose first byte
|
|
323
|
+
* holds its sequence number and size, and cc_type 2 pairs continue it. A
|
|
324
|
+
* packet cut short by the next start is dropped. Each complete packet's
|
|
325
|
+
* service blocks go to their service.
|
|
326
|
+
*/
|
|
327
|
+
var Dtvcc = class {
|
|
328
|
+
constructor() {
|
|
329
|
+
_defineProperty(this, "packet", null);
|
|
330
|
+
_defineProperty(this, "size", 0);
|
|
331
|
+
_defineProperty(this, "services", /* @__PURE__ */ new Map());
|
|
332
|
+
}
|
|
333
|
+
push(type, a, b, time) {
|
|
334
|
+
if (type === 3) {
|
|
335
|
+
const sizeCode = a & 63;
|
|
336
|
+
this.size = (sizeCode === 0 ? 64 : sizeCode) * 2 - 1;
|
|
337
|
+
this.packet = [b];
|
|
338
|
+
} else if (type === 2 && this.packet !== null) this.packet.push(a, b);
|
|
339
|
+
else return;
|
|
340
|
+
if (this.packet.length >= this.size) {
|
|
341
|
+
this.blocks(Uint8Array.from(this.packet.slice(0, this.size)), time);
|
|
342
|
+
this.packet = null;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/** Every service's closed cues since the last drain, by service number. */
|
|
346
|
+
drain() {
|
|
347
|
+
const out = /* @__PURE__ */ new Map();
|
|
348
|
+
for (const [number, service] of this.services) {
|
|
349
|
+
const cues = service.drain();
|
|
350
|
+
if (cues.length > 0) out.set(number, cues);
|
|
351
|
+
}
|
|
352
|
+
return out;
|
|
353
|
+
}
|
|
354
|
+
/** Service blocks (§6.2): a header of service number and size, extended for services 7 to 63. */
|
|
355
|
+
blocks(data, time) {
|
|
356
|
+
let i = 0;
|
|
357
|
+
while (i < data.length) {
|
|
358
|
+
const header = data[i];
|
|
359
|
+
let service = header >> 5;
|
|
360
|
+
const size = header & 31;
|
|
361
|
+
i += 1;
|
|
362
|
+
if (service === 0 || size === 0) return;
|
|
363
|
+
if (service === 7) {
|
|
364
|
+
var _data$i;
|
|
365
|
+
service = ((_data$i = data[i]) !== null && _data$i !== void 0 ? _data$i : 0) & 63;
|
|
366
|
+
i += 1;
|
|
367
|
+
}
|
|
368
|
+
let decoder = this.services.get(service);
|
|
369
|
+
if (decoder === void 0) {
|
|
370
|
+
decoder = new Cea708Service();
|
|
371
|
+
this.services.set(service, decoder);
|
|
372
|
+
}
|
|
373
|
+
decoder.decode(data.subarray(i, i + size), time);
|
|
374
|
+
i += size;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
//#endregion
|
|
379
|
+
export { Cea708Service, Dtvcc };
|
|
@@ -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 };
|