X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=test%2Fplayer_test.cc;h=03f2eb6e655d977f0910c3338e15f94cbd13675c;hp=c325537fa80a18908049188f5ade4b83ba9e7c76;hb=fb0e2ead59a442700c671270c7d57b5bffeaeab3;hpb=ea63ad9560757e56505551db3bf2e1c31be5c76c diff --git a/test/player_test.cc b/test/player_test.cc index c325537fa..03f2eb6e6 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -25,21 +25,21 @@ */ -#include "lib/film.h" -#include "lib/ffmpeg_content.h" -#include "lib/dcp_content_type.h" -#include "lib/ratio.h" #include "lib/audio_buffers.h" -#include "lib/player.h" -#include "lib/video_content.h" -#include "lib/image_content.h" -#include "lib/string_text_file_content.h" -#include "lib/content_factory.h" -#include "lib/dcp_content.h" -#include "lib/text_content.h" #include "lib/butler.h" #include "lib/compose.hpp" +#include "lib/content_factory.h" #include "lib/cross.h" +#include "lib/dcp_content.h" +#include "lib/dcp_content_type.h" +#include "lib/ffmpeg_content.h" +#include "lib/film.h" +#include "lib/image_content.h" +#include "lib/player.h" +#include "lib/ratio.h" +#include "lib/string_text_file_content.h" +#include "lib/text_content.h" +#include "lib/video_content.h" #include "test.h" #include #include @@ -48,7 +48,6 @@ using std::cout; using std::list; -using std::pair; using std::shared_ptr; using std::make_shared; using boost::bind; @@ -84,7 +83,7 @@ BOOST_AUTO_TEST_CASE (player_silence_padding_test) accumulated = std::make_shared(film->audio_channels(), 0); - auto player = std::make_shared(film); + auto player = std::make_shared(film, Image::Alignment::COMPACT); player->Audio.connect (bind (&accumulate, _1, _2)); while (!player->pass ()) {} BOOST_REQUIRE (accumulated->frames() >= 48000); @@ -164,7 +163,7 @@ BOOST_AUTO_TEST_CASE (player_subframe_test) /* Length should be rounded up from B's length to the next video frame */ BOOST_CHECK (film->length() == DCPTime::from_frames(3 * 24 + 1, 24)); - auto player = std::make_shared(film); + auto player = std::make_shared(film, Image::Alignment::COMPACT); player->setup_pieces (); BOOST_REQUIRE_EQUAL (player->_black._periods.size(), 1U); BOOST_CHECK (player->_black._periods.front() == DCPTimePeriod(DCPTime::from_frames(3 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24))); @@ -206,12 +205,12 @@ BOOST_AUTO_TEST_CASE (player_interleave_test) film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); - auto player = std::make_shared(film); + auto player = std::make_shared(film, Image::Alignment::COMPACT); player->Video.connect (bind (&video, _1, _2)); player->Audio.connect (bind (&audio, _1, _2)); video_frames = audio_frames = 0; while (!player->pass ()) { - BOOST_CHECK (abs(video_frames - (audio_frames / 2000)) < 8); + BOOST_CHECK (abs(video_frames - (audio_frames / 2000)) <= 8); } } @@ -229,20 +228,20 @@ BOOST_AUTO_TEST_CASE (player_seek_test) BOOST_REQUIRE (!wait_for_jobs ()); dcp->only_text()->set_use (true); - auto player = std::make_shared(film); + auto player = std::make_shared(film, Image::Alignment::COMPACT); player->set_fast (); player->set_always_burn_open_subtitles (); player->set_play_referenced (); - auto butler = std::make_shared(film, player, AudioMapping(), 2, bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true); + auto butler = std::make_shared(film, player, AudioMapping(), 2, bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false); butler->disable_audio(); for (int i = 0; i < 10; ++i) { auto t = DCPTime::from_frames (i, 24); butler->seek (t, true); - auto video = butler->get_video(true, 0); + auto video = butler->get_video(Butler::Behaviour::BLOCKING, 0); BOOST_CHECK_EQUAL(video.second.get(), t.get()); - write_image(video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true), String::compose("build/test/player_seek_test_%1.png", i)); + write_image(video.first->image(bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, true), String::compose("build/test/player_seek_test_%1.png", i)); /* This 14.08 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine (17.10 and 16.04 seem to anti-alias a little differently) but to reject gross errors e.g. missing fonts or missing text altogether. @@ -261,12 +260,12 @@ BOOST_AUTO_TEST_CASE (player_seek_test2) BOOST_REQUIRE (!wait_for_jobs ()); dcp->only_text()->set_use (true); - auto player = std::make_shared(film); + auto player = std::make_shared(film, Image::Alignment::COMPACT); player->set_fast (); player->set_always_burn_open_subtitles (); player->set_play_referenced (); - auto butler = std::make_shared(film, player, AudioMapping(), 2, bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true); + auto butler = std::make_shared(film, player, AudioMapping(), 2, bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false); butler->disable_audio(); butler->seek(DCPTime::from_seconds(5), true); @@ -274,10 +273,10 @@ BOOST_AUTO_TEST_CASE (player_seek_test2) for (int i = 0; i < 10; ++i) { auto t = DCPTime::from_seconds(5) + DCPTime::from_frames (i, 24); butler->seek (t, true); - auto video = butler->get_video(true, 0); + auto video = butler->get_video(Butler::Behaviour::BLOCKING, 0); BOOST_CHECK_EQUAL(video.second.get(), t.get()); write_image( - video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true), String::compose("build/test/player_seek_test2_%1.png", i) + video.first->image(bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, true), String::compose("build/test/player_seek_test2_%1.png", i) ); check_image(TestPaths::private_data() / String::compose("player_seek_test2_%1.png", i), String::compose("build/test/player_seek_test2_%1.png", i), 14.08); } @@ -335,7 +334,7 @@ BOOST_AUTO_TEST_CASE (player_ignore_video_and_audio_test) text->only_text()->set_type (TextType::CLOSED_CAPTION); text->only_text()->set_use (true); - auto player = std::make_shared(film); + auto player = std::make_shared(film, Image::Alignment::COMPACT); player->set_ignore_video (); player->set_ignore_audio (); @@ -355,9 +354,9 @@ BOOST_AUTO_TEST_CASE (player_trim_crash) film->examine_and_add_content (boon); BOOST_REQUIRE (!wait_for_jobs()); - auto player = std::make_shared(film); + auto player = std::make_shared(film, Image::Alignment::COMPACT); player->set_fast (); - auto butler = std::make_shared(film, player, AudioMapping(), 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true); + auto butler = std::make_shared(film, player, AudioMapping(), 6, bind(&PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, true, false); /* Wait for the butler to fill */ dcpomatic_sleep_seconds (5); @@ -467,3 +466,34 @@ BOOST_AUTO_TEST_CASE (player_silence_at_end_crash) film2->set_video_frame_rate (24); make_and_verify_dcp (film2); } + + +/** #2257 */ +BOOST_AUTO_TEST_CASE (encrypted_dcp_with_no_kdm_gives_no_butler_error) +{ + auto content = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("encrypted_dcp_with_no_kdm_gives_no_butler_error", { content }); + int constexpr length = 24 * 25; + content->video->set_length(length); + film->set_encrypted (true); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_CPL_METADATA, + }); + + auto content2 = std::make_shared(film->dir(film->dcp_name())); + auto film2 = new_test_film2 ("encrypted_dcp_with_no_kdm_gives_no_butler_error2", { content2 }); + + auto player = std::make_shared(film2, Image::Alignment::COMPACT); + Butler butler(film2, player, AudioMapping(), 2, bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false); + + float buffer[2000 * 6]; + for (int i = 0; i < length; ++i) { + butler.get_video(Butler::Behaviour::BLOCKING, 0); + butler.get_audio(Butler::Behaviour::BLOCKING, buffer, 2000); + } + + BOOST_CHECK_NO_THROW(butler.rethrow()); +} +