2 Copyright (C) 2014-2021 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/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
35 /** @file src/reel_asset.h
36 * @brief ReelAsset class
40 #ifndef LIBDCP_REEL_ASSET_H
41 #define LIBDCP_REEL_ASSET_H
67 * @brief An entry in a <Reel> which refers to a use of a piece of content.
69 * This class encapsulates the XML that exists in a <Reel> to say
70 * that a piece of content is used in this reel. It does not
71 * describe the content itself (but links to an Asset object which does).
73 class ReelAsset : public Object
76 /** Construct a ReelAsset
77 * @param id ID of this ReelAsset (which is that of the MXF, if there is one)
78 * @param edit_rate Edit rate for the asset
79 * @param intrinsic_duration Intrinsic duration of this asset
80 * @param entry_point Entry point to use in that asset
82 ReelAsset (std::string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
84 explicit ReelAsset (std::shared_ptr<const cxml::Node>);
86 virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const = 0;
88 Fraction edit_rate () const {
92 int64_t intrinsic_duration () const {
93 return _intrinsic_duration;
96 void set_entry_point (int64_t e) {
100 void unset_entry_point () {
101 _entry_point = boost::none;
104 boost::optional<int64_t> entry_point () const {
108 void set_duration (int64_t d) {
112 boost::optional<int64_t> duration () const {
116 /** @return <Duration>, or <IntrinsicDuration> - <EntryPoint> if <Duration> is not present */
117 int64_t actual_duration () const;
119 std::string annotation_text () const {
120 return _annotation_text;
123 void set_annotation_text (std::string at) {
124 _annotation_text = at;
127 bool asset_equals (std::shared_ptr<const ReelAsset>, EqualityOptions, NoteHandler) const;
131 /** @return the node name that this asset uses in the CPL's <Reel> node
132 * e.g. MainPicture, MainSound etc.
134 virtual std::string cpl_node_name (Standard) const = 0;
136 /** @return Any attribute that should be used on the asset's node in the CPL */
137 virtual std::pair<std::string, std::string> cpl_node_attribute (Standard) const;
139 /** @return Any namespace that should be used on the asset's node in the CPL */
140 virtual std::pair<std::string, std::string> cpl_node_namespace (Standard) const;
142 xmlpp::Node* write_to_cpl_asset (xmlpp::Node* node, Standard standard, boost::optional<std::string> hash) const;
144 int64_t _intrinsic_duration = 0; ///< The <IntrinsicDuration> from the reel's entry for this asset
145 boost::optional<int64_t> _duration; ///< The <Duration> from the reel's entry for this asset, if present
148 std::string _annotation_text; ///< The <AnnotationText> from the reel's entry for this asset
149 Fraction _edit_rate; ///< The <EditRate> from the reel's entry for this asset
150 boost::optional<int64_t> _entry_point; ///< The <EntryPoint> from the reel's entry for this asset