summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-02 09:20:19 +0100
committerCarl Hetherington <cth@carlh.net>2016-06-02 09:20:19 +0100
commit4da794a09e4e3114fea02f955e485ae5a5ca2dd7 (patch)
tree7095a16aa5249dd6e8234ffcf073bb1893c95e81
parent51919d468831a876f31d5a6e2b25f8913314770d (diff)
Various tweaks to ReelAsset hashes.
Make ReelAsset::_hash optional. When writing the ReelAsset to the CPL, use _hash rather than re-fetching it from the asset. Provide accessor for _hash.
-rw-r--r--src/reel_asset.cc6
-rw-r--r--src/reel_asset.h10
2 files changed, 13 insertions, 3 deletions
diff --git a/src/reel_asset.cc b/src/reel_asset.cc
index c2d9824c..38173ddf 100644
--- a/src/reel_asset.cc
+++ b/src/reel_asset.cc
@@ -74,7 +74,7 @@ ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
, _intrinsic_duration (node->number_child<int64_t> ("IntrinsicDuration"))
, _entry_point (node->number_child<int64_t> ("EntryPoint"))
, _duration (node->number_child<int64_t> ("Duration"))
- , _hash (node->optional_string_child ("Hash").get_value_or (""))
+ , _hash (node->optional_string_child ("Hash"))
{
}
@@ -93,7 +93,9 @@ 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 (_asset_ref.asset()->hash ());
+ if (_hash) {
+ a->add_child("Hash")->add_child_text (_hash.get());
+ }
}
pair<string, string>
diff --git a/src/reel_asset.h b/src/reel_asset.h
index a90436a8..eea60fc8 100644
--- a/src/reel_asset.h
+++ b/src/reel_asset.h
@@ -84,6 +84,13 @@ public:
return _duration;
}
+ /** @return the asset's hash, if this ReelAsset has been created from one,
+ * otherwise the hash written to the CPL for this asset (if present).
+ */
+ boost::optional<std::string> hash () const {
+ return _hash;
+ }
+
protected:
template <class T>
@@ -117,7 +124,8 @@ private:
int64_t _intrinsic_duration; ///< The &lt;IntrinsicDuration&gt; from the reel's entry for this asset
int64_t _entry_point; ///< The &lt;EntryPoint&gt; from the reel's entry for this asset
int64_t _duration; ///< The &lt;Duration&gt; from the reel's entry for this asset
- std::string _hash; ///< The &lt;Hash&gt; from the reel's entry for this asset
+ /** Either our asset's computed hash or the hash read in from the CPL, if it's present */
+ boost::optional<std::string> _hash;
};
}