Read ISDCF Metadata from 2.14.x metadata (#2083).
authorcah <cth@carlh.net>
Sat, 25 Sep 2021 18:38:58 +0000 (20:38 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 25 Sep 2021 20:21:31 +0000 (22:21 +0200)
src/lib/film.cc
test/data
test/film_metadata_test.cc

index 296066f58756d5d48e903cea458bc1202802cebc..3e6430ee36b6cedf0dfd50669f44b487a91ac0d4 100644 (file)
@@ -729,6 +729,41 @@ Film::read_metadata (optional<boost::filesystem::path> path)
                _audio_language = dcp::LanguageTag(*audio_language);
        }
 
+       /* Read the old ISDCFMetadata tag from 2.14.x metadata */
+       auto isdcf = f.optional_node_child("ISDCFMetadata");
+       if (isdcf) {
+               if (auto territory = isdcf->optional_string_child("Territory")) {
+                       try {
+                               _release_territory = dcp::LanguageTag::RegionSubtag(*territory);
+                       } catch (...) {
+                               /* Invalid region subtag; just ignore it */
+                       }
+               }
+               if (auto audio_language = isdcf->optional_string_child("AudioLanguage")) {
+                       try {
+                               _audio_language = dcp::LanguageTag(*audio_language);
+                       } catch (...) {
+                               /* Invalid language tag; just ignore it */
+                       }
+               }
+               if (auto content_version = isdcf->optional_string_child("ContentVersion")) {
+                       _content_versions.push_back (*content_version);
+               }
+               if (auto rating = isdcf->optional_string_child("Rating")) {
+                       _ratings.push_back (dcp::Rating("", *rating));
+               }
+               if (auto mastered_luminance = isdcf->optional_number_child<float>("MasteredLuminance")) {
+                       _luminance = dcp::Luminance(*mastered_luminance, dcp::Luminance::Unit::FOOT_LAMBERT);
+               }
+               _studio = isdcf->optional_string_child("Studio");
+               _facility = isdcf->optional_string_child("Facility");
+               _temp_version = isdcf->optional_bool_child("TempVersion").get_value_or("false");
+               _pre_release = isdcf->optional_bool_child("PreRelease").get_value_or("false");
+               _red_band = isdcf->optional_bool_child("RedBand").get_value_or("false");
+               _two_d_version_of_three_d = isdcf->optional_bool_child("TwoDVersionOfThreeD").get_value_or("false");
+               _chain = isdcf->optional_string_child("Chain");
+       }
+
        list<string> notes;
        _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
 
index 9a5f520e6106d259c9fb4bd364fb0a881a599f7f..d8d9a1eedc24b5f67f377b6e87e649cdee6fc3b7 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit 9a5f520e6106d259c9fb4bd364fb0a881a599f7f
+Subproject commit d8d9a1eedc24b5f67f377b6e87e649cdee6fc3b7
index 029b990e9d0ffbc5886535d4df13995882e3a7dc..80ecf3881f793c094ff1da8a2d83ec29732e1069 100644 (file)
@@ -41,6 +41,7 @@
 using std::string;
 using std::list;
 using std::make_shared;
+using std::vector;
 
 
 BOOST_AUTO_TEST_CASE (film_metadata_test)
@@ -125,3 +126,28 @@ BOOST_AUTO_TEST_CASE (metadata_loads_from_2_14_x_2)
                       );
 }
 
+
+BOOST_AUTO_TEST_CASE (metadata_loads_from_2_14_x_3)
+{
+       namespace fs = boost::filesystem;
+       auto film = make_shared<Film>(fs::path("build/test/metadata_loads_from_2_14_x_3"));
+       auto notes = film->read_metadata(fs::path("test/data/2.14.x.metadata.3.xml"));
+
+       BOOST_REQUIRE (film->release_territory());
+       BOOST_REQUIRE (film->release_territory()->subtag() == dcp::LanguageTag::RegionSubtag("de").subtag());
+
+       BOOST_REQUIRE (film->audio_language());
+       BOOST_REQUIRE (*film->audio_language() == dcp::LanguageTag("sv-SE"));
+
+       BOOST_REQUIRE (film->content_versions() == vector<string>{"3"});
+       BOOST_REQUIRE (film->ratings() == vector<dcp::Rating>{ dcp::Rating("", "214rating") });
+       BOOST_REQUIRE_EQUAL (film->studio().get_value_or(""), "214studio");
+       BOOST_REQUIRE_EQUAL (film->facility().get_value_or(""), "214facility");
+       BOOST_REQUIRE_EQUAL (film->temp_version(), true);
+       BOOST_REQUIRE_EQUAL (film->pre_release(), true);
+       BOOST_REQUIRE_EQUAL (film->red_band(), true);
+       BOOST_REQUIRE_EQUAL (film->two_d_version_of_three_d(), true);
+       BOOST_REQUIRE_EQUAL (film->chain().get_value_or(""), "214chain");
+       BOOST_REQUIRE (film->luminance() == dcp::Luminance(14, dcp::Luminance::Unit::FOOT_LAMBERT));
+}
+