X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fmap_cli_test.cc;h=ed2a7e5ec5aad4ede1d3dba538abe39646bab74c;hb=HEAD;hp=3e6abc059cd9b93f031cce5fabdfaaddecd19200;hpb=3a1ddb9e182be28a22c5bbc85c06ee6629b72fe6;p=dcpomatic.git diff --git a/test/map_cli_test.cc b/test/map_cli_test.cc index 3e6abc059..ed2a7e5ec 100644 --- a/test/map_cli_test.cc +++ b/test/map_cli_test.cc @@ -25,6 +25,7 @@ #include "lib/content_factory.h" #include "lib/film.h" #include "lib/map_cli.h" +#include "lib/text_content.h" #include "test.h" #include #include @@ -115,6 +116,38 @@ BOOST_AUTO_TEST_CASE(map_simple_dcp_copy) } +/** Map a single DCP into a new DCP, referring to the CPL by ID */ +BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_by_id) +{ + string const name = "map_simple_dcp_copy_by_id"; + string const out = String::compose("build/test/%1_out", name); + + auto content = content_factory("test/data/flat_red.png"); + auto film = new_test_film2(name + "_in", content); + make_and_verify_dcp(film); + + dcp::CPL cpl(find_cpl(film->dir(film->dcp_name()))); + + vector const args = { + "map_cli", + "-o", out, + "-d", film->dir(film->dcp_name()).string(), + cpl.id() + }; + + boost::filesystem::remove_all(out); + + vector output_messages; + auto error = run(args, output_messages); + BOOST_CHECK(!error); + + verify_dcp(out, {}); + + BOOST_CHECK(boost::filesystem::is_regular_file(find_prefix(out, "j2c_"))); + BOOST_CHECK(boost::filesystem::is_regular_file(find_prefix(out, "pcm_"))); +} + + /** Map a single DCP into a new DCP using the symlink option */ BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_with_symlinks) { @@ -190,6 +223,7 @@ BOOST_AUTO_TEST_CASE(map_simple_interop_dcp_with_subs) auto subs = content_factory("test/data/15s.srt").front(); auto film = new_test_film2(name + "_in", { picture, subs }); film->set_interop(true); + subs->only_text()->set_language(dcp::LanguageTag("de")); make_and_verify_dcp(film, {dcp::VerificationNote::Code::INVALID_STANDARD}); vector const args = { @@ -209,8 +243,9 @@ BOOST_AUTO_TEST_CASE(map_simple_interop_dcp_with_subs) } -/** Map an OV and a VF into a single DCP */ -BOOST_AUTO_TEST_CASE(map_ov_vf_copy) +static +void +test_map_ov_vf_copy(vector extra_args = {}) { string const name = "map_ov_vf_copy"; string const out = String::compose("build/test/%1_out", name); @@ -220,16 +255,15 @@ BOOST_AUTO_TEST_CASE(map_ov_vf_copy) make_and_verify_dcp(ov_film); auto const ov_dir = ov_film->dir(ov_film->dcp_name()); - auto vf_ov = make_shared(ov_dir); auto vf_sound = content_factory("test/data/sine_440.wav").front(); auto vf_film = new_test_film2(name + "_vf", { vf_ov, vf_sound }); vf_ov->set_reference_video(true); - make_and_verify_dcp(vf_film, {dcp::VerificationNote::Code::EXTERNAL_ASSET}); + make_and_verify_dcp(vf_film, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false); auto const vf_dir = vf_film->dir(vf_film->dcp_name()); - vector const args = { + vector args = { "map_cli", "-o", out, "-d", ov_dir.string(), @@ -237,6 +271,8 @@ BOOST_AUTO_TEST_CASE(map_ov_vf_copy) find_cpl(vf_dir).string() }; + args.insert(std::end(args), std::begin(extra_args), std::end(extra_args)); + boost::filesystem::remove_all(out); vector output_messages; @@ -251,6 +287,60 @@ BOOST_AUTO_TEST_CASE(map_ov_vf_copy) } +/** Map an OV and a VF into a single DCP */ +BOOST_AUTO_TEST_CASE(map_ov_vf_copy) +{ + test_map_ov_vf_copy(); + test_map_ov_vf_copy({"-l"}); +} + + +/** Map an OV and VF into a single DCP, where the VF refers to the OV's assets multiple times */ +BOOST_AUTO_TEST_CASE(map_ov_vf_copy_multiple_reference) +{ + string const name = "map_ov_vf_copy_multiple_reference"; + string const out = String::compose("build/test/%1_out", name); + + auto ov_content = content_factory("test/data/flat_red.png"); + auto ov_film = new_test_film2(name + "_ov", ov_content); + make_and_verify_dcp(ov_film); + + auto const ov_dir = ov_film->dir(ov_film->dcp_name()); + + auto vf_ov1 = make_shared(ov_dir); + auto vf_ov2 = make_shared(ov_dir); + auto vf_sound = content_factory("test/data/sine_440.wav").front(); + auto vf_film = new_test_film2(name + "_vf", { vf_ov1, vf_ov2, vf_sound }); + vf_film->set_reel_type(ReelType::BY_VIDEO_CONTENT); + vf_ov2->set_position(vf_film, vf_ov1->end(vf_film)); + vf_ov1->set_reference_video(true); + vf_ov2->set_reference_video(true); + make_and_verify_dcp(vf_film, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false); + + auto const vf_dir = vf_film->dir(vf_film->dcp_name()); + + vector const args = { + "map_cli", + "-o", out, + "-d", ov_dir.string(), + "-d", vf_dir.string(), + "-l", + find_cpl(vf_dir).string() + }; + + boost::filesystem::remove_all(out); + + vector output_messages; + auto error = run(args, output_messages); + BOOST_CHECK(!error); + + verify_dcp(out, {}); + + check_file(find_file(out, "cpl_"), find_file(vf_dir, "cpl_")); + check_file(find_file(out, "j2c_"), find_file(ov_dir, "j2c_")); +} + + /** Map a single DCP into a new DCP using the rename option */ BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_with_rename) { @@ -321,6 +411,7 @@ test_two_cpls_each_with_subs(string name, bool interop) auto subs = content_factory("test/data/15s.srt").front(); films[i] = new_test_film2(String::compose("%1_%2_in", name, i), { picture, subs }); films[i]->set_interop(interop); + subs->only_text()->set_language(dcp::LanguageTag("de")); make_and_verify_dcp(films[i], acceptable_errors); } @@ -353,3 +444,170 @@ BOOST_AUTO_TEST_CASE(map_two_smpte_cpls_each_with_subs) { test_two_cpls_each_with_subs("map_two_smpte_cpls_each_with_subs", false); } + + +BOOST_AUTO_TEST_CASE(map_with_given_config) +{ + ConfigRestorer cr; + + string const name = "map_with_given_config"; + string const out = String::compose("build/test/%1_out", name); + + auto content = content_factory("test/data/flat_red.png"); + auto film = new_test_film2(name + "_in", content); + make_and_verify_dcp(film); + + vector const args = { + "map_cli", + "-o", out, + "-d", film->dir(film->dcp_name()).string(), + "--config", "test/data/map_with_given_config", + find_cpl(film->dir(film->dcp_name())).string() + }; + + boost::filesystem::remove_all(out); + + Config::instance()->drop(); + vector output_messages; + auto error = run(args, output_messages); + BOOST_CHECK(!error); + + /* It should be signed by the key in test/data/map_with_given_config, not the one in test/data/signer_key */ + BOOST_CHECK(dcp::file_to_string(find_file(out, "cpl_")).find("dnQualifier=\\+uOcNN2lPuxpxgd/5vNkkBER0GE=,CN=CS.dcpomatic.smpte-430-2.LEAF,OU=dcpomatic.com,O=dcpomatic.com") != std::string::npos); +} + + +BOOST_AUTO_TEST_CASE(map_multireel_interop_ov_and_vf_adding_ccaps) +{ + string const name = "map_multireel_interop_ov_and_vf_adding_ccaps"; + string const out = String::compose("build/test/%1_out", name); + + vector> video = { + content_factory("test/data/flat_red.png")[0], + content_factory("test/data/flat_red.png")[0], + content_factory("test/data/flat_red.png")[0] + }; + + auto ov = new_test_film2(name + "_ov", { video[0], video[1], video[2] }); + ov->set_reel_type(ReelType::BY_VIDEO_CONTENT); + ov->set_interop(true); + make_and_verify_dcp(ov, { dcp::VerificationNote::Code::INVALID_STANDARD }); + + auto ov_dcp = make_shared(ov->dir(ov->dcp_name())); + + vector> ccap = { + content_factory("test/data/short.srt")[0], + content_factory("test/data/short.srt")[0], + content_factory("test/data/short.srt")[0] + }; + + auto vf = new_test_film2(name + "_vf", { ov_dcp, ccap[0], ccap[1], ccap[2] }); + vf->set_interop(true); + vf->set_reel_type(ReelType::BY_VIDEO_CONTENT); + ov_dcp->set_reference_video(true); + ov_dcp->set_reference_audio(true); + for (auto i = 0; i < 3; ++i) { + ccap[i]->text[0]->set_use(true); + ccap[i]->text[0]->set_type(TextType::CLOSED_CAPTION); + } + make_and_verify_dcp( + vf, + { + dcp::VerificationNote::Code::INVALID_STANDARD, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::EXTERNAL_ASSET + }); + + vector const args = { + "map_cli", + "-o", out, + "-d", ov->dir(ov->dcp_name()).string(), + "-d", vf->dir(vf->dcp_name()).string(), + find_cpl(vf->dir(vf->dcp_name())).string() + }; + + boost::filesystem::remove_all(out); + + vector output_messages; + auto error = run(args, output_messages); + BOOST_CHECK(!error); + + verify_dcp(out, { dcp::VerificationNote::Code::INVALID_STANDARD }); +} + + +BOOST_AUTO_TEST_CASE(map_uses_config_for_issuer_and_creator) +{ + ConfigRestorer cr; + + Config::instance()->set_dcp_issuer("ostrabagalous"); + Config::instance()->set_dcp_creator("Fred"); + + string const name = "map_uses_config_for_issuer_and_creator"; + string const out = String::compose("build/test/%1_out", name); + + auto content = content_factory("test/data/flat_red.png"); + auto film = new_test_film2(name + "_in", content); + make_and_verify_dcp(film); + + vector const args = { + "map_cli", + "-o", out, + "-d", film->dir(film->dcp_name()).string(), + find_cpl(film->dir(film->dcp_name())).string() + }; + + boost::filesystem::remove_all(out); + + vector output_messages; + auto error = run(args, output_messages); + BOOST_CHECK(!error); + + cxml::Document assetmap("AssetMap"); + assetmap.read_file(film->dir(film->dcp_name()) / "ASSETMAP.xml"); + BOOST_CHECK(assetmap.string_child("Issuer") == "ostrabagalous"); + BOOST_CHECK(assetmap.string_child("Creator") == "Fred"); + + cxml::Document pkl("PackingList"); + pkl.read_file(find_prefix(out, "pkl_")); + BOOST_CHECK(pkl.string_child("Issuer") == "ostrabagalous"); + BOOST_CHECK(pkl.string_child("Creator") == "Fred"); +} + + +BOOST_AUTO_TEST_CASE(map_handles_interop_png_subs) +{ + string const name = "map_handles_interop_png_subs"; + auto arrietty = content_factory(TestPaths::private_data() / "arrietty_JP-EN.mkv")[0]; + auto film = new_test_film2(name + "_input", { arrietty }); + film->set_interop(true); + arrietty->set_trim_end(dcpomatic::ContentTime::from_seconds(110)); + arrietty->text[0]->set_use(true); + arrietty->text[0]->set_language(dcp::LanguageTag("de")); + make_and_verify_dcp( + film, + { + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_STANDARD + }); + + auto const out = boost::filesystem::path("build") / "test" / (name + "_output"); + + vector const args = { + "map_cli", + "-o", out.string(), + "-d", film->dir(film->dcp_name()).string(), + find_cpl(film->dir(film->dcp_name())).string() + }; + + boost::filesystem::remove_all(out); + + vector output_messages; + auto error = run(args, output_messages); + BOOST_CHECK(!error); + + verify_dcp(out, { dcp::VerificationNote::Code::INVALID_STANDARD }); +} +