4 // this must be built within the gstreamer dir, else this will fail
5 #include <gst/gstpropsprivate.h>
7 void print_prop(GstPropsEntry *prop,gboolean showname,gchar *pfx) {
9 GstPropsEntry *listentry;
13 printf("%s%s: ",pfx,g_quark_to_string(prop->propid));
17 switch (prop->propstype) {
18 case GST_PROPS_INT_ID_NUM:
19 printf("Integer: %d\n",prop->data.int_data);
21 case GST_PROPS_INT_RANGE_ID_NUM:
22 printf("Integer range: %d - %d\n",prop->data.int_range_data.min,
23 prop->data.int_range_data.max);
25 case GST_PROPS_BOOL_ID_NUM:
26 printf("Boolean: %s\n",prop->data.bool_data ? "TRUE" : "FALSE");
28 case GST_PROPS_FOURCC_ID_NUM:
29 printf("FourCC: %c%c%c%c\n",
30 prop->data.fourcc_data & 0xff,prop->data.fourcc_data>>8 & 0xff,
31 prop->data.fourcc_data>>16 & 0xff,prop->data.fourcc_data>>24 & 0xff);
33 case GST_PROPS_LIST_ID_NUM:
35 longprefix = g_strdup_printf("%s ",pfx);
36 list = prop->data.list_data.entries;
38 listentry = (GstPropsEntry*)(list->data);
39 list = g_list_next(list);
40 print_prop(listentry,FALSE,longprefix);
49 void print_props(GstProps *properties,gchar *pfx) {
53 props = properties->properties;
55 prop = (GstPropsEntry*)(props->data);
56 props = g_list_next(props);
58 print_prop(prop,TRUE,pfx);
63 struct _GstPropsEntry {
85 gint print_element_info(GstElementFactory *factory) {
87 GstObjectClass *gstobject_class;
88 GstElementClass *gstelement_class;
92 GstPadTemplate *padtemplate;
98 element = gst_elementfactory_create(factory,"element");
100 g_print ("couldn't construct element for some reason\n");
104 gstobject_class = GST_OBJECT_CLASS (GTK_OBJECT (element)->klass);
105 gstelement_class = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass);
107 printf("Factory Details:\n");
108 printf(" Long name:\t%s\n",factory->details->longname);
109 printf(" Class:\t%s\n",factory->details->klass);
110 printf(" Description:\t%s\n",factory->details->description);
111 printf(" Version:\t%s\n",factory->details->version);
112 printf(" Author(s):\t%s\n",factory->details->author);
113 printf(" Copyright:\t%s\n",factory->details->copyright);
116 printf("Pad Templates:\n");
117 if (factory->numpadtemplates) {
118 pads = factory->padtemplates;
120 padtemplate = (GstPadTemplate*)(pads->data);
121 pads = g_list_next(pads);
123 if (padtemplate->direction == GST_PAD_SRC)
124 printf(" SRC template: '%s'\n",padtemplate->name_template);
125 else if (padtemplate->direction == GST_PAD_SINK)
126 printf(" SINK template: '%s'\n",padtemplate->name_template);
128 printf(" UNKNOWN!!! template: '%s'\n",padtemplate->name_template);
130 if (padtemplate->presence == GST_PAD_ALWAYS)
131 printf(" Exists: Always\n");
132 else if (padtemplate->presence == GST_PAD_SOMETIMES)
133 printf(" Exists: Sometimes\n");
134 else if (padtemplate->presence == GST_PAD_REQUEST)
135 printf(" Exists: Request\n");
137 printf(" Exists: UNKNOWN!!!\n");
139 if (padtemplate->caps) {
140 printf(" Capabilities:\n");
141 caps = padtemplate->caps;
145 cap = (GstCaps*)(caps->data);
146 caps = g_list_next(caps);
148 printf(" '%s':\n",cap->name);
150 type = gst_type_find_by_id (cap->id);
152 printf(" MIME type: '%s':\n",type->mime);
154 printf(" MIME type: 'unknown/unknown':\n");
157 print_props(cap->properties," ");
166 printf("Element Flags:\n");
167 if (GST_FLAG_IS_SET(element,GST_ELEMENT_COMPLEX))
168 printf(" GST_ELEMENT_COMPLEX\n");
169 if (GST_FLAG_IS_SET(element,GST_ELEMENT_DECOUPLED))
170 printf(" GST_ELEMENT_DECOUPLED\n");
171 if (GST_FLAG_IS_SET(element,GST_ELEMENT_THREAD_SUGGESTED))
172 printf(" GST_ELEMENT_THREADSUGGESTED\n");
173 if (GST_FLAG_IS_SET(element,GST_ELEMENT_NO_SEEK))
174 printf(" GST_ELEMENT_NO_SEEK\n");
175 if (! GST_FLAG_IS_SET(element, GST_ELEMENT_COMPLEX | GST_ELEMENT_DECOUPLED |
176 GST_ELEMENT_THREAD_SUGGESTED | GST_ELEMENT_NO_SEEK))
177 printf(" no flags set\n");
181 printf("Element Implementation:\n");
182 if (element->loopfunc)
183 printf(" loopfunc()-based element\n");
185 printf(" No loopfunc(), must be chain-based or not configured yet\n");
186 if (gstelement_class->change_state)
187 printf(" Has change_state() function\n");
189 printf(" No change_state() class function\n");
190 if (gstobject_class->save_thyself)
191 printf(" Has custom save_thyself() class function\n");
192 if (gstobject_class->restore_thyself)
193 printf(" Has custom restore_thyself() class function\n");
198 if (element->numpads) {
199 pads = gst_element_get_pad_list(element);
201 pad = GST_PAD(pads->data);
202 pads = g_list_next(pads);
203 realpad = GST_REAL_PAD(pad);
205 if (gst_pad_get_direction(pad) == GST_PAD_SRC)
206 printf(" SRC: '%s'\n",gst_pad_get_name(pad));
207 else if (gst_pad_get_direction(pad) == GST_PAD_SINK)
208 printf(" SINK: '%s'\n",gst_pad_get_name(pad));
210 printf(" UNKNOWN!!!: '%s'\n",gst_pad_get_name(pad));
212 printf(" Implementation:\n");
213 if (realpad->chainfunc)
214 printf(" Has chainfunc(): %s\n",GST_DEBUG_FUNCPTR_NAME(realpad->chainfunc));
215 if (realpad->getfunc)
216 printf(" Has getfunc(): %s\n",GST_DEBUG_FUNCPTR_NAME(realpad->getfunc));
217 if (realpad->getregionfunc)
218 printf(" Has getregionfunc(): %s\n",GST_DEBUG_FUNCPTR_NAME(realpad->getregionfunc));
219 if (realpad->qosfunc)
220 printf(" Has qosfunc(): %s\n",GST_DEBUG_FUNCPTR_NAME(realpad->qosfunc));
221 if (realpad->eosfunc) {
222 printf(" Has eosfunc(): %s\n",GST_DEBUG_FUNCPTR_NAME(realpad->eosfunc));
225 if (pad->padtemplate)
226 printf(" Pad Template: '%s'\n",pad->padtemplate->name_template);
229 printf(" Capabilities:\n");
230 caps = realpad->caps;
234 cap = (GstCaps*)(caps->data);
235 caps = g_list_next(caps);
237 printf(" '%s':\n",cap->name);
239 type = gst_type_find_by_id (cap->id);
241 printf(" MIME type: '%s':\n",type->mime);
243 printf(" MIME type: 'unknown/unknown':\n");
246 print_props(cap->properties," ");
255 printf("Element Arguments:\n");
256 args = gtk_object_query_args(GTK_OBJECT_TYPE(element), &flags, &num_args);
257 for (i=0;i<num_args;i++) {
258 gtk_object_getv(GTK_OBJECT(element), 1, &args[i]);
260 // FIXME should say whether it's read-only or not
262 printf(" %s: ",args[i].name);
263 switch (args[i].type) {
264 case GTK_TYPE_STRING: printf("String");break;
265 case GTK_TYPE_BOOL: printf("Boolean");break;
269 case GTK_TYPE_INT: printf("Integer");break;
271 case GTK_TYPE_DOUBLE: printf("Float");break;
273 if (args[i].type == GST_TYPE_FILENAME)
275 else if (GTK_FUNDAMENTAL_TYPE (args[i].type) == GTK_TYPE_ENUM) {
276 GtkEnumValue *values;
279 printf("Enum (default %d)", GTK_VALUE_ENUM (args[i]));
280 values = gtk_type_enum_get_values (args[i].type);
281 while (values[j].value_name) {
282 printf("\n (%d): \t%s", values[j].value, values[j].value_nick);
286 else if (args[i].type == GTK_TYPE_WIDGET)
295 if (num_args == 0) g_print (" none");
301 void print_element_list() {
302 GList *plugins, *factories;
304 GstElementFactory *factory;
306 plugins = gst_plugin_get_list();
308 plugin = (GstPlugin*)(plugins->data);
309 plugins = g_list_next (plugins);
311 // printf("%s:\n",plugin->name);
313 factories = gst_plugin_get_factory_list(plugin);
315 factory = (GstElementFactory*)(factories->data);
316 factories = g_list_next (factories);
318 printf("%s: %s: %s\n",plugin->name,factory->name,factory->details->longname);
326 void print_plugin_info(GstPlugin *plugin) {
328 GstElementFactory *factory;
330 printf("Plugin Details:\n");
331 printf(" Name:\t\t%s\n",plugin->name);
332 printf(" Long Name:\t%s\n",plugin->longname);
333 printf(" Filename:\t%s\n",plugin->filename);
336 if (plugin->numelements) {
337 printf("Element Factories:\n");
339 factories = gst_plugin_get_factory_list(plugin);
341 factory = (GstElementFactory*)(factories->data);
342 factories = g_list_next(factories);
344 printf(" %s: %s\n",factory->name,factory->details->longname);
351 int main(int argc,char *argv[]) {
352 GstElementFactory *factory;
356 gst_init(&argc,&argv);
358 // if no arguments, print out list of elements
360 print_element_list();
362 // else we try to get a factory
364 // first check for help
365 if (strstr(argv[1],"-help")) {
366 printf("Usage: %s\t\t\tList all registered elements\n",argv[0]);
367 printf(" %s element-name\tShow element details\n",argv[0]);
368 printf(" %s plugin-name[.so]\tShow information about plugin\n",argv[0]);
372 // only search for a factory if there's not a '.so'
373 if (! strstr(argv[1],".so")) {
374 factory = gst_elementfactory_find (argv[1]);
376 // if there's a factory, print out the info
378 return print_element_info(factory);
381 so = strstr(argv[1],".so");
385 // otherwise assume it's a plugin
386 plugin = gst_plugin_find (argv[1]);
388 // if there is such a plugin, print out info
390 print_plugin_info(plugin);
393 printf("no such element or plugin '%s'\n",argv[1]);