More automated renaming.
[dcpomatic.git] / src / lib / dcp_content.h
1 /*
2     Copyright (C) 2014-2018 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 #ifndef DCPOMATIC_DCP_CONTENT_H
22 #define DCPOMATIC_DCP_CONTENT_H
23
24 /** @file  src/lib/dcp_content.h
25  *  @brief DCPContent class.
26  */
27
28 #include "content.h"
29 #include <libcxml/cxml.h>
30 #include <dcp/encrypted_kdm.h>
31
32 class DCPContentProperty
33 {
34 public:
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_CAPTION;
40         static int const NAME;
41         static int const CAPTIONS;
42 };
43
44 class ContentPart;
45
46 /** @class DCPContent
47  *  @brief An existing DCP used as input.
48  */
49 class DCPContent : public Content
50 {
51 public:
52         DCPContent (boost::shared_ptr<const Film>, boost::filesystem::path p);
53         DCPContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int version);
54
55         boost::shared_ptr<DCPContent> shared_from_this () {
56                 return boost::dynamic_pointer_cast<DCPContent> (Content::shared_from_this ());
57         }
58
59         boost::shared_ptr<const DCPContent> shared_from_this () const {
60                 return boost::dynamic_pointer_cast<const DCPContent> (Content::shared_from_this ());
61         }
62
63         DCPTime full_length () const;
64
65         void examine (boost::shared_ptr<Job>);
66         std::string summary () const;
67         std::string technical_summary () const;
68         void as_xml (xmlpp::Node *, bool with_paths) const;
69         std::string identifier () const;
70         void take_settings_from (boost::shared_ptr<const Content> c);
71
72         void set_default_colour_conversion ();
73         std::list<DCPTime> reel_split_points () const;
74
75         std::vector<boost::filesystem::path> directories () const;
76
77         bool encrypted () const {
78                 boost::mutex::scoped_lock lm (_mutex);
79                 return _encrypted;
80         }
81
82         void add_kdm (dcp::EncryptedKDM);
83         void add_ov (boost::filesystem::path ov);
84
85         boost::optional<dcp::EncryptedKDM> kdm () const {
86                 return _kdm;
87         }
88
89         bool can_be_played () const;
90         bool needs_kdm () const;
91         bool needs_assets () const;
92
93         void set_reference_video (bool r);
94
95         bool reference_video () const {
96                 boost::mutex::scoped_lock lm (_mutex);
97                 return _reference_video;
98         }
99
100         bool can_reference_video (std::string &) const;
101
102         void set_reference_audio (bool r);
103
104         bool reference_audio () const {
105                 boost::mutex::scoped_lock lm (_mutex);
106                 return _reference_audio;
107         }
108
109         bool can_reference_audio (std::string &) const;
110
111         void set_reference_caption (TextType type, bool r);
112
113         /** @param type Original type of captions in the DCP.
114          *  @return true if these captions are to be referenced.
115          */
116         bool reference_caption (TextType type) const {
117                 boost::mutex::scoped_lock lm (_mutex);
118                 return _reference_caption[type];
119         }
120
121         bool can_reference_caption (TextType type, std::string &) const;
122
123         void set_cpl (std::string id);
124
125         boost::optional<std::string> cpl () const {
126                 boost::mutex::scoped_lock lm (_mutex);
127                 return _cpl;
128         }
129
130         std::string name () const {
131                 boost::mutex::scoped_lock lm (_mutex);
132                 return _name;
133         }
134
135         bool three_d () const {
136                 boost::mutex::scoped_lock lm (_mutex);
137                 return _three_d;
138         }
139
140 private:
141         friend class reels_test5;
142
143         void add_properties (std::list<UserProperty>& p) const;
144
145         void read_directory (boost::filesystem::path);
146         std::list<DCPTimePeriod> reels () const;
147         bool can_reference (
148                 boost::function <bool (boost::shared_ptr<const Content>)>,
149                 std::string overlapping,
150                 std::string& why_not
151                 ) const;
152
153         std::string _name;
154         /** true if our DCP is encrypted */
155         bool _encrypted;
156         /** true if this DCP needs more assets before it can be played */
157         bool _needs_assets;
158         boost::optional<dcp::EncryptedKDM> _kdm;
159         /** true if _kdm successfully decrypts the first frame of our DCP */
160         bool _kdm_valid;
161         /** true if the video in this DCP should be included in the output by reference
162          *  rather than by rewrapping.
163          */
164         bool _reference_video;
165         /** true if the audio in this DCP should be included in the output by reference
166          *  rather than by rewrapping.
167          */
168         bool _reference_audio;
169         /** true if the captions in this DCP should be included in the output by reference
170          *  rather than by rewrapping.  The types here are the original caption types,
171          *  not what they are being used for.
172          */
173         bool _reference_caption[CAPTION_COUNT];
174
175         boost::optional<dcp::Standard> _standard;
176         bool _three_d;
177         /** ID of the CPL to use; older metadata might not specify this: in that case
178          *  just use the only CPL.
179          */
180         boost::optional<std::string> _cpl;
181         /** List of the lengths of the reels in this DCP */
182         std::list<int64_t> _reel_lengths;
183 };
184
185 #endif