Allow progressive writes to be encrypted.
[libdcp.git] / src / mxf_asset.cc
index a7cc0a582b2edbf7caf6309ddbd39e0150872c75..54c204e7ec67ffa9bcd9af88c427fb77b7c8b95e 100644 (file)
@@ -37,6 +37,7 @@
 
 using std::string;
 using std::list;
+using std::pair;
 using boost::shared_ptr;
 using boost::lexical_cast;
 using boost::dynamic_pointer_cast;
@@ -60,6 +61,7 @@ MXFAsset::MXFAsset (string directory, string file_name, boost::signals2::signal<
        , _decryption_context (0)
 {
        if (_encrypted) {
+               /* Generate an encryption key and a UUID for it */
                _key_id = make_uuid ();
                uint8_t key_buffer[ASDCP::KeyLen];
                Kumu::FortunaRNG rng;
@@ -144,9 +146,13 @@ MXFAsset::add_typed_key_id (xmlpp::Element* parent) const
 }
 
 void
-MXFAsset::write_to_cpl (xmlpp::Node* node) const
+MXFAsset::write_to_cpl (xmlpp::Element* node, bool interop) const
 {
-       xmlpp::Node* a = node->add_child (cpl_node_name ());
+       pair<string, string> const attr = cpl_node_attribute (interop);
+       xmlpp::Element* a = node->add_child (cpl_node_name ());
+       if (!attr.first.empty ()) {
+               a->set_attribute (attr.first, attr.second);
+       }
        a->add_child ("Id")->add_child_text ("urn:uuid:" + _uuid);
        a->add_child ("AnnotationText")->add_child_text (_file_name);
        a->add_child ("EditRate")->add_child_text (lexical_cast<string> (_edit_rate) + " 1");