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, ...)
48 g_print ("%s", _name);
50 va_start (args, format);
51 retval = g_vprintf (format, args);
56 print_field (GQuark field, const GValue * value, gpointer pfx)
58 gchar *str = gst_value_serialize (value);
60 n_print ("%s %15s: %s\n", (gchar *) pfx, g_quark_to_string (field), str);
66 print_caps (const GstCaps * caps, const gchar * pfx)
70 g_return_if_fail (caps != NULL);
72 if (gst_caps_is_any (caps)) {
73 n_print ("%sANY\n", pfx);
76 if (gst_caps_is_empty (caps)) {
77 n_print ("%sEMPTY\n", pfx);
81 for (i = 0; i < gst_caps_get_size (caps); i++) {
82 GstStructure *structure = gst_caps_get_structure (caps, i);
84 n_print ("%s%s\n", pfx, gst_structure_get_name (structure));
85 gst_structure_foreach (structure, print_field, (gpointer) pfx);
91 print_formats (const GstFormat * formats)
93 while (formats && *formats) {
94 const GstFormatDefinition *definition;
96 definition = gst_format_get_details (*formats);
98 n_print ("\t\t(%d):\t%s (%s)\n", *formats,
99 definition->nick, definition->description);
101 n_print ("\t\t(%d):\tUnknown format\n", *formats);
109 print_query_types (const GstQueryType * types)
111 while (types && *types) {
112 const GstQueryTypeDefinition *definition;
114 definition = gst_query_type_get_details (*types);
116 n_print ("\t\t(%d):\t%s (%s)\n", *types,
117 definition->nick, definition->description);
119 n_print ("\t\t(%d):\tUnknown query format\n", *types);
127 print_event_masks (const GstEventMask * masks)
132 GFlagsClass *flags_class = NULL;
134 event_type = gst_event_type_get_type ();
135 klass = (GEnumClass *) g_type_class_ref (event_type);
137 while (masks && masks->type) {
139 gint flags = 0, index = 0;
141 switch (masks->type) {
143 flags = masks->flags;
144 event_flags = gst_seek_type_get_type ();
145 flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
151 value = g_enum_get_value (klass, masks->type);
152 g_print ("\t\t%s ", value->value_nick);
158 value = g_flags_get_first_value (flags_class, 1 << index);
161 g_print ("| %s ", value->value_nick);
176 get_rank_name (gint rank)
181 case GST_RANK_MARGINAL:
183 case GST_RANK_SECONDARY:
185 case GST_RANK_PRIMARY:
193 print_factory_details_info (GstElementFactory * factory)
195 n_print ("Factory Details:\n");
196 n_print (" Long name:\t%s\n", factory->details.longname);
197 n_print (" Class:\t%s\n", factory->details.klass);
198 n_print (" Description:\t%s\n", factory->details.description);
199 n_print (" Author(s):\t%s\n", factory->details.author);
200 n_print (" Rank:\t\t%s (%d)\n",
201 get_rank_name (GST_PLUGIN_FEATURE (factory)->rank),
202 GST_PLUGIN_FEATURE (factory)->rank);
207 print_hierarchy (GType type, gint level, gint * maxlevel)
212 parent = g_type_parent (type);
214 *maxlevel = *maxlevel + 1;
218 print_hierarchy (parent, level, maxlevel);
221 g_print ("%s", _name);
223 for (i = 1; i < *maxlevel - level; i++)
225 if (*maxlevel - level)
228 g_print ("%s\n", g_type_name (type));
235 print_interfaces (GType type)
238 GType *iface, *ifaces = g_type_interfaces (type, &n_ifaces);
243 g_print ("%s", _name);
244 g_print (_("Implemented Interfaces:\n"));
248 g_print ("%s", _name);
249 g_print (" %s\n", g_type_name (*iface));
253 g_print ("%s", _name);
261 print_element_properties_info (GstElement * element)
263 GParamSpec **property_specs;
264 guint num_properties, i;
268 property_specs = g_object_class_list_properties
269 (G_OBJECT_GET_CLASS (element), &num_properties);
271 n_print ("Element Properties:\n");
273 for (i = 0; i < num_properties; i++) {
274 GValue value = { 0, };
275 GParamSpec *param = property_specs[i];
279 g_value_init (&value, param->value_type);
281 n_print (" %-20s: %s\n", g_param_spec_get_name (param),
282 g_param_spec_get_blurb (param));
285 n_print ("%-23.23s flags: ", "");
286 if (param->flags & G_PARAM_READABLE) {
287 g_object_get_property (G_OBJECT (element), param->name, &value);
293 g_print (_("readable"));
295 if (param->flags & G_PARAM_WRITABLE) {
300 g_print (_("writable"));
302 if (param->flags & GST_PARAM_CONTROLLABLE) {
307 g_print (_("controllable"));
311 switch (G_VALUE_TYPE (&value)) {
314 GParamSpecString *pstring = G_PARAM_SPEC_STRING (param);
316 n_print ("%-23.23s String. ", "");
318 if (pstring->default_value == NULL)
319 g_print ("Default: null ");
321 g_print ("Default: \"%s\" ", pstring->default_value);
324 const char *string_val = g_value_get_string (&value);
326 if (string_val == NULL)
327 g_print ("Current: null");
329 g_print ("Current: \"%s\"", string_val);
335 GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param);
337 n_print ("%-23.23s Boolean. ", "");
338 g_print ("Default: %s ", (pboolean->default_value ? "true" : "false"));
340 g_print ("Current: %s",
341 (g_value_get_boolean (&value) ? "true" : "false"));
346 GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
348 n_print ("%-23.23s Unsigned Long. ", "");
349 g_print ("Range: %lu - %lu Default: %lu ",
350 pulong->minimum, pulong->maximum, pulong->default_value);
352 g_print ("Current: %lu", g_value_get_ulong (&value));
357 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
359 n_print ("%-23.23s Long. ", "");
360 g_print ("Range: %ld - %ld Default: %ld ",
361 plong->minimum, plong->maximum, plong->default_value);
363 g_print ("Current: %ld", g_value_get_long (&value));
368 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
370 n_print ("%-23.23s Unsigned Integer. ", "");
371 g_print ("Range: %u - %u Default: %u ",
372 puint->minimum, puint->maximum, puint->default_value);
374 g_print ("Current: %u", g_value_get_uint (&value));
379 GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
381 n_print ("%-23.23s Integer. ", "");
382 g_print ("Range: %d - %d Default: %d ",
383 pint->minimum, pint->maximum, pint->default_value);
385 g_print ("Current: %d", g_value_get_int (&value));
390 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
392 n_print ("%-23.23s Unsigned Integer64. ", "");
393 g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
394 " Default: %" G_GUINT64_FORMAT " ",
395 puint64->minimum, puint64->maximum, puint64->default_value);
397 g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value));
402 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
404 n_print ("%-23.23s Integer64. ", "");
405 g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
406 " Default: %" G_GINT64_FORMAT " ",
407 pint64->minimum, pint64->maximum, pint64->default_value);
409 g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value));
414 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
416 n_print ("%-23.23s Float. ", "");
417 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
418 pfloat->minimum, pfloat->maximum, pfloat->default_value);
420 g_print ("Current: %15.7g", g_value_get_float (&value));
425 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
427 n_print ("%-23.23s Double. ", "");
428 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
429 pdouble->minimum, pdouble->maximum, pdouble->default_value);
431 g_print ("Current: %15.7g", g_value_get_double (&value));
435 if (param->value_type == GST_TYPE_CAPS) {
436 const GstCaps *caps = gst_value_get_caps (&value);
439 n_print ("%-23.23s Caps (NULL)", "");
441 print_caps (caps, " ");
443 } else if (G_IS_PARAM_SPEC_ENUM (param)) {
444 GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param);
448 const gchar *def_val_nick = "", *cur_val_nick = "";
450 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
451 enum_value = g_value_get_enum (&value);
453 while (values[j].value_name) {
454 if (values[j].value == enum_value)
455 cur_val_nick = values[j].value_nick;
456 if (values[j].value == penum->default_value)
457 def_val_nick = values[j].value_nick;
462 ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"",
463 "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value,
464 def_val_nick, enum_value, cur_val_nick);
467 while (values[j].value_name) {
470 g_print ("%s", _name);
471 g_print ("%-23.23s (%d): %-16s - %s", "",
472 values[j].value, values[j].value_nick, values[j].value_name);
475 /* g_type_class_unref (ec); */
476 } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
477 GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
481 GString *cur_flags = NULL, *def_flags = NULL;
483 values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
484 flags_value = g_value_get_flags (&value);
486 while (values[j].value_name) {
487 if (values[j].value & flags_value) {
489 g_string_append_printf (cur_flags, " | %s",
490 values[j].value_nick);
492 cur_flags = g_string_new (values[j].value_nick);
495 if (values[j].value & pflags->default_value) {
497 g_string_append_printf (def_flags, " | %s",
498 values[j].value_nick);
500 def_flags = g_string_new (values[j].value_nick);
507 ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"",
508 "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value,
509 (def_flags ? def_flags->str : "(none)"), flags_value,
510 (cur_flags ? cur_flags->str : "(none)"));
513 while (values[j].value_name) {
516 g_print ("%s", _name);
517 g_print ("%-23.23s (0x%08x): %-16s - %s", "",
518 values[j].value, values[j].value_nick, values[j].value_name);
523 g_string_free (cur_flags, TRUE);
525 g_string_free (def_flags, TRUE);
526 } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
527 n_print ("%-23.23s Object of type \"%s\"", "",
528 g_type_name (param->value_type));
529 } else if (G_IS_PARAM_SPEC_BOXED (param)) {
530 n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
531 g_type_name (param->value_type));
532 } else if (G_IS_PARAM_SPEC_POINTER (param)) {
533 if (param->value_type != G_TYPE_POINTER) {
534 n_print ("%-23.23s Pointer of type \"%s\".", "",
535 g_type_name (param->value_type));
537 n_print ("%-23.23s Pointer.", "");
539 } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
540 GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);
542 if (pvarray->element_spec) {
543 n_print ("%-23.23s Array of GValues of type \"%s\"", "",
544 g_type_name (pvarray->element_spec->value_type));
546 n_print ("%-23.23s Array of GValues", "");
548 } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
549 GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);
551 n_print ("%-23.23s Fraction. ", "");
553 g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
554 pfraction->min_num, pfraction->min_den,
555 pfraction->max_num, pfraction->max_den,
556 pfraction->def_num, pfraction->def_den);
558 g_print ("Current: %d/%d",
559 gst_value_get_fraction_numerator (&value),
560 gst_value_get_fraction_denominator (&value));
562 } else if (GST_IS_PARAM_SPEC_MINI_OBJECT (param)) {
563 n_print ("%-23.23s MiniObject of type \"%s\"", "",
564 g_type_name (param->value_type));
566 n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
567 g_type_name (param->value_type));
572 g_print (" Write only\n");
576 g_value_reset (&value);
578 if (num_properties == 0)
581 g_free (property_specs);
585 print_pad_templates_info (GstElement * element, GstElementFactory * factory)
587 GstElementClass *gstelement_class;
589 GstStaticPadTemplate *padtemplate;
591 n_print ("Pad Templates:\n");
592 if (!factory->numpadtemplates) {
597 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
599 pads = factory->staticpadtemplates;
601 padtemplate = (GstStaticPadTemplate *) (pads->data);
602 pads = g_list_next (pads);
604 if (padtemplate->direction == GST_PAD_SRC)
605 n_print (" SRC template: '%s'\n", padtemplate->name_template);
606 else if (padtemplate->direction == GST_PAD_SINK)
607 n_print (" SINK template: '%s'\n", padtemplate->name_template);
609 n_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
611 if (padtemplate->presence == GST_PAD_ALWAYS)
612 n_print (" Availability: Always\n");
613 else if (padtemplate->presence == GST_PAD_SOMETIMES)
614 n_print (" Availability: Sometimes\n");
615 else if (padtemplate->presence == GST_PAD_REQUEST) {
616 n_print (" Availability: On request\n");
617 n_print (" Has request_new_pad() function: %s\n",
618 GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
620 n_print (" Availability: UNKNOWN!!!\n");
622 if (padtemplate->static_caps.string) {
623 n_print (" Capabilities:\n");
624 print_caps (gst_static_caps_get (&padtemplate->static_caps), " ");
632 print_element_flag_info (GstElement * element)
634 gboolean have_flags = FALSE;
637 n_print ("Element Flags:\n");
640 n_print (" no flags set\n");
642 if (GST_IS_BIN (element)) {
644 n_print ("Bin Flags:\n");
646 n_print (" no flags set\n");
651 print_implementation_info (GstElement * element)
653 GstObjectClass *gstobject_class;
654 GstElementClass *gstelement_class;
656 gstobject_class = GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (element));
657 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
660 n_print ("Element Implementation:\n");
662 n_print (" Has change_state() function: %s\n",
663 GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
664 #ifndef GST_DISABLE_LOADSAVE
665 n_print (" Has custom save_thyself() function: %s\n",
666 GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
667 n_print (" Has custom restore_thyself() function: %s\n",
668 GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
673 print_clocking_info (GstElement * element)
675 if (!gst_element_requires_clock (element) &&
676 !(gst_element_provides_clock (element) &&
677 gst_element_get_clock (element))) {
679 n_print ("Element has no clocking capabilities.");
684 n_print ("Clocking Interaction:\n");
685 if (gst_element_requires_clock (element)) {
686 n_print (" element requires a clock\n");
689 if (gst_element_provides_clock (element)) {
692 clock = gst_element_get_clock (element);
694 n_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock));
696 n_print (" element is supposed to provide a clock but returned NULL\n");
701 print_index_info (GstElement * element)
703 if (gst_element_is_indexable (element)) {
705 n_print ("Indexing capabilities:\n");
706 n_print (" element can do indexing\n");
709 n_print ("Element has no indexing capabilities.\n");
714 print_uri_handler_info (GstElement * element)
716 if (GST_IS_URI_HANDLER (element)) {
717 const gchar *uri_type;
718 gchar **uri_protocols;
720 if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC)
722 else if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) ==
726 uri_type = "unknown";
728 uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
731 n_print ("URI handling capabilities:\n");
732 n_print (" Element can act as %s.\n", uri_type);
734 if (uri_protocols && *uri_protocols) {
735 n_print (" Supported URI protocols:\n");
736 for (; *uri_protocols != NULL; uri_protocols++)
737 n_print (" %s\n", *uri_protocols);
739 n_print (" No supported URI protocols\n");
742 n_print ("Element has no URI handling capabilities.\n");
747 print_pad_info (GstElement * element)
755 if (!element->numpads) {
760 pads = element->pads;
764 pad = GST_PAD (pads->data);
765 pads = g_list_next (pads);
769 name = gst_pad_get_name (pad);
770 if (gst_pad_get_direction (pad) == GST_PAD_SRC)
771 g_print (" SRC: '%s'", name);
772 else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
773 g_print (" SINK: '%s'", name);
775 g_print (" UNKNOWN!!!: '%s'", name);
781 n_print (" Implementation:\n");
783 n_print (" Has chainfunc(): %s\n",
784 GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
785 if (pad->getrangefunc)
786 n_print (" Has getrangefunc(): %s\n",
787 GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
788 if (pad->eventfunc != gst_pad_event_default)
789 n_print (" Has custom eventfunc(): %s\n",
790 GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
791 if (pad->queryfunc != gst_pad_query_default)
792 n_print (" Has custom queryfunc(): %s\n",
793 GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
794 if (pad->querytypefunc != gst_pad_get_query_types_default) {
795 n_print (" Provides query types:\n");
796 print_query_types (gst_pad_get_query_types (pad));
799 if (pad->intlinkfunc != gst_pad_get_internal_links_default)
800 n_print (" Has custom intconnfunc(): %s\n",
801 GST_DEBUG_FUNCPTR_NAME (pad->intlinkfunc));
803 if (pad->bufferallocfunc)
804 n_print (" Has bufferallocfunc(): %s\n",
805 GST_DEBUG_FUNCPTR_NAME (pad->bufferallocfunc));
807 if (pad->padtemplate)
808 n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template);
811 n_print (" Capabilities:\n");
812 print_caps (pad->caps, " ");
819 compare_signal_names (GSignalQuery * a, GSignalQuery * b)
821 return strcmp (a->signal_name, b->signal_name);
826 print_signal_info (GstElement * element)
828 /* Signals/Actions Block */
832 GSignalQuery *query = NULL;
834 GSList *found_signals, *l;
836 for (k = 0; k < 2; k++) {
837 found_signals = NULL;
838 for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
839 if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
842 if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
845 signals = g_signal_list_ids (type, &nsignals);
846 for (i = 0; i < nsignals; i++) {
847 query = g_new0 (GSignalQuery, 1);
848 g_signal_query (signals[i], query);
850 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
851 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
852 found_signals = g_slist_append (found_signals, query);
863 n_print ("Element Signals:\n");
865 n_print ("Element Actions:\n");
870 for (l = found_signals; l; l = l->next) {
874 query = (GSignalQuery *) l->data;
875 indent_len = strlen (query->signal_name) +
876 strlen (g_type_name (query->return_type)) + 24;
878 indent = g_new0 (gchar, indent_len + 1);
879 memset (indent, ' ', indent_len);
881 n_print (" \"%s\" : %s user_function (%s* object",
883 g_type_name (query->return_type), g_type_name (type));
885 for (j = 0; j < query->n_params; j++) {
887 g_print ("%s", _name);
888 if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
889 g_print (",\n%s%s arg%d", indent,
890 g_type_name (query->param_types[j]), j);
891 } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
892 g_print (",\n%s%s arg%d", indent,
893 g_type_name (query->param_types[j]), j);
895 g_print (",\n%s%s* arg%d", indent,
896 g_type_name (query->param_types[j]), j);
902 g_print ("%s", _name);
903 g_print (",\n%sgpointer user_data);\n", indent);
911 g_slist_foreach (found_signals, (GFunc) g_free, NULL);
912 g_slist_free (found_signals);
918 print_children_info (GstElement * element)
922 if (!GST_IS_BIN (element))
925 children = (GList *) GST_BIN (element)->children;
928 g_print ("Children:\n");
932 n_print (" %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
933 children = g_list_next (children);
938 print_element_list (gboolean print_all)
940 int plugincount = 0, featurecount = 0;
941 GList *plugins, *orig_plugins;
943 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
945 GList *features, *orig_features;
948 plugin = (GstPlugin *) (plugins->data);
949 plugins = g_list_next (plugins);
952 orig_features = features =
953 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
956 GstPluginFeature *feature;
958 feature = GST_PLUGIN_FEATURE (features->data);
961 if (GST_IS_ELEMENT_FACTORY (feature)) {
962 GstElementFactory *factory;
964 factory = GST_ELEMENT_FACTORY (feature);
966 print_element_info (factory, TRUE);
968 g_print ("%s: %s: %s\n", plugin->desc.name,
969 GST_PLUGIN_FEATURE_NAME (factory),
970 gst_element_factory_get_longname (factory));
971 } else if (GST_IS_INDEX_FACTORY (feature)) {
972 GstIndexFactory *factory;
974 factory = GST_INDEX_FACTORY (feature);
976 g_print ("%s: %s: %s\n", plugin->desc.name,
977 GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
978 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
979 GstTypeFindFactory *factory;
981 factory = GST_TYPE_FIND_FACTORY (feature);
983 g_print ("%s: %s: ", plugin->desc.name,
984 gst_plugin_feature_get_name (feature));
985 if (factory->extensions) {
988 while (factory->extensions[i]) {
990 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
997 g_print ("no extensions\n");
1001 n_print ("%s: %s (%s)\n", plugin->desc.name,
1002 GST_PLUGIN_FEATURE_NAME (feature),
1003 g_type_name (G_OBJECT_TYPE (feature)));
1006 features = g_list_next (features);
1009 gst_plugin_feature_list_free (orig_features);
1012 gst_plugin_list_free (orig_plugins);
1015 g_print (_("Total count: "));
1016 g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
1018 g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
1023 print_all_uri_handlers (void)
1025 GList *plugins, *p, *features, *f;
1027 plugins = gst_default_registry_get_plugin_list ();
1029 for (p = plugins; p; p = p->next) {
1030 GstPlugin *plugin = (GstPlugin *) (p->data);
1033 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1036 for (f = features; f; f = f->next) {
1037 GstPluginFeature *feature = GST_PLUGIN_FEATURE (features->data);
1039 if (GST_IS_ELEMENT_FACTORY (feature)) {
1040 GstElementFactory *factory;
1041 GstElement *element;
1043 factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
1045 g_print ("element plugin %s couldn't be loaded\n", plugin->desc.name);
1049 element = gst_element_factory_create (factory, NULL);
1051 g_print ("couldn't construct element for %s for some reason\n",
1052 GST_OBJECT_NAME (factory));
1053 gst_object_unref (factory);
1057 if (GST_IS_URI_HANDLER (element)) {
1059 gchar **uri_protocols, *joined;
1061 switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
1074 gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
1075 joined = g_strjoinv (", ", uri_protocols);
1077 g_print ("%s (%s, rank %u): %s\n", GST_OBJECT_NAME (factory), dir,
1078 gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
1082 //g_strfreev (uri_protocols);
1085 gst_object_unref (element);
1086 gst_object_unref (factory);
1090 gst_plugin_feature_list_free (features);
1093 gst_plugin_list_free (plugins);
1097 print_plugin_info (GstPlugin * plugin)
1099 n_print ("Plugin Details:\n");
1100 n_print (" Name:\t\t\t%s\n", plugin->desc.name);
1101 n_print (" Description:\t\t%s\n", plugin->desc.description);
1102 n_print (" Filename:\t\t%s\n",
1103 plugin->filename ? plugin->filename : "(null)");
1104 n_print (" Version:\t\t%s\n", plugin->desc.version);
1105 n_print (" License:\t\t%s\n", plugin->desc.license);
1106 n_print (" Source module:\t%s\n", plugin->desc.source);
1107 n_print (" Binary package:\t%s\n", plugin->desc.package);
1108 n_print (" Origin URL:\t\t%s\n", plugin->desc.origin);
1113 print_plugin_features (GstPlugin * plugin)
1116 gint num_features = 0;
1117 gint num_elements = 0;
1119 gint num_indexes = 0;
1123 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1127 GstPluginFeature *feature;
1129 feature = GST_PLUGIN_FEATURE (features->data);
1131 if (GST_IS_ELEMENT_FACTORY (feature)) {
1132 GstElementFactory *factory;
1134 factory = GST_ELEMENT_FACTORY (feature);
1135 n_print (" %s: %s\n", GST_PLUGIN_FEATURE_NAME (factory),
1136 gst_element_factory_get_longname (factory));
1138 } else if (GST_IS_INDEX_FACTORY (feature)) {
1139 GstIndexFactory *factory;
1141 factory = GST_INDEX_FACTORY (feature);
1142 n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
1144 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1145 GstTypeFindFactory *factory;
1147 factory = GST_TYPE_FIND_FACTORY (feature);
1148 if (factory->extensions) {
1151 g_print ("%s: %s: ", plugin->desc.name,
1152 gst_plugin_feature_get_name (feature));
1153 while (factory->extensions[i]) {
1154 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1159 g_print ("%s: %s: no extensions\n", plugin->desc.name,
1160 gst_plugin_feature_get_name (feature));
1164 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1165 g_type_name (G_OBJECT_TYPE (feature)));
1169 features = g_list_next (features);
1172 n_print (" %d features:\n", num_features);
1173 if (num_elements > 0)
1174 n_print (" +-- %d elements\n", num_elements);
1176 n_print (" +-- %d types\n", num_types);
1177 if (num_indexes > 0)
1178 n_print (" +-- %d indexes\n", num_indexes);
1180 n_print (" +-- %d other objects\n", num_other);
1186 print_element_features (const gchar * element_name)
1188 GstPluginFeature *feature;
1190 /* FIXME implement other pretty print function for these */
1191 feature = gst_default_registry_find_feature (element_name,
1192 GST_TYPE_INDEX_FACTORY);
1194 n_print ("%s: an index\n", element_name);
1197 feature = gst_default_registry_find_feature (element_name,
1198 GST_TYPE_TYPE_FIND_FACTORY);
1200 n_print ("%s: a typefind function\n", element_name);
1208 print_element_info (GstElementFactory * factory, gboolean print_names)
1210 GstElement *element;
1214 GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
1218 g_print ("element plugin couldn't be loaded\n");
1222 element = gst_element_factory_create (factory, NULL);
1224 g_print ("couldn't construct element for some reason\n");
1229 _name = g_strdup_printf ("%s: ", GST_PLUGIN_FEATURE (factory)->name);
1233 print_factory_details_info (factory);
1234 if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
1237 plugin = gst_registry_find_plugin (gst_registry_get_default (),
1238 GST_PLUGIN_FEATURE (factory)->plugin_name);
1240 print_plugin_info (plugin);
1244 print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
1245 print_interfaces (G_OBJECT_TYPE (element));
1247 print_pad_templates_info (element, factory);
1248 print_element_flag_info (element);
1249 print_implementation_info (element);
1250 print_clocking_info (element);
1251 print_index_info (element);
1252 print_uri_handler_info (element);
1253 print_pad_info (element);
1254 print_element_properties_info (element);
1255 print_signal_info (element);
1256 print_children_info (element);
1258 gst_object_unref (element);
1259 gst_object_unref (factory);
1267 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
1269 GstPadDirection direction;
1270 const gchar *type_name;
1272 const GList *static_templates, *l;
1273 GstCaps *caps = NULL;
1276 klass = gst_element_factory_get_klass (factory);
1277 g_return_if_fail (klass != NULL);
1279 if (strstr (klass, "Demuxer") ||
1280 strstr (klass, "Decoder") ||
1281 strstr (klass, "Depay") || strstr (klass, "Parser")) {
1282 type_name = "decoder";
1283 direction = GST_PAD_SINK;
1284 } else if (strstr (klass, "Muxer") ||
1285 strstr (klass, "Encoder") || strstr (klass, "Pay")) {
1286 type_name = "encoder";
1287 direction = GST_PAD_SRC;
1292 /* decoder/demuxer sink pads should always be static and there should only
1293 * be one, the same applies to encoders/muxers and source pads */
1294 static_templates = gst_element_factory_get_static_pad_templates (factory);
1295 for (l = static_templates; l != NULL; l = l->next) {
1296 GstStaticPadTemplate *tmpl = NULL;
1298 tmpl = (GstStaticPadTemplate *) l->data;
1299 if (tmpl->direction == direction) {
1300 caps = gst_static_pad_template_get_caps (tmpl);
1306 g_printerr ("Couldn't find static pad template for %s '%s'\n",
1307 type_name, GST_PLUGIN_FEATURE_NAME (factory));
1311 caps = gst_caps_make_writable (caps);
1312 num = gst_caps_get_size (caps);
1313 for (i = 0; i < num; ++i) {
1317 s = gst_caps_get_structure (caps, i);
1318 /* remove fields that are almost always just MIN-MAX of some sort
1319 * in order to make the caps look less messy */
1320 gst_structure_remove_field (s, "pixel-aspect-ratio");
1321 gst_structure_remove_field (s, "framerate");
1322 gst_structure_remove_field (s, "channels");
1323 gst_structure_remove_field (s, "width");
1324 gst_structure_remove_field (s, "height");
1325 gst_structure_remove_field (s, "rate");
1326 gst_structure_remove_field (s, "depth");
1327 gst_structure_remove_field (s, "clock-rate");
1328 s_str = gst_structure_to_string (s);
1329 g_print ("%s-%s\n", type_name, s_str);
1332 gst_caps_unref (caps);
1336 print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
1338 gchar **protocols, **p;
1340 protocols = gst_element_factory_get_uri_protocols (factory);
1341 if (protocols != NULL && *protocols != NULL) {
1342 switch (gst_element_factory_get_uri_type (factory)) {
1344 for (p = protocols; *p != NULL; ++p)
1345 g_print ("urisink-%s\n", *p);
1348 for (p = protocols; *p != NULL; ++p)
1349 g_print ("urisource-%s\n", *p);
1354 g_strfreev (protocols);
1359 print_plugin_automatic_install_info (GstPlugin * plugin)
1361 const gchar *plugin_name;
1362 GList *features, *l;
1364 plugin_name = gst_plugin_get_name (plugin);
1366 /* not interested in typefind factories, only element factories */
1367 features = gst_registry_get_feature_list (gst_registry_get_default (),
1368 GST_TYPE_ELEMENT_FACTORY);
1370 for (l = features; l != NULL; l = l->next) {
1371 GstPluginFeature *feature;
1373 feature = GST_PLUGIN_FEATURE (l->data);
1375 /* only interested in the ones that are in the plugin we just loaded */
1376 if (g_str_equal (plugin_name, feature->plugin_name)) {
1377 GstElementFactory *factory;
1379 g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
1381 factory = GST_ELEMENT_FACTORY (feature);
1382 print_plugin_automatic_install_info_protocols (factory);
1383 print_plugin_automatic_install_info_codecs (factory);
1387 g_list_foreach (features, (GFunc) gst_object_unref, NULL);
1388 g_list_free (features);
1392 main (int argc, char *argv[])
1394 gboolean print_all = FALSE;
1395 gboolean plugin_name = FALSE;
1396 gboolean print_aii = FALSE;
1397 gboolean uri_handlers = FALSE;
1398 GOptionEntry options[] = {
1399 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
1400 N_("Print all elements"), NULL},
1401 {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
1402 N_("Print a machine-parsable list of features the specified plugin "
1404 "Useful in connection with external automatic plugin "
1405 "installation mechanisms"), NULL},
1406 {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
1407 N_("List the plugin contents"), NULL},
1408 {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
1410 ("Print supported URI schemes, with the elements that implement them"),
1412 GST_TOOLS_GOPTION_VERSION,
1415 GOptionContext *ctx;
1419 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1420 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1421 textdomain (GETTEXT_PACKAGE);
1424 if (!g_thread_supported ())
1425 g_thread_init (NULL);
1427 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
1428 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
1429 g_option_context_add_group (ctx, gst_init_get_option_group ());
1430 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1431 g_print ("Error initializing: %s\n", err->message);
1434 g_option_context_free (ctx);
1436 gst_tools_print_version ("gst-inspect");
1438 if (print_all && argc > 1) {
1439 g_print ("-a requires no extra arguments\n");
1443 if (uri_handlers && argc > 1) {
1444 g_print ("-u requires no extra arguments\n");
1448 /* if no arguments, print out list of elements */
1450 print_all_uri_handlers ();
1451 } else if (argc == 1 || print_all) {
1452 print_element_list (print_all);
1454 /* else we try to get a factory */
1455 GstElementFactory *factory;
1457 const char *arg = argv[argc - 1];
1461 factory = gst_element_factory_find (arg);
1463 /* if there's a factory, print out the info */
1465 retval = print_element_info (factory, print_all);
1466 gst_object_unref (factory);
1468 retval = print_element_features (arg);
1474 /* otherwise check if it's a plugin */
1476 plugin = gst_default_registry_find_plugin (arg);
1478 /* if there is such a plugin, print out info */
1481 print_plugin_automatic_install_info (plugin);
1483 print_plugin_info (plugin);
1484 print_plugin_features (plugin);
1487 GError *error = NULL;
1489 if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
1490 plugin = gst_plugin_load_file (arg, &error);
1494 print_plugin_automatic_install_info (plugin);
1496 print_plugin_info (plugin);
1497 print_plugin_features (plugin);
1500 g_print (_("Could not load plugin file: %s\n"), error->message);
1501 g_error_free (error);
1505 g_print (_("No such element or plugin '%s'\n"), arg);