diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2007-12-05 17:11:48 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2007-12-05 17:11:48 +0000 |
commit | f2f9bf045ba32d7a79069837ed63fb103c6b995a (patch) | |
tree | a1088cc11658dfd5d53746a25bfa31f9b82630cb /gst/playback/gstfactorylists.c | |
parent | 75aa042450b540c430c465cb3664608f9ed25750 (diff) |
gst/playback/Makefile.am: Group decodebin2 and uridecodebin into the same plugin so that they can share the GEnumType.
Original commit message from CVS:
* gst/playback/Makefile.am:
Group decodebin2 and uridecodebin into the same plugin so that they
can share the GEnumType.
* gst/playback/gstdecodebin2.c: (_gst_array_accumulator),
(_gst_select_accumulator), (gst_decode_bin_class_init),
(gst_decode_bin_init), (gst_decode_bin_autoplug_sort),
(gst_decode_bin_autoplug_select), (gst_decode_bin_autoplug_add),
(analyze_new_pad), (connect_pad), (gst_decode_bin_plugin_init):
Add signal to sort factories instead of the more awkward autoplug-select
signal.
Modify autoplug_select so that we can try, skip or expose the
autopluggin of an element on a pad.
* gst/playback/gstfactorylists.c: (compare_ranks),
(decoders_filter), (sinks_filter), (gst_factory_list_is_type),
(element_filter), (gst_factory_list_get_elements),
(gst_factory_list_debug), (gst_factory_list_filter):
* gst/playback/gstfactorylists.h:
Simplify the API, allow getting elements based on mask.
* gst/playback/gstplay-marshal.list:
Add some more marshallers.
* gst/playback/gstplaybin2.c: (init_group), (gst_play_bin_init),
(gst_play_bin_finalize), (pad_removed_cb), (autoplug_factories_cb),
(autoplug_select_cb), (activate_group):
Add support for managing non-raw sinks by providing a custom element and
sink list to decodebin2.
Try to plug non-raw sinks when decodebin2 using autoplug-select of
decodebin2.
* gst/playback/gstplaysink.c: (gen_video_chain), (gen_audio_chain),
(gst_play_sink_set_mode), (gst_play_sink_request_pad):
* gst/playback/gstplaysink.h:
Add support for raw and non-raw sinks.
Add support to force sinks selected by playbin2.
Don't plug raw converters for non-raw sinks.
* gst/playback/gsturidecodebin.c: (_gst_array_accumulator),
(_gst_select_accumulator), (gst_uri_decode_bin_class_init),
(proxy_autoplug_select_signal), (gst_uri_decode_bin_plugin_init),
(plugin_init):
Use right accumulators.
Proxy new signal.
Diffstat (limited to 'gst/playback/gstfactorylists.c')
-rw-r--r-- | gst/playback/gstfactorylists.c | 163 |
1 files changed, 90 insertions, 73 deletions
diff --git a/gst/playback/gstfactorylists.c b/gst/playback/gstfactorylists.c index ca6166d83..667beaf0f 100644 --- a/gst/playback/gstfactorylists.c +++ b/gst/playback/gstfactorylists.c @@ -20,6 +20,11 @@ #include "gstfactorylists.h" +typedef struct +{ + GstFactoryListType type; +} FilterData; + /* function used to sort element features. We first sort on the rank, then * on the element name (to get a consistent, predictable list) */ static gint @@ -44,61 +49,15 @@ compare_ranks (GValue * v1, GValue * v2) return diff; } -#if 0 -static void -print_feature (GstPluginFeature * feature) -{ - const gchar *rname; - - rname = gst_plugin_feature_get_name (feature); - - GST_DEBUG ("%s", rname); -} -#endif - -/* get a filtered feature list as a GValueArray */ -static GValueArray * -get_feature_array (GstPluginFeatureFilter filter) -{ - GValueArray *result; - GList *walk, *list; - - result = g_value_array_new (0); - - /* get the feature list using the filter */ - list = gst_default_registry_feature_filter (filter, FALSE, NULL); - - /* convert to an array */ - for (walk = list; walk; walk = g_list_next (walk)) { - GstElementFactory *factory = GST_ELEMENT_FACTORY (walk->data); - GValue val = { 0, }; - - g_value_init (&val, G_TYPE_OBJECT); - g_value_set_object (&val, factory); - g_value_array_append (result, &val); - g_value_unset (&val); - } - gst_plugin_feature_list_free (list); - - /* sort on rank and name */ - g_value_array_sort (result, (GCompareFunc) compare_ranks); - - return result; -} - /* the filter function for selecting the elements we can use in * autoplugging */ static gboolean -decoders_filter (GstPluginFeature * feature) +decoders_filter (GstElementFactory * factory) { guint rank; const gchar *klass; - /* we only care about element factories */ - if (!GST_IS_ELEMENT_FACTORY (feature)) - return FALSE; - - klass = gst_element_factory_get_klass (GST_ELEMENT_FACTORY (feature)); + klass = gst_element_factory_get_klass (factory); /* only demuxers, decoders, depayloaders and parsers can play */ if (strstr (klass, "Demux") == NULL && strstr (klass, "Decoder") == NULL && @@ -108,7 +67,7 @@ decoders_filter (GstPluginFeature * feature) } /* only select elements with autoplugging rank */ - rank = gst_plugin_feature_get_rank (feature); + rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)); if (rank < GST_RANK_MARGINAL) return FALSE; @@ -118,16 +77,12 @@ decoders_filter (GstPluginFeature * feature) /* the filter function for selecting the elements we can use in * autoplugging */ static gboolean -sinks_filter (GstPluginFeature * feature) +sinks_filter (GstElementFactory * factory) { guint rank; const gchar *klass; - /* we only care about element factories */ - if (!GST_IS_ELEMENT_FACTORY (feature)) - return FALSE; - - klass = gst_element_factory_get_klass (GST_ELEMENT_FACTORY (feature)); + klass = gst_element_factory_get_klass (factory); /* only sinks can play */ if (strstr (klass, "Sink") == NULL) { return FALSE; @@ -139,54 +94,116 @@ sinks_filter (GstPluginFeature * feature) } /* only select elements with autoplugging rank */ - rank = gst_plugin_feature_get_rank (feature); + rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)); if (rank < GST_RANK_MARGINAL) return FALSE; return TRUE; } - /** - * gst_factory_list_get_decoders: + * gst_factory_list_is_type: + * @factory: a #GstElementFactory + * @type: a #GstFactoryListType * - * Get a sorted list of factories that can be used in decoding pipelines. + * Check if @factory if of the given types. * - * Returns: a #GValueArray of #GstElementFactory elements. Use - * g_value_array_free() after usage. + * Returns: %TRUE if @factory is of @type. */ -GValueArray * -gst_factory_list_get_decoders (void) +gboolean +gst_factory_list_is_type (GstElementFactory * factory, GstFactoryListType type) { - GValueArray *result; + gboolean res = FALSE; - /* first filter out the interesting element factories */ - result = get_feature_array ((GstPluginFeatureFilter) decoders_filter); + if (!res && (type & GST_FACTORY_LIST_SINK)) + res = sinks_filter (factory); + if (!res && (type & GST_FACTORY_LIST_DECODER)) + res = decoders_filter (factory); - return result; + return res; +} + +static gboolean +element_filter (GstPluginFeature * feature, FilterData * data) +{ + gboolean res; + + /* we only care about element factories */ + if (!GST_IS_ELEMENT_FACTORY (feature)) + return FALSE; + + res = gst_factory_list_is_type (GST_ELEMENT_FACTORY (feature), data->type); + + return res; } /** - * gst_factory_list_get_sinks: + * gst_factory_list_get_elements: + * @type: a #GstFactoryListType * - * Get a sorted list of factories that can be used as sinks in a decoding - * pipeline. + * Get a sorted list of factories of @type. * * Returns: a #GValueArray of #GstElementFactory elements. Use * g_value_array_free() after usage. */ GValueArray * -gst_factory_list_get_sinks (void) +gst_factory_list_get_elements (GstFactoryListType type) { GValueArray *result; + GList *walk, *list; + FilterData data; - /* first filter out the interesting element factories */ - result = get_feature_array ((GstPluginFeatureFilter) sinks_filter); + result = g_value_array_new (0); + + /* prepare type */ + data.type = type; + + /* get the feature list using the filter */ + list = + gst_default_registry_feature_filter ((GstPluginFeatureFilter) + element_filter, FALSE, &data); + + /* convert to an array */ + for (walk = list; walk; walk = g_list_next (walk)) { + GstElementFactory *factory = GST_ELEMENT_FACTORY (walk->data); + GValue val = { 0, }; + + g_value_init (&val, G_TYPE_OBJECT); + g_value_set_object (&val, factory); + g_value_array_append (result, &val); + g_value_unset (&val); + } + gst_plugin_feature_list_free (list); + + /* sort on rank and name */ + g_value_array_sort (result, (GCompareFunc) compare_ranks); return result; } /** + * gst_factory_list_debug: + * @array: an array of element factories + * + * Debug the element factory names in @array. + */ +void +gst_factory_list_debug (GValueArray * array) +{ + gint i; + + for (i = 0; i < array->n_values; i++) { + GValue *value; + GstPluginFeature *feature; + + value = g_value_array_get_nth (array, i); + feature = g_value_get_object (value); + + GST_DEBUG ("%s", gst_plugin_feature_get_name (feature)); + } +} + +/** * gst_factory_list_filter: * @array: a #GValueArray to filter * @caps: a #GstCaps |