X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=test%2Fisdcf_name_test.cc;h=2b9092c8329cbaa2d87e14ea3d5b69006b4df91b;hp=54b9a24d7f88c46cafd5aae5c3224ad1490192cb;hb=cc279961a2a9ffea67ed21378fef44c2e1bcb202;hpb=8d9e73b753ed51067d93aa377bb24400ff22936e diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc index 54b9a24d7..2b9092c83 100644 --- a/test/isdcf_name_test.cc +++ b/test/isdcf_name_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. @@ -25,22 +25,20 @@ */ -#include -#include "lib/film.h" -#include "lib/ratio.h" -#include "lib/dcp_content_type.h" -#include "lib/image_content.h" -#include "lib/video_content.h" -#include "lib/audio_mapping.h" -#include "lib/ffmpeg_content.h" #include "lib/audio_content.h" +#include "lib/audio_mapping.h" #include "lib/content_factory.h" +#include "lib/dcp_content_type.h" +#include "lib/ffmpeg_content.h" +#include "lib/film.h" +#include "lib/image_content.h" +#include "lib/ratio.h" #include "lib/text_content.h" +#include "lib/video_content.h" #include "test.h" -#include +#include -using std::cout; using std::make_shared; using std::shared_ptr; using std::string; @@ -56,23 +54,20 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); film->set_container (Ratio::from_id ("185")); film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4); - auto audio = content_factory("test/data/sine_440.wav").front(); + auto audio = content_factory("test/data/sine_440.wav")[0]; film->examine_and_add_content (audio); BOOST_REQUIRE (!wait_for_jobs()); - BOOST_REQUIRE (audio->audio); - audio->audio->set_language(dcp::LanguageTag("en-US")); + film->set_audio_language(dcp::LanguageTag("en-US")); film->set_content_versions({"1"}); film->set_release_territory(dcp::LanguageTag::RegionSubtag("GB")); film->set_ratings({dcp::Rating("BBFC", "PG")}); film->set_studio (string("ST")); film->set_facility (string("FAC")); - ISDCFMetadata m; - film->set_isdcf_metadata (m); film->set_interop (true); BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_EN-XX_GB-PG_10_2K_ST_20140704_FAC_IOP_OV"); /* Check that specifying no audio language writes XX */ - audio->audio->set_language (boost::none); + film->set_audio_language (boost::none); BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_XX-XX_GB-PG_10_2K_ST_20140704_FAC_IOP_OV"); /* Test a long name and some different data */ @@ -83,7 +78,7 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4); film->set_audio_channels (1); film->set_resolution (Resolution::FOUR_K); - auto text = content_factory("test/data/subrip.srt").front(); + auto text = content_factory("test/data/subrip.srt")[0]; BOOST_REQUIRE_EQUAL (text->text.size(), 1U); text->text.front()->set_burn (true); text->text.front()->set_language (dcp::LanguageTag("fr-FR")); @@ -94,18 +89,16 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) film->set_studio (string("di")); film->set_facility (string("ppfacility")); BOOST_REQUIRE (!wait_for_jobs()); - audio = content_factory("test/data/sine_440.wav").front(); + audio = content_factory("test/data/sine_440.wav")[0]; film->examine_and_add_content (audio); BOOST_REQUIRE (!wait_for_jobs()); - BOOST_REQUIRE (audio->audio); - audio->audio->set_language (dcp::LanguageTag("de-DE")); - film->set_isdcf_metadata (m); + film->set_audio_language (dcp::LanguageTag("de-DE")); film->set_interop (false); BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV"); - /* Test to see that RU ratings like 6+ survive */ + /* Test to see that RU ratings like 6+ are stripped of their + */ film->set_ratings({dcp::Rating("RARS", "6+")}); - BOOST_CHECK_EQUAL (film->dcp_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-6+_MOS_4K_DI_20140704_PPF_SMPTE_OV"); + BOOST_CHECK_EQUAL (film->dcp_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-6_MOS_4K_DI_20140704_PPF_SMPTE_OV"); film->set_ratings({dcp::Rating("MPA", "R")}); /* Test interior aspect ratio: shouldn't be shown with trailers */ @@ -129,6 +122,13 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) content->video->set_custom_ratio (1.9); BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-190_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV"); + + /* And it should be possible to set any 'strange' ratio, not just the ones we know about */ + content->video->set_custom_ratio (2.2); + BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-220_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV"); + content->video->set_custom_ratio (1.95); + BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-195_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV"); + content->video->set_custom_ratio (1.33); /* Test 3D */ @@ -143,11 +143,10 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) film->set_pre_release (true); film->set_red_band (true); film->set_two_d_version_of_three_d (true); - m.chain = "MyChain"; - m.mastered_luminance = "4fl"; - film->set_isdcf_metadata (m); + film->set_chain (string("MyChain")); + film->set_luminance (dcp::Luminance(4.5, dcp::Luminance::Unit::FOOT_LAMBERT)); film->set_video_frame_rate (48); - BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2-Temp-Pre-RedBand-MyChain-2D-4fl-48_F-133_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV"); + BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2-Temp-Pre-RedBand-MyChain-2D-4.5fl-48_F-133_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV"); /* Test a name which is already in camelCase */ @@ -156,9 +155,8 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) film->set_pre_release (false); film->set_red_band (false); film->set_two_d_version_of_three_d (false); - m.chain = ""; - m.mastered_luminance = ""; - film->set_isdcf_metadata (m); + film->set_chain (string("")); + film->set_luminance (boost::none); film->set_video_frame_rate (24); film->set_name ("IKnowCamels"); BOOST_CHECK_EQUAL (film->isdcf_name(false), "IKnowCamels_XSN-2_F-133_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV"); @@ -230,5 +228,24 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) mapping.set (0, dcp::Channel::VI, 1.0); sound->audio->set_mapping (mapping); BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_71-HI-VI_4K_DI_20140704_PPF_SMPTE_OV"); + + /* Check that the proper codes are used, not just part of the language code; in this case, QBP instead of PT (#2235) */ + film->set_audio_language(dcp::LanguageTag("pt-BR")); + BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_QBP-fr_US-R_71-HI-VI_4K_DI_20140704_PPF_SMPTE_OV"); + + /* Check that nothing is added for non-existant ratings */ + film->set_ratings({}); + BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_QBP-fr_US_71-HI-VI_4K_DI_20140704_PPF_SMPTE_OV"); +} + + +BOOST_AUTO_TEST_CASE(isdcf_name_with_atmos) +{ + auto content = content_factory(TestPaths::private_data() / "atmos_asset.mxf"); + auto film = new_test_film2("isdcf_name_with_atmos", content); + film->_isdcf_date = boost::gregorian::date(2023, boost::gregorian::Jan, 18); + film->set_name("Hello"); + + BOOST_CHECK_EQUAL(film->isdcf_name(false), "Hello_TST-1_F_XX-XX_MOS-ATMOS_2K_20230118_SMPTE_OV"); }