Fixes for new libdcp with multiple content versions.
authorCarl Hetherington <cth@carlh.net>
Sun, 27 Sep 2020 19:18:51 +0000 (21:18 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 27 Sep 2020 19:18:51 +0000 (21:18 +0200)
src/lib/copy_dcp_details_to_film.cc
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/lib/dcp_examiner.cc
src/lib/dcp_examiner.h
test/import_dcp_test.cc

index d73ee87..c33b097 100644 (file)
@@ -70,10 +70,6 @@ copy_dcp_details_to_film (shared_ptr<const DCPContent> dcp, shared_ptr<Film> fil
        }
 
        film->set_ratings (dcp->ratings());
-
-       vector<string> cv;
-       cv.push_back (dcp->content_version());
-       film->set_content_versions (cv);
+       film->set_content_versions (dcp->content_versions());
 }
 
-
index 00ffb39..0bef73f 100644 (file)
@@ -158,7 +158,9 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version)
                _ratings.push_back (dcp::Rating(i));
        }
 
-       _content_version = node->optional_string_child("ContentVersion").get_value_or("");
+       BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("ContentVersion")) {
+               _content_versions.push_back (i->content());
+       }
 }
 
 void
@@ -274,7 +276,7 @@ DCPContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
                        _markers[i->first] = ContentTime(i->second.as_editable_units(DCPTime::HZ));
                }
                _ratings = examiner->ratings ();
-               _content_version = examiner->content_version ();
+               _content_versions = examiner->content_versions ();
        }
 
        if (old_texts == texts) {
@@ -390,7 +392,9 @@ DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const
                i.as_xml (rating);
        }
 
-       node->add_child("ContentVersion")->add_child_text (_content_version);
+       BOOST_FOREACH (string i, _content_versions) {
+               node->add_child("ContentVersion")->add_child_text(i);
+       }
 }
 
 DCPTime
index 6d70767..e8532ff 100644 (file)
@@ -162,8 +162,8 @@ public:
                return _ratings;
        }
 
-       std::string content_version () const {
-               return _content_version;
+       std::vector<std::string> content_versions () const {
+               return _content_versions;
        }
 
 private:
@@ -214,7 +214,7 @@ private:
        std::list<int64_t> _reel_lengths;
        std::map<dcp::Marker, dcpomatic::ContentTime> _markers;
        std::vector<dcp::Rating> _ratings;
-       std::string _content_version;
+       std::vector<std::string> _content_versions;
 };
 
 #endif
index 65cfb88..27eb74a 100644 (file)
@@ -260,7 +260,9 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
        _three_d = !cpl->reels().empty() && cpl->reels().front()->main_picture() &&
                dynamic_pointer_cast<dcp::StereoPictureAsset> (cpl->reels().front()->main_picture()->asset());
        _ratings = cpl->ratings();
-       _content_version = cpl->content_version().label_text;
+       BOOST_FOREACH (dcp::ContentVersion i, cpl->content_versions()) {
+               _content_versions.push_back (i.label_text);
+       }
 
        _cpl = cpl->id ();
 }
index cb68aa5..232d7f0 100644 (file)
@@ -134,8 +134,8 @@ public:
                return _ratings;
        }
 
-       std::string content_version () const {
-               return _content_version;
+       std::vector<std::string> content_versions () const {
+               return _content_versions;
        }
 
        bool has_atmos () const {
@@ -176,7 +176,7 @@ private:
        std::list<int64_t> _reel_lengths;
        std::map<dcp::Marker, dcp::Time> _markers;
        std::vector<dcp::Rating> _ratings;
-       std::string _content_version;
+       std::vector<std::string> _content_versions;
        bool _has_atmos;
        Frame _atmos_length;
        dcp::Fraction _atmos_edit_rate;
index 07116c1..ad6fc88 100644 (file)
@@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_metadata_test)
        film2->write_metadata ();
 
        BOOST_CHECK (imported->ratings() == ratings);
-       BOOST_CHECK_EQUAL (imported->content_version(), "Fred");
+       BOOST_CHECK (imported->content_versions() == cv);
 
        /* Load that film and check that the metadata has been loaded */
        shared_ptr<Film> film3(new Film(boost::filesystem::path("build/test/import_dcp_metadata_test2")));
@@ -195,6 +195,6 @@ BOOST_AUTO_TEST_CASE (import_dcp_metadata_test)
        BOOST_REQUIRE (reloaded);
 
        BOOST_CHECK (reloaded->ratings() == ratings);
-       BOOST_CHECK_EQUAL (reloaded->content_version(), "Fred");
+       BOOST_CHECK (reloaded->content_versions() == cv);
 }