Merge branch 'master' into speed-up
[dcpomatic.git] / src / lib / film.cc
index 3f92100802ade784a839bef4a790a939fa547a2b..e2a4cbeda60efda1089f2b8e840c6a64940f5702 100644 (file)
@@ -86,6 +86,7 @@ int const Film::state_version = 1;
 
 Film::Film (string d, bool must_exist)
        : _use_dci_name (true)
+       , _trust_content_header (true)
        , _dcp_content_type (0)
        , _format (0)
        , _scaler (Scaler::from_id ("bicubic"))
@@ -144,6 +145,7 @@ Film::Film (Film const & o)
        , _name              (o._name)
        , _use_dci_name      (o._use_dci_name)
        , _content           (o._content)
+       , _trust_content_header (o._trust_content_header)
        , _dcp_content_type  (o._dcp_content_type)
        , _format            (o._format)
        , _crop              (o._crop)
@@ -404,6 +406,7 @@ Film::write_metadata () const
        f << "name " << _name << "\n";
        f << "use_dci_name " << _use_dci_name << "\n";
        f << "content " << _content << "\n";
+       f << "trust_content_header " << (_trust_content_header ? "1" : "0") << "\n";
        if (_dcp_content_type) {
                f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
        }
@@ -513,6 +516,8 @@ Film::read_metadata ()
                        _use_dci_name = (v == "1");
                } else if (k == "content") {
                        _content = v;
+               } else if (k == "trust_content_header") {
+                       _trust_content_header = (v == "1");
                } else if (k == "dcp_content_type") {
                        _dcp_content_type = DCPContentType::from_pretty_name (v);
                } else if (k == "format") {
@@ -976,7 +981,7 @@ Film::set_content (string c)
                signal_changed (CONTENT);
                
                set_content_digest (md5_digest (content_path ()));
-               
+
                examine_content ();
 
        } catch (...) {
@@ -987,6 +992,22 @@ Film::set_content (string c)
 
        }
 }
+
+void
+Film::set_trust_content_header (bool t)
+{
+       {
+               boost::mutex::scoped_lock lm (_state_mutex);
+               _trust_content_header = t;
+       }
+       
+       signal_changed (TRUST_CONTENT_HEADER);
+
+       if (!_trust_content_header) && !content().empty()) {
+               /* We just said that we don't trust the content's header */
+               examine_content ();
+       }
+}
               
 void
 Film::set_dcp_content_type (DCPContentType const * t)