/* Read the DCP to find out about it */
dcp.read ();
- if (dcp.encrypted ()) {
+ if (dcp.all_encrypted()) {
std::cout << "DCP is encrypted.\n";
+ } else if (dcp.any_encrypted()) {
+ std::cout << "DCP is partially encrypted.\n";
} else {
std::cout << "DCP is not encrypted.\n";
}
/** @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;
}
}
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.
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,
_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;
}
}
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.
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 &);
}
bool
-Reel::encrypted () const
+Reel::any_encrypted () const
{
auto ecc = false;
for (auto i: _closed_captions) {
}
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)
{
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;
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());
plaintext_path /= "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV";
dcp::DCP plaintext (plaintext_path.string ());
plaintext.read ();
- BOOST_CHECK_EQUAL (plaintext.encrypted (), false);
+ BOOST_CHECK_EQUAL (plaintext.any_encrypted(), false);
boost::filesystem::path encrypted_path = private_test;
encrypted_path /= "TONEPLATES-SMPTE-ENCRYPTED_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV";
dcp::DCP encrypted (encrypted_path.string ());
encrypted.read ();
- BOOST_CHECK_EQUAL (encrypted.encrypted (), true);
+ BOOST_CHECK_EQUAL (encrypted.any_encrypted(), true);
dcp::DecryptedKDM kdm (
dcp::EncryptedKDM (