Remove subtitle language from text content.
authorCarl Hetherington <cth@carlh.net>
Wed, 18 Nov 2020 00:31:30 +0000 (01:31 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 20 Nov 2020 22:47:03 +0000 (23:47 +0100)
src/lib/dcp_subtitle_content.cc
src/lib/text_content.cc
src/lib/text_content.h
src/lib/writer.cc
src/wx/text_panel.cc
src/wx/text_panel.h
test/isdcf_name_test.cc

index f8d12d4e4a4c1130c932846aca7bbb40d0f6a591..43936314b5c41238ad17fafcb37d7ff4a8b8adc6 100644 (file)
@@ -69,12 +69,6 @@ DCPSubtitleContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
        /* Default to turning these subtitles on */
        only_text()->set_use (true);
 
-       if (iop) {
-               only_text()->set_language (iop->language ());
-       } else if (smpte) {
-               only_text()->set_language (smpte->language().get_value_or (""));
-       }
-
        _length = ContentTime::from_seconds (sc->latest_subtitle_out().as_seconds ());
 
        sc->fix_empty_font_ids ();
index 901d38647c05bdd20504c8ce6e69e893c56fd1ad..ecd28d1a0ba59ec8420f87537495dee732fb8d03 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -47,17 +47,16 @@ int const TextContentProperty::X_SCALE = 502;
 int const TextContentProperty::Y_SCALE = 503;
 int const TextContentProperty::USE = 504;
 int const TextContentProperty::BURN = 505;
-int const TextContentProperty::LANGUAGE = 506;
-int const TextContentProperty::FONTS = 507;
-int const TextContentProperty::COLOUR = 508;
-int const TextContentProperty::EFFECT = 509;
-int const TextContentProperty::EFFECT_COLOUR = 510;
-int const TextContentProperty::LINE_SPACING = 511;
-int const TextContentProperty::FADE_IN = 512;
-int const TextContentProperty::FADE_OUT = 513;
-int const TextContentProperty::OUTLINE_WIDTH = 514;
-int const TextContentProperty::TYPE = 515;
-int const TextContentProperty::DCP_TRACK = 516;
+int const TextContentProperty::FONTS = 506;
+int const TextContentProperty::COLOUR = 507;
+int const TextContentProperty::EFFECT = 508;
+int const TextContentProperty::EFFECT_COLOUR = 509;
+int const TextContentProperty::LINE_SPACING = 510;
+int const TextContentProperty::FADE_IN = 511;
+int const TextContentProperty::FADE_OUT = 512;
+int const TextContentProperty::OUTLINE_WIDTH = 513;
+int const TextContentProperty::TYPE = 514;
+int const TextContentProperty::DCP_TRACK = 515;
 
 TextContent::TextContent (Content* parent, TextType type, TextType original_type)
        : ContentPart (parent)
@@ -215,12 +214,6 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
                _fade_out = ContentTime (*fo);
        }
 
-       if (version >= 37) {
-               _language = node->optional_string_child ("Language").get_value_or ("");
-       } else {
-               _language = node->optional_string_child ("SubtitleLanguage").get_value_or ("");
-       }
-
        list<cxml::NodePtr> fonts = node->node_children ("Font");
        for (list<cxml::NodePtr>::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
                _fonts.push_back (shared_ptr<Font> (new Font (*i)));
@@ -316,7 +309,6 @@ TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)
        _y_offset = ref->y_offset ();
        _x_scale = ref->x_scale ();
        _y_scale = ref->y_scale ();
-       _language = ref->language ();
        _fonts = ref_fonts;
        _line_spacing = ref->line_spacing ();
        _fade_in = ref->fade_in ();
@@ -343,7 +335,6 @@ TextContent::as_xml (xmlpp::Node* root) const
        text->add_child("YOffset")->add_child_text (raw_convert<string> (_y_offset));
        text->add_child("XScale")->add_child_text (raw_convert<string> (_x_scale));
        text->add_child("YScale")->add_child_text (raw_convert<string> (_y_scale));
-       text->add_child("Language")->add_child_text (_language);
        if (_colour) {
                text->add_child("Red")->add_child_text (raw_convert<string> (_colour->r));
                text->add_child("Green")->add_child_text (raw_convert<string> (_colour->g));
@@ -410,9 +401,7 @@ TextContent::identifier () const
                s += "_" + f->file().get_value_or("Default").string();
        }
 
-       /* The DCP track and language are for metadata only, and don't affect
-          how this content looks.
-       */
+       /* The DCP track is for metadata only, and doesn't affect how this content looks */
 
        return s;
 }
