summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-01-03 23:31:26 +0000
committerCarl Hetherington <cth@carlh.net>2015-01-03 23:31:26 +0000
commit35d8cf6d0e45cb5fff078dd984b492b3c83fa4ee (patch)
tree5a71dcc7a0fb52770ea28f9acd25cb0241833e16 /src
parenta6ada5bc1f64c71ada4ebf53db297799eca6d333 (diff)
Add support for reading non-MXF-wrapped SMPTE subtitle files.
Diffstat (limited to 'src')
-rw-r--r--src/dcp.cc3
-rw-r--r--src/smpte_subtitle_content.cc40
-rw-r--r--src/smpte_subtitle_content.h6
3 files changed, 30 insertions, 19 deletions
diff --git a/src/dcp.cc b/src/dcp.cc
index ea55454a..589e3b3b 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -110,6 +110,9 @@ DCP::read (bool keep_going, ReadErrors* errors)
}
/* Read all the assets from the asset map */
+ /* XXX: I think we should be looking at the PKL here to decide type, not
+ the extension of the file.
+ */
for (map<string, boost::filesystem::path>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
boost::filesystem::path path = _directory / i->second;
diff --git a/src/smpte_subtitle_content.cc b/src/smpte_subtitle_content.cc
index 1fa94d1c..d34c1dbe 100644
--- a/src/smpte_subtitle_content.cc
+++ b/src/smpte_subtitle_content.cc
@@ -31,29 +31,35 @@ using std::stringstream;
using boost::shared_ptr;
using namespace dcp;
-SMPTESubtitleContent::SMPTESubtitleContent (boost::filesystem::path file)
+SMPTESubtitleContent::SMPTESubtitleContent (boost::filesystem::path file, bool mxf)
: SubtitleContent (file)
{
- ASDCP::TimedText::MXFReader reader;
- Kumu::Result_t r = reader.OpenRead (file.string().c_str ());
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", file, r));
- }
-
- string s;
- reader.ReadTimedTextResource (s, 0, 0);
shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
- stringstream t;
- t << s;
- xml->read_stream (t);
- ASDCP::WriterInfo info;
- reader.FillWriterInfo (info);
+ if (mxf) {
+ ASDCP::TimedText::MXFReader reader;
+ Kumu::Result_t r = reader.OpenRead (file.string().c_str ());
+ if (ASDCP_FAILURE (r)) {
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file, r));
+ }
- char buffer[64];
- Kumu::bin2UUIDhex (info.AssetUUID, ASDCP::UUIDlen, buffer, sizeof (buffer));
- _id = buffer;
+ 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");
shared_ptr<cxml::Node> subtitle_list = xml->optional_node_child ("SubtitleList");
diff --git a/src/smpte_subtitle_content.h b/src/smpte_subtitle_content.h
index b760f727..70f6f260 100644
--- a/src/smpte_subtitle_content.h
+++ b/src/smpte_subtitle_content.h
@@ -26,8 +26,10 @@ class SMPTELoadFont;
class SMPTESubtitleContent : public SubtitleContent
{
public:
- /** @param file MXF file */
- SMPTESubtitleContent (boost::filesystem::path file);
+ /** @param file File name
+ * @param mxf true if `file' is a MXF, or false if it is an XML file.
+ */
+ SMPTESubtitleContent (boost::filesystem::path file, bool mxf = true);
private:
std::list<boost::shared_ptr<SMPTELoadFont> > _load_font_nodes;