X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Freel_asset.h;h=ba08c267f36585c0ed3623c5db28a25e3d0af665;hb=89d9ddba959f02b17f1d0e75e2f12c357ce29f2b;hp=c7c9f73eef349813fa0304cd62cfe774662120a3;hpb=d927e9b913606f4fc982885c7582ecaf0e3c5a1a;p=libdcp.git diff --git a/src/reel_asset.h b/src/reel_asset.h index c7c9f73e..ba08c267 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of libdcp. @@ -31,30 +31,38 @@ files in the program, then also delete it here. */ + /** @file src/reel_asset.h - * @brief ReelAsset class. + * @brief ReelAsset class */ + #ifndef LIBDCP_REEL_ASSET_H #define LIBDCP_REEL_ASSET_H + #include "object.h" #include "util.h" #include "ref.h" -#include +#include + namespace cxml { class Node; } + namespace xmlpp { class Node; } + namespace dcp { + class Asset; + /** @class ReelAsset * @brief An entry in a <Reel> which refers to a use of a piece of content. * @@ -65,22 +73,17 @@ class Asset; class ReelAsset : public Object { public: - ReelAsset (); - ReelAsset (boost::shared_ptr asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); - explicit ReelAsset (boost::shared_ptr); - - virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const; - virtual bool equals (boost::shared_ptr, EqualityOptions, NoteHandler) const; + /** Construct a ReelAsset + * @param id ID of this ReelAsset (which is that of the MXF, if there is one) + * @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 (std::string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); - /** @return a Ref to our actual asset */ - Ref const & asset_ref () const { - return _asset_ref; - } + explicit ReelAsset (std::shared_ptr); - /** @return a Ref to our actual asset */ - Ref & asset_ref () { - return _asset_ref; - } + virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const = 0; Fraction edit_rate () const { return _edit_rate; @@ -90,58 +93,65 @@ public: return _intrinsic_duration; } - int64_t entry_point () const { + void set_entry_point (int64_t e) { + _entry_point = e; + } + + void unset_entry_point () { + _entry_point = boost::none; + } + + boost::optional entry_point () const { return _entry_point; } - int64_t duration () const { - return _duration; + void set_duration (int64_t d) { + _duration = d; } - /** @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; + boost::optional duration () const { + return _duration; } -protected: + /** @return , or - if is not present */ + int64_t actual_duration () const; - template - boost::shared_ptr asset_of_type () const { - return boost::dynamic_pointer_cast (_asset_ref.asset ()); + std::string annotation_text () const { + return _annotation_text; } - template - boost::shared_ptr asset_of_type () { - return boost::dynamic_pointer_cast (_asset_ref.asset ()); + void set_annotation_text (std::string at) { + _annotation_text = at; } + bool asset_equals (std::shared_ptr, EqualityOptions, NoteHandler) const; + +protected: + /** @return the node name that this asset uses in the CPL's <Reel> node * e.g. MainPicture, MainSound etc. */ - virtual std::string cpl_node_name () const = 0; + virtual std::string cpl_node_name (Standard) const = 0; - /** @return Any attribute that should be used on the asset's node in the - * CPL. - */ + /** @return Any attribute that should be used on the asset's node in the CPL */ virtual std::pair cpl_node_attribute (Standard) const; - /** Reference to the asset (MXF or XML file) that this reel entry - * applies to. - */ - Ref _asset_ref; + /** @return Any namespace that should be used on the asset's node in the CPL */ + virtual std::pair cpl_node_namespace (Standard) const; + + xmlpp::Node* write_to_cpl_asset (xmlpp::Node* node, Standard standard, boost::optional hash) const; + + int64_t _intrinsic_duration = 0; ///< The <IntrinsicDuration> from the reel's entry for this asset + boost::optional _duration; ///< The <Duration> from the reel's entry for this asset, if present private: - std::string _annotation_text; ///< The <AnnotationText> from the reel's entry for this asset - Fraction _edit_rate; ///< The <EditRate> from the reel's entry for this asset - 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 - /** Either our asset's computed hash or the hash read in from the CPL, if it's present */ - boost::optional _hash; + std::string _annotation_text; ///< The <AnnotationText> from the reel's entry for this asset + Fraction _edit_rate; ///< The <EditRate> from the reel's entry for this asset + boost::optional _entry_point; ///< The <EntryPoint> from the reel's entry for this asset }; + } + #endif