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);
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,
"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;
}
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);
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;
}