diff --git a/gst/autoplug/gstspideridentity.c b/gst/autoplug/gstspideridentity.c index 49bb4d81ed..15007e4028 100644 --- a/gst/autoplug/gstspideridentity.c +++ b/gst/autoplug/gstspideridentity.c @@ -448,9 +448,9 @@ static void gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident) { GstData *data; - GList *type_list = NULL; GstTypeFind gst_find; SpiderTypeFind find; + GList *walk, *type_list = NULL; g_return_if_fail (GST_IS_SPIDER_IDENTITY (ident)); @@ -468,21 +468,21 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident) } /* now do the actual typefinding with the supplied buffer */ - type_list = gst_type_find_factory_get_list (); + walk = type_list = gst_type_find_factory_get_list (); find.best_probability = 0; find.caps = NULL; gst_find.data = &find; gst_find.peek = spider_find_peek; gst_find.suggest = spider_find_suggest; - while (type_list) { - GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (type_list->data); + while (walk) { + GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data); GST_DEBUG ("trying typefind function %s", GST_PLUGIN_FEATURE_NAME (factory)); gst_type_find_factory_call_function (factory, &gst_find); if (find.best_probability >= GST_TYPE_FIND_MAXIMUM) goto plug; - type_list = g_list_next (type_list); + walk = g_list_next (walk); } if (find.best_probability > 0) goto plug; @@ -504,6 +504,8 @@ plug: g_assert (gst_pad_try_set_caps (ident->src, find.caps) > 0); gst_caps_debug (find.caps, "spider starting caps"); gst_caps_unref (find.caps); + if (type_list) + g_list_free (type_list); gst_spider_identity_plug (ident); diff --git a/gst/elements/gsttypefind.c b/gst/elements/gsttypefind.c index 4a5c2d9a97..a973f5aa86 100644 --- a/gst/elements/gsttypefind.c +++ b/gst/elements/gsttypefind.c @@ -472,6 +472,11 @@ compare_type_find_entry (gconstpointer a, gconstpointer b) return two->probability - one->probability; } } +static gint +compare_type_find_factory (gconstpointer fac1, gconstpointer fac2) +{ + return GST_PLUGIN_FEATURE (fac1)->rank - GST_PLUGIN_FEATURE (fac2)->rank; +} static void gst_type_find_element_chain (GstPad *pad, GstData *data) { @@ -495,10 +500,12 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) gst_data_unref (data); if (typefind->possibilities == NULL) { /* not yet started, get all typefinding functions into our "queue" */ - const GList *all_factories = gst_type_find_factory_get_list (); + GList *all_factories = gst_type_find_factory_get_list (); GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", g_list_length ((GList *) all_factories)); + all_factories = g_list_sort (all_factories, compare_type_find_factory); + walk = all_factories; while (all_factories) { entry = g_new0 (TypeFindEntry, 1); @@ -508,6 +515,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) typefind->possibilities = g_list_prepend (typefind->possibilities, entry); all_factories = g_list_next (all_factories); } + g_list_free (all_factories); } /* call every typefind function once */ walk = entries = typefind->possibilities; diff --git a/gst/elements/gsttypefindelement.c b/gst/elements/gsttypefindelement.c index 4a5c2d9a97..a973f5aa86 100644 --- a/gst/elements/gsttypefindelement.c +++ b/gst/elements/gsttypefindelement.c @@ -472,6 +472,11 @@ compare_type_find_entry (gconstpointer a, gconstpointer b) return two->probability - one->probability; } } +static gint +compare_type_find_factory (gconstpointer fac1, gconstpointer fac2) +{ + return GST_PLUGIN_FEATURE (fac1)->rank - GST_PLUGIN_FEATURE (fac2)->rank; +} static void gst_type_find_element_chain (GstPad *pad, GstData *data) { @@ -495,10 +500,12 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) gst_data_unref (data); if (typefind->possibilities == NULL) { /* not yet started, get all typefinding functions into our "queue" */ - const GList *all_factories = gst_type_find_factory_get_list (); + GList *all_factories = gst_type_find_factory_get_list (); GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", g_list_length ((GList *) all_factories)); + all_factories = g_list_sort (all_factories, compare_type_find_factory); + walk = all_factories; while (all_factories) { entry = g_new0 (TypeFindEntry, 1); @@ -508,6 +515,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) typefind->possibilities = g_list_prepend (typefind->possibilities, entry); all_factories = g_list_next (all_factories); } + g_list_free (all_factories); } /* call every typefind function once */ walk = entries = typefind->possibilities; diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index 6c16a2154c..2e2cb31132 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -252,7 +252,7 @@ gst_type_find_factory_register (GstPlugin *plugin, const gchar *name, guint rank /*** typefind function interface **********************************************/ -/* +/** * gst_type_find_peek: * @find: the find object the function was called with * @offset: the offset @@ -274,7 +274,7 @@ gst_type_find_peek (GstTypeFind *find, gint64 offset, guint size) return find->peek (find->data, offset, size); } -/* +/** * gst_type_find_suggest: * @find: the find object the function was called with * @probability: the probability in percent that the suggestion is right diff --git a/gst/gsttypefind.h b/gst/gsttypefind.h index 19a93171d5..6e18ee4b80 100644 --- a/gst/gsttypefind.h +++ b/gst/gsttypefind.h @@ -67,6 +67,7 @@ struct _GstTypeFind { /* optional */ guint64 (* get_length) (gpointer data); + /* */ GST_STRUCT_PADDING }; diff --git a/plugins/elements/gsttypefind.c b/plugins/elements/gsttypefind.c index 4a5c2d9a97..a973f5aa86 100644 --- a/plugins/elements/gsttypefind.c +++ b/plugins/elements/gsttypefind.c @@ -472,6 +472,11 @@ compare_type_find_entry (gconstpointer a, gconstpointer b) return two->probability - one->probability; } } +static gint +compare_type_find_factory (gconstpointer fac1, gconstpointer fac2) +{ + return GST_PLUGIN_FEATURE (fac1)->rank - GST_PLUGIN_FEATURE (fac2)->rank; +} static void gst_type_find_element_chain (GstPad *pad, GstData *data) { @@ -495,10 +500,12 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) gst_data_unref (data); if (typefind->possibilities == NULL) { /* not yet started, get all typefinding functions into our "queue" */ - const GList *all_factories = gst_type_find_factory_get_list (); + GList *all_factories = gst_type_find_factory_get_list (); GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", g_list_length ((GList *) all_factories)); + all_factories = g_list_sort (all_factories, compare_type_find_factory); + walk = all_factories; while (all_factories) { entry = g_new0 (TypeFindEntry, 1); @@ -508,6 +515,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) typefind->possibilities = g_list_prepend (typefind->possibilities, entry); all_factories = g_list_next (all_factories); } + g_list_free (all_factories); } /* call every typefind function once */ walk = entries = typefind->possibilities; diff --git a/plugins/elements/gsttypefindelement.c b/plugins/elements/gsttypefindelement.c index 4a5c2d9a97..a973f5aa86 100644 --- a/plugins/elements/gsttypefindelement.c +++ b/plugins/elements/gsttypefindelement.c @@ -472,6 +472,11 @@ compare_type_find_entry (gconstpointer a, gconstpointer b) return two->probability - one->probability; } } +static gint +compare_type_find_factory (gconstpointer fac1, gconstpointer fac2) +{ + return GST_PLUGIN_FEATURE (fac1)->rank - GST_PLUGIN_FEATURE (fac2)->rank; +} static void gst_type_find_element_chain (GstPad *pad, GstData *data) { @@ -495,10 +500,12 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) gst_data_unref (data); if (typefind->possibilities == NULL) { /* not yet started, get all typefinding functions into our "queue" */ - const GList *all_factories = gst_type_find_factory_get_list (); + GList *all_factories = gst_type_find_factory_get_list (); GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", g_list_length ((GList *) all_factories)); + all_factories = g_list_sort (all_factories, compare_type_find_factory); + walk = all_factories; while (all_factories) { entry = g_new0 (TypeFindEntry, 1); @@ -508,6 +515,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) typefind->possibilities = g_list_prepend (typefind->possibilities, entry); all_factories = g_list_next (all_factories); } + g_list_free (all_factories); } /* call every typefind function once */ walk = entries = typefind->possibilities;