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
32 #define DEFAULT_PAGER "less"
35 #include <gst/gst_private.h> /* for internal Factories */
39 #include <glib/gprintf.h>
42 # include <sys/wait.h>
45 static char *_name = NULL;
46 static int indent = 0;
48 static int print_element_info (GstPluginFeature * feature,
49 gboolean print_names);
50 static int print_typefind_info (GstPluginFeature * feature,
51 gboolean print_names);
52 static int print_tracer_info (GstPluginFeature * feature, gboolean print_names);
54 #define push_indent() push_indent_n(1)
55 #define pop_indent() push_indent_n(-1)
56 #define pop_indent_n(n) push_indent_n(-n)
61 g_assert (n > 0 || indent > 0);
70 n_print (const char *format, ...)
76 g_print ("%s", _name);
78 for (i = 0; i < indent; ++i)
81 va_start (args, format);
82 g_vprintf (format, args);
87 print_field (GQuark field, const GValue * value, gpointer pfx)
89 gchar *str = gst_value_serialize (value);
91 n_print ("%s %15s: %s\n", (gchar *) pfx, g_quark_to_string (field), str);
97 print_caps (const GstCaps * caps, const gchar * pfx)
101 g_return_if_fail (caps != NULL);
103 if (gst_caps_is_any (caps)) {
104 n_print ("%sANY\n", pfx);
107 if (gst_caps_is_empty (caps)) {
108 n_print ("%sEMPTY\n", pfx);
112 for (i = 0; i < gst_caps_get_size (caps); i++) {
113 GstStructure *structure = gst_caps_get_structure (caps, i);
114 GstCapsFeatures *features = gst_caps_get_features (caps, i);
116 if (features && (gst_caps_features_is_any (features) ||
117 !gst_caps_features_is_equal (features,
118 GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) {
119 gchar *features_string = gst_caps_features_to_string (features);
121 n_print ("%s%s(%s)\n", pfx, gst_structure_get_name (structure),
123 g_free (features_string);
125 n_print ("%s%s\n", pfx, gst_structure_get_name (structure));
127 gst_structure_foreach (structure, print_field, (gpointer) pfx);
132 get_rank_name (char *s, gint rank)
134 static const int ranks[4] = {
135 GST_RANK_NONE, GST_RANK_MARGINAL, GST_RANK_SECONDARY, GST_RANK_PRIMARY
137 static const char *rank_names[4] = { "none", "marginal", "secondary",
144 for (i = 0; i < 4; i++) {
145 if (rank == ranks[i])
146 return rank_names[i];
147 if (abs (rank - ranks[i]) < abs (rank - ranks[best_i])) {
152 sprintf (s, "%s %c %d", rank_names[best_i],
153 (rank - ranks[best_i] > 0) ? '+' : '-', abs (ranks[best_i] - rank));
159 print_factory_details_info (GstElementFactory * factory)
165 rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory));
166 n_print ("Factory Details:\n");
169 n_print ("%-25s%s (%d)\n", "Rank", get_rank_name (s, rank), rank);
171 keys = gst_element_factory_get_metadata_keys (factory);
173 for (k = keys; *k != NULL; ++k) {
177 val = gst_element_factory_get_metadata (factory, key);
178 key[0] = g_ascii_toupper (key[0]);
179 n_print ("%-25s%s\n", key, val);
188 print_hierarchy (GType type, gint level, gint * maxlevel)
193 parent = g_type_parent (type);
195 *maxlevel = *maxlevel + 1;
199 print_hierarchy (parent, level, maxlevel);
202 g_print ("%s", _name);
204 for (i = 1; i < *maxlevel - level; i++)
206 if (*maxlevel - level)
209 g_print ("%s\n", g_type_name (type));
216 print_interfaces (GType type)
219 GType *iface, *ifaces = g_type_interfaces (type, &n_ifaces);
223 n_print (_("Implemented Interfaces:\n"));
227 n_print ("%s\n", g_type_name (*iface));
238 flags_to_string (GFlagsValue * vals, guint flags)
243 /* first look for an exact match and count the number of values */
244 for (i = 0; vals[i].value_name != NULL; ++i) {
245 if (vals[i].value == flags)
246 return g_strdup (vals[i].value_nick);
249 s = g_string_new (NULL);
251 /* we assume the values are sorted from lowest to highest value */
255 if (vals[i].value != 0 && (flags_left & vals[i].value) == vals[i].value) {
257 g_string_append_c (s, '+');
258 g_string_append (s, vals[i].value_nick);
259 flags_left -= vals[i].value;
266 g_string_assign (s, "(none)");
268 return g_string_free (s, FALSE);
271 #define KNOWN_PARAM_FLAGS \
272 (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY | \
273 G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS | \
274 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_DEPRECATED | \
275 GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING | \
276 GST_PARAM_MUTABLE_PAUSED | GST_PARAM_MUTABLE_READY)
279 sort_gparamspecs (GParamSpec ** a, GParamSpec ** b)
281 return g_strcmp0 (g_param_spec_get_name (*a), g_param_spec_get_name (*b));
284 /* obj will be NULL if we're printing properties of pad template pads */
286 print_object_properties_info (GObject * obj, GObjectClass * obj_class,
289 GParamSpec **property_specs;
290 guint num_properties, i;
294 property_specs = g_object_class_list_properties (obj_class, &num_properties);
295 g_qsort_with_data (property_specs, num_properties, sizeof (gpointer),
296 (GCompareDataFunc) sort_gparamspecs, NULL);
298 n_print ("%s:\n", desc);
302 for (i = 0; i < num_properties; i++) {
303 GValue value = { 0, };
304 GParamSpec *param = property_specs[i];
305 GType owner_type = param->owner_type;
307 /* We're printing pad properties */
308 if (obj == NULL && (owner_type == G_TYPE_OBJECT
309 || owner_type == GST_TYPE_OBJECT || owner_type == GST_TYPE_PAD))
314 g_value_init (&value, param->value_type);
316 n_print ("%-20s: %s\n", g_param_spec_get_name (param),
317 g_param_spec_get_blurb (param));
323 readable = ! !(param->flags & G_PARAM_READABLE);
324 if (readable && obj != NULL) {
325 g_object_get_property (obj, param->name, &value);
327 /* if we can't read the property value, assume it's set to the default
328 * (which might not be entirely true for sub-classes, but that's an
329 * unlikely corner-case anyway) */
330 g_param_value_set_default (param, &value);
333 g_print ("%s%s", (first_flag) ? "" : ", ", _("readable"));
336 if (param->flags & G_PARAM_WRITABLE) {
337 g_print ("%s%s", (first_flag) ? "" : ", ", _("writable"));
340 if (param->flags & G_PARAM_DEPRECATED) {
341 g_print ("%s%s", (first_flag) ? "" : ", ", _("deprecated"));
344 if (param->flags & GST_PARAM_CONTROLLABLE) {
345 g_print (", %s", _("controllable"));
348 if (param->flags & GST_PARAM_MUTABLE_PLAYING) {
349 g_print (", %s", _("changeable in NULL, READY, PAUSED or PLAYING state"));
350 } else if (param->flags & GST_PARAM_MUTABLE_PAUSED) {
351 g_print (", %s", _("changeable only in NULL, READY or PAUSED state"));
352 } else if (param->flags & GST_PARAM_MUTABLE_READY) {
353 g_print (", %s", _("changeable only in NULL or READY state"));
355 if (param->flags & ~KNOWN_PARAM_FLAGS) {
356 g_print ("%s0x%0x", (first_flag) ? "" : ", ",
357 param->flags & ~KNOWN_PARAM_FLAGS);
361 switch (G_VALUE_TYPE (&value)) {
364 const char *string_val = g_value_get_string (&value);
366 n_print ("String. ");
368 if (string_val == NULL)
369 g_print ("Default: null");
371 g_print ("Default: \"%s\"", string_val);
376 gboolean bool_val = g_value_get_boolean (&value);
378 n_print ("Boolean. Default: %s", bool_val ? "true" : "false");
383 GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
385 n_print ("Unsigned Long. Range: %lu - %lu Default: %lu ",
386 pulong->minimum, pulong->maximum, g_value_get_ulong (&value));
388 GST_ERROR ("%s: property '%s' of type ulong: consider changing to "
389 "uint/uint64", G_OBJECT_CLASS_NAME (obj_class),
390 g_param_spec_get_name (param));
395 GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
397 n_print ("Long. Range: %ld - %ld Default: %ld ",
398 plong->minimum, plong->maximum, g_value_get_long (&value));
400 GST_ERROR ("%s: property '%s' of type long: consider changing to "
401 "int/int64", G_OBJECT_CLASS_NAME (obj_class),
402 g_param_spec_get_name (param));
407 GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
409 n_print ("Unsigned Integer. Range: %u - %u Default: %u ",
410 puint->minimum, puint->maximum, g_value_get_uint (&value));
415 GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
417 n_print ("Integer. Range: %d - %d Default: %d ",
418 pint->minimum, pint->maximum, g_value_get_int (&value));
423 GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
425 n_print ("Unsigned Integer64. Range: %" G_GUINT64_FORMAT " - "
426 "%" G_GUINT64_FORMAT " Default: %" G_GUINT64_FORMAT " ",
427 puint64->minimum, puint64->maximum, g_value_get_uint64 (&value));
432 GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
434 n_print ("Integer64. Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
435 " Default: %" G_GINT64_FORMAT " ",
436 pint64->minimum, pint64->maximum, g_value_get_int64 (&value));
441 GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
443 n_print ("Float. Range: %15.7g - %15.7g Default: %15.7g ",
444 pfloat->minimum, pfloat->maximum, g_value_get_float (&value));
449 GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
451 n_print ("Double. Range: %15.7g - %15.7g Default: %15.7g ",
452 pdouble->minimum, pdouble->maximum, g_value_get_double (&value));
457 GST_ERROR ("%s: property '%s' of type char: consider changing to "
458 "int/string", G_OBJECT_CLASS_NAME (obj_class),
459 g_param_spec_get_name (param));
462 if (param->value_type == GST_TYPE_CAPS) {
463 const GstCaps *caps = gst_value_get_caps (&value);
466 n_print ("Caps (NULL)");
468 print_caps (caps, " ");
470 } else if (G_IS_PARAM_SPEC_ENUM (param)) {
474 const gchar *value_nick = "";
476 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
477 enum_value = g_value_get_enum (&value);
479 while (values[j].value_name) {
480 if (values[j].value == enum_value)
481 value_nick = values[j].value_nick;
485 n_print ("Enum \"%s\" Default: %d, \"%s\"",
486 g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick);
489 while (values[j].value_name) {
491 n_print (" (%d): %-16s - %s",
492 values[j].value, values[j].value_nick, values[j].value_name);
495 /* g_type_class_unref (ec); */
496 } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
497 GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param);
501 vals = pflags->flags_class->values;
503 cur = flags_to_string (vals, g_value_get_flags (&value));
505 n_print ("Flags \"%s\" Default: 0x%08x, \"%s\"",
506 g_type_name (G_VALUE_TYPE (&value)),
507 g_value_get_flags (&value), cur);
509 while (vals[0].value_name) {
511 n_print (" (0x%08x): %-16s - %s",
512 vals[0].value, vals[0].value_nick, vals[0].value_name);
517 } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
518 n_print ("Object of type \"%s\"", g_type_name (param->value_type));
519 } else if (G_IS_PARAM_SPEC_BOXED (param)) {
520 n_print ("Boxed pointer of type \"%s\"",
521 g_type_name (param->value_type));
522 if (param->value_type == GST_TYPE_STRUCTURE) {
523 const GstStructure *s = gst_value_get_structure (&value);
525 gst_structure_foreach (s, print_field,
528 } else if (G_IS_PARAM_SPEC_POINTER (param)) {
529 if (param->value_type != G_TYPE_POINTER) {
530 n_print ("Pointer of type \"%s\".",
531 g_type_name (param->value_type));
533 n_print ("Pointer.");
535 } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
536 GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);
538 if (pvarray->element_spec) {
539 n_print ("Array of GValues of type \"%s\"",
540 g_type_name (pvarray->element_spec->value_type));
542 n_print ("Array of GValues");
544 } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
545 GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);
547 n_print ("Fraction. Range: %d/%d - %d/%d Default: %d/%d ",
548 pfraction->min_num, pfraction->min_den,
549 pfraction->max_num, pfraction->max_den,
550 gst_value_get_fraction_numerator (&value),
551 gst_value_get_fraction_denominator (&value));
552 } else if (param->value_type == GST_TYPE_ARRAY) {
553 GstParamSpecArray *parray = GST_PARAM_SPEC_ARRAY_LIST (param);
555 if (parray->element_spec) {
556 n_print ("GstValueArray of GValues of type \"%s\"",
557 g_type_name (parray->element_spec->value_type));
559 n_print ("GstValueArray of GValues");
562 n_print ("Unknown type %ld \"%s\"",
563 (glong) param->value_type, g_type_name (param->value_type));
568 g_print (" Write only\n");
574 g_value_reset (&value);
576 if (num_properties == 0)
581 g_free (property_specs);
585 print_element_properties_info (GstElement * element)
588 print_object_properties_info (G_OBJECT (element),
589 G_OBJECT_GET_CLASS (element), "Element Properties");
593 print_pad_templates_info (GstElement * element, GstElementFactory * factory)
596 GstStaticPadTemplate *padtemplate;
597 GstPadTemplate *tmpl;
599 n_print ("Pad Templates:\n");
603 if (gst_element_factory_get_num_pad_templates (factory) == 0) {
608 pads = gst_element_factory_get_static_pad_templates (factory);
610 padtemplate = (GstStaticPadTemplate *) (pads->data);
611 pads = g_list_next (pads);
613 if (padtemplate->direction == GST_PAD_SRC)
614 n_print ("SRC template: '%s'\n", padtemplate->name_template);
615 else if (padtemplate->direction == GST_PAD_SINK)
616 n_print ("SINK template: '%s'\n", padtemplate->name_template);
618 n_print ("UNKNOWN template: '%s'\n", padtemplate->name_template);
622 if (padtemplate->presence == GST_PAD_ALWAYS)
623 n_print ("Availability: Always\n");
624 else if (padtemplate->presence == GST_PAD_SOMETIMES)
625 n_print ("Availability: Sometimes\n");
626 else if (padtemplate->presence == GST_PAD_REQUEST) {
627 n_print ("Availability: On request\n");
629 n_print ("Availability: UNKNOWN\n");
631 if (padtemplate->static_caps.string) {
632 GstCaps *caps = gst_static_caps_get (&padtemplate->static_caps);
634 n_print ("Capabilities:\n");
637 print_caps (caps, ""); // FIXME
640 gst_caps_unref (caps);
643 tmpl = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (element),
644 padtemplate->name_template);
646 GType pad_type = GST_PAD_TEMPLATE_GTYPE (tmpl);
648 if (pad_type != G_TYPE_NONE && pad_type != GST_TYPE_PAD) {
651 pad_klass = g_type_class_ref (pad_type);
652 n_print ("Type: %s\n", g_type_name (pad_type));
653 print_object_properties_info (NULL, pad_klass, "Pad Properties");
654 g_type_class_unref (pad_klass);
669 print_clocking_info (GstElement * element)
671 gboolean requires_clock, provides_clock;
674 GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_REQUIRE_CLOCK);
676 GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
678 if (!requires_clock && !provides_clock) {
680 n_print ("Element has no clocking capabilities.\n");
685 n_print ("Clocking Interaction:\n");
689 if (requires_clock) {
690 n_print ("element requires a clock\n");
693 if (provides_clock) {
696 clock = gst_element_get_clock (element);
698 n_print ("element provides a clock: %s\n", GST_OBJECT_NAME (clock));
699 gst_object_unref (clock);
701 n_print ("element is supposed to provide a clock but returned NULL\n");
708 print_uri_handler_info (GstElement * element)
710 if (GST_IS_URI_HANDLER (element)) {
711 const gchar *const *uri_protocols;
712 const gchar *uri_type;
714 if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC)
716 else if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) ==
720 uri_type = "unknown";
722 uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
725 n_print ("URI handling capabilities:\n");
729 n_print ("Element can act as %s.\n", uri_type);
731 if (uri_protocols && *uri_protocols) {
732 n_print ("Supported URI protocols:\n");
734 for (; *uri_protocols != NULL; uri_protocols++)
735 n_print ("%s\n", *uri_protocols);
738 n_print ("No supported URI protocols\n");
743 n_print ("Element has no URI handling capabilities.\n");
748 print_pad_info (GstElement * element)
758 if (!element->numpads) {
763 pads = element->pads;
768 pad = GST_PAD (pads->data);
769 pads = g_list_next (pads);
771 name = gst_pad_get_name (pad);
772 if (gst_pad_get_direction (pad) == GST_PAD_SRC)
773 n_print ("SRC: '%s'\n", name);
774 else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
775 n_print ("SINK: '%s'\n", name);
777 n_print ("UNKNOWN: '%s'\n", name);
781 if (pad->padtemplate) {
783 n_print ("Pad Template: '%s'\n", pad->padtemplate->name_template);
787 caps = gst_pad_get_current_caps (pad);
789 n_print ("Capabilities:\n");
791 print_caps (caps, ""); // FIXME
793 gst_caps_unref (caps);
802 has_sometimes_template (GstElement * element)
804 GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
807 for (l = klass->padtemplates; l != NULL; l = l->next) {
808 if (GST_PAD_TEMPLATE (l->data)->presence == GST_PAD_SOMETIMES)
816 gtype_needs_ptr_marker (GType type)
818 if (type == G_TYPE_POINTER)
821 if (G_TYPE_FUNDAMENTAL (type) == G_TYPE_POINTER || G_TYPE_IS_BOXED (type)
822 || G_TYPE_IS_OBJECT (type))
829 print_signal_info (GstElement * element)
831 /* Signals/Actions Block */
835 GSignalQuery *query = NULL;
837 GSList *found_signals, *l;
839 for (k = 0; k < 2; k++) {
840 found_signals = NULL;
842 /* For elements that have sometimes pads, also list a few useful GstElement
843 * signals. Put these first, so element-specific ones come later. */
844 if (k == 0 && has_sometimes_template (element)) {
845 query = g_new0 (GSignalQuery, 1);
846 g_signal_query (g_signal_lookup ("pad-added", GST_TYPE_ELEMENT), query);
847 found_signals = g_slist_append (found_signals, query);
848 query = g_new0 (GSignalQuery, 1);
849 g_signal_query (g_signal_lookup ("pad-removed", GST_TYPE_ELEMENT), query);
850 found_signals = g_slist_append (found_signals, query);
851 query = g_new0 (GSignalQuery, 1);
852 g_signal_query (g_signal_lookup ("no-more-pads", GST_TYPE_ELEMENT),
854 found_signals = g_slist_append (found_signals, query);
857 for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
858 if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
861 if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
864 signals = g_signal_list_ids (type, &nsignals);
865 for (i = 0; i < nsignals; i++) {
866 query = g_new0 (GSignalQuery, 1);
867 g_signal_query (signals[i], query);
869 if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
870 (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
871 found_signals = g_slist_append (found_signals, query);
882 n_print ("Element Signals:\n");
884 n_print ("Element Actions:\n");
889 for (l = found_signals; l; l = l->next) {
894 query = (GSignalQuery *) l->data;
895 indent_len = strlen (query->signal_name) +
896 strlen (g_type_name (query->return_type)) + 24;
898 if (gtype_needs_ptr_marker (query->return_type)) {
905 indent = g_new0 (gchar, indent_len + 1);
906 memset (indent, ' ', indent_len);
908 n_print (" \"%s\" : %s %suser_function (%s* object",
909 query->signal_name, g_type_name (query->return_type), pmark,
912 for (j = 0; j < query->n_params; j++) {
913 const gchar *type_name, *asterisk;
915 type_name = g_type_name (query->param_types[j]);
916 asterisk = gtype_needs_ptr_marker (query->param_types[j]) ? "*" : "";
919 n_print ("%s%s%s arg%d", indent, type_name, asterisk, j);
924 n_print ("%sgpointer user_data);\n", indent);
932 g_slist_foreach (found_signals, (GFunc) g_free, NULL);
933 g_slist_free (found_signals);
939 print_children_info (GstElement * element)
943 if (!GST_IS_BIN (element))
946 children = (GList *) GST_BIN (element)->children;
949 n_print ("Children:\n");
953 n_print (" %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
954 children = g_list_next (children);
959 print_preset_list (GstElement * element)
961 gchar **presets, **preset;
963 if (!GST_IS_PRESET (element))
966 presets = gst_preset_get_preset_names (GST_PRESET (element));
967 if (presets && *presets) {
969 n_print ("Presets:\n");
970 for (preset = presets; *preset; preset++) {
971 n_print (" \"%s\"\n", *preset);
973 g_strfreev (presets);
978 print_blacklist (void)
980 GList *plugins, *cur;
983 g_print ("%s\n", _("Blacklisted files:"));
985 plugins = gst_registry_get_plugin_list (gst_registry_get ());
986 for (cur = plugins; cur != NULL; cur = g_list_next (cur)) {
987 GstPlugin *plugin = (GstPlugin *) (cur->data);
988 if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) {
989 g_print (" %s\n", gst_plugin_get_name (plugin));
995 g_print (_("Total count: "));
996 g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count),
999 gst_plugin_list_free (plugins);
1003 print_typefind_extensions (const gchar * const *extensions)
1007 while (extensions[i]) {
1008 g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
1014 print_element_list (gboolean print_all, gchar * ftypes)
1016 int plugincount = 0, featurecount = 0, blacklistcount = 0;
1017 GList *plugins, *orig_plugins;
1018 gchar **types = NULL;
1023 types = g_strsplit (ftypes, "/", -1);
1024 for (i = 0; types[i]; i++)
1025 *types[i] = g_ascii_toupper (*types[i]);
1029 orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ());
1031 GList *features, *orig_features;
1034 plugin = (GstPlugin *) (plugins->data);
1035 plugins = g_list_next (plugins);
1038 if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) {
1043 orig_features = features =
1044 gst_registry_get_feature_list_by_plugin (gst_registry_get (),
1045 gst_plugin_get_name (plugin));
1047 GstPluginFeature *feature;
1049 if (G_UNLIKELY (features->data == NULL))
1051 feature = GST_PLUGIN_FEATURE (features->data);
1054 if (GST_IS_ELEMENT_FACTORY (feature)) {
1056 GstElementFactory *factory;
1058 factory = GST_ELEMENT_FACTORY (feature);
1061 gboolean all_found = TRUE;
1064 gst_element_factory_get_metadata (factory,
1065 GST_ELEMENT_METADATA_KLASS);
1066 for (i = 0; types[i]; i++) {
1067 if (!strstr (klass, types[i])) {
1077 print_element_info (feature, TRUE);
1079 g_print ("%s: %s: %s\n", gst_plugin_get_name (plugin),
1080 GST_OBJECT_NAME (factory),
1081 gst_element_factory_get_metadata (factory,
1082 GST_ELEMENT_METADATA_LONGNAME));
1083 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1084 GstTypeFindFactory *factory;
1085 const gchar *const *extensions;
1089 factory = GST_TYPE_FIND_FACTORY (feature);
1091 g_print ("%s: %s: ", gst_plugin_get_name (plugin),
1092 gst_plugin_feature_get_name (feature));
1094 extensions = gst_type_find_factory_get_extensions (factory);
1095 if (extensions != NULL) {
1097 print_typefind_extensions (extensions);
1102 g_print ("no extensions\n");
1108 n_print ("%s: %s (%s)\n", gst_plugin_get_name (plugin),
1109 GST_OBJECT_NAME (feature), g_type_name (G_OBJECT_TYPE (feature)));
1113 features = g_list_next (features);
1116 gst_plugin_feature_list_free (orig_features);
1119 gst_plugin_list_free (orig_plugins);
1123 g_print (_("Total count: "));
1124 g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
1125 if (blacklistcount) {
1127 g_print (ngettext ("%d blacklist entry", "%d blacklist entries",
1128 blacklistcount), blacklistcount);
1129 g_print (" not shown)");
1132 g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
1137 print_all_uri_handlers (void)
1139 GList *plugins, *p, *features, *f;
1141 plugins = gst_registry_get_plugin_list (gst_registry_get ());
1143 for (p = plugins; p; p = p->next) {
1144 GstPlugin *plugin = (GstPlugin *) (p->data);
1147 gst_registry_get_feature_list_by_plugin (gst_registry_get (),
1148 gst_plugin_get_name (plugin));
1150 for (f = features; f; f = f->next) {
1151 GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data);
1153 if (GST_IS_ELEMENT_FACTORY (feature)) {
1154 GstElementFactory *factory;
1155 GstElement *element;
1157 factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
1159 g_print ("element plugin %s couldn't be loaded\n",
1160 gst_plugin_get_name (plugin));
1164 element = gst_element_factory_create (factory, NULL);
1166 g_print ("couldn't construct element for %s for some reason\n",
1167 GST_OBJECT_NAME (factory));
1168 gst_object_unref (factory);
1172 if (GST_IS_URI_HANDLER (element)) {
1173 const gchar *const *uri_protocols;
1177 switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
1190 gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
1191 joined = g_strjoinv (", ", (gchar **) uri_protocols);
1193 g_print ("%s (%s, rank %u): %s\n",
1194 gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), dir,
1195 gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
1201 gst_object_unref (element);
1202 gst_object_unref (factory);
1206 gst_plugin_feature_list_free (features);
1209 gst_plugin_list_free (plugins);
1213 print_plugin_info (GstPlugin * plugin)
1215 const gchar *release_date = gst_plugin_get_release_date_string (plugin);
1216 const gchar *filename = gst_plugin_get_filename (plugin);
1218 n_print ("Plugin Details:\n");
1222 n_print ("%-25s%s\n", "Name", gst_plugin_get_name (plugin));
1223 n_print ("%-25s%s\n", "Description", gst_plugin_get_description (plugin));
1224 n_print ("%-25s%s\n", "Filename", (filename != NULL) ? filename : "(null)");
1225 n_print ("%-25s%s\n", "Version", gst_plugin_get_version (plugin));
1226 n_print ("%-25s%s\n", "License", gst_plugin_get_license (plugin));
1227 n_print ("%-25s%s\n", "Source module", gst_plugin_get_source (plugin));
1229 if (release_date != NULL) {
1230 const gchar *tz = "(UTC)";
1233 /* may be: YYYY-MM-DD or YYYY-MM-DDTHH:MMZ */
1234 /* YYYY-MM-DDTHH:MMZ => YYYY-MM-DD HH:MM (UTC) */
1235 str = g_strdup (release_date);
1236 sep = strstr (str, "T");
1239 sep = strstr (sep + 1, "Z");
1245 n_print ("%-25s%s%s\n", "Source release date", str, tz);
1248 n_print ("%-25s%s\n", "Binary package", gst_plugin_get_package (plugin));
1249 n_print ("%-25s%s\n", "Origin URL", gst_plugin_get_origin (plugin));
1257 print_plugin_features (GstPlugin * plugin)
1259 GList *features, *origlist;
1260 gint num_features = 0;
1261 gint num_elements = 0;
1262 gint num_tracers = 0;
1263 gint num_typefinders = 0;
1264 gint num_devproviders = 0;
1267 origlist = features =
1268 gst_registry_get_feature_list_by_plugin (gst_registry_get (),
1269 gst_plugin_get_name (plugin));
1272 GstPluginFeature *feature;
1274 feature = GST_PLUGIN_FEATURE (features->data);
1276 if (GST_IS_ELEMENT_FACTORY (feature)) {
1277 GstElementFactory *factory;
1279 factory = GST_ELEMENT_FACTORY (feature);
1280 n_print (" %s: %s\n", GST_OBJECT_NAME (factory),
1281 gst_element_factory_get_metadata (factory,
1282 GST_ELEMENT_METADATA_LONGNAME));
1284 } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
1285 GstTypeFindFactory *factory;
1286 const gchar *const *extensions;
1288 factory = GST_TYPE_FIND_FACTORY (feature);
1289 extensions = gst_type_find_factory_get_extensions (factory);
1293 g_print (" %s: %s: ", gst_plugin_get_name (plugin),
1294 gst_plugin_feature_get_name (feature));
1295 while (extensions[i]) {
1296 g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
1301 g_print (" %s: %s: no extensions\n", gst_plugin_get_name (plugin),
1302 gst_plugin_feature_get_name (feature));
1305 } else if (GST_IS_DEVICE_PROVIDER_FACTORY (feature)) {
1306 GstDeviceProviderFactory *factory;
1308 factory = GST_DEVICE_PROVIDER_FACTORY (feature);
1309 n_print (" %s: %s\n", GST_OBJECT_NAME (factory),
1310 gst_device_provider_factory_get_metadata (factory,
1311 GST_ELEMENT_METADATA_LONGNAME));
1313 } else if (GST_IS_TRACER_FACTORY (feature)) {
1314 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1315 g_type_name (G_OBJECT_TYPE (feature)));
1317 } else if (feature) {
1318 n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
1319 g_type_name (G_OBJECT_TYPE (feature)));
1323 features = g_list_next (features);
1326 gst_plugin_feature_list_free (origlist);
1329 n_print (" %d features:\n", num_features);
1330 if (num_elements > 0)
1331 n_print (" +-- %d elements\n", num_elements);
1332 if (num_typefinders > 0)
1333 n_print (" +-- %d typefinders\n", num_typefinders);
1334 if (num_devproviders > 0)
1335 n_print (" +-- %d device providers\n", num_devproviders);
1336 if (num_tracers > 0)
1337 n_print (" +-- %d tracers\n", num_tracers);
1339 n_print (" +-- %d other objects\n", num_other);
1345 print_feature_info (const gchar * feature_name, gboolean print_all)
1347 GstPluginFeature *feature;
1348 GstRegistry *registry = gst_registry_get ();
1351 if ((feature = gst_registry_find_feature (registry, feature_name,
1352 GST_TYPE_ELEMENT_FACTORY))) {
1353 ret = print_element_info (feature, print_all);
1356 if ((feature = gst_registry_find_feature (registry, feature_name,
1357 GST_TYPE_TYPE_FIND_FACTORY))) {
1358 ret = print_typefind_info (feature, print_all);
1361 if ((feature = gst_registry_find_feature (registry, feature_name,
1362 GST_TYPE_TRACER_FACTORY))) {
1363 ret = print_tracer_info (feature, print_all);
1367 /* TODO: handle DEVICE_PROVIDER_FACTORY */
1372 gst_object_unref (feature);
1377 print_element_info (GstPluginFeature * feature, gboolean print_names)
1379 GstElementFactory *factory;
1380 GstElement *element;
1384 factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
1386 g_print ("element plugin couldn't be loaded\n");
1390 element = gst_element_factory_create (factory, NULL);
1392 gst_object_unref (factory);
1393 g_print ("couldn't construct element for some reason\n");
1398 _name = g_strdup_printf ("%s: ", GST_OBJECT_NAME (factory));
1402 print_factory_details_info (factory);
1404 plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
1406 print_plugin_info (plugin);
1407 gst_object_unref (plugin);
1410 print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
1411 print_interfaces (G_OBJECT_TYPE (element));
1413 print_pad_templates_info (element, factory);
1414 print_clocking_info (element);
1415 print_uri_handler_info (element);
1416 print_pad_info (element);
1417 print_element_properties_info (element);
1418 print_signal_info (element);
1419 print_children_info (element);
1420 print_preset_list (element);
1422 gst_object_unref (element);
1423 gst_object_unref (factory);
1429 print_typefind_info (GstPluginFeature * feature, gboolean print_names)
1431 GstTypeFindFactory *factory;
1436 const gchar *const *extensions;
1438 factory = GST_TYPE_FIND_FACTORY (gst_plugin_feature_load (feature));
1440 g_print ("typefind plugin couldn't be loaded\n");
1445 _name = g_strdup_printf ("%s: ", GST_OBJECT_NAME (factory));
1449 n_print ("Factory Details:\n");
1450 rank = gst_plugin_feature_get_rank (feature);
1451 n_print (" %-25s%s (%d)\n", "Rank", get_rank_name (s, rank), rank);
1452 n_print (" %-25s%s\n", "Name", GST_OBJECT_NAME (factory));
1453 caps = gst_type_find_factory_get_caps (factory);
1455 gchar *caps_str = gst_caps_to_string (factory->caps);
1457 n_print (" %-25s%s\n", "Caps", caps_str);
1460 extensions = gst_type_find_factory_get_extensions (factory);
1462 n_print (" %-25s", "Extensions");
1463 print_typefind_extensions (extensions);
1468 plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
1470 print_plugin_info (plugin);
1471 gst_object_unref (plugin);
1474 gst_object_unref (factory);
1480 print_tracer_info (GstPluginFeature * feature, gboolean print_names)
1482 GstTracerFactory *factory;
1487 factory = GST_TRACER_FACTORY (gst_plugin_feature_load (feature));
1489 g_print ("tracer plugin couldn't be loaded\n");
1493 tracer = (GstTracer *) g_object_new (factory->type, NULL);
1495 gst_object_unref (factory);
1496 g_print ("couldn't construct tracer for some reason\n");
1501 _name = g_strdup_printf ("%s: ", GST_OBJECT_NAME (factory));
1505 n_print ("Factory Details:\n");
1506 n_print (" %-25s%s\n", "Name", GST_OBJECT_NAME (factory));
1509 plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
1511 print_plugin_info (plugin);
1512 gst_object_unref (plugin);
1515 print_hierarchy (G_OBJECT_TYPE (tracer), 0, &maxlevel);
1516 print_interfaces (G_OBJECT_TYPE (tracer));
1518 /* TODO: list what hooks it registers
1519 * - the data is available in gsttracerutils, we need to iterate the
1520 * _priv_tracers hashtable for each probe and then check the list of hooks
1521 * for each probe whether hook->tracer == tracer :/
1524 /* TODO: list what records it emits
1525 * - in class_init tracers can create GstTracerRecord instances
1526 * - those only get logged right now and there is no association with the
1527 * tracer that created them
1528 * - we'd need to add them to GstTracerFactory
1529 * gst_tracer_class_add_record (klass, record);
1530 * - needs work in gstregistrychunks to (de)serialize specs
1531 * - gst_tracer_register() would need to iterate the list of records and
1532 * copy the record->spec into the factory
1535 gst_object_unref (tracer);
1536 gst_object_unref (factory);
1542 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
1544 GstPadDirection direction;
1545 const gchar *type_name;
1547 const GList *static_templates, *l;
1548 GstCaps *caps = NULL;
1552 gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS);
1553 g_return_if_fail (klass != NULL);
1555 if (strstr (klass, "Demuxer") ||
1556 strstr (klass, "Decoder") ||
1557 strstr (klass, "Depay") || strstr (klass, "Parser")) {
1558 type_name = "decoder";
1559 direction = GST_PAD_SINK;
1560 } else if (strstr (klass, "Muxer") ||
1561 strstr (klass, "Encoder") || strstr (klass, "Pay")) {
1562 type_name = "encoder";
1563 direction = GST_PAD_SRC;
1568 /* decoder/demuxer sink pads should always be static and there should only
1569 * be one, the same applies to encoders/muxers and source pads */
1570 static_templates = gst_element_factory_get_static_pad_templates (factory);
1571 for (l = static_templates; l != NULL; l = l->next) {
1572 GstStaticPadTemplate *tmpl = NULL;
1574 tmpl = (GstStaticPadTemplate *) l->data;
1575 if (tmpl->direction == direction) {
1576 caps = gst_static_pad_template_get_caps (tmpl);
1582 g_printerr ("Couldn't find static pad template for %s '%s'\n",
1583 type_name, GST_OBJECT_NAME (factory));
1587 caps = gst_caps_make_writable (caps);
1588 num = gst_caps_get_size (caps);
1589 for (i = 0; i < num; ++i) {
1593 s = gst_caps_get_structure (caps, i);
1594 /* remove fields that are almost always just MIN-MAX of some sort
1595 * in order to make the caps look less messy */
1596 gst_structure_remove_field (s, "pixel-aspect-ratio");
1597 gst_structure_remove_field (s, "framerate");
1598 gst_structure_remove_field (s, "channels");
1599 gst_structure_remove_field (s, "width");
1600 gst_structure_remove_field (s, "height");
1601 gst_structure_remove_field (s, "rate");
1602 gst_structure_remove_field (s, "depth");
1603 gst_structure_remove_field (s, "clock-rate");
1604 s_str = gst_structure_to_string (s);
1605 g_print ("%s-%s\n", type_name, s_str);
1608 gst_caps_unref (caps);
1612 print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
1614 const gchar *const *protocols;
1616 protocols = gst_element_factory_get_uri_protocols (factory);
1617 if (protocols != NULL && *protocols != NULL) {
1618 switch (gst_element_factory_get_uri_type (factory)) {
1620 while (*protocols != NULL) {
1621 g_print ("urisink-%s\n", *protocols);
1626 while (*protocols != NULL) {
1627 g_print ("urisource-%s\n", *protocols);
1638 print_plugin_automatic_install_info (GstPlugin * plugin)
1640 GList *features, *l;
1642 /* not interested in typefind factories, only element factories */
1643 features = gst_registry_get_feature_list (gst_registry_get (),
1644 GST_TYPE_ELEMENT_FACTORY);
1646 for (l = features; l != NULL; l = l->next) {
1647 GstPluginFeature *feature;
1648 GstPlugin *feature_plugin;
1650 feature = GST_PLUGIN_FEATURE (l->data);
1652 /* only interested in the ones that are in the plugin we just loaded */
1653 feature_plugin = gst_plugin_feature_get_plugin (feature);
1654 if (feature_plugin == plugin) {
1655 GstElementFactory *factory;
1657 g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
1659 factory = GST_ELEMENT_FACTORY (feature);
1660 print_plugin_automatic_install_info_protocols (factory);
1661 print_plugin_automatic_install_info_codecs (factory);
1664 gst_object_unref (feature_plugin);
1667 g_list_foreach (features, (GFunc) gst_object_unref, NULL);
1668 g_list_free (features);
1672 print_all_plugin_automatic_install_info (void)
1674 GList *plugins, *orig_plugins;
1676 orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ());
1680 plugin = (GstPlugin *) (plugins->data);
1681 plugins = g_list_next (plugins);
1683 print_plugin_automatic_install_info (plugin);
1685 gst_plugin_list_free (orig_plugins);
1690 redirect_stdout (void)
1695 if (pipe (pipefd) == -1) {
1696 g_printerr (_("Error creating pipe: %s\n"), g_strerror (errno));
1701 if (child_id == -1) {
1702 g_printerr (_("Error forking: %s\n"), g_strerror (errno));
1706 if (child_id == 0) {
1711 pager = g_getenv ("PAGER");
1713 pager = DEFAULT_PAGER;
1714 argv = g_strsplit (pager, " ", 0);
1718 dup2 (pipefd[0], STDIN_FILENO);
1721 ret = execvp (argv[0], argv);
1724 /* No less? Let's just dump everything to stdout then */
1730 if ((ret = read (STDIN_FILENO, buffer, sizeof (buffer))) == -1) {
1731 if (errno == EINTR || errno == EAGAIN) {
1735 g_printerr (_("Error reading from console: %s\n"),
1736 g_strerror (errno));
1741 bytes_written = write (STDOUT_FILENO, buffer, ret);
1742 } while (bytes_written == -1 && (errno == EINTR || errno == EAGAIN));
1744 if (bytes_written < 0) {
1745 g_printerr (_("Error writing to console: %s\n"), g_strerror (errno));
1754 dup2 (pipefd[1], STDOUT_FILENO);
1756 close (STDIN_FILENO);
1762 main (int argc, char *argv[])
1764 gboolean print_all = FALSE;
1765 gboolean do_print_blacklist = FALSE;
1766 gboolean plugin_name = FALSE;
1767 gboolean print_aii = FALSE;
1768 gboolean uri_handlers = FALSE;
1769 gboolean check_exists = FALSE;
1770 gchar *min_version = NULL;
1771 guint minver_maj = GST_VERSION_MAJOR;
1772 guint minver_min = GST_VERSION_MINOR;
1773 guint minver_micro = 0;
1774 gchar *types = NULL;
1775 #ifndef GST_DISABLE_OPTION_PARSING
1776 GOptionEntry options[] = {
1777 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
1778 N_("Print all elements"), NULL},
1779 {"print-blacklist", 'b', 0, G_OPTION_ARG_NONE, &do_print_blacklist,
1780 N_("Print list of blacklisted files"), NULL},
1781 {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii,
1782 N_("Print a machine-parsable list of features the specified plugin "
1783 "or all plugins provide.\n "
1784 "Useful in connection with external automatic plugin "
1785 "installation mechanisms"), NULL},
1786 {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
1787 N_("List the plugin contents"), NULL},
1788 {"types", 't', 0, G_OPTION_ARG_STRING, &types,
1789 N_("A slashes ('/') separated list of types of elements (also known "
1790 "as klass) to list. (unordered)"), NULL},
1791 {"exists", '\0', 0, G_OPTION_ARG_NONE, &check_exists,
1792 N_("Check if the specified element or plugin exists"), NULL},
1793 {"atleast-version", '\0', 0, G_OPTION_ARG_STRING, &min_version,
1795 ("When checking if an element or plugin exists, also check that its "
1796 "version is at least the version specified"), NULL},
1797 {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
1799 ("Print supported URI schemes, with the elements that implement them"),
1801 GST_TOOLS_GOPTION_VERSION,
1804 GOptionContext *ctx;
1808 setlocale (LC_ALL, "");
1811 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1812 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1813 textdomain (GETTEXT_PACKAGE);
1816 /* avoid glib warnings when inspecting deprecated properties */
1817 g_setenv ("G_ENABLE_DIAGNOSTIC", "0", FALSE);
1819 g_set_prgname ("gst-inspect-" GST_API_VERSION);
1821 #ifndef GST_DISABLE_OPTION_PARSING
1822 ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
1823 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
1824 g_option_context_add_group (ctx, gst_init_get_option_group ());
1825 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1826 g_printerr ("Error initializing: %s\n", err->message);
1827 g_clear_error (&err);
1828 g_option_context_free (ctx);
1831 g_option_context_free (ctx);
1833 gst_init (&argc, &argv);
1837 if (isatty (STDOUT_FILENO)) {
1842 gst_tools_print_version ();
1844 if (print_all && argc > 1) {
1845 g_printerr ("-a requires no extra arguments\n");
1849 if (uri_handlers && argc > 1) {
1850 g_printerr ("-u requires no extra arguments\n");
1854 /* --atleast-version implies --exists */
1855 if (min_version != NULL) {
1856 if (sscanf (min_version, "%u.%u.%u", &minver_maj, &minver_min,
1857 &minver_micro) < 2) {
1858 g_printerr ("Can't parse version '%s' passed to --atleast-version\n",
1862 check_exists = TRUE;
1869 g_printerr ("--exists requires an extra command line argument\n");
1873 GstPluginFeature *feature;
1875 feature = gst_registry_lookup_feature (gst_registry_get (), argv[1]);
1876 if (feature != NULL && gst_plugin_feature_check_version (feature,
1877 minver_maj, minver_min, minver_micro)) {
1884 gst_object_unref (feature);
1886 /* FIXME: support checking for plugins too */
1887 g_printerr ("Checking for plugins is not supported yet\n");
1894 /* if no arguments, print out list of elements */
1896 print_all_uri_handlers ();
1897 } else if (argc == 1 || print_all) {
1898 if (do_print_blacklist)
1902 print_all_plugin_automatic_install_info ();
1904 print_element_list (print_all, types);
1907 /* else we try to get a factory */
1908 const char *arg = argv[argc - 1];
1912 retval = print_feature_info (arg, print_all);
1915 /* otherwise check if it's a plugin */
1917 GstPlugin *plugin = gst_registry_find_plugin (gst_registry_get (), arg);
1919 /* if there is such a plugin, print out info */
1922 print_plugin_automatic_install_info (plugin);
1924 print_plugin_info (plugin);
1925 print_plugin_features (plugin);
1928 GError *error = NULL;
1930 if (g_file_test (arg, G_FILE_TEST_EXISTS)) {
1931 plugin = gst_plugin_load_file (arg, &error);
1935 print_plugin_automatic_install_info (plugin);
1937 print_plugin_info (plugin);
1938 print_plugin_features (plugin);
1941 g_printerr (_("Could not load plugin file: %s\n"), error->message);
1942 g_clear_error (&error);
1946 g_printerr (_("No such element or plugin '%s'\n"), arg);
1955 /* So that the pipe we create in redirect_stdout() is closed */
1956 close (STDOUT_FILENO);