Missing install target.
[libdcp.git] / src / reel_asset.cc
index 037a39780e55a4a5f43eee630da1955ce77611a6..46e0bd3c9ce2600fc4d21f0028831522c24290f4 100644 (file)
@@ -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
 
 */
 
+/** @file  src/reel_asset.cc
+ *  @brief ReelAsset class.
+ */
+
 #include "raw_convert.h"
 #include "reel_asset.h"
-#include "content.h"
+#include "asset.h"
 #include "compose.hpp"
 #include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
+#include <iostream>
 
 using std::pair;
+using std::cout;
 using std::string;
 using std::stringstream;
 using std::make_pair;
@@ -31,8 +38,7 @@ using boost::shared_ptr;
 using namespace dcp;
 
 ReelAsset::ReelAsset ()
-       : Object (make_uuid ())
-       , _content (_id)
+       : _asset_ref (_id)
        , _edit_rate (Fraction (24, 1))
        , _intrinsic_duration (0)
        , _entry_point (0)
@@ -42,27 +48,27 @@ ReelAsset::ReelAsset ()
 }
 
 /** Construct a ReelAsset.
- *  @param content Content that this asset refers to.
- *  @param edit_rate Edit rate for the content.
- *  @param intrinsic_duration Intrinsic duration of this content.
- *  @param entry_point Entry point to use in that content.
+ *  @param asset Asset that this ReelAsset refers to.
+ *  @param edit_rate Edit rate for the asset.
+ *  @param intrinsic_duration Intrinsic duration of this asset.
+ *  @param entry_point Entry point to use in that asset.
  */
-ReelAsset::ReelAsset (shared_ptr<Content> content, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
-       : Object (content->id ())
-       , _content (content)
+ReelAsset::ReelAsset (shared_ptr<Asset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+       : Object (asset->id ())
+       , _asset_ref (asset)
        , _edit_rate (edit_rate)
        , _intrinsic_duration (intrinsic_duration)
        , _entry_point (entry_point)
        , _duration (intrinsic_duration - entry_point)
-       , _hash (make_digest (content->file (), 0))
+       , _hash (make_digest (asset->file (), 0))
 {
        /* default _annotation_text to the leaf name of our file */
-        _annotation_text = content->file().leaf().string ();
+        _annotation_text = asset->file().leaf().string ();
 }
 
 ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
        : Object (node->string_child ("Id"))
-       , _content (_id)
+       , _asset_ref (_id)
        , _annotation_text (node->optional_string_child ("AnnotationText").get_value_or (""))
        , _edit_rate (Fraction (node->string_child ("EditRate")))
        , _intrinsic_duration (node->number_child<int64_t> ("IntrinsicDuration"))
@@ -72,7 +78,7 @@ ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
 {
        if (_id.length() > 9) {
                _id = _id.substr (9);
-               _content.set_id (_id);
+               _asset_ref.set_id (_id);
        }
 }
 
@@ -90,7 +96,7 @@ ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
         a->add_child("IntrinsicDuration")->add_child_text (raw_convert<string> (_intrinsic_duration));
         a->add_child("EntryPoint")->add_child_text (raw_convert<string> (_entry_point));
         a->add_child("Duration")->add_child_text (raw_convert<string> (_duration));
-       a->add_child("Hash")->add_child_text (_content.object()->hash ());
+       a->add_child("Hash")->add_child_text (_asset_ref.object()->hash ());
 }
 
 pair<string, string>
@@ -105,8 +111,12 @@ ReelAsset::equals (shared_ptr<const ReelAsset> other, EqualityOptions opt, NoteH
        if (_annotation_text != other->_annotation_text) {
                stringstream s;
                s << "Reel: annotation texts differ (" << _annotation_text << " vs " << other->_annotation_text << ")\n";
-               note (DCP_ERROR, s.str ());
-               return false;
+               if (!opt.reel_annotation_texts_can_differ) {
+                       note (DCP_ERROR, s.str ());
+                       return false;
+               } else {
+                       note (DCP_NOTE, s.str ());
+               }
        }
 
        if (_edit_rate != other->_edit_rate) {
@@ -138,8 +148,8 @@ ReelAsset::equals (shared_ptr<const ReelAsset> other, EqualityOptions opt, NoteH
                }
        }
 
-       if (_content.resolved () && other->_content.resolved ()) {
-               return _content->equals (other->_content.object (), opt, note);
+       if (_asset_ref.resolved () && other->_asset_ref.resolved ()) {
+               return _asset_ref->equals (other->_asset_ref.object (), opt, note);
        }
 
        return true;