2 Copyright (C) 2020 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 /** @file test/test_no_use_video.cc
23 * @brief Test some cases where the video parts of inputs are ignored, to
24 * check that the right DCPs are made.
25 * @ingroup completedcp
29 #include "lib/audio_content.h"
30 #include "lib/content.h"
31 #include "lib/content_factory.h"
33 #include "lib/dcp_content.h"
34 #include "lib/video_content.h"
39 #include <dcp/reel_sound_asset.h>
40 #include <dcp/reel_picture_asset.h>
41 #include <boost/test/unit_test.hpp>
44 using std::dynamic_pointer_cast;
45 using std::make_shared;
46 using std::shared_ptr;
49 /** Overlay two video-only bits of content, don't use the video on one and
50 * make sure the other one is in the DCP.
52 BOOST_AUTO_TEST_CASE (no_use_video_test1)
54 auto film = new_test_film2 ("no_use_video_test1");
55 auto A = content_factory("test/data/flat_red.png").front();
56 auto B = content_factory("test/data/flat_green.png").front();
57 film->examine_and_add_content (A);
58 film->examine_and_add_content (B);
59 BOOST_REQUIRE (!wait_for_jobs());
61 A->set_position (film, dcpomatic::DCPTime());
62 B->set_position (film, dcpomatic::DCPTime());
63 A->video->set_use (false);
66 BOOST_REQUIRE (!wait_for_jobs());
68 check_dcp ("test/data/no_use_video_test1", film);
72 /** Overlay two muxed sources and disable the video on one */
73 BOOST_AUTO_TEST_CASE (no_use_video_test2)
75 auto film = new_test_film2 ("no_use_video_test2");
76 auto A = content_factory (TestPaths::private_data() / "dolby_aurora.vob").front();
77 auto B = content_factory (TestPaths::private_data() / "big_buck_bunny_trailer_480p.mov").front();
78 film->examine_and_add_content (A);
79 film->examine_and_add_content (B);
80 BOOST_REQUIRE (!wait_for_jobs());
82 A->set_position (film, dcpomatic::DCPTime());
83 B->set_position (film, dcpomatic::DCPTime());
84 A->video->set_use (false);
87 BOOST_REQUIRE (!wait_for_jobs());
89 check_dcp (TestPaths::private_data() / "no_use_video_test2", film);
93 /** Make two DCPs and make a VF with the audio from one and the video from another */
94 BOOST_AUTO_TEST_CASE (no_use_video_test3)
96 auto ov_a = new_test_film2 ("no_use_video_test3_ov_a");
97 auto ov_a_pic = content_factory("test/data/flat_red.png").front();
98 BOOST_REQUIRE (ov_a_pic);
99 auto ov_a_snd = content_factory("test/data/sine_16_48_220_10.wav").front();
100 BOOST_REQUIRE (ov_a_snd);
101 ov_a->examine_and_add_content (ov_a_pic);
102 ov_a->examine_and_add_content (ov_a_snd);
103 BOOST_REQUIRE (!wait_for_jobs());
105 BOOST_REQUIRE (!wait_for_jobs());
107 auto ov_b = new_test_film2("no_use_video_test3_ov_b");
108 auto ov_b_pic = content_factory("test/data/flat_green.png").front();
109 BOOST_REQUIRE (ov_b_pic);
110 auto ov_b_snd = content_factory("test/data/sine_16_48_880_10.wav").front();
111 BOOST_REQUIRE (ov_b_snd);
112 ov_b->examine_and_add_content (ov_b_pic);
113 ov_b->examine_and_add_content (ov_b_snd);
114 BOOST_REQUIRE (!wait_for_jobs());
116 BOOST_REQUIRE (!wait_for_jobs());
118 auto vf = new_test_film2 ("no_use_video_test3_vf");
119 auto A = make_shared<DCPContent>(ov_a->dir(ov_a->dcp_name()));
120 auto B = make_shared<DCPContent>(ov_b->dir(ov_b->dcp_name()));
121 vf->examine_and_add_content (A);
122 vf->examine_and_add_content (B);
123 BOOST_REQUIRE (!wait_for_jobs());
125 A->set_position (vf, dcpomatic::DCPTime());
126 A->video->set_use (false);
127 B->set_position (vf, dcpomatic::DCPTime());
128 AudioMapping mapping (16, 16);
129 mapping.make_zero ();
130 B->audio->set_mapping(mapping);
132 A->set_reference_audio (true);
133 B->set_reference_video (true);
136 BOOST_REQUIRE (!wait_for_jobs());
138 dcp::DCP ov_a_check (ov_a->dir(ov_a->dcp_name()));
140 BOOST_REQUIRE_EQUAL (ov_a_check.cpls().size(), 1U);
141 BOOST_REQUIRE_EQUAL (ov_a_check.cpls().front()->reels().size(), 1U);
142 auto ov_a_reel (ov_a_check.cpls().front()->reels().front());
144 dcp::DCP ov_b_check (ov_b->dir(ov_b->dcp_name()));
146 BOOST_REQUIRE_EQUAL (ov_b_check.cpls().size(), 1U);
147 BOOST_REQUIRE_EQUAL (ov_b_check.cpls().front()->reels().size(), 1U);
148 auto ov_b_reel (ov_b_check.cpls().front()->reels().front());
150 dcp::DCP vf_check (vf->dir(vf->dcp_name()));
152 BOOST_REQUIRE_EQUAL (vf_check.cpls().size(), 1U);
153 BOOST_REQUIRE_EQUAL (vf_check.cpls().front()->reels().size(), 1U);
154 auto vf_reel (vf_check.cpls().front()->reels().front());
156 BOOST_CHECK_EQUAL (vf_reel->main_picture()->asset_ref().id(), ov_b_reel->main_picture()->asset_ref().id());
157 BOOST_CHECK_EQUAL (vf_reel->main_sound()->asset_ref().id(), ov_a_reel->main_sound()->asset_ref().id());