libdcp
dcp.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012-2021 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 
40 #ifndef LIBDCP_DCP_H
41 #define LIBDCP_DCP_H
42 
43 
44 #include "compose.hpp"
45 #include "types.h"
46 #include "util.h"
47 #include "certificate.h"
48 #include "metadata.h"
49 #include "name_format.h"
50 #include "verify.h"
51 #include "version.h"
52 #include <boost/signals2.hpp>
53 #include <memory>
54 #include <string>
55 #include <vector>
56 
57 
58 namespace xmlpp {
59  class Document;
60  class Element;
61 }
62 
63 
65 namespace dcp
66 {
67 
68 
69 class PKL;
70 class Content;
71 class Reel;
72 class CPL;
73 class CertificateChain;
74 class DecryptedKDM;
75 class Asset;
76 class ReadError;
77 
78 
82 class DCP
83 {
84 public:
92  explicit DCP (boost::filesystem::path directory);
93 
94  DCP (DCP const&) = delete;
95  DCP& operator= (DCP const&) = delete;
96 
115  void read (std::vector<VerificationNote>* notes = nullptr, bool ignore_incorrect_picture_mxf_type = false);
116 
123  bool equals (DCP const & other, EqualityOptions options, NoteHandler note) const;
124 
125  void add (std::shared_ptr<CPL> cpl);
126 
127  std::vector<std::shared_ptr<CPL>> cpls () const;
128 
133  std::vector<std::shared_ptr<Asset>> assets (bool ignore_unresolved = false) const;
134 
135  bool any_encrypted () const;
136  bool all_encrypted () const;
137 
142  void add (DecryptedKDM const &);
143 
153  void write_xml (
154  std::string issuer = String::compose("libdcp %1", dcp::version),
155  std::string creator = String::compose("libdcp %1", dcp::version),
156  std::string issue_date = LocalTime().as_string(),
157  std::string annotation_text = String::compose("Created by libdcp %1", dcp::version),
158  std::shared_ptr<const CertificateChain> signer = std::shared_ptr<const CertificateChain>(),
159  NameFormat name_format = NameFormat("%t")
160  );
161 
162  void resolve_refs (std::vector<std::shared_ptr<Asset>> assets);
163 
165  boost::optional<Standard> standard () const {
166  return _standard;
167  }
168 
169  boost::filesystem::path directory () const {
170  return _directory;
171  }
172 
176  std::vector<std::shared_ptr<PKL>> pkls () const {
177  return _pkls;
178  }
179 
180  boost::optional<boost::filesystem::path> asset_map_path () {
181  return _asset_map;
182  }
183 
184  static std::vector<boost::filesystem::path> directories_from_files (std::vector<boost::filesystem::path> files);
185 
186 private:
187 
188  void write_volindex (Standard standard) const;
189 
194  void write_assetmap (
195  Standard standard, std::string pkl_uuid, boost::filesystem::path pkl_path,
196  std::string issuer, std::string creator, std::string issue_date, std::string annotation_text
197  ) const;
198 
200  boost::filesystem::path _directory;
202  std::vector<std::shared_ptr<CPL>> _cpls;
204  std::vector<std::shared_ptr<PKL>> _pkls;
206  mutable boost::optional<boost::filesystem::path> _asset_map;
207 
209  boost::optional<Standard> _standard;
210 };
211 
212 
213 }
214 
215 
216 #endif
Certificate class.
A class to create or read a DCP.
Definition: dcp.h:83
DCP(boost::filesystem::path directory)
Definition: dcp.cc:100
void write_xml(std::string issuer=String::compose("libdcp %1", dcp::version), std::string creator=String::compose("libdcp %1", dcp::version), std::string issue_date=LocalTime().as_string(), std::string annotation_text=String::compose("Created by libdcp %1", dcp::version), std::shared_ptr< const CertificateChain > signer=std::shared_ptr< const CertificateChain >(), NameFormat name_format=NameFormat("%t"))
Definition: dcp.cc:490
bool equals(DCP const &other, EqualityOptions options, NoteHandler note) const
Definition: dcp.cc:303
static std::vector< boost::filesystem::path > directories_from_files(std::vector< boost::filesystem::path > files)
Definition: dcp.cc:585
std::vector< std::shared_ptr< Asset > > assets(bool ignore_unresolved=false) const
Definition: dcp.cc:549
std::vector< std::shared_ptr< PKL > > _pkls
Definition: dcp.h:204
boost::filesystem::path _directory
Definition: dcp.h:200
void write_assetmap(Standard standard, std::string pkl_uuid, boost::filesystem::path pkl_path, std::string issuer, std::string creator, std::string issue_date, std::string annotation_text) const
Definition: dcp.cc:416
std::vector< std::shared_ptr< CPL > > _cpls
Definition: dcp.h:202
boost::optional< Standard > standard() const
Definition: dcp.h:165
void read(std::vector< VerificationNote > *notes=nullptr, bool ignore_incorrect_picture_mxf_type=false)
Definition: dcp.cc:112
std::vector< std::shared_ptr< PKL > > pkls() const
Definition: dcp.h:176
void write_volindex(Standard standard) const
Definition: dcp.cc:382
boost::optional< boost::filesystem::path > _asset_map
Definition: dcp.h:206
boost::optional< Standard > _standard
Definition: dcp.h:209
A decrypted KDM.
Definition: decrypted_kdm.h:76
A representation of a local time (down to the second), including its offset from GMT (equivalent to x...
Definition: local_time.h:64
MXFMetadata class.
NameFormat class.
Namespace for everything in libdcp.
Definition: array_data.h:50
A class to describe what "equality" means for a particular test.
Definition: types.h:249
Miscellaneous types.
Utility methods and classes.
dcp::verify() method and associated code
Versioning variables that are written by the build system.