@@ -517,12 +506,6 @@ TextContent::set_y_scale (double s)
        maybe_set (_y_scale, s, TextContentProperty::Y_SCALE);
 }
 
-void
-TextContent::set_language (string language)
-{
-       maybe_set (_language, language, TextContentProperty::LANGUAGE);
-}
-
 void
 TextContent::set_line_spacing (double s)
 {
index 5eda8764ffeaa91ea5c20758fb46c2cad71e1844..1c7eef19a031ff05b0e07d74bd9a8e656dd7af1c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -40,7 +40,6 @@ public:
        static int const Y_SCALE;
        static int const USE;
        static int const BURN;
-       static int const LANGUAGE;
        static int const FONTS;
        static int const COLOUR;
        static int const EFFECT;
@@ -77,7 +76,6 @@ public:
        void set_y_offset (double);
        void set_x_scale (double);
        void set_y_scale (double);
-       void set_language (std::string language);
        void set_colour (dcp::Colour);
        void unset_colour ();
        void set_effect (dcp::Effect);
@@ -129,11 +127,6 @@ public:
                return _fonts;
        }
 
-       std::string language () const {
-               boost::mutex::scoped_lock lm (_mutex);
-               return _language;
-       }
-
        boost::optional<dcp::Colour> colour () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _colour;
@@ -186,10 +179,6 @@ public:
 
        static std::list<boost::shared_ptr<TextContent> > from_xml (Content* parent, cxml::ConstNodePtr, int version);
 
-protected:
-       /** subtitle language (e.g. "German") or empty if it is not known */
-       std::string _language;
-
 private:
        friend struct ffmpeg_pts_offset_test;
 
index 346cbb0c26cdbdd8ee03eda3c3683de58f1971cb..79e5ad73b4efa276d4ea75925d412cb7406e78a9 100644 (file)
@@ -660,15 +660,12 @@ Writer::write_cover_sheet ()
        boost::algorithm::replace_all (text, "$CONTAINER", _film->container()->container_nickname());
        boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", _film->isdcf_metadata().audio_language);
 
-       optional<string> subtitle_language;
-       BOOST_FOREACH (shared_ptr<Content> i, _film->content()) {
-               BOOST_FOREACH (shared_ptr<TextContent> j, i->text) {
-                       if (j->type() == TEXT_OPEN_SUBTITLE && j->use()) {
-                               subtitle_language = j->language ();
-                       }
-               }
+       vector<dcp::LanguageTag> subtitle_languages = _film->subtitle_languages();
+       if (subtitle_languages.empty()) {
+               boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", "None");
+       } else {
+               boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_languages.front().description());
        }
-       boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_language.get_value_or("None"));
 
        boost::uintmax_t size = 0;
        for (
index e7f5741bb71fbe39936861bb0fae3682a4ea5065..f29aea6ff165c50cc26cffee54d2de6de8388326 100644 (file)
@@ -60,8 +60,6 @@ TextPanel::TextPanel (ContentPanel* p, TextType t)
        , _outline_subtitles (0)
        , _dcp_track_label (0)
        , _dcp_track (0)
-       , _language_label (0)
-       , _language (0)
        , _text_view (0)
        , _fonts_dialog (0)
        , _original_type (t)
@@ -157,16 +155,6 @@ TextPanel::setup_visibility ()
                        _dcp_track->Destroy ();
                        _dcp_track = 0;
                }
-               if (!_language_label) {
-                       _language_label = create_label (this, _("Language"), true);
-                       add_label_to_sizer (_grid, _language_label, true, wxGBPosition(_language_row, 0));
-               }
-               if (!_language) {
-                       _language = new wxTextCtrl (this, wxID_ANY);
-                       _language->Bind (wxEVT_TEXT, boost::bind(&TextPanel::language_changed, this));
-                       _grid->Add (_language, wxGBPosition(_language_row, 1), wxDefaultSpan, wxEXPAND);
-                       film_content_changed (TextContentProperty::LANGUAGE);
-               }
                if (!_outline_subtitles) {
                        _outline_subtitles = new CheckBox (this, _("Show subtitle area"));
                        _outline_subtitles->Bind (wxEVT_CHECKBOX, boost::bind (&TextPanel::outline_subtitles_changed, this));
@@ -175,22 +163,14 @@ TextPanel::setup_visibility ()
 
                break;
        case TEXT_CLOSED_CAPTION:
-               if (_language_label) {
-                       _language_label->Destroy ();
-                       _language_label = 0;
-               }
-               if (_language) {
-                       _language->Destroy ();
-                       _language = 0;
-               }
                if (!_dcp_track_label) {
                        _dcp_track_label = create_label (this, _("CCAP track"), true);
-                       add_label_to_sizer (_grid, _dcp_track_label, true, wxGBPosition(_language_row, 0));
+                       add_label_to_sizer (_grid, _dcp_track_label, true, wxGBPosition(_ccap_track_row, 0));
                }
                if (!_dcp_track) {
                        _dcp_track = new wxChoice (this, wxID_ANY);
                        _dcp_track->Bind (wxEVT_CHOICE, boost::bind(&TextPanel::dcp_track_changed, this));
-                       _grid->Add (_dcp_track, wxGBPosition(_language_row, 1), wxDefaultSpan, wxEXPAND);
+                       _grid->Add (_dcp_track, wxGBPosition(_ccap_track_row, 1), wxDefaultSpan, wxEXPAND);
                        update_dcp_tracks ();
                        film_content_changed (TextContentProperty::DCP_TRACK);
                }
@@ -278,7 +258,7 @@ TextPanel::add_to_grid ()
                ++r;
        }
 
