2 Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <boost/test/unit_test.hpp>
22 #include "lib/ratio.h"
23 #include "lib/dcp_content_type.h"
24 #include "lib/image_content.h"
25 #include "lib/sndfile_content.h"
26 #include "lib/video_content.h"
27 #include "lib/audio_mapping.h"
28 #include "lib/audio_content.h"
33 using boost::shared_ptr;
35 BOOST_AUTO_TEST_CASE (isdcf_name_test)
37 shared_ptr<Film> film = new_test_film ("isdcf_name_test");
41 film->set_name ("My Nice Film");
42 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
43 film->set_container (Ratio::from_id ("185"));
44 film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
46 m.content_version = 1;
47 m.audio_language = "EN";
48 m.subtitle_language = "XX";
53 film->set_isdcf_metadata (m);
54 film->set_interop (true);
55 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_EN-XX_UK-PG_2K_ST_20140704_FA_IOP_OV");
57 /* Test a long name and some different data */
59 film->set_name ("My Nice Film With A Very Long Name");
60 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
61 film->set_container (Ratio::from_id ("239"));
62 film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
63 film->set_audio_channels (1);
64 film->set_resolution (RESOLUTION_4K);
65 m.content_version = 2;
66 m.audio_language = "DE";
67 m.subtitle_language = "FR";
72 film->set_isdcf_metadata (m);
73 film->set_interop (false);
74 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-R_4K_DI_20140704_PP_SMPTE_OV");
76 /* Test interior aspect ratio: shouldn't be shown with trailers */
78 shared_ptr<ImageContent> content (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
79 film->examine_and_add_content (content);
81 content->video->set_scale (VideoContentScale (Ratio::from_id ("133")));
82 film->set_container (Ratio::from_id ("185"));
83 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_F_DE-fr_US-R_4K_DI_20140704_PP_SMPTE_OV");
85 /* But should be shown for anything else */
87 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("XSN"));
88 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-133_DE-fr_US-R_4K_DI_20140704_PP_SMPTE_OV");
92 film->set_three_d (true);
93 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2-3D_F-133_DE-fr_US-R_4K_DI_20140704_PP_SMPTE-3D_OV");
95 /* Test content type modifiers */
97 film->set_three_d (false);
98 m.temp_version = true;
102 m.two_d_version_of_three_d = true;
103 m.mastered_luminance = "4fl";
104 film->set_isdcf_metadata (m);
105 film->set_video_frame_rate (48);
106 BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2-Temp-Pre-RedBand-MyChain-2D-4fl-48_F-133_DE-fr_US-R_4K_DI_20140704_PP_SMPTE_OV");
108 /* Test a name which is already in camelCase */
110 film->set_three_d (false);
111 m.temp_version = false;
112 m.pre_release = false;
115 m.two_d_version_of_three_d = false;
116 m.mastered_luminance = "";
117 film->set_isdcf_metadata (m);
118 film->set_video_frame_rate (24);
119 film->set_name ("IKnowCamels");
120 BOOST_CHECK_EQUAL (film->isdcf_name(false), "IKnowCamels_XSN-2_F-133_DE-fr_US-R_4K_DI_20140704_PP_SMPTE_OV");
122 /* And one in capitals */
124 film->set_name ("LIKE SHOUTING");
125 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_4K_DI_20140704_PP_SMPTE_OV");
127 /* Test audio channel markup */
129 film->set_audio_channels (6);
130 shared_ptr<SndfileContent> sound (new SndfileContent (film, "test/data/sine_440.wav"));
131 film->examine_and_add_content (sound);
133 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_10_4K_DI_20140704_PP_SMPTE_OV");
135 AudioMapping mapping = sound->audio->mapping ();
137 mapping.set (0, dcp::LEFT, 1.0);
138 sound->audio->set_mapping (mapping);
139 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_20_4K_DI_20140704_PP_SMPTE_OV");
140 mapping.set (0, dcp::RIGHT, 1.0);
141 sound->audio->set_mapping (mapping);
142 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_30_4K_DI_20140704_PP_SMPTE_OV");
143 mapping.set (0, dcp::LFE, 1.0);
144 sound->audio->set_mapping (mapping);
145 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_31_4K_DI_20140704_PP_SMPTE_OV");
146 mapping.set (0, dcp::LS, 1.0);
147 sound->audio->set_mapping (mapping);
148 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_41_4K_DI_20140704_PP_SMPTE_OV");
149 mapping.set (0, dcp::RS, 1.0);
150 sound->audio->set_mapping (mapping);
151 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51_4K_DI_20140704_PP_SMPTE_OV");
152 mapping.set (0, dcp::HI, 1.0);
153 sound->audio->set_mapping (mapping);
154 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51_4K_DI_20140704_PP_SMPTE_OV");
155 film->set_audio_channels (8);
156 mapping.set (0, dcp::HI, 1.0);
157 sound->audio->set_mapping (mapping);
158 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_61_4K_DI_20140704_PP_SMPTE_OV");
159 mapping.set (0, dcp::VI, 1.0);
160 sound->audio->set_mapping (mapping);
161 BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_71_4K_DI_20140704_PP_SMPTE_OV");