2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 #include <boost/test/unit_test.hpp>
23 #include "mono_picture_frame.h"
25 #include "argb_frame.h"
26 #include "mono_picture_mxf.h"
27 #include "reel_picture_asset.h"
31 using boost::dynamic_pointer_cast;
32 using boost::shared_ptr;
34 static shared_ptr<const dcp::ARGBFrame>
35 get_frame (dcp::DCP const & dcp)
37 shared_ptr<const dcp::Reel> reel = dcp.cpls().front()->reels().front ();
38 shared_ptr<dcp::PictureMXF> picture = reel->main_picture()->mxf ();
39 BOOST_CHECK (picture);
41 shared_ptr<const dcp::MonoPictureMXF> mono_picture = dynamic_pointer_cast<const dcp::MonoPictureMXF> (picture);
42 shared_ptr<const dcp::MonoPictureFrame> j2k_frame = mono_picture->get_frame (0);
43 return j2k_frame->argb_frame ();
46 /** Decrypt an encrypted test DCP and check that its first frame is the same as the unencrypted version */
47 BOOST_AUTO_TEST_CASE (decryption_test)
49 boost::filesystem::path plaintext_path = test_corpus;
50 plaintext_path /= "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV";
51 dcp::DCP plaintext (plaintext_path.string ());
53 BOOST_CHECK_EQUAL (plaintext.encrypted (), false);
55 boost::filesystem::path encrypted_path = test_corpus;
56 encrypted_path /= "TONEPLATES-SMPTE-ENCRYPTED_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV";
57 dcp::DCP encrypted (encrypted_path.string ());
59 BOOST_CHECK_EQUAL (encrypted.encrypted (), true);
62 "test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml",
63 "test/data/private.key"
68 shared_ptr<const dcp::ARGBFrame> plaintext_frame = get_frame (plaintext);
69 shared_ptr<const dcp::ARGBFrame> encrypted_frame = get_frame (encrypted);
71 /* Check that plaintext and encrypted are the same */
72 BOOST_CHECK_EQUAL (plaintext_frame->stride(), encrypted_frame->stride());
73 BOOST_CHECK_EQUAL (plaintext_frame->size().width, encrypted_frame->size().width);
74 BOOST_CHECK_EQUAL (plaintext_frame->size().height, encrypted_frame->size().height);
75 BOOST_CHECK_EQUAL (memcmp (plaintext_frame->data(), encrypted_frame->data(), plaintext_frame->stride() * plaintext_frame->size().height), 0);
78 /** Load in a KDM that didn't work at first */
79 BOOST_AUTO_TEST_CASE (failing_kdm_test)
82 "test/data/target.pem.crt.de5d4eba-e683-41ca-bdda-aa4ad96af3f4.kdm.xml",
83 "test/data/private.key"