Update NEWS and RELEASE as well
[platform/upstream/gstreamer.git] / tools / gst-xmlinspect.c
1 /* GStreamer gst-xmlinspect
2  * Copyright (C) 2003 Wim Taymans <wtay@chello.be>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /* FIXME 0.11: remove gst-xmlinspect and gst-feedback etc. */
21 #ifdef HAVE_CONFIG_H
22 #  include "config.h"
23 #endif
24
25 #include <string.h>
26 #include <locale.h>
27 #include <glib/gprintf.h>
28
29 #include "tools.h"
30
31 #define PUT_START_TAG(pfx,tag)                                  \
32 G_STMT_START{                                                   \
33   g_print ("%*.*s<%s>\n", pfx, pfx, "", tag);                   \
34 }G_STMT_END
35
36 #define PUT_END_TAG(pfx,tag)                                    \
37 G_STMT_START{                                                   \
38   g_print ("%*.*s</%s>\n", pfx, pfx, "", tag);                  \
39 }G_STMT_END
40
41 #define PUT_ESCAPED(pfx,tag,value)                              \
42 G_STMT_START{                                                   \
43   const gchar *toconv = value;                                  \
44   if (value) {                                                  \
45     gchar *v = g_markup_escape_text (toconv, strlen (toconv));  \
46     g_print ("%*.*s<%s>%s</%s>\n", pfx, pfx, "", tag, v, tag);  \
47     g_free (v);                                                 \
48   }                                                             \
49 }G_STMT_END
50
51 #ifdef G_HAVE_ISO_VARARGS
52
53 #define PUT_STRING(pfx, ...)                                    \
54 G_STMT_START{                                                   \
55   gchar *ps_val = g_strdup_printf(__VA_ARGS__);                 \
56   g_print ("%*.*s%s\n", pfx, pfx, "", ps_val);                  \
57   g_free(ps_val);                                               \
58 }G_STMT_END
59
60 #elif defined(G_HAVE_GNUC_VARARGS)
61
62 #define PUT_STRING(pfx, str, a...)                              \
63 G_STMT_START{                                                   \
64   g_print ("%*.*s"str"\n", pfx, pfx, "" , ##a);                 \
65 }G_STMT_END
66
67 #else
68
69 static inline void
70 PUT_STRING (int pfx, const char *format, ...)
71 {
72   va_list varargs;
73
74   g_print ("%*.*s", pfx, pfx, "");
75   va_start (varargs, format);
76   g_vprintf (format, varargs);
77   va_end (varargs);
78   g_print ("\n");
79 }
80
81 #endif
82
83 static void
84 print_caps (const GstCaps * caps, gint pfx)
85 {
86   char *s;
87
88   if (!caps)
89     return;
90
91   s = gst_caps_to_string (caps);
92   PUT_ESCAPED (pfx, "caps", s);
93   g_free (s);
94 }
95
96 #if 0
97 static void
98 print_formats (const GstFormat * formats, gint pfx)
99 {
100   while (formats && *formats) {
101     const GstFormatDefinition *definition;
102
103     definition = gst_format_get_details (*formats);
104     if (definition)
105       PUT_STRING (pfx, "<format id=\"%d\" nick=\"%s\">%s</format>",
106           *formats, definition->nick, definition->description);
107     else
108       PUT_STRING (pfx, "<format id=\"%d\">unknown</format>", *formats);
109
110     formats++;
111   }
112 }
113 #endif
114
115 static void
116 print_query_types (const GstQueryType * types, gint pfx)
117 {
118   while (types && *types) {
119     const GstQueryTypeDefinition *definition;
120
121     definition = gst_query_type_get_details (*types);
122     if (definition)
123       PUT_STRING (pfx, "<query-type id=\"%d\" nick=\"%s\">%s</query-type>",
124           *types, definition->nick, definition->description);
125     else
126       PUT_STRING (pfx, "<query-type id=\"%d\">unknown</query-type>", *types);
127
128     types++;
129   }
130 }
131
132 #if 0
133 static void
134 print_event_masks (const GstEventMask * masks, gint pfx)
135 {
136   GType event_type;
137   GEnumClass *klass;
138   GType event_flags;
139   GFlagsClass *flags_class = NULL;
140
141   event_type = gst_event_type_get_type ();
142   klass = (GEnumClass *) g_type_class_ref (event_type);
143
144   while (masks && masks->type) {
145     GEnumValue *value;
146     gint flags = 0, index = 0;
147
148     switch (masks->type) {
149       case GST_EVENT_SEEK:
150         flags = masks->flags;
151         event_flags = gst_seek_type_get_type ();
152         flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
153         break;
154       default:
155         break;
156     }
157
158     value = g_enum_get_value (klass, masks->type);
159     PUT_STRING (pfx, "<event type=\"%s\">", value->value_nick);
160
161     while (flags) {
162       GFlagsValue *value;
163
164       if (flags & 1) {
165         value = g_flags_get_first_value (flags_class, 1 << index);
166
167         if (value)
168           PUT_ESCAPED (pfx + 1, "flag", value->value_nick);
169         else
170           PUT_ESCAPED (pfx + 1, "flag", "?");
171       }
172       flags >>= 1;
173       index++;
174     }
175     PUT_END_TAG (pfx, "event");
176
177     masks++;
178   }
179 }
180 #endif
181
182 static void
183 output_hierarchy (GType type, gint level, gint * maxlevel)
184 {
185   GType parent;
186
187   parent = g_type_parent (type);
188
189   *maxlevel = *maxlevel + 1;
190   level++;
191
192   PUT_STRING (level, "<object name=\"%s\">", g_type_name (type));
193
194   if (parent)
195     output_hierarchy (parent, level, maxlevel);
196
197   PUT_END_TAG (level, "object");
198 }
199
200 static void
201 print_element_properties (GstElement * element, gint pfx)
202 {
203   GParamSpec **property_specs;
204   guint num_properties;
205   gint i;
206   gboolean readable;
207
208   property_specs = g_object_class_list_properties
209       (G_OBJECT_GET_CLASS (element), &num_properties);
210
211   PUT_START_TAG (pfx, "element-properties");
212
213   for (i = 0; i < num_properties; i++) {
214     GValue value = { 0, };
215     GParamSpec *param = property_specs[i];
216
217     readable = FALSE;
218
219     g_value_init (&value, param->value_type);
220     if (param->flags & G_PARAM_READABLE) {
221       g_object_get_property (G_OBJECT (element), param->name, &value);
222       readable = TRUE;
223     }
224     PUT_START_TAG (pfx + 1, "element-property");
225     PUT_ESCAPED (pfx + 2, "name", g_param_spec_get_name (param));
226     PUT_ESCAPED (pfx + 2, "type", g_type_name (param->value_type));
227     PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (param));
228     PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (param));
229     if (readable) {
230       PUT_ESCAPED (pfx + 2, "flags", "RW");
231     } else {
232       PUT_ESCAPED (pfx + 2, "flags", "W");
233     }
234
235     switch (G_VALUE_TYPE (&value)) {
236       case G_TYPE_STRING:
237         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
238         break;
239       case G_TYPE_BOOLEAN:
240         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
241         break;
242       case G_TYPE_ULONG:
243       {
244         GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
245
246         PUT_STRING (pfx + 2, "<range min=\"%lu\" max=\"%lu\"/>",
247             pulong->minimum, pulong->maximum);
248         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
249         break;
250       }
251       case G_TYPE_LONG:
252       {
253         GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
254
255         PUT_STRING (pfx + 2, "<range min=\"%ld\" max=\"%ld\"/>",
256             plong->minimum, plong->maximum);
257         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
258         break;
259       }
260       case G_TYPE_UINT:
261       {
262         GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
263
264         PUT_STRING (pfx + 2, "<range min=\"%u\" max=\"%u\"/>",
265             puint->minimum, puint->maximum);
266         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
267         break;
268       }
269       case G_TYPE_INT:
270       {
271         GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
272
273         PUT_STRING (pfx + 2, "<range min=\"%d\" max=\"%d\"/>",
274             pint->minimum, pint->maximum);
275         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
276         break;
277       }
278       case G_TYPE_UINT64:
279       {
280         GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
281
282         PUT_STRING (pfx + 2,
283             "<range min=\"%" G_GUINT64_FORMAT "\" max=\"%" G_GUINT64_FORMAT
284             "\"/>", puint64->minimum, puint64->maximum);
285         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
286         break;
287       }
288       case G_TYPE_INT64:
289       {
290         GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
291
292         PUT_STRING (pfx + 2,
293             "<range min=\"%" G_GINT64_FORMAT "\" max=\"%" G_GINT64_FORMAT
294             "\"/>", pint64->minimum, pint64->maximum);
295         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
296         break;
297       }
298       case G_TYPE_FLOAT:
299       {
300         GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
301
302         PUT_STRING (pfx + 2, "<range min=\"%f\" max=\"%f\"/>",
303             pfloat->minimum, pfloat->maximum);
304         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
305         break;
306       }
307       case G_TYPE_DOUBLE:
308       {
309         GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
310
311         PUT_STRING (pfx + 2, "<range min=\"%g\" max=\"%g\"/>",
312             pdouble->minimum, pdouble->maximum);
313         PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
314         break;
315       }
316       default:
317         if (param->value_type == GST_TYPE_CAPS) {
318           GstCaps *caps = g_value_peek_pointer (&value);
319
320           if (!caps)
321             PUT_ESCAPED (pfx + 2, "default", "NULL");
322           else {
323             print_caps (caps, 2);
324           }
325         } else if (G_IS_PARAM_SPEC_ENUM (param)) {
326           GEnumValue *values;
327           guint j = 0;
328           gint enum_value;
329
330           values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
331           enum_value = g_value_get_enum (&value);
332
333           while (values[j].value_name) {
334             if (values[j].value == enum_value)
335               break;
336             j++;
337           }
338           PUT_STRING (pfx + 2, "<default>%d</default>", values[j].value);
339
340           PUT_START_TAG (pfx + 2, "enum-values");
341           j = 0;
342           while (values[j].value_name) {
343             PUT_STRING (pfx + 3, "<value value=\"%d\" nick=\"%s\"/>",
344                 values[j].value, values[j].value_nick);
345             j++;
346           }
347           PUT_END_TAG (pfx + 2, "enum-values");
348         } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
349           GFlagsValue *values;
350           guint j = 0;
351           gint flags_value;
352
353           values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
354           flags_value = g_value_get_flags (&value);
355
356           PUT_STRING (pfx + 2, "<default>%d</default>", flags_value);
357
358           PUT_START_TAG (pfx + 2, "flags");
359           j = 0;
360           while (values[j].value_name) {
361             PUT_STRING (pfx + 3, "<flag value=\"%d\" nick=\"%s\"/>",
362                 values[j].value, values[j].value_nick);
363             j++;
364           }
365           PUT_END_TAG (pfx + 2, "flags");
366         } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
367           PUT_ESCAPED (pfx + 2, "object-type", g_type_name (param->value_type));
368         }
369         break;
370     }
371
372     PUT_END_TAG (pfx + 1, "element-property");
373   }
374   PUT_END_TAG (pfx, "element-properties");
375   g_free (property_specs);
376 }
377
378 static void
379 print_element_signals (GstElement * element, gint pfx)
380 {
381   guint *signals;
382   guint nsignals;
383   gint i, k;
384   GSignalQuery *query;
385
386   signals = g_signal_list_ids (G_OBJECT_TYPE (element), &nsignals);
387   for (k = 0; k < 2; k++) {
388     gint counted = 0;
389
390     if (k == 0)
391       PUT_START_TAG (pfx, "element-signals");
392     else
393       PUT_START_TAG (pfx, "element-actions");
394
395     for (i = 0; i < nsignals; i++) {
396       gint n_params;
397       GType return_type;
398       const GType *param_types;
399       gint j;
400
401       query = g_new0 (GSignalQuery, 1);
402       g_signal_query (signals[i], query);
403
404       if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
405           (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) {
406         n_params = query->n_params;
407         return_type = query->return_type;
408         param_types = query->param_types;
409
410         PUT_START_TAG (pfx + 1, "signal");
411         PUT_ESCAPED (pfx + 2, "name", query->signal_name);
412         PUT_ESCAPED (pfx + 2, "return-type", g_type_name (return_type));
413         PUT_ESCAPED (pfx + 2, "object-type",
414             g_type_name (G_OBJECT_TYPE (element)));
415
416         PUT_START_TAG (pfx + 2, "params");
417         for (j = 0; j < n_params; j++) {
418           PUT_ESCAPED (pfx + 3, "type", g_type_name (param_types[j]));
419         }
420
421         PUT_END_TAG (pfx + 2, "params");
422
423         PUT_END_TAG (pfx + 1, "signal");
424
425         counted++;
426       }
427
428       g_free (query);
429     }
430     if (k == 0)
431       PUT_END_TAG (pfx, "element-signals");
432     else
433       PUT_END_TAG (pfx, "element-actions");
434   }
435 }
436
437 static gint
438 print_element_info (GstElementFactory * factory)
439 {
440   GstElement *element;
441 #ifndef GST_DISABLE_LOADSAVE
442   GstObjectClass *gstobject_class;
443 #endif
444   GstElementClass *gstelement_class;
445   GList *pads;
446   GstPad *pad;
447   GstStaticPadTemplate *padtemplate;
448   gint maxlevel = 0;
449
450   element = gst_element_factory_create (factory, "element");
451   if (!element) {
452     g_print ("couldn't construct element for some reason\n");
453     return -1;
454   }
455   PUT_START_TAG (0, "element");
456   PUT_ESCAPED (1, "name", GST_PLUGIN_FEATURE_NAME (factory));
457
458 #ifndef GST_DISABLE_LOADSAVE
459   gstobject_class = GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (element));
460 #endif
461   gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
462
463   PUT_START_TAG (1, "details");
464   PUT_ESCAPED (2, "long-name", factory->details.longname);
465   PUT_ESCAPED (2, "class", factory->details.klass);
466   PUT_ESCAPED (2, "description", factory->details.description);
467   PUT_ESCAPED (2, "authors", factory->details.author);
468   PUT_END_TAG (1, "details");
469
470   output_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
471
472   PUT_START_TAG (1, "pad-templates");
473   if (factory->numpadtemplates) {
474     pads = factory->staticpadtemplates;
475     while (pads) {
476       padtemplate = (GstStaticPadTemplate *) (pads->data);
477       pads = g_list_next (pads);
478
479       PUT_START_TAG (2, "pad-template");
480       PUT_ESCAPED (3, "name", padtemplate->name_template);
481
482       if (padtemplate->direction == GST_PAD_SRC)
483         PUT_ESCAPED (3, "direction", "src");
484       else if (padtemplate->direction == GST_PAD_SINK)
485         PUT_ESCAPED (3, "direction", "sink");
486       else
487         PUT_ESCAPED (3, "direction", "unknown");
488
489       if (padtemplate->presence == GST_PAD_ALWAYS)
490         PUT_ESCAPED (3, "presence", "always");
491       else if (padtemplate->presence == GST_PAD_SOMETIMES)
492         PUT_ESCAPED (3, "presence", "sometimes");
493       else if (padtemplate->presence == GST_PAD_REQUEST) {
494         PUT_ESCAPED (3, "presence", "request");
495         PUT_ESCAPED (3, "request-function",
496             GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
497       } else
498         PUT_ESCAPED (3, "presence", "unknown");
499
500       if (padtemplate->static_caps.string) {
501         print_caps (gst_static_caps_get (&padtemplate->static_caps), 3);
502       }
503       PUT_END_TAG (2, "pad-template");
504     }
505   }
506   PUT_END_TAG (1, "pad-templates");
507
508   PUT_START_TAG (1, "element-flags");
509   PUT_END_TAG (1, "element-flags");
510
511   if (GST_IS_BIN (element)) {
512     PUT_START_TAG (1, "bin-flags");
513
514     PUT_END_TAG (1, "bin-flags");
515   }
516
517
518   PUT_START_TAG (1, "element-implementation");
519
520   PUT_STRING (2, "<state-change function=\"%s\"/>",
521       GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
522
523 #ifndef GST_DISABLE_LOADSAVE
524   PUT_STRING (2, "<save function=\"%s\"/>",
525       GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
526   PUT_STRING (2, "<load function=\"%s\"/>",
527       GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
528 #endif
529   PUT_END_TAG (1, "element-implementation");
530
531   PUT_START_TAG (1, "clocking-interaction");
532   if (gst_element_requires_clock (element)) {
533     PUT_STRING (2, "<requires-clock/>");
534   }
535   if (gst_element_provides_clock (element)) {
536     GstClock *clock;
537
538     clock = gst_element_get_clock (element);
539     if (clock)
540       PUT_STRING (2, "<provides-clock name=\"%s\"/>", GST_OBJECT_NAME (clock));
541   }
542   PUT_END_TAG (1, "clocking-interaction");
543
544   if (gst_element_is_indexable (element)) {
545     PUT_STRING (1, "<indexing-capabilities/>");
546   }
547
548   PUT_START_TAG (1, "pads");
549   if (element->numpads) {
550     const GList *pads;
551
552     pads = element->pads;
553     while (pads) {
554       pad = GST_PAD (pads->data);
555       pads = g_list_next (pads);
556
557       PUT_START_TAG (2, "pad");
558       PUT_ESCAPED (3, "name", gst_pad_get_name (pad));
559
560       if (gst_pad_get_direction (pad) == GST_PAD_SRC)
561         PUT_ESCAPED (3, "direction", "src");
562       else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
563         PUT_ESCAPED (3, "direction", "sink");
564       else
565         PUT_ESCAPED (3, "direction", "unknown");
566
567       if (pad->padtemplate)
568         PUT_ESCAPED (3, "template", pad->padtemplate->name_template);
569
570       PUT_START_TAG (3, "implementation");
571       if (pad->chainfunc)
572         PUT_STRING (4, "<chain-based function=\"%s\"/>",
573             GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
574       if (pad->getrangefunc)
575         PUT_STRING (4, "<get-range-based function=\"%s\"/>",
576             GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
577       if (pad->eventfunc != gst_pad_event_default)
578         PUT_STRING (4, "<event-function function=\"%s\"/>",
579             GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
580       if (pad->queryfunc != gst_pad_query_default)
581         PUT_STRING (4, "<query-function function=\"%s\"/>",
582             GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
583       if (pad->querytypefunc != gst_pad_get_query_types_default) {
584         PUT_STRING (4, "<query-type-func function=\"%s\">",
585             GST_DEBUG_FUNCPTR_NAME (pad->querytypefunc));
586         print_query_types (gst_pad_get_query_types (pad), 5);
587         PUT_END_TAG (4, "query-type-func");
588       }
589
590       if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default)
591         PUT_STRING (4, "<iterintlink-function function=\"%s\"/>",
592             GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc));
593
594       if (pad->bufferallocfunc)
595         PUT_STRING (4, "<bufferalloc-function function=\"%s\"/>",
596             GST_DEBUG_FUNCPTR_NAME (pad->bufferallocfunc));
597       PUT_END_TAG (3, "implementation");
598
599       if (pad->caps) {
600         print_caps (pad->caps, 3);
601       }
602       PUT_END_TAG (2, "pad");
603     }
604   }
605   PUT_END_TAG (1, "pads");
606
607   print_element_properties (element, 1);
608   print_element_signals (element, 1);
609
610   /* for compound elements */
611   /* FIXME: gst_bin_get_list does not exist anymore
612      if (GST_IS_BIN (element)) {
613      GList *children;
614      GstElement *child;
615      PUT_START_TAG (1, "children");
616      children = (GList *) gst_bin_get_list (GST_BIN (element));
617      while (children) {
618      child = GST_ELEMENT (children->data);
619      children = g_list_next (children);
620
621      PUT_ESCAPED (2, "child", GST_ELEMENT_NAME (child));
622      }
623      PUT_END_TAG (1, "children");
624      }
625    */
626   PUT_END_TAG (0, "element");
627
628   return 0;
629 }
630
631 int
632 main (int argc, char *argv[])
633 {
634   GstElementFactory *factory;
635   GOptionEntry options[] = {
636     GST_TOOLS_GOPTION_VERSION,
637     {NULL}
638   };
639   GOptionContext *ctx;
640   GError *err = NULL;
641
642   setlocale (LC_ALL, "");
643
644 #if !GLIB_CHECK_VERSION (2, 31, 0)
645   g_thread_init (NULL);
646 #endif
647
648   gst_tools_set_prgname ("gst-xmlinspect");
649
650   ctx = g_option_context_new ("[ELEMENT-NAME]");
651   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
652   g_option_context_add_group (ctx, gst_init_get_option_group ());
653   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
654     g_print ("Error initializing: %s\n", err->message);
655     exit (1);
656   }
657   g_option_context_free (ctx);
658
659   gst_tools_print_version ("gst-xmlinspect");
660
661   /* if no arguments, print out all elements */
662   if (argc == 1) {
663     GList *features, *f;
664
665     features = gst_registry_get_feature_list (gst_registry_get_default (),
666         GST_TYPE_ELEMENT_FACTORY);
667
668     PUT_STRING (0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
669
670     for (f = features; f != NULL; f = f->next)
671       print_element_info (GST_ELEMENT_FACTORY (f->data));
672
673     gst_plugin_feature_list_free (features);
674     return 0;
675   }
676
677   /* else we try to get a factory */
678   factory = gst_element_factory_find (argv[1]);
679
680   /* if there's a factory, print out the info */
681   if (factory) {
682     PUT_STRING (0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
683     return print_element_info (factory);
684   }
685
686   /* otherwise, error out */
687   g_printerr ("no such element '%s'\n", argv[1]);
688   return -1;
689 }