diff options
author | Mathieu Duponchelle <mathieu.duponchelle@opencreed.com> | 2015-02-23 21:17:16 +0100 |
---|---|---|
committer | Mathieu Duponchelle <mathieu.duponchelle@opencreed.com> | 2015-02-23 21:17:54 +0100 |
commit | c2d483941d08a584124bf4b342b0315f897b1944 (patch) | |
tree | e1a13f1926baf61bfa390de03cd51fc9c7c27a3e | |
parent | c3454a85c5207dfe33dcaaebf37d8163198a6816 (diff) |
completion-helper: Add filtering by klass and sink caps.
-rw-r--r-- | libs/gst/helpers/gst-completion-helper.c | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/libs/gst/helpers/gst-completion-helper.c b/libs/gst/helpers/gst-completion-helper.c index 2e83dd592..e99b73b7b 100644 --- a/libs/gst/helpers/gst-completion-helper.c +++ b/libs/gst/helpers/gst-completion-helper.c @@ -27,6 +27,7 @@ #include <gst/gst.h> #include <glib.h> #include <stdlib.h> +#include <string.h> static GList * get_pad_templates_info (GstElement * element, GstElementFactory * factory, @@ -96,8 +97,22 @@ _are_linkable (GstPluginFeature * feature, GList * caps_list) return print; } +static gboolean +_belongs_to_klass (GstElementFactory * factory, const gchar * klass) +{ + const gchar *factory_klass; + + + factory_klass = + gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS); + if (strstr (factory_klass, klass)) + return TRUE; + return FALSE; +} + static void -_list_features (const gchar * compatible_with) +_list_features (const gchar * compatible_with, const gchar * klass, + GstCaps * sinkcaps) { GList *plugins, *orig_plugins; GList *caps_list = NULL; @@ -132,6 +147,13 @@ _list_features (const gchar * compatible_with) gboolean print = TRUE; if (caps_list) print = _are_linkable (feature, caps_list); + if (print && klass) + print = _belongs_to_klass (GST_ELEMENT_FACTORY (feature), klass); + if (print && sinkcaps) + print = + gst_element_factory_can_sink_any_caps (GST_ELEMENT_FACTORY + (feature), sinkcaps); + if (print) g_print ("%s ", gst_plugin_feature_get_name (feature)); } @@ -182,6 +204,10 @@ main (int argc, char *argv[]) gboolean list_features = FALSE; gchar *compatible_with = NULL; gchar *element = NULL; + gchar *klass = NULL; + gchar *caps_str = NULL; + GstCaps *sinkcaps = NULL; + gint exit_code = EXIT_SUCCESS; GOptionEntry options[] = { {"list-features", 'l', 0, G_OPTION_ARG_NONE, &list_features, @@ -191,6 +217,10 @@ main (int argc, char *argv[]) NULL}, {"element-properties", '\0', 0, G_OPTION_ARG_STRING, &element, "The element to list properties on", NULL}, + {"klass", '\0', 0, G_OPTION_ARG_STRING, &klass, + "Only print the elements belonging to that klass", NULL}, + {"sinkcaps", '\0', 0, G_OPTION_ARG_STRING, &caps_str, + "Only print the elements that can sink these caps", NULL}, {NULL} }; @@ -209,18 +239,31 @@ main (int argc, char *argv[]) } g_option_context_free (ctx); - if (compatible_with) { - _list_features (compatible_with); - exit (EXIT_SUCCESS); + if (caps_str) { + sinkcaps = gst_caps_from_string (caps_str); + if (!sinkcaps) { + exit_code = EXIT_FAILURE; + goto done; + } + } + + if (compatible_with || klass || sinkcaps) { + _list_features (compatible_with, klass, sinkcaps); + goto done; } if (element) { _list_element_properties (element); - exit (EXIT_SUCCESS); + goto done; } if (list_features) { - _list_features (NULL); - exit (EXIT_SUCCESS); + _list_features (NULL, NULL, NULL); + goto done; } + +done: + if (sinkcaps) + gst_caps_unref (sinkcaps); + exit (exit_code); } |