Add some missing locking.
[dcpomatic.git] / src / lib / text_content.h
index e566d05524721fc952f4cbaeb4fd4806d8c4df95..7c060cd482afb76fa3bdd152bb8dd178c4d2350f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
+
 #ifndef DCPOMATIC_CAPTION_CONTENT_H
 #define DCPOMATIC_CAPTION_CONTENT_H
 
+
 #include "content_part.h"
 #include "dcp_text_track.h"
 #include <libcxml/cxml.h>
+#include <dcp/language_tag.h>
 #include <dcp/types.h>
 #include <boost/signals2.hpp>
 
+
 namespace dcpomatic {
        class Font;
 }
@@ -50,8 +54,11 @@ public:
        static int const OUTLINE_WIDTH;
        static int const TYPE;
        static int const DCP_TRACK;
+       static int const LANGUAGE;
+       static int const LANGUAGE_IS_ADDITIONAL;
 };
 
+
 /** @class TextContent
  *  @brief Description of how some text content should be presented.
  *
@@ -62,14 +69,16 @@ class TextContent : public ContentPart
 {
 public:
        TextContent (Content* parent, TextType type, TextType original_type);
-       TextContent (Content* parent, std::vector<std::shared_ptr<Content> >);
-       TextContent (Content* parent, cxml::ConstNodePtr, int version);
+       TextContent (Content* parent, std::vector<std::shared_ptr<Content>>);
+       TextContent (Content* parent, cxml::ConstNodePtr, int version, std::list<std::string>& notes);
 
        void as_xml (xmlpp::Node *) const;
        std::string identifier () const;
        void take_settings_from (std::shared_ptr<const TextContent> c);
 
+       void clear_fonts ();
        void add_font (std::shared_ptr<dcpomatic::Font> font);
+       std::shared_ptr<dcpomatic::Font> get_font(std::string id) const;
 
        void set_use (bool);
        void set_burn (bool);
@@ -92,6 +101,8 @@ public:
        void set_type (TextType type);
        void set_dcp_track (DCPTextTrack track);
        void unset_dcp_track ();
+       void set_language (boost::optional<dcp::LanguageTag> language = boost::none);
+       void set_language_is_additional (bool additional);
 
        bool use () const {
                boost::mutex::scoped_lock lm (_mutex);
@@ -123,7 +134,7 @@ public:
                return _y_scale;
        }
 
-       std::list<std::shared_ptr<dcpomatic::Font> > fonts () const {
+       std::list<std::shared_ptr<dcpomatic::Font>> fonts () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _fonts;
        }
@@ -178,13 +189,24 @@ public:
                return _dcp_track;
        }
 
-       static std::list<std::shared_ptr<TextContent> > from_xml (Content* parent, cxml::ConstNodePtr, int version);
+       boost::optional<dcp::LanguageTag> language () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _language;
+       }
+
+       bool language_is_additional () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _language_is_additional;
+       }
+
+       static std::list<std::shared_ptr<TextContent>> from_xml (Content* parent, cxml::ConstNodePtr, int version, std::list<std::string>& notes);
 
 private:
        friend struct ffmpeg_pts_offset_test;
 
        void font_changed ();
        void connect_to_fonts ();
+       std::shared_ptr<dcpomatic::Font> get_font_unlocked(std::string id) const;
 
        std::list<boost::signals2::connection> _font_connections;
 
@@ -202,7 +224,7 @@ private:
        double _x_scale;
        /** y scale factor to apply to subtitles */
        double _y_scale;
-       std::list<std::shared_ptr<dcpomatic::Font> > _fonts;
+       std::list<std::shared_ptr<dcpomatic::Font>> _fonts;
        boost::optional<dcp::Colour> _colour;
        boost::optional<dcp::Effect> _effect;
        boost::optional<dcp::Colour> _effect_colour;
@@ -219,6 +241,8 @@ private:
        TextType _original_type;
        /** the track of closed captions that this content should be put in, or empty to put in the default (only) track */
        boost::optional<DCPTextTrack> _dcp_track;
+       boost::optional<dcp::LanguageTag> _language;
+       bool _language_is_additional = false;
 };
 
 #endif