summaryrefslogtreecommitdiff
path: root/src/reader_factory.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-01-14 17:39:32 +0000
committerCarl Hetherington <cth@carlh.net>2015-01-20 11:20:25 +0000
commit3f630fb8334238ab8a58fbe1a0f513ae2c00de80 (patch)
tree4b773b91029d6374bfd4f2194053d3e249d597cd /src/reader_factory.cc
parent49cafda01b3e07c47e3b20dd5ee91e1426446aea (diff)
Simplify time representation; better in-tree DCP subtitle parser.
Diffstat (limited to 'src/reader_factory.cc')
-rw-r--r--src/reader_factory.cc32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/reader_factory.cc b/src/reader_factory.cc
index 18783da..05634c0 100644
--- a/src/reader_factory.cc
+++ b/src/reader_factory.cc
@@ -17,12 +17,14 @@
*/
-#include <fstream>
-#include <boost/algorithm/string.hpp>
#include "reader_factory.h"
-#include "dcp_reader.h"
+#include "interop_dcp_reader.h"
+#include "smpte_dcp_reader.h"
#include "stl_binary_reader.h"
#include "stl_text_reader.h"
+#include <libxml++/libxml++.h>
+#include <boost/algorithm/string.hpp>
+#include <fstream>
using std::string;
using std::ifstream;
@@ -35,14 +37,24 @@ sub::reader_factory (boost::filesystem::path file_name)
{
string ext = file_name.extension().string();
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
-
- if (ext == ".xml") {
- return shared_ptr<Reader> (new DCPReader (file_name, true));
- }
- if (ext == ".mxf") {
- return shared_ptr<Reader> (new DCPReader (file_name, false));
- }
+ if (ext == ".xml") {
+ /* XXX: unfortunate API weakness in libcxml; we can't find out what a
+ file's root node name is.
+ */
+ xmlpp::DomParser parser (file_name.string ());
+ string const root = parser.get_document()->get_root_node()->get_name();
+ if (root == "DCSubtitle") {
+ return shared_ptr<Reader> (new InteropDCPReader (file_name));
+ } else if (root == "SubtitleReel") {
+ return shared_ptr<Reader> (new SMPTEDCPReader (file_name, false));
+ }
+ }
+
+ if (ext == ".mxf") {
+ /* Assume this is some MXF-wrapped SMPTE subtitles */
+ return shared_ptr<Reader> (new SMPTEDCPReader (file_name, true));
+ }
if (ext == ".stl") {
/* Check the start of the DFC */