Allow specification of trusted devices by thumbprint rather than
[dcpomatic.git] / src / lib / film.cc
index 93e7aa1c05c4322368ee87299b4289a8102d02df..426c7f81ddeb30bb0b90b4a26db8e6edacf8c5d6 100644 (file)
@@ -157,6 +157,7 @@ Film::Film (optional<boost::filesystem::path> dir)
        , _reel_type (REELTYPE_SINGLE)
        , _reel_length (2000000000)
        , _upload_after_make_dcp (Config::instance()->default_upload_after_make_dcp())
+       , _reencode_j2k (false)
        , _state_version (current_state_version)
        , _dirty (false)
 {
@@ -398,11 +399,19 @@ Film::metadata (bool with_content_paths) const
        root->add_child("ReelType")->add_child_text (raw_convert<string> (static_cast<int> (_reel_type)));
        root->add_child("ReelLength")->add_child_text (raw_convert<string> (_reel_length));
        root->add_child("UploadAfterMakeDCP")->add_child_text (_upload_after_make_dcp ? "1" : "0");
+       root->add_child("ReencodeJ2K")->add_child_text (_reencode_j2k ? "1" : "0");
        _playlist->as_xml (root->add_child ("Playlist"), with_content_paths);
 
        return doc;
 }
 
+void
+Film::write_metadata (boost::filesystem::path path) const
+{
+       shared_ptr<xmlpp::Document> doc = metadata ();
+       doc->write_to_file_formatted (path.string());
+}
+
 /** Write state to our `metadata' file */
 void
 Film::write_metadata () const
@@ -505,6 +514,7 @@ Film::read_metadata (optional<boost::filesystem::path> path)
        _reel_type = static_cast<ReelType> (f.optional_number_child<int>("ReelType").get_value_or (static_cast<int>(REELTYPE_SINGLE)));
        _reel_length = f.optional_number_child<int64_t>("ReelLength").get_value_or (2000000000);
        _upload_after_make_dcp = f.optional_bool_child("UploadAfterMakeDCP").get_value_or (false);
+       _reencode_j2k = f.optional_bool_child("ReencodeJ2K").get_value_or(false);
 
        list<string> notes;
        /* This method is the only one that can return notes (so far) */
@@ -936,6 +946,13 @@ Film::set_upload_after_make_dcp (bool u)
        _upload_after_make_dcp = u;
 }
 
+void
+Film::set_reencode_j2k (bool r)
+{
+       ChangeSignaller<Film> ch (this, REENCODE_J2K);
+       _reencode_j2k = r;
+}
+
 void
 Film::signal_change (ChangeType type, int p)
 {
@@ -948,19 +965,18 @@ Film::signal_change (ChangeType type, Property p)
        if (type == CHANGE_TYPE_DONE) {
                _dirty = true;
 
-               switch (p) {
-               case Film::CONTENT:
+               if (p == Film::CONTENT) {
                        set_video_frame_rate (_playlist->best_video_frame_rate ());
-                       break;
-               case Film::VIDEO_FRAME_RATE:
-               case Film::SEQUENCE:
-                       _playlist->maybe_sequence ();
-                       break;
-               default:
-                       break;
                }
 
                emit (boost::bind (boost::ref (Change), type, p));
+
+               if (p == Film::VIDEO_FRAME_RATE || p == Film::SEQUENCE) {
+                       /* We want to call Playlist::maybe_sequence but this must happen after the
+                          main signal emission (since the butler will see that emission and un-suspend itself).
+                       */
+                       emit (boost::bind(&Playlist::maybe_sequence, _playlist.get()));
+               }
        } else {
                Change (type, p);
        }
@@ -1243,7 +1259,7 @@ Film::frame_size () const
 }
 
 /** @param recipient KDM recipient certificate.
- *  @param trusted_devices Certificates of other trusted devices (can be empty).
+ *  @param trusted_devices Certificate thumbprints of other trusted devices (can be empty).
  *  @param cpl_file CPL filename.
  *  @param from KDM from time expressed as a local time with an offset from UTC.
  *  @param until KDM to time expressed as a local time with an offset from UTC.
@@ -1255,7 +1271,7 @@ Film::frame_size () const
 dcp::EncryptedKDM
 Film::make_kdm (
        dcp::Certificate recipient,
-       vector<dcp::Certificate> trusted_devices,
+       vector<string> trusted_devices,
        boost::filesystem::path cpl_file,
        dcp::LocalTime from,
        dcp::LocalTime until,
@@ -1341,7 +1357,7 @@ Film::make_kdms (
                if (i->recipient) {
                        dcp::EncryptedKDM const kdm = make_kdm (
                                i->recipient.get(),
-                               i->trusted_devices,
+                               i->trusted_device_thumbprints(),
                                cpl_file,
                                dcp::LocalTime (from, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),
                                dcp::LocalTime (until, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),