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