From: Sebastian Dröge Date: Tue, 6 Sep 2011 12:16:10 +0000 (+0200) Subject: decodebin2: Do a subset check before actually using a factory X-Git-Tag: 1.19.3~511^2~6555^2~519 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50a88396ae6d54a83a10e7d2efd551d39033148e;p=platform%2Fupstream%2Fgstreamer.git decodebin2: Do a subset check before actually using a factory This prevents autoplugging if the caps have a non-empty intersection but are not accepted by the next element's pad. --- diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index cf9541c..2312230 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -1766,6 +1766,48 @@ connect_pad (GstDecodeBin * dbin, GstElement * src, GstDecodePad * dpad, /* Remove selected factory from the list. */ g_value_array_remove (factories, 0); + /* Check if the caps are really supported by the factory. The + * factory list is non-empty-subset filtered while caps + * are only accepted by a pad if they are a subset of the + * pad caps. + * + * FIXME: Only do this for fixed caps here. Non-fixed caps + * can happen if a Parser/Converter was autoplugged before + * this. We then assume that it will be able to convert to + * everything that the decoder would want. + * + * A subset check will fail here because the parser caps + * will be generic and while the decoder will only + * support a subset of the parser caps. + */ + if (gst_caps_is_fixed (caps)) { + const GList *templs; + gboolean skip = FALSE; + + templs = gst_element_factory_get_static_pad_templates (factory); + + while (templs) { + GstStaticPadTemplate *templ = (GstStaticPadTemplate *) templs->data; + + if (templ->direction == GST_PAD_SINK) { + GstCaps *templcaps = gst_static_caps_get (&templ->static_caps); + + if (!gst_caps_is_subset (caps, templcaps)) { + gst_caps_unref (templcaps); + skip = TRUE; + break; + } + + gst_caps_unref (templcaps); + } + templs = g_list_next (templs); + } + if (skip) { + gst_object_unref (factory); + continue; + } + } + /* If the factory is for a parser we first check if the factory * was already used for the current chain. If it was used already * we would otherwise create an infinite loop here because the