Take Film pointer out of Content.
[dcpomatic.git] / src / lib / film.cc
index 807aeaf2fe3d59d9ac0f7d6a8791436d5efb16a4..4d6b3d7e3b4fa132bf54b9e75fa568246f1e3615 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,6 +399,7 @@ 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;
@@ -512,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) */
@@ -943,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)
 {
@@ -965,7 +975,7 @@ Film::signal_change (ChangeType type, Property p)
                        /* 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()));
+                       emit (boost::bind(&Playlist::maybe_sequence, _playlist.get(), shared_from_this()));
                }
        } else {
                Change (type, p);
@@ -1106,7 +1116,7 @@ Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c, bool disable_audi
 
        if (Config::instance()->automatic_audio_analysis() && content->audio && !disable_audio_analysis) {
                shared_ptr<Playlist> playlist (new Playlist);
-               playlist->add (content);
+               playlist->add (shared_from_this(), content);
                boost::signals2::connection c;
                JobManager::instance()->analyse_audio (
                        shared_from_this(), playlist, false, c, bind (&Film::audio_analysis_finished, this)
@@ -1120,9 +1130,9 @@ Film::add_content (shared_ptr<Content> c)
 {
        /* Add {video,subtitle} content after any existing {video,subtitle} content */
        if (c->video) {
-               c->set_position (_playlist->video_end());
+               c->set_position (shared_from_this(), _playlist->video_end(shared_from_this()));
        } else if (!c->text.empty()) {
-               c->set_position (_playlist->text_end());
+               c->set_position (shared_from_this(), _playlist->text_end(shared_from_this()));
        }
 
        if (_template_film) {
@@ -1132,7 +1142,7 @@ Film::add_content (shared_ptr<Content> c)
                }
        }
 
-       _playlist->add (c);
+       _playlist->add (shared_from_this(), c);
 }
 
 void
@@ -1144,20 +1154,20 @@ Film::remove_content (shared_ptr<Content> c)
 void
 Film::move_content_earlier (shared_ptr<Content> c)
 {
-       _playlist->move_earlier (c);
+       _playlist->move_earlier (shared_from_this(), c);
 }
 
 void
 Film::move_content_later (shared_ptr<Content> c)
 {
-       _playlist->move_later (c);
+       _playlist->move_later (shared_from_this(), c);
 }
 
 /** @return length of the film from time 0 to the last thing on the playlist */
 DCPTime
 Film::length () const
 {
-       return _playlist->length().ceil(video_frame_rate());
+       return _playlist->length(shared_from_this()).ceil(video_frame_rate());
 }
 
 int
@@ -1249,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.
@@ -1261,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,
@@ -1347,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()),
@@ -1369,7 +1379,7 @@ Film::make_kdms (
 uint64_t
 Film::required_disk_space () const
 {
-       return _playlist->required_disk_space (j2k_bandwidth(), audio_channels(), audio_frame_rate());
+       return _playlist->required_disk_space (shared_from_this(), j2k_bandwidth(), audio_channels(), audio_frame_rate());
 }
 
 /** This method checks the disk that the Film is on and tries to decide whether or not
@@ -1503,7 +1513,7 @@ Film::audio_output_names () const
 void
 Film::repeat_content (ContentList c, int n)
 {
-       _playlist->repeat (c, n);
+       _playlist->repeat (shared_from_this(), c, n);
 }
 
 void
@@ -1544,7 +1554,7 @@ Film::reels () const
                        }
                }
 
-               DCPTime video_end = last_video ? last_video->end() : DCPTime(0);
+               DCPTime video_end = last_video ? last_video->end(shared_from_this()) : DCPTime(0);
                if (last_split) {
                        /* Definitely go from the last split to the end of the video content */
                        p.push_back (DCPTimePeriod (last_split.get(), video_end));
@@ -1579,7 +1589,7 @@ Film::reels () const
 string
 Film::content_summary (DCPTimePeriod period) const
 {
-       return _playlist->content_summary (period);
+       return _playlist->content_summary (shared_from_this(), period);
 }
 
 void