codemirror-lang-liquidsoap 0.2.9 → 0.3.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.
Files changed (418) hide show
  1. package/dist/cli.js +2 -2
  2. package/dist/index.js +2 -2
  3. package/package.json +4 -3
  4. package/src/cli.ts +0 -0
  5. package/src/liquidsoap.grammar +1 -1
  6. package/src/parser.js +1 -1
  7. package/tests/liquidsoap/.github/alpine/APKBUILD-minimal.in +1 -1
  8. package/tests/liquidsoap/.github/alpine/APKBUILD.in +1 -1
  9. package/tests/liquidsoap/.github/alpine/liquidsoap.pre-install +0 -0
  10. package/tests/liquidsoap/.github/debian/rules +1 -1
  11. package/tests/liquidsoap/.github/debian/rules-minimal +1 -1
  12. package/tests/liquidsoap/.github/opam/liquidsoap-core-windows.opam +4 -3
  13. package/tests/liquidsoap/.github/opam/packages/ffmpeg-av-windows/ffmpeg-av-windows.1.2.0/opam +38 -0
  14. package/tests/liquidsoap/.github/opam/packages/ffmpeg-avcodec-windows/ffmpeg-avcodec-windows.1.2.0/opam +37 -0
  15. package/tests/liquidsoap/.github/opam/packages/ffmpeg-avdevice-windows/ffmpeg-avdevice-windows.1.2.0/opam +37 -0
  16. package/tests/liquidsoap/.github/opam/packages/ffmpeg-avfilter-windows/ffmpeg-avfilter-windows.1.2.0/opam +37 -0
  17. package/tests/liquidsoap/.github/opam/packages/ffmpeg-avutil-windows/ffmpeg-avutil-windows.1.2.0/opam +37 -0
  18. package/tests/liquidsoap/.github/opam/packages/ffmpeg-swresample-windows/ffmpeg-swresample-windows.1.2.0/opam +38 -0
  19. package/tests/liquidsoap/.github/opam/packages/ffmpeg-swscale-windows/ffmpeg-swscale-windows.1.2.0/opam +37 -0
  20. package/tests/liquidsoap/.github/opam/packages/ffmpeg-windows/ffmpeg-windows.1.2.0/opam +35 -0
  21. package/tests/liquidsoap/.github/scripts/add-local-opam-packages.sh +0 -0
  22. package/tests/liquidsoap/.github/scripts/build-apk.sh +0 -0
  23. package/tests/liquidsoap/.github/scripts/build-deb.sh +0 -0
  24. package/tests/liquidsoap/.github/scripts/build-details.sh +1 -1
  25. package/tests/liquidsoap/.github/scripts/build-doc.sh +0 -0
  26. package/tests/liquidsoap/.github/scripts/build-docker-alpine.sh +0 -0
  27. package/tests/liquidsoap/.github/scripts/build-docker.sh +0 -0
  28. package/tests/liquidsoap/.github/scripts/build-posix.sh +16 -13
  29. package/tests/liquidsoap/.github/scripts/build-website.sh +0 -0
  30. package/tests/liquidsoap/.github/scripts/build-win32.sh +0 -0
  31. package/tests/liquidsoap/.github/scripts/checkout-deps.sh +0 -0
  32. package/tests/liquidsoap/.github/scripts/export-metrics.sh +0 -0
  33. package/tests/liquidsoap/.github/scripts/push-docker.sh +0 -0
  34. package/tests/liquidsoap/.github/scripts/stats-posix.sh +0 -0
  35. package/tests/liquidsoap/.github/scripts/test-posix.sh +0 -0
  36. package/tests/liquidsoap/.github/workflows/ci.yml +10 -1
  37. package/tests/liquidsoap/.pre-commit-config.yaml +1 -1
  38. package/tests/liquidsoap/CHANGES.md +101 -1
  39. package/tests/liquidsoap/README.md +1 -1
  40. package/tests/liquidsoap/ROADMAP.md +28 -26
  41. package/tests/liquidsoap/doc/content/cookbook.md +46 -3
  42. package/tests/liquidsoap/doc/content/database.md +126 -0
  43. package/tests/liquidsoap/doc/content/documentation.md +1 -0
  44. package/tests/liquidsoap/doc/content/encoding_formats.md +6 -7
  45. package/tests/liquidsoap/doc/content/ffmpeg_encoder.md +20 -0
  46. package/tests/liquidsoap/doc/content/hls_output.md +27 -2
  47. package/tests/liquidsoap/doc/content/index.md +1 -1
  48. package/tests/liquidsoap/doc/content/liq/basic-radio.liq +14 -6
  49. package/tests/liquidsoap/doc/content/liq/check +0 -0
  50. package/tests/liquidsoap/doc/content/liq/liquidsoap +0 -0
  51. package/tests/liquidsoap/doc/content/liq/medialib.sqlite.liq +4 -0
  52. package/tests/liquidsoap/doc/content/liq/on2-if2.liq +5 -2
  53. package/tests/liquidsoap/doc/content/liq/on2-initial.liq +10 -5
  54. package/tests/liquidsoap/doc/content/liq/on2-replaygain.liq +13 -4
  55. package/tests/liquidsoap/doc/content/liq/on2-volume.liq +4 -2
  56. package/tests/liquidsoap/doc/content/liq/playlists.liq +2 -1
  57. package/tests/liquidsoap/doc/content/liq/radiopi.liq +2 -6
  58. package/tests/liquidsoap/doc/content/liq/source-cue.liq +26 -0
  59. package/tests/liquidsoap/doc/content/liq/space_overhead.liq +0 -0
  60. package/tests/liquidsoap/doc/content/liq/split-cue.liq +7 -8
  61. package/tests/liquidsoap/doc/content/liq/sqlite.liq +120 -0
  62. package/tests/liquidsoap/doc/content/liq/video-in-video.liq +2 -0
  63. package/tests/liquidsoap/doc/content/migrating.md +12 -0
  64. package/tests/liquidsoap/doc/content/on2_part2.md +1 -1
  65. package/tests/liquidsoap/doc/content/playlist_parsers.md +2 -10
  66. package/tests/liquidsoap/doc/content/seek.md +1 -20
  67. package/tests/liquidsoap/doc/dune.inc +655 -0
  68. package/tests/liquidsoap/dune-project +8 -5
  69. package/tests/liquidsoap/liquidsoap +0 -0
  70. package/tests/liquidsoap/liquidsoap-core.opam +6 -4
  71. package/tests/liquidsoap/src/core/builtins/builtins_ffmpeg_bitstream_filters.ml +100 -128
  72. package/tests/liquidsoap/src/core/builtins/builtins_ffmpeg_decoder.ml +10 -11
  73. package/tests/liquidsoap/src/core/builtins/builtins_ffmpeg_encoder.ml +14 -15
  74. package/tests/liquidsoap/src/core/builtins/builtins_ffmpeg_filters.ml +33 -3
  75. package/tests/liquidsoap/src/core/builtins/builtins_files.ml +64 -12
  76. package/tests/liquidsoap/src/core/builtins/builtins_optionals.ml +0 -1
  77. package/tests/liquidsoap/src/core/builtins/builtins_prometheus.ml +4 -4
  78. package/tests/liquidsoap/src/core/builtins/builtins_request.ml +16 -1
  79. package/tests/liquidsoap/src/core/builtins/builtins_resolvers.ml +1 -1
  80. package/tests/liquidsoap/src/core/builtins/builtins_settings.ml +12 -2
  81. package/tests/liquidsoap/src/core/builtins/builtins_socket.ml +17 -4
  82. package/tests/liquidsoap/src/core/builtins/builtins_source.ml +17 -7
  83. package/tests/liquidsoap/src/core/builtins/builtins_sqlite.ml +362 -0
  84. package/tests/liquidsoap/src/core/builtins/builtins_ssl.ml +18 -9
  85. package/tests/liquidsoap/src/core/builtins/builtins_tls.ml +38 -27
  86. package/tests/liquidsoap/src/core/clock.ml +1 -1
  87. package/tests/liquidsoap/src/core/clock.mli +1 -1
  88. package/tests/liquidsoap/src/core/conversions/conversion.ml +4 -38
  89. package/tests/liquidsoap/src/core/conversions/mean.ml +12 -14
  90. package/tests/liquidsoap/src/core/conversions/stereo.ml +4 -4
  91. package/tests/liquidsoap/src/core/conversions/swap.ml +8 -23
  92. package/tests/liquidsoap/src/core/decoder/aac_decoder.ml +3 -3
  93. package/tests/liquidsoap/src/core/decoder/decoder.ml +134 -129
  94. package/tests/liquidsoap/src/core/decoder/decoder.mli +11 -4
  95. package/tests/liquidsoap/src/core/decoder/decoder_utils.ml +8 -9
  96. package/tests/liquidsoap/src/core/decoder/decoder_utils.mli +2 -2
  97. package/tests/liquidsoap/src/core/decoder/external_decoder.ml +7 -5
  98. package/tests/liquidsoap/src/core/decoder/ffmpeg_copy_decoder.ml +1 -1
  99. package/tests/liquidsoap/src/core/decoder/ffmpeg_decoder.ml +138 -60
  100. package/tests/liquidsoap/src/core/decoder/ffmpeg_decoder_common.ml +10 -0
  101. package/tests/liquidsoap/src/core/decoder/ffmpeg_internal_decoder.ml +1 -2
  102. package/tests/liquidsoap/src/core/decoder/ffmpeg_raw_decoder.ml +1 -1
  103. package/tests/liquidsoap/src/core/decoder/flac_metadata_plug.ml +3 -3
  104. package/tests/liquidsoap/src/core/decoder/gstreamer_decoder.ml +1 -2
  105. package/tests/liquidsoap/src/core/decoder/id3_plug.ml +3 -3
  106. package/tests/liquidsoap/src/core/decoder/image/sdlimage_decoder.ml +3 -3
  107. package/tests/liquidsoap/src/core/decoder/image_decoder.ml +25 -23
  108. package/tests/liquidsoap/src/core/decoder/image_plug.ml +3 -3
  109. package/tests/liquidsoap/src/core/decoder/liq_flac_decoder.ml +10 -11
  110. package/tests/liquidsoap/src/core/decoder/liq_ogg_decoder.ml +5 -5
  111. package/tests/liquidsoap/src/core/decoder/mad_decoder.ml +6 -7
  112. package/tests/liquidsoap/src/core/decoder/midi_decoder.ml +10 -10
  113. package/tests/liquidsoap/src/core/decoder/ogg_metadata_plug.ml +3 -3
  114. package/tests/liquidsoap/src/core/decoder/srt_decoder.ml +23 -15
  115. package/tests/liquidsoap/src/core/decoder/taglib_plug.ml +3 -3
  116. package/tests/liquidsoap/src/core/decoder/text/video_text_sdl.ml +12 -7
  117. package/tests/liquidsoap/src/core/decoder/video_plug.ml +3 -3
  118. package/tests/liquidsoap/src/core/dune +19 -22
  119. package/tests/liquidsoap/src/core/encoder/encoder.ml +1 -1
  120. package/tests/liquidsoap/src/core/encoder/encoder.mli +1 -1
  121. package/tests/liquidsoap/src/core/encoder/encoder_formats.ml +6 -0
  122. package/tests/liquidsoap/src/core/encoder/encoder_utils.ml +66 -0
  123. package/tests/liquidsoap/src/core/encoder/encoders/avi_encoder.ml +38 -39
  124. package/tests/liquidsoap/src/core/encoder/encoders/fdkaac_encoder.ml +1 -1
  125. package/tests/liquidsoap/src/core/encoder/encoders/ffmpeg_copy_encoder.ml +26 -24
  126. package/tests/liquidsoap/src/core/encoder/encoders/ffmpeg_encoder.ml +24 -6
  127. package/tests/liquidsoap/src/core/encoder/encoders/ffmpeg_encoder_common.ml +52 -45
  128. package/tests/liquidsoap/src/core/encoder/encoders/ffmpeg_internal_encoder.ml +55 -34
  129. package/tests/liquidsoap/src/core/encoder/encoders/gstreamer_encoder.ml +27 -22
  130. package/tests/liquidsoap/src/core/encoder/encoders/lame_encoder.ml +5 -4
  131. package/tests/liquidsoap/src/core/encoder/encoders/ogg_encoder.ml +14 -7
  132. package/tests/liquidsoap/src/core/encoder/encoders/shine_encoder.ml +4 -5
  133. package/tests/liquidsoap/src/core/encoder/formats/ffmpeg_format.ml +9 -0
  134. package/tests/liquidsoap/src/core/encoder/lang/lang_ffmpeg.ml +13 -10
  135. package/tests/liquidsoap/src/core/encoder/lang_encoder.ml +1 -1
  136. package/tests/liquidsoap/src/core/harbor/harbor.ml +7 -2
  137. package/tests/liquidsoap/src/core/harbor/harbor_base.ml +7 -3
  138. package/tests/liquidsoap/src/core/io/alsa_io.ml +8 -5
  139. package/tests/liquidsoap/src/core/io/ffmpeg_filter_io.ml +9 -14
  140. package/tests/liquidsoap/src/core/io/ffmpeg_io.ml +23 -24
  141. package/tests/liquidsoap/src/core/io/gstreamer_io.ml +24 -20
  142. package/tests/liquidsoap/src/core/io/oss_io.ml +7 -5
  143. package/tests/liquidsoap/src/core/io/portaudio_io.ml +7 -5
  144. package/tests/liquidsoap/src/core/io/pulseaudio_io.ml +8 -7
  145. package/tests/liquidsoap/src/core/io/srt_io.ml +115 -114
  146. package/tests/liquidsoap/src/core/io/udp_io.ml +6 -3
  147. package/tests/liquidsoap/src/core/lang.mli +3 -0
  148. package/tests/liquidsoap/src/core/lang_source.ml +23 -9
  149. package/tests/liquidsoap/src/core/ogg_formats/opus_encoder.ml +1 -1
  150. package/tests/liquidsoap/src/core/operators/accelerate.ml +10 -23
  151. package/tests/liquidsoap/src/core/operators/add.ml +131 -122
  152. package/tests/liquidsoap/src/core/operators/amplify.ml +36 -27
  153. package/tests/liquidsoap/src/core/operators/available.ml +20 -8
  154. package/tests/liquidsoap/src/core/operators/biquad_filter.ml +8 -8
  155. package/tests/liquidsoap/src/core/operators/chord.ml +7 -9
  156. package/tests/liquidsoap/src/core/operators/clip.ml +7 -7
  157. package/tests/liquidsoap/src/core/operators/comb.ml +7 -8
  158. package/tests/liquidsoap/src/core/operators/compand.ml +9 -9
  159. package/tests/liquidsoap/src/core/operators/compress.ml +15 -10
  160. package/tests/liquidsoap/src/core/operators/compress_exp.ml +8 -9
  161. package/tests/liquidsoap/src/core/operators/cross.ml +180 -247
  162. package/tests/liquidsoap/src/core/operators/defer.ml +8 -18
  163. package/tests/liquidsoap/src/core/operators/delay.ml +10 -18
  164. package/tests/liquidsoap/src/core/operators/delay_line.ml +9 -8
  165. package/tests/liquidsoap/src/core/operators/dtmf.ml +18 -16
  166. package/tests/liquidsoap/src/core/operators/dyn_op.ml +66 -63
  167. package/tests/liquidsoap/src/core/operators/echo.ml +8 -7
  168. package/tests/liquidsoap/src/core/operators/filter.ml +8 -8
  169. package/tests/liquidsoap/src/core/operators/filter_rc.ml +11 -10
  170. package/tests/liquidsoap/src/core/operators/fir_filter.ml +8 -7
  171. package/tests/liquidsoap/src/core/operators/flanger.ml +9 -8
  172. package/tests/liquidsoap/src/core/operators/frei0r_op.ml +113 -91
  173. package/tests/liquidsoap/src/core/operators/gate.ml +9 -8
  174. package/tests/liquidsoap/src/core/operators/iir_filter.ml +7 -7
  175. package/tests/liquidsoap/src/core/operators/insert_metadata.ml +29 -54
  176. package/tests/liquidsoap/src/core/operators/ladspa_op.ml +38 -36
  177. package/tests/liquidsoap/src/core/operators/lilv_op.ml +44 -44
  178. package/tests/liquidsoap/src/core/operators/lufs.ml +8 -8
  179. package/tests/liquidsoap/src/core/operators/map_metadata.ml +23 -20
  180. package/tests/liquidsoap/src/core/operators/map_op.ml +6 -7
  181. package/tests/liquidsoap/src/core/operators/max_duration.ml +21 -20
  182. package/tests/liquidsoap/src/core/operators/midi_routing.ml +13 -9
  183. package/tests/liquidsoap/src/core/operators/ms_stereo.ml +13 -15
  184. package/tests/liquidsoap/src/core/operators/muxer.ml +30 -101
  185. package/tests/liquidsoap/src/core/operators/noblank.ml +26 -48
  186. package/tests/liquidsoap/src/core/operators/normalize.ml +13 -9
  187. package/tests/liquidsoap/src/core/operators/on_end.ml +25 -12
  188. package/tests/liquidsoap/src/core/operators/on_frame.ml +9 -9
  189. package/tests/liquidsoap/src/core/operators/on_metadata.ml +9 -10
  190. package/tests/liquidsoap/src/core/operators/on_offset.ml +20 -13
  191. package/tests/liquidsoap/src/core/operators/on_track.ml +7 -10
  192. package/tests/liquidsoap/src/core/operators/pan.ml +7 -8
  193. package/tests/liquidsoap/src/core/operators/pipe.ml +14 -17
  194. package/tests/liquidsoap/src/core/operators/pitch.ml +7 -5
  195. package/tests/liquidsoap/src/core/operators/replaygain_op.ml +6 -6
  196. package/tests/liquidsoap/src/core/operators/resample.ml +7 -6
  197. package/tests/liquidsoap/src/core/operators/rms_smooth.ml +8 -8
  198. package/tests/liquidsoap/src/core/operators/sequence.ml +48 -58
  199. package/tests/liquidsoap/src/core/operators/soundtouch_op.ml +12 -12
  200. package/tests/liquidsoap/src/core/operators/st_bpm.ml +8 -7
  201. package/tests/liquidsoap/src/core/operators/stereotool_op.ml +5 -7
  202. package/tests/liquidsoap/src/core/operators/still_frame.ml +13 -10
  203. package/tests/liquidsoap/src/core/operators/switch.ml +128 -168
  204. package/tests/liquidsoap/src/core/operators/time_warp.ml +44 -103
  205. package/tests/liquidsoap/src/core/operators/track/merge_metadata.ml +31 -48
  206. package/tests/liquidsoap/src/core/operators/track_map.ml +6 -32
  207. package/tests/liquidsoap/src/core/operators/video_effects.ml +48 -13
  208. package/tests/liquidsoap/src/core/operators/video_fade.ml +69 -57
  209. package/tests/liquidsoap/src/core/operators/window_op.ml +8 -8
  210. package/tests/liquidsoap/src/core/outputs/graphics_out.ml +11 -8
  211. package/tests/liquidsoap/src/core/outputs/harbor_output.ml +3 -3
  212. package/tests/liquidsoap/src/core/outputs/hls_output.ml +203 -116
  213. package/tests/liquidsoap/src/core/outputs/icecast2.ml +31 -5
  214. package/tests/liquidsoap/src/core/outputs/output.ml +27 -31
  215. package/tests/liquidsoap/src/core/outputs/output.mli +4 -5
  216. package/tests/liquidsoap/src/core/outputs/pipe_output.ml +19 -8
  217. package/tests/liquidsoap/src/core/outputs/sdl_out.ml +12 -9
  218. package/tests/liquidsoap/src/core/playlist_parser.ml +2 -6
  219. package/tests/liquidsoap/src/core/request.ml +84 -36
  220. package/tests/liquidsoap/src/core/request.mli +11 -8
  221. package/tests/liquidsoap/src/core/source.ml +343 -181
  222. package/tests/liquidsoap/src/core/source.mli +147 -33
  223. package/tests/liquidsoap/src/core/sources/alsa_in.ml +4 -6
  224. package/tests/liquidsoap/src/core/sources/audio_gen.ml +23 -22
  225. package/tests/liquidsoap/src/core/sources/bjack_in.ml +7 -5
  226. package/tests/liquidsoap/src/core/sources/blank.ml +55 -36
  227. package/tests/liquidsoap/src/core/sources/debug_sources.ml +2 -2
  228. package/tests/liquidsoap/src/core/sources/external_input_video.ml +2 -3
  229. package/tests/liquidsoap/src/core/sources/generated.ml +25 -47
  230. package/tests/liquidsoap/src/core/sources/harbor_input.ml +7 -9
  231. package/tests/liquidsoap/src/core/sources/latest_metadata.ml +1 -2
  232. package/tests/liquidsoap/src/core/sources/noise.ml +38 -27
  233. package/tests/liquidsoap/src/core/sources/request_dynamic.ml +181 -198
  234. package/tests/liquidsoap/src/core/sources/synthesized.ml +36 -23
  235. package/tests/liquidsoap/src/core/sources/video_board.ml +8 -10
  236. package/tests/liquidsoap/src/core/sources/video_testsrc.ml +9 -11
  237. package/tests/liquidsoap/src/core/sources/video_text.ml +8 -11
  238. package/tests/liquidsoap/src/core/stream/aFrame.ml +0 -32
  239. package/tests/liquidsoap/src/core/stream/aFrame.mli +2 -46
  240. package/tests/liquidsoap/src/core/stream/content.ml +96 -11
  241. package/tests/liquidsoap/src/core/stream/content.mli +32 -22
  242. package/tests/liquidsoap/src/core/stream/content_audio.ml +8 -4
  243. package/tests/liquidsoap/src/core/stream/content_base.ml +24 -35
  244. package/tests/liquidsoap/src/core/stream/content_midi.ml +0 -1
  245. package/tests/liquidsoap/src/core/stream/content_pcm_base.ml +0 -1
  246. package/tests/liquidsoap/src/core/stream/content_timed.ml +15 -1
  247. package/tests/liquidsoap/src/core/stream/content_video.ml +91 -30
  248. package/tests/liquidsoap/src/core/stream/ffmpeg_content_base.ml +0 -49
  249. package/tests/liquidsoap/src/core/stream/ffmpeg_copy_content.ml +2 -1
  250. package/tests/liquidsoap/src/core/stream/ffmpeg_raw_content.ml +2 -1
  251. package/tests/liquidsoap/src/core/stream/frame.ml +67 -118
  252. package/tests/liquidsoap/src/core/stream/frame.mli +49 -43
  253. package/tests/liquidsoap/src/core/stream/frame_base.ml +20 -32
  254. package/tests/liquidsoap/src/core/stream/frame_settings.ml +13 -36
  255. package/tests/liquidsoap/src/core/stream/generator.ml +47 -140
  256. package/tests/liquidsoap/src/core/stream/generator.mli +6 -13
  257. package/tests/liquidsoap/src/core/stream/mFrame.ml +0 -12
  258. package/tests/liquidsoap/src/core/stream/mFrame.mli +0 -19
  259. package/tests/liquidsoap/src/core/stream/metadata_base.ml +75 -0
  260. package/tests/liquidsoap/src/core/stream/vFrame.ml +0 -16
  261. package/tests/liquidsoap/src/core/stream/vFrame.mli +1 -35
  262. package/tests/liquidsoap/src/core/synth/dssi_op.ml +19 -20
  263. package/tests/liquidsoap/src/core/synth/keyboard.ml +6 -10
  264. package/tests/liquidsoap/src/core/synth/keyboard_sdl.ml +5 -11
  265. package/tests/liquidsoap/src/core/synth/synth_op.ml +11 -10
  266. package/tests/liquidsoap/src/core/tools/http.ml +40 -6
  267. package/tests/liquidsoap/src/core/tools/http.mli +21 -3
  268. package/tests/liquidsoap/src/core/tools/liq_posix_time.ml +3 -1
  269. package/tests/liquidsoap/src/core/tools/producer_consumer.ml +7 -18
  270. package/tests/liquidsoap/src/core/tools/server.ml +1 -1
  271. package/tests/liquidsoap/src/core/tools/server_builtins.ml +1 -1
  272. package/tests/liquidsoap/src/core/tools/start_stop.ml +2 -6
  273. package/tests/liquidsoap/src/core/tools/tutils.ml +1 -1
  274. package/tests/liquidsoap/src/core/track.ml +1 -2
  275. package/tests/liquidsoap/src/core/visualization/midimeter.ml +7 -5
  276. package/tests/liquidsoap/src/core/visualization/video_volume.ml +55 -68
  277. package/tests/liquidsoap/src/core/visualization/vis_volume.ml +1 -1
  278. package/tests/liquidsoap/src/js/index.html +4 -4
  279. package/tests/liquidsoap/src/{core/builtins/builtins_magic.ml → lang/active_value.ml} +16 -12
  280. package/tests/liquidsoap/src/lang/active_value.mli +33 -0
  281. package/tests/liquidsoap/src/lang/builtins_math.ml +7 -6
  282. package/tests/liquidsoap/src/lang/dune +1 -0
  283. package/tests/liquidsoap/src/lang/environment.ml +3 -1
  284. package/tests/liquidsoap/src/lang/evaluation.ml +13 -2
  285. package/tests/liquidsoap/src/lang/lang.mli +3 -0
  286. package/tests/liquidsoap/src/lang/lang_core.ml +13 -6
  287. package/tests/liquidsoap/src/lang/lexer.ml +2 -0
  288. package/tests/liquidsoap/src/lang/methods.ml +1 -0
  289. package/tests/liquidsoap/src/lang/methods.mli +1 -0
  290. package/tests/liquidsoap/src/lang/modules.ml +1 -0
  291. package/tests/liquidsoap/src/lang/parser_helper.ml +10 -1
  292. package/tests/liquidsoap/src/lang/parser_helper.mli +8 -1
  293. package/tests/liquidsoap/src/lang/term/parsed_term.ml +2 -0
  294. package/tests/liquidsoap/src/lang/term/runtime_term.ml +6 -1
  295. package/tests/liquidsoap/src/lang/term/term_base.ml +128 -74
  296. package/tests/liquidsoap/src/lang/term/term_reducer.ml +69 -3
  297. package/tests/liquidsoap/src/lang/term.ml +0 -47
  298. package/tests/liquidsoap/src/lang/type.ml +17 -1
  299. package/tests/liquidsoap/src/lang/type.mli +1 -0
  300. package/tests/liquidsoap/src/lang/types/type_base.ml +1 -1
  301. package/tests/liquidsoap/src/lang/utils.ml +1 -0
  302. package/tests/liquidsoap/src/lang/value.ml +16 -2
  303. package/tests/liquidsoap/src/libs/error.liq +16 -0
  304. package/tests/liquidsoap/src/libs/extra/deprecations.liq +18 -0
  305. package/tests/liquidsoap/src/libs/extra/metadata.liq +101 -0
  306. package/tests/liquidsoap/src/libs/extra/openai.liq +152 -0
  307. package/tests/liquidsoap/src/libs/extra/server.liq +39 -25
  308. package/tests/liquidsoap/src/libs/extra/source.liq +188 -0
  309. package/tests/liquidsoap/src/libs/fades.liq +92 -46
  310. package/tests/liquidsoap/src/libs/file.liq +71 -5
  311. package/tests/liquidsoap/src/libs/medialib.liq +384 -2
  312. package/tests/liquidsoap/src/libs/metadata.liq +1 -9
  313. package/tests/liquidsoap/src/libs/playlist.liq +224 -141
  314. package/tests/liquidsoap/src/libs/request.liq +112 -84
  315. package/tests/liquidsoap/src/libs/server.liq +12 -0
  316. package/tests/liquidsoap/src/libs/source.liq +24 -3
  317. package/tests/liquidsoap/src/libs/sqlite.liq +164 -0
  318. package/tests/liquidsoap/src/libs/stdlib.liq +4 -0
  319. package/tests/liquidsoap/src/libs/string.liq +35 -1
  320. package/tests/liquidsoap/src/libs/utils.liq +8 -0
  321. package/tests/liquidsoap/src/libs/video.liq +2 -1
  322. package/tests/liquidsoap/src/runtime/build_config.ml +1 -1
  323. package/tests/liquidsoap/src/runtime/main.ml +1 -1
  324. package/tests/liquidsoap/src/tooling/parsed_json.ml +4 -0
  325. package/tests/liquidsoap/tests/core/content_test.ml +32 -20
  326. package/tests/liquidsoap/tests/core/decoder_test.ml +4 -4
  327. package/tests/liquidsoap/tests/core/ffmpeg_quality.ml +2 -0
  328. package/tests/liquidsoap/tests/core/frame_test.ml +0 -35
  329. package/tests/liquidsoap/tests/core/generator_test.ml +4 -4
  330. package/tests/liquidsoap/tests/core/more_types.ml +2 -0
  331. package/tests/liquidsoap/tests/core/output_encoded_test.ml +7 -5
  332. package/tests/liquidsoap/tests/core/output_test.ml +6 -11
  333. package/tests/liquidsoap/tests/core/stream_decoder_test.ml +3 -4
  334. package/tests/liquidsoap/tests/failures/ctype.liq +0 -0
  335. package/tests/liquidsoap/tests/failures/error.liq +0 -0
  336. package/tests/liquidsoap/tests/failures/record-invalid-member1.liq +0 -0
  337. package/tests/liquidsoap/tests/failures/record-invalid-member2.liq +0 -0
  338. package/tests/liquidsoap/tests/failures/ref.liq +0 -0
  339. package/tests/liquidsoap/tests/fixme/GH1170.liq +0 -0
  340. package/tests/liquidsoap/tests/fixme/cross2.liq +0 -0
  341. package/tests/liquidsoap/tests/fixme/cross3.liq +0 -0
  342. package/tests/liquidsoap/tests/fixme/sequence-1.liq +0 -0
  343. package/tests/liquidsoap/tests/language/bool.liq +1 -12
  344. package/tests/liquidsoap/tests/language/dune.inc +12 -0
  345. package/tests/liquidsoap/tests/language/file.liq +7 -2
  346. package/tests/liquidsoap/tests/language/functions.liq +2 -13
  347. package/tests/liquidsoap/tests/language/interactive.liq +5 -16
  348. package/tests/liquidsoap/tests/language/list.liq +73 -78
  349. package/tests/liquidsoap/tests/language/loop.liq +6 -18
  350. package/tests/liquidsoap/tests/language/mem_usage.liq +0 -1
  351. package/tests/liquidsoap/tests/language/metadata.liq +9 -13
  352. package/tests/liquidsoap/tests/language/null.liq +8 -12
  353. package/tests/liquidsoap/tests/language/number.liq +10 -0
  354. package/tests/liquidsoap/tests/language/pp.liq +8 -20
  355. package/tests/liquidsoap/tests/language/predicate.liq +6 -18
  356. package/tests/liquidsoap/tests/language/ref.liq +3 -15
  357. package/tests/liquidsoap/tests/language/regexp.liq +14 -25
  358. package/tests/liquidsoap/tests/language/sqlite.liq +96 -0
  359. package/tests/liquidsoap/tests/language/stdlib.liq +7 -20
  360. package/tests/liquidsoap/tests/language/string.liq +7 -0
  361. package/tests/liquidsoap/tests/media/dune.inc +39 -0
  362. package/tests/liquidsoap/tests/media/encoder_audio_only.liq.in +1 -1
  363. package/tests/liquidsoap/tests/media/encoder_audio_video.liq.in +1 -1
  364. package/tests/liquidsoap/tests/media/encoder_multitrack.liq.in +1 -1
  365. package/tests/liquidsoap/tests/media/encoder_video_only.liq.in +1 -1
  366. package/tests/liquidsoap/tests/media/ffmpeg_bitstream_filter.liq +94 -0
  367. package/tests/liquidsoap/tests/media/ffmpeg_complex_filter.liq +1 -1
  368. package/tests/liquidsoap/tests/media/ffmpeg_filter.liq +3 -9
  369. package/tests/liquidsoap/tests/media/ffmpeg_raw_hls.liq +15 -12
  370. package/tests/liquidsoap/tests/media/ffmpeg_transparency_filter.liq +3 -9
  371. package/tests/liquidsoap/tests/media/gen_dune.ml +1 -0
  372. package/tests/liquidsoap/tests/media/mk_encoder_test.sh +0 -0
  373. package/tests/liquidsoap/tests/media/mk_stream_test.sh +0 -0
  374. package/tests/liquidsoap/tests/media/multitrack.liq +21 -1
  375. package/tests/liquidsoap/tests/media/stream_audio.liq.in +0 -0
  376. package/tests/liquidsoap/tests/media/stream_video.liq.in +0 -0
  377. package/tests/liquidsoap/tests/performance/erathostenes.liq +0 -0
  378. package/tests/liquidsoap/tests/performance/memory.liq +0 -0
  379. package/tests/liquidsoap/tests/performance/small-record.liq +0 -0
  380. package/tests/liquidsoap/tests/regression/GH1327.liq +8 -0
  381. package/tests/liquidsoap/tests/regression/GH3316.liq +2 -0
  382. package/tests/liquidsoap/tests/regression/GH3645.liq +16 -0
  383. package/tests/liquidsoap/tests/regression/GH3675.liq +37 -0
  384. package/tests/liquidsoap/tests/regression/LS354-2.liq +11 -3
  385. package/tests/liquidsoap/tests/regression/dune.inc +45 -14
  386. package/tests/liquidsoap/tests/regression/track_sensitive.liq +17 -0
  387. package/tests/liquidsoap/tests/regression/unified-pcm-types.aac +0 -0
  388. package/tests/liquidsoap/tests/regression/unified-pcm-types.liq +3 -0
  389. package/tests/liquidsoap/tests/run_test.ml +7 -3
  390. package/tests/liquidsoap/tests/streams/195.liq +4 -1
  391. package/tests/liquidsoap/tests/streams/cross-override.liq +12 -4
  392. package/tests/liquidsoap/tests/streams/cross-persist-override.liq +12 -4
  393. package/tests/liquidsoap/tests/streams/cross.liq +1 -1
  394. package/tests/liquidsoap/tests/streams/crossfade.liq +11 -24
  395. package/tests/liquidsoap/tests/streams/cue-cut.liq +16 -0
  396. package/tests/liquidsoap/tests/streams/dtmf.liq +3 -0
  397. package/tests/liquidsoap/tests/streams/dtmf_pcm_s16.liq +4 -0
  398. package/tests/liquidsoap/tests/streams/dune.inc +145 -0
  399. package/tests/liquidsoap/tests/streams/fades-persistent-override.liq +7 -2
  400. package/tests/liquidsoap/tests/streams/hls_discontinuity.liq +68 -0
  401. package/tests/liquidsoap/tests/streams/hls_id3v2.liq +76 -4
  402. package/tests/liquidsoap/tests/streams/hls_large_frame.liq +31 -0
  403. package/tests/liquidsoap/tests/streams/merge_metadata.liq +2 -4
  404. package/tests/liquidsoap/tests/streams/no-cue-cut.liq +22 -0
  405. package/tests/liquidsoap/tests/streams/random.liq +4 -4
  406. package/tests/liquidsoap/tests/streams/rotate.liq +44 -21
  407. package/tests/liquidsoap/tests/streams/sharing.liq +5 -0
  408. package/tests/liquidsoap/tests/streams/source-cue.liq +134 -0
  409. package/tests/liquidsoap/tests/streams/srt_raw_pcm.liq +5 -0
  410. package/tests/liquidsoap/tests/test.liq +1 -2
  411. package/tests/run.sh +0 -0
  412. package/tests/liquidsoap/.github/opam/packages/duppy/duppy.0.9.3/opam +0 -37
  413. package/tests/liquidsoap/.github/opam/packages/ssl/ssl.0.7.0/opam +0 -40
  414. package/tests/liquidsoap/src/core/liqmagic.disabled.ml +0 -2
  415. package/tests/liquidsoap/src/core/liqmagic.enabled.ml +0 -3
  416. package/tests/liquidsoap/src/core/liqmagic.mli +0 -4
  417. package/tests/liquidsoap/src/core/operators/cuepoint.ml +0 -216
  418. package/tests/liquidsoap/tests/regression/GH3121.liq +0 -16
