From: Carl Hetherington Date: Thu, 27 Oct 2016 20:00:41 +0000 (+0100) Subject: Use the same ContextID whenever encrypting the picture asset for a project; X-Git-Tag: v2.9.39~29 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=83efe84020dc0ba2801c4b305448790720fe133f;p=dcpomatic.git Use the same ContextID whenever encrypting the picture asset for a project; this ensures that resumption of encodes works. Before this, a random ContextID would be created for each run (#980). --- diff --git a/ChangeLog b/ChangeLog index 60e90800e..f2057c48d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-10-31 c.hetherington + + * Fix failure to resume encodes when using encryption (#980). + 2016-10-29 Carl Hetherington * Updated de_DE translation from Carsten Kurz. diff --git a/cscript b/cscript index 3020ba6fe..e8bcf0091 100644 --- a/cscript +++ b/cscript @@ -233,7 +233,7 @@ def dependencies(target): ffmpeg_options = {} return (('ffmpeg-cdist', '1d4a1a4', ffmpeg_options), - ('libdcp', '079d5ca'), + ('libdcp', 'd23e6e1'), ('libsub', 'ef7c2ec')) def configure_options(target): diff --git a/src/lib/film.cc b/src/lib/film.cc index 1a1957d33..d331516dd 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -132,6 +132,7 @@ Film::Film (optional dir) , _resolution (RESOLUTION_2K) , _signed (true) , _encrypted (false) + , _context_id (dcp::make_uuid ()) , _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ()) , _isdcf_metadata (Config::instance()->default_isdcf_metadata ()) , _video_frame_rate (24) @@ -361,6 +362,7 @@ Film::metadata (bool with_content_paths) const root->add_child("Signed")->add_child_text (_signed ? "1" : "0"); root->add_child("Encrypted")->add_child_text (_encrypted ? "1" : "0"); root->add_child("Key")->add_child_text (_key.hex ()); + root->add_child("ContextID")->add_child_text (_context_id); if (_audio_processor) { root->add_child("AudioProcessor")->add_child_text (_audio_processor->id ()); } @@ -463,6 +465,7 @@ Film::read_metadata (optional path) _three_d = f.bool_child ("ThreeD"); _interop = f.bool_child ("Interop"); _key = dcp::Key (f.string_child ("Key")); + _context_id = f.optional_string_child("ContextID").get_value_or (dcp::make_uuid ()); if (f.optional_string_child ("AudioProcessor")) { _audio_processor = AudioProcessor::from_id (f.string_child ("AudioProcessor")); diff --git a/src/lib/film.h b/src/lib/film.h index ad94852a2..2b700b007 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -284,6 +284,11 @@ public: return _upload_after_make_dcp; } + std::string context_id () const { + return _context_id; + } + + /* SET */ void set_directory (boost::filesystem::path); @@ -357,6 +362,10 @@ private: bool _signed; bool _encrypted; dcp::Key _key; + /** context ID used when encrypting picture assets; we keep it so that we can + * re-start picture MXF encodes. + */ + std::string _context_id; /** bandwidth for J2K files in bits per second */ int _j2k_bandwidth; /** ISDCF naming stuff */ diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 398c9c66d..bf232579f 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -88,6 +88,7 @@ ReelWriter::ReelWriter ( if (_film->encrypted ()) { _picture_asset->set_key (_film->key ()); + _picture_asset->set_context_id (_film->context_id ()); } _picture_asset->set_file ( diff --git a/test/recover_test.cc b/test/recover_test.cc index dfd3f790f..a16e19639 100644 --- a/test/recover_test.cc +++ b/test/recover_test.cc @@ -78,25 +78,27 @@ BOOST_AUTO_TEST_CASE (recover_test_2d) BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2))); } -BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted) +BOOST_AUTO_TEST_CASE (recover_test_3d) { - shared_ptr film = new_test_film ("recover_test_2d_encrypted"); + shared_ptr film = new_test_film ("recover_test_3d"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); film->set_container (Ratio::from_id ("185")); film->set_name ("recover_test"); - film->set_encrypted (true); + film->set_three_d (true); - shared_ptr content (new FFmpegContent (film, "test/data/count300bd24.m2ts")); + shared_ptr content (new ImageContent (film, "test/data/3d_test")); + content->video->set_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT); film->examine_and_add_content (content); wait_for_jobs (); film->make_dcp (); wait_for_jobs (); - boost::filesystem::path const video = "build/test/recover_test_2d_encrypted/video/185_2K_9284c41c42044ef9b4c14482730cdffe_24_100000000_P_S_0_1200000.mxf"; + boost::filesystem::path const video = "build/test/recover_test_3d/video/185_2K_961f053444e90c5ddbf978eb0ebfa772_24_100000000_P_S_3D_0_96000.mxf"; + boost::filesystem::copy_file ( video, - "build/test/recover_test_2d_encrypted/original.mxf" + "build/test/recover_test_3d/original.mxf" ); boost::filesystem::resize_file (video, 2 * 1024 * 1024); @@ -104,34 +106,35 @@ BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted) film->make_dcp (); wait_for_jobs (); - shared_ptr A (new dcp::MonoPictureAsset ("build/test/recover_test_2d_encrypted/original.mxf")); - shared_ptr B (new dcp::MonoPictureAsset (video)); + shared_ptr A (new dcp::StereoPictureAsset ("build/test/recover_test_3d/original.mxf")); + shared_ptr B (new dcp::StereoPictureAsset (video)); dcp::EqualityOptions eq; BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2))); } -BOOST_AUTO_TEST_CASE (recover_test_3d) + +BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted) { - shared_ptr film = new_test_film ("recover_test_3d"); + shared_ptr film = new_test_film ("recover_test_2d_encrypted"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); film->set_container (Ratio::from_id ("185")); film->set_name ("recover_test"); - film->set_three_d (true); + film->set_encrypted (true); - shared_ptr content (new ImageContent (film, "test/data/3d_test")); - content->video->set_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT); + shared_ptr content (new FFmpegContent (film, "test/data/count300bd24.m2ts")); film->examine_and_add_content (content); wait_for_jobs (); film->make_dcp (); wait_for_jobs (); - boost::filesystem::path const video = "build/test/recover_test_3d/video/185_2K_961f053444e90c5ddbf978eb0ebfa772_24_100000000_P_S_3D_0_96000.mxf"; + boost::filesystem::path const video = + "build/test/recover_test_2d_encrypted/video/185_2K_517799e697fdd13033f9f7e836e7dc43_24_100000000_E_S_0_1200000.mxf"; boost::filesystem::copy_file ( video, - "build/test/recover_test_3d/original.mxf" + "build/test/recover_test_2d_encrypted/original.mxf" ); boost::filesystem::resize_file (video, 2 * 1024 * 1024); @@ -139,8 +142,10 @@ BOOST_AUTO_TEST_CASE (recover_test_3d) film->make_dcp (); wait_for_jobs (); - shared_ptr A (new dcp::StereoPictureAsset ("build/test/recover_test_3d/original.mxf")); - shared_ptr B (new dcp::StereoPictureAsset (video)); + shared_ptr A (new dcp::MonoPictureAsset ("build/test/recover_test_2d_encrypted/original.mxf")); + A->set_key (film->key ()); + shared_ptr B (new dcp::MonoPictureAsset (video)); + B->set_key (film->key ()); dcp::EqualityOptions eq; BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2)));