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 or read a DCP.
29 #include <boost/shared_ptr.hpp>
30 #include <boost/signals2.hpp>
32 #include "certificates.h"
39 /** @brief Namespace for everything in libdcp */
58 * @brief A class to create or read a DCP.
61 class DCP : public boost::noncopyable
64 /** Construct a DCP. You can pass an existing DCP's directory
65 * as the parameter, or a non-existant folder to create a new
68 * @param directory Directory containing the DCP's files.
70 DCP (boost::filesystem::path directory);
72 void read (bool require_mxfs = true);
74 /** Read an existing DCP's assets.
76 * The DCP's XML metadata will be examined, and you can then look at the contents
81 void read_cpls (bool require_mxfs = true);
83 /** Write the required XML files to the directory that was
84 * passed into the constructor.
86 void write_xml (bool interop, XMLMetadata const &, boost::shared_ptr<const Signer> signer = boost::shared_ptr<const Signer> ()) const;
88 /** Compare this DCP with another, according to various options.
89 * @param other DCP to compare this one to.
90 * @param options Options to define what "equality" means.
91 * @return true if the DCPs are equal according to EqualityOptions, otherwise false.
93 bool equals (DCP const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
95 /** Add a CPL to this DCP.
96 * @param cpl CPL to add.
98 void add_cpl (boost::shared_ptr<CPL> cpl);
100 /** @return The list of CPLs in this DCP */
101 std::list<boost::shared_ptr<CPL> > cpls () const {
105 /** Add another DCP as a source of assets for this DCP. This should be called before
106 * ::read() on the DCP that needs the extra assets. For example
108 * DCP original_version ("my_dcp_OV");
109 * DCP supplemental ("my_dcp_VF");
110 * supplemental.add_assets_from (original_version);
111 * supplemental.read ();
113 void add_assets_from (DCP const &);
115 bool encrypted () const;
117 void add_kdm (KDM const &);
119 /** Emitted with a parameter between 0 and 1 to indicate progress
122 boost::signals2::signal<void (float)> Progress;
126 /** Write the PKL file.
127 * @param pkl_uuid UUID to use.
129 std::string write_pkl (std::string pkl_uuid, bool, XMLMetadata const &, boost::shared_ptr<const Signer>) const;
131 /** Write the VOLINDEX file */
132 void write_volindex (bool) const;
134 /** Write the ASSETMAP file.
135 * @param pkl_uuid UUID of our PKL.
136 * @param pkl_length Length of our PKL in bytes.
138 void write_assetmap (std::string pkl_uuid, int pkl_length, bool, XMLMetadata const &) const;
140 /** @return Assets in all the CPLs in this DCP */
141 std::list<boost::shared_ptr<const Asset> > assets () const;
144 std::list<std::string> cpls;
146 std::string asset_map;
151 /** the directory that we are writing to */
152 boost::filesystem::path _directory;
154 std::list<boost::shared_ptr<CPL> > _cpls;
156 std::list<PathAssetMap> _asset_maps;