From 7ca05917591b3477a7d68a1e5adc308737b9e3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 18 Feb 2015 13:36:16 +0200 Subject: [PATCH] vaapidecode: intersect filter from query caps According to documentation[1] when receiving a GST_QUERY_CAPS the return value should be all formats that this elements supports, taking into account limitations of peer elements further downstream or upstream, sorted by order of preference, highest preference first. This patch add those limitations intersecting with the received filter in the query. Also takes into account the already negotiated caps. Also adds the processing of the query on the SRC pad. 1. http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-nego-getcaps.html https://bugzilla.gnome.org/show_bug.cgi?id=744406 --- gst/vaapi/gstvaapidecode.c | 56 +++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 1513e33483..e48fdba86e 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -990,7 +990,24 @@ gst_vaapidecode_query(GST_PAD_QUERY_FUNCTION_ARGS) switch (GST_QUERY_TYPE(query)) { #if GST_CHECK_VERSION(1,0,0) case GST_QUERY_CAPS: { - GstCaps * const caps = gst_vaapidecode_get_caps(pad); + GstCaps *filter, *caps = NULL; + + gst_query_parse_caps(query, &filter); + if (!decode->sinkpad_caps) + caps = gst_vaapidecode_get_caps(pad); + else + caps = gst_caps_ref(decode->sinkpad_caps); + + if (filter) { + GstCaps *tmp = caps; + caps = gst_caps_intersect_full(filter, tmp, + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref(tmp); + } + + GST_DEBUG_OBJECT(decode, "Returning sink caps %" GST_PTR_FORMAT, + caps); + gst_query_set_caps_result(query, caps); gst_caps_unref(caps); res = TRUE; @@ -1003,9 +1020,40 @@ gst_vaapidecode_query(GST_PAD_QUERY_FUNCTION_ARGS) break; } } - else - res = GST_PAD_QUERY_FUNCTION_CALL(plugin->srcpad_query, pad, - parent, query); + else { + switch (GST_QUERY_TYPE(query)) { +#if GST_CHECK_VERSION(1,0,0) + case GST_QUERY_CAPS: { + GstCaps *filter, *caps = NULL; + + gst_query_parse_caps(query, &filter); + if (!decode->srcpad_caps) + caps = gst_pad_get_pad_template_caps(pad); + else + caps = gst_caps_ref(decode->srcpad_caps); + + if (filter) { + GstCaps *tmp = caps; + caps = gst_caps_intersect_full(filter, tmp, + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref(tmp); + } + + GST_DEBUG_OBJECT(decode, "Returning src caps %" GST_PTR_FORMAT, + caps); + + gst_query_set_caps_result(query, caps); + gst_caps_unref(caps); + res = TRUE; + break; + } +#endif + default: + res = GST_PAD_QUERY_FUNCTION_CALL(plugin->srcpad_query, pad, + parent, query); + break; + } + } gst_object_unref(decode); return res;