#include <gst/gst.h>
#include <glib.h>
#include <stdlib.h>
+#include <string.h>
static GList *
get_pad_templates_info (GstElement * element, GstElementFactory * factory,
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;
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));
}
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,
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}
};
}
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);
}