tools/gst-inspect.c (print_all_uri_handlers): New function, prints a summary of what URI schemes are supported by wha...

Original commit message from CVS:
2008-11-17  Andy Wingo  <wingo@pobox.com>

* tools/gst-inspect.c (print_all_uri_handlers): New function,
prints a summary of what URI schemes are supported by what
elements.
(main): Plumb in support for --uri-handlers or -u, and fix the
argc check for -a and -u.
This commit is contained in:
Andy Wingo 2008-11-17 15:48:14 +00:00
parent e79e2061ae
commit de6f88f0f0
2 changed files with 97 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2008-11-17 Andy Wingo <wingo@pobox.com>
* tools/gst-inspect.c (print_all_uri_handlers): New function,
prints a summary of what URI schemes are supported by what
elements.
(main): Plumb in support for --uri-handlers or -u, and fix the
argc check for -a and -u.
2008-11-17 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/gstutils.h:

View file

@ -1019,6 +1019,80 @@ print_element_list (gboolean print_all)
g_print ("\n");
}
static void
print_all_uri_handlers (void)
{
GList *plugins, *p, *features, *f;
plugins = gst_default_registry_get_plugin_list ();
for (p = plugins; p; p = p->next) {
GstPlugin *plugin = (GstPlugin *) (p->data);
features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
plugin->desc.name);
for (f = features; f; f = f->next) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (features->data);
if (GST_IS_ELEMENT_FACTORY (feature)) {
GstElementFactory *factory;
GstElement *element;
factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
if (!factory) {
g_print ("element plugin %s couldn't be loaded\n", plugin->desc.name);
continue;
}
element = gst_element_factory_create (factory, NULL);
if (!element) {
g_print ("couldn't construct element for %s for some reason\n",
GST_OBJECT_NAME (factory));
gst_object_unref (factory);
continue;
}
if (GST_IS_URI_HANDLER (element)) {
const gchar *dir;
gchar **uri_protocols, *joined;
switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
case GST_URI_SRC:
dir = "read";
break;
case GST_URI_SINK:
dir = "write";
break;
default:
dir = "unknown";
break;
}
uri_protocols =
gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
joined = g_strjoinv (", ", uri_protocols);
g_print ("%s (%s, rank %u): %s\n", GST_OBJECT_NAME (factory), dir,
gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
joined);
g_free (joined);
//g_strfreev (uri_protocols);
}
gst_object_unref (element);
gst_object_unref (factory);
}
}
gst_plugin_feature_list_free (features);
}
gst_plugin_list_free (plugins);
}
static void
print_plugin_info (GstPlugin * plugin)
{
@ -1320,6 +1394,7 @@ main (int argc, char *argv[])
gboolean print_all = FALSE;
gboolean plugin_name = FALSE;
gboolean print_aii = FALSE;
gboolean uri_handlers = FALSE;
GOptionEntry options[] = {
{"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
N_("Print all elements"), NULL},
@ -1330,6 +1405,10 @@ main (int argc, char *argv[])
"installation mechanisms"), NULL},
{"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
N_("List the plugin contents"), NULL},
{"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
N_
("Print supported URI schemes, with the elements that implement them"),
NULL},
GST_TOOLS_GOPTION_VERSION,
{NULL}
};
@ -1356,16 +1435,23 @@ main (int argc, char *argv[])
gst_tools_print_version ("gst-inspect");
if (print_all && argc > 2) {
if (print_all && argc > 1) {
g_print ("-a requires no extra arguments\n");
return 1;
}
if (uri_handlers && argc > 1) {
g_print ("-u requires no extra arguments\n");
exit (1);
}
/* if no arguments, print out list of elements */
if (argc == 1 || print_all) {
if (uri_handlers) {
print_all_uri_handlers ();
} else if (argc == 1 || print_all) {
print_element_list (print_all);
/* else we try to get a factory */
} else {
/* else we try to get a factory */
GstElementFactory *factory;
GstPlugin *plugin;
const char *arg = argv[argc - 1];