Stop crashing when running the hints check on films with silent/black gaps.
[dcpomatic.git] / src / lib / text_content.h
index 0327d4a97bbbad9ab7beac32be84a2af65486314..5eda8764ffeaa91ea5c20758fb46c2cad71e1844 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 #define DCPOMATIC_CAPTION_CONTENT_H
 
 #include "content_part.h"
+#include "dcp_text_track.h"
 #include <libcxml/cxml.h>
 #include <dcp/types.h>
 #include <boost/signals2.hpp>
 
-class Font;
+namespace dcpomatic {
+       class Font;
+}
 
 class TextContentProperty
 {
@@ -37,7 +40,6 @@ public:
        static int const Y_SCALE;
        static int const USE;
        static int const BURN;
-       static int const NAME;
        static int const LANGUAGE;
        static int const FONTS;
        static int const COLOUR;
@@ -48,6 +50,7 @@ public:
        static int const FADE_OUT;
        static int const OUTLINE_WIDTH;
        static int const TYPE;
+       static int const DCP_TRACK;
 };
 
 /** @class TextContent
@@ -66,7 +69,7 @@ public:
        std::string identifier () const;
        void take_settings_from (boost::shared_ptr<const TextContent> c);
 
-       void add_font (boost::shared_ptr<Font> font);
+       void add_font (boost::shared_ptr<dcpomatic::Font> font);
 
        void set_use (bool);
        void set_burn (bool);
@@ -74,7 +77,6 @@ public:
        void set_y_offset (double);
        void set_x_scale (double);
        void set_y_scale (double);
-       void set_name (std::string name);
        void set_language (std::string language);
        void set_colour (dcp::Colour);
        void unset_colour ();
@@ -83,12 +85,14 @@ public:
        void set_effect_colour (dcp::Colour);
        void unset_effect_colour ();
        void set_line_spacing (double s);
-       void set_fade_in (ContentTime);
+       void set_fade_in (dcpomatic::ContentTime);
        void unset_fade_in ();
-       void set_fade_out (ContentTime);
+       void set_fade_out (dcpomatic::ContentTime);
        void set_outline_width (int);
        void unset_fade_out ();
        void set_type (TextType type);
+       void set_dcp_track (DCPTextTrack track);
+       void unset_dcp_track ();
 
        bool use () const {
                boost::mutex::scoped_lock lm (_mutex);
@@ -120,16 +124,11 @@ public:
                return _y_scale;
        }
 
-       std::list<boost::shared_ptr<Font> > fonts () const {
+       std::list<boost::shared_ptr<dcpomatic::Font> > fonts () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _fonts;
        }
 
-       std::string name () const {
-               boost::mutex::scoped_lock lm (_mutex);
-               return _name;
-       }
-
        std::string language () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _language;
@@ -155,12 +154,12 @@ public:
                return _line_spacing;
        }
 
-       boost::optional<ContentTime> fade_in () const {
+       boost::optional<dcpomatic::ContentTime> fade_in () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _fade_in;
        }
 
-       boost::optional<ContentTime> fade_out () const {
+       boost::optional<dcpomatic::ContentTime> fade_out () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _fade_out;
        }
@@ -180,11 +179,14 @@ public:
                return _original_type;
        }
 
+       boost::optional<DCPTextTrack> dcp_track () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _dcp_track;
+       }
+
        static std::list<boost::shared_ptr<TextContent> > from_xml (Content* parent, cxml::ConstNodePtr, int version);
 
 protected:
-       /** Name (annotation text) for this subtitle */
-       std::string _name;
        /** subtitle language (e.g. "German") or empty if it is not known */
        std::string _language;
 
@@ -211,14 +213,14 @@ private:
        double _x_scale;
        /** y scale factor to apply to subtitles */
        double _y_scale;
-       std::list<boost::shared_ptr<Font> > _fonts;
+       std::list<boost::shared_ptr<dcpomatic::Font> > _fonts;
        boost::optional<dcp::Colour> _colour;
        boost::optional<dcp::Effect> _effect;
        boost::optional<dcp::Colour> _effect_colour;
        /** scaling factor for line spacing; 1 is "standard", < 1 is closer together, > 1 is further apart */
        double _line_spacing;
-       boost::optional<ContentTime> _fade_in;
-       boost::optional<ContentTime> _fade_out;
+       boost::optional<dcpomatic::ContentTime> _fade_in;
+       boost::optional<dcpomatic::ContentTime> _fade_out;
        int _outline_width;
        /** what these captions will be used for in the output DCP (not necessarily what
         *  they were originally).
@@ -226,6 +228,8 @@ private:
        TextType _type;
        /** the original type of these captions in their content */
        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;
 };
 
 #endif