Gnash 0.8.9

AudioDecoderFfmpeg.h

Go to the documentation of this file.
00001 // AudioDecoderFfmpeg.h: Audio decoding using the FFMPEG library.
00002 // 
00003 //   Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_AUDIODECODERFFMPEG_H
00020 #define GNASH_AUDIODECODERFFMPEG_H
00021 
00022 #include "ffmpegHeaders.h"
00023 
00024 #include "log.h"
00025 #include "AudioDecoder.h" // for inheritance
00026 #include "AudioResamplerFfmpeg.h" // for composition
00027 
00028 // Forward declarations
00029 namespace gnash {
00030     namespace media {
00031         class SoundInfo;
00032         class AudioInfo;
00033     }
00034 }
00035 
00036 namespace gnash {
00037 namespace media {
00038 namespace ffmpeg {
00039 
00041 class AudioDecoderFfmpeg : public AudioDecoder {
00042         
00043 public:
00048         AudioDecoderFfmpeg(const AudioInfo& info);
00049 
00054         AudioDecoderFfmpeg(SoundInfo& info);
00055         ~AudioDecoderFfmpeg();
00056 
00057     // See dox in AudioDecoder.h
00058         boost::uint8_t* decode(const boost::uint8_t* input,
00059             boost::uint32_t inputSize, boost::uint32_t& outputSize,
00060             boost::uint32_t& decodedBytes, bool parse);
00061 
00062         boost::uint8_t* decode(const EncodedAudioFrame& af,
00063             boost::uint32_t& outputSize);
00064 
00065 private:
00066 
00067         void setup(const AudioInfo& info);
00068         void setup(SoundInfo& info);
00069 
00070         boost::uint8_t* decodeFrame(const boost::uint8_t* input,
00071             boost::uint32_t inputSize, boost::uint32_t& outputSize);
00072 
00073         AVCodec* _audioCodec;
00074         AVCodecContext* _audioCodecCtx;
00075         AVCodecParserContext* _parser;
00076 
00077         // Use for resampling audio
00078         AudioResamplerFfmpeg _resampler;
00079 
00081     bool _needsParsing;
00082 
00084     //
00101     int parseInput(const boost::uint8_t* input, boost::uint32_t inputSize,
00102             boost::uint8_t const ** outFrame, int* outFrameSize);
00103 };
00104         
00105 } // gnash.media.ffmpeg namespace 
00106 } // gnash.media namespace 
00107 } // gnash namespace
00108 
00109 #endif