summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-13 14:45:16 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-13 14:45:16 +0100
commit7394f50d8b5334a17cac37c8956b1b7e8e5e49c8 (patch)
tree26a0d79b5ea6a2932bcc1ffbe75c8110716ebf26 /src/parse
parent797916ae28d976f3c5be62d37b45864219af6098 (diff)
Try to move XML bits out into parse/ subdir.
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/asset_map.cc78
-rw-r--r--src/parse/asset_map.h81
-rw-r--r--src/parse/cpl.cc147
-rw-r--r--src/parse/cpl.h161
-rw-r--r--src/parse/pkl.cc51
-rw-r--r--src/parse/pkl.h60
-rw-r--r--src/parse/subtitle.cc135
-rw-r--r--src/parse/subtitle.h93
8 files changed, 806 insertions, 0 deletions
diff --git a/src/parse/asset_map.cc b/src/parse/asset_map.cc
new file mode 100644
index 00000000..aedc931e
--- /dev/null
+++ b/src/parse/asset_map.cc
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2012 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/asset_map.cc
+ * @brief Classes used to parse a AssetMap.
+ */
+
+#include <boost/algorithm/string.hpp>
+#include "asset_map.h"
+#include "../util.h"
+#include "../xml.h"
+
+using std::string;
+using std::list;
+using boost::shared_ptr;
+using namespace libdcp::parse;
+
+AssetMap::AssetMap (string file)
+{
+ cxml::File f (file, "AssetMap");
+
+ id = f.string_child ("Id");
+ creator = f.string_child ("Creator");
+ volume_count = f.number_child<int64_t> ("VolumeCount");
+ issue_date = f.string_child ("IssueDate");
+ issuer = f.string_child ("Issuer");
+ assets = type_grand_children<AssetMapAsset> (f, "AssetList", "Asset");
+}
+
+AssetMapAsset::AssetMapAsset (shared_ptr<const cxml::Node> node)
+{
+ id = node->string_child ("Id");
+ packing_list = node->optional_string_child ("PackingList").get_value_or ("");
+ chunks = type_grand_children<Chunk> (node, "ChunkList", "Chunk");
+}
+
+Chunk::Chunk (shared_ptr<const cxml::Node> node)
+{
+ path = node->string_child ("Path");
+
+ string const prefix = "file://";
+
+ if (boost::algorithm::starts_with (path, prefix)) {
+ path = path.substr (prefix.length());
+ }
+
+ volume_index = node->optional_number_child<int64_t> ("VolumeIndex").get_value_or (0);
+ offset = node->optional_number_child<int64_t> ("Offset").get_value_or (0);
+ length = node->optional_number_child<int64_t> ("Length").get_value_or (0);
+}
+
+shared_ptr<AssetMapAsset>
+AssetMap::asset_from_id (string id) const
+{
+ for (list<shared_ptr<AssetMapAsset> >::const_iterator i = assets.begin (); i != assets.end(); ++i) {
+ if ((*i)->id == id) {
+ return *i;
+ }
+ }
+
+ return shared_ptr<AssetMapAsset> ();
+}
diff --git a/src/parse/asset_map.h b/src/parse/asset_map.h
new file mode 100644
index 00000000..af3e8918
--- /dev/null
+++ b/src/parse/asset_map.h
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2012 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/asset_map.h
+ * @brief Classes used to parse a AssetMap.
+ */
+
+#include <stdint.h>
+#include <boost/shared_ptr.hpp>
+#include <libcxml/cxml.h>
+
+namespace libdcp {
+
+namespace parse {
+
+/** @class Chunk
+ * @brief A simple parser for and representation of a \<Chunk\> node within an asset map.
+ */
+class Chunk
+{
+public:
+ Chunk ();
+ Chunk (boost::shared_ptr<const cxml::Node> node);
+
+ std::string path;
+ int64_t volume_index;
+ int64_t offset;
+ int64_t length;
+};
+
+/** @class AssetMapAsset
+ * @brief A simple parser for and representation of an \<AssetMap\> node within an asset map.
+ */
+class AssetMapAsset
+{
+public:
+ AssetMapAsset ();
+ AssetMapAsset (boost::shared_ptr<const cxml::Node> node);
+
+ std::string id;
+ std::string packing_list;
+ std::list<boost::shared_ptr<Chunk> > chunks;
+};
+
+/** @class AssetMap
+ * @brief A simple parser for and representation of an asset map file.
+ */
+class AssetMap
+{
+public:
+ AssetMap (std::string file);
+
+ boost::shared_ptr<AssetMapAsset> asset_from_id (std::string id) const;
+
+ std::string id;
+ std::string creator;
+ int64_t volume_count;
+ std::string issue_date;
+ std::string issuer;
+ std::list<boost::shared_ptr<AssetMapAsset> > assets;
+};
+
+}
+
+}
diff --git a/src/parse/cpl.cc b/src/parse/cpl.cc
new file mode 100644
index 00000000..c4cf4374
--- /dev/null
+++ b/src/parse/cpl.cc
@@ -0,0 +1,147 @@
+/*
+ Copyright (C) 2012 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/cpl_file.cc
+ * @brief Classes used to parse a CPL.
+ */
+
+#include <iostream>
+#include "cpl.h"
+#include "../xml.h"
+#include "../util.h"
+
+using std::string;
+using std::bad_cast;
+using boost::shared_ptr;
+using namespace libdcp::parse;
+
+CPL::CPL (string file)
+{
+ cxml::File f (file, "CompositionPlaylist");
+
+ id = f.string_child ("Id");
+ annotation_text = f.optional_string_child ("AnnotationText").get_value_or ("");
+ issue_date = f.string_child ("IssueDate");
+ creator = f.optional_string_child ("Creator").get_value_or ("");
+ content_title_text = f.string_child ("ContentTitleText");
+ content_kind = content_kind_from_string (f.string_child ("ContentKind"));
+ content_version = optional_type_child<ContentVersion> (f, "ContentVersion");
+ f.ignore_child ("RatingList");
+ reels = type_grand_children<Reel> (f, "ReelList", "Reel");
+
+ f.ignore_child ("Issuer");
+ f.ignore_child ("Signer");
+ f.ignore_child ("Signature");
+
+ f.done ();
+}
+
+ContentVersion::ContentVersion (shared_ptr<const cxml::Node> node)
+{
+ id = node->optional_string_child ("Id").get_value_or ("");
+ label_text = node->string_child ("LabelText");
+ node->done ();
+}
+
+Reel::Reel (shared_ptr<const cxml::Node> node)
+{
+ id = node->string_child ("Id");
+ asset_list = type_child<CPLAssetList> (node, "AssetList");
+
+ node->ignore_child ("AnnotationText");
+ node->done ();
+}
+
+CPLAssetList::CPLAssetList (shared_ptr<const cxml::Node> node)
+{
+ main_picture = optional_type_child<MainPicture> (node, "MainPicture");
+ main_stereoscopic_picture = optional_type_child<MainStereoscopicPicture> (node, "MainStereoscopicPicture");
+ main_sound = optional_type_child<MainSound> (node, "MainSound");
+ main_subtitle = optional_type_child<MainSubtitle> (node, "MainSubtitle");
+
+ node->done ();
+}
+
+MainPicture::MainPicture (shared_ptr<const cxml::Node> node)
+ : Picture (node)
+{
+
+}
+
+MainStereoscopicPicture::MainStereoscopicPicture (shared_ptr<const cxml::Node> node)
+ : Picture (node)
+{
+
+}
+
+Picture::Picture (shared_ptr<const cxml::Node> node)
+{
+ id = node->string_child ("Id");
+ annotation_text = node->optional_string_child ("AnnotationText").get_value_or ("");
+ edit_rate = Fraction (node->string_child ("EditRate"));
+ intrinsic_duration = node->number_child<int64_t> ("IntrinsicDuration");
+ entry_point = node->number_child<int64_t> ("EntryPoint");
+ duration = node->number_child<int64_t> ("Duration");
+ frame_rate = Fraction (node->string_child ("FrameRate"));
+ try {
+ screen_aspect_ratio = Fraction (node->string_child ("ScreenAspectRatio"));
+ } catch (XMLError& e) {
+ /* Maybe it's not a fraction */
+ }
+ try {
+ float f = node->number_child<float> ("ScreenAspectRatio");
+ screen_aspect_ratio = Fraction (f * 1000, 1000);
+ } catch (bad_cast& e) {
+
+ }
+
+ node->ignore_child ("Hash");
+
+ node->done ();
+}
+
+MainSound::MainSound (shared_ptr<const cxml::Node> node)
+{
+ id = node->string_child ("Id");
+ annotation_text = node->optional_string_child ("AnnotationText").get_value_or ("");
+ edit_rate = Fraction (node->string_child ("EditRate"));
+ intrinsic_duration = node->number_child<int64_t> ("IntrinsicDuration");
+ entry_point = node->number_child<int64_t> ("EntryPoint");
+ duration = node->number_child<int64_t> ("Duration");
+
+ node->ignore_child ("Hash");
+ node->ignore_child ("Language");
+
+ node->done ();
+}
+
+MainSubtitle::MainSubtitle (shared_ptr<const cxml::Node> node)
+{
+ id = node->string_child ("Id");
+ annotation_text = node->optional_string_child ("AnnotationText").get_value_or ("");
+ edit_rate = Fraction (node->string_child ("EditRate"));
+ intrinsic_duration = node->number_child<int64_t> ("IntrinsicDuration");
+ entry_point = node->number_child<int64_t> ("EntryPoint");
+ duration = node->number_child<int64_t> ("Duration");
+
+ node->ignore_child ("Hash");
+ node->ignore_child ("Language");
+
+ node->done ();
+}
diff --git a/src/parse/cpl.h b/src/parse/cpl.h
new file mode 100644
index 00000000..434a244b
--- /dev/null
+++ b/src/parse/cpl.h
@@ -0,0 +1,161 @@
+/*
+ Copyright (C) 2012 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/parse/cpl.h
+ * @brief Classes used to parse a CPL.
+ */
+
+#include <stdint.h>
+#include <boost/shared_ptr.hpp>
+#include <libcxml/cxml.h>
+#include "../types.h"
+
+namespace libdcp {
+
+namespace parse {
+
+/** @brief A simple representation of a CPL \<Picture\> node */
+class Picture
+{
+public:
+ Picture () {}
+ Picture (boost::shared_ptr<const cxml::Node> node);
+
+ std::string id;
+ std::string annotation_text;
+ Fraction edit_rate;
+ /** Duration of the whole thing */
+ int64_t intrinsic_duration;
+ /** Start point in frames */
+ int64_t entry_point;
+ /** Duration that will actually play */
+ int64_t duration;
+ Fraction frame_rate;
+ Fraction screen_aspect_ratio;
+};
+
+
+/** @brief A simple parser for and representation of a CPL \<MainPicture\> node */
+class MainPicture : public Picture
+{
+public:
+ MainPicture () {}
+ MainPicture (boost::shared_ptr<const cxml::Node> node);
+};
+
+/** @brief A simple parser for and representation of a CPL \<MainStereoscopicPicture\> node */
+class MainStereoscopicPicture : public Picture
+{
+public:
+ MainStereoscopicPicture () {}
+ MainStereoscopicPicture (boost::shared_ptr<const cxml::Node> node);
+};
+
+/** @brief A simple parser for and representation of a CPL \<MainSound\> node */
+class MainSound
+{
+public:
+ MainSound () {}
+ MainSound (boost::shared_ptr<const cxml::Node> node);
+
+ std::string id;
+ std::string annotation_text;
+ Fraction edit_rate;
+ int64_t intrinsic_duration;
+ int64_t entry_point;
+ int64_t duration;
+};
+
+/** @brief A simple parser for and representation of a CPL \<MainSubtitle\> node */
+class MainSubtitle
+{
+public:
+ MainSubtitle () {}
+ MainSubtitle (boost::shared_ptr<const cxml::Node> node);
+
+ std::string id;
+ std::string annotation_text;
+ Fraction edit_rate;
+ int64_t intrinsic_duration;
+ int64_t entry_point;
+ int64_t duration;
+};
+
+/** @brief A simple parser for and representation of a CPL \<AssetList\> node */
+class CPLAssetList
+{
+public:
+ CPLAssetList () {}
+ CPLAssetList (boost::shared_ptr<const cxml::Node> node);
+
+ boost::shared_ptr<MainPicture> main_picture;
+ boost::shared_ptr<MainStereoscopicPicture> main_stereoscopic_picture;
+ boost::shared_ptr<MainSound> main_sound;
+ boost::shared_ptr<MainSubtitle> main_subtitle;
+};
+
+/** @brief A simple parser for and representation of a CPL \<Reel\> node */
+class Reel
+{
+public:
+ Reel () {}
+ Reel (boost::shared_ptr<const cxml::Node> node);
+
+ std::string id;
+ boost::shared_ptr<CPLAssetList> asset_list;
+};
+
+
+/** @brief A simple parser for and representation of a CPL \<ContentVersion\> node */
+class ContentVersion
+{
+public:
+ ContentVersion () {}
+ ContentVersion (boost::shared_ptr<const cxml::Node> node);
+
+ std::string id;
+ std::string label_text;
+};
+
+/** @class CPL
+ * @brief Class to parse a CPL
+ *
+ * This class is used to parse XML CPL files. It is rarely necessary
+ * for the caller to use it outside libdcp.
+ */
+class CPL
+{
+public:
+ /** Parse a CPL XML file into our member variables */
+ CPL (std::string file);
+
+ std::string id;
+ std::string annotation_text;
+ std::string issue_date;
+ std::string creator;
+ std::string content_title_text;
+ ContentKind content_kind;
+ boost::shared_ptr<ContentVersion> content_version;
+ std::list<boost::shared_ptr<Reel> > reels;
+};
+
+}
+
+}
+
diff --git a/src/parse/pkl.cc b/src/parse/pkl.cc
new file mode 100644
index 00000000..d790cfe4
--- /dev/null
+++ b/src/parse/pkl.cc
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2012 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/pkl_file.cc
+ * @brief Classes used to parse a PKL.
+ */
+
+#include <iostream>
+#include "pkl.h"
+
+using namespace std;
+using namespace boost;
+using namespace libdcp::parse;
+
+PKL::PKL (string file)
+{
+ cxml::File f (file, "PackingList");
+
+ id = f.string_child ("Id");
+ annotation_text = f.optional_string_child ("AnnotationText").get_value_or ("");
+ issue_date = f.string_child ("IssueDate");
+ issuer = f.string_child ("Issuer");
+ creator = f.string_child ("Creator");
+ assets = type_grand_children<PKLAsset> (f, "AssetList", "Asset");
+}
+
+PKLAsset::PKLAsset (boost::shared_ptr<const cxml::Node> node)
+{
+ id = node->string_child ("Id");
+ annotation_text = node->optional_string_child ("AnnotationText").get_value_or ("");
+ hash = node->string_child ("Hash");
+ size = node->number_child<int64_t> ("Size");
+ type = node->string_child ("Type");
+ original_file_name = node->optional_string_child ("OriginalFileName").get_value_or ("");
+}
diff --git a/src/parse/pkl.h b/src/parse/pkl.h
new file mode 100644
index 00000000..13d87fa1
--- /dev/null
+++ b/src/parse/pkl.h
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2012 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file src/parse/pkl.h
+ * @brief Classes used to parse a PKL
+ */
+
+#include <boost/shared_ptr.hpp>
+#include "../xml.h"
+
+namespace libdcp {
+
+namespace parse {
+
+class PKLAsset
+{
+public:
+ PKLAsset () {}
+ PKLAsset (boost::shared_ptr<const cxml::Node>);
+
+ std::string id;
+ std::string annotation_text;
+ std::string hash;
+ int64_t size;
+ std::string type;
+ std::string original_file_name;
+};
+
+class PKL
+{
+public:
+ PKL (std::string file);
+
+ std::string id;
+ std::string annotation_text;
+ std::string issue_date;
+ std::string issuer;
+ std::string creator;
+ std::list<boost::shared_ptr<PKLAsset> > assets;
+};
+
+}
+
+}
diff --git a/src/parse/subtitle.cc b/src/parse/subtitle.cc
new file mode 100644
index 00000000..471d62b7
--- /dev/null
+++ b/src/parse/subtitle.cc
@@ -0,0 +1,135 @@
+/*
+ Copyright (C) 2012-2013 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+#include "subtitle.h"
+#include "../types.h"
+
+using std::string;
+using std::list;
+using boost::shared_ptr;
+using boost::optional;
+using boost::lexical_cast;
+using namespace libdcp;
+using namespace libdcp::parse;
+
+Font::Font (shared_ptr<const cxml::Node> node)
+{
+ text = node->content ();
+
+ id = node->optional_string_attribute ("Id").get_value_or ("");
+ size = node->optional_number_attribute<int64_t> ("Size").get_value_or (0);
+ italic = node->optional_bool_attribute ("Italic").get_value_or (false);
+ optional<string> c = node->optional_string_attribute ("Color");
+ if (c) {
+ color = Color (c.get ());
+ }
+ optional<string> const e = node->optional_string_attribute ("Effect");
+ if (e) {
+ effect = string_to_effect (e.get ());
+ }
+ c = node->optional_string_attribute ( "EffectColor");
+ if (c) {
+ effect_color = Color (c.get ());
+ }
+ subtitle_nodes = type_children<Subtitle> (node, "Subtitle");
+ font_nodes = type_children<Font> (node, "Font");
+ text_nodes = type_children<Text> (node, "Text");
+}
+
+Font::Font (list<shared_ptr<Font> > const & font_nodes)
+ : size (0)
+ , italic (false)
+ , color ("FFFFFFFF")
+ , effect_color ("FFFFFFFF")
+{
+ for (list<shared_ptr<Font> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) {
+ if (!(*i)->id.empty ()) {
+ id = (*i)->id;
+ }
+ if ((*i)->size != 0) {
+ size = (*i)->size;
+ }
+ if ((*i)->italic) {
+ italic = (*i)->italic.get ();
+ }
+ if ((*i)->color) {
+ color = (*i)->color.get ();
+ }
+ if ((*i)->effect) {
+ effect = (*i)->effect.get ();
+ }
+ if ((*i)->effect_color) {
+ effect_color = (*i)->effect_color.get ();
+ }
+ }
+}
+
+LoadFont::LoadFont (shared_ptr<const cxml::Node> node)
+{
+ id = node->string_attribute ("Id");
+ uri = node->string_attribute ("URI");
+}
+
+
+Subtitle::Subtitle (shared_ptr<const cxml::Node> node)
+{
+ in = Time (node->string_attribute ("TimeIn"));
+ out = Time (node->string_attribute ("TimeOut"));
+ font_nodes = type_children<Font> (node, "Font");
+ text_nodes = type_children<Text> (node, "Text");
+ fade_up_time = fade_time (node, "FadeUpTime");
+ fade_down_time = fade_time (node, "FadeDownTime");
+}
+
+Time
+Subtitle::fade_time (shared_ptr<const cxml::Node> node, string name)
+{
+ string const u = node->optional_string_attribute (name).get_value_or ("");
+ Time t;
+
+ if (u.empty ()) {
+ t = Time (0, 0, 0, 20);
+ } else if (u.find (":") != string::npos) {
+ t = Time (u);
+ } else {
+ t = Time (0, 0, 0, lexical_cast<int> (u));
+ }
+
+ if (t > Time (0, 0, 8, 0)) {
+ t = Time (0, 0, 8, 0);
+ }
+
+ return t;
+}
+
+Text::Text (shared_ptr<const cxml::Node> node)
+ : v_align (CENTER)
+{
+ text = node->content ();
+ v_position = node->number_attribute<float> ("VPosition");
+ optional<string> v = node->optional_string_attribute ("VAlign");
+ if (v) {
+ v_align = string_to_valign (v.get ());
+ }
+
+ font_nodes = type_children<Font> (node, "Font");
+}
+
diff --git a/src/parse/subtitle.h b/src/parse/subtitle.h
new file mode 100644
index 00000000..34321545
--- /dev/null
+++ b/src/parse/subtitle.h
@@ -0,0 +1,93 @@
+/*
+ Copyright (C) 2012 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "../xml.h"
+#include "../dcp_time.h"
+#include "../types.h"
+
+namespace libdcp
+{
+
+namespace parse
+{
+
+class Font;
+
+class Text
+{
+public:
+ Text () {}
+ Text (boost::shared_ptr<const cxml::Node> node);
+
+ float v_position;
+ VAlign v_align;
+ std::string text;
+ std::list<boost::shared_ptr<Font> > font_nodes;
+};
+
+class Subtitle
+{
+public:
+ Subtitle () {}
+ Subtitle (boost::shared_ptr<const cxml::Node> node);
+
+ Time in;
+ Time out;
+ Time fade_up_time;
+ Time fade_down_time;
+ std::list<boost::shared_ptr<Font> > font_nodes;
+ std::list<boost::shared_ptr<Text> > text_nodes;
+
+private:
+ Time fade_time (boost::shared_ptr<const cxml::Node>, std::string name);
+};
+
+class Font
+{
+public:
+ Font () {}
+ Font (boost::shared_ptr<const cxml::Node> node);
+ Font (std::list<boost::shared_ptr<Font> > const & font_nodes);
+
+ std::string text;
+ std::string id;
+ int size;
+ boost::optional<bool> italic;
+ boost::optional<Color> color;
+ boost::optional<Effect> effect;
+ boost::optional<Color> effect_color;
+
+ std::list<boost::shared_ptr<Subtitle> > subtitle_nodes;
+ std::list<boost::shared_ptr<Font> > font_nodes;
+ std::list<boost::shared_ptr<Text> > text_nodes;
+};
+
+class LoadFont
+{
+public:
+ LoadFont () {}
+ LoadFont (boost::shared_ptr<const cxml::Node> node);
+
+ std::string id;
+ std::string uri;
+};
+
+}
+
+}