Add new "territory type" so that INT-T{D,L} can be chosen (#2704).
authorCarl Hetherington <cth@carlh.net>
Fri, 5 Jan 2024 00:28:19 +0000 (01:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 5 Jan 2024 16:06:21 +0000 (17:06 +0100)
src/lib/film.cc
src/lib/film.h
src/lib/film_property.h
src/lib/territory_type.cc [new file with mode: 0644]
src/lib/territory_type.h [new file with mode: 0644]
src/wx/dcp_panel.cc
src/wx/metadata_dialog.cc
src/wx/metadata_dialog.h
test/data

index a5b393cc126a2a08cc58d7709b159f761fa8e8bc..5b6b44892427131b024b82d53d10e4efb674c1cb 100644 (file)
@@ -426,6 +426,7 @@ Film::metadata (bool with_content_paths) const
                root->add_child("ContentVersion")->add_child_text(i);
        }
        root->add_child("NameLanguage")->add_child_text(_name_language.to_string());
+       root->add_child("TerritoryType")->add_child_text(territory_type_to_string(_territory_type));
        if (_release_territory) {
                root->add_child("ReleaseTerritory")->add_child_text(_release_territory->subtag());
        }
@@ -617,6 +618,10 @@ Film::read_metadata (optional<boost::filesystem::path> path)
        if (name_language) {
                _name_language = dcp::LanguageTag (*name_language);
        }
+       auto territory_type = f.optional_string_child("TerritoryType");
+       if (territory_type) {
+               _territory_type = string_to_territory_type(*territory_type);
+       }
        auto release_territory = f.optional_string_child("ReleaseTerritory");
        if (release_territory) {
                _release_territory = dcp::LanguageTag::RegionSubtag (*release_territory);
@@ -977,7 +982,11 @@ Film::isdcf_name (bool if_created_now) const
                isdcf_name += "-XX";
        }
 
-       if (_release_territory) {
+       if (_territory_type == TerritoryType::INTERNATIONAL_TEXTED) {
+               isdcf_name += "_INT-TD";
+       } else if (_territory_type == TerritoryType::INTERNATIONAL_TEXTLESS) {
+               isdcf_name += "_INT-TL";
+       } else if (_release_territory) {
                auto territory = _release_territory->subtag();
                isdcf_name += "_" + to_upper (territory);
                if (!_ratings.empty()) {
@@ -2207,3 +2216,11 @@ Film::last_written_by_earlier_than(int major, int minor, int micro) const
        return our_micro < micro;
 }
 
+
+void
+Film::set_territory_type(TerritoryType type)
+{
+       FilmChangeSignaller ch(this, FilmProperty::TERRITORY_TYPE);
+       _territory_type = type;
+}
+
index 8aeae8e4ed37ed97b3022e188d518f1027ed3f4b..f2425585859f60c05795f9015f7a883e665d9709 100644 (file)
@@ -37,6 +37,7 @@
 #include "named_channel.h"
 #include "resolution.h"
 #include "signaller.h"
+#include "territory_type.h"
 #include "transcode_job.h"
 #include "types.h"
 #include "util.h"
@@ -314,6 +315,10 @@ public:
                return _name_language;
        }
 
+       TerritoryType territory_type() const {
+               return _territory_type;
+       }
+
        boost::optional<dcp::LanguageTag::RegionSubtag> release_territory () const {
                return _release_territory;
        }
@@ -407,6 +412,7 @@ public:
        void set_ratings (std::vector<dcp::Rating> r);
        void set_content_versions (std::vector<std::string> v);
        void set_name_language (dcp::LanguageTag lang);
+       void set_territory_type(TerritoryType type);
        void set_release_territory (boost::optional<dcp::LanguageTag::RegionSubtag> region = boost::none);
        void set_sign_language_video_language (boost::optional<dcp::LanguageTag> tag);
        void set_version_number (int v);
@@ -523,6 +529,7 @@ private:
        std::vector<dcp::Rating> _ratings;
        std::vector<std::string> _content_versions;
        dcp::LanguageTag _name_language;
+       TerritoryType _territory_type = TerritoryType::SPECIFIC;
        boost::optional<dcp::LanguageTag::RegionSubtag> _release_territory;
        boost::optional<dcp::LanguageTag> _sign_language_video_language;
        int _version_number;
index 55596af70aa8750d506a0fb5cb6f5a0be8a62224..c232979657620e09a51a366415afb207d0b9d2e3 100644 (file)
@@ -70,6 +70,7 @@ enum class FilmProperty {
        RED_BAND,
        TWO_D_VERSION_OF_THREE_D,
        LUMINANCE,
+       TERRITORY_TYPE,
 };
 
 
diff --git a/src/lib/territory_type.cc b/src/lib/territory_type.cc
new file mode 100644 (file)
index 0000000..83bf6da
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+    Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#include "dcpomatic_assert.h"
+#include "territory_type.h"
+
+
+using std::string;
+
+
+string
+territory_type_to_string(TerritoryType type)
+{
+       switch (type) {
+       case TerritoryType::INTERNATIONAL_TEXTED:
+               return "international-texted";
+       case TerritoryType::INTERNATIONAL_TEXTLESS:
+               return "international-textless";
+       case TerritoryType::SPECIFIC:
+               return "specific";
+       }
+
+       DCPOMATIC_ASSERT(false);
+}
+
+
+TerritoryType
+string_to_territory_type(string type)
+{
+       if (type == "international-texted") {
+               return TerritoryType::INTERNATIONAL_TEXTED;
+       } else if (type == "international-textless") {
+               return TerritoryType::INTERNATIONAL_TEXTLESS;
+       } else if (type == "specific") {
+               return TerritoryType::SPECIFIC;
+       }
+
+       DCPOMATIC_ASSERT(false);
+}
+
diff --git a/src/lib/territory_type.h b/src/lib/territory_type.h
new file mode 100644 (file)
index 0000000..f1e09d9
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+    Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef DCPOMATIC_TERRITORY_TYPE_H
+#define DCPOMATIC_TERRITORY_TYPE_H
+
+
+#include <string>
+
+
+enum class TerritoryType
+{
+       INTERNATIONAL_TEXTED,
+       INTERNATIONAL_TEXTLESS,
+       SPECIFIC
+};
+
+
+std::string territory_type_to_string(TerritoryType);
+TerritoryType string_to_territory_type(std::string);
+
+
+#endif
+
index 1b1cc0e363f2015e9dfc65acf1d821e3b224bda4..eba5b777c64c977be9e3e146caf312e89ae74342 100644 (file)
@@ -530,6 +530,7 @@ DCPPanel::film_changed(FilmProperty p)
        case FilmProperty::TWO_D_VERSION_OF_THREE_D:
        case FilmProperty::CHAIN:
        case FilmProperty::LUMINANCE:
+       case FilmProperty::TERRITORY_TYPE:
                setup_dcp_name ();
                break;
        default:
index 4cbe7b1a425dd142cc474034fb0f3ff46ce9901d..347f2fffd2beebf342e633f5e31f6860a294d9a3 100644 (file)
@@ -106,6 +106,7 @@ MetadataDialog::setup ()
        _enable_luminance->bind(&MetadataDialog::enable_luminance_changed, this);
        _luminance_value->Bind (wxEVT_SPINCTRLDOUBLE, boost::bind(&MetadataDialog::luminance_changed, this));
        _luminance_unit->Bind (wxEVT_CHOICE, boost::bind(&MetadataDialog::luminance_changed, this));
+       _territory_type->bind(&MetadataDialog::territory_type_changed, this);
 
        _film_changed_connection = film()->Change.connect(boost::bind(&MetadataDialog::film_changed, this, _1, _2));
 
@@ -119,11 +120,22 @@ MetadataDialog::setup ()
        film_changed(ChangeType::DONE, FilmProperty::TWO_D_VERSION_OF_THREE_D);
        film_changed(ChangeType::DONE, FilmProperty::CHAIN);
        film_changed(ChangeType::DONE, FilmProperty::LUMINANCE);
+       film_changed(ChangeType::DONE, FilmProperty::TERRITORY_TYPE);
 
        setup_sensitivity ();
 }
 
 
+void
+MetadataDialog::territory_type_changed()
+{
+       auto data = _territory_type->get_data();
+       if (data) {
+               film()->set_territory_type(string_to_territory_type(wx_to_std(data->data())));
+       }
+}
+
+
 void
 MetadataDialog::film_changed(ChangeType type, FilmProperty property)
 {
@@ -180,6 +192,9 @@ MetadataDialog::film_changed(ChangeType type, FilmProperty property)
                        checked_set(_luminance_value, 14);
                        checked_set (_luminance_unit, 1);
                }
+       } else if (property == FilmProperty::TERRITORY_TYPE) {
+               _territory_type->set_by_data(territory_type_to_string(film()->territory_type()));
+               setup_sensitivity();
        }
 }
 
