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/>.
22 /** @file src/lib/dcp_examiner.h
23 * @brief DCPExaminer class.
27 #include "audio_examiner.h"
28 #include "dcp_text_track.h"
29 #include "dcpomatic_assert.h"
30 #include "video_examiner.h"
31 #include <dcp/dcp_time.h>
32 #include <dcp/rating.h>
38 class DCPExaminer : public VideoExaminer, public AudioExaminer
41 DCPExaminer(std::shared_ptr<const DCPContent>, bool tolerant);
43 bool has_video () const override {
47 boost::optional<double> video_frame_rate () const override {
48 return _video_frame_rate;
51 dcp::Size video_size () const override {
52 DCPOMATIC_ASSERT (_has_video);
53 DCPOMATIC_ASSERT (_video_size);
57 Frame video_length () const override {
61 bool yuv () const override {
65 VideoRange range () const override {
66 return VideoRange::FULL;
69 PixelQuanta pixel_quanta () const override {
73 std::string name () const {
77 bool encrypted () const {
81 bool needs_assets () const {
85 bool has_audio () const override {
89 int audio_channels () const override {
90 return _audio_channels.get_value_or (0);
93 Frame audio_length () const override {
97 int audio_frame_rate () const override {
98 return _audio_frame_rate.get_value_or (48000);
101 boost::optional<dcp::LanguageTag> audio_language () const {
102 return _audio_language;
105 /** @param type TEXT_OPEN_SUBTITLE or TEXT_CLOSED_CAPTION.
106 * @return the number of "streams" of this type in the DCP.
107 * Reels do not affect the return value of this method: if a DCP
108 * has any subtitles, type=TEXT_OPEN_SUBTITLE will return 1.
110 int text_count (TextType type) const {
111 return _text_count[type];
114 boost::optional<dcp::LanguageTag> open_subtitle_language () const {
115 return _open_subtitle_language;
118 DCPTextTrack dcp_text_track (int i) const {
119 DCPOMATIC_ASSERT (i >= 0 && i < static_cast<int>(_dcp_text_tracks.size()));
120 return _dcp_text_tracks[i];
123 bool kdm_valid () const {
127 boost::optional<dcp::Standard> standard () const {
131 bool three_d () const {
135 dcp::ContentKind content_kind () const {
136 DCPOMATIC_ASSERT(_content_kind);
137 return *_content_kind;
140 std::string cpl () const {
144 std::list<int64_t> reel_lengths () const {
145 return _reel_lengths;
148 std::map<dcp::Marker, dcp::Time> markers () const {
152 std::vector<dcp::Rating> ratings () const {
156 std::vector<std::string> content_versions () const {
157 return _content_versions;
160 bool has_atmos () const {
164 Frame atmos_length () const {
165 return _atmos_length;
168 dcp::Fraction atmos_edit_rate () const {
169 return _atmos_edit_rate;
172 /** @return fonts in each reel */
173 std::vector<std::vector<std::shared_ptr<dcpomatic::Font>>> fonts() const {
178 boost::optional<double> _video_frame_rate;
179 boost::optional<dcp::Size> _video_size;
180 Frame _video_length = 0;
181 boost::optional<int> _audio_channels;
182 boost::optional<int> _audio_frame_rate;
183 Frame _audio_length = 0;
185 /** true if this DCP has video content (but false if it has unresolved references to video content) */
186 bool _has_video = false;
187 /** true if this DCP has audio content (but false if it has unresolved references to audio content) */
188 bool _has_audio = false;
189 boost::optional<dcp::LanguageTag> _audio_language;
190 /** number of different assets of each type (OCAP/CCAP) */
191 EnumIndexedVector<int, TextType> _text_count;
192 boost::optional<dcp::LanguageTag> _open_subtitle_language;
193 /** the DCPTextTracks for each of our CCAPs */
194 std::vector<DCPTextTrack> _dcp_text_tracks;
195 bool _encrypted = false;
196 bool _needs_assets = false;
197 bool _kdm_valid = false;
198 boost::optional<dcp::Standard> _standard;
199 bool _three_d = false;
200 boost::optional<dcp::ContentKind> _content_kind;
202 std::list<int64_t> _reel_lengths;
203 std::map<dcp::Marker, dcp::Time> _markers;
204 std::vector<dcp::Rating> _ratings;
205 std::vector<std::string> _content_versions;
206 bool _has_atmos = false;
207 Frame _atmos_length = 0;
208 dcp::Fraction _atmos_edit_rate;
209 std::vector<std::vector<std::shared_ptr<dcpomatic::Font>>> _fonts;