From 4da794a09e4e3114fea02f955e485ae5a5ca2dd7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 2 Jun 2016 09:20:19 +0100 Subject: 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. --- src/reel_asset.cc | 6 ++++-- src/reel_asset.h | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') 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 node) , _intrinsic_duration (node->number_child ("IntrinsicDuration")) , _entry_point (node->number_child ("EntryPoint")) , _duration (node->number_child ("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 (_intrinsic_duration)); a->add_child("EntryPoint")->add_child_text (raw_convert (_entry_point)); a->add_child("Duration")->add_child_text (raw_convert (_duration)); - a->add_child("Hash")->add_child_text (_asset_ref.asset()->hash ()); + if (_hash) { + a->add_child("Hash")->add_child_text (_hash.get()); + } } pair 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 hash () const { + return _hash; + } + protected: template @@ -117,7 +124,8 @@ private: int64_t _intrinsic_duration; ///< The <IntrinsicDuration> from the reel's entry for this asset int64_t _entry_point; ///< The <EntryPoint> from the reel's entry for this asset int64_t _duration; ///< The <Duration> from the reel's entry for this asset - std::string _hash; ///< The <Hash> 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 _hash; }; } -- cgit v1.2.3