From 0cc3f199cac0f9b1803fffe8660aea299e7585ff Mon Sep 17 00:00:00 2001 From: Wonchul Lee Date: Thu, 1 Sep 2016 14:47:02 +0900 Subject: [PATCH] playbackutils: Move compare_factories_func Move _decode_bin_compare_factories_func function to playbackutils https://bugzilla.gnome.org/show_bug.cgi?id=770692 --- gst/playback/gstdecodebin2.c | 34 +++------------------------------ gst/playback/gstplaybackutils.c | 27 ++++++++++++++++++++++++++ gst/playback/gstplaybackutils.h | 2 ++ gst/playback/gsturidecodebin.c | 6 ++---- gst/playback/gsturisourcebin.c | 6 ++---- 5 files changed, 36 insertions(+), 39 deletions(-) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 89ed6a9f8e..d6872ad397 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -100,9 +100,7 @@ #include "gstplay-enum.h" #include "gstplayback.h" #include "gstrawcaps.h" - -/* Also used by gsturidecodebin.c */ -gint _decode_bin_compare_factories_func (gconstpointer p1, gconstpointer p2); +#include "gstplaybackutils.h" /* generic templates */ static GstStaticPadTemplate decoder_bin_sink_template = @@ -1023,33 +1021,6 @@ gst_decode_bin_class_init (GstDecodeBinClass * klass) g_type_class_ref (GST_TYPE_DECODE_PAD); } -gint -_decode_bin_compare_factories_func (gconstpointer p1, gconstpointer p2) -{ - GstPluginFeature *f1, *f2; - gboolean is_parser1, is_parser2; - - f1 = (GstPluginFeature *) p1; - f2 = (GstPluginFeature *) p2; - - is_parser1 = gst_element_factory_list_is_type (GST_ELEMENT_FACTORY_CAST (f1), - GST_ELEMENT_FACTORY_TYPE_PARSER); - is_parser2 = gst_element_factory_list_is_type (GST_ELEMENT_FACTORY_CAST (f2), - GST_ELEMENT_FACTORY_TYPE_PARSER); - - - /* We want all parsers first as we always want to plug parsers - * before decoders */ - if (is_parser1 && !is_parser2) - return -1; - else if (!is_parser1 && is_parser2) - return 1; - - /* And if it's a both a parser we first sort by rank - * and then by factory name */ - return gst_plugin_feature_rank_compare_func (p1, p2); -} - /* Must be called with factories lock! */ static void gst_decode_bin_update_factories_list (GstDecodeBin * dbin) @@ -1064,7 +1035,8 @@ gst_decode_bin_update_factories_list (GstDecodeBin * dbin) gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_DECODABLE, GST_RANK_MARGINAL); dbin->factories = - g_list_sort (dbin->factories, _decode_bin_compare_factories_func); + g_list_sort (dbin->factories, + gst_playback_utils_compare_factories_func); dbin->factories_cookie = cookie; } } diff --git a/gst/playback/gstplaybackutils.c b/gst/playback/gstplaybackutils.c index d003c9195d..ef98528e0a 100644 --- a/gst/playback/gstplaybackutils.c +++ b/gst/playback/gstplaybackutils.c @@ -131,3 +131,30 @@ gst_playback_utils_get_n_common_capsfeatures (GstElementFactory * fact1, return n_common_cf; } + +gint +gst_playback_utils_compare_factories_func (gconstpointer p1, gconstpointer p2) +{ + GstPluginFeature *f1, *f2; + gboolean is_parser1, is_parser2; + + f1 = (GstPluginFeature *) p1; + f2 = (GstPluginFeature *) p2; + + is_parser1 = gst_element_factory_list_is_type (GST_ELEMENT_FACTORY_CAST (f1), + GST_ELEMENT_FACTORY_TYPE_PARSER); + is_parser2 = gst_element_factory_list_is_type (GST_ELEMENT_FACTORY_CAST (f2), + GST_ELEMENT_FACTORY_TYPE_PARSER); + + + /* We want all parsers first as we always want to plug parsers + * before decoders */ + if (is_parser1 && !is_parser2) + return -1; + else if (!is_parser1 && is_parser2) + return 1; + + /* And if it's a both a parser we first sort by rank + * and then by factory name */ + return gst_plugin_feature_rank_compare_func (p1, p2); +} diff --git a/gst/playback/gstplaybackutils.h b/gst/playback/gstplaybackutils.h index c9f895eb62..10c3a8ab36 100644 --- a/gst/playback/gstplaybackutils.h +++ b/gst/playback/gstplaybackutils.h @@ -32,6 +32,8 @@ gst_playback_utils_get_n_common_capsfeatures (GstElementFactory * fact1, GstElementFactory * fact2, GstPlayFlags flags, gboolean isaudioelement); +gint +gst_playback_utils_compare_factories_func (gconstpointer p1, gconstpointer p2); G_END_DECLS #endif /* __GST_PLAYBACK_UTILS_H__ */ diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index 0d06776a01..83355ea686 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -41,9 +41,7 @@ #include "gstplay-enum.h" #include "gstrawcaps.h" #include "gstplayback.h" - -/* From gstdecodebin2.c */ -gint _decode_bin_compare_factories_func (gconstpointer p1, gconstpointer p2); +#include "gstplaybackutils.h" #define GST_TYPE_URI_DECODE_BIN \ (gst_uri_decode_bin_get_type()) @@ -321,7 +319,7 @@ gst_uri_decode_bin_update_factories_list (GstURIDecodeBin * dec) gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_DECODABLE, GST_RANK_MARGINAL); dec->factories = - g_list_sort (dec->factories, _decode_bin_compare_factories_func); + g_list_sort (dec->factories, gst_playback_utils_compare_factories_func); dec->factories_cookie = cookie; } } diff --git a/gst/playback/gsturisourcebin.c b/gst/playback/gsturisourcebin.c index b97d425bad..ccdd0b86ca 100644 --- a/gst/playback/gsturisourcebin.c +++ b/gst/playback/gsturisourcebin.c @@ -50,9 +50,7 @@ #include "gstplay-enum.h" #include "gstrawcaps.h" #include "gstplayback.h" - -/* From gstdecodebin2.c */ -gint _decode_bin_compare_factories_func (gconstpointer p1, gconstpointer p2); +#include "gstplaybackutils.h" #define GST_TYPE_URI_DECODE_BIN \ (gst_uri_source_bin_get_type()) @@ -355,7 +353,7 @@ gst_uri_source_bin_update_factories_list (GstURISourceBin * dec) gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_DECODABLE, GST_RANK_MARGINAL); dec->factories = - g_list_sort (dec->factories, _decode_bin_compare_factories_func); + g_list_sort (dec->factories, gst_playback_utils_compare_factories_func); dec->factories_cookie = cookie; } }