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__
height
@ height
Definition: klash_part.cpp:329
gnash::media::gst::EncodedExtraGstData::buffer
GstBuffer * buffer
Definition: MediaParserGst.h:75
gnash::image::GnashImage::width
size_t width() const
Get the image's width.
Definition: GnashImage.h:126
gnash::image::ImageRGB
24-bit RGB bitmap
Definition: GnashImage.h:217
dsodefs.h
gnash::media::NO_VIDEO_CODEC
@ NO_VIDEO_CODEC
No video codec.
Definition: MediaParser.h:78
gnash::image::GnashImage::iterator
value_type * iterator
Definition: GnashImage.h:83
gnash::media::VideoDecoder
Abstract base class for embedded video decoders.
Definition: VideoDecoder.h:46
_
#define _(String)
Definition: log.h:44
gnash::media::VIDEO_CODEC_VP6A
@ VIDEO_CODEC_VP6A
On2 VP6 Alpha video codec.
Definition: MediaParser.h:90
gnash::media::gst::VideoDecoderGst::push
void push(const EncodedVideoFrame &buffer)
Push an encoded video frame into the decoder.
Definition: VideoDecoderGst.cpp:168
gnash::media::VIDEO_CODEC_SCREENVIDEO
@ VIDEO_CODEC_SCREENVIDEO
Screenvideo codec.
Definition: MediaParser.h:84
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::media::VIDEO_CODEC_H263
@ VIDEO_CODEC_H263
H263/SVQ3 video codec.
Definition: MediaParser.h:81
gnash::media::gst::VideoDecoderGst::width
int width() const
Get the width of the video.
Definition: VideoDecoderGst.cpp:42
gnash::image::GnashImage::channels
size_t channels() const
Get the number of channels.
Definition: GnashImage.h:119
swfdec_gst_decoder_pull
GstBuffer * swfdec_gst_decoder_pull(SwfdecGstDecoder *dec)
Definition: swfdec_codec_gst.c:399
GnashImage.h
SwfdecGstDecoder
Definition: swfdec_codec_gst.h:29
gnash::media::VIDEO_CODEC_H264
@ VIDEO_CODEC_H264
MPEG-4 Part 10, or Advanced Video Coding.
Definition: MediaParser.h:96
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::media::EncodedVideoFrame::extradata
std::unique_ptr< EncodedExtraData > extradata
Definition: MediaParser.h:443
gnash::media::EncodedVideoFrame::data
const std::uint8_t * data() const
Return pointer to actual data. Ownership retained by this class.
Definition: MediaParser.h:431
swfdec_gst_decoder_push_eos
void swfdec_gst_decoder_push_eos(SwfdecGstDecoder *dec)
Definition: swfdec_codec_gst.c:393
swfdec_gst_decoder_init
gboolean swfdec_gst_decoder_init(SwfdecGstDecoder *dec, GstCaps *srccaps, GstCaps *sinkcaps,...)
Definition: swfdec_codec_gst.c:280
gnash::media::gst::EncodedExtraGstData
Class to hold GstBuffer. Takes ownership.
Definition: MediaParserGst.h:64
gnash::image::GnashImage::const_iterator
const value_type * const_iterator
Definition: GnashImage.h:84
gnash::media::EncodedVideoFrame::dataSize
std::uint32_t dataSize() const
Return size of data buffer.
Definition: MediaParser.h:434
gnash::media::VIDEO_CODEC_VP6
@ VIDEO_CODEC_VP6
On2 VP6 video codec.
Definition: MediaParser.h:87
gnash::key::type
type
Definition: GnashKey.h:330
MediaParserGst.h
gnash::media::gst::VideoDecoderGst::height
int height() const
Get the height of the video.
Definition: VideoDecoderGst.cpp:48
swfdec_gst_decoder_push
gboolean swfdec_gst_decoder_push(SwfdecGstDecoder *dec, GstBuffer *buffer)
Definition: swfdec_codec_gst.c:365
MediaParser.h
VideoDecoder.h
gnash::media::EncodedVideoFrame::frameNum
unsigned frameNum() const
Return video frame number.
Definition: MediaParser.h:440
gnash::media::gst::gnashGstBuffer::begin
virtual const_iterator begin() const
Access the raw data.
Definition: VideoDecoderGst.h:62
gnash::image::ImageRGB::ImageRGB
ImageRGB(size_t width, size_t height)
Create an empty RGB image with uninitialized data.
Definition: GnashImage.cpp:109
gnash::media::gst::VideoDecoderGst::peek
bool peek()
Check whether a decoded frame is ready to be popped.
Definition: VideoDecoderGst.cpp:221
gnash::media::EncodedVideoFrame
An encoded video frame.
Definition: MediaParser.h:403
gst
log.h
gnash::media::gst::gnashGstBuffer::stride
virtual size_t stride() const
Get the pitch of the image buffer.
Definition: VideoDecoderGst.h:53
gnash::media::videoCodecType
videoCodecType
Video codec ids as defined in flash.
Definition: MediaParser.h:76
gnash::media::gst::gnashGstBuffer::gnashGstBuffer
gnashGstBuffer(GstBuffer *buf, int width, int height)
Definition: VideoDecoderGst.h:43
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
SwfdecGstDecoder::queue
GQueue * queue
Definition: swfdec_codec_gst.h:33
swfdec_codec_gst.h
GstUtil.h
gnash::media::gst::VideoDecoderGst
GST based VideoDecoder.
Definition: VideoDecoderGst.h:74
VideoDecoderGst.h
gnash::media::gst::gnashGstBuffer::~gnashGstBuffer
~gnashGstBuffer()
Definition: VideoDecoderGst.h:48
width
@ width
Definition: klash_part.cpp:329
gnash::media::gst::gnashGstBuffer::begin
virtual iterator begin()
Access the raw data.
Definition: VideoDecoderGst.h:57
gnash::MediaException
An exception from MediaHandler subsystem.
Definition: GnashException.h:50
gnash::media::gst::VideoDecoderGst::~VideoDecoderGst
~VideoDecoderGst()
Definition: VideoDecoderGst.cpp:112
gnash::media::gst::VideoDecoderGst::pop
std::unique_ptr< image::GnashImage > pop()
Pop a decoded frame from the decoder. THIS METHOD MAY BLOCK.
Definition: VideoDecoderGst.cpp:195
gnash::media::gst::gnashGstBuffer
Definition: VideoDecoderGst.h:41
swfdec_gst_decoder_finish
void swfdec_gst_decoder_finish(SwfdecGstDecoder *dec)
Definition: swfdec_codec_gst.c:337
gnash::media::VIDEO_CODEC_SCREENVIDEO2
@ VIDEO_CODEC_SCREENVIDEO2
Screenvideo2 codec.
Definition: MediaParser.h:93
gnash::image::GnashImage::height
size_t height() const
Get the image's width.
Definition: GnashImage.h:133
gnash::media::gst::GstUtil::check_missing_plugins
static bool check_missing_plugins(GstCaps *caps)
Check for missing plugins and try to install them if necessary.
Definition: GstUtil.cpp:102