2 Copyright (C) 2015 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.
21 #include "lib/ratio.h"
22 #include "lib/ffmpeg_content.h"
23 #include "lib/image_content.h"
24 #include "lib/dcp_content_type.h"
25 #include "lib/dcp_content.h"
27 #include <boost/test/unit_test.hpp>
30 using boost::shared_ptr;
32 /** Test Film::reels() */
33 BOOST_AUTO_TEST_CASE (reels_test1)
35 shared_ptr<Film> film = new_test_film ("reels_test1");
36 film->set_container (Ratio::from_id ("185"));
37 shared_ptr<FFmpegContent> A (new FFmpegContent (film, "test/data/test.mp4"));
38 film->examine_and_add_content (A);
39 shared_ptr<FFmpegContent> B (new FFmpegContent (film, "test/data/test.mp4"));
40 film->examine_and_add_content (B);
42 BOOST_CHECK_EQUAL (A->full_length(), DCPTime (288000));
44 film->set_reel_type (REELTYPE_SINGLE);
45 list<DCPTimePeriod> r = film->reels ();
46 BOOST_CHECK_EQUAL (r.size(), 1);
47 BOOST_CHECK_EQUAL (r.front().from, DCPTime (0));
48 BOOST_CHECK_EQUAL (r.front().to, DCPTime (288000 * 2));
50 film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
52 BOOST_CHECK_EQUAL (r.size(), 2);
53 BOOST_CHECK_EQUAL (r.front().from, DCPTime (0));
54 BOOST_CHECK_EQUAL (r.front().to, DCPTime (288000));
55 BOOST_CHECK_EQUAL (r.back().from, DCPTime (288000));
56 BOOST_CHECK_EQUAL (r.back().to, DCPTime (288000 * 2));
58 film->set_j2k_bandwidth (100000000);
59 film->set_reel_type (REELTYPE_BY_LENGTH);
60 /* This is just over 2.5s at 100Mbit/s; should correspond to 60 frames */
61 film->set_reel_length (31253154);
63 BOOST_CHECK_EQUAL (r.size(), 3);
64 list<DCPTimePeriod>::const_iterator i = r.begin ();
65 BOOST_CHECK_EQUAL (i->from, DCPTime (0));
66 BOOST_CHECK_EQUAL (i->to, DCPTime::from_frames (60, 24));
68 BOOST_CHECK_EQUAL (i->from, DCPTime::from_frames (60, 24));
69 BOOST_CHECK_EQUAL (i->to, DCPTime::from_frames (120, 24));
71 BOOST_CHECK_EQUAL (i->from, DCPTime::from_frames (120, 24));
72 BOOST_CHECK_EQUAL (i->to, DCPTime::from_frames (144, 24));
75 /** Make a short DCP with multi reels split by video content, then import
76 * this into a new project and make a new DCP referencing it.
78 BOOST_AUTO_TEST_CASE (reels_test2)
80 shared_ptr<Film> film = new_test_film ("reels_test2");
81 film->set_name ("reels_test2");
82 film->set_container (Ratio::from_id ("185"));
83 film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
86 shared_ptr<ImageContent> c (new ImageContent (film, "test/data/flat_red.png"));
87 film->examine_and_add_content (c);
89 c->set_video_length (24);
93 shared_ptr<ImageContent> c (new ImageContent (film, "test/data/flat_green.png"));
94 film->examine_and_add_content (c);
96 c->set_video_length (24);
100 shared_ptr<ImageContent> c (new ImageContent (film, "test/data/flat_blue.png"));
101 film->examine_and_add_content (c);
103 c->set_video_length (24);
106 film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
112 check_dcp ("test/data/reels_test2", film->dir (film->dcp_name()));
114 shared_ptr<Film> film2 = new_test_film ("reels_test3");
115 film2->set_name ("reels_test3");
116 film2->set_container (Ratio::from_id ("185"));
117 film2->set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
118 film2->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
120 shared_ptr<DCPContent> c (new DCPContent (film2, film->dir (film->dcp_name ())));
121 film2->examine_and_add_content (c);
124 list<DCPTimePeriod> r = film2->reels ();
125 BOOST_CHECK_EQUAL (r.size(), 3);
126 list<DCPTimePeriod>::const_iterator i = r.begin ();
127 BOOST_CHECK_EQUAL (i->from, DCPTime (0));
128 BOOST_CHECK_EQUAL (i->to, DCPTime (96000));
130 BOOST_CHECK_EQUAL (i->from, DCPTime (96000));
131 BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 2));
133 BOOST_CHECK_EQUAL (i->from, DCPTime (96000 * 2));
134 BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 3));
136 c->set_reference_video (true);
137 c->set_reference_audio (true);