More player debugging for butler video-full states.
[dcpomatic.git] / src / lib / ffmpeg_content.h
1 /*
2     Copyright (C) 2013-2016 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 #ifndef DCPOMATIC_FFMPEG_CONTENT_H
22 #define DCPOMATIC_FFMPEG_CONTENT_H
23
24 #include "content.h"
25 #include "audio_stream.h"
26
27 struct AVFormatContext;
28 struct AVStream;
29
30 class Filter;
31 class FFmpegSubtitleStream;
32 class FFmpegAudioStream;
33 class VideoContent;
34 struct ffmpeg_pts_offset_test;
35 struct audio_sampling_rate_test;
36
37 class FFmpegContentProperty
38 {
39 public:
40         static int const SUBTITLE_STREAMS;
41         /** The chosen subtitle stream, or something about it */
42         static int const SUBTITLE_STREAM;
43         static int const FILTERS;
44 };
45
46 class FFmpegContent : public Content
47 {
48 public:
49         FFmpegContent (boost::filesystem::path);
50         FFmpegContent (cxml::ConstNodePtr, int version, std::list<std::string> &);
51         FFmpegContent (std::vector<boost::shared_ptr<Content> >);
52
53         boost::shared_ptr<FFmpegContent> shared_from_this () {
54                 return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ());
55         }
56
57         boost::shared_ptr<const FFmpegContent> shared_from_this () const {
58                 return boost::dynamic_pointer_cast<const FFmpegContent> (Content::shared_from_this ());
59         }
60
61         void examine (boost::shared_ptr<const Film> film, boost::shared_ptr<Job>);
62         void take_settings_from (boost::shared_ptr<const Content> c);
63         std::string summary () const;
64         std::string technical_summary () const;
65         void as_xml (xmlpp::Node *, bool with_paths) const;
66         DCPTime full_length (boost::shared_ptr<const Film> film) const;
67         DCPTime approximate_length () const;
68
69         std::string identifier () const;
70
71         void set_default_colour_conversion ();
72
73         void set_filters (std::vector<Filter const *> const &);
74
75         std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
76                 boost::mutex::scoped_lock lm (_mutex);
77                 return _subtitle_streams;
78         }
79
80         boost::shared_ptr<FFmpegSubtitleStream> subtitle_stream () const {
81                 boost::mutex::scoped_lock lm (_mutex);
82                 return _subtitle_stream;
83         }
84
85         std::vector<boost::shared_ptr<FFmpegAudioStream> > ffmpeg_audio_streams () const;
86
87         std::vector<Filter const *> filters () const {
88                 boost::mutex::scoped_lock lm (_mutex);
89                 return _filters;
90         }
91
92         void set_subtitle_stream (boost::shared_ptr<FFmpegSubtitleStream>);
93
94         boost::optional<ContentTime> first_video () const {
95                 boost::mutex::scoped_lock lm (_mutex);
96                 return _first_video;
97         }
98
99         void signal_subtitle_stream_changed ();
100
101         boost::optional<std::string> decryption_key () const {
102                 boost::mutex::scoped_lock lm (_mutex);
103                 return _decryption_key;
104         }
105
106         bool encrypted () const {
107                 boost::mutex::scoped_lock lm (_mutex);
108                 return _encrypted;
109         }
110
111 private:
112         void add_properties (boost::shared_ptr<const Film> film, std::list<UserProperty> &) const;
113
114         friend struct ffmpeg_pts_offset_test;
115         friend struct audio_sampling_rate_test;
116
117         std::vector<boost::shared_ptr<FFmpegSubtitleStream> > _subtitle_streams;
118         boost::shared_ptr<FFmpegSubtitleStream> _subtitle_stream;
119         boost::optional<ContentTime> _first_video;
120         /** Video filters that should be used when generating DCPs */
121         std::vector<Filter const *> _filters;
122
123         boost::optional<AVColorRange> _color_range;
124         boost::optional<AVColorPrimaries> _color_primaries;
125         boost::optional<AVColorTransferCharacteristic> _color_trc;
126         boost::optional<AVColorSpace> _colorspace;
127         boost::optional<int> _bits_per_pixel;
128         boost::optional<std::string> _decryption_key;
129         bool _encrypted;
130 };
131
132 #endif