2 Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 /** @file test/isdcf_name_test.cc
23 * @brief Test creation of ISDCF names.
28 #include "lib/audio_content.h"
29 #include "lib/audio_mapping.h"
30 #include "lib/content_factory.h"
31 #include "lib/dcp_content_type.h"
32 #include "lib/ffmpeg_content.h"
34 #include "lib/image_content.h"
35 #include "lib/ratio.h"
36 #include "lib/text_content.h"
37 #include "lib/video_content.h"
39 #include <boost/test/unit_test.hpp>
42 using std::make_shared;
43 using std::shared_ptr;
47 BOOST_AUTO_TEST_CASE (isdcf_name_test)
49 auto film = new_test_film ("isdcf_name_test");
53 film->set_name ("My Nice Film");
54 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
55 film->set_container (Ratio::from_id ("185"));
56 film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
57 auto audio = content_factory("test/data/sine_440.wav")[0];
58 film->examine_and_add_content (audio);
59 BOOST_REQUIRE (!wait_for_jobs());
60 film->set_audio_language(dcp::LanguageTag("en-US"));
61 film->set_content_versions({"1"});
62 film->set_release_territory(dcp::LanguageTag::RegionSubtag("GB"));
63 film->set_ratings({dcp::Rating("BBFC", "PG")});
64 film->set_studio (string("ST"));
65 film->set_facility (string("FAC"));
66 film->set_interop (true);
67 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_EN-XX_GB-PG_10_2K_ST_20140704_FAC_IOP_OV");
69 /* Check that specifying no audio language writes XX */
70 film->set_audio_language (boost::none);
71 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_XX-XX_GB-PG_10_2K_ST_20140704_FAC_IOP_OV");
73 /* Test a long name and some different data */
75 film->set_name ("My Nice Film With A Very Long Name");
76 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
77 film->set_container (Ratio::from_id ("239"));
78 film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
79 film->set_audio_channels (1);
80 film->set_resolution (Resolution::FOUR_K);
81 auto text = content_factory("test/data/subrip.srt")[0];
82 BOOST_REQUIRE_EQUAL (text->text.size(), 1U);
83 text->text.front()->set_burn (true);
84 text->text.front()->set_language (dcp::LanguageTag("fr-FR"));
85 film->examine_and_add_content (text);
86 film->set_version_number(2);
87 film->set_release_territory(dcp::LanguageTag::RegionSubtag("US"));
88 film->set_ratings({dcp::Rating("MPA", "R")});
89 film->set_studio (string("di"));
90 film->set_facility (string("ppfacility"));
91 BOOST_REQUIRE (!wait_for_jobs());
92 audio = content_factory("test/data/sine_440.wav")[0];
93 film->examine_and_add_content (audio);
94 BOOST_REQUIRE (!wait_for_jobs());
95 film->set_audio_language (dcp::LanguageTag("de-DE"));
96 film->set_interop (false);
97 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
99 /* Test to see that RU ratings like 6+ are stripped of their + */
100 film->set_ratings({dcp::Rating("RARS", "6+")});
101 BOOST_CHECK_EQUAL (film->dcp_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-6_MOS_4K_DI_20140704_PPF_SMPTE_OV");
102 film->set_ratings({dcp::Rating("MPA", "R")});
104 /* Test interior aspect ratio: shouldn't be shown with trailers */
106 shared_ptr<ImageContent> content (new ImageContent ("test/data/simple_testcard_640x480.png"));
107 film->examine_and_add_content (content);
108 BOOST_REQUIRE (!wait_for_jobs());
109 content->video->set_custom_ratio (1.33);
110 film->set_container (Ratio::from_id ("185"));
111 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_F_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
113 /* But should be shown for anything else */
115 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("XSN"));
116 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-133_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
118 /* And it should always be numeric */
120 content->video->set_custom_ratio (2.39);
121 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-239_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
123 content->video->set_custom_ratio (1.9);
124 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-190_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
126 /* And it should be possible to set any 'strange' ratio, not just the ones we know about */
127 content->video->set_custom_ratio (2.2);
128 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-220_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
129 content->video->set_custom_ratio (1.95);
130 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-195_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
132 content->video->set_custom_ratio (1.33);
136 film->set_three_d (true);
137 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2-3D_F-133_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE-3D_OV");
139 /* Test content type modifiers */
141 film->set_three_d (false);
142 film->set_temp_version (true);
143 film->set_pre_release (true);
144 film->set_red_band (true);
145 film->set_two_d_version_of_three_d (true);
146 film->set_chain (string("MyChain"));
147 film->set_luminance (dcp::Luminance(4.5, dcp::Luminance::Unit::FOOT_LAMBERT));
148 film->set_video_frame_rate (48);
149 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");
151 /* Test a name which is already in camelCase */
153 film->set_three_d (false);
154 film->set_temp_version (false);
155 film->set_pre_release (false);
156 film->set_red_band (false);
157 film->set_two_d_version_of_three_d (false);
158 film->set_chain (string(""));
159 film->set_luminance (boost::none);
160 film->set_video_frame_rate (24);
161 film->set_name ("IKnowCamels");
162 BOOST_CHECK_EQUAL (film->isdcf_name(false), "IKnowCamels_XSN-2_F-133_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
164 /* And one in capitals */
166 film->set_name ("LIKE SHOUTING");
167 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
169 /* Test audio channel markup */
171 film->set_audio_channels (6);
172 auto sound = make_shared<FFmpegContent>("test/data/sine_440.wav");
173 film->examine_and_add_content (sound);
174 BOOST_REQUIRE (!wait_for_jobs());
175 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_10_4K_DI_20140704_PPF_SMPTE_OV");
177 AudioMapping mapping = sound->audio->mapping ();
179 mapping.set (0, dcp::Channel::LEFT, 1.0);
180 sound->audio->set_mapping (mapping);
181 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_20_4K_DI_20140704_PPF_SMPTE_OV");
182 mapping.set (0, dcp::Channel::RIGHT, 1.0);
183 sound->audio->set_mapping (mapping);
184 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_30_4K_DI_20140704_PPF_SMPTE_OV");
185 mapping.set (0, dcp::Channel::LFE, 1.0);
186 sound->audio->set_mapping (mapping);
187 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_31_4K_DI_20140704_PPF_SMPTE_OV");
188 mapping.set (0, dcp::Channel::LS, 1.0);
189 sound->audio->set_mapping (mapping);
190 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_41_4K_DI_20140704_PPF_SMPTE_OV");
191 mapping.set (0, dcp::Channel::RS, 1.0);
192 sound->audio->set_mapping (mapping);
193 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51_4K_DI_20140704_PPF_SMPTE_OV");
194 mapping.set (0, dcp::Channel::HI, 1.0);
195 sound->audio->set_mapping (mapping);
196 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51_4K_DI_20140704_PPF_SMPTE_OV");
198 film->set_audio_channels (8);
199 mapping.set (0, dcp::Channel::HI, 1.0);
200 sound->audio->set_mapping (mapping);
201 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51-HI_4K_DI_20140704_PPF_SMPTE_OV");
202 mapping.set (0, dcp::Channel::VI, 1.0);
203 sound->audio->set_mapping (mapping);
204 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51-HI-VI_4K_DI_20140704_PPF_SMPTE_OV");
206 film->set_audio_channels(10);
207 mapping.set (0, dcp::Channel::HI, 0.0);
208 mapping.set (0, dcp::Channel::VI, 0.0);
209 sound->audio->set_mapping (mapping);
210 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51_4K_DI_20140704_PPF_SMPTE_OV");
211 mapping.set (0, dcp::Channel::HI, 1.0);
212 sound->audio->set_mapping (mapping);
213 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51-HI_4K_DI_20140704_PPF_SMPTE_OV");
214 mapping.set (0, dcp::Channel::VI, 1.0);
215 sound->audio->set_mapping (mapping);
216 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51-HI-VI_4K_DI_20140704_PPF_SMPTE_OV");
218 film->set_audio_channels(12);
219 mapping.set (0, dcp::Channel::BSL, 1.0);
220 mapping.set (0, dcp::Channel::BSR, 1.0);
221 mapping.set (0, dcp::Channel::HI, 0.0);
222 mapping.set (0, dcp::Channel::VI, 0.0);
223 sound->audio->set_mapping (mapping);
224 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_71_4K_DI_20140704_PPF_SMPTE_OV");
225 mapping.set (0, dcp::Channel::HI, 1.0);
226 sound->audio->set_mapping (mapping);
227 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_71-HI_4K_DI_20140704_PPF_SMPTE_OV");
228 mapping.set (0, dcp::Channel::VI, 1.0);
229 sound->audio->set_mapping (mapping);
230 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");
232 /* Check that the proper codes are used, not just part of the language code; in this case, QBP instead of PT (#2235) */
233 film->set_audio_language(dcp::LanguageTag("pt-BR"));
234 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");
236 /* Check that nothing is added for non-existent ratings */
237 film->set_ratings({});
238 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_QBP-fr_US_71-HI-VI_4K_DI_20140704_PPF_SMPTE_OV");
242 BOOST_AUTO_TEST_CASE(isdcf_name_with_atmos)
244 auto content = content_factory(TestPaths::private_data() / "atmos_asset.mxf");
245 auto film = new_test_film2("isdcf_name_with_atmos", content);
246 film->_isdcf_date = boost::gregorian::date(2023, boost::gregorian::Jan, 18);
247 film->set_name("Hello");
249 BOOST_CHECK_EQUAL(film->isdcf_name(false), "Hello_TST-1_F_XX-XX_MOS-IAB_2K_20230118_SMPTE_OV");
253 BOOST_AUTO_TEST_CASE(isdcf_name_with_ccap)
255 auto content = content_factory("test/data/short.srt")[0];
256 auto film = new_test_film2("isdcf_name_with_ccap", { content });
257 content->text[0]->set_use(true);
258 content->text[0]->set_type(TextType::CLOSED_CAPTION);
259 content->text[0]->set_dcp_track(DCPTextTrack("Foo", dcp::LanguageTag("de-DE")));
260 film->_isdcf_date = boost::gregorian::date(2023, boost::gregorian::Jan, 18);
261 film->set_name("Hello");
263 BOOST_CHECK_EQUAL(film->isdcf_name(false), "Hello_TST-1_F_XX-DE-CCAP_MOS_2K_20230118_SMPTE_OV");