Gnash  0.8.10
VideoDecoderGst.h
Go to the documentation of this file.
00001 // VideoDecoderGst.h: Video decoding using Gstreamer.
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_VIDEODECODERGST_H
00021 #define GNASH_VIDEODECODERGST_H
00022 
00023 #include "GnashImage.h"
00024 #include "log.h"
00025 #include "VideoDecoder.h"
00026 #include "dsodefs.h"
00027 #include "MediaParser.h" // for videoCodecType enum
00028 
00029 #include <gst/gst.h>
00030 
00031 
00032 #include "swfdec_codec_gst.h"
00033 
00034 
00035 namespace gnash {
00036 namespace media {
00037 namespace gst {
00038 
00039 // Convenience wrapper for GstBuffer. Intended to be wrapped in an auto_ptr.
00040 class gnashGstBuffer : public image::ImageRGB
00041 {
00042 public:
00043   gnashGstBuffer(GstBuffer* buf, int width, int height)
00044   : image::ImageRGB(NULL, width, height),
00045     _buffer(buf)
00046   {}
00047   
00048   ~gnashGstBuffer()
00049   {
00050     gst_buffer_unref(_buffer);
00051   }
00052   
00053   virtual size_t stride() const {
00054       return (width() * channels() + 3) &~ 3;
00055   }
00056 
00057   virtual iterator begin()
00058   {
00059     return GST_BUFFER_DATA(_buffer);
00060   }
00061 
00062   virtual const_iterator begin() const
00063   {
00064     return GST_BUFFER_DATA(_buffer);
00065   }
00066 
00067 private:
00068   GstBuffer* _buffer;
00069 };
00070 
00071 
00073 class DSOEXPORT VideoDecoderGst : public VideoDecoder
00074 {
00075 public:
00076     VideoDecoderGst(videoCodecType codec_type, int width, int height,
00077                     const boost::uint8_t* extradata, size_t extradatasize);
00078     VideoDecoderGst(GstCaps* caps);
00079     ~VideoDecoderGst();
00080 
00081     void push(const EncodedVideoFrame& buffer);
00082 
00083     std::auto_ptr<image::GnashImage> pop();
00084   
00085     bool peek();
00086 
00088     //
00090     int width() const;
00091 
00093     //
00095     int height() const;
00096 
00097 private:
00098 
00099     int _width;
00100     int _height;
00101 
00102     void setup(GstCaps* caps);
00103 
00104     VideoDecoderGst();
00105     VideoDecoderGst(const VideoDecoderGst&);
00106 
00107     SwfdecGstDecoder _decoder;
00108 };
00109 
00110 
00111 } // gnash.media.gst namespace
00112 } // namespace media
00113 } // namespace gnash
00114 #endif // __VIDEODECODERGST_H__