[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash libmedia/Makefile.am libmedia/VideoDecode...
From: |
Bastiaan Jacques |
Subject: |
[Gnash-commit] gnash libmedia/Makefile.am libmedia/VideoDecode... |
Date: |
Sat, 23 Feb 2008 18:12:53 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Bastiaan Jacques <bjacques> 08/02/23 18:12:53
Modified files:
libmedia : Makefile.am VideoDecoder.h
libmedia/ffmpeg: VideoDecoderFfmpeg.cpp VideoDecoderFfmpeg.h
libmedia/gst : VideoDecoderGst.cpp VideoDecoderGst.h
server/parser : video_stream_def.cpp video_stream_def.h
. : ChangeLog
Log message:
* libmedia/Makefile.am: Remove MediaDecoder* from the build,
since
they are unused and unmaintained.
* libmedia/VideoDecoder.h: Revise the VideoDecoder interface,
closely
modeled after that of VideoDecoderGst.
* libmedia/ffmpeg/VideoDecoderFfmpeg.{cpp,h}: Implement the new
VideoDecoder interface. This fixes embedded video.
* libmedia/gst/VideoDecoderGst.{cpp,h}: Update VideoDecoderGst
to
match the new VideoDecoder interface.
* server/parser/video_stream_def.{cpp,h}: Remove
Gstreamer-specific
calls and get rid of #ifdefs.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/Makefile.am?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/VideoDecoder.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/VideoDecoderFfmpeg.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/gst/VideoDecoderGst.cpp?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/gst/VideoDecoderGst.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/video_stream_def.cpp?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/video_stream_def.h?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5733&r2=1.5734
Patches:
Index: libmedia/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libmedia/Makefile.am,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libmedia/Makefile.am 22 Feb 2008 14:40:51 -0000 1.15
+++ libmedia/Makefile.am 23 Feb 2008 18:12:51 -0000 1.16
@@ -77,13 +77,11 @@
FLVParser.cpp \
AudioDecoderNellymoser.cpp \
AudioDecoderSimple.cpp \
- MediaDecoder.cpp \
$(NULL)
noinst_HEADERS = \
FLVParser.h \
MediaBuffer.h \
- MediaDecoder.h \
AudioDecoder.h \
VideoDecoder.h \
MediaParser.h \
@@ -103,7 +101,6 @@
gst/SoundHandlerGst.cpp \
gst/GstUtil.cpp \
gst/SoundGst.cpp \
- gst/MediaDecoderGst.cpp \
gst/gstflvdemux.c \
gst/gstflvparse.c \
gst/gstbuffersrc.c
@@ -116,7 +113,6 @@
gst/SoundHandlerGst.h \
gst/GstUtil.h \
gst/SoundGst.h \
- gst/MediaDecoderGst.h \
gst/gstflvdemux.h \
gst/gstflvparse.h \
gst/gstbuffersrc.h \
Index: libmedia/VideoDecoder.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/VideoDecoder.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libmedia/VideoDecoder.h 21 Jan 2008 23:10:14 -0000 1.11
+++ libmedia/VideoDecoder.h 23 Feb 2008 18:12:51 -0000 1.12
@@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// $Id: VideoDecoder.h,v 1.11 2008/01/21 23:10:14 rsavoye Exp $
+// $Id: VideoDecoder.h,v 1.12 2008/02/23 18:12:51 bjacques Exp $
#ifndef __VIDEODECODER_H__
#define __VIDEODECODER_H__
@@ -27,92 +27,78 @@
namespace gnash {
namespace media {
-/// Video decoding base class.
-class VideoDecoder {
+class EncodedVideoFrame;
-public:
- VideoDecoder() {}
+/// \brief Abstract base class for embedded video decoders.
+///
+/// This very simple design allows, but does not require does not require,
+/// the use of threads in an implementation. A user of this class push a frame
+/// into the decoder and can subsequently pop a decoded frame. Since the pop()
+/// call may block, it is advisable to first call peek() to see if there is a
+/// frame ready to be popped.
+class VideoDecoder : public boost::noncopyable {
- // virtual classes need a virtual destructor !
- virtual ~VideoDecoder() {}
+public:
+ virtual ~VideoDecoder()
+ {
+ }
- /// Return the number of bytes input frame data is expected
- /// to be padded with zeroes. Make sure to provide such
- /// padding to avoid illegal reads.
+ /// Push an encoded video frame into the decoder
///
- virtual unsigned getPaddingBytes() const { return 8; }
+ /// @param the video frame to decode
+ virtual void push(const EncodedVideoFrame& buffer) = 0;
- /// Sets up the decoder.
- //
- /// @param info
- /// VideoInfo class with all the info needed to decode
- /// the video correctly.
- ///
- /// @return true if succesfull else false
+ /// Pop a decoded frame from the decoder. THIS METHOD MAY BLOCK.
///
- virtual bool setup(VideoInfo* /*info*/) { return false; }
+ /// @return The decoded video frame.
+ virtual std::auto_ptr<image::rgb> pop() = 0;
- /// Sets up the decoder.
- //
- /// @param width
- /// The width of the video
- ///
- /// @param height
- /// The height of the video
- ///
- /// @param deblocking
- /// Should a deblocking filter be used? 1 = off, 2 = on
- ///
- /// @param smoothing
- /// Should the video be smoothed?
- ///
- /// @param format
- /// The codec of the video, see codecType
- ///
- /// @param outputFormat
- /// The outputFormat of the video, see videoOutputFormat
- ///
- /// @return true if succesfull else false
- ///
- virtual bool setup(
- int /*width*/,
- int /*height*/,
- int /*deblocking*/,
- bool /*smoothing*/,
- videoCodecType /*format*/,
- int /*outputFormat*/) /* should this argument be of
VideoOutputFormat type ?*/ { return false; }
-
- /// Decodes a frame and returns a pointer to the data
- //
- /// @param input
- /// The video data
+ /// Check whether a decoded frame is ready to be popped. This method will
+ /// never block.
///
- /// @param inputSize
- /// The size of the video data
- ///
- /// @param outputSize
- /// The output size of the video data, is passed by reference.
- ///
- /// @return a pointer to the decoded data, or NULL if decoding fails.
- /// The caller owns the decoded data.
- ///
- virtual boost::uint8_t* decode(boost::uint8_t* /*input*/,
boost::uint32_t /*inputSize*/, boost::uint32_t& /*outputSize*/) { return NULL; }
+ /// @return true if there is a frame ready to be popped.
+ virtual bool peek() = 0;
+};
- /// Decodes a frame and returns an image::base containing it
- //
- /// @param input
- /// The video data
- ///
- /// @param inputSize
- /// The size of the video data
- ///
- /// @return a pointer to the image with the decoded data, or NULL if
decoding fails.
- /// The caller owns the decoded data.
- ///
- virtual std::auto_ptr<image::image_base> decodeToImage(boost::uint8_t*
/*input*/, boost::uint32_t /*inputSize*/) { return
std::auto_ptr<image::image_base>(NULL); }
+/// This class represents a video frame that has not yet been decoded.
+class EncodedVideoFrame : public boost::noncopyable
+{
+public:
+ /// @param buffer Pointer to the video data corresponding to this frame. This
+ /// class takes ownership of the pointer.
+ /// @param buf_size The size, in bytes, of the data pointed to in the buffer
+ /// argument
+ /// @param frame_number The number of the frame in the video stream.
+ EncodedVideoFrame(boost::uint8_t* buffer, size_t buf_size, size_t frame_num)
+ : _buffer(buffer),
+ _buffer_size(buf_size),
+ _frame_number(frame_num)
+ {}
+
+ uint8_t* data() const
+ {
+ return _buffer.get();
+ }
+
+ size_t dataSize() const
+ {
+ return _buffer_size;
+ }
+
+ size_t frameNum() const
+ {
+ return _frame_number;
+ }
+
+private:
+ boost::scoped_array<uint8_t> _buffer;
+ size_t _buffer_size;
+ size_t _frame_number;
};
+
+
} // gnash.media namespace
} // gnash namespace
Index: libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 22 Feb 2008 14:20:45 -0000
1.2
+++ libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 23 Feb 2008 18:12:51 -0000
1.3
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: VideoDecoderFfmpeg.cpp,v 1.2 2008/02/22 14:20:45 strk Exp $
+// $Id: VideoDecoderFfmpeg.cpp,v 1.3 2008/02/23 18:12:51 bjacques Exp $
#include "VideoDecoderFfmpeg.h"
@@ -27,32 +27,15 @@
}
#endif
#include <boost/scoped_array.hpp>
+#include <boost/foreach.hpp>
namespace gnash {
namespace media {
-VideoDecoderFfmpeg::VideoDecoderFfmpeg ()
+VideoDecoderFfmpeg::VideoDecoderFfmpeg(videoCodecType format, int width,int
height)
:
_videoCodec(NULL),
_videoCodecCtx(NULL)
-{}
-
-VideoDecoderFfmpeg::~VideoDecoderFfmpeg()
-{
- if (_videoCodecCtx)
- {
- avcodec_close(_videoCodecCtx);
- av_free(_videoCodecCtx);
- }
-}
-
-bool VideoDecoderFfmpeg::setup(
- int width,
- int height,
- int /*deblocking*/,
- bool /*smoothing*/,
- videoCodecType format, // should this argument be of codecType
type ?
- int /*outputFormat*/)
{
// Init the avdecoder-decoder
avcodec_init();
@@ -76,35 +59,45 @@
default:
log_error(_("Unsupported video codec %d"),
static_cast<int>(format));
- return false;
+ return;
}
- _videoCodec = avcodec_find_decoder(static_cast<CodecID>(codec_id));
+ _videoCodec = avcodec_find_decoder(static_cast<CodecID>(codec_id)); //
WTF?
if (!_videoCodec) {
log_error(_("libavcodec can't decode the current video
format"));
- return false;
+ return;
}
_videoCodecCtx = avcodec_alloc_context();
if (!_videoCodecCtx) {
log_error(_("libavcodec couldn't allocate context"));
- return false;
+ return;
}
int ret = avcodec_open(_videoCodecCtx, _videoCodec);
if (ret < 0) {
log_error(_("libavcodec failed to initialize codec"));
- return false;
+ return;
}
_videoCodecCtx->width = width;
_videoCodecCtx->height = height;
assert(_videoCodecCtx->width > 0);
assert(_videoCodecCtx->height > 0);
- return true;
+ return;
+}
+
+VideoDecoderFfmpeg::~VideoDecoderFfmpeg()
+{
+ if (_videoCodecCtx)
+ {
+ avcodec_close(_videoCodecCtx);
+ av_free(_videoCodecCtx);
+ }
}
+
bool VideoDecoderFfmpeg::setup(VideoInfo* info)
{
// Init the avdecoder-decoder
@@ -370,5 +363,44 @@
}
+
+void
+VideoDecoderFfmpeg::push(const EncodedVideoFrame& buffer)
+{
+ _video_frames.push_back(&buffer);
+
+}
+
+std::auto_ptr<image::rgb>
+VideoDecoderFfmpeg::pop()
+{
+ std::auto_ptr<image::rgb> ret;
+
+ BOOST_FOREACH(const EncodedVideoFrame* frame, _video_frames) {
+ size_t output_size = 0;
+ boost::uint8_t* decoded_data = decode(frame->data(), frame->dataSize(),
+ output_size);
+ if (!decoded_data || !output_size) {
+ assert(!output_size && !decoded_data);
+ continue;
+ }
+
+ image::rgb* newimg = new image::rgb(decoded_data, _videoCodecCtx->width,
+ _videoCodecCtx->height, (_videoCodecCtx->width * 3 + 3) & ~3);
+
+ ret.reset(newimg);
+ }
+
+ _video_frames.clear();
+
+ return ret;
+}
+
+bool
+VideoDecoderFfmpeg::peek()
+{
+ return (!_video_frames.empty());
+}
+
} // gnash.media namespace
} // gnash namespace
Index: libmedia/ffmpeg/VideoDecoderFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/VideoDecoderFfmpeg.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libmedia/ffmpeg/VideoDecoderFfmpeg.h 22 Feb 2008 14:20:45 -0000
1.2
+++ libmedia/ffmpeg/VideoDecoderFfmpeg.h 23 Feb 2008 18:12:51 -0000
1.3
@@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// $Id: VideoDecoderFfmpeg.h,v 1.2 2008/02/22 14:20:45 strk Exp $
+// $Id: VideoDecoderFfmpeg.h,v 1.3 2008/02/23 18:12:51 bjacques Exp $
#ifndef __VIDEODECODERFFMPEG_H__
#define __VIDEODECODERFFMPEG_H__
@@ -40,20 +40,13 @@
class VideoDecoderFfmpeg : public VideoDecoder {
public:
- VideoDecoderFfmpeg();
+ VideoDecoderFfmpeg(videoCodecType format, int width, int height);
~VideoDecoderFfmpeg();
virtual unsigned getPaddingBytes() const { return
FF_INPUT_BUFFER_PADDING_SIZE; }
bool setup(VideoInfo* info);
- bool setup(
- int /*width*/,
- int /*height*/,
- int /*deblocking*/,
- bool /*smoothing*/,
- videoCodecType /*format*/,
- int /*outputFormat*/);
boost::uint8_t* decode(boost::uint8_t* input, boost::uint32_t
inputSize, boost::uint32_t& outputSize);
@@ -61,10 +54,18 @@
static boost::uint8_t* convertRGB24(AVCodecContext* srcCtx, AVFrame*
srcFrame);
+
+ void push(const EncodedVideoFrame& buffer);
+
+ std::auto_ptr<image::rgb> pop();
+
+ bool peek();
+
private:
AVCodec* _videoCodec;
AVCodecContext* _videoCodecCtx;
+ std::vector<const EncodedVideoFrame*> _video_frames;
};
Index: libmedia/gst/VideoDecoderGst.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/gst/VideoDecoderGst.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- libmedia/gst/VideoDecoderGst.cpp 22 Feb 2008 18:28:31 -0000 1.16
+++ libmedia/gst/VideoDecoderGst.cpp 23 Feb 2008 18:12:51 -0000 1.17
@@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// $Id: VideoDecoderGst.cpp,v 1.16 2008/02/22 18:28:31 bjacques Exp $
+// $Id: VideoDecoderGst.cpp,v 1.17 2008/02/23 18:12:51 bjacques Exp $
#ifdef HAVE_CONFIG_H
#include "gnashconfig.h"
@@ -125,22 +125,31 @@
}
void
-VideoDecoderGst::pushRawFrame(GstBuffer* buffer)
+VideoDecoderGst::push(const EncodedVideoFrame& frame)
{
if (!_pipeline) {
return;
}
+
+ GstBuffer* buffer = gst_buffer_new();
+
+ GST_BUFFER_DATA(buffer) = frame.data();
+ GST_BUFFER_SIZE(buffer) = frame.dataSize();
+ GST_BUFFER_OFFSET(buffer) = frame.frameNum();
+ GST_BUFFER_TIMESTAMP(buffer) = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_DURATION(buffer) = GST_CLOCK_TIME_NONE;
+
gst_app_src_push_buffer (GST_APP_SRC(_appsrc), buffer);
checkMessages();
}
-std::auto_ptr<gnashGstBuffer>
-VideoDecoderGst::popDecodedFrame()
+std::auto_ptr<image::rgb>
+VideoDecoderGst::pop()
{
if (!_pipeline) {
- return std::auto_ptr<gnashGstBuffer>();
+ return std::auto_ptr<image::rgb>();
}
checkMessages();
@@ -148,7 +157,7 @@
GstBuffer* buffer = gst_app_sink_pull_buffer_timed (GST_APP_SINK(_appsink));
if (!buffer) {
- return std::auto_ptr<gnashGstBuffer>();
+ return std::auto_ptr<image::rgb>();
}
GstCaps* caps = gst_buffer_get_caps(buffer);
@@ -164,7 +173,7 @@
gst_caps_unref(caps);
- std::auto_ptr<gnashGstBuffer> ret(new gnashGstBuffer(buffer, width, height));
+ std::auto_ptr<image::rgb> ret(new gnashGstBuffer(buffer, width, height));
return ret;
}
@@ -181,17 +190,6 @@
}
void
-VideoDecoderGst::reset()
-{
- if (!_pipeline) {
- return;
- }
-
- gst_element_set_state (GST_ELEMENT (_pipeline), GST_STATE_NULL); // Flushes
- gst_element_set_state (GST_ELEMENT (_pipeline), GST_STATE_PLAYING);
-}
-
-void
VideoDecoderGst::checkMessages() // any messages for me?
{
if (!_pipeline) {
Index: libmedia/gst/VideoDecoderGst.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/gst/VideoDecoderGst.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- libmedia/gst/VideoDecoderGst.h 29 Jan 2008 05:18:33 -0000 1.13
+++ libmedia/gst/VideoDecoderGst.h 23 Feb 2008 18:12:51 -0000 1.14
@@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// $Id: VideoDecoderGst.h,v 1.13 2008/01/29 05:18:33 bjacques Exp $
+// $Id: VideoDecoderGst.h,v 1.14 2008/02/23 18:12:51 bjacques Exp $
#ifndef __VIDEODECODERGST_H__
#define __VIDEODECODERGST_H__
@@ -30,6 +30,7 @@
#include <gst/gst.h>
#include "log.h"
#include "MediaParser.h"
+#include "VideoDecoder.h"
namespace gnash {
@@ -64,35 +65,22 @@
};
-class VideoDecoderGst
+class VideoDecoderGst : public VideoDecoder
{
public:
-
VideoDecoderGst(videoCodecType codec_type, int width, int height);
~VideoDecoderGst();
- void pushRawFrame(GstBuffer* buffer);
+ void push(const EncodedVideoFrame& buffer);
- /// Will block
- std::auto_ptr<gnashGstBuffer> popDecodedFrame();
+ std::auto_ptr<image::rgb> pop();
- /// Returns true if there is a decoded frame ready to be popped.
bool peek();
- /// Clears the pipeline so that the stream can start from scratch.
- void reset();
-
+private:
void checkMessages();
-
- static void
- decodebin_newpad_cb(GstElement* decodebin, GstPad* pad,
- gboolean last, gpointer user_data);
- static void
- decodebin_unknown_cb(GstElement* decodebin, GstPad* pad,
- gboolean last, gpointer user_data);
-
void handleMessage(GstMessage* message);
-private:
+
VideoDecoderGst();
VideoDecoderGst(const gnash::media::VideoDecoderGst&);
Index: server/parser/video_stream_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/video_stream_def.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- server/parser/video_stream_def.cpp 22 Feb 2008 14:20:49 -0000 1.40
+++ server/parser/video_stream_def.cpp 23 Feb 2008 18:12:52 -0000 1.41
@@ -16,7 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: video_stream_def.cpp,v 1.40 2008/02/22 14:20:49 strk Exp $
+// $Id: video_stream_def.cpp,v 1.41 2008/02/23 18:12:52 bjacques Exp $
#include "video_stream_def.h"
#include "video_stream_instance.h"
@@ -44,25 +44,10 @@
{
}
-
-#ifdef SOUND_GST
-void myunref(GstBuffer* buf)
-{
- gst_buffer_unref(buf);
-}
-#endif
-
-
video_stream_definition::~video_stream_definition()
{
-#ifdef SOUND_GST
- std::for_each(_video_frames.begin(), _video_frames.end(), myunref);
-#elif defined(USE_FFMPEG)
- for ( int32_t size = _video_frames.size()-1; size >= 0; size-- ) {
- delete _video_frames[size];
- }
- _video_frames.clear();
-#endif
+ std::for_each(_video_frames.begin(), _video_frames.end(),
+ boost::checked_deleter<media::EncodedVideoFrame>());
}
@@ -104,17 +89,17 @@
}
#ifdef SOUND_GST
- _decoder.reset( new media::VideoDecoderGst(m_codec_id, _width, _height)
);
+# define VIDEO_DECODER_NAME VideoDecoderGst
#elif defined(USE_FFMPEG)
- _decoder.reset( new media::VideoDecoderFfmpeg() );
+# define VIDEO_DECODER_NAME VideoDecoderFfmpeg
#endif
+ _decoder.reset( new media::VIDEO_DECODER_NAME(m_codec_id, _width,
_height) );
+#undef VIDEO_DECODER_NAME
}
void
video_stream_definition::readDefineVideoFrame(stream* in, SWF::tag_type tag,
movie_definition* m)
{
-#ifdef SOUND_GST
-
// Character ID has been read already, and was loaded in the constructor
assert(tag == SWF::VIDEOFRAME);
@@ -131,25 +116,16 @@
unsigned int dataSize = in->get_tag_end_position() - in->get_position();
- GstBuffer* buffer = gst_buffer_new_and_alloc(dataSize+8);
- memset(GST_BUFFER_DATA(buffer)+dataSize, 0, 8);
- GST_BUFFER_SIZE (buffer) = dataSize;
-
- if (!buffer) {
- log_error(_("Failed to allocate a buffer of size %d advertised
by SWF."),
- dataSize);
- return;
- }
+ uint8_t* buffer = new uint8_t[dataSize + 8]; // FIXME: catch bad_alloc
- GST_BUFFER_OFFSET(buffer) = frameNum;
- GST_BUFFER_TIMESTAMP(buffer) = GST_CLOCK_TIME_NONE;
- GST_BUFFER_DURATION(buffer) = GST_CLOCK_TIME_NONE;
+ size_t bytesread = in->read((char*)buffer, dataSize);
+ memset(buffer+bytesread, 0, 8);
- in->read((char*)GST_BUFFER_DATA(buffer), dataSize);
+ using namespace media;
- _video_frames.push_back(buffer);
+ EncodedVideoFrame* frame = new EncodedVideoFrame(buffer, dataSize, frameNum);
-#endif
+ _video_frames.push_back(frame);
}
@@ -160,21 +136,15 @@
return ch;
}
-#ifdef SOUND_GST
-
bool
-has_frame_number(GstBuffer* buf, boost::uint32_t frameNumber)
+has_frame_number(media::EncodedVideoFrame* frame, boost::uint32_t frameNumber)
{
- return GST_BUFFER_OFFSET(buf) == frameNumber;
+ return frame->frameNum() == frameNumber;
}
-#endif
-
std::auto_ptr<image::image_base>
video_stream_definition::get_frame_data(boost::uint32_t frameNum)
{
-#ifdef SOUND_GST
-
if (_video_frames.empty()) {
return std::auto_ptr<image::image_base>();
}
@@ -210,25 +180,18 @@
return std::auto_ptr<image::image_base>();
}
- gst_buffer_ref(*it); // make sure gstreamer doesn't delete the
buffer.
- _last_decoded_frame = GST_BUFFER_OFFSET(*it);
- _decoder->pushRawFrame(*it);
+ _last_decoded_frame = (*it)->frameNum();
+ _decoder->push(*(*it));
}
- std::auto_ptr<media::gnashGstBuffer> buffer =
_decoder->popDecodedFrame();
+ std::auto_ptr<image::rgb> buffer = _decoder->pop();
// If more data has arrived, replace the buffer with the next frame.
while (_decoder->peek()) {
- buffer = _decoder->popDecodedFrame();
+ buffer = _decoder->pop();
}
return std::auto_ptr<image::image_base>(buffer.release());
-
-#elif defined(USE_FFMPEG)
-
- return std::auto_ptr<image::image_base>( NULL );
-
-#endif
}
Index: server/parser/video_stream_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/video_stream_def.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/parser/video_stream_def.h 22 Feb 2008 14:20:49 -0000 1.23
+++ server/parser/video_stream_def.h 23 Feb 2008 18:12:52 -0000 1.24
@@ -16,7 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: video_stream_def.h,v 1.23 2008/02/22 14:20:49 strk Exp $
+// $Id: video_stream_def.h,v 1.24 2008/02/23 18:12:52 bjacques Exp $
#ifndef GNASH_VIDEO_STREAM_DEF_H
#define GNASH_VIDEO_STREAM_DEF_H
@@ -31,6 +31,7 @@
#include "swf.h"
#include "rect.h" // for composition
#include "ControlTag.h"
+#include "VideoDecoder.h"
#ifdef SOUND_GST
# include "VideoDecoderGst.h"
@@ -163,11 +164,7 @@
/// Elements of this vector are owned by this instance, and will be
deleted
/// at instance destruction time.
///
-#ifdef SOUND_GST
- typedef std::vector<GstBuffer*> EmbedFrameVec;
-#elif defined(USE_FFMPEG)
- typedef std::vector<uint8_t*> EmbedFrameVec;
-#endif
+ typedef std::vector<media::EncodedVideoFrame*> EmbedFrameVec;
EmbedFrameVec _video_frames;
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5733
retrieving revision 1.5734
diff -u -b -r1.5733 -r1.5734
--- ChangeLog 23 Feb 2008 15:56:49 -0000 1.5733
+++ ChangeLog 23 Feb 2008 18:12:52 -0000 1.5734
@@ -1,3 +1,16 @@
+2008-02-22 Bastiaan Jacques <address@hidden>
+
+ * libmedia/Makefile.am: Remove MediaDecoder* from the build, since
+ they are unused and unmaintained.
+ * libmedia/VideoDecoder.h: Revise the VideoDecoder interface, closely
+ modeled after that of VideoDecoderGst.
+ * libmedia/ffmpeg/VideoDecoderFfmpeg.{cpp,h}: Implement the new
+ VideoDecoder interface. This fixes embedded video.
+ * libmedia/gst/VideoDecoderGst.{cpp,h}: Update VideoDecoderGst to
+ match the new VideoDecoder interface.
+ * server/parser/video_stream_def.{cpp,h}: Remove Gstreamer-specific
+ calls and get rid of #ifdefs.
+
2008-02-23 Benjamin Wolsey <address@hidden>
* testsuite/swfdec/PASSING: new tests passing.
- [Gnash-commit] gnash libmedia/Makefile.am libmedia/VideoDecode...,
Bastiaan Jacques <=