diff options
Diffstat (limited to 'src/reader_factory.cc')
| -rw-r--r-- | src/reader_factory.cc | 32 |
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 */ |
