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., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
28 /* FIXME 2.0: suppress warnings for deprecated API such as GValueArray
29 * with newer GLib versions (>= 2.31.0) */
30 #define GLIB_DISABLE_DEPRECATION_WARNINGS
36 #include <glib/gprintf.h>
38 static char *_name = NULL;
40 static int print_element_info (GstElementFactory * factory,
41 gboolean print_names);
47 n_print (const char *format, ...)
52 g_print ("%s", _name);
54 va_start (args, format);
55 g_vprintf (format, args);
60 print_field (GQuark field, const GValue * value, gpointer pfx)
62 gchar *str = gst_value_serialize (value);
64 n_print ("%s %15s: %s\n", (gchar *) pfx, g_quark_to_string (field), str);
70 print_caps (const GstCaps * caps, const gchar * pfx)
74 g_return_if_fail (caps != NULL);
76 if (gst_caps_is_any (caps)) {
77 n_print ("%sANY\n", pfx);
80 if (gst_caps_is_empty (caps)) {
81 n_print ("%sEMPTY\n", pfx);
85 for (i = 0; i < gst_caps_get_size (caps); i++) {
86 GstStructure *structure = gst_caps_get_structure (caps, i);
87 GstCapsFeatures *features = gst_caps_get_features (caps, i);
89 if (features && (gst_caps_features_is_any (features) ||
90 !gst_caps_features_is_equal (features,
91 GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) {
92 gchar *features_string = gst_caps_features_to_string (features);
94 n_print ("%s%s(%s)\n", pfx, gst_structure_get_name (structure),
96 g_free (features_string);
98 n_print ("%s%s\n", pfx, gst_structure_get_name (structure));
100 gst_structure_foreach (structure, print_field, (gpointer) pfx);
105 get_rank_name (char *s, gint rank)
107 static const int ranks[4] = {
108 GST_RANK_NONE, GST_RANK_MARGINAL, GST_RANK_SECONDARY, GST_RANK_PRIMARY
110 static const char *rank_names[4] = { "none", "marginal", "secondary",
117 for (i = 0; i < 4; i++) {
118 if (rank == ranks[i])
119 return rank_names[i];
120 if (abs (rank - ranks[i]) < abs (rank - ranks[best_i])) {
125 sprintf (s, "%s %c %d", rank_names[best_i],
126 (rank - ranks[best_i] > 0) ? '+' : '-', abs (ranks[best_i] - rank));
132 print_factory_details_info (GstElementFactory * factory)
138 rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory));
139 n_print ("Factory Details:\n");
140 n_print (" %-25s%s (%d)\n", "Rank", get_rank_name (s, rank), rank);
142 keys = gst_element_factory_get_metadata_keys (factory);
144 for (k = keys; *k != NULL; ++k) {
148 val = gst_element_factory_get_metadata (factory, key);
149 key[0] = g_ascii_toupper (key[0]);
150 n_print (" %-25s%s\n", key, val);
158 print_hierarchy (GType type, gint level, gint * maxlevel)
163 parent = g_type_parent (type);
165 *maxlevel = *maxlevel + 1;
169 print_hierarchy (parent, level, maxlevel);
172 g_print ("%s", _name);
174 for (i = 1; i < *maxlevel - level; i++)
176 if (*maxlevel - level)
179 g_print ("%s\n", g_type_name (type));
186 print_interfaces (GType type)
189 GType *iface, *ifaces = g_type_interfaces (type, &n_ifaces);
194 g_print ("%s", _name);
195 g_print (_("Implemented Interfaces:\n"));
199 g_print ("%s", _name);
200 g_print (" %s\n", g_type_name (*iface));
204 g_print ("%s", _name);
212 flags_to_string (GFlagsValue * vals, guint flags)
217 /* first look for an exact match and count the number of values */
218 for (i = 0; vals[i].value_name != NULL; ++i) {
219 if (vals[i].value == flags)
220 return g_strdup (vals[i].value_nick);
223 s = g_string_new (NULL);
225 /* we assume the values are sorted from lowest to highest value */
229 if (vals[i].value != 0 && (flags_left & vals[i].value) == vals[i].value) {
231 g_string_append_c (s, '+');
232 g_string_append (s, vals[i].value_nick);
233 flags_left -= vals[i].value;
240 g_string_assign (s, "(none)");
242 return g_string_free (s, FALSE);
245 #define KNOWN_PARAM_FLAGS \
246 (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY | \
247 G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS | \
248 G_PARAM_READABLE | G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE | \
249 GST_PARAM_MUTABLE_PLAYING | GST_PARAM_MUTABLE_PAUSED | \
250 GST_PARAM_MUTABLE_READY)
253 print_element_properties_info (GstElement * element)
255 GParamSpec **property_specs;
256 guint num_properties, i;
260 property_specs = g_object_class_list_properties
261 (G_OBJECT_GET_CLASS (element), &num_properties);
263 n_print ("Element Properties:\n");
265 for (i = 0; i < num_properties; i++) {
266 GValue value = { 0, };
267 GParamSpec *param = property_specs[i];
271 g_value_init (&value, param->value_type);
273 n_print (" %-20s: %s\n", g_param_spec_get_name (param),
274 g_param_spec_get_blurb (param));
277 n_print ("%-23.23s flags: ", "");
278 if (param->flags & G_PARAM_READABLE) {
279 g_object_get_property (G_OBJECT (element), param->name, &value);
281 g_print ("%s%s", (first_flag) ? "" : ", ", _("readable"));
284 /* if we can't read the property value, assume it's set to the default
285 * (which might not be entirely true for sub-classes, but that's an
286 * unlikely corner-case anyway) */
287 g_param_value_set_default (param, &value);
289 if (param->flags & G_PARAM_WRITABLE) {
290 g_print ("%s%s", (first_flag) ? "" : ", ", _("writable"));
293 if (param->flags & GST_PARAM_CONTROLLABLE) {
294 g_print (", %s", _("controllable"));
297 if (param->flags & GST_PARAM_MUTABLE_PLAYING) {
298 g_print (", %s", _("changeable in NULL, READY, PAUSED or PLAYING state"));
299 } else if (param->flags & GST_PARAM_MUTABLE_PAUSED) {
300 g_print (", %s", _("changeable only in NULL, READY or PAUSED state"));
301 } else if (param->flags & GST_PARAM_MUTABLE_READY) {
302 g_print (", %s", _("changeable only in NULL or READY state"));
304 if (param->flags & ~KNOWN_PARAM_FLAGS) {
305 g_print ("%s0x%0x", (first_flag) ? "" : ", ",
306 param->flags & ~KNOWN_PARAM_FLAGS);
310 switch (G_VALUE_TYPE (&value)) {
313 const char *string_val = g_value_get_string (&value);
315 n_print ("%-23.23s String. ", "");
317 if (string_val == NULL)
318 g_print ("Default: null");
320 g_print ("Default: \"%s\"", string_val);
325 gboolean bool_val = g_value_get_boolean (&value);
327 n_print ("%-23.23s Boolean. ", "");
329 g_print ("Default: %s", bool_val ? "true" : "false");
334 GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
336 n_print ("%-23.23s Unsigned Long. ", "");
337 g_print ("Range: %lu - %lu Default: %lu ",
338 pulong->minimum, pulong->maximum, g_value_get_ulong (&value));
340 GST_ERROR ("%s: property '%s' of type ulong: consider changing to "
341 "uint/uint64", GST_OBJECT_NAME (element),
342 g_param_spec_get_name (param));
347 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
349 n_print ("%-23.23s Long. ", "");
350 g_print ("Range: %ld - %ld Default: %ld ",
351 plong->minimum, plong->maximum, g_value_get_long (&value));
353 GST_ERROR ("%s: property '%s' of type long: consider changing to "
354 "int/int64", GST_OBJECT_NAME (element),
355 g_param_spec_get_name (param));
360 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
362 n_print ("%-23.23s Unsigned Integer. ", "");
363 g_print ("Range: %u - %u Default: %u ",
364 puint->minimum, puint->maximum, g_value_get_uint (&value));
369 GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
371 n_print ("%-23.23s Integer. ", "");
372 g_print ("Range: %d - %d Default: %d ",
373 pint->minimum, pint->maximum, g_value_get_int (&value));
378 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
380 n_print ("%-23.23s Unsigned Integer64. ", "");
381 g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
382 " Default: %" G_GUINT64_FORMAT " ",
383 puint64->minimum, puint64->maximum, g_value_get_uint64 (&value));
388 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
390 n_print ("%-23.23s Integer64. ", "");
391 g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
392 " Default: %" G_GINT64_FORMAT " ",
393 pint64->minimum, pint64->maximum, g_value_get_int64 (&value));
398 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
400 n_print ("%-23.23s Float. ", "");
401 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
402 pfloat->minimum, pfloat->maximum, g_value_get_float (&value));
407 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
409 n_print ("%-23.23s Double. ", "");
410 g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
411 pdouble->minimum, pdouble->maximum, g_value_get_double (&value));
416 GST_ERROR ("%s: property '%s' of type char: consider changing to "
417 "int/string", GST_OBJECT_NAME (element),
418 g_param_spec_get_name (param));
421 if (param->value_type == GST_TYPE_CAPS) {
422 const GstCaps *caps = gst_value_get_caps (&value);
425 n_print ("%-23.23s Caps (NULL)", "");
427 print_caps (caps, " ");
429 } else if (G_IS_PARAM_SPEC_ENUM (param)) {
433 const gchar *value_nick = "";
435 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
436 enum_value = g_value_get_enum (&value);
438 while (values[j].value_name) {
439 if (values[j].value == enum_value)
440 value_nick = values[j].value_nick;
444 n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\"", "",
445 g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick);
448 while (values[j].value_name) {
451 g_print ("%s", _name);
452 g_print ("%-23.23s (%d): %-16s - %s", "",
453 values[j].value, values[j].value_nick, values[j].value_name);
456 /* g_type_class_unref (ec); */
457 } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
458 GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
462 vals = pflags->flags_class->values;
464 cur = flags_to_string (vals, g_value_get_flags (&value));
466 n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "",
467 g_type_name (G_VALUE_TYPE (&value)),
468 g_value_get_flags (&value), cur);
470 while (vals[0].value_name) {
473 g_print ("%s", _name);
474 g_print ("%-23.23s (0x%08x): %-16s - %s", "",
475 vals[0].value, vals[0].value_nick, vals[0].value_name);
480 } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
481 n_print ("%-23.23s Object of type \"%s\"", "",
482 g_type_name (param->value_type));
483 } else if (G_IS_PARAM_SPEC_BOXED (param)) {
484 n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
485 g_type_name (param->value_type));
486 if (param->value_type == GST_TYPE_STRUCTURE) {
487 const GstStructure *s = gst_value_get_structure (&value);
489 gst_structure_foreach (s, print_field,
492 } else if (G_IS_PARAM_SPEC_POINTER (param)) {
493 if (param->value_type != G_TYPE_POINTER) {
494 n_print ("%-23.23s Pointer of type \"%s\".", "",
495 g_type_name (param->value_type));
497 n_print ("%-23.23s Pointer.", "");
499 } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
500 GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);
502 if (pvarray->element_spec) {
503 n_print ("%-23.23s Array of GValues of type \"%s\"", "",
504 g_type_name (pvarray->element_spec->value_type));
506 n_print ("%-23.23s Array of GValues", "");
508 } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
509 GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);
511 n_print ("%-23.23s Fraction. ", "");
513 g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
514 pfraction->min_num, pfraction->min_den,
515 pfraction->max_num, pfraction->max_den,
516 gst_value_get_fraction_numerator (&value),
517 gst_value_get_fraction_denominator (&value));
519 n_print ("%-23.23s Unknown type %ld \"%s\"", "",
520 (glong) param->value_type, g_type_name (param->value_type));
525 g_print (" Write only\n");
529 g_value_reset (&value);
531 if (num_properties == 0)
534 g_free (property_specs);
538 print_pad_templates_info (GstElement * element, GstElementFactory * factory)
540 GstElementClass *gstelement_class;
542 GstStaticPadTemplate *padtemplate;
544 n_print ("Pad Templates:\n");
545 if (gst_element_factory_get_num_pad_templates (factory) == 0) {
550 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
552 pads = gst_element_factory_get_static_pad_templates (factory);
554 padtemplate = (GstStaticPadTemplate *) (pads->data);
555 pads = g_list_next (pads);
557 if (padtemplate->direction == GST_PAD_SRC)
558 n_print (" SRC template: '%s'\n", padtemplate->name_template);
559 else if (padtemplate->direction == GST_PAD_SINK)
560 n_print (" SINK template: '%s'\n", padtemplate->name_template);
562 n_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
564 if (padtemplate->presence == GST_PAD_ALWAYS)
565 n_print (" Availability: Always\n");
566 else if (padtemplate->presence == GST_PAD_SOMETIMES)
567 n_print (" Availability: Sometimes\n");
568 else if (padtemplate->presence == GST_PAD_REQUEST) {
569 n_print (" Availability: On request\n");
570 n_print (" Has request_new_pad() function: %s\n",
571 GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
573 n_print (" Availability: UNKNOWN!!!\n");
575 if (padtemplate->static_caps.string) {
576 n_print (" Capabilities:\n");
577 print_caps (gst_static_caps_get (&padtemplate->static_caps), " ");
585 print_element_flag_info (GstElement * element)
587 gboolean have_flags = FALSE;
590 n_print ("Element Flags:\n");
593 n_print (" no flags set\n");
595 if (GST_IS_BIN (element)) {
597 n_print ("Bin Flags:\n");
599 n_print (" no flags set\n");
604 print_implementation_info (GstElement * element)
606 GstElementClass *gstelement_class;
608 gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
611 n_print ("Element Implementation:\n");
613 n_print (" Has change_state() function: %s\n",
614 GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
618 print_clocking_info (GstElement * element)
620 gboolean requires_clock, provides_clock;
623 GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_REQUIRE_CLOCK);
625 GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
627 if (!requires_clock && !provides_clock) {
629 n_print ("Element has no clocking capabilities.\n");
634 n_print ("Clocking Interaction:\n");
635 if (requires_clock) {
636 n_print (" element requires a clock\n");
639 if (provides_clock) {
642 clock = gst_element_get_clock (element);
644 n_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock));
645 gst_object_unref (clock);
647 n_print (" element is supposed to provide a clock but returned NULL\n");
652 print_uri_handler_info (GstElement * element)
654 if (GST_IS_URI_HANDLER (element)) {
655 const gchar *const *uri_protocols;
656 const gchar *uri_type;
658 if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC)
660 else if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) ==
664 uri_type = "unknown";
666 uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
669 n_print ("URI handling capabilities:\n");
670 n_print (" Element can act as %s.\n", uri_type);
672 if (uri_protocols && *uri_protocols) {
673 n_print (" Supported URI protocols:\n");
674 for (; *uri_protocols != NULL; uri_protocols++)
675 n_print (" %s\n", *uri_protocols);
677 n_print (" No supported URI protocols\n");
680 n_print ("Element has no URI handling capabilities.\n");
685 print_pad_info (GstElement * element)
693 if (!element->numpads) {
698 pads = element->pads;
703 pad = GST_PAD (pads->data);
704 pads = g_list_next (pads);
706 name = gst_pad_get_name (pad);
707 if (gst_pad_get_direction (pad) == GST_PAD_SRC)
708 g_print (" SRC: '%s'", name);
709 else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
710 g_print (" SINK: '%s'", name);
712 g_print (" UNKNOWN!!!: '%s'", name);
718 if (pad->padtemplate)
719 n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template);
721 caps = gst_pad_get_current_caps (pad);
723 n_print (" Capabilities:\n");
724 print_caps (caps, " ");
725 gst_caps_unref (caps);
731 has_sometimes_template (GstElement * element)
733 GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
736 for (l = klass->padtemplates; l != NULL; l = l->next) {
737 if (GST_PAD_TEMPLATE (l->data)->presence == GST_PAD_SOMETIMES)
745 print_signal_info (GstElement * element)
747 /* Signals/Actions Block */
751 GSignalQuery *query = NULL;
753 GSList *found_signals, *l;
755 for (k = 0; k < 2; k++) {
756 found_signals = NULL;
758 /* For elements that have sometimes pads, also list a few useful GstElement
759 * signals. Put these first, so element-specific ones come later. */
760 if (k == 0 && has_sometimes_template (element)) {
761 query = g_new0 (GSignalQuery, 1);
762 g_signal_query (g_signal_lookup ("pad-added", GST_TYPE_ELEMENT), query);
763 found_signals = g_slist_append (found_signals, query);
764 query = g_new0 (GSignalQuery, 1);
765 g_signal_query (g_signal_lookup ("pad-removed", GST_TYPE_ELEMENT), query);
766 found_signals = g_slist_append (found_signals, query);
767 query = g_new0 (GSignalQuery, 1);
768 g_signal_query (g_signal_lookup ("no-more-pads", GST_TYPE_ELEMENT),
770 found_signals = g_slist_append (found_signals, query);
773 for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
774 if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
777 if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
780 signals = g_signal_list_ids (type, &nsignals);
781 for (i = 0; i < nsignals; i++) {
782 query = g_new0 (GSignalQuery, 1);
783 g_signal_query (signals[i], query);
785 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
786 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
787 found_signals = g_slist_append (found_signals, query);
798 n_print ("Element Signals:\n");
800 n_print ("Element Actions:\n");
805 for (l = found_signals; l; l = l->next) {
810 query = (GSignalQuery *) l->data;
811 indent_len = strlen (query->signal_name) +
812 strlen (g_type_name (query->return_type)) + 24;
815 if (query->return_type == G_TYPE_POINTER) {
817 } else if (G_TYPE_FUNDAMENTAL (query->return_type) == G_TYPE_POINTER
818 || G_TYPE_IS_BOXED (query->return_type)
819 || G_TYPE_IS_OBJECT (query->return_type)) {
826 indent = g_new0 (gchar, indent_len + 1);
827 memset (indent, ' ', indent_len);
829 n_print (" \"%s\" : %s %suser_function (%s* object",
830 query->signal_name, g_type_name (query->return_type), pmark,
833 for (j = 0; j < query->n_params; j++) {
835 if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
836 n_print ("%s%s arg%d", indent,
837 g_type_name (query->param_types[j]), j);
838 } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
839 n_print ("%s%s arg%d", indent,
840 g_type_name (query->param_types[j]), j);
842 n_print ("%s%s* arg%d", indent,
843 g_type_name (query->param_types[j]), j);
849 n_print ("%sgpointer user_data);\n", indent);
857 g_slist_foreach (found_signals, (GFunc) g_free, NULL);
858 g_slist_free (found_signals);
864 print_children_info (GstElement * element)
868 if (!GST_IS_BIN (element))
871 children = (GList *) GST_BIN (element)->children;
874 n_print ("Children:\n");
878 n_print (" %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
879 children = g_list_next (children);
884 print_blacklist (void)
886 GList *plugins, *cur;
889 g_print ("%s\n", _("Blacklisted files:"));
891 plugins = gst_registry_get_plugin_list (gst_registry_get ());
892 for (cur = plugins; cur != NULL; cur = g_list_next (cur)) {
893 GstPlugin *plugin = (GstPlugin *) (cur->data);
894 if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) {
895 g_print (" %s\n", gst_plugin_get_name (plugin));
901 g_print (_("Total count: "));
902 g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count),
905 gst_plugin_list_free (plugins);
909 print_element_list (gboolean print_all)
911 int plugincount = 0, featurecount = 0, blacklistcount = 0;
912 GList *plugins, *orig_plugins;
914 orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ());
916 GList *features, *orig_features;
919 plugin = (GstPlugin *) (plugins->data);
920 plugins = g_list_next (plugins);
923 if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) {
928 orig_features = features =
929 gst_registry_get_feature_list_by_plugin (gst_registry_get (),
930 gst_plugin_get_name (plugin));
932 GstPluginFeature *feature;
934 if (G_UNLIKELY (features->data == NULL))
936 feature = GST_PLUGIN_FEATURE (features->data);
939 if (GST_IS_ELEMENT_FACTORY (feature)) {
940 GstElementFactory *factory;
942 factory = GST_ELEMENT_FACTORY (feature);
944 print_element_info (factory, TRUE);
946 g_print ("%s: %s: %s\n", gst_plugin_get_name (plugin),
947 GST_OBJECT_NAME (factory),
948 gst_element_factory_get_metadata (factory,
949 GST_ELEMENT_METADATA_LONGNAME));
950 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
951 GstTypeFindFactory *factory;
952 const gchar *const *extensions;
954 factory = GST_TYPE_FIND_FACTORY (feature);
956 g_print ("%s: %s: ", gst_plugin_get_name (plugin),
957 gst_plugin_feature_get_name (feature));
959 extensions = gst_type_find_factory_get_extensions (factory);
960 if (extensions != NULL) {
963 while (extensions[i]) {
965 g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
972 g_print ("no extensions\n");
976 n_print ("%s: %s (%s)\n", gst_plugin_get_name (plugin),
977 GST_OBJECT_NAME (feature), g_type_name (G_OBJECT_TYPE (feature)));
981 features = g_list_next (features);
984 gst_plugin_feature_list_free (orig_features);
987 gst_plugin_list_free (orig_plugins);
990 g_print (_("Total count: "));
991 g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
992 if (blacklistcount) {
994 g_print (ngettext ("%d blacklist entry", "%d blacklist entries",
995 blacklistcount), blacklistcount);
996 g_print (" not shown)");
999 g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
1004 print_all_uri_handlers (void)
1006 GList *plugins, *p, *features, *f;
1008 plugins = gst_registry_get_plugin_list (gst_registry_get ());
1010 for (p = plugins; p; p = p->next) {
1011 GstPlugin *plugin = (GstPlugin *) (p->data);
1014 gst_registry_get_feature_list_by_plugin (gst_registry_get (),
1015 gst_plugin_get_name (plugin));
1017 for (f = features; f; f = f->next) {
1018 GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data);
1020 if (GST_IS_ELEMENT_FACTORY (feature)) {
1021 GstElementFactory *factory;
1022 GstElement *element;
1024 factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
1026 g_print ("element plugin %s couldn't be loaded\n",
1027 gst_plugin_get_name (plugin));
1031 element = gst_element_factory_create (factory, NULL);
1033 g_print ("couldn't construct element for %s for some reason\n",
1034 GST_OBJECT_NAME (factory));
1035 gst_object_unref (factory);
1039 if (GST_IS_URI_HANDLER (element)) {
1040 const gchar *const *uri_protocols;
1044 switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
1057 gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
1058 joined = g_strjoinv (", ", (gchar **) uri_protocols);
1060 g_print ("%s (%s, rank %u): %s\n",
1061 gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), dir,
1062 gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
1068 gst_object_unref (element);
1069 gst_object_unref (factory);
1073 gst_plugin_feature_list_free (features);
1076 gst_plugin_list_free (plugins);
1080 print_plugin_info (GstPlugin * plugin)
1082 const gchar *release_date = gst_plugin_get_release_date_string (plugin);
1083 const gchar *filename = gst_plugin_get_filename (plugin);
1085 n_print ("Plugin Details:\n");
1086 n_print (" %-25s%s\n", "Name", gst_plugin_get_name (plugin));
1087 n_print (" %-25s%s\n", "Description", gst_plugin_get_description (plugin));
1088 n_print (" %-25s%s\n", "Filename", (filename != NULL) ? filename : "(null)");
1089 n_print (" %-25s%s\n", "Version", gst_plugin_get_version (plugin));
1090 n_print (" %-25s%s\n", "License", gst_plugin_get_license (plugin));
1091 n_print (" %-25s%s\n", "Source module", gst_plugin_get_source (plugin));
1093 if (release_date != NULL) {
1094 const gchar *tz = "(UTC)";
1097 /* may be: YYYY-MM-DD or YYYY-MM-DDTHH:MMZ */
1098 /* YYYY-MM-DDTHH:MMZ => YYYY-MM-DD HH:MM (UTC) */
1099 str = g_strdup (release_date);
1100 sep = strstr (str, "T");
1103 sep = strstr (sep + 1, "Z");
1109 n_print (" %-25s%s%s\n", "Source release date", str, tz);
1112 n_print (" %-25s%s\n", "Binary package", gst_plugin_get_package (plugin));
1113 n_print (" %-25s%s\n", "Origin URL", gst_plugin_get_origin (plugin));
1118 print_plugin_features (GstPlugin * plugin)
1120 GList *features, *origlist;
1121 gint num_features = 0;
1122 gint num_elements = 0;
1123 gint num_typefinders = 0;
1124 gint num_devproviders = 0;
1127 origlist = features =
1128 gst_registry_get_feature_list_by_plugin (gst_registry_get (),
1129 gst_plugin_get_name (plugin));
1132 GstPluginFeature *feature;
1134 feature = GST_PLUGIN_FEATURE (features->data);
1136 if (GST_IS_ELEMENT_FACTORY (feature)) {
1137 GstElementFactory *factory;
1139 factory = GST_ELEMENT_FACTORY (feature);
1140 n_print (" %s: %s\n", GST_OBJECT_NAME (factory),
1141 gst_element_factory_get_metadata (factory,
1142 GST_ELEMENT_METADATA_LONGNAME));
1144 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1145 GstTypeFindFactory *factory;
1146 const gchar *const *extensions;
1148 factory = GST_TYPE_FIND_FACTORY (feature);
1149 extensions = gst_type_find_factory_get_extensions (factory);
1153 g_print (" %s: %s: ", gst_plugin_get_name (plugin),
1154 gst_plugin_feature_get_name (feature));
1155 while (extensions[i]) {
1156 g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
1161 g_print (" %s: %s: no extensions\n", gst_plugin_get_name (plugin),
1162 gst_plugin_feature_get_name (feature));
1165 } else if (GST_IS_DEVICE_PROVIDER_FACTORY (feature)) {
1166 GstDeviceProviderFactory *factory;
1168 factory = GST_DEVICE_PROVIDER_FACTORY (feature);
1169 n_print (" %s: %s\n", GST_OBJECT_NAME (factory),
1170 gst_device_provider_factory_get_metadata (factory,
1171 GST_ELEMENT_METADATA_LONGNAME));
1173 } else if (feature) {
1174 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1175 g_type_name (G_OBJECT_TYPE (feature)));
1179 features = g_list_next (features);
1182 gst_plugin_feature_list_free (origlist);
1185 n_print (" %d features:\n", num_features);
1186 if (num_elements > 0)
1187 n_print (" +-- %d elements\n", num_elements);
1188 if (num_typefinders > 0)
1189 n_print (" +-- %d typefinders\n", num_typefinders);
1190 if (num_devproviders > 0)
1191 n_print (" +-- %d device providers\n", num_devproviders);
1193 n_print (" +-- %d other objects\n", num_other);
1199 print_element_features (const gchar * element_name)
1201 GstPluginFeature *feature;
1203 /* FIXME implement other pretty print function for these */
1204 feature = gst_registry_find_feature (gst_registry_get (), element_name,
1205 GST_TYPE_TYPE_FIND_FACTORY);
1207 n_print ("%s: a typefind function\n", element_name);
1215 print_element_info (GstElementFactory * factory, gboolean print_names)
1217 GstElement *element;
1222 GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
1226 g_print ("element plugin couldn't be loaded\n");
1230 element = gst_element_factory_create (factory, NULL);
1232 gst_object_unref (factory);
1233 g_print ("couldn't construct element for some reason\n");
1238 _name = g_strdup_printf ("%s: ", GST_OBJECT_NAME (factory));
1242 print_factory_details_info (factory);
1244 plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
1246 print_plugin_info (plugin);
1247 gst_object_unref (plugin);
1250 print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
1251 print_interfaces (G_OBJECT_TYPE (element));
1253 print_pad_templates_info (element, factory);
1254 print_element_flag_info (element);
1255 print_implementation_info (element);
1256 print_clocking_info (element);
1257 print_uri_handler_info (element);
1258 print_pad_info (element);
1259 print_element_properties_info (element);
1260 print_signal_info (element);
1261 print_children_info (element);
1263 gst_object_unref (element);
1264 gst_object_unref (factory);
1272 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
1274 GstPadDirection direction;
1275 const gchar *type_name;
1277 const GList *static_templates, *l;
1278 GstCaps *caps = NULL;
1282 gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS);
1283 g_return_if_fail (klass != NULL);
1285 if (strstr (klass, "Demuxer") ||
1286 strstr (klass, "Decoder") ||
1287 strstr (klass, "Depay") || strstr (klass, "Parser")) {
1288 type_name = "decoder";
1289 direction = GST_PAD_SINK;
1290 } else if (strstr (klass, "Muxer") ||
1291 strstr (klass, "Encoder") || strstr (klass, "Pay")) {
1292 type_name = "encoder";
1293 direction = GST_PAD_SRC;
1298 /* decoder/demuxer sink pads should always be static and there should only
1299 * be one, the same applies to encoders/muxers and source pads */
1300 static_templates = gst_element_factory_get_static_pad_templates (factory);
1301 for (l = static_templates; l != NULL; l = l->next) {
1302 GstStaticPadTemplate *tmpl = NULL;
1304 tmpl = (GstStaticPadTemplate *) l->data;
1305 if (tmpl->direction == direction) {
1306 caps = gst_static_pad_template_get_caps (tmpl);
1312 g_printerr ("Couldn't find static pad template for %s '%s'\n",
1313 type_name, GST_OBJECT_NAME (factory));
1317 caps = gst_caps_make_writable (caps);
1318 num = gst_caps_get_size (caps);
1319 for (i = 0; i < num; ++i) {
1323 s = gst_caps_get_structure (caps, i);
1324 /* remove fields that are almost always just MIN-MAX of some sort
1325 * in order to make the caps look less messy */
1326 gst_structure_remove_field (s, "pixel-aspect-ratio");
1327 gst_structure_remove_field (s, "framerate");
1328 gst_structure_remove_field (s, "channels");
1329 gst_structure_remove_field (s, "width");
1330 gst_structure_remove_field (s, "height");
1331 gst_structure_remove_field (s, "rate");
1332 gst_structure_remove_field (s, "depth");
1333 gst_structure_remove_field (s, "clock-rate");
1334 s_str = gst_structure_to_string (s);
1335 g_print ("%s-%s\n", type_name, s_str);
1338 gst_caps_unref (caps);
1342 print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
1344 const gchar *const *protocols;
1346 protocols = gst_element_factory_get_uri_protocols (factory);
1347 if (protocols != NULL && *protocols != NULL) {
1348 switch (gst_element_factory_get_uri_type (factory)) {
1350 while (*protocols != NULL) {
1351 g_print ("urisink-%s\n", *protocols);
1356 while (*protocols != NULL) {
1357 g_print ("urisource-%s\n", *protocols);
1368 print_plugin_automatic_install_info (GstPlugin * plugin)
1370 GList *features, *l;
1372 /* not interested in typefind factories, only element factories */
1373 features = gst_registry_get_feature_list (gst_registry_get (),
1374 GST_TYPE_ELEMENT_FACTORY);
1376 for (l = features; l != NULL; l = l->next) {
1377 GstPluginFeature *feature;
1378 GstPlugin *feature_plugin;
1380 feature = GST_PLUGIN_FEATURE (l->data);
1382 /* only interested in the ones that are in the plugin we just loaded */
1383 feature_plugin = gst_plugin_feature_get_plugin (feature);
1384 if (feature_plugin == plugin) {
1385 GstElementFactory *factory;
1387 g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
1389 factory = GST_ELEMENT_FACTORY (feature);
1390 print_plugin_automatic_install_info_protocols (factory);
1391 print_plugin_automatic_install_info_codecs (factory);
1394 gst_object_unref (feature_plugin);
1397 g_list_foreach (features, (GFunc) gst_object_unref, NULL);
1398 g_list_free (features);
1402 print_all_plugin_automatic_install_info (void)
1404 GList *plugins, *orig_plugins;
1406 orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ());
1410 plugin = (GstPlugin *) (plugins->data);
1411 plugins = g_list_next (plugins);
1413 print_plugin_automatic_install_info (plugin);
1415 gst_plugin_list_free (orig_plugins);
1419 main (int argc, char *argv[])
1421 gboolean print_all = FALSE;
1422 gboolean do_print_blacklist = FALSE;
1423 gboolean plugin_name = FALSE;
1424 gboolean print_aii = FALSE;
1425 gboolean uri_handlers = FALSE;
1426 gboolean check_exists = FALSE;
1427 gchar *min_version = NULL;
1428 guint minver_maj = GST_VERSION_MAJOR;
1429 guint minver_min = GST_VERSION_MINOR;
1430 guint minver_micro = 0;
1431 #ifndef GST_DISABLE_OPTION_PARSING
1432 GOptionEntry options[] = {
1433 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
1434 N_("Print all elements"), NULL},
1435 {"print-blacklist", 'b', 0, G_OPTION_ARG_NONE, &do_print_blacklist,
1436 N_("Print list of blacklisted files"), NULL},
1437 {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
1438 N_("Print a machine-parsable list of features the specified plugin "
1439 "or all plugins provide.\n "
1440 "Useful in connection with external automatic plugin "
1441 "installation mechanisms"), NULL},
1442 {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
1443 N_("List the plugin contents"), NULL},
1444 {"exists", '\0', 0, G_OPTION_ARG_NONE, &check_exists,
1445 N_("Check if the specified element or plugin exists"), NULL},
1446 {"atleast-version", '\0', 0, G_OPTION_ARG_STRING, &min_version,
1448 ("When checking if an element or plugin exists, also check that its "
1449 "version is at least the version specified"), NULL},
1450 {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
1452 ("Print supported URI schemes, with the elements that implement them"),
1454 GST_TOOLS_GOPTION_VERSION,
1457 GOptionContext *ctx;
1461 setlocale (LC_ALL, "");
1464 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1465 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1466 textdomain (GETTEXT_PACKAGE);
1469 /* avoid glib warnings when inspecting deprecated properties */
1470 g_setenv ("G_ENABLE_DIAGNOSTIC", "0", FALSE);
1472 g_set_prgname ("gst-inspect-" GST_API_VERSION);
1474 #ifndef GST_DISABLE_OPTION_PARSING
1475 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
1476 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
1477 g_option_context_add_group (ctx, gst_init_get_option_group ());
1478 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1479 g_printerr ("Error initializing: %s\n", err->message);
1482 g_option_context_free (ctx);
1484 gst_init (&argc, &argv);
1487 gst_tools_print_version ();
1489 if (print_all && argc > 1) {
1490 g_printerr ("-a requires no extra arguments\n");
1494 if (uri_handlers && argc > 1) {
1495 g_printerr ("-u requires no extra arguments\n");
1499 /* --atleast-version implies --exists */
1500 if (min_version != NULL) {
1501 if (sscanf (min_version, "%u.%u.%u", &minver_maj, &minver_min,
1502 &minver_micro) < 2) {
1503 g_printerr ("Can't parse version '%s' passed to --atleast-version\n",
1507 check_exists = TRUE;
1514 g_printerr ("--exists requires an extra command line argument\n");
1518 GstPluginFeature *feature;
1520 feature = gst_registry_lookup_feature (gst_registry_get (), argv[1]);
1521 if (feature != NULL && gst_plugin_feature_check_version (feature,
1522 minver_maj, minver_min, minver_micro)) {
1528 /* FIXME: support checking for plugins too */
1529 g_printerr ("Checking for plugins is not supported yet\n");
1536 /* if no arguments, print out list of elements */
1538 print_all_uri_handlers ();
1539 } else if (argc == 1 || print_all) {
1540 if (do_print_blacklist)
1544 print_all_plugin_automatic_install_info ();
1546 print_element_list (print_all);
1549 /* else we try to get a factory */
1550 GstElementFactory *factory;
1552 const char *arg = argv[argc - 1];
1556 factory = gst_element_factory_find (arg);
1558 /* if there's a factory, print out the info */
1560 retval = print_element_info (factory, print_all);
1561 gst_object_unref (factory);
1563 retval = print_element_features (arg);
1569 /* otherwise check if it's a plugin */
1571 plugin = gst_registry_find_plugin (gst_registry_get (), arg);
1573 /* if there is such a plugin, print out info */
1576 print_plugin_automatic_install_info (plugin);
1578 print_plugin_info (plugin);
1579 print_plugin_features (plugin);
1582 GError *error = NULL;
1584 if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
1585 plugin = gst_plugin_load_file (arg, &error);
1589 print_plugin_automatic_install_info (plugin);
1591 print_plugin_info (plugin);
1592 print_plugin_features (plugin);
1595 g_printerr (_("Could not load plugin file: %s\n"), error->message);
1596 g_error_free (error);
1600 g_printerr (_("No such element or plugin '%s'\n"), arg);