summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-01-12 17:21:41 +0000
committerCarl Hetherington <cth@carlh.net>2015-01-12 17:21:41 +0000
commitdbdc438c066ee2a80943b9494e78db19905f9fa9 (patch)
tree08daf75600719d6dd0130c596ef81d30ce4b3de3 /src
parentfd1d21f713e9b0abd8afebcbab36d70aac9b6cce (diff)
Files missed from previous commit.
Diffstat (limited to 'src')
-rw-r--r--src/dcp/font.cc93
-rw-r--r--src/dcp/font.h63
-rw-r--r--src/dcp/interop_load_font.cc56
-rw-r--r--src/dcp/interop_load_font.h43
-rw-r--r--src/dcp/load_font.h38
-rw-r--r--src/dcp/smpte_load_font.cc31
-rw-r--r--src/dcp/smpte_load_font.h41
-rw-r--r--src/dcp/subtitle.cc71
-rw-r--r--src/dcp/subtitle.h59
-rw-r--r--src/dcp/text.h59
-rw-r--r--src/dcp/wscript1
-rw-r--r--src/interop_dcp_reader.cc53
-rw-r--r--src/interop_dcp_reader.h40
-rw-r--r--src/smpte_dcp_reader.cc83
-rw-r--r--src/smpte_dcp_reader.h40
-rw-r--r--src/util.cc37
-rw-r--r--src/util.h28
17 files changed, 836 insertions, 0 deletions
diff --git a/src/dcp/font.cc b/src/dcp/font.cc
new file mode 100644
index 0000000..6368703
--- /dev/null
+++ b/src/dcp/font.cc
@@ -0,0 +1,93 @@
+/*
+ Copyright (C) 2012-2014 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 "font.h"
+#include "text.h"
+#include <libcxml/cxml.h>
+#include <boost/foreach.hpp>
+
+using std::string;
+using std::list;
+using boost::shared_ptr;
+using boost::optional;
+using namespace sub;
+
+dcp::Font::Font (cxml::ConstNodePtr node, int tcr)
+{
+ text = node->content ();
+
+ id = node->optional_string_attribute ("Id");
+ size = node->optional_number_attribute<int64_t> ("Size").get_value_or (0);
+ italic = node->optional_bool_attribute ("Italic");
+ optional<string> c = node->optional_string_attribute ("Color");
+ if (c) {
+ colour = Colour (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_colour = Colour (c.get ());
+ }
+
+ list<cxml::NodePtr> s = node->node_children ("Subtitle");
+ BOOST_FOREACH (cxml::NodePtr& i, s) {
+ subtitle_nodes.push_back (shared_ptr<Subtitle> (new Subtitle (i, tcr)));
+ }
+
+ list<cxml::NodePtr> f = node->node_children ("Font");
+ BOOST_FOREACH (cxml::NodePtr& i, f) {
+ font_nodes.push_back (shared_ptr<Font> (new Font (i, tcr)));
+ }
+
+ list<cxml::NodePtr> t = node->node_children ("Text");
+ BOOST_FOREACH (cxml::NodePtr& i, t) {
+ text_nodes.push_back (shared_ptr<Text> (new Text (i, tcr)));
+ }
+}
+
+dcp::Font::Font (std::list<boost::shared_ptr<Font> > const & font_nodes)
+ : size (0)
+ , italic (false)
+ , colour ("FFFFFFFF")
+ , effect_colour ("FFFFFFFF")
+{
+ for (list<shared_ptr<Font> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) {
+ if ((*i)->id) {
+ id = (*i)->id;
+ }
+ if ((*i)->size != 0) {
+ size = (*i)->size;
+ }
+ if ((*i)->italic) {
+ italic = (*i)->italic.get ();
+ }
+ if ((*i)->colour) {
+ colour = (*i)->colour.get ();
+ }
+ if ((*i)->effect) {
+ effect = (*i)->effect.get ();
+ }
+ if ((*i)->effect_colour) {
+ effect_colour = (*i)->effect_colour.get ();
+ }
+ }
+}
diff --git a/src/dcp/font.h b/src/dcp/font.h
new file mode 100644
index 0000000..2b4a5fc
--- /dev/null
+++ b/src/dcp/font.h
@@ -0,0 +1,63 @@
+/*
+ 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
+ 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/dcp/font.h
+ * @brief Font class
+ */
+
+#include "../colour.h"
+#include "../effect.h"
+#include "subtitle.h"
+#include <libcxml/cxml.h>
+#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+#include <list>
+
+namespace sub {
+namespace dcp {
+
+/** @class Font
+ * @brief Helper class for parsing subtitle XML.
+ */
+class Font
+{
+public:
+ Font ()
+ : size (0)
+ {}
+
+ Font (cxml::ConstNodePtr node, int tcr);
+ Font (std::list<boost::shared_ptr<Font> > const & font_nodes);
+
+ std::string text;
+ boost::optional<std::string> id;
+ int size;
+ boost::optional<bool> italic;
+ boost::optional<Colour> colour;
+ boost::optional<Effect> effect;
+ boost::optional<Colour> effect_colour;
+
+ std::list<boost::shared_ptr<Subtitle> > subtitle_nodes;
+ std::list<boost::shared_ptr<Font> > font_nodes;
+ std::list<boost::shared_ptr<Text> > text_nodes;
+};
+
+}
+
+}
diff --git a/src/dcp/interop_load_font.cc b/src/dcp/interop_load_font.cc
new file mode 100644
index 0000000..2ee3ee9
--- /dev/null
+++ b/src/dcp/interop_load_font.cc
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2012-2014 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 "interop_load_font.h"
+#include <libcxml/cxml.h>
+
+using std::string;
+using boost::shared_ptr;
+using boost::optional;
+using namespace sub;
+
+dcp::InteropLoadFont::InteropLoadFont (string id_, string uri_)
+ : LoadFont (id_)
+ , uri (uri_)
+{
+
+}
+
+dcp::InteropLoadFont::InteropLoadFont (cxml::ConstNodePtr node)
+{
+ optional<string> x = node->optional_string_attribute ("Id");
+ if (!x) {
+ x = node->optional_string_attribute ("ID");
+ }
+ id = x.get_value_or ("");
+
+ uri = node->string_attribute ("URI");
+}
+
+bool
+dcp::operator== (InteropLoadFont const & a, InteropLoadFont const & b)
+{
+ return a.id == b.id && a.uri == b.uri;
+}
+
+bool
+dcp::operator!= (InteropLoadFont const & a, InteropLoadFont const & b)
+{
+ return !(a == b);
+}
diff --git a/src/dcp/interop_load_font.h b/src/dcp/interop_load_font.h
new file mode 100644
index 0000000..373b26c
--- /dev/null
+++ b/src/dcp/interop_load_font.h
@@ -0,0 +1,43 @@
+/*
+ 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
+ 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 "load_font.h"
+#include <libcxml/cxml.h>
+#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+
+namespace sub {
+namespace dcp {
+
+class InteropLoadFont : public LoadFont
+{
+public:
+ InteropLoadFont () {}
+ InteropLoadFont (std::string id, std::string uri);
+ InteropLoadFont (cxml::ConstNodePtr node);
+
+ std::string uri;
+};
+
+bool operator== (InteropLoadFont const & a, InteropLoadFont const & b);
+bool operator!= (InteropLoadFont const & a, InteropLoadFont const & b);
+
+}
+
+}
diff --git a/src/dcp/load_font.h b/src/dcp/load_font.h
new file mode 100644
index 0000000..f269c87
--- /dev/null
+++ b/src/dcp/load_font.h
@@ -0,0 +1,38 @@
+/*
+ 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
+ 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 <string>
+
+namespace sub {
+namespace dcp {
+
+class LoadFont
+{
+public:
+ LoadFont () {}
+ LoadFont (std::string id_)
+ : id (id_)
+ {}
+
+ std::string id;
+};
+
+}
+
+}
diff --git a/src/dcp/smpte_load_font.cc b/src/dcp/smpte_load_font.cc
new file mode 100644
index 0000000..d433cbf
--- /dev/null
+++ b/src/dcp/smpte_load_font.cc
@@ -0,0 +1,31 @@
+/*
+ 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
+ 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 "smpte_load_font.h"
+#include <libcxml/cxml.h>
+
+using std::string;
+using boost::shared_ptr;
+using namespace sub;
+
+dcp::SMPTELoadFont::SMPTELoadFont (shared_ptr<const cxml::Node> node)
+ : LoadFont (node->string_attribute ("ID"))
+{
+ urn = node->content().substr (9);
+}
diff --git a/src/dcp/smpte_load_font.h b/src/dcp/smpte_load_font.h
new file mode 100644
index 0000000..aba05c8
--- /dev/null
+++ b/src/dcp/smpte_load_font.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2012-2014 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 "load_font.h"
+#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+
+namespace cxml {
+ class Node;
+}
+
+namespace sub {
+namespace dcp {
+
+class SMPTELoadFont : public LoadFont
+{
+public:
+ SMPTELoadFont (boost::shared_ptr<const cxml::Node> node);
+
+ std::string urn;
+};
+
+}
+
+}
diff --git a/src/dcp/subtitle.cc b/src/dcp/subtitle.cc
new file mode 100644
index 0000000..3de9f8f
--- /dev/null
+++ b/src/dcp/subtitle.cc
@@ -0,0 +1,71 @@
+/*
+ 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
+ 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 "subtitle.h"
+#include "font.h"
+#include "text.h"
+#include <libcxml/cxml.h>
+#include <boost/lexical_cast.hpp>
+
+using std::string;
+using std::list;
+using boost::optional;
+using boost::shared_ptr;
+using boost::lexical_cast;
+using namespace sub;
+
+dcp::Subtitle::Subtitle (boost::shared_ptr<const cxml::Node> node, int tcr)
+{
+ in. = Time (node->string_attribute ("TimeIn"), tcr);
+ out = Time (node->string_attribute ("TimeOut"), tcr);
+
+ list<cxml::NodePtr> f = node->node_children ("Font");
+ for (list<cxml::NodePtr>::iterator i = f.begin(); i != f.end(); ++i) {
+ font_nodes.push_back (shared_ptr<Font> (new Font (*i, tcr)));
+ }
+
+ list<cxml::NodePtr> t = node->node_children ("Text");
+ for (list<cxml::NodePtr>::iterator i = t.begin(); i != t.end(); ++i) {
+ text_nodes.push_back (shared_ptr<Text> (new Text (*i, tcr)));
+ }
+
+ fade_up_time = fade_time (node, "FadeUpTime", tcr);
+ fade_down_time = fade_time (node, "FadeDownTime", tcr);
+}
+
+Time
+dcp::Subtitle::fade_time (shared_ptr<const cxml::Node> node, string name, int tcr)
+{
+ string const u = node->optional_string_attribute (name).get_value_or ("");
+ Time t;
+
+ if (u.empty ()) {
+ t = Time (0, 0, 0, 20, 250);
+ } else if (u.find (":") != string::npos) {
+ t = Time (u, tcr);
+ } else {
+ t = Time (0, 0, 0, lexical_cast<int> (u), tcr);
+ }
+
+ if (t > Time (0, 0, 8, 0, 250)) {
+ t = Time (0, 0, 8, 0, 250);
+ }
+
+ return t;
+}
diff --git a/src/dcp/subtitle.h b/src/dcp/subtitle.h
new file mode 100644
index 0000000..17e405c
--- /dev/null
+++ b/src/dcp/subtitle.h
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2012-2014 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.
+
+*/
+
+#ifndef LIBSUB_DCP_SUBTITLE_H
+#define LIBSUB_DCP_SUBTITLE_H
+
+#include "../time_pair.h"
+#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+#include <list>
+
+namespace cxml {
+ class Node;
+}
+
+namespace sub {
+namespace dcp {
+
+class Font;
+class Text;
+
+class Subtitle
+{
+public:
+ Subtitle () {}
+ Subtitle (boost::shared_ptr<const cxml::Node> node, int tcr);
+
+ FrameTime in;
+ FrameTime out;
+ FrameTime fade_up_time;
+ FrameTime fade_down_time;
+ std::list<boost::shared_ptr<Font> > font_nodes;
+ std::list<boost::shared_ptr<Text> > text_nodes;
+
+private:
+ TimePair fade_time (boost::shared_ptr<const cxml::Node>, std::string name, int tcr);
+};
+
+}
+
+}
+
+#endif
diff --git a/src/dcp/text.h b/src/dcp/text.h
new file mode 100644
index 0000000..a9c0358
--- /dev/null
+++ b/src/dcp/text.h
@@ -0,0 +1,59 @@
+/*
+ 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
+ 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/text.h
+ * @brief Text class for parsing DCP subtitle XML.
+ */
+
+#include "../vertical_reference.h"
+#include <boost/shared_ptr.hpp>
+#include <list>
+
+namespace cxml {
+ class Node;
+}
+
+namespace sub {
+namespace dcp {
+
+class Font;
+
+/** @class Text
+ * @brief Parser for Text nodes from subtitle XML.
+ */
+class Text
+{
+public:
+ /** Construct a default text node */
+ Text ()
+ : v_position (0)
+ , v_align (TOP_OF_SCREEN)
+ {}
+
+ Text (boost::shared_ptr<const cxml::Node> node, int tcr);
+
+ float v_position;
+ VerticalReference v_align;
+ std::string text;
+ std::list<boost::shared_ptr<Font> > font_nodes;
+};
+
+}
+
+}
diff --git a/src/dcp/wscript b/src/dcp/wscript
new file mode 100644
index 0000000..a70ef26
--- /dev/null
+++ b/src/dcp/wscript
@@ -0,0 +1 @@
+# This is a dummy just so my waft script works
diff --git a/src/interop_dcp_reader.cc b/src/interop_dcp_reader.cc
new file mode 100644
index 0000000..5cbb1a2
--- /dev/null
+++ b/src/interop_dcp_reader.cc
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2014-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
+ 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 "interop_dcp_reader.h"
+#include "dcp/interop_load_font.h"
+#include "xml.h"
+#include "dcp/font.h"
+#include <libcxml/cxml.h>
+#include <boost/foreach.hpp>
+
+using std::list;
+using boost::shared_ptr;
+using namespace sub;
+
+InteropDCPReader::InteropDCPReader (boost::filesystem::path file)
+{
+ shared_ptr<cxml::Document> xml (new cxml::Document ("DCSubtitle"));
+ xml->read_file (file);
+ _id = xml->string_child ("SubtitleID");
+
+ _movie_title = xml->string_child ("MovieTitle");
+ _load_font_nodes = type_children<dcp::InteropLoadFont> (xml, "LoadFont");
+
+ list<cxml::NodePtr> f = xml->node_children ("Font");
+ list<shared_ptr<dcp::Font> > font_nodes;
+ BOOST_FOREACH (cxml::NodePtr& i, f) {
+ font_nodes.push_back (shared_ptr<dcp::Font> (new dcp::Font (i, 250)));
+ }
+
+ parse_common (xml, font_nodes);
+}
+
+int
+InteropDCPReader::timecode_rate () const
+{
+ return 250;
+}
diff --git a/src/interop_dcp_reader.h b/src/interop_dcp_reader.h
new file mode 100644
index 0000000..f9077fe
--- /dev/null
+++ b/src/interop_dcp_reader.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2014-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
+ 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 "dcp_reader.h"
+
+namespace sub {
+
+namespace dcp {
+ class InteropLoadFont;
+}
+
+class InteropDCPReader : public DCPReader
+{
+public:
+ InteropDCPReader (boost::filesystem::path file);
+
+private:
+ int timecode_rate () const;
+
+ std::string _movie_title;
+ std::list<boost::shared_ptr<dcp::InteropLoadFont> > _load_font_nodes;
+};
+
+}
diff --git a/src/smpte_dcp_reader.cc b/src/smpte_dcp_reader.cc
new file mode 100644
index 0000000..5999fa8
--- /dev/null
+++ b/src/smpte_dcp_reader.cc
@@ -0,0 +1,83 @@
+/*
+ Copyright (C) 2014-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
+ 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 "smpte_dcp_reader.h"
+#include "exceptions.h"
+#include "xml.h"
+#include "AS_DCP.h"
+#include "KM_util.h"
+#include "dcp/font.h"
+#include "dcp/smpte_load_font.h"
+#include <libcxml/cxml.h>
+#include <boost/foreach.hpp>
+
+using std::string;
+using std::list;
+using std::stringstream;
+using boost::shared_ptr;
+using namespace sub;
+
+SMPTEDCPReader::SMPTEDCPReader (boost::filesystem::path file, bool mxf)
+{
+ shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
+
+ if (mxf) {
+ ASDCP::TimedText::MXFReader reader;
+ Kumu::Result_t r = reader.OpenRead (file.string().c_str ());
+ if (ASDCP_FAILURE (r)) {
+ boost::throw_exception (MXFError ("could not open MXF file for reading"));
+ }
+
+ string s;
+ reader.ReadTimedTextResource (s, 0, 0);
+ stringstream t;
+ t << s;
+ xml->read_stream (t);
+
+ ASDCP::WriterInfo info;
+ reader.FillWriterInfo (info);
+
+ char buffer[64];
+ Kumu::bin2UUIDhex (info.AssetUUID, ASDCP::UUIDlen, buffer, sizeof (buffer));
+ _id = buffer;
+ } else {
+ xml->read_file (file);
+ _id = xml->string_child("Id").substr (9);
+ }
+
+ _load_font_nodes = type_children<dcp::SMPTELoadFont> (xml, "LoadFont");
+
+ _timecode_rate = xml->number_child<int> ("TimeCodeRate");
+
+ shared_ptr<cxml::Node> subtitle_list = xml->optional_node_child ("SubtitleList");
+
+ 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<dcp::Font> (new dcp::Font (i, _timecode_rate)));
+ }
+
+ parse_common (xml, font_nodes);
+}
+
+int
+SMPTEDCPReader::timecode_rate () const
+{
+ return _timecode_rate;
+}
diff --git a/src/smpte_dcp_reader.h b/src/smpte_dcp_reader.h
new file mode 100644
index 0000000..b8c0c05
--- /dev/null
+++ b/src/smpte_dcp_reader.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2014-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
+ 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 "dcp_reader.h"
+
+namespace sub {
+
+namespace dcp {
+ class SMPTELoadFont;
+}
+
+class SMPTEDCPReader : public DCPReader
+{
+public:
+ SMPTEDCPReader (boost::filesystem::path file, bool mxf);
+
+private:
+ int timecode_rate () const;
+
+ std::list<boost::shared_ptr<dcp::SMPTELoadFont> > _load_font_nodes;
+ int _timecode_rate;
+};
+
+}
diff --git a/src/util.cc b/src/util.cc
new file mode 100644
index 0000000..5f4cd39
--- /dev/null
+++ b/src/util.cc
@@ -0,0 +1,37 @@
+/*
+ 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
+ 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 "util.h"
+
+using std::string;
+
+/** @param s A string.
+ * @return true if the string contains only space, newline or tab characters, or is empty.
+ */
+bool
+sub::empty_or_white_space (string s)
+{
+ for (size_t i = 0; i < s.length(); ++i) {
+ if (s[i] != ' ' && s[i] != '\n' && s[i] != '\t') {
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..e77d62e
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,28 @@
+/*
+ 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
+ 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 <string>
+
+namespace sub {
+
+extern bool empty_or_white_space (std::string s);
+
+}
+
+