rtsp-media-factory-uri: don't autoplug parsers in a loop

Stop autoplugging parsers if caps have parsed=true set. Fixes autoplugging
h264parse forever.
This commit is contained in:
Alessandro Decina 2012-10-12 06:07:07 +02:00
parent 8da18a85ef
commit 3a49b8e783

View file

@ -291,17 +291,49 @@ find_payloader (GstRTSPMediaFactoryURI * urifact, GstCaps * caps)
{
GList *list;
GstElementFactory *factory = NULL;
gboolean autoplug_more = FALSE;
/* first find a demuxer that can link */
list = gst_element_factory_list_filter (urifact->demuxers, caps,
GST_PAD_SINK, FALSE);
if (list != NULL) {
/* we have a demuxer, try that one first */
if (list) {
GstStructure *structure = gst_caps_get_structure (caps, 0);
gboolean parsed = FALSE;
gst_structure_get_boolean (structure, "parsed", &parsed);
/* Avoid plugging parsers in a loop. This is not 100% correct, as some
* parsers don't set parsed=true in caps. We should do something like
* decodebin does and track decode chains and elements plugged in those
* chains...
*/
if (parsed) {
GList *walk;
const gchar *klass;
for (walk = list; walk; walk = walk->next) {
factory = GST_ELEMENT_FACTORY (walk->data);
klass = gst_element_factory_get_klass (factory);
if (strstr (klass, "Parser"))
/* caps have parsed=true, so skip this parser to avoid loops */
continue;
autoplug_more = TRUE;
break;
}
} else {
/* caps don't have parsed=true set and we have a demuxer/parser */
autoplug_more = TRUE;
}
gst_plugin_feature_list_free (list);
return NULL;
}
if (autoplug_more)
/* we have a demuxer, try that one first */
return NULL;
/* no demuxer try a depayloader */
list = gst_element_factory_list_filter (urifact->payloaders, caps,
GST_PAD_SINK, FALSE);