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