2 Copyright (C) 2014-2018 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/>.
21 #ifndef DCPOMATIC_DCP_CONTENT_H
22 #define DCPOMATIC_DCP_CONTENT_H
24 /** @file src/lib/dcp_content.h
25 * @brief DCPContent class.
29 #include <libcxml/cxml.h>
30 #include <dcp/encrypted_kdm.h>
32 class DCPContentProperty
35 static int const NEEDS_KDM;
36 static int const NEEDS_ASSETS;
37 static int const REFERENCE_VIDEO;
38 static int const REFERENCE_AUDIO;
39 static int const REFERENCE_TEXT;
40 static int const NAME;
41 static int const TEXTS;
48 * @brief An existing DCP used as input.
50 class DCPContent : public Content
53 DCPContent (boost::filesystem::path p);
54 DCPContent (cxml::ConstNodePtr, int version);
56 boost::shared_ptr<DCPContent> shared_from_this () {
57 return boost::dynamic_pointer_cast<DCPContent> (Content::shared_from_this ());
60 boost::shared_ptr<const DCPContent> shared_from_this () const {
61 return boost::dynamic_pointer_cast<const DCPContent> (Content::shared_from_this ());
64 dcpomatic::DCPTime full_length (boost::shared_ptr<const Film> film) const;
65 dcpomatic::DCPTime approximate_length () const;
67 void examine (boost::shared_ptr<const Film> film, boost::shared_ptr<Job>);
68 std::string summary () const;
69 std::string technical_summary () const;
70 void as_xml (xmlpp::Node *, bool with_paths) const;
71 std::string identifier () const;
72 void take_settings_from (boost::shared_ptr<const Content> c);
74 void set_default_colour_conversion ();
75 std::list<dcpomatic::DCPTime> reel_split_points (boost::shared_ptr<const Film> film) const;
77 std::string video_processing_description (boost::shared_ptr<const Film> film) const;
79 std::vector<boost::filesystem::path> directories () const;
81 bool encrypted () const {
82 boost::mutex::scoped_lock lm (_mutex);
86 void add_kdm (dcp::EncryptedKDM);
87 void add_ov (boost::filesystem::path ov);
89 boost::optional<dcp::EncryptedKDM> kdm () const {
93 bool can_be_played () const;
94 bool needs_kdm () const;
95 bool needs_assets () const;
97 void set_reference_video (bool r);
99 bool reference_video () const {
100 boost::mutex::scoped_lock lm (_mutex);
101 return _reference_video;
104 bool can_reference_video (boost::shared_ptr<const Film> film, std::string &) const;
106 void set_reference_audio (bool r);
108 bool reference_audio () const {
109 boost::mutex::scoped_lock lm (_mutex);
110 return _reference_audio;
113 bool can_reference_audio (boost::shared_ptr<const Film> film, std::string &) const;
115 void set_reference_text (TextType type, bool r);
117 /** @param type Original type of texts in the DCP.
118 * @return true if these texts are to be referenced.
120 bool reference_text (TextType type) const {
121 boost::mutex::scoped_lock lm (_mutex);
122 return _reference_text[type];
125 bool can_reference_text (boost::shared_ptr<const Film> film, TextType type, std::string &) const;
127 void set_cpl (std::string id);
129 boost::optional<std::string> cpl () const {
130 boost::mutex::scoped_lock lm (_mutex);
134 std::string name () const {
135 boost::mutex::scoped_lock lm (_mutex);
139 bool three_d () const {
140 boost::mutex::scoped_lock lm (_mutex);
144 boost::optional<dcp::ContentKind> content_kind () const {
145 boost::mutex::scoped_lock lm (_mutex);
146 return _content_kind;
149 dcp::Standard standard () const {
150 boost::mutex::scoped_lock lm (_mutex);
151 DCPOMATIC_ASSERT (_standard);
152 return _standard.get ();
155 std::map<dcp::Marker, dcpomatic::ContentTime> markers () const {
159 bool kdm_timing_window_valid () const;
161 Resolution resolution () const;
163 std::vector<dcp::Rating> ratings () const {
167 std::string content_version () const {
168 return _content_version;
172 friend class reels_test5;
174 void add_properties (boost::shared_ptr<const Film> film, std::list<UserProperty>& p) const;
176 void read_directory (boost::filesystem::path);
177 void read_sub_directory (boost::filesystem::path);
178 std::list<dcpomatic::DCPTimePeriod> reels (boost::shared_ptr<const Film> film) const;
180 boost::shared_ptr<const Film> film,
181 boost::function <bool (boost::shared_ptr<const Content>)>,
182 std::string overlapping,
187 /** true if our DCP is encrypted */
189 /** true if this DCP needs more assets before it can be played */
191 boost::optional<dcp::EncryptedKDM> _kdm;
192 /** true if _kdm successfully decrypts the first frame of our DCP */
194 /** true if the video in this DCP should be included in the output by reference
195 * rather than by rewrapping.
197 bool _reference_video;
198 /** true if the audio in this DCP should be included in the output by reference
199 * rather than by rewrapping.
201 bool _reference_audio;
202 /** true if the texts in this DCP should be included in the output by reference
203 * rather than by rewrapping. The types here are the original text types,
204 * not what they are being used for.
206 bool _reference_text[TEXT_COUNT];
208 boost::optional<dcp::Standard> _standard;
209 boost::optional<dcp::ContentKind> _content_kind;
211 /** ID of the CPL to use; older metadata might not specify this: in that case
212 * just use the only CPL.
214 boost::optional<std::string> _cpl;
215 /** List of the lengths of the reels in this DCP */
216 std::list<int64_t> _reel_lengths;
217 std::map<dcp::Marker, dcpomatic::ContentTime> _markers;
218 std::vector<dcp::Rating> _ratings;
219 std::string _content_version;