Remove ReelEncryptableAsset and tidy up a bit.
authorCarl Hetherington <cth@carlh.net>
Tue, 13 Apr 2021 21:36:22 +0000 (23:36 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 13 Apr 2021 21:36:22 +0000 (23:36 +0200)
31 files changed:
src/cpl.cc
src/cpl.h
src/decrypted_kdm.cc
src/decrypted_kdm.h
src/reel.cc
src/reel_asset.cc
src/reel_asset.h
src/reel_atmos_asset.cc
src/reel_atmos_asset.h
src/reel_closed_caption_asset.cc
src/reel_encryptable_asset.cc [deleted file]
src/reel_encryptable_asset.h [deleted file]
src/reel_file_asset.cc
src/reel_file_asset.h
src/reel_interop_closed_caption_asset.cc
src/reel_interop_closed_caption_asset.h
src/reel_interop_subtitle_asset.cc
src/reel_interop_subtitle_asset.h
src/reel_markers_asset.cc
src/reel_picture_asset.cc
src/reel_picture_asset.h
src/reel_smpte_closed_caption_asset.cc
src/reel_smpte_closed_caption_asset.h
src/reel_smpte_subtitle_asset.cc
src/reel_smpte_subtitle_asset.h
src/reel_sound_asset.cc
src/reel_sound_asset.h
src/reel_subtitle_asset.cc
src/reel_subtitle_asset.h
src/verify.cc
src/wscript

index 1257484abf40577e95d3a5c53dd16094a347ab90..145ce1cdcc53b273ce48b32a156701bce62dc71d 100644 (file)
@@ -538,52 +538,6 @@ CPL::reel_file_assets () const
 }
 
 
