{}
};
+class MetadataError : public std::runtime_error
+{
+public:
+ explicit MetadataError (std::string s)
+ : std::runtime_error (s)
+ {}
+};
+
class OldFormatError : public std::runtime_error
{
public:
int const TextContentProperty::FADE_IN = 512;
int const TextContentProperty::FADE_OUT = 513;
int const TextContentProperty::OUTLINE_WIDTH = 514;
+int const TextContentProperty::TYPE = 515;
TextContent::TextContent (Content* parent)
: ContentPart (parent)
, _y_scale (1)
, _line_spacing (1)
, _outline_width (2)
+ , _type (TEXT_SUBTITLE)
{
}
, _y_scale (1)
, _line_spacing (node->optional_number_child<double>("LineSpacing").get_value_or (1))
, _outline_width (node->optional_number_child<int>("OutlineWidth").get_value_or (2))
+ , _type (TEXT_SUBTITLE)
{
if (version >= 32) {
_use = node->bool_child ("UseSubtitles");
}
connect_to_fonts ();
+
+ _type = string_to_text_type (node->optional_string_child("TextType").get_value_or("subtitle"));
}
TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)
for (list<shared_ptr<Font> >::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
(*i)->as_xml (root->add_child("Font"));
}
+
+ root->add_child("TextType", text_type_to_string(_type));
}
string
maybe_set (_fade_out, optional<ContentTime>(), TextContentProperty::FADE_OUT);
}
+void
+TextContent::set_type (TextType type)
+{
+ maybe_set (_type, type, TextContentProperty::TYPE);
+}
+
void
TextContent::set_outline_width (int w)
{
static int const FADE_IN;
static int const FADE_OUT;
static int const OUTLINE_WIDTH;
+ static int const TYPE;
};
/** @class TextContent
void set_fade_out (ContentTime);
void set_outline_width (int);
void unset_fade_out ();
+ void set_type (TextType type);
bool use () const {
boost::mutex::scoped_lock lm (_mutex);
return _outline_width;
}
+ TextType type () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _type;
+ }
+
static boost::shared_ptr<TextContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
protected:
boost::optional<ContentTime> _fade_in;
boost::optional<ContentTime> _fade_out;
int _outline_width;
+ TextType _type;
};
#endif
*/
#include "types.h"
+#include "compose.hpp"
#include "dcpomatic_assert.h"
#include <dcp/raw_convert.h>
#include <libxml++/libxml++.h>
node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom));
}
+TextType
+string_to_text_type (string s)
+{
+ if (s == "subtitle") {
+ return TEXT_SUBTITLE;
+ } else if (s == "ccap") {
+ return TEXT_CLOSED_CAPTION;
+ } else {
+ throw MetadataError (String::compose ("Unknown text type %1", s));
+ }
+}
+
+string
+text_type_to_string (TextType t)
+{
+ switch (t) {
+ case TEXT_SUBTITLE:
+ return "subtitle";
+ case TEXT_CLOSED_CAPTION:
+ return "ccap";
+ default:
+ DCPOMATIC_ASSERT (false);
+ }
+}
+
string
video_frame_type_to_string (VideoFrameType t)
{
REELTYPE_BY_LENGTH
};
+enum TextType
+{
+ TEXT_SUBTITLE,
+ TEXT_CLOSED_CAPTION
+};
+
+extern std::string text_type_to_string (TextType t);
+extern TextType string_to_text_type (std::string s);
+
/** @struct Crop
* @brief A description of the crop of an image or video.
*/