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>
40 using boost::shared_ptr;
43 note (dcp::NoteType t, string n)
45 if (t == dcp::DCP_ERROR) {
50 BOOST_AUTO_TEST_CASE (recover_test_2d)
52 shared_ptr<Film> film = new_test_film ("recover_test_2d");
53 film->set_interop (false);
54 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
55 film->set_container (Ratio::from_id ("185"));
56 film->set_name ("recover_test");
58 shared_ptr<FFmpegContent> content (new FFmpegContent("test/data/count300bd24.m2ts"));
59 film->examine_and_add_content (content);
65 boost::filesystem::path const video = "build/test/recover_test_2d/video/185_2K_84d36460538435d5d511ee533c8528df_24_100000000_P_S_0_1200000.mxf";
66 boost::filesystem::copy_file (
68 "build/test/recover_test_2d/original.mxf"
71 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
76 shared_ptr<dcp::MonoPictureAsset> A (new dcp::MonoPictureAsset ("build/test/recover_test_2d/original.mxf"));
77 shared_ptr<dcp::MonoPictureAsset> B (new dcp::MonoPictureAsset (video));
79 dcp::EqualityOptions eq;
80 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));
83 BOOST_AUTO_TEST_CASE (recover_test_3d)
85 shared_ptr<Film> film = new_test_film ("recover_test_3d");
86 film->set_interop (false);
87 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
88 film->set_container (Ratio::from_id ("185"));
89 film->set_name ("recover_test");
90 film->set_three_d (true);
92 shared_ptr<ImageContent> content (new ImageContent("test/data/3d_test"));
93 content->video->set_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT);
94 film->examine_and_add_content (content);
100 boost::filesystem::path const video = "build/test/recover_test_3d/video/185_2K_961f053444e90c5ddbf978eb0ebfa772_24_100000000_P_S_3D_0_96000.mxf";
102 boost::filesystem::copy_file (
104 "build/test/recover_test_3d/original.mxf"
107 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
112 shared_ptr<dcp::StereoPictureAsset> A (new dcp::StereoPictureAsset ("build/test/recover_test_3d/original.mxf"));
113 shared_ptr<dcp::StereoPictureAsset> B (new dcp::StereoPictureAsset (video));
115 dcp::EqualityOptions eq;
116 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));
120 BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted)
122 shared_ptr<Film> film = new_test_film ("recover_test_2d_encrypted");
123 film->set_interop (false);
124 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
125 film->set_container (Ratio::from_id ("185"));
126 film->set_name ("recover_test");
127 film->set_encrypted (true);
129 shared_ptr<FFmpegContent> content (new FFmpegContent("test/data/count300bd24.m2ts"));
130 film->examine_and_add_content (content);
136 boost::filesystem::path const video =
137 "build/test/recover_test_2d_encrypted/video/185_2K_84d36460538435d5d511ee533c8528df_24_100000000_E_S_0_1200000.mxf";
139 boost::filesystem::copy_file (
141 "build/test/recover_test_2d_encrypted/original.mxf"
144 boost::filesystem::resize_file (video, 2 * 1024 * 1024);
149 shared_ptr<dcp::MonoPictureAsset> A (new dcp::MonoPictureAsset ("build/test/recover_test_2d_encrypted/original.mxf"));
150 A->set_key (film->key ());
151 shared_ptr<dcp::MonoPictureAsset> B (new dcp::MonoPictureAsset (video));
152 B->set_key (film->key ());
154 dcp::EqualityOptions eq;
155 BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));