2 Copyright (C) 2014-2022 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic 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 DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef DCPOMATIC_DCP_CONTENT_H
23 #define DCPOMATIC_DCP_CONTENT_H
26 /** @file src/lib/dcp_content.h
27 * @brief DCPContent class.
32 #include "enum_indexed_vector.h"
34 #include "resolution.h"
35 #include <libcxml/cxml.h>
36 #include <dcp/content_kind.h>
37 #include <dcp/encrypted_kdm.h>
38 #include <dcp/rating.h>
41 class DCPContentProperty
44 static int const NEEDS_KDM;
45 static int const NEEDS_ASSETS;
46 static int const REFERENCE_VIDEO;
47 static int const REFERENCE_AUDIO;
48 static int const REFERENCE_TEXT;
49 static int const NAME;
50 static int const TEXTS;
56 * @brief An existing DCP used as input.
58 class DCPContent : public Content
61 DCPContent (boost::filesystem::path p);
62 DCPContent (cxml::ConstNodePtr, int version);
64 std::shared_ptr<DCPContent> shared_from_this () {
65 return std::dynamic_pointer_cast<DCPContent> (Content::shared_from_this ());
68 std::shared_ptr<const DCPContent> shared_from_this () const {
69 return std::dynamic_pointer_cast<const DCPContent> (Content::shared_from_this ());
72 dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const override;
73 dcpomatic::DCPTime approximate_length () const override;
75 void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job>) override;
76 std::string summary () const override;
77 std::string technical_summary () const override;
78 void as_xml(xmlpp::Element*, bool with_paths) const override;
79 std::string identifier () const override;
80 void take_settings_from (std::shared_ptr<const Content> c) override;
82 void set_default_colour_conversion ();
83 std::list<dcpomatic::DCPTime> reel_split_points (std::shared_ptr<const Film> film) const override;
85 std::vector<boost::filesystem::path> directories () const;
87 bool encrypted () const {
88 boost::mutex::scoped_lock lm (_mutex);
92 void add_kdm (dcp::EncryptedKDM);
93 void add_ov (boost::filesystem::path ov);
95 boost::optional<dcp::EncryptedKDM> kdm () const {
99 bool can_be_played () const override;
100 bool needs_kdm () const;
101 bool needs_assets () const;
103 bool can_reference_anything(std::shared_ptr<const Film> film, std::string& why_not) const;
105 void set_reference_video (bool r);
107 bool reference_video () const {
108 boost::mutex::scoped_lock lm (_mutex);
109 return _reference_video;
112 bool can_reference_video (std::shared_ptr<const Film> film, std::string &) const;
114 void set_reference_audio (bool r);
116 bool reference_audio () const {
117 boost::mutex::scoped_lock lm (_mutex);
118 return _reference_audio;
121 bool can_reference_audio (std::shared_ptr<const Film> film, std::string &) const;
123 void set_reference_text (TextType type, bool r);
125 /** @param type Original type of texts in the DCP.
126 * @return true if these texts are to be referenced.
128 bool reference_text (TextType type) const {
129 boost::mutex::scoped_lock lm (_mutex);
130 return _reference_text[type];
133 bool can_reference_text (std::shared_ptr<const Film> film, TextType type, std::string &) const;
135 void set_cpl (std::string id);
137 boost::optional<std::string> cpl () const {
138 boost::mutex::scoped_lock lm (_mutex);
142 std::string name () const {
143 boost::mutex::scoped_lock lm (_mutex);
147 bool three_d () const {
148 boost::mutex::scoped_lock lm (_mutex);
152 boost::optional<dcp::ContentKind> content_kind () const {
153 boost::mutex::scoped_lock lm (_mutex);
154 return _content_kind;
157 dcp::Standard standard () const {
158 boost::mutex::scoped_lock lm (_mutex);
159 DCPOMATIC_ASSERT (_standard);
160 return _standard.get ();
163 std::map<dcp::Marker, dcpomatic::ContentTime> markers () const {
167 bool kdm_timing_window_valid () const;
169 Resolution resolution () const;
171 std::vector<dcp::Rating> ratings () const {
175 std::vector<std::string> content_versions () const {
176 return _content_versions;
179 int active_audio_channels() const;
181 void check_font_ids();
184 friend struct reels_test5;
186 void add_properties (std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override;
188 void read_directory (boost::filesystem::path);
189 void read_sub_directory (boost::filesystem::path);
190 std::list<dcpomatic::DCPTimePeriod> reels (std::shared_ptr<const Film> film) const;
191 bool overlaps(std::shared_ptr<const Film> film, std::function<bool (std::shared_ptr<const Content>)> part) const;
194 /** true if our DCP is encrypted */
196 /** true if this DCP needs more assets before it can be played */
198 boost::optional<dcp::EncryptedKDM> _kdm;
199 /** true if _kdm successfully decrypts the first frame of our DCP */
201 /** true if the video in this DCP should be included in the output by reference
202 * rather than by rewrapping.
204 bool _reference_video;
205 /** true if the audio in this DCP should be included in the output by reference
206 * rather than by rewrapping.
208 bool _reference_audio;
209 /** true if the texts in this DCP should be included in the output by reference
210 * rather than by rewrapping. The types here are the original text types,
211 * not what they are being used for.
213 EnumIndexedVector<bool, TextType> _reference_text;
215 boost::optional<dcp::Standard> _standard;
216 boost::optional<dcp::ContentKind> _content_kind;
218 /** ID of the CPL to use; older metadata might not specify this: in that case
219 * just use the only CPL.
221 boost::optional<std::string> _cpl;
222 /** List of the lengths of the reels in this DCP */
223 std::list<int64_t> _reel_lengths;
224 std::map<dcp::Marker, dcpomatic::ContentTime> _markers;
225 std::vector<dcp::Rating> _ratings;
226 std::vector<std::string> _content_versions;
227 EnumIndexedVector<bool, TextType> _has_non_zero_entry_point;
229 boost::optional<int> _active_audio_channels;