Make player more tolerant of some DCP errors.
[dcpomatic.git] / src / lib / dcp_examiner.h
1 /*
2     Copyright (C) 2014-2019 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
29 class DCPContent;
30
31 class DCPExaminer : public DCP, public VideoExaminer, public AudioExaminer
32 {
33 public:
34         explicit DCPExaminer (boost::shared_ptr<const DCPContent>, bool tolerant);
35
36         bool has_video () const {
37                 return _has_video;
38         }
39
40         boost::optional<double> video_frame_rate () const {
41                 return _video_frame_rate;
42         }
43
44         dcp::Size video_size () const {
45                 DCPOMATIC_ASSERT (_has_video);
46                 DCPOMATIC_ASSERT (_video_size);
47                 return *_video_size;
48         }
49
50         Frame video_length () const {
51                 return _video_length;
52         }
53
54         bool yuv () const {
55                 return false;
56         }
57
58         VideoRange range () const {
59                 return VIDEO_RANGE_FULL;
60         }
61
62         std::string name () const {
63                 return _name;
64         }
65
66         bool encrypted () const {
67                 return _encrypted;
68         }
69
70         bool needs_assets () const {
71                 return _needs_assets;
72         }
73
74         bool has_audio () const {
75                 return _has_audio;
76         }
77
78         int audio_channels () const {
79                 return _audio_channels.get_value_or (0);
80         }
81
82         Frame audio_length () const {
83                 return _audio_length;
84         }
85
86         int audio_frame_rate () const {
87                 return _audio_frame_rate.get_value_or (48000);
88         }
89
90         /** @param type TEXT_OPEN_SUBTITLE or TEXT_CLOSED_CAPTION.
91          *  @return Number of assets of this type in this DCP.
92          */
93         int text_count (TextType type) const {
94                 return _text_count[type];
95         }
96
97         bool kdm_valid () const {
98                 return _kdm_valid;
99         }
100
101         boost::optional<dcp::Standard> standard () const {
102                 return _standard;
103         }
104
105         bool three_d () const {
106                 return _three_d;
107         }
108
109         dcp::ContentKind content_kind () const {
110                 return _content_kind;
111         }
112
113         std::string cpl () const {
114                 return _cpl;
115         }
116
117         std::list<int64_t> reel_lengths () const {
118                 return _reel_lengths;
119         }
120
121 private:
122         boost::optional<double> _video_frame_rate;
123         boost::optional<dcp::Size> _video_size;
124         Frame _video_length;
125         boost::optional<int> _audio_channels;
126         boost::optional<int> _audio_frame_rate;
127         Frame _audio_length;
128         std::string _name;
129         /** true if this DCP has video content (but false if it has unresolved references to video content) */
130         bool _has_video;
131         /** true if this DCP has audio content (but false if it has unresolved references to audio content) */
132         bool _has_audio;
133         /** number of different assets of each type (OCAP/CCAP) */
134         int _text_count[TEXT_COUNT];
135         bool _encrypted;
136         bool _needs_assets;
137         bool _kdm_valid;
138         boost::optional<dcp::Standard> _standard;
139         bool _three_d;
140         dcp::ContentKind _content_kind;
141         std::string _cpl;
142         std::list<int64_t> _reel_lengths;
143 };