summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-01-19 00:32:53 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-19 00:32:53 +0100
commit1f284533185a798c0ed36669bd6c9729adf6ec5a (patch)
tree94dd3de07e0670f1bf1eed0de94ada1033ceb7f6 /src
parent37631b4d5e07eddbf052c1cff315d6a98b3bcb73 (diff)
Rename encrypted() to any_encrypted() and add all_encrypted().
Diffstat (limited to 'src')
-rw-r--r--src/cpl.cc19
-rw-r--r--src/cpl.h3
-rw-r--r--src/dcp.cc19
-rw-r--r--src/dcp.h3
-rw-r--r--src/reel.cc30
-rw-r--r--src/reel.h3
-rw-r--r--src/verify.cc2
7 files changed, 66 insertions, 13 deletions
diff --git a/src/cpl.cc b/src/cpl.cc
index 76f6002b..a976e072 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -584,10 +584,10 @@ CPL::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler not
/** @return true if we have any encrypted content */
bool
-CPL::encrypted () const
+CPL::any_encrypted () const
{
for (auto i: _reels) {
- if (i->encrypted ()) {
+ if (i->any_encrypted()) {
return true;
}
}
@@ -595,6 +595,21 @@ CPL::encrypted () const
return false;
}
+
+/** @return true if we have all our encryptable content is encrypted */
+bool
+CPL::all_encrypted () const
+{
+ for (auto i: _reels) {
+ if (!i->all_encrypted()) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
/** Add a KDM to this CPL. If the KDM is for any of this CPLs assets it will be used
* to decrypt those assets.
* @param kdm KDM.
diff --git a/src/cpl.h b/src/cpl.h
index d96181e5..5d087c03 100644
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -93,7 +93,8 @@ public:
std::vector<std::shared_ptr<const ReelMXF>> reel_mxfs () const;
std::vector<std::shared_ptr<ReelMXF>> reel_mxfs ();
- bool encrypted () const;
+ bool any_encrypted () const;
+ bool all_encrypted () const;
void write_xml (
boost::filesystem::path file,
diff --git a/src/dcp.cc b/src/dcp.cc
index ca7313a5..ee1a64ed 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -316,11 +316,12 @@ DCP::add (std::shared_ptr<CPL> cpl)
_cpls.push_back (cpl);
}
+
bool
-DCP::encrypted () const
+DCP::any_encrypted () const
{
for (auto i: cpls()) {
- if (i->encrypted()) {
+ if (i->any_encrypted()) {
return true;
}
}
@@ -328,6 +329,20 @@ DCP::encrypted () const
return false;
}
+
+bool
+DCP::all_encrypted () const
+{
+ for (auto i: cpls()) {
+ if (!i->all_encrypted()) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
/** Add a KDM to decrypt this DCP. This method must be called after DCP::read()
* or the KDM you specify will be ignored.
* @param kdm KDM to use.
diff --git a/src/dcp.h b/src/dcp.h
index 73f154c7..7323de9a 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -106,7 +106,8 @@ public:
std::vector<std::shared_ptr<CPL>> cpls () const;
std::vector<std::shared_ptr<Asset>> assets (bool ignore_unresolved = false) const;
- bool encrypted () const;
+ bool any_encrypted () const;
+ bool all_encrypted () const;
void add (DecryptedKDM const &);
diff --git a/src/reel.cc b/src/reel.cc
index 89056cff..a05a7b36 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -223,7 +223,7 @@ Reel::equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandle
}
bool
-Reel::encrypted () const
+Reel::any_encrypted () const
{
auto ecc = false;
for (auto i: _closed_captions) {
@@ -233,14 +233,34 @@ Reel::encrypted () const
}
return (
- (_main_picture && _main_picture->encrypted ()) ||
- (_main_sound && _main_sound->encrypted ()) ||
- (_main_subtitle && _main_subtitle->encrypted ()) ||
+ (_main_picture && _main_picture->encrypted()) ||
+ (_main_sound && _main_sound->encrypted()) ||
+ (_main_subtitle && _main_subtitle->encrypted()) ||
ecc ||
- (_atmos && _atmos->encrypted ())
+ (_atmos && _atmos->encrypted())
);
}
+
+bool
+Reel::all_encrypted () const
+{
+ auto ecc = true;
+ for (auto i: _closed_captions) {
+ if (!i->encrypted()) {
+ ecc = false;
+ }
+ }
+
+ return (
+ (!_main_picture || _main_picture->encrypted()) &&
+ (!_main_sound || _main_sound->encrypted()) &&
+ (!_main_subtitle || _main_subtitle->encrypted()) &&
+ ecc &&
+ (!_atmos || _atmos->encrypted())
+ );
+}
+
void
Reel::add (DecryptedKDM const & kdm)
{
diff --git a/src/reel.h b/src/reel.h
index 083ecd0e..14d599ea 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -114,7 +114,8 @@ public:
xmlpp::Element* write_to_cpl (xmlpp::Element* node, Standard standard) const;
- bool encrypted () const;
+ bool any_encrypted () const;
+ bool all_encrypted () const;
bool equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandler notes) const;
diff --git a/src/verify.cc b/src/verify.cc
index 26173a5b..3b0fb7c9 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -1352,7 +1352,7 @@ dcp::verify (
check_extension_metadata (cpl, notes);
- if (cpl->encrypted()) {
+ if (cpl->any_encrypted()) {
cxml::Document doc ("CompositionPlaylist");
DCP_ASSERT (cpl->file());
doc.read_file (cpl->file().get());