From 3303fc4fb5c80b36fb787da60e280b775a3250d9 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 14 Jan 2016 17:35:28 -0300 Subject: basetransform: add recursive-accept-caps handler The handler will do an accept-caps to check if the caps is accepted by the element and, if successful, create new query with the output caps and send it to its peer. --- libs/gst/base/gstbasetransform.c | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 4155a51a6..a9122270e 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -1590,6 +1590,56 @@ gst_base_transform_default_query (GstBaseTransform * trans, } break; } + case GST_QUERY_RECURSIVE_ACCEPT_CAPS: + { + GstCaps *caps; + GstQuery *accept_caps_query; + gboolean accept_caps_result; + + gst_query_parse_recursive_accept_caps (query, &caps); + + /* check if we accept it */ + accept_caps_query = gst_query_new_accept_caps (gst_caps_ref (caps)); + if (!gst_pad_query (pad, query)) { + GST_DEBUG_OBJECT (pad, "Accept-caps query got no answer, can't " + "proceed with recursive-accept-caps"); + break; + } + + gst_query_parse_accept_caps_result (accept_caps_query, + &accept_caps_result); + gst_query_unref (accept_caps_query); + if (accept_caps_result) { + GstCaps *othercaps; + GstQuery *peer_query; + gboolean peer_query_result; + + /* convert our caps to the output caps and proceed with the query */ + othercaps = gst_base_transform_find_transform (trans, pad, caps); + if (!othercaps || gst_caps_is_empty (othercaps)) { + GST_DEBUG_OBJECT (pad, "Could not generate othercaps from caps %" + GST_PTR_FORMAT, caps); + gst_query_set_recursive_accept_caps_result (query, FALSE); + gst_caps_unref (othercaps); + ret = TRUE; + } else { + peer_query = gst_query_new_recursive_accept_caps (othercaps); + if (gst_pad_peer_query (otherpad, peer_query)) { + ret = TRUE; + gst_query_parse_recursive_accept_caps_result (peer_query, + &peer_query_result); + gst_query_set_recursive_accept_caps_result (query, + peer_query_result); + } + gst_query_unref (peer_query); + } + + } else { + ret = TRUE; + gst_query_set_recursive_accept_caps_result (query, FALSE); + } + break; + } case GST_QUERY_CAPS: { GstCaps *filter, *caps; -- cgit v1.2.3