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_info (GstElementFactory * factory)
206 n_print ("Factory Details:\n");
207 n_print (" Long name:\t%s\n", factory->details.longname);
208 n_print (" Class:\t%s\n", factory->details.klass);
209 n_print (" Description:\t%s\n", factory->details.description);
210 n_print (" Author(s):\t%s\n", factory->details.author);
211 n_print (" Rank:\t\t%s (%d)\n",
212 get_rank_name (s, GST_PLUGIN_FEATURE (factory)->rank),
213 GST_PLUGIN_FEATURE (factory)->rank);
218 print_hierarchy (GType type, gint level, gint * maxlevel)
223 parent = g_type_parent (type);
225 *maxlevel = *maxlevel + 1;
229 print_hierarchy (parent, level, maxlevel);
232 g_print ("%s", _name);
234 for (i = 1; i < *maxlevel - level; i++)
236 if (*maxlevel - level)
239 g_print ("%s\n", g_type_name (type));
246 print_interfaces (GType type)
249 GType *iface, *ifaces = g_type_interfaces (type, &n_ifaces);
254 g_print ("%s", _name);
255 g_print (_("Implemented Interfaces:\n"));
259 g_print ("%s", _name);
260 g_print (" %s\n", g_type_name (*iface));
264 g_print ("%s", _name);
272 flags_to_string (GFlagsValue * vals, guint flags)
277 /* first look for an exact match and count the number of values */
278 for (i = 0; vals[i].value_name != NULL; ++i) {
279 if (vals[i].value == flags)
280 return g_strdup (vals[i].value_nick);
283 s = g_string_new (NULL);
285 /* we assume the values are sorted from lowest to highest value */
289 if (vals[i].value != 0 && (flags_left & vals[i].value) == vals[i].value) {
291 g_string_append (s, " | ");
292 g_string_append (s, vals[i].value_nick);
293 flags_left -= vals[i].value;
300 g_string_assign (s, "(none)");
302 return g_string_free (s, FALSE);
306 print_element_properties_info (GstElement * element)
308 GParamSpec **property_specs;
309 guint num_properties, i;
313 property_specs = g_object_class_list_properties
314 (G_OBJECT_GET_CLASS (element), &num_properties);
316 n_print ("Element Properties:\n");
318 for (i = 0; i < num_properties; i++) {
319 GValue value = { 0, };
320 GParamSpec *param = property_specs[i];
324 g_value_init (&value, param->value_type);
326 n_print (" %-20s: %s\n", g_param_spec_get_name (param),
327 g_param_spec_get_blurb (param));
330 n_print ("%-23.23s flags: ", "");
331 if (param->flags & G_PARAM_READABLE) {
332 g_object_get_property (G_OBJECT (element), param->name, &value);
338 g_print (_("readable"));
340 if (param->flags & G_PARAM_WRITABLE) {
345 g_print (_("writable"));
347 if (param->flags & GST_PARAM_CONTROLLABLE) {
350 g_print (_("controllable"));
354 switch (G_VALUE_TYPE (&value)) {
357 GParamSpecString *pstring = G_PARAM_SPEC_STRING (param);
359 n_print ("%-23.23s String. ", "");
361 if (pstring->default_value == NULL)
362 g_print ("Default: null ");
364 g_print ("Default: \"%s\" ", pstring->default_value);
367 const char *string_val = g_value_get_string (&value);
369 if (string_val == NULL)
370 g_print ("Current: null");
372 g_print ("Current: \"%s\"", string_val);
378 GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param);
380 n_print ("%-23.23s Boolean. ", "");
381 g_print ("Default: %s ", (pboolean->default_value ? "true" : "false"));
383 g_print ("Current: %s",
384 (g_value_get_boolean (&value) ? "true" : "false"));
389 GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
391 n_print ("%-23.23s Unsigned Long. ", "");
392 g_print ("Range: %lu - %lu Default: %lu ",
393 pulong->minimum, pulong->maximum, pulong->default_value);
395 g_print ("Current: %lu", g_value_get_ulong (&value));
400 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
402 n_print ("%-23.23s Long. ", "");
403 g_print ("Range: %ld - %ld Default: %ld ",
404 plong->minimum, plong->maximum, plong->default_value);
406 g_print ("Current: %ld", g_value_get_long (&value));
411 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
413 n_print ("%-23.23s Unsigned Integer. ", "");
414 g_print ("Range: %u - %u Default: %u ",
415 puint->minimum, puint->maximum, puint->default_value);
417 g_print ("Current: %u", g_value_get_uint (&value));
422 GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
424 n_print ("%-23.23s Integer. ", "");
425 g_print ("Range: %d - %d Default: %d ",
426 pint->minimum, pint->maximum, pint->default_value);
428 g_print ("Current: %d", g_value_get_int (&value));
433 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
435 n_print ("%-23.23s Unsigned Integer64. ", "");
436 g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
437 " Default: %" G_GUINT64_FORMAT " ",
438 puint64->minimum, puint64->maximum, puint64->default_value);
440 g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value));
445 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
447 n_print ("%-23.23s Integer64. ", "");
448 g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
449 " Default: %" G_GINT64_FORMAT " ",
450 pint64->minimum, pint64->maximum, pint64->default_value);
452 g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value));
457 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
459 n_print ("%-23.23s Float. ", "");
460 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
461 pfloat->minimum, pfloat->maximum, pfloat->default_value);
463 g_print ("Current: %15.7g", g_value_get_float (&value));
468 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
470 n_print ("%-23.23s Double. ", "");
471 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
472 pdouble->minimum, pdouble->maximum, pdouble->default_value);
474 g_print ("Current: %15.7g", g_value_get_double (&value));
478 if (param->value_type == GST_TYPE_CAPS) {
479 const GstCaps *caps = gst_value_get_caps (&value);
482 n_print ("%-23.23s Caps (NULL)", "");
484 print_caps (caps, " ");
486 } else if (G_IS_PARAM_SPEC_ENUM (param)) {
487 GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param);
491 const gchar *def_val_nick = "", *cur_val_nick = "";
493 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
494 enum_value = g_value_get_enum (&value);
496 while (values[j].value_name) {
497 if (values[j].value == enum_value)
498 cur_val_nick = values[j].value_nick;
499 if (values[j].value == penum->default_value)
500 def_val_nick = values[j].value_nick;
505 ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"",
506 "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value,
507 def_val_nick, enum_value, cur_val_nick);
510 while (values[j].value_name) {
513 g_print ("%s", _name);
514 g_print ("%-23.23s (%d): %-16s - %s", "",
515 values[j].value, values[j].value_nick, values[j].value_name);
518 /* g_type_class_unref (ec); */
519 } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
520 GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
524 vals = pflags->flags_class->values;
526 cur = flags_to_string (vals, g_value_get_flags (&value));
527 def = flags_to_string (vals, pflags->default_value);
530 ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"",
531 "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value,
532 def, 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);
545 } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
546 n_print ("%-23.23s Object of type \"%s\"", "",
547 g_type_name (param->value_type));
548 } else if (G_IS_PARAM_SPEC_BOXED (param)) {
549 n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
550 g_type_name (param->value_type));
551 } else if (G_IS_PARAM_SPEC_POINTER (param)) {
552 if (param->value_type != G_TYPE_POINTER) {
553 n_print ("%-23.23s Pointer of type \"%s\".", "",
554 g_type_name (param->value_type));
556 n_print ("%-23.23s Pointer.", "");
558 } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
559 GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);
561 if (pvarray->element_spec) {
562 n_print ("%-23.23s Array of GValues of type \"%s\"", "",
563 g_type_name (pvarray->element_spec->value_type));
565 n_print ("%-23.23s Array of GValues", "");
567 } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
568 GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);
570 n_print ("%-23.23s Fraction. ", "");
572 g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
573 pfraction->min_num, pfraction->min_den,
574 pfraction->max_num, pfraction->max_den,
575 pfraction->def_num, pfraction->def_den);
577 g_print ("Current: %d/%d",
578 gst_value_get_fraction_numerator (&value),
579 gst_value_get_fraction_denominator (&value));
581 } else if (GST_IS_PARAM_SPEC_MINI_OBJECT (param)) {
582 n_print ("%-23.23s MiniObject of type \"%s\"", "",
583 g_type_name (param->value_type));
585 n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
586 g_type_name (param->value_type));
591 g_print (" Write only\n");
595 g_value_reset (&value);
597 if (num_properties == 0)
600 g_free (property_specs);
604 print_pad_templates_info (GstElement * element, GstElementFactory * factory)
606 GstElementClass *gstelement_class;
608 GstStaticPadTemplate *padtemplate;
610 n_print ("Pad Templates:\n");
611 if (!factory->numpadtemplates) {
616 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
618 pads = factory->staticpadtemplates;
620 padtemplate = (GstStaticPadTemplate *) (pads->data);
621 pads = g_list_next (pads);
623 if (padtemplate->direction == GST_PAD_SRC)
624 n_print (" SRC template: '%s'\n", padtemplate->name_template);
625 else if (padtemplate->direction == GST_PAD_SINK)
626 n_print (" SINK template: '%s'\n", padtemplate->name_template);
628 n_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
630 if (padtemplate->presence == GST_PAD_ALWAYS)
631 n_print (" Availability: Always\n");
632 else if (padtemplate->presence == GST_PAD_SOMETIMES)
633 n_print (" Availability: Sometimes\n");
634 else if (padtemplate->presence == GST_PAD_REQUEST) {
635 n_print (" Availability: On request\n");
636 n_print (" Has request_new_pad() function: %s\n",
637 GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
639 n_print (" Availability: UNKNOWN!!!\n");
641 if (padtemplate->static_caps.string) {
642 n_print (" Capabilities:\n");
643 print_caps (gst_static_caps_get (&padtemplate->static_caps), " ");
651 print_element_flag_info (GstElement * element)
653 gboolean have_flags = FALSE;
656 n_print ("Element Flags:\n");
659 n_print (" no flags set\n");
661 if (GST_IS_BIN (element)) {
663 n_print ("Bin Flags:\n");
665 n_print (" no flags set\n");
670 print_implementation_info (GstElement * element)
672 GstObjectClass *gstobject_class;
673 GstElementClass *gstelement_class;
675 gstobject_class = GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (element));
676 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
679 n_print ("Element Implementation:\n");
681 n_print (" Has change_state() function: %s\n",
682 GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
683 #ifndef GST_DISABLE_LOADSAVE
684 n_print (" Has custom save_thyself() function: %s\n",
685 GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
686 n_print (" Has custom restore_thyself() function: %s\n",
687 GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
692 print_clocking_info (GstElement * element)
694 if (!gst_element_requires_clock (element) &&
695 !(gst_element_provides_clock (element) &&
696 gst_element_get_clock (element))) {
698 n_print ("Element has no clocking capabilities.");
703 n_print ("Clocking Interaction:\n");
704 if (gst_element_requires_clock (element)) {
705 n_print (" element requires a clock\n");
708 if (gst_element_provides_clock (element)) {
711 clock = gst_element_get_clock (element);
713 n_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock));
715 n_print (" element is supposed to provide a clock but returned NULL\n");
720 print_index_info (GstElement * element)
722 if (gst_element_is_indexable (element)) {
724 n_print ("Indexing capabilities:\n");
725 n_print (" element can do indexing\n");
728 n_print ("Element has no indexing capabilities.\n");
733 print_uri_handler_info (GstElement * element)
735 if (GST_IS_URI_HANDLER (element)) {
736 const gchar *uri_type;
737 gchar **uri_protocols;
739 if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC)
741 else if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) ==
745 uri_type = "unknown";
747 uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
750 n_print ("URI handling capabilities:\n");
751 n_print (" Element can act as %s.\n", uri_type);
753 if (uri_protocols && *uri_protocols) {
754 n_print (" Supported URI protocols:\n");
755 for (; *uri_protocols != NULL; uri_protocols++)
756 n_print (" %s\n", *uri_protocols);
758 n_print (" No supported URI protocols\n");
761 n_print ("Element has no URI handling capabilities.\n");
766 print_pad_info (GstElement * element)
774 if (!element->numpads) {
779 pads = element->pads;
783 pad = GST_PAD (pads->data);
784 pads = g_list_next (pads);
788 name = gst_pad_get_name (pad);
789 if (gst_pad_get_direction (pad) == GST_PAD_SRC)
790 g_print (" SRC: '%s'", name);
791 else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
792 g_print (" SINK: '%s'", name);
794 g_print (" UNKNOWN!!!: '%s'", name);
800 n_print (" Implementation:\n");
802 n_print (" Has chainfunc(): %s\n",
803 GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
804 if (pad->getrangefunc)
805 n_print (" Has getrangefunc(): %s\n",
806 GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
807 if (pad->eventfunc != gst_pad_event_default)
808 n_print (" Has custom eventfunc(): %s\n",
809 GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
810 if (pad->queryfunc != gst_pad_query_default)
811 n_print (" Has custom queryfunc(): %s\n",
812 GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
813 if (pad->querytypefunc != gst_pad_get_query_types_default) {
814 n_print (" Provides query types:\n");
815 print_query_types (gst_pad_get_query_types (pad));
818 if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default)
819 n_print (" Has custom iterintlinkfunc(): %s\n",
820 GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc));
822 if (pad->bufferallocfunc)
823 n_print (" Has bufferallocfunc(): %s\n",
824 GST_DEBUG_FUNCPTR_NAME (pad->bufferallocfunc));
826 if (pad->padtemplate)
827 n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template);
830 n_print (" Capabilities:\n");
831 print_caps (pad->caps, " ");
838 compare_signal_names (GSignalQuery * a, GSignalQuery * b)
840 return strcmp (a->signal_name, b->signal_name);
845 print_signal_info (GstElement * element)
847 /* Signals/Actions Block */
851 GSignalQuery *query = NULL;
853 GSList *found_signals, *l;
855 for (k = 0; k < 2; k++) {
856 found_signals = NULL;
857 for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
858 if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
861 if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
864 signals = g_signal_list_ids (type, &nsignals);
865 for (i = 0; i < nsignals; i++) {
866 query = g_new0 (GSignalQuery, 1);
867 g_signal_query (signals[i], query);
869 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
870 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
871 found_signals = g_slist_append (found_signals, query);
882 n_print ("Element Signals:\n");
884 n_print ("Element Actions:\n");
889 for (l = found_signals; l; l = l->next) {
893 query = (GSignalQuery *) l->data;
894 indent_len = strlen (query->signal_name) +
895 strlen (g_type_name (query->return_type)) + 24;
897 indent = g_new0 (gchar, indent_len + 1);
898 memset (indent, ' ', indent_len);
900 n_print (" \"%s\" : %s user_function (%s* object",
902 g_type_name (query->return_type), g_type_name (type));
904 for (j = 0; j < query->n_params; j++) {
906 g_print ("%s", _name);
907 if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
908 g_print (",\n%s%s arg%d", indent,
909 g_type_name (query->param_types[j]), j);
910 } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
911 g_print (",\n%s%s arg%d", indent,
912 g_type_name (query->param_types[j]), j);
914 g_print (",\n%s%s* arg%d", indent,
915 g_type_name (query->param_types[j]), j);
921 g_print ("%s", _name);
922 g_print (",\n%sgpointer user_data);\n", indent);
930 g_slist_foreach (found_signals, (GFunc) g_free, NULL);
931 g_slist_free (found_signals);
937 print_children_info (GstElement * element)
941 if (!GST_IS_BIN (element))
944 children = (GList *) GST_BIN (element)->children;
947 g_print ("Children:\n");
951 n_print (" %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
952 children = g_list_next (children);
957 print_blacklist (void)
959 GList *plugins, *cur;
962 g_print ("%s\n", _("Blacklisted files:"));
964 plugins = gst_default_registry_get_plugin_list ();
965 for (cur = plugins; cur != NULL; cur = g_list_next (cur)) {
966 GstPlugin *plugin = (GstPlugin *) (cur->data);
967 if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
968 g_print (" %s\n", plugin->desc.name);
974 g_print (_("Total count: "));
975 g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count),
978 gst_plugin_list_free (plugins);
982 print_element_list (gboolean print_all)
984 int plugincount = 0, featurecount = 0, blacklistcount = 0;
985 GList *plugins, *orig_plugins;
987 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
989 GList *features, *orig_features;
992 plugin = (GstPlugin *) (plugins->data);
993 plugins = g_list_next (plugins);
996 if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
1001 orig_features = features =
1002 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1005 GstPluginFeature *feature;
1007 if (G_UNLIKELY (features->data == NULL))
1009 feature = GST_PLUGIN_FEATURE (features->data);
1012 if (GST_IS_ELEMENT_FACTORY (feature)) {
1013 GstElementFactory *factory;
1015 factory = GST_ELEMENT_FACTORY (feature);
1017 print_element_info (factory, TRUE);
1019 g_print ("%s: %s: %s\n", plugin->desc.name,
1020 GST_PLUGIN_FEATURE_NAME (factory),
1021 gst_element_factory_get_longname (factory));
1022 } else if (GST_IS_INDEX_FACTORY (feature)) {
1023 GstIndexFactory *factory;
1025 factory = GST_INDEX_FACTORY (feature);
1027 g_print ("%s: %s: %s\n", plugin->desc.name,
1028 GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
1029 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1030 GstTypeFindFactory *factory;
1032 factory = GST_TYPE_FIND_FACTORY (feature);
1034 g_print ("%s: %s: ", plugin->desc.name,
1035 gst_plugin_feature_get_name (feature));
1036 if (factory->extensions) {
1039 while (factory->extensions[i]) {
1041 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1048 g_print ("no extensions\n");
1052 n_print ("%s: %s (%s)\n", plugin->desc.name,
1053 GST_PLUGIN_FEATURE_NAME (feature),
1054 g_type_name (G_OBJECT_TYPE (feature)));
1058 features = g_list_next (features);
1061 gst_plugin_feature_list_free (orig_features);
1064 gst_plugin_list_free (orig_plugins);
1067 g_print (_("Total count: "));
1068 g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
1069 if (blacklistcount) {
1071 g_print (ngettext ("%d blacklist entry", "%d blacklist entries",
1072 blacklistcount), blacklistcount);
1073 g_print (" not shown)");
1076 g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
1081 print_all_uri_handlers (void)
1083 GList *plugins, *p, *features, *f;
1085 plugins = gst_default_registry_get_plugin_list ();
1087 for (p = plugins; p; p = p->next) {
1088 GstPlugin *plugin = (GstPlugin *) (p->data);
1091 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1094 for (f = features; f; f = f->next) {
1095 GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data);
1097 if (GST_IS_ELEMENT_FACTORY (feature)) {
1098 GstElementFactory *factory;
1099 GstElement *element;
1101 factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
1103 g_print ("element plugin %s couldn't be loaded\n", plugin->desc.name);
1107 element = gst_element_factory_create (factory, NULL);
1109 g_print ("couldn't construct element for %s for some reason\n",
1110 GST_OBJECT_NAME (factory));
1111 gst_object_unref (factory);
1115 if (GST_IS_URI_HANDLER (element)) {
1117 gchar **uri_protocols, *joined;
1119 switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
1132 gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
1133 joined = g_strjoinv (", ", uri_protocols);
1135 g_print ("%s (%s, rank %u): %s\n", GST_OBJECT_NAME (factory), dir,
1136 gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
1140 //g_strfreev (uri_protocols);
1143 gst_object_unref (element);
1144 gst_object_unref (factory);
1148 gst_plugin_feature_list_free (features);
1151 gst_plugin_list_free (plugins);
1155 print_plugin_info (GstPlugin * plugin)
1157 n_print ("Plugin Details:\n");
1158 n_print (" Name:\t\t\t%s\n", plugin->desc.name);
1159 n_print (" Description:\t\t%s\n", plugin->desc.description);
1160 n_print (" Filename:\t\t%s\n",
1161 plugin->filename ? plugin->filename : "(null)");
1162 n_print (" Version:\t\t%s\n", plugin->desc.version);
1163 n_print (" License:\t\t%s\n", plugin->desc.license);
1164 n_print (" Source module:\t%s\n", plugin->desc.source);
1165 n_print (" Binary package:\t%s\n", plugin->desc.package);
1166 n_print (" Origin URL:\t\t%s\n", plugin->desc.origin);
1171 print_plugin_features (GstPlugin * plugin)
1174 gint num_features = 0;
1175 gint num_elements = 0;
1176 gint num_typefinders = 0;
1177 gint num_indexes = 0;
1181 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1185 GstPluginFeature *feature;
1187 feature = GST_PLUGIN_FEATURE (features->data);
1189 if (GST_IS_ELEMENT_FACTORY (feature)) {
1190 GstElementFactory *factory;
1192 factory = GST_ELEMENT_FACTORY (feature);
1193 n_print (" %s: %s\n", GST_PLUGIN_FEATURE_NAME (factory),
1194 gst_element_factory_get_longname (factory));
1196 } else if (GST_IS_INDEX_FACTORY (feature)) {
1197 GstIndexFactory *factory;
1199 factory = GST_INDEX_FACTORY (feature);
1200 n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
1202 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1203 GstTypeFindFactory *factory;
1205 factory = GST_TYPE_FIND_FACTORY (feature);
1206 if (factory->extensions) {
1209 g_print ("%s: %s: ", plugin->desc.name,
1210 gst_plugin_feature_get_name (feature));
1211 while (factory->extensions[i]) {
1212 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1217 g_print ("%s: %s: no extensions\n", plugin->desc.name,
1218 gst_plugin_feature_get_name (feature));
1221 } else if (feature) {
1222 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1223 g_type_name (G_OBJECT_TYPE (feature)));
1227 features = g_list_next (features);
1230 n_print (" %d features:\n", num_features);
1231 if (num_elements > 0)
1232 n_print (" +-- %d elements\n", num_elements);
1233 if (num_typefinders > 0)
1234 n_print (" +-- %d typefinders\n", num_typefinders);
1235 if (num_indexes > 0)
1236 n_print (" +-- %d indexes\n", num_indexes);
1238 n_print (" +-- %d other objects\n", num_other);
1244 print_element_features (const gchar * element_name)
1246 GstPluginFeature *feature;
1248 /* FIXME implement other pretty print function for these */
1249 feature = gst_default_registry_find_feature (element_name,
1250 GST_TYPE_INDEX_FACTORY);
1252 n_print ("%s: an index\n", element_name);
1255 feature = gst_default_registry_find_feature (element_name,
1256 GST_TYPE_TYPE_FIND_FACTORY);
1258 n_print ("%s: a typefind function\n", element_name);
1266 print_element_info (GstElementFactory * factory, gboolean print_names)
1268 GstElement *element;
1272 GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
1276 g_print ("element plugin couldn't be loaded\n");
1280 element = gst_element_factory_create (factory, NULL);
1282 g_print ("couldn't construct element for some reason\n");
1287 _name = g_strdup_printf ("%s: ", GST_PLUGIN_FEATURE (factory)->name);
1291 print_factory_details_info (factory);
1292 if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
1295 plugin = gst_registry_find_plugin (gst_registry_get_default (),
1296 GST_PLUGIN_FEATURE (factory)->plugin_name);
1298 print_plugin_info (plugin);
1302 print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
1303 print_interfaces (G_OBJECT_TYPE (element));
1305 print_pad_templates_info (element, factory);
1306 print_element_flag_info (element);
1307 print_implementation_info (element);
1308 print_clocking_info (element);
1309 print_index_info (element);
1310 print_uri_handler_info (element);
1311 print_pad_info (element);
1312 print_element_properties_info (element);
1313 print_signal_info (element);
1314 print_children_info (element);
1316 gst_object_unref (element);
1317 gst_object_unref (factory);
1325 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
1327 GstPadDirection direction;
1328 const gchar *type_name;
1330 const GList *static_templates, *l;
1331 GstCaps *caps = NULL;
1334 klass = gst_element_factory_get_klass (factory);
1335 g_return_if_fail (klass != NULL);
1337 if (strstr (klass, "Demuxer") ||
1338 strstr (klass, "Decoder") ||
1339 strstr (klass, "Depay") || strstr (klass, "Parser")) {
1340 type_name = "decoder";
1341 direction = GST_PAD_SINK;
1342 } else if (strstr (klass, "Muxer") ||
1343 strstr (klass, "Encoder") || strstr (klass, "Pay")) {
1344 type_name = "encoder";
1345 direction = GST_PAD_SRC;
1350 /* decoder/demuxer sink pads should always be static and there should only
1351 * be one, the same applies to encoders/muxers and source pads */
1352 static_templates = gst_element_factory_get_static_pad_templates (factory);
1353 for (l = static_templates; l != NULL; l = l->next) {
1354 GstStaticPadTemplate *tmpl = NULL;
1356 tmpl = (GstStaticPadTemplate *) l->data;
1357 if (tmpl->direction == direction) {
1358 caps = gst_static_pad_template_get_caps (tmpl);
1364 g_printerr ("Couldn't find static pad template for %s '%s'\n",
1365 type_name, GST_PLUGIN_FEATURE_NAME (factory));
1369 caps = gst_caps_make_writable (caps);
1370 num = gst_caps_get_size (caps);
1371 for (i = 0; i < num; ++i) {
1375 s = gst_caps_get_structure (caps, i);
1376 /* remove fields that are almost always just MIN-MAX of some sort
1377 * in order to make the caps look less messy */
1378 gst_structure_remove_field (s, "pixel-aspect-ratio");
1379 gst_structure_remove_field (s, "framerate");
1380 gst_structure_remove_field (s, "channels");
1381 gst_structure_remove_field (s, "width");
1382 gst_structure_remove_field (s, "height");
1383 gst_structure_remove_field (s, "rate");
1384 gst_structure_remove_field (s, "depth");
1385 gst_structure_remove_field (s, "clock-rate");
1386 s_str = gst_structure_to_string (s);
1387 g_print ("%s-%s\n", type_name, s_str);
1390 gst_caps_unref (caps);
1394 print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
1396 gchar **protocols, **p;
1398 protocols = gst_element_factory_get_uri_protocols (factory);
1399 if (protocols != NULL && *protocols != NULL) {
1400 switch (gst_element_factory_get_uri_type (factory)) {
1402 for (p = protocols; *p != NULL; ++p)
1403 g_print ("urisink-%s\n", *p);
1406 for (p = protocols; *p != NULL; ++p)
1407 g_print ("urisource-%s\n", *p);
1412 g_strfreev (protocols);
1417 print_plugin_automatic_install_info (GstPlugin * plugin)
1419 const gchar *plugin_name;
1420 GList *features, *l;
1422 plugin_name = gst_plugin_get_name (plugin);
1424 /* not interested in typefind factories, only element factories */
1425 features = gst_registry_get_feature_list (gst_registry_get_default (),
1426 GST_TYPE_ELEMENT_FACTORY);
1428 for (l = features; l != NULL; l = l->next) {
1429 GstPluginFeature *feature;
1431 feature = GST_PLUGIN_FEATURE (l->data);
1433 /* only interested in the ones that are in the plugin we just loaded */
1434 if (g_str_equal (plugin_name, feature->plugin_name)) {
1435 GstElementFactory *factory;
1437 g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
1439 factory = GST_ELEMENT_FACTORY (feature);
1440 print_plugin_automatic_install_info_protocols (factory);
1441 print_plugin_automatic_install_info_codecs (factory);
1445 g_list_foreach (features, (GFunc) gst_object_unref, NULL);
1446 g_list_free (features);
1450 print_all_plugin_automatic_install_info (void)
1452 GList *plugins, *orig_plugins;
1454 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
1458 plugin = (GstPlugin *) (plugins->data);
1459 plugins = g_list_next (plugins);
1461 print_plugin_automatic_install_info (plugin);
1463 gst_plugin_list_free (orig_plugins);
1467 main (int argc, char *argv[])
1469 gboolean print_all = FALSE;
1470 gboolean do_print_blacklist = FALSE;
1471 gboolean plugin_name = FALSE;
1472 gboolean print_aii = FALSE;
1473 gboolean uri_handlers = FALSE;
1474 #ifndef GST_DISABLE_OPTION_PARSING
1475 GOptionEntry options[] = {
1476 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
1477 N_("Print all elements"), NULL},
1478 {"print-blacklist", 'b', 0, G_OPTION_ARG_NONE, &do_print_blacklist,
1479 N_("Print list of blacklisted files"), NULL},
1480 {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
1481 N_("Print a machine-parsable list of features the specified plugin "
1482 "or all plugins provide.\n "
1483 "Useful in connection with external automatic plugin "
1484 "installation mechanisms"), NULL},
1485 {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
1486 N_("List the plugin contents"), NULL},
1487 {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
1489 ("Print supported URI schemes, with the elements that implement them"),
1491 GST_TOOLS_GOPTION_VERSION,
1494 GOptionContext *ctx;
1499 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1500 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1501 textdomain (GETTEXT_PACKAGE);
1504 g_thread_init (NULL);
1506 gst_tools_set_prgname ("gst-inspect");
1508 #ifndef GST_DISABLE_OPTION_PARSING
1509 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
1510 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
1511 g_option_context_add_group (ctx, gst_init_get_option_group ());
1512 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1513 g_print ("Error initializing: %s\n", err->message);
1516 g_option_context_free (ctx);
1518 gst_init (&argc, &argv);
1521 gst_tools_print_version ("gst-inspect");
1523 if (print_all && argc > 1) {
1524 g_print ("-a requires no extra arguments\n");
1528 if (uri_handlers && argc > 1) {
1529 g_print ("-u requires no extra arguments\n");
1533 /* if no arguments, print out list of elements */
1535 print_all_uri_handlers ();
1536 } else if (argc == 1 || print_all) {
1537 if (do_print_blacklist)
1541 print_all_plugin_automatic_install_info ();
1543 print_element_list (print_all);
1546 /* else we try to get a factory */
1547 GstElementFactory *factory;
1549 const char *arg = argv[argc - 1];
1553 factory = gst_element_factory_find (arg);
1555 /* if there's a factory, print out the info */
1557 retval = print_element_info (factory, print_all);
1558 gst_object_unref (factory);
1560 retval = print_element_features (arg);
1566 /* otherwise check if it's a plugin */
1568 plugin = gst_default_registry_find_plugin (arg);
1570 /* if there is such a plugin, print out info */
1573 print_plugin_automatic_install_info (plugin);
1575 print_plugin_info (plugin);
1576 print_plugin_features (plugin);
1579 GError *error = NULL;
1581 if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
1582 plugin = gst_plugin_load_file (arg, &error);
1586 print_plugin_automatic_install_info (plugin);
1588 print_plugin_info (plugin);
1589 print_plugin_features (plugin);
1592 g_print (_("Could not load plugin file: %s\n"), error->message);
1593 g_error_free (error);
1597 g_print (_("No such element or plugin '%s'\n"), arg);