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