From 21bc8ddcb769852060519dc50f75ec15c866ba35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 8 Sep 2011 14:42:13 +0200 Subject: [PATCH] Revert "Revert "decodebin2: Do a subset check before actually using a factory"" This reverts commit 5f5d832a3bcff0828758f164fcb13c4258aefb36. --- gst/playback/gstdecodebin2.c | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 9a877bb9be..1563bedef9 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -1741,6 +1741,46 @@ 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) + 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