x11: use new setup_allocation vmethod

This commit is contained in:
Wim Taymans 2011-07-26 13:17:20 +02:00
parent 56a542ec92
commit 662c1f4b6c
2 changed files with 115 additions and 141 deletions

View file

@ -1141,7 +1141,7 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
newpool = gst_ximage_buffer_pool_new (ximagesink);
structure = gst_buffer_pool_get_config (newpool);
gst_buffer_pool_config_set (structure, caps, size, 0, 0, 0, 15);
gst_buffer_pool_config_set (structure, caps, size, 2, 0, 0, 15);
if (!gst_buffer_pool_set_config (newpool, structure))
goto config_failed;
@ -1424,14 +1424,9 @@ gst_ximagesink_event (GstBaseSink * sink, GstEvent * event)
}
static gboolean
gst_ximagesink_sink_query (GstPad * sinkpad, GstQuery * query)
gst_ximagesink_setup_allocation (GstBaseSink * bsink, GstQuery * query)
{
GstXImageSink *ximagesink = GST_XIMAGESINK (GST_PAD_PARENT (sinkpad));
gboolean res = TRUE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_ALLOCATION:
{
GstXImageSink *ximagesink = GST_XIMAGESINK (bsink);
GstBufferPool *pool;
GstStructure *config;
GstCaps *caps;
@ -1453,8 +1448,7 @@ gst_ximagesink_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 (ximagesink,
"we had a pool with caps %" GST_PTR_FORMAT, pcaps);
@ -1490,28 +1484,23 @@ gst_ximagesink_sink_query (GstPad * sinkpad, GstQuery * query)
gst_query_add_allocation_meta (query, GST_META_API_VIDEO_CROP);
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 (bsink, "no caps specified");
return FALSE;
}
invalid_caps:
{
GST_DEBUG_OBJECT (sinkpad, "invalid caps specified");
GST_DEBUG_OBJECT (bsink, "invalid caps specified");
return FALSE;
}
config_failed:
{
GST_DEBUG_OBJECT (sinkpad, "failed setting config");
GST_DEBUG_OBJECT (bsink, "failed setting config");
return FALSE;
}
}
@ -1883,10 +1872,6 @@ gst_ximagesink_finalize (GObject * object)
static void
gst_ximagesink_init (GstXImageSink * ximagesink)
{
/* for the ALLOCATION query */
gst_pad_set_query_function (GST_BASE_SINK (ximagesink)->sinkpad,
gst_ximagesink_sink_query);
ximagesink->display_name = NULL;
ximagesink->xcontext = NULL;
ximagesink->xwindow = NULL;
@ -1990,6 +1975,8 @@ gst_ximagesink_class_init (GstXImageSinkClass * klass)
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_ximagesink_getcaps);
gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_ximagesink_setcaps);
gstbasesink_class->get_times = GST_DEBUG_FUNCPTR (gst_ximagesink_get_times);
gstbasesink_class->setup_allocation =
GST_DEBUG_FUNCPTR (gst_ximagesink_setup_allocation);
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_ximagesink_event);
videosink_class->show_frame = GST_DEBUG_FUNCPTR (gst_ximagesink_show_frame);

View file

@ -1650,7 +1650,7 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
newpool = gst_xvimage_buffer_pool_new (xvimagesink);
structure = gst_buffer_pool_get_config (newpool);
gst_buffer_pool_config_set (structure, caps, size, 0, 0, 0, 15);
gst_buffer_pool_config_set (structure, caps, size, 2, 0, 0, 15);
if (!gst_buffer_pool_set_config (newpool, structure))
goto config_failed;
@ -1939,14 +1939,9 @@ gst_xvimagesink_event (GstBaseSink * sink, GstEvent * event)
}
static gboolean
gst_xvimagesink_sink_query (GstPad * sinkpad, GstQuery * query)
gst_xvimagesink_setup_allocation (GstBaseSink * bsink, GstQuery * query)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (GST_PAD_PARENT (sinkpad));
gboolean res = TRUE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_ALLOCATION:
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (bsink);
GstBufferPool *pool;
GstStructure *config;
GstCaps *caps;
@ -1969,8 +1964,7 @@ gst_xvimagesink_sink_query (GstPad * sinkpad, GstQuery * query)
/* we had a pool, check caps */
GST_DEBUG_OBJECT (xvimagesink, "check existing pool 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);
if (!gst_caps_is_equal (caps, pcaps)) {
GST_DEBUG_OBJECT (xvimagesink, "pool has different caps");
@ -2004,28 +1998,23 @@ gst_xvimagesink_sink_query (GstPad * sinkpad, GstQuery * query)
gst_query_add_allocation_meta (query, GST_META_API_VIDEO_CROP);
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 (bsink, "no caps specified");
return FALSE;
}
invalid_caps:
{
GST_DEBUG_OBJECT (sinkpad, "invalid caps specified");
GST_DEBUG_OBJECT (bsink, "invalid caps specified");
return FALSE;
}
config_failed:
{
GST_DEBUG_OBJECT (sinkpad, "failed setting config");
GST_DEBUG_OBJECT (bsink, "failed setting config");
return FALSE;
}
}
@ -2759,10 +2748,6 @@ gst_xvimagesink_finalize (GObject * object)
static void
gst_xvimagesink_init (GstXvImageSink * xvimagesink)
{
/* for the ALLOCATION query */
gst_pad_set_query_function (GST_BASE_SINK (xvimagesink)->sinkpad,
gst_xvimagesink_sink_query);
xvimagesink->display_name = NULL;
xvimagesink->adaptor_no = 0;
xvimagesink->xcontext = NULL;
@ -2960,6 +2945,8 @@ gst_xvimagesink_class_init (GstXvImageSinkClass * klass)
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_xvimagesink_getcaps);
gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_xvimagesink_setcaps);
gstbasesink_class->get_times = GST_DEBUG_FUNCPTR (gst_xvimagesink_get_times);
gstbasesink_class->setup_allocation =
GST_DEBUG_FUNCPTR (gst_xvimagesink_setup_allocation);
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_xvimagesink_event);
videosink_class->show_frame = GST_DEBUG_FUNCPTR (gst_xvimagesink_show_frame);