-template <class T>
-void
-add_encryptable_assets (vector<shared_ptr<T>>& assets, vector<shared_ptr<Reel>> reels)
-{
-       for (auto i: reels) {
-               if (i->main_picture ()) {
-                       assets.push_back (i->main_picture());
-               }
-               if (i->main_sound ()) {
-                       assets.push_back (i->main_sound());
-               }
-               if (i->main_subtitle ()) {
-                       if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(i->main_subtitle())) {
-                               assets.push_back (enc);
-                       }
-               }
-               for (auto j: i->closed_captions()) {
-                       if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(j)) {
-                               assets.push_back (enc);
-                       }
-               }
-               if (i->atmos ()) {
-                       assets.push_back (i->atmos());
-               }
-       }
-}
-
-
-vector<shared_ptr<ReelEncryptableAsset>>
-CPL::reel_encryptable_assets ()
-{
-       vector<shared_ptr<ReelEncryptableAsset>> c;
-       add_encryptable_assets (c, _reels);
-       return c;
-}
-
-
-vector<shared_ptr<const ReelEncryptableAsset>>
-CPL::reel_encryptable_assets () const
-{
-       vector<shared_ptr<const ReelEncryptableAsset>> c;
-       add_encryptable_assets (c, _reels);
-       return c;
-}
-
-
 bool
 CPL::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
 {
index 03e35a4e3220b3a08257572dac1642a9da047067..246233c1e0a05d141451861226630c3335c89b9b 100644 (file)
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -59,7 +59,6 @@ struct verify_invalid_language3;
 namespace dcp {
 
 
-class ReelEncryptableAsset;
 class ReelFileAsset;
 class Reel;
 class MXFMetadata;
@@ -104,10 +103,6 @@ public:
        std::vector<std::shared_ptr<const ReelFileAsset>> reel_file_assets () const;
        std::vector<std::shared_ptr<ReelFileAsset>> reel_file_assets ();
 
-       /** @return the ReelEncryptableAssets in this CPL in all reels */
-       std::vector<std::shared_ptr<const ReelEncryptableAsset>> reel_encryptable_assets () const;
-       std::vector<std::shared_ptr<ReelEncryptableAsset>> reel_encryptable_assets ();
-
        /** @return true if we have any encrypted content */
        bool any_encrypted () const;
 
index 447a0a12ee95a0d0fe93b65ca21d15747ee11e57..03c5ea26a25196ce544b932ca4832c9c500a4917 100644 (file)
  */
 
 
+#include "certificate_chain.h"
+#include "compose.hpp"
+#include "cpl.h"
+#include "dcp_assert.h"
 #include "decrypted_kdm.h"
 #include "decrypted_kdm_key.h"
 #include "encrypted_kdm.h"
-#include "reel_encryptable_asset.h"
+#include "exceptions.h"
 #include "reel_asset.h"
+#include "reel_file_asset.h"
 #include "util.h"
-#include "exceptions.h"
-#include "cpl.h"
-#include "certificate_chain.h"
-#include "dcp_assert.h"
-#include "compose.hpp"
 #include <asdcp/AS_DCP.h>
 #include <asdcp/KM_util.h>
 #include <openssl/rsa.h>
@@ -251,7 +251,7 @@ DecryptedKDM::DecryptedKDM (
 
 DecryptedKDM::DecryptedKDM (
        string cpl_id,
-       map<shared_ptr<const ReelEncryptableAsset>, Key> keys,
+       map<shared_ptr<const ReelFileAsset>, Key> keys,
        LocalTime not_valid_before,
        LocalTime not_valid_after,
        string annotation_text,
@@ -264,7 +264,7 @@ DecryptedKDM::DecryptedKDM (
        , _content_title_text (content_title_text)
        , _issue_date (issue_date)
 {
-       for (map<shared_ptr<const ReelEncryptableAsset>, Key>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
+       for (map<shared_ptr<const ReelFileAsset>, Key>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
                add_key (i->first->key_type(), i->first->key_id().get(), i->second, cpl_id, Standard::SMPTE);
        }
 }
@@ -287,9 +287,9 @@ DecryptedKDM::DecryptedKDM (
 {
        /* Create DecryptedKDMKey objects for each encryptable asset */
        bool did_one = false;
-       for (auto i: cpl->reel_encryptable_assets()) {
-               if (i->key_id()) {
-                       add_key (i->key_type(), i->key_id().get(), key, cpl->id(), Standard::SMPTE);
+       for (auto i: cpl->reel_file_assets()) {
+               if (i->encryptable()) {
+                       add_key (i->key_type().get(), i->key_id().get(), key, cpl->id(), Standard::SMPTE);
                        did_one = true;
                }
        }
index 16b0acbab0fc4280939239960b82f4d36d6cece0..6bdd9fcd459006226af62d57985286d21e6fbb2f 100644 (file)
@@ -60,7 +60,7 @@ class DecryptedKDMKey;
 class EncryptedKDM;
 class CertificateChain;
 class CPL;
-class ReelEncryptableAsset;
+class ReelFileAsset;
 
 
 /** @class DecryptedKDM
@@ -99,7 +99,7 @@ public:
         */
        DecryptedKDM (
                std::string cpl_id,
-               std::map<std::shared_ptr<const ReelEncryptableAsset>, Key> keys,
+               std::map<std::shared_ptr<const ReelFileAsset>, Key> keys,
                LocalTime not_valid_before,
                LocalTime not_valid_after,
                std::string annotation_text,
index 4baa2fc9bfe981283b2e625539b3bf2346200030..e99f7140d809cb568befc96467da0daadb7e0bc4 100644 (file)
@@ -274,24 +274,15 @@ Reel::any_encrypted () const
 {
        auto ecc = false;
        for (auto i: _closed_captions) {
-               if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(i)) {
-                       if (enc->encrypted()) {
-                               ecc = true;
-                       }
-               }
-       }
-
-       bool esub = false;
-       if (_main_subtitle) {
-               if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(_main_picture)) {
-                       esub = enc->encrypted();
+               if (i->encrypted()) {
+                       ecc = true;
                }
        }
 
        return (
                (_main_picture && _main_picture->encrypted()) ||
                (_main_sound && _main_sound->encrypted()) ||
-               esub ||
+               (_main_subtitle && _main_subtitle->encrypted()) ||
                ecc ||
                (_atmos && _atmos->encrypted())
                );
@@ -303,25 +294,15 @@ Reel::all_encrypted () const
 {
        auto ecc = true;
        for (auto i: _closed_captions) {
-               if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(i)) {
-                       if (!enc->encrypted()) {
-                               ecc = false;
-                       }
-               }
-       }
-
-       /* It's ok if there's no subtitle, or it's not encryptable */
-       bool esub = true;
-       if (_main_subtitle) {
-               if (auto enc = dynamic_pointer_cast<ReelEncryptableAsset>(_main_picture)) {
-                       esub = enc->encrypted();
+               if (!i->encrypted()) {
+                       ecc = false;
                }
        }
 
        return (
                (!_main_picture || _main_picture->encrypted()) &&
                (!_main_sound || _main_sound->encrypted()) &&
-               esub &&
+               (!_main_subtitle || _main_subtitle->encrypted()) &&
                ecc &&
                (!_atmos || _atmos->encrypted())
               );
index cd54ccba753f43fc93a11fcfb2ecfb2efc185063..1a6a25bee0b19d215cbab3832fd053aa675b4d60 100644 (file)
@@ -78,7 +78,7 @@ ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
 
 
 xmlpp::Node*
-ReelAsset::write_to_cpl_asset (xmlpp::Node* node, Standard standard, optional<string> hash) const
+ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
 {
        auto a = node->add_child (cpl_node_name (standard));
        auto const attr = cpl_node_attribute (standard);
@@ -99,9 +99,6 @@ ReelAsset::write_to_cpl_asset (xmlpp::Node* node, Standard standard, optional<st
        if (_duration) {
                a->add_child("Duration")->add_child_text(raw_convert<string>(*_duration));
        }
-       if (hash) {
-               a->add_child("Hash")->add_child_text (hash.get());
-       }
        return a;
 }
 
index 00355335ec10e716604ad2ba29debe86246690a1..ab06434ebe5f2f14774def1dc267e4afad623128 100644 (file)
@@ -83,7 +83,11 @@ public:
 
        explicit ReelAsset (std::shared_ptr<const cxml::Node>);
 
-       virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const = 0;
+       virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const;
+
+       virtual bool encryptable () const {
+               return false;
+       }
 
        Fraction edit_rate () const {
                return _edit_rate;
@@ -139,8 +143,6 @@ protected:
        /** @return Any namespace that should be used on the asset's node in the CPL */
        virtual std::pair<std::string, std::string> cpl_node_namespace () const;
 
-       xmlpp::Node* write_to_cpl_asset (xmlpp::Node* node, Standard standard, boost::optional<std::string> hash) const;
-
        int64_t _intrinsic_duration = 0;       ///< The &lt;IntrinsicDuration&gt; from the reel's entry for this asset
        boost::optional<int64_t> _duration;    ///< The &lt;Duration&gt; from the reel's entry for this asset, if present
 
index b17dceca48446e82bd416e3bc689817711b6266f..1df26ce9d4b77dfe377d4249961027fff7434751 100644 (file)
@@ -51,8 +51,7 @@ using namespace dcp;
 
 
 ReelAtmosAsset::ReelAtmosAsset (std::shared_ptr<AtmosAsset> asset, int64_t entry_point)
-       : ReelFileAsset (asset, asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
-       , ReelEncryptableAsset (asset->key_id())
+       : ReelFileAsset (asset, asset->key_id(), asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
 {
 
 }
@@ -60,7 +59,6 @@ ReelAtmosAsset::ReelAtmosAsset (std::shared_ptr<AtmosAsset> asset, int64_t entry
 
 ReelAtmosAsset::ReelAtmosAsset (std::shared_ptr<const cxml::Node> node)
        : ReelFileAsset (node)
-       , ReelEncryptableAsset (node)
 {
        node->ignore_child ("DataType");
        node->done ();
@@ -81,18 +79,10 @@ ReelAtmosAsset::cpl_node_namespace () const
 }
 
 
-string
-ReelAtmosAsset::key_type () const
-{
-       return "MDEK";
-}
-
-
 xmlpp::Node *
 ReelAtmosAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
 {
-       auto asset = write_to_cpl_asset (node, standard, hash());
-       write_to_cpl_encryptable (asset);
+       auto asset = ReelFileAsset::write_to_cpl (node, standard);
        asset->add_child("axd:DataType")->add_child_text("urn:smpte:ul:060e2b34.04010105.0e090604.00000000");
        return asset;
 }
index 8aaf6a592f32833246a0feeb7238568b02959eb0..2e4a8d4e36ae7d982ea10f174cd3cae5aed21bef 100644 (file)
@@ -41,9 +41,8 @@
 #define LIBDCP_REEL_ATMOS_ASSET_H
 
 
-#include "reel_asset.h"
+#include "reel_file_asset.h"
 #include "atmos_asset.h"
-#include "reel_encryptable_asset.h"
 
 
 namespace dcp {
@@ -55,7 +54,7 @@ class AtmosAsset;
 /** @class ReelAtmosAsset
  *  @brief Part of a Reel's description which refers to a Atmos MXF
  */
-class ReelAtmosAsset : public ReelFileAsset, public ReelEncryptableAsset
+class ReelAtmosAsset : public ReelFileAsset
 {
 public:
        ReelAtmosAsset (std::shared_ptr<AtmosAsset> asset, int64_t entry_point);
@@ -69,7 +68,9 @@ public:
        bool equals (std::shared_ptr<const ReelAtmosAsset>, EqualityOptions, NoteHandler) const;
 
 private:
-       std::string key_type () const override;
+       boost::optional<std::string> key_type () const override {
+               return std::string("MDEK");
+       }
        std::string cpl_node_name (Standard standard) const override;
        std::pair<std::string, std::string> cpl_node_namespace () const override;
 };
index 4ba6fe0c3386c5091590ca7d2e039afa5be94f5b..3e4627d3eb3989eb89d0275742525bdcbeed43c2 100644 (file)
@@ -54,7 +54,14 @@ using namespace dcp;
 
 
 ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
-       : ReelFileAsset (asset, asset->id(), edit_rate, intrinsic_duration, entry_point)
+       : ReelFileAsset (
+               asset,
+               dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : boost::none,
+               asset->id(),
+               edit_rate,
+               intrinsic_duration,
+               entry_point
+               )
 {
 
 }
@@ -79,3 +86,5 @@ ReelClosedCaptionAsset::equals (shared_ptr<const ReelClosedCaptionAsset> other,
 
        return true;
 }
+
+
diff --git a/src/reel_encryptable_asset.cc b/src/reel_encryptable_asset.cc
deleted file mode 100644 (file)
index f8e8303..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
-
-    This file is part of libdcp.
-
-    libdcp is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    libdcp is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
-
-    In addition, as a special exception, the copyright holders give
-    permission to link the code of portions of this program with the
-    OpenSSL library under certain conditions as described in each
-    individual source file, and distribute linked combinations
-    including the two.
-
-    You must obey the GNU General Public License in all respects
-    for all of the code used other than OpenSSL.  If you modify
-    file(s) with this exception, you may extend this exception to your
-    version of the file(s), but you are not obligated to do so.  If you
-    do not wish to do so, delete this exception statement from your
-    version.  If you delete this exception statement from all source
-    files in the program, then also delete it here.
-*/
-
-
-/** @file  src/reel_encryptable_asset.cc
- *  @brief ReelEncryptableAsset class
- */
-
-
-#include "reel_encryptable_asset.h"
-#include "util.h"
-#include "mxf.h"
-#include "dcp_assert.h"
-#include <libcxml/cxml.h>
-#include <libxml++/libxml++.h>
-
-
-using std::string;
-using std::shared_ptr;
-using boost::optional;
-using namespace dcp;
-
-
-ReelEncryptableAsset::ReelEncryptableAsset (optional<string> key_id)
-       : _key_id (key_id)
-{
-
-}
-
-
-ReelEncryptableAsset::ReelEncryptableAsset (shared_ptr<const cxml::Node> node)
-       : _key_id (node->optional_string_child("KeyId"))
-{
-       if (_key_id) {
-               _key_id = remove_urn_uuid (*_key_id);
-       }
-}
-
-
-void
-ReelEncryptableAsset::write_to_cpl_encryptable (xmlpp::Node* node) const
-{
-        if (key_id()) {
-               auto hash = find_child (node, "Hash");
-               node->add_child_before(hash, "KeyId")->add_child_text("urn:uuid:" + key_id().get());
-        }
-}
diff --git a/src/reel_encryptable_asset.h b/src/reel_encryptable_asset.h
deleted file mode 100644 (file)
index 0eeb964..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
-
-    This file is part of libdcp.
-
-    libdcp is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    libdcp is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
-
-    In addition, as a special exception, the copyright holders give
-    permission to link the code of portions of this program with the
-    OpenSSL library under certain conditions as described in each
-    individual source file, and distribute linked combinations
-    including the two.
-
-    You must obey the GNU General Public License in all respects
-    for all of the code used other than OpenSSL.  If you modify
-    file(s) with this exception, you may extend this exception to your
-    version of the file(s), but you are not obligated to do so.  If you
-    do not wish to do so, delete this exception statement from your
-    version.  If you delete this exception statement from all source
-    files in the program, then also delete it here.
-*/
-
-
-/** @file  src/reel_encryptable_asset.h
- *  @brief ReelEncryptableAsset class
- */
-
-
-#ifndef LIBDCP_REEL_ENCRYPTABLE_ASSET_H
-#define LIBDCP_REEL_ENCRYPTABLE_ASSET_H
-
-
-#include "reel_file_asset.h"
-#include "ref.h"
-#include <boost/optional.hpp>
-#include <memory>
-#include <string>
-
-
-namespace cxml {
-       class Node;
-}
-
-
-namespace dcp {
-
-
-/** @class ReelEncryptableAsset
- *  @brief Part of a Reel's description which refers to an asset which can be encrypted
- */
-class ReelEncryptableAsset
-{
-public:
-       explicit ReelEncryptableAsset (boost::optional<std::string> key_id);
-       explicit ReelEncryptableAsset (std::shared_ptr<const cxml::Node>);
-       virtual ~ReelEncryptableAsset () {}
-
-       /** @return the 4-character key type for this MXF (MDIK, MDAK, etc.) */
-       virtual std::string key_type () const = 0;
-
-       /** @return true if a KeyId is specified for this asset, implying
-        *  that its content is encrypted.
-        */
-       bool encrypted () const {
-               return static_cast<bool>(_key_id);
-       }
-
-       /** @return Key ID to describe the key that encrypts this asset's
-        *  content, if there is one.
-        */
-       boost::optional<std::string> key_id () const {
-               return _key_id;
-       }
-
-protected:
-       void write_to_cpl_encryptable (xmlpp::Node* node) const;
-
-private:
-       boost::optional<std::string> _key_id; ///< The &lt;KeyId&gt; from the reel's entry for this asset, if there is one
-};
-
-
-}
-
-
-#endif
index 85bf9de71b80e6a96a30a88ab4547f26cda90bf3..1ca77b4d764aaf3e05136ec65d8ccf280b1a3f0b 100644 (file)
 
 #include "asset.h"
 #include "reel_file_asset.h"
+#include <libxml++/libxml++.h>
 
 
 using std::shared_ptr;
+using std::string;
+using boost::optional;
 using namespace dcp;
 
 
-ReelFileAsset::ReelFileAsset (shared_ptr<Asset> asset, std::string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+ReelFileAsset::ReelFileAsset (shared_ptr<Asset> asset, optional<string> key_id, std::string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
        : ReelAsset (id, edit_rate, intrinsic_duration, entry_point)
        , _asset_ref (asset)
        , _hash (asset->hash())
+       , _key_id (key_id)
 {
 
 }
@@ -57,9 +61,12 @@ ReelFileAsset::ReelFileAsset (shared_ptr<Asset> asset, std::string id, Fraction
 ReelFileAsset::ReelFileAsset (shared_ptr<const cxml::Node> node)
        : ReelAsset (node)
        , _asset_ref (remove_urn_uuid(node->string_child("Id")))
-       , _hash (node->optional_string_child ("Hash"))
+       , _hash (node->optional_string_child("Hash"))
+       , _key_id (node->optional_string_child("KeyId"))
 {
-
+       if (_key_id) {
+               _key_id = remove_urn_uuid (*_key_id);
+       }
 }
 
 
@@ -82,3 +89,17 @@ ReelFileAsset::file_asset_equals (shared_ptr<const ReelFileAsset> other, Equalit
        return true;
 }
 
+
+xmlpp::Node *
+ReelFileAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+{
+       auto asset = ReelAsset::write_to_cpl (node, standard);
+        if (_key_id) {
+               asset->add_child("KeyId")->add_child_text("urn:uuid:" + *_key_id);
+        }
+       if (_hash) {
+               asset->add_child("Hash")->add_child_text(*_hash);
+       }
+       return asset;
+}
+
index 042f94b4852b5572ed9d31347d96d189e4042145..6ef917abf79f5f8b9ad5f4f6f0d787f84e8ee165 100644 (file)
@@ -53,9 +53,11 @@ namespace dcp {
 class ReelFileAsset : public ReelAsset
 {
 public:
-       ReelFileAsset (std::shared_ptr<Asset> asset, std::string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
+       ReelFileAsset (std::shared_ptr<Asset> asset, boost::optional<std::string> key_id, std::string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
        explicit ReelFileAsset (std::shared_ptr<const cxml::Node> node);
 
+       virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+
        /** @return a Ref to our actual asset */
        Ref const & asset_ref () const {
                return _asset_ref;
@@ -79,6 +81,22 @@ public:
 
        bool file_asset_equals (std::shared_ptr<const ReelFileAsset> other, EqualityOptions opt, NoteHandler note) const;
 
+       virtual boost::optional<std::string> key_type () const {
+               return boost::none;
+       }
+
+       bool encryptable () const override {
+               return static_cast<bool>(key_type());
+       }
+
+       boost::optional<std::string> key_id () const {
+               return _key_id;
+       }
+
+       bool encrypted () const {
+               return static_cast<bool>(key_id());
+       }
+
 protected:
 
        template <class T>
@@ -98,6 +116,7 @@ protected:
 
        /** Either our asset's computed hash or the hash read in from the CPL, if it's present */
        boost::optional<std::string> _hash;
+       boost::optional<std::string> _key_id; ///< The &lt;KeyId&gt; from the reel's entry for this asset, if there is one
 };
 
 
index 0730f77e8f8709b02338b31ffd5798d5adb9d1f6..3e85b135377f518d89a79eaf7d4c26e12230eab7 100644 (file)
@@ -58,18 +58,6 @@ ReelInteropClosedCaptionAsset::ReelInteropClosedCaptionAsset (shared_ptr<const c
 }
 
 
-xmlpp::Node *
-ReelInteropClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
-{
-       auto asset = write_to_cpl_asset (node, standard, hash());
-       if (_language) {
-               asset->add_child("Language")->add_child_text(*_language);
-       }
-
-       return asset;
-}
-
-
 string
 ReelInteropClosedCaptionAsset::cpl_node_name (Standard) const
 {
@@ -83,3 +71,13 @@ ReelInteropClosedCaptionAsset::cpl_node_namespace () const
        return make_pair("http://www.digicine.com/PROTO-ASDCP-CC-CPL-20070926#", "cc-cpl");
 }
 
+
+xmlpp::Node *
+ReelInteropClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+{
+       auto asset = ReelClosedCaptionAsset::write_to_cpl (node, standard);
+       if (_language) {
+               asset->add_child("Language")->add_child_text(*_language);
+       }
+       return asset;
+}
index 8031142d5c63422b59a963e0d8433ca3d73947f0..bb5b5cecde93e3c2a370e0cbb34b56fdec3548fc 100644 (file)
@@ -54,12 +54,12 @@ public:
        ReelInteropClosedCaptionAsset (std::shared_ptr<InteropSubtitleAsset> asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point);
        explicit ReelInteropClosedCaptionAsset (std::shared_ptr<const cxml::Node>);
 
+       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+
        std::shared_ptr<InteropSubtitleAsset> interop_asset () const {
                return std::dynamic_pointer_cast<InteropSubtitleAsset>(asset());
        }
 
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const;
-
 private:
        std::string cpl_node_name (Standard) const;
        std::pair<std::string, std::string> cpl_node_namespace () const override;
index 5b8cfcddfe72ae85783fd9bba70e6a013f952e0b..08ea4bb40a7b9565e67b30278b02bd1e515f1fd5 100644 (file)
@@ -60,15 +60,3 @@ ReelInteropSubtitleAsset::ReelInteropSubtitleAsset (std::shared_ptr<const cxml::
        node->done ();
 }
 
-
-xmlpp::Node *
-ReelInteropSubtitleAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
-{
-       auto asset = write_to_cpl_asset (node, standard, _hash);
-       if (_language) {
-               asset->add_child("Language")->add_child_text(*_language);
-       }
-       return asset;
-}
-
-
index 41c4fa67a2e2ec00d36214916533940a4db2bfd2..83a7ab25d7f4c31bc2d19950fd02d05454f979dc 100644 (file)
@@ -57,8 +57,6 @@ public:
        std::shared_ptr<InteropSubtitleAsset> interop_asset () const {
                return std::dynamic_pointer_cast<InteropSubtitleAsset>(asset());
        }
-
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const;
 };
 
 
index c6339df5dd6969dae923b920cd3861ce697b02bb..55a50a68992b2de56be9e6b52ea766d86931034e 100644 (file)
@@ -105,7 +105,7 @@ xmlpp::Node*
 ReelMarkersAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
 {
        int const tcr = edit_rate().numerator / edit_rate().denominator;
-       auto asset = write_to_cpl_asset (node, standard, optional<string>());
+       auto asset = ReelAsset::write_to_cpl (node, standard);
        auto ml = asset->add_child("MarkerList");
        for (auto const& i: _markers) {
                auto m = ml->add_child("Marker");
index ddc6a802eb9017bf5a297109b3322ebe9b00d9de..4f7f863f086ba1fe1a13c588cd3b86038b25e2af 100644 (file)
@@ -57,8 +57,7 @@ using namespace dcp;
 
 
 ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureAsset> asset, int64_t entry_point)
-       : ReelFileAsset (asset, asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
-       , ReelEncryptableAsset (asset->key_id())
+       : ReelFileAsset (asset, asset->key_id(), asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
        , _frame_rate (asset->frame_rate ())
        , _screen_aspect_ratio (asset->screen_aspect_ratio ())
 {
@@ -68,7 +67,6 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureAsset> asset, int64_t entr
 
 ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
        : ReelFileAsset (node)
-       , ReelEncryptableAsset (node)
 {
        _frame_rate = Fraction (node->string_child ("FrameRate"));
        try {
@@ -88,9 +86,10 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
 xmlpp::Node*
 ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
 {
-       auto asset = write_to_cpl_asset (node, standard, hash());
+       auto asset = ReelFileAsset::write_to_cpl (node, standard);
 
        asset->add_child("FrameRate")->add_child_text(String::compose("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
+
        if (standard == Standard::INTEROP) {
 
                /* Allowed values for this tag from the standard */
@@ -111,26 +110,17 @@ ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
                        }
                }
 
-               asset->add_child ("ScreenAspectRatio")->add_child_text (raw_convert<string> (closest.get(), 2, true));
+               asset->add_child("ScreenAspectRatio")->add_child_text(raw_convert<string>(closest.get(), 2, true));
        } else {
-               asset->add_child ("ScreenAspectRatio")->add_child_text (
+               asset->add_child("ScreenAspectRatio")->add_child_text(
                        String::compose ("%1 %2", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator)
                        );
        }
 
-       write_to_cpl_encryptable (asset);
-
        return asset;
 }
 
 
-string
-ReelPictureAsset::key_type () const
-{
-       return "MDIK";
-}
-
-
 bool
 ReelPictureAsset::equals (shared_ptr<const ReelPictureAsset> other, EqualityOptions opt, NoteHandler note) const
 {
index 6eb01bc9e36df5ed8150978e6e76293b01d3f70c..5a925e24ad93918aaa1f7f51f822c9fbed82fee4 100644 (file)
@@ -41,8 +41,7 @@
 #define LIBDCP_REEL_PICTURE_ASSET_H
 
 
-#include "reel_encryptable_asset.h"
-#include "reel_asset.h"
+#include "reel_file_asset.h"
 #include "picture_asset.h"
 
 
@@ -52,7 +51,7 @@ namespace dcp {
 /** @class ReelPictureAsset
  *  @brief Part of a Reel's description which refers to a picture asset
  */
-class ReelPictureAsset : public ReelFileAsset, public ReelEncryptableAsset
+class ReelPictureAsset : public ReelFileAsset
 {
 public:
        ReelPictureAsset (std::shared_ptr<PictureAsset> asset, int64_t entry_point);
@@ -88,7 +87,9 @@ public:
        }
 
 private:
-       std::string key_type () const;
+       boost::optional<std::string> key_type () const override {
+               return std::string ("MDIK");
+       }
 
        Fraction _frame_rate;
        Fraction _screen_aspect_ratio;
index 441250376f2266b8b795734f511a7a5e4f330665..34fba18b9fea64753349b5f42b5ecaa428978177 100644 (file)
@@ -50,7 +50,6 @@ using namespace dcp;
 
 ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
        : ReelClosedCaptionAsset (asset, edit_rate, intrinsic_duration, entry_point)
-       , ReelEncryptableAsset (asset->key_id())
 {
 
 }
@@ -58,7 +57,6 @@ ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<SMPTESubtit
 
 ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<const cxml::Node> node)
        : ReelClosedCaptionAsset (node)
-       , ReelEncryptableAsset (node)
 {
        node->done ();
 }
@@ -67,13 +65,10 @@ ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<const cxml:
 xmlpp::Node *
 ReelSMPTEClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
 {
-       auto asset = write_to_cpl_asset (node, standard, hash());
-       write_to_cpl_encryptable (asset);
-
+       auto asset = ReelClosedCaptionAsset::write_to_cpl (node, standard);
        if (_language) {
                asset->add_child("Language", "tt")->add_child_text(*_language);
        }
-
        return asset;
 }
 
index 32fe511768d8f893e5d3f24a929f1c6e663dd1d6..889ce5f6d8db9357d2c2c1b182626a799ec3fdf8 100644 (file)
@@ -41,7 +41,6 @@
 #define LIBDCP_REEL_SMPTE_CLOSED_CAPTION_ASSET_H
 
 
-#include "reel_encryptable_asset.h"
 #include "reel_file_asset.h"
 #include "reel_closed_caption_asset.h"
 #include "smpte_subtitle_asset.h"
@@ -50,7 +49,7 @@
 namespace dcp {
 
 
-class ReelSMPTEClosedCaptionAsset : public ReelClosedCaptionAsset, public ReelEncryptableAsset
+class ReelSMPTEClosedCaptionAsset : public ReelClosedCaptionAsset
 {
 public:
        ReelSMPTEClosedCaptionAsset (std::shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point);
@@ -63,8 +62,8 @@ public:
        }
 
 private:
-       std::string key_type () const override {
-               return "MDSK";
+       boost::optional<std::string> key_type () const override {
+               return std::string("MDSK");
        }
 
        std::string cpl_node_name (Standard) const override;
index 0cd38c21e2f4d6190d2c5f6b15b2e22e35ac0f72..5a7c8c6ca4db79722c6b7902c9655025dd49a2b5 100644 (file)
@@ -50,7 +50,6 @@ using namespace dcp;
 
 ReelSMPTESubtitleAsset::ReelSMPTESubtitleAsset (shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
        : ReelSubtitleAsset (asset, edit_rate, intrinsic_duration, entry_point)
-       , ReelEncryptableAsset (asset->key_id())
 {
 
 }
@@ -58,20 +57,7 @@ ReelSMPTESubtitleAsset::ReelSMPTESubtitleAsset (shared_ptr<SMPTESubtitleAsset> a
 
 ReelSMPTESubtitleAsset::ReelSMPTESubtitleAsset (shared_ptr<const cxml::Node> node)
        : ReelSubtitleAsset (node)
-       , ReelEncryptableAsset (node)
 {
        node->done ();
 }
 
-
-xmlpp::Node *
-ReelSMPTESubtitleAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
-{
-       auto asset = write_to_cpl_asset (node, standard, _hash);
-       write_to_cpl_encryptable (asset);
-       if (_language) {
-               asset->add_child("Language")->add_child_text(*_language);
-       }
-       return asset;
-}
-
index 8a7e0c24445c78c6122c52d36c0ae15c1396fb6c..aaff9a98b674f103706548fbb6f51fab7f939079 100644 (file)
@@ -37,7 +37,6 @@
  */
 
 
-#include "reel_encryptable_asset.h"
 #include "reel_subtitle_asset.h"
 #include "smpte_subtitle_asset.h"
 
@@ -51,21 +50,19 @@ class SMPTESubtitleAsset;
 /** @class ReelSMPTESubtitleAsset
  *  @brief Part of a Reel's description which refers to an SMPTE subtitle MXF file
  */
-class ReelSMPTESubtitleAsset : public ReelSubtitleAsset, public ReelEncryptableAsset
+class ReelSMPTESubtitleAsset : public ReelSubtitleAsset
 {
 public:
        ReelSMPTESubtitleAsset (std::shared_ptr<SMPTESubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
        explicit ReelSMPTESubtitleAsset (std::shared_ptr<const cxml::Node>);
 
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
-
        std::shared_ptr<SMPTESubtitleAsset> smpte_asset () const {
                return std::dynamic_pointer_cast<SMPTESubtitleAsset>(asset());
        }
 
 private:
-       std::string key_type () const {
-               return "MDSK";
+       boost::optional<std::string> key_type () const override {
+               return std::string("MDSK");
        }
 };
 
index 9cf672dffe184fc18536fb6ddecdbfaeff0dae50..e944467f130d294fc2216994324fbc2ca6ef709b 100644 (file)
 
 using std::string;
 using std::shared_ptr;
+using boost::optional;
 using namespace dcp;
 
 
 ReelSoundAsset::ReelSoundAsset (shared_ptr<SoundAsset> asset, int64_t entry_point)
-       : ReelFileAsset (asset, asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
-       , ReelEncryptableAsset (asset->key_id())
+       : ReelFileAsset (asset, asset->key_id(), asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
 {
 
 }
@@ -58,7 +58,6 @@ ReelSoundAsset::ReelSoundAsset (shared_ptr<SoundAsset> asset, int64_t entry_poin
 
 ReelSoundAsset::ReelSoundAsset (shared_ptr<const cxml::Node> node)
        : ReelFileAsset (node)
-       , ReelEncryptableAsset (node)
 {
        node->ignore_child ("Language");
        node->done ();
@@ -72,19 +71,10 @@ ReelSoundAsset::cpl_node_name (Standard) const
 }
 
 
-string
+optional<string>
 ReelSoundAsset::key_type () const
 {
-       return "MDAK";
-}
-
-
-xmlpp::Node *
-ReelSoundAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
-{
-       auto asset = write_to_cpl_asset (node, standard, hash());
-       write_to_cpl_encryptable (asset);
-       return asset;
+       return string("MDAK");
 }
 
 
index bf686ec9fcf62281a535483008520971f60d4d6e..0b4d0f9d2e9fed5d12b7aa6a42c86b7a96e465b4 100644 (file)
@@ -37,8 +37,7 @@
  */
 
 
-#include "reel_encryptable_asset.h"
-#include "reel_asset.h"
+#include "reel_file_asset.h"
 #include "sound_asset.h"
 #include <memory>
 #include <string>
@@ -50,27 +49,26 @@ namespace dcp {
 /** @class ReelSoundAsset
  *  @brief Part of a Reel's description which refers to a sound asset
  */
-class ReelSoundAsset : public ReelFileAsset, public ReelEncryptableAsset
+class ReelSoundAsset : public ReelFileAsset
 {
 public:
        ReelSoundAsset (std::shared_ptr<dcp::SoundAsset> content, int64_t entry_point);
        explicit ReelSoundAsset (std::shared_ptr<const cxml::Node>);
 
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const;
        bool equals (std::shared_ptr<const ReelSoundAsset>, EqualityOptions, NoteHandler) const;
 
        /** @return the SoundAsset that this object refers to */
        std::shared_ptr<SoundAsset> asset () {
-               return asset_of_type<SoundAsset> ();
+               return asset_of_type<SoundAsset>();
        }
 
        /** @return the SoundAsset that this object refers to */
        std::shared_ptr<const SoundAsset> asset () const {
-               return asset_of_type<const SoundAsset> ();
+               return asset_of_type<const SoundAsset>();
        }
 
 private:
-       std::string key_type () const;
+       boost::optional<std::string> key_type () const;
        std::string cpl_node_name (Standard standard) const;
 };
 
index 9c683caad63e6c4cef5dc1bfd23e957232c7fadf..e3ca20065150c88f8f804aa216f48ba7e9b1f53b 100644 (file)
@@ -52,7 +52,14 @@ using namespace dcp;
 
 
 ReelSubtitleAsset::ReelSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
-       : ReelFileAsset (asset, asset->id(), edit_rate, intrinsic_duration, entry_point)
+       : ReelFileAsset (
+               asset,
+               dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : boost::none,
+               asset->id(),
+               edit_rate,
+               intrinsic_duration,
+               entry_point
+               )
 {
 
 }
@@ -85,11 +92,22 @@ ReelSubtitleAsset::equals (shared_ptr<const ReelSubtitleAsset> other, EqualityOp
        if (!asset_equals (other, opt, note)) {
                return false;
        }
-
-       if (_asset_ref.resolved() && other->_asset_ref.resolved()) {
-               return _asset_ref->equals (other->_asset_ref.asset(), opt, note);
+       if (!file_asset_equals (other, opt, note)) {
+               return false;
        }
 
        return true;
 }
 
+
+xmlpp::Node *
+ReelSubtitleAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+{
+       auto asset = ReelFileAsset::write_to_cpl (node, standard);
+       if (_language) {
+               asset->add_child("Language")->add_child_text(*_language);
+       }
+       return asset;
+}
+
+
index fd4c5cd19a632e0d4a250b91b444145dae2216f2..a4e674ba419e52f97b50aefebe7f4146a0e1501b 100644 (file)
@@ -65,6 +65,8 @@ public:
        ReelSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
        explicit ReelSubtitleAsset (std::shared_ptr<const cxml::Node>);
 
+       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const;
+
        bool equals (std::shared_ptr<const ReelSubtitleAsset>, EqualityOptions, NoteHandler) const;
 
        std::shared_ptr<SubtitleAsset> asset () const {
index e176362aeae3a78e98056eb9842cb6c409607211..a2298f385ce98dae4b93f62d1196d5796ffdcad1 100644 (file)
@@ -1088,14 +1088,9 @@ pkl_has_encrypted_assets (shared_ptr<DCP> dcp, shared_ptr<PKL> pkl)
        for (auto i: dcp->cpls()) {
                for (auto j: i->reel_file_assets()) {
                        if (j->asset_ref().resolved()) {
-                               /* It's a bit surprising / broken but Interop subtitle assets are represented
-                                * in reels by ReelSubtitleAsset which inherits ReelEncryptableAsset, so it's possible for
-                                * ReelEncryptableAssets to have assets which are not MXFs.
-                                */
-                               if (auto asset = dynamic_pointer_cast<MXF>(j->asset_ref().asset())) {
-                                       if (asset->encrypted()) {
-                                               encrypted.push_back(j->asset_ref().id());
-                                       }
+                               auto mxf = dynamic_pointer_cast<MXF>(j->asset_ref().asset());
+                               if (mxf && mxf->encrypted()) {
+                                       encrypted.push_back(j->asset_ref().id());
                                }
                        }
                }
@@ -1242,7 +1237,7 @@ dcp::verify (
                                                notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::INVALID_INTRINSIC_DURATION, i->id()});
                                        }
                                        auto file_asset = dynamic_pointer_cast<ReelFileAsset>(i);
-                                       if (dynamic_pointer_cast<ReelEncryptableAsset>(i) && !file_asset->hash()) {
+                                       if (i->encryptable() && !file_asset->hash()) {
                                                notes.push_back ({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::MISSING_HASH, i->id()});
                                        }
                                }
index f6e0d15b00269bb1790ae559d682f9f3690e26dc..de7d8e67aa5563133de8898ad789acec92760896 100644 (file)
@@ -82,7 +82,6 @@ def build(bld):
              reel_asset.cc
              reel_atmos_asset.cc
              reel_closed_caption_asset.cc
-             reel_encryptable_asset.cc
              reel_file_asset.cc
              reel_interop_closed_caption_asset.cc
              reel_interop_subtitle_asset.cc
@@ -173,7 +172,7 @@ def build(bld):
               reel.h
               reel_asset.h
               reel_atmos_asset.h
-              reel_encryptable_asset.h
+              reel_closed_caption_asset.h
               reel_file_asset.h
               reel_interop_closed_caption_asset.h
               reel_interop_subtitle_asset.h