Add _sign_language property to Content.
[dcpomatic.git] / src / lib / video_content.cc
index 9abb2b39483e2529b1896eee30e37c6a21aa198a..2472edd0924043a89ba22c2a5a6324e4d7a385cf 100644 (file)
@@ -52,6 +52,7 @@ int const VideoContentProperty::RANGE             = 7;
 int const VideoContentProperty::CUSTOM_RATIO      = 8;
 int const VideoContentProperty::CUSTOM_SIZE       = 9;
 int const VideoContentProperty::BURNT_SUBTITLE_LANGUAGE = 10;
+int const VideoContentProperty::TYPE              = 11;
 
 
 using std::cout;
@@ -76,6 +77,7 @@ VideoContent::VideoContent (Content* parent)
        : ContentPart (parent)
        , _use (true)
        , _length (0)
+       , _type(VideoType::MAIN)
        , _frame_type (VideoFrameType::TWO_D)
        , _yuv (true)
        , _fade_in (0)
@@ -108,6 +110,8 @@ VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int versio
        _use = node->optional_bool_child("Use").get_value_or(true);
        _length = node->number_child<Frame> ("VideoLength");
 
+       _type = string_to_video_type(node->optional_string_child("VideoType").get_value_or("main"));
+
        if (version <= 34) {
                /* Snapshot of the VideoFrameType enum at version 34 */
                switch (node->number_child<int> ("VideoFrameType")) {
@@ -221,6 +225,10 @@ VideoContent::VideoContent (Content* parent, vector<shared_ptr<Content> > c)
                        throw JoinError (_("Content to be joined must have the same picture size."));
                }
 
+               if (c[i]->video->type() != ref->type()) {
+                       throw JoinError(_("Content to be joined must have the same video type."));
+               }
+
                if (c[i]->video->frame_type() != ref->frame_type()) {
                        throw JoinError (_("Content to be joined must have the same video frame type."));
                }
@@ -260,6 +268,7 @@ VideoContent::VideoContent (Content* parent, vector<shared_ptr<Content> > c)
 
        _use = ref->use ();
        _size = ref->size ();
+       _type = ref->type();
        _frame_type = ref->frame_type ();
        _crop = ref->requested_crop ();
        _custom_ratio = ref->custom_ratio ();
@@ -279,6 +288,7 @@ VideoContent::as_xml (xmlpp::Node* node) const
        node->add_child("VideoLength")->add_child_text (raw_convert<string> (_length));
        node->add_child("VideoWidth")->add_child_text (raw_convert<string> (_size.width));
        node->add_child("VideoHeight")->add_child_text (raw_convert<string> (_size.height));
+       node->add_child("VideoType")->add_child_text(video_type_to_string(_type));
        node->add_child("VideoFrameType")->add_child_text (video_frame_type_to_string (_frame_type));
        if (_sample_aspect_ratio) {
                node->add_child("SampleAspectRatio")->add_child_text (raw_convert<string> (_sample_aspect_ratio.get ()));
@@ -556,6 +566,13 @@ VideoContent::set_bottom_crop (int c)
 }
 
 
+void
+VideoContent::set_type(VideoType type)
+{
+       maybe_set(_type, type, VideoContentProperty::TYPE);
+}
+
+
 void
 VideoContent::set_frame_type (VideoFrameType t)
 {