2 Copyright (C) 2013 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 <boost/enable_shared_from_this.hpp>
24 #include "video_content.h"
25 #include "audio_content.h"
26 #include "subtitle_content.h"
29 class ffmpeg_pts_offset_test;
31 class FFmpegAudioStream
34 FFmpegAudioStream (std::string n, int i, int f, int c)
42 FFmpegAudioStream (boost::shared_ptr<const cxml::Node>);
44 void as_xml (xmlpp::Node *) const;
51 boost::optional<double> first_audio;
54 friend class ffmpeg_pts_offset_test;
55 /* Constructor for tests */
56 FFmpegAudioStream () {}
59 extern bool operator== (FFmpegAudioStream const & a, FFmpegAudioStream const & b);
61 class FFmpegSubtitleStream
64 FFmpegSubtitleStream (std::string n, int i)
69 FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>);
71 void as_xml (xmlpp::Node *) const;
77 extern bool operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b);
79 class FFmpegContentProperty : public VideoContentProperty
82 static int const SUBTITLE_STREAMS;
83 static int const SUBTITLE_STREAM;
84 static int const AUDIO_STREAMS;
85 static int const AUDIO_STREAM;
86 static int const FILTERS;
89 class FFmpegContent : public VideoContent, public AudioContent, public SubtitleContent
92 FFmpegContent (boost::shared_ptr<const Film>, boost::filesystem::path);
93 FFmpegContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);
95 boost::shared_ptr<FFmpegContent> shared_from_this () {
96 return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ());
99 void examine (boost::shared_ptr<Job>);
100 std::string summary () const;
101 std::string information () const;
102 void as_xml (xmlpp::Node *) const;
103 Time length () const;
105 std::string identifier () const;
108 int audio_channels () const;
109 AudioContent::Frame audio_length () const;
110 int content_audio_frame_rate () const;
111 int output_audio_frame_rate () const;
112 AudioMapping audio_mapping () const;
113 void set_audio_mapping (AudioMapping);
115 void set_filters (std::vector<Filter const *> const &);
117 std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
118 boost::mutex::scoped_lock lm (_mutex);
119 return _subtitle_streams;
122 boost::shared_ptr<FFmpegSubtitleStream> subtitle_stream () const {
123 boost::mutex::scoped_lock lm (_mutex);
124 return _subtitle_stream;
127 std::vector<boost::shared_ptr<FFmpegAudioStream> > audio_streams () const {
128 boost::mutex::scoped_lock lm (_mutex);
129 return _audio_streams;
132 boost::shared_ptr<FFmpegAudioStream> audio_stream () const {
133 boost::mutex::scoped_lock lm (_mutex);
134 return _audio_stream;
137 std::vector<Filter const *> filters () const {
138 boost::mutex::scoped_lock lm (_mutex);
142 void set_subtitle_stream (boost::shared_ptr<FFmpegSubtitleStream>);
143 void set_audio_stream (boost::shared_ptr<FFmpegAudioStream>);
145 boost::optional<double> first_video () const {
146 boost::mutex::scoped_lock lm (_mutex);
151 friend class ffmpeg_pts_offset_test;
153 std::vector<boost::shared_ptr<FFmpegSubtitleStream> > _subtitle_streams;
154 boost::shared_ptr<FFmpegSubtitleStream> _subtitle_stream;
155 std::vector<boost::shared_ptr<FFmpegAudioStream> > _audio_streams;
156 boost::shared_ptr<FFmpegAudioStream> _audio_stream;
157 boost::optional<double> _first_video;
158 /** Video filters that should be used when generating DCPs */
159 std::vector<Filter const *> _filters;