Assorted image subtitle fixes.
[dcpomatic.git] / src / lib / ffmpeg_subtitle_stream.cc
index 3d8fd4e8375466710cb51ffd4a6a7a4ac950c75e..66b587209af7c55f2a5958bd3e16af9327e390da 100644 (file)
 */
 
 #include "ffmpeg_subtitle_stream.h"
+#include "raw_convert.h"
+#include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
+
+using std::string;
 
 /** Construct a SubtitleStream from a value returned from to_string().
  *  @param t String returned from to_string().
 FFmpegSubtitleStream::FFmpegSubtitleStream (cxml::ConstNodePtr node)
        : FFmpegStream (node)
 {
-       
+       BOOST_FOREACH (cxml::NodePtr i, node->node_children ("Period")) {
+               periods.push_back (
+                       ContentTimePeriod (
+                               ContentTime (node->number_child<ContentTime::Type> ("From")),
+                               ContentTime (node->number_child<ContentTime::Type> ("To"))
+                               )
+                       );
+       }
 }
 
 void
 FFmpegSubtitleStream::as_xml (xmlpp::Node* root) const
 {
        FFmpegStream::as_xml (root);
+
+       BOOST_FOREACH (ContentTimePeriod const & i, periods) {
+               xmlpp::Node* node = root->add_child ("Period");
+               node->add_child("From")->add_child_text (raw_convert<string> (i.from.get ()));
+               node->add_child("To")->add_child_text (raw_convert<string> (i.to.get ()));
+       }
 }