update for allocation query changes

This commit is contained in:
Wim Taymans 2012-03-15 20:36:51 +01:00
parent 02dc419aae
commit 7c0e2b5b1e
7 changed files with 76 additions and 67 deletions

View file

@ -4,6 +4,7 @@ libgstlibvisual_la_SOURCES = visual.c
libgstlibvisual_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LIBVISUAL_CFLAGS) libgstlibvisual_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LIBVISUAL_CFLAGS)
libgstlibvisual_la_LIBADD = \ libgstlibvisual_la_LIBADD = \
$(top_builddir)/gst-libs/gst/audio/libgstaudio-$(GST_MAJORMINOR).la \ $(top_builddir)/gst-libs/gst/audio/libgstaudio-$(GST_MAJORMINOR).la \
$(top_builddir)/gst-libs/gst/video/libgstvideo-$(GST_MAJORMINOR).la \
$(GST_BASE_LIBS) $(LIBVISUAL_LIBS) $(GST_BASE_LIBS) $(LIBVISUAL_LIBS)
libgstlibvisual_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstlibvisual_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstlibvisual_la_LIBTOOLFLAGS = --tag=disable-static libgstlibvisual_la_LIBTOOLFLAGS = --tag=disable-static

View file

@ -24,6 +24,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/base/gstadapter.h> #include <gst/base/gstadapter.h>
#include <gst/video/video.h> #include <gst/video/video.h>
#include <gst/video/gstvideopool.h>
#include <gst/audio/audio.h> #include <gst/audio/audio.h>
#include <libvisual/libvisual.h> #include <libvisual/libvisual.h>
@ -422,7 +423,8 @@ gst_vis_src_negotiate (GstVisual * visual)
GstCaps *caps; GstCaps *caps;
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, padding, alignment; GstStructure *config;
guint size, min, max;
caps = gst_pad_query_caps (visual->srcpad, NULL); caps = gst_pad_query_caps (visual->srcpad, NULL);
@ -461,30 +463,32 @@ gst_vis_src_negotiate (GstVisual * visual)
/* find a pool for the negotiated caps now */ /* find a pool for the negotiated caps now */
query = gst_query_new_allocation (target, TRUE); query = gst_query_new_allocation (target, TRUE);
if (gst_pad_peer_query (visual->srcpad, query)) { if (!gst_pad_peer_query (visual->srcpad, query)) {
/* we got configuration from our peer, parse them */ /* not a problem, we deal with the defaults of the query */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, GST_DEBUG_OBJECT (visual, "allocation query failed");
&padding, &alignment, &pool); }
if (gst_query_get_n_allocation_pools (query) > 0) {
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
size = MAX (size, visual->outsize);
} else { } else {
pool = NULL;
size = visual->outsize; size = visual->outsize;
min = max = 0; min = max = 0;
prefix = 0;
padding = 0;
alignment = 0;
} }
if (pool == NULL) { if (pool == NULL) {
GstStructure *config; /* no pool, just parameters, we can make our own */
GST_DEBUG_OBJECT (visual, "no pool, making new pool");
/* we did not get a pool, make one ourselves then */ pool = gst_video_buffer_pool_new ();
pool = gst_buffer_pool_new ();
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, target, size, min, max, prefix,
padding, alignment);
gst_buffer_pool_set_config (pool, config);
} }
/* and configure */
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, target, size, min, max, 0, 0, 0);
gst_buffer_pool_set_config (pool, config);
if (visual->pool) if (visual->pool)
gst_object_unref (visual->pool); gst_object_unref (visual->pool);
visual->pool = pool; visual->pool = pool;
@ -899,8 +903,8 @@ gst_visual_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY: case GST_STATE_CHANGE_NULL_TO_READY:
visual->actor = visual->actor =
visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->info-> visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->
plugname); info->plugname);
visual->video = visual_video_new (); visual->video = visual_video_new ();
visual->audio = visual_audio_new (); visual->audio = visual_audio_new ();
/* can't have a play without actors */ /* can't have a play without actors */

View file

