Add OpenSSL licence exception.
[libdcp.git] / src / dcp.h
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
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.
10
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.
15
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/>.
18
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
23     including the two.
24
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.
32 */
33
34 /** @file  src/dcp.h
35  *  @brief DCP class.
36  */
37
38 #ifndef LIBDCP_DCP_H
39 #define LIBDCP_DCP_H
40
41 #include "types.h"
42 #include "certificate.h"
43 #include "metadata.h"
44 #include <boost/shared_ptr.hpp>
45 #include <boost/signals2.hpp>
46 #include <string>
47 #include <vector>
48
49 namespace xmlpp {
50         class Document;
51         class Element;
52 }
53
54 /** @brief Namespace for everything in libdcp */
55 namespace dcp
56 {
57
58 class Content;
59 class Reel;
60 class CPL;
61 class XMLMetadata;
62 class CertificateChain;
63 class DecryptedKDM;
64 class Asset;
65 class DCPReadError;
66
67 /** @class DCP
68  *  @brief A class to create or read a DCP.
69  */
70
71 class DCP : public boost::noncopyable
72 {
73 public:
74         /** Construct a DCP.  You can pass an existing DCP's directory
75          *  as the parameter; alternatively, directory will be created
76          *  if it does not exist.  Note that if you pass an existing DCP
77          *  into this constructor it will not be read until you call ::read().
78          *
79          *  @param directory Directory containing the DCP's files.
80          */
81         explicit DCP (boost::filesystem::path directory);
82
83         typedef std::list<boost::shared_ptr<DCPReadError> > ReadErrors;
84
85         /** Read the DCP's structure into this object.
86          *  @param keep_going true to try to keep going in the face of (some) errors.
87          *  @param errors List of errors that will be added to if keep_going is true.
88          *  @param ignore_incorrect_picture_mxf_type true to try loading MXF files marked as monoscopic
89          *  as stereoscopic if the monoscopic load fails; fixes problems some 3D DCPs that (I think)
90          *  have an incorrect descriptor in their MXF.
91          */
92         void read (bool keep_going = false, ReadErrors* errors = 0, bool ignore_incorrect_picture_mxf_type = false);
93
94         /** Compare this DCP with another, according to various options.
95          *  @param other DCP to compare this one to.
96          *  @param options Options to define what "equality" means.
97          *  @param note Functor to handle notes made by the equality operation.
98          *  @return true if the DCPs are equal according to EqualityOptions, otherwise false.
99          */
100         bool equals (DCP const & other, EqualityOptions options, NoteHandler note) const;
101
102         void add (boost::shared_ptr<CPL> cpl);
103
104         std::list<boost::shared_ptr<CPL> > cpls () const;
105         std::list<boost::shared_ptr<Asset> > assets () const;
106
107         bool encrypted () const;
108
109         void add (DecryptedKDM const &);
110
111         void write_xml (
112                 Standard standard,
113                 XMLMetadata metadata = XMLMetadata (),
114                 boost::shared_ptr<const CertificateChain> signer = boost::shared_ptr<const CertificateChain> ()
115         );
116
117         void resolve_refs (std::list<boost::shared_ptr<Asset> > assets);
118
119         /** @return Standard of a DCP that was read in */
120         boost::optional<Standard> standard () const {
121                 return _standard;
122         }
123
124 private:
125
126         /** Write the PKL file.
127          *  @param pkl_uuid UUID to use.
128          */
129         boost::filesystem::path write_pkl (
130                 Standard standard,
131                 std::string pkl_uuid,
132                 XMLMetadata metadata,
133                 boost::shared_ptr<const CertificateChain> signer
134                 ) const;
135
136         void write_volindex (Standard standard) const;
137
138         /** Write the ASSETMAP file.
139          *  @param pkl_uuid UUID of our PKL.
140          *  @param pkl_length Length of our PKL in bytes.
141          */
142         void write_assetmap (Standard standard, std::string pkl_uuid, int pkl_length, XMLMetadata metadata) const;
143
144         /** the directory that we are writing to */
145         boost::filesystem::path _directory;
146         /** the CPLs that make up this DCP */
147         std::list<boost::shared_ptr<CPL> > _cpls;
148
149         /** Standard of DCP that was read in */
150         boost::optional<Standard> _standard;
151 };
152
153 }
154
155 #endif