_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;
- }
-
- DCP_ASSERT (i != c.end ());
-
- if (!_key_id.empty ()) {
- (*i)->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id);
- }
-}
/** @return the 4-character key type for this MXF (MDIK, MDAK, etc.) */
virtual std::string key_type () const = 0;
- 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.
*/
void
ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
{
- ReelMXFAsset::write_to_cpl (node, standard);
+ ReelAsset::write_to_cpl (node, standard);
- 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;
- }
-
- DCP_ASSERT (i != c.end ());
+ /* Find <MainPicture> */
+ xmlpp::Node* mp = find_child (node, cpl_node_name ());
- (*i)->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
+ mp->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
if (standard == INTEROP) {
stringstream s;
s << std::fixed << std::setprecision (2) << (float (_screen_aspect_ratio.numerator) / _screen_aspect_ratio.denominator);
- (*i)->add_child ("ScreenAspectRatio")->add_child_text (s.str ());
+ mp->add_child ("ScreenAspectRatio")->add_child_text (s.str ());
} else {
- (*i)->add_child ("ScreenAspectRatio")->add_child_text (
+ mp->add_child ("ScreenAspectRatio")->add_child_text (
String::compose ("%1 %2", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator)
);
}
+
+ if (!key_id ().empty ()) {
+ /* Find <Hash> */
+ xmlpp::Node* hash = find_child (mp, "Hash");
+ mp->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id ());
+ }
}
string
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2015 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
*/
#include "reel_sound_asset.h"
+#include "dcp_assert.h"
#include <libcxml/cxml.h>
using std::string;
{
return "MDAK";
}
+
+void
+ReelSoundAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+{
+ ReelAsset::write_to_cpl (node, standard);
+
+ if (!key_id ().empty ()) {
+ /* Find <MainSound> */
+ xmlpp::Node* ms = find_child (node, cpl_node_name ());
+ /* Find <Hash> */
+ xmlpp::Node* hash = find_child (ms, "Hash");
+ ms->add_child_before (hash, "KeyId")->add_child_text ("urn:uuid:" + key_id ());
+ }
+}
ReelSoundAsset (boost::shared_ptr<dcp::SoundMXF> content, int64_t entry_point);
ReelSoundAsset (boost::shared_ptr<const cxml::Node>);
+ void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+
/** @return the SoundMXF that this object refers to */
boost::shared_ptr<SoundMXF> mxf () {
return boost::dynamic_pointer_cast<SoundMXF> (_content.object ());
char digest_base64[64];
return Kumu::base64encode (digest, 20, digest_base64, 64);
}
+
+xmlpp::Node *
+dcp::find_child (xmlpp::Node const * node, string name)
+{
+ xmlpp::Node::NodeList c = node->get_children ();
+ xmlpp::Node::NodeList::iterator i = c.begin();
+ while (i != c.end() && (*i)->get_name() != name) {
+ ++i;
+ }
+
+ DCP_ASSERT (i != c.end ());
+ return *i;
+}
namespace xmlpp {
class Element;
+ class Node;
}
namespace dcp {
extern FILE * fopen_boost (boost::filesystem::path, std::string);
extern std::string file_to_string (boost::filesystem::path, uintmax_t max_length = 65536);
extern std::string private_key_fingerprint (std::string key);
+extern xmlpp::Node* find_child (xmlpp::Node const * node, std::string name);
template <class F, class T>
std::list<boost::shared_ptr<T> >