2 Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 /** @file src/lib/dcp_examiner.h
22 * @brief DCPExaminer class.
25 #include "video_examiner.h"
26 #include "audio_examiner.h"
28 #include "dcp_text_track.h"
29 #include "dcpomatic_assert.h"
30 #include <dcp/dcp_time.h>
34 class DCPExaminer : public DCP, public VideoExaminer, public AudioExaminer
37 explicit DCPExaminer (std::shared_ptr<const DCPContent>, bool tolerant);
39 bool has_video () const {
43 boost::optional<double> video_frame_rate () const {
44 return _video_frame_rate;
47 dcp::Size video_size () const {
48 DCPOMATIC_ASSERT (_has_video);
49 DCPOMATIC_ASSERT (_video_size);
53 Frame video_length () const {
61 VideoRange range () const {
62 return VideoRange::FULL;
65 PixelQuanta pixel_quanta () const {
69 std::string name () const {
73 bool encrypted () const {
77 bool needs_assets () const {
81 bool has_audio () const {
85 int audio_channels () const {
86 return _audio_channels.get_value_or (0);
89 Frame audio_length () const {
93 int audio_frame_rate () const {
94 return _audio_frame_rate.get_value_or (48000);
97 boost::optional<dcp::LanguageTag> audio_language () const {
98 return _audio_language;
101 /** @param type TEXT_OPEN_SUBTITLE or TEXT_CLOSED_CAPTION.
102 * @return Number of assets of this type in this DCP.
104 int text_count (TextType type) const {
105 return _text_count[static_cast<int>(type)];
108 boost::optional<dcp::LanguageTag> open_subtitle_language () const {
109 return _open_subtitle_language;
112 DCPTextTrack dcp_text_track (int i) const {
113 DCPOMATIC_ASSERT (i >= 0 && i < static_cast<int>(_dcp_text_tracks.size()));
114 return _dcp_text_tracks[i];
117 bool kdm_valid () const {
121 boost::optional<dcp::Standard> standard () const {
125 bool three_d () const {
129 dcp::ContentKind content_kind () const {
130 return _content_kind;
133 std::string cpl () const {
137 std::list<int64_t> reel_lengths () const {
138 return _reel_lengths;
141 std::map<dcp::Marker, dcp::Time> markers () const {
145 std::vector<dcp::Rating> ratings () const {
149 std::vector<std::string> content_versions () const {
150 return _content_versions;
153 bool has_atmos () const {
157 Frame atmos_length () const {
158 return _atmos_length;
161 dcp::Fraction atmos_edit_rate () const {
162 return _atmos_edit_rate;
166 boost::optional<double> _video_frame_rate;
167 boost::optional<dcp::Size> _video_size;
168 Frame _video_length = 0;
169 boost::optional<int> _audio_channels;
170 boost::optional<int> _audio_frame_rate;
171 Frame _audio_length = 0;
173 /** true if this DCP has video content (but false if it has unresolved references to video content) */
174 bool _has_video = false;
175 /** true if this DCP has audio content (but false if it has unresolved references to audio content) */
176 bool _has_audio = false;
177 boost::optional<dcp::LanguageTag> _audio_language;
178 /** number of different assets of each type (OCAP/CCAP) */
179 int _text_count[static_cast<int>(TextType::COUNT)];
180 boost::optional<dcp::LanguageTag> _open_subtitle_language;
181 /** the DCPTextTracks for each of our CCAPs */
182 std::vector<DCPTextTrack> _dcp_text_tracks;
183 bool _encrypted = false;
184 bool _needs_assets = false;
185 bool _kdm_valid = false;
186 boost::optional<dcp::Standard> _standard;
187 bool _three_d = false;
188 dcp::ContentKind _content_kind;
190 std::list<int64_t> _reel_lengths;
191 std::map<dcp::Marker, dcp::Time> _markers;
192 std::vector<dcp::Rating> _ratings;
193 std::vector<std::string> _content_versions;
194 bool _has_atmos = false;
195 Frame _atmos_length = 0;
196 dcp::Fraction _atmos_edit_rate;