playbackutils: Move compare_factories_func

Move _decode_bin_compare_factories_func function to playbackutils

https://bugzilla.gnome.org/show_bug.cgi?id=770692
This commit is contained in:
Wonchul Lee 2016-09-01 14:47:02 +09:00 committed by Sebastian Dröge
parent 4b854b3440
commit 0cc3f199ca
5 changed files with 36 additions and 39 deletions

View file

@ -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;
}
}

View file

@ -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);
}

View file

@ -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__ */

View file

@ -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;
}
}

View file

@ -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;
}
}