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 <boost/signals2.hpp>
32 #include "certificates.h"
39 /** @brief Namespace for everything in libdcp */
53 CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
54 CPL (std::string directory, std::string file, boost::shared_ptr<const AssetMap> asset_map, bool require_mxfs = true);
56 void add_reel (boost::shared_ptr<const Reel> reel);
58 /** @return the length in frames */
63 /** @return the type of the content, used by media servers
64 * to categorise things (e.g. feature, trailer, etc.)
66 ContentKind content_kind () const {
70 std::list<boost::shared_ptr<const Reel> > reels () const {
74 /** @return the CPL's name, as will be presented on projector
75 * media servers and theatre management systems.
77 std::string name () const {
81 /** @return the number of frames per second */
82 int frames_per_second () const {
86 std::list<boost::shared_ptr<const Asset> > assets () const;
88 bool equals (CPL const & other, EqualityOptions options, std::list<std::string>& notes) const;
90 void write_xml (bool, CertificateChain const &, std::string const &) const;
91 void write_to_assetmap (std::ostream& s) const;
92 void write_to_pkl (xmlpp::Element* p) const;
94 boost::shared_ptr<xmlpp::Document> make_kdm (CertificateChain const &, std::string const &, boost::shared_ptr<const Certificate>) const;
97 std::string _directory;
98 /** the name of the DCP */
100 /** the content kind of the CPL */
101 ContentKind _content_kind;
102 /** length in frames */
104 /** frames per second */
107 std::list<boost::shared_ptr<const Reel> > _reels;
110 mutable std::string _digest;
113 /** @class DCP dcp.h libdcp/dcp.h
114 * @brief A class to create or read a DCP.
120 /** Construct a DCP. You can pass an existing DCP's directory
121 * as the parameter, or a non-existant folder to create a new
124 * @param directory Directory containing the DCP's files.
126 DCP (std::string directory);
128 /** Read an existing DCP's data.
130 * The DCP's XML metadata will be examined, and you can then look at the contents
133 * @param require_mxfs true to throw an exception if MXF files are missing; setting to false
134 * can be useful for testing, but normally it should be set to true.
136 void read (bool require_mxfs = true);
138 /** Write the required XML files to the directory that was
139 * passed into the constructor.
141 void write_xml () const;
143 /** Compare this DCP with another, according to various options.
144 * @param other DCP to compare this one to.
145 * @param options Options to define just what "equality" means.
146 * @param notes Filled in with notes about differences.
147 * @return true if the DCPs are equal according to EqualityOptions, otherwise false.
149 bool equals (DCP const & other, EqualityOptions options, std::list<std::string>& notes) const;
151 void add_cpl (boost::shared_ptr<CPL> cpl);
153 std::list<boost::shared_ptr<const CPL> > cpls () const {
157 void set_encrypted (bool e) {
161 void set_certificates (CertificateChain const & c) {
165 CertificateChain certificates () const {
166 return _certificates;
169 void set_signer_key (std::string const & s) {
173 std::string signer_key () const {
177 /** Emitted with a parameter between 0 and 1 to indicate progress
180 boost::signals2::signal<void (float)> Progress;
184 /** Write the PKL file.
185 * @param pkl_uuid UUID to use.
187 std::string write_pkl (std::string pkl_uuid) const;
189 /** Write the VOLINDEX file */
190 void write_volindex () const;
192 /** Write the ASSETMAP file.
193 * @param pkl_uuid UUID of our PKL.
194 * @param pkl_length Length of our PKL in bytes.
196 void write_assetmap (std::string pkl_uuid, int pkl_length) const;
198 std::list<boost::shared_ptr<const Asset> > assets () const;
201 std::list<std::string> cpls;
203 std::string asset_map;
206 /** the directory that we are writing to */
207 std::string _directory;
208 std::list<boost::shared_ptr<const CPL> > _cpls;
211 CertificateChain _certificates;
212 std::string _signer_key;