2 Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 #ifndef DCPOMATIC_FFMPEG_CONTENT_H
21 #define DCPOMATIC_FFMPEG_CONTENT_H
23 #include "audio_content.h"
25 struct AVFormatContext;
29 class FFmpegSubtitleStream;
30 class FFmpegAudioStream;
32 struct ffmpeg_pts_offset_test;
33 struct audio_sampling_rate_test;
35 class FFmpegContentProperty
38 static int const SUBTITLE_STREAMS;
39 /** The chosen subtitle stream, or something about it */
40 static int const SUBTITLE_STREAM;
41 static int const FILTERS;
44 class FFmpegContent : public AudioContent
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> >);
51 boost::shared_ptr<FFmpegContent> shared_from_this () {
52 return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ());
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;
61 std::string identifier () const;
64 void set_default_colour_conversion ();
67 std::vector<AudioStreamPtr> audio_streams () const;
70 bool has_text_subtitles () const;
71 bool has_image_subtitles () const;
72 double subtitle_video_frame_rate () const;
74 void set_filters (std::vector<Filter const *> const &);
76 std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
77 boost::mutex::scoped_lock lm (_mutex);
78 return _subtitle_streams;
81 boost::shared_ptr<FFmpegSubtitleStream> subtitle_stream () const {
82 boost::mutex::scoped_lock lm (_mutex);
83 return _subtitle_stream;
86 std::vector<boost::shared_ptr<FFmpegAudioStream> > ffmpeg_audio_streams () const {
87 boost::mutex::scoped_lock lm (_mutex);
88 return _audio_streams;
91 std::vector<Filter const *> filters () const {
92 boost::mutex::scoped_lock lm (_mutex);
96 void set_subtitle_stream (boost::shared_ptr<FFmpegSubtitleStream>);
98 boost::optional<ContentTime> first_video () const {
99 boost::mutex::scoped_lock lm (_mutex);
103 std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;
104 std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod, bool starting) const;
106 void signal_subtitle_stream_changed ();
109 void add_properties (std::list<UserProperty> &) const;
112 friend struct ffmpeg_pts_offset_test;
113 friend struct audio_sampling_rate_test;
115 std::vector<boost::shared_ptr<FFmpegSubtitleStream> > _subtitle_streams;
116 boost::shared_ptr<FFmpegSubtitleStream> _subtitle_stream;
117 std::vector<boost::shared_ptr<FFmpegAudioStream> > _audio_streams;
118 boost::optional<ContentTime> _first_video;
119 /** Video filters that should be used when generating DCPs */
120 std::vector<Filter const *> _filters;
122 AVColorRange _color_range;
123 AVColorPrimaries _color_primaries;
124 AVColorTransferCharacteristic _color_trc;
125 AVColorSpace _colorspace;
126 boost::optional<int> _bits_per_pixel;