mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
completion-helper: Add filtering by klass and sink caps.
This commit is contained in:
parent
c3454a85c5
commit
c2d483941d
1 changed files with 50 additions and 7 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static GList *
|
static GList *
|
||||||
get_pad_templates_info (GstElement * element, GstElementFactory * factory,
|
get_pad_templates_info (GstElement * element, GstElementFactory * factory,
|
||||||
|
@ -96,8 +97,22 @@ _are_linkable (GstPluginFeature * feature, GList * caps_list)
|
||||||
return print;
|
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
|
static void
|
||||||
_list_features (const gchar * compatible_with)
|
_list_features (const gchar * compatible_with, const gchar * klass,
|
||||||
|
GstCaps * sinkcaps)
|
||||||
{
|
{
|
||||||
GList *plugins, *orig_plugins;
|
GList *plugins, *orig_plugins;
|
||||||
GList *caps_list = NULL;
|
GList *caps_list = NULL;
|
||||||
|
@ -132,6 +147,13 @@ _list_features (const gchar * compatible_with)
|
||||||
gboolean print = TRUE;
|
gboolean print = TRUE;
|
||||||
if (caps_list)
|
if (caps_list)
|
||||||
print = _are_linkable (feature, 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)
|
if (print)
|
||||||
g_print ("%s ", gst_plugin_feature_get_name (feature));
|
g_print ("%s ", gst_plugin_feature_get_name (feature));
|
||||||
}
|
}
|
||||||
|
@ -182,6 +204,10 @@ main (int argc, char *argv[])
|
||||||
gboolean list_features = FALSE;
|
gboolean list_features = FALSE;
|
||||||
gchar *compatible_with = NULL;
|
gchar *compatible_with = NULL;
|
||||||
gchar *element = NULL;
|
gchar *element = NULL;
|
||||||
|
gchar *klass = NULL;
|
||||||
|
gchar *caps_str = NULL;
|
||||||
|
GstCaps *sinkcaps = NULL;
|
||||||
|
gint exit_code = EXIT_SUCCESS;
|
||||||
|
|
||||||
GOptionEntry options[] = {
|
GOptionEntry options[] = {
|
||||||
{"list-features", 'l', 0, G_OPTION_ARG_NONE, &list_features,
|
{"list-features", 'l', 0, G_OPTION_ARG_NONE, &list_features,
|
||||||
|
@ -191,6 +217,10 @@ main (int argc, char *argv[])
|
||||||
NULL},
|
NULL},
|
||||||
{"element-properties", '\0', 0, G_OPTION_ARG_STRING, &element,
|
{"element-properties", '\0', 0, G_OPTION_ARG_STRING, &element,
|
||||||
"The element to list properties on", NULL},
|
"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}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -209,18 +239,31 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
g_option_context_free (ctx);
|
g_option_context_free (ctx);
|
||||||
|
|
||||||
if (compatible_with) {
|
if (caps_str) {
|
||||||
_list_features (compatible_with);
|
sinkcaps = gst_caps_from_string (caps_str);
|
||||||
exit (EXIT_SUCCESS);
|
if (!sinkcaps) {
|
||||||
|
exit_code = EXIT_FAILURE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compatible_with || klass || sinkcaps) {
|
||||||
|
_list_features (compatible_with, klass, sinkcaps);
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
_list_element_properties (element);
|
_list_element_properties (element);
|
||||||
exit (EXIT_SUCCESS);
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_features) {
|
if (list_features) {
|
||||||
_list_features (NULL);
|
_list_features (NULL, NULL, NULL);
|
||||||
exit (EXIT_SUCCESS);
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (sinkcaps)
|
||||||
|
gst_caps_unref (sinkcaps);
|
||||||
|
exit (exit_code);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue