Use the same ContextID whenever encrypting the picture asset for a project;
authorCarl Hetherington <cth@carlh.net>
Thu, 27 Oct 2016 20:00:41 +0000 (21:00 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 31 Oct 2016 11:34:16 +0000 (11:34 +0000)
this ensures that resumption of encodes works.  Before this, a random ContextID
would be created for each run (#980).

ChangeLog
cscript
src/lib/film.cc
src/lib/film.h
src/lib/reel_writer.cc
test/recover_test.cc

index 60e90800e3e70e5a3c6c2d64eb0460934ed4b874..f2057c48d6110541b83abe708010f9f4b3b6fad5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-10-31  c.hetherington  <cth@carlh.net>
+
+       * Fix failure to resume encodes when using encryption (#980).
+
 2016-10-29  Carl Hetherington  <cth@carlh.net>
 
        * Updated de_DE translation from Carsten Kurz.
diff --git a/cscript b/cscript
index 3020ba6fef9e58d099b5869936b9740e4de522cc..e8bcf00915c3101fb507c91a588783f90cdb5c8f 100644 (file)
--- 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):
index 1a1957d33a4ae97c76038398952e4d84d3480060..d331516dd1e9cac9c7b9b979975a1d4578927266 100644 (file)
@@ -132,6 +132,7 @@ Film::Film (optional<boost::filesystem::path> 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<boost::filesystem::path> 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"));
index ad94852a2486e9757a888d205a70a33ee7e9f735..2b700b00752834cc48e803d61404932a8f7e9783 100644 (file)
@@ -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 */
index 398c9c66d21d41def29be74c1e69abef43de05f4..bf232579f1c2b960b92edfde9996e27a7d883374 100644 (file)
@@ -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 (
index dfd3f790f512d3fbaef9accd78ecbf5ad3afbdb9..a16e19639aade6b1624d8d28e0ef65dc12f67890 100644 (file)
@@ -78,25 +78,27 @@ BOOST_AUTO_TEST_CASE (recover_test_2d)
        BOOST_CHECK (A->equals (B, eq, boost::bind (&note, _1, _2)));
 }
 
-BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted)
+BOOST_AUTO_TEST_CASE (recover_test_3d)
 {
-       shared_ptr<Film> film = new_test_film ("recover_test_2d_encrypted");
+       shared_ptr<Film> 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<FFmpegContent> content (new FFmpegContent (film, "test/data/count300bd24.m2ts"));
+       shared_ptr<ImageContent> 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<dcp::MonoPictureAsset> A (new dcp::MonoPictureAsset ("build/test/recover_test_2d_encrypted/original.mxf"));
-       shared_ptr<dcp::MonoPictureAsset> B (new dcp::MonoPictureAsset (video));
+       shared_ptr<dcp::StereoPictureAsset> A (new dcp::StereoPictureAsset ("build/test/recover_test_3d/original.mxf"));
+       shared_ptr<dcp::StereoPictureAsset> B (new dcp::StereoPictureAsset (video));
 
        dcp::EqualityOptions eq;
        BOOST_CHECK (A->equals (B, eq, boost::bind (&note, _1, _2)));
 }
 
-BOOST_AUTO_TEST_CASE (recover_test_3d)
+
+BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted)
 {
-       shared_ptr<Film> film = new_test_film ("recover_test_3d");
+       shared_ptr<Film> 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<ImageContent> content (new ImageContent (film, "test/data/3d_test"));
-       content->video->set_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT);
+       shared_ptr<FFmpegContent> 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<dcp::StereoPictureAsset> A (new dcp::StereoPictureAsset ("build/test/recover_test_3d/original.mxf"));
-       shared_ptr<dcp::StereoPictureAsset> B (new dcp::StereoPictureAsset (video));
+       shared_ptr<dcp::MonoPictureAsset> A (new dcp::MonoPictureAsset ("build/test/recover_test_2d_encrypted/original.mxf"));
+       A->set_key (film->key ());
+       shared_ptr<dcp::MonoPictureAsset> B (new dcp::MonoPictureAsset (video));
+       B->set_key (film->key ());
 
        dcp::EqualityOptions eq;
        BOOST_CHECK (A->equals (B, eq, boost::bind (&note, _1, _2)));