@@ -22,78 +22,6 @@
22
22
 
23
23
  open Mm
24
24
 
25
- module MG = struct
26
- type t = {
27
- mutable metadata : (int * Frame.metadata) list;
28
- mutable breaks : int list;
29
- mutable length : int;
30
- }
31
-
32
- let create () = { metadata = []; breaks = []; length = 0 }
33
-
34
- let clear g =
35
- g.metadata <- [];
36
- g.breaks <- [];
37
- g.length <- 0
38
-
39
- let advance g len =
40
- g.metadata <- List.map (fun (t, m) -> (t - len, m)) g.metadata;
41
- g.metadata <- List.filter (fun (t, _) -> t >= 0) g.metadata;
42
- g.breaks <- List.map (fun t -> t - len) g.breaks;
43
- g.breaks <- List.filter (fun t -> t >= 0) g.breaks;
44
- g.length <- g.length - len;
45
- assert (g.length >= 0)
46
-
47
- let length g = g.length
48
- let remaining g = match g.breaks with a :: _ -> a | _ -> -1
49
- let metadata g len = List.filter (fun (t, _) -> t < len) g.metadata
50
-
51
- let feed_from_frame g frame =
52
- let size = Lazy.force Frame.size in
53
- let length = length g in
54
- g.metadata <-
55
- g.metadata
56
- @ List.map (fun (t, m) -> (length + t, m)) (Frame.get_all_metadata frame);
57
- g.breaks <-
58
- g.breaks
59
- @ List.map
60
- (fun t -> length + t)
61
- (* Filter out the last break, which only marks the end of frame, not a
62
- * track limit (doesn't mean is_partial). *)
63
- (List.filter (fun x -> x < size) (Frame.breaks frame));
64
- let frame_length =
65
- let rec aux = function [t] -> t | _ :: tl -> aux tl | [] -> size in
66
- aux (Frame.breaks frame)
67
- in
68
- g.length <- g.length + frame_length
69
-
70
- let drop_initial_break g =
71
- match g.breaks with
72
- | 0 :: tl -> g.breaks <- tl
73
- | [] -> () (* end of stream / underrun... *)
74
- | _ -> assert false
75
-
76
- let fill g frame =
77
- let offset = Frame.position frame in
78
- let needed =
79
- let size = Lazy.force Frame.size in
80
- let remaining = remaining g in
81
- let remaining = if remaining = -1 then length g else remaining in
82
- min (size - offset) remaining
83
- in
84
- List.iter
85
- (fun (p, m) -> if p < needed then Frame.set_metadata frame (offset + p) m)
86
- g.metadata;
87
- advance g needed;
88
-
89
- (* Mark the end of this filling. If the frame is partial it must be because
90
- * of a break in the generator, or because the generator is emptying.
91
- * Conversely, each break in the generator must cause a partial frame, so
92
- * don't remove any if it isn't partial. *)
93
- Frame.add_break frame (offset + needed);
94
- if Frame.is_partial frame then drop_initial_break g
95
- end
96
-
97
25
  (** Create a buffer between two clocks.
98
26
  *
99
27
  * This creates an active operator in the inner clock (the action consists
@@ -127,8 +55,7 @@ module Buffer = struct
127
55
  method remaining =
128
56
  proceed c (fun () -> Generator.remaining (Lazy.force c.generator))
129
57
 
130
- method private _is_ready ?frame:_ _ =
131
- proceed c (fun () -> not c.buffering)
58
+ method private can_generate_frame = proceed c (fun () -> not c.buffering)
132
59
 
133
60
  method! seek len =
134
61
  let len = min (Generator.length (Lazy.force c.generator)) len in
@@ -138,16 +65,19 @@ module Buffer = struct
138
65
  method seek_source = (self :> Source.source)
139
66
  method buffer_length = Generator.length (Lazy.force c.generator)
140
67
 
141
- method private get_frame frame =
68
+ method private generate_frame =
142
69
  proceed c (fun () ->
143
70
  assert (not c.buffering);
144
- Generator.fill (Lazy.force c.generator) frame;
71
+ let frame =
72
+ Generator.slice (Lazy.force c.generator) (Lazy.force Frame.size)
73
+ in
145
74
  if
146
75
  Frame.is_partial frame
147
76
  && Generator.length (Lazy.force c.generator) = 0
148
77
  then (
149
78
  self#log#important "Buffer emptied, start buffering...";
150
- c.buffering <- true))
79
+ c.buffering <- true);
80
+ frame)
151
81
 
152
82
  method abort_track = proceed c (fun () -> c.abort <- true)
153
83
  end
@@ -172,7 +102,7 @@ module Buffer = struct
172
102
  if c.abort then (
173
103
  c.abort <- false;
174
104
  source#abort_track);
175
- Generator.feed (Lazy.force c.generator) frame;
105
+ Generator.append (Lazy.force c.generator) frame;
176
106
  if Generator.length (Lazy.force c.generator) > prebuf then (
177
107
  c.buffering <- false;
178
108
  if Generator.length (Lazy.force c.generator) > maxbuf then
@@ -274,7 +204,7 @@ module AdaptativeBuffer = struct
274
204
  write r buf
275
205
  end
276
206
 
277
- (* TODO: also have breaks and metadata as in generators. *)
207
+ (* TODO: also have track_marks and metadata as in generators. *)
278
208
 
279
209
  (** The kind of value shared by a producer and a consumer. *)
280
210
  type control = {
@@ -283,7 +213,7 @@ module AdaptativeBuffer = struct
283
213
  rb : RB.t; (* the ringbuffer *)
284
214
  mutable rb_length : float;
285
215
  (* average length of the ringbuffer, in samples *)
286
- mg : MG.t; (* metadata generator *)
216
+ mutable mg : Generator.t;
287
217
  mutable buffering : bool;
288
218
  (* when true we are buffering: filling the buffer, but not reading from it *)
289
219
  mutable abort : bool; (* whether we asked to abort the current track *)
@@ -303,11 +233,8 @@ module AdaptativeBuffer = struct
303
233
  method seek_source = (self :> Source.source)
304
234
  method stype = `Fallible
305
235
  method self_sync = (`Static, false)
306
- method remaining = proceed c (fun () -> MG.remaining c.mg)
307
-
308
- method private _is_ready ?frame:_ _ =
309
- proceed c (fun () -> not c.buffering)
310
-
236
+ method remaining = proceed c (fun () -> Generator.remaining c.mg)
237
+ method private can_generate_frame = proceed c (fun () -> not c.buffering)
311
238
  method ratio = proceed c (fun () -> c.rb_length /. prebuf)
312
239
 
313
240
  method buffer_duration =
@@ -324,7 +251,7 @@ module AdaptativeBuffer = struct
324
251
  converter <-
325
252
  Some (Audio_converter.Samplerate.create self#audio_channels)
326
253
 
327
- method private get_frame frame =
254
+ method private generate_frame =
328
255
  proceed c (fun () ->
329
256
  assert (not c.buffering);
330
257
 
@@ -390,29 +317,43 @@ module AdaptativeBuffer = struct
390
317
  let scaling = c.rb_length /. prebuf in
391
318
  let scale n = int_of_float (float n *. scaling) in
392
319
  let unscale n = int_of_float (float n /. scaling) in
393
- let ofs = Frame.position frame in
394
- let len = Lazy.force Frame.size - ofs in
395
- let aofs = Frame.audio_of_main ofs in
396
- let alen = Frame.audio_of_main len in
397
- let buf = AFrame.pcm frame in
320
+ let length = Lazy.force Frame.size in
321
+ let frame = Frame.create ~length self#content_type in
322
+ let alen = Frame.audio_of_main length in
323
+ let buf =
324
+ Content.Audio.get_data (Frame.get frame Frame.Fields.audio)
325
+ in
398
326
  let salen = scale alen in
399
- fill buf aofs alen salen;
400
- Frame.add_break frame (ofs + len);
327
+ fill buf 0 alen salen;
328
+ let frame =
329
+ Frame.set_data frame Frame.Fields.audio Content.Audio.lift_data
330
+ buf
331
+ in
401
332
 
402
333
  (* self#log#debug "filled %d from %d (x %f)" len ofs scaling; *)
403
334
 
404
- (* Fill in metadata *)
405
- let md = MG.metadata c.mg (scale len) in
406
- List.iter (fun (t, m) -> Frame.set_metadata frame (unscale t) m) md;
407
- MG.advance c.mg (min (Frame.main_of_audio salen) (MG.length c.mg));
408
- if Frame.is_partial frame then MG.drop_initial_break c.mg;
335
+ (* Fill in metadata and track mark *)
336
+ let content = Generator.slice c.mg (scale length) in
337
+ let frame =
338
+ List.fold_left
339
+ (fun frame (pos, m) -> Frame.add_metadata frame (unscale pos) m)
340
+ frame
341
+ (Frame.get_all_metadata content)
342
+ in
343
+ let frame =
344
+ match Frame.track_marks content with
345
+ | p :: _ -> Frame.add_track_mark frame (unscale p)
346
+ | _ -> frame
347
+ in
409
348
 
410
349
  (* If there is no data left, we should buffer again. *)
411
350
  if RB.read_space c.rb = 0 then (
412
351
  self#log#important "Buffer emptied, start buffering...";
413
352
  self#log#debug "Current scaling factor is x%f." scaling;
414
- MG.advance c.mg (MG.length c.mg);
415
- c.buffering <- true))
353
+ Generator.clear c.mg;
354
+ c.buffering <- true);
355
+
356
+ frame)
416
357
 
417
358
  method abort_track = proceed c (fun () -> c.abort <- true)
418
359
  end
@@ -443,9 +384,9 @@ module AdaptativeBuffer = struct
443
384
  (* Not enough write space, let's drop a frame. *)
444
385
  self#log#important "Buffer full, dropping a frame.";
445
386
  RB.read_advance c.rb len;
446
- MG.advance c.mg (Frame.main_of_audio len));
387
+ Generator.truncate c.mg (Frame.main_of_audio len));
447
388
  RB.write c.rb (Audio.sub buf 0 len);
448
- MG.feed_from_frame c.mg frame;
389
+ Generator.append c.mg frame;
449
390
  if RB.read_space c.rb > prebuf then (
450
391
  if c.buffering && reset then
451
392
  c.rb_length <- float (Frame.audio_of_seconds pre_buffer);
@@ -459,7 +400,7 @@ module AdaptativeBuffer = struct
459
400
  lock = Mutex.create ();
460
401
  rb = RB.create (Frame.audio_of_seconds max_buffer);
461
402
  rb_length = float (Frame.audio_of_seconds pre_buffer);
462
- mg = MG.create ();
403
+ mg = Generator.create Frame.Fields.empty;
463
404
  buffering = true;
464
405
  abort = false;
465
406
  }
@@ -22,65 +22,48 @@
22
22
 
23
23
  class merge_metadata tracks =
24
24
  let sources = List.map snd tracks in
25
- let stype =
26
- if List.for_all (fun s -> s#stype = `Infallible) sources then `Infallible
27
- else `Fallible
28
- in
29
25
  let self_sync_type = Utils.self_sync_type sources in
30
26
  object (self)
31
27
  inherit Source.operator ~name:"track.metadata.merge" sources
32
28
  initializer Typing.(self#frame_type <: Lang.unit_t)
33
- method stype = stype
29
+ method stype = `Infallible
34
30
 
35
31
  method self_sync =
36
- (Lazy.force self_sync_type, List.exists (fun s -> snd s#self_sync) sources)
32
+ ( Lazy.force self_sync_type,
33
+ List.exists (fun s -> s#is_ready && snd s#self_sync) sources )
37
34
 
38
35
  method abort_track = List.iter (fun s -> s#abort_track) sources
36
+ method private ready_sources = List.filter (fun s -> s#is_ready) sources
37
+ method private can_generate_frame = self#ready_sources <> []
39
38
 
40
- method private _is_ready ?frame () =
41
- List.for_all (fun s -> s#is_ready ?frame ()) sources
39
+ method seek_source =
40
+ match self#ready_sources with
41
+ | s :: [] -> s
42
+ | _ -> (self :> Source.source)
42
43
 
43
- method seek_source = (self :> Source.source)
44
- method remaining = -1
45
- val mutable track_frames = []
44
+ method remaining =
45
+ match self#ready_sources with s :: [] -> s#remaining | _ -> -1
46
46
 
47
- method private track_frame source =
48
- try List.assq source track_frames
49
- with Not_found ->
50
- let f = Frame.create source#content_type in
51
- track_frames <- (source, f) :: track_frames;
52
- f
53
-
54
- method get_frame buf =
55
- let pos = Frame.position buf in
56
- let max_pos =
57
- List.fold_left
58
- (fun max_pos (source : Source.source) ->
59
- let tmp_frame = self#track_frame source in
60
- if source#is_ready ~frame:tmp_frame () && Frame.is_partial tmp_frame
61
- then (
62
- source#get tmp_frame;
63
- List.iter
64
- (fun (p, m) ->
65
- if pos <= p then (
66
- let m =
67
- match Frame.get_metadata buf p with
68
- | None -> m
69
- | Some m' ->
70
- Frame.Metadata.fold
71
- (fun lbl v m -> Frame.Metadata.add lbl v m)
72
- m' m
73
- in
74
- Frame.set_metadata buf p m))
75
- (Frame.get_all_metadata tmp_frame));
76
- max max_pos (Frame.position tmp_frame))
77
- (Frame.position buf) sources
78
- in
79
- Frame.add_break buf max_pos
80
-
81
- initializer
82
- self#on_after_output (fun () ->
83
- List.iter (fun (_, frame) -> Frame.clear frame) track_frames)
47
+ method private generate_frame =
48
+ match self#ready_sources with
49
+ | [] -> assert false
50
+ | s :: rest ->
51
+ List.fold_left
52
+ (fun frame source ->
53
+ let l = Frame.get_all_metadata source#get_frame in
54
+ let l =
55
+ List.fold_left
56
+ (fun l (pos, m) ->
57
+ ( pos,
58
+ Frame.Metadata.append
59
+ (Option.value ~default:Frame.Metadata.empty
60
+ (Frame.get_metadata frame pos))
61
+ m )
62
+ :: l)
63
+ [] l
64
+ in
65
+ Frame.add_all_metadata frame l)
66
+ s#get_frame rest
84
67
  end
85
68
 
86
69
  let _ =
@@ -23,44 +23,18 @@
23
23
  open Source
24
24
 
25
25
  class track_map ~name ~field ~fn s =
26
- object (self)
26
+ object
27
27
  inherit operator ~name [s]
28
28
  method stype = s#stype
29
29
  method remaining = s#remaining
30
30
  method abort_track = s#abort_track
31
31
  method seek_source = s#seek_source
32
32
  method self_sync = s#self_sync
33
- method private _is_ready = s#is_ready
34
- val mutable tmp_frame = None
35
-
36
- method tmp_frame =
37
- match tmp_frame with
38
- | Some b -> b
39
- | None ->
40
- let format = Frame.Fields.find field s#content_type in
41
- let f =
42
- Frame.create (Frame.Fields.add field format Frame.Fields.empty)
43
- in
44
- tmp_frame <- Some f;
45
- f
46
-
47
- method private get_frame buf =
48
- let tmp_frame = self#tmp_frame in
49
- let start_pos = Frame.position buf in
50
- assert (start_pos = Frame.position tmp_frame);
51
- s#get tmp_frame;
52
- let end_pos = Frame.position tmp_frame in
53
- let len = end_pos - start_pos in
54
- let src = fn (Content.sub (Frame.get tmp_frame field) start_pos len) in
55
- Content.blit src 0 (Frame.get buf field) start_pos len;
56
- List.iter
57
- (fun (pos, m) ->
58
- if start_pos <= pos && pos < end_pos then
59
- Generator.add_metadata ~pos buf m)
60
- (Frame.get_all_metadata tmp_frame);
61
- Frame.add_break buf end_pos
62
-
63
- initializer self#on_after_output (fun () -> Frame.clear self#tmp_frame)
33
+ method private can_generate_frame = s#is_ready
34
+
35
+ method private generate_frame =
36
+ let buf = s#get_frame in
37
+ Frame.set buf field (fn (Frame.get buf field))
64
38
  end
65
39
 
66
40
  let to_pcm_s16 c =
@@ -25,6 +25,16 @@ open Source
25
25
 
26
26
  let log = Log.make ["video"]
27
27
 
28
+ let cached_effect effect =
29
+ let cache = ref None in
30
+ fun args ->
31
+ match !cache with
32
+ | Some (old_args, result) when old_args = args -> result
33
+ | _ ->
34
+ let result = effect args in
35
+ cache := Some (args, result);
36
+ result
37
+
28
38
  let rgb_of_int c =
29
39
  let c =
30
40
  if c < 0 || c > 0xffffff then (
@@ -74,15 +84,30 @@ class virtual base ~name (source : source) f =
74
84
  method remaining = source#remaining
75
85
  method seek_source = source#seek_source
76
86
  method self_sync = source#self_sync
77
- method private _is_ready = source#is_ready
87
+ method private can_generate_frame = source#is_ready
78
88
  method abort_track = source#abort_track
79
-
80
- method private get_frame buf =
81
- match VFrame.get_content buf source with
82
- | Some (rgb, offset, length) -> (
83
- try f (Content.Video.get_data rgb) offset length
84
- with Content.Invalid -> ())
85
- | _ -> ()
89
+ method virtual content_type : Frame.content_type
90
+
91
+ method private generate_frame =
92
+ let c = source#get_mutable_content Frame.Fields.video in
93
+ let buf = Content.Video.get_data c in
94
+ let data = buf.Content.Video.data in
95
+ let data =
96
+ if data = [] then data
97
+ else (
98
+ let positions, images =
99
+ List.fold_left
100
+ (fun (positions, images) (pos, img) ->
101
+ (pos :: positions, img :: images))
102
+ ([], []) buf.Content.Video.data
103
+ in
104
+ let positions = List.rev positions in
105
+ let video = Array.of_list (List.rev images) in
106
+ f video 0 (List.length images);
107
+ List.mapi (fun i pos -> (pos, Video.Canvas.get video i)) positions)
108
+ in
109
+ source#set_frame_data Frame.Fields.video Content.Video.lift_data
110
+ { buf with Content.Video.data }
86
111
  end
87
112
 
88
113
  class effect ~name (source : source) effect =
@@ -237,14 +262,21 @@ let _ =
237
262
  let height = List.assoc "height" p |> Lang.to_int_getter in
238
263
  let c, a = color_arg p in
239
264
  let src = List.assoc "" p |> Lang.to_source in
265
+ let effect =
266
+ cached_effect (fun (width, height, color, alpha) ->
267
+ let r = Image.YUV420.create width height in
268
+ Image.YUV420.fill r color;
269
+ Image.YUV420.fill_alpha r alpha;
270
+ r)
271
+ in
240
272
  new effect_map ~name:"video.add_rectangle" src (fun buf ->
241
273
  let x = x () in
242
274
  let y = y () in
243
275
  let width = width () in
244
276
  let height = height () in
245
- let r = Image.YUV420.create width height in
246
- Image.YUV420.fill r (c ());
247
- Image.YUV420.fill_alpha r (a ());
277
+ let color = c () in
278
+ let alpha = a () in
279
+ let r = effect (width, height, color, alpha) in
248
280
  let r = Video.Canvas.Image.make ~x ~y ~width:(-1) ~height:(-1) r in
249
281
  Video.Canvas.Image.add r buf))
250
282
 
@@ -506,11 +538,14 @@ let _ =
506
538
  let q = Lang.assoc "" 2 param |> to_point_getter in
507
539
  let s = Lang.assoc "" 3 param |> Lang.to_source in
508
540
  let c, a = color_arg param in
541
+ let effect =
542
+ cached_effect (fun (r, g, b, a) ->
543
+ Video.Canvas.Image.Draw.line (r, g, b, a) (p ()) (q ()))
544
+ in
509
545
  new effect_map ~name:"video.add_line" s (fun buf ->
510
546
  let r, g, b = c () in
511
547
  let a = a () in
512
- (* TODO: we could keep the image if the values did not change *)
513
- let line = Video.Canvas.Image.Draw.line (r, g, b, a) (p ()) (q ()) in
548
+ let line = effect (r, g, b, a) in
514
549
  Video.Canvas.Image.add line buf))
515
550
 
516
551
  let _ =
@@ -28,29 +28,22 @@ let video_fade = Lang.add_module ~base:Modules.video "fade"
28
28
  (** Fade-in at the beginning of every track.
29
29
  * The [duration] is in seconds. *)
30
30
  class fade_in ?(meta = "liq_video_fade_in") duration fader fadefun source =
31
- object
31
+ object (self)
32
32
  inherit operator ~name:"video.fade.in" [source]
33
33
  method stype = source#stype
34
- method private _is_ready = source#is_ready
34
+ method private can_generate_frame = source#is_ready
35
35
  method abort_track = source#abort_track
36
36
  method remaining = source#remaining
37
37
  method self_sync = source#self_sync
38
38
  method seek_source = source#seek_source
39
39
  val mutable state = `Idle
40
40
 
41
- method private get_frame ab =
42
- let off_ticks = Frame.position ab in
43
- let video_content = VFrame.get_content ab source in
44
- (* In video frames: [length] of the fade, [count] since beginning.
45
- This must be done before accessing the (possibly empty video content)
46
- because the state has to be updated anyway. Also, it is important
47
- that the metadata is ready at the position in ticks rather than
48
- video, otherwise we might miss some data. *)
49
- let fade, fadefun, length, count =
41
+ method private process frame =
42
+ let fade, fadefun, duration, position =
50
43
  match state with
51
44
  | `Idle ->
52
45
  let duration =
53
- match Frame.get_metadata ab off_ticks with
46
+ match Frame.get_metadata frame 0 with
54
47
  | None -> duration
55
48
  | Some m -> (
56
49
  match Frame.Metadata.find_opt meta m with
@@ -58,32 +51,44 @@ class fade_in ?(meta = "liq_video_fade_in") duration fader fadefun source =
58
51
  try float_of_string d with _ -> duration)
59
52
  | None -> duration)
60
53
  in
61
- let length = Frame.video_of_seconds duration in
62
- let fade = fader length in
54
+ let fade = fader (Frame.video_of_seconds duration) in
55
+ let duration = Frame.main_of_seconds duration in
63
56
  let fadefun = fadefun () in
64
- state <- `Play (fade, fadefun, length, 0);
65
- (fade, fadefun, length, 0)
66
- | `Play (fade, fadefun, length, count) ->
67
- (fade, fadefun, length, count)
57
+ let v = (fade, fadefun, duration, 0) in
58
+ state <- `Play v;
59
+ v
60
+ | `Play v -> v
68
61
  in
69
- if Frame.is_partial ab then state <- `Idle;
70
- match video_content with
71
- | Some (rgb, off, len) ->
72
- let rgb = Content.Video.get_data rgb in
73
- if count < length then
74
- for i = 0 to min (len - 1) (length - count - 1) do
75
- let m = fade (count + i) in
76
- (* TODO @smimram *)
77
- ignore (fadefun (Video.Canvas.get rgb (off + i)) m)
78
- done;
79
- if state <> `Idle then
80
- state <- `Play (fade, fadefun, length, count + len)
81
- | _ -> ()
62
+ if position < duration then (
63
+ let buf =
64
+ Content.Video.get_data
65
+ (Content.copy (Frame.get frame Frame.Fields.video))
66
+ in
67
+ let data =
68
+ List.mapi
69
+ (fun i (pos, img) ->
70
+ let m = fade (Frame.video_of_main position + i) in
71
+ ignore (fadefun img m);
72
+ (pos, img))
73
+ buf.Content.Video.data
74
+ in
75
+ state <- `Play (fade, fadefun, duration, position + Frame.position frame);
76
+ Frame.set_data frame Frame.Fields.video Content.Video.lift_data
77
+ { buf with Content.Video.data })
78
+ else frame
79
+
80
+ method private generate_frame =
81
+ match self#split_frame source#get_frame with
82
+ | frame, None -> self#process frame
83
+ | end_track, Some begin_track ->
84
+ let end_track = self#process end_track in
85
+ state <- `Idle;
86
+ Frame.append end_track (self#process begin_track)
82
87
  end
83
88
 
84
89
  (** Fade-out after every frame. *)
85
90
  class fade_out ?(meta = "liq_video_fade_out") duration fader fadefun source =
86
- object
91
+ object (self)
87
92
  inherit operator ~name:"video.fade.out" [source]
88
93
  method stype = source#stype
89
94
  method abort_track = source#abort_track
@@ -94,20 +99,17 @@ class fade_out ?(meta = "liq_video_fade_out") duration fader fadefun source =
94
99
  * The value is set at the beginning of every track, depending on metadata. *)
95
100
  val mutable cur_length = None
96
101
  method remaining = source#remaining
97
- method private _is_ready = source#is_ready
102
+ method private can_generate_frame = source#is_ready
98
103
 
99
- method private get_frame ab =
100
- let n = Frame.video_of_main source#remaining in
101
- let off_ticks = Frame.position ab in
102
- let video_content = VFrame.get_content ab source in
103
- (* In video frames: [length] of the fade. *)
104
+ method private process_frame ~remaining frame =
105
+ (* In main ticks: [length] of the fade. *)
104
106
  let fade, fadefun, length =
105
107
  match cur_length with
106
108
  | Some (f, g, l) -> (f, g, l)
107
109
  | None ->
108
110
  (* Set the length at the beginning of a track *)
109
111
  let duration =
110
- match Frame.get_metadata ab off_ticks with
112
+ match Frame.get_metadata frame 0 with
111
113
  | None -> duration
112
114
  | Some m -> (
113
115
  match Frame.Metadata.find_opt meta m with
@@ -115,29 +117,39 @@ class fade_out ?(meta = "liq_video_fade_out") duration fader fadefun source =
115
117
  | Some d -> (
116
118
  try float_of_string d with _ -> duration))
117
119
  in
118
- let l = Frame.video_of_seconds duration in
119
- let f = fader l in
120
+ let l = Frame.main_of_seconds duration in
121
+ let f = fader (Frame.video_of_seconds duration) in
120
122
  let g = fadefun () in
121
123
  cur_length <- Some (f, g, l);
122
124
  (f, g, l)
123
125
  in
124
- (* Reset the length at the end of a track *)
125
- if Frame.is_partial ab then cur_length <- None;
126
126
 
127
- (* Do the actual processing of video samples *)
128
- match video_content with
129
- | Some (rgb, off, len) -> (
130
- (* Process the buffer *)
131
- match if n >= 0 && n < length then Some n else None with
132
- | Some n ->
133
- let rgb = Content.Video.get_data rgb in
134
- for i = 0 to len - 1 do
135
- let m = fade (n - i) in
136
- (* TODO @smimram *)
137
- ignore (fadefun (Video.Canvas.get rgb (off + i)) m)
138
- done
139
- | None -> ())
140
- | _ -> ()
127
+ if remaining < length then (
128
+ let content = Content.copy (Frame.get frame Frame.Fields.video) in
129
+ let buf = Content.Video.get_data content in
130
+
131
+ let data =
132
+ List.mapi
133
+ (fun i (pos, img) ->
134
+ let m = fade (Frame.video_of_main remaining - i) in
135
+ (* TODO @smimram *)
136
+ ignore (fadefun img m);
137
+ (pos, img))
138
+ buf.Content.Video.data
139
+ in
140
+
141
+ Frame.set_data frame Frame.Fields.video Content.Video.lift_data
142
+ { buf with Content.Video.data })
143
+ else frame
144
+
145
+ method private generate_frame =
146
+ match self#split_frame source#get_frame with
147
+ | frame, None -> self#process_frame ~remaining:source#remaining frame
148
+ | end_track, Some begin_track ->
149
+ let end_track = self#process_frame ~remaining:0 end_track in
150
+ cur_length <- None;
151
+ Frame.append end_track
152
+ (self#process_frame ~remaining:source#remaining begin_track)
141
153
  end
142
154
 
143
155
  (** Lang interface *)