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