summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-07-20 14:36:16 +0100
committerCarl Hetherington <cth@carlh.net>2014-07-20 14:36:16 +0100
commit454e76146a5bd522e47ebbedd490e89ef95dd186 (patch)
tree680f06149597f5ca28c3235e8f570e953b8b6ec3
parentb371e448833d5a2bac837698c756f27786e38737 (diff)
Put ReelAsset key id into a new ReelMXFAsset.
-rw-r--r--src/reel_asset.cc12
-rw-r--r--src/reel_asset.h15
-rw-r--r--src/reel_mxf_asset.cc65
-rw-r--r--src/reel_mxf_asset.h58
-rw-r--r--src/reel_picture_asset.cc10
-rw-r--r--src/reel_picture_asset.h4
-rw-r--r--src/reel_sound_asset.cc8
-rw-r--r--src/reel_sound_asset.h4
-rw-r--r--src/wscript2
9 files changed, 140 insertions, 38 deletions
diff --git a/src/reel_asset.cc b/src/reel_asset.cc
index 62ee87bd..4c93b629 100644
--- a/src/reel_asset.cc
+++ b/src/reel_asset.cc
@@ -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 ());
}
diff --git a/src/reel_asset.h b/src/reel_asset.h
index 40eb6986..93f6fe91 100644
--- a/src/reel_asset.h
+++ b/src/reel_asset.h
@@ -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
index 00000000..8395376e
--- /dev/null
+++ b/src/reel_mxf_asset.cc
@@ -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
index 00000000..21116d28
--- /dev/null
+++ b/src/reel_mxf_asset.h
@@ -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
diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc
index 344f7019..c8556b4c 100644
--- a/src/reel_picture_asset.cc
+++ b/src/reel_picture_asset.cc
@@ -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();
diff --git a/src/reel_picture_asset.h b/src/reel_picture_asset.h
index 31b370c6..e635e850 100644
--- a/src/reel_picture_asset.h
+++ b/src/reel_picture_asset.h
@@ -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 ();
diff --git a/src/reel_sound_asset.cc b/src/reel_sound_asset.cc
index c9af664c..ee308fa0 100644
--- a/src/reel_sound_asset.cc
+++ b/src/reel_sound_asset.cc
@@ -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 ();
diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h
index 7725c615..af898b46 100644
--- a/src/reel_sound_asset.h
+++ b/src/reel_sound_asset.h
@@ -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);
diff --git a/src/wscript b/src/wscript
index 87059b36..6145a5cd 100644
--- a/src/wscript
+++ b/src/wscript
@@ -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