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 unique_ptr.
41 {
42 public:
43  gnashGstBuffer(GstBuffer* buf, int width, int height)
44  : image::ImageRGB(nullptr, 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 std::uint8_t* extradata, size_t extradatasize);
78  VideoDecoderGst(GstCaps* caps);
79  ~VideoDecoderGst();
80 
81  void push(const EncodedVideoFrame& buffer);
82 
83  std::unique_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__
virtual size_t stride() const
Get the pitch of the image buffer.
Definition: VideoDecoderGst.h:53
Definition: VideoDecoderGst.h:40
Abstract base class for embedded video decoders.
Definition: VideoDecoder.h:46
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
An encoded video frame.
Definition: MediaParser.h:402
~gnashGstBuffer()
Definition: VideoDecoderGst.h:48
24-bit RGB bitmap
Definition: GnashImage.h:216
const size_t _width
Width of image, in pixels.
Definition: GnashImage.h:203
size_t height() const
Get the image&#39;s width.
Definition: GnashImage.h:133
virtual iterator begin()
Access the raw data.
Definition: VideoDecoderGst.h:57
gnashGstBuffer(GstBuffer *buf, int width, int height)
Definition: VideoDecoderGst.h:43
virtual const_iterator begin() const
Access the raw data.
Definition: VideoDecoderGst.h:62
size_t width() const
Get the image&#39;s width.
Definition: GnashImage.h:126
GST based VideoDecoder.
Definition: VideoDecoderGst.h:73
videoCodecType
Video codec ids as defined in flash.
Definition: MediaParser.h:75
#define DSOEXPORT
Definition: dsodefs.h:55
const size_t _height
Height of image, in pixels.
Definition: GnashImage.h:206
value_type * iterator
Definition: GnashImage.h:83
Definition: swfdec_codec_gst.h:29
size_t channels() const
Get the number of channels.
Definition: GnashImage.h:119
ImageRGB(size_t width, size_t height)
Create an empty RGB image with uninitialized data.
Definition: GnashImage.cpp:109
const value_type * const_iterator
Definition: GnashImage.h:84