2 Copyright (C) 2012-2014 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.
43 #include "certificate.h"
45 #include "name_format.h"
47 #include <boost/shared_ptr.hpp>
48 #include <boost/signals2.hpp>
57 /** @brief Namespace for everything in libdcp */
66 class CertificateChain;
72 * @brief A class to create or read a DCP.
75 class DCP : public boost::noncopyable
78 /** Construct a DCP. You can pass an existing DCP's directory
79 * as the parameter; alternatively, directory will be created
80 * if it does not exist. Note that if you pass an existing DCP
81 * into this constructor it will not be read until you call ::read().
83 * @param directory Directory containing the DCP's files.
85 explicit DCP (boost::filesystem::path directory);
87 /** Read the DCP's structure into this object.
88 * @param notes List of notes that will be added to if non-0.
89 * @param ignore_incorrect_picture_mxf_type true to try loading MXF files marked as monoscopic
90 * as stereoscopic if the monoscopic load fails; fixes problems some 3D DCPs that (I think)
91 * have an incorrect descriptor in their MXF.
93 void read (std::list<VerificationNote>* notes = 0, bool ignore_incorrect_picture_mxf_type = false);
95 /** Compare this DCP with another, according to various options.
96 * @param other DCP to compare this one to.
97 * @param options Options to define what "equality" means.
98 * @param note Functor to handle notes made by the equality operation.
99 * @return true if the DCPs are equal according to EqualityOptions, otherwise false.
101 bool equals (DCP const & other, EqualityOptions options, NoteHandler note) const;
103 void add (boost::shared_ptr<CPL> cpl);
105 std::list<boost::shared_ptr<CPL> > cpls () const;
106 std::list<boost::shared_ptr<Asset> > assets (bool ignore_unresolved = false) const;
108 bool encrypted () const;
110 void add (DecryptedKDM const &);
114 XMLMetadata metadata = XMLMetadata (),
115 boost::shared_ptr<const CertificateChain> signer = boost::shared_ptr<const CertificateChain> (),
116 NameFormat name_format = NameFormat("%t")
119 void resolve_refs (std::list<boost::shared_ptr<Asset> > assets);
121 /** @return Standard of a DCP that was read in */
122 boost::optional<Standard> standard () const {
126 boost::filesystem::path directory () const {
130 /** @return PKLs if this DCP was read from an existing one, or if write_xml() has been called on it.
131 * If neither is true, this method returns an empty list.
133 std::list<boost::shared_ptr<PKL> > pkls () const {
137 boost::optional<boost::filesystem::path> asset_map_path () {
141 static std::vector<boost::filesystem::path> directories_from_files (std::vector<boost::filesystem::path> files);
145 void write_volindex (Standard standard) const;
147 /** Write the ASSETMAP file.
148 * @param pkl_uuid UUID of our PKL.
149 * @param pkl_path Pathname of our PKL file.
151 void write_assetmap (Standard standard, std::string pkl_uuid, boost::filesystem::path pkl_path, XMLMetadata metadata) const;
153 /** The directory that we are writing to */
154 boost::filesystem::path _directory;
155 /** The CPLs that make up this DCP */
156 std::list<boost::shared_ptr<CPL> > _cpls;
157 /** The PKLs that make up this DCP */
158 std::list<boost::shared_ptr<PKL> > _pkls;
159 /** File that the ASSETMAP was read from or last written to */
160 mutable boost::optional<boost::filesystem::path> _asset_map;
162 /** Standard of DCP that was read in */
163 boost::optional<Standard> _standard;