summaryrefslogtreecommitdiff
path: root/src/smpte_subtitle_asset.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-08-30 15:06:31 +0100
committerCarl Hetherington <cth@carlh.net>2016-08-30 15:06:31 +0100
commit3e24098b32d6160759378e671bfca241dd9025d9 (patch)
tree609e04b68b8d59ff54eca7169a4f065a48837add /src/smpte_subtitle_asset.cc
parentac6df088854c0eeb7795436aafcfae7d367f4486 (diff)
Neater and more correct XML subtitle parser.
Diffstat (limited to 'src/smpte_subtitle_asset.cc')
-rw-r--r--src/smpte_subtitle_asset.cc20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index c58162b3..128729d8 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -37,7 +37,6 @@
#include "smpte_subtitle_asset.h"
#include "smpte_load_font_node.h"
-#include "font_node.h"
#include "exceptions.h"
#include "xml.h"
#include "raw_convert.h"
@@ -139,20 +138,17 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml)
_start_time = Time (xml->string_child ("StartTime"), _time_code_rate);
}
- shared_ptr<cxml::Node> subtitle_list = xml->optional_node_child ("SubtitleList");
+ /* Now we need to drop down to xmlpp */
- list<shared_ptr<dcp::FontNode> > font_nodes;
- BOOST_FOREACH (cxml::NodePtr const & i, subtitle_list->node_children ("Font")) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, _time_code_rate, SMPTE)));
- }
-
- list<shared_ptr<dcp::SubtitleNode> > subtitle_nodes;
- BOOST_FOREACH (cxml::NodePtr const & i, subtitle_list->node_children ("Subtitle")) {
- subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, _time_code_rate, SMPTE)));
+ list<ParseState> ps;
+ xmlpp::Node::NodeList c = xml->node()->get_children ();
+ for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) {
+ xmlpp::Element const * e = dynamic_cast<xmlpp::Element const *> (*i);
+ if (e && e->get_name() == "SubtitleList") {
+ parse_subtitles (e, ps, _time_code_rate, SMPTE);
+ }
}
- parse_subtitles (xml, font_nodes, subtitle_nodes);
-
/* Guess intrinsic duration */
_intrinsic_duration = latest_subtitle_out().as_editable_units (_edit_rate.numerator / _edit_rate.denominator);
}