No-op: remove all trailing whitespace.
[dcpomatic.git] / test / isdcf_name_test.cc
1 /*
2     Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include <boost/test/unit_test.hpp>
21 #include "lib/film.h"
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 "test.h"
27
28 using std::cout;
29 using boost::shared_ptr;
30
31 BOOST_AUTO_TEST_CASE (isdcf_name_test)
32 {
33         shared_ptr<Film> film = new_test_film ("isdcf_name_test");
34
35         /* A basic test */
36
37         film->set_name ("My Nice Film");
38         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
39         film->set_container (Ratio::from_id ("185"));
40         film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
41         ISDCFMetadata m;
42         m.content_version = 1;
43         m.audio_language = "EN";
44         m.subtitle_language = "XX";
45         m.territory = "UK";
46         m.rating = "PG";
47         m.studio = "ST";
48         m.facility = "FA";
49         m.package_type = "OV";
50         film->set_isdcf_metadata (m);
51         film->set_interop (true);
52         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_EN-XX_UK-PG_2K_ST_20140704_FA_IOP_OV");
53
54         /* Test a long name and some different data */
55
56         film->set_name ("My Nice Film With A Very Long Name");
57         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
58         film->set_container (Ratio::from_id ("239"));
59         film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
60         film->set_audio_channels (1);
61         film->set_resolution (RESOLUTION_4K);
62         m.content_version = 2;
63         m.audio_language = "DE";
64         m.subtitle_language = "FR";
65         m.territory = "US";
66         m.rating = "R";
67         m.studio = "DI";
68         m.facility = "PP";
69         m.package_type = "VF";
70         film->set_isdcf_metadata (m);
71         film->set_interop (false);
72         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_S_DE-FR_US-R_4K_DI_20140704_PP_SMPTE_VF");
73
74         /* Test interior aspect ratio: shouldn't be shown with trailers */
75
76         shared_ptr<ImageContent> content (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
77         film->examine_and_add_content (content);
78         wait_for_jobs ();
79         content->set_scale (VideoContentScale (Ratio::from_id ("133")));
80         film->set_container (Ratio::from_id ("185"));
81         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_F_DE-FR_US-R_4K_DI_20140704_PP_SMPTE_VF");
82
83         /* But should be shown for anything else */
84
85         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("XSN"));
86         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2_F-133_DE-FR_US-R_4K_DI_20140704_PP_SMPTE_VF");
87
88         /* Test 3D */
89
90         film->set_three_d (true);
91         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_XSN-2-3D_F-133_DE-FR_US-R_4K_DI_20140704_PP_SMPTE-3D_VF");
92
93         /* Test content type modifiers */
94
95         film->set_three_d (false);
96         m.temp_version = true;
97         m.pre_release = true;
98         m.red_band = true;
99         m.chain = "MyChain";
100         m.two_d_version_of_three_d = true;
101         m.mastered_luminance = "4fl";
102         film->set_isdcf_metadata (m);
103         film->set_video_frame_rate (48);
104         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_VF");
105
106         /* Test a name which is already in camelCase */
107
108         film->set_three_d (false);
109         m.temp_version = false;
110         m.pre_release = false;
111         m.red_band = false;
112         m.chain = "";
113         m.two_d_version_of_three_d = false;
114         m.mastered_luminance = "";
115         film->set_isdcf_metadata (m);
116         film->set_video_frame_rate (24);
117         film->set_name ("IKnowCamels");
118         BOOST_CHECK_EQUAL (film->isdcf_name(false), "IKnowCamels_XSN-2_F-133_DE-FR_US-R_4K_DI_20140704_PP_SMPTE_VF");
119
120         /* And one in capitals */
121
122         film->set_name ("LIKE SHOUTING");
123         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_4K_DI_20140704_PP_SMPTE_VF");
124
125         /* Test audio channel markup */
126
127         film->set_audio_channels (6);
128         shared_ptr<SndfileContent> sound (new SndfileContent (film, "test/data/sine_440.wav"));
129         film->examine_and_add_content (sound);
130         wait_for_jobs ();
131         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_10_4K_DI_20140704_PP_SMPTE_VF");
132
133         AudioMapping mapping = sound->audio_mapping ();
134
135         mapping.set (0, dcp::LEFT, 1.0);
136         sound->set_audio_mapping (mapping);
137         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_20_4K_DI_20140704_PP_SMPTE_VF");
138         mapping.set (0, dcp::RIGHT, 1.0);
139         sound->set_audio_mapping (mapping);
140         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_30_4K_DI_20140704_PP_SMPTE_VF");
141         mapping.set (0, dcp::LFE, 1.0);
142         sound->set_audio_mapping (mapping);
143         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_31_4K_DI_20140704_PP_SMPTE_VF");
144         mapping.set (0, dcp::LS, 1.0);
145         sound->set_audio_mapping (mapping);
146         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_41_4K_DI_20140704_PP_SMPTE_VF");
147         mapping.set (0, dcp::RS, 1.0);
148         sound->set_audio_mapping (mapping);
149         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_51_4K_DI_20140704_PP_SMPTE_VF");
150         mapping.set (0, dcp::HI, 1.0);
151         sound->set_audio_mapping (mapping);
152         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_51_4K_DI_20140704_PP_SMPTE_VF");
153         film->set_audio_channels (8);
154         mapping.set (0, dcp::HI, 1.0);
155         sound->set_audio_mapping (mapping);
156         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_61_4K_DI_20140704_PP_SMPTE_VF");
157         mapping.set (0, dcp::VI, 1.0);
158         sound->set_audio_mapping (mapping);
159         BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-FR_US-R_71_4K_DI_20140704_PP_SMPTE_VF");
160 }
161
162