|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #ifdef HAVE_CONFIG_H |
|
18 # include "config.h" |
|
19 #endif |
|
20 |
|
21 #include <string.h> |
|
22 #include <locale.h> |
|
23 #include <glib/gprintf.h> |
|
24 |
|
25 #include "tools.h" |
|
26 |
|
27 #define PUT_START_TAG(pfx,tag) \ |
|
28 G_STMT_START{ \ |
|
29 g_print ("%*.*s<%s>\n", pfx, pfx, "", tag); \ |
|
30 }G_STMT_END |
|
31 |
|
32 #define PUT_END_TAG(pfx,tag) \ |
|
33 G_STMT_START{ \ |
|
34 g_print ("%*.*s</%s>\n", pfx, pfx, "", tag); \ |
|
35 }G_STMT_END |
|
36 |
|
37 #define PUT_ESCAPED(pfx,tag,value) \ |
|
38 G_STMT_START{ \ |
|
39 const gchar *toconv = value; \ |
|
40 if (value) { \ |
|
41 gchar *v = g_markup_escape_text (toconv, strlen (toconv)); \ |
|
42 g_print ("%*.*s<%s>%s</%s>\n", pfx, pfx, "", tag, v, tag); \ |
|
43 g_free (v); \ |
|
44 } \ |
|
45 }G_STMT_END |
|
46 |
|
47 #ifdef G_HAVE_ISO_VARARGS |
|
48 |
|
49 #define PUT_STRING(pfx, ...) \ |
|
50 G_STMT_START{ \ |
|
51 gchar *ps_val = g_strdup_printf(__VA_ARGS__); \ |
|
52 g_print ("%*.*s%s\n", pfx, pfx, "", ps_val); \ |
|
53 g_free(ps_val); \ |
|
54 }G_STMT_END |
|
55 |
|
56 #elif defined(G_HAVE_GNUC_VARARGS) |
|
57 |
|
58 #define PUT_STRING(pfx, str, a...) \ |
|
59 G_STMT_START{ \ |
|
60 g_print ("%*.*s"str"\n", pfx, pfx, "" , ##a); \ |
|
61 }G_STMT_END |
|
62 |
|
63 #else |
|
64 |
|
65 static inline void |
|
66 PUT_STRING (int pfx, const char *format, ...) |
|
67 { |
|
68 va_list varargs; |
|
69 |
|
70 g_print ("%*.*s", pfx, pfx, ""); |
|
71 va_start (varargs, format); |
|
72 g_vprintf (format, varargs); |
|
73 va_end (varargs); |
|
74 g_print ("\n"); |
|
75 } |
|
76 |
|
77 #endif |
|
78 |
|
79 static void |
|
80 print_caps (const GstCaps * caps, gint pfx) |
|
81 { |
|
82 char *s; |
|
83 |
|
84 if (!caps) |
|
85 return; |
|
86 |
|
87 s = gst_caps_to_string (caps); |
|
88 PUT_ESCAPED (pfx, "caps", s); |
|
89 g_free (s); |
|
90 } |
|
91 |
|
92 #if 0 |
|
93 static void |
|
94 print_formats (const GstFormat * formats, gint pfx) |
|
95 { |
|
96 while (formats && *formats) { |
|
97 const GstFormatDefinition *definition; |
|
98 |
|
99 definition = gst_format_get_details (*formats); |
|
100 if (definition) |
|
101 PUT_STRING (pfx, "<format id=\"%d\" nick=\"%s\">%s</format>", |
|
102 *formats, definition->nick, definition->description); |
|
103 else |
|
104 PUT_STRING (pfx, "<format id=\"%d\">unknown</format>", *formats); |
|
105 |
|
106 formats++; |
|
107 } |
|
108 } |
|
109 #endif |
|
110 |
|
111 static void |
|
112 print_query_types (const GstQueryType * types, gint pfx) |
|
113 { |
|
114 while (types && *types) { |
|
115 const GstQueryTypeDefinition *definition; |
|
116 |
|
117 definition = gst_query_type_get_details (*types); |
|
118 if (definition) |
|
119 PUT_STRING (pfx, "<query-type id=\"%d\" nick=\"%s\">%s</query-type>", |
|
120 *types, definition->nick, definition->description); |
|
121 else |
|
122 PUT_STRING (pfx, "<query-type id=\"%d\">unknown</query-type>", *types); |
|
123 |
|
124 types++; |
|
125 } |
|
126 } |
|
127 |
|
128 #if 0 |
|
129 static void |
|
130 print_event_masks (const GstEventMask * masks, gint pfx) |
|
131 { |
|
132 #ifndef GST_DISABLE_ENUMTYPES |
|
133 GType event_type; |
|
134 GEnumClass *klass; |
|
135 GType event_flags; |
|
136 GFlagsClass *flags_class = NULL; |
|
137 |
|
138 event_type = gst_event_type_get_type (); |
|
139 klass = (GEnumClass *) g_type_class_ref (event_type); |
|
140 |
|
141 while (masks && masks->type) { |
|
142 GEnumValue *value; |
|
143 gint flags = 0, index = 0; |
|
144 |
|
145 switch (masks->type) { |
|
146 case GST_EVENT_SEEK: |
|
147 flags = masks->flags; |
|
148 event_flags = gst_seek_type_get_type (); |
|
149 flags_class = (GFlagsClass *) g_type_class_ref (event_flags); |
|
150 break; |
|
151 default: |
|
152 break; |
|
153 } |
|
154 |
|
155 value = g_enum_get_value (klass, masks->type); |
|
156 PUT_STRING (pfx, "<event type=\"%s\">", value->value_nick); |
|
157 |
|
158 while (flags) { |
|
159 GFlagsValue *value; |
|
160 |
|
161 if (flags & 1) { |
|
162 value = g_flags_get_first_value (flags_class, 1 << index); |
|
163 |
|
164 if (value) |
|
165 PUT_ESCAPED (pfx + 1, "flag", value->value_nick); |
|
166 else |
|
167 PUT_ESCAPED (pfx + 1, "flag", "?"); |
|
168 } |
|
169 flags >>= 1; |
|
170 index++; |
|
171 } |
|
172 PUT_END_TAG (pfx, "event"); |
|
173 |
|
174 masks++; |
|
175 } |
|
176 #endif |
|
177 } |
|
178 #endif |
|
179 |
|
180 static void |
|
181 output_hierarchy (GType type, gint level, gint * maxlevel) |
|
182 { |
|
183 GType parent; |
|
184 |
|
185 parent = g_type_parent (type); |
|
186 |
|
187 *maxlevel = *maxlevel + 1; |
|
188 level++; |
|
189 |
|
190 PUT_STRING (level, "<object name=\"%s\">", g_type_name (type)); |
|
191 |
|
192 if (parent) |
|
193 output_hierarchy (parent, level, maxlevel); |
|
194 |
|
195 PUT_END_TAG (level, "object"); |
|
196 } |
|
197 |
|
198 static void |
|
199 print_element_properties (GstElement * element, gint pfx) |
|
200 { |
|
201 GParamSpec **property_specs; |
|
202 guint num_properties; |
|
203 gint i; |
|
204 gboolean readable; |
|
205 |
|
206 property_specs = g_object_class_list_properties |
|
207 (G_OBJECT_GET_CLASS (element), &num_properties); |
|
208 |
|
209 PUT_START_TAG (pfx, "element-properties"); |
|
210 |
|
211 for (i = 0; i < num_properties; i++) { |
|
212 GValue value = { 0, }; |
|
213 GParamSpec *param = property_specs[i]; |
|
214 |
|
215 readable = FALSE; |
|
216 |
|
217 g_value_init (&value, param->value_type); |
|
218 if (param->flags & G_PARAM_READABLE) { |
|
219 g_object_get_property (G_OBJECT (element), param->name, &value); |
|
220 readable = TRUE; |
|
221 } |
|
222 PUT_START_TAG (pfx + 1, "element-property"); |
|
223 PUT_ESCAPED (pfx + 2, "name", g_param_spec_get_name (param)); |
|
224 PUT_ESCAPED (pfx + 2, "type", g_type_name (param->value_type)); |
|
225 PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (param)); |
|
226 PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (param)); |
|
227 if (readable) { |
|
228 PUT_ESCAPED (pfx + 2, "flags", "RW"); |
|
229 } else { |
|
230 PUT_ESCAPED (pfx + 2, "flags", "W"); |
|
231 } |
|
232 |
|
233 switch (G_VALUE_TYPE (&value)) { |
|
234 case G_TYPE_STRING: |
|
235 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
236 break; |
|
237 case G_TYPE_BOOLEAN: |
|
238 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
239 break; |
|
240 case G_TYPE_ULONG: |
|
241 { |
|
242 GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); |
|
243 |
|
244 PUT_STRING (pfx + 2, "<range min=\"%lu\" max=\"%lu\"/>", |
|
245 pulong->minimum, pulong->maximum); |
|
246 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
247 break; |
|
248 } |
|
249 case G_TYPE_LONG: |
|
250 { |
|
251 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); |
|
252 |
|
253 PUT_STRING (pfx + 2, "<range min=\"%ld\" max=\"%ld\"/>", |
|
254 plong->minimum, plong->maximum); |
|
255 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
256 break; |
|
257 } |
|
258 case G_TYPE_UINT: |
|
259 { |
|
260 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); |
|
261 |
|
262 PUT_STRING (pfx + 2, "<range min=\"%u\" max=\"%u\"/>", |
|
263 puint->minimum, puint->maximum); |
|
264 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
265 break; |
|
266 } |
|
267 case G_TYPE_INT: |
|
268 { |
|
269 GParamSpecInt *pint = G_PARAM_SPEC_INT (param); |
|
270 |
|
271 PUT_STRING (pfx + 2, "<range min=\"%d\" max=\"%d\"/>", |
|
272 pint->minimum, pint->maximum); |
|
273 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
274 break; |
|
275 } |
|
276 case G_TYPE_UINT64: |
|
277 { |
|
278 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); |
|
279 |
|
280 PUT_STRING (pfx + 2, |
|
281 "<range min=\"%" G_GUINT64_FORMAT "\" max=\"%" G_GUINT64_FORMAT |
|
282 "\"/>", puint64->minimum, puint64->maximum); |
|
283 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
284 break; |
|
285 } |
|
286 case G_TYPE_INT64: |
|
287 { |
|
288 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); |
|
289 |
|
290 PUT_STRING (pfx + 2, |
|
291 "<range min=\"%" G_GINT64_FORMAT "\" max=\"%" G_GINT64_FORMAT |
|
292 "\"/>", pint64->minimum, pint64->maximum); |
|
293 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
294 break; |
|
295 } |
|
296 case G_TYPE_FLOAT: |
|
297 { |
|
298 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param); |
|
299 |
|
300 PUT_STRING (pfx + 2, "<range min=\"%f\" max=\"%f\"/>", |
|
301 pfloat->minimum, pfloat->maximum); |
|
302 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
303 break; |
|
304 } |
|
305 case G_TYPE_DOUBLE: |
|
306 { |
|
307 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param); |
|
308 |
|
309 PUT_STRING (pfx + 2, "<range min=\"%g\" max=\"%g\"/>", |
|
310 pdouble->minimum, pdouble->maximum); |
|
311 PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); |
|
312 break; |
|
313 } |
|
314 default: |
|
315 if (param->value_type == GST_TYPE_CAPS) { |
|
316 GstCaps *caps = g_value_peek_pointer (&value); |
|
317 |
|
318 if (!caps) |
|
319 PUT_ESCAPED (pfx + 2, "default", "NULL"); |
|
320 else { |
|
321 print_caps (caps, 2); |
|
322 } |
|
323 } else if (G_IS_PARAM_SPEC_ENUM (param)) { |
|
324 GEnumValue *values; |
|
325 guint j = 0; |
|
326 gint enum_value; |
|
327 |
|
328 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; |
|
329 enum_value = g_value_get_enum (&value); |
|
330 |
|
331 while (values[j].value_name) { |
|
332 if (values[j].value == enum_value) |
|
333 break; |
|
334 j++; |
|
335 } |
|
336 PUT_STRING (pfx + 2, "<default>%d</default>", values[j].value); |
|
337 |
|
338 PUT_START_TAG (pfx + 2, "enum-values"); |
|
339 j = 0; |
|
340 while (values[j].value_name) { |
|
341 PUT_STRING (pfx + 3, "<value value=\"%d\" nick=\"%s\"/>", |
|
342 values[j].value, values[j].value_nick); |
|
343 j++; |
|
344 } |
|
345 PUT_END_TAG (pfx + 2, "enum-values"); |
|
346 } else if (G_IS_PARAM_SPEC_FLAGS (param)) { |
|
347 GFlagsValue *values; |
|
348 guint j = 0; |
|
349 gint flags_value; |
|
350 |
|
351 values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values; |
|
352 flags_value = g_value_get_flags (&value); |
|
353 |
|
354 PUT_STRING (pfx + 2, "<default>%d</default>", flags_value); |
|
355 |
|
356 PUT_START_TAG (pfx + 2, "flags"); |
|
357 j = 0; |
|
358 while (values[j].value_name) { |
|
359 PUT_STRING (pfx + 3, "<flag value=\"%d\" nick=\"%s\"/>", |
|
360 values[j].value, values[j].value_nick); |
|
361 j++; |
|
362 } |
|
363 PUT_END_TAG (pfx + 2, "flags"); |
|
364 } else if (G_IS_PARAM_SPEC_OBJECT (param)) { |
|
365 PUT_ESCAPED (pfx + 2, "object-type", g_type_name (param->value_type)); |
|
366 } |
|
367 break; |
|
368 } |
|
369 |
|
370 PUT_END_TAG (pfx + 1, "element-property"); |
|
371 } |
|
372 PUT_END_TAG (pfx, "element-properties"); |
|
373 g_free (property_specs); |
|
374 } |
|
375 |
|
376 static void |
|
377 print_element_signals (GstElement * element, gint pfx) |
|
378 { |
|
379 guint *signals; |
|
380 guint nsignals; |
|
381 gint i, k; |
|
382 GSignalQuery *query; |
|
383 |
|
384 signals = g_signal_list_ids (G_OBJECT_TYPE (element), &nsignals); |
|
385 for (k = 0; k < 2; k++) { |
|
386 gint counted = 0; |
|
387 |
|
388 if (k == 0) |
|
389 PUT_START_TAG (pfx, "element-signals"); |
|
390 else |
|
391 PUT_START_TAG (pfx, "element-actions"); |
|
392 |
|
393 for (i = 0; i < nsignals; i++) { |
|
394 gint n_params; |
|
395 GType return_type; |
|
396 const GType *param_types; |
|
397 gint j; |
|
398 |
|
399 query = g_new0 (GSignalQuery, 1); |
|
400 g_signal_query (signals[i], query); |
|
401 |
|
402 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) || |
|
403 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) { |
|
404 n_params = query->n_params; |
|
405 return_type = query->return_type; |
|
406 param_types = query->param_types; |
|
407 |
|
408 PUT_START_TAG (pfx + 1, "signal"); |
|
409 PUT_ESCAPED (pfx + 2, "name", query->signal_name); |
|
410 PUT_ESCAPED (pfx + 2, "return-type", g_type_name (return_type)); |
|
411 PUT_ESCAPED (pfx + 2, "object-type", |
|
412 g_type_name (G_OBJECT_TYPE (element))); |
|
413 |
|
414 PUT_START_TAG (pfx + 2, "params"); |
|
415 for (j = 0; j < n_params; j++) { |
|
416 PUT_ESCAPED (pfx + 3, "type", g_type_name (param_types[j])); |
|
417 } |
|
418 |
|
419 PUT_END_TAG (pfx + 2, "params"); |
|
420 |
|
421 PUT_END_TAG (pfx + 1, "signal"); |
|
422 |
|
423 counted++; |
|
424 } |
|
425 |
|
426 g_free (query); |
|
427 } |
|
428 if (k == 0) |
|
429 PUT_END_TAG (pfx, "element-signals"); |
|
430 else |
|
431 PUT_END_TAG (pfx, "element-actions"); |
|
432 } |
|
433 } |
|
434 |
|
435 static gint |
|
436 print_element_info (GstElementFactory * factory) |
|
437 { |
|
438 GstElement *element; |
|
439 GstObjectClass *gstobject_class; |
|
440 GstElementClass *gstelement_class; |
|
441 GList *pads; |
|
442 GstPad *pad; |
|
443 GstStaticPadTemplate *padtemplate; |
|
444 gint maxlevel = 0; |
|
445 |
|
446 element = gst_element_factory_create (factory, "element"); |
|
447 if (!element) { |
|
448 g_print ("couldn't construct element for some reason\n"); |
|
449 return -1; |
|
450 } |
|
451 PUT_START_TAG (0, "element"); |
|
452 PUT_ESCAPED (1, "name", GST_PLUGIN_FEATURE_NAME (factory)); |
|
453 |
|
454 gstobject_class = GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (element)); |
|
455 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element)); |
|
456 |
|
457 PUT_START_TAG (1, "details"); |
|
458 PUT_ESCAPED (2, "long-name", factory->details.longname); |
|
459 PUT_ESCAPED (2, "class", factory->details.klass); |
|
460 PUT_ESCAPED (2, "description", factory->details.description); |
|
461 PUT_ESCAPED (2, "authors", factory->details.author); |
|
462 PUT_END_TAG (1, "details"); |
|
463 |
|
464 output_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel); |
|
465 |
|
466 PUT_START_TAG (1, "pad-templates"); |
|
467 if (factory->numpadtemplates) { |
|
468 pads = factory->staticpadtemplates; |
|
469 while (pads) { |
|
470 padtemplate = (GstStaticPadTemplate *) (pads->data); |
|
471 pads = g_list_next (pads); |
|
472 |
|
473 PUT_START_TAG (2, "pad-template"); |
|
474 PUT_ESCAPED (3, "name", padtemplate->name_template); |
|
475 |
|
476 if (padtemplate->direction == GST_PAD_SRC) |
|
477 PUT_ESCAPED (3, "direction", "src"); |
|
478 else if (padtemplate->direction == GST_PAD_SINK) |
|
479 PUT_ESCAPED (3, "direction", "sink"); |
|
480 else |
|
481 PUT_ESCAPED (3, "direction", "unknown"); |
|
482 |
|
483 if (padtemplate->presence == GST_PAD_ALWAYS) |
|
484 PUT_ESCAPED (3, "presence", "always"); |
|
485 else if (padtemplate->presence == GST_PAD_SOMETIMES) |
|
486 PUT_ESCAPED (3, "presence", "sometimes"); |
|
487 else if (padtemplate->presence == GST_PAD_REQUEST) { |
|
488 PUT_ESCAPED (3, "presence", "request"); |
|
489 PUT_ESCAPED (3, "request-function", |
|
490 GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad)); |
|
491 } else |
|
492 PUT_ESCAPED (3, "presence", "unknown"); |
|
493 |
|
494 if (padtemplate->static_caps.string) { |
|
495 print_caps (gst_static_caps_get (&padtemplate->static_caps), 3); |
|
496 } |
|
497 PUT_END_TAG (2, "pad-template"); |
|
498 } |
|
499 } |
|
500 PUT_END_TAG (1, "pad-templates"); |
|
501 |
|
502 PUT_START_TAG (1, "element-flags"); |
|
503 PUT_END_TAG (1, "element-flags"); |
|
504 |
|
505 if (GST_IS_BIN (element)) { |
|
506 PUT_START_TAG (1, "bin-flags"); |
|
507 |
|
508 PUT_END_TAG (1, "bin-flags"); |
|
509 } |
|
510 |
|
511 |
|
512 PUT_START_TAG (1, "element-implementation"); |
|
513 |
|
514 PUT_STRING (2, "<state-change function=\"%s\"/>", |
|
515 GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state)); |
|
516 |
|
517 #ifndef GST_DISABLE_LOADSAVE |
|
518 PUT_STRING (2, "<save function=\"%s\"/>", |
|
519 GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself)); |
|
520 PUT_STRING (2, "<load function=\"%s\"/>", |
|
521 GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself)); |
|
522 #endif |
|
523 PUT_END_TAG (1, "element-implementation"); |
|
524 |
|
525 PUT_START_TAG (1, "clocking-interaction"); |
|
526 if (gst_element_requires_clock (element)) { |
|
527 PUT_STRING (2, "<requires-clock/>"); |
|
528 } |
|
529 if (gst_element_provides_clock (element)) { |
|
530 GstClock *clock; |
|
531 |
|
532 clock = gst_element_get_clock (element); |
|
533 if (clock) |
|
534 PUT_STRING (2, "<provides-clock name=\"%s\"/>", GST_OBJECT_NAME (clock)); |
|
535 } |
|
536 PUT_END_TAG (1, "clocking-interaction"); |
|
537 |
|
538 #ifndef GST_DISABLE_INDEX |
|
539 if (gst_element_is_indexable (element)) { |
|
540 PUT_STRING (1, "<indexing-capabilities/>"); |
|
541 } |
|
542 #endif |
|
543 |
|
544 PUT_START_TAG (1, "pads"); |
|
545 if (element->numpads) { |
|
546 const GList *pads; |
|
547 |
|
548 pads = element->pads; |
|
549 while (pads) { |
|
550 pad = GST_PAD (pads->data); |
|
551 pads = g_list_next (pads); |
|
552 |
|
553 PUT_START_TAG (2, "pad"); |
|
554 PUT_ESCAPED (3, "name", gst_pad_get_name (pad)); |
|
555 |
|
556 if (gst_pad_get_direction (pad) == GST_PAD_SRC) |
|
557 PUT_ESCAPED (3, "direction", "src"); |
|
558 else if (gst_pad_get_direction (pad) == GST_PAD_SINK) |
|
559 PUT_ESCAPED (3, "direction", "sink"); |
|
560 else |
|
561 PUT_ESCAPED (3, "direction", "unknown"); |
|
562 |
|
563 if (pad->padtemplate) |
|
564 PUT_ESCAPED (3, "template", pad->padtemplate->name_template); |
|
565 |
|
566 PUT_START_TAG (3, "implementation"); |
|
567 if (pad->chainfunc) |
|
568 PUT_STRING (4, "<chain-based function=\"%s\"/>", |
|
569 GST_DEBUG_FUNCPTR_NAME (pad->chainfunc)); |
|
570 if (pad->getrangefunc) |
|
571 PUT_STRING (4, "<get-range-based function=\"%s\"/>", |
|
572 GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc)); |
|
573 if (pad->eventfunc != gst_pad_event_default) |
|
574 PUT_STRING (4, "<event-function function=\"%s\"/>", |
|
575 GST_DEBUG_FUNCPTR_NAME (pad->eventfunc)); |
|
576 if (pad->queryfunc != gst_pad_query_default) |
|
577 PUT_STRING (4, "<query-function function=\"%s\"/>", |
|
578 GST_DEBUG_FUNCPTR_NAME (pad->queryfunc)); |
|
579 if (pad->querytypefunc != gst_pad_get_query_types_default) { |
|
580 PUT_STRING (4, "<query-type-func function=\"%s\">", |
|
581 GST_DEBUG_FUNCPTR_NAME (pad->querytypefunc)); |
|
582 print_query_types (gst_pad_get_query_types (pad), 5); |
|
583 PUT_END_TAG (4, "query-type-func"); |
|
584 } |
|
585 |
|
586 if (pad->intlinkfunc != gst_pad_get_internal_links_default) |
|
587 PUT_STRING (4, "<intlink-function function=\"%s\"/>", |
|
588 GST_DEBUG_FUNCPTR_NAME (pad->intlinkfunc)); |
|
589 |
|
590 if (pad->bufferallocfunc) |
|
591 PUT_STRING (4, "<bufferalloc-function function=\"%s\"/>", |
|
592 GST_DEBUG_FUNCPTR_NAME (pad->bufferallocfunc)); |
|
593 PUT_END_TAG (3, "implementation"); |
|
594 |
|
595 if (pad->caps) { |
|
596 print_caps (pad->caps, 3); |
|
597 } |
|
598 PUT_END_TAG (2, "pad"); |
|
599 } |
|
600 } |
|
601 PUT_END_TAG (1, "pads"); |
|
602 |
|
603 print_element_properties (element, 1); |
|
604 print_element_signals (element, 1); |
|
605 |
|
606 /* for compound elements */ |
|
607 /* FIXME: gst_bin_get_list does not exist anymore |
|
608 if (GST_IS_BIN (element)) { |
|
609 GList *children; |
|
610 GstElement *child; |
|
611 PUT_START_TAG (1, "children"); |
|
612 children = (GList *) gst_bin_get_list (GST_BIN (element)); |
|
613 while (children) { |
|
614 child = GST_ELEMENT (children->data); |
|
615 children = g_list_next (children); |
|
616 |
|
617 PUT_ESCAPED (2, "child", GST_ELEMENT_NAME (child)); |
|
618 } |
|
619 PUT_END_TAG (1, "children"); |
|
620 } |
|
621 */ |
|
622 PUT_END_TAG (0, "element"); |
|
623 |
|
624 return 0; |
|
625 } |
|
626 |
|
627 static void |
|
628 print_element_list (void) |
|
629 { |
|
630 GList *plugins; |
|
631 |
|
632 plugins = gst_default_registry_get_plugin_list (); |
|
633 while (plugins) { |
|
634 GList *features; |
|
635 GstPlugin *plugin; |
|
636 |
|
637 plugin = (GstPlugin *) (plugins->data); |
|
638 plugins = g_list_next (plugins); |
|
639 |
|
640 features = |
|
641 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (), |
|
642 plugin->desc.name); |
|
643 while (features) { |
|
644 GstPluginFeature *feature; |
|
645 |
|
646 feature = GST_PLUGIN_FEATURE (features->data); |
|
647 |
|
648 if (GST_IS_ELEMENT_FACTORY (feature)) { |
|
649 GstElementFactory *factory; |
|
650 |
|
651 factory = GST_ELEMENT_FACTORY (feature); |
|
652 g_print ("%s: %s: %s\n", plugin->desc.name, |
|
653 GST_PLUGIN_FEATURE_NAME (factory), |
|
654 gst_element_factory_get_longname (factory)); |
|
655 } |
|
656 #ifndef GST_DISABLE_INDEX |
|
657 else if (GST_IS_INDEX_FACTORY (feature)) { |
|
658 GstIndexFactory *factory; |
|
659 |
|
660 factory = GST_INDEX_FACTORY (feature); |
|
661 g_print ("%s: %s: %s\n", plugin->desc.name, |
|
662 GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); |
|
663 } |
|
664 #endif |
|
665 else if (GST_IS_TYPE_FIND_FACTORY (feature)) { |
|
666 GstTypeFindFactory *factory; |
|
667 |
|
668 factory = GST_TYPE_FIND_FACTORY (feature); |
|
669 if (factory->extensions) { |
|
670 guint i = 0; |
|
671 |
|
672 g_print ("%s type: ", plugin->desc.name); |
|
673 while (factory->extensions[i]) { |
|
674 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); |
|
675 i++; |
|
676 } |
|
677 } else |
|
678 g_print ("%s type: N/A\n", plugin->desc.name); |
|
679 } else { |
|
680 g_print ("%s: %s (%s)\n", plugin->desc.name, |
|
681 GST_PLUGIN_FEATURE_NAME (feature), |
|
682 g_type_name (G_OBJECT_TYPE (feature))); |
|
683 } |
|
684 |
|
685 features = g_list_next (features); |
|
686 } |
|
687 } |
|
688 } |
|
689 |
|
690 static void |
|
691 print_plugin_info (GstPlugin * plugin) |
|
692 { |
|
693 GList *features; |
|
694 gint num_features = 0; |
|
695 gint num_elements = 0; |
|
696 gint num_autoplug = 0; |
|
697 gint num_types = 0; |
|
698 gint num_indexes = 0; |
|
699 gint num_other = 0; |
|
700 |
|
701 g_print ("Plugin Details:\n"); |
|
702 g_print (" Name:\t\t%s\n", plugin->desc.name); |
|
703 g_print (" Description:\t%s\n", plugin->desc.description); |
|
704 g_print (" Filename:\t%s\n", plugin->filename); |
|
705 g_print (" Version:\t%s\n", plugin->desc.version); |
|
706 g_print (" License:\t%s\n", plugin->desc.license); |
|
707 g_print (" Package:\t%s\n", plugin->desc.package); |
|
708 g_print (" Origin URL:\t%s\n", plugin->desc.origin); |
|
709 g_print ("\n"); |
|
710 |
|
711 features = |
|
712 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (), |
|
713 plugin->desc.name); |
|
714 |
|
715 while (features) { |
|
716 GstPluginFeature *feature; |
|
717 |
|
718 feature = GST_PLUGIN_FEATURE (features->data); |
|
719 |
|
720 if (GST_IS_ELEMENT_FACTORY (feature)) { |
|
721 GstElementFactory *factory; |
|
722 |
|
723 factory = GST_ELEMENT_FACTORY (feature); |
|
724 g_print (" %s: %s\n", GST_OBJECT_NAME (factory), |
|
725 gst_element_factory_get_longname (factory)); |
|
726 num_elements++; |
|
727 } |
|
728 #ifndef GST_DISABLE_INDEX |
|
729 else if (GST_IS_INDEX_FACTORY (feature)) { |
|
730 GstIndexFactory *factory; |
|
731 |
|
732 factory = GST_INDEX_FACTORY (feature); |
|
733 g_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc); |
|
734 num_indexes++; |
|
735 } |
|
736 #endif |
|
737 else if (GST_IS_TYPE_FIND_FACTORY (feature)) { |
|
738 GstTypeFindFactory *factory; |
|
739 |
|
740 factory = GST_TYPE_FIND_FACTORY (feature); |
|
741 if (factory->extensions) { |
|
742 guint i = 0; |
|
743 |
|
744 g_print ("%s type: ", plugin->desc.name); |
|
745 while (factory->extensions[i]) { |
|
746 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); |
|
747 i++; |
|
748 } |
|
749 } else |
|
750 g_print ("%s type: N/A\n", plugin->desc.name); |
|
751 num_types++; |
|
752 } else { |
|
753 g_print (" %s (%s)\n", GST_OBJECT_NAME (feature), |
|
754 g_type_name (G_OBJECT_TYPE (feature))); |
|
755 num_other++; |
|
756 } |
|
757 num_features++; |
|
758 features = g_list_next (features); |
|
759 } |
|
760 g_print ("\n %d features:\n", num_features); |
|
761 if (num_elements > 0) |
|
762 g_print (" +-- %d elements\n", num_elements); |
|
763 if (num_autoplug > 0) |
|
764 g_print (" +-- %d autopluggers\n", num_autoplug); |
|
765 if (num_types > 0) |
|
766 g_print (" +-- %d types\n", num_types); |
|
767 if (num_indexes > 0) |
|
768 g_print (" +-- %d indexes\n", num_indexes); |
|
769 if (num_other > 0) |
|
770 g_print (" +-- %d other objects\n", num_other); |
|
771 |
|
772 g_print ("\n"); |
|
773 } |
|
774 |
|
775 |
|
776 int |
|
777 main (int argc, char *argv[]) |
|
778 { |
|
779 GstElementFactory *factory; |
|
780 GstPlugin *plugin; |
|
781 gchar *so; |
|
782 GOptionEntry options[] = { |
|
783 {"gst-inspect-plugin", 'p', 0, G_OPTION_ARG_STRING, |
|
784 "Show plugin details", NULL}, |
|
785 {"gst-inspect-scheduler", 's', 0, G_OPTION_ARG_STRING, |
|
786 "Show scheduler details", NULL}, |
|
787 GST_TOOLS_GOPTION_VERSION, |
|
788 {NULL} |
|
789 }; |
|
790 GOptionContext *ctx; |
|
791 GError *err = NULL; |
|
792 |
|
793 setlocale (LC_ALL, ""); |
|
794 |
|
795 if (!g_thread_supported ()) |
|
796 g_thread_init (NULL); |
|
797 |
|
798 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]"); |
|
799 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); |
|
800 g_option_context_add_group (ctx, gst_init_get_option_group ()); |
|
801 if (!g_option_context_parse (ctx, &argc, &argv, &err)) { |
|
802 g_print ("Error initializing: %s\n", err->message); |
|
803 exit (1); |
|
804 } |
|
805 g_option_context_free (ctx); |
|
806 |
|
807 gst_tools_print_version ("gst-xmlinspect"); |
|
808 |
|
809 PUT_STRING (0, "<?xml version=\"1.0\"?>"); |
|
810 |
|
811 /* if no arguments, print out list of elements */ |
|
812 if (argc == 1) { |
|
813 print_element_list (); |
|
814 |
|
815 /* else we try to get a factory */ |
|
816 } else { |
|
817 /* first check for help */ |
|
818 if (strstr (argv[1], "-help")) { |
|
819 g_print ("Usage: %s\t\t\tList all registered elements\n", argv[0]); |
|
820 g_print (" %s element-name\tShow element details\n", argv[0]); |
|
821 g_print (" %s plugin-name[.so]\tShow information about plugin\n", |
|
822 argv[0]); |
|
823 return 0; |
|
824 } |
|
825 |
|
826 /* only search for a factory if there's not a '.so' */ |
|
827 if (!strstr (argv[1], ".so")) { |
|
828 factory = gst_element_factory_find (argv[1]); |
|
829 |
|
830 /* if there's a factory, print out the info */ |
|
831 if (factory) |
|
832 return print_element_info (factory); |
|
833 else { |
|
834 GstPluginFeature *feature; |
|
835 |
|
836 /* FIXME implement other pretty print function for these */ |
|
837 #ifndef GST_DISABLE_INDEX |
|
838 feature = gst_default_registry_find_feature (argv[1], |
|
839 GST_TYPE_INDEX_FACTORY); |
|
840 if (feature) { |
|
841 g_print ("%s: an index\n", argv[1]); |
|
842 return 0; |
|
843 } |
|
844 #endif |
|
845 feature = gst_default_registry_find_feature (argv[1], |
|
846 GST_TYPE_TYPE_FIND_FACTORY); |
|
847 if (feature) { |
|
848 g_print ("%s: a type find function\n", argv[1]); |
|
849 return 0; |
|
850 } |
|
851 } |
|
852 } else { |
|
853 /* strip the .so */ |
|
854 so = strstr (argv[1], ".so"); |
|
855 so[0] = '\0'; |
|
856 } |
|
857 |
|
858 /* otherwise assume it's a plugin */ |
|
859 plugin = gst_default_registry_find_plugin (argv[1]); |
|
860 |
|
861 /* if there is such a plugin, print out info */ |
|
862 |
|
863 if (plugin) { |
|
864 print_plugin_info (plugin); |
|
865 } else { |
|
866 g_print ("no such element or plugin '%s'\n", argv[1]); |
|
867 return -1; |
|
868 } |
|
869 } |
|
870 |
|
871 return 0; |
|
872 } |