summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-01-11 23:04:57 +0100
committerCarl Hetherington <cth@carlh.net>2025-01-12 02:06:50 +0100
commit20c749bb5aee7a12d6a4365bc35fee01b9810fe3 (patch)
tree71b6e2894281d0c0e5109b5161bf3441aa46072b
parent5d9b8579950a4440b43a649c27fa36082144773d (diff)
Rename subtitle_languages() -> open_text_languages().
Also make it return open captions as well as open subtitles (#2941).
-rw-r--r--src/lib/film.cc6
-rw-r--r--src/lib/film.h6
-rw-r--r--src/lib/reel_writer.cc4
-rw-r--r--src/lib/subtitle_film_encoder.cc2
-rw-r--r--src/lib/writer.cc4
-rw-r--r--test/isdcf_name_test.cc8
-rw-r--r--test/subtitle_metadata_test.cc2
7 files changed, 18 insertions, 14 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc
index cf04ac0da..8f884a8a5 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -819,7 +819,7 @@ Film::mapped_audio_channels () const
pair<optional<dcp::LanguageTag>, vector<dcp::LanguageTag>>
-Film::subtitle_languages(bool* burnt_in) const
+Film::open_text_languages(bool* burnt_in) const
{
if (burnt_in) {
*burnt_in = true;
@@ -830,7 +830,7 @@ Film::subtitle_languages(bool* burnt_in) const
auto dcp = dynamic_pointer_cast<DCPContent>(i);
for (auto const& text: i->text) {
auto const use = text->use() || (dcp && dcp->reference_text(TextType::OPEN_SUBTITLE));
- if (use && text->type() == TextType::OPEN_SUBTITLE) {
+ if (use && is_open(text->type())) {
if (!text->burn() && burnt_in) {
*burnt_in = false;
}
@@ -1012,7 +1012,7 @@ Film::isdcf_name (bool if_created_now) const
isdcf_name += "_" + to_upper (audio_language);
bool burnt_in;
- auto sub_langs = subtitle_languages(&burnt_in);
+ auto sub_langs = open_text_languages(&burnt_in);
auto ccap_langs = closed_caption_languages();
if (sub_langs.first && sub_langs.first->language()) {
auto lang = entry_for_language(*sub_langs.first);
diff --git a/src/lib/film.h b/src/lib/film.h
index 648d9828b..f095023a3 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -177,10 +177,10 @@ public:
return _audio_language;
}
- /** @param burnt_in If non-null, filled with true if all subtitles are burnt in, otherwise false.
- * @return pair containing the main subtitle language, and additional languages
+ /** @param burnt_in If non-null, filled with true if all open subtitles/captions are burnt in, otherwise false.
+ * @return pair containing the main open subtitle/caption language, and additional languages
*/
- std::pair<boost::optional<dcp::LanguageTag>, std::vector<dcp::LanguageTag>> subtitle_languages(bool* burnt_in = nullptr) const;
+ std::pair<boost::optional<dcp::LanguageTag>, std::vector<dcp::LanguageTag>> open_text_languages(bool* burnt_in = nullptr) const;
/** @return all closed caption languages in the film */
std::vector<dcp::LanguageTag> closed_caption_languages() const;
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc
index ec7fc9e39..3cd889249 100644
--- a/src/lib/reel_writer.cc
+++ b/src/lib/reel_writer.cc
@@ -623,7 +623,7 @@ ReelWriter::create_reel_text (
if (subtitle) {
/* We have a subtitle asset that we either made or are referencing */
- if (auto main_language = film()->subtitle_languages().first) {
+ if (auto main_language = film()->open_text_languages().first) {
subtitle->set_language (*main_language);
}
}
@@ -796,7 +796,7 @@ ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track, bool
shared_ptr<dcp::TextAsset> asset;
optional<string> font;
- auto lang = film()->subtitle_languages();
+ auto lang = film()->open_text_languages();
if (film()->interop()) {
auto s = make_shared<dcp::InteropTextAsset>();
s->set_movie_title (film()->name());
diff --git a/src/lib/subtitle_film_encoder.cc b/src/lib/subtitle_film_encoder.cc
index c9520bf0b..a127ba73f 100644
--- a/src/lib/subtitle_film_encoder.cc
+++ b/src/lib/subtitle_film_encoder.cc
@@ -140,7 +140,7 @@ SubtitleFilmEncoder::text(PlayerText subs, TextType type, optional<DCPTextTrack>
if (!_assets[_reel_index].first) {
shared_ptr<dcp::TextAsset> asset;
- auto lang = _film->subtitle_languages ();
+ auto const lang = _film->open_text_languages();
if (_film->interop ()) {
auto s = make_shared<dcp::InteropTextAsset>();
s->set_movie_title (_film->name());
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index b1d21cae1..9b7f059f9 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -695,7 +695,7 @@ Writer::finish()
cpl->set_main_picture_active_area({ active_area.width & ~1, active_area.height & ~1});
}
- auto sl = film()->subtitle_languages().second;
+ auto const sl = film()->open_text_languages().second;
if (!sl.empty()) {
cpl->set_additional_subtitle_languages(sl);
}
@@ -746,7 +746,7 @@ Writer::write_cover_sheet()
boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", _("None"));
}
- auto subtitle_languages = film()->subtitle_languages();
+ auto const subtitle_languages = film()->open_text_languages();
if (subtitle_languages.first) {
boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_languages.first->description());
} else {
diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc
index 3897aabbe..40626621f 100644
--- a/test/isdcf_name_test.cc
+++ b/test/isdcf_name_test.cc
@@ -78,8 +78,8 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test)
film->set_resolution (Resolution::FOUR_K);
auto text = content_factory("test/data/subrip.srt")[0];
BOOST_REQUIRE_EQUAL (text->text.size(), 1U);
- text->text.front()->set_burn (true);
- text->text.front()->set_language (dcp::LanguageTag("fr-FR"));
+ text->text[0]->set_burn(true);
+ text->text[0]->set_language(dcp::LanguageTag("fr-FR"));
film->examine_and_add_content (text);
film->set_version_number(2);
film->set_release_territory(dcp::LanguageTag::RegionSubtag("US"));
@@ -94,6 +94,10 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test)
film->set_interop (false);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
+ /* Should be the same if the subs are marked as open captions */
+ text->text[0]->set_type(TextType::OPEN_CAPTION);
+ BOOST_CHECK_EQUAL(film->isdcf_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
+
/* Test to see that RU ratings like 6+ are stripped of their + */
film->set_ratings({dcp::Rating("RARS", "6+")});
BOOST_CHECK_EQUAL (film->dcp_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr_US-6_MOS_4K_DI_20140704_PPF_SMPTE_OV");
diff --git a/test/subtitle_metadata_test.cc b/test/subtitle_metadata_test.cc
index ce925defb..d8b887576 100644
--- a/test/subtitle_metadata_test.cc
+++ b/test/subtitle_metadata_test.cc
@@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE (subtitle_metadata_test1)
auto film = make_shared<Film>(p);
film->read_metadata();
- auto langs = film->subtitle_languages ();
+ auto langs = film->open_text_languages();
BOOST_REQUIRE (langs.first);
BOOST_CHECK_EQUAL (langs.first->to_string(), "de-DE");
}