mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 11:29:55 +00:00
Updated -inspect to list elements and plugin info too
Original commit message from CVS: Updated -inspect to list elements and plugin info too
This commit is contained in:
parent
9e0b75c937
commit
e318439f64
2 changed files with 119 additions and 22 deletions
|
@ -1,4 +1,5 @@
|
|||
#include <gst/gst.h>
|
||||
#include <string.h>
|
||||
|
||||
// this must be built within the gstreamer dir, else this will fail
|
||||
#include <gst/gstpropsprivate.h>
|
||||
|
@ -81,8 +82,7 @@ struct _GstPropsEntry {
|
|||
};
|
||||
*/
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElementFactory *factory;
|
||||
gint print_element_info(GstElementFactory *factory) {
|
||||
GstElement *element;
|
||||
GstElementClass *gstelement_class;
|
||||
GList *pads, *caps;
|
||||
|
@ -93,15 +93,11 @@ int main(int argc,char *argv[]) {
|
|||
guint32 *flags;
|
||||
gint num_args,i;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
factory = gst_elementfactory_find(argv[1]);
|
||||
if (!factory) {
|
||||
g_print ("no elementfactory for element '%s' exists\n", argv[1]);
|
||||
element = gst_elementfactory_create(factory,"element");
|
||||
if (!element) {
|
||||
g_print ("couldn't construct element for some reason\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
element = gst_elementfactory_create(factory,argv[1]);
|
||||
gstelement_class = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass);
|
||||
|
||||
printf("Factory Details:\n");
|
||||
|
@ -271,3 +267,103 @@ int main(int argc,char *argv[]) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_element_list() {
|
||||
GList *plugins, *factories;
|
||||
GstPlugin *plugin;
|
||||
GstElementFactory *factory;
|
||||
|
||||
plugins = gst_plugin_get_list();
|
||||
while (plugins) {
|
||||
plugin = (GstPlugin*)(plugins->data);
|
||||
plugins = g_list_next (plugins);
|
||||
|
||||
// printf("%s:\n",plugin->name);
|
||||
|
||||
factories = gst_plugin_get_factory_list(plugin);
|
||||
while (factories) {
|
||||
factory = (GstElementFactory*)(factories->data);
|
||||
factories = g_list_next (factories);
|
||||
|
||||
printf("%s: %s: %s\n",plugin->name,factory->name,factory->details->longname);
|
||||
}
|
||||
|
||||
// printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void print_plugin_info(GstPlugin *plugin) {
|
||||
GList *factories;
|
||||
GstElementFactory *factory;
|
||||
|
||||
printf("Plugin Details:\n");
|
||||
printf(" Name:\t\t%s\n",plugin->name);
|
||||
printf(" Long Name:\t%s\n",plugin->longname);
|
||||
printf(" Filename:\t%s\n",plugin->filename);
|
||||
printf("\n");
|
||||
|
||||
if (plugin->numelements) {
|
||||
printf("Element Factories:\n");
|
||||
|
||||
factories = gst_plugin_get_factory_list(plugin);
|
||||
while (factories) {
|
||||
factory = (GstElementFactory*)(factories->data);
|
||||
factories = g_list_next(factories);
|
||||
|
||||
printf(" %s: %s\n",factory->name,factory->details->longname);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElementFactory *factory;
|
||||
GstPlugin *plugin;
|
||||
gchar *so;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
// if no arguments, print out list of elements
|
||||
if (argc == 1) {
|
||||
print_element_list();
|
||||
|
||||
// else we try to get a factory
|
||||
} else {
|
||||
// first check for help
|
||||
if (strstr(argv[1],"-help")) {
|
||||
printf("Usage: %s\t\t\tList all registered elements\n",argv[0]);
|
||||
printf(" %s element-name\tShow element details\n",argv[0]);
|
||||
printf(" %s plugin-name[.so]\tShow information about plugin\n",argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// only search for a factory if there's not a '.so'
|
||||
if (! strstr(argv[1],".so")) {
|
||||
factory = gst_elementfactory_find (argv[1]);
|
||||
|
||||
// if there's a factory, print out the info
|
||||
if (factory)
|
||||
return print_element_info(factory);
|
||||
} else {
|
||||
// strip the .so
|
||||
so = strstr(argv[1],".so");
|
||||
so[0] = '\0';
|
||||
}
|
||||
|
||||
// otherwise assume it's a plugin
|
||||
plugin = gst_plugin_find (argv[1]);
|
||||
|
||||
// if there is such a plugin, print out info
|
||||
if (plugin) {
|
||||
print_plugin_info(plugin);
|
||||
|
||||
} else {
|
||||
printf("no such element or plugin '%s'\n",argv[1]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -144,6 +144,18 @@ gint parse_cmdline(int argc,char *argv[],GstBin *parent) {
|
|||
else DEBUG("have src pad %s:%s\n",GST_DEBUG_PAD_NAME(srcpad));
|
||||
}
|
||||
|
||||
// argument with = in it
|
||||
} else if (strstr(arg, "=")) {
|
||||
gchar * argname;
|
||||
gchar * argval;
|
||||
gchar * pos = strstr(arg, "=");
|
||||
// we have an argument
|
||||
argname = g_strndup(arg, pos - arg);
|
||||
argval = pos+1;
|
||||
DEBUG("attempting to set argument '%s'\n", arg);
|
||||
gtk_object_set(GTK_OBJECT(previous),argname,argval,NULL);
|
||||
g_free(argname);
|
||||
|
||||
// element or argument, or beginning of bin or thread
|
||||
} else {
|
||||
DEBUG("have element or bin/thread\n");
|
||||
|
@ -161,18 +173,6 @@ gint parse_cmdline(int argc,char *argv[],GstBin *parent) {
|
|||
|
||||
i += parse_cmdline(argc - i, argv + i + 1, GST_BIN (element));
|
||||
|
||||
} else if (strstr(arg, "=")) {
|
||||
gchar * argname;
|
||||
gchar * argval;
|
||||
gchar * pos = strstr(arg, "=");
|
||||
// we have an argument
|
||||
argname = g_strndup(arg, pos - arg);
|
||||
argval = pos+1;
|
||||
DEBUG("attempting to set argument '%s'\n", arg);
|
||||
gtk_object_set(GTK_OBJECT(previous),argname,argval,NULL);
|
||||
g_free(argname);
|
||||
i++;
|
||||
continue;
|
||||
} else {
|
||||
// we have an element
|
||||
DEBUG("attempting to create element '%s'\n",arg);
|
||||
|
@ -351,7 +351,8 @@ int main(int argc,char *argv[]) {
|
|||
|
||||
VERBOSE("RUNNING pipeline\n");
|
||||
gst_element_set_state(pipeline,GST_STATE_PLAYING);
|
||||
for (i=0; i < 1000; i++)
|
||||
|
||||
while(1)
|
||||
gst_bin_iterate (GST_BIN (pipeline));
|
||||
|
||||
fprintf(stderr,"\n");
|
||||
|
|
Loading…
Reference in a new issue