X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fplayer_test.cc;h=0c9b6f21f0a8c81f55b0e13e383ccc5802b3148b;hb=ed68bfad5c795afb342c5228f3c1dc7770a6d646;hp=0ddb67afcb70b817e718803190cc1ca0aa25ff93;hpb=2d04092a7938c078ade1a1f54a485b96a23d510c;p=dcpomatic.git diff --git a/test/player_test.cc b/test/player_test.cc index 0ddb67afc..0c9b6f21f 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -31,10 +31,10 @@ #include "lib/player.h" #include "lib/video_content.h" #include "lib/image_content.h" -#include "lib/text_subtitle_content.h" +#include "lib/string_text_file_content.h" #include "lib/content_factory.h" #include "lib/dcp_content.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" #include "lib/butler.h" #include "lib/compose.hpp" #include "test.h" @@ -92,6 +92,7 @@ BOOST_AUTO_TEST_CASE (player_black_fill_test) film->set_name ("black_fill_test"); film->set_container (Ratio::from_id ("185")); film->set_sequence (false); + film->set_interop (false); shared_ptr contentA (new ImageContent (film, "test/data/simple_testcard_640x480.png")); shared_ptr contentB (new ImageContent (film, "test/data/simple_testcard_640x480.png")); @@ -180,7 +181,7 @@ BOOST_AUTO_TEST_CASE (player_interleave_test) film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr s (new TextSubtitleContent (film, "test/data/subrip.srt")); + shared_ptr s (new StringTextFileContent (film, "test/data/subrip.srt")); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); @@ -193,12 +194,6 @@ BOOST_AUTO_TEST_CASE (player_interleave_test) } } -static void -note_handler (dcp::NoteType, std::string) -{ - -} - /** Test some seeks towards the start of a DCP with awkward subtitles; see mantis #1085 * and a number of others. I thought this was a player seek bug but in fact it was * caused by the subtitle starting just after the start of the video frame and hence @@ -210,11 +205,11 @@ BOOST_AUTO_TEST_CASE (player_seek_test) shared_ptr dcp (new DCPContent (film, private_data / "awkward_subs")); film->examine_and_add_content (dcp, true); BOOST_REQUIRE (!wait_for_jobs ()); - dcp->subtitle->set_use (true); + dcp->only_text()->set_use (true); shared_ptr player (new Player (film, film->playlist())); player->set_fast (); - player->set_always_burn_subtitles (true); + player->set_always_burn_open_subtitles (); player->set_play_referenced (); shared_ptr butler (new Butler (player, film->log(), AudioMapping(), 2)); @@ -225,7 +220,100 @@ BOOST_AUTO_TEST_CASE (player_seek_test) butler->seek (t, true); pair, DCPTime> video = butler->get_video(); BOOST_CHECK_EQUAL(video.second.get(), t.get()); - write_image(video.first->image(note_handler, PlayerVideo::always_rgb, false, true), String::compose("build/test/player_seek_test_%1.png", i), "RGB"); - check_image(String::compose("test/data/player_seek_test_%1.png", i), String::compose("build/test/player_seek_test_%1.png", i)); + write_image(video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true), String::compose("build/test/player_seek_test_%1.png", i), "RGB"); + /* This 0.011 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. + */ + check_image(String::compose("test/data/player_seek_test_%1.png", i), String::compose("build/test/player_seek_test_%1.png", i), 0.011); } } + +/** Test some more seeks towards the start of a DCP with awkward subtitles */ +BOOST_AUTO_TEST_CASE (player_seek_test2) +{ + shared_ptr film (new Film (optional())); + shared_ptr dcp (new DCPContent (film, private_data / "awkward_subs2")); + film->examine_and_add_content (dcp, true); + BOOST_REQUIRE (!wait_for_jobs ()); + dcp->only_text()->set_use (true); + + shared_ptr player (new Player (film, film->playlist())); + player->set_fast (); + player->set_always_burn_open_subtitles (); + player->set_play_referenced (); + + shared_ptr butler (new Butler (player, film->log(), AudioMapping(), 2)); + butler->disable_audio(); + + butler->seek(DCPTime::from_seconds(5), true); + + for (int i = 0; i < 10; ++i) { + DCPTime t = DCPTime::from_seconds(5) + DCPTime::from_frames (i, 24); + butler->seek (t, true); + pair, DCPTime> video = butler->get_video(); + BOOST_CHECK_EQUAL(video.second.get(), t.get()); + write_image(video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true), String::compose("build/test/player_seek_test2_%1.png", i), "RGB"); + check_image(String::compose("test/data/player_seek_test2_%1.png", i), String::compose("build/test/player_seek_test2_%1.png", i), 0.011); + } +} + +/** Test a bug when trimmed content follows other content */ +BOOST_AUTO_TEST_CASE (player_trim_test) +{ + shared_ptr film = new_test_film2 ("player_trim_test"); + shared_ptr A = content_factory(film, "test/data/flat_red.png").front(); + film->examine_and_add_content (A); + BOOST_REQUIRE (!wait_for_jobs ()); + A->video->set_length (10 * 24); + shared_ptr B = content_factory(film, "test/data/flat_red.png").front(); + film->examine_and_add_content (B); + BOOST_REQUIRE (!wait_for_jobs ()); + B->video->set_length (10 * 24); + B->set_position (DCPTime::from_seconds (10)); + B->set_trim_start (ContentTime::from_seconds (2)); + + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs ()); +} + +struct Sub { + PlayerText text; + TextType type; + optional track; + DCPTimePeriod period; +}; + +static void +store (list* out, PlayerText text, TextType type, optional track, DCPTimePeriod period) +{ + Sub s; + s.text = text; + s.type = type; + s.track = track; + s.period = period; + out->push_back (s); +} + +/** Test ignoring both video and audio */ +BOOST_AUTO_TEST_CASE (player_ignore_video_and_audio_test) +{ + shared_ptr film = new_test_film2 ("player_ignore_video_and_audio_test"); + shared_ptr ff = content_factory(film, private_data / "boon_telly.mkv").front(); + film->examine_and_add_content (ff); + shared_ptr text = content_factory(film, "test/data/subrip.srt").front(); + film->examine_and_add_content (text); + BOOST_REQUIRE (!wait_for_jobs()); + text->only_text()->set_type (TEXT_CLOSED_CAPTION); + text->only_text()->set_use (true); + + shared_ptr player (new Player(film, film->playlist())); + player->set_ignore_video (); + player->set_ignore_audio (); + + list out; + player->Text.connect (bind (&store, &out, _1, _2, _3, _4)); + while (!player->pass ()) {} + + BOOST_CHECK_EQUAL (out.size(), 6); +}