#include <boost/scoped_array.hpp>
+#ifndef M_PI
+#define M_PI (3.14159265358979323846)
+#endif
+
+
using std::dynamic_pointer_cast;
using std::make_pair;
-using std::make_shared;
using std::map;
using std::pair;
using std::shared_ptr;
using std::string;
+using std::vector;
using boost::optional;
using boost::scoped_array;
-pair<uint8_t*, dcp::Size>
+pair<vector<uint8_t>, dcp::Size>
get_frame (dcp::DCP const & dcp)
{
- shared_ptr<const dcp::Reel> reel = dcp.cpls().front()->reels().front ();
- shared_ptr<dcp::PictureAsset> picture = reel->main_picture()->asset ();
+ auto reel = dcp.cpls().front()->reels()[0];
+ auto picture = reel->main_picture()->asset();
BOOST_CHECK (picture);
- shared_ptr<const dcp::MonoPictureAsset> mono_picture = dynamic_pointer_cast<const dcp::MonoPictureAsset> (picture);
- shared_ptr<const dcp::MonoPictureAssetReader> reader = mono_picture->start_read ();
- shared_ptr<const dcp::MonoPictureFrame> j2k_frame = reader->get_frame (0);
- shared_ptr<dcp::OpenJPEGImage> xyz = j2k_frame->xyz_image();
+ auto mono_picture = dynamic_pointer_cast<const dcp::MonoPictureAsset>(picture);
+ auto reader = mono_picture->start_read();
+ auto j2k_frame = reader->get_frame(0);
+ auto xyz = j2k_frame->xyz_image();
- uint8_t* argb = new uint8_t[xyz->size().width * xyz->size().height * 4];
- dcp::xyz_to_rgba (j2k_frame->xyz_image(), dcp::ColourConversion::srgb_to_xyz(), argb, xyz->size().width * 4);
+ std::vector<uint8_t> argb(xyz->size().width * xyz->size().height * 4);
+ dcp::xyz_to_rgba(j2k_frame->xyz_image(), dcp::ColourConversion::srgb_to_xyz(), argb.data(), xyz->size().width * 4);
return make_pair (argb, xyz->size ());
}
/** Decrypt an encrypted test DCP and check that its first frame is the same as the unencrypted version */
BOOST_AUTO_TEST_CASE (decryption_test1)
{
- boost::filesystem::path plaintext_path = private_test;
+ auto plaintext_path = private_test;
plaintext_path /= "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV";
dcp::DCP plaintext (plaintext_path.string ());
plaintext.read ();
BOOST_CHECK_EQUAL (plaintext.any_encrypted(), false);
- boost::filesystem::path encrypted_path = private_test;
+ auto encrypted_path = private_test;
encrypted_path /= "TONEPLATES-SMPTE-ENCRYPTED_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV";
dcp::DCP encrypted (encrypted_path.string ());
encrypted.read ();
encrypted.add (kdm);
- pair<uint8_t *, dcp::Size> plaintext_frame = get_frame (plaintext);
- pair<uint8_t *, dcp::Size> encrypted_frame = get_frame (encrypted);
+ auto plaintext_frame = get_frame(plaintext);
+ auto encrypted_frame = get_frame(encrypted);
/* Check that plaintext and encrypted are the same */
BOOST_CHECK_EQUAL (
memcmp (
- plaintext_frame.first,
- encrypted_frame.first,
+ plaintext_frame.first.data(),
+ encrypted_frame.first.data(),
plaintext_frame.second.width * plaintext_frame.second.height * 4
),
0
);
-
- delete[] plaintext_frame.first;
- delete[] encrypted_frame.first;
}
/** Load in a KDM that didn't work at first */
{
dcp::DecryptedKDM kdm (
dcp::EncryptedKDM (dcp::file_to_string ("test/data/target.pem.crt.de5d4eba-e683-41ca-bdda-aa4ad96af3f4.kdm.xml")),
- dcp::file_to_string ("test/data/private.key")
+ dcp::file_to_string("test/data/failing-private.key")
);
}
auto context_id = dcp::make_uuid();
dcp::Key key;
- auto picture_asset = make_shared<dcp::MonoPictureAsset>(dcp::Fraction(24, 1), dcp::Standard::SMPTE);
+ auto picture_asset = std::make_shared<dcp::MonoPictureAsset>(dcp::Fraction(24, 1), dcp::Standard::SMPTE);
picture_asset->set_key (key);
picture_asset->set_context_id (context_id);
auto picture_writer = picture_asset->start_write(dir / "picture.mxf", false);
}
picture_writer->finalize();
- auto sound_asset = make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 2, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE);
+ auto sound_asset = std::make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 2, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE);
sound_asset->set_key (key);
sound_asset->set_context_id (context_id);
auto sound_writer = sound_asset->start_write(dir / "sound.mxf");
sound_writer->write (audio.data(), 48000);
sound_writer->finalize ();
- auto subs_asset = make_shared<dcp::SMPTESubtitleAsset>();
+ auto subs_asset = std::make_shared<dcp::SMPTESubtitleAsset>();
subs_asset->set_key (key);
subs_asset->set_context_id (context_id);
- subs_asset->add(make_shared<dcp::SubtitleString>(
+ subs_asset->add(std::make_shared<dcp::SubtitleString>(
optional<string>(),
false, false, false,
dcp::Colour(255, 255, 255),
dcp::Time(0, 0, 5, 0, 24),
0.5, dcp::HAlign::CENTER,
0.5, dcp::VAlign::CENTER,
+ 0,
dcp::Direction::LTR,
"Hello world",
dcp::Effect::NONE,
));
subs_asset->write (dir / "subs.mxf");
- auto reel = make_shared<dcp::Reel>();
- auto reel_picture_asset = make_shared<dcp::ReelMonoPictureAsset>(picture_asset, 0);
- auto reel_sound_asset = make_shared<dcp::ReelSoundAsset>(sound_asset, 0);
- auto reel_subs_asset = make_shared<dcp::ReelSMPTESubtitleAsset>(subs_asset, dcp::Fraction(24, 1), 120, 0);
+ auto reel = std::make_shared<dcp::Reel>();
+ auto reel_picture_asset = std::make_shared<dcp::ReelMonoPictureAsset>(picture_asset, 0);
+ auto reel_sound_asset = std::make_shared<dcp::ReelSoundAsset>(sound_asset, 0);
+ auto reel_subs_asset = std::make_shared<dcp::ReelSMPTESubtitleAsset>(subs_asset, dcp::Fraction(24, 1), 120, 0);
reel->add(reel_picture_asset);
reel->add(reel_sound_asset);
reel->add(reel_subs_asset);