diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/decrypted_kdm.cc | 4 | ||||
| -rw-r--r-- | src/mxf.cc | 6 | ||||
| -rw-r--r-- | src/mxf.h | 10 | ||||
| -rw-r--r-- | src/reel_mxf_asset.cc | 24 | ||||
| -rw-r--r-- | src/reel_mxf_asset.h | 10 |
5 files changed, 36 insertions, 18 deletions
diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc index bf9daa1a..4d9c44a8 100644 --- a/src/decrypted_kdm.cc +++ b/src/decrypted_kdm.cc @@ -203,10 +203,10 @@ DecryptedKDM::DecryptedKDM ( /* XXX: do non-MXF assets need keys? */ shared_ptr<const ReelMXFAsset> mxf = boost::dynamic_pointer_cast<const ReelMXFAsset> (i); if (mxf) { - if (mxf->key_id().empty ()) { + if (!mxf->key_id ()) { throw NotEncryptedError (mxf->id()); } - _keys.push_back (DecryptedKDMKey (mxf->key_type(), mxf->key_id(), key, cpl->id ())); + _keys.push_back (DecryptedKDMKey (mxf->key_type(), mxf->key_id().get(), key, cpl->id ())); } } } @@ -79,12 +79,12 @@ MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, Standard standard) Kumu::hex2bin (_id.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c); DCP_ASSERT (c == Kumu::UUID_Length); - if (_key) { + if (_key_id) { Kumu::GenRandomUUID (writer_info->ContextID); writer_info->EncryptedEssence = true; unsigned int c; - Kumu::hex2bin (_key_id.c_str(), writer_info->CryptographicKeyID, Kumu::UUID_Length, &c); + Kumu::hex2bin (_key_id.get().c_str(), writer_info->CryptographicKeyID, Kumu::UUID_Length, &c); DCP_ASSERT (c == Kumu::UUID_Length); } } @@ -123,7 +123,7 @@ MXF::set_key (Key key) { _key = key; - if (_key_id.empty ()) { + if (!_key_id) { /* No key ID so far; we now need one */ _key_id = make_uuid (); } @@ -60,7 +60,7 @@ public: /** @return true if the data is encrypted */ bool encrypted () const { - return !_key_id.empty (); + return _key_id; } /** Set the ID of the key that is used for encryption/decryption. @@ -70,8 +70,8 @@ public: _key_id = i; } - /** @return the ID of the key used for encryption/decryption, or an empty string */ - std::string key_id () const { + /** @return the ID of the key used for encryption/decryption, if there is one */ + boost::optional<std::string> key_id () const { return _key_id; } @@ -112,8 +112,8 @@ protected: ASDCP::AESEncContext* _encryption_context; ASDCP::AESDecContext* _decryption_context; - /** ID of the key used for encryption/decryption, or an empty string */ - std::string _key_id; + /** ID of the key used for encryption/decryption, if there is one */ + boost::optional<std::string> _key_id; /** Key used for encryption/decryption, if there is one */ boost::optional<Key> _key; MXFMetadata _metadata; diff --git a/src/reel_mxf_asset.cc b/src/reel_mxf_asset.cc index 95b97021..938f1e48 100644 --- a/src/reel_mxf_asset.cc +++ b/src/reel_mxf_asset.cc @@ -41,9 +41,27 @@ ReelMXFAsset::ReelMXFAsset (shared_ptr<MXF> mxf, Fraction edit_rate, int64_t int ReelMXFAsset::ReelMXFAsset (shared_ptr<const cxml::Node> node) : ReelAsset (node) - , _key_id (node->optional_string_child ("KeyId").get_value_or ("")) + , _key_id (node->optional_string_child ("KeyId")) { - if (_key_id.length() > 9) { - _key_id = _key_id.substr (9); + if (_key_id && _key_id.get().length() > 9) { + _key_id = _key_id.get().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) { + (*i)->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id.get ()); + } +} diff --git a/src/reel_mxf_asset.h b/src/reel_mxf_asset.h index 60234f4f..9b6a78a9 100644 --- a/src/reel_mxf_asset.h +++ b/src/reel_mxf_asset.h @@ -47,18 +47,18 @@ public: * that its content is encrypted. */ bool encrypted () const { - return !_key_id.empty (); + return _key_id; } - /** @return Key ID to describe the key that encrypts this asset's; - * content. + /** @return Key ID to describe the key that encrypts this asset's + * content, if there is one. */ - std::string key_id () const { + boost::optional<std::string> key_id () const { return _key_id; } private: - std::string _key_id; ///< The <KeyId> from the reel's entry for this asset, or empty if there isn't one + boost::optional<std::string> _key_id; ///< The <KeyId> from the reel's entry for this asset, if there is one }; } |
