Subtitle language test updates.
authorCarl Hetherington <cth@carlh.net>
Sat, 21 Nov 2020 01:31:12 +0000 (02:31 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 21 Nov 2020 21:12:37 +0000 (22:12 +0100)
src/lib/reel_writer.cc
src/lib/subtitle_encoder.cc
test/closed_caption_test.cc
test/data

index 16b34d7..3c516f5 100644 (file)
@@ -608,7 +608,9 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
                        );
                if (a) {
                        a->set_annotation_text (i->first.name);
-                       a->set_language (dcp::LanguageTag(i->first.language));
+                       if (!i->first.language.empty()) {
+                               a->set_language (dcp::LanguageTag(i->first.language));
+                       }
                }
        }
 
@@ -697,7 +699,7 @@ ReelWriter::write (PlayerText subs, TextType type, optional<DCPTextTrack> track,
                        s->set_movie_title (_film->name ());
                        if (type == TEXT_OPEN_SUBTITLE) {
                                s->set_language (lang.empty() ? "Unknown" : lang.front().to_string());
-                       } else {
+                       } else if (!track->language.empty()) {
                                s->set_language (track->language);
                        }
                        s->set_reel_number (raw_convert<string> (_reel_index + 1));
index 61c4dc3..1ef7fcd 100644 (file)
@@ -134,7 +134,9 @@ SubtitleEncoder::text (PlayerText subs, TextType type, optional<DCPTextTrack> tr
                if (_film->interop ()) {
                        shared_ptr<dcp::InteropSubtitleAsset> s (new dcp::InteropSubtitleAsset());
                        s->set_movie_title (_film->name());
-                       s->set_language (lang.empty() ? "Unknown" : lang.front().to_string());
+                       if (!lang.empty()) {
+                               s->set_language (lang.front().to_string());
+                       }
                        s->set_reel_number (raw_convert<string>(_reel_index + 1));
                        _assets[_reel_index].first = s;
                } else {
@@ -142,7 +144,7 @@ SubtitleEncoder::text (PlayerText subs, TextType type, optional<DCPTextTrack> tr
                        s->set_content_title_text (_film->name());
                        if (!lang.empty()) {
                                s->set_language (lang.front());
-                       } else {
+                       } else if (!track->language.empty()) {
                                s->set_language (dcp::LanguageTag(track->language));
                        }
                        s->set_edit_rate (dcp::Fraction (_film->video_frame_rate(), 1));
index 283ce6b..86666a4 100644 (file)
@@ -69,11 +69,11 @@ BOOST_AUTO_TEST_CASE (closed_caption_test2)
        BOOST_REQUIRE (!wait_for_jobs ());
 
        content1->only_text()->set_type (TEXT_CLOSED_CAPTION);
-       content1->only_text()->set_dcp_track (DCPTextTrack("First track", "French"));
+       content1->only_text()->set_dcp_track (DCPTextTrack("First track", "fr-FR"));
        content2->only_text()->set_type (TEXT_CLOSED_CAPTION);
-       content2->only_text()->set_dcp_track (DCPTextTrack("Second track", "German"));
+       content2->only_text()->set_dcp_track (DCPTextTrack("Second track", "de-DE"));
        content3->only_text()->set_type (TEXT_CLOSED_CAPTION);
-       content3->only_text()->set_dcp_track (DCPTextTrack("Third track", "Italian"));
+       content3->only_text()->set_dcp_track (DCPTextTrack("Third track", "it-IT"));
 
        film->make_dcp ();
        BOOST_REQUIRE (!wait_for_jobs ());
@@ -89,13 +89,13 @@ BOOST_AUTO_TEST_CASE (closed_caption_test2)
        list<shared_ptr<dcp::ReelClosedCaptionAsset> >::const_iterator i = ccaps.begin ();
        BOOST_CHECK_EQUAL ((*i)->annotation_text(), "First track");
        BOOST_REQUIRE (static_cast<bool>((*i)->language()));
-       BOOST_CHECK_EQUAL ((*i)->language().get(), "French");
+       BOOST_CHECK_EQUAL ((*i)->language().get(), "fr-FR");
        ++i;
        BOOST_CHECK_EQUAL ((*i)->annotation_text(), "Second track");
        BOOST_REQUIRE (static_cast<bool>((*i)->language()));
-       BOOST_CHECK_EQUAL ((*i)->language().get(), "German");
+       BOOST_CHECK_EQUAL ((*i)->language().get(), "de-DE");
        ++i;
        BOOST_CHECK_EQUAL ((*i)->annotation_text(), "Third track");
        BOOST_REQUIRE (static_cast<bool>((*i)->language()));
-       BOOST_CHECK_EQUAL ((*i)->language().get(), "Italian");
+       BOOST_CHECK_EQUAL ((*i)->language().get(), "it-IT");
 }
index 26e2bde..d2e0ea4 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit 26e2bdec46705b5a0b5967ddc52af38d26972781
+Subproject commit d2e0ea48f4cb2d9571d450aabd78c3d2699ecb7d