-/*
- * 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
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:
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
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
-/*
- * 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
* 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__
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);