Basics of reel split.
[dcpomatic.git] / test / import_dcp_test.cc
1 /*
2     Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "test.h"
21 #include "lib/film.h"
22 #include "lib/dcp_subtitle_content.h"
23 #include "lib/ratio.h"
24 #include "lib/dcp_content_type.h"
25 #include "lib/dcp_content.h"
26 #include "lib/ffmpeg_content.h"
27 #include "lib/config.h"
28 #include "lib/cross.h"
29 #include <dcp/cpl.h>
30 #include <boost/test/unit_test.hpp>
31
32 using boost::shared_ptr;
33
34 /** Make an encrypted DCP, import it and make a new unencrypted DCP */
35 BOOST_AUTO_TEST_CASE (import_dcp_test)
36 {
37         shared_ptr<Film> A = new_test_film ("import_dcp_test");
38         A->set_container (Ratio::from_id ("185"));
39         A->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
40         A->set_name ("frobozz");
41
42         shared_ptr<FFmpegContent> c (new FFmpegContent (A, "test/data/test.mp4"));
43         A->examine_and_add_content (c);
44         A->set_encrypted (true);
45         wait_for_jobs ();
46
47         A->make_dcp ();
48         wait_for_jobs ();
49
50         dcp::DCP A_dcp ("build/test/import_dcp_test/" + A->dcp_name());
51         A_dcp.read ();
52
53         Config::instance()->set_decryption_chain (shared_ptr<dcp::CertificateChain> (new dcp::CertificateChain (openssl_path ())));
54
55         dcp::EncryptedKDM kdm = A->make_kdm (
56                 Config::instance()->decryption_chain()->leaf (),
57                 A_dcp.cpls().front()->file (),
58                 dcp::LocalTime ("2014-07-21T00:00:00+00:00"),
59                 dcp::LocalTime ("2024-07-21T00:00:00+00:00"),
60                 dcp::MODIFIED_TRANSITIONAL_1
61                 );
62
63         shared_ptr<Film> B = new_test_film ("import_dcp_test2");
64         B->set_container (Ratio::from_id ("185"));
65         B->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
66         B->set_name ("frobozz");
67
68         shared_ptr<DCPContent> d (new DCPContent (B, "build/test/import_dcp_test/" + A->dcp_name()));
69         d->add_kdm (kdm);
70         B->examine_and_add_content (d);
71         wait_for_jobs ();
72
73         B->make_dcp ();
74         wait_for_jobs ();
75
76         /* Should be 1s red, 1s green, 1s blue */
77         check_dcp ("test/data/import_dcp_test2", "build/test/import_dcp_test2/" + B->dcp_name());
78 }