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.
32 #include <glib/gprintf.h>
34 static char *_name = NULL;
36 static int print_element_info (GstElementFactory * factory,
37 gboolean print_names);
40 n_print (const char *format, ...)
45 g_print ("%s", _name);
47 va_start (args, format);
48 g_vprintf (format, args);
53 print_field (GQuark field, const GValue * value, gpointer pfx)
55 gchar *str = gst_value_serialize (value);
57 n_print ("%s %15s: %s\n", (gchar *) pfx, g_quark_to_string (field), str);
63 print_caps (const GstCaps * caps, const gchar * pfx)
67 g_return_if_fail (caps != NULL);
69 if (gst_caps_is_any (caps)) {
70 n_print ("%sANY\n", pfx);
73 if (gst_caps_is_empty (caps)) {
74 n_print ("%sEMPTY\n", pfx);
78 for (i = 0; i < gst_caps_get_size (caps); i++) {
79 GstStructure *structure = gst_caps_get_structure (caps, i);
81 n_print ("%s%s\n", pfx, gst_structure_get_name (structure));
82 gst_structure_foreach (structure, print_field, (gpointer) pfx);
88 print_formats (const GstFormat * formats)
90 while (formats && *formats) {
91 const GstFormatDefinition *definition;
93 definition = gst_format_get_details (*formats);
95 n_print ("\t\t(%d):\t%s (%s)\n", *formats,
96 definition->nick, definition->description);
98 n_print ("\t\t(%d):\tUnknown format\n", *formats);
105 print_event_masks (const GstEventMask * masks)
110 GFlagsClass *flags_class = NULL;
112 event_type = gst_event_type_get_type ();
113 klass = (GEnumClass *) g_type_class_ref (event_type);
115 while (masks && masks->type) {
117 gint flags = 0, index = 0;
119 switch (masks->type) {
121 flags = masks->flags;
122 event_flags = gst_seek_type_get_type ();
123 flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
129 value = g_enum_get_value (klass, masks->type);
130 g_print ("\t\t%s ", value->value_nick);
136 value = g_flags_get_first_value (flags_class, 1 << index);
139 g_print ("| %s ", value->value_nick);
154 get_rank_name (char *s, gint rank)
156 static const int ranks[4] = {
157 GST_RANK_NONE, GST_RANK_MARGINAL, GST_RANK_SECONDARY, GST_RANK_PRIMARY
159 static const char *rank_names[4] = { "none", "marginal", "secondary",
166 for (i = 0; i < 4; i++) {
167 if (rank == ranks[i])
168 return rank_names[i];
169 if (abs (rank - ranks[i]) < abs (rank - ranks[best_i])) {
174 sprintf (s, "%s %c %d", rank_names[best_i],
175 (rank - ranks[best_i] > 0) ? '+' : '-', abs (ranks[best_i] - rank));
181 print_factory_details_metadata (GQuark field_id, const GValue * value,
184 gchar *val = g_strdup_value_contents (value);
185 gchar *key = g_strdup (g_quark_to_string (field_id));
187 key[0] = g_ascii_toupper (key[0]);
188 n_print (" %s:\t\t%s\n", key, val);
195 print_factory_details_info (GstElementFactory * factory)
199 n_print ("Factory Details:\n");
200 n_print (" Rank:\t\t%s (%d)\n",
201 get_rank_name (s, GST_PLUGIN_FEATURE (factory)->rank),
202 GST_PLUGIN_FEATURE (factory)->rank);
203 gst_structure_foreach ((GstStructure *) factory->metadata,
204 print_factory_details_metadata, NULL);
209 print_hierarchy (GType type, gint level, gint * maxlevel)
214 parent = g_type_parent (type);
216 *maxlevel = *maxlevel + 1;
220 print_hierarchy (parent, level, maxlevel);
223 g_print ("%s", _name);
225 for (i = 1; i < *maxlevel - level; i++)
227 if (*maxlevel - level)
230 g_print ("%s\n", g_type_name (type));
237 print_interfaces (GType type)
240 GType *iface, *ifaces = g_type_interfaces (type, &n_ifaces);
245 g_print ("%s", _name);
246 g_print (_("Implemented Interfaces:\n"));
250 g_print ("%s", _name);
251 g_print (" %s\n", g_type_name (*iface));
255 g_print ("%s", _name);
263 flags_to_string (GFlagsValue * vals, guint flags)
268 /* first look for an exact match and count the number of values */
269 for (i = 0; vals[i].value_name != NULL; ++i) {
270 if (vals[i].value == flags)
271 return g_strdup (vals[i].value_nick);
274 s = g_string_new (NULL);
276 /* we assume the values are sorted from lowest to highest value */
280 if (vals[i].value != 0 && (flags_left & vals[i].value) == vals[i].value) {
282 g_string_append_c (s, '+');
283 g_string_append (s, vals[i].value_nick);
284 flags_left -= vals[i].value;
291 g_string_assign (s, "(none)");
293 return g_string_free (s, FALSE);
296 #define KNOWN_PARAM_FLAGS \
297 (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY | \
298 G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS | \
299 G_PARAM_READABLE | G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE | \
300 GST_PARAM_MUTABLE_PLAYING | GST_PARAM_MUTABLE_PAUSED | \
301 GST_PARAM_MUTABLE_READY)
304 print_element_properties_info (GstElement * element)
306 GParamSpec **property_specs;
307 guint num_properties, i;
311 property_specs = g_object_class_list_properties
312 (G_OBJECT_GET_CLASS (element), &num_properties);
314 n_print ("Element Properties:\n");
316 for (i = 0; i < num_properties; i++) {
317 GValue value = { 0, };
318 GParamSpec *param = property_specs[i];
322 g_value_init (&value, param->value_type);
324 n_print (" %-20s: %s\n", g_param_spec_get_name (param),
325 g_param_spec_get_blurb (param));
328 n_print ("%-23.23s flags: ", "");
329 if (param->flags & G_PARAM_READABLE) {
330 g_object_get_property (G_OBJECT (element), param->name, &value);
332 g_print ("%s%s", (first_flag) ? "" : ", ", _("readable"));
335 if (param->flags & G_PARAM_WRITABLE) {
336 g_print ("%s%s", (first_flag) ? "" : ", ", _("writable"));
339 if (param->flags & GST_PARAM_CONTROLLABLE) {
340 g_print (", %s", _("controllable"));
343 if (param->flags & GST_PARAM_MUTABLE_PLAYING) {
344 g_print (", %s", _("changeable in NULL, READY, PAUSED or PLAYING state"));
345 } else if (param->flags & GST_PARAM_MUTABLE_PAUSED) {
346 g_print (", %s", _("changeable only in NULL, READY or PAUSED state"));
347 } else if (param->flags & GST_PARAM_MUTABLE_READY) {
348 g_print (", %s", _("changeable only in NULL or READY state"));
350 if (param->flags & ~KNOWN_PARAM_FLAGS) {
351 g_print ("%s0x%0x", (first_flag) ? "" : ", ",
352 param->flags & ~KNOWN_PARAM_FLAGS);
356 switch (G_VALUE_TYPE (&value)) {
359 GParamSpecString *pstring = G_PARAM_SPEC_STRING (param);
361 n_print ("%-23.23s String. ", "");
363 if (pstring->default_value == NULL)
364 g_print ("Default: null ");
366 g_print ("Default: \"%s\" ", pstring->default_value);
369 const char *string_val = g_value_get_string (&value);
371 if (string_val == NULL)
372 g_print ("Current: null");
374 g_print ("Current: \"%s\"", string_val);
380 GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param);
382 n_print ("%-23.23s Boolean. ", "");
383 g_print ("Default: %s ", (pboolean->default_value ? "true" : "false"));
385 g_print ("Current: %s",
386 (g_value_get_boolean (&value) ? "true" : "false"));
391 GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
393 n_print ("%-23.23s Unsigned Long. ", "");
394 g_print ("Range: %lu - %lu Default: %lu ",
395 pulong->minimum, pulong->maximum, pulong->default_value);
397 g_print ("Current: %lu", g_value_get_ulong (&value));
402 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
404 n_print ("%-23.23s Long. ", "");
405 g_print ("Range: %ld - %ld Default: %ld ",
406 plong->minimum, plong->maximum, plong->default_value);
408 g_print ("Current: %ld", g_value_get_long (&value));
413 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
415 n_print ("%-23.23s Unsigned Integer. ", "");
416 g_print ("Range: %u - %u Default: %u ",
417 puint->minimum, puint->maximum, puint->default_value);
419 g_print ("Current: %u", g_value_get_uint (&value));
424 GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
426 n_print ("%-23.23s Integer. ", "");
427 g_print ("Range: %d - %d Default: %d ",
428 pint->minimum, pint->maximum, pint->default_value);
430 g_print ("Current: %d", g_value_get_int (&value));
435 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
437 n_print ("%-23.23s Unsigned Integer64. ", "");
438 g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
439 " Default: %" G_GUINT64_FORMAT " ",
440 puint64->minimum, puint64->maximum, puint64->default_value);
442 g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value));
447 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
449 n_print ("%-23.23s Integer64. ", "");
450 g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
451 " Default: %" G_GINT64_FORMAT " ",
452 pint64->minimum, pint64->maximum, pint64->default_value);
454 g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value));
459 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
461 n_print ("%-23.23s Float. ", "");
462 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
463 pfloat->minimum, pfloat->maximum, pfloat->default_value);
465 g_print ("Current: %15.7g", g_value_get_float (&value));
470 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
472 n_print ("%-23.23s Double. ", "");
473 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
474 pdouble->minimum, pdouble->maximum, pdouble->default_value);
476 g_print ("Current: %15.7g", g_value_get_double (&value));
480 if (param->value_type == GST_TYPE_CAPS) {
481 const GstCaps *caps = gst_value_get_caps (&value);
484 n_print ("%-23.23s Caps (NULL)", "");
486 print_caps (caps, " ");
488 } else if (G_IS_PARAM_SPEC_ENUM (param)) {
489 GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param);
493 const gchar *def_val_nick = "", *cur_val_nick = "";
495 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
496 enum_value = g_value_get_enum (&value);
498 while (values[j].value_name) {
499 if (values[j].value == enum_value)
500 cur_val_nick = values[j].value_nick;
501 if (values[j].value == penum->default_value)
502 def_val_nick = values[j].value_nick;
507 ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"",
508 "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value,
509 def_val_nick, enum_value, cur_val_nick);
512 while (values[j].value_name) {
515 g_print ("%s", _name);
516 g_print ("%-23.23s (%d): %-16s - %s", "",
517 values[j].value, values[j].value_nick, values[j].value_name);
520 /* g_type_class_unref (ec); */
521 } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
522 GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
526 vals = pflags->flags_class->values;
528 cur = flags_to_string (vals, g_value_get_flags (&value));
529 def = flags_to_string (vals, pflags->default_value);
532 ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"",
533 "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value,
534 def, g_value_get_flags (&value), cur);
536 while (vals[0].value_name) {
539 g_print ("%s", _name);
540 g_print ("%-23.23s (0x%08x): %-16s - %s", "",
541 vals[0].value, vals[0].value_nick, vals[0].value_name);
547 } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
548 n_print ("%-23.23s Object of type \"%s\"", "",
549 g_type_name (param->value_type));
550 } else if (G_IS_PARAM_SPEC_BOXED (param)) {
551 n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
552 g_type_name (param->value_type));
553 } else if (G_IS_PARAM_SPEC_POINTER (param)) {
554 if (param->value_type != G_TYPE_POINTER) {
555 n_print ("%-23.23s Pointer of type \"%s\".", "",
556 g_type_name (param->value_type));
558 n_print ("%-23.23s Pointer.", "");
560 } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
561 GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);
563 if (pvarray->element_spec) {
564 n_print ("%-23.23s Array of GValues of type \"%s\"", "",
565 g_type_name (pvarray->element_spec->value_type));
567 n_print ("%-23.23s Array of GValues", "");
569 } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
570 GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);
572 n_print ("%-23.23s Fraction. ", "");
574 g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
575 pfraction->min_num, pfraction->min_den,
576 pfraction->max_num, pfraction->max_den,
577 pfraction->def_num, pfraction->def_den);
579 g_print ("Current: %d/%d",
580 gst_value_get_fraction_numerator (&value),
581 gst_value_get_fraction_denominator (&value));
584 n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
585 g_type_name (param->value_type));
590 g_print (" Write only\n");
594 g_value_reset (&value);
596 if (num_properties == 0)
599 g_free (property_specs);
603 print_pad_templates_info (GstElement * element, GstElementFactory * factory)
605 GstElementClass *gstelement_class;
607 GstStaticPadTemplate *padtemplate;
609 n_print ("Pad Templates:\n");
610 if (!factory->numpadtemplates) {
615 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
617 pads = factory->staticpadtemplates;
619 padtemplate = (GstStaticPadTemplate *) (pads->data);
620 pads = g_list_next (pads);
622 if (padtemplate->direction == GST_PAD_SRC)
623 n_print (" SRC template: '%s'\n", padtemplate->name_template);
624 else if (padtemplate->direction == GST_PAD_SINK)
625 n_print (" SINK template: '%s'\n", padtemplate->name_template);
627 n_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
629 if (padtemplate->presence == GST_PAD_ALWAYS)
630 n_print (" Availability: Always\n");
631 else if (padtemplate->presence == GST_PAD_SOMETIMES)
632 n_print (" Availability: Sometimes\n");
633 else if (padtemplate->presence == GST_PAD_REQUEST) {
634 n_print (" Availability: On request\n");
635 n_print (" Has request_new_pad() function: %s\n",
636 GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
638 n_print (" Availability: UNKNOWN!!!\n");
640 if (padtemplate->static_caps.string) {
641 n_print (" Capabilities:\n");
642 print_caps (gst_static_caps_get (&padtemplate->static_caps), " ");
650 print_element_flag_info (GstElement * element)
652 gboolean have_flags = FALSE;
655 n_print ("Element Flags:\n");
658 n_print (" no flags set\n");
660 if (GST_IS_BIN (element)) {
662 n_print ("Bin Flags:\n");
664 n_print (" no flags set\n");
669 print_implementation_info (GstElement * element)
671 GstElementClass *gstelement_class;
673 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
676 n_print ("Element Implementation:\n");
678 n_print (" Has change_state() function: %s\n",
679 GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
683 print_clocking_info (GstElement * element)
685 if (!gst_element_requires_clock (element) &&
686 !(gst_element_provides_clock (element) &&
687 gst_element_get_clock (element))) {
689 n_print ("Element has no clocking capabilities.");
694 n_print ("Clocking Interaction:\n");
695 if (gst_element_requires_clock (element)) {
696 n_print (" element requires a clock\n");
699 if (gst_element_provides_clock (element)) {
702 clock = gst_element_get_clock (element);
704 n_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock));
706 n_print (" element is supposed to provide a clock but returned NULL\n");
711 print_index_info (GstElement * element)
713 if (gst_element_is_indexable (element)) {
715 n_print ("Indexing capabilities:\n");
716 n_print (" element can do indexing\n");
719 n_print ("Element has no indexing capabilities.\n");
724 print_uri_handler_info (GstElement * element)
726 if (GST_IS_URI_HANDLER (element)) {
727 const gchar *uri_type;
728 gchar **uri_protocols;
730 if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC)
732 else if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) ==
736 uri_type = "unknown";
738 uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
741 n_print ("URI handling capabilities:\n");
742 n_print (" Element can act as %s.\n", uri_type);
744 if (uri_protocols && *uri_protocols) {
745 n_print (" Supported URI protocols:\n");
746 for (; *uri_protocols != NULL; uri_protocols++)
747 n_print (" %s\n", *uri_protocols);
749 n_print (" No supported URI protocols\n");
752 n_print ("Element has no URI handling capabilities.\n");
757 print_pad_info (GstElement * element)
765 if (!element->numpads) {
770 pads = element->pads;
775 pad = GST_PAD (pads->data);
776 pads = g_list_next (pads);
780 name = gst_pad_get_name (pad);
781 if (gst_pad_get_direction (pad) == GST_PAD_SRC)
782 g_print (" SRC: '%s'", name);
783 else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
784 g_print (" SINK: '%s'", name);
786 g_print (" UNKNOWN!!!: '%s'", name);
792 n_print (" Implementation:\n");
794 n_print (" Has chainfunc(): %s\n",
795 GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
796 if (pad->getrangefunc)
797 n_print (" Has getrangefunc(): %s\n",
798 GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
799 if (pad->eventfunc != gst_pad_event_default)
800 n_print (" Has custom eventfunc(): %s\n",
801 GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
802 if (pad->queryfunc != gst_pad_query_default)
803 n_print (" Has custom queryfunc(): %s\n",
804 GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
806 if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default)
807 n_print (" Has custom iterintlinkfunc(): %s\n",
808 GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc));
810 if (pad->getcapsfunc)
811 n_print (" Has getcapsfunc(): %s\n",
812 GST_DEBUG_FUNCPTR_NAME (pad->getcapsfunc));
813 if (pad->fixatecapsfunc)
814 n_print (" Has fixatecapsfunc(): %s\n",
815 GST_DEBUG_FUNCPTR_NAME (pad->fixatecapsfunc));
818 if (pad->padtemplate)
819 n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template);
821 caps = gst_pad_get_current_caps (pad);
823 n_print (" Capabilities:\n");
824 print_caps (caps, " ");
825 gst_caps_unref (caps);
831 has_sometimes_template (GstElement * element)
833 GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
836 for (l = klass->padtemplates; l != NULL; l = l->next) {
837 if (GST_PAD_TEMPLATE (l->data)->presence == GST_PAD_SOMETIMES)
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;
858 /* For elements that have sometimes pads, also list a few useful GstElement
859 * signals. Put these first, so element-specific ones come later. */
860 if (k == 0 && has_sometimes_template (element)) {
861 query = g_new0 (GSignalQuery, 1);
862 g_signal_query (g_signal_lookup ("pad-added", GST_TYPE_ELEMENT), query);
863 found_signals = g_slist_append (found_signals, query);
864 query = g_new0 (GSignalQuery, 1);
865 g_signal_query (g_signal_lookup ("pad-removed", GST_TYPE_ELEMENT), query);
866 found_signals = g_slist_append (found_signals, query);
867 query = g_new0 (GSignalQuery, 1);
868 g_signal_query (g_signal_lookup ("no-more-pads", GST_TYPE_ELEMENT),
870 found_signals = g_slist_append (found_signals, query);
873 for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
874 if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
877 if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
880 signals = g_signal_list_ids (type, &nsignals);
881 for (i = 0; i < nsignals; i++) {
882 query = g_new0 (GSignalQuery, 1);
883 g_signal_query (signals[i], query);
885 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
886 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
887 found_signals = g_slist_append (found_signals, query);
898 n_print ("Element Signals:\n");
900 n_print ("Element Actions:\n");
905 for (l = found_signals; l; l = l->next) {
909 query = (GSignalQuery *) l->data;
910 indent_len = strlen (query->signal_name) +
911 strlen (g_type_name (query->return_type)) + 24;
913 indent = g_new0 (gchar, indent_len + 1);
914 memset (indent, ' ', indent_len);
916 n_print (" \"%s\" : %s user_function (%s* object",
918 g_type_name (query->return_type), g_type_name (type));
920 for (j = 0; j < query->n_params; j++) {
922 g_print ("%s", _name);
923 if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
924 g_print (",\n%s%s arg%d", indent,
925 g_type_name (query->param_types[j]), j);
926 } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
927 g_print (",\n%s%s arg%d", indent,
928 g_type_name (query->param_types[j]), j);
930 g_print (",\n%s%s* arg%d", indent,
931 g_type_name (query->param_types[j]), j);
937 g_print ("%s", _name);
938 g_print (",\n%sgpointer user_data);\n", indent);
946 g_slist_foreach (found_signals, (GFunc) g_free, NULL);
947 g_slist_free (found_signals);
953 print_children_info (GstElement * element)
957 if (!GST_IS_BIN (element))
960 children = (GList *) GST_BIN (element)->children;
963 g_print ("Children:\n");
967 n_print (" %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
968 children = g_list_next (children);
973 print_blacklist (void)
975 GList *plugins, *cur;
978 g_print ("%s\n", _("Blacklisted files:"));
980 plugins = gst_default_registry_get_plugin_list ();
981 for (cur = plugins; cur != NULL; cur = g_list_next (cur)) {
982 GstPlugin *plugin = (GstPlugin *) (cur->data);
983 if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
984 g_print (" %s\n", plugin->desc.name);
990 g_print (_("Total count: "));
991 g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count),
994 gst_plugin_list_free (plugins);
998 print_element_list (gboolean print_all)
1000 int plugincount = 0, featurecount = 0, blacklistcount = 0;
1001 GList *plugins, *orig_plugins;
1003 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
1005 GList *features, *orig_features;
1008 plugin = (GstPlugin *) (plugins->data);
1009 plugins = g_list_next (plugins);
1012 if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
1017 orig_features = features =
1018 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1021 GstPluginFeature *feature;
1023 if (G_UNLIKELY (features->data == NULL))
1025 feature = GST_PLUGIN_FEATURE (features->data);
1028 if (GST_IS_ELEMENT_FACTORY (feature)) {
1029 GstElementFactory *factory;
1031 factory = GST_ELEMENT_FACTORY (feature);
1033 print_element_info (factory, TRUE);
1035 g_print ("%s: %s: %s\n", plugin->desc.name,
1036 GST_OBJECT_NAME (factory),
1037 gst_element_factory_get_longname (factory));
1038 } else if (GST_IS_INDEX_FACTORY (feature)) {
1039 GstIndexFactory *factory;
1041 factory = GST_INDEX_FACTORY (feature);
1043 g_print ("%s: %s: %s\n", plugin->desc.name,
1044 GST_OBJECT_NAME (factory), factory->longdesc);
1045 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1046 GstTypeFindFactory *factory;
1048 factory = GST_TYPE_FIND_FACTORY (feature);
1050 g_print ("%s: %s: ", plugin->desc.name,
1051 gst_plugin_feature_get_name (feature));
1052 if (factory->extensions) {
1055 while (factory->extensions[i]) {
1057 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1064 g_print ("no extensions\n");
1068 n_print ("%s: %s (%s)\n", plugin->desc.name,
1069 GST_OBJECT_NAME (feature), g_type_name (G_OBJECT_TYPE (feature)));
1073 features = g_list_next (features);
1076 gst_plugin_feature_list_free (orig_features);
1079 gst_plugin_list_free (orig_plugins);
1082 g_print (_("Total count: "));
1083 g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
1084 if (blacklistcount) {
1086 g_print (ngettext ("%d blacklist entry", "%d blacklist entries",
1087 blacklistcount), blacklistcount);
1088 g_print (" not shown)");
1091 g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
1096 print_all_uri_handlers (void)
1098 GList *plugins, *p, *features, *f;
1100 plugins = gst_default_registry_get_plugin_list ();
1102 for (p = plugins; p; p = p->next) {
1103 GstPlugin *plugin = (GstPlugin *) (p->data);
1106 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1109 for (f = features; f; f = f->next) {
1110 GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data);
1112 if (GST_IS_ELEMENT_FACTORY (feature)) {
1113 GstElementFactory *factory;
1114 GstElement *element;
1116 factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
1118 g_print ("element plugin %s couldn't be loaded\n", plugin->desc.name);
1122 element = gst_element_factory_create (factory, NULL);
1124 g_print ("couldn't construct element for %s for some reason\n",
1125 GST_OBJECT_NAME (factory));
1126 gst_object_unref (factory);
1130 if (GST_IS_URI_HANDLER (element)) {
1132 gchar **uri_protocols, *joined;
1134 switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
1147 gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
1148 joined = g_strjoinv (", ", uri_protocols);
1150 g_print ("%s (%s, rank %u): %s\n",
1151 gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), dir,
1152 gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
1158 gst_object_unref (element);
1159 gst_object_unref (factory);
1163 gst_plugin_feature_list_free (features);
1166 gst_plugin_list_free (plugins);
1170 print_plugin_info (GstPlugin * plugin)
1172 n_print ("Plugin Details:\n");
1173 n_print (" Name:\t\t\t%s\n", plugin->desc.name);
1174 n_print (" Description:\t\t%s\n", plugin->desc.description);
1175 n_print (" Filename:\t\t%s\n",
1176 plugin->filename ? plugin->filename : "(null)");
1177 n_print (" Version:\t\t%s\n", plugin->desc.version);
1178 n_print (" License:\t\t%s\n", plugin->desc.license);
1179 n_print (" Source module:\t%s\n", plugin->desc.source);
1180 if (plugin->desc.release_datetime != NULL) {
1181 const gchar *tz = "(UTC)";
1184 /* may be: YYYY-MM-DD or YYYY-MM-DDTHH:MMZ */
1185 /* YYYY-MM-DDTHH:MMZ => YYYY-MM-DD HH:MM (UTC) */
1186 str = g_strdup (plugin->desc.release_datetime);
1187 sep = strstr (str, "T");
1190 sep = strstr (sep + 1, "Z");
1196 n_print (" Source release date:\t%s%s\n", str, tz);
1199 n_print (" Binary package:\t%s\n", plugin->desc.package);
1200 n_print (" Origin URL:\t\t%s\n", plugin->desc.origin);
1205 print_plugin_features (GstPlugin * plugin)
1207 GList *features, *origlist;
1208 gint num_features = 0;
1209 gint num_elements = 0;
1210 gint num_typefinders = 0;
1211 gint num_indexes = 0;
1214 origlist = features =
1215 gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
1219 GstPluginFeature *feature;
1221 feature = GST_PLUGIN_FEATURE (features->data);
1223 if (GST_IS_ELEMENT_FACTORY (feature)) {
1224 GstElementFactory *factory;
1226 factory = GST_ELEMENT_FACTORY (feature);
1227 n_print (" %s: %s\n", GST_OBJECT_NAME (factory),
1228 gst_element_factory_get_longname (factory));
1230 } else if (GST_IS_INDEX_FACTORY (feature)) {
1231 GstIndexFactory *factory;
1233 factory = GST_INDEX_FACTORY (feature);
1234 n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
1236 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1237 GstTypeFindFactory *factory;
1239 factory = GST_TYPE_FIND_FACTORY (feature);
1240 if (factory->extensions) {
1243 g_print ("%s: %s: ", plugin->desc.name,
1244 gst_plugin_feature_get_name (feature));
1245 while (factory->extensions[i]) {
1246 g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
1251 g_print ("%s: %s: no extensions\n", plugin->desc.name,
1252 gst_plugin_feature_get_name (feature));
1255 } else if (feature) {
1256 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1257 g_type_name (G_OBJECT_TYPE (feature)));
1261 features = g_list_next (features);
1264 gst_plugin_feature_list_free (origlist);
1267 n_print (" %d features:\n", num_features);
1268 if (num_elements > 0)
1269 n_print (" +-- %d elements\n", num_elements);
1270 if (num_typefinders > 0)
1271 n_print (" +-- %d typefinders\n", num_typefinders);
1272 if (num_indexes > 0)
1273 n_print (" +-- %d indexes\n", num_indexes);
1275 n_print (" +-- %d other objects\n", num_other);
1281 print_element_features (const gchar * element_name)
1283 GstPluginFeature *feature;
1285 /* FIXME implement other pretty print function for these */
1286 feature = gst_default_registry_find_feature (element_name,
1287 GST_TYPE_INDEX_FACTORY);
1289 n_print ("%s: an index\n", element_name);
1292 feature = gst_default_registry_find_feature (element_name,
1293 GST_TYPE_TYPE_FIND_FACTORY);
1295 n_print ("%s: a typefind function\n", element_name);
1303 print_element_info (GstElementFactory * factory, gboolean print_names)
1305 GstElement *element;
1309 GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
1313 g_print ("element plugin couldn't be loaded\n");
1317 element = gst_element_factory_create (factory, NULL);
1319 g_print ("couldn't construct element for some reason\n");
1324 _name = g_strdup_printf ("%s: ", GST_OBJECT_NAME (factory));
1328 print_factory_details_info (factory);
1329 if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
1332 plugin = gst_registry_find_plugin (gst_registry_get_default (),
1333 GST_PLUGIN_FEATURE (factory)->plugin_name);
1335 print_plugin_info (plugin);
1339 print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
1340 print_interfaces (G_OBJECT_TYPE (element));
1342 print_pad_templates_info (element, factory);
1343 print_element_flag_info (element);
1344 print_implementation_info (element);
1345 print_clocking_info (element);
1346 print_index_info (element);
1347 print_uri_handler_info (element);
1348 print_pad_info (element);
1349 print_element_properties_info (element);
1350 print_signal_info (element);
1351 print_children_info (element);
1353 gst_object_unref (element);
1354 gst_object_unref (factory);
1362 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
1364 GstPadDirection direction;
1365 const gchar *type_name;
1367 const GList *static_templates, *l;
1368 GstCaps *caps = NULL;
1371 klass = gst_element_factory_get_klass (factory);
1372 g_return_if_fail (klass != NULL);
1374 if (strstr (klass, "Demuxer") ||
1375 strstr (klass, "Decoder") ||
1376 strstr (klass, "Depay") || strstr (klass, "Parser")) {
1377 type_name = "decoder";
1378 direction = GST_PAD_SINK;
1379 } else if (strstr (klass, "Muxer") ||
1380 strstr (klass, "Encoder") || strstr (klass, "Pay")) {
1381 type_name = "encoder";
1382 direction = GST_PAD_SRC;
1387 /* decoder/demuxer sink pads should always be static and there should only
1388 * be one, the same applies to encoders/muxers and source pads */
1389 static_templates = gst_element_factory_get_static_pad_templates (factory);
1390 for (l = static_templates; l != NULL; l = l->next) {
1391 GstStaticPadTemplate *tmpl = NULL;
1393 tmpl = (GstStaticPadTemplate *) l->data;
1394 if (tmpl->direction == direction) {
1395 caps = gst_static_pad_template_get_caps (tmpl);
1401 g_printerr ("Couldn't find static pad template for %s '%s'\n",
1402 type_name, GST_OBJECT_NAME (factory));
1406 caps = gst_caps_make_writable (caps);
1407 num = gst_caps_get_size (caps);
1408 for (i = 0; i < num; ++i) {
1412 s = gst_caps_get_structure (caps, i);
1413 /* remove fields that are almost always just MIN-MAX of some sort
1414 * in order to make the caps look less messy */
1415 gst_structure_remove_field (s, "pixel-aspect-ratio");
1416 gst_structure_remove_field (s, "framerate");
1417 gst_structure_remove_field (s, "channels");
1418 gst_structure_remove_field (s, "width");
1419 gst_structure_remove_field (s, "height");
1420 gst_structure_remove_field (s, "rate");
1421 gst_structure_remove_field (s, "depth");
1422 gst_structure_remove_field (s, "clock-rate");
1423 s_str = gst_structure_to_string (s);
1424 g_print ("%s-%s\n", type_name, s_str);
1427 gst_caps_unref (caps);
1431 print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
1433 gchar **protocols, **p;
1435 protocols = gst_element_factory_get_uri_protocols (factory);
1436 if (protocols != NULL && *protocols != NULL) {
1437 switch (gst_element_factory_get_uri_type (factory)) {
1439 for (p = protocols; *p != NULL; ++p)
1440 g_print ("urisink-%s\n", *p);
1443 for (p = protocols; *p != NULL; ++p)
1444 g_print ("urisource-%s\n", *p);
1449 g_strfreev (protocols);
1454 print_plugin_automatic_install_info (GstPlugin * plugin)
1456 const gchar *plugin_name;
1457 GList *features, *l;
1459 plugin_name = gst_plugin_get_name (plugin);
1461 /* not interested in typefind factories, only element factories */
1462 features = gst_registry_get_feature_list (gst_registry_get_default (),
1463 GST_TYPE_ELEMENT_FACTORY);
1465 for (l = features; l != NULL; l = l->next) {
1466 GstPluginFeature *feature;
1468 feature = GST_PLUGIN_FEATURE (l->data);
1470 /* only interested in the ones that are in the plugin we just loaded */
1471 if (g_str_equal (plugin_name, feature->plugin_name)) {
1472 GstElementFactory *factory;
1474 g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
1476 factory = GST_ELEMENT_FACTORY (feature);
1477 print_plugin_automatic_install_info_protocols (factory);
1478 print_plugin_automatic_install_info_codecs (factory);
1482 g_list_foreach (features, (GFunc) gst_object_unref, NULL);
1483 g_list_free (features);
1487 print_all_plugin_automatic_install_info (void)
1489 GList *plugins, *orig_plugins;
1491 orig_plugins = plugins = gst_default_registry_get_plugin_list ();
1495 plugin = (GstPlugin *) (plugins->data);
1496 plugins = g_list_next (plugins);
1498 print_plugin_automatic_install_info (plugin);
1500 gst_plugin_list_free (orig_plugins);
1504 main (int argc, char *argv[])
1506 gboolean print_all = FALSE;
1507 gboolean do_print_blacklist = FALSE;
1508 gboolean plugin_name = FALSE;
1509 gboolean print_aii = FALSE;
1510 gboolean uri_handlers = FALSE;
1511 #ifndef GST_DISABLE_OPTION_PARSING
1512 GOptionEntry options[] = {
1513 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
1514 N_("Print all elements"), NULL},
1515 {"print-blacklist", 'b', 0, G_OPTION_ARG_NONE, &do_print_blacklist,
1516 N_("Print list of blacklisted files"), NULL},
1517 {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
1518 N_("Print a machine-parsable list of features the specified plugin "
1519 "or all plugins provide.\n "
1520 "Useful in connection with external automatic plugin "
1521 "installation mechanisms"), NULL},
1522 {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
1523 N_("List the plugin contents"), NULL},
1524 {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
1526 ("Print supported URI schemes, with the elements that implement them"),
1528 GST_TOOLS_GOPTION_VERSION,
1531 GOptionContext *ctx;
1536 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1537 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1538 textdomain (GETTEXT_PACKAGE);
1541 g_thread_init (NULL);
1543 gst_tools_set_prgname ("gst-inspect");
1545 #ifndef GST_DISABLE_OPTION_PARSING
1546 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
1547 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
1548 g_option_context_add_group (ctx, gst_init_get_option_group ());
1549 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1550 g_print ("Error initializing: %s\n", err->message);
1553 g_option_context_free (ctx);
1555 gst_init (&argc, &argv);
1558 gst_tools_print_version ("gst-inspect");
1560 if (print_all && argc > 1) {
1561 g_print ("-a requires no extra arguments\n");
1565 if (uri_handlers && argc > 1) {
1566 g_print ("-u requires no extra arguments\n");
1570 /* if no arguments, print out list of elements */
1572 print_all_uri_handlers ();
1573 } else if (argc == 1 || print_all) {
1574 if (do_print_blacklist)
1578 print_all_plugin_automatic_install_info ();
1580 print_element_list (print_all);
1583 /* else we try to get a factory */
1584 GstElementFactory *factory;
1586 const char *arg = argv[argc - 1];
1590 factory = gst_element_factory_find (arg);
1592 /* if there's a factory, print out the info */
1594 retval = print_element_info (factory, print_all);
1595 gst_object_unref (factory);
1597 retval = print_element_features (arg);
1603 /* otherwise check if it's a plugin */
1605 plugin = gst_default_registry_find_plugin (arg);
1607 /* if there is such a plugin, print out info */
1610 print_plugin_automatic_install_info (plugin);
1612 print_plugin_info (plugin);
1613 print_plugin_features (plugin);
1616 GError *error = NULL;
1618 if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
1619 plugin = gst_plugin_load_file (arg, &error);
1623 print_plugin_automatic_install_info (plugin);
1625 print_plugin_info (plugin);
1626 print_plugin_features (plugin);
1629 g_print (_("Could not load plugin file: %s\n"), error->message);
1630 g_error_free (error);
1634 g_print (_("No such element or plugin '%s'\n"), arg);