X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fbutler_test.cc;h=97e4ccc0effbdec2718baa3fd399bc8303398940;hb=b9f949d688b6e9563f6350286bbbc3f169b1b9fe;hp=3d524a3b258382d98f82786224fae38a69793eb2;hpb=c8fa584045ad65283a85015f18ee8789ddf881d1;p=dcpomatic.git diff --git a/test/butler_test.cc b/test/butler_test.cc index 3d524a3b2..97e4ccc0e 100644 --- a/test/butler_test.cc +++ b/test/butler_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2021 Carl Hetherington + Copyright (C) 2017-2022 Carl Hetherington This file is part of DCP-o-matic. @@ -19,13 +19,14 @@ */ +#include "lib/audio_content.h" +#include "lib/audio_mapping.h" #include "lib/butler.h" -#include "lib/film.h" -#include "lib/dcp_content_type.h" -#include "lib/ratio.h" #include "lib/content_factory.h" -#include "lib/audio_mapping.h" +#include "lib/dcp_content_type.h" +#include "lib/film.h" #include "lib/player.h" +#include "lib/ratio.h" #include "test.h" #include @@ -45,9 +46,9 @@ BOOST_AUTO_TEST_CASE (butler_test1) film->set_name ("butler_test1"); film->set_container (Ratio::from_id ("185")); - auto video = content_factory("test/data/flat_red.png").front(); + auto video = content_factory("test/data/flat_red.png")[0]; film->examine_and_add_content (video); - auto audio = content_factory("test/data/staircase.wav").front(); + auto audio = content_factory("test/data/staircase.wav")[0]; film->examine_and_add_content (audio); BOOST_REQUIRE (!wait_for_jobs ()); @@ -59,7 +60,20 @@ BOOST_AUTO_TEST_CASE (butler_test1) map.set (i, i, 1); } - Butler butler (film, make_shared(film, Image::Alignment::COMPACT), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, false, false); + Player player(film, Image::Alignment::COMPACT); + + Butler butler ( + film, + player, + map, + 6, + boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24), + VideoRange::FULL, + Image::Alignment::COMPACT, + false, + false, + Butler::Audio::ENABLED + ); BOOST_CHECK (butler.get_video(Butler::Behaviour::BLOCKING, 0).second == DCPTime()); BOOST_CHECK (butler.get_video(Butler::Behaviour::BLOCKING, 0).second == DCPTime::from_frames(1, 24)); @@ -77,3 +91,51 @@ BOOST_AUTO_TEST_CASE (butler_test1) BOOST_REQUIRE_EQUAL (buffer[i * 6 + 5], 0); } } + + +BOOST_AUTO_TEST_CASE (butler_test2) +{ + auto content = content_factory(TestPaths::private_data() / "arrietty_JP-EN.mkv"); + BOOST_REQUIRE (!content.empty()); + auto film = new_test_film2 ("butler_test2", { content.front() }); + BOOST_REQUIRE (content.front()->audio); + content.front()->audio->set_delay(100); + + /* This is the map of the player output (5.1) to the butler output (also 5.1) */ + auto map = AudioMapping (6, 6); + for (int i = 0; i < 6; ++i) { + map.set (i, i, 1); + } + + Player player(film, Image::Alignment::COMPACT); + + Butler butler ( + film, + player, + map, + 6, + boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24), + VideoRange::FULL, + Image::Alignment::COMPACT, + false, + false, + Butler::Audio::ENABLED + ); + + int const audio_frames_per_video_frame = 48000 / 25; + float audio_buffer[audio_frames_per_video_frame * 6]; + for (int i = 0; i < 16; ++i) { + butler.get_video(Butler::Behaviour::BLOCKING, 0); + butler.get_audio(Butler::Behaviour::BLOCKING, audio_buffer, audio_frames_per_video_frame); + } + + butler.seek (DCPTime::from_seconds(60), false); + + for (int i = 0; i < 240; ++i) { + butler.get_video(Butler::Behaviour::BLOCKING, 0); + butler.get_audio(Butler::Behaviour::BLOCKING, audio_buffer, audio_frames_per_video_frame); + } + + butler.rethrow(); +} +