Store and allow access to the raw XML that is read in from
authorCarl Hetherington <cth@carlh.net>
Fri, 8 May 2020 20:44:50 +0000 (22:44 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 8 May 2020 20:44:50 +0000 (22:44 +0200)
subtitle assets so that it cab be verified without any
interference from being passed through libdcp.

src/interop_subtitle_asset.cc
src/smpte_subtitle_asset.cc
src/subtitle_asset.h

index d250b752e9d1f0aa10d00a1398237073d8ab853c..39521ed75edf87836ac60d7e50dab23f79fe07c4 100644 (file)
@@ -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");
index 33a0c943536d5d79b7928bdeeb3033a15579984e..81a0aa6f42093f26b7737a361b17a1ba53ce70d4 100644 (file)
@@ -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);
 }
index 9792ce05e026ed070e7da8b55b8188d439b13851..fd233cc8a63be77f178474d3aa13931ed40c8d56 100644 (file)
@@ -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;