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 DVDOMATIC_FFMPEG_CONTENT_H
21 #define DVDOMATIC_FFMPEG_CONTENT_H
23 #include <boost/enable_shared_from_this.hpp>
24 #include "video_content.h"
25 #include "audio_content.h"
27 class FFmpegAudioStream
30 FFmpegAudioStream (std::string n, int i, int f, int64_t c)
37 FFmpegAudioStream (boost::shared_ptr<const cxml::Node>);
39 void as_xml (xmlpp::Node *) const;
41 int channels () const {
42 return av_get_channel_layout_nb_channels (channel_layout);
48 int64_t channel_layout;
51 extern bool operator== (FFmpegAudioStream const & a, FFmpegAudioStream const & b);
53 class FFmpegSubtitleStream
56 FFmpegSubtitleStream (std::string n, int i)
61 FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>);
63 void as_xml (xmlpp::Node *) const;
69 extern bool operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b);
71 class FFmpegContentProperty : public VideoContentProperty
74 static int const SUBTITLE_STREAMS;
75 static int const SUBTITLE_STREAM;
76 static int const AUDIO_STREAMS;
77 static int const AUDIO_STREAM;
80 class FFmpegContent : public VideoContent, public AudioContent, public boost::enable_shared_from_this<FFmpegContent>
83 FFmpegContent (boost::filesystem::path);
84 FFmpegContent (boost::shared_ptr<const cxml::Node>);
85 FFmpegContent (FFmpegContent const &);
87 void examine (boost::shared_ptr<Film>, boost::shared_ptr<Job>, bool);
88 std::string summary () const;
89 std::string information () const;
90 void as_xml (xmlpp::Node *) const;
91 boost::shared_ptr<Content> clone () const;
94 int audio_channels () const;
95 ContentAudioFrame audio_length () const;
96 int audio_frame_rate () const;
97 int64_t audio_channel_layout () const;
99 std::vector<FFmpegSubtitleStream> subtitle_streams () const {
100 boost::mutex::scoped_lock lm (_mutex);
101 return _subtitle_streams;
104 boost::optional<FFmpegSubtitleStream> subtitle_stream () const {
105 boost::mutex::scoped_lock lm (_mutex);
106 return _subtitle_stream;
109 std::vector<FFmpegAudioStream> audio_streams () const {
110 boost::mutex::scoped_lock lm (_mutex);
111 return _audio_streams;
114 boost::optional<FFmpegAudioStream> audio_stream () const {
115 boost::mutex::scoped_lock lm (_mutex);
116 return _audio_stream;
119 void set_subtitle_stream (FFmpegSubtitleStream);
120 void set_audio_stream (FFmpegAudioStream);
123 std::vector<FFmpegSubtitleStream> _subtitle_streams;
124 boost::optional<FFmpegSubtitleStream> _subtitle_stream;
125 std::vector<FFmpegAudioStream> _audio_streams;
126 boost::optional<FFmpegAudioStream> _audio_stream;