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