summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-02-14 20:55:45 +0000
committerCarl Hetherington <cth@carlh.net>2018-02-14 22:16:07 +0000
commit72bb29fad754774e78f2901d7db39f7d73def010 (patch)
treed0a809faea94ff5c3a58378ecdb194d9ab1a8235
parentfaddfd5cce5d447ca50a0a97ded3e6f3c86c355e (diff)
Add parsing of ForensicMarkFlagList in KDMRequiredExtensions constructor.
-rw-r--r--src/encrypted_kdm.cc33
1 files changed, 30 insertions, 3 deletions
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 <libxml++/document.h>
#include <libxml++/nodes/element.h>
#include <libxml/parser.h>
+#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
@@ -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<AuthorizedDeviceInfo> 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: