2 Copyright (C) 2014-2015 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/>.
21 /** @file test/recover_test.cc
22 * @brief Test recovery of a DCP transcode after a crash.
28 #include "lib/dcp_content_type.h"
29 #include "lib/image_content.h"
30 #include "lib/ffmpeg_content.h"
31 #include "lib/video_content.h"
32 #include "lib/ratio.h"
33 #include <dcp/mono_picture_asset.h>
34 #include <dcp/stereo_picture_asset.h>
35 #include <boost/test/unit_test.hpp>
39 using std::make_shared;
40 using std::shared_ptr;
42 #if BOOST_VERSION >= 106100
43 using namespace boost::placeholders;
47 note (dcp::NoteType t, string n)
49 if (t == dcp::NoteType::ERROR) {
54 BOOST_AUTO_TEST_CASE (recover_test_2d)
56 shared_ptr<Film> film = new_test_film ("recover_test_2d");
57 film->set_interop (false);
58 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
59 film->set_container (Ratio::from_id ("185"));
60 film->set_name ("recover_test");
62 shared_ptr<FFmpegContent> content (new FFmpegContent("test/data/count300bd24.m2ts"));
63 film->examine_and_add_content (content);
64 BOOST_REQUIRE (!wait_for_jobs());
67 BOOST_REQUIRE (!wait_for_jobs());
69 boost::filesystem::path const video = "build/test/recover_test_2d/video/185_2K_02543352c540f4b083bff3f1e309d4a9_24_100000000_P_S_0_1200000.mxf";
70 boost::filesystem::copy_file (
72 "build/test/recover_test_2d/original.mxf"
75 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
78 BOOST_REQUIRE (!wait_for_jobs());
80 shared_ptr<dcp::MonoPictureAsset> A (new dcp::MonoPictureAsset ("build/test/recover_test_2d/original.mxf"));
81 shared_ptr<dcp::MonoPictureAsset> B (new dcp::MonoPictureAsset (video));
83 dcp::EqualityOptions eq;
84 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));
87 BOOST_AUTO_TEST_CASE (recover_test_3d, * boost::unit_test::depends_on("recover_test_2d"))
89 auto film = new_test_film ("recover_test_3d");
90 film->set_interop (false);
91 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
92 film->set_container (Ratio::from_id ("185"));
93 film->set_name ("recover_test");
94 film->set_three_d (true);
96 auto content = make_shared<ImageContent>("test/data/3d_test");
97 content->video->set_frame_type (VideoFrameType::THREE_D_LEFT_RIGHT);
98 film->examine_and_add_content (content);
99 BOOST_REQUIRE (!wait_for_jobs());
102 BOOST_REQUIRE (!wait_for_jobs());
104 boost::filesystem::path const video = "build/test/recover_test_3d/video/185_2K_70e6661af92ae94458784c16a21a9748_24_100000000_P_S_3D_0_96000.mxf";
106 boost::filesystem::copy_file (
108 "build/test/recover_test_3d/original.mxf"
111 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
114 BOOST_REQUIRE (!wait_for_jobs());
116 auto A = make_shared<dcp::StereoPictureAsset>("build/test/recover_test_3d/original.mxf");
117 auto B = make_shared<dcp::StereoPictureAsset>(video);
119 dcp::EqualityOptions eq;
120 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));
124 BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted, * boost::unit_test::depends_on("recover_test_3d"))
126 auto film = new_test_film ("recover_test_2d_encrypted");
127 film->set_interop (false);
128 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
129 film->set_container (Ratio::from_id ("185"));
130 film->set_name ("recover_test");
131 film->set_encrypted (true);
132 film->_key = dcp::Key("eafcb91c9f5472edf01f3a2404c57258");
134 auto content = make_shared<FFmpegContent>("test/data/count300bd24.m2ts");
135 film->examine_and_add_content (content);
136 BOOST_REQUIRE (!wait_for_jobs());
139 BOOST_REQUIRE (!wait_for_jobs());
141 boost::filesystem::path const video =
142 "build/test/recover_test_2d_encrypted/video/185_2K_02543352c540f4b083bff3f1e309d4a9_24_100000000_Eeafcb91c9f5472edf01f3a2404c57258_S_0_1200000.mxf";
144 boost::filesystem::copy_file (
146 "build/test/recover_test_2d_encrypted/original.mxf"
149 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
152 BOOST_REQUIRE (!wait_for_jobs());
154 auto A = make_shared<dcp::MonoPictureAsset>("build/test/recover_test_2d_encrypted/original.mxf");
155 A->set_key (film->key ());
156 auto B = make_shared<dcp::MonoPictureAsset>(video);
157 B->set_key (film->key ());
159 dcp::EqualityOptions eq;
160 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));