Tidying a few things up.
[libdcp.git] / src / reel_file_asset.cc
index 40cff83fb601d7da9834d250497dc34537518078..1ca77b4d764aaf3e05136ec65d8ccf280b1a3f0b 100644 (file)
 */
 
 
-/** @file  src/reel_mxf.cc
+/** @file  src/reel_file_asset.cc
  *  @brief ReelFileAsset class
  */
 
 
+#include "asset.h"
 #include "reel_file_asset.h"
-#include "util.h"
-#include "mxf.h"
-#include "dcp_assert.h"
-#include <libcxml/cxml.h>
 #include <libxml++/libxml++.h>
 
 
-using std::string;
 using std::shared_ptr;
+using std::string;
 using boost::optional;
 using namespace dcp;
 
 
-ReelFileAsset::ReelFileAsset (shared_ptr<Asset> asset, optional<string> key_id)
-       : _asset_ref (asset)
-       , _key_id (key_id)
+ReelFileAsset::ReelFileAsset (shared_ptr<Asset> asset, optional<string> key_id, std::string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+       : ReelAsset (id, edit_rate, intrinsic_duration, entry_point)
+       , _asset_ref (asset)
        , _hash (asset->hash())
+       , _key_id (key_id)
 {
 
 }
 
 
 ReelFileAsset::ReelFileAsset (shared_ptr<const cxml::Node> node)
-       : _asset_ref (remove_urn_uuid(node->string_child("Id")))
-       , _key_id (node->optional_string_child ("KeyId"))
-       , _hash (node->optional_string_child ("Hash"))
+       : ReelAsset (node)
+       , _asset_ref (remove_urn_uuid(node->string_child("Id")))
+       , _hash (node->optional_string_child("Hash"))
+       , _key_id (node->optional_string_child("KeyId"))
 {
        if (_key_id) {
                _key_id = remove_urn_uuid (*_key_id);
@@ -72,7 +71,7 @@ ReelFileAsset::ReelFileAsset (shared_ptr<const cxml::Node> node)
 
 
 bool
-ReelFileAsset::mxf_equals (shared_ptr<const ReelFileAsset> other, EqualityOptions opt, NoteHandler note) const
+ReelFileAsset::file_asset_equals (shared_ptr<const ReelFileAsset> other, EqualityOptions opt, NoteHandler note) const
 {
        if (_hash != other->_hash) {
                if (!opt.reel_hashes_can_differ) {
@@ -91,11 +90,16 @@ ReelFileAsset::mxf_equals (shared_ptr<const ReelFileAsset> other, EqualityOption
 }
 
 
-void
-ReelFileAsset::write_to_cpl_mxf (xmlpp::Node* node) const
+xmlpp::Node *
+ReelFileAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
 {
-        if (key_id ()) {
-               auto hash = find_child (node, "Hash");
-               node->add_child_before(hash, "KeyId")->add_child_text("urn:uuid:" + key_id().get());
+       auto asset = ReelAsset::write_to_cpl (node, standard);
+        if (_key_id) {
+               asset->add_child("KeyId")->add_child_text("urn:uuid:" + *_key_id);
         }
+       if (_hash) {
+               asset->add_child("Hash")->add_child_text(*_hash);
+       }
+       return asset;
 }
+