; Regenerate using dune build @gendune --auto-promote

(include dune.inc)

(executable
 (name gen_dune)
 (libraries liquidsoap_build_tools)
 (modules gen_dune))

(rule
 (alias gendune)
 (deps
  (source_tree .))
 (target dune.inc.gen)
 (action
  (with-stdout-to
   dune.inc.gen
   (run ./gen_dune.exe))))

(rule
 (alias gendune)
 (action
  (diff dune.inc dune.inc.gen)))

(rule
 (alias mediatest)
 (package liquidsoap)
 (target first-concat.mp4)
 (action
  (run
   ffmpeg
   -hide_banner
   -loglevel
   error
   -f
   lavfi
   -i
   "testsrc=duration=20:size=1280x720:rate=30"
   -vf
   "setpts=N+1235"
   %{target})))

(rule
 (alias mediatest)
 (package liquidsoap)
 (target second-concat.mp4)
 (action
  (run
   ffmpeg
   -hide_banner
   -loglevel
   error
   -f
   lavfi
   -i
   "testsrc=duration=30:size=1280x720:rate=30"
   -vf
   "setpts=N+756"
   %{target})))

(rule
 (alias mediatest)
 (package liquidsoap)
 (target third-concat.mp4)
 (action
  (run
   ffmpeg
   -hide_banner
   -loglevel
   error
   -f
   lavfi
   -i
   "testsrc=duration=10:size=1280x720:rate=30"
   -vf
   "setpts=N+245"
   %{target})))

(rule
 (alias mediatest)
 (package liquidsoap)
 (target background.jpg)
 (action
  (run
   ffmpeg
   -hide_banner
   -loglevel
   error
   -f
   lavfi
   -i
   testsrc=size=1280x720
   -t
   1
   -f
   mjpeg
   %{target})))

(rule
 (alias mediatest)
 (package liquidsoap)
 (target logo.png)
 (action
  (run
   ffmpeg
   -hide_banner
   -loglevel
   error
   -f
   lavfi
   -i
   testsrc=size=50x50
   -t
   1
   -f
   mjpeg
   %{target})))

(rule
 (alias mediatest)
 (package liquidsoap)
 (deps
  first-concat.mp4
  second-concat.mp4
  third-concat.mp4
  ffmpeg_copy_concat.liq
  ../../src/bin/liquidsoap.exe
  (package liquidsoap)
  (source_tree ../../src/lib)
  (:test_liq ../test.liq)
  (:run_test ../run_test.exe))
 (action
  (run
   %{run_test}
   "FFmpeg copy+concat"
   liquidsoap
   %{test_liq}
   ffmpeg_copy_concat.liq)))

(rule
 (alias mediatest)
 (package liquidsoap)
 (deps
  all_media_files
  ffmpeg_complex_filter.liq
  ../../src/bin/liquidsoap.exe
  (package liquidsoap)
  (source_tree ../../src/lib)
  (:test_liq ../test.liq)
  (:run_test ../run_test.exe))
 (action
  (run
   %{run_test}
   "FFmpeg complex filter"
   liquidsoap
   %{test_liq}
   ffmpeg_complex_filter.liq)))

(rule
 (alias mediatest)
 (package liquidsoap)
 (target long-video.mp4)
 (action
  (run
   ffmpeg
   -hide_banner
   -loglevel
   error
   -f
   lavfi
   -i
   "testsrc=d=30:s=1920x1080:r=24,format=yuv420p"
   -f
   lavfi
   -i
   "sine=f=440:b=4"
   -shortest
   %{target})))

(rule
 (alias mediatest)
 (package liquidsoap)
 (deps
  long-video.mp4
  ffmpeg_distributed_hls.liq
  ffmpeg_distributed_hls_state.json
  ../../src/bin/liquidsoap.exe
  (package liquidsoap)
  (source_tree ../../src/lib)
  (:test_liq ../test.liq)
  (:run_test ../run_test.exe))
 (action
  (run
   %{run_test}
   "FFmpeg distributed HLS encoding"
   liquidsoap
   %{test_liq}
   ffmpeg_distributed_hls.liq
   --
   long-video.mp4)))

(rule
 (alias mediatest)
 (package liquidsoap)
 (deps
  all_media_files
  background.jpg
  logo.png
  ffmpeg_transparency_filter.liq
  ../../src/bin/liquidsoap.exe
  (package liquidsoap)
  (source_tree ../../src/lib)
  (:test_liq ../test.liq)
  (:run_test ../run_test.exe))
 (action
  (run
   %{run_test}
   "FFmpeg transparency filter"
   liquidsoap
   %{test_liq}
   ffmpeg_transparency_filter.liq)))

(rule
 (alias mediatest)
 (package liquidsoap)
 (deps
  all_media_files
  background.jpg
  logo.png
  ffmpeg_filter_changing_rate.liq
  ../../src/bin/liquidsoap.exe
  (package liquidsoap)
  (source_tree ../../src/lib)
  (:test_liq ../test.liq)
  (:run_test ../run_test.exe))
 (action
  (run
   %{run_test}
   "FFmpeg filter with changing video rate"
   liquidsoap
   %{test_liq}
   ./ffmpeg_filter_changing_rate.liq
   --
   ./@ffmpeg[format='mp4',@audio[codec='aac',channels=2],@video[codec='libx264']].mp4
   ./@ffmpeg[format='mp4',@audio[codec='aac',channels=2],@video[codec='libx264',r=12]].mp4)))

(rule
 (alias mediatest)
 (package liquidsoap)
 (deps
  all_media_files
  lufs_integrated.liq
  ../../src/bin/liquidsoap.exe
  (package liquidsoap)
  (source_tree ../../src/lib)
  (:test_liq ../test.liq)
  (:run_test ../run_test.exe))
 (action
  (run
   %{run_test}
   "Integrated LUFS computation"
   liquidsoap
   %{test_liq}
   lufs_integrated.liq)))

(rule
 (alias mediatest)
 (package liquidsoap)
 (deps long-video.mp4)
 (target test-image.png)
 (action
  (run
   ffmpeg
   -hide_banner
   -loglevel
   error
   -i
   long-video.mp4
   -frames:v
   1
   %{target})))

(rule
 (alias mediatest)
 (package liquidsoap)
 (deps
  test-image.png
  image_decoder_duration.liq
  ../../src/bin/liquidsoap.exe
  (package liquidsoap)
  (source_tree ../../src/lib)
  (:test_liq ../test.liq)
  (:run_test ../run_test.exe))
 (action
  (run
   %{run_test}
   "Image decoder with fixed duration"
   liquidsoap
   %{test_liq}
   image_decoder_duration.liq)))
