discoverer: Handle NULL/ANY/EMPTY caps without crashing

This commit is contained in:
Sebastian Dröge 2016-11-28 19:45:46 +02:00
parent 647b183adb
commit 7e24acc67f

View file

@ -817,6 +817,14 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
} }
gst_structure_id_get (st, _CAPS_QUARK, GST_TYPE_CAPS, &caps, NULL); gst_structure_id_get (st, _CAPS_QUARK, GST_TYPE_CAPS, &caps, NULL);
if (!caps || gst_caps_is_empty (caps) || gst_caps_is_any (caps)) {
GST_WARNING ("Couldn't find caps !");
if (caps)
gst_caps_unref (caps);
return make_info (parent, GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
}
caps_st = gst_caps_get_structure (caps, 0); caps_st = gst_caps_get_structure (caps, 0);
name = gst_structure_get_name (caps_st); name = gst_structure_get_name (caps_st);
@ -1034,10 +1042,20 @@ find_stream_for_node (GstDiscoverer * dc, const GstStructure * topology)
static gboolean static gboolean
child_is_same_stream (const GstCaps * _parent, const GstCaps * child) child_is_same_stream (const GstCaps * _parent, const GstCaps * child)
{ {
GstCaps *parent = gst_caps_copy (_parent); GstCaps *parent;
guint i, size = gst_caps_get_size (parent); guint i, size;
gboolean res; gboolean res;
if (_parent == child)
return TRUE;
if (!_parent)
return FALSE;
if (!child)
return FALSE;
parent = gst_caps_copy (_parent);
size = gst_caps_get_size (parent);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
gst_structure_remove_field (gst_caps_get_structure (parent, i), "parsed"); gst_structure_remove_field (gst_caps_get_structure (parent, i), "parsed");
gst_structure_remove_field (gst_caps_get_structure (parent, i), "framed"); gst_structure_remove_field (gst_caps_get_structure (parent, i), "framed");
@ -1054,6 +1072,13 @@ child_is_raw_stream (const GstCaps * parent, const GstCaps * child)
const GstStructure *st1, *st2; const GstStructure *st1, *st2;
const gchar *name1, *name2; const gchar *name1, *name2;
if (parent == child)
return TRUE;
if (!parent)
return FALSE;
if (!child)
return FALSE;
st1 = gst_caps_get_structure (parent, 0); st1 = gst_caps_get_structure (parent, 0);
name1 = gst_structure_get_name (st1); name1 = gst_structure_get_name (st1);
st2 = gst_caps_get_structure (child, 0); st2 = gst_caps_get_structure (child, 0);
@ -1131,6 +1156,7 @@ parse_stream_topology (GstDiscoverer * dc, const GstStructure * topology,
res->next = next; res->next = next;
next->previous = res; next->previous = res;
} }
if (caps)
gst_caps_unref (caps); gst_caps_unref (caps);
} }
} }