2 Copyright (C) 2014-2021 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.
45 #include "certificate.h"
47 #include "language_tag.h"
49 #include <boost/filesystem.hpp>
50 #include <boost/function.hpp>
51 #include <boost/optional.hpp>
56 struct verify_invalid_language3;
65 class CertificateChain;
70 * @brief A Composition Playlist
72 class CPL : public Asset
75 CPL (std::string annotation_text, ContentKind content_kind);
77 /** Construct a CPL object from a XML file */
78 explicit CPL (boost::filesystem::path file);
81 std::shared_ptr<const Asset> other,
82 EqualityOptions options,
86 /** Add a reel to this CPL
87 * @param reel Reel to add
89 void add (std::shared_ptr<Reel> reel);
91 /** Add a KDM to this CPL. If the KDM is for any of this CPLs assets it will be used
92 * to decrypt those assets.
95 void add (DecryptedKDM const &);
97 /** @return the reels in this CPL */
98 std::vector<std::shared_ptr<Reel>> reels () const {
102 /** @return the ReelMXFs in this CPL in all reels */
103 std::vector<std::shared_ptr<const ReelMXF>> reel_mxfs () const;
104 std::vector<std::shared_ptr<ReelMXF>> reel_mxfs ();
106 /** @return true if we have any encrypted content */
107 bool any_encrypted () const;
109 /** @return true if we have all our encryptable content is encrypted */
110 bool all_encrypted () const;
112 /** Write an CompositonPlaylist XML file
114 * @param file Filename to write
115 * @param standard INTEROP or SMPTE
116 * @param signer Signer to sign the CPL, or 0 to add no signature
119 boost::filesystem::path file,
121 std::shared_ptr<const CertificateChain>
124 void resolve_refs (std::vector<std::shared_ptr<Asset>>);
126 int64_t duration () const;
128 void set_issuer (std::string issuer) {
132 void set_creator (std::string creator) {
136 void set_issue_date (std::string issue_date) {
137 _issue_date = issue_date;
140 /** @return contents of the <AnnotationText> node, if present */
141 boost::optional<std::string> annotation_text () const {
142 return _annotation_text;
145 void set_annotation_text (std::string at) {
146 _annotation_text = at;
149 /** @return contents of the <ContentTitleText> node */
150 std::string content_title_text () const {
151 return _content_title_text;
154 void set_content_title_text (std::string ct) {
155 _content_title_text = ct;
158 void set_content_kind (dcp::ContentKind k) {
162 /** @return the type of the content, used by media servers
163 * to categorise things (e.g. feature, trailer, etc.)
165 ContentKind content_kind () const {
166 return _content_kind;
169 boost::optional<ContentVersion> content_version () const;
171 std::vector<ContentVersion> content_versions () const {
172 return _content_versions;
175 void set_content_version (ContentVersion v) {
176 _content_versions.clear ();
177 _content_versions.push_back (v);
180 void set_content_versions (std::vector<ContentVersion> v);
182 std::vector<Rating> ratings () const {
186 void set_ratings (std::vector<Rating> r) {
190 boost::optional<std::string> full_content_title_text () const {
191 return _full_content_title_text;
194 void set_full_content_title_text (std::string t) {
195 _full_content_title_text = t;
198 boost::optional<std::string> full_content_title_text_language () const {
199 return _full_content_title_text_language;
202 void set_full_content_title_text_language (dcp::LanguageTag l) {
203 _full_content_title_text_language = l.to_string();
206 boost::optional<std::string> release_territory () const {
207 return _release_territory;
210 void set_release_territory (dcp::LanguageTag::RegionSubtag t) {
211 _release_territory = t.subtag();
214 boost::optional<std::string> release_territory_scope () const {
215 return _release_territory_scope;
218 boost::optional<int> version_number () const {
219 return _version_number;
222 void set_version_number (int v);
224 void unset_version_number ();
226 boost::optional<Status> status () const {
230 void set_status (Status s) {
234 boost::optional<std::string> chain () const {
238 void set_chain (std::string c) {
242 boost::optional<std::string> distributor () const {
246 void set_distributor (std::string d) {
250 boost::optional<std::string> facility () const {
254 void set_facility (std::string f) {
258 boost::optional<Luminance> luminance () const {
262 void set_luminance (Luminance l) {
266 boost::optional<std::string> main_sound_configuration () const {
267 return _main_sound_configuration;
270 void set_main_sound_configuration (std::string c) {
271 _main_sound_configuration = c;
274 boost::optional<int> main_sound_sample_rate () const {
275 return _main_sound_sample_rate;
278 void set_main_sound_sample_rate (int r) {
279 _main_sound_sample_rate = r;
282 boost::optional<dcp::Size> main_picture_stored_area () const {
283 return _main_picture_stored_area;
286 void set_main_picture_stored_area (dcp::Size s) {
287 _main_picture_stored_area = s;
290 boost::optional<dcp::Size> main_picture_active_area () const {
291 return _main_picture_active_area;
294 void set_main_picture_active_area (dcp::Size s) {
295 _main_picture_active_area = s;
298 std::vector<std::string> additional_subtitle_languages () const {
299 return _additional_subtitle_languages;
302 void set_additional_subtitle_languages (std::vector<dcp::LanguageTag> const& lang);
304 boost::optional<Standard> standard () const {
308 static std::string static_pkl_type (Standard standard);
311 /** @return type string for PKLs for this asset */
312 std::string pkl_type (Standard standard) const;
315 friend struct ::verify_invalid_language3;
317 void maybe_write_composition_metadata_asset (xmlpp::Element* node) const;
318 void read_composition_metadata_asset (cxml::ConstNodePtr node);
321 std::string _creator;
322 std::string _issue_date;
323 boost::optional<std::string> _annotation_text;
324 std::string _content_title_text; ///< <ContentTitleText>
325 ContentKind _content_kind; ///< <ContentKind>
326 std::vector<ContentVersion> _content_versions;
327 std::vector<Rating> _ratings;
328 /** Human-readable name of the composition, without any metadata (i.e. no -FTR-EN-XX- etc.) */
329 boost::optional<std::string> _full_content_title_text;
330 boost::optional<std::string> _full_content_title_text_language;
331 /** This is stored and returned as a string so that we can tolerate non-RFC-5646 strings,
332 * but must be set as a dcp::LanguageTag to try to ensure that we create compliant output.
334 boost::optional<std::string> _release_territory;
335 boost::optional<std::string> _release_territory_scope;
336 boost::optional<int> _version_number;
337 boost::optional<Status> _status;
338 boost::optional<std::string> _chain;
339 boost::optional<std::string> _distributor;
340 boost::optional<std::string> _facility;
341 boost::optional<Luminance> _luminance;
342 boost::optional<std::string> _main_sound_configuration;
343 boost::optional<int> _main_sound_sample_rate;
344 boost::optional<dcp::Size> _main_picture_stored_area;
345 boost::optional<dcp::Size> _main_picture_active_area;
346 /* See note for _release_territory above */
347 std::vector<std::string> _additional_subtitle_languages;
349 std::vector<std::shared_ptr<Reel>> _reels;
351 /** Standard of CPL that was read in */
352 boost::optional<Standard> _standard;