Somewhat fix inclusion of CCAP language in ISDCF name (#2610).
authorCarl Hetherington <cth@carlh.net>
Tue, 12 Sep 2023 21:14:35 +0000 (23:14 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 12 Sep 2023 21:14:35 +0000 (23:14 +0200)
src/lib/film.cc
src/lib/film.h
test/isdcf_name_test.cc

index dabef62bb24b230a46aeea506d06a29b14fb166b..803dbb73204ad7a3b223ca183273d33482066d30 100644 (file)
@@ -969,23 +969,17 @@ Film::isdcf_name (bool if_created_now) const
 
        isdcf_name += "_" + to_upper (audio_language);
 
-       /* 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.
-       */
-
        auto burnt_in = true;
-       auto ccap = false;
        for (auto i: content_list) {
                for (auto text: i->text) {
                        if (text->type() == TextType::OPEN_SUBTITLE && text->use() && !text->burn()) {
                                burnt_in = false;
-                       } else if (text->type() == TextType::CLOSED_CAPTION && text->use()) {
-                               ccap = true;
                        }
                }
        }
 
        auto sub_langs = subtitle_languages();
+       auto ccap_langs = closed_caption_languages();
        if (sub_langs.first && sub_langs.first->language()) {
                auto lang = entry_for_language(*sub_langs.first);
                if (burnt_in) {
@@ -995,15 +989,13 @@ Film::isdcf_name (bool if_created_now) const
                }
 
                isdcf_name += "-" + lang;
+       } else if (!ccap_langs.empty()) {
+               isdcf_name += "-" + to_upper(entry_for_language(ccap_langs[0])) + "-CCAP";
        } else {
                /* No subtitles */
                isdcf_name += "-XX";
        }
 
-       if (ccap) {
-               isdcf_name += "-CCAP";
-       }
-
        if (_release_territory) {
                auto territory = _release_territory->subtag();
                isdcf_name += "_" + to_upper (territory);
index 5c230614decc9fe657afd52bccc13d2b20ccb061..8aeae8e4ed37ed97b3022e188d518f1027ed3f4b 100644 (file)
@@ -74,6 +74,7 @@ class Job;
 class Film;
 struct isdcf_name_test;
 struct isdcf_name_with_atmos;
+struct isdcf_name_with_ccap;
 struct recover_test_2d_encrypted;
 struct atmos_encrypted_passthrough_test;
 
@@ -447,6 +448,7 @@ private:
 
        friend struct ::isdcf_name_test;
        friend struct ::isdcf_name_with_atmos;
+       friend struct ::isdcf_name_with_ccap;
        friend struct ::recover_test_2d_encrypted;
        friend struct ::atmos_encrypted_passthrough_test;
        template <class, class> friend class ChangeSignalDespatcher;
index a359e3efab1cb90c775e736f829218f36a14d1e9..56686d2ac8a4c1c0e69e996dcce975b9a18f3a8c 100644 (file)
@@ -249,3 +249,17 @@ BOOST_AUTO_TEST_CASE(isdcf_name_with_atmos)
        BOOST_CHECK_EQUAL(film->isdcf_name(false), "Hello_TST-1_F_XX-XX_MOS-IAB_2K_20230118_SMPTE_OV");
 }
 
+
+BOOST_AUTO_TEST_CASE(isdcf_name_with_ccap)
+{
+       auto content = content_factory("test/data/short.srt")[0];
+       auto film = new_test_film2("isdcf_name_with_ccap", { content });
+       content->text[0]->set_use(true);
+       content->text[0]->set_type(TextType::CLOSED_CAPTION);
+       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-CCAP_MOS_2K_20230118_SMPTE_OV");
+}
+