2 Copyright (C) 2015-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 "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");
43 dcp::Colour (255, 255, 255),
46 dcp::Time (0, 4, 9, 22, 24),
47 dcp::Time (0, 4, 11, 22, 24),
55 dcp::Colour (0, 0, 0),
56 dcp::Time (0, 0, 0, 0, 24),
57 dcp::Time (0, 0, 0, 0, 24)
63 boost::optional<string> (),
66 dcp::Colour (128, 0, 64),
69 dcp::Time (5, 41, 0, 21, 24),
70 dcp::Time (6, 12, 15, 21, 24),
78 dcp::Colour (1, 2, 3),
79 dcp::Time (1, 2, 3, 4, 24),
80 dcp::Time (5, 6, 7, 8, 24)
84 c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
88 "<DCSubtitle Version=\"1.0\">\n"
89 " <SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>\n"
90 " <MovieTitle>Test</MovieTitle>\n"
91 " <ReelNumber>1</ReelNumber>\n"
92 " <Language>EN</Language>\n"
93 " <Font Id=\"Frutiger\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
94 " <Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">\n"
95 " <Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>\n"
98 " <Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underlined=\"no\" Weight=\"bold\">\n"
99 " <Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:218\" TimeOut=\"06:12:15:218\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">\n"
100 " <Text VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>\n"
108 /* Write some subtitle content as SMPTE XML and check that it is right */
109 BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test)
111 dcp::SMPTESubtitleAsset c;
112 c.set_reel_number (1);
113 c.set_language ("EN");
114 c.set_content_title_text ("Test");
115 c.set_issue_date (dcp::LocalTime ("2016-04-01T03:52:00+00:00"));
118 dcp::SubtitleString (
122 dcp::Colour (255, 255, 255),
125 dcp::Time (0, 4, 9, 22, 24),
126 dcp::Time (0, 4, 11, 22, 24),
134 dcp::Colour (0, 0, 0),
135 dcp::Time (0, 0, 0, 0, 24),
136 dcp::Time (0, 0, 0, 0, 24)
141 dcp::SubtitleString (
142 boost::optional<string> (),
145 dcp::Colour (128, 0, 64),
148 dcp::Time (5, 41, 0, 21, 24),
149 dcp::Time (6, 12, 15, 21, 24),
157 dcp::Colour (1, 2, 3),
158 dcp::Time (1, 2, 3, 4, 24),
159 dcp::Time (5, 6, 7, 8, 24)
163 c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
167 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
168 "<dcst:SubtitleReel xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n"
169 " <dcst:Id>urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6</dcst:Id>\n"
170 " <dcst:ContentTitleText>Test</dcst:ContentTitleText>\n"
171 " <dcst:IssueDate>2016-04-01T03:52:00.000+00:00</dcst:IssueDate>\n"
172 " <dcst:ReelNumber>1</dcst:ReelNumber>\n"
173 " <dcst:Language>EN</dcst:Language>\n"
174 " <dcst:EditRate>24 1</dcst:EditRate>\n"
175 " <dcst:TimeCodeRate>24</dcst:TimeCodeRate>\n"
176 " <dcst:SubtitleList>\n"
177 " <dcst:Font ID=\"Frutiger\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underline=\"no\" Weight=\"normal\">\n"
178 " <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"
179 " <dcst:Text Valign=\"top\" Vposition=\"80\">Hello world</dcst:Text>\n"
180 " </dcst:Subtitle>\n"
182 " <dcst:Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underline=\"no\" Weight=\"bold\">\n"
183 " <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"
184 " <dcst:Text Valign=\"bottom\" Vposition=\"40\" Direction=\"rtl\">What's going on</dcst:Text>\n"
185 " </dcst:Subtitle>\n"
187 " </dcst:SubtitleList>\n"
188 "</dcst:SubtitleReel>\n",