Update content list when selected CPL changes in DCP content.
[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 };
42
43 class ContentPart;
44
45 /** @class DCPContent
46  *  @brief An existing DCP used as input.
47  */
48 class DCPContent : public Content
49 {
50 public:
51         DCPContent (boost::shared_ptr<const Film>, boost::filesystem::path p);
52         DCPContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int version);
53
54         boost::shared_ptr<DCPContent> shared_from_this () {
55                 return boost::dynamic_pointer_cast<DCPContent> (Content::shared_from_this ());
56         }
57
58         boost::shared_ptr<const DCPContent> shared_from_this () const {
59                 return boost::dynamic_pointer_cast<const DCPContent> (Content::shared_from_this ());
60         }
61
62         DCPTime full_length () const;
63
64         void examine (boost::shared_ptr<Job>);
65         std::string summary () const;
66         std::string technical_summary () const;
67         void as_xml (xmlpp::Node *, bool with_paths) const;
68         std::string identifier () const;
69         void use_template (boost::shared_ptr<const Content> c);
70
71         void set_default_colour_conversion ();
72         std::list<DCPTime> reel_split_points () const;
73
74         std::vector<boost::filesystem::path> directories () const;
75
76         bool encrypted () const {
77                 boost::mutex::scoped_lock lm (_mutex);
78                 return _encrypted;
79         }
80
81         void add_kdm (dcp::EncryptedKDM);
82         void add_ov (boost::filesystem::path ov);
83
84         boost::optional<dcp::EncryptedKDM> kdm () const {
85                 return _kdm;
86         }
87
88         bool can_be_played () const;
89         bool needs_kdm () const;
90         bool needs_assets () const;
91
92         void set_reference_video (bool r);
93
94         bool reference_video () const {
95                 boost::mutex::scoped_lock lm (_mutex);
96                 return _reference_video;
97         }
98
99         bool can_reference_video (std::list<std::string> &) const;
100
101         void set_reference_audio (bool r);
102
103         bool reference_audio () const {
104                 boost::mutex::scoped_lock lm (_mutex);
105                 return _reference_audio;
106         }
107
108         bool can_reference_audio (std::list<std::string> &) const;
109
110         void set_reference_subtitle (bool r);
111
112         bool reference_subtitle () const {
113                 boost::mutex::scoped_lock lm (_mutex);
114                 return _reference_subtitle;
115         }
116
117         bool can_reference_subtitle (std::list<std::string> &) const;
118
119         void set_cpl (std::string id);
120
121         boost::optional<std::string> cpl () const {
122                 boost::mutex::scoped_lock lm (_mutex);
123                 return _cpl;
124         }
125
126 private:
127         friend class reels_test5;
128
129         void add_properties (std::list<UserProperty>& p) const;
130
131         void read_directory (boost::filesystem::path);
132         std::list<DCPTimePeriod> reels () const;
133         bool can_reference (
134                 boost::function <boost::shared_ptr<ContentPart> (boost::shared_ptr<const Content>)>,
135                 std::string overlapping,
136                 std::list<std::string>& why_not
137                 ) const;
138
139         std::string name () const {
140                 boost::mutex::scoped_lock lm (_mutex);
141                 return _name;
142         }
143
144         std::string _name;
145         /** true if our DCP is encrypted */
146         bool _encrypted;
147         /** true if this DCP needs more assets before it can be played */
148         bool _needs_assets;
149         boost::optional<dcp::EncryptedKDM> _kdm;
150         /** true if _kdm successfully decrypts the first frame of our DCP */
151         bool _kdm_valid;
152         /** true if the video in this DCP should be included in the output by reference
153          *  rather than by rewrapping.
154          */
155         bool _reference_video;
156         /** true if the audio in this DCP should be included in the output by reference
157          *  rather than by rewrapping.
158          */
159         bool _reference_audio;
160         /** true if the subtitle in this DCP should be included in the output by reference
161          *  rather than by rewrapping.
162          */
163         bool _reference_subtitle;
164
165         boost::optional<dcp::Standard> _standard;
166         bool _three_d;
167         /** ID of the CPL to use; older metadata might not specify this: in that case
168          *  just use the only CPL.
169          */
170         boost::optional<std::string> _cpl;
171 };
172
173 #endif