Include tidying src/lib/a-j*.h
[dcpomatic.git] / src / lib / ffmpeg_content.h
1 /*
2     Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef DCPOMATIC_FFMPEG_CONTENT_H
21 #define DCPOMATIC_FFMPEG_CONTENT_H
22
23 #include "video_content.h"
24 #include "audio_content.h"
25 #include "subtitle_content.h"
26
27 struct AVFormatContext;
28 struct AVStream;
29
30 class Filter;
31 class FFmpegSubtitleStream;
32 class FFmpegAudioStream;
33 struct ffmpeg_pts_offset_test;
34 struct audio_sampling_rate_test;
35
36 class FFmpegContentProperty : public VideoContentProperty
37 {
38 public:
39         static int const SUBTITLE_STREAMS;
40         static int const SUBTITLE_STREAM;
41         static int const FILTERS;
42 };
43
44 class FFmpegContent : public VideoContent, public AudioContent, public SubtitleContent
45 {
46 public:
47         FFmpegContent (boost::shared_ptr<const Film>, boost::filesystem::path);
48         FFmpegContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int version, std::list<std::string> &);
49         FFmpegContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
50
51         boost::shared_ptr<FFmpegContent> shared_from_this () {
52                 return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ());
53         }
54
55         void examine (boost::shared_ptr<Job>);
56         std::string summary () const;
57         std::string technical_summary () const;
58         void as_xml (xmlpp::Node *) const;
59         DCPTime full_length () const;
60
61         std::string identifier () const;
62
63         /* VideoContent */
64         void set_default_colour_conversion ();
65
66         /* AudioContent */
67         std::vector<AudioStreamPtr> audio_streams () const;
68
69         /* SubtitleContent */
70         bool has_text_subtitles () const;
71         bool has_image_subtitles () const;
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                 boost::mutex::scoped_lock lm (_mutex);
87                 return _audio_streams;
88         }
89
90         std::vector<Filter const *> filters () const {
91                 boost::mutex::scoped_lock lm (_mutex);
92                 return _filters;
93         }
94
95         void set_subtitle_stream (boost::shared_ptr<FFmpegSubtitleStream>);
96
97         boost::optional<ContentTime> first_video () const {
98                 boost::mutex::scoped_lock lm (_mutex);
99                 return _first_video;
100         }
101
102         std::list<ContentTimePeriod> subtitles_during (ContentTimePeriod, bool starting) const;
103
104 protected:
105         void add_properties (std::list<std::pair<std::string, std::string> > &) const;
106
107 private:
108         friend struct ffmpeg_pts_offset_test;
109         friend struct audio_sampling_rate_test;
110
111         std::vector<boost::shared_ptr<FFmpegSubtitleStream> > _subtitle_streams;
112         boost::shared_ptr<FFmpegSubtitleStream> _subtitle_stream;
113         std::vector<boost::shared_ptr<FFmpegAudioStream> > _audio_streams;
114         boost::optional<ContentTime> _first_video;
115         /** Video filters that should be used when generating DCPs */
116         std::vector<Filter const *> _filters;
117
118         AVColorRange _color_range;
119         AVColorPrimaries _color_primaries;
120         AVColorTransferCharacteristic _color_trc;
121         AVColorSpace _colorspace;
122         boost::optional<int> _bits_per_pixel;
123 };
124
125 #endif