-       _language_row = r;
+       _ccap_track_row = r;
        ++r;
 
        add_label_to_sizer (_grid, _stream_label, true, wxGBPosition (r, 0));
@@ -468,10 +448,6 @@ TextPanel::film_content_changed (int property)
        } else if (property == TextContentProperty::LINE_SPACING) {
                checked_set (_line_spacing, text ? lrint (text->line_spacing() * 100) : 100);
                clear_outline_subtitles ();
-       } else if (property == TextContentProperty::LANGUAGE) {
-               if (_language) {
-                       checked_set (_language, text ? text->language() : "");
-               }
        } else if (property == TextContentProperty::DCP_TRACK) {
                if (_dcp_track) {
                        update_dcp_track_selection ();
@@ -683,15 +659,6 @@ TextPanel::line_spacing_changed ()
        }
 }
 
-void
-TextPanel::language_changed ()
-{
-       DCPOMATIC_ASSERT (_language);
-       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_text ()) {
-               i->text_of_original_type(_original_type)->set_language (wx_to_std (_language->GetValue()));
-       }
-}
-
 void
 TextPanel::content_selection_changed ()
 {
@@ -703,7 +670,6 @@ TextPanel::content_selection_changed ()
        film_content_changed (TextContentProperty::X_SCALE);
        film_content_changed (TextContentProperty::Y_SCALE);
        film_content_changed (TextContentProperty::LINE_SPACING);
-       film_content_changed (TextContentProperty::LANGUAGE);
        film_content_changed (TextContentProperty::FONTS);
        film_content_changed (TextContentProperty::TYPE);
        film_content_changed (TextContentProperty::DCP_TRACK);
index 7a7b7b504b3b95d41d3bb3621254adf9159064ce..cd0890e3d24a0a53fdaef02f436097d643f99472 100644 (file)
@@ -45,7 +45,6 @@ private:
        void y_scale_changed ();
        void line_spacing_changed ();
        void dcp_track_changed ();
-       void language_changed ();
        void stream_changed ();
        void text_view_clicked ();
        void fonts_dialog_clicked ();
@@ -90,8 +89,6 @@ private:
        wxSpinCtrl* _line_spacing;
        wxStaticText* _dcp_track_label;
        wxChoice* _dcp_track;
-       wxStaticText* _language_label;
-       wxTextCtrl* _language;
        wxStaticText* _stream_label;
        wxChoice* _stream;
        wxButton* _text_view_button;
@@ -102,7 +99,7 @@ private:
        TextType _original_type;
 
        int _outline_subtitles_row;
-       int _language_row;
+       int _ccap_track_row;
 
        boost::weak_ptr<Content> _analysis_content;
        boost::signals2::scoped_connection _analysis_finished_connection;
index b88afb0a052329d43cf2bb27c2bb7e9932838c92..29bcff6ed26080ed9ef9d061f3e12136d346393f 100644 (file)
@@ -69,9 +69,9 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test)
        film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4);
        film->set_audio_channels (1);
        film->set_resolution (RESOLUTION_4K);
+       film->set_subtitle_language (dcp::LanguageTag("fr-FR"));
        shared_ptr<Content> text = content_factory("test/data/subrip.srt").front();
        BOOST_REQUIRE_EQUAL (text->text.size(), 1U);
-       text->text.front()->set_language ("fr");
        text->text.front()->set_burn (true);
        film->examine_and_add_content (text);
        BOOST_REQUIRE (!wait_for_jobs());