2 Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
22 #include "lib/image_content.h"
23 #include "lib/dcp_subtitle_content.h"
24 #include "lib/video_content.h"
29 #include <dcp/interop_subtitle_asset.h>
30 #include <dcp/reel_subtitle_asset.h>
31 #include <boost/test/unit_test.hpp>
34 using boost::shared_ptr;
36 /* Check that timings are done correctly for multi-reel DCPs with PNG subs */
37 BOOST_AUTO_TEST_CASE (subtitle_reel_test)
39 shared_ptr<Film> film = new_test_film2 ("subtitle_reel_test");
40 film->set_interop (true);
41 shared_ptr<ImageContent> red_a (new ImageContent("test/data/flat_red.png"));
42 shared_ptr<ImageContent> red_b (new ImageContent("test/data/flat_red.png"));
43 shared_ptr<DCPSubtitleContent> sub_a (new DCPSubtitleContent("test/data/png_subs/subs.xml"));
44 shared_ptr<DCPSubtitleContent> sub_b (new DCPSubtitleContent("test/data/png_subs/subs.xml"));
46 film->examine_and_add_content (red_a);
47 film->examine_and_add_content (red_b);
48 film->examine_and_add_content (sub_a);
49 film->examine_and_add_content (sub_b);
51 BOOST_REQUIRE (!wait_for_jobs());
53 red_a->set_position (film, DCPTime());
54 red_a->video->set_length (240);
55 sub_a->set_position (film, DCPTime());
56 red_b->set_position (film, DCPTime::from_seconds(10));
57 red_b->video->set_length (240);
58 sub_b->set_position (film, DCPTime::from_seconds(10));
60 film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
63 BOOST_REQUIRE (!wait_for_jobs());
65 dcp::DCP dcp ("build/test/subtitle_reel_test/" + film->dcp_name());
67 BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1);
68 shared_ptr<dcp::CPL> cpl = dcp.cpls().front();
70 list<shared_ptr<dcp::Reel> > reels = cpl->reels ();
71 BOOST_REQUIRE_EQUAL (reels.size(), 2);
72 list<shared_ptr<dcp::Reel> >::const_iterator i = reels.begin ();
73 BOOST_REQUIRE ((*i)->main_subtitle());
74 BOOST_REQUIRE ((*i)->main_subtitle()->asset());
75 shared_ptr<dcp::InteropSubtitleAsset> A = boost::dynamic_pointer_cast<dcp::InteropSubtitleAsset>((*i)->main_subtitle()->asset());
78 BOOST_REQUIRE ((*i)->main_subtitle());
79 BOOST_REQUIRE ((*i)->main_subtitle()->asset());
80 shared_ptr<dcp::InteropSubtitleAsset> B = boost::dynamic_pointer_cast<dcp::InteropSubtitleAsset>((*i)->main_subtitle()->asset());
83 BOOST_REQUIRE_EQUAL (A->subtitles().size(), 1);
84 BOOST_REQUIRE_EQUAL (B->subtitles().size(), 1);
86 /* These times should be the same as they are should be offset from the start of the reel */
87 BOOST_CHECK (A->subtitles().front()->in() == B->subtitles().front()->in());