pair<optional<dcp::LanguageTag>, vector<dcp::LanguageTag>>
-Film::open_text_languages(bool* burnt_in) const
+Film::open_text_languages(bool* burnt_in, bool* caption) const
{
if (burnt_in) {
*burnt_in = true;
for (auto i: content()) {
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));
+ auto const use = text->use() ||
+ (dcp && (dcp->reference_text(TextType::OPEN_SUBTITLE) || dcp->reference_text(TextType::OPEN_CAPTION)));
+
if (use && is_open(text->type())) {
if (!text->burn() && burnt_in) {
*burnt_in = false;
result.second.push_back(text->language().get());
} else {
result.first = text->language().get();
+ if (caption && text->type() == TextType::OPEN_CAPTION) {
+ *caption = true;
+ }
}
}
}
vector<dcp::LanguageTag>
-Film::closed_text_languages() const
+Film::closed_text_languages(bool* caption) const
{
vector<dcp::LanguageTag> result;
for (auto i: content()) {
for (auto text: i->text) {
if (text->use() && is_closed(text->type()) && text->dcp_track() && text->dcp_track()->language) {
result.push_back(*text->dcp_track()->language);
+ if (caption && result.size() == 1 && text->type() == TextType::CLOSED_CAPTION) {
+ *caption = true;
+ }
}
}
}
isdcf_name += "_" + to_upper (audio_language);
bool burnt_in;
- auto const open_langs = open_text_languages(&burnt_in);
- auto const closed_langs = closed_text_languages();
+ bool open_caption = false;
+ auto const open_langs = open_text_languages(&burnt_in, &open_caption);
+
+ bool closed_caption = false;
+ auto const closed_langs = closed_text_languages(&closed_caption);
+
if (open_langs.first && open_langs.first->language()) {
auto lang = entry_for_language(*open_langs.first);
if (burnt_in) {
}
isdcf_name += "-" + lang;
+ if (open_caption) {
+ isdcf_name += "-OCAP";
+ }
} else if (!closed_langs.empty()) {
- isdcf_name += "-" + to_upper(entry_for_language(closed_langs[0])) + "-CCAP";
+ isdcf_name += "-" + to_upper(entry_for_language(closed_langs[0]));
+ if (closed_caption) {
+ isdcf_name += "-CCAP";
+ }
} else {
/* No subtitles */
isdcf_name += "-XX";
struct isdcf_name_test;
struct isdcf_name_with_atmos;
struct isdcf_name_with_ccap;
+struct isdcf_name_with_closed_subtitles;
struct ov_subs_in_vf_name;
struct recover_test_2d_encrypted;
}
/** @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
+ * @param caption If non-null, filled with true if the first returned language is a caption rather than a subtitle.
+ * @return Pair containing the main open subtitle/caption language, and additional languages
*/
- std::pair<boost::optional<dcp::LanguageTag>, std::vector<dcp::LanguageTag>> open_text_languages(bool* burnt_in = nullptr) const;
- /** @return all closed subtitle/caption languages in the film */
- std::vector<dcp::LanguageTag> closed_text_languages() const;
+ std::pair<boost::optional<dcp::LanguageTag>, std::vector<dcp::LanguageTag>> open_text_languages(
+ bool* burnt_in = nullptr, bool* caption = nullptr
+ ) const;
+ /** @param caption If non-null, filled with true if the first returned language is a caption rather than a subtitle.
+ * @return All closed subtitle/caption languages in the film.
+ */
+ std::vector<dcp::LanguageTag> closed_text_languages(bool* caption = nullptr) const;
std::string content_summary (dcpomatic::DCPTimePeriod period) const;
friend struct ::isdcf_name_test;
friend struct ::isdcf_name_with_atmos;
friend struct ::isdcf_name_with_ccap;
+ friend struct ::isdcf_name_with_closed_subtitles;
friend struct ::ov_subs_in_vf_name;
friend struct paths_test;
friend struct ::recover_test_2d_encrypted;
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 */
+ /* Test the subs being 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");
+ BOOST_CHECK_EQUAL(film->isdcf_name(false), "MyNiceFilmWith_TLR-2_S_DE-fr-OCAP_US-R_MOS_4K_DI_20140704_PPF_SMPTE_OV");
+ text->text[0]->set_type(TextType::OPEN_SUBTITLE);
/* Test to see that RU ratings like 6+ are stripped of their + */
film->set_ratings({dcp::Rating("RARS", "6+")});
BOOST_CHECK_EQUAL(film->isdcf_name(false), "Hello_TST-1_F_XX-DE-CCAP_MOS_2K_20230118_SMPTE_OV");
}
+
+BOOST_AUTO_TEST_CASE(isdcf_name_with_closed_subtitles)
+{
+ auto content = content_factory("test/data/short.srt")[0];
+ auto film = new_test_film("isdcf_name_with_closed_subtitles", { content });
+ content->text[0]->set_use(true);
+ content->text[0]->set_type(TextType::CLOSED_SUBTITLE);
+ content->text[0]->set_dcp_track(DCPTextTrack("Foo", dcp::LanguageTag("de-DE")));
+ film->_isdcf_date = boost::gregorian::date(2023, boost::gregorian::Jan, 18);
+ film->set_name("Hello");
+
+ BOOST_CHECK_EQUAL(film->isdcf_name(false), "Hello_TST-1_F_XX-DE_MOS_2K_20230118_SMPTE_OV");
+}