From 43cca4d3a11e077b3e75c713b95942cc3afc9eb1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 5 Jan 2024 01:28:19 +0100 Subject: [PATCH] Add new "territory type" so that INT-T{D,L} can be chosen (#2704). --- src/lib/film.cc | 19 ++++++++++++- src/lib/film.h | 7 +++++ src/lib/film_property.h | 1 + src/lib/territory_type.cc | 57 +++++++++++++++++++++++++++++++++++++++ src/lib/territory_type.h | 41 ++++++++++++++++++++++++++++ src/wx/dcp_panel.cc | 1 + src/wx/metadata_dialog.cc | 27 ++++++++++++++++++- src/wx/metadata_dialog.h | 2 ++ test/data | 2 +- 9 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 src/lib/territory_type.cc create mode 100644 src/lib/territory_type.h diff --git a/src/lib/film.cc b/src/lib/film.cc index a5b393cc1..5b6b44892 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -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 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; +} + diff --git a/src/lib/film.h b/src/lib/film.h index 8aeae8e4e..f24255858 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -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 release_territory () const { return _release_territory; } @@ -407,6 +412,7 @@ public: void set_ratings (std::vector r); void set_content_versions (std::vector v); void set_name_language (dcp::LanguageTag lang); + void set_territory_type(TerritoryType type); void set_release_territory (boost::optional region = boost::none); void set_sign_language_video_language (boost::optional tag); void set_version_number (int v); @@ -523,6 +529,7 @@ private: std::vector _ratings; std::vector _content_versions; dcp::LanguageTag _name_language; + TerritoryType _territory_type = TerritoryType::SPECIFIC; boost::optional _release_territory; boost::optional _sign_language_video_language; int _version_number; diff --git a/src/lib/film_property.h b/src/lib/film_property.h index 55596af70..c23297965 100644 --- a/src/lib/film_property.h +++ b/src/lib/film_property.h @@ -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 index 000000000..83bf6dadb --- /dev/null +++ b/src/lib/territory_type.cc @@ -0,0 +1,57 @@ +/* + Copyright (C) 2023 Carl Hetherington + + 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 . +*/ + + +#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 index 000000000..f1e09d91a --- /dev/null +++ b/src/lib/territory_type.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2023 Carl Hetherington + + 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 . +*/ + + +#ifndef DCPOMATIC_TERRITORY_TYPE_H +#define DCPOMATIC_TERRITORY_TYPE_H + + +#include + + +enum class TerritoryType +{ + INTERNATIONAL_TEXTED, + INTERNATIONAL_TEXTLESS, + SPECIFIC +}; + + +std::string territory_type_to_string(TerritoryType); +TerritoryType string_to_territory_type(std::string); + + +#endif + diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 1b1cc0e36..eba5b777c 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -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: diff --git a/src/wx/metadata_dialog.cc b/src/wx/metadata_dialog.cc index 4cbe7b1a4..347f2fffd 100644 --- a/src/wx/metadata_dialog.cc +++ b/src/wx/metadata_dialog.cc @@ -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(optionalterritory_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()); diff --git a/src/wx/metadata_dialog.h b/src/wx/metadata_dialog.h index 43da2ba71..5b4efb8c9 100644 --- a/src/wx/metadata_dialog.h +++ b/src/wx/metadata_dialog.h @@ -78,6 +78,7 @@ private: void luminance_changed (); std::vector ratings () const; void set_ratings (std::vector 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 _release_territory_copy; RegionSubtagWidget* _release_territory; + Choice* _territory_type; LanguageTagWidget* _sign_language_video_language = nullptr; CheckBox* _enable_facility; wxTextCtrl* _facility; diff --git a/test/data b/test/data index a513e2cd9..ae6d44f2c 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit a513e2cd9f48dd0f6f748e4b5a77c559bbf915cf +Subproject commit ae6d44f2c605b2035fa0346798c3b536ed1a0160 -- 2.30.2