Rename ReelMXF -> ReelFileAsset.
authorCarl Hetherington <cth@carlh.net>
Tue, 26 Jan 2021 20:52:21 +0000 (21:52 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 26 Jan 2021 20:52:21 +0000 (21:52 +0100)
21 files changed:
src/cpl.cc
src/cpl.h
src/dcp.cc
src/decrypted_kdm.cc
src/decrypted_kdm.h
src/reel_atmos_asset.cc
src/reel_atmos_asset.h
src/reel_closed_caption_asset.cc
src/reel_closed_caption_asset.h
src/reel_file_asset.cc [new file with mode: 0644]
src/reel_file_asset.h [new file with mode: 0644]
src/reel_mxf.cc [deleted file]
src/reel_mxf.h [deleted file]
src/reel_picture_asset.cc
src/reel_picture_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 5f8d895560391ec5e7d4028e771207ae8f142718..c528af31ebb763796db993bac48efd62839cad7b 100644 (file)
@@ -491,55 +491,43 @@ CPL::maybe_write_composition_metadata_asset (xmlpp::Element* node) const
 }
 
 
-vector<shared_ptr<ReelMXF>>
-CPL::reel_mxfs ()
+template <class T>
+void
+add_file_assets (vector<shared_ptr<T>>& assets, vector<shared_ptr<Reel>> reels)
 {
-       vector<shared_ptr<ReelMXF>> c;
-
-       for (auto i: _reels) {
+       for (auto i: reels) {
                if (i->main_picture ()) {
-                       c.push_back (i->main_picture());
+                       assets.push_back (i->main_picture());
                }
                if (i->main_sound ()) {
-                       c.push_back (i->main_sound());
+                       assets.push_back (i->main_sound());
                }
                if (i->main_subtitle ()) {
-                       c.push_back (i->main_subtitle());
+                       assets.push_back (i->main_subtitle());
                }
                for (auto j: i->closed_captions()) {
-                       c.push_back (j);
+                       assets.push_back (j);
                }
                if (i->atmos ()) {
-                       c.push_back (i->atmos());
+                       assets.push_back (i->atmos());
                }
        }
+}
+
 
+vector<shared_ptr<ReelFileAsset>>
+CPL::reel_file_assets ()
+{
+       vector<shared_ptr<ReelFileAsset>> c;
+       add_file_assets (c, _reels);
        return c;
 }
 
-vector<shared_ptr<const ReelMXF>>
-CPL::reel_mxfs () const
+vector<shared_ptr<const ReelFileAsset>>
+CPL::reel_file_assets () const
 {
-       vector<shared_ptr<const ReelMXF>> c;
-
-       for (auto i: _reels) {
-               if (i->main_picture ()) {
-                       c.push_back (i->main_picture());
-               }
-               if (i->main_sound ()) {
-                       c.push_back (i->main_sound());
-               }
-               if (i->main_subtitle ()) {
-                       c.push_back (i->main_subtitle());
-               }
-               for (auto j: i->closed_captions()) {
-                       c.push_back (j);
-               }
-               if (i->atmos ()) {
-                       c.push_back (i->atmos());
-               }
-       }
-
+       vector<shared_ptr<const ReelFileAsset>> c;
+       add_file_assets (c, _reels);
        return c;
 }
 
index 78d3d907a20b798f8cc62f542aa5e255956b2e20..72818fb14d98418f61a48c07f0865fb46edbef04 100644 (file)
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -59,7 +59,7 @@ struct verify_invalid_language3;
 namespace dcp {
 
 
-class ReelMXF;
+class ReelFileAsset;
 class Reel;
 class MXFMetadata;
 class CertificateChain;
@@ -99,9 +99,9 @@ public:
                return _reels;
        }
 
-       /** @return the ReelMXFs in this CPL in all reels */
-       std::vector<std::shared_ptr<const ReelMXF>> reel_mxfs () const;
-       std::vector<std::shared_ptr<ReelMXF>> reel_mxfs ();
+       /** @return the ReelFileAssets in this CPL in all reels */
+       std::vector<std::shared_ptr<const ReelFileAsset>> reel_file_assets () const;
+       std::vector<std::shared_ptr<ReelFileAsset>> reel_file_assets ();
 
        /** @return true if we have any encrypted content */
        bool any_encrypted () const;
index 9ccc6eef02a1c0ae600d9a69790ac70b517150f7..df1d531b6d6a168131831005b8ea444b8458ae13 100644 (file)
@@ -261,7 +261,7 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m
        /* While we've got the ASSETMAP lets look and see if this DCP refers to things that are not in its ASSETMAP */
        if (notes) {
                for (auto i: cpls()) {
-                       for (auto j: i->reel_mxfs()) {
+                       for (auto j: i->reel_file_assets()) {
                                if (!j->asset_ref().resolved() && paths.find(j->asset_ref().id()) == paths.end()) {
                                        notes->push_back (VerificationNote(VerificationNote::Type::WARNING, VerificationNote::Code::EXTERNAL_ASSET, j->asset_ref().id()));
                                }
@@ -519,7 +519,7 @@ DCP::assets (bool ignore_unresolved) const
        vector<shared_ptr<Asset>> assets;
        for (auto i: cpls()) {
                assets.push_back (i);
-               for (auto j: i->reel_mxfs()) {
+               for (auto j: i->reel_file_assets()) {
                        if (ignore_unresolved && !j->asset_ref().resolved()) {
                                continue;
                        }
index 174efb1b983de9865a40c240471d8eef8294fbbc..e734d407503f6114765a2cec6ef7ec28db20bf2d 100644 (file)
@@ -40,7 +40,7 @@
 #include "decrypted_kdm.h"
 #include "decrypted_kdm_key.h"
 #include "encrypted_kdm.h"
-#include "reel_mxf.h"
+#include "reel_file_asset.h"
 #include "reel_asset.h"
 #include "util.h"
 #include "exceptions.h"
@@ -251,7 +251,7 @@ DecryptedKDM::DecryptedKDM (
 
 DecryptedKDM::DecryptedKDM (
        string cpl_id,
-       map<shared_ptr<const ReelMXF>, 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 ReelMXF>, 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,7 +287,7 @@ DecryptedKDM::DecryptedKDM (
 {
        /* Create DecryptedKDMKey objects for each encryptable asset */
        bool did_one = false;
-       for (auto i: cpl->reel_mxfs()) {
+       for (auto i: cpl->reel_file_assets()) {
                if (i->key_id()) {
                        add_key (i->key_type(), i->key_id().get(), key, cpl->id(), Standard::SMPTE);
                        did_one = true;
index 7bc9a217f2973f8361833d242064fe9dcf35c0ba..6bdd9fcd459006226af62d57985286d21e6fbb2f 100644 (file)
@@ -60,7 +60,7 @@ class DecryptedKDMKey;
 class EncryptedKDM;
 class CertificateChain;
 class CPL;
-class ReelMXF;
+class ReelFileAsset;
 
 
 /** @class DecryptedKDM
@@ -99,7 +99,7 @@ public:
         */
        DecryptedKDM (
                std::string cpl_id,
-               std::map<std::shared_ptr<const ReelMXF>, Key> keys,
+               std::map<std::shared_ptr<const ReelFileAsset>, Key> keys,
                LocalTime not_valid_before,
                LocalTime not_valid_after,
                std::string annotation_text,
index d9e290a90496e7b97e23e35042204f58d2f8ec74..760e4211f6e3ca00307359564e1c1640be73c460 100644 (file)
@@ -52,7 +52,7 @@ using namespace dcp;
 
 ReelAtmosAsset::ReelAtmosAsset (std::shared_ptr<AtmosAsset> asset, int64_t entry_point)
        : ReelAsset (asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
-       , ReelMXF (asset, asset->key_id())
+       , ReelFileAsset (asset, asset->key_id())
 {
 
 }
@@ -60,7 +60,7 @@ ReelAtmosAsset::ReelAtmosAsset (std::shared_ptr<AtmosAsset> asset, int64_t entry
 
 ReelAtmosAsset::ReelAtmosAsset (std::shared_ptr<const cxml::Node> node)
        : ReelAsset (node)
-       , ReelMXF (node)
+       , ReelFileAsset (node)
 {
        node->ignore_child ("DataType");
        node->done ();
index 0477504ce40edf68c578a24a9601e0947896ed5e..d9f4a8e31556ca50311d30ac8ccf385d9a0ec772 100644 (file)
@@ -43,7 +43,7 @@
 
 #include "reel_asset.h"
 #include "atmos_asset.h"
-#include "reel_mxf.h"
+#include "reel_file_asset.h"
 
 
 namespace dcp {
@@ -55,7 +55,7 @@ class AtmosAsset;
 /** @class ReelAtmosAsset
  *  @brief Part of a Reel's description which refers to a Atmos MXF
  */
-class ReelAtmosAsset : public ReelAsset, public ReelMXF
+class ReelAtmosAsset : public ReelAsset, public ReelFileAsset
 {
 public:
        ReelAtmosAsset (std::shared_ptr<AtmosAsset> asset, int64_t entry_point);
index 3369fdd961f7a1ab8cdbbf78b646f6756ca757a6..a57a06705368c77d4d12d9131c276dad01efe0a7 100644 (file)
@@ -55,7 +55,7 @@ using namespace dcp;
 
 ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
        : ReelAsset (asset->id(), edit_rate, intrinsic_duration, entry_point)
-       , ReelMXF (asset, dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : optional<string>())
+       , ReelFileAsset (asset, dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : optional<string>())
 {
 
 }
@@ -63,7 +63,7 @@ ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> a
 
 ReelClosedCaptionAsset::ReelClosedCaptionAsset (std::shared_ptr<const cxml::Node> node)
        : ReelAsset (node)
-       , ReelMXF (node)
+       , ReelFileAsset (node)
 {
        _language = node->optional_string_child ("Language");
        node->done ();
index 0aad8740b12d4e495a06312a85cb804a3807c9a5..12fc5e66a0aa28f22455caa9a076fe5b5ebd3a78 100644 (file)
@@ -44,7 +44,7 @@
 #include "language_tag.h"
 #include "subtitle_asset.h"
 #include "reel_asset.h"
-#include "reel_mxf.h"
+#include "reel_file_asset.h"
 
 
 struct verify_invalid_language2;
@@ -59,7 +59,7 @@ class SubtitleAsset;
 /** @class ReelClosedCaptionAsset
  *  @brief Part of a Reel's description which refers to a closed caption XML/MXF file
  */
-class ReelClosedCaptionAsset : public ReelAsset, public ReelMXF
+class ReelClosedCaptionAsset : public ReelAsset, public ReelFileAsset
 {
 public:
        ReelClosedCaptionAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point);
diff --git a/src/reel_file_asset.cc b/src/reel_file_asset.cc
new file mode 100644 (file)
index 0000000..40cff83
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+    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_mxf.cc
+ *  @brief ReelFileAsset class
+ */
+
+
+#include "reel_file_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;
+
+
+ReelFileAsset::ReelFileAsset (shared_ptr<Asset> asset, optional<string> key_id)
+       : _asset_ref (asset)
+       , _key_id (key_id)
+       , _hash (asset->hash())
+{
+
+}
+
+
+ReelFileAsset::ReelFileAsset (shared_ptr<const cxml::Node> node)
+       : _asset_ref (remove_urn_uuid(node->string_child("Id")))
+       , _key_id (node->optional_string_child ("KeyId"))
+       , _hash (node->optional_string_child ("Hash"))
+{
+       if (_key_id) {
+               _key_id = remove_urn_uuid (*_key_id);
+       }
+}
+
+
+bool
+ReelFileAsset::mxf_equals (shared_ptr<const ReelFileAsset> other, EqualityOptions opt, NoteHandler note) const
+{
+       if (_hash != other->_hash) {
+               if (!opt.reel_hashes_can_differ) {
+                       note (NoteType::ERROR, "Reel: hashes differ");
+                       return false;
+               } else {
+                       note (NoteType::NOTE, "Reel: hashes differ");
+               }
+       }
+
+       if (_asset_ref.resolved() && other->_asset_ref.resolved()) {
+               return _asset_ref->equals (other->_asset_ref.asset(), opt, note);
+       }
+
+       return true;
+}
+
+
+void
+ReelFileAsset::write_to_cpl_mxf (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_file_asset.h b/src/reel_file_asset.h
new file mode 100644 (file)
index 0000000..9cf02e2
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+    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_file_asset.h
+ *  @brief ReelFileAsset class
+ */
+
+
+#ifndef LIBDCP_REEL_MXF_H
+#define LIBDCP_REEL_MXF_H
+
+
+#include "ref.h"
+#include <boost/optional.hpp>
+#include <memory>
+#include <string>
+
+
+namespace cxml {
+       class Node;
+}
+
+
+namespace dcp {
+
+
+/** @class ReelFileAsset
+ *  @brief Part of a Reel's description which refers to an asset which can be encrypted
+ */
+class ReelFileAsset
+{
+public:
+       explicit ReelFileAsset (std::shared_ptr<Asset> asset, boost::optional<std::string> key_id);
+       explicit ReelFileAsset (std::shared_ptr<const cxml::Node>);
+       virtual ~ReelFileAsset () {}
+
+       /** @return the 4-character key type for this MXF (MDIK, MDAK, etc.) */
+       virtual std::string key_type () const = 0;
+
+       /** @return a Ref to our actual asset */
+       Ref const & asset_ref () const {
+               return _asset_ref;
+       }
+
+       /** @return a Ref to our actual asset */
+       Ref & asset_ref () {
+               return _asset_ref;
+       }
+
+       /** @return the asset's hash, if this ReelFileAsset has been created from one,
+        *  otherwise the hash written to the CPL for this asset (if present).
+        */
+       boost::optional<std::string> hash () const {
+               return _hash;
+       }
+
+       void set_hash (std::string h) {
+               _hash = h;
+       }
+
+       /** @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;
+       }
+
+       bool mxf_equals (std::shared_ptr<const ReelFileAsset> other, EqualityOptions opt, NoteHandler note) const;
+
+protected:
+
+       template <class T>
+       std::shared_ptr<T> asset_of_type () const {
+               return std::dynamic_pointer_cast<T> (_asset_ref.asset ());
+       }
+
+       template <class T>
+       std::shared_ptr<T> asset_of_type () {
+               return std::dynamic_pointer_cast<T> (_asset_ref.asset ());
+       }
+
+       void write_to_cpl_mxf (xmlpp::Node* node) const;
+
+       /** Reference to the asset (MXF or XML file) that this reel entry
+        *  applies to.
+        */
+       Ref _asset_ref;
+
+private:
+       boost::optional<std::string> _key_id; ///< The &lt;KeyId&gt; from the reel's entry for this asset, if there is one
+       /** Either our asset's computed hash or the hash read in from the CPL, if it's present */
+       boost::optional<std::string> _hash;
+};
+
+
+}
+
+
+#endif
diff --git a/src/reel_mxf.cc b/src/reel_mxf.cc
deleted file mode 100644 (file)
index 1e7d947..0000000
+++ /dev/null
@@ -1,101 +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_mxf.cc
- *  @brief ReelMXF class
- */
-
-
-#include "reel_mxf.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;
-
-
-ReelMXF::ReelMXF (shared_ptr<Asset> asset, optional<string> key_id)
-       : _asset_ref (asset)
-       , _key_id (key_id)
-       , _hash (asset->hash())
-{
-
-}
-
-
-ReelMXF::ReelMXF (shared_ptr<const cxml::Node> node)
-       : _asset_ref (remove_urn_uuid(node->string_child("Id")))
-       , _key_id (node->optional_string_child ("KeyId"))
-       , _hash (node->optional_string_child ("Hash"))
-{
-       if (_key_id) {
-               _key_id = remove_urn_uuid (*_key_id);
-       }
-}
-
-
-bool
-ReelMXF::mxf_equals (shared_ptr<const ReelMXF> other, EqualityOptions opt, NoteHandler note) const
-{
-       if (_hash != other->_hash) {
-               if (!opt.reel_hashes_can_differ) {
-                       note (NoteType::ERROR, "Reel: hashes differ");
-                       return false;
-               } else {
-                       note (NoteType::NOTE, "Reel: hashes differ");
-               }
-       }
-
-       if (_asset_ref.resolved() && other->_asset_ref.resolved()) {
-               return _asset_ref->equals (other->_asset_ref.asset(), opt, note);
-       }
-
-       return true;
-}
-
-
-void
-ReelMXF::write_to_cpl_mxf (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_mxf.h b/src/reel_mxf.h
deleted file mode 100644 (file)
index 099ddfe..0000000
+++ /dev/null
@@ -1,137 +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_mxf.h
- *  @brief ReelMXF class
- */
-
-
-#ifndef LIBDCP_REEL_MXF_H
-#define LIBDCP_REEL_MXF_H
-
-
-#include "ref.h"
-#include <boost/optional.hpp>
-#include <memory>
-#include <string>
-
-
-namespace cxml {
-       class Node;
-}
-
-
-namespace dcp {
-
-
-/** @class ReelMXF
- *  @brief Part of a Reel's description which refers to an asset which can be encrypted
- */
-class ReelMXF
-{
-public:
-       explicit ReelMXF (std::shared_ptr<Asset> asset, boost::optional<std::string> key_id);
-       explicit ReelMXF (std::shared_ptr<const cxml::Node>);
-       virtual ~ReelMXF () {}
-
-       /** @return the 4-character key type for this MXF (MDIK, MDAK, etc.) */
-       virtual std::string key_type () const = 0;
-
-       /** @return a Ref to our actual asset */
-       Ref const & asset_ref () const {
-               return _asset_ref;
-       }
-
-       /** @return a Ref to our actual asset */
-       Ref & asset_ref () {
-               return _asset_ref;
-       }
-
-       /** @return the asset's hash, if this ReelMXF has been created from one,
-        *  otherwise the hash written to the CPL for this asset (if present).
-        */
-       boost::optional<std::string> hash () const {
-               return _hash;
-       }
-
-       void set_hash (std::string h) {
-               _hash = h;
-       }
-
-       /** @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;
-       }
-
-       bool mxf_equals (std::shared_ptr<const ReelMXF> other, EqualityOptions opt, NoteHandler note) const;
-
-protected:
-
-       template <class T>
-       std::shared_ptr<T> asset_of_type () const {
-               return std::dynamic_pointer_cast<T> (_asset_ref.asset ());
-       }
-
-       template <class T>
-       std::shared_ptr<T> asset_of_type () {
-               return std::dynamic_pointer_cast<T> (_asset_ref.asset ());
-       }
-
-       void write_to_cpl_mxf (xmlpp::Node* node) const;
-
-       /** Reference to the asset (MXF or XML file) that this reel entry
-        *  applies to.
-        */
-       Ref _asset_ref;
-
-private:
-       boost::optional<std::string> _key_id; ///< The &lt;KeyId&gt; from the reel's entry for this asset, if there is one
-       /** Either our asset's computed hash or the hash read in from the CPL, if it's present */
-       boost::optional<std::string> _hash;
-};
-
-
-}
-
-
-#endif
index 8cdb9f4482c5c992824779a959730144903bb833..6e1c53116df4a97bb305a191ac3f752c4eba2a87 100644 (file)
@@ -58,7 +58,7 @@ using namespace dcp;
 
 ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureAsset> asset, int64_t entry_point)
        : ReelAsset (asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
-       , ReelMXF (asset, asset->key_id())
+       , ReelFileAsset (asset, asset->key_id())
        , _frame_rate (asset->frame_rate ())
        , _screen_aspect_ratio (asset->screen_aspect_ratio ())
 {
@@ -68,7 +68,7 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureAsset> asset, int64_t entr
 
 ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
        : ReelAsset (node)
-       , ReelMXF (node)
+       , ReelFileAsset (node)
 {
        _frame_rate = Fraction (node->string_child ("FrameRate"));
        try {
index 12c23717d032a52af70887ceaf097bfb69a77097..961cde9cee3024415601c6d87d17726ed88271d9 100644 (file)
@@ -41,7 +41,7 @@
 #define LIBDCP_REEL_PICTURE_ASSET_H
 
 
-#include "reel_mxf.h"
+#include "reel_file_asset.h"
 #include "reel_asset.h"
 #include "picture_asset.h"
 
@@ -52,7 +52,7 @@ namespace dcp {
 /** @class ReelPictureAsset
  *  @brief Part of a Reel's description which refers to a picture asset
  */
-class ReelPictureAsset : public ReelAsset, public ReelMXF
+class ReelPictureAsset : public ReelAsset, public ReelFileAsset
 {
 public:
        ReelPictureAsset (std::shared_ptr<PictureAsset> asset, int64_t entry_point);
index d3cc41d184facb77165b2aa21febaf689a2bfd71..539ce7b72477188e38265a36cbd276187442a512 100644 (file)
@@ -50,7 +50,7 @@ using namespace dcp;
 
 ReelSoundAsset::ReelSoundAsset (shared_ptr<SoundAsset> asset, int64_t entry_point)
        : ReelAsset (asset->id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
-       , ReelMXF (asset, asset->key_id())
+       , ReelFileAsset (asset, asset->key_id())
 {
 
 }
@@ -58,7 +58,7 @@ ReelSoundAsset::ReelSoundAsset (shared_ptr<SoundAsset> asset, int64_t entry_poin
 
 ReelSoundAsset::ReelSoundAsset (shared_ptr<const cxml::Node> node)
        : ReelAsset (node)
-       , ReelMXF (node)
+       , ReelFileAsset (node)
 {
        node->ignore_child ("Language");
        node->done ();
index 931bbc1e8b01aaea1adafc564c63aab5108f5ad5..e6143f11a87d26ecfa3004f4d25b5873640d53ad 100644 (file)
@@ -37,7 +37,7 @@
  */
 
 
-#include "reel_mxf.h"
+#include "reel_file_asset.h"
 #include "reel_asset.h"
 #include "sound_asset.h"
 #include <memory>
@@ -50,7 +50,7 @@ namespace dcp {
 /** @class ReelSoundAsset
  *  @brief Part of a Reel's description which refers to a sound asset
  */
-class ReelSoundAsset : public ReelAsset, public ReelMXF
+class ReelSoundAsset : public ReelAsset, public ReelFileAsset
 {
 public:
        ReelSoundAsset (std::shared_ptr<dcp::SoundAsset> content, int64_t entry_point);
index 3a5319626aea20e283ce6f680898cd702e530b1d..e75b918afc8d01de9b866c8a821c3f917cdb42e8 100644 (file)
@@ -53,7 +53,7 @@ using namespace dcp;
 
 ReelSubtitleAsset::ReelSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
        : ReelAsset (asset->id(), edit_rate, intrinsic_duration, entry_point)
-       , ReelMXF (asset, dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : optional<string>())
+       , ReelFileAsset (asset, dynamic_pointer_cast<SMPTESubtitleAsset>(asset) ? dynamic_pointer_cast<SMPTESubtitleAsset>(asset)->key_id() : optional<string>())
 {
 
 }
@@ -61,7 +61,7 @@ ReelSubtitleAsset::ReelSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Frac
 
 ReelSubtitleAsset::ReelSubtitleAsset (std::shared_ptr<const cxml::Node> node)
        : ReelAsset (node)
-       , ReelMXF (node)
+       , ReelFileAsset (node)
 {
        _language = node->optional_string_child("Language");
        node->done ();
index 93124140ce70ab1545f31a9beb77f748dd62e0f8..67b0f8440956b5adf2448ff0bdf4923ae586ed8f 100644 (file)
@@ -43,7 +43,7 @@
 
 #include "language_tag.h"
 #include "reel_asset.h"
-#include "reel_mxf.h"
+#include "reel_file_asset.h"
 #include "subtitle_asset.h"
 
 
@@ -59,7 +59,7 @@ class SubtitleAsset;
 /** @class ReelSubtitleAsset
  *  @brief Part of a Reel's description which refers to a subtitle XML/MXF file
  */
-class ReelSubtitleAsset : public ReelAsset, public ReelMXF
+class ReelSubtitleAsset : public ReelAsset, public ReelFileAsset
 {
 public:
        ReelSubtitleAsset (std::shared_ptr<SubtitleAsset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
index 3cb61bad286629c863c8ff14af8d132ec7845696..e45c381e4f725e22f51c9969848eb682672b2e78 100644 (file)
@@ -376,19 +376,19 @@ enum class VerifyAssetResult {
 
 
 static VerifyAssetResult
-verify_asset (shared_ptr<const DCP> dcp, shared_ptr<const ReelMXF> reel_mxf, function<void (float)> progress)
+verify_asset (shared_ptr<const DCP> dcp, shared_ptr<const ReelFileAsset> reel_file_asset, function<void (float)> progress)
 {
-       auto const actual_hash = reel_mxf->asset_ref()->hash(progress);
+       auto const actual_hash = reel_file_asset->asset_ref()->hash(progress);
 
        auto pkls = dcp->pkls();
        /* We've read this DCP in so it must have at least one PKL */
        DCP_ASSERT (!pkls.empty());
 
-       auto asset = reel_mxf->asset_ref().asset();
+       auto asset = reel_file_asset->asset_ref().asset();
 
        optional<string> pkl_hash;
        for (auto i: pkls) {
-               pkl_hash = i->hash (reel_mxf->asset_ref()->id());
+               pkl_hash = i->hash (reel_file_asset->asset_ref()->id());
                if (pkl_hash) {
                        break;
                }
@@ -396,7 +396,7 @@ verify_asset (shared_ptr<const DCP> dcp, shared_ptr<const ReelMXF> reel_mxf, fun
 
        DCP_ASSERT (pkl_hash);
 
-       auto cpl_hash = reel_mxf->hash();
+       auto cpl_hash = reel_file_asset->hash();
        if (cpl_hash && *cpl_hash != *pkl_hash) {
                return VerifyAssetResult::CPL_PKL_DIFFER;
        }
@@ -443,9 +443,9 @@ biggest_frame_size (shared_ptr<const StereoPictureFrame> frame)
 
 template <class A, class R, class F>
 optional<VerifyPictureAssetResult>
-verify_picture_asset_type (shared_ptr<const ReelMXF> reel_mxf, function<void (float)> progress)
+verify_picture_asset_type (shared_ptr<const ReelFileAsset> reel_file_asset, function<void (float)> progress)
 {
-       auto asset = dynamic_pointer_cast<A>(reel_mxf->asset_ref().asset());
+       auto asset = dynamic_pointer_cast<A>(reel_file_asset->asset_ref().asset());
        if (!asset) {
                return optional<VerifyPictureAssetResult>();
        }
@@ -472,11 +472,11 @@ verify_picture_asset_type (shared_ptr<const ReelMXF> reel_mxf, function<void (fl
 
 
 static VerifyPictureAssetResult
-verify_picture_asset (shared_ptr<const ReelMXF> reel_mxf, function<void (float)> progress)
+verify_picture_asset (shared_ptr<const ReelFileAsset> reel_file_asset, function<void (float)> progress)
 {
-       auto r = verify_picture_asset_type<MonoPictureAsset, MonoPictureAssetReader, MonoPictureFrame>(reel_mxf, progress);
+       auto r = verify_picture_asset_type<MonoPictureAsset, MonoPictureAssetReader, MonoPictureFrame>(reel_file_asset, progress);
        if (!r) {
-               r = verify_picture_asset_type<StereoPictureAsset, StereoPictureAssetReader, StereoPictureFrame>(reel_mxf, progress);
+               r = verify_picture_asset_type<StereoPictureAsset, StereoPictureAssetReader, StereoPictureFrame>(reel_file_asset, progress);
        }
 
        DCP_ASSERT (r);
@@ -1022,11 +1022,11 @@ pkl_has_encrypted_assets (shared_ptr<DCP> dcp, shared_ptr<PKL> pkl)
 {
        vector<string> encrypted;
        for (auto i: dcp->cpls()) {
-               for (auto j: i->reel_mxfs()) {
+               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 ReelMXF, so it's possible for
-                                * ReelMXFs to have assets which are not MXFs.
+                                * in reels by ReelSubtitleAsset which inherits ReelFileAsset, so it's possible for
+                                * ReelFileAssets to have assets which are not MXFs.
                                 */
                                if (auto asset = dynamic_pointer_cast<MXF>(j->asset_ref().asset())) {
                                        if (asset->encrypted()) {
@@ -1166,8 +1166,8 @@ dcp::verify (
                                        if ((i->intrinsic_duration() * i->edit_rate().denominator / i->edit_rate().numerator) < 1) {
                                                notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::INVALID_INTRINSIC_DURATION, i->id()});
                                        }
-                                       auto mxf = dynamic_pointer_cast<ReelMXF>(i);
-                                       if (mxf && !mxf->hash()) {
+                                       auto file_asset = dynamic_pointer_cast<ReelFileAsset>(i);
+                                       if (file_asset && !file_asset->hash()) {
                                                notes.push_back ({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::MISSING_HASH, i->id()});
                                        }
                                }
index 4366dca766f4902ecf0866e7a9dbd5a77af13d08..025a7d4d4308ca4b2b728b65dfb718cb33c1376d 100644 (file)
@@ -82,8 +82,8 @@ def build(bld):
              reel_asset.cc
              reel_atmos_asset.cc
              reel_closed_caption_asset.cc
+             reel_file_asset.cc
              reel_mono_picture_asset.cc
-             reel_mxf.cc
              reel_picture_asset.cc
              reel_markers_asset.cc
              reel_sound_asset.cc