Make similar changes to the previous commit for _xml_id.
authorCarl Hetherington <cth@carlh.net>
Thu, 27 May 2021 12:22:48 +0000 (14:22 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 27 May 2021 12:25:17 +0000 (14:25 +0200)
This is also unavailable if the asset is encrypted.

src/smpte_subtitle_asset.cc
src/smpte_subtitle_asset.h
src/verify.cc

index d0fbc0eb1ea140720c91e844a50d4d99df0fd203..11450ef3192cf0368fc045423bd30d28132ae252 100644 (file)
@@ -347,7 +347,8 @@ SMPTESubtitleAsset::xml_as_string () const
        root->set_namespace_declaration (subtitle_smpte_ns, "dcst");
        root->set_namespace_declaration ("http://www.w3.org/2001/XMLSchema", "xs");
 
        root->set_namespace_declaration (subtitle_smpte_ns, "dcst");
        root->set_namespace_declaration ("http://www.w3.org/2001/XMLSchema", "xs");
 
-       root->add_child("Id", "dcst")->add_child_text ("urn:uuid:" + _xml_id);
+       DCP_ASSERT (_xml_id);
+       root->add_child("Id", "dcst")->add_child_text ("urn:uuid:" + *_xml_id);
        root->add_child("ContentTitleText", "dcst")->add_child_text (_content_title_text);
        if (_annotation_text) {
                root->add_child("AnnotationText", "dcst")->add_child_text (_annotation_text.get ());
        root->add_child("ContentTitleText", "dcst")->add_child_text (_content_title_text);
        if (_annotation_text) {
                root->add_child("AnnotationText", "dcst")->add_child_text (_annotation_text.get ());
@@ -422,7 +423,8 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
 
        descriptor.NamespaceName = subtitle_smpte_ns;
        unsigned int c;
 
        descriptor.NamespaceName = subtitle_smpte_ns;
        unsigned int c;
-       Kumu::hex2bin (_xml_id.c_str(), descriptor.AssetID, ASDCP::UUIDlen, &c);
+       DCP_ASSERT (_xml_id);
+       Kumu::hex2bin (_xml_id->c_str(), descriptor.AssetID, ASDCP::UUIDlen, &c);
        DCP_ASSERT (c == Kumu::UUID_Length);
        descriptor.ContainerDuration = _intrinsic_duration;
 
        DCP_ASSERT (c == Kumu::UUID_Length);
        descriptor.ContainerDuration = _intrinsic_duration;
 
index f63392c7a1ef94a6c817aa783612be07cb2d5b24..4e220d4d586003a06da83ab79ec60fc3afc1d409 100644 (file)
@@ -176,7 +176,10 @@ public:
                return _start_time;
        }
 
                return _start_time;
        }
 
-       std::string xml_id () const {
+       /** @return ID from XML's <Id> tag, or the <Id> that will be used when writing the XML,
+        *  or boost::none if this content is encrypted and no key is available.
+        */
+       boost::optional<std::string> xml_id () const {
                return _xml_id;
        }
 
                return _xml_id;
        }
 
@@ -227,8 +230,9 @@ private:
        std::vector<std::shared_ptr<SMPTELoadFontNode>> _load_font_nodes;
        /** UUID for the XML inside the MXF, which should be the same as the ResourceID in the MXF (our _resource_id)
         *  but different to the AssetUUID in the MXF (our _id) according to SMPTE Bv2.1 and Doremi's 2.8.18 release notes.
        std::vector<std::shared_ptr<SMPTELoadFontNode>> _load_font_nodes;
        /** UUID for the XML inside the MXF, which should be the same as the ResourceID in the MXF (our _resource_id)
         *  but different to the AssetUUID in the MXF (our _id) according to SMPTE Bv2.1 and Doremi's 2.8.18 release notes.
+        *  May be boost::none if this object has been made from an encrypted object without a key.
         */
         */
-       std::string _xml_id;
+       boost::optional<std::string> _xml_id;
 
        /** ResourceID read from the MXF, if there was one */
        boost::optional<std::string> _resource_id;
 
        /** ResourceID read from the MXF, if there was one */
        boost::optional<std::string> _resource_id;
index 40f7c0b691cf8290ab549cb4d1e885c39745c146..5550a67f21867fa9f99efa843c02d6a1cbeacf39 100644 (file)
@@ -703,12 +703,17 @@ verify_smpte_subtitle_asset (
        }
 
        DCP_ASSERT (asset->resource_id());
        }
 
        DCP_ASSERT (asset->resource_id());
-       if (asset->resource_id().get() != asset->xml_id()) {
-               notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::MISMATCHED_TIMED_TEXT_RESOURCE_ID });
-       }
+       auto xml_id = asset->xml_id();
+       if (xml_id) {
+               if (asset->resource_id().get() != xml_id) {
+                       notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::MISMATCHED_TIMED_TEXT_RESOURCE_ID });
+               }
 
 
-       if (asset->id() == asset->resource_id().get() || asset->id() == asset->xml_id()) {
-               notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_TIMED_TEXT_ASSET_ID });
+               if (asset->id() == asset->resource_id().get() || asset->id() == xml_id) {
+                       notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_TIMED_TEXT_ASSET_ID });
+               }
+       } else {
+               notes.push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED});
        }
 }
 
        }
 }