2 Copyright (C) 2012-2014 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.
28 #include "certificate.h"
30 #include <boost/shared_ptr.hpp>
31 #include <boost/signals2.hpp>
40 /** @brief Namespace for everything in libdcp */
48 class CertificateChain;
54 * @brief A class to create or read a DCP.
57 class DCP : public boost::noncopyable
60 /** Construct a DCP. You can pass an existing DCP's directory
61 * as the parameter; alternatively, directory will be created
62 * if it does not exist. Note that if you pass an existing DCP
63 * into this constructor it will not be read until you call ::read().
65 * @param directory Directory containing the DCP's files.
67 DCP (boost::filesystem::path directory);
69 typedef std::list<boost::shared_ptr<DCPReadError> > ReadErrors;
71 /** Read the DCP's structure into this object.
72 * @param keep_going true to try to keep going in the face of (some) errors.
73 * @param errors List of errors that will be added to if keep_going is true.
74 * @param ignore_incorrect_picture_mxf_type true to try loading MXF files marked as monoscopic
75 * as stereoscopic if the monoscopic load fails; fixes problems some 3D DCPs that (I think)
76 * have an incorrect descriptor in their MXF.
78 void read (bool keep_going = false, ReadErrors* errors = 0, bool ignore_incorrect_picture_mxf_type = false);
80 /** Compare this DCP with another, according to various options.
81 * @param other DCP to compare this one to.
82 * @param options Options to define what "equality" means.
83 * @param note Functor to handle notes made by the equality operation.
84 * @return true if the DCPs are equal according to EqualityOptions, otherwise false.
86 bool equals (DCP const & other, EqualityOptions options, NoteHandler note) const;
88 void add (boost::shared_ptr<CPL> cpl);
90 std::list<boost::shared_ptr<CPL> > cpls () const;
91 std::list<boost::shared_ptr<Asset> > assets () const;
93 bool encrypted () const;
95 void add (DecryptedKDM const &);
99 XMLMetadata metadata = XMLMetadata (),
100 boost::shared_ptr<const CertificateChain> signer = boost::shared_ptr<const CertificateChain> ()
103 void resolve_refs (std::list<boost::shared_ptr<Asset> > assets);
105 /** @return Standard of a DCP that was read in */
106 boost::optional<Standard> standard () const {
112 /** Write the PKL file.
113 * @param pkl_uuid UUID to use.
115 boost::filesystem::path write_pkl (
117 std::string pkl_uuid,
118 XMLMetadata metadata,
119 boost::shared_ptr<const CertificateChain> signer
122 void write_volindex (Standard standard) const;
124 /** Write the ASSETMAP file.
125 * @param pkl_uuid UUID of our PKL.
126 * @param pkl_length Length of our PKL in bytes.
128 void write_assetmap (Standard standard, std::string pkl_uuid, int pkl_length, XMLMetadata metadata) const;
130 /** the directory that we are writing to */
131 boost::filesystem::path _directory;
132 /** the CPLs that make up this DCP */
133 std::list<boost::shared_ptr<CPL> > _cpls;
135 /** Standard of DCP that was read in */
136 boost::optional<Standard> _standard;