@@ -187,6 +202,13 @@ MetadataDialog::film_changed(ChangeType type, FilmProperty property)
 void
 MetadataDialog::setup_standard (wxPanel* panel, wxSizer* sizer)
 {
+       add_label_to_sizer(sizer, panel, _("Territory type"), true, 0, wxALIGN_CENTER_VERTICAL);
+       _territory_type = new Choice(panel);
+       _territory_type->add(_("Specific"), wx_to_std(territory_type_to_string(TerritoryType::SPECIFIC)));
+       _territory_type->add(_("International texted"), wx_to_std(territory_type_to_string(TerritoryType::INTERNATIONAL_TEXTED)));
+       _territory_type->add(_("International textless"), wx_to_std(territory_type_to_string(TerritoryType::INTERNATIONAL_TEXTLESS)));
+       sizer->Add(_territory_type);
+
        _enable_release_territory = new CheckBox(panel, _("Release territory"));
        sizer->Add (_enable_release_territory, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_GAP);
        _release_territory = new RegionSubtagWidget(panel, _("Release territory for this DCP"), film()->release_territory());
@@ -230,9 +252,12 @@ MetadataDialog::release_territory_changed(optional<dcp::LanguageTag::RegionSubta
 void
 MetadataDialog::setup_sensitivity ()
 {
+       auto const territory_type = film()->territory_type();
+       _enable_release_territory->Enable(territory_type == TerritoryType::SPECIFIC);
        _sign_language_video_language->enable (film()->has_sign_language_video_channel());
        auto const enabled = _enable_release_territory->GetValue();
-       _release_territory->enable(enabled);
+       _release_territory->enable(enabled && territory_type == TerritoryType::SPECIFIC);
+       _ratings->Enable(territory_type == TerritoryType::SPECIFIC);
        _facility->Enable (_enable_facility->GetValue());
        _chain->Enable (_enable_chain->GetValue());
        _studio->Enable (_enable_studio->GetValue());
index 43da2ba717f344372155cb1329c6b05878db8760..5b4efb8c92ac0734aa4c9fc01c345572cce4fdb1 100644 (file)
@@ -78,6 +78,7 @@ private:
        void luminance_changed ();
        std::vector<dcp::Rating> ratings () const;
        void set_ratings (std::vector<dcp::Rating> r);
+       void territory_type_changed();
 
        CheckBox* _enable_release_territory;
        /** The current release territory displayed in the UI; since we can't easily convert
@@ -86,6 +87,7 @@ private:
         */
        boost::optional<dcp::LanguageTag::RegionSubtag> _release_territory_copy;
        RegionSubtagWidget* _release_territory;
+       Choice* _territory_type;
        LanguageTagWidget* _sign_language_video_language = nullptr;
        CheckBox* _enable_facility;
        wxTextCtrl* _facility;
index a513e2cd9f48dd0f6f748e4b5a77c559bbf915cf..ae6d44f2c605b2035fa0346798c3b536ed1a0160 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit a513e2cd9f48dd0f6f748e4b5a77c559bbf915cf
+Subproject commit ae6d44f2c605b2035fa0346798c3b536ed1a0160