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"
27 #include "audio_mapping.h"
30 class ffmpeg_pts_offset_test;
32 class FFmpegAudioStream
35 FFmpegAudioStream (std::string n, int i, int f, int c)
42 mapping.make_default ();
45 FFmpegAudioStream (boost::shared_ptr<const cxml::Node>);
47 void as_xml (xmlpp::Node *) const;
54 boost::optional<double> first_audio;
57 friend class ffmpeg_pts_offset_test;
59 /* Constructor for tests */
65 extern bool operator== (FFmpegAudioStream const & a, FFmpegAudioStream const & b);
67 class FFmpegSubtitleStream
70 FFmpegSubtitleStream (std::string n, int i)
75 FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>);
77 void as_xml (xmlpp::Node *) const;
83 extern bool operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b);
85 class FFmpegContentProperty : public VideoContentProperty
88 static int const SUBTITLE_STREAMS;
89 static int const SUBTITLE_STREAM;
90 static int const AUDIO_STREAMS;
91 static int const AUDIO_STREAM;
92 static int const FILTERS;
95 class FFmpegContent : public VideoContent, public AudioContent, public SubtitleContent
98 FFmpegContent (boost::shared_ptr<const Film>, boost::filesystem::path);
99 FFmpegContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);
101 boost::shared_ptr<FFmpegContent> shared_from_this () {
102 return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ());
105 void examine (boost::shared_ptr<Job>);
106 std::string summary () const;
107 std::string technical_summary () const;
108 std::string information () const;
109 void as_xml (xmlpp::Node *) const;
110 Time full_length () const;
112 std::string identifier () const;
115 int audio_channels () const;
116 AudioContent::Frame audio_length () const;
117 int content_audio_frame_rate () const;
118 int output_audio_frame_rate () const;
119 AudioMapping audio_mapping () const;
120 void set_audio_mapping (AudioMapping);
122 void set_filters (std::vector<Filter const *> const &);
124 std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
125 boost::mutex::scoped_lock lm (_mutex);
126 return _subtitle_streams;
129 boost::shared_ptr<FFmpegSubtitleStream> subtitle_stream () const {
130 boost::mutex::scoped_lock lm (_mutex);
131 return _subtitle_stream;
134 std::vector<boost::shared_ptr<FFmpegAudioStream> > audio_streams () const {
135 boost::mutex::scoped_lock lm (_mutex);
136 return _audio_streams;
139 boost::shared_ptr<FFmpegAudioStream> audio_stream () const {
140 boost::mutex::scoped_lock lm (_mutex);
141 return _audio_stream;
144 std::vector<Filter const *> filters () const {
145 boost::mutex::scoped_lock lm (_mutex);
149 void set_subtitle_stream (boost::shared_ptr<FFmpegSubtitleStream>);
150 void set_audio_stream (boost::shared_ptr<FFmpegAudioStream>);
152 boost::optional<double> first_video () const {
153 boost::mutex::scoped_lock lm (_mutex);
158 friend class ffmpeg_pts_offset_test;
160 std::vector<boost::shared_ptr<FFmpegSubtitleStream> > _subtitle_streams;
161 boost::shared_ptr<FFmpegSubtitleStream> _subtitle_stream;
162 std::vector<boost::shared_ptr<FFmpegAudioStream> > _audio_streams;
163 boost::shared_ptr<FFmpegAudioStream> _audio_stream;
164 boost::optional<double> _first_video;
165 /** Video filters that should be used when generating DCPs */
166 std::vector<Filter const *> _filters;