Fixes for new libdcp with multiple content versions.
[dcpomatic.git] / src / lib / dcp_examiner.h
1 /*
2     Copyright (C) 2014-2020 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 /** @file  src/lib/dcp_examiner.h
22  *  @brief DCPExaminer class.
23  */
24
25 #include "video_examiner.h"
26 #include "audio_examiner.h"
27 #include "dcp.h"
28 #include "dcp_text_track.h"
29 #include "dcpomatic_assert.h"
30 #include <dcp/dcp_time.h>
31
32 class DCPContent;
33
34 class DCPExaminer : public DCP, public VideoExaminer, public AudioExaminer
35 {
36 public:
37         explicit DCPExaminer (boost::shared_ptr<const DCPContent>, bool tolerant);
38
39         bool has_video () const {
40                 return _has_video;
41         }
42
43         boost::optional<double> video_frame_rate () const {
44                 return _video_frame_rate;
45         }
46
47         dcp::Size video_size () const {
48                 DCPOMATIC_ASSERT (_has_video);
49                 DCPOMATIC_ASSERT (_video_size);
50                 return *_video_size;
51         }
52
53         Frame video_length () const {
54                 return _video_length;
55         }
56
57         bool yuv () const {
58                 return false;
59         }
60
61         VideoRange range () const {
62                 return VIDEO_RANGE_FULL;
63         }
64
65         std::string name () const {
66                 return _name;
67         }
68
69         bool encrypted () const {
70                 return _encrypted;
71         }
72
73         bool needs_assets () const {
74                 return _needs_assets;
75         }
76
77         bool has_audio () const {
78                 return _has_audio;
79         }
80
81         int audio_channels () const {
82                 return _audio_channels.get_value_or (0);
83         }
84
85         Frame audio_length () const {
86                 return _audio_length;
87         }
88
89         int audio_frame_rate () const {
90                 return _audio_frame_rate.get_value_or (48000);
91         }
92
93         /** @param type TEXT_OPEN_SUBTITLE or TEXT_CLOSED_CAPTION.
94          *  @return Number of assets of this type in this DCP.
95          */
96         int text_count (TextType type) const {
97                 return _text_count[type];
98         }
99
100         DCPTextTrack dcp_text_track (int i) const {
101                 DCPOMATIC_ASSERT (i >= 0 && i < static_cast<int>(_dcp_text_tracks.size()));
102                 return _dcp_text_tracks[i];
103         }
104
105         bool kdm_valid () const {
106                 return _kdm_valid;
107         }
108
109         boost::optional<dcp::Standard> standard () const {
110                 return _standard;
111         }
112
113         bool three_d () const {
114                 return _three_d;
115         }
116
117         dcp::ContentKind content_kind () const {
118                 return _content_kind;
119         }
120
121         std::string cpl () const {
122                 return _cpl;
123         }
124
125         std::list<int64_t> reel_lengths () const {
126                 return _reel_lengths;
127         }
128
129         std::map<dcp::Marker, dcp::Time> markers () const {
130                 return _markers;
131         }
132
133         std::vector<dcp::Rating> ratings () const {
134                 return _ratings;
135         }
136
137         std::vector<std::string> content_versions () const {
138                 return _content_versions;
139         }
140
141         bool has_atmos () const {
142                 return _has_atmos;
143         }
144
145         Frame atmos_length () const {
146                 return _atmos_length;
147         }
148
149         dcp::Fraction atmos_edit_rate () const {
150                 return _atmos_edit_rate;
151         }
152
153 private:
154         boost::optional<double> _video_frame_rate;
155         boost::optional<dcp::Size> _video_size;
156         Frame _video_length;
157         boost::optional<int> _audio_channels;
158         boost::optional<int> _audio_frame_rate;
159         Frame _audio_length;
160         std::string _name;
161         /** true if this DCP has video content (but false if it has unresolved references to video content) */
162         bool _has_video;
163         /** true if this DCP has audio content (but false if it has unresolved references to audio content) */
164         bool _has_audio;
165         /** number of different assets of each type (OCAP/CCAP) */
166         int _text_count[TEXT_COUNT];
167         /** the DCPTextTracks for each of our CCAPs */
168         std::vector<DCPTextTrack> _dcp_text_tracks;
169         bool _encrypted;
170         bool _needs_assets;
171         bool _kdm_valid;
172         boost::optional<dcp::Standard> _standard;
173         bool _three_d;
174         dcp::ContentKind _content_kind;
175         std::string _cpl;
176         std::list<int64_t> _reel_lengths;
177         std::map<dcp::Marker, dcp::Time> _markers;
178         std::vector<dcp::Rating> _ratings;
179         std::vector<std::string> _content_versions;
180         bool _has_atmos;
181         Frame _atmos_length;
182         dcp::Fraction _atmos_edit_rate;
183 };