From: Carl Hetherington Date: Fri, 26 Feb 2021 00:24:48 +0000 (+0100) Subject: More verification of DCPs during tests. X-Git-Tag: v2.15.133~27 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=ea63ad9560757e56505551db3bf2e1c31be5c76c;p=dcpomatic.git More verification of DCPs during tests. --- diff --git a/test/4k_test.cc b/test/4k_test.cc index 38b43e9cd..f3ce0bfcc 100644 --- a/test/4k_test.cc +++ b/test/4k_test.cc @@ -51,8 +51,12 @@ BOOST_AUTO_TEST_CASE (fourk_test) film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE, + dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE + }); boost::filesystem::path p (test_film_dir ("4k_test")); p /= film->dcp_name (); diff --git a/test/atmos_test.cc b/test/atmos_test.cc index c3e8c341c..ca55a13ae 100644 --- a/test/atmos_test.cc +++ b/test/atmos_test.cc @@ -46,8 +46,7 @@ BOOST_AUTO_TEST_CASE (atmos_passthrough_test) &cl ); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::MISSING_CPL_METADATA}); auto ref = TestPaths::private_data() / "atmos_asset.mxf"; BOOST_REQUIRE (mxf_atmos_files_same(ref, dcp_file(film, "atmos"), true)); diff --git a/test/audio_processor_test.cc b/test/audio_processor_test.cc index fcb81e104..52dacb646 100644 --- a/test/audio_processor_test.cc +++ b/test/audio_processor_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/audio_processor_test.cc * @brief Test audio processors. * @ingroup feature */ + #include "lib/audio_processor.h" #include "lib/analyse_audio_job.h" #include "lib/dcp_content_type.h" @@ -32,14 +34,17 @@ #include "test.h" #include + using std::shared_ptr; +using std::make_shared; + /** Test the mid-side decoder for analysis and DCP-making */ BOOST_AUTO_TEST_CASE (audio_processor_test) { - shared_ptr film = new_test_film ("audio_processor_test"); + auto film = new_test_film ("audio_processor_test"); film->set_name ("audio_processor_test"); - shared_ptr c (new FFmpegContent("test/data/white.wav")); + auto c = make_shared("test/data/white.wav"); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); @@ -48,12 +53,11 @@ BOOST_AUTO_TEST_CASE (audio_processor_test) film->set_audio_processor (AudioProcessor::from_id ("mid-side-decoder")); /* Analyse the audio and check it doesn't crash */ - shared_ptr job (new AnalyseAudioJob (film, film->playlist(), false)); + auto job = make_shared (film, film->playlist(), false); JobManager::instance()->add (job); BOOST_REQUIRE (!wait_for_jobs()); /* Make a DCP and check it */ - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::MISSING_CPL_METADATA}); check_dcp ("test/data/audio_processor_test", film->dir (film->dcp_name ())); } diff --git a/test/burnt_subtitle_test.cc b/test/burnt_subtitle_test.cc index 1d689e332..0fffe4913 100644 --- a/test/burnt_subtitle_test.cc +++ b/test/burnt_subtitle_test.cc @@ -66,8 +66,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_subrip) content->subtitle->set_burn (true); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); check_dcp ("test/data/burnt_subtitle_test_subrip", film->dir (film->dcp_name ())); } diff --git a/test/closed_caption_test.cc b/test/closed_caption_test.cc index b5b13e040..2b80c812e 100644 --- a/test/closed_caption_test.cc +++ b/test/closed_caption_test.cc @@ -42,8 +42,14 @@ BOOST_AUTO_TEST_CASE (closed_caption_test1) content->only_text()->set_type (TextType::CLOSED_CAPTION); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::INVALID_CLOSED_CAPTION_LINE_LENGTH, + dcp::VerificationNote::Code::MISSING_CPL_METADATA + }); /* Just check to see that there's a CCAP in the CPL: this check could be better! diff --git a/test/dcp_decoder_test.cc b/test/dcp_decoder_test.cc index c1ad90d6f..45b715e95 100644 --- a/test/dcp_decoder_test.cc +++ b/test/dcp_decoder_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington + Copyright (C) 2019-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/dcp_decoder_test.cc * @brief Test DCPDecoder class. * @ingroup selfcontained */ + #include "lib/film.h" #include "lib/dcp_content.h" #include "lib/dcp_decoder.h" @@ -36,38 +38,32 @@ #include #include + using std::list; using std::string; using std::vector; using std::make_shared; using std::shared_ptr; + /* Check that DCPDecoder reuses old data when it should */ BOOST_AUTO_TEST_CASE (check_reuse_old_data_test) { /* Make some DCPs */ - auto ov = new_test_film2 ("check_reuse_old_data_ov"); - ov->examine_and_add_content (content_factory("test/data/flat_red.png").front()); - BOOST_REQUIRE (!wait_for_jobs()); - ov->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + auto ov = new_test_film2 ("check_reuse_old_data_ov", {content_factory("test/data/flat_red.png").front()}); + make_and_verify_dcp (ov); - auto vf = new_test_film2 ("check_reuse_old_data_vf"); auto ov_content = make_shared(ov->dir(ov->dcp_name(false))); - vf->examine_and_add_content (ov_content); - vf->examine_and_add_content (content_factory("test/data/L.wav").front()); - BOOST_REQUIRE (!wait_for_jobs()); + auto vf = new_test_film2 ("check_reuse_old_data_vf", {ov_content, content_factory("test/data/L.wav").front()}); ov_content->set_reference_video (true); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}); auto encrypted = new_test_film2 ("check_reuse_old_data_decrypted"); encrypted->examine_and_add_content (content_factory("test/data/flat_red.png").front()); BOOST_REQUIRE (!wait_for_jobs()); encrypted->set_encrypted (true); - encrypted->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (encrypted); dcp::DCP encrypted_dcp (encrypted->dir(encrypted->dcp_name())); encrypted_dcp.read (); diff --git a/test/digest_test.cc b/test/digest_test.cc index bfa8e62f6..59a8cb7a7 100644 --- a/test/digest_test.cc +++ b/test/digest_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/digest_test.cc * @brief Check computed DCP digests against references calculated by the `openssl` binary. * @ingroup feature */ + #include "lib/film.h" #include "lib/image_content.h" #include "lib/dcp_content_type.h" @@ -34,14 +36,17 @@ #include #include + using std::list; using std::string; using std::shared_ptr; +using std::make_shared; + static string openssl_hash (boost::filesystem::path file) { - FILE* pipe = popen (String::compose ("openssl sha1 -binary %1 | openssl base64 -e", file.string()).c_str (), "r"); + auto pipe = popen (String::compose ("openssl sha1 -binary %1 | openssl base64 -e", file.string()).c_str (), "r"); BOOST_REQUIRE (pipe); char buffer[128]; string output; @@ -57,15 +62,16 @@ openssl_hash (boost::filesystem::path file) return output; } + /** Test the digests made by the DCP writing code on a multi-reel DCP */ BOOST_AUTO_TEST_CASE (digest_test) { - shared_ptr film = new_test_film ("digest_test"); + auto film = new_test_film ("digest_test"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); film->set_name ("digest_test"); - shared_ptr r (new ImageContent("test/data/flat_red.png")); - shared_ptr g (new ImageContent("test/data/flat_green.png")); - shared_ptr b (new ImageContent("test/data/flat_blue.png")); + auto r = make_shared("test/data/flat_red.png"); + auto g = make_shared("test/data/flat_green.png"); + auto b = make_shared("test/data/flat_blue.png"); film->examine_and_add_content (r); film->examine_and_add_content (g); film->examine_and_add_content (b); @@ -73,8 +79,7 @@ BOOST_AUTO_TEST_CASE (digest_test) BOOST_REQUIRE (!wait_for_jobs()); BOOST_CHECK (Config::instance()->master_encoding_threads() > 1); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); dcp::DCP dcp (film->dir (film->dcp_name ())); dcp.read (); diff --git a/test/ffmpeg_audio_only_test.cc b/test/ffmpeg_audio_only_test.cc index 020c2cc13..a68f7cf57 100644 --- a/test/ffmpeg_audio_only_test.cc +++ b/test/ffmpeg_audio_only_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2017 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/ffmpeg_audio_only_test.cc * @brief Test FFmpeg content with audio but no video. * @ingroup feature */ + #include "lib/film.h" #include "lib/ffmpeg_content.h" #include "lib/dcp_content_type.h" @@ -36,15 +38,19 @@ #include #include + using std::min; +using std::shared_ptr; +using std::make_shared; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif -using std::shared_ptr; -static SNDFILE* ref = 0; + +static SNDFILE* ref = nullptr; static int ref_buffer_size = 0; -static float* ref_buffer = 0; +static float* ref_buffer = nullptr; + static void audio (std::shared_ptr audio, int channels) @@ -68,21 +74,21 @@ audio (std::shared_ptr audio, int channels) } } + /** Test the FFmpeg code with audio-only content */ static shared_ptr test (boost::filesystem::path file) { - shared_ptr film = new_test_film ("ffmpeg_audio_only_test"); + auto film = new_test_film ("ffmpeg_audio_only_test"); film->set_name ("test_film"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); - shared_ptr c (new FFmpegContent(file)); + auto c = make_shared(file); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); film->write_metadata (); /* See if can make a DCP without any errors */ - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::MISSING_CPL_METADATA}); BOOST_CHECK (!JobManager::instance()->errors()); /* Compare the audio data player reads with what libsndfile reads */ @@ -95,7 +101,7 @@ test (boost::filesystem::path file) ref_buffer_size = info.samplerate * info.channels; ref_buffer = new float[ref_buffer_size]; - shared_ptr player (new Player(film)); + auto player = make_shared(film); player->Audio.connect (bind (&audio, _1, info.channels)); while (!player->pass ()) {} @@ -106,10 +112,11 @@ test (boost::filesystem::path file) return film; } + BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test1) { /* S16 */ - shared_ptr film = test ("test/data/staircase.wav"); + auto film = test ("test/data/staircase.wav"); /* Compare the audio data in the DCP with what libsndfile reads */ @@ -119,12 +126,12 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test1) /* We don't want to test anything that requires resampling */ BOOST_REQUIRE_EQUAL (info.samplerate, 48000); - int16_t* buffer = new int16_t[info.channels * 2000]; + auto buffer = new int16_t[info.channels * 2000]; dcp::SoundAsset asset (dcp_file(film, "pcm")); - shared_ptr reader = asset.start_read (); + auto reader = asset.start_read (); for (int i = 0; i < asset.intrinsic_duration(); ++i) { - shared_ptr frame = reader->get_frame(i); + auto frame = reader->get_frame(i); sf_count_t this_time = min (info.frames, sf_count_t(2000)); sf_readf_short (ref, buffer, this_time); for (int j = 0; j < this_time; ++j) { @@ -136,10 +143,11 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test1) delete[] buffer; } + BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test2) { /* S32 1 channel */ - shared_ptr film = test ("test/data/sine_440.wav"); + auto film = test ("test/data/sine_440.wav"); /* Compare the audio data in the DCP with what libsndfile reads */ @@ -149,12 +157,12 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test2) /* We don't want to test anything that requires resampling */ BOOST_REQUIRE_EQUAL (info.samplerate, 48000); - int32_t* buffer = new int32_t[info.channels * 2000]; + auto buffer = new int32_t[info.channels * 2000]; dcp::SoundAsset asset (dcp_file(film, "pcm")); - shared_ptr reader = asset.start_read (); + auto reader = asset.start_read (); for (int i = 0; i < asset.intrinsic_duration(); ++i) { - shared_ptr frame = reader->get_frame(i); + auto frame = reader->get_frame(i); sf_count_t this_time = min (info.frames, sf_count_t(2000)); sf_readf_int (ref, buffer, this_time); for (int j = 0; j < this_time; ++j) { @@ -170,10 +178,11 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test2) delete[] buffer; } + BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test3) { /* S24 1 channel */ - shared_ptr film = test ("test/data/sine_24_48_440.wav"); + auto film = test ("test/data/sine_24_48_440.wav"); /* Compare the audio data in the DCP with what libsndfile reads */ @@ -183,12 +192,12 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_only_test3) /* We don't want to test anything that requires resampling */ BOOST_REQUIRE_EQUAL (info.samplerate, 48000); - int32_t* buffer = new int32_t[info.channels * 2000]; + auto buffer = new int32_t[info.channels * 2000]; dcp::SoundAsset asset (dcp_file(film, "pcm")); - shared_ptr reader = asset.start_read (); + auto reader = asset.start_read (); for (int i = 0; i < asset.intrinsic_duration(); ++i) { - shared_ptr frame = reader->get_frame(i); + auto frame = reader->get_frame(i); sf_count_t this_time = min (info.frames, sf_count_t(2000)); sf_readf_int (ref, buffer, this_time); for (int j = 0; j < this_time; ++j) { diff --git a/test/ffmpeg_audio_test.cc b/test/ffmpeg_audio_test.cc index fc315ec2d..5a36b99f4 100644 --- a/test/ffmpeg_audio_test.cc +++ b/test/ffmpeg_audio_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2016 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/ffmpeg_audio_test.cc * @brief Test reading audio from an FFmpeg file. * @ingroup feature */ + #include "lib/ffmpeg_content.h" #include "lib/film.h" #include "lib/dcp_content_type.h" @@ -41,14 +43,17 @@ #include #include + +using std::make_shared; using std::string; using std::shared_ptr; + BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) { - shared_ptr film = new_test_film ("ffmpeg_audio_test"); + auto film = new_test_film ("ffmpeg_audio_test"); film->set_name ("ffmpeg_audio_test"); - shared_ptr c (new FFmpegContent ("test/data/staircase.mov")); + auto c = make_shared ("test/data/staircase.mov"); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); @@ -56,10 +61,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); - film->make_dcp (); - film->write_metadata (); - - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); boost::filesystem::path path = "build/test"; path /= "ffmpeg_audio_test"; @@ -67,7 +69,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) dcp::DCP check (path.string ()); check.read (); - shared_ptr sound_asset = check.cpls().front()->reels().front()->main_sound (); + auto sound_asset = check.cpls().front()->reels().front()->main_sound (); BOOST_CHECK (sound_asset); BOOST_CHECK_EQUAL (sound_asset->asset()->channels (), 6); @@ -77,7 +79,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) int frame = 0; while (n < sound_asset->asset()->intrinsic_duration()) { - shared_ptr sound_frame = sound_asset->asset()->start_read()->get_frame (frame++); + auto sound_frame = sound_asset->asset()->start_read()->get_frame (frame++); uint8_t const * d = sound_frame->data (); for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->asset()->channels())) { @@ -124,27 +126,29 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) } } + /** Decode a file containing truehd so we can profile it; this is with the player set to normal */ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test2) { - shared_ptr film = new_test_film2 ("ffmpeg_audio_test2"); - shared_ptr content = content_factory(TestPaths::private_data() / "wayne.mkv").front(); + auto film = new_test_film2 ("ffmpeg_audio_test2"); + auto content = content_factory(TestPaths::private_data() / "wayne.mkv").front(); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr player (new Player(film)); + auto player = make_shared(film); while (!player->pass ()) {} } + /** Decode a file containing truehd so we can profile it; this is with the player set to fast */ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test3) { - shared_ptr film = new_test_film2 ("ffmpeg_audio_test3"); - shared_ptr content = content_factory(TestPaths::private_data() / "wayne.mkv").front(); + auto film = new_test_film2 ("ffmpeg_audio_test3"); + auto content = content_factory(TestPaths::private_data() / "wayne.mkv").front(); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr player (new Player(film)); + auto player = make_shared(film); player->set_fast (); while (!player->pass ()) {} } @@ -153,12 +157,12 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test3) /** Decode a file whose audio previously crashed DCP-o-matic (#1857) */ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test4) { - shared_ptr film = new_test_film2 ("ffmpeg_audio_test4"); - shared_ptr content = content_factory(TestPaths::private_data() / "Actuellement aout 2020.wmv").front(); + auto film = new_test_film2 ("ffmpeg_audio_test4"); + auto content = content_factory(TestPaths::private_data() / "Actuellement aout 2020.wmv").front(); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr player (new Player(film)); + auto player = make_shared(film); player->set_fast (); BOOST_CHECK_NO_THROW (while (!player->pass()) {}); } diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index 4654723b0..74603f6c0 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -18,6 +18,7 @@ */ + #include "lib/ffmpeg_encoder.h" #include "lib/film.h" #include "lib/ffmpeg_content.h" @@ -34,12 +35,14 @@ #include "test.h" #include + using std::string; using std::shared_ptr; using std::make_shared; using boost::optional; using namespace dcpomatic; + static void ffmpeg_content_test (int number, boost::filesystem::path content, ExportFormat format) { @@ -78,36 +81,41 @@ ffmpeg_content_test (int number, boost::filesystem::path content, ExportFormat f cl.run (); } + /** Red / green / blue MP4 -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test1) { ffmpeg_content_test (1, "test/data/test.mp4", ExportFormat::PRORES); } + /** Dolby Aurora trailer VOB -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test2) { ffmpeg_content_test (2, TestPaths::private_data() / "dolby_aurora.vob", ExportFormat::PRORES); } + /** Sintel trailer -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test3) { ffmpeg_content_test (3, TestPaths::private_data() / "Sintel_Trailer1.480p.DivX_Plus_HD.mkv", ExportFormat::PRORES); } + /** Big Buck Bunny trailer -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test4) { ffmpeg_content_test (4, TestPaths::private_data() / "big_buck_bunny_trailer_480p.mov", ExportFormat::PRORES); } + /** Still image -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test5) { auto film = new_test_film ("ffmpeg_encoder_prores_test5"); film->set_name ("ffmpeg_encoder_prores_test5"); - shared_ptr c (new ImageContent(TestPaths::private_data() / "bbc405.png")); + auto c = make_shared(TestPaths::private_data() / "bbc405.png"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); @@ -117,20 +125,21 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test5) c->video->set_length (240); film->write_metadata (); - shared_ptr job (new TranscodeJob (film)); + auto job = make_shared (film); FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test5.mov", ExportFormat::PRORES, false, false, false, 23); encoder.go (); } + /** Subs -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test6) { - shared_ptr film = new_test_film ("ffmpeg_encoder_prores_test6"); + auto film = new_test_film ("ffmpeg_encoder_prores_test6"); film->set_name ("ffmpeg_encoder_prores_test6"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr s (new StringTextFileContent("test/data/subrip2.srt")); + auto s = make_shared("test/data/subrip2.srt"); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->only_text()->set_colour (dcp::Colour (255, 255, 0)); @@ -138,50 +147,53 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test6) s->only_text()->set_effect_colour (dcp::Colour (0, 255, 255)); film->write_metadata(); - shared_ptr job (new TranscodeJob (film)); + auto job = make_shared (film); FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test6.mov", ExportFormat::PRORES, false, false, false, 23); encoder.go (); } + /** Video + subs -> Prores */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_prores_test7) { - shared_ptr film = new_test_film ("ffmpeg_encoder_prores_test7"); + auto film = new_test_film ("ffmpeg_encoder_prores_test7"); film->set_name ("ffmpeg_encoder_prores_test7"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr c (new FFmpegContent("test/data/test.mp4")); + auto c = make_shared("test/data/test.mp4"); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr s (new StringTextFileContent("test/data/subrip.srt")); + auto s = make_shared("test/data/subrip.srt"); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->only_text()->set_colour (dcp::Colour (255, 255, 0)); s->only_text()->set_effect (dcp::Effect::SHADOW); s->only_text()->set_effect_colour (dcp::Colour (0, 255, 255)); - shared_ptr job (new TranscodeJob (film)); + auto job = make_shared (film); FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_prores_test7.mov", ExportFormat::PRORES, false, false, false, 23); encoder.go (); } + /** Red / green / blue MP4 -> H264 */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test1) { ffmpeg_content_test(1, "test/data/test.mp4", ExportFormat::H264_AAC); } + /** Just subtitles -> H264 */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test2) { - shared_ptr film = new_test_film ("ffmpeg_encoder_h264_test2"); + auto film = new_test_film ("ffmpeg_encoder_h264_test2"); film->set_name ("ffmpeg_encoder_h264_test2"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr s (new StringTextFileContent("test/data/subrip2.srt")); + auto s = make_shared("test/data/subrip2.srt"); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->only_text()->set_colour (dcp::Colour (255, 255, 0)); @@ -189,24 +201,25 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test2) s->only_text()->set_effect_colour (dcp::Colour (0, 255, 255)); film->write_metadata(); - shared_ptr job (new TranscodeJob (film)); + auto job = make_shared (film); FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test2.mp4", ExportFormat::H264_AAC, false, false, false, 23); encoder.go (); } + /** Video + subs -> H264 */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test3) { - shared_ptr film = new_test_film ("ffmpeg_encoder_h264_test3"); + auto film = new_test_film ("ffmpeg_encoder_h264_test3"); film->set_name ("ffmpeg_encoder_h264_test3"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr c (new FFmpegContent("test/data/test.mp4")); + auto c = make_shared("test/data/test.mp4"); film->examine_and_add_content (c); - BOOST_REQUIRE (!wait_for_jobs ()); + BOOST_REQUIRE (!wait_for_jobs()); - shared_ptr s (new StringTextFileContent("test/data/subrip.srt")); + auto s = make_shared("test/data/subrip.srt"); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); s->only_text()->set_colour (dcp::Colour (255, 255, 0)); @@ -214,44 +227,45 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test3) s->only_text()->set_effect_colour (dcp::Colour (0, 255, 255)); film->write_metadata(); - shared_ptr job (new TranscodeJob (film)); + auto job = make_shared (film); FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test3.mp4", ExportFormat::H264_AAC, false, false, false, 23); encoder.go (); } + /** Scope-in-flat DCP -> H264 */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test4) { - shared_ptr film = new_test_film2("ffmpeg_encoder_h264_test4"); - film->examine_and_add_content(shared_ptr(new DCPContent("test/data/scope_dcp"))); + auto film = new_test_film2("ffmpeg_encoder_h264_test4", {make_shared("test/data/scope_dcp")}); BOOST_REQUIRE(!wait_for_jobs()); film->set_container(Ratio::from_id("185")); - shared_ptr job(new TranscodeJob(film)); + auto job = make_shared(film); FFmpegEncoder encoder(film, job, "build/test/ffmpeg_encoder_h264_test4.mp4", ExportFormat::H264_AAC, false, false, false, 23); encoder.go(); } + /** Test mixdown from 5.1 to stereo */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test5) { - shared_ptr film = new_test_film ("ffmpeg_transcoder_h264_test5"); + auto film = new_test_film ("ffmpeg_transcoder_h264_test5"); film->set_name ("ffmpeg_transcoder_h264_test5"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr L (new FFmpegContent("test/data/L.wav")); + auto L = make_shared("test/data/L.wav"); film->examine_and_add_content (L); - shared_ptr R (new FFmpegContent("test/data/R.wav")); + auto R = make_shared("test/data/R.wav"); film->examine_and_add_content (R); - shared_ptr C (new FFmpegContent("test/data/C.wav")); + auto C = make_shared("test/data/C.wav"); film->examine_and_add_content (C); - shared_ptr Ls (new FFmpegContent("test/data/Ls.wav")); + auto Ls = make_shared("test/data/Ls.wav"); film->examine_and_add_content (Ls); - shared_ptr Rs (new FFmpegContent("test/data/Rs.wav")); + auto Rs = make_shared("test/data/Rs.wav"); film->examine_and_add_content (Rs); - shared_ptr Lfe (new FFmpegContent("test/data/Lfe.wav")); + auto Lfe = make_shared("test/data/Lfe.wav"); film->examine_and_add_content (Lfe); BOOST_REQUIRE (!wait_for_jobs ()); @@ -282,62 +296,57 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test5) map.set (0, 5, 1); Rs->audio->set_mapping (map); - shared_ptr job (new TranscodeJob (film)); + auto job = make_shared (film); FFmpegEncoder encoder (film, job, "build/test/ffmpeg_encoder_h264_test5.mp4", ExportFormat::H264_AAC, true, false, false, 23); encoder.go (); check_ffmpeg ("build/test/ffmpeg_encoder_h264_test5.mp4", "test/data/ffmpeg_encoder_h264_test5.mp4", 1); } + /** Test export of a VF */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test6) { - shared_ptr film = new_test_film2 ("ffmpeg_encoder_h264_test6_ov"); - film->examine_and_add_content (shared_ptr(new ImageContent(TestPaths::private_data() / "bbc405.png"))); - BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); + auto film = new_test_film2 ("ffmpeg_encoder_h264_test6_ov"); + film->examine_and_add_content (make_shared(TestPaths::private_data() / "bbc405.png")); BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); - shared_ptr film2 = new_test_film2 ("ffmpeg_encoder_h264_test6_vf"); - shared_ptr ov (new DCPContent("build/test/ffmpeg_encoder_h264_test6_ov/" + film->dcp_name(false))); + auto film2 = new_test_film2 ("ffmpeg_encoder_h264_test6_vf"); + auto ov = make_shared("build/test/ffmpeg_encoder_h264_test6_ov/" + film->dcp_name(false)); film2->examine_and_add_content (ov); BOOST_REQUIRE (!wait_for_jobs()); ov->set_reference_video (true); - shared_ptr subs = content_factory("test/data/subrip.srt").front(); + auto subs = content_factory("test/data/subrip.srt").front(); film2->examine_and_add_content (subs); BOOST_REQUIRE (!wait_for_jobs()); for (auto i: subs->text) { i->set_use (true); } - shared_ptr job (new TranscodeJob (film2)); + auto job = make_shared (film2); FFmpegEncoder encoder (film2, job, "build/test/ffmpeg_encoder_h264_test6_vf.mp4", ExportFormat::H264_AAC, true, false, false, 23); encoder.go (); } + /** Test export of a 3D DCP in a 2D project */ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test7) { - shared_ptr film = new_test_film2 ("ffmpeg_encoder_h264_test7_data"); - shared_ptr L (shared_ptr(new ImageContent(TestPaths::private_data() / "bbc405.png"))); - film->examine_and_add_content (L); - shared_ptr R (shared_ptr(new ImageContent(TestPaths::private_data() / "bbc405.png"))); - film->examine_and_add_content (R); - BOOST_REQUIRE (!wait_for_jobs()); + auto L = make_shared(TestPaths::private_data() / "bbc405.png"); + auto R = make_shared(TestPaths::private_data() / "bbc405.png"); + auto film = new_test_film2 ("ffmpeg_encoder_h264_test7_data", {L, R}); L->video->set_frame_type (VideoFrameType::THREE_D_LEFT); L->set_position (film, DCPTime()); R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT); R->set_position (film, DCPTime()); film->set_three_d (true); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); - shared_ptr film2 = new_test_film2 ("ffmpeg_encoder_h264_test7_export"); - shared_ptr dcp (new DCPContent(film->dir(film->dcp_name()))); - film2->examine_and_add_content (dcp); - BOOST_REQUIRE (!wait_for_jobs()); + auto dcp = make_shared(film->dir(film->dcp_name())); + auto film2 = new_test_film2 ("ffmpeg_encoder_h264_test7_export", {dcp}); - shared_ptr job (new TranscodeJob (film2)); + auto job = make_shared (film2); FFmpegEncoder encoder (film2, job, "build/test/ffmpeg_encoder_h264_test7.mp4", ExportFormat::H264_AAC, true, false, false, 23); encoder.go (); } diff --git a/test/file_naming_test.cc b/test/file_naming_test.cc index 079026cba..0b76952a8 100644 --- a/test/file_naming_test.cc +++ b/test/file_naming_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2020 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/file_naming_test.cc * @brief Test how files in DCPs are named. * @ingroup feature */ + #include "test.h" #include "lib/config.h" #include "lib/film.h" @@ -35,8 +37,11 @@ #include #include + using std::string; using std::shared_ptr; +using std::make_shared; + class Keep { @@ -55,20 +60,21 @@ private: dcp::NameFormat _format; }; + BOOST_AUTO_TEST_CASE (file_naming_test) { Keep k; - Config::instance()->set_dcp_asset_filename_format (dcp::NameFormat ("%c")); + Config::instance()->set_dcp_asset_filename_format (dcp::NameFormat("%c")); - shared_ptr film = new_test_film ("file_naming_test"); + auto film = new_test_film ("file_naming_test"); film->set_name ("file_naming_test"); film->set_video_frame_rate (24); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); - shared_ptr r (new FFmpegContent("test/data/flat_red.png")); + auto r = make_shared("test/data/flat_red.png"); film->examine_and_add_content (r); - shared_ptr g (new FFmpegContent("test/data/flat_green.png")); + auto g = make_shared("test/data/flat_green.png"); film->examine_and_add_content (g); - shared_ptr b (new FFmpegContent("test/data/flat_blue.png")); + auto b = make_shared("test/data/flat_blue.png"); film->examine_and_add_content (b); BOOST_REQUIRE (!wait_for_jobs()); @@ -84,19 +90,20 @@ BOOST_AUTO_TEST_CASE (file_naming_test) film->set_reel_type (ReelType::BY_VIDEO_CONTENT); film->write_metadata (); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE, + dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE + }); int got[3] = { 0, 0, 0 }; - for ( - boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (film->file(film->dcp_name())); - i != boost::filesystem::directory_iterator(); - ++i) { - if (boost::regex_match(i->path().string(), boost::regex(".*flat_red\\.png_.*\\.mxf"))) { + for (auto i: boost::filesystem::directory_iterator(film->file(film->dcp_name()))) { + if (boost::regex_match(i.path().string(), boost::regex(".*flat_red\\.png_.*\\.mxf"))) { ++got[0]; - } else if (boost::regex_match(i->path().string(), boost::regex(".*flat_green\\.png_.*\\.mxf"))) { + } else if (boost::regex_match(i.path().string(), boost::regex(".*flat_green\\.png_.*\\.mxf"))) { ++got[1]; - } else if (boost::regex_match(i->path().string(), boost::regex(".*flat_blue\\.png_.*\\.mxf"))) { + } else if (boost::regex_match(i.path().string(), boost::regex(".*flat_blue\\.png_.*\\.mxf"))) { ++got[2]; } } @@ -106,12 +113,13 @@ BOOST_AUTO_TEST_CASE (file_naming_test) } } + BOOST_AUTO_TEST_CASE (file_naming_test2) { Keep k; Config::instance()->set_dcp_asset_filename_format (dcp::NameFormat ("%c")); - shared_ptr film = new_test_film ("file_naming_test2"); + auto film = new_test_film ("file_naming_test2"); film->set_name ("file_naming_test2"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); @@ -121,11 +129,11 @@ BOOST_AUTO_TEST_CASE (file_naming_test2) boost::filesystem::path::imbue(std::locale()); #endif - shared_ptr r (new FFmpegContent("test/data/flät_red.png")); + auto r = make_shared("test/data/flät_red.png"); film->examine_and_add_content (r); - shared_ptr g (new FFmpegContent("test/data/flat_green.png")); + auto g = make_shared("test/data/flat_green.png"); film->examine_and_add_content (g); - shared_ptr b (new FFmpegContent("test/data/flat_blue.png")); + auto b = make_shared("test/data/flat_blue.png"); film->examine_and_add_content (b); BOOST_REQUIRE (!wait_for_jobs()); @@ -140,19 +148,20 @@ BOOST_AUTO_TEST_CASE (file_naming_test2) b->video->set_length (24); film->set_reel_type (ReelType::BY_VIDEO_CONTENT); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE, + dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE + }); int got[3] = { 0, 0, 0 }; - for ( - boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (film->file(film->dcp_name())); - i != boost::filesystem::directory_iterator(); - ++i) { - if (boost::regex_match(i->path().string(), boost::regex(".*flat_red\\.png_.*\\.mxf"))) { + for (auto i: boost::filesystem::directory_iterator (film->file(film->dcp_name()))) { + if (boost::regex_match(i.path().string(), boost::regex(".*flat_red\\.png_.*\\.mxf"))) { ++got[0]; - } else if (boost::regex_match(i->path().string(), boost::regex(".*flat_green\\.png_.*\\.mxf"))) { + } else if (boost::regex_match(i.path().string(), boost::regex(".*flat_green\\.png_.*\\.mxf"))) { ++got[1]; - } else if (boost::regex_match(i->path().string(), boost::regex(".*flat_blue\\.png_.*\\.mxf"))) { + } else if (boost::regex_match(i.path().string(), boost::regex(".*flat_blue\\.png_.*\\.mxf"))) { ++got[2]; } } diff --git a/test/import_dcp_test.cc b/test/import_dcp_test.cc index 54cea296b..3620a55c5 100644 --- a/test/import_dcp_test.cc +++ b/test/import_dcp_test.cc @@ -65,8 +65,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_test) A->set_encrypted (true); BOOST_CHECK (!wait_for_jobs ()); - A->make_dcp (); - BOOST_CHECK (!wait_for_jobs ()); + make_and_verify_dcp (A); dcp::DCP A_dcp ("build/test/import_dcp_test/" + A->dcp_name()); A_dcp.read (); @@ -97,8 +96,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_test) JobManager::instance()->add (make_shared(B, d)); BOOST_CHECK (!wait_for_jobs ()); - B->make_dcp (); - BOOST_CHECK (!wait_for_jobs ()); + make_and_verify_dcp (B); /* Should be 1s red, 1s green, 1s blue */ check_dcp ("test/data/import_dcp_test2", "build/test/import_dcp_test2/" + B->dcp_name()); @@ -116,12 +114,11 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test) content->video->set_length (24 * 60 * 10); - film->set_marker(dcp::Marker::FFOC, dcpomatic::DCPTime::from_seconds(1.91)); + film->set_marker(dcp::Marker::FFOC, dcpomatic::DCPTime::from_frames(1, 24)); film->set_marker(dcp::Marker::FFMC, dcpomatic::DCPTime::from_seconds(9.4)); film->set_marker(dcp::Marker::LFMC, dcpomatic::DCPTime::from_seconds(9.99)); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); /* Import the DCP to a new film and check the markers */ auto imported = make_shared(film->dir(film->dcp_name())); @@ -134,8 +131,6 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test) BOOST_CHECK_EQUAL (imported->markers().size(), 4U); auto markers = imported->markers(); - BOOST_REQUIRE(markers.find(dcp::Marker::FFOC) != markers.end()); - BOOST_CHECK(markers[dcp::Marker::FFOC] == dcpomatic::ContentTime(184000)); BOOST_REQUIRE(markers.find(dcp::Marker::FFMC) != markers.end()); BOOST_CHECK(markers[dcp::Marker::FFMC] == dcpomatic::ContentTime(904000)); BOOST_REQUIRE(markers.find(dcp::Marker::LFMC) != markers.end()); @@ -151,8 +146,6 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test) BOOST_CHECK_EQUAL (reloaded->markers().size(), 4U); markers = reloaded->markers(); - BOOST_REQUIRE(markers.find(dcp::Marker::FFOC) != markers.end()); - BOOST_CHECK(markers[dcp::Marker::FFOC] == dcpomatic::ContentTime(184000)); BOOST_REQUIRE(markers.find(dcp::Marker::FFMC) != markers.end()); BOOST_CHECK(markers[dcp::Marker::FFMC] == dcpomatic::ContentTime(904000)); BOOST_REQUIRE(markers.find(dcp::Marker::LFMC) != markers.end()); @@ -179,8 +172,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_metadata_test) vector cv = { "Fred "}; film->set_content_versions (cv); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); /* Import the DCP to a new film and check the metadata */ auto film2 = new_test_film2 ("import_dcp_metadata_test2"); diff --git a/test/j2k_bandwidth_test.cc b/test/j2k_bandwidth_test.cc index c114cbfe7..182505107 100644 --- a/test/j2k_bandwidth_test.cc +++ b/test/j2k_bandwidth_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/bandwidth_test.cc * @brief Test whether we output whatever J2K bandwidth is requested. * @ingroup feature */ + #include "test.h" #include "lib/dcp_content_type.h" #include "lib/film.h" @@ -32,29 +34,36 @@ #include +using std::make_shared; using std::string; using std::shared_ptr; + static void check (int target_bits_per_second) { int const duration = 10; string const name = "bandwidth_test_" + dcp::raw_convert (target_bits_per_second); - shared_ptr film = new_test_film (name); + auto film = new_test_film (name); film->set_name (name); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); film->set_j2k_bandwidth (target_bits_per_second); - shared_ptr content (new ImageContent(TestPaths::private_data() / "prophet_frame.tiff")); + auto content = make_shared(TestPaths::private_data() / "prophet_frame.tiff"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); content->video->set_length (24 * duration); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE, + dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, + dcp::VerificationNote::Code::NEARLY_INVALID_PICTURE_FRAME_SIZE_IN_BYTES + }); - boost::filesystem::directory_iterator i (boost::filesystem::path ("build") / "test" / name / "video"); + boost::filesystem::directory_iterator i (boost::filesystem::path("build") / "test" / name / "video"); boost::filesystem::path test = *i++; - BOOST_REQUIRE (i == boost::filesystem::directory_iterator ()); + BOOST_REQUIRE (i == boost::filesystem::directory_iterator()); double actual_bits_per_second = boost::filesystem::file_size(test) * 8.0 / duration; @@ -63,6 +72,7 @@ check (int target_bits_per_second) BOOST_CHECK ((actual_bits_per_second / target_bits_per_second) < 1.15); } + BOOST_AUTO_TEST_CASE (bandwidth_test) { check (50000000); diff --git a/test/markers_test.cc b/test/markers_test.cc index 1541348d1..70f4cad82 100644 --- a/test/markers_test.cc +++ b/test/markers_test.cc @@ -49,8 +49,7 @@ BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test1) BOOST_REQUIRE (!wait_for_jobs()); film->set_interop (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name())); dcp.read (); @@ -81,8 +80,12 @@ BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test2) film->set_interop (false); film->set_marker (dcp::Marker::FFOC, dcpomatic::DCPTime::from_seconds(1)); film->set_marker (dcp::Marker::LFOC, dcpomatic::DCPTime::from_seconds(9)); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::INCORRECT_FFOC, + dcp::VerificationNote::Code::INCORRECT_LFOC + }); dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name())); dcp.read (); diff --git a/test/optimise_stills_test.cc b/test/optimise_stills_test.cc index cec864e0f..f2690f61e 100644 --- a/test/optimise_stills_test.cc +++ b/test/optimise_stills_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "lib/dcp_encoder.h" #include "lib/writer.h" #include "lib/transcode_job.h" @@ -33,6 +34,7 @@ #include #include + using std::getline; using std::ifstream; using std::string; @@ -42,6 +44,7 @@ using boost::split; using std::dynamic_pointer_cast; using std::shared_ptr; + static void check (string name, int check_full, int check_repeat) @@ -69,38 +72,38 @@ check (string name, int check_full, int check_repeat) BOOST_CHECK_EQUAL (repeat, check_repeat); } + /** Make a 2D DCP out of a 2D still and check that the J2K encoding is only done once for each frame */ BOOST_AUTO_TEST_CASE (optimise_stills_test1) { - shared_ptr film = new_test_film ("optimise_stills_test1"); + auto film = new_test_film ("optimise_stills_test1"); LogSwitcher ls (film->log()); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); - shared_ptr content = content_factory("test/data/flat_red.png").front (); + auto content = content_factory("test/data/flat_red.png").front (); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); check ("optimise_stills_test1", 1, 10 * 24 - 1); } + /** Make a 3D DCP out of a 3D L/R still and check that the J2K encoding is only done once for L and R */ BOOST_AUTO_TEST_CASE (optimise_stills_test2) { - shared_ptr film = new_test_film ("optimise_stills_test2"); + auto film = new_test_film ("optimise_stills_test2"); LogSwitcher ls (film->log()); film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); + film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR")); film->set_name ("frobozz"); - shared_ptr content = content_factory("test/data/flat_red.png").front (); + auto content = content_factory("test/data/flat_red.png").front(); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); content->video->set_frame_type (VideoFrameType::THREE_D_LEFT_RIGHT); film->set_three_d (true); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); check ("optimise_stills_test2", 2, 10 * 48 - 2); } diff --git a/test/overlap_video_test.cc b/test/overlap_video_test.cc index 246a75834..7268070d5 100644 --- a/test/overlap_video_test.cc +++ b/test/overlap_video_test.cc @@ -67,8 +67,7 @@ BOOST_AUTO_TEST_CASE (overlap_video_test1) BOOST_CHECK (player->_black.done()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); dcp::DCP back (film->dir(film->dcp_name())); back.read (); diff --git a/test/player_test.cc b/test/player_test.cc index 9194b84bb..c325537fa 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2019 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/player_test.cc * @brief Test Player class. * @ingroup selfcontained */ + #include "lib/film.h" #include "lib/ffmpeg_content.h" #include "lib/dcp_content_type.h" @@ -43,10 +45,12 @@ #include #include + using std::cout; using std::list; using std::pair; using std::shared_ptr; +using std::make_shared; using boost::bind; using boost::optional; #if BOOST_VERSION >= 106100 @@ -54,8 +58,10 @@ using namespace boost::placeholders; #endif using namespace dcpomatic; + static shared_ptr accumulated; + static void accumulate (shared_ptr audio, DCPTime) { @@ -63,21 +69,22 @@ accumulate (shared_ptr audio, DCPTime) accumulated->append (audio); } + /** Check that the Player correctly generates silence when used with a silent FFmpegContent */ BOOST_AUTO_TEST_CASE (player_silence_padding_test) { - shared_ptr film = new_test_film ("player_silence_padding_test"); + auto film = new_test_film ("player_silence_padding_test"); film->set_name ("player_silence_padding_test"); - shared_ptr c (new FFmpegContent("test/data/test.mp4")); + auto c = std::make_shared("test/data/test.mp4"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); - accumulated.reset (new AudioBuffers (film->audio_channels(), 0)); + accumulated = std::make_shared(film->audio_channels(), 0); - shared_ptr player (new Player(film)); + auto player = std::make_shared(film); player->Audio.connect (bind (&accumulate, _1, _2)); while (!player->pass ()) {} BOOST_REQUIRE (accumulated->frames() >= 48000); @@ -90,17 +97,18 @@ BOOST_AUTO_TEST_CASE (player_silence_padding_test) } } + /* Test insertion of black frames between separate bits of video content */ BOOST_AUTO_TEST_CASE (player_black_fill_test) { - shared_ptr film = new_test_film ("black_fill_test"); + auto film = new_test_film ("black_fill_test"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); 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("test/data/simple_testcard_640x480.png")); - shared_ptr contentB (new ImageContent("test/data/simple_testcard_640x480.png")); + auto contentA = std::make_shared("test/data/simple_testcard_640x480.png"); + auto contentB = std::make_shared("test/data/simple_testcard_640x480.png"); film->examine_and_add_content (contentA); film->examine_and_add_content (contentB); @@ -113,9 +121,12 @@ BOOST_AUTO_TEST_CASE (player_black_fill_test) contentB->set_position (film, DCPTime::from_frames(7, film->video_frame_rate())); contentB->video->set_custom_ratio (1.85); - film->make_dcp (); - - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE, + dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE + }); boost::filesystem::path ref; ref = "test"; @@ -131,19 +142,20 @@ BOOST_AUTO_TEST_CASE (player_black_fill_test) check_dcp (ref.string(), check.string()); } + /** Check behaviour with an awkward playlist whose data does not end on a video frame start */ BOOST_AUTO_TEST_CASE (player_subframe_test) { - shared_ptr film = new_test_film ("reels_test7"); + auto film = new_test_film ("reels_test7"); film->set_name ("reels_test7"); - film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); - shared_ptr A = content_factory("test/data/flat_red.png").front(); + film->set_container (Ratio::from_id("185")); + film->set_dcp_content_type (DCPContentType::from_isdcf_name("TST")); + auto A = content_factory("test/data/flat_red.png").front(); film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr B = content_factory("test/data/awkward_length.wav").front(); + BOOST_REQUIRE (!wait_for_jobs()); + auto B = content_factory("test/data/awkward_length.wav").front(); film->examine_and_add_content (B); - BOOST_REQUIRE (!wait_for_jobs ()); + BOOST_REQUIRE (!wait_for_jobs()); film->set_video_frame_rate (24); A->video->set_length (3 * 24); @@ -152,7 +164,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)); - shared_ptr player (new Player(film)); + auto player = std::make_shared(film); 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))); @@ -160,9 +172,11 @@ BOOST_AUTO_TEST_CASE (player_subframe_test) BOOST_CHECK (player->_silent._periods.front() == DCPTimePeriod(DCPTime(289920), DCPTime::from_frames(3 * 24 + 1, 24))); } + static Frame video_frames; static Frame audio_frames; + static void video (shared_ptr, DCPTime) { @@ -175,23 +189,24 @@ audio (shared_ptr audio, DCPTime) audio_frames += audio->frames(); } + /** Check with a video-only file that the video and audio emissions happen more-or-less together */ BOOST_AUTO_TEST_CASE (player_interleave_test) { - shared_ptr film = new_test_film ("ffmpeg_transcoder_basic_test_subs"); + auto film = new_test_film ("ffmpeg_transcoder_basic_test_subs"); film->set_name ("ffmpeg_transcoder_basic_test"); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); - shared_ptr c (new FFmpegContent("test/data/test.mp4")); + auto c = std::make_shared("test/data/test.mp4"); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr s (new StringTextFileContent("test/data/subrip.srt")); + auto s = std::make_shared("test/data/subrip.srt"); film->examine_and_add_content (s); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr player (new Player(film)); + auto player = std::make_shared(film); player->Video.connect (bind (&video, _1, _2)); player->Audio.connect (bind (&audio, _1, _2)); video_frames = audio_frames = 0; @@ -200,6 +215,7 @@ BOOST_AUTO_TEST_CASE (player_interleave_test) } } + /** 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 @@ -207,24 +223,24 @@ BOOST_AUTO_TEST_CASE (player_interleave_test) */ BOOST_AUTO_TEST_CASE (player_seek_test) { - shared_ptr film (new Film (optional())); - shared_ptr dcp (new DCPContent(TestPaths::private_data() / "awkward_subs")); + auto film = std::make_shared(optional()); + auto dcp = std::make_shared(TestPaths::private_data() / "awkward_subs"); film->examine_and_add_content (dcp, true); BOOST_REQUIRE (!wait_for_jobs ()); dcp->only_text()->set_use (true); - shared_ptr player (new Player(film)); + auto player = std::make_shared(film); player->set_fast (); player->set_always_burn_open_subtitles (); player->set_play_referenced (); - shared_ptr butler (new Butler (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, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true); butler->disable_audio(); for (int i = 0; i < 10; ++i) { - DCPTime t = DCPTime::from_frames (i, 24); + auto t = DCPTime::from_frames (i, 24); butler->seek (t, true); - pair, DCPTime> video = butler->get_video(true, 0); + auto video = butler->get_video(true, 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)); /* This 14.08 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine @@ -235,29 +251,30 @@ BOOST_AUTO_TEST_CASE (player_seek_test) } } + /** 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(TestPaths::private_data() / "awkward_subs2")); + auto film = std::make_shared(optional()); + auto dcp = std::make_shared(TestPaths::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)); + auto player = std::make_shared(film); player->set_fast (); player->set_always_burn_open_subtitles (); player->set_play_referenced (); - shared_ptr butler (new Butler(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, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true); 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); + auto t = DCPTime::from_seconds(5) + DCPTime::from_frames (i, 24); butler->seek (t, true); - pair, DCPTime> video = butler->get_video(true, 0); + auto video = butler->get_video(true, 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) @@ -266,25 +283,26 @@ BOOST_AUTO_TEST_CASE (player_seek_test2) } } + /** 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("test/data/flat_red.png").front(); + auto film = new_test_film2 ("player_trim_test"); + auto A = content_factory("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("test/data/flat_red.png").front(); + auto B = content_factory("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 (film, DCPTime::from_seconds(10)); B->set_trim_start (ContentTime::from_seconds (2)); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); } + struct Sub { PlayerText text; TextType type; @@ -292,6 +310,7 @@ struct Sub { DCPTimePeriod period; }; + static void store (list* out, PlayerText text, TextType type, optional track, DCPTimePeriod period) { @@ -303,19 +322,20 @@ store (list* out, PlayerText text, TextType type, optional tr 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(TestPaths::private_data() / "boon_telly.mkv").front(); + auto film = new_test_film2 ("player_ignore_video_and_audio_test"); + auto ff = content_factory(TestPaths::private_data() / "boon_telly.mkv").front(); film->examine_and_add_content (ff); - shared_ptr text = content_factory("test/data/subrip.srt").front(); + auto text = content_factory("test/data/subrip.srt").front(); film->examine_and_add_content (text); BOOST_REQUIRE (!wait_for_jobs()); text->only_text()->set_type (TextType::CLOSED_CAPTION); text->only_text()->set_use (true); - shared_ptr player (new Player(film)); + auto player = std::make_shared(film); player->set_ignore_video (); player->set_ignore_audio (); @@ -326,17 +346,18 @@ BOOST_AUTO_TEST_CASE (player_ignore_video_and_audio_test) BOOST_CHECK_EQUAL (out.size(), 6U); } + /** Trigger a crash due to the assertion failure in Player::emit_audio */ BOOST_AUTO_TEST_CASE (player_trim_crash) { - shared_ptr film = new_test_film2 ("player_trim_crash"); - shared_ptr boon = content_factory(TestPaths::private_data() / "boon_telly.mkv").front(); + auto film = new_test_film2 ("player_trim_crash"); + auto boon = content_factory(TestPaths::private_data() / "boon_telly.mkv").front(); film->examine_and_add_content (boon); BOOST_REQUIRE (!wait_for_jobs()); - shared_ptr player (new Player(film)); + auto player = std::make_shared(film); player->set_fast (); - shared_ptr butler (new Butler(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, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, true); /* Wait for the butler to fill */ dcpomatic_sleep_seconds (5); @@ -351,27 +372,28 @@ BOOST_AUTO_TEST_CASE (player_trim_crash) butler->rethrow (); } + /** Test a crash when the gap between the last audio and the start of a silent period is more than 1 sample */ BOOST_AUTO_TEST_CASE (player_silence_crash) { - shared_ptr film = new_test_film2 ("player_silence_crash"); - shared_ptr sine = content_factory("test/data/impulse_train.wav").front(); + auto film = new_test_film2 ("player_silence_crash"); + auto sine = content_factory("test/data/impulse_train.wav").front(); film->examine_and_add_content (sine); BOOST_REQUIRE (!wait_for_jobs()); sine->set_video_frame_rate (23.976); film->write_metadata (); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::MISSING_CPL_METADATA}); } + /** Test a crash when processing a 3D DCP */ BOOST_AUTO_TEST_CASE (player_3d_test_1) { - shared_ptr film = new_test_film2 ("player_3d_test_1a"); - shared_ptr left = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("player_3d_test_1a"); + auto left = content_factory("test/data/flat_red.png").front(); film->examine_and_add_content (left); - shared_ptr right = content_factory("test/data/flat_blue.png").front(); + auto right = content_factory("test/data/flat_blue.png").front(); film->examine_and_add_content (right); BOOST_REQUIRE (!wait_for_jobs()); @@ -381,28 +403,22 @@ BOOST_AUTO_TEST_CASE (player_3d_test_1) right->set_position (film, DCPTime()); film->set_three_d (true); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); - shared_ptr film2 = new_test_film2 ("player_3d_test_1b"); - shared_ptr dcp(new DCPContent(film->dir(film->dcp_name()))); - film2->examine_and_add_content (dcp); - BOOST_REQUIRE (!wait_for_jobs()); + auto dcp = std::make_shared(film->dir(film->dcp_name())); + auto film2 = new_test_film2 ("player_3d_test_1b", {dcp}); film2->set_three_d (true); - film2->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film2); } + /** Test a crash when processing a 3D DCP as content in a 2D project */ BOOST_AUTO_TEST_CASE (player_3d_test_2) { - shared_ptr film = new_test_film2 ("player_3d_test_2a"); - shared_ptr left = content_factory("test/data/flat_red.png").front(); - film->examine_and_add_content (left); - shared_ptr right = content_factory("test/data/flat_blue.png").front(); - film->examine_and_add_content (right); - BOOST_REQUIRE (!wait_for_jobs()); + auto left = content_factory("test/data/flat_red.png").front(); + auto right = content_factory("test/data/flat_blue.png").front(); + auto film = new_test_film2 ("player_3d_test_2a", {left, right}); left->video->set_frame_type (VideoFrameType::THREE_D_LEFT); left->set_position (film, DCPTime()); @@ -410,53 +426,44 @@ BOOST_AUTO_TEST_CASE (player_3d_test_2) right->set_position (film, DCPTime()); film->set_three_d (true); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); - shared_ptr film2 = new_test_film2 ("player_3d_test_2b"); - shared_ptr dcp(new DCPContent(film->dir(film->dcp_name()))); - film2->examine_and_add_content (dcp); - BOOST_REQUIRE (!wait_for_jobs()); + auto dcp = std::make_shared(film->dir(film->dcp_name())); + auto film2 = new_test_film2 ("player_3d_test_2b", {dcp}); - film2->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film2); } + /** Test a crash when there is video-only content at the end of the DCP and a frame-rate conversion is happening; * #1691. */ BOOST_AUTO_TEST_CASE (player_silence_at_end_crash) { /* 25fps DCP with some audio */ - shared_ptr film1 = new_test_film2 ("player_silence_at_end_crash_1"); - shared_ptr content1 = content_factory("test/data/flat_red.png").front(); - film1->examine_and_add_content (content1); - BOOST_REQUIRE (!wait_for_jobs()); + auto content1 = content_factory("test/data/flat_red.png").front(); + auto film1 = new_test_film2 ("player_silence_at_end_crash_1", {content1}); content1->video->set_length (25); film1->set_video_frame_rate (25); - film1->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film1); /* Make another project importing this DCP */ - shared_ptr film2 = new_test_film2 ("player_silence_at_end_crash_2"); - shared_ptr content2(new DCPContent(film1->dir(film1->dcp_name()))); - film2->examine_and_add_content (content2); - BOOST_REQUIRE (!wait_for_jobs()); + auto content2 = std::make_shared(film1->dir(film1->dcp_name())); + auto film2 = new_test_film2 ("player_silence_at_end_crash_2", {content2}); /* and importing just the video MXF on its own at the end */ optional video; - for (boost::filesystem::directory_iterator i(film1->dir(film1->dcp_name())); i != boost::filesystem::directory_iterator(); ++i) { - if (boost::starts_with(i->path().filename().string(), "j2c_")) { - video = i->path(); + for (auto i: boost::filesystem::directory_iterator(film1->dir(film1->dcp_name()))) { + if (boost::starts_with(i.path().filename().string(), "j2c_")) { + video = i.path(); } } BOOST_REQUIRE (video); - shared_ptr content3 = content_factory(*video).front(); + auto content3 = content_factory(*video).front(); film2->examine_and_add_content (content3); BOOST_REQUIRE (!wait_for_jobs()); content3->set_position (film2, DCPTime::from_seconds(1.5)); film2->set_video_frame_rate (24); - film2->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film2); } diff --git a/test/recover_test.cc b/test/recover_test.cc index 164bf2322..b36dad05a 100644 --- a/test/recover_test.cc +++ b/test/recover_test.cc @@ -68,8 +68,12 @@ BOOST_AUTO_TEST_CASE (recover_test_2d) film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE, + dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE + }); boost::filesystem::path const video = "build/test/recover_test_2d/video/185_2K_02543352c540f4b083bff3f1e309d4a9_24_100000000_P_S_0_1200000.mxf"; boost::filesystem::copy_file ( diff --git a/test/remake_id_test.cc b/test/remake_id_test.cc index 8f8ab820b..c4953f980 100644 --- a/test/remake_id_test.cc +++ b/test/remake_id_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2018 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "lib/ffmpeg_content.h" #include "lib/content_factory.h" #include "lib/text_content.h" @@ -30,11 +31,14 @@ #include #include + using std::string; using std::vector; using std::shared_ptr; -using boost::optional; using std::dynamic_pointer_cast; +using std::make_shared; +using boost::optional; + /** Check for bug #1126 whereby making a new DCP using the same video asset as an old one * corrupts the old one. @@ -42,54 +46,47 @@ using std::dynamic_pointer_cast; BOOST_AUTO_TEST_CASE (remake_id_test1) { /* Make a DCP */ - shared_ptr film = new_test_film2 ("remake_id_test1_1"); - shared_ptr content = content_factory("test/data/flat_red.png").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + auto content = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("remake_id_test1_1", {content}); + make_and_verify_dcp (film); /* Copy the video file */ - boost::filesystem::path first_video = dcp_file(film, "j2c"); + auto first_video = dcp_file(film, "j2c"); boost::filesystem::copy_file (first_video, first_video.string() + ".copy"); /* Make a new DCP with the same video file */ film->set_name ("remake_id_test1_2"); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); /* Check that the video in the first DCP hasn't changed */ check_file (first_video, first_video.string() + ".copy"); } + /** Check for bug #1232 where remaking an encrypted DCP causes problems with HMAC IDs (?) */ BOOST_AUTO_TEST_CASE (remake_id_test2) { /* Make a DCP */ - shared_ptr film = new_test_film2 ("remake_id_test2_1"); - shared_ptr content = content_factory("test/data/flat_red.png").front(); - film->examine_and_add_content (content); + auto content = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("remake_id_test2_1", {content}); film->set_encrypted (true); - BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); /* Remove and remake it */ boost::filesystem::remove_all(film->dir(film->dcp_name())); - film->make_dcp(); - BOOST_REQUIRE(!wait_for_jobs()); + make_and_verify_dcp (film); /* Find the CPL */ optional cpl; - for (boost::filesystem::directory_iterator i(film->dir(film->dcp_name())); i != boost::filesystem::directory_iterator(); ++i) { - if (i->path().filename().string().substr(0, 4) == "cpl_") { - cpl = i->path(); + for (auto i: boost::filesystem::directory_iterator(film->dir(film->dcp_name()))) { + if (i.path().filename().string().substr(0, 4) == "cpl_") { + cpl = i.path(); } } BOOST_REQUIRE(cpl); /* Make a DKDM */ - dcp::EncryptedKDM kdm = film->make_kdm ( + auto kdm = film->make_kdm ( Config::instance()->decryption_chain()->leaf(), vector(), *cpl, @@ -101,13 +98,10 @@ BOOST_AUTO_TEST_CASE (remake_id_test2) ); /* Import the DCP into a new film */ - shared_ptr film2 = new_test_film2("remake_id_test2_2"); - shared_ptr dcp_content(new DCPContent(film->dir(film->dcp_name()))); - film2->examine_and_add_content(dcp_content); - BOOST_REQUIRE(!wait_for_jobs()); + auto dcp_content = make_shared(film->dir(film->dcp_name())); + auto film2 = new_test_film2("remake_id_test2_2", {dcp_content}); dcp_content->add_kdm(kdm); - JobManager::instance()->add(shared_ptr(new ExamineContentJob(film2, dcp_content))); - BOOST_REQUIRE(!wait_for_jobs()); - film2->make_dcp(); + JobManager::instance()->add(make_shared(film2, dcp_content)); BOOST_REQUIRE(!wait_for_jobs()); + make_and_verify_dcp (film2); } diff --git a/test/remake_with_subtitle_test.cc b/test/remake_with_subtitle_test.cc index 81738c2ea..3b6cf930c 100644 --- a/test/remake_with_subtitle_test.cc +++ b/test/remake_with_subtitle_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "lib/ffmpeg_content.h" #include "lib/content_factory.h" #include "lib/text_content.h" @@ -25,28 +26,28 @@ #include "test.h" #include + using std::shared_ptr; using std::dynamic_pointer_cast; + /** Check that if we remake a DCP having turned off subtitles the code notices * and doesn't re-use the old video data. */ BOOST_AUTO_TEST_CASE (remake_with_subtitle_test) { - shared_ptr film = new_test_film2 ("remake_with_subtitle_test"); - shared_ptr content = dynamic_pointer_cast(content_factory(TestPaths::private_data() / "prophet_short_clip.mkv").front()); + auto film = new_test_film2 ("remake_with_subtitle_test"); + auto content = dynamic_pointer_cast(content_factory(TestPaths::private_data() / "prophet_short_clip.mkv").front()); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); content->only_text()->set_burn (true); content->only_text()->set_use (true); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); boost::filesystem::remove_all (film->dir (film->dcp_name(), false)); content->only_text()->set_use (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); check_one_frame (film->dir(film->dcp_name()), 325, TestPaths::private_data() / "prophet_frame_325_no_subs.j2c"); } diff --git a/test/scaling_test.cc b/test/scaling_test.cc index 809748e28..c361da80b 100644 --- a/test/scaling_test.cc +++ b/test/scaling_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/scaling_test.cc * @brief Test scaling and black-padding of images from a still-image source. * @ingroup feature */ + #include #include "lib/image_content.h" #include "lib/ratio.h" @@ -31,17 +33,23 @@ #include "lib/video_content.h" #include "test.h" + using std::string; using std::shared_ptr; +using std::make_shared; + static void scaling_test_for (shared_ptr film, shared_ptr content, float ratio, std::string image, string container) { content->video->set_custom_ratio (ratio); film->set_container (Ratio::from_id (container)); film->set_interop (false); - film->make_dcp (); - - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE, + dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE + }); boost::filesystem::path ref; ref = "test"; @@ -57,12 +65,13 @@ static void scaling_test_for (shared_ptr film, shared_ptr content check_dcp (ref.string(), check.string()); } + BOOST_AUTO_TEST_CASE (scaling_test) { - shared_ptr film = new_test_film ("scaling_test"); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); + auto film = new_test_film ("scaling_test"); + film->set_dcp_content_type (DCPContentType::from_isdcf_name("FTR")); film->set_name ("scaling_test"); - shared_ptr imc (new ImageContent("test/data/simple_testcard_640x480.png")); + auto imc = make_shared("test/data/simple_testcard_640x480.png"); film->examine_and_add_content (imc); diff --git a/test/skip_frame_test.cc b/test/skip_frame_test.cc index 928d173df..d096e50e5 100644 --- a/test/skip_frame_test.cc +++ b/test/skip_frame_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2016 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + /** @file test/skip_frame_test.cc * @brief Test the skip of frames by the player when putting a 48fps * source into a 24fps DCP. @@ -26,6 +27,7 @@ * @see test/repeat_frame_test.cc */ + #include #include "test.h" #include "lib/film.h" @@ -34,16 +36,19 @@ #include "lib/dcp_content_type.h" #include "lib/video_content.h" + using std::shared_ptr; +using std::make_shared; + BOOST_AUTO_TEST_CASE (skip_frame_test) { - shared_ptr film = new_test_film ("skip_frame_test"); + auto film = new_test_film ("skip_frame_test"); film->set_name ("skip_frame_test"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); film->set_interop (false); - shared_ptr c (new FFmpegContent("test/data/count300bd48.m2ts")); + auto c = make_shared("test/data/count300bd48.m2ts"); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); @@ -51,8 +56,7 @@ BOOST_AUTO_TEST_CASE (skip_frame_test) film->write_metadata (); film->set_video_frame_rate (24); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); /* Should be white numbers on a black background counting up from 2 in steps of 2 up to 300. diff --git a/test/srt_subtitle_test.cc b/test/srt_subtitle_test.cc index 1d8fb89da..cd4ce3a05 100644 --- a/test/srt_subtitle_test.cc +++ b/test/srt_subtitle_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/srt_subtitle_test.cc * @brief Test writing DCPs with subtitles from .srt. * @ingroup feature */ + #include "lib/film.h" #include "lib/string_text_file_content.h" #include "lib/dcp_content_type.h" @@ -34,43 +36,53 @@ #include #include + using std::string; using std::list; using std::shared_ptr; +using std::make_shared; using namespace dcpomatic; + /** Make a very short DCP with a single subtitle from .srt with no specified fonts */ BOOST_AUTO_TEST_CASE (srt_subtitle_test) { - shared_ptr film = new_test_film ("srt_subtitle_test"); + auto film = new_test_film ("srt_subtitle_test"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_audio_channels (6); film->set_interop (false); - shared_ptr content (new StringTextFileContent("test/data/subrip2.srt")); + auto content = make_shared("test/data/subrip2.srt"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); content->only_text()->set_use (true); content->only_text()->set_burn (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_CPL_METADATA + }); + /* Should be blank video with a subtitle MXF */ check_dcp ("test/data/srt_subtitle_test", film->dir (film->dcp_name ())); } + /** Same again but with a `font' specified */ BOOST_AUTO_TEST_CASE (srt_subtitle_test2) { - shared_ptr film = new_test_film ("srt_subtitle_test2"); + auto film = new_test_film ("srt_subtitle_test2"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_audio_channels (6); film->set_interop (false); - shared_ptr content (new StringTextFileContent ("test/data/subrip2.srt")); + auto content = make_shared ("test/data/subrip2.srt"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); @@ -79,29 +91,34 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test2) /* Use test/data/subrip2.srt as if it were a font file */ content->only_text()->fonts().front()->set_file("test/data/subrip2.srt"); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_CPL_METADATA + }); /* Should be blank video with a subtitle MXF */ check_dcp ("test/data/srt_subtitle_test2", film->dir (film->dcp_name ())); } + static void check_subtitle_file (shared_ptr film, boost::filesystem::path ref) { /* Find the subtitle file and check it */ - list ignore; - ignore.push_back ("SubtitleID"); - check_xml (subtitle_file(film), ref, ignore); + check_xml (subtitle_file(film), ref, {"SubtitleID"}); } + /** Make another DCP with a longer .srt file */ BOOST_AUTO_TEST_CASE (srt_subtitle_test3) { Cleanup cl; - shared_ptr content (new StringTextFileContent(TestPaths::private_data() / "Ankoemmling_short.srt")); - shared_ptr film = new_test_film2 ("srt_subtitle_test3", { content }, &cl); + auto content = make_shared(TestPaths::private_data() / "Ankoemmling_short.srt"); + auto film = new_test_film2 ("srt_subtitle_test3", { content }, &cl); film->set_name ("frobozz"); film->set_interop (true); @@ -117,65 +134,76 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test3) cl.run (); } + /** Build a small DCP with no picture and a single subtitle overlaid onto it */ BOOST_AUTO_TEST_CASE (srt_subtitle_test4) { - shared_ptr film = new_test_film ("srt_subtitle_test4"); + auto film = new_test_film ("srt_subtitle_test4"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (false); - shared_ptr content (new StringTextFileContent("test/data/subrip2.srt")); + auto content = make_shared("test/data/subrip2.srt"); content->only_text()->set_use (true); content->only_text()->set_burn (false); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_CPL_METADATA + }); /* Should be blank video with MXF subtitles */ check_dcp ("test/data/xml_subtitle_test", film->dir (film->dcp_name ())); } + /** Check the subtitle XML when there are two subtitle files in the project */ BOOST_AUTO_TEST_CASE (srt_subtitle_test5) { - shared_ptr film = new_test_film ("srt_subtitle_test5"); + auto film = new_test_film ("srt_subtitle_test5"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (true); film->set_sequence (false); - shared_ptr content (new StringTextFileContent("test/data/subrip2.srt")); + auto content = make_shared("test/data/subrip2.srt"); content->only_text()->set_use (true); content->only_text()->set_burn (false); film->examine_and_add_content (content); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); content->set_position (film, DCPTime()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); - film->write_metadata (); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_STANDARD}); check_dcp ("test/data/xml_subtitle_test2", film->dir (film->dcp_name ())); } + BOOST_AUTO_TEST_CASE (srt_subtitle_test6) { - shared_ptr film = new_test_film2 ("srt_subtitle_test6"); + auto content = make_shared("test/data/frames.srt"); + auto film = new_test_film2 ("srt_subtitle_test6", {content}); film->set_interop (false); - shared_ptr content (new StringTextFileContent("test/data/frames.srt")); content->only_text()->set_use (true); content->only_text()->set_burn (false); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); - film->write_metadata (); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_CPL_METADATA, + dcp::VerificationNote::Code::INVALID_SUBTITLE_DURATION, + dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING, + }); check_dcp ("test/data/srt_subtitle_test6", film->dir(film->dcp_name())); } + #if 0 /* XXX: this is disabled; there is some difference in font rendering between the test machine and others. diff --git a/test/subtitle_reel_number_test.cc b/test/subtitle_reel_number_test.cc index b19fd1cd0..98974f1b3 100644 --- a/test/subtitle_reel_number_test.cc +++ b/test/subtitle_reel_number_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "lib/string_text_file_content.h" #include "lib/film.h" #include "lib/ratio.h" @@ -32,18 +33,21 @@ #include #include -using std::string; -using std::shared_ptr; + using std::dynamic_pointer_cast; +using std::make_shared; +using std::shared_ptr; +using std::string; + /* Check that ReelNumber is setup correctly when making multi-reel subtitled DCPs */ BOOST_AUTO_TEST_CASE (subtitle_reel_number_test) { - shared_ptr film = new_test_film ("subtitle_reel_number_test"); + auto film = new_test_film ("subtitle_reel_number_test"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); - shared_ptr content (new StringTextFileContent("test/data/subrip5.srt")); + auto content = make_shared("test/data/subrip5.srt"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); content->only_text()->set_use (true); @@ -51,8 +55,7 @@ BOOST_AUTO_TEST_CASE (subtitle_reel_number_test) film->set_reel_type (ReelType::BY_LENGTH); film->set_interop (true); film->set_reel_length (1024 * 1024 * 512); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_STANDARD}); dcp::DCP dcp ("build/test/subtitle_reel_number_test/" + film->dcp_name()); dcp.read (); diff --git a/test/subtitle_reel_test.cc b/test/subtitle_reel_test.cc index c910d4aec..e56f9664a 100644 --- a/test/subtitle_reel_test.cc +++ b/test/subtitle_reel_test.cc @@ -67,8 +67,7 @@ BOOST_AUTO_TEST_CASE (subtitle_reel_test) film->set_reel_type (ReelType::BY_VIDEO_CONTENT); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_STANDARD}); dcp::DCP dcp ("build/test/subtitle_reel_test/" + film->dcp_name()); dcp.read (); @@ -116,8 +115,13 @@ BOOST_AUTO_TEST_CASE (subtitle_in_all_reels_test) auto subs = content_factory("test/data/15s.srt").front(); film->examine_and_add_content (subs); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING + }); dcp::DCP dcp ("build/test/subtitle_in_all_reels_test/" + film->dcp_name()); dcp.read (); @@ -161,8 +165,12 @@ BOOST_AUTO_TEST_CASE (closed_captions_in_all_reels_test) ccap2->text.front()->set_type (TextType::CLOSED_CAPTION); ccap2->text.front()->set_dcp_track (DCPTextTrack("Other", "en-GB")); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING + }); dcp::DCP dcp ("build/test/closed_captions_in_all_reels_test/" + film->dcp_name()); dcp.read (); diff --git a/test/subtitle_trim_test.cc b/test/subtitle_trim_test.cc index 3a615c8d8..f0fea4765 100644 --- a/test/subtitle_trim_test.cc +++ b/test/subtitle_trim_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,25 +18,31 @@ */ + #include "lib/film.h" #include "lib/dcp_subtitle_content.h" #include "test.h" #include + +using std::make_shared; using std::shared_ptr; -using namespace dcpomatic; + /** Check for no crash when trimming DCP subtitles (#1275) */ BOOST_AUTO_TEST_CASE (subtitle_trim_test1) { - shared_ptr film = new_test_film2 ("subtitle_trim_test1"); - shared_ptr content (new DCPSubtitleContent ("test/data/dcp_sub5.xml")); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs ()); + auto content = make_shared("test/data/dcp_sub5.xml"); + auto film = new_test_film2 ("subtitle_trim_test1", {content}); - content->set_trim_end (ContentTime::from_seconds (2)); + content->set_trim_end (dcpomatic::ContentTime::from_seconds(2)); film->write_metadata (); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_CPL_METADATA + }); } diff --git a/test/threed_test.cc b/test/threed_test.cc index 8b58e2bfb..cda278a59 100644 --- a/test/threed_test.cc +++ b/test/threed_test.cc @@ -56,12 +56,10 @@ BOOST_AUTO_TEST_CASE (threed_test1) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); film->set_three_d (true); - film->make_dcp (); - film->write_metadata (); - - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); } + /** Basic sanity check of THREE_D_ALTERNATE; at the moment this is just to make sure * that such a transcode completes without error. */ @@ -78,12 +76,10 @@ BOOST_AUTO_TEST_CASE (threed_test2) film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); film->set_three_d (true); - film->make_dcp (); - film->write_metadata (); - - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); } + /** Basic sanity check of THREE_D_LEFT and THREE_D_RIGHT; at the moment this is just to make sure * that such a transcode completes without error. */ @@ -100,12 +96,10 @@ BOOST_AUTO_TEST_CASE (threed_test3) R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT); film->set_three_d (true); - film->make_dcp (); - film->write_metadata (); - - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); } + BOOST_AUTO_TEST_CASE (threed_test4) { auto film = new_test_film2 ("threed_test4"); @@ -125,12 +119,10 @@ BOOST_AUTO_TEST_CASE (threed_test4) R->set_trim_end (dcpomatic::ContentTime::from_seconds(22)); film->set_three_d (true); - film->make_dcp (); - film->write_metadata (); - - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_PICTURE_ASSET_RESOLUTION_FOR_3D}); } + BOOST_AUTO_TEST_CASE (threed_test5) { auto film = new_test_film2 ("threed_test5"); @@ -149,12 +141,10 @@ BOOST_AUTO_TEST_CASE (threed_test5) R->set_trim_end (dcpomatic::ContentTime::from_seconds(3 * 60 + 20)); film->set_three_d (true); - film->make_dcp (); - film->write_metadata (); - - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K}); } + BOOST_AUTO_TEST_CASE (threed_test6) { auto film = new_test_film2 ("threed_test6"); @@ -168,13 +158,11 @@ BOOST_AUTO_TEST_CASE (threed_test6) R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT); film->set_three_d (true); - film->make_dcp (); - film->write_metadata (); - - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); check_dcp ("test/data/threed_test6", film->dir(film->dcp_name())); } + /** Check 2D content set as being 3D; this should give an informative error */ BOOST_AUTO_TEST_CASE (threed_test7) { diff --git a/test/vf_kdm_test.cc b/test/vf_kdm_test.cc index 9b987a703..86e6c3950 100644 --- a/test/vf_kdm_test.cc +++ b/test/vf_kdm_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/vf_kdm_test.cc * @brief Test encrypted VF creation and import * @ingroup feature */ + #include "test.h" #include "lib/film.h" #include "lib/dcp_subtitle_content.h" @@ -36,63 +38,64 @@ #include #include -using std::vector; -using std::string; + +using std::make_shared; using std::shared_ptr; +using std::string; +using std::vector; + BOOST_AUTO_TEST_CASE (vf_kdm_test) { /* Make an encrypted DCP from test.mp4 */ - shared_ptr A = new_test_film ("vf_kdm_test_ov"); + auto A = new_test_film ("vf_kdm_test_ov"); A->set_container (Ratio::from_id ("185")); A->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); A->set_name ("frobozz"); A->set_interop (true); - shared_ptr c (new FFmpegContent("test/data/test.mp4")); + auto c = make_shared("test/data/test.mp4"); A->examine_and_add_content (c); A->set_encrypted (true); BOOST_REQUIRE (!wait_for_jobs()); - A->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (A, {dcp::VerificationNote::Code::INVALID_STANDARD}); dcp::DCP A_dcp ("build/test/vf_kdm_test_ov/" + A->dcp_name()); A_dcp.read (); - Config::instance()->set_decryption_chain (shared_ptr (new dcp::CertificateChain (openssl_path ()))); + Config::instance()->set_decryption_chain (make_shared(openssl_path())); - dcp::EncryptedKDM A_kdm = A->make_kdm ( - Config::instance()->decryption_chain()->leaf (), + auto A_kdm = A->make_kdm ( + Config::instance()->decryption_chain()->leaf(), vector(), A_dcp.cpls().front()->file().get(), - dcp::LocalTime ("2030-07-21T00:00:00+00:00"), - dcp::LocalTime ("2031-07-21T00:00:00+00:00"), + dcp::LocalTime("2030-07-21T00:00:00+00:00"), + dcp::LocalTime("2031-07-21T00:00:00+00:00"), dcp::Formulation::MODIFIED_TRANSITIONAL_1, true, 0 ); /* Import A into a new project, with the required KDM, and make a VF that refers to it */ - shared_ptr B = new_test_film ("vf_kdm_test_vf"); - B->set_container (Ratio::from_id ("185")); - B->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); + auto B = new_test_film ("vf_kdm_test_vf"); + B->set_container (Ratio::from_id("185")); + B->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR")); B->set_name ("frobozz"); B->set_interop (true); - shared_ptr d (new DCPContent ("build/test/vf_kdm_test_ov/" + A->dcp_name())); + auto d = make_shared("build/test/vf_kdm_test_ov/" + A->dcp_name()); d->add_kdm (A_kdm); d->set_reference_video (true); B->examine_and_add_content (d); B->set_encrypted (true); BOOST_REQUIRE (!wait_for_jobs()); - B->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (B, {dcp::VerificationNote::Code::INVALID_STANDARD, dcp::VerificationNote::Code::EXTERNAL_ASSET}); dcp::DCP B_dcp ("build/test/vf_kdm_test_vf/" + B->dcp_name()); B_dcp.read (); - dcp::EncryptedKDM B_kdm = B->make_kdm ( + auto B_kdm = B->make_kdm ( Config::instance()->decryption_chain()->leaf (), vector(), B_dcp.cpls().front()->file().get(), @@ -106,19 +109,18 @@ BOOST_AUTO_TEST_CASE (vf_kdm_test) This KDM should decrypt assets from the OV too. */ - shared_ptr C = new_test_film ("vf_kdm_test_check"); + auto C = new_test_film ("vf_kdm_test_check"); C->set_container (Ratio::from_id ("185")); C->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); C->set_name ("frobozz"); C->set_interop (true); - shared_ptr e (new DCPContent ("build/test/vf_kdm_test_vf/" + B->dcp_name())); + auto e = make_shared("build/test/vf_kdm_test_vf/" + B->dcp_name()); e->add_kdm (B_kdm); e->add_ov ("build/test/vf_kdm_test_ov/" + A->dcp_name()); C->examine_and_add_content (e); BOOST_REQUIRE (!wait_for_jobs()); - C->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (C, {dcp::VerificationNote::Code::INVALID_STANDARD}); /* Should be 1s red, 1s green, 1s blue */ check_dcp ("test/data/vf_kdm_test_check", "build/test/vf_kdm_test_check/" + C->dcp_name()); diff --git a/test/vf_test.cc b/test/vf_test.cc index b538f967c..b7e976041 100644 --- a/test/vf_test.cc +++ b/test/vf_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2019 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/vf_Test.cc * @brief Various VF-related tests. * @ingroup feature */ + #include "lib/film.h" #include "lib/dcp_content.h" #include "lib/ffmpeg_content.h" @@ -39,19 +41,22 @@ #include #include + using std::list; using std::string; using std::cout; using std::shared_ptr; +using std::make_shared; using std::dynamic_pointer_cast; using namespace dcpomatic; + /** Test the logic which decides whether a DCP can be referenced or not */ BOOST_AUTO_TEST_CASE (vf_test1) { - shared_ptr film = new_test_film ("vf_test1"); + auto film = new_test_film ("vf_test1"); film->set_interop (false); - shared_ptr dcp (new DCPContent ("test/data/reels_test2")); + auto dcp = make_shared("test/data/reels_test2"); film->examine_and_add_content (dcp); BOOST_REQUIRE (!wait_for_jobs()); @@ -71,7 +76,7 @@ BOOST_AUTO_TEST_CASE (vf_test1) BOOST_CHECK (!dcp->can_reference_text(film, TextType::OPEN_SUBTITLE, why_not)); BOOST_CHECK (!dcp->can_reference_text(film, TextType::CLOSED_CAPTION, why_not)); - shared_ptr other (new FFmpegContent("test/data/test.mp4")); + auto other = make_shared("test/data/test.mp4"); film->examine_and_add_content (other); BOOST_REQUIRE (!wait_for_jobs()); BOOST_CHECK (!other->audio); @@ -89,87 +94,91 @@ BOOST_AUTO_TEST_CASE (vf_test1) BOOST_CHECK (!dcp->can_reference_text(film, TextType::CLOSED_CAPTION, why_not)); } + /** Make a OV with video and audio and a VF referencing the OV and adding subs */ BOOST_AUTO_TEST_CASE (vf_test2) { /* Make the OV */ - shared_ptr ov = new_test_film ("vf_test2_ov"); - ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); + auto ov = new_test_film ("vf_test2_ov"); + ov->set_dcp_content_type (DCPContentType::from_isdcf_name("TST")); ov->set_name ("vf_test2_ov"); - shared_ptr video = content_factory ("test/data/flat_red.png").front(); + auto video = content_factory("test/data/flat_red.png").front(); ov->examine_and_add_content (video); BOOST_REQUIRE (!wait_for_jobs()); video->video->set_length (24 * 5); - shared_ptr audio = content_factory ("test/data/white.wav").front(); + auto audio = content_factory("test/data/white.wav").front(); ov->examine_and_add_content (audio); BOOST_REQUIRE (!wait_for_jobs()); - ov->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov); /* Make the VF */ - shared_ptr vf = new_test_film ("vf_test2_vf"); + auto vf = new_test_film ("vf_test2_vf"); vf->set_name ("vf_test2_vf"); - vf->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); + vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST")); vf->set_reel_type (ReelType::BY_VIDEO_CONTENT); - shared_ptr dcp (new DCPContent(ov->dir (ov->dcp_name ()))); - BOOST_REQUIRE (dcp); + auto dcp = make_shared(ov->dir(ov->dcp_name())); vf->examine_and_add_content (dcp); BOOST_REQUIRE (!wait_for_jobs()); dcp->set_reference_video (true); dcp->set_reference_audio (true); - shared_ptr sub = content_factory("test/data/subrip4.srt").front(); + auto sub = content_factory("test/data/subrip4.srt").front(); vf->examine_and_add_content (sub); BOOST_REQUIRE (!wait_for_jobs()); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); - vf->write_metadata (); + make_and_verify_dcp ( + vf, + { + dcp::VerificationNote::Code::EXTERNAL_ASSET, + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::INVALID_SUBTITLE_DURATION + }); - dcp::DCP ov_c (ov->dir (ov->dcp_name ())); + dcp::DCP ov_c (ov->dir(ov->dcp_name())); ov_c.read (); BOOST_REQUIRE_EQUAL (ov_c.cpls().size(), 1U); - BOOST_REQUIRE_EQUAL (ov_c.cpls().front()->reels().size(), 1U); - BOOST_REQUIRE (ov_c.cpls().front()->reels().front()->main_picture()); - string const pic_id = ov_c.cpls().front()->reels().front()->main_picture()->id(); - BOOST_REQUIRE (ov_c.cpls().front()->reels().front()->main_sound()); - string const sound_id = ov_c.cpls().front()->reels().front()->main_sound()->id(); - BOOST_REQUIRE (!ov_c.cpls().front()->reels().front()->main_subtitle()); - - dcp::DCP vf_c (vf->dir (vf->dcp_name ())); + BOOST_REQUIRE_EQUAL (ov_c.cpls()[0]->reels().size(), 1U); + BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_picture()); + string const pic_id = ov_c.cpls()[0]->reels()[0]->main_picture()->id(); + BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_sound()); + string const sound_id = ov_c.cpls()[0]->reels()[0]->main_sound()->id(); + BOOST_REQUIRE (!ov_c.cpls()[0]->reels()[0]->main_subtitle()); + + dcp::DCP vf_c (vf->dir(vf->dcp_name())); vf_c.read (); BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U); - BOOST_REQUIRE_EQUAL (vf_c.cpls().front()->reels().size(), 1U); - BOOST_REQUIRE (vf_c.cpls().front()->reels().front()->main_picture()); - BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_picture()->id(), pic_id); - BOOST_REQUIRE (vf_c.cpls().front()->reels().front()->main_sound()); - BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_sound()->id(), sound_id); - BOOST_REQUIRE (vf_c.cpls().front()->reels().front()->main_subtitle()); + BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 1U); + BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_picture()); + BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->id(), pic_id); + BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_sound()); + BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->id(), sound_id); + BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_subtitle()); } + /** Test creation of a VF using a trimmed OV; the output should have entry point / * duration altered to effect the trimming. */ BOOST_AUTO_TEST_CASE (vf_test3) { /* Make the OV */ - shared_ptr ov = new_test_film ("vf_test3_ov"); + auto ov = new_test_film ("vf_test3_ov"); ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); ov->set_name ("vf_test3_ov"); - shared_ptr video = content_factory("test/data/flat_red.png").front(); + auto video = content_factory("test/data/flat_red.png").front(); ov->examine_and_add_content (video); BOOST_REQUIRE (!wait_for_jobs()); video->video->set_length (24 * 5); - shared_ptr audio = content_factory("test/data/white.wav").front(); + auto audio = content_factory("test/data/white.wav").front(); ov->examine_and_add_content (audio); BOOST_REQUIRE (!wait_for_jobs()); - ov->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov); /* Make the VF */ - shared_ptr vf = new_test_film ("vf_test3_vf"); + auto vf = new_test_film ("vf_test3_vf"); vf->set_name ("vf_test3_vf"); - vf->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); + vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST")); vf->set_reel_type (ReelType::BY_VIDEO_CONTENT); - shared_ptr dcp (new DCPContent(ov->dir(ov->dcp_name()))); + auto dcp = make_shared(ov->dir(ov->dcp_name())); BOOST_REQUIRE (dcp); dcp->set_trim_start (ContentTime::from_seconds (1)); dcp->set_trim_end (ContentTime::from_seconds (1)); @@ -177,119 +186,115 @@ BOOST_AUTO_TEST_CASE (vf_test3) BOOST_REQUIRE (!wait_for_jobs()); dcp->set_reference_video (true); dcp->set_reference_audio (true); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); - vf->write_metadata (); + make_and_verify_dcp (vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}); - dcp::DCP vf_c (vf->dir (vf->dcp_name ())); + dcp::DCP vf_c (vf->dir(vf->dcp_name())); vf_c.read (); BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U); - BOOST_REQUIRE_EQUAL (vf_c.cpls().front()->reels().size(), 1U); - BOOST_REQUIRE (vf_c.cpls().front()->reels().front()->main_picture()); - BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_picture()->entry_point().get_value_or(0), 24); - BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_picture()->actual_duration(), 72); - BOOST_REQUIRE (vf_c.cpls().front()->reels().front()->main_sound()); - BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_sound()->entry_point().get_value_or(0), 24); - BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_sound()->actual_duration(), 72); + BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 1U); + BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_picture()); + BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->entry_point().get_value_or(0), 24); + BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->actual_duration(), 72); + BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_sound()); + BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->entry_point().get_value_or(0), 24); + BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->actual_duration(), 72); } + /** Make a OV with video and audio and a VF referencing the OV and adding some more video */ BOOST_AUTO_TEST_CASE (vf_test4) { /* Make the OV */ - shared_ptr ov = new_test_film ("vf_test4_ov"); + auto ov = new_test_film ("vf_test4_ov"); ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); ov->set_name ("vf_test4_ov"); - shared_ptr video = content_factory("test/data/flat_red.png").front(); + auto video = content_factory("test/data/flat_red.png").front(); ov->examine_and_add_content (video); BOOST_REQUIRE (!wait_for_jobs()); video->video->set_length (24 * 5); - shared_ptr audio = content_factory("test/data/white.wav").front(); + auto audio = content_factory("test/data/white.wav").front(); ov->examine_and_add_content (audio); BOOST_REQUIRE (!wait_for_jobs()); - ov->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov); /* Make the VF */ - shared_ptr vf = new_test_film ("vf_test4_vf"); + auto vf = new_test_film ("vf_test4_vf"); vf->set_name ("vf_test4_vf"); - vf->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); + vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST")); vf->set_reel_type (ReelType::BY_VIDEO_CONTENT); vf->set_sequence (false); - shared_ptr dcp (new DCPContent(ov->dir(ov->dcp_name()))); + auto dcp = make_shared(ov->dir(ov->dcp_name())); BOOST_REQUIRE (dcp); vf->examine_and_add_content (dcp); BOOST_REQUIRE (!wait_for_jobs()); dcp->set_position(vf, DCPTime::from_seconds(10)); dcp->set_reference_video (true); dcp->set_reference_audio (true); - shared_ptr more_video = content_factory("test/data/flat_red.png").front(); + auto more_video = content_factory("test/data/flat_red.png").front(); vf->examine_and_add_content (more_video); BOOST_REQUIRE (!wait_for_jobs()); more_video->set_position (vf, DCPTime()); vf->write_metadata (); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}); - dcp::DCP ov_c (ov->dir (ov->dcp_name ())); + dcp::DCP ov_c (ov->dir(ov->dcp_name())); ov_c.read (); BOOST_REQUIRE_EQUAL (ov_c.cpls().size(), 1U); - BOOST_REQUIRE_EQUAL (ov_c.cpls().front()->reels().size(), 1U); - BOOST_REQUIRE (ov_c.cpls().front()->reels().front()->main_picture()); - string const pic_id = ov_c.cpls().front()->reels().front()->main_picture()->id(); - BOOST_REQUIRE (ov_c.cpls().front()->reels().front()->main_sound()); - string const sound_id = ov_c.cpls().front()->reels().front()->main_sound()->id(); - BOOST_REQUIRE (!ov_c.cpls().front()->reels().front()->main_subtitle()); + BOOST_REQUIRE_EQUAL (ov_c.cpls()[0]->reels().size(), 1U); + BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_picture()); + string const pic_id = ov_c.cpls()[0]->reels()[0]->main_picture()->id(); + BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_sound()); + string const sound_id = ov_c.cpls()[0]->reels()[0]->main_sound()->id(); + BOOST_REQUIRE (!ov_c.cpls()[0]->reels()[0]->main_subtitle()); dcp::DCP vf_c (vf->dir (vf->dcp_name ())); vf_c.read (); BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U); - BOOST_REQUIRE_EQUAL (vf_c.cpls().front()->reels().size(), 2U); - BOOST_REQUIRE (vf_c.cpls().front()->reels().back()->main_picture()); - BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().back()->main_picture()->id(), pic_id); - BOOST_REQUIRE (vf_c.cpls().front()->reels().back()->main_sound()); - BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().back()->main_sound()->id(), sound_id); + BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 2U); + BOOST_REQUIRE (vf_c.cpls()[0]->reels().back()->main_picture()); + BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels().back()->main_picture()->id(), pic_id); + BOOST_REQUIRE (vf_c.cpls()[0]->reels().back()->main_sound()); + BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels().back()->main_sound()->id(), sound_id); } + /** Test bug #1495 */ BOOST_AUTO_TEST_CASE (vf_test5) { /* Make the OV */ - shared_ptr ov = new_test_film ("vf_test5_ov"); + auto ov = new_test_film ("vf_test5_ov"); ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); ov->set_reel_type (ReelType::BY_VIDEO_CONTENT); for (int i = 0; i < 3; ++i) { - shared_ptr video = content_factory("test/data/flat_red.png").front(); + auto video = content_factory("test/data/flat_red.png").front(); ov->examine_and_add_content (video); BOOST_REQUIRE (!wait_for_jobs()); video->video->set_length (24 * 10); } BOOST_REQUIRE (!wait_for_jobs()); - ov->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov); /* Make the VF */ - shared_ptr vf = new_test_film ("vf_test5_vf"); + auto vf = new_test_film ("vf_test5_vf"); vf->set_name ("vf_test5_vf"); vf->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); vf->set_reel_type (ReelType::BY_VIDEO_CONTENT); vf->set_sequence (false); - shared_ptr dcp (new DCPContent(ov->dir(ov->dcp_name()))); + auto dcp = make_shared(ov->dir(ov->dcp_name())); BOOST_REQUIRE (dcp); vf->examine_and_add_content (dcp); BOOST_REQUIRE (!wait_for_jobs()); dcp->set_reference_video (true); dcp->set_reference_audio (true); dcp->set_trim_end (ContentTime::from_seconds(15)); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}); /* Check that the selected reel assets are right */ - shared_ptr player (new Player(vf)); - list a = player->get_reel_assets(); + auto player = make_shared(vf); + auto a = player->get_reel_assets(); BOOST_REQUIRE_EQUAL (a.size(), 4U); - list::const_iterator i = a.begin(); + auto i = a.begin(); BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(0), DCPTime(960000))); ++i; BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(0), DCPTime(960000))); @@ -300,73 +305,68 @@ BOOST_AUTO_TEST_CASE (vf_test5) ++i; } + /** Test bug #1528 */ BOOST_AUTO_TEST_CASE (vf_test6) { /* Make the OV */ - shared_ptr ov = new_test_film ("vf_test6_ov"); + auto ov = new_test_film ("vf_test6_ov"); ov->set_dcp_content_type (DCPContentType::from_isdcf_name("TST")); ov->set_reel_type (ReelType::BY_VIDEO_CONTENT); - shared_ptr video = content_factory("test/data/flat_red.png").front(); + auto video = content_factory("test/data/flat_red.png").front(); ov->examine_and_add_content (video); BOOST_REQUIRE (!wait_for_jobs()); video->video->set_length (24 * 10); - ov->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov); /* Make the VF */ - shared_ptr vf = new_test_film ("vf_test6_vf"); + auto vf = new_test_film ("vf_test6_vf"); vf->set_name ("vf_test6_vf"); vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST")); vf->set_reel_type (ReelType::BY_VIDEO_CONTENT); vf->set_sequence (false); - shared_ptr dcp (new DCPContent(ov->dir(ov->dcp_name()))); - BOOST_REQUIRE (dcp); + auto dcp = make_shared(ov->dir(ov->dcp_name())); vf->examine_and_add_content (dcp); BOOST_REQUIRE (!wait_for_jobs()); dcp->set_reference_video (true); dcp->set_reference_audio (true); - shared_ptr sub = content_factory("test/data/15s.srt").front(); + auto sub = content_factory("test/data/15s.srt").front(); vf->examine_and_add_content (sub); BOOST_REQUIRE (!wait_for_jobs()); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + vf, + { + dcp::VerificationNote::Code::EXTERNAL_ASSET, + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME + }); } + /** Test bug #1643 (the second part; referring fails if there are gaps) */ BOOST_AUTO_TEST_CASE (vf_test7) { /* First OV */ - shared_ptr ov1 = new_test_film2 ("vf_test7_ov1"); + auto ov1 = new_test_film2 ("vf_test7_ov1", {content_factory("test/data/flat_red.png").front()}); ov1->set_video_frame_rate (24); - ov1->examine_and_add_content (content_factory("test/data/flat_red.png").front()); - BOOST_REQUIRE (!wait_for_jobs()); - ov1->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov1); /* Second OV */ - shared_ptr ov2 = new_test_film2 ("vf_test7_ov2"); + auto ov2 = new_test_film2 ("vf_test7_ov2", {content_factory("test/data/flat_red.png").front()}); ov2->set_video_frame_rate (24); - ov2->examine_and_add_content (content_factory("test/data/flat_red.png").front()); - BOOST_REQUIRE (!wait_for_jobs()); - ov2->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov2); /* VF */ - shared_ptr vf = new_test_film2 ("vf_test7_vf"); - shared_ptr ov1_dcp (new DCPContent(ov1->dir(ov1->dcp_name()))); - vf->examine_and_add_content (ov1_dcp); - shared_ptr ov2_dcp (new DCPContent(ov1->dir(ov1->dcp_name()))); - vf->examine_and_add_content (ov2_dcp); - BOOST_REQUIRE (!wait_for_jobs()); + auto ov1_dcp = make_shared(ov1->dir(ov1->dcp_name())); + auto ov2_dcp = make_shared(ov2->dir(ov2->dcp_name())); + auto vf = new_test_film2 ("vf_test7_vf", {ov1_dcp, ov2_dcp}); vf->set_reel_type (ReelType::BY_VIDEO_CONTENT); ov1_dcp->set_reference_video (true); ov2_dcp->set_reference_video (true); ov1_dcp->set_position (vf, DCPTime::from_seconds(1)); ov2_dcp->set_position (vf, DCPTime::from_seconds(20)); vf->write_metadata (); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (vf); }