From cfe484d983a46d8a14c1ea0c32d0c937218f15c1 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Wed, 10 May 2023 12:38:11 +0200 Subject: [PATCH] switchbin: Always respond to caps query with all allowed caps The caps query specifies _all_ caps that the element can handle, not just caps from the current path element. If for example a switchbin has two paths, with one having an element that handles video/x-h264, and another path whose element handles video/x-raw, and the second path is the current path, then the existing code would report only video/x-raw as supported. Fix this by report all allowed caps, even if there is a current path defined. Part-of: --- .../gst/switchbin/gstswitchbin.c | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/switchbin/gstswitchbin.c b/subprojects/gst-plugins-bad/gst/switchbin/gstswitchbin.c index 91bca4a739..9ab4effe75 100644 --- a/subprojects/gst-plugins-bad/gst/switchbin/gstswitchbin.c +++ b/subprojects/gst-plugins-bad/gst/switchbin/gstswitchbin.c @@ -512,38 +512,21 @@ gst_switch_bin_handle_query (GstPad * pad, GstObject * parent, GstQuery * query, gst_query_parse_caps (query, &filter); + GST_DEBUG_OBJECT (switch_bin, "new caps query; filter: %" GST_PTR_FORMAT, + filter); + PATH_LOCK (switch_bin); if (switch_bin->num_paths == 0) { - /* No paths exist - cannot return any caps */ + GST_DEBUG_OBJECT (switch_bin, "no paths exist; " + "cannot return any caps to query"); caps = NULL; - } else if ((switch_bin->current_path == NULL) - || (switch_bin->current_path->element == NULL)) { - /* Paths exist, but there is no current path (or the path currently - * does not have an element) - just return all allowed caps */ + } else { + GST_DEBUG_OBJECT (switch_bin, "returning all allowed caps to query"); caps = gst_switch_bin_get_allowed_caps (switch_bin, pad, pad_name, filter); - } else { - /* Paths exist and there is a current path - * Forward the query to its element */ - - GstQuery *caps_query = gst_query_new_caps (NULL); - GstPad *element_pad = - gst_element_get_static_pad (switch_bin->current_path->element, - pad_name); - - caps = NULL; - if (gst_pad_query (element_pad, caps_query)) { - GstCaps *query_caps; - gst_query_parse_caps_result (caps_query, &query_caps); - caps = gst_caps_copy (query_caps); - } - - gst_query_unref (caps_query); - gst_object_unref (GST_OBJECT (element_pad)); } - PATH_UNLOCK (switch_bin); if (caps != NULL) {