Changes to libdcp.
[dcpomatic.git] / src / lib / film.cc
index 75dfa45eba397e3cddc0c07e712cfdb6f43a41b7..548c51796f4c10352a8a17aed9c4fa5da8b5206b 100644 (file)
@@ -27,7 +27,7 @@
 #include "util.h"
 #include "job_manager.h"
 #include "transcode_job.h"
-#include "scp_dcp_job.h"
+#include "upload_job.h"
 #include "log.h"
 #include "exceptions.h"
 #include "examine_content_job.h"
@@ -45,7 +45,7 @@
 #include "md5_digester.h"
 #include <libcxml/cxml.h>
 #include <dcp/cpl.h>
-#include <dcp/signer.h>
+#include <dcp/certificate_chain.h>
 #include <dcp/util.h>
 #include <dcp/local_time.h>
 #include <dcp/decrypted_kdm.h>
@@ -87,7 +87,7 @@ using boost::starts_with;
 using boost::optional;
 using boost::is_any_of;
 using dcp::Size;
-using dcp::Signer;
+using dcp::CertificateChain;
 
 #define LOG_GENERAL(...) log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
 #define LOG_GENERAL_NC(...) log()->log (__VA_ARGS__, Log::TYPE_GENERAL);
@@ -128,7 +128,6 @@ Film::Film (boost::filesystem::path dir, bool log)
        , _three_d (false)
        , _sequence_video (true)
        , _interop (false)
-       , _burn_subtitles (false)
        , _audio_processor (0)
        , _state_version (current_state_version)
        , _dirty (false)
@@ -199,10 +198,6 @@ Film::video_identifier () const
                s << "_S";
        }
 
-       if (_burn_subtitles) {
-               s << "_B";
-       }
-
        if (_three_d) {
                s << "_3D";
        }
@@ -232,29 +227,13 @@ Film::internal_video_asset_filename () const
        return video_identifier() + ".mxf";
 }
 
-string
-Film::filename_safe_name () const
-{
-       string const n = name ();
-       string o;
-       for (size_t i = 0; i < n.length(); ++i) {
-               if (isalnum (n[i])) {
-                       o += n[i];
-               } else {
-                       o += "_";
-               }
-       }
-
-       return o;
-}
-
 boost::filesystem::path
-Film::audio_analysis_path () const
+Film::audio_analysis_path (shared_ptr<const Playlist> playlist) const
 {
        boost::filesystem::path p = dir ("analysis");
 
        MD5Digester digester;
-       BOOST_FOREACH (shared_ptr<Content> i, content ()) {
+       BOOST_FOREACH (shared_ptr<Content> i, playlist->content ()) {
                shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (i);
                if (!ac) {
                        continue;
@@ -262,7 +241,15 @@ Film::audio_analysis_path () const
 
                digester.add (ac->digest ());
                digester.add (ac->audio_mapping().digest ());
-               digester.add (ac->audio_gain ());
+               if (playlist->content().size() != 1) {
+                       /* Analyses should be considered equal regardless of gain
+                          if they were made from just one piece of content.  This
+                          is because we can fake any gain change in a single-content
+                          analysis at the plotting stage rather than having to
+                          recompute it.
+                       */
+                       digester.add (ac->audio_gain ());
+               }
        }
 
        if (audio_processor ()) {
@@ -281,25 +268,12 @@ Film::make_dcp ()
                throw BadSettingError (_("name"), _("cannot contain slashes"));
        }
 
-       bool must_burn = false;
-       ContentList cl = content ();
-       BOOST_FOREACH (shared_ptr<Content> c, cl) {
-               shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c);
-               if (sc && sc->has_image_subtitles() && sc->use_subtitles() && !burn_subtitles()) {
-                       must_burn = true;
-               }
-       }
-
-       if (must_burn) {
-               throw EncodeError (_("this project has content with image-based subtitles, which this version of DCP-o-matic cannot include as separate DCP subtitles.  To use subtitles with this project you must burn them into the image (tick the box on the DCP Video tab)."));
-       }
-
        set_isdcf_date_today ();
 
        environment_info (log ());
 
-       for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) {
-               LOG_GENERAL ("Content: %1", (*i)->technical_summary());
+       BOOST_FOREACH (shared_ptr<const Content> i, content ()) {
+               LOG_GENERAL ("Content: %1", i->technical_summary());
        }
        LOG_GENERAL ("DCP video rate %1 fps", video_frame_rate());
        LOG_GENERAL ("%1 threads", Config::instance()->num_local_encoding_threads());
@@ -328,7 +302,7 @@ Film::make_dcp ()
 void
 Film::send_dcp_to_tms ()
 {
-       shared_ptr<Job> j (new SCPDCPJob (shared_from_this()));
+       shared_ptr<Job> j (new UploadJob (shared_from_this()));
        JobManager::instance()->add (j);
 }
 
@@ -359,7 +333,6 @@ Film::metadata () const
        root->add_child("ThreeD")->add_child_text (_three_d ? "1" : "0");
        root->add_child("SequenceVideo")->add_child_text (_sequence_video ? "1" : "0");
        root->add_child("Interop")->add_child_text (_interop ? "1" : "0");
-       root->add_child("BurnSubtitles")->add_child_text (_burn_subtitles ? "1" : "0");
        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 ());
@@ -441,9 +414,6 @@ Film::read_metadata ()
        _sequence_video = f.bool_child ("SequenceVideo");
        _three_d = f.bool_child ("ThreeD");
        _interop = f.bool_child ("Interop");
-       if (_state_version >= 32) {
-               _burn_subtitles = f.bool_child ("BurnSubtitles");
-       }
        _key = dcp::Key (f.string_child ("Key"));
 
        if (f.optional_string_child ("AudioProcessor")) {
@@ -621,7 +591,9 @@ Film::isdcf_name (bool if_created_now) const
 
        if (!dm.territory.empty ()) {
                d << "_" << dm.territory;
-               if (!dm.rating.empty ()) {
+               if (dm.rating.empty ()) {
+                       d << "-NR";
+               } else {
                        d << "-" << dm.rating;
                }
        }
@@ -818,13 +790,6 @@ Film::set_interop (bool i)
        signal_changed (INTEROP);
 }
 
-void
-Film::set_burn_subtitles (bool b)
-{
-       _burn_subtitles = b;
-       signal_changed (BURN_SUBTITLES);
-}
-
 void
 Film::set_audio_processor (AudioProcessor const * processor)
 {
@@ -1033,6 +998,8 @@ Film::active_frame_rate_change (DCPTime t) const
 void
 Film::playlist_content_changed (boost::weak_ptr<Content> c, int p, bool frequent)
 {
+       _dirty = true;
+
        if (p == VideoContentProperty::VIDEO_FRAME_RATE) {
                set_video_frame_rate (_playlist->best_dcp_frame_rate ());
        } else if (p == AudioContentProperty::AUDIO_STREAMS) {
@@ -1096,7 +1063,7 @@ Film::make_kdm (
        ) const
 {
        shared_ptr<const dcp::CPL> cpl (new dcp::CPL (cpl_file));
-       shared_ptr<const dcp::Signer> signer = Config::instance()->signer();
+       shared_ptr<const dcp::CertificateChain> signer = Config::instance()->signer();
        if (!signer->valid ()) {
                throw InvalidSignerError ();
        }