@ -773,7 +773,7 @@ theora_negotiate (GstTheoraDec * dec)
GstVideoFormat format; GstVideoFormat format;
GstQuery *query; GstQuery *query;
GstBufferPool *pool; GstBufferPool *pool;
guint size, min, max, prefix, padding, alignment; guint size, min, max;
GstStructure *config; GstStructure *config;
GstCaps *caps; GstCaps *caps;
GstVideoInfo info, cinfo; GstVideoInfo info, cinfo;
@ -876,23 +876,22 @@ theora_negotiate (GstTheoraDec * dec)
query = gst_query_new_allocation (caps, TRUE); query = gst_query_new_allocation (caps, TRUE);
if (gst_pad_peer_query (dec->srcpad, query)) { if (gst_pad_peer_query (dec->srcpad, query)) {
GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints");
/* we got configuration from our peer, parse them */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
&padding, &alignment, &pool);
/* check if downstream supports cropping */ /* check if downstream supports cropping */
dec->has_cropping = dec->has_cropping =
gst_query_has_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE); gst_query_has_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE);
} else { } else {
/* not a problem, deal with defaults */
GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints");
dec->has_cropping = FALSE;
}
if (gst_query_get_n_allocation_pools (query) > 0) {
/* we got configuration from our peer, parse them */
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
} else {
pool = NULL;
size = 0; size = 0;
min = max = 0; min = max = 0;
prefix = 0;
padding = 0;
alignment = 0;
pool = NULL;
dec->has_cropping = FALSE;
} }
GST_DEBUG_OBJECT (dec, "downstream cropping %d", dec->has_cropping); GST_DEBUG_OBJECT (dec, "downstream cropping %d", dec->has_cropping);
@ -918,14 +917,16 @@ theora_negotiate (GstTheoraDec * dec)
size = MAX (size, GST_VIDEO_INFO_SIZE (&dec->vinfo)); size = MAX (size, GST_VIDEO_INFO_SIZE (&dec->vinfo));
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding, gst_buffer_pool_config_set (config, caps, size, min, max, 0, 0, 0);
alignment);
gst_caps_unref (caps); gst_caps_unref (caps);
/* just set the option, if the pool can support it we will transparently use if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) {
* it through the video info API. We could also see if the pool support this /* just set the option, if the pool can support it we will transparently use
* option and only activate it then. */ * it through the video info API. We could also see if the pool support this
gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); * option and only activate it then. */
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
}
gst_buffer_pool_set_config (pool, config); gst_buffer_pool_set_config (pool, config);
/* and activate */ /* and activate */

View file

@ -92,7 +92,7 @@ gst_video_filter_propose_allocation (GstBaseTransform * trans,
} else } else
pool = NULL; pool = NULL;
gst_query_set_allocation_params (query, size, 0, 0, 0, 0, 15, pool); gst_query_add_allocation_pool (query, pool, size, 0, 0);
gst_object_unref (pool); gst_object_unref (pool);
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE);
@ -113,19 +113,21 @@ config_failed:
static gboolean static gboolean
gst_video_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query) gst_video_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
{ {
GstBufferPool *pool = NULL;
guint size, min, max, prefix, padding, alignment;
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, if (gst_query_get_n_allocation_pools (query) > 0) {
&padding, &alignment, &pool); GstBufferPool *pool = NULL;
if (pool) { gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
GstStructure *config;
config = gst_buffer_pool_get_config (pool); if (pool) {
gst_buffer_pool_config_add_option (config, GstStructure *config;
GST_BUFFER_POOL_OPTION_VIDEO_META);
gst_buffer_pool_set_config (pool, config); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
gst_buffer_pool_set_config (pool, config);
gst_object_unref (pool);
}
} }
return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans, return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans,
query); query);

View file

@ -610,30 +610,31 @@ static gboolean
gst_video_test_src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query) gst_video_test_src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
{ {
GstVideoTestSrc *videotestsrc; GstVideoTestSrc *videotestsrc;
GstBufferPool *pool;
guint size, min, max, prefix, padding, alignment;
videotestsrc = GST_VIDEO_TEST_SRC (bsrc); videotestsrc = GST_VIDEO_TEST_SRC (bsrc);
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, if (gst_query_get_n_allocation_pools (query) > 0) {
&padding, &alignment, &pool); GstBufferPool *pool;
/* adjust size */ guint size, min, max;
size = MAX (size, videotestsrc->info.size);
if (pool) { gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
GstStructure *config;
config = gst_buffer_pool_get_config (pool); /* adjust size */
gst_buffer_pool_config_add_option (config, size = MAX (size, videotestsrc->info.size);
GST_BUFFER_POOL_OPTION_VIDEO_META);
gst_buffer_pool_set_config (pool, config); if (pool) {
GstStructure *config;
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
gst_buffer_pool_set_config (pool, config);
}
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
if (pool)
gst_object_unref (pool);
} }
gst_query_set_allocation_params (query, size, min, max, prefix,
padding, alignment, pool);
if (pool)
gst_object_unref (pool);
return TRUE; return TRUE;
} }

View file

@ -1472,7 +1472,7 @@ gst_ximagesink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
goto config_failed; goto config_failed;
} }
/* we need at least 2 buffer because we hold on to the last one */ /* we need at least 2 buffer because we hold on to the last one */
gst_query_set_allocation_params (query, size, 2, 0, 0, 0, 0, pool); gst_query_add_allocation_pool (query, pool, size, 2, 0);
/* we also support various metadata */ /* we also support various metadata */
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE);

View file

@ -1986,7 +1986,7 @@ gst_xvimagesink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
goto config_failed; goto config_failed;
} }
/* we need at least 2 buffer because we hold on to the last one */ /* we need at least 2 buffer because we hold on to the last one */
gst_query_set_allocation_params (query, size, 2, 0, 0, 0, 0, pool); gst_query_add_allocation_pool (query, pool, size, 2, 0);
/* we also support various metadata */ /* we also support various metadata */
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE);