Put ReelAsset key id into a new ReelMXFAsset.
authorCarl Hetherington <cth@carlh.net>
Sun, 20 Jul 2014 13:36:16 +0000 (14:36 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 20 Jul 2014 13:36:16 +0000 (14:36 +0100)
src/reel_asset.cc
src/reel_asset.h
src/reel_mxf_asset.cc [new file with mode: 0644]
src/reel_mxf_asset.h [new file with mode: 0644]
src/reel_picture_asset.cc
src/reel_picture_asset.h
src/reel_sound_asset.cc
src/reel_sound_asset.h
src/wscript

index 62ee87bdfb573ab79907489507edfe7e3c0b32fc..4c93b62926e2bbc299829e6a265e7af6995c2888 100644 (file)
@@ -46,7 +46,7 @@ ReelAsset::ReelAsset ()
  *  @param intrinsic_duration Intrinsic duration of this content.
  *  @param entry_point Entry point to use in that content.
  */
-ReelAsset::ReelAsset (boost::shared_ptr<Content> content, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+ReelAsset::ReelAsset (shared_ptr<Content> content, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
        : Object (content->id ())
        , _content (content)
        , _edit_rate (edit_rate)
@@ -59,7 +59,7 @@ ReelAsset::ReelAsset (boost::shared_ptr<Content> content, Fraction edit_rate, in
         _annotation_text = content->file().leaf().string ();
 }
 
-ReelAsset::ReelAsset (boost::shared_ptr<const cxml::Node> node)
+ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
        : Object (node->string_child ("Id"))
        , _content (_id)
        , _annotation_text (node->optional_string_child ("AnnotationText").get_value_or (""))
@@ -68,16 +68,11 @@ ReelAsset::ReelAsset (boost::shared_ptr<const cxml::Node> node)
        , _entry_point (node->number_child<int64_t> ("EntryPoint"))
        , _duration (node->number_child<int64_t> ("Duration"))
        , _hash (node->optional_string_child ("Hash").get_value_or (""))
-       , _key_id (node->optional_string_child ("KeyId").get_value_or (""))
 {
        if (_id.length() > 9) {
                _id = _id.substr (9);
                _content.set_id (_id);
        }
-       
-       if (_key_id.length() > 9) {
-               _key_id = _key_id.substr (9);
-       }
 }
 
 void
@@ -94,9 +89,6 @@ ReelAsset::write_to_cpl (xmlpp::Node* node, Standard) const
         a->add_child("IntrinsicDuration")->add_child_text (raw_convert<string> (_intrinsic_duration));
         a->add_child("EntryPoint")->add_child_text (raw_convert<string> (_entry_point));
         a->add_child("Duration")->add_child_text (raw_convert<string> (_duration));
-        if (!_key_id.empty ()) {
-                a->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id);
-        }
        a->add_child("Hash")->add_child_text (_content.object()->hash ());
 }
 
index 40eb6986f975aeb27c7b9c69527b9a0ac359cb74..93f6fe91d810ee4c45b060760a8ebfaa5d51d116 100644 (file)
@@ -67,13 +67,6 @@ public:
                return _content;
        }
 
-       /** @return true if a KeyId is specified for this asset, implying
-        *  that its content is encrypted.
-        */
-       bool encrypted () const {
-               return !_key_id.empty ();
-       }
-
        int64_t entry_point () const {
                return _entry_point;
        }
@@ -82,13 +75,6 @@ public:
                return _duration;
        }
 
-       /** @return Key ID to describe the key that encrypts this asset's;
-        *  content.
-        */
-       std::string key_id () const {
-               return _key_id;
-       }
-
 protected:
        /** @return the node name that this asset uses in the CPL's &lt;Reel&gt; node
         *  e.g. MainPicture, MainSound etc.
@@ -113,7 +99,6 @@ private:
        int64_t _entry_point;         ///< The &lt;EntryPoint&gt; from the reel's entry for this asset
        int64_t _duration;            ///< The &lt;Duration&gt; from the reel's entry for this asset
        std::string _hash;            ///< The &lt;Hash&gt; from the reel's entry for this asset
-       std::string _key_id;          ///< The &lt;KeyId&gt; from the reel's entry for this asset, or empty if there isn't one
 };
 
 }
diff --git a/src/reel_mxf_asset.cc b/src/reel_mxf_asset.cc
new file mode 100644 (file)
index 0000000..8395376
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+
+    This program 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.
+
+    This program 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 this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "reel_mxf_asset.h"
+#include "mxf.h"
+#include <libcxml/cxml.h>
+
+using boost::shared_ptr;
+using namespace dcp;
+
+ReelMXFAsset::ReelMXFAsset ()
+       : ReelAsset ()
+{
+
+}
+
+ReelMXFAsset::ReelMXFAsset (shared_ptr<MXF> mxf, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+       : ReelAsset (mxf, edit_rate, intrinsic_duration, entry_point)
+       , _key_id (mxf->key_id ())
+{
+
+}
+
+ReelMXFAsset::ReelMXFAsset (shared_ptr<const cxml::Node> node)
+       : ReelAsset (node)
+       , _key_id (node->optional_string_child ("KeyId").get_value_or (""))
+{
+       if (_key_id.length() > 9) {
+               _key_id = _key_id.substr (9);
+       }
+}
+
+void
+ReelMXFAsset::write_to_cpl (xmlpp::Node* node, Standard s) const
+{
+       ReelAsset::write_to_cpl (node, s);
+
+       xmlpp::Node::NodeList c = node->get_children ();
+       xmlpp::Node::NodeList::iterator i = c.begin();
+       while (i != c.end() && (*i)->get_name() != cpl_node_name ()) {
+               ++i;
+       }
+
+       assert (i != c.end ());
+       
+        if (!_key_id.empty ()) {
+                (*i)->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id);
+        }
+}
diff --git a/src/reel_mxf_asset.h b/src/reel_mxf_asset.h
new file mode 100644 (file)
index 0000000..21116d2
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+
+    This program 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.
+
+    This program 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 this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef LIBDCP_REEL_MXF_ASSET_H
+#define LIBDCP_REEL_MXF_ASSET_H
+
+#include "reel_asset.h"
+
+namespace dcp {
+
+class MXF;     
+
+class ReelMXFAsset : public ReelAsset
+{
+public:
+       ReelMXFAsset ();
+       ReelMXFAsset (boost::shared_ptr<MXF> mxf, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
+       ReelMXFAsset (boost::shared_ptr<const cxml::Node>);
+
+       void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+       
+       /** @return true if a KeyId is specified for this asset, implying
+        *  that its content is encrypted.
+        */
+       bool encrypted () const {
+               return !_key_id.empty ();
+       }
+
+       /** @return Key ID to describe the key that encrypts this asset's;
+        *  content.
+        */
+       std::string key_id () const {
+               return _key_id;
+       }
+
+private:
+       std::string _key_id;          ///< The &lt;KeyId&gt; from the reel's entry for this asset, or empty if there isn't one
+};
+
+}
+
+#endif
index 344f7019cb28f708221573468a9c33e2803c6f60..c8556b4c35faf3b0e2d2616e5d90b7aa4cdfcccf 100644 (file)
@@ -41,16 +41,16 @@ ReelPictureAsset::ReelPictureAsset ()
 
 }
 
-ReelPictureAsset::ReelPictureAsset (boost::shared_ptr<PictureMXF> content, int64_t entry_point)
-       : ReelAsset (content, content->edit_rate(), content->intrinsic_duration(), entry_point)
+ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureMXF> content, int64_t entry_point)
+       : ReelMXFAsset (content, content->edit_rate(), content->intrinsic_duration(), entry_point)
        , _frame_rate (content->frame_rate ())
        , _screen_aspect_ratio (content->screen_aspect_ratio ())
 {
        
 }
 
