Gnash  0.8.10
VideoDecoderFfmpeg.h
Go to the documentation of this file.
00001 // VideoDecoderFfmpeg.h: Video 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_VIDEODECODERFFMPEG_H
00021 #define GNASH_VIDEODECODERFFMPEG_H
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "gnashconfig.h"
00025 #endif
00026 
00027 #include <vector>
00028 #include <memory>
00029 #include "dsodefs.h" //For DSOEXPORT
00030 #include "log.h"
00031 #include "VideoDecoder.h"
00032 #include "MediaParser.h" // for videoCodecType enum
00033 #include "ffmpegHeaders.h"
00034 
00035 namespace gnash {
00036 namespace media {
00037 namespace ffmpeg {
00038 
00039 // Forward declarations
00040 class CodecContextWrapper;
00041 #ifdef HAVE_SWSCALE_H
00042 class SwsContextWrapper;
00043 #endif
00044 
00045 
00047 class VideoDecoderFfmpeg : public VideoDecoder {
00048     
00049 public:
00050 
00051     DSOEXPORT VideoDecoderFfmpeg(videoCodecType format, int width, int height);
00052 
00053     DSOEXPORT VideoDecoderFfmpeg(const VideoInfo& info);
00054 
00055     DSOEXPORT ~VideoDecoderFfmpeg();
00056     
00057     void push(const EncodedVideoFrame& buffer);
00058 
00059     std::auto_ptr<image::GnashImage> pop();
00060     
00061     bool peek();
00062 
00063     int width() const;
00064 
00065     int height() const;
00066     
00067 private:
00068     
00070     //
00073     static CodecID flashToFfmpegCodec(videoCodecType format);
00074 
00084     std::auto_ptr<image::GnashImage> frameToImage(AVCodecContext* srcCtx,
00085             const AVFrame& srcFrame);
00086 
00087     void init(enum CodecID format, int width, int height,
00088             boost::uint8_t* extradata=0, int extradataSize=0);
00089 
00090     std::auto_ptr<image::GnashImage> decode(const boost::uint8_t* input,
00091             boost::uint32_t input_size);
00092 
00093     std::auto_ptr<image::GnashImage> decode(const EncodedVideoFrame* vf)
00094     {
00095         return decode(vf->data(), vf->dataSize());
00096     }
00097 
00098     AVCodec* _videoCodec;
00099     std::auto_ptr<CodecContextWrapper> _videoCodecCtx;
00100 
00101 #if HAVE_SWSCALE_H
00102 
00103     //
00108     std::auto_ptr<SwsContextWrapper> _swsContext;
00109 #endif
00110 
00111     std::vector<const EncodedVideoFrame*> _video_frames;
00112 };
00113     
00114 } // gnash.media.ffmpeg namespace 
00115 } // gnash.media namespace 
00116 } // gnash namespace
00117 
00118 #endif // __VIDEODECODERFFMPEG_H__