From: Carl Hetherington Date: Thu, 27 May 2021 12:22:48 +0000 (+0200) Subject: Make similar changes to the previous commit for _xml_id. X-Git-Tag: v1.8.0~30 X-Git-Url: https://main.carlh.net/gitweb/?p=libdcp.git;a=commitdiff_plain;h=dd672d926e3b88cbe42b0778fda397d9e858b592 Make similar changes to the previous commit for _xml_id. This is also unavailable if the asset is encrypted. --- diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index d0fbc0eb..11450ef3 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -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->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 ()); @@ -422,7 +423,8 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const 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; diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h index f63392c7..4e220d4d 100644 --- a/src/smpte_subtitle_asset.h +++ b/src/smpte_subtitle_asset.h @@ -176,7 +176,10 @@ public: return _start_time; } - std::string xml_id () const { + /** @return ID from XML's tag, or the that will be used when writing the XML, + * or boost::none if this content is encrypted and no key is available. + */ + boost::optional xml_id () const { return _xml_id; } @@ -227,8 +230,9 @@ private: std::vector> _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 _xml_id; /** ResourceID read from the MXF, if there was one */ boost::optional _resource_id; diff --git a/src/verify.cc b/src/verify.cc index 40f7c0b6..5550a67f 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -703,12 +703,17 @@ verify_smpte_subtitle_asset ( } 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}); } }