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