From f3a770a20c1ab8a91548cb3bd5c33c25ef75146e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 15 Mar 2012 20:37:56 +0100 Subject: [PATCH] update for allocation query changes --- ext/aalib/gstaasink.c | 2 +- ext/dv/gstdvdec.c | 43 ++++++++++++++++++++++++------------------- ext/gdk_pixbuf/gstgdkpixbuf.c | 35 +++++++++++++++++++---------------- ext/jpeg/gstjpegdec.c | 21 ++++++++++----------- ext/libpng/gstpngdec.c | 42 ++++++++++++++++++++++++------------------ gst/goom/gstgoom.c | 34 ++++++++++++++++++---------------- gst/goom2k1/gstgoom.c | 33 +++++++++++++++++---------------- gst/monoscope/gstmonoscope.c | 31 ++++++++++++++++--------------- gst/rtp/gstrtpvrawdepay.c | 34 ++++++++++++++++++---------------- sys/v4l2/gstv4l2sink.c | 2 +- sys/v4l2/gstv4l2src.c | 28 ++++++++++++++++++---------- 11 files changed, 166 insertions(+), 139 deletions(-) diff --git a/ext/aalib/gstaasink.c b/ext/aalib/gstaasink.c index 1894631..a162d07 100644 --- a/ext/aalib/gstaasink.c +++ b/ext/aalib/gstaasink.c @@ -346,7 +346,7 @@ gst_aasink_propose_allocation (GstBaseSink * bsink, GstQuery * query) size = GST_VIDEO_INFO_SIZE (&info); /* 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, NULL); + gst_query_add_allocation_pool (query, NULL, size, 2, 0); /* we support various metadata */ gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c index 3cadcd9..71fc8af 100644 --- a/ext/dv/gstdvdec.c +++ b/ext/dv/gstdvdec.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "gstdvdec.h" @@ -252,46 +253,50 @@ static void gst_dvdec_negotiate_pool (GstDVDec * dec, GstCaps * caps, GstVideoInfo * info) { GstQuery *query; - GstBufferPool *pool = NULL; - guint size, min, max, prefix, padding, alignment; + GstBufferPool *pool; + guint size, min, max; GstStructure *config; /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (caps, TRUE); - if (gst_pad_peer_query (dec->srcpad, query)) { - GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints"); + if (!gst_pad_peer_query (dec->srcpad, query)) { + GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); + } + + if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &padding, &alignment, &pool); + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); size = MAX (size, info->size); } else { - GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); + pool = NULL; size = info->size; min = max = 0; - prefix = 0; - padding = 0; - alignment = 0; } if (pool == NULL) { /* we did not get a pool, make one ourselves then */ - pool = gst_buffer_pool_new (); + pool = gst_video_buffer_pool_new (); } - if (dec->pool) + if (dec->pool) { + gst_buffer_pool_set_active (dec->pool, FALSE); gst_object_unref (dec->pool); + } dec->pool = pool; config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding, - alignment); - /* just set the option, if the pool can support it we will transparently use - * it through the video info API. We could also see if the pool support this - * option and only activate it then. */ - gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); - + gst_buffer_pool_config_set (config, caps, size, min, max, 0, 0, 0); + + if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) { + /* just set the option, if the pool can support it we will transparently use + * it through the video info API. We could also see if the pool support this + * 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); + /* and activate */ gst_buffer_pool_set_active (pool, TRUE); diff --git a/ext/gdk_pixbuf/gstgdkpixbuf.c b/ext/gdk_pixbuf/gstgdkpixbuf.c index 0076a3c..3952888 100644 --- a/ext/gdk_pixbuf/gstgdkpixbuf.c +++ b/ext/gdk_pixbuf/gstgdkpixbuf.c @@ -224,8 +224,9 @@ gst_gdk_pixbuf_setup_pool (GstGdkPixbuf * filter, GstVideoInfo * info) { GstCaps *target; GstQuery *query; - GstBufferPool *pool = NULL; - guint size, min, max, prefix, padding, alignment; + GstBufferPool *pool; + GstStructure *config; + guint size, min, max; target = gst_pad_get_current_caps (filter->srcpad); @@ -233,32 +234,34 @@ gst_gdk_pixbuf_setup_pool (GstGdkPixbuf * filter, GstVideoInfo * info) /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (target, TRUE); - if (gst_pad_peer_query (filter->srcpad, query)) { + if (!gst_pad_peer_query (filter->srcpad, query)) { + /* not a problem, we use the query defaults */ + GST_DEBUG_OBJECT (filter, "ALLOCATION query failed"); + } + + if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &padding, &alignment, &pool); + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); } else { + pool = NULL; size = info->size; min = max = 0; - prefix = 0; - padding = 0; - alignment = 0; } if (pool == NULL) { - GstStructure *config; - /* we did not get a pool, make one ourselves then */ 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); } - if (filter->pool) + /* 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 (filter->pool) { + gst_buffer_pool_set_active (filter->pool, FALSE); gst_object_unref (filter->pool); + } filter->pool = pool; /* and activate */ diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index 8178814..b5d6f44 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -1163,8 +1163,8 @@ static gboolean gst_jpeg_dec_buffer_pool (GstJpegDec * dec, GstCaps * caps) { GstQuery *query; - GstBufferPool *pool = NULL; - guint size, min, max, prefix, padding, alignment; + GstBufferPool *pool; + guint size, min, max; GstStructure *config; GST_DEBUG_OBJECT (dec, "setting up bufferpool"); @@ -1172,18 +1172,18 @@ gst_jpeg_dec_buffer_pool (GstJpegDec * dec, GstCaps * caps) /* find a pool for the negotiated caps now */ 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, "peer query failed, using defaults"); + } + + if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &padding, &alignment, &pool); + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); size = MAX (size, dec->info.size); } else { - GST_DEBUG_OBJECT (dec, "peer query failed, using defaults"); + pool = NULL; size = dec->info.size; min = max = 0; - prefix = 0; - padding = 0; - alignment = 15; } gst_query_unref (query); @@ -1193,8 +1193,7 @@ gst_jpeg_dec_buffer_pool (GstJpegDec * dec, GstCaps * caps) } config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_set (config, caps, size, min, max, prefix, - padding, alignment | 15); + gst_buffer_pool_config_set (config, caps, size, min, max, 0, 0, 15); /* and store */ gst_buffer_pool_set_config (pool, config); diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c index 623237e..7c569ed 100644 --- a/ext/libpng/gstpngdec.c +++ b/ext/libpng/gstpngdec.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include GST_DEBUG_CATEGORY_STATIC (pngdec_debug); @@ -337,46 +339,50 @@ static GstFlowReturn gst_pngdec_negotiate_pool (GstPngDec * dec, GstCaps * caps, GstVideoInfo * info) { GstQuery *query; - GstBufferPool *pool = NULL; - guint size, min, max, prefix, padding, alignment; + GstBufferPool *pool; + guint size, min, max; GstStructure *config; /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (caps, TRUE); - if (gst_pad_peer_query (dec->srcpad, query)) { - GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints"); + if (!gst_pad_peer_query (dec->srcpad, query)) { + GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); + } + + if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &padding, &alignment, &pool); + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); size = MAX (size, info->size); } else { - GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); + pool = NULL; size = info->size; min = max = 0; - prefix = 0; - padding = 0; - alignment = 0; } if (pool == NULL) { /* we did not get a pool, make one ourselves then */ - pool = gst_buffer_pool_new (); + pool = gst_video_buffer_pool_new (); } - if (dec->pool) + if (dec->pool) { + gst_buffer_pool_set_active (dec->pool, TRUE); gst_object_unref (dec->pool); + } dec->pool = pool; config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding, - alignment); - /* just set the option, if the pool can support it we will transparently use - * it through the video info API. We could also see if the pool support this - * option and only activate it then. */ - gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); + gst_buffer_pool_config_set (config, caps, size, min, max, 0, 0, 0); + if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) { + /* just set the option, if the pool can support it we will transparently use + * it through the video info API. We could also see if the pool support this + * 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); + /* and activate */ gst_buffer_pool_set_active (pool, TRUE); diff --git a/gst/goom/gstgoom.c b/gst/goom/gstgoom.c index 64c7135..20d2445 100644 --- a/gst/goom/gstgoom.c +++ b/gst/goom/gstgoom.c @@ -254,8 +254,9 @@ gst_goom_src_negotiate (GstGoom * goom) GstStructure *structure; GstCaps *templ; GstQuery *query; - GstBufferPool *pool = NULL; - guint size, min, max, prefix, padding, alignment; + GstBufferPool *pool; + GstStructure *config; + guint size, min, max; templ = gst_pad_get_pad_template_caps (goom->srcpad); @@ -288,32 +289,33 @@ gst_goom_src_negotiate (GstGoom * goom) /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (target, TRUE); - if (gst_pad_peer_query (goom->srcpad, query)) { + if (!gst_pad_peer_query (goom->srcpad, query)) { + /* no problem, we use the query defaults */ + GST_DEBUG_OBJECT (goom, "ALLOCATION query failed"); + } + + if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &padding, &alignment, &pool); + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); } else { + pool = NULL; size = goom->outsize; min = max = 0; - prefix = 0; - padding = 0; - alignment = 0; } if (pool == NULL) { - GstStructure *config; - /* we did not get a pool, make one ourselves then */ 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); } - if (goom->pool) + 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 (goom->pool) { + gst_buffer_pool_set_active (goom->pool, FALSE); gst_object_unref (goom->pool); + } goom->pool = pool; /* and activate */ diff --git a/gst/goom2k1/gstgoom.c b/gst/goom2k1/gstgoom.c index 228df9f..8917c95 100644 --- a/gst/goom2k1/gstgoom.c +++ b/gst/goom2k1/gstgoom.c @@ -252,7 +252,8 @@ gst_goom_src_negotiate (GstGoom * goom) GstCaps *templ; GstQuery *query; GstBufferPool *pool = NULL; - guint size, min, max, prefix, padding, alignment; + GstStructure *config; + guint size, min, max; templ = gst_pad_get_pad_template_caps (goom->srcpad); @@ -281,36 +282,36 @@ gst_goom_src_negotiate (GstGoom * goom) gst_goom_src_setcaps (goom, target); - /* try to get a bufferpool now */ /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (target, TRUE); - if (gst_pad_peer_query (goom->srcpad, query)) { + if (!gst_pad_peer_query (goom->srcpad, query)) { + /* no problem, we use the query defaults */ + GST_DEBUG_OBJECT (goom, "ALLOCATION query failed"); + } + + if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &padding, &alignment, &pool); + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); } else { + pool = NULL; size = goom->outsize; min = max = 0; - prefix = 0; - padding = 0; - alignment = 0; } if (pool == NULL) { - GstStructure *config; - /* we did not get a pool, make one ourselves then */ 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); } - if (goom->pool) + 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 (goom->pool) { + gst_buffer_pool_set_active (goom->pool, FALSE); gst_object_unref (goom->pool); + } goom->pool = pool; /* and activate */ diff --git a/gst/monoscope/gstmonoscope.c b/gst/monoscope/gstmonoscope.c index aaaa000..068a28e 100644 --- a/gst/monoscope/gstmonoscope.c +++ b/gst/monoscope/gstmonoscope.c @@ -226,8 +226,9 @@ gst_monoscope_src_negotiate (GstMonoscope * monoscope) GstStructure *structure; GstCaps *templ; GstQuery *query; - GstBufferPool *pool = NULL; - guint size, min, max, prefix, alignment; + GstBufferPool *pool; + GstStructure *config; + guint size, min, max; templ = gst_pad_get_pad_template_caps (monoscope->srcpad); @@ -260,31 +261,31 @@ gst_monoscope_src_negotiate (GstMonoscope * monoscope) /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (target, TRUE); - if (gst_pad_peer_query (monoscope->srcpad, query)) { + if (!gst_pad_peer_query (monoscope->srcpad, query)) { + } + + if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &alignment, &pool); + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); } else { + pool = NULL; size = monoscope->outsize; min = max = 0; - prefix = 0; - alignment = 0; } if (pool == NULL) { - GstStructure *config; - /* we did not get a pool, make one ourselves then */ pool = gst_buffer_pool_new (); - - config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_set (config, target, size, min, max, prefix, - alignment); - gst_buffer_pool_set_config (pool, config); } - if (monoscope->pool) + 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 (monoscope->pool) { + gst_buffer_pool_set_active (monoscope->pool, TRUE); gst_object_unref (monoscope->pool); + } monoscope->pool = pool; /* and activate */ diff --git a/gst/rtp/gstrtpvrawdepay.c b/gst/rtp/gstrtpvrawdepay.c index 941107b..c19ea4d 100644 --- a/gst/rtp/gstrtpvrawdepay.c +++ b/gst/rtp/gstrtpvrawdepay.c @@ -118,29 +118,29 @@ gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps, { GstQuery *query; GstBufferPool *pool = NULL; - guint size, min, max, prefix, padding, alignment; + guint size, min, max; GstStructure *config; /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (caps, TRUE); - if (gst_pad_peer_query (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depay), query)) { - GST_DEBUG_OBJECT (depay, "got downstream ALLOCATION hints"); + if (!gst_pad_peer_query (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depay), query)) { + /* not a problem, we use the defaults of query */ + GST_DEBUG_OBJECT (depay, "could not get downstream ALLOCATION hints"); + } + + if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &padding, &alignment, &pool); + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); } else { - GST_DEBUG_OBJECT (depay, "didn't get downstream ALLOCATION hints"); + GST_DEBUG_OBJECT (depay, "didn't get downstream pool hints"); size = info->size; min = max = 0; - prefix = 0; - padding = 0; - alignment = 0; } if (pool == NULL) { /* we did not get a pool, make one ourselves then */ - pool = gst_buffer_pool_new (); + pool = gst_video_buffer_pool_new (); } if (depay->pool) @@ -148,12 +148,14 @@ gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps, depay->pool = pool; config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding, - alignment); - /* just set the metadata, if the pool can support it we will transparently use - * it through the video info API. We could also see if the pool support this - * metadata and only activate it then. */ - gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); + gst_buffer_pool_config_set (config, caps, size, min, max, 0, 0, 0); + if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) { + /* just set the metadata, if the pool can support it we will transparently use + * it through the video info API. We could also see if the pool support this + * metadata 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); /* and activate */ diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c index b428dac..4df8729 100644 --- a/sys/v4l2/gstv4l2sink.c +++ b/sys/v4l2/gstv4l2sink.c @@ -651,7 +651,7 @@ gst_v4l2sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) } } /* we need at least 2 buffers to operate */ - 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 */ gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index 26a61c3..e8f30da 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -511,17 +511,24 @@ gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query) GstV4l2Src *src; GstV4l2Object *obj; GstBufferPool *pool; - guint size, min, max, prefix, padding, alignment; + guint size, min, max; + gboolean update; src = GST_V4L2SRC (bsrc); obj = src->v4l2object; - gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &padding, &alignment, &pool); + if (gst_query_get_n_allocation_pools (query) > 0) { + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); + update = TRUE; + } else { + pool = NULL; + min = max = 0; + size = 0; + update = FALSE; + } - GST_DEBUG_OBJECT (src, "allocation: size:%u min:%u max:%u prefix:%u " - "padding: %u align:%u pool:%" GST_PTR_FORMAT, size, min, max, - prefix, padding, alignment, pool); + GST_DEBUG_OBJECT (src, "allocation: size:%u min:%u max:%u pool:%" + GST_PTR_FORMAT, size, min, max, pool); if (min != 0) { /* if there is a min-buffers suggestion, use it. We add 1 because we need 1 @@ -571,8 +578,7 @@ gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query) config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL, NULL); - gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding, - alignment); + gst_buffer_pool_config_set (config, caps, size, min, max, 0, 0, 0); /* if downstream supports video metadata, add this to the pool config */ if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) @@ -582,8 +588,10 @@ gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query) gst_buffer_pool_set_config (pool, config); } - gst_query_set_allocation_params (query, size, min, max, prefix, padding, - alignment, pool); + if (update) + gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max); + else + gst_query_add_allocation_pool (query, pool, size, min, max); return TRUE; } -- 2.7.4