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 "asset_map.h"
45 #include "certificate.h"
46 #include "compose.hpp"
47 #include "metadata.h"
48 #include "name_format.h"
49 #include "util.h"
50 #include "verify.h"
51 #include "version.h"
52 #include <memory>
53 #include <string>
54 #include <vector>
55 
56 
57 namespace xmlpp {
58  class Document;
59  class Element;
60 }
61 
62 
64 namespace dcp
65 {
66 
67 
68 class Asset;
69 class CPL;
70 class CertificateChain;
71 class Content;
72 class DecryptedKDM;
73 class EqualityOptions;
74 class PKL;
75 class ReadError;
76 class Reel;
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 
97  DCP (DCP &&);
98  DCP& operator= (DCP &&);
99 
118  void read (std::vector<VerificationNote>* notes = nullptr, bool ignore_incorrect_picture_mxf_type = false);
119 
126  bool equals(DCP const & other, EqualityOptions const& options, NoteHandler note) const;
127 
128  void add (std::shared_ptr<CPL> cpl);
129 
130  std::vector<std::shared_ptr<CPL>> cpls () const;
131 
136  std::vector<std::shared_ptr<Asset>> assets (bool ignore_unresolved = false) const;
137 
138  bool any_encrypted () const;
139  bool all_encrypted () const;
140 
145  void add (DecryptedKDM const &);
146 
147  void set_issuer(std::string issuer);
148  void set_creator(std::string creator);
149  void set_issue_date(std::string issue_date);
150  void set_annotation_text(std::string annotation_text);
151 
157  void write_xml(
158  std::shared_ptr<const CertificateChain> signer = std::shared_ptr<const CertificateChain>(),
159  bool include_mca_subdescriptors = true,
160  NameFormat name_format = NameFormat("%t")
161  );
162 
163  void resolve_refs (std::vector<std::shared_ptr<Asset>> assets);
164 
166  boost::optional<Standard> standard () const {
167  if (!_asset_map) {
168  return {};
169  }
170 
171  return _asset_map->standard();
172  }
173 
174  boost::filesystem::path directory () const {
175  return _directory;
176  }
177 
181  std::vector<std::shared_ptr<PKL>> pkls () const {
182  return _pkls;
183  }
184 
185  boost::optional<boost::filesystem::path> asset_map_file() const {
186  if (!_asset_map) {
187  return {};
188  }
189 
190  return _asset_map->file();
191  }
192 
193  boost::optional<AssetMap> asset_map() const {
194  return _asset_map;
195  }
196 
197  static std::vector<boost::filesystem::path> directories_from_files (std::vector<boost::filesystem::path> files);
198 
199 private:
200 
201  void write_volindex (Standard standard) const;
202 
204  boost::filesystem::path _directory;
206  std::vector<std::shared_ptr<CPL>> _cpls;
208  std::vector<std::shared_ptr<PKL>> _pkls;
209  boost::optional<AssetMap> _asset_map;
210 
211  /* Metadata to use for newly created PKLs and AssetMaps */
212  boost::optional<std::string> _new_issuer;
213  boost::optional<std::string> _new_creator;
214  boost::optional<std::string> _new_issue_date;
215  boost::optional<std::string> _new_annotation_text;
216 };
217 
218 
219 }
220 
221 
222 #endif
Certificate class.
A class to create or read a DCP.
Definition: dcp.h:83
DCP(boost::filesystem::path directory)
Definition: dcp.cc:99
static std::vector< boost::filesystem::path > directories_from_files(std::vector< boost::filesystem::path > files)
Definition: dcp.cc:561
bool equals(DCP const &other, EqualityOptions const &options, NoteHandler note) const
Definition: dcp.cc:342
std::vector< std::shared_ptr< Asset > > assets(bool ignore_unresolved=false) const
Definition: dcp.cc:532
std::vector< std::shared_ptr< PKL > > _pkls
Definition: dcp.h:208
boost::filesystem::path _directory
Definition: dcp.h:204
std::vector< std::shared_ptr< CPL > > _cpls
Definition: dcp.h:206
void write_xml(std::shared_ptr< const CertificateChain > signer=std::shared_ptr< const CertificateChain >(), bool include_mca_subdescriptors=true, NameFormat name_format=NameFormat("%t"))
Definition: dcp.cc:452
boost::optional< Standard > standard() const
Definition: dcp.h:166
void read(std::vector< VerificationNote > *notes=nullptr, bool ignore_incorrect_picture_mxf_type=false)
Definition: dcp.cc:140
std::vector< std::shared_ptr< PKL > > pkls() const
Definition: dcp.h:181
void write_volindex(Standard standard) const
Definition: dcp.cc:418
A decrypted KDM.
Definition: decrypted_kdm.h:75
A class to describe what "equality" means for a particular test.
MXFMetadata class.
NameFormat class.
Namespace for everything in libdcp.
Definition: array_data.h:50
Utility methods and classes.
dcp::verify() method and associated code
Versioning variables that are written by the build system.