mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
utils: fix proxy_getcaps
Make it return the padtemplate caps on errors and no parent. Only intersect pads of the oposite direction of the source pad.
This commit is contained in:
parent
6bff920ba0
commit
c6f2a94777
1 changed files with 29 additions and 18 deletions
|
@ -2631,22 +2631,18 @@ static gboolean
|
||||||
getcaps_fold_func (GstPad * pad, GValue * ret, GstPad * orig)
|
getcaps_fold_func (GstPad * pad, GValue * ret, GstPad * orig)
|
||||||
{
|
{
|
||||||
gboolean empty = FALSE;
|
gboolean empty = FALSE;
|
||||||
|
GstCaps *peercaps, *existing;
|
||||||
|
|
||||||
/* skip the pad, the request came from */
|
existing = g_value_get_pointer (ret);
|
||||||
if (G_UNLIKELY (pad != orig)) {
|
peercaps = gst_pad_peer_get_caps_reffed (pad);
|
||||||
GstCaps *peercaps, *existing;
|
if (G_LIKELY (peercaps)) {
|
||||||
|
GstCaps *intersection = gst_caps_intersect (existing, peercaps);
|
||||||
|
|
||||||
existing = g_value_get_pointer (ret);
|
empty = gst_caps_is_empty (intersection);
|
||||||
peercaps = gst_pad_peer_get_caps_reffed (pad);
|
|
||||||
if (G_LIKELY (peercaps)) {
|
|
||||||
GstCaps *intersection = gst_caps_intersect (existing, peercaps);
|
|
||||||
|
|
||||||
empty = gst_caps_is_empty (intersection);
|
g_value_set_pointer (ret, intersection);
|
||||||
|
gst_caps_unref (existing);
|
||||||
g_value_set_pointer (ret, intersection);
|
gst_caps_unref (peercaps);
|
||||||
gst_caps_unref (existing);
|
|
||||||
gst_caps_unref (peercaps);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
return !empty;
|
return !empty;
|
||||||
|
@ -2681,14 +2677,19 @@ gst_pad_proxy_getcaps (GstPad * pad)
|
||||||
|
|
||||||
element = gst_pad_get_parent_element (pad);
|
element = gst_pad_get_parent_element (pad);
|
||||||
if (element == NULL)
|
if (element == NULL)
|
||||||
return NULL;
|
goto no_parent;
|
||||||
|
|
||||||
/* value to hold the return, by default it holds ANY, the ref is taken by
|
/* value to hold the return, by default it holds ANY, the ref is taken by
|
||||||
* the GValue. */
|
* the GValue. */
|
||||||
g_value_init (&ret, G_TYPE_POINTER);
|
g_value_init (&ret, G_TYPE_POINTER);
|
||||||
g_value_set_pointer (&ret, gst_caps_new_any ());
|
g_value_set_pointer (&ret, gst_caps_new_any ());
|
||||||
|
|
||||||
iter = gst_element_iterate_pads (element);
|
/* only iterate the pads in the oposite direction */
|
||||||
|
if (GST_PAD_IS_SRC (pad))
|
||||||
|
iter = gst_element_iterate_sink_pads (element);
|
||||||
|
else
|
||||||
|
iter = gst_element_iterate_src_pads (element);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
res =
|
res =
|
||||||
gst_iterator_fold (iter, (GstIteratorFoldFunction) getcaps_fold_func,
|
gst_iterator_fold (iter, (GstIteratorFoldFunction) getcaps_fold_func,
|
||||||
|
@ -2722,19 +2723,29 @@ done:
|
||||||
caps = g_value_get_pointer (&ret);
|
caps = g_value_get_pointer (&ret);
|
||||||
g_value_unset (&ret);
|
g_value_unset (&ret);
|
||||||
|
|
||||||
intersected = gst_caps_intersect (caps, gst_pad_get_pad_template_caps (pad));
|
if (caps) {
|
||||||
gst_caps_unref (caps);
|
intersected =
|
||||||
|
gst_caps_intersect (caps, gst_pad_get_pad_template_caps (pad));
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
} else {
|
||||||
|
intersected = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||||
|
}
|
||||||
|
|
||||||
return intersected;
|
return intersected;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
no_parent:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (pad, "no parent");
|
||||||
|
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||||
|
}
|
||||||
error:
|
error:
|
||||||
{
|
{
|
||||||
g_warning ("Pad list returned error on element %s",
|
g_warning ("Pad list returned error on element %s",
|
||||||
GST_ELEMENT_NAME (element));
|
GST_ELEMENT_NAME (element));
|
||||||
gst_iterator_free (iter);
|
gst_iterator_free (iter);
|
||||||
gst_object_unref (element);
|
gst_object_unref (element);
|
||||||
return NULL;
|
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue