Gnash  0.8.11dev
VideoDecoderFfmpeg.h
Go to the documentation of this file.
1 // VideoDecoderFfmpeg.h: Video decoding using the FFMPEG library.
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_VIDEODECODERFFMPEG_H
21 #define GNASH_VIDEODECODERFFMPEG_H
22 
23 #ifdef HAVE_CONFIG_H
24 #include "gnashconfig.h"
25 #endif
26 
27 #include <vector>
28 #include <memory>
29 #include "dsodefs.h" //For DSOEXPORT
30 #include "log.h"
31 #include "VideoDecoder.h"
32 #include "MediaParser.h" // for videoCodecType enum
33 #include "ffmpegHeaders.h"
34 
35 namespace gnash {
36 namespace media {
37 namespace ffmpeg {
38 
39 // Forward declarations
40 class CodecContextWrapper;
41 #ifdef HAVE_SWSCALE_H
42 class SwsContextWrapper;
43 #endif
44 
45 
48 
49 public:
50 
52 
54 
56 
57  void push(const EncodedVideoFrame& buffer);
58 
59  std::auto_ptr<image::GnashImage> pop();
60 
61  bool peek();
62 
63  int width() const;
64 
65  int height() const;
66 
67 private:
68 
70  //
73  static CodecID flashToFfmpegCodec(videoCodecType format);
74 
84  std::auto_ptr<image::GnashImage> frameToImage(AVCodecContext* srcCtx,
85  const AVFrame& srcFrame);
86 
87  void init(enum CodecID format, int width, int height,
88  boost::uint8_t* extradata=0, int extradataSize=0);
89 
90  std::auto_ptr<image::GnashImage> decode(const boost::uint8_t* input,
91  boost::uint32_t input_size);
92 
93  std::auto_ptr<image::GnashImage> decode(const EncodedVideoFrame* vf)
94  {
95  return decode(vf->data(), vf->dataSize());
96  }
97 
98  AVCodec* _videoCodec;
99  std::auto_ptr<CodecContextWrapper> _videoCodecCtx;
100 
101 #if HAVE_SWSCALE_H
102  //
108  std::auto_ptr<SwsContextWrapper> _swsContext;
109 #endif
110 
111  std::vector<const EncodedVideoFrame*> _video_frames;
112 };
113 
114 } // gnash.media.ffmpeg namespace
115 } // gnash.media namespace
116 } // gnash namespace
117 
118 #endif // __VIDEODECODERFFMPEG_H__