Fix incorrect day-of-month in LocalTime.
[libdcp.git] / src / smpte_subtitle_content.cc
index d34c1dbe6b5f9702ae7f31625f913b55a66a466c..4435fe23929c0f5ed4c2236b464e42a3e284d583 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #include "xml.h"
 #include "AS_DCP.h"
 #include "KM_util.h"
+#include <boost/foreach.hpp>
 
 using std::string;
 using std::list;
 using std::stringstream;
+using std::cout;
 using boost::shared_ptr;
 using namespace dcp;
 
@@ -62,8 +64,31 @@ SMPTESubtitleContent::SMPTESubtitleContent (boost::filesystem::path file, bool m
        
        _load_font_nodes = type_children<dcp::SMPTELoadFont> (xml, "LoadFont");
 
+       int tcr = xml->number_child<int> ("TimeCodeRate");
+
        shared_ptr<cxml::Node> subtitle_list = xml->optional_node_child ("SubtitleList");
-       list<shared_ptr<dcp::Font> > font_nodes = type_children<dcp::Font> (subtitle_list, "Font");
+
+       list<cxml::NodePtr> f = subtitle_list->node_children ("Font");
+       list<shared_ptr<dcp::Font> > font_nodes;
+       BOOST_FOREACH (cxml::NodePtr& i, f) {
+               font_nodes.push_back (shared_ptr<Font> (new Font (i, tcr)));
+       }
 
        parse_common (xml, font_nodes);
 }
+
+list<shared_ptr<LoadFont> >
+SMPTESubtitleContent::load_font_nodes () const
+{
+       list<shared_ptr<LoadFont> > lf;
+       copy (_load_font_nodes.begin(), _load_font_nodes.end(), back_inserter (lf));
+       return lf;
+}
+
+bool
+SMPTESubtitleContent::valid_mxf (boost::filesystem::path file)
+{
+       ASDCP::TimedText::MXFReader reader;
+       Kumu::Result_t r = reader.OpenRead (file.string().c_str ());
+       return !ASDCP_FAILURE (r);
+}