2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * @brief Parent class for assets of DCPs.
24 #ifndef LIBDCP_ASSET_H
25 #define LIBDCP_ASSET_H
29 #include <boost/filesystem.hpp>
30 #include <boost/function.hpp>
31 #include <libxml++/libxml++.h>
45 /** @brief Parent class for assets of DCPs
47 * These are collections of pictures or sound.
52 /** Construct an Asset.
53 * @param directory Directory where our XML or MXF file is.
54 * @param file_name Name of our file within directory, or empty to make one up based on UUID.
56 Asset (boost::filesystem::path directory, boost::filesystem::path file_name = "");
60 /** Write details of the asset to a CPL AssetList node.
61 * @param p Parent element.
62 * @param i true to use the Interop standard, false for SMPTE.
64 virtual void write_to_cpl (xmlpp::Element* p, bool i) const = 0;
66 /** Write details of the asset to a PKL AssetList node.
67 * @param p Parent node.
69 void write_to_pkl (xmlpp::Node *) const;
71 /** Write details of the asset to a ASSETMAP stream.
74 void write_to_assetmap (xmlpp::Node *) const;
76 /** Compute the digest for this asset. Calling this is optional: if
77 * it is not called, the digest will be computed when required. However,
78 * calling this method allows the caller to see the progress of the
79 * computation, which can be long for large assets.
80 * @param Called with progress between 0 and 1.
82 void compute_digest (boost::function<void (float)> progress);
84 std::string uuid () const {
88 boost::filesystem::path path () const;
90 void set_directory (boost::filesystem::path d) {
94 void set_file_name (boost::filesystem::path f) {
98 int entry_point () const {
102 int duration () const {
106 int intrinsic_duration () const {
107 return _intrinsic_duration;
110 int edit_rate () const {
114 void set_entry_point (int e) {
118 void set_duration (int d) {
122 void set_intrinsic_duration (int d) {
123 _intrinsic_duration = d;
126 void set_edit_rate (int r) {
130 virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const;
134 std::string digest () const;
136 /** Directory that our MXF or XML file is in */
137 boost::filesystem::path _directory;
138 /** Name of our MXF or XML file */
139 boost::filesystem::path _file_name;
142 /** The edit rate; this is normally equal to the number of video frames per second */
144 /** Start point to present in frames */
146 /** Total length in frames */
147 int _intrinsic_duration;
148 /** Length to present in frames */
152 /** Digest of our MXF or XML file */
153 mutable std::string _digest;