parsebin: fix critical when sorting pads

If the pad does not have a current caps, get_pad() returns the query
caps which can be ANY. In such case the caps does not have any structure
resulting in a critical warning when calling gst_caps_get_structure().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1254>
This commit is contained in:
Guillaume Desmottes 2021-10-26 15:12:16 +02:00 committed by GStreamer Marge Bot
parent e6f39394f5
commit 1d833eba60

View file

@ -3336,15 +3336,31 @@ static gint
sort_end_pads (GstParsePad * da, GstParsePad * db)
{
gint va, vb;
GstCaps *capsa, *capsb;
GstStructure *sa, *sb;
const gchar *namea, *nameb;
gchar *ida, *idb;
gint ret;
GstCaps *capsa, *capsb;
capsa = get_pad_caps (GST_PAD_CAST (da));
capsb = get_pad_caps (GST_PAD_CAST (db));
if (gst_caps_get_size (capsa) == 0 || gst_caps_get_size (capsb) == 0) {
if (gst_caps_is_any (capsa))
va = 6;
if (gst_caps_is_empty (capsa))
va = 7;
else
va = 0;
if (gst_caps_is_any (capsb))
vb = 6;
if (gst_caps_is_empty (capsb))
vb = 7;
else
vb = 0;
} else {
GstStructure *sa, *sb;
sa = gst_caps_get_structure ((const GstCaps *) capsa, 0);
sb = gst_caps_get_structure ((const GstCaps *) capsb, 0);
@ -3376,6 +3392,7 @@ sort_end_pads (GstParsePad * da, GstParsePad * db)
vb = 4;
else
vb = 5;
}
gst_caps_unref (capsa);
gst_caps_unref (capsb);