BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Marker")) {
_markers[dcp::marker_from_string(i->string_attribute("type"))] = ContentTime(raw_convert<int64_t>(i->content()));
}
+
+ BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Rating")) {
+ _ratings.push_back (dcp::Rating(i));
+ }
+
+ _content_version = node->optional_string_child("ContentVersion").get_value_or("");
}
void
for (map<dcp::Marker, dcp::Time>::const_iterator i = markers.begin(); i != markers.end(); ++i) {
_markers[i->first] = ContentTime(i->second.as_editable_units(DCPTime::HZ));
}
+ _ratings = examiner->ratings ();
+ _content_version = examiner->content_version ();
}
if (old_texts == texts) {
marker->set_attribute("type", dcp::marker_to_string(i->first));
marker->add_child_text(raw_convert<string>(i->second.get()));
}
+
+ BOOST_FOREACH (dcp::Rating i, _ratings) {
+ xmlpp::Element* rating = node->add_child("Rating");
+ i.as_xml (rating);
+ }
+
+ node->add_child("ContentVersion")->add_child_text (_content_version);
}
DCPTime
Resolution resolution () const;
+ std::vector<dcp::Rating> ratings () const {
+ return _ratings;
+ }
+
+ std::string content_version () const {
+ return _content_version;
+ }
+
private:
friend class reels_test5;
/** List of the lengths of the reels in this DCP */
std::list<int64_t> _reel_lengths;
std::map<dcp::Marker, dcpomatic::ContentTime> _markers;
+ std::vector<dcp::Rating> _ratings;
+ std::string _content_version;
};
#endif
#include "exceptions.h"
#include "image.h"
#include "config.h"
+#include "util.h"
#include <dcp/dcp.h>
#include <dcp/decrypted_kdm.h>
#include <dcp/cpl.h>
_standard = cpl->standard().get();
_three_d = !cpl->reels().empty() && cpl->reels().front()->main_picture() &&
dynamic_pointer_cast<dcp::StereoPictureAsset> (cpl->reels().front()->main_picture()->asset());
+ _ratings = list_to_vector (cpl->ratings());
+ _content_version = cpl->content_version_label_text ();
_cpl = cpl->id ();
}
return _markers;
}
+ std::vector<dcp::Rating> ratings () const {
+ return _ratings;
+ }
+
+ std::string content_version () const {
+ return _content_version;
+ }
+
private:
boost::optional<double> _video_frame_rate;
boost::optional<dcp::Size> _video_size;
std::string _cpl;
std::list<int64_t> _reel_lengths;
std::map<dcp::Marker, dcp::Time> _markers;
+ std::vector<dcp::Rating> _ratings;
+ std::string _content_version;
};
BOOST_REQUIRE(markers.find(dcp::LFMC) != markers.end());
BOOST_CHECK(markers[dcp::LFMC] == dcpomatic::ContentTime(960000));
}
+
+
+/** Check that DCP metadata (ratings and content version) are imported correctly */
+BOOST_AUTO_TEST_CASE (import_dcp_metadata_test)
+{
+ /* Make a DCP with some ratings and a content version */
+ shared_ptr<Film> film = new_test_film2 ("import_dcp_metadata_test");
+ shared_ptr<Content> content = content_factory("test/data/flat_red.png").front();
+ film->examine_and_add_content (content);
+ BOOST_REQUIRE (!wait_for_jobs());
+
+ content->video->set_length (10);
+
+ std::vector<dcp::Rating> ratings;
+ ratings.push_back (dcp::Rating("BBFC", "15"));
+ ratings.push_back (dcp::Rating("MPAA", "NC-17"));
+ film->set_ratings (ratings);
+
+ film->set_content_version ("Fred");
+
+ film->make_dcp ();
+ BOOST_REQUIRE (!wait_for_jobs());
+
+ /* Import the DCP to a new film and check the metadata */
+ shared_ptr<Film> film2 = new_test_film2 ("import_dcp_metadata_test2");
+ shared_ptr<DCPContent> imported (new DCPContent(film->dir(film->dcp_name())));
+ film2->examine_and_add_content (imported);
+ BOOST_REQUIRE (!wait_for_jobs());
+ film2->write_metadata ();
+
+ BOOST_CHECK (imported->ratings() == ratings);
+ BOOST_CHECK_EQUAL (imported->content_version(), "Fred");
+
+ /* 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")));
+ film3->read_metadata ();
+ BOOST_REQUIRE (film3->content().size() == 1);
+ shared_ptr<DCPContent> reloaded = dynamic_pointer_cast<DCPContent>(film3->content().front());
+ BOOST_REQUIRE (reloaded);
+
+ BOOST_CHECK (reloaded->ratings() == ratings);
+ BOOST_CHECK_EQUAL (reloaded->content_version(), "Fred");
+}
+