summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-05-08 22:44:50 +0200
committerCarl Hetherington <cth@carlh.net>2020-05-08 22:44:50 +0200
commit1a1ad378a86e4546c746ac5b89377f50d8580c15 (patch)
treee3f3972f10729deec69ee3634dba6cbad06289ed /src
parent7fe06c648aa6e0262dd2d053c93e604de8963342 (diff)
Store and allow access to the raw XML that is read in from
subtitle assets so that it cab be verified without any interference from being passed through libdcp.
Diffstat (limited to 'src')
-rw-r--r--src/interop_subtitle_asset.cc2
-rw-r--r--src/smpte_subtitle_asset.cc11
-rw-r--r--src/subtitle_asset.h7
3 files changed, 14 insertions, 6 deletions
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index d250b752..39521ed7 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -61,6 +61,8 @@ using namespace dcp;
InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
: SubtitleAsset (file)
{
+ _raw_xml = dcp::file_to_string (file);
+
shared_ptr<cxml::Document> xml (new cxml::Document ("DCSubtitle"));
xml->read_file (file);
_id = xml->string_child ("SubtitleID");
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index 33a0c943..81a0aa6f 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -94,15 +94,15 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
_id = read_writer_info (info);
if (!_key_id) {
/* Not encrypted; read it in now */
- string s;
- reader->ReadTimedTextResource (s);
- xml->read_string (s);
+ reader->ReadTimedTextResource (_raw_xml);
+ xml->read_string (_raw_xml);
parse_xml (xml);
read_mxf_descriptor (reader, shared_ptr<DecryptionContext> (new DecryptionContext (optional<Key>(), SMPTE)));
}
} else {
/* Plain XML */
try {
+ _raw_xml = dcp::file_to_string (file);
xml.reset (new cxml::Document ("SubtitleReel"));
xml->read_file (file);
parse_xml (xml);
@@ -278,11 +278,10 @@ SMPTESubtitleAsset::set_key (Key key)
);
}
- string s;
shared_ptr<DecryptionContext> dec (new DecryptionContext (key, SMPTE));
- reader->ReadTimedTextResource (s, dec->context(), dec->hmac());
+ reader->ReadTimedTextResource (_raw_xml, dec->context(), dec->hmac());
shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
- xml->read_string (s);
+ xml->read_string (_raw_xml);
parse_xml (xml);
read_mxf_descriptor (reader, dec);
}
diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h
index 9792ce05..fd233cc8 100644
--- a/src/subtitle_asset.h
+++ b/src/subtitle_asset.h
@@ -105,6 +105,10 @@ public:
virtual std::list<boost::shared_ptr<LoadFontNode> > load_font_nodes () const = 0;
+ std::string raw_xml () const {
+ return _raw_xml;
+ }
+
protected:
friend struct ::interop_dcp_font_test;
friend struct ::smpte_dcp_font_test;
@@ -174,6 +178,9 @@ protected:
/** TTF font data that we need */
std::list<Font> _fonts;
+ /** The raw XML data that we read from our asset; useful for validation */
+ std::string _raw_xml;
+
private:
friend struct ::pull_fonts_test1;
friend struct ::pull_fonts_test2;