v4l2: use new setup_allocation vmethod

This commit is contained in:
Wim Taymans 2011-07-26 13:18:55 +02:00
parent b2e1532021
commit e43ab9f2cd

View file

@ -138,9 +138,9 @@ static void gst_v4l2sink_get_property (GObject * object, guint prop_id,
static GstStateChangeReturn gst_v4l2sink_change_state (GstElement * element,
GstStateChange transition);
static gboolean gst_v4l2sink_sink_query (GstPad * sinkpad, GstQuery * query);
/* GstBaseSink methods: */
static gboolean gst_v4l2sink_setup_allocation (GstBaseSink * bsink,
GstQuery * query);
static GstCaps *gst_v4l2sink_get_caps (GstBaseSink * bsink, GstCaps * filter);
static gboolean gst_v4l2sink_set_caps (GstBaseSink * bsink, GstCaps * caps);
#if 0
@ -225,6 +225,8 @@ gst_v4l2sink_class_init (GstV4l2SinkClass * klass)
basesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_get_caps);
basesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_set_caps);
basesink_class->setup_allocation =
GST_DEBUG_FUNCPTR (gst_v4l2sink_setup_allocation);
basesink_class->render = GST_DEBUG_FUNCPTR (gst_v4l2sink_show_frame);
klass->v4l2_class_devices = NULL;
@ -236,10 +238,6 @@ gst_v4l2sink_class_init (GstV4l2SinkClass * klass)
static void
gst_v4l2sink_init (GstV4l2Sink * v4l2sink)
{
/* for the ALLOCATION query */
gst_pad_set_query_function (GST_BASE_SINK (v4l2sink)->sinkpad,
gst_v4l2sink_sink_query);
v4l2sink->v4l2object = gst_v4l2_object_new (GST_ELEMENT (v4l2sink),
V4L2_BUF_TYPE_VIDEO_OUTPUT, DEFAULT_PROP_DEVICE,
gst_v4l2_get_output, gst_v4l2_set_output, NULL);
@ -669,15 +667,10 @@ invalid_format:
}
static gboolean
gst_v4l2sink_sink_query (GstPad * sinkpad, GstQuery * query)
gst_v4l2sink_setup_allocation (GstBaseSink * bsink, GstQuery * query)
{
GstV4l2Sink *v4l2sink = GST_V4L2SINK (GST_PAD_PARENT (sinkpad));
GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink);
GstV4l2Object *obj = v4l2sink->v4l2object;
gboolean res = TRUE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_ALLOCATION:
{
GstBufferPool *pool;
GstStructure *config;
GstCaps *caps;
@ -697,8 +690,7 @@ gst_v4l2sink_sink_query (GstPad * sinkpad, GstQuery * query)
/* we had a pool, check caps */
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_get (config, &pcaps, &size, NULL, NULL, NULL,
NULL);
gst_buffer_pool_config_get (config, &pcaps, &size, NULL, NULL, NULL, NULL);
GST_DEBUG_OBJECT (v4l2sink,
"we had a pool with caps %" GST_PTR_FORMAT, pcaps);
@ -715,18 +707,13 @@ gst_v4l2sink_sink_query (GstPad * sinkpad, GstQuery * query)
if (pool)
gst_object_unref (pool);
break;
}
default:
res = FALSE;
break;
}
return res;
return TRUE;
/* ERRORS */
no_caps:
{
GST_DEBUG_OBJECT (sinkpad, "no caps specified");
GST_DEBUG_OBJECT (v4l2sink, "no caps specified");
return FALSE;
}
different_caps: