Support ISDCF naming convention version 9.
[dcpomatic.git] / test / isdcf_name_test.cc
1 /*
2     Copyright (C) 2014 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 "test.h"
26
27 using std::cout;
28 using boost::shared_ptr;
29
30 BOOST_AUTO_TEST_CASE (isdcf_name_test)
31 {
32         shared_ptr<Film> film = new_test_film ("isdcf_name_test");
33
34         /* A basic test */
35
36         film->set_name ("My Nice Film");
37         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
38         film->set_container (Ratio::from_id ("185"));
39         film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
40         ISDCFMetadata m;
41         m.content_version = 1;
42         m.audio_language = "EN";
43         m.subtitle_language = "XX";
44         m.territory = "UK";
45         m.rating = "PG";
46         m.studio = "ST";
47         m.facility = "FA";
48         m.package_type = "OV";
49         film->set_isdcf_metadata (m);
50         film->set_interop (true);
51         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_EN-XX_UK-PG_51_2K_ST_20140704_FA_IOP_OV");
52
53         /* Test a long name and some different data */
54
55         film->set_name ("My Nice Film With A Very Long Name");
56         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
57         film->set_container (Ratio::from_id ("239"));
58         film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
59         film->set_audio_channels (1);
60         film->set_resolution (RESOLUTION_4K);
61         m.content_version = 2;
62         m.audio_language = "DE";
63         m.subtitle_language = "FR";
64         m.territory = "US";
65         m.rating = "R";
66         m.studio = "DI";
67         m.facility = "PP";
68         m.package_type = "VF";
69         film->set_isdcf_metadata (m);
70         film->set_interop (false);
71         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_S_DE-FR_US-R_10_4K_DI_20140704_PP_SMPTE_VF");
72
73         /* Test interior aspect ratio */
74
75         shared_ptr<ImageContent> content (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
76         film->examine_and_add_content (content);
77         wait_for_jobs ();
78         content->set_scale (VideoContentScale (Ratio::from_id ("133")));
79         film->set_container (Ratio::from_id ("185"));
80         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_F-133_DE-FR_US-R_10_4K_DI_20140704_PP_SMPTE_VF");
81
82         /* Test 3D */
83
84         film->set_three_d (true);
85         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2-3D_F-133_DE-FR_US-R_10_4K_DI_20140704_PP_SMPTE-3D_VF");
86
87         /* Test content type modifiers */
88
89         film->set_three_d (false);
90         m.temp_version = true;
91         m.pre_release = true;
92         m.red_band = true;
93         m.chain = "MyChain";
94         m.two_d_version_of_three_d = true;
95         m.mastered_luminance = "4fl";
96         film->set_isdcf_metadata (m);
97         film->set_video_frame_rate (48);
98         BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2-Temp-Pre-RedBand-MyChain-2D-4fl-48_F-133_DE-FR_US-R_10_4K_DI_20140704_PP_SMPTE_VF");
99 }
100