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_metadata (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 (" Rank:\t\t%s (%d)\n",
222 get_rank_name (s, GST_PLUGIN_FEATURE (factory)->rank),
223 GST_PLUGIN_FEATURE (factory)->rank);
224 gst_structure_foreach ((GstStructure *) factory->metadata,
225 print_factory_details_metadata, NULL);
230 print_hierarchy (GType type, gint level, gint * maxlevel)
235 parent = g_type_parent (type);
237 *maxlevel = *maxlevel + 1;
241 print_hierarchy (parent, level, maxlevel);
244 g_print ("%s", _name);
246 for (i = 1; i < *maxlevel - level; i++)
248 if (*maxlevel - level)
251 g_print ("%s\n", g_type_name (type));
258 print_interfaces (GType type)
261 GType *iface, *ifaces = g_type_interfaces (type, &n_ifaces);
266 g_print ("%s", _name);
267 g_print (_("Implemented Interfaces:\n"));
271 g_print ("%s", _name);
272 g_print (" %s\n", g_type_name (*iface));
276 g_print ("%s", _name);
284 flags_to_string (GFlagsValue * vals, guint flags)
289 /* first look for an exact match and count the number of values */
290 for (i = 0; vals[i].value_name != NULL; ++i) {
291 if (vals[i].value == flags)
292 return g_strdup (vals[i].value_nick);
295 s = g_string_new (NULL);
297 /* we assume the values are sorted from lowest to highest value */
301 if (vals[i].value != 0 && (flags_left & vals[i].value) == vals[i].value) {
303 g_string_append (s, " | ");
304 g_string_append (s, vals[i].value_nick);
305 flags_left -= vals[i].value;
312 g_string_assign (s, "(none)");
314 return g_string_free (s, FALSE);
317 #define KNOWN_PARAM_FLAGS \
318 (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY | \
319 G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS | \
320 G_PARAM_READABLE | G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE | \
321 GST_PARAM_MUTABLE_PLAYING | GST_PARAM_MUTABLE_PAUSED | \
322 GST_PARAM_MUTABLE_READY)
325 print_element_properties_info (GstElement * element)
327 GParamSpec **property_specs;
328 guint num_properties, i;
332 property_specs = g_object_class_list_properties
333 (G_OBJECT_GET_CLASS (element), &num_properties);
335 n_print ("Element Properties:\n");
337 for (i = 0; i < num_properties; i++) {
338 GValue value = { 0, };
339 GParamSpec *param = property_specs[i];
343 g_value_init (&value, param->value_type);
345 n_print (" %-20s: %s\n", g_param_spec_get_name (param),
346 g_param_spec_get_blurb (param));
349 n_print ("%-23.23s flags: ", "");
350 if (param->flags & G_PARAM_READABLE) {
351 g_object_get_property (G_OBJECT (element), param->name, &value);
353 g_print ("%s%s", (first_flag) ? "" : ", ", _("readable"));
356 if (param->flags & G_PARAM_WRITABLE) {
357 g_print ("%s%s", (first_flag) ? "" : ", ", _("writable"));
360 if (param->flags & GST_PARAM_CONTROLLABLE) {
361 g_print (", %s", _("controllable"));
364 if (param->flags & GST_PARAM_MUTABLE_PLAYING) {
365 g_print (", %s", _("changeable in NULL, READY, PAUSED or PLAYING state"));
366 } else if (param->flags & GST_PARAM_MUTABLE_PAUSED) {
367 g_print (", %s", _("changeable only in NULL, READY or PAUSED state"));
368 } else if (param->flags & GST_PARAM_MUTABLE_READY) {
369 g_print (", %s", _("changeable only in NULL or READY state"));
371 if (param->flags & ~KNOWN_PARAM_FLAGS) {
372 g_print ("%s0x%0x", (first_flag) ? "" : ", ",
373 param->flags & ~KNOWN_PARAM_FLAGS);
377 switch (G_VALUE_TYPE (&value)) {
380 GParamSpecString *pstring = G_PARAM_SPEC_STRING (param);
382 n_print ("%-23.23s String. ", "");
384 if (pstring->default_value == NULL)
385 g_print ("Default: null ");
387 g_print ("Default: \"%s\" ", pstring->default_value);
390 const char *string_val = g_value_get_string (&value);
392 if (string_val == NULL)
393 g_print ("Current: null");
395 g_print ("Current: \"%s\"", string_val);
401 GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param);
403 n_print ("%-23.23s Boolean. ", "");
404 g_print ("Default: %s ", (pboolean->default_value ? "true" : "false"));
406 g_print ("Current: %s",
407 (g_value_get_boolean (&value) ? "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, pulong->default_value);
418 g_print ("Current: %lu", g_value_get_ulong (&value));
423 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
425 n_print ("%-23.23s Long. ", "");
426 g_print ("Range: %ld - %ld Default: %ld ",
427 plong->minimum, plong->maximum, plong->default_value);
429 g_print ("Current: %ld", g_value_get_long (&value));
434 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
436 n_print ("%-23.23s Unsigned Integer. ", "");
437 g_print ("Range: %u - %u Default: %u ",
438 puint->minimum, puint->maximum, puint->default_value);
440 g_print ("Current: %u", g_value_get_uint (&value));
445 GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
447 n_print ("%-23.23s Integer. ", "");
448 g_print ("Range: %d - %d Default: %d ",
449 pint->minimum, pint->maximum, pint->default_value);
451 g_print ("Current: %d", g_value_get_int (&value));
456 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
458 n_print ("%-23.23s Unsigned Integer64. ", "");
459 g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
460 " Default: %" G_GUINT64_FORMAT " ",
461 puint64->minimum, puint64->maximum, puint64->default_value);
463 g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value));
468 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
470 n_print ("%-23.23s Integer64. ", "");
471 g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
472 " Default: %" G_GINT64_FORMAT " ",
473 pint64->minimum, pint64->maximum, pint64->default_value);
475 g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value));
480 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
482 n_print ("%-23.23s Float. ", "");
483 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
484 pfloat->minimum, pfloat->maximum, pfloat->default_value);
486 g_print ("Current: %15.7g", g_value_get_float (&value));
491 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
493 n_print ("%-23.23s Double. ", "");
494 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
495 pdouble->minimum, pdouble->maximum, pdouble->default_value);
497 g_print ("Current: %15.7g", g_value_get_double (&value));
501 if (param->value_type == GST_TYPE_CAPS) {
502 const GstCaps *caps = gst_value_get_caps (&value);
505 n_print ("%-23.23s Caps (NULL)", "");
507 print_caps (caps, " ");
509 } else if (G_IS_PARAM_SPEC_ENUM (param)) {
510 GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param);
514 const gchar *def_val_nick = "", *cur_val_nick = "";
516 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
517 enum_value = g_value_get_enum (&value);
519 while (values[j].value_name) {
520 if (values[j].value == enum_value)
521 cur_val_nick = values[j].value_nick;
522 if (values[j].value == penum->default_value)
523 def_val_nick = values[j].value_nick;
528 ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"",
529 "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value,
530 def_val_nick, enum_value, cur_val_nick);
533 while (values[j].value_name) {
536 g_print ("%s", _name);
537 g_print ("%-23.23s (%d): %-16s - %s", "",
538 values[j].value, values[j].value_nick, values[j].value_name);
541 /* g_type_class_unref (ec); */
542 } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
543 GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
547 vals = pflags->flags_class->values;
549 cur = flags_to_string (vals, g_value_get_flags (&value));
550 def = flags_to_string (vals, pflags->default_value);
553 ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"",
554 "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value,
555 def, g_value_get_flags (&value), cur);
557 while (vals[0].value_name) {
560 g_print ("%s", _name);
561 g_print ("%-23.23s (0x%08x): %-16s - %s", "",
562 vals[0].value, vals[0].value_nick, vals[0].value_name);
568 } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
569 n_print ("%-23.23s Object of type \"%s\"", "",
570 g_type_name (param->value_type));
571 } else if (G_IS_PARAM_SPEC_BOXED (param)) {
572 n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
573 g_type_name (param->value_type));
574 } else if (G_IS_PARAM_SPEC_POINTER (param)) {
575 if (param->value_type != G_TYPE_POINTER) {
576 n_print ("%-23.23s Pointer of type \"%s\".", "",
577 g_type_name (param->value_type));
579 n_print ("%-23.23s Pointer.", "");
581 } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
582 GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);
584 if (pvarray->element_spec) {
585 n_print ("%-23.23s Array of GValues of type \"%s\"", "",
586 g_type_name (pvarray->element_spec->value_type));
588 n_print ("%-23.23s Array of GValues", "");
590 } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
591 GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);
593 n_print ("%-23.23s Fraction. ", "");
595 g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
596 pfraction->min_num, pfraction->min_den,
597 pfraction->max_num, pfraction->max_den,
598 pfraction->def_num, pfraction->def_den);
600 g_print ("Current: %d/%d",
601 gst_value_get_fraction_numerator (&value),
602 gst_value_get_fraction_denominator (&value));
605 n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
606 g_type_name (param->value_type));
611 g_print (" Write only\n");
615 g_value_reset (&value);
617 if (num_properties == 0)
620 g_free (property_specs);
624 print_pad_templates_info (GstElement * element, GstElementFactory * factory)
626 GstElementClass *gstelement_class;
628 GstStaticPadTemplate *padtemplate;
630 n_print ("Pad Templates:\n");
631 if (!factory->numpadtemplates) {
636 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
638 pads = factory->staticpadtemplates;
640 padtemplate = (GstStaticPadTemplate *) (pads->data);
641 pads = g_list_next (pads);
643 if (padtemplate->direction == GST_PAD_SRC)
644 n_print (" SRC template: '%s'\n", padtemplate->name_template);
645 else if (padtemplate->direction == GST_PAD_SINK)
646 n_print (" SINK template: '%s'\n", padtemplate->name_template);
648 n_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
650 if (padtemplate->presence == GST_PAD_ALWAYS)
651 n_print (" Availability: Always\n");
652 else if (padtemplate->presence == GST_PAD_SOMETIMES)
653 n_print (" Availability: Sometimes\n");
654 else if (padtemplate->presence == GST_PAD_REQUEST) {
655 n_print (" Availability: On request\n");
656 n_print (" Has request_new_pad() function: %s\n",
657 GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
659 n_print (" Availability: UNKNOWN!!!\n");
661 if (padtemplate->static_caps.string) {
662 n_print (" Capabilities:\n");
663 print_caps (gst_static_caps_get (&padtemplate->static_caps), " ");
671 print_element_flag_info (GstElement * element)
673 gboolean have_flags = FALSE;
676 n_print ("Element Flags:\n");
679 n_print (" no flags set\n");
681 if (GST_IS_BIN (element)) {
683 n_print ("Bin Flags:\n");
685 n_print (" no flags set\n");
690 print_implementation_info (GstElement * element)
692 GstObjectClass *gstobject_class;
693 GstElementClass *gstelement_class;
695 gstobject_class = GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (element));
696 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
699 n_print ("Element Implementation:\n");
701 n_print (" Has change_state() function: %s\n",
702 GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
706 print_clocking_info (GstElement * element)
708 if (!gst_element_requires_clock (element) &&
709 !(gst_element_provides_clock (element) &&
710 gst_element_get_clock (element))) {
712 n_print ("Element has no clocking capabilities.");
717 n_print ("Clocking Interaction:\n");
718 if (gst_element_requires_clock (element)) {
719 n_print (" element requires a clock\n");
722 if (gst_element_provides_clock (element)) {
725 clock = gst_element_get_clock (element);
727 n_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock));
729 n_print (" element is supposed to provide a clock but returned NULL\n");
734 print_index_info (GstElement * element)
736 if (gst_element_is_indexable (element)) {
738 n_print ("Indexing capabilities:\n");
739 n_print (" element can do indexing\n");
742 n_print ("Element has no indexing capabilities.\n");
747 print_uri_handler_info (GstElement * element)
749 if (GST_IS_URI_HANDLER (element)) {
750 const gchar *uri_type;
751 gchar **uri_protocols;
753 if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC)
755 else if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) ==
759 uri_type = "unknown";
761 uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
764 n_print ("URI handling capabilities:\n");
765 n_print (" Element can act as %s.\n", uri_type);
767 if (uri_protocols && *uri_protocols) {
768 n_print (" Supported URI protocols:\n");
769 for (; *uri_protocols != NULL; uri_protocols++)
770 n_print (" %s\n", *uri_protocols);
772 n_print (" No supported URI protocols\n");
775 n_print ("Element has no URI handling capabilities.\n");
780 print_pad_info (GstElement * element)
788 if (!element->numpads) {
793 pads = element->pads;
798 pad = GST_PAD (pads->data);
799 pads = g_list_next (pads);
803 name = gst_pad_get_name (pad);
804 if (gst_pad_get_direction (pad) == GST_PAD_SRC)
805 g_print (" SRC: '%s'", name);
806 else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
807 g_print (" SINK: '%s'", name);
809 g_print (" UNKNOWN!!!: '%s'", name);
815 n_print (" Implementation:\n");
817 n_print (" Has chainfunc(): %s\n",
818 GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
819 if (pad->getrangefunc)
820 n_print (" Has getrangefunc(): %s\n",
821 GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
822 if (pad->eventfunc != gst_pad_event_default)
823 n_print (" Has custom eventfunc(): %s\n",
824 GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
825 if (pad->queryfunc != gst_pad_query_default)
826 n_print (" Has custom queryfunc(): %s\n",
827 GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
828 if (pad->querytypefunc != gst_pad_get_query_types_default) {
829 const GstQueryType *query_types = gst_pad_get_query_types (pad);
831 n_print (" Provides query types:\n");
832 print_query_types (query_types);
836 if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default)
837 n_print (" Has custom iterintlinkfunc(): %s\n",
838 GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc));
840 if (pad->getcapsfunc)
841 n_print (" Has getcapsfunc(): %s\n",
842 GST_DEBUG_FUNCPTR_NAME (pad->getcapsfunc));
843 if (pad->setcapsfunc)
844 n_print (" Has setcapsfunc(): %s\n",
845 GST_DEBUG_FUNCPTR_NAME (pad->setcapsfunc));
846 /* gst_pad_acceptcaps_default is static :/ */
847 if (pad->acceptcapsfunc)
848 n_print (" Has acceptcapsfunc(): %s\n",
849 GST_DEBUG_FUNCPTR_NAME (pad->acceptcapsfunc));
850 if (pad->fixatecapsfunc)
851 n_print (" Has fixatecapsfunc(): %s\n",
852 GST_DEBUG_FUNCPTR_NAME (pad->fixatecapsfunc));
855 if (pad->padtemplate)
856 n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template);
858 caps = gst_pad_get_current_caps (pad);
860 n_print (" Capabilities:\n");
861 print_caps (caps, " ");
862 gst_caps_unref (caps);
868 has_sometimes_template (GstElement * element)
870 GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
873 for (l = klass->padtemplates; l != NULL; l = l->next) {
874 if (GST_PAD_TEMPLATE (l->data)->presence == GST_PAD_SOMETIMES)
882 print_signal_info (GstElement * element)
884 /* Signals/Actions Block */
888 GSignalQuery *query = NULL;
890 GSList *found_signals, *l;
892 for (k = 0; k < 2; k++) {
893 found_signals = NULL;
895 /* For elements that have sometimes pads, also list a few useful GstElement
896 * signals. Put these first, so element-specific ones come later. */
897 if (k == 0 && has_sometimes_template (element)) {
898 query = g_new0 (GSignalQuery, 1);
899 g_signal_query (g_signal_lookup ("pad-added", GST_TYPE_ELEMENT), query);
900 found_signals = g_slist_append (found_signals, query);
901 query = g_new0 (GSignalQuery, 1);
902 g_signal_query (g_signal_lookup ("pad-removed", GST_TYPE_ELEMENT), query);
903 found_signals = g_slist_append (found_signals, query);
904 query = g_new0 (GSignalQuery, 1);
905 g_signal_query (g_signal_lookup ("no-more-pads", GST_TYPE_ELEMENT),
907 found_signals = g_slist_append (found_signals, query);
910 for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
911 if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
914 if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
917 signals = g_signal_list_ids (type, &nsignals);
918 for (i = 0; i < nsignals; i++) {
919 query = g_new0 (GSignalQuery, 1);
920 g_signal_query (signals[i], query);
922 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
923 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
924 found_signals = g_slist_append (found_signals, query);
935 n_print ("Element Signals:\n");
937 n_print ("Element Actions:\n");
942 for (l = found_signals; l; l = l->next) {
946 query = (GSignalQuery *) l->data;
947 indent_len = strlen (query->signal_name) +
948 strlen (g_type_name (query->return_type)) + 24;
950 indent = g_new0 (gchar, indent_len + 1);
951 memset (indent, ' ', indent_len);
953 n_print (" \"%s\" : %s user_function (%s* object",
955 g_type_name (query->return_type), g_type_name (type));
957 for (j = 0; j < query->n_params; j++) {
959 g_print ("%s", _name);
960 if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
961 g_print (",\n%s%s arg%d", indent,
962 g_type_name (query->param_types[j]), j);
963 } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
964 g_print (",\n%s%s arg%d", indent,
965 g_type_name (query->param_types[j]), j);
967 g_print (",\n%s%s* arg%d", indent,
968 g_type_name (query->param_types[j]), j);
974 g_print ("%s", _name);
975 g_print (",\n%sgpointer user_data);\n", indent);
983 g_slist_foreach (found_signals, (GFunc) g_free, NULL);
984 g_slist_free (found_signals);
990 print_children_info (GstElement * element)
994 if (!GST_IS_BIN (element))
997 children = (GList *) GST_BIN (element)->children;
1000 g_print ("Children:\n");
1004 n_print (" %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
1005 children = g_list_next (children);
1010 print_blacklist (void)
1012 GList *plugins, *cur;
1015 g_print ("%s\n", _("Blacklisted files:"));
1017 plugins = gst_default_registry_get_plugin_list ();
1018 for (cur = plugins; cur != NULL; cur = g_list_next (cur)) {
1019 GstPlugin *plugin = (GstPlugin *) (cur->data);
1020 if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
1021 g_print (" %s\n", plugin->desc.name);
1027 g_print (_("Total count: "));
1028 g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count),
1031 gst_plugin_list_free (plugins);
1035 print_element_list (gboolean print_all)
1037 int plugincount = 0, featurecount = 0, blacklistcount = 0;
1038 GList *plugins, *orig_plugins;
1040 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
1042 GList *features, *orig_features;
1045 plugin = (GstPlugin *) (plugins->data);
1046 plugins = g_list_next (plugins);
1049 if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
1054 orig_features = features =
1055 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1058 GstPluginFeature *feature;
1060 if (G_UNLIKELY (features->data == NULL))
1062 feature = GST_PLUGIN_FEATURE (features->data);
1065 if (GST_IS_ELEMENT_FACTORY (feature)) {
1066 GstElementFactory *factory;
1068 factory = GST_ELEMENT_FACTORY (feature);
1070 print_element_info (factory, TRUE);
1072 g_print ("%s: %s: %s\n", plugin->desc.name,
1073 GST_PLUGIN_FEATURE_NAME (factory),
1074 gst_element_factory_get_longname (factory));
1075 } else if (GST_IS_INDEX_FACTORY (feature)) {
1076 GstIndexFactory *factory;
1078 factory = GST_INDEX_FACTORY (feature);
1080 g_print ("%s: %s: %s\n", plugin->desc.name,
1081 GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
1082 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1083 GstTypeFindFactory *factory;
1085 factory = GST_TYPE_FIND_FACTORY (feature);
1087 g_print ("%s: %s: ", plugin->desc.name,
1088 gst_plugin_feature_get_name (feature));
1089 if (factory->extensions) {
1092 while (factory->extensions[i]) {
1094 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1101 g_print ("no extensions\n");
1105 n_print ("%s: %s (%s)\n", plugin->desc.name,
1106 GST_PLUGIN_FEATURE_NAME (feature),
1107 g_type_name (G_OBJECT_TYPE (feature)));
1111 features = g_list_next (features);
1114 gst_plugin_feature_list_free (orig_features);
1117 gst_plugin_list_free (orig_plugins);
1120 g_print (_("Total count: "));
1121 g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
1122 if (blacklistcount) {
1124 g_print (ngettext ("%d blacklist entry", "%d blacklist entries",
1125 blacklistcount), blacklistcount);
1126 g_print (" not shown)");
1129 g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
1134 print_all_uri_handlers (void)
1136 GList *plugins, *p, *features, *f;
1138 plugins = gst_default_registry_get_plugin_list ();
1140 for (p = plugins; p; p = p->next) {
1141 GstPlugin *plugin = (GstPlugin *) (p->data);
1144 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1147 for (f = features; f; f = f->next) {
1148 GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data);
1150 if (GST_IS_ELEMENT_FACTORY (feature)) {
1151 GstElementFactory *factory;
1152 GstElement *element;
1154 factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
1156 g_print ("element plugin %s couldn't be loaded\n", plugin->desc.name);
1160 element = gst_element_factory_create (factory, NULL);
1162 g_print ("couldn't construct element for %s for some reason\n",
1163 GST_OBJECT_NAME (factory));
1164 gst_object_unref (factory);
1168 if (GST_IS_URI_HANDLER (element)) {
1170 gchar **uri_protocols, *joined;
1172 switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
1185 gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
1186 joined = g_strjoinv (", ", uri_protocols);
1188 g_print ("%s (%s, rank %u): %s\n",
1189 gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), dir,
1190 gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
1196 gst_object_unref (element);
1197 gst_object_unref (factory);
1201 gst_plugin_feature_list_free (features);
1204 gst_plugin_list_free (plugins);
1208 print_plugin_info (GstPlugin * plugin)
1210 n_print ("Plugin Details:\n");
1211 n_print (" Name:\t\t\t%s\n", plugin->desc.name);
1212 n_print (" Description:\t\t%s\n", plugin->desc.description);
1213 n_print (" Filename:\t\t%s\n",
1214 plugin->filename ? plugin->filename : "(null)");
1215 n_print (" Version:\t\t%s\n", plugin->desc.version);
1216 n_print (" License:\t\t%s\n", plugin->desc.license);
1217 n_print (" Source module:\t%s\n", plugin->desc.source);
1218 if (plugin->desc.release_datetime != NULL) {
1219 const gchar *tz = "(UTC)";
1222 /* may be: YYYY-MM-DD or YYYY-MM-DDTHH:MMZ */
1223 /* YYYY-MM-DDTHH:MMZ => YYYY-MM-DD HH:MM (UTC) */
1224 str = g_strdup (plugin->desc.release_datetime);
1225 sep = strstr (str, "T");
1228 sep = strstr (sep + 1, "Z");
1234 n_print (" Source release date:\t%s%s\n", str, tz);
1237 n_print (" Binary package:\t%s\n", plugin->desc.package);
1238 n_print (" Origin URL:\t\t%s\n", plugin->desc.origin);
1243 print_plugin_features (GstPlugin * plugin)
1246 gint num_features = 0;
1247 gint num_elements = 0;
1248 gint num_typefinders = 0;
1249 gint num_indexes = 0;
1253 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1257 GstPluginFeature *feature;
1259 feature = GST_PLUGIN_FEATURE (features->data);
1261 if (GST_IS_ELEMENT_FACTORY (feature)) {
1262 GstElementFactory *factory;
1264 factory = GST_ELEMENT_FACTORY (feature);
1265 n_print (" %s: %s\n", GST_PLUGIN_FEATURE_NAME (factory),
1266 gst_element_factory_get_longname (factory));
1268 } else if (GST_IS_INDEX_FACTORY (feature)) {
1269 GstIndexFactory *factory;
1271 factory = GST_INDEX_FACTORY (feature);
1272 n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
1274 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1275 GstTypeFindFactory *factory;
1277 factory = GST_TYPE_FIND_FACTORY (feature);
1278 if (factory->extensions) {
1281 g_print ("%s: %s: ", plugin->desc.name,
1282 gst_plugin_feature_get_name (feature));
1283 while (factory->extensions[i]) {
1284 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1289 g_print ("%s: %s: no extensions\n", plugin->desc.name,
1290 gst_plugin_feature_get_name (feature));
1293 } else if (feature) {
1294 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1295 g_type_name (G_OBJECT_TYPE (feature)));
1299 features = g_list_next (features);
1302 n_print (" %d features:\n", num_features);
1303 if (num_elements > 0)
1304 n_print (" +-- %d elements\n", num_elements);
1305 if (num_typefinders > 0)
1306 n_print (" +-- %d typefinders\n", num_typefinders);
1307 if (num_indexes > 0)
1308 n_print (" +-- %d indexes\n", num_indexes);
1310 n_print (" +-- %d other objects\n", num_other);
1316 print_element_features (const gchar * element_name)
1318 GstPluginFeature *feature;
1320 /* FIXME implement other pretty print function for these */
1321 feature = gst_default_registry_find_feature (element_name,
1322 GST_TYPE_INDEX_FACTORY);
1324 n_print ("%s: an index\n", element_name);
1327 feature = gst_default_registry_find_feature (element_name,
1328 GST_TYPE_TYPE_FIND_FACTORY);
1330 n_print ("%s: a typefind function\n", element_name);
1338 print_element_info (GstElementFactory * factory, gboolean print_names)
1340 GstElement *element;
1344 GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
1348 g_print ("element plugin couldn't be loaded\n");
1352 element = gst_element_factory_create (factory, NULL);
1354 g_print ("couldn't construct element for some reason\n");
1359 _name = g_strdup_printf ("%s: ", GST_PLUGIN_FEATURE (factory)->name);
1363 print_factory_details_info (factory);
1364 if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
1367 plugin = gst_registry_find_plugin (gst_registry_get_default (),
1368 GST_PLUGIN_FEATURE (factory)->plugin_name);
1370 print_plugin_info (plugin);
1374 print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
1375 print_interfaces (G_OBJECT_TYPE (element));
1377 print_pad_templates_info (element, factory);
1378 print_element_flag_info (element);
1379 print_implementation_info (element);
1380 print_clocking_info (element);
1381 print_index_info (element);
1382 print_uri_handler_info (element);
1383 print_pad_info (element);
1384 print_element_properties_info (element);
1385 print_signal_info (element);
1386 print_children_info (element);
1388 gst_object_unref (element);
1389 gst_object_unref (factory);
1397 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
1399 GstPadDirection direction;
1400 const gchar *type_name;
1402 const GList *static_templates, *l;
1403 GstCaps *caps = NULL;
1406 klass = gst_element_factory_get_klass (factory);
1407 g_return_if_fail (klass != NULL);
1409 if (strstr (klass, "Demuxer") ||
1410 strstr (klass, "Decoder") ||
1411 strstr (klass, "Depay") || strstr (klass, "Parser")) {
1412 type_name = "decoder";
1413 direction = GST_PAD_SINK;
1414 } else if (strstr (klass, "Muxer") ||
1415 strstr (klass, "Encoder") || strstr (klass, "Pay")) {
1416 type_name = "encoder";
1417 direction = GST_PAD_SRC;
1422 /* decoder/demuxer sink pads should always be static and there should only
1423 * be one, the same applies to encoders/muxers and source pads */
1424 static_templates = gst_element_factory_get_static_pad_templates (factory);
1425 for (l = static_templates; l != NULL; l = l->next) {
1426 GstStaticPadTemplate *tmpl = NULL;
1428 tmpl = (GstStaticPadTemplate *) l->data;
1429 if (tmpl->direction == direction) {
1430 caps = gst_static_pad_template_get_caps (tmpl);
1436 g_printerr ("Couldn't find static pad template for %s '%s'\n",
1437 type_name, GST_PLUGIN_FEATURE_NAME (factory));
1441 caps = gst_caps_make_writable (caps);
1442 num = gst_caps_get_size (caps);
1443 for (i = 0; i < num; ++i) {
1447 s = gst_caps_get_structure (caps, i);
1448 /* remove fields that are almost always just MIN-MAX of some sort
1449 * in order to make the caps look less messy */
1450 gst_structure_remove_field (s, "pixel-aspect-ratio");
1451 gst_structure_remove_field (s, "framerate");
1452 gst_structure_remove_field (s, "channels");
1453 gst_structure_remove_field (s, "width");
1454 gst_structure_remove_field (s, "height");
1455 gst_structure_remove_field (s, "rate");
1456 gst_structure_remove_field (s, "depth");
1457 gst_structure_remove_field (s, "clock-rate");
1458 s_str = gst_structure_to_string (s);
1459 g_print ("%s-%s\n", type_name, s_str);
1462 gst_caps_unref (caps);
1466 print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
1468 gchar **protocols, **p;
1470 protocols = gst_element_factory_get_uri_protocols (factory);
1471 if (protocols != NULL && *protocols != NULL) {
1472 switch (gst_element_factory_get_uri_type (factory)) {
1474 for (p = protocols; *p != NULL; ++p)
1475 g_print ("urisink-%s\n", *p);
1478 for (p = protocols; *p != NULL; ++p)
1479 g_print ("urisource-%s\n", *p);
1484 g_strfreev (protocols);
1489 print_plugin_automatic_install_info (GstPlugin * plugin)
1491 const gchar *plugin_name;
1492 GList *features, *l;
1494 plugin_name = gst_plugin_get_name (plugin);
1496 /* not interested in typefind factories, only element factories */
1497 features = gst_registry_get_feature_list (gst_registry_get_default (),
1498 GST_TYPE_ELEMENT_FACTORY);
1500 for (l = features; l != NULL; l = l->next) {
1501 GstPluginFeature *feature;
1503 feature = GST_PLUGIN_FEATURE (l->data);
1505 /* only interested in the ones that are in the plugin we just loaded */
1506 if (g_str_equal (plugin_name, feature->plugin_name)) {
1507 GstElementFactory *factory;
1509 g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
1511 factory = GST_ELEMENT_FACTORY (feature);
1512 print_plugin_automatic_install_info_protocols (factory);
1513 print_plugin_automatic_install_info_codecs (factory);
1517 g_list_foreach (features, (GFunc) gst_object_unref, NULL);
1518 g_list_free (features);
1522 print_all_plugin_automatic_install_info (void)
1524 GList *plugins, *orig_plugins;
1526 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
1530 plugin = (GstPlugin *) (plugins->data);
1531 plugins = g_list_next (plugins);
1533 print_plugin_automatic_install_info (plugin);
1535 gst_plugin_list_free (orig_plugins);
1539 main (int argc, char *argv[])
1541 gboolean print_all = FALSE;
1542 gboolean do_print_blacklist = FALSE;
1543 gboolean plugin_name = FALSE;
1544 gboolean print_aii = FALSE;
1545 gboolean uri_handlers = FALSE;
1546 #ifndef GST_DISABLE_OPTION_PARSING
1547 GOptionEntry options[] = {
1548 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
1549 N_("Print all elements"), NULL},
1550 {"print-blacklist", 'b', 0, G_OPTION_ARG_NONE, &do_print_blacklist,
1551 N_("Print list of blacklisted files"), NULL},
1552 {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
1553 N_("Print a machine-parsable list of features the specified plugin "
1554 "or all plugins provide.\n "
1555 "Useful in connection with external automatic plugin "
1556 "installation mechanisms"), NULL},
1557 {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
1558 N_("List the plugin contents"), NULL},
1559 {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
1561 ("Print supported URI schemes, with the elements that implement them"),
1563 GST_TOOLS_GOPTION_VERSION,
1566 GOptionContext *ctx;
1571 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1572 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1573 textdomain (GETTEXT_PACKAGE);
1576 g_thread_init (NULL);
1578 gst_tools_set_prgname ("gst-inspect");
1580 #ifndef GST_DISABLE_OPTION_PARSING
1581 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
1582 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
1583 g_option_context_add_group (ctx, gst_init_get_option_group ());
1584 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1585 g_print ("Error initializing: %s\n", err->message);
1588 g_option_context_free (ctx);
1590 gst_init (&argc, &argv);
1593 gst_tools_print_version ("gst-inspect");
1595 if (print_all && argc > 1) {
1596 g_print ("-a requires no extra arguments\n");
1600 if (uri_handlers && argc > 1) {
1601 g_print ("-u requires no extra arguments\n");
1605 /* if no arguments, print out list of elements */
1607 print_all_uri_handlers ();
1608 } else if (argc == 1 || print_all) {
1609 if (do_print_blacklist)
1613 print_all_plugin_automatic_install_info ();
1615 print_element_list (print_all);
1618 /* else we try to get a factory */
1619 GstElementFactory *factory;
1621 const char *arg = argv[argc - 1];
1625 factory = gst_element_factory_find (arg);
1627 /* if there's a factory, print out the info */
1629 retval = print_element_info (factory, print_all);
1630 gst_object_unref (factory);
1632 retval = print_element_features (arg);
1638 /* otherwise check if it's a plugin */
1640 plugin = gst_default_registry_find_plugin (arg);
1642 /* if there is such a plugin, print out info */
1645 print_plugin_automatic_install_info (plugin);
1647 print_plugin_info (plugin);
1648 print_plugin_features (plugin);
1651 GError *error = NULL;
1653 if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
1654 plugin = gst_plugin_load_file (arg, &error);
1658 print_plugin_automatic_install_info (plugin);
1660 print_plugin_info (plugin);
1661 print_plugin_features (plugin);
1664 g_print (_("Could not load plugin file: %s\n"), error->message);
1665 g_error_free (error);
1669 g_print (_("No such element or plugin '%s'\n"), arg);