From 471c9d05fc19484f3e50cf805d14237b72bbb7b2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 26 Feb 2014 17:48:29 +0000 Subject: Hacks to support MXF-wrapped subtitles. --- src/parse/subtitle.cc | 22 ++++++++++++++++++---- src/parse/subtitle.h | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src/parse') diff --git a/src/parse/subtitle.cc b/src/parse/subtitle.cc index 612af716..914be677 100644 --- a/src/parse/subtitle.cc +++ b/src/parse/subtitle.cc @@ -84,10 +84,14 @@ Font::Font (list > const & font_nodes) LoadFont::LoadFont (shared_ptr node) { - id = node->string_attribute ("Id"); - uri = node->string_attribute ("URI"); + optional x = node->optional_string_attribute ("Id"); + if (!x) { + x = node->optional_string_attribute ("ID"); + } + id = x.get_value_or (""); + + uri = node->optional_string_attribute ("URI"); } - Subtitle::Subtitle (shared_ptr node) { @@ -123,9 +127,19 @@ Subtitle::fade_time (shared_ptr node, string name) Text::Text (shared_ptr node) : v_align (CENTER) { + /* Vertical position */ text = node->content (); - v_position = node->number_attribute ("VPosition"); + optional x = node->optional_number_attribute ("VPosition"); + if (!x) { + x = node->number_attribute ("Vposition"); + } + v_position = x.get (); + + /* Vertical alignment */ optional v = node->optional_string_attribute ("VAlign"); + if (!v) { + v = node->optional_string_attribute ("Valign"); + } if (v) { v_align = string_to_valign (v.get ()); } diff --git a/src/parse/subtitle.h b/src/parse/subtitle.h index c20278a3..3d99d9bc 100644 --- a/src/parse/subtitle.h +++ b/src/parse/subtitle.h @@ -92,7 +92,7 @@ public: LoadFont (boost::shared_ptr node); std::string id; - std::string uri; + boost::optional uri; }; } -- cgit v1.2.3