2 Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
20 /** @file src/reel_asset.h
21 * @brief ReelAsset class.
24 #ifndef LIBDCP_REEL_ASSET_H
25 #define LIBDCP_REEL_ASSET_H
30 #include <boost/shared_ptr.hpp>
45 * @brief An entry in a <Reel> which refers to a use of a piece of content.
47 * This class encapsulates the XML that exists in a <Reel> to say
48 * that a piece of content is used in this reel. It does not
49 * describe the content itself (but links to an Asset object which does).
51 class ReelAsset : public Object
55 ReelAsset (boost::shared_ptr<Asset> asset, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
56 explicit ReelAsset (boost::shared_ptr<const cxml::Node>);
58 virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
59 virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, NoteHandler) const;
61 /** @return a Ref to our actual asset */
62 Ref const & asset_ref () const {
66 /** @return a Ref to our actual asset */
71 Fraction edit_rate () const {
75 int64_t intrinsic_duration () const {
76 return _intrinsic_duration;
79 int64_t entry_point () const {
83 int64_t duration () const {
87 /** @return the asset's hash, if this ReelAsset has been created from one,
88 * otherwise the hash written to the CPL for this asset (if present).
90 boost::optional<std::string> hash () const {
97 boost::shared_ptr<T> asset_of_type () const {
98 return boost::dynamic_pointer_cast<T> (_asset_ref.asset ());
102 boost::shared_ptr<T> asset_of_type () {
103 return boost::dynamic_pointer_cast<T> (_asset_ref.asset ());
106 /** @return the node name that this asset uses in the CPL's <Reel> node
107 * e.g. MainPicture, MainSound etc.
109 virtual std::string cpl_node_name () const = 0;
111 /** @return Any attribute that should be used on the asset's node in the
114 virtual std::pair<std::string, std::string> cpl_node_attribute (Standard) const;
116 /** Reference to the asset (MXF or XML file) that this reel entry
122 std::string _annotation_text; ///< The <AnnotationText> from the reel's entry for this asset
123 Fraction _edit_rate; ///< The <EditRate> from the reel's entry for this asset
124 int64_t _intrinsic_duration; ///< The <IntrinsicDuration> from the reel's entry for this asset
125 int64_t _entry_point; ///< The <EntryPoint> from the reel's entry for this asset
126 int64_t _duration; ///< The <Duration> from the reel's entry for this asset
127 /** Either our asset's computed hash or the hash read in from the CPL, if it's present */
128 boost::optional<std::string> _hash;