Read the bits we can from the MXF header even when it is encrypted.
authorCarl Hetherington <cth@carlh.net>
Thu, 27 May 2021 09:45:11 +0000 (11:45 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 27 May 2021 09:45:11 +0000 (11:45 +0200)
src/smpte_subtitle_asset.cc
src/smpte_subtitle_asset.h

index 0fa315b905a69484c2966bf77c2da8111bbe2f4a..dc8acf51db120e1413a473e6a9cbb0add587fa6a 100644 (file)
@@ -106,7 +106,10 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
                        reader->ReadTimedTextResource (_raw_xml);
                        xml->read_string (_raw_xml);
                        parse_xml (xml);
                        reader->ReadTimedTextResource (_raw_xml);
                        xml->read_string (_raw_xml);
                        parse_xml (xml);
-                       read_mxf_descriptor (reader, make_shared<DecryptionContext>(optional<Key>(), Standard::SMPTE));
+                       read_mxf_descriptor (reader);
+                       read_mxf_resources (reader, make_shared<DecryptionContext>(optional<Key>(), Standard::SMPTE));
+               } else {
+                       read_mxf_descriptor (reader);
                }
        } else {
                /* Plain XML */
                }
        } else {
                /* Plain XML */
@@ -202,7 +205,7 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml)
 
 
 void
 
 
 void
-SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader> reader, shared_ptr<DecryptionContext> dec)
+SMPTESubtitleAsset::read_mxf_resources (shared_ptr<ASDCP::TimedText::MXFReader> reader, shared_ptr<DecryptionContext> dec)
 {
        ASDCP::TimedText::TimedTextDescriptor descriptor;
        reader->FillTimedTextDescriptor (descriptor);
 {
        ASDCP::TimedText::TimedTextDescriptor descriptor;
        reader->FillTimedTextDescriptor (descriptor);
@@ -253,6 +256,14 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader>
                        break;
                }
        }
                        break;
                }
        }
+}
+
+
+void
+SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader> reader)
+{
+       ASDCP::TimedText::TimedTextDescriptor descriptor;
+       reader->FillTimedTextDescriptor (descriptor);
 
        _intrinsic_duration = descriptor.ContainerDuration;
        /* The thing which is called AssetID in the descriptor is also known as the
 
        _intrinsic_duration = descriptor.ContainerDuration;
        /* The thing which is called AssetID in the descriptor is also known as the
@@ -300,7 +311,7 @@ SMPTESubtitleAsset::set_key (Key key)
        auto xml = make_shared<cxml::Document>("SubtitleReel");
        xml->read_string (_raw_xml);
        parse_xml (xml);
        auto xml = make_shared<cxml::Document>("SubtitleReel");
        xml->read_string (_raw_xml);
        parse_xml (xml);
-       read_mxf_descriptor (reader, dec);
+       read_mxf_resources (reader, dec);
 }
 
 
 }
 
 
index 1ece2405c10952028648a4841c79d99915e1ea02..f63392c7a1ef94a6c817aa783612be07cb2d5b24 100644 (file)
@@ -180,7 +180,7 @@ public:
                return _xml_id;
        }
 
                return _xml_id;
        }
 
-       /** @return ResourceID read from the MXF, if there was one */
+       /** @return ResourceID read from any MXF that was read */
        boost::optional<std::string> resource_id () const {
                return _resource_id;
        }
        boost::optional<std::string> resource_id () const {
                return _resource_id;
        }
@@ -204,7 +204,8 @@ private:
 
        void read_fonts (std::shared_ptr<ASDCP::TimedText::MXFReader>);
        void parse_xml (std::shared_ptr<cxml::Document> xml);
 
        void read_fonts (std::shared_ptr<ASDCP::TimedText::MXFReader>);
        void parse_xml (std::shared_ptr<cxml::Document> xml);
-       void read_mxf_descriptor (std::shared_ptr<ASDCP::TimedText::MXFReader> reader, std::shared_ptr<DecryptionContext> dec);
+       void read_mxf_descriptor (std::shared_ptr<ASDCP::TimedText::MXFReader> reader);
+       void read_mxf_resources (std::shared_ptr<ASDCP::TimedText::MXFReader> reader, std::shared_ptr<DecryptionContext> dec);
 
        /** The total length of this content in video frames.  The amount of
         *  content presented may be less than this.
 
        /** The total length of this content in video frames.  The amount of
         *  content presented may be less than this.