From 107007f05339f8eee0cebbcf892ef8c5327647e5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 18 Jul 2012 16:20:41 +0200 Subject: [PATCH] pad: improve query caps function In the proxy_query_caps function, also filter against the filter in the query. We don't need to filter against the filter in the query anymore in the default caps query function because we already did this in the proxy_query_caps. --- gst/gstpad.c | 13 ++++++------- gst/gstutils.c | 14 ++++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gst/gstpad.c b/gst/gstpad.c index 03d6b67..3d3fcf4 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2775,18 +2775,18 @@ gst_pad_query_caps_default (GstPad * pad, GstQuery * query) GstPadTemplate *templ; gboolean fixed_caps; - GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps"); - - gst_query_parse_caps (query, &filter); + GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "query caps %" GST_PTR_FORMAT, + query); /* first try to proxy if we must */ if (GST_PAD_IS_PROXY_CAPS (pad)) { if ((gst_pad_proxy_query_caps (pad, query))) { - gst_query_parse_caps_result (query, &result); - goto filter_done; + goto done; } } + gst_query_parse_caps (query, &filter); + /* no proxy or it failed, do default handling */ fixed_caps = GST_PAD_IS_FIXED_CAPS (pad); @@ -2819,7 +2819,6 @@ gst_pad_query_caps_default (GstPad * pad, GstQuery * query) filter_done_unlock: GST_OBJECT_UNLOCK (pad); -filter_done: /* run the filter on the result */ if (filter) { GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, @@ -2833,10 +2832,10 @@ filter_done: "using caps %p %" GST_PTR_FORMAT, result, result); result = gst_caps_ref (result); } - gst_query_set_caps_result (query, result); gst_caps_unref (result); +done: return TRUE; } diff --git a/gst/gstutils.c b/gst/gstutils.c index 6811f2f..6bf9d24 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -2498,7 +2498,7 @@ query_caps_func (GstPad * pad, QueryCapsData * data) gboolean gst_pad_proxy_query_caps (GstPad * pad, GstQuery * query) { - GstCaps *templ, *intersected; + GstCaps *filter, *templ, *result; QueryCapsData data; g_return_val_if_fail (GST_IS_PAD (pad), FALSE); @@ -2509,18 +2509,20 @@ gst_pad_proxy_query_caps (GstPad * pad, GstQuery * query) GST_DEBUG_PAD_NAME (pad)); data.query = query; - /* value to hold the return, by default it holds ANY */ - data.ret = gst_caps_new_any (); + + /* value to hold the return, by default it holds the filter or ANY */ + gst_query_parse_caps (query, &filter); + data.ret = filter ? gst_caps_ref (filter) : gst_caps_new_any (); gst_pad_forward (pad, (GstPadForwardFunction) query_caps_func, &data); templ = gst_pad_get_pad_template_caps (pad); - intersected = gst_caps_intersect (data.ret, templ); + result = gst_caps_intersect (data.ret, templ); gst_caps_unref (data.ret); gst_caps_unref (templ); - gst_query_set_caps_result (query, intersected); - gst_caps_unref (intersected); + gst_query_set_caps_result (query, result); + gst_caps_unref (result); return TRUE; } -- 2.7.4