Use XX as an audio language when there is no specified audio language (#1939).
authorCarl Hetherington <cth@carlh.net>
Thu, 25 Mar 2021 21:58:50 +0000 (22:58 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 25 Mar 2021 21:58:50 +0000 (22:58 +0100)
Previously we would omit the audio and subtitle language parts of the
DCI name if there was no specified audio language.  Sadly if we do
do that EasyDCP player 4.0.1 reports a warning (whose details you
can't see on the demo version).

src/lib/film.cc
test/isdcf_name_test.cc

index 321a932d17751f9fb6b75210195fcf73d35bca30..46074e2ada19632b09e84c30dd2fe822d5f48930 100644 (file)
@@ -904,41 +904,41 @@ Film::isdcf_name (bool if_created_now) const
                }
        }
 
-       if (!dm.audio_language.empty ()) {
-               d += "_" + dm.audio_language;
+       auto const audio_language = dm.audio_language.empty() ? "XX" : dm.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.
-               */
+       d += "_" + audio_language;
 
-               auto burnt_in = true;
-               auto ccap = false;
-               for (auto i: content()) {
-                       for (auto j: i->text) {
-                               if (j->type() == TextType::OPEN_SUBTITLE && j->use() && !j->burn()) {
-                                       burnt_in = false;
-                               } else if (j->type() == TextType::CLOSED_CAPTION && j->use()) {
-                                       ccap = true;
-                               }
-                       }
-               }
+       /* 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.
+       */
 
-               if (!_subtitle_languages.empty()) {
-                       auto lang = _subtitle_languages.front().language().get_value_or("en").subtag();
-                       if (burnt_in) {
-                               transform (lang.begin(), lang.end(), lang.begin(), ::tolower);
-                       } else {
-                               transform (lang.begin(), lang.end(), lang.begin(), ::toupper);
+       auto burnt_in = true;
+       auto ccap = false;
+       for (auto i: content()) {
+               for (auto j: i->text) {
+                       if (j->type() == TextType::OPEN_SUBTITLE && j->use() && !j->burn()) {
+                               burnt_in = false;
+                       } else if (j->type() == TextType::CLOSED_CAPTION && j->use()) {
+                               ccap = true;
                        }
+               }
+       }
 
-                       d += "-" + lang;
-                       if (ccap) {
-                               d += "-CCAP";
-                       }
+       if (!_subtitle_languages.empty()) {
+               auto lang = _subtitle_languages.front().language().get_value_or("en").subtag();
+               if (burnt_in) {
+                       transform (lang.begin(), lang.end(), lang.begin(), ::tolower);
                } else {
-                       /* No subtitles */
-                       d += "-XX";
+                       transform (lang.begin(), lang.end(), lang.begin(), ::toupper);
                }
+
+               d += "-" + lang;
+               if (ccap) {
+                       d += "-CCAP";
+               }
+       } else {
+               /* No subtitles */
+               d += "-XX";
        }
 
        if (!dm.territory.empty ()) {
index dc2263206963367ea389d163ffbc8fb5d9202912..dad2ba7d971783d781c09b59b3bbedf2264ea10e 100644 (file)
@@ -42,7 +42,7 @@ using std::shared_ptr;
 
 BOOST_AUTO_TEST_CASE (isdcf_name_test)
 {
-       shared_ptr<Film> film = new_test_film ("isdcf_name_test");
+       auto film = new_test_film ("isdcf_name_test");
 
        /* A basic test */
 
@@ -61,6 +61,11 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test)
        film->set_interop (true);
        BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_EN-XX_UK-PG_MOS_2K_ST_20140704_FA_IOP_OV");
 
+       /* Check that specifying no audio language writes XX */
+       m.audio_language = "";
+       film->set_isdcf_metadata (m);
+       BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilm_FTR-1_F_XX-XX_UK-PG_MOS_2K_ST_20140704_FA_IOP_OV");
+
        /* Test a long name and some different data */
 
        film->set_name ("My Nice Film With A Very Long Name");
@@ -215,3 +220,4 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test)
        sound->audio->set_mapping (mapping);
        BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_71-HI-VI_4K_DI_20140704_PP_SMPTE_OV");
 }
+