Move chain to the Interop/SMPTE metadata.
[dcpomatic.git] / src / lib / film.cc
index b34c852952bf9c12e22e3b7059d9435192058072..14747058548a5a3bd4bda5a8aa11e585c3db1bba 100644 (file)
@@ -490,6 +490,13 @@ Film::metadata (bool with_content_paths) const
        if (_facility) {
                root->add_child("Facility")->add_child_text(*_facility);
        }
+       if (_studio) {
+               root->add_child("Studio")->add_child_text(*_studio);
+       }
+       root->add_child("TempVersion")->add_child_text(_temp_version ? "1" : "0");
+       root->add_child("PreRelease")->add_child_text(_pre_release ? "1" : "0");
+       root->add_child("RedBand")->add_child_text(_red_band ? "1" : "0");
+       root->add_child("TwoDVersionOfThreeD")->add_child_text(_two_d_version_of_three_d ? "1" : "0");
        if (_luminance) {
                root->add_child("LuminanceValue")->add_child_text(raw_convert<string>(_luminance->value()));
                root->add_child("LuminanceUnit")->add_child_text(dcp::Luminance::unit_to_string(_luminance->unit()));
@@ -666,6 +673,11 @@ Film::read_metadata (optional<boost::filesystem::path> path)
        _chain = f.optional_string_child("Chain");
        _distributor = f.optional_string_child("Distributor");
        _facility = f.optional_string_child("Facility");
+       _studio = f.optional_string_child("Studio");
+       _temp_version = f.optional_bool_child("TempVersion").get_value_or(false);
+       _pre_release = f.optional_bool_child("PreRelease").get_value_or(false);
+       _red_band = f.optional_bool_child("RedBand").get_value_or(false);
+       _two_d_version_of_three_d = f.optional_bool_child("TwoDVersionOfThreeD").get_value_or(false);
 
        auto value = f.optional_number_child<float>("LuminanceValue");
        auto unit = f.optional_string_child("LuminanceUnit");
@@ -862,27 +874,27 @@ Film::isdcf_name (bool if_created_now) const
 
        auto const dm = isdcf_metadata ();
 
-       if (dm.temp_version) {
+       if (_temp_version) {
                d += "-Temp";
        }
 
-       if (dm.pre_release) {
+       if (_pre_release) {
                d += "-Pre";
        }
 
-       if (dm.red_band) {
+       if (_red_band) {
                d += "-RedBand";
        }
 
-       if (!dm.chain.empty ()) {
-               d += "-" + dm.chain;
+       if (_chain && !_chain->empty()) {
+               d += "-" + *_chain;
        }
 
        if (three_d ()) {
                d += "-3D";
        }
 
-       if (dm.two_d_version_of_three_d) {
+       if (_two_d_version_of_three_d) {
                d += "-2D";
        }
 
@@ -919,9 +931,8 @@ Film::isdcf_name (bool if_created_now) const
 
        auto audio_langs = audio_languages();
        auto audio_language = (audio_langs.empty() || !audio_langs.front().language()) ? "XX" : audio_langs.front().language()->subtag();
-       transform (audio_language.begin(), audio_language.end(), audio_language.begin(), ::toupper);
 
-       d += "_" + audio_language;
+       d += "_" + to_upper (audio_language);
 
        /* I'm not clear on the precise details of the convention for CCAP labelling;
           for now I'm just appending -CCAP if we have any closed captions.
@@ -945,7 +956,7 @@ Film::isdcf_name (bool if_created_now) const
                if (burnt_in) {
                        transform (lang.begin(), lang.end(), lang.begin(), ::tolower);
                } else {
-                       transform (lang.begin(), lang.end(), lang.begin(), ::toupper);
+                       lang = to_upper (lang);
                }
 
                d += "-" + lang;
@@ -959,8 +970,7 @@ Film::isdcf_name (bool if_created_now) const
 
        if (_release_territory) {
                auto territory = _release_territory->subtag();
-               transform (territory.begin(), territory.end(), territory.begin(), ::toupper);
-               d += "_" + territory;
+               d += "_" + to_upper (territory);
                if (_ratings.empty ()) {
                        d += "-NR";
                } else {
@@ -988,8 +998,8 @@ Film::isdcf_name (bool if_created_now) const
 
        d += "_" + resolution_to_string (_resolution);
 
-       if (!dm.studio.empty ()) {
-               d += "_" + dm.studio;
+       if (_studio && _studio->length() >= 2) {
+               d += "_" + to_upper (_studio->substr(0, 4));
        }
 
        if (if_created_now) {
@@ -998,8 +1008,8 @@ Film::isdcf_name (bool if_created_now) const
                d += "_" + boost::gregorian::to_iso_string (_isdcf_date);
        }
 
-       if (!dm.facility.empty ()) {
-               d += "_" + dm.facility;
+       if (_facility && _facility->length() >= 3) {
+               d += "_" + to_upper(_facility->substr(0, 3));
        }
 
        if (_interop) {
@@ -1153,9 +1163,8 @@ Film::set_three_d (bool t)
        FilmChangeSignaller ch (this, Property::THREE_D);
        _three_d = t;
 
-       if (_three_d && _isdcf_metadata.two_d_version_of_three_d) {
-               FilmChangeSignaller ch (this, Property::ISDCF_METADATA);
-               _isdcf_metadata.two_d_version_of_three_d = false;
+       if (_three_d && _two_d_version_of_three_d) {
+               set_two_d_version_of_three_d (false);
        }
 }
 
@@ -2063,6 +2072,14 @@ Film::set_facility (optional<string> f)
 }
 
 
+void
+Film::set_studio (optional<string> s)
+{
+       FilmChangeSignaller ch (this, Property::STUDIO);
+       _studio = s;
+}
+
+
 optional<DCPTime>
 Film::marker (dcp::Marker type) const
 {
@@ -2120,3 +2137,36 @@ Film::add_ffoc_lfoc (Markers& markers) const
                markers[dcp::Marker::LFOC] = length() - DCPTime::from_frames(1, video_frame_rate());
        }
 }
+
+
+void
+Film::set_temp_version (bool t)
+{
+       FilmChangeSignaller ch (this, Property::TEMP_VERSION);
+       _temp_version = t;
+}
+
+
+void
+Film::set_pre_release (bool p)
+{
+       FilmChangeSignaller ch (this, Property::PRE_RELEASE);
+       _pre_release = p;
+}
+
+
+void
+Film::set_red_band (bool r)
+{
+       FilmChangeSignaller ch (this, Property::RED_BAND);
+       _red_band = r;
+}
+
+
+void
+Film::set_two_d_version_of_three_d (bool t)
+{
+       FilmChangeSignaller ch (this, Property::TWO_D_VERSION_OF_THREE_D);
+       _two_d_version_of_three_d = t;
+}
+