diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-04-02 23:43:54 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-04-02 23:43:54 +0000 |
| commit | 698e3ac8863d264237003b49750ae074d612f451 (patch) | |
| tree | a6ef673ad68c1fb43844dd23482c7a97514b3918 /src/lib | |
| parent | d5c8fb9b826aaac2acab58f8a7b2eec4fcce99a6 (diff) | |
Extract subtitle language from text content rather than ISDCFMetadata (part of #1516).
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 35 | ||||
| -rw-r--r-- | src/lib/isdcf_metadata.cc | 5 | ||||
| -rw-r--r-- | src/lib/isdcf_metadata.h | 3 | ||||
| -rw-r--r-- | src/lib/writer.cc | 14 |
4 files changed, 33 insertions, 24 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 9be048b65..caa95c6be 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -722,32 +722,35 @@ Film::isdcf_name (bool if_created_now) const if (!dm.audio_language.empty ()) { d += "_" + dm.audio_language; - if (!dm.subtitle_language.empty()) { - /* 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. - */ + /* 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. + */ - bool burnt_in = true; - bool ccap = false; - BOOST_FOREACH (shared_ptr<Content> i, content()) { - BOOST_FOREACH (shared_ptr<TextContent> j, i->text) { - if (j->type() == TEXT_OPEN_SUBTITLE && j->use() && !j->burn()) { + optional<string> subtitle_language; + bool burnt_in = true; + bool ccap = false; + BOOST_FOREACH (shared_ptr<Content> i, content()) { + BOOST_FOREACH (shared_ptr<TextContent> j, i->text) { + if (j->type() == TEXT_OPEN_SUBTITLE && j->use()) { + subtitle_language = j->language (); + if (!j->burn()) { burnt_in = false; - } else if (j->type() == TEXT_CLOSED_CAPTION) { - ccap = true; } + } else if (j->type() == TEXT_CLOSED_CAPTION && j->use()) { + ccap = true; } } + } - string language = dm.subtitle_language; - if (burnt_in && language != "XX") { - transform (language.begin(), language.end(), language.begin(), ::tolower); + if (subtitle_language) { + if (burnt_in && *subtitle_language != "XX") { + transform (subtitle_language->begin(), subtitle_language->end(), subtitle_language->begin(), ::tolower); } else { - transform (language.begin(), language.end(), language.begin(), ::toupper); + transform (subtitle_language->begin(), subtitle_language->end(), subtitle_language->begin(), ::toupper); } - d += "-" + language; + d += "-" + *subtitle_language; if (ccap) { d += "-CCAP"; } diff --git a/src/lib/isdcf_metadata.cc b/src/lib/isdcf_metadata.cc index 1b424c925..5e689ee27 100644 --- a/src/lib/isdcf_metadata.cc +++ b/src/lib/isdcf_metadata.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -33,7 +33,6 @@ using dcp::raw_convert; ISDCFMetadata::ISDCFMetadata (cxml::ConstNodePtr node) : content_version (node->number_child<int> ("ContentVersion")) , audio_language (node->string_child ("AudioLanguage")) - , subtitle_language (node->string_child ("SubtitleLanguage")) , territory (node->string_child ("Territory")) , rating (node->string_child ("Rating")) , studio (node->string_child ("Studio")) @@ -54,7 +53,6 @@ ISDCFMetadata::as_xml (xmlpp::Node* root) const { root->add_child("ContentVersion")->add_child_text (raw_convert<string> (content_version)); root->add_child("AudioLanguage")->add_child_text (audio_language); - root->add_child("SubtitleLanguage")->add_child_text (subtitle_language); root->add_child("Territory")->add_child_text (territory); root->add_child("Rating")->add_child_text (rating); root->add_child("Studio")->add_child_text (studio); @@ -72,7 +70,6 @@ operator== (ISDCFMetadata const & a, ISDCFMetadata const & b) { return a.content_version == b.content_version && a.audio_language == b.audio_language && - a.subtitle_language == b.subtitle_language && a.territory == b.territory && a.rating == b.rating && a.studio == b.studio && diff --git a/src/lib/isdcf_metadata.h b/src/lib/isdcf_metadata.h index 49d204cf4..0c70fb6bc 100644 --- a/src/lib/isdcf_metadata.h +++ b/src/lib/isdcf_metadata.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -46,7 +46,6 @@ public: int content_version; std::string audio_language; - std::string subtitle_language; std::string territory; std::string rating; std::string studio; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 45a74624f..d0f0825f1 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -35,6 +35,7 @@ #include "font.h" #include "util.h" #include "reel_writer.h" +#include "text_content.h" #include <dcp/cpl.h> #include <dcp/locale_convert.h> #include <boost/foreach.hpp> @@ -591,7 +592,16 @@ Writer::write_cover_sheet () boost::algorithm::replace_all (text, "$TYPE", _film->dcp_content_type()->pretty_name()); boost::algorithm::replace_all (text, "$CONTAINER", _film->container()->container_nickname()); boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", _film->isdcf_metadata().audio_language); - boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", _film->isdcf_metadata().subtitle_language); + + optional<string> subtitle_language; + BOOST_FOREACH (shared_ptr<Content> i, _film->content()) { + BOOST_FOREACH (shared_ptr<TextContent> j, i->text) { + if (j->type() == TEXT_OPEN_SUBTITLE && j->use()) { + subtitle_language = j->language (); + } + } + } + boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_language.get_value_or("None")); boost::uintmax_t size = 0; for ( |
