From b5bcd7301565bbe144c61c4da0b6beb17c088ca2 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Mon, 7 Oct 2013 22:52:27 +0200 Subject: [PATCH] discoverer: filter 'parsed' field when checking for same caps We're checking the caps to see if we got more caps details after a parser got plugged. This will also have a flipped 'parsed' field. If the field was already present before the parse the match will fail. Add a function that will do the check while excluding this field. --- gst-libs/gst/pbutils/gstdiscoverer.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/pbutils/gstdiscoverer.c b/gst-libs/gst/pbutils/gstdiscoverer.c index 90c318406a..ff7d9cd7e6 100644 --- a/gst-libs/gst/pbutils/gstdiscoverer.c +++ b/gst-libs/gst/pbutils/gstdiscoverer.c @@ -997,6 +997,24 @@ find_stream_for_node (GstDiscoverer * dc, const GstStructure * topology) return st; } +/* this can fail due to parsed=TRUE/FALSE differences, thus we filter the + * parent */ +static gboolean +child_is_same_stream (const GstCaps * _parent, const GstCaps * child) +{ + GstCaps *parent = gst_caps_copy (_parent); + guint i, size = gst_caps_get_size (parent); + gboolean res; + + for (i = 0; i < size; i++) { + gst_structure_remove_field (gst_caps_get_structure (parent, i), "parsed"); + } + res = gst_caps_can_intersect (parent, child); + gst_caps_unref (parent); + return res; +} + + static gboolean child_is_raw_stream (const GstCaps * parent, const GstCaps * child) { @@ -1062,7 +1080,7 @@ parse_stream_topology (GstDiscoverer * dc, const GstStructure * topology, parent = res; if (gst_structure_id_get (st, _CAPS_QUARK, GST_TYPE_CAPS, &caps, NULL)) { - if (gst_caps_can_intersect (parent->caps, caps)) { + if (child_is_same_stream (parent->caps, caps)) { /* We sometimes get an extra sub-stream from the parser. If this is * the case, we just replace the parent caps with this stream's caps * since they might contain more information */