Read UTF8 string lengths correctly when checking closed captions (part of #1446).
[dcpomatic.git] / src / lib / text_content.h
index cca678ad22fb1de69a5c186f7608b5941931c4d4..83860dff54fb6f733356a30de07833b282a7d336 100644 (file)
 
 */
 
-#ifndef DCPOMATIC_SUBTITLE_CONTENT_H
-#define DCPOMATIC_SUBTITLE_CONTENT_H
+#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/types.h>
 #include <boost/signals2.hpp>
@@ -47,6 +48,7 @@ public:
        static int const FADE_OUT;
        static int const OUTLINE_WIDTH;
        static int const TYPE;
+       static int const DCP_TRACK;
 };
 
 /** @class TextContent
@@ -58,7 +60,7 @@ public:
 class TextContent : public ContentPart
 {
 public:
-       explicit TextContent (Content* parent);
+       TextContent (Content* parent, TextType type, TextType original_type);
        TextContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
 
        void as_xml (xmlpp::Node *) const;
@@ -87,6 +89,8 @@ public:
        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);
@@ -168,7 +172,17 @@ public:
                return _type;
        }
 
-       static boost::shared_ptr<TextContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
+       TextType original_type () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               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:
        /** subtitle language (e.g. "German") or empty if it is not known */
@@ -206,7 +220,14 @@ private:
        boost::optional<ContentTime> _fade_in;
        boost::optional<ContentTime> _fade_out;
        int _outline_width;
+       /** what these captions will be used for in the output DCP (not necessarily what
+        *  they were originally).
+        */
        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