Possibly fix legacy dcp_trim_start tags; use DCI name for content type to be a little...
authorCarl Hetherington <cth@carlh.net>
Thu, 7 Feb 2013 22:02:16 +0000 (22:02 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 7 Feb 2013 22:02:16 +0000 (22:02 +0000)
src/lib/dcp_content_type.cc
src/lib/dcp_content_type.h
src/lib/film.cc

index aae80530831228d7440e6b2f06dade0af5a81033..1c96979e4cb77470a5bc84a63b1a6609a06f4471 100644 (file)
@@ -63,6 +63,18 @@ DCPContentType::from_pretty_name (string n)
        return 0;
 }
 
+DCPContentType const *
+DCPContentType::from_dci_name (string n)
+{
+       for (vector<DCPContentType const *>::const_iterator i = _dcp_content_types.begin(); i != _dcp_content_types.end(); ++i) {
+               if ((*i)->dci_name() == n) {
+                       return *i;
+               }
+       }
+
+       return 0;
+}
+
 DCPContentType const *
 DCPContentType::from_index (int n)
 {
index 2b6e60a19cb902b701b9075c5797d34f28f575f5..960bb012948cf8c8b8be310b5ee13622a7cd934d 100644 (file)
@@ -50,6 +50,7 @@ public:
        }
 
        static DCPContentType const * from_pretty_name (std::string);
+       static DCPContentType const * from_dci_name (std::string);
        static DCPContentType const * from_index (int);
        static int as_index (DCPContentType const *);
        static std::vector<DCPContentType const *> all ();
index e759b761c9d89099e79d2ec5b6bb51f4587db5b9..59f79e6667ec91c2e8fd3fccbf2304d61eba4938 100644 (file)
@@ -72,7 +72,7 @@ using boost::starts_with;
 using boost::optional;
 using libdcp::Size;
 
-int const Film::state_version = 2;
+int const Film::state_version = 3;
 
 /** Construct a Film object in a given directory, reading any metadata
  *  file that exists in that directory.  An exception will be thrown if
@@ -374,7 +374,7 @@ Film::write_metadata () const
        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";
+               f << "dcp_content_type " << _dcp_content_type->dci_name () << "\n";
        }
        if (_format) {
                f << "format " << _format->as_metadata () << "\n";
@@ -478,7 +478,11 @@ Film::read_metadata ()
                } 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);
+                       if (version < 3) {
+                               _dcp_content_type = DCPContentType::from_pretty_name (v);
+                       } else {
+                               _dcp_content_type = DCPContentType::from_dci_name (v);
+                       }
                } else if (k == "format") {
                        _format = Format::from_metadata (v);
                } else if (k == "left_crop") {
@@ -493,9 +497,9 @@ Film::read_metadata ()
                        _filters.push_back (Filter::from_id (v));
                } else if (k == "scaler") {
                        _scaler = Scaler::from_id (v);
-               } else if ( ((!version || version < 2) && k == "trim_start") || k == "trim_start") {
+               } else if ( ((!version || version < 2) && k == "dcp_trim_start") || k == "trim_start") {
                        _trim_start = atoi (v.c_str ());
-               } else if ( ((!version || version < 2) && k == "trim_end") || k == "trim_end") {
+               } else if ( ((!version || version < 2) && k == "dcp_trim_end") || k == "trim_end") {
                        _trim_end = atoi (v.c_str ());
                } else if (k == "dcp_ab") {
                        _dcp_ab = (v == "1");