Update to test/data.
[dcpomatic.git] / src / lib / caption_content.cc
index 0d13568e20ee3347999c64497e93b2539f958d0b..4d0795190dc9f61261ffb3c282070bf8cff955a8 100644 (file)
@@ -57,7 +57,7 @@ int const CaptionContentProperty::FADE_OUT = 513;
 int const CaptionContentProperty::OUTLINE_WIDTH = 514;
 int const CaptionContentProperty::TYPE = 515;
 
-CaptionContent::CaptionContent (Content* parent)
+CaptionContent::CaptionContent (Content* parent, CaptionType original_type)
        : ContentPart (parent)
        , _use (false)
        , _burn (false)
@@ -67,8 +67,8 @@ CaptionContent::CaptionContent (Content* parent)
        , _y_scale (1)
        , _line_spacing (1)
        , _outline_width (2)
-       , _type (CAPTION_OPEN)
-       , _original_type (CAPTION_OPEN)
+       , _type (original_type)
+       , _original_type (original_type)
 {
 
 }
@@ -99,7 +99,7 @@ CaptionContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
                return c;
        }
 
-       if (!node->node_child("Caption")) {
+       if (!node->optional_node_child("Caption")) {
                return list<shared_ptr<CaptionContent> >();
        }
 
@@ -121,6 +121,7 @@ CaptionContent::CaptionContent (Content* parent, cxml::ConstNodePtr node, int ve
        , _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 (CAPTION_OPEN)
+       , _original_type (CAPTION_OPEN)
 {
        if (version >= 37) {
                _use = node->bool_child ("Use");
@@ -225,55 +226,58 @@ CaptionContent::CaptionContent (Content* parent, cxml::ConstNodePtr node, int ve
        connect_to_fonts ();
 
        _type = string_to_caption_type (node->optional_string_child("Type").get_value_or("open"));
-       _original_type = string_to_caption_type (node->optional_string_child("Type").get_value_or("open"));
+       _original_type = string_to_caption_type (node->optional_string_child("OriginalType").get_value_or("open"));
 }
 
 CaptionContent::CaptionContent (Content* parent, vector<shared_ptr<Content> > c)
        : ContentPart (parent)
 {
-       shared_ptr<CaptionContent> ref = c[0]->caption;
+       /* This constructor is for join which is only supported for content types
+          that have a single caption, so we can use only_caption() here.
+       */
+       shared_ptr<CaptionContent> ref = c[0]->only_caption();
        DCPOMATIC_ASSERT (ref);
        list<shared_ptr<Font> > ref_fonts = ref->fonts ();
 
        for (size_t i = 1; i < c.size(); ++i) {
 
-               if (c[i]->caption->use() != ref->use()) {
+               if (c[i]->only_caption()->use() != ref->use()) {
                        throw JoinError (_("Content to be joined must have the same 'use subtitles' setting."));
                }
 
-               if (c[i]->caption->burn() != ref->burn()) {
+               if (c[i]->only_caption()->burn() != ref->burn()) {
                        throw JoinError (_("Content to be joined must have the same 'burn subtitles' setting."));
                }
 
-               if (c[i]->caption->x_offset() != ref->x_offset()) {
+               if (c[i]->only_caption()->x_offset() != ref->x_offset()) {
                        throw JoinError (_("Content to be joined must have the same subtitle X offset."));
                }
 
-               if (c[i]->caption->y_offset() != ref->y_offset()) {
+               if (c[i]->only_caption()->y_offset() != ref->y_offset()) {
                        throw JoinError (_("Content to be joined must have the same subtitle Y offset."));
                }
 
-               if (c[i]->caption->x_scale() != ref->x_scale()) {
+               if (c[i]->only_caption()->x_scale() != ref->x_scale()) {
                        throw JoinError (_("Content to be joined must have the same subtitle X scale."));
                }
 
-               if (c[i]->caption->y_scale() != ref->y_scale()) {
+               if (c[i]->only_caption()->y_scale() != ref->y_scale()) {
                        throw JoinError (_("Content to be joined must have the same subtitle Y scale."));
                }
 
-               if (c[i]->caption->line_spacing() != ref->line_spacing()) {
+               if (c[i]->only_caption()->line_spacing() != ref->line_spacing()) {
                        throw JoinError (_("Content to be joined must have the same subtitle line spacing."));
                }
 
-               if ((c[i]->caption->fade_in() != ref->fade_in()) || (c[i]->caption->fade_out() != ref->fade_out())) {
+               if ((c[i]->only_caption()->fade_in() != ref->fade_in()) || (c[i]->only_caption()->fade_out() != ref->fade_out())) {
                        throw JoinError (_("Content to be joined must have the same subtitle fades."));
                }
 
-               if ((c[i]->caption->outline_width() != ref->outline_width())) {
+               if ((c[i]->only_caption()->outline_width() != ref->outline_width())) {
                        throw JoinError (_("Content to be joined must have the same outline width."));
                }
 
-               list<shared_ptr<Font> > fonts = c[i]->caption->fonts ();
+               list<shared_ptr<Font> > fonts = c[i]->only_caption()->fonts ();
                if (fonts.size() != ref_fonts.size()) {
                        throw JoinError (_("Content to be joined must use the same fonts."));
                }
@@ -302,6 +306,8 @@ CaptionContent::CaptionContent (Content* parent, vector<shared_ptr<Content> > c)
        _fade_in = ref->fade_in ();
        _fade_out = ref->fade_out ();
        _outline_width = ref->outline_width ();
+       _type = ref->type ();
+       _original_type = ref->original_type ();
 
        connect_to_fonts ();
 }