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/equality_options.h>
36 #include <dcp/mono_j2k_picture_asset.h>
37 #include <dcp/stereo_j2k_picture_asset.h>
38 #include <boost/test/unit_test.hpp>
43 using std::make_shared;
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 auto 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");
66 film->set_video_bit_rate(VideoEncoding::JPEG2000, 100000000);
68 auto content = make_shared<FFmpegContent>("test/data/count300bd24.m2ts");
69 film->examine_and_add_content (content);
70 BOOST_REQUIRE (!wait_for_jobs());
75 dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE,
76 dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE
79 auto video = [film]() {
80 return find_file(boost::filesystem::path("build/test/recover_test_2d") / film->dcp_name(false), "j2c_");
83 boost::filesystem::copy_file (
85 "build/test/recover_test_2d/original.mxf"
88 boost::filesystem::resize_file(video(), 2 * 1024 * 1024);
93 dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE,
94 dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE
97 /* We end up with two CPLs in this directory, which Clairmeta gives an error for */
101 auto A = make_shared<dcp::MonoJ2KPictureAsset>("build/test/recover_test_2d/original.mxf");
102 auto B = make_shared<dcp::MonoJ2KPictureAsset>(video());
104 dcp::EqualityOptions eq;
105 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));
109 BOOST_AUTO_TEST_CASE (recover_test_3d, * boost::unit_test::depends_on("recover_test_2d"))
111 auto film = new_test_film ("recover_test_3d");
112 film->set_interop (false);
113 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
114 film->set_container (Ratio::from_id ("185"));
115 film->set_name ("recover_test");
116 film->set_three_d (true);
117 film->set_video_bit_rate(VideoEncoding::JPEG2000, 100000000);
119 auto content = make_shared<ImageContent>("test/data/3d_test");
120 content->video->set_frame_type (VideoFrameType::THREE_D_LEFT_RIGHT);
121 film->examine_and_add_content (content);
122 BOOST_REQUIRE (!wait_for_jobs());
124 make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE });
126 auto video = [film]() {
127 return find_file(boost::filesystem::path("build/test/recover_test_3d") / film->dcp_name(false), "j2c_");
130 boost::filesystem::copy_file (
132 "build/test/recover_test_3d/original.mxf"
135 boost::filesystem::resize_file(video(), 2 * 1024 * 1024);
140 dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE
143 /* We end up with two CPLs in this directory, which Clairmeta gives an error for */
147 auto A = make_shared<dcp::StereoJ2KPictureAsset>("build/test/recover_test_3d/original.mxf");
148 auto B = make_shared<dcp::StereoJ2KPictureAsset>(video());
150 dcp::EqualityOptions eq;
151 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));
155 BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted, * boost::unit_test::depends_on("recover_test_3d"))
157 auto film = new_test_film ("recover_test_2d_encrypted");
158 film->set_interop (false);
159 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
160 film->set_container (Ratio::from_id ("185"));
161 film->set_name ("recover_test");
162 film->set_encrypted (true);
163 film->_key = dcp::Key("eafcb91c9f5472edf01f3a2404c57258");
164 film->set_video_bit_rate(VideoEncoding::JPEG2000, 100000000);
166 auto content = make_shared<FFmpegContent>("test/data/count300bd24.m2ts");
167 film->examine_and_add_content (content);
168 BOOST_REQUIRE (!wait_for_jobs());
170 make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE });
172 auto video = [film]() {
173 return find_file(boost::filesystem::path("build/test/recover_test_2d_encrypted") / film->dcp_name(false), "j2c_");
176 boost::filesystem::copy_file (
178 "build/test/recover_test_2d_encrypted/original.mxf"
181 boost::filesystem::resize_file(video(), 2 * 1024 * 1024);
186 dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE
189 /* We end up with two CPLs in this directory, which Clairmeta gives an error for */
193 auto A = make_shared<dcp::MonoJ2KPictureAsset>("build/test/recover_test_2d_encrypted/original.mxf");
194 A->set_key (film->key ());
195 auto B = make_shared<dcp::MonoJ2KPictureAsset>(video());
196 B->set_key (film->key ());
198 dcp::EqualityOptions eq;
199 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));