2 Copyright (C) 2014-2021 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/recover_test.cc
23 * @brief Test recovery of a DCP transcode after a crash.
30 #include "lib/dcp_content_type.h"
31 #include "lib/image_content.h"
32 #include "lib/ffmpeg_content.h"
33 #include "lib/video_content.h"
34 #include "lib/ratio.h"
35 #include <dcp/mono_picture_asset.h>
36 #include <dcp/stereo_picture_asset.h>
37 #include <boost/test/unit_test.hpp>
42 using std::make_shared;
43 using std::shared_ptr;
45 #if BOOST_VERSION >= 106100
46 using namespace boost::placeholders;
51 note (dcp::NoteType t, string n)
53 if (t == dcp::NoteType::ERROR) {
59 BOOST_AUTO_TEST_CASE (recover_test_2d)
61 shared_ptr<Film> film = new_test_film ("recover_test_2d");
62 film->set_interop (false);
63 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
64 film->set_container (Ratio::from_id ("185"));
65 film->set_name ("recover_test");
67 shared_ptr<FFmpegContent> content (new FFmpegContent("test/data/count300bd24.m2ts"));
68 film->examine_and_add_content (content);
69 BOOST_REQUIRE (!wait_for_jobs());
72 BOOST_REQUIRE (!wait_for_jobs());
74 boost::filesystem::path const video = "build/test/recover_test_2d/video/185_2K_02543352c540f4b083bff3f1e309d4a9_24_100000000_P_S_0_1200000.mxf";
75 boost::filesystem::copy_file (
77 "build/test/recover_test_2d/original.mxf"
80 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
82 make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE });
84 shared_ptr<dcp::MonoPictureAsset> A (new dcp::MonoPictureAsset ("build/test/recover_test_2d/original.mxf"));
85 shared_ptr<dcp::MonoPictureAsset> B (new dcp::MonoPictureAsset (video));
87 dcp::EqualityOptions eq;
88 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));
92 BOOST_AUTO_TEST_CASE (recover_test_3d, * boost::unit_test::depends_on("recover_test_2d"))
94 auto film = new_test_film ("recover_test_3d");
95 film->set_interop (false);
96 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
97 film->set_container (Ratio::from_id ("185"));
98 film->set_name ("recover_test");
99 film->set_three_d (true);
101 auto content = make_shared<ImageContent>("test/data/3d_test");
102 content->video->set_frame_type (VideoFrameType::THREE_D_LEFT_RIGHT);
103 film->examine_and_add_content (content);
104 BOOST_REQUIRE (!wait_for_jobs());
106 make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE });
108 boost::filesystem::path const video = "build/test/recover_test_3d/video/185_2K_70e6661af92ae94458784c16a21a9748_24_100000000_P_S_3D_0_96000.mxf";
110 boost::filesystem::copy_file (
112 "build/test/recover_test_3d/original.mxf"
115 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
117 make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE });
119 auto A = make_shared<dcp::StereoPictureAsset>("build/test/recover_test_3d/original.mxf");
120 auto B = make_shared<dcp::StereoPictureAsset>(video);
122 dcp::EqualityOptions eq;
123 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));
127 BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted, * boost::unit_test::depends_on("recover_test_3d"))
129 auto film = new_test_film ("recover_test_2d_encrypted");
130 film->set_interop (false);
131 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
132 film->set_container (Ratio::from_id ("185"));
133 film->set_name ("recover_test");
134 film->set_encrypted (true);
135 film->_key = dcp::Key("eafcb91c9f5472edf01f3a2404c57258");
137 auto content = make_shared<FFmpegContent>("test/data/count300bd24.m2ts");
138 film->examine_and_add_content (content);
139 BOOST_REQUIRE (!wait_for_jobs());
141 make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE });
143 boost::filesystem::path const video =
144 "build/test/recover_test_2d_encrypted/video/185_2K_02543352c540f4b083bff3f1e309d4a9_24_100000000_Eeafcb91c9f5472edf01f3a2404c57258_S_0_1200000.mxf";
146 boost::filesystem::copy_file (
148 "build/test/recover_test_2d_encrypted/original.mxf"
151 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
153 make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE });
155 auto A = make_shared<dcp::MonoPictureAsset>("build/test/recover_test_2d_encrypted/original.mxf");
156 A->set_key (film->key ());
157 auto B = make_shared<dcp::MonoPictureAsset>(video);
158 B->set_key (film->key ());
160 dcp::EqualityOptions eq;
161 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));