Fix insensitive subtitle controls after adding a VF.
[dcpomatic.git] / src / lib / dcp_content.h
1 /*
2     Copyright (C) 2014-2016 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_SUBTITLE;
40         static int const NAME;
41         static int const HAS_SUBTITLES;
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 use_template (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::list<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::list<std::string> &) const;
110
111         void set_reference_subtitle (bool r);
112
113         bool reference_subtitle () const {
114                 boost::mutex::scoped_lock lm (_mutex);
115                 return _reference_subtitle;
116         }
117
118         bool can_reference_subtitle (std::list<std::string> &) const;
119
120         void set_cpl (std::string id);
121
122         boost::optional<std::string> cpl () const {
123                 boost::mutex::scoped_lock lm (_mutex);
124                 return _cpl;
125         }
126
127 private:
128         friend class reels_test5;
129
130         void add_properties (std::list<UserProperty>& p) const;
131
132         void read_directory (boost::filesystem::path);
133         std::list<DCPTimePeriod> reels () const;
134         bool can_reference (
135                 boost::function <boost::shared_ptr<ContentPart> (boost::shared_ptr<const Content>)>,
136                 std::string overlapping,
137                 std::list<std::string>& why_not
138                 ) const;
139
140         std::string name () const {
141                 boost::mutex::scoped_lock lm (_mutex);
142                 return _name;
143         }
144
145         std::string _name;
146         /** true if our DCP is encrypted */
147         bool _encrypted;
148         /** true if this DCP needs more assets before it can be played */
149         bool _needs_assets;
150         boost::optional<dcp::EncryptedKDM> _kdm;
151         /** true if _kdm successfully decrypts the first frame of our DCP */
152         bool _kdm_valid;
153         /** true if the video in this DCP should be included in the output by reference
154          *  rather than by rewrapping.
155          */
156         bool _reference_video;
157         /** true if the audio in this DCP should be included in the output by reference
158          *  rather than by rewrapping.
159          */
160         bool _reference_audio;
161         /** true if the subtitle in this DCP should be included in the output by reference
162          *  rather than by rewrapping.
163          */
164         bool _reference_subtitle;
165
166         boost::optional<dcp::Standard> _standard;
167         bool _three_d;
168         /** ID of the CPL to use; older metadata might not specify this: in that case
169          *  just use the only CPL.
170          */
171         boost::optional<std::string> _cpl;
172         /** List of the lengths of the reels in this DCP */
173         std::list<int64_t> _reel_lengths;
174 };
175
176 #endif