diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-07 00:39:15 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-07 00:39:15 +0100 |
| commit | 932b942a51bef4e2dd2de9f83aa5b68ad07f60f9 (patch) | |
| tree | 40f81e0b4b2e04f46bab243e9c94ff24b8bcb2ef /test | |
| parent | 4313456938d34d93239194e914b82e7a5ae14c1c (diff) | |
Working decryption via KDM.
Diffstat (limited to 'test')
| -rw-r--r-- | test/decryption_test.cc | 61 | ||||
| -rw-r--r-- | test/kdm_test.cc | 4 | ||||
| -rw-r--r-- | test/read_dcp_test.cc | 2 | ||||
| -rw-r--r-- | test/rewrite_subs.cc | 8 | ||||
| -rw-r--r-- | test/wscript | 1 |
5 files changed, 68 insertions, 8 deletions
diff --git a/test/decryption_test.cc b/test/decryption_test.cc index 6870a286..507d2efd 100644 --- a/test/decryption_test.cc +++ b/test/decryption_test.cc @@ -17,7 +17,14 @@ */ -BOOST_AUTO_TEST_CASE (is_encrypted_test) +#include <tiffio.h> +#include "kdm.h" +#include "picture_frame.h" +#include "argb_frame.h" + +using boost::dynamic_pointer_cast; + +BOOST_AUTO_TEST_CASE (decryption_test) { boost::filesystem::path plaintext_path = test_corpus; plaintext_path /= "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV"; @@ -30,4 +37,56 @@ BOOST_AUTO_TEST_CASE (is_encrypted_test) libdcp::DCP encrypted (encrypted_path.string ()); encrypted.read (); BOOST_CHECK_EQUAL (encrypted.encrypted (), true); + + libdcp::KDM kdm ( + "test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml", + "test/data/private.key" + ); + + encrypted.add_kdm (kdm); + + shared_ptr<const libdcp::Reel> encrypted_reel = encrypted.cpls().front()->reels().front (); + shared_ptr<const libdcp::PictureAsset> encrypted_picture = encrypted_reel->main_picture (); + BOOST_CHECK (encrypted_picture); + + shared_ptr<const libdcp::MonoPictureAsset> encrypted_mono_picture = dynamic_pointer_cast<const libdcp::MonoPictureAsset> (encrypted_picture); + shared_ptr<const libdcp::MonoPictureFrame> j2k_frame = encrypted_mono_picture->get_frame (0); + + shared_ptr<const libdcp::ARGBFrame> argb_frame = j2k_frame->argb_frame (); + + + + uint8_t* tiff_frame = new uint8_t[1998 * 3 * 1080]; + + uint8_t* t = tiff_frame; + uint8_t* r = argb_frame->data (); + for (int y = 0; y < 1080; ++y) { + for (int x = 0; x < 1998; ++x) { + /* Our data is first-byte blue, second-byte green, third-byte red, fourth-byte alpha, + so we need to twiddle here. + */ + + t[0] = r[2]; // red + t[1] = r[1]; // green + t[2] = r[0]; // blue + t += 3; + r += 4; + } + } + + TIFF* output = TIFFOpen ("foo.tiff", "w"); + BOOST_CHECK (output); + + TIFFSetField (output, TIFFTAG_IMAGEWIDTH, 1998); + TIFFSetField (output, TIFFTAG_IMAGELENGTH, 1080); + TIFFSetField (output, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + TIFFSetField (output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField (output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + TIFFSetField (output, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField (output, TIFFTAG_SAMPLESPERPIXEL, 3); + + BOOST_CHECK (TIFFWriteEncodedStrip (output, 0, tiff_frame, 1998 * 1080 * 3)); + TIFFClose (output); + + delete[] tiff_frame; } diff --git a/test/kdm_test.cc b/test/kdm_test.cc index 172661e3..f536e189 100644 --- a/test/kdm_test.cc +++ b/test/kdm_test.cc @@ -34,11 +34,11 @@ BOOST_AUTO_TEST_CASE (kdm_test) BOOST_CHECK_EQUAL (ciphers.front().key_id(), "4ac4f922-8239-4831-b23b-31426d0542c4"); BOOST_CHECK_EQUAL (ciphers.front().not_valid_before(), "2013-07-06T20:04:58+00:00"); BOOST_CHECK_EQUAL (ciphers.front().not_valid_after(), "2023-07-02T20:04:56+00:00"); - BOOST_CHECK_EQUAL (ciphers.front().key_data(), "8a2729c3e5b65c45d78305462104c3fb"); + BOOST_CHECK_EQUAL (ciphers.front().key_string(), "8a2729c3e5b65c45d78305462104c3fb"); BOOST_CHECK_EQUAL (ciphers.back().cpl_id(), "eece17de-77e8-4a55-9347-b6bab5724b9f"); BOOST_CHECK_EQUAL (ciphers.back().key_id(), "73baf5de-e195-4542-ab28-8a465f7d4079"); BOOST_CHECK_EQUAL (ciphers.back().not_valid_before(), "2013-07-06T20:04:58+00:00"); BOOST_CHECK_EQUAL (ciphers.back().not_valid_after(), "2023-07-02T20:04:56+00:00"); - BOOST_CHECK_EQUAL (ciphers.back().key_data(), "5327fb7ec2e807bd57059615bf8a169d"); + BOOST_CHECK_EQUAL (ciphers.back().key_string(), "5327fb7ec2e807bd57059615bf8a169d"); } diff --git a/test/read_dcp_test.cc b/test/read_dcp_test.cc index 026073a3..5e6827d1 100644 --- a/test/read_dcp_test.cc +++ b/test/read_dcp_test.cc @@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE (read_dcp) libdcp::DCP d ("test/ref/DCP/foo"); d.read (); - list<shared_ptr<const libdcp::CPL> > cpls = d.cpls (); + list<shared_ptr<libdcp::CPL> > cpls = d.cpls (); BOOST_CHECK_EQUAL (cpls.size(), 1); BOOST_CHECK_EQUAL (cpls.front()->name(), "A Test DCP"); diff --git a/test/rewrite_subs.cc b/test/rewrite_subs.cc index 8c055d9e..c7f8bfbd 100644 --- a/test/rewrite_subs.cc +++ b/test/rewrite_subs.cc @@ -23,11 +23,11 @@ try DCP* dcp = new DCP (argv[1]); dcp->read (false); - list<shared_ptr<const CPL> > cpls = dcp->cpls (); - for (list<boost::shared_ptr<const CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) { + list<shared_ptr<CPL> > cpls = dcp->cpls (); + for (list<boost::shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) { - list<shared_ptr<const Reel> > reels = (*i)->reels (); - for (list<shared_ptr<const Reel> >::iterator j = reels.begin(); j != reels.end(); ++j) { + list<shared_ptr<Reel> > reels = (*i)->reels (); + for (list<shared_ptr<Reel> >::iterator j = reels.begin(); j != reels.end(); ++j) { if ((*j)->main_subtitle()) { (*j)->main_subtitle()->write_xml (); diff --git a/test/wscript b/test/wscript index 2892bf9e..f957b106 100644 --- a/test/wscript +++ b/test/wscript @@ -14,6 +14,7 @@ def configure(conf): uselib_store = 'BOOST_TEST') conf.env.prepend_value('LINKFLAGS', '-Lsrc') + conf.env.append_value('LIB', 'tiff') def build(bld): obj = bld(features = 'cxx cxxprogram') |
