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 A class to create a DCP.
29 #include <boost/shared_ptr.hpp>
30 #include <sigc++/sigc++.h>
37 /** @brief Namespace for everything in libdcp */
51 CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
52 CPL (std::string directory, std::string file, boost::shared_ptr<const AssetMap> asset_map, bool require_mxfs = true);
54 void add_reel (boost::shared_ptr<const Reel> reel);
56 /** @return the length in frames */
61 /** @return the type of the content, used by media servers
62 * to categorise things (e.g. feature, trailer, etc.)
64 ContentKind content_kind () const {
68 std::list<boost::shared_ptr<const Reel> > reels () const {
72 /** @return the CPL's name, as will be presented on projector
73 * media servers and theatre management systems.
75 std::string name () const {
79 /** @return the number of frames per second */
80 int frames_per_second () const {
84 std::list<boost::shared_ptr<const Asset> > assets () const;
86 bool equals (CPL const & other, EqualityOptions options, std::list<std::string>& notes) const;
88 void write_xml () const;
89 void write_to_assetmap (std::ostream& s) const;
90 void write_to_pkl (std::ostream& s) const;
93 std::string _directory;
94 /** the name of the DCP */
96 /** the content kind of the CPL */
97 ContentKind _content_kind;
98 /** length in frames */
100 /** frames per second */
103 std::list<boost::shared_ptr<const Reel> > _reels;
106 mutable std::string _digest;
109 /** @class DCP dcp.h libdcp/dcp.h
110 * @brief A class to create or read a DCP.
116 /** Construct a DCP. You can pass an existing DCP's directory
117 * as the parameter, or a non-existant folder to create a new
120 * @param directory Directory containing the DCP's files.
122 DCP (std::string directory);
124 /** Read an existing DCP's data.
126 * The DCP's XML metadata will be examined, and you can then look at the contents
129 * @param require_mxfs true to throw an exception if MXF files are missing; setting to false
130 * can be useful for testing, but normally it should be set to true.
132 void read (bool require_mxfs = true);
134 /** Write the required XML files to the directory that was
135 * passed into the constructor.
137 void write_xml () const;
139 /** Compare this DCP with another, according to various options.
140 * @param other DCP to compare this one to.
141 * @param options Options to define just what "equality" means.
142 * @param notes Filled in with notes about differences.
143 * @return true if the DCPs are equal according to EqualityOptions, otherwise false.
145 bool equals (DCP const & other, EqualityOptions options, std::list<std::string>& notes) const;
147 void add_cpl (boost::shared_ptr<CPL> cpl);
149 std::list<boost::shared_ptr<const CPL> > cpls () const {
153 /** Emitted with a parameter between 0 and 1 to indicate progress
156 sigc::signal1<void, float> Progress;
160 /** Write the PKL file.
161 * @param pkl_uuid UUID to use.
163 std::string write_pkl (std::string pkl_uuid) const;
165 /** Write the VOLINDEX file */
166 void write_volindex () const;
168 /** Write the ASSETMAP file.
169 * @param pkl_uuid UUID of our PKL.
170 * @param pkl_length Length of our PKL in bytes.
172 void write_assetmap (std::string pkl_uuid, int pkl_length) const;
174 std::list<boost::shared_ptr<const Asset> > assets () const;
177 std::list<std::string> cpls;
179 std::string asset_map;
180 std::list<std::string> subtitles;
183 /** the directory that we are writing to */
184 std::string _directory;
185 std::list<boost::shared_ptr<const CPL> > _cpls;