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, ...)
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);
125 #ifndef GST_DISABLE_ENUMTYPES
128 print_event_masks (const GstEventMask * masks)
133 GFlagsClass *flags_class = NULL;
135 event_type = gst_event_type_get_type ();
136 klass = (GEnumClass *) g_type_class_ref (event_type);
138 while (masks && masks->type) {
140 gint flags = 0, index = 0;
142 switch (masks->type) {
144 flags = masks->flags;
145 event_flags = gst_seek_type_get_type ();
146 flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
152 value = g_enum_get_value (klass, masks->type);
153 g_print ("\t\t%s ", value->value_nick);
159 value = g_flags_get_first_value (flags_class, 1 << index);
162 g_print ("| %s ", value->value_nick);
177 print_event_masks (const GstEventMask * masks)
183 get_rank_name (gint rank)
188 case GST_RANK_MARGINAL:
190 case GST_RANK_SECONDARY:
192 case GST_RANK_PRIMARY:
200 print_factory_details_info (GstElementFactory * factory)
202 n_print ("Factory Details:\n");
203 n_print (" Long name:\t%s\n", factory->details.longname);
204 n_print (" Class:\t%s\n", factory->details.klass);
205 n_print (" Description:\t%s\n", factory->details.description);
206 n_print (" Author(s):\t%s\n", factory->details.author);
207 n_print (" Rank:\t\t%s (%d)\n",
208 get_rank_name (GST_PLUGIN_FEATURE (factory)->rank),
209 GST_PLUGIN_FEATURE (factory)->rank);
214 print_hierarchy (GType type, gint level, gint * maxlevel)
219 parent = g_type_parent (type);
221 *maxlevel = *maxlevel + 1;
225 print_hierarchy (parent, level, maxlevel);
230 for (i = 1; i < *maxlevel - level; i++)
232 if (*maxlevel - level)
235 g_print ("%s\n", g_type_name (type));
242 print_interfaces (GType type)
245 GType *iface, *ifaces = g_type_interfaces (type, &n_ifaces);
251 g_print (_("Implemented Interfaces:\n"));
256 g_print (" %s\n", g_type_name (*iface));
268 print_element_properties_info (GstElement * element)
270 GParamSpec **property_specs;
271 guint num_properties, i;
275 property_specs = g_object_class_list_properties
276 (G_OBJECT_GET_CLASS (element), &num_properties);
278 n_print ("Element Properties:\n");
280 for (i = 0; i < num_properties; i++) {
281 GValue value = { 0, };
282 GParamSpec *param = property_specs[i];
286 g_value_init (&value, param->value_type);
288 n_print (" %-20s: %s\n", g_param_spec_get_name (param),
289 g_param_spec_get_blurb (param));
292 n_print ("%-23.23s flags: ", "");
293 if (param->flags & G_PARAM_READABLE) {
294 g_object_get_property (G_OBJECT (element), param->name, &value);
300 g_print (_("readable"));
302 if (param->flags & G_PARAM_WRITABLE) {
307 g_print (_("writable"));
309 if (param->flags & GST_PARAM_CONTROLLABLE) {
314 g_print (_("controllable"));
318 switch (G_VALUE_TYPE (&value)) {
321 GParamSpecString *pstring = G_PARAM_SPEC_STRING (param);
323 n_print ("%-23.23s String. ", "");
325 if (pstring->default_value == NULL)
326 g_print ("Default: null ");
328 g_print ("Default: \"%s\" ", pstring->default_value);
331 const char *string_val = g_value_get_string (&value);
333 if (string_val == NULL)
334 g_print ("Current: null");
336 g_print ("Current: \"%s\"", string_val);
342 GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param);
344 n_print ("%-23.23s Boolean. ", "");
345 g_print ("Default: %s ", (pboolean->default_value ? "true" : "false"));
347 g_print ("Current: %s",
348 (g_value_get_boolean (&value) ? "true" : "false"));
353 GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
355 n_print ("%-23.23s Unsigned Long. ", "");
356 g_print ("Range: %lu - %lu Default: %lu ",
357 pulong->minimum, pulong->maximum, pulong->default_value);
359 g_print ("Current: %lu", g_value_get_ulong (&value));
364 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
366 n_print ("%-23.23s Long. ", "");
367 g_print ("Range: %ld - %ld Default: %ld ",
368 plong->minimum, plong->maximum, plong->default_value);
370 g_print ("Current: %ld", g_value_get_long (&value));
375 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
377 n_print ("%-23.23s Unsigned Integer. ", "");
378 g_print ("Range: %u - %u Default: %u ",
379 puint->minimum, puint->maximum, puint->default_value);
381 g_print ("Current: %u", g_value_get_uint (&value));
386 GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
388 n_print ("%-23.23s Integer. ", "");
389 g_print ("Range: %d - %d Default: %d ",
390 pint->minimum, pint->maximum, pint->default_value);
392 g_print ("Current: %d", g_value_get_int (&value));
397 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
399 n_print ("%-23.23s Unsigned Integer64. ", "");
400 g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
401 " Default: %" G_GUINT64_FORMAT " ",
402 puint64->minimum, puint64->maximum, puint64->default_value);
404 g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value));
409 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
411 n_print ("%-23.23s Integer64. ", "");
412 g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
413 " Default: %" G_GINT64_FORMAT " ",
414 pint64->minimum, pint64->maximum, pint64->default_value);
416 g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value));
421 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
423 n_print ("%-23.23s Float. ", "");
424 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
425 pfloat->minimum, pfloat->maximum, pfloat->default_value);
427 g_print ("Current: %15.7g", g_value_get_float (&value));
432 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
434 n_print ("%-23.23s Double. ", "");
435 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
436 pdouble->minimum, pdouble->maximum, pdouble->default_value);
438 g_print ("Current: %15.7g", g_value_get_double (&value));
442 if (param->value_type == GST_TYPE_CAPS) {
443 const GstCaps *caps = gst_value_get_caps (&value);
446 n_print ("%-23.23s Caps (NULL)", "");
448 print_caps (caps, " ");
450 } else if (G_IS_PARAM_SPEC_ENUM (param)) {
451 GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param);
455 const gchar *def_val_nick = "", *cur_val_nick = "";
457 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
458 enum_value = g_value_get_enum (&value);
460 while (values[j].value_name) {
461 if (values[j].value == enum_value)
462 cur_val_nick = values[j].value_nick;
463 if (values[j].value == penum->default_value)
464 def_val_nick = values[j].value_nick;
469 ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"",
470 "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value,
471 def_val_nick, enum_value, cur_val_nick);
474 while (values[j].value_name) {
478 g_print ("%-23.23s (%d): %-16s - %s", "",
479 values[j].value, values[j].value_nick, values[j].value_name);
482 /* g_type_class_unref (ec); */
483 } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
484 GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
488 GString *cur_flags = NULL, *def_flags = NULL;
490 values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
491 flags_value = g_value_get_flags (&value);
493 while (values[j].value_name) {
494 if (values[j].value & flags_value) {
496 g_string_append_printf (cur_flags, " | %s",
497 values[j].value_nick);
499 cur_flags = g_string_new (values[j].value_nick);
502 if (values[j].value & pflags->default_value) {
504 g_string_append_printf (def_flags, " | %s",
505 values[j].value_nick);
507 def_flags = g_string_new (values[j].value_nick);
514 ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"",
515 "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value,
516 (def_flags ? def_flags->str : "(none)"), flags_value,
517 (cur_flags ? cur_flags->str : "(none)"));
520 while (values[j].value_name) {
524 g_print ("%-23.23s (0x%08x): %-16s - %s", "",
525 values[j].value, values[j].value_nick, values[j].value_name);
530 g_string_free (cur_flags, TRUE);
532 g_string_free (def_flags, TRUE);
533 } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
534 n_print ("%-23.23s Object of type \"%s\"", "",
535 g_type_name (param->value_type));
536 } else if (G_IS_PARAM_SPEC_BOXED (param)) {
537 n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
538 g_type_name (param->value_type));
539 } else if (G_IS_PARAM_SPEC_POINTER (param)) {
540 if (param->value_type != G_TYPE_POINTER) {
541 n_print ("%-23.23s Pointer of type \"%s\".", "",
542 g_type_name (param->value_type));
544 n_print ("%-23.23s Pointer.", "");
546 } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
547 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");
700 #ifndef GST_DISABLE_INDEX
702 print_index_info (GstElement * element)
704 if (gst_element_is_indexable (element)) {
706 n_print ("Indexing capabilities:\n");
707 n_print (" element can do indexing\n");
710 n_print ("Element has no indexing capabilities.\n");
715 print_index_info (GstElement * element)
721 print_pad_info (GstElement * element)
729 if (!element->numpads) {
734 pads = element->pads;
738 pad = GST_PAD (pads->data);
739 pads = g_list_next (pads);
743 name = gst_pad_get_name (pad);
744 if (gst_pad_get_direction (pad) == GST_PAD_SRC)
745 g_print (" SRC: '%s'", name);
746 else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
747 g_print (" SINK: '%s'", name);
749 g_print (" UNKNOWN!!!: '%s'", name);
755 n_print (" Implementation:\n");
757 n_print (" Has chainfunc(): %s\n",
758 GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
759 if (pad->getrangefunc)
760 n_print (" Has getrangefunc(): %s\n",
761 GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
762 if (pad->eventfunc != gst_pad_event_default)
763 n_print (" Has custom eventfunc(): %s\n",
764 GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
765 if (pad->queryfunc != gst_pad_query_default)
766 n_print (" Has custom queryfunc(): %s\n",
767 GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
768 if (pad->querytypefunc != gst_pad_get_query_types_default) {
769 n_print (" Provides query types:\n");
770 print_query_types (gst_pad_get_query_types (pad));
773 if (pad->intlinkfunc != gst_pad_get_internal_links_default)
774 n_print (" Has custom intconnfunc(): %s\n",
775 GST_DEBUG_FUNCPTR_NAME (pad->intlinkfunc));
777 if (pad->bufferallocfunc)
778 n_print (" Has bufferallocfunc(): %s\n",
779 GST_DEBUG_FUNCPTR_NAME (pad->bufferallocfunc));
781 if (pad->padtemplate)
782 n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template);
785 n_print (" Capabilities:\n");
786 print_caps (pad->caps, " ");
793 compare_signal_names (GSignalQuery * a, GSignalQuery * b)
795 return strcmp (a->signal_name, b->signal_name);
800 print_signal_info (GstElement * element)
802 /* Signals/Actions Block */
806 GSignalQuery *query = NULL;
808 GSList *found_signals, *l;
810 for (k = 0; k < 2; k++) {
811 found_signals = NULL;
812 for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
813 if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
816 if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
819 signals = g_signal_list_ids (type, &nsignals);
820 for (i = 0; i < nsignals; i++) {
821 query = g_new0 (GSignalQuery, 1);
822 g_signal_query (signals[i], query);
824 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
825 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
826 found_signals = g_slist_append (found_signals, query);
837 n_print ("Element Signals:\n");
839 n_print ("Element Actions:\n");
844 for (l = found_signals; l; l = l->next) {
848 query = (GSignalQuery *) l->data;
849 indent_len = strlen (query->signal_name) +
850 strlen (g_type_name (query->return_type)) + 24;
852 indent = g_new0 (gchar, indent_len + 1);
853 memset (indent, ' ', indent_len);
855 n_print (" \"%s\" : %s user_function (%s* object",
857 g_type_name (query->return_type), g_type_name (type));
859 for (j = 0; j < query->n_params; j++) {
862 if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
863 g_print (",\n%s%s arg%d", indent,
864 g_type_name (query->param_types[j]), j);
865 } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
866 g_print (",\n%s%s arg%d", indent,
867 g_type_name (query->param_types[j]), j);
869 g_print (",\n%s%s* arg%d", indent,
870 g_type_name (query->param_types[j]), j);
877 g_print (",\n%sgpointer user_data);\n", indent);
885 g_slist_foreach (found_signals, (GFunc) g_free, NULL);
886 g_slist_free (found_signals);
892 print_children_info (GstElement * element)
896 if (!GST_IS_BIN (element))
899 children = (GList *) GST_BIN (element)->children;
902 g_print ("Children:\n");
906 n_print (" %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
907 children = g_list_next (children);
912 print_element_list (gboolean print_all)
914 int plugincount = 0, featurecount = 0;
915 GList *plugins, *orig_plugins;
917 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
919 GList *features, *orig_features;
922 plugin = (GstPlugin *) (plugins->data);
923 plugins = g_list_next (plugins);
926 orig_features = features =
927 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
930 GstPluginFeature *feature;
932 feature = GST_PLUGIN_FEATURE (features->data);
935 if (GST_IS_ELEMENT_FACTORY (feature)) {
936 GstElementFactory *factory;
938 factory = GST_ELEMENT_FACTORY (feature);
940 print_element_info (factory, TRUE);
942 g_print ("%s: %s: %s\n", plugin->desc.name,
943 GST_PLUGIN_FEATURE_NAME (factory),
944 gst_element_factory_get_longname (factory));
946 #ifndef GST_DISABLE_INDEX
947 else if (GST_IS_INDEX_FACTORY (feature)) {
948 GstIndexFactory *factory;
950 factory = GST_INDEX_FACTORY (feature);
952 g_print ("%s: %s: %s\n", plugin->desc.name,
953 GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
956 else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
957 GstTypeFindFactory *factory;
959 factory = GST_TYPE_FIND_FACTORY (feature);
961 g_print ("%s: %s: ", plugin->desc.name,
962 gst_plugin_feature_get_name (feature));
963 if (factory->extensions) {
966 while (factory->extensions[i]) {
968 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
975 g_print ("no extensions\n");
979 n_print ("%s: %s (%s)\n", plugin->desc.name,
980 GST_PLUGIN_FEATURE_NAME (feature),
981 g_type_name (G_OBJECT_TYPE (feature)));
984 features = g_list_next (features);
987 gst_plugin_feature_list_free (orig_features);
990 gst_plugin_list_free (orig_plugins);
993 g_print (_("Total count: "));
994 g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
996 g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
1001 print_plugin_info (GstPlugin * plugin)
1003 n_print ("Plugin Details:\n");
1004 n_print (" Name:\t\t\t%s\n", plugin->desc.name);
1005 n_print (" Description:\t\t%s\n", plugin->desc.description);
1006 n_print (" Filename:\t\t%s\n",
1007 plugin->filename ? plugin->filename : "(null)");
1008 n_print (" Version:\t\t%s\n", plugin->desc.version);
1009 n_print (" License:\t\t%s\n", plugin->desc.license);
1010 n_print (" Source module:\t%s\n", plugin->desc.source);
1011 n_print (" Binary package:\t%s\n", plugin->desc.package);
1012 n_print (" Origin URL:\t\t%s\n", plugin->desc.origin);
1017 print_plugin_features (GstPlugin * plugin)
1020 gint num_features = 0;
1021 gint num_elements = 0;
1023 gint num_indexes = 0;
1027 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1031 GstPluginFeature *feature;
1033 feature = GST_PLUGIN_FEATURE (features->data);
1035 if (GST_IS_ELEMENT_FACTORY (feature)) {
1036 GstElementFactory *factory;
1038 factory = GST_ELEMENT_FACTORY (feature);
1039 n_print (" %s: %s\n", GST_PLUGIN_FEATURE_NAME (factory),
1040 gst_element_factory_get_longname (factory));
1043 #ifndef GST_DISABLE_INDEX
1044 else if (GST_IS_INDEX_FACTORY (feature)) {
1045 GstIndexFactory *factory;
1047 factory = GST_INDEX_FACTORY (feature);
1048 n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
1052 else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1053 GstTypeFindFactory *factory;
1055 factory = GST_TYPE_FIND_FACTORY (feature);
1056 if (factory->extensions) {
1059 g_print ("%s: %s: ", plugin->desc.name,
1060 gst_plugin_feature_get_name (feature));
1061 while (factory->extensions[i]) {
1062 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1067 g_print ("%s: %s: no extensions\n", plugin->desc.name,
1068 gst_plugin_feature_get_name (feature));
1072 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1073 g_type_name (G_OBJECT_TYPE (feature)));
1077 features = g_list_next (features);
1080 n_print (" %d features:\n", num_features);
1081 if (num_elements > 0)
1082 n_print (" +-- %d elements\n", num_elements);
1084 n_print (" +-- %d types\n", num_types);
1085 if (num_indexes > 0)
1086 n_print (" +-- %d indexes\n", num_indexes);
1088 n_print (" +-- %d other objects\n", num_other);
1094 print_element_features (const gchar * element_name)
1096 GstPluginFeature *feature;
1098 /* FIXME implement other pretty print function for these */
1099 #ifndef GST_DISABLE_INDEX
1100 feature = gst_default_registry_find_feature (element_name,
1101 GST_TYPE_INDEX_FACTORY);
1103 n_print ("%s: an index\n", element_name);
1107 feature = gst_default_registry_find_feature (element_name,
1108 GST_TYPE_TYPE_FIND_FACTORY);
1110 n_print ("%s: a typefind function\n", element_name);
1118 print_element_info (GstElementFactory * factory, gboolean print_names)
1120 GstElement *element;
1124 GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
1128 g_print ("element plugin couldn't be loaded\n");
1132 element = gst_element_factory_create (factory, NULL);
1134 g_print ("couldn't construct element for some reason\n");
1139 _name = g_strdup_printf ("%s: ", GST_PLUGIN_FEATURE (factory)->name);
1143 print_factory_details_info (factory);
1144 if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
1147 plugin = gst_registry_find_plugin (gst_registry_get_default (),
1148 GST_PLUGIN_FEATURE (factory)->plugin_name);
1150 print_plugin_info (plugin);
1154 print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
1155 print_interfaces (G_OBJECT_TYPE (element));
1157 print_pad_templates_info (element, factory);
1158 print_element_flag_info (element);
1159 print_implementation_info (element);
1160 print_clocking_info (element);
1161 print_index_info (element);
1162 print_pad_info (element);
1163 print_element_properties_info (element);
1164 print_signal_info (element);
1165 print_children_info (element);
1167 gst_object_unref (element);
1168 gst_object_unref (factory);
1176 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
1178 GstPadDirection direction;
1179 const gchar *type_name;
1181 const GList *static_templates, *l;
1182 GstCaps *caps = NULL;
1185 klass = gst_element_factory_get_klass (factory);
1186 g_return_if_fail (klass != NULL);
1188 if (strstr (klass, "Demuxer") ||
1189 strstr (klass, "Decoder") ||
1190 strstr (klass, "Depay") || strstr (klass, "Parser")) {
1191 type_name = "decoder";
1192 direction = GST_PAD_SINK;
1193 } else if (strstr (klass, "Muxer") ||
1194 strstr (klass, "Encoder") || strstr (klass, "Pay")) {
1195 type_name = "encoder";
1196 direction = GST_PAD_SRC;
1201 /* decoder/demuxer sink pads should always be static and there should only
1202 * be one, the same applies to encoders/muxers and source pads */
1203 static_templates = gst_element_factory_get_static_pad_templates (factory);
1204 for (l = static_templates; l != NULL; l = l->next) {
1205 GstStaticPadTemplate *tmpl = NULL;
1207 tmpl = (GstStaticPadTemplate *) l->data;
1208 if (tmpl->direction == direction) {
1209 caps = gst_static_pad_template_get_caps (tmpl);
1215 g_printerr ("Couldn't find static pad template for %s '%s'\n",
1216 type_name, GST_PLUGIN_FEATURE_NAME (factory));
1220 caps = gst_caps_make_writable (caps);
1221 num = gst_caps_get_size (caps);
1222 for (i = 0; i < num; ++i) {
1226 s = gst_caps_get_structure (caps, i);
1227 /* remove fields that are almost always just MIN-MAX of some sort
1228 * in order to make the caps look less messy */
1229 gst_structure_remove_field (s, "pixel-aspect-ratio");
1230 gst_structure_remove_field (s, "framerate");
1231 gst_structure_remove_field (s, "channels");
1232 gst_structure_remove_field (s, "width");
1233 gst_structure_remove_field (s, "height");
1234 gst_structure_remove_field (s, "rate");
1235 gst_structure_remove_field (s, "depth");
1236 gst_structure_remove_field (s, "clock-rate");
1237 s_str = gst_structure_to_string (s);
1238 g_print ("%s-%s\n", type_name, s_str);
1241 gst_caps_unref (caps);
1245 print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
1247 gchar **protocols, **p;
1249 protocols = gst_element_factory_get_uri_protocols (factory);
1250 if (protocols != NULL && *protocols != NULL) {
1251 switch (gst_element_factory_get_uri_type (factory)) {
1253 for (p = protocols; *p != NULL; ++p)
1254 g_print ("urisink-%s\n", *p);
1257 for (p = protocols; *p != NULL; ++p)
1258 g_print ("urisource-%s\n", *p);
1263 g_strfreev (protocols);
1268 print_plugin_automatic_install_info (GstPlugin * plugin)
1270 const gchar *plugin_name;
1271 GList *features, *l;
1273 plugin_name = gst_plugin_get_name (plugin);
1275 /* not interested in typefind factories, only element factories */
1276 features = gst_registry_get_feature_list (gst_registry_get_default (),
1277 GST_TYPE_ELEMENT_FACTORY);
1279 for (l = features; l != NULL; l = l->next) {
1280 GstPluginFeature *feature;
1282 feature = GST_PLUGIN_FEATURE (l->data);
1284 /* only interested in the ones that are in the plugin we just loaded */
1285 if (g_str_equal (plugin_name, feature->plugin_name)) {
1286 GstElementFactory *factory;
1288 g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
1290 factory = GST_ELEMENT_FACTORY (feature);
1291 print_plugin_automatic_install_info_protocols (factory);
1292 print_plugin_automatic_install_info_codecs (factory);
1296 g_list_foreach (features, (GFunc) gst_object_unref, NULL);
1297 g_list_free (features);
1301 main (int argc, char *argv[])
1303 gboolean print_all = FALSE;
1304 gboolean print_aii = FALSE;
1305 GOptionEntry options[] = {
1306 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
1307 N_("Print all elements"), NULL},
1308 {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
1309 N_("Print a machine-parsable list of features the specified plugin "
1311 "Useful in connection with external automatic plugin "
1312 "installation mechanisms"), NULL},
1313 GST_TOOLS_GOPTION_VERSION,
1316 GOptionContext *ctx;
1320 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1321 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1322 textdomain (GETTEXT_PACKAGE);
1325 if (!g_thread_supported ())
1326 g_thread_init (NULL);
1328 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
1329 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
1330 g_option_context_add_group (ctx, gst_init_get_option_group ());
1331 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1332 g_print ("Error initializing: %s\n", err->message);
1335 g_option_context_free (ctx);
1337 gst_tools_print_version ("gst-inspect");
1339 if (print_all && argc > 2) {
1340 g_print ("-a requires no extra arguments\n");
1344 /* if no arguments, print out list of elements */
1345 if (argc == 1 || print_all) {
1346 print_element_list (print_all);
1347 /* else we try to get a factory */
1349 GstElementFactory *factory;
1351 const char *arg = argv[argc - 1];
1354 factory = gst_element_factory_find (arg);
1355 /* if there's a factory, print out the info */
1357 retval = print_element_info (factory, print_all);
1358 gst_object_unref (factory);
1360 retval = print_element_features (arg);
1363 /* otherwise check if it's a plugin */
1365 plugin = gst_default_registry_find_plugin (arg);
1367 /* if there is such a plugin, print out info */
1370 print_plugin_automatic_install_info (plugin);
1372 print_plugin_info (plugin);
1373 print_plugin_features (plugin);
1376 GError *error = NULL;
1378 if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
1379 plugin = gst_plugin_load_file (arg, &error);
1383 print_plugin_automatic_install_info (plugin);
1385 print_plugin_info (plugin);
1386 print_plugin_features (plugin);
1389 g_print (_("Could not load plugin file: %s\n"), error->message);
1390 g_error_free (error);
1394 g_print (_("No such element or plugin '%s'\n"), arg);