From 72bb29fad754774e78f2901d7db39f7d73def010 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 14 Feb 2018 20:55:45 +0000 Subject: Add parsing of ForensicMarkFlagList in KDMRequiredExtensions constructor. --- src/encrypted_kdm.cc | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index f932f35a..d7a2bcc6 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,7 @@ using std::map; using std::pair; using boost::shared_ptr; using boost::optional; +using boost::starts_with; using namespace dcp; namespace dcp { @@ -382,7 +384,25 @@ public: , authorized_device_info (node->node_child ("AuthorizedDeviceInfo")) , key_id_list (node->node_child ("KeyIdList")) { - + disable_forensic_marking_picture = 0; + disable_forensic_marking_audio = 0; + if (node->optional_node_child("ForensicMarkFlagList")) { + BOOST_FOREACH (cxml::ConstNodePtr i, node->node_child("ForensicMarkFlagList")->node_children("ForensicMarkFlag")) { + if (i->content() == picture_disable) { + disable_forensic_marking_picture = -1; + } else if (starts_with(i->content(), audio_disable)) { + disable_forensic_marking_audio = -1; + string const above = audio_disable + "-above-channel-"; + if (starts_with(i->content(), above)) { + string above_number = i->content().substr(above.length()); + if (above_number == "") { + throw KDMFormatError("Badly-formatted ForensicMarkFlag"); + } + disable_forensic_marking_audio = atoi(above_number.c_str()); + } + } + } + } } void as_xml (xmlpp::Element* node) const @@ -405,10 +425,10 @@ public: if (disable_forensic_marking_picture || disable_forensic_marking_audio) { xmlpp::Element* forensic_mark_flag_list = node->add_child ("ForensicMarkFlagList"); if (disable_forensic_marking_picture) { - forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text ("http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-picture-disable"); + forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text(picture_disable); } if (disable_forensic_marking_audio) { - string mrkflg = "http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-audio-disable"; + string mrkflg = audio_disable; if (disable_forensic_marking_audio != -1) { mrkflg = str (boost::format (mrkflg + "-above-channel-%u") % disable_forensic_marking_audio); } @@ -427,8 +447,15 @@ public: int disable_forensic_marking_audio; boost::optional authorized_device_info; KeyIdList key_id_list; + +private: + static const string picture_disable; + static const string audio_disable; }; +const string KDMRequiredExtensions::picture_disable = "http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-picture-disable"; +const string KDMRequiredExtensions::audio_disable = "http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-audio-disable"; + class RequiredExtensions { public: -- cgit v1.2.3