Gnash  0.8.11dev
VideoDecoderGst.h
Go to the documentation of this file.
1 // VideoDecoderGst.h: Video decoding using Gstreamer.
2 //
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef GNASH_VIDEODECODERGST_H
21 #define GNASH_VIDEODECODERGST_H
22 
23 #include "GnashImage.h"
24 #include "log.h"
25 #include "VideoDecoder.h"
26 #include "dsodefs.h"
27 #include "MediaParser.h" // for videoCodecType enum
28 
29 #include <gst/gst.h>
30 
31 
32 #include "swfdec_codec_gst.h"
33 
34 
35 namespace gnash {
36 namespace media {
37 namespace gst {
38 
39 // Convenience wrapper for GstBuffer. Intended to be wrapped in an auto_ptr.
41 {
42 public:
43  gnashGstBuffer(GstBuffer* buf, int width, int height)
44  : image::ImageRGB(NULL, width, height),
45  _buffer(buf)
46  {}
47 
49  {
50  gst_buffer_unref(_buffer);
51  }
52 
53  virtual size_t stride() const {
54  return (width() * channels() + 3) &~ 3;
55  }
56 
57  virtual iterator begin()
58  {
59  return GST_BUFFER_DATA(_buffer);
60  }
61 
62  virtual const_iterator begin() const
63  {
64  return GST_BUFFER_DATA(_buffer);
65  }
66 
67 private:
68  GstBuffer* _buffer;
69 };
70 
71 
74 {
75 public:
76  VideoDecoderGst(videoCodecType codec_type, int width, int height,
77  const boost::uint8_t* extradata, size_t extradatasize);
78  VideoDecoderGst(GstCaps* caps);
79  ~VideoDecoderGst();
80 
81  void push(const EncodedVideoFrame& buffer);
82 
83  std::auto_ptr<image::GnashImage> pop();
84 
85  bool peek();
86 
88  //
90  int width() const;
91 
93  //
95  int height() const;
96 
97 private:
98 
99  int _width;
100  int _height;
101 
102  void setup(GstCaps* caps);
103 
104  VideoDecoderGst();
106 
107  SwfdecGstDecoder _decoder;
108 };
109 
110 
111 } // gnash.media.gst namespace
112 } // namespace media
113 } // namespace gnash
114 #endif // __VIDEODECODERGST_H__