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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4632>
This commit is contained in:
Carlos Rafael Giani 2023-05-10 12:38:11 +02:00 committed by Tim-Philipp Müller
parent c994f27f34
commit cfe484d983

View file

@ -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) {