-ReelPictureAsset::ReelPictureAsset (boost::shared_ptr<const cxml::Node> node)
-       : ReelAsset (node)
+ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
+       : ReelMXFAsset (node)
 {
        _frame_rate = Fraction (node->string_child ("FrameRate"));
        try {
@@ -69,7 +69,7 @@ ReelPictureAsset::ReelPictureAsset (boost::shared_ptr<const cxml::Node> node)
 void
 ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
 {
-       ReelAsset::write_to_cpl (node, standard);
+       ReelMXFAsset::write_to_cpl (node, standard);
 
        xmlpp::Node::NodeList c = node->get_children ();
        xmlpp::Node::NodeList::iterator i = c.begin();
index 31b370c6237bec52301b87518faadc52203270e8..e635e850eda3568802c4128331a6640883c8190e 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef LIBDCP_REEL_PICTURE_ASSET_H
 #define LIBDCP_REEL_PICTURE_ASSET_H
 
-#include "reel_asset.h"
+#include "reel_mxf_asset.h"
 #include "picture_mxf.h"
 
 namespace dcp {
@@ -32,7 +32,7 @@ namespace dcp {
 /** @class ReelPictureAsset
  *  @brief Part of a Reel's description which refers to a picture MXF.
  */
-class ReelPictureAsset : public ReelAsset
+class ReelPictureAsset : public ReelMXFAsset
 {
 public:
        ReelPictureAsset ();
index c9af664c6c6bbe0916018cef6f54954bfe94ee91..ee308fa0f6c669a53784929bda266b2050a531f2 100644 (file)
@@ -28,14 +28,14 @@ using std::string;
 using boost::shared_ptr;
 using namespace dcp;
 
-ReelSoundAsset::ReelSoundAsset (boost::shared_ptr<SoundMXF> content, int64_t entry_point)
-       : ReelAsset (content, content->edit_rate(), content->intrinsic_duration(), entry_point)
+ReelSoundAsset::ReelSoundAsset (shared_ptr<SoundMXF> content, int64_t entry_point)
+       : ReelMXFAsset (content, content->edit_rate(), content->intrinsic_duration(), entry_point)
 {
 
 }
 
-ReelSoundAsset::ReelSoundAsset (boost::shared_ptr<const cxml::Node> node)
-       : ReelAsset (node)
+ReelSoundAsset::ReelSoundAsset (shared_ptr<const cxml::Node> node)
+       : ReelMXFAsset (node)
 {
        node->ignore_child ("Language");
        node->done ();
index 7725c6158bc1337760a202b16a81b5edc7c5811e..af898b463aecccca8839ac9c02b29836d40f7ea2 100644 (file)
@@ -21,7 +21,7 @@
  *  @brief ReelSoundAsset class.
  */
 
-#include "reel_asset.h"
+#include "reel_mxf_asset.h"
 #include "sound_mxf.h"
 #include <boost/shared_ptr.hpp>
 #include <string>
@@ -31,7 +31,7 @@ namespace dcp {
 /** @class ReelSoundAsset
  *  @brief Part of a Reel's description which refers to a sound MXF.
  */
-class ReelSoundAsset : public ReelAsset
+class ReelSoundAsset : public ReelMXFAsset
 {
 public:
        ReelSoundAsset (boost::shared_ptr<dcp::SoundMXF> content, int64_t entry_point);
index 87059b36e4238af1c2ba8225e4425360929ce92d..6145a5cdb292dff2ea4ac9db4ddd186b9501c259 100644 (file)
@@ -44,6 +44,7 @@ def build(bld):
                  reel.cc
                  reel_asset.cc
                  reel_mono_picture_asset.cc
+                 reel_mxf_asset.cc
                  reel_picture_asset.cc
                  reel_sound_asset.cc
                  reel_stereo_picture_asset.cc
@@ -97,6 +98,7 @@ def build(bld):
               reel.h
               reel_asset.h
               reel_mono_picture_asset.h
+              reel_mxf_asset.h
               reel_picture_asset.h
               reel_sound_asset.h
               reel_stereo_picture_asset.h