diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-05 01:51:24 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-05 01:51:24 +0100 |
| commit | b038dc192bdac76da3b1bebdd6b448e8be830814 (patch) | |
| tree | a21f6ab4fce16b514c97c41039733d81175020cd /src | |
| parent | e6913e8eb44e1dc990ef89f19ab64792880898a5 (diff) | |
Fix ordering of KeyId tag in SMPTE CPLs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/reel_mxf_asset.cc | 18 | ||||
| -rw-r--r-- | src/reel_mxf_asset.h | 2 | ||||
| -rw-r--r-- | src/reel_picture_asset.cc | 23 | ||||
| -rw-r--r-- | src/reel_sound_asset.cc | 17 | ||||
| -rw-r--r-- | src/reel_sound_asset.h | 2 | ||||
| -rw-r--r-- | src/util.cc | 13 | ||||
| -rw-r--r-- | src/util.h | 2 |
7 files changed, 45 insertions, 32 deletions
diff --git a/src/reel_mxf_asset.cc b/src/reel_mxf_asset.cc index 9d7c1fad..55cb7e9c 100644 --- a/src/reel_mxf_asset.cc +++ b/src/reel_mxf_asset.cc @@ -46,21 +46,3 @@ ReelMXFAsset::ReelMXFAsset (shared_ptr<const cxml::Node> node) _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); - } -} diff --git a/src/reel_mxf_asset.h b/src/reel_mxf_asset.h index 765ba393..60234f4f 100644 --- a/src/reel_mxf_asset.h +++ b/src/reel_mxf_asset.h @@ -43,8 +43,6 @@ public: /** @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. */ diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index 6bac3bce..d08f1781 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -71,26 +71,27 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node) 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 diff --git a/src/reel_sound_asset.cc b/src/reel_sound_asset.cc index 55167d82..a5e32b02 100644 --- a/src/reel_sound_asset.cc +++ b/src/reel_sound_asset.cc @@ -1,5 +1,5 @@ /* - 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 @@ -22,6 +22,7 @@ */ #include "reel_sound_asset.h" +#include "dcp_assert.h" #include <libcxml/cxml.h> using std::string; @@ -52,3 +53,17 @@ ReelSoundAsset::key_type () const { 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 ()); + } +} diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h index b5dc819a..622a97cf 100644 --- a/src/reel_sound_asset.h +++ b/src/reel_sound_asset.h @@ -37,6 +37,8 @@ public: 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 ()); diff --git a/src/util.cc b/src/util.cc index 044801b7..86d1bc87 100644 --- a/src/util.cc +++ b/src/util.cc @@ -414,3 +414,16 @@ dcp::private_key_fingerprint (string key) 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; +} @@ -35,6 +35,7 @@ namespace xmlpp { class Element; + class Node; } namespace dcp { @@ -67,6 +68,7 @@ extern boost::optional<boost::filesystem::path> relative_to_root (boost::filesys 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> > |
