intervideosink: render preroll frames as well

Derive from GstVideoSink so that preroll frames will automatically
get rendered too, unless the show-preroll-frame property is set to
FALSE. Fixes intervideosrc only picking up frames if intervideosink
is in PLAYING state.

https://bugzilla.gnome.org/show_bug.cgi?id=755049
This commit is contained in:
Tim-Philipp Müller 2015-09-16 00:19:35 +01:00
parent 86a8ff50c0
commit 0cb160a685
2 changed files with 9 additions and 10 deletions

View file

@ -40,9 +40,6 @@
#include "config.h" #include "config.h"
#endif #endif
#include <gst/gst.h>
#include <gst/base/gstbasesink.h>
#include <gst/video/video.h>
#include "gstintervideosink.h" #include "gstintervideosink.h"
#include <string.h> #include <string.h>
@ -63,7 +60,7 @@ static gboolean gst_inter_video_sink_start (GstBaseSink * sink);
static gboolean gst_inter_video_sink_stop (GstBaseSink * sink); static gboolean gst_inter_video_sink_stop (GstBaseSink * sink);
static gboolean gst_inter_video_sink_set_caps (GstBaseSink * sink, static gboolean gst_inter_video_sink_set_caps (GstBaseSink * sink,
GstCaps * caps); GstCaps * caps);
static GstFlowReturn gst_inter_video_sink_render (GstBaseSink * sink, static GstFlowReturn gst_inter_video_sink_show_frame (GstVideoSink * sink,
GstBuffer * buffer); GstBuffer * buffer);
enum enum
@ -84,7 +81,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
/* class initialization */ /* class initialization */
G_DEFINE_TYPE (GstInterVideoSink, gst_inter_video_sink, GST_TYPE_BASE_SINK); G_DEFINE_TYPE (GstInterVideoSink, gst_inter_video_sink, GST_TYPE_VIDEO_SINK);
static void static void
gst_inter_video_sink_class_init (GstInterVideoSinkClass * klass) gst_inter_video_sink_class_init (GstInterVideoSinkClass * klass)
@ -92,6 +89,7 @@ gst_inter_video_sink_class_init (GstInterVideoSinkClass * klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass); GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass);
GstVideoSinkClass *video_sink_class = GST_VIDEO_SINK_CLASS (klass);
GST_DEBUG_CATEGORY_INIT (gst_inter_video_sink_debug_category, GST_DEBUG_CATEGORY_INIT (gst_inter_video_sink_debug_category,
"intervideosink", 0, "debug category for intervideosink element"); "intervideosink", 0, "debug category for intervideosink element");
@ -112,8 +110,9 @@ gst_inter_video_sink_class_init (GstInterVideoSinkClass * klass)
GST_DEBUG_FUNCPTR (gst_inter_video_sink_get_times); GST_DEBUG_FUNCPTR (gst_inter_video_sink_get_times);
base_sink_class->start = GST_DEBUG_FUNCPTR (gst_inter_video_sink_start); base_sink_class->start = GST_DEBUG_FUNCPTR (gst_inter_video_sink_start);
base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_inter_video_sink_stop); base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_inter_video_sink_stop);
base_sink_class->render = GST_DEBUG_FUNCPTR (gst_inter_video_sink_render);
base_sink_class->set_caps = GST_DEBUG_FUNCPTR (gst_inter_video_sink_set_caps); base_sink_class->set_caps = GST_DEBUG_FUNCPTR (gst_inter_video_sink_set_caps);
video_sink_class->show_frame =
GST_DEBUG_FUNCPTR (gst_inter_video_sink_show_frame);
g_object_class_install_property (gobject_class, PROP_CHANNEL, g_object_class_install_property (gobject_class, PROP_CHANNEL,
g_param_spec_string ("channel", "Channel", g_param_spec_string ("channel", "Channel",
@ -244,7 +243,7 @@ gst_inter_video_sink_set_caps (GstBaseSink * sink, GstCaps * caps)
} }
static GstFlowReturn static GstFlowReturn
gst_inter_video_sink_render (GstBaseSink * sink, GstBuffer * buffer) gst_inter_video_sink_show_frame (GstVideoSink * sink, GstBuffer * buffer)
{ {
GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (sink); GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (sink);

View file

@ -20,7 +20,7 @@
#ifndef _GST_INTER_VIDEO_SINK_H_ #ifndef _GST_INTER_VIDEO_SINK_H_
#define _GST_INTER_VIDEO_SINK_H_ #define _GST_INTER_VIDEO_SINK_H_
#include <gst/base/gstbasesink.h> #include <gst/video/video.h>
#include "gstintersurface.h" #include "gstintersurface.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@ -36,7 +36,7 @@ typedef struct _GstInterVideoSinkClass GstInterVideoSinkClass;
struct _GstInterVideoSink struct _GstInterVideoSink
{ {
GstBaseSink base_intervideosink; GstVideoSink videosink;
GstInterSurface *surface; GstInterSurface *surface;
char *channel; char *channel;
@ -46,7 +46,7 @@ struct _GstInterVideoSink
struct _GstInterVideoSinkClass struct _GstInterVideoSinkClass
{ {
GstBaseSinkClass base_intervideosink_class; GstVideoSinkClass videosinkclass;
}; };
GType gst_inter_video_sink_get_type (void); GType gst_inter_video_sink_get_type (void);