Various playlist editor developments and fixes.
[dcpomatic.git] / test / subtitle_reel_number_test.cc
1 /*
2     Copyright (C) 2017 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 "lib/string_text_file_content.h"
22 #include "lib/film.h"
23 #include "lib/ratio.h"
24 #include "lib/text_content.h"
25 #include "lib/dcp_content_type.h"
26 #include "test.h"
27 #include <dcp/cpl.h>
28 #include <dcp/dcp.h>
29 #include <dcp/reel.h>
30 #include <dcp/interop_subtitle_asset.h>
31 #include <dcp/reel_subtitle_asset.h>
32 #include <dcp/raw_convert.h>
33 #include <boost/test/unit_test.hpp>
34
35 using std::string;
36 using boost::shared_ptr;
37 using boost::dynamic_pointer_cast;
38
39 /* Check that ReelNumber is setup correctly when making multi-reel subtitled DCPs */
40 BOOST_AUTO_TEST_CASE (subtitle_reel_number_test)
41 {
42         shared_ptr<Film> film = new_test_film ("subtitle_reel_number_test");
43         film->set_container (Ratio::from_id ("185"));
44         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
45         film->set_name ("frobozz");
46         shared_ptr<StringTextFileContent> content (new StringTextFileContent("test/data/subrip5.srt"));
47         film->examine_and_add_content (content);
48         BOOST_REQUIRE (!wait_for_jobs ());
49         content->only_text()->set_use (true);
50         content->only_text()->set_burn (false);
51         film->set_reel_type (REELTYPE_BY_LENGTH);
52         film->set_interop (true);
53         film->set_reel_length (1024 * 1024 * 512);
54         film->make_dcp ();
55         BOOST_REQUIRE (!wait_for_jobs ());
56
57         dcp::DCP dcp ("build/test/subtitle_reel_number_test/" + film->dcp_name());
58         dcp.read ();
59         BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1);
60         shared_ptr<dcp::CPL> cpl = dcp.cpls().front();
61         BOOST_REQUIRE_EQUAL (cpl->reels().size(), 6);
62
63         int n = 1;
64         BOOST_FOREACH (shared_ptr<dcp::Reel> i, cpl->reels()) {
65                 if (i->main_subtitle()) {
66                         shared_ptr<dcp::InteropSubtitleAsset> ass = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(i->main_subtitle()->asset());
67                         BOOST_REQUIRE (ass);
68                         BOOST_CHECK_EQUAL (ass->reel_number(), dcp::raw_convert<string>(n));
69                         ++n;
70                 }
71         }
72 }