video: add GstVideoSinkClass::show_frame()

Add ::show_frame() vfunc which maps to basesink's ::preroll and ::render
vfuncs and add some gtk-doc chunks.

API: GstVideoSinkClass::show_frame()
This commit is contained in:
Tim-Philipp Müller 2009-09-08 18:19:19 +01:00
parent 3bbbea6212
commit e2b4187fe3
2 changed files with 84 additions and 11 deletions

View file

@ -1,7 +1,6 @@
/*
* GStreamer Video sink.
*
/* GStreamer video sink base class
* Copyright (C) <2003> Julien Moutte <julien@moutte.net>
* Copyright (C) <2009> Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -44,7 +43,12 @@
GST_DEBUG_CATEGORY_STATIC (video_sink_debug);
#define GST_CAT_DEFAULT video_sink_debug
static GstElementClass *parent_class = NULL;
static GstBaseSinkClass *parent_class = NULL;
static GstFlowReturn gst_video_sink_show_preroll_frame (GstBaseSink * bsink,
GstBuffer * buf);
static GstFlowReturn gst_video_sink_show_frame (GstBaseSink * bsink,
GstBuffer * buf);
/**
* gst_video_sink_center_rect:
@ -112,7 +116,13 @@ gst_video_sink_init (GstVideoSink * videosink)
static void
gst_video_sink_class_init (GstVideoSinkClass * klass)
{
GstBaseSinkClass *basesink_class = (GstBaseSinkClass *) klass;
parent_class = g_type_class_peek_parent (klass);
basesink_class->render = GST_DEBUG_FUNCPTR (gst_video_sink_show_frame);
basesink_class->preroll =
GST_DEBUG_FUNCPTR (gst_video_sink_show_preroll_frame);
}
static void
@ -121,6 +131,46 @@ gst_video_sink_base_init (gpointer g_class)
GST_DEBUG_CATEGORY_INIT (video_sink_debug, "videosink", 0, "GstVideoSink");
}
static GstFlowReturn
gst_video_sink_show_preroll_frame (GstBaseSink * bsink, GstBuffer * buf)
{
GstVideoSinkClass *klass;
klass = GST_VIDEO_SINK_GET_CLASS (bsink);
if (klass->show_frame == NULL) {
if (parent_class->preroll != NULL)
return parent_class->preroll (bsink, buf);
else
return GST_FLOW_OK;
}
GST_LOG_OBJECT (bsink, "rendering frame, ts=%" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
return klass->show_frame (GST_VIDEO_SINK_CAST (bsink), buf);
}
static GstFlowReturn
gst_video_sink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
{
GstVideoSinkClass *klass;
klass = GST_VIDEO_SINK_GET_CLASS (bsink);
if (klass->show_frame == NULL) {
if (parent_class->render != NULL)
return parent_class->render (bsink, buf);
else
return GST_FLOW_OK;
}
GST_LOG_OBJECT (bsink, "rendering frame, ts=%" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
return klass->show_frame (GST_VIDEO_SINK_CAST (bsink), buf);
}
/* Public methods */
GType

View file

@ -1,7 +1,6 @@
/*
* GStreamer Video sink.
*
/* GStreamer video sink base class
* Copyright (C) <2003> Julien Moutte <julien@moutte.net>
* Copyright (C) <2009> Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -18,7 +17,9 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* FIXME 0.11: turn this into a proper base class */
#ifndef __GST_VIDEO_SINK_H__
#define __GST_VIDEO_SINK_H__
@ -80,18 +81,40 @@ struct _GstVideoRectangle {
gint h;
};
/**
* GstVideoSink:
* @element: the parent object structure (which is GstBaseSink)
* @height: video height (derived class needs to set this)
* @width: video width (derived class needs to set this)
*
* The video sink instance structure. Derived video sinks should set the
* @height and @width members.
*/
struct _GstVideoSink {
GstBaseSink element;
GstBaseSink element; /* FIXME 0.11: this should not be called 'element' */
gint width, height;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
/**
* GstVideoSinkClass:
* @parent_class: the parent class structure
* @show_frame: render a video frame. Maps to #GstBaseSink::render and
* #GstBaseSink::preroll vfuncs. Since: 0.10.25
*
* The video sink class structure. Derived classes should override the
* @show_frame virtual function.
*/
struct _GstVideoSinkClass {
GstBaseSinkClass parent_class;
gpointer _gst_reserved[GST_PADDING];
GstFlowReturn (*show_frame) (GstVideoSink *video_sink, GstBuffer *buf);
/*< private >*/
gpointer _gst_reserved[GST_PADDING - 1];
};
GType gst_video_sink_get_type (void);