2 Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp 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 libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
20 #include "interop_subtitle_asset.h"
21 #include "smpte_subtitle_asset.h"
22 #include "subtitle_string.h"
24 #include <boost/test/unit_test.hpp>
28 using boost::shared_ptr;
30 /* Write some subtitle content as Interop XML and check that it is right */
31 BOOST_AUTO_TEST_CASE (write_interop_subtitle_test)
33 dcp::InteropSubtitleAsset c;
34 c.set_reel_number ("1");
35 c.set_language ("EN");
36 c.set_movie_title ("Test");
44 dcp::Colour (255, 255, 255),
47 dcp::Time (0, 4, 9, 22, 24),
48 dcp::Time (0, 4, 11, 22, 24),
56 dcp::Colour (0, 0, 0),
57 dcp::Time (0, 0, 0, 0, 24),
58 dcp::Time (0, 0, 0, 0, 24)
64 boost::optional<string> (),
68 dcp::Colour (128, 0, 64),
71 dcp::Time (5, 41, 0, 21, 24),
72 dcp::Time (6, 12, 15, 21, 24),
80 dcp::Colour (1, 2, 3),
81 dcp::Time (1, 2, 3, 4, 24),
82 dcp::Time (5, 6, 7, 8, 24)
86 c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
90 "<DCSubtitle Version=\"1.0\">\n"
91 " <SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>\n"
92 " <MovieTitle>Test</MovieTitle>\n"
93 " <ReelNumber>1</ReelNumber>\n"
94 " <Language>EN</Language>\n"
95 " <Font Id=\"Frutiger\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
96 " <Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">\n"
97 " <Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>\n"
100 " <Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underlined=\"yes\" Weight=\"bold\">\n"
101 " <Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:218\" TimeOut=\"06:12:15:218\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">\n"
102 " <Text VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>\n"
110 /* Write some subtitle content as SMPTE XML and check that it is right */
111 BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test)
113 dcp::SMPTESubtitleAsset c;
114 c.set_reel_number (1);
115 c.set_language ("EN");
116 c.set_content_title_text ("Test");
117 c.set_issue_date (dcp::LocalTime ("2016-04-01T03:52:00+00:00"));
120 dcp::SubtitleString (
125 dcp::Colour (255, 255, 255),
128 dcp::Time (0, 4, 9, 22, 24),
129 dcp::Time (0, 4, 11, 22, 24),
137 dcp::Colour (0, 0, 0),
138 dcp::Time (0, 0, 0, 0, 24),
139 dcp::Time (0, 0, 0, 0, 24)
144 dcp::SubtitleString (
145 boost::optional<string> (),
149 dcp::Colour (128, 0, 64),
152 dcp::Time (5, 41, 0, 21, 24),
153 dcp::Time (6, 12, 15, 21, 24),
161 dcp::Colour (1, 2, 3),
162 dcp::Time (1, 2, 3, 4, 24),
163 dcp::Time (5, 6, 7, 8, 24)
167 c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
171 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
172 "<dcst:SubtitleReel xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n"
173 " <dcst:Id>urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6</dcst:Id>\n"
174 " <dcst:ContentTitleText>Test</dcst:ContentTitleText>\n"
175 " <dcst:IssueDate>2016-04-01T03:52:00.000+00:00</dcst:IssueDate>\n"
176 " <dcst:ReelNumber>1</dcst:ReelNumber>\n"
177 " <dcst:Language>EN</dcst:Language>\n"
178 " <dcst:EditRate>24 1</dcst:EditRate>\n"
179 " <dcst:TimeCodeRate>24</dcst:TimeCodeRate>\n"
180 " <dcst:SubtitleList>\n"
181 " <dcst:Font ID=\"Frutiger\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underline=\"no\" Weight=\"normal\">\n"
182 " <dcst:Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:22\" TimeOut=\"00:04:11:22\" FadeUpTime=\"00:00:00:00\" FadeDownTime=\"00:00:00:00\">\n"
183 " <dcst:Text Valign=\"top\" Vposition=\"80\">Hello world</dcst:Text>\n"
184 " </dcst:Subtitle>\n"
186 " <dcst:Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underline=\"yes\" Weight=\"bold\">\n"
187 " <dcst:Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:21\" TimeOut=\"06:12:15:21\" FadeUpTime=\"01:02:03:04\" FadeDownTime=\"05:06:07:08\">\n"
188 " <dcst:Text Valign=\"bottom\" Vposition=\"40\" Direction=\"rtl\">What's going on</dcst:Text>\n"
189 " </dcst:Subtitle>\n"
191 " </dcst:SubtitleList>\n"
192 "</dcst:SubtitleReel>\n",