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.
This commit is contained in:
Wim Taymans 2012-07-18 16:20:41 +02:00
parent 5360ba56f7
commit 107007f053
2 changed files with 14 additions and 13 deletions

View file

@ -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;
}

View file

@ -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;
}