Add missing GUI-side verification note descriptions.
[dcpomatic.git] / src / lib / dcp_content.h
1 /*
2     Copyright (C) 2014-2022 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21
22 #ifndef DCPOMATIC_DCP_CONTENT_H
23 #define DCPOMATIC_DCP_CONTENT_H
24
25
26 /** @file  src/lib/dcp_content.h
27  *  @brief DCPContent class.
28  */
29
30
31 #include "content.h"
32 #include "font.h"
33 #include <libcxml/cxml.h>
34 #include <dcp/content_kind.h>
35 #include <dcp/encrypted_kdm.h>
36 #include <dcp/rating.h>
37
38
39 class DCPContentProperty
40 {
41 public:
42         static int const NEEDS_KDM;
43         static int const NEEDS_ASSETS;
44         static int const REFERENCE_VIDEO;
45         static int const REFERENCE_AUDIO;
46         static int const REFERENCE_TEXT;
47         static int const NAME;
48         static int const TEXTS;
49         static int const CPL;
50 };
51
52
53 /** @class DCPContent
54  *  @brief An existing DCP used as input.
55  */
56 class DCPContent : public Content
57 {
58 public:
59         DCPContent (boost::filesystem::path p);
60         DCPContent (cxml::ConstNodePtr, int version);
61
62         std::shared_ptr<DCPContent> shared_from_this () {
63                 return std::dynamic_pointer_cast<DCPContent> (Content::shared_from_this ());
64         }
65
66         std::shared_ptr<const DCPContent> shared_from_this () const {
67                 return std::dynamic_pointer_cast<const DCPContent> (Content::shared_from_this ());
68         }
69
70         dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const override;
71         dcpomatic::DCPTime approximate_length () const override;
72
73         void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job>) override;
74         std::string summary () const override;
75         std::string technical_summary () const override;
76         void as_xml (xmlpp::Node *, bool with_paths) const override;
77         std::string identifier () const override;
78         void take_settings_from (std::shared_ptr<const Content> c) override;
79
80         void set_default_colour_conversion ();
81         std::list<dcpomatic::DCPTime> reel_split_points (std::shared_ptr<const Film> film) const override;
82
83         std::vector<boost::filesystem::path> directories () const;
84
85         bool encrypted () const {
86                 boost::mutex::scoped_lock lm (_mutex);
87                 return _encrypted;
88         }
89
90         void add_kdm (dcp::EncryptedKDM);
91         void add_ov (boost::filesystem::path ov);
92
93         boost::optional<dcp::EncryptedKDM> kdm () const {
94                 return _kdm;
95         }
96
97         bool can_be_played () const override;
98         bool needs_kdm () const;
99         bool needs_assets () const;
100
101         void set_reference_video (bool r);
102
103         bool reference_video () const {
104                 boost::mutex::scoped_lock lm (_mutex);
105                 return _reference_video;
106         }
107
108         bool can_reference_video (std::shared_ptr<const Film> film, std::string &) const;
109
110         void set_reference_audio (bool r);
111
112         bool reference_audio () const {
113                 boost::mutex::scoped_lock lm (_mutex);
114                 return _reference_audio;
115         }
116
117         bool can_reference_audio (std::shared_ptr<const Film> film, std::string &) const;
118
119         void set_reference_text (TextType type, bool r);
120
121         /** @param type Original type of texts in the DCP.
122          *  @return true if these texts are to be referenced.
123          */
124         bool reference_text (TextType type) const {
125                 boost::mutex::scoped_lock lm (_mutex);
126                 return _reference_text[static_cast<int>(type)];
127         }
128
129         bool can_reference_text (std::shared_ptr<const Film> film, TextType type, std::string &) const;
130
131         void set_cpl (std::string id);
132
133         boost::optional<std::string> cpl () const {
134                 boost::mutex::scoped_lock lm (_mutex);
135                 return _cpl;
136         }
137
138         std::string name () const {
139                 boost::mutex::scoped_lock lm (_mutex);
140                 return _name;
141         }
142
143         bool three_d () const {
144                 boost::mutex::scoped_lock lm (_mutex);
145                 return _three_d;
146         }
147
148         boost::optional<dcp::ContentKind> content_kind () const {
149                 boost::mutex::scoped_lock lm (_mutex);
150                 return _content_kind;
151         }
152
153         dcp::Standard standard () const {
154                 boost::mutex::scoped_lock lm (_mutex);
155                 DCPOMATIC_ASSERT (_standard);
156                 return _standard.get ();
157         }
158
159         std::map<dcp::Marker, dcpomatic::ContentTime> markers () const {
160                 return _markers;
161         }
162
163         bool kdm_timing_window_valid () const;
164
165         Resolution resolution () const;
166
167         std::vector<dcp::Rating> ratings () const {
168                 return _ratings;
169         }
170
171         std::vector<std::string> content_versions () const {
172                 return _content_versions;
173         }
174
175         void check_font_ids();
176
177 private:
178         friend struct reels_test5;
179
180         void add_properties (std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override;
181
182         void read_directory (boost::filesystem::path);
183         void read_sub_directory (boost::filesystem::path);
184         std::list<dcpomatic::DCPTimePeriod> reels (std::shared_ptr<const Film> film) const;
185         bool can_reference (
186                 std::shared_ptr<const Film> film,
187                 std::function <bool (std::shared_ptr<const Content>)>,
188                 std::string overlapping,
189                 std::string& why_not
190                 ) const;
191
192         std::string _name;
193         /** true if our DCP is encrypted */
194         bool _encrypted;
195         /** true if this DCP needs more assets before it can be played */
196         bool _needs_assets;
197         boost::optional<dcp::EncryptedKDM> _kdm;
198         /** true if _kdm successfully decrypts the first frame of our DCP */
199         bool _kdm_valid;
200         /** true if the video in this DCP should be included in the output by reference
201          *  rather than by rewrapping.
202          */
203         bool _reference_video;
204         /** true if the audio in this DCP should be included in the output by reference
205          *  rather than by rewrapping.
206          */
207         bool _reference_audio;
208         /** true if the texts in this DCP should be included in the output by reference
209          *  rather than by rewrapping.  The types here are the original text types,
210          *  not what they are being used for.
211          */
212         bool _reference_text[static_cast<int>(TextType::COUNT)];
213
214         boost::optional<dcp::Standard> _standard;
215         boost::optional<dcp::ContentKind> _content_kind;
216         bool _three_d;
217         /** ID of the CPL to use; older metadata might not specify this: in that case
218          *  just use the only CPL.
219          */
220         boost::optional<std::string> _cpl;
221         /** List of the lengths of the reels in this DCP */
222         std::list<int64_t> _reel_lengths;
223         std::map<dcp::Marker, dcpomatic::ContentTime> _markers;
224         std::vector<dcp::Rating> _ratings;
225         std::vector<std::string> _content_versions;
226 };
227
228
229 extern std::string id_for_font_in_reel(std::string id, int reel);
230 extern void add_fonts_from_examiner(std::shared_ptr<TextContent> text, std::vector<std::vector<std::shared_ptr<dcpomatic::Font>>> const& fonts);
231
232
233
234 #endif