diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-21 15:16:18 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-21 15:16:18 +0100 |
| commit | cbd4450197a083bf58bda510e626f73ba583cb66 (patch) | |
| tree | 2be308772512539570beab36beab02bde72d6d4b /src/lib/caption_content.cc | |
| parent | 1013175d5f6adfa0e6a7442e4c9aebb893787748 (diff) | |
Basics of multiple captions per content so that DCPContent can
hold subs and closed captions.
Diffstat (limited to 'src/lib/caption_content.cc')
| -rw-r--r-- | src/lib/caption_content.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/lib/caption_content.cc b/src/lib/caption_content.cc index af534980a..d44fb55c5 100644 --- a/src/lib/caption_content.cc +++ b/src/lib/caption_content.cc @@ -68,11 +68,15 @@ CaptionContent::CaptionContent (Content* parent) , _line_spacing (1) , _outline_width (2) , _type (CAPTION_OPEN) + , _original_type (CAPTION_OPEN) { } -shared_ptr<CaptionContent> +/** @return CaptionContents from node or <Caption> nodes under node (according to version). + * The list could be empty if no CaptionContents are found. + */ +list<shared_ptr<CaptionContent> > CaptionContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version) { if (version < 34) { @@ -80,7 +84,7 @@ CaptionContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version) subtitle streams, so check for that. */ if (node->string_child("Type") == "FFmpeg" && node->node_children("SubtitleStream").empty()) { - return shared_ptr<CaptionContent> (); + return list<shared_ptr<CaptionContent> >(); } /* Otherwise we can drop through to the newer logic */ @@ -88,16 +92,22 @@ CaptionContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version) if (version < 37) { if (!node->optional_number_child<double>("SubtitleXOffset") && !node->optional_number_child<double>("SubtitleOffset")) { - return shared_ptr<CaptionContent> (); + return list<shared_ptr<CaptionContent> >(); } - return shared_ptr<CaptionContent> (new CaptionContent (parent, node, version)); + list<shared_ptr<CaptionContent> > c; + c.push_back (shared_ptr<CaptionContent> (new CaptionContent (parent, node, version))); + return c; } if (!node->node_child("Caption")) { - return shared_ptr<CaptionContent> (); + return list<shared_ptr<CaptionContent> >(); } - return shared_ptr<CaptionContent> (new CaptionContent (parent, node->node_child("Caption"), version)); + list<shared_ptr<CaptionContent> > c; + BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Caption")) { + c.push_back (shared_ptr<CaptionContent> (new CaptionContent (parent, i, version))); + } + return c; } CaptionContent::CaptionContent (Content* parent, cxml::ConstNodePtr node, int version) @@ -215,6 +225,7 @@ 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")); } @@ -270,6 +281,7 @@ CaptionContent::as_xml (xmlpp::Node* root) const } caption->add_child("Type")->add_child_text (caption_type_to_string(_type)); + caption->add_child("OriginalType")->add_child_text (caption_type_to_string(_original_type)); } string |
