2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2004 Thomas Vander Stichele <thomas@apestaart.org>
6 * gst-inspect.c: tool to inspect the GStreamer registry
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 #include <gst/controller/gstcontroller.h>
34 #include <glib/gprintf.h>
36 static char *_name = NULL;
38 static int print_element_info (GstElementFactory * factory,
39 gboolean print_names);
42 n_print (const char *format, ...)
47 g_print ("%s", _name);
49 va_start (args, format);
50 g_vprintf (format, args);
55 print_field (GQuark field, const GValue * value, gpointer pfx)
57 gchar *str = gst_value_serialize (value);
59 n_print ("%s %15s: %s\n", (gchar *) pfx, g_quark_to_string (field), str);
65 print_caps (const GstCaps * caps, const gchar * pfx)
69 g_return_if_fail (caps != NULL);
71 if (gst_caps_is_any (caps)) {
72 n_print ("%sANY\n", pfx);
75 if (gst_caps_is_empty (caps)) {
76 n_print ("%sEMPTY\n", pfx);
80 for (i = 0; i < gst_caps_get_size (caps); i++) {
81 GstStructure *structure = gst_caps_get_structure (caps, i);
83 n_print ("%s%s\n", pfx, gst_structure_get_name (structure));
84 gst_structure_foreach (structure, print_field, (gpointer) pfx);
90 print_formats (const GstFormat * formats)
92 while (formats && *formats) {
93 const GstFormatDefinition *definition;
95 definition = gst_format_get_details (*formats);
97 n_print ("\t\t(%d):\t%s (%s)\n", *formats,
98 definition->nick, definition->description);
100 n_print ("\t\t(%d):\tUnknown format\n", *formats);
108 print_query_types (const GstQueryType * types)
110 while (types && *types) {
111 const GstQueryTypeDefinition *definition;
113 definition = gst_query_type_get_details (*types);
115 n_print ("\t\t(%d):\t%s (%s)\n", *types,
116 definition->nick, definition->description);
118 n_print ("\t\t(%d):\tUnknown query format\n", *types);
126 print_event_masks (const GstEventMask * masks)
131 GFlagsClass *flags_class = NULL;
133 event_type = gst_event_type_get_type ();
134 klass = (GEnumClass *) g_type_class_ref (event_type);
136 while (masks && masks->type) {
138 gint flags = 0, index = 0;
140 switch (masks->type) {
142 flags = masks->flags;
143 event_flags = gst_seek_type_get_type ();
144 flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
150 value = g_enum_get_value (klass, masks->type);
151 g_print ("\t\t%s ", value->value_nick);
157 value = g_flags_get_first_value (flags_class, 1 << index);
160 g_print ("| %s ", value->value_nick);
175 get_rank_name (char *s, gint rank)
177 static const int ranks[4] = {
178 GST_RANK_NONE, GST_RANK_MARGINAL, GST_RANK_SECONDARY, GST_RANK_PRIMARY
180 static const char *rank_names[4] = { "none", "marginal", "secondary",
187 for (i = 0; i < 4; i++) {
188 if (rank == ranks[i])
189 return rank_names[i];
190 if (abs (rank - ranks[i]) < abs (rank - ranks[best_i])) {
195 sprintf (s, "%s %c %d", rank_names[best_i],
196 (rank - ranks[best_i] > 0) ? '+' : '-', abs (ranks[best_i] - rank));
202 print_factory_details_meta_data (GQuark field_id, const GValue * value,
205 gchar *val = g_strdup_value_contents (value);
206 gchar *key = g_strdup (g_quark_to_string (field_id));
208 key[0] = g_ascii_toupper (key[0]);
209 n_print (" %s:\t\t%s\n", key, val);
216 print_factory_details_info (GstElementFactory * factory)
220 n_print ("Factory Details:\n");
221 n_print (" Long name:\t%s\n", factory->details.longname);
222 n_print (" Class:\t%s\n", factory->details.klass);
223 n_print (" Description:\t%s\n", factory->details.description);
224 n_print (" Author(s):\t%s\n", factory->details.author);
225 n_print (" Rank:\t\t%s (%d)\n",
226 get_rank_name (s, GST_PLUGIN_FEATURE (factory)->rank),
227 GST_PLUGIN_FEATURE (factory)->rank);
228 if (factory->meta_data != NULL) {
229 gst_structure_foreach ((GstStructure *) factory->meta_data,
230 print_factory_details_meta_data, NULL);
236 print_hierarchy (GType type, gint level, gint * maxlevel)
241 parent = g_type_parent (type);
243 *maxlevel = *maxlevel + 1;
247 print_hierarchy (parent, level, maxlevel);
250 g_print ("%s", _name);
252 for (i = 1; i < *maxlevel - level; i++)
254 if (*maxlevel - level)
257 g_print ("%s\n", g_type_name (type));
264 print_interfaces (GType type)
267 GType *iface, *ifaces = g_type_interfaces (type, &n_ifaces);
272 g_print ("%s", _name);
273 g_print (_("Implemented Interfaces:\n"));
277 g_print ("%s", _name);
278 g_print (" %s\n", g_type_name (*iface));
282 g_print ("%s", _name);
290 flags_to_string (GFlagsValue * vals, guint flags)
295 /* first look for an exact match and count the number of values */
296 for (i = 0; vals[i].value_name != NULL; ++i) {
297 if (vals[i].value == flags)
298 return g_strdup (vals[i].value_nick);
301 s = g_string_new (NULL);
303 /* we assume the values are sorted from lowest to highest value */
307 if (vals[i].value != 0 && (flags_left & vals[i].value) == vals[i].value) {
309 g_string_append_c (s, '+');
310 g_string_append (s, vals[i].value_nick);
311 flags_left -= vals[i].value;
318 g_string_assign (s, "(none)");
320 return g_string_free (s, FALSE);
323 #define KNOWN_PARAM_FLAGS \
324 (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY | \
325 G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS | \
326 G_PARAM_READABLE | G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE | \
327 GST_PARAM_MUTABLE_PLAYING | GST_PARAM_MUTABLE_PAUSED | \
328 GST_PARAM_MUTABLE_READY)
331 print_element_properties_info (GstElement * element)
333 GParamSpec **property_specs;
334 guint num_properties, i;
338 property_specs = g_object_class_list_properties
339 (G_OBJECT_GET_CLASS (element), &num_properties);
341 n_print ("Element Properties:\n");
343 for (i = 0; i < num_properties; i++) {
344 GValue value = { 0, };
345 GParamSpec *param = property_specs[i];
349 g_value_init (&value, param->value_type);
351 n_print (" %-20s: %s\n", g_param_spec_get_name (param),
352 g_param_spec_get_blurb (param));
355 n_print ("%-23.23s flags: ", "");
356 if (param->flags & G_PARAM_READABLE) {
357 g_object_get_property (G_OBJECT (element), param->name, &value);
359 g_print ("%s%s", (first_flag) ? "" : ", ", _("readable"));
362 /* if we can't read the property value, assume it's set to the default
363 * (which might not be entirely true for sub-classes, but that's an
364 * unlikely corner-case anyway) */
365 g_param_value_set_default (param, &value);
367 if (param->flags & G_PARAM_WRITABLE) {
368 g_print ("%s%s", (first_flag) ? "" : ", ", _("writable"));
371 if (param->flags & GST_PARAM_CONTROLLABLE) {
372 g_print (", %s", _("controllable"));
375 if (param->flags & GST_PARAM_MUTABLE_PLAYING) {
376 g_print (", %s", _("changeable in NULL, READY, PAUSED or PLAYING state"));
377 } else if (param->flags & GST_PARAM_MUTABLE_PAUSED) {
378 g_print (", %s", _("changeable only in NULL, READY or PAUSED state"));
379 } else if (param->flags & GST_PARAM_MUTABLE_READY) {
380 g_print (", %s", _("changeable only in NULL or READY state"));
382 if (param->flags & ~KNOWN_PARAM_FLAGS) {
383 g_print ("%s0x%0x", (first_flag) ? "" : ", ",
384 param->flags & ~KNOWN_PARAM_FLAGS);
388 switch (G_VALUE_TYPE (&value)) {
391 const char *string_val = g_value_get_string (&value);
393 n_print ("%-23.23s String. ", "");
395 if (string_val == NULL)
396 g_print ("Default: null");
398 g_print ("Default: \"%s\"", string_val);
403 gboolean bool_val = g_value_get_boolean (&value);
405 n_print ("%-23.23s Boolean. ", "");
407 g_print ("Default: %s", bool_val ? "true" : "false");
412 GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
414 n_print ("%-23.23s Unsigned Long. ", "");
415 g_print ("Range: %lu - %lu Default: %lu ",
416 pulong->minimum, pulong->maximum, g_value_get_ulong (&value));
421 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
423 n_print ("%-23.23s Long. ", "");
424 g_print ("Range: %ld - %ld Default: %ld ",
425 plong->minimum, plong->maximum, g_value_get_long (&value));
430 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
432 n_print ("%-23.23s Unsigned Integer. ", "");
433 g_print ("Range: %u - %u Default: %u ",
434 puint->minimum, puint->maximum, g_value_get_uint (&value));
439 GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
441 n_print ("%-23.23s Integer. ", "");
442 g_print ("Range: %d - %d Default: %d ",
443 pint->minimum, pint->maximum, g_value_get_int (&value));
448 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
450 n_print ("%-23.23s Unsigned Integer64. ", "");
451 g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
452 " Default: %" G_GUINT64_FORMAT " ",
453 puint64->minimum, puint64->maximum, g_value_get_uint64 (&value));
458 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
460 n_print ("%-23.23s Integer64. ", "");
461 g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
462 " Default: %" G_GINT64_FORMAT " ",
463 pint64->minimum, pint64->maximum, g_value_get_int64 (&value));
468 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
470 n_print ("%-23.23s Float. ", "");
471 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
472 pfloat->minimum, pfloat->maximum, g_value_get_float (&value));
477 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
479 n_print ("%-23.23s Double. ", "");
480 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
481 pdouble->minimum, pdouble->maximum, g_value_get_double (&value));
485 if (param->value_type == GST_TYPE_CAPS) {
486 const GstCaps *caps = gst_value_get_caps (&value);
489 n_print ("%-23.23s Caps (NULL)", "");
491 print_caps (caps, " ");
493 } else if (G_IS_PARAM_SPEC_ENUM (param)) {
497 const gchar *value_nick = "";
499 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
500 enum_value = g_value_get_enum (&value);
502 while (values[j].value_name) {
503 if (values[j].value == enum_value)
504 value_nick = values[j].value_nick;
508 n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\"", "",
509 g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick);
512 while (values[j].value_name) {
515 g_print ("%s", _name);
516 g_print ("%-23.23s (%d): %-16s - %s", "",
517 values[j].value, values[j].value_nick, values[j].value_name);
520 /* g_type_class_unref (ec); */
521 } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
522 GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
526 vals = pflags->flags_class->values;
528 cur = flags_to_string (vals, g_value_get_flags (&value));
530 n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "",
531 g_type_name (G_VALUE_TYPE (&value)),
532 g_value_get_flags (&value), cur);
534 while (vals[0].value_name) {
537 g_print ("%s", _name);
538 g_print ("%-23.23s (0x%08x): %-16s - %s", "",
539 vals[0].value, vals[0].value_nick, vals[0].value_name);
544 } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
545 n_print ("%-23.23s Object of type \"%s\"", "",
546 g_type_name (param->value_type));
547 } else if (G_IS_PARAM_SPEC_BOXED (param)) {
548 n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
549 g_type_name (param->value_type));
550 } else if (G_IS_PARAM_SPEC_POINTER (param)) {
551 if (param->value_type != G_TYPE_POINTER) {
552 n_print ("%-23.23s Pointer of type \"%s\".", "",
553 g_type_name (param->value_type));
555 n_print ("%-23.23s Pointer.", "");
557 } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
558 GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);
560 if (pvarray->element_spec) {
561 n_print ("%-23.23s Array of GValues of type \"%s\"", "",
562 g_type_name (pvarray->element_spec->value_type));
564 n_print ("%-23.23s Array of GValues", "");
566 } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
567 GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);
569 n_print ("%-23.23s Fraction. ", "");
571 g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
572 pfraction->min_num, pfraction->min_den,
573 pfraction->max_num, pfraction->max_den,
574 gst_value_get_fraction_numerator (&value),
575 gst_value_get_fraction_denominator (&value));
576 } else if (GST_IS_PARAM_SPEC_MINI_OBJECT (param)) {
577 n_print ("%-23.23s MiniObject of type \"%s\"", "",
578 g_type_name (param->value_type));
580 n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
581 g_type_name (param->value_type));
586 g_print (" Write only\n");
590 g_value_reset (&value);
592 if (num_properties == 0)
595 g_free (property_specs);
599 print_pad_templates_info (GstElement * element, GstElementFactory * factory)
601 GstElementClass *gstelement_class;
603 GstStaticPadTemplate *padtemplate;
605 n_print ("Pad Templates:\n");
606 if (!factory->numpadtemplates) {
611 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
613 pads = factory->staticpadtemplates;
615 padtemplate = (GstStaticPadTemplate *) (pads->data);
616 pads = g_list_next (pads);
618 if (padtemplate->direction == GST_PAD_SRC)
619 n_print (" SRC template: '%s'\n", padtemplate->name_template);
620 else if (padtemplate->direction == GST_PAD_SINK)
621 n_print (" SINK template: '%s'\n", padtemplate->name_template);
623 n_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
625 if (padtemplate->presence == GST_PAD_ALWAYS)
626 n_print (" Availability: Always\n");
627 else if (padtemplate->presence == GST_PAD_SOMETIMES)
628 n_print (" Availability: Sometimes\n");
629 else if (padtemplate->presence == GST_PAD_REQUEST) {
630 n_print (" Availability: On request\n");
631 n_print (" Has request_new_pad() function: %s\n",
632 GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
634 n_print (" Availability: UNKNOWN!!!\n");
636 if (padtemplate->static_caps.string) {
637 n_print (" Capabilities:\n");
638 print_caps (gst_static_caps_get (&padtemplate->static_caps), " ");
646 print_element_flag_info (GstElement * element)
648 gboolean have_flags = FALSE;
651 n_print ("Element Flags:\n");
654 n_print (" no flags set\n");
656 if (GST_IS_BIN (element)) {
658 n_print ("Bin Flags:\n");
660 n_print (" no flags set\n");
665 print_implementation_info (GstElement * element)
667 GstObjectClass *gstobject_class;
668 GstElementClass *gstelement_class;
670 gstobject_class = GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (element));
671 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
674 n_print ("Element Implementation:\n");
676 n_print (" Has change_state() function: %s\n",
677 GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
678 #ifndef GST_DISABLE_LOADSAVE
679 n_print (" Has custom save_thyself() function: %s\n",
680 GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
681 n_print (" Has custom restore_thyself() function: %s\n",
682 GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
687 print_clocking_info (GstElement * element)
689 if (!gst_element_requires_clock (element) &&
690 !(gst_element_provides_clock (element) &&
691 gst_element_get_clock (element))) {
693 n_print ("Element has no clocking capabilities.");
698 n_print ("Clocking Interaction:\n");
699 if (gst_element_requires_clock (element)) {
700 n_print (" element requires a clock\n");
703 if (gst_element_provides_clock (element)) {
706 clock = gst_element_get_clock (element);
708 n_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock));
710 n_print (" element is supposed to provide a clock but returned NULL\n");
715 print_index_info (GstElement * element)
717 if (gst_element_is_indexable (element)) {
719 n_print ("Indexing capabilities:\n");
720 n_print (" element can do indexing\n");
723 n_print ("Element has no indexing capabilities.\n");
728 print_uri_handler_info (GstElement * element)
730 if (GST_IS_URI_HANDLER (element)) {
731 const gchar *uri_type;
732 gchar **uri_protocols;
734 if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC)
736 else if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) ==
740 uri_type = "unknown";
742 uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
745 n_print ("URI handling capabilities:\n");
746 n_print (" Element can act as %s.\n", uri_type);
748 if (uri_protocols && *uri_protocols) {
749 n_print (" Supported URI protocols:\n");
750 for (; *uri_protocols != NULL; uri_protocols++)
751 n_print (" %s\n", *uri_protocols);
753 n_print (" No supported URI protocols\n");
756 n_print ("Element has no URI handling capabilities.\n");
761 print_pad_info (GstElement * element)
769 if (!element->numpads) {
774 pads = element->pads;
778 pad = GST_PAD (pads->data);
779 pads = g_list_next (pads);
783 name = gst_pad_get_name (pad);
784 if (gst_pad_get_direction (pad) == GST_PAD_SRC)
785 g_print (" SRC: '%s'", name);
786 else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
787 g_print (" SINK: '%s'", name);
789 g_print (" UNKNOWN!!!: '%s'", name);
795 n_print (" Implementation:\n");
797 n_print (" Has chainfunc(): %s\n",
798 GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
799 if (pad->getrangefunc)
800 n_print (" Has getrangefunc(): %s\n",
801 GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
802 if (pad->eventfunc != gst_pad_event_default)
803 n_print (" Has custom eventfunc(): %s\n",
804 GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
805 if (pad->queryfunc != gst_pad_query_default)
806 n_print (" Has custom queryfunc(): %s\n",
807 GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
808 if (pad->querytypefunc != gst_pad_get_query_types_default) {
809 const GstQueryType *query_types = gst_pad_get_query_types (pad);
811 n_print (" Provides query types:\n");
812 print_query_types (query_types);
816 if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default)
817 n_print (" Has custom iterintlinkfunc(): %s\n",
818 GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc));
820 if (pad->bufferallocfunc)
821 n_print (" Has bufferallocfunc(): %s\n",
822 GST_DEBUG_FUNCPTR_NAME (pad->bufferallocfunc));
824 if (pad->getcapsfunc)
825 n_print (" Has getcapsfunc(): %s\n",
826 GST_DEBUG_FUNCPTR_NAME (pad->getcapsfunc));
827 if (pad->setcapsfunc)
828 n_print (" Has setcapsfunc(): %s\n",
829 GST_DEBUG_FUNCPTR_NAME (pad->setcapsfunc));
830 /* gst_pad_acceptcaps_default is static :/ */
831 if (pad->acceptcapsfunc)
832 n_print (" Has acceptcapsfunc(): %s\n",
833 GST_DEBUG_FUNCPTR_NAME (pad->acceptcapsfunc));
834 if (pad->fixatecapsfunc)
835 n_print (" Has fixatecapsfunc(): %s\n",
836 GST_DEBUG_FUNCPTR_NAME (pad->fixatecapsfunc));
839 if (pad->padtemplate)
840 n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template);
843 n_print (" Capabilities:\n");
844 print_caps (pad->caps, " ");
850 has_sometimes_template (GstElement * element)
852 GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
855 for (l = klass->padtemplates; l != NULL; l = l->next) {
856 if (GST_PAD_TEMPLATE (l->data)->presence == GST_PAD_SOMETIMES)
864 print_signal_info (GstElement * element)
866 /* Signals/Actions Block */
870 GSignalQuery *query = NULL;
872 GSList *found_signals, *l;
874 for (k = 0; k < 2; k++) {
875 found_signals = NULL;
877 /* For elements that have sometimes pads, also list a few useful GstElement
878 * signals. Put these first, so element-specific ones come later. */
879 if (k == 0 && has_sometimes_template (element)) {
880 query = g_new0 (GSignalQuery, 1);
881 g_signal_query (g_signal_lookup ("pad-added", GST_TYPE_ELEMENT), query);
882 found_signals = g_slist_append (found_signals, query);
883 query = g_new0 (GSignalQuery, 1);
884 g_signal_query (g_signal_lookup ("pad-removed", GST_TYPE_ELEMENT), query);
885 found_signals = g_slist_append (found_signals, query);
886 query = g_new0 (GSignalQuery, 1);
887 g_signal_query (g_signal_lookup ("no-more-pads", GST_TYPE_ELEMENT),
889 found_signals = g_slist_append (found_signals, query);
892 for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
893 if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
896 if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
899 signals = g_signal_list_ids (type, &nsignals);
900 for (i = 0; i < nsignals; i++) {
901 query = g_new0 (GSignalQuery, 1);
902 g_signal_query (signals[i], query);
904 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
905 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
906 found_signals = g_slist_append (found_signals, query);
917 n_print ("Element Signals:\n");
919 n_print ("Element Actions:\n");
924 for (l = found_signals; l; l = l->next) {
928 query = (GSignalQuery *) l->data;
929 indent_len = strlen (query->signal_name) +
930 strlen (g_type_name (query->return_type)) + 24;
932 indent = g_new0 (gchar, indent_len + 1);
933 memset (indent, ' ', indent_len);
935 n_print (" \"%s\" : %s user_function (%s* object",
937 g_type_name (query->return_type), g_type_name (type));
939 for (j = 0; j < query->n_params; j++) {
941 g_print ("%s", _name);
942 if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
943 g_print (",\n%s%s arg%d", indent,
944 g_type_name (query->param_types[j]), j);
945 } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
946 g_print (",\n%s%s arg%d", indent,
947 g_type_name (query->param_types[j]), j);
949 g_print (",\n%s%s* arg%d", indent,
950 g_type_name (query->param_types[j]), j);
956 g_print ("%s", _name);
957 g_print (",\n%sgpointer user_data);\n", indent);
965 g_slist_foreach (found_signals, (GFunc) g_free, NULL);
966 g_slist_free (found_signals);
972 print_children_info (GstElement * element)
976 if (!GST_IS_BIN (element))
979 children = (GList *) GST_BIN (element)->children;
982 g_print ("Children:\n");
986 n_print (" %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
987 children = g_list_next (children);
992 print_blacklist (void)
994 GList *plugins, *cur;
997 g_print ("%s\n", _("Blacklisted files:"));
999 plugins = gst_default_registry_get_plugin_list ();
1000 for (cur = plugins; cur != NULL; cur = g_list_next (cur)) {
1001 GstPlugin *plugin = (GstPlugin *) (cur->data);
1002 if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
1003 g_print (" %s\n", plugin->desc.name);
1009 g_print (_("Total count: "));
1010 g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count),
1013 gst_plugin_list_free (plugins);
1017 print_element_list (gboolean print_all)
1019 int plugincount = 0, featurecount = 0, blacklistcount = 0;
1020 GList *plugins, *orig_plugins;
1022 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
1024 GList *features, *orig_features;
1027 plugin = (GstPlugin *) (plugins->data);
1028 plugins = g_list_next (plugins);
1031 if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
1036 orig_features = features =
1037 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1040 GstPluginFeature *feature;
1042 if (G_UNLIKELY (features->data == NULL))
1044 feature = GST_PLUGIN_FEATURE (features->data);
1047 if (GST_IS_ELEMENT_FACTORY (feature)) {
1048 GstElementFactory *factory;
1050 factory = GST_ELEMENT_FACTORY (feature);
1052 print_element_info (factory, TRUE);
1054 g_print ("%s: %s: %s\n", plugin->desc.name,
1055 GST_PLUGIN_FEATURE_NAME (factory),
1056 gst_element_factory_get_longname (factory));
1057 } else if (GST_IS_INDEX_FACTORY (feature)) {
1058 GstIndexFactory *factory;
1060 factory = GST_INDEX_FACTORY (feature);
1062 g_print ("%s: %s: %s\n", plugin->desc.name,
1063 GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
1064 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1065 GstTypeFindFactory *factory;
1067 factory = GST_TYPE_FIND_FACTORY (feature);
1069 g_print ("%s: %s: ", plugin->desc.name,
1070 gst_plugin_feature_get_name (feature));
1071 if (factory->extensions) {
1074 while (factory->extensions[i]) {
1076 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1083 g_print ("no extensions\n");
1087 n_print ("%s: %s (%s)\n", plugin->desc.name,
1088 GST_PLUGIN_FEATURE_NAME (feature),
1089 g_type_name (G_OBJECT_TYPE (feature)));
1093 features = g_list_next (features);
1096 gst_plugin_feature_list_free (orig_features);
1099 gst_plugin_list_free (orig_plugins);
1102 g_print (_("Total count: "));
1103 g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
1104 if (blacklistcount) {
1106 g_print (ngettext ("%d blacklist entry", "%d blacklist entries",
1107 blacklistcount), blacklistcount);
1108 g_print (" not shown)");
1111 g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
1116 print_all_uri_handlers (void)
1118 GList *plugins, *p, *features, *f;
1120 plugins = gst_default_registry_get_plugin_list ();
1122 for (p = plugins; p; p = p->next) {
1123 GstPlugin *plugin = (GstPlugin *) (p->data);
1126 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1129 for (f = features; f; f = f->next) {
1130 GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data);
1132 if (GST_IS_ELEMENT_FACTORY (feature)) {
1133 GstElementFactory *factory;
1134 GstElement *element;
1136 factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
1138 g_print ("element plugin %s couldn't be loaded\n", plugin->desc.name);
1142 element = gst_element_factory_create (factory, NULL);
1144 g_print ("couldn't construct element for %s for some reason\n",
1145 GST_OBJECT_NAME (factory));
1146 gst_object_unref (factory);
1150 if (GST_IS_URI_HANDLER (element)) {
1152 gchar **uri_protocols, *joined;
1154 switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
1167 gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
1168 joined = g_strjoinv (", ", uri_protocols);
1170 g_print ("%s (%s, rank %u): %s\n",
1171 gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), dir,
1172 gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
1178 gst_object_unref (element);
1179 gst_object_unref (factory);
1183 gst_plugin_feature_list_free (features);
1186 gst_plugin_list_free (plugins);
1190 print_plugin_info (GstPlugin * plugin)
1192 n_print ("Plugin Details:\n");
1193 n_print (" Name:\t\t\t%s\n", plugin->desc.name);
1194 n_print (" Description:\t\t%s\n", plugin->desc.description);
1195 n_print (" Filename:\t\t%s\n",
1196 plugin->filename ? plugin->filename : "(null)");
1197 n_print (" Version:\t\t%s\n", plugin->desc.version);
1198 n_print (" License:\t\t%s\n", plugin->desc.license);
1199 n_print (" Source module:\t%s\n", plugin->desc.source);
1200 if (plugin->desc.release_datetime != NULL) {
1201 const gchar *tz = "(UTC)";
1204 /* may be: YYYY-MM-DD or YYYY-MM-DDTHH:MMZ */
1205 /* YYYY-MM-DDTHH:MMZ => YYYY-MM-DD HH:MM (UTC) */
1206 str = g_strdup (plugin->desc.release_datetime);
1207 sep = strstr (str, "T");
1210 sep = strstr (sep + 1, "Z");
1216 n_print (" Source release date:\t%s%s\n", str, tz);
1219 n_print (" Binary package:\t%s\n", plugin->desc.package);
1220 n_print (" Origin URL:\t\t%s\n", plugin->desc.origin);
1225 print_plugin_features (GstPlugin * plugin)
1228 gint num_features = 0;
1229 gint num_elements = 0;
1230 gint num_typefinders = 0;
1231 gint num_indexes = 0;
1235 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1239 GstPluginFeature *feature;
1241 feature = GST_PLUGIN_FEATURE (features->data);
1243 if (GST_IS_ELEMENT_FACTORY (feature)) {
1244 GstElementFactory *factory;
1246 factory = GST_ELEMENT_FACTORY (feature);
1247 n_print (" %s: %s\n", GST_PLUGIN_FEATURE_NAME (factory),
1248 gst_element_factory_get_longname (factory));
1250 } else if (GST_IS_INDEX_FACTORY (feature)) {
1251 GstIndexFactory *factory;
1253 factory = GST_INDEX_FACTORY (feature);
1254 n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
1256 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1257 GstTypeFindFactory *factory;
1259 factory = GST_TYPE_FIND_FACTORY (feature);
1260 if (factory->extensions) {
1263 g_print ("%s: %s: ", plugin->desc.name,
1264 gst_plugin_feature_get_name (feature));
1265 while (factory->extensions[i]) {
1266 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1271 g_print ("%s: %s: no extensions\n", plugin->desc.name,
1272 gst_plugin_feature_get_name (feature));
1275 } else if (feature) {
1276 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1277 g_type_name (G_OBJECT_TYPE (feature)));
1281 features = g_list_next (features);
1284 n_print (" %d features:\n", num_features);
1285 if (num_elements > 0)
1286 n_print (" +-- %d elements\n", num_elements);
1287 if (num_typefinders > 0)
1288 n_print (" +-- %d typefinders\n", num_typefinders);
1289 if (num_indexes > 0)
1290 n_print (" +-- %d indexes\n", num_indexes);
1292 n_print (" +-- %d other objects\n", num_other);
1298 print_element_features (const gchar * element_name)
1300 GstPluginFeature *feature;
1302 /* FIXME implement other pretty print function for these */
1303 feature = gst_default_registry_find_feature (element_name,
1304 GST_TYPE_INDEX_FACTORY);
1306 n_print ("%s: an index\n", element_name);
1309 feature = gst_default_registry_find_feature (element_name,
1310 GST_TYPE_TYPE_FIND_FACTORY);
1312 n_print ("%s: a typefind function\n", element_name);
1320 print_element_info (GstElementFactory * factory, gboolean print_names)
1322 GstElement *element;
1326 GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
1330 g_print ("element plugin couldn't be loaded\n");
1334 element = gst_element_factory_create (factory, NULL);
1336 g_print ("couldn't construct element for some reason\n");
1341 _name = g_strdup_printf ("%s: ", GST_PLUGIN_FEATURE (factory)->name);
1345 print_factory_details_info (factory);
1346 if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
1349 plugin = gst_registry_find_plugin (gst_registry_get_default (),
1350 GST_PLUGIN_FEATURE (factory)->plugin_name);
1352 print_plugin_info (plugin);
1356 print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
1357 print_interfaces (G_OBJECT_TYPE (element));
1359 print_pad_templates_info (element, factory);
1360 print_element_flag_info (element);
1361 print_implementation_info (element);
1362 print_clocking_info (element);
1363 print_index_info (element);
1364 print_uri_handler_info (element);
1365 print_pad_info (element);
1366 print_element_properties_info (element);
1367 print_signal_info (element);
1368 print_children_info (element);
1370 gst_object_unref (element);
1371 gst_object_unref (factory);
1379 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
1381 GstPadDirection direction;
1382 const gchar *type_name;
1384 const GList *static_templates, *l;
1385 GstCaps *caps = NULL;
1388 klass = gst_element_factory_get_klass (factory);
1389 g_return_if_fail (klass != NULL);
1391 if (strstr (klass, "Demuxer") ||
1392 strstr (klass, "Decoder") ||
1393 strstr (klass, "Depay") || strstr (klass, "Parser")) {
1394 type_name = "decoder";
1395 direction = GST_PAD_SINK;
1396 } else if (strstr (klass, "Muxer") ||
1397 strstr (klass, "Encoder") || strstr (klass, "Pay")) {
1398 type_name = "encoder";
1399 direction = GST_PAD_SRC;
1404 /* decoder/demuxer sink pads should always be static and there should only
1405 * be one, the same applies to encoders/muxers and source pads */
1406 static_templates = gst_element_factory_get_static_pad_templates (factory);
1407 for (l = static_templates; l != NULL; l = l->next) {
1408 GstStaticPadTemplate *tmpl = NULL;
1410 tmpl = (GstStaticPadTemplate *) l->data;
1411 if (tmpl->direction == direction) {
1412 caps = gst_static_pad_template_get_caps (tmpl);
1418 g_printerr ("Couldn't find static pad template for %s '%s'\n",
1419 type_name, GST_PLUGIN_FEATURE_NAME (factory));
1423 caps = gst_caps_make_writable (caps);
1424 num = gst_caps_get_size (caps);
1425 for (i = 0; i < num; ++i) {
1429 s = gst_caps_get_structure (caps, i);
1430 /* remove fields that are almost always just MIN-MAX of some sort
1431 * in order to make the caps look less messy */
1432 gst_structure_remove_field (s, "pixel-aspect-ratio");
1433 gst_structure_remove_field (s, "framerate");
1434 gst_structure_remove_field (s, "channels");
1435 gst_structure_remove_field (s, "width");
1436 gst_structure_remove_field (s, "height");
1437 gst_structure_remove_field (s, "rate");
1438 gst_structure_remove_field (s, "depth");
1439 gst_structure_remove_field (s, "clock-rate");
1440 s_str = gst_structure_to_string (s);
1441 g_print ("%s-%s\n", type_name, s_str);
1444 gst_caps_unref (caps);
1448 print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
1450 gchar **protocols, **p;
1452 protocols = gst_element_factory_get_uri_protocols (factory);
1453 if (protocols != NULL && *protocols != NULL) {
1454 switch (gst_element_factory_get_uri_type (factory)) {
1456 for (p = protocols; *p != NULL; ++p)
1457 g_print ("urisink-%s\n", *p);
1460 for (p = protocols; *p != NULL; ++p)
1461 g_print ("urisource-%s\n", *p);
1466 g_strfreev (protocols);
1471 print_plugin_automatic_install_info (GstPlugin * plugin)
1473 const gchar *plugin_name;
1474 GList *features, *l;
1476 plugin_name = gst_plugin_get_name (plugin);
1478 /* not interested in typefind factories, only element factories */
1479 features = gst_registry_get_feature_list (gst_registry_get_default (),
1480 GST_TYPE_ELEMENT_FACTORY);
1482 for (l = features; l != NULL; l = l->next) {
1483 GstPluginFeature *feature;
1485 feature = GST_PLUGIN_FEATURE (l->data);
1487 /* only interested in the ones that are in the plugin we just loaded */
1488 if (g_str_equal (plugin_name, feature->plugin_name)) {
1489 GstElementFactory *factory;
1491 g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
1493 factory = GST_ELEMENT_FACTORY (feature);
1494 print_plugin_automatic_install_info_protocols (factory);
1495 print_plugin_automatic_install_info_codecs (factory);
1499 g_list_foreach (features, (GFunc) gst_object_unref, NULL);
1500 g_list_free (features);
1504 print_all_plugin_automatic_install_info (void)
1506 GList *plugins, *orig_plugins;
1508 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
1512 plugin = (GstPlugin *) (plugins->data);
1513 plugins = g_list_next (plugins);
1515 print_plugin_automatic_install_info (plugin);
1517 gst_plugin_list_free (orig_plugins);
1521 main (int argc, char *argv[])
1523 gboolean print_all = FALSE;
1524 gboolean do_print_blacklist = FALSE;
1525 gboolean plugin_name = FALSE;
1526 gboolean print_aii = FALSE;
1527 gboolean uri_handlers = FALSE;
1528 #ifndef GST_DISABLE_OPTION_PARSING
1529 GOptionEntry options[] = {
1530 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
1531 N_("Print all elements"), NULL},
1532 {"print-blacklist", 'b', 0, G_OPTION_ARG_NONE, &do_print_blacklist,
1533 N_("Print list of blacklisted files"), NULL},
1534 {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
1535 N_("Print a machine-parsable list of features the specified plugin "
1536 "or all plugins provide.\n "
1537 "Useful in connection with external automatic plugin "
1538 "installation mechanisms"), NULL},
1539 {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
1540 N_("List the plugin contents"), NULL},
1541 {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
1543 ("Print supported URI schemes, with the elements that implement them"),
1545 GST_TOOLS_GOPTION_VERSION,
1548 GOptionContext *ctx;
1553 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1554 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1555 textdomain (GETTEXT_PACKAGE);
1558 g_thread_init (NULL);
1560 gst_tools_set_prgname ("gst-inspect");
1562 #ifndef GST_DISABLE_OPTION_PARSING
1563 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
1564 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
1565 g_option_context_add_group (ctx, gst_init_get_option_group ());
1566 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1567 g_print ("Error initializing: %s\n", err->message);
1570 g_option_context_free (ctx);
1572 gst_init (&argc, &argv);
1575 gst_tools_print_version ("gst-inspect");
1577 if (print_all && argc > 1) {
1578 g_print ("-a requires no extra arguments\n");
1582 if (uri_handlers && argc > 1) {
1583 g_print ("-u requires no extra arguments\n");
1587 /* if no arguments, print out list of elements */
1589 print_all_uri_handlers ();
1590 } else if (argc == 1 || print_all) {
1591 if (do_print_blacklist)
1595 print_all_plugin_automatic_install_info ();
1597 print_element_list (print_all);
1600 /* else we try to get a factory */
1601 GstElementFactory *factory;
1603 const char *arg = argv[argc - 1];
1607 factory = gst_element_factory_find (arg);
1609 /* if there's a factory, print out the info */
1611 retval = print_element_info (factory, print_all);
1612 gst_object_unref (factory);
1614 retval = print_element_features (arg);
1620 /* otherwise check if it's a plugin */
1622 plugin = gst_default_registry_find_plugin (arg);
1624 /* if there is such a plugin, print out info */
1627 print_plugin_automatic_install_info (plugin);
1629 print_plugin_info (plugin);
1630 print_plugin_features (plugin);
1633 GError *error = NULL;
1635 if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
1636 plugin = gst_plugin_load_file (arg, &error);
1640 print_plugin_automatic_install_info (plugin);
1642 print_plugin_info (plugin);
1643 print_plugin_features (plugin);
1646 g_print (_("Could not load plugin file: %s\n"), error->message);
1647 g_error_free (error);
1651 g_print (_("No such element or plugin '%s'\n"), arg);