tools: gst-inspect: don't print element flags whch are always 'none'
[platform/upstream/gstreamer.git] / tools / gst-inspect.c
index 9642ea9..7592049 100644 (file)
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
-/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
- * with newer GLib versions (>= 2.31.0) */
-#define GLIB_DISABLE_DEPRECATION_WARNINGS
-
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
 
+/* FIXME 2.0: suppress warnings for deprecated API such as GValueArray
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include "tools.h"
+#include <gst/gst_private.h>    /* for internal Factories */
 
 #include <string.h>
 #include <locale.h>
 #include <glib/gprintf.h>
 
 static char *_name = NULL;
+static int indent = 0;
 
-static int print_element_info (GstElementFactory * factory,
+static int print_element_info (GstPluginFeature * feature,
+    gboolean print_names);
+static int print_typefind_info (GstPluginFeature * feature,
     gboolean print_names);
+static int print_tracer_info (GstPluginFeature * feature, gboolean print_names);
+
+#define push_indent() push_indent_n(1)
+#define pop_indent() push_indent_n(-1)
+#define pop_indent_n(n) push_indent_n(-n)
+
+static void
+push_indent_n (int n)
+{
+  g_assert (n > 0 || indent > 0);
+  indent += n;
+}
+
+/* *INDENT-OFF* */
+G_GNUC_PRINTF (1, 2)
+/* *INDENT-ON* */
 
 static void
 n_print (const char *format, ...)
 {
   va_list args;
+  int i;
 
   if (_name)
     g_print ("%s", _name);
 
+  for (i = 0; i < indent; ++i)
+    g_print ("  ");
+
   va_start (args, format);
   g_vprintf (format, args);
   va_end (args);
@@ -81,78 +105,22 @@ print_caps (const GstCaps * caps, const gchar * pfx)
 
   for (i = 0; i < gst_caps_get_size (caps); i++) {
     GstStructure *structure = gst_caps_get_structure (caps, i);
+    GstCapsFeatures *features = gst_caps_get_features (caps, i);
 
-    n_print ("%s%s\n", pfx, gst_structure_get_name (structure));
-    gst_structure_foreach (structure, print_field, (gpointer) pfx);
-  }
-}
-
-#if 0
-static void
-print_formats (const GstFormat * formats)
-{
-  while (formats && *formats) {
-    const GstFormatDefinition *definition;
-
-    definition = gst_format_get_details (*formats);
-    if (definition)
-      n_print ("\t\t(%d):\t%s (%s)\n", *formats,
-          definition->nick, definition->description);
-    else
-      n_print ("\t\t(%d):\tUnknown format\n", *formats);
-
-    formats++;
-  }
-}
-
-static void
-print_event_masks (const GstEventMask * masks)
-{
-  GType event_type;
-  GEnumClass *klass;
-  GType event_flags;
-  GFlagsClass *flags_class = NULL;
-
-  event_type = gst_event_type_get_type ();
-  klass = (GEnumClass *) g_type_class_ref (event_type);
-
-  while (masks && masks->type) {
-    GEnumValue *value;
-    gint flags = 0, index = 0;
-
-    switch (masks->type) {
-      case GST_EVENT_SEEK:
-        flags = masks->flags;
-        event_flags = gst_seek_type_get_type ();
-        flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
-        break;
-      default:
-        break;
-    }
-
-    value = g_enum_get_value (klass, masks->type);
-    g_print ("\t\t%s ", value->value_nick);
-
-    while (flags) {
-      GFlagsValue *value;
-
-      if (flags & 1) {
-        value = g_flags_get_first_value (flags_class, 1 << index);
+    if (features && (gst_caps_features_is_any (features) ||
+            !gst_caps_features_is_equal (features,
+                GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) {
+      gchar *features_string = gst_caps_features_to_string (features);
 
-        if (value)
-          g_print ("| %s ", value->value_nick);
-        else
-          g_print ("| ? ");
-      }
-      flags >>= 1;
-      index++;
+      n_print ("%s%s(%s)\n", pfx, gst_structure_get_name (structure),
+          features_string);
+      g_free (features_string);
+    } else {
+      n_print ("%s%s\n", pfx, gst_structure_get_name (structure));
     }
-    g_print ("\n");
-
-    masks++;
+    gst_structure_foreach (structure, print_field, (gpointer) pfx);
   }
 }
-#endif
 
 static const char *
 get_rank_name (char *s, gint rank)
@@ -190,7 +158,9 @@ print_factory_details_info (GstElementFactory * factory)
 
   rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory));
   n_print ("Factory Details:\n");
-  n_print ("  Rank:\t\t%s (%d)\n", get_rank_name (s, rank), rank);
+
+  push_indent ();
+  n_print ("%-25s%s (%d)\n", "Rank", get_rank_name (s, rank), rank);
 
   keys = gst_element_factory_get_metadata_keys (factory);
   if (keys != NULL) {
@@ -200,10 +170,11 @@ print_factory_details_info (GstElementFactory * factory)
 
       val = gst_element_factory_get_metadata (factory, key);
       key[0] = g_ascii_toupper (key[0]);
-      n_print ("  %s:\t\t%s\n", key, val);
+      n_print ("%-25s%s\n", key, val);
     }
     g_strfreev (keys);
   }
+  pop_indent ();
   n_print ("\n");
 }
 
@@ -243,19 +214,15 @@ print_interfaces (GType type)
 
   if (ifaces) {
     if (n_ifaces) {
-      if (_name)
-        g_print ("%s", _name);
-      g_print (_("Implemented Interfaces:\n"));
+      n_print (_("Implemented Interfaces:\n"));
+      push_indent ();
       iface = ifaces;
       while (*iface) {
-        if (_name)
-          g_print ("%s", _name);
-        g_print ("  %s\n", g_type_name (*iface));
+        n_print ("%s\n", g_type_name (*iface));
         iface++;
       }
-      if (_name)
-        g_print ("%s", _name);
-      g_print ("\n");
+      pop_indent ();
+      n_print ("\n");
     }
     g_free (ifaces);
   }
@@ -298,38 +265,48 @@ flags_to_string (GFlagsValue * vals, guint flags)
 #define KNOWN_PARAM_FLAGS \
   (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY | \
   G_PARAM_LAX_VALIDATION |  G_PARAM_STATIC_STRINGS | \
-  G_PARAM_READABLE | G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE | \
-  GST_PARAM_MUTABLE_PLAYING | GST_PARAM_MUTABLE_PAUSED | \
-  GST_PARAM_MUTABLE_READY)
+  G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_DEPRECATED | \
+  GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING | \
+  GST_PARAM_MUTABLE_PAUSED | GST_PARAM_MUTABLE_READY)
 
+/* obj will be NULL if we're printing properties of pad template pads */
 static void
-print_element_properties_info (GstElement * element)
+print_object_properties_info (GObject * obj, GObjectClass * obj_class,
+    const gchar * desc)
 {
   GParamSpec **property_specs;
   guint num_properties, i;
   gboolean readable;
   gboolean first_flag;
 
-  property_specs = g_object_class_list_properties
-      (G_OBJECT_GET_CLASS (element), &num_properties);
-  n_print ("\n");
-  n_print ("Element Properties:\n");
+  property_specs = g_object_class_list_properties (obj_class, &num_properties);
+  n_print ("%s:\n", desc);
+
+  push_indent ();
 
   for (i = 0; i < num_properties; i++) {
     GValue value = { 0, };
     GParamSpec *param = property_specs[i];
+    GType owner_type = param->owner_type;
+
+    /* We're printing pad properties */
+    if (obj == NULL && (owner_type == G_TYPE_OBJECT
+            || owner_type == GST_TYPE_OBJECT || owner_type == GST_TYPE_PAD))
+      continue;
 
     readable = FALSE;
 
     g_value_init (&value, param->value_type);
 
-    n_print ("  %-20s: %s\n", g_param_spec_get_name (param),
+    n_print ("%-20s: %s\n", g_param_spec_get_name (param),
         g_param_spec_get_blurb (param));
 
+    push_indent_n (11);
+
     first_flag = TRUE;
-    n_print ("%-23.23s flags: ", "");
-    if (param->flags & G_PARAM_READABLE) {
-      g_object_get_property (G_OBJECT (element), param->name, &value);
+    n_print ("flags: ");
+    if (param->flags & G_PARAM_READABLE && obj != NULL) {
+      g_object_get_property (obj, param->name, &value);
       readable = TRUE;
       g_print ("%s%s", (first_flag) ? "" : ", ", _("readable"));
       first_flag = FALSE;
@@ -343,6 +320,10 @@ print_element_properties_info (GstElement * element)
       g_print ("%s%s", (first_flag) ? "" : ", ", _("writable"));
       first_flag = FALSE;
     }
+    if (param->flags & G_PARAM_DEPRECATED) {
+      g_print ("%s%s", (first_flag) ? "" : ", ", _("deprecated"));
+      first_flag = FALSE;
+    }
     if (param->flags & GST_PARAM_CONTROLLABLE) {
       g_print (", %s", _("controllable"));
       first_flag = FALSE;
@@ -358,14 +339,14 @@ print_element_properties_info (GstElement * element)
       g_print ("%s0x%0x", (first_flag) ? "" : ", ",
           param->flags & ~KNOWN_PARAM_FLAGS);
     }
-    n_print ("\n");
+    g_print ("\n");
 
     switch (G_VALUE_TYPE (&value)) {
       case G_TYPE_STRING:
       {
         const char *string_val = g_value_get_string (&value);
 
-        n_print ("%-23.23s String. ", "");
+        n_print ("String. ");
 
         if (string_val == NULL)
           g_print ("Default: null");
@@ -377,21 +358,18 @@ print_element_properties_info (GstElement * element)
       {
         gboolean bool_val = g_value_get_boolean (&value);
 
-        n_print ("%-23.23s Boolean. ", "");
-
-        g_print ("Default: %s", bool_val ? "true" : "false");
+        n_print ("Boolean. Default: %s", bool_val ? "true" : "false");
         break;
       }
       case G_TYPE_ULONG:
       {
         GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
 
-        n_print ("%-23.23s Unsigned Long. ", "");
-        g_print ("Range: %lu - %lu Default: %lu ",
+        n_print ("Unsigned Long. Range: %lu - %lu Default: %lu ",
             pulong->minimum, pulong->maximum, g_value_get_ulong (&value));
 
         GST_ERROR ("%s: property '%s' of type ulong: consider changing to "
-            "uint/uint64", GST_OBJECT_NAME (element),
+            "uint/uint64", G_OBJECT_CLASS_NAME (obj_class),
             g_param_spec_get_name (param));
         break;
       }
@@ -399,12 +377,11 @@ print_element_properties_info (GstElement * element)
       {
         GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
 
-        n_print ("%-23.23s Long. ", "");
-        g_print ("Range: %ld - %ld Default: %ld ",
+        n_print ("Long. Range: %ld - %ld Default: %ld ",
             plong->minimum, plong->maximum, g_value_get_long (&value));
 
         GST_ERROR ("%s: property '%s' of type long: consider changing to "
-            "int/int64", GST_OBJECT_NAME (element),
+            "int/int64", G_OBJECT_CLASS_NAME (obj_class),
             g_param_spec_get_name (param));
         break;
       }
@@ -412,8 +389,7 @@ print_element_properties_info (GstElement * element)
       {
         GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
 
-        n_print ("%-23.23s Unsigned Integer. ", "");
-        g_print ("Range: %u - %u Default: %u ",
+        n_print ("Unsigned Integer. Range: %u - %u Default: %u ",
             puint->minimum, puint->maximum, g_value_get_uint (&value));
         break;
       }
@@ -421,8 +397,7 @@ print_element_properties_info (GstElement * element)
       {
         GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
 
-        n_print ("%-23.23s Integer. ", "");
-        g_print ("Range: %d - %d Default: %d ",
+        n_print ("Integer. Range: %d - %d Default: %d ",
             pint->minimum, pint->maximum, g_value_get_int (&value));
         break;
       }
@@ -430,9 +405,8 @@ print_element_properties_info (GstElement * element)
       {
         GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
 
-        n_print ("%-23.23s Unsigned Integer64. ", "");
-        g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
-            " Default: %" G_GUINT64_FORMAT " ",
+        n_print ("Unsigned Integer64. Range: %" G_GUINT64_FORMAT " - "
+            "%" G_GUINT64_FORMAT " Default: %" G_GUINT64_FORMAT " ",
             puint64->minimum, puint64->maximum, g_value_get_uint64 (&value));
         break;
       }
@@ -440,8 +414,7 @@ print_element_properties_info (GstElement * element)
       {
         GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
 
-        n_print ("%-23.23s Integer64. ", "");
-        g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
+        n_print ("Integer64. Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
             " Default: %" G_GINT64_FORMAT " ",
             pint64->minimum, pint64->maximum, g_value_get_int64 (&value));
         break;
@@ -450,8 +423,7 @@ print_element_properties_info (GstElement * element)
       {
         GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
 
-        n_print ("%-23.23s Float. ", "");
-        g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
+        n_print ("Float. Range: %15.7g - %15.7g Default: %15.7g ",
             pfloat->minimum, pfloat->maximum, g_value_get_float (&value));
         break;
       }
@@ -459,15 +431,14 @@ print_element_properties_info (GstElement * element)
       {
         GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
 
-        n_print ("%-23.23s Double. ", "");
-        g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
+        n_print ("Double. Range: %15.7g - %15.7g Default: %15.7g ",
             pdouble->minimum, pdouble->maximum, g_value_get_double (&value));
         break;
       }
       case G_TYPE_CHAR:
       case G_TYPE_UCHAR:
         GST_ERROR ("%s: property '%s' of type char: consider changing to "
-            "int/string", GST_OBJECT_NAME (element),
+            "int/string", G_OBJECT_CLASS_NAME (obj_class),
             g_param_spec_get_name (param));
         /* fall through */
       default:
@@ -475,7 +446,7 @@ print_element_properties_info (GstElement * element)
           const GstCaps *caps = gst_value_get_caps (&value);
 
           if (!caps)
-            n_print ("%-23.23s Caps (NULL)", "");
+            n_print ("Caps (NULL)");
           else {
             print_caps (caps, "                           ");
           }
@@ -494,15 +465,13 @@ print_element_properties_info (GstElement * element)
             j++;
           }
 
-          n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\"", "",
+          n_print ("Enum \"%s\" Default: %d, \"%s\"",
               g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick);
 
           j = 0;
           while (values[j].value_name) {
             g_print ("\n");
-            if (_name)
-              g_print ("%s", _name);
-            g_print ("%-23.23s    (%d): %-16s - %s", "",
+            n_print ("   (%d): %-16s - %s",
                 values[j].value, values[j].value_nick, values[j].value_name);
             j++;
           }
@@ -516,55 +485,65 @@ print_element_properties_info (GstElement * element)
 
           cur = flags_to_string (vals, g_value_get_flags (&value));
 
-          n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "",
+          n_print ("Flags \"%s\" Default: 0x%08x, \"%s\"",
               g_type_name (G_VALUE_TYPE (&value)),
               g_value_get_flags (&value), cur);
 
           while (vals[0].value_name) {
             g_print ("\n");
-            if (_name)
-              g_print ("%s", _name);
-            g_print ("%-23.23s    (0x%08x): %-16s - %s", "",
+            n_print ("   (0x%08x): %-16s - %s",
                 vals[0].value, vals[0].value_nick, vals[0].value_name);
             ++vals;
           }
 
           g_free (cur);
         } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
-          n_print ("%-23.23s Object of type \"%s\"", "",
-              g_type_name (param->value_type));
+          n_print ("Object of type \"%s\"", g_type_name (param->value_type));
         } else if (G_IS_PARAM_SPEC_BOXED (param)) {
-          n_print ("%-23.23s Boxed pointer of type \"%s\"", "",
+          n_print ("Boxed pointer of type \"%s\"",
               g_type_name (param->value_type));
+          if (param->value_type == GST_TYPE_STRUCTURE) {
+            const GstStructure *s = gst_value_get_structure (&value);
+            if (s)
+              gst_structure_foreach (s, print_field,
+                  (gpointer) "                           ");
+          }
         } else if (G_IS_PARAM_SPEC_POINTER (param)) {
           if (param->value_type != G_TYPE_POINTER) {
-            n_print ("%-23.23s Pointer of type \"%s\".", "",
+            n_print ("Pointer of type \"%s\".",
                 g_type_name (param->value_type));
           } else {
-            n_print ("%-23.23s Pointer.", "");
+            n_print ("Pointer.");
           }
         } else if (param->value_type == G_TYPE_VALUE_ARRAY) {
           GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param);
 
           if (pvarray->element_spec) {
-            n_print ("%-23.23s Array of GValues of type \"%s\"", "",
+            n_print ("Array of GValues of type \"%s\"",
                 g_type_name (pvarray->element_spec->value_type));
           } else {
-            n_print ("%-23.23s Array of GValues", "");
+            n_print ("Array of GValues");
           }
         } else if (GST_IS_PARAM_SPEC_FRACTION (param)) {
           GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param);
 
-          n_print ("%-23.23s Fraction. ", "");
-
-          g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
+          n_print ("Fraction. Range: %d/%d - %d/%d Default: %d/%d ",
               pfraction->min_num, pfraction->min_den,
               pfraction->max_num, pfraction->max_den,
               gst_value_get_fraction_numerator (&value),
               gst_value_get_fraction_denominator (&value));
+        } else if (param->value_type == GST_TYPE_ARRAY) {
+          GstParamSpecArray *parray = GST_PARAM_SPEC_ARRAY_LIST (param);
+
+          if (parray->element_spec) {
+            n_print ("GstValueArray of GValues of type \"%s\"",
+                g_type_name (parray->element_spec->value_type));
+          } else {
+            n_print ("GstValueArray of GValues");
+          }
         } else {
-          n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
-              g_type_name (param->value_type));
+          n_print ("Unknown type %ld \"%s\"",
+              (glong) param->value_type, g_type_name (param->value_type));
         }
         break;
     }
@@ -573,92 +552,100 @@ print_element_properties_info (GstElement * element)
     else
       g_print ("\n");
 
+    pop_indent_n (11);
+
     g_value_reset (&value);
   }
   if (num_properties == 0)
-    n_print ("  none\n");
+    n_print ("none\n");
+
+  pop_indent ();
 
   g_free (property_specs);
 }
 
 static void
+print_element_properties_info (GstElement * element)
+{
+  g_print ("\n");
+  print_object_properties_info (G_OBJECT (element),
+      G_OBJECT_GET_CLASS (element), "Element Properties");
+}
+
+static void
 print_pad_templates_info (GstElement * element, GstElementFactory * factory)
 {
-  GstElementClass *gstelement_class;
   const GList *pads;
   GstStaticPadTemplate *padtemplate;
+  GstPadTemplate *tmpl;
 
   n_print ("Pad Templates:\n");
+
+  push_indent ();
+
   if (gst_element_factory_get_num_pad_templates (factory) == 0) {
-    n_print ("  none\n");
-    return;
+    n_print ("none\n");
+    goto done;
   }
 
-  gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
-
   pads = gst_element_factory_get_static_pad_templates (factory);
   while (pads) {
     padtemplate = (GstStaticPadTemplate *) (pads->data);
     pads = g_list_next (pads);
 
     if (padtemplate->direction == GST_PAD_SRC)
-      n_print ("  SRC template: '%s'\n", padtemplate->name_template);
+      n_print ("SRC template: '%s'\n", padtemplate->name_template);
     else if (padtemplate->direction == GST_PAD_SINK)
-      n_print ("  SINK template: '%s'\n", padtemplate->name_template);
+      n_print ("SINK template: '%s'\n", padtemplate->name_template);
     else
-      n_print ("  UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
+      n_print ("UNKNOWN template: '%s'\n", padtemplate->name_template);
+
+    push_indent ();
 
     if (padtemplate->presence == GST_PAD_ALWAYS)
-      n_print ("    Availability: Always\n");
+      n_print ("Availability: Always\n");
     else if (padtemplate->presence == GST_PAD_SOMETIMES)
-      n_print ("    Availability: Sometimes\n");
+      n_print ("Availability: Sometimes\n");
     else if (padtemplate->presence == GST_PAD_REQUEST) {
-      n_print ("    Availability: On request\n");
-      n_print ("      Has request_new_pad() function: %s\n",
-          GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
+      n_print ("Availability: On request\n");
     } else
-      n_print ("    Availability: UNKNOWN!!!\n");
+      n_print ("Availability: UNKNOWN\n");
 
     if (padtemplate->static_caps.string) {
-      n_print ("    Capabilities:\n");
-      print_caps (gst_static_caps_get (&padtemplate->static_caps), "      ");
-    }
+      GstCaps *caps = gst_static_caps_get (&padtemplate->static_caps);
 
-    n_print ("\n");
-  }
-}
+      n_print ("Capabilities:\n");
 
-static void
-print_element_flag_info (GstElement * element)
-{
-  gboolean have_flags = FALSE;
+      push_indent ();
+      print_caps (caps, "");    // FIXME
+      pop_indent ();
 
-  n_print ("\n");
-  n_print ("Element Flags:\n");
+      gst_caps_unref (caps);
+    }
 
-  if (!have_flags)
-    n_print ("  no flags set\n");
+    tmpl = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (element),
+        padtemplate->name_template);
+    if (tmpl != NULL) {
+      GType pad_type = GST_PAD_TEMPLATE_GTYPE (tmpl);
 
-  if (GST_IS_BIN (element)) {
-    n_print ("\n");
-    n_print ("Bin Flags:\n");
-    if (!have_flags)
-      n_print ("  no flags set\n");
-  }
-}
+      if (pad_type != G_TYPE_NONE && pad_type != GST_TYPE_PAD) {
+        gpointer pad_klass;
 
-static void
-print_implementation_info (GstElement * element)
-{
-  GstElementClass *gstelement_class;
+        pad_klass = g_type_class_ref (pad_type);
+        n_print ("Type: %s\n", g_type_name (pad_type));
+        print_object_properties_info (NULL, pad_klass, "Pad Properties");
+        g_type_class_unref (pad_klass);
+      }
+    }
 
-  gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
+    pop_indent ();
 
-  n_print ("\n");
-  n_print ("Element Implementation:\n");
+    if (pads != NULL)
+      n_print ("\n");
+  }
 
-  n_print ("  Has change_state() function: %s\n",
-      GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
+done:
+  pop_indent ();
 }
 
 static void
@@ -673,14 +660,17 @@ print_clocking_info (GstElement * element)
 
   if (!requires_clock && !provides_clock) {
     n_print ("\n");
-    n_print ("Element has no clocking capabilities.");
+    n_print ("Element has no clocking capabilities.\n");
     return;
   }
 
   n_print ("\n");
   n_print ("Clocking Interaction:\n");
+
+  push_indent ();
+
   if (requires_clock) {
-    n_print ("  element requires a clock\n");
+    n_print ("element requires a clock\n");
   }
 
   if (provides_clock) {
@@ -688,24 +678,13 @@ print_clocking_info (GstElement * element)
 
     clock = gst_element_get_clock (element);
     if (clock) {
-      n_print ("  element provides a clock: %s\n", GST_OBJECT_NAME (clock));
+      n_print ("element provides a clock: %s\n", GST_OBJECT_NAME (clock));
       gst_object_unref (clock);
     } else
-      n_print ("  element is supposed to provide a clock but returned NULL\n");
+      n_print ("element is supposed to provide a clock but returned NULL\n");
   }
-}
 
-static void
-print_index_info (GstElement * element)
-{
-  if (GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_INDEXABLE)) {
-    n_print ("\n");
-    n_print ("Indexing capabilities:\n");
-    n_print ("  element can do indexing\n");
-  } else {
-    n_print ("\n");
-    n_print ("Element has no indexing capabilities.\n");
-  }
+  pop_indent ();
 }
 
 static void
@@ -727,15 +706,22 @@ print_uri_handler_info (GstElement * element)
 
     n_print ("\n");
     n_print ("URI handling capabilities:\n");
-    n_print ("  Element can act as %s.\n", uri_type);
+
+    push_indent ();
+
+    n_print ("Element can act as %s.\n", uri_type);
 
     if (uri_protocols && *uri_protocols) {
-      n_print ("  Supported URI protocols:\n");
+      n_print ("Supported URI protocols:\n");
+      push_indent ();
       for (; *uri_protocols != NULL; uri_protocols++)
-        n_print ("    %s\n", *uri_protocols);
+        n_print ("%s\n", *uri_protocols);
+      pop_indent ();
     } else {
-      n_print ("  No supported URI protocols\n");
+      n_print ("No supported URI protocols\n");
     }
+
+    pop_indent ();
   } else {
     n_print ("Element has no URI handling capabilities.\n");
   }
@@ -750,9 +736,11 @@ print_pad_info (GstElement * element)
   n_print ("\n");
   n_print ("Pads:\n");
 
+  push_indent ();
+
   if (!element->numpads) {
-    n_print ("  none\n");
-    return;
+    n_print ("none\n");
+    goto done;
   }
 
   pads = element->pads;
@@ -763,48 +751,34 @@ print_pad_info (GstElement * element)
     pad = GST_PAD (pads->data);
     pads = g_list_next (pads);
 
-    n_print ("");
-
     name = gst_pad_get_name (pad);
     if (gst_pad_get_direction (pad) == GST_PAD_SRC)
-      g_print ("  SRC: '%s'", name);
+      n_print ("SRC: '%s'\n", name);
     else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
-      g_print ("  SINK: '%s'", name);
+      n_print ("SINK: '%s'\n", name);
     else
-      g_print ("  UNKNOWN!!!: '%s'", name);
+      n_print ("UNKNOWN: '%s'\n", name);
 
     g_free (name);
 
-    g_print ("\n");
-
-    n_print ("    Implementation:\n");
-    if (pad->chainfunc)
-      n_print ("      Has chainfunc(): %s\n",
-          GST_DEBUG_FUNCPTR_NAME (pad->chainfunc));
-    if (pad->getrangefunc)
-      n_print ("      Has getrangefunc(): %s\n",
-          GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc));
-    if (pad->eventfunc != gst_pad_event_default)
-      n_print ("      Has custom eventfunc(): %s\n",
-          GST_DEBUG_FUNCPTR_NAME (pad->eventfunc));
-    if (pad->queryfunc != gst_pad_query_default)
-      n_print ("      Has custom queryfunc(): %s\n",
-          GST_DEBUG_FUNCPTR_NAME (pad->queryfunc));
-
-    if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default)
-      n_print ("      Has custom iterintlinkfunc(): %s\n",
-          GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc));
-
-    if (pad->padtemplate)
-      n_print ("    Pad Template: '%s'\n", pad->padtemplate->name_template);
+    if (pad->padtemplate) {
+      push_indent ();
+      n_print ("Pad Template: '%s'\n", pad->padtemplate->name_template);
+      pop_indent ();
+    }
 
     caps = gst_pad_get_current_caps (pad);
     if (caps) {
-      n_print ("    Capabilities:\n");
-      print_caps (caps, "      ");
+      n_print ("Capabilities:\n");
+      push_indent ();
+      print_caps (caps, "");    // FIXME
+      pop_indent ();
       gst_caps_unref (caps);
     }
   }
+
+done:
+  pop_indent ();
 }
 
 static gboolean
@@ -821,6 +795,19 @@ has_sometimes_template (GstElement * element)
   return FALSE;
 }
 
+static gboolean
+gtype_needs_ptr_marker (GType type)
+{
+  if (type == G_TYPE_POINTER)
+    return FALSE;
+
+  if (G_TYPE_FUNDAMENTAL (type) == G_TYPE_POINTER || G_TYPE_IS_BOXED (type)
+      || G_TYPE_IS_OBJECT (type))
+    return TRUE;
+
+  return FALSE;
+}
+
 static void
 print_signal_info (GstElement * element)
 {
@@ -884,31 +871,35 @@ print_signal_info (GstElement * element)
 
     for (l = found_signals; l; l = l->next) {
       gchar *indent;
+      const gchar *pmark;
       int indent_len;
 
       query = (GSignalQuery *) l->data;
       indent_len = strlen (query->signal_name) +
           strlen (g_type_name (query->return_type)) + 24;
 
+      if (gtype_needs_ptr_marker (query->return_type)) {
+        pmark = "* ";
+        indent_len += 2;
+      } else {
+        pmark = "";
+      }
+
       indent = g_new0 (gchar, indent_len + 1);
       memset (indent, ' ', indent_len);
 
-      n_print ("  \"%s\" :  %s user_function (%s* object",
-          query->signal_name,
-          g_type_name (query->return_type), g_type_name (type));
+      n_print ("  \"%s\" :  %s %suser_function (%s* object",
+          query->signal_name, g_type_name (query->return_type), pmark,
+          g_type_name (type));
 
       for (j = 0; j < query->n_params; j++) {
+        const gchar *type_name, *asterisk;
+
+        type_name = g_type_name (query->param_types[j]);
+        asterisk = gtype_needs_ptr_marker (query->param_types[j]) ? "*" : "";
+
         g_print (",\n");
-        if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
-          n_print ("%s%s arg%d", indent,
-              g_type_name (query->param_types[j]), j);
-        } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
-          n_print ("%s%s arg%d", indent,
-              g_type_name (query->param_types[j]), j);
-        } else {
-          n_print ("%s%s* arg%d", indent,
-              g_type_name (query->param_types[j]), j);
-        }
+        n_print ("%s%s%s arg%d", indent, type_name, asterisk, j);
       }
 
       if (k == 0) {
@@ -948,6 +939,25 @@ print_children_info (GstElement * element)
 }
 
 static void
+print_preset_list (GstElement * element)
+{
+  gchar **presets, **preset;
+
+  if (!GST_IS_PRESET (element))
+    return;
+
+  presets = gst_preset_get_preset_names (GST_PRESET (element));
+  if (presets && *presets) {
+    n_print ("\n");
+    n_print ("Presets:\n");
+    for (preset = presets; *preset; preset++) {
+      n_print ("  \"%s\"\n", *preset);
+    }
+    g_strfreev (presets);
+  }
+}
+
+static void
 print_blacklist (void)
 {
   GList *plugins, *cur;
@@ -973,10 +983,31 @@ print_blacklist (void)
 }
 
 static void
-print_element_list (gboolean print_all)
+print_typefind_extensions (const gchar * const *extensions)
+{
+  guint i = 0;
+
+  while (extensions[i]) {
+    g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
+    i++;
+  }
+}
+
+static void
+print_element_list (gboolean print_all, gchar * ftypes)
 {
   int plugincount = 0, featurecount = 0, blacklistcount = 0;
   GList *plugins, *orig_plugins;
+  gchar **types = NULL;
+
+  if (ftypes) {
+    gint i;
+
+    types = g_strsplit (ftypes, "/", -1);
+    for (i = 0; types[i]; i++)
+      *types[i] = g_ascii_toupper (*types[i]);
+
+  }
 
   orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ());
   while (plugins) {
@@ -1004,28 +1035,40 @@ print_element_list (gboolean print_all)
       featurecount++;
 
       if (GST_IS_ELEMENT_FACTORY (feature)) {
+        const gchar *klass;
         GstElementFactory *factory;
 
         factory = GST_ELEMENT_FACTORY (feature);
+        if (types) {
+          gint i;
+          gboolean all_found = TRUE;
+
+          klass =
+              gst_element_factory_get_metadata (factory,
+              GST_ELEMENT_METADATA_KLASS);
+          for (i = 0; types[i]; i++) {
+            if (!strstr (klass, types[i])) {
+              all_found = FALSE;
+              break;
+            }
+          }
+
+          if (!all_found)
+            goto next;
+        }
         if (print_all)
-          print_element_info (factory, TRUE);
+          print_element_info (feature, TRUE);
         else
           g_print ("%s:  %s: %s\n", gst_plugin_get_name (plugin),
               GST_OBJECT_NAME (factory),
-              gst_element_factory_get_longname (factory));
-#if 0
-      } else if (GST_IS_INDEX_FACTORY (feature)) {
-        GstIndexFactory *factory;
-
-        factory = GST_INDEX_FACTORY (feature);
-        if (!print_all)
-          g_print ("%s:  %s: %s\n", plugin->desc.name,
-              GST_OBJECT_NAME (factory), factory->longdesc);
-#endif
+              gst_element_factory_get_metadata (factory,
+                  GST_ELEMENT_METADATA_LONGNAME));
       } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
         GstTypeFindFactory *factory;
         const gchar *const *extensions;
 
+        if (types)
+          goto next;
         factory = GST_TYPE_FIND_FACTORY (feature);
         if (!print_all)
           g_print ("%s: %s: ", gst_plugin_get_name (plugin),
@@ -1033,20 +1076,17 @@ print_element_list (gboolean print_all)
 
         extensions = gst_type_find_factory_get_extensions (factory);
         if (extensions != NULL) {
-          guint i = 0;
-
-          while (extensions[i]) {
-            if (!print_all)
-              g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
-            i++;
-          }
-          if (!print_all)
+          if (!print_all) {
+            print_typefind_extensions (extensions);
             g_print ("\n");
+          }
         } else {
           if (!print_all)
             g_print ("no extensions\n");
         }
       } else {
+        if (types)
+          goto next;
         if (!print_all)
           n_print ("%s:  %s (%s)\n", gst_plugin_get_name (plugin),
               GST_OBJECT_NAME (feature), g_type_name (G_OBJECT_TYPE (feature)));
@@ -1060,6 +1100,7 @@ print_element_list (gboolean print_all)
   }
 
   gst_plugin_list_free (orig_plugins);
+  g_strfreev (types);
 
   g_print ("\n");
   g_print (_("Total count: "));
@@ -1158,12 +1199,15 @@ print_plugin_info (GstPlugin * plugin)
   const gchar *filename = gst_plugin_get_filename (plugin);
 
   n_print ("Plugin Details:\n");
-  n_print ("  Name:\t\t\t%s\n", gst_plugin_get_name (plugin));
-  n_print ("  Description:\t\t%s\n", gst_plugin_get_description (plugin));
-  n_print ("  Filename:\t\t%s\n", (filename != NULL) ? filename : "(null)");
-  n_print ("  Version:\t\t%s\n", gst_plugin_get_version (plugin));
-  n_print ("  License:\t\t%s\n", gst_plugin_get_license (plugin));
-  n_print ("  Source module:\t%s\n", gst_plugin_get_source (plugin));
+
+  push_indent ();
+
+  n_print ("%-25s%s\n", "Name", gst_plugin_get_name (plugin));
+  n_print ("%-25s%s\n", "Description", gst_plugin_get_description (plugin));
+  n_print ("%-25s%s\n", "Filename", (filename != NULL) ? filename : "(null)");
+  n_print ("%-25s%s\n", "Version", gst_plugin_get_version (plugin));
+  n_print ("%-25s%s\n", "License", gst_plugin_get_license (plugin));
+  n_print ("%-25s%s\n", "Source module", gst_plugin_get_source (plugin));
 
   if (release_date != NULL) {
     const gchar *tz = "(UTC)";
@@ -1181,11 +1225,14 @@ print_plugin_info (GstPlugin * plugin)
     } else {
       tz = "";
     }
-    n_print ("  Source release date:\t%s%s\n", str, tz);
+    n_print ("%-25s%s%s\n", "Source release date", str, tz);
     g_free (str);
   }
-  n_print ("  Binary package:\t%s\n", gst_plugin_get_package (plugin));
-  n_print ("  Origin URL:\t\t%s\n", gst_plugin_get_origin (plugin));
+  n_print ("%-25s%s\n", "Binary package", gst_plugin_get_package (plugin));
+  n_print ("%-25s%s\n", "Origin URL", gst_plugin_get_origin (plugin));
+
+  pop_indent ();
+
   n_print ("\n");
 }
 
@@ -1195,8 +1242,9 @@ print_plugin_features (GstPlugin * plugin)
   GList *features, *origlist;
   gint num_features = 0;
   gint num_elements = 0;
+  gint num_tracers = 0;
   gint num_typefinders = 0;
-  gint num_indexes = 0;
+  gint num_devproviders = 0;
   gint num_other = 0;
 
   origlist = features =
@@ -1213,16 +1261,9 @@ print_plugin_features (GstPlugin * plugin)
 
       factory = GST_ELEMENT_FACTORY (feature);
       n_print ("  %s: %s\n", GST_OBJECT_NAME (factory),
-          gst_element_factory_get_longname (factory));
+          gst_element_factory_get_metadata (factory,
+              GST_ELEMENT_METADATA_LONGNAME));
       num_elements++;
-#if 0
-    } else if (GST_IS_INDEX_FACTORY (feature)) {
-      GstIndexFactory *factory;
-
-      factory = GST_INDEX_FACTORY (feature);
-      n_print ("  %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
-      num_indexes++;
-#endif
     } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
       GstTypeFindFactory *factory;
       const gchar *const *extensions;
@@ -1232,7 +1273,7 @@ print_plugin_features (GstPlugin * plugin)
       if (extensions) {
         guint i = 0;
 
-        g_print ("%s: %s: ", gst_plugin_get_name (plugin),
+        g_print ("  %s: %s: ", gst_plugin_get_name (plugin),
             gst_plugin_feature_get_name (feature));
         while (extensions[i]) {
           g_print ("%s%s", i > 0 ? ", " : "", extensions[i]);
@@ -1240,10 +1281,22 @@ print_plugin_features (GstPlugin * plugin)
         }
         g_print ("\n");
       } else
-        g_print ("%s: %s: no extensions\n", gst_plugin_get_name (plugin),
+        g_print ("  %s: %s: no extensions\n", gst_plugin_get_name (plugin),
             gst_plugin_feature_get_name (feature));
 
       num_typefinders++;
+    } else if (GST_IS_DEVICE_PROVIDER_FACTORY (feature)) {
+      GstDeviceProviderFactory *factory;
+
+      factory = GST_DEVICE_PROVIDER_FACTORY (feature);
+      n_print ("  %s: %s\n", GST_OBJECT_NAME (factory),
+          gst_device_provider_factory_get_metadata (factory,
+              GST_ELEMENT_METADATA_LONGNAME));
+      num_devproviders++;
+    } else if (GST_IS_TRACER_FACTORY (feature)) {
+      n_print ("  %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
+          g_type_name (G_OBJECT_TYPE (feature)));
+      num_tracers++;
     } else if (feature) {
       n_print ("  %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
           g_type_name (G_OBJECT_TYPE (feature)));
@@ -1261,8 +1314,10 @@ print_plugin_features (GstPlugin * plugin)
     n_print ("  +-- %d elements\n", num_elements);
   if (num_typefinders > 0)
     n_print ("  +-- %d typefinders\n", num_typefinders);
-  if (num_indexes > 0)
-    n_print ("  +-- %d indexes\n", num_indexes);
+  if (num_devproviders > 0)
+    n_print ("  +-- %d device providers\n", num_devproviders);
+  if (num_tracers > 0)
+    n_print ("  +-- %d tracers\n", num_tracers);
   if (num_other > 0)
     n_print ("  +-- %d other objects\n", num_other);
 
@@ -1270,40 +1325,46 @@ print_plugin_features (GstPlugin * plugin)
 }
 
 static int
-print_element_features (const gchar * element_name)
+print_feature_info (const gchar * feature_name, gboolean print_all)
 {
   GstPluginFeature *feature;
+  GstRegistry *registry = gst_registry_get ();
+  int ret;
 
-  /* FIXME implement other pretty print function for these */
-#if 0
-  feature = gst_default_registry_find_feature (element_name,
-      GST_TYPE_INDEX_FACTORY);
-  if (feature) {
-    n_print ("%s: an index\n", element_name);
-    return 0;
+  if ((feature = gst_registry_find_feature (registry, feature_name,
+              GST_TYPE_ELEMENT_FACTORY))) {
+    ret = print_element_info (feature, print_all);
+    goto handled;
   }
-#endif
-  feature = gst_registry_find_feature (gst_registry_get (), element_name,
-      GST_TYPE_TYPE_FIND_FACTORY);
-  if (feature) {
-    n_print ("%s: a typefind function\n", element_name);
-    return 0;
+  if ((feature = gst_registry_find_feature (registry, feature_name,
+              GST_TYPE_TYPE_FIND_FACTORY))) {
+    ret = print_typefind_info (feature, print_all);
+    goto handled;
   }
+  if ((feature = gst_registry_find_feature (registry, feature_name,
+              GST_TYPE_TRACER_FACTORY))) {
+    ret = print_tracer_info (feature, print_all);
+    goto handled;
+  }
+
+  /* TODO: handle DEVICE_PROVIDER_FACTORY */
 
   return -1;
+
+handled:
+  gst_object_unref (feature);
+  return ret;
 }
 
 static int
-print_element_info (GstElementFactory * factory, gboolean print_names)
+print_element_info (GstPluginFeature * feature, gboolean print_names)
 {
+  GstElementFactory *factory;
   GstElement *element;
   GstPlugin *plugin;
   gint maxlevel = 0;
 
-  factory =
-      GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
-          (factory)));
-
+  factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
   if (!factory) {
     g_print ("element plugin couldn't be loaded\n");
     return -1;
@@ -1333,23 +1394,130 @@ print_element_info (GstElementFactory * factory, gboolean print_names)
   print_interfaces (G_OBJECT_TYPE (element));
 
   print_pad_templates_info (element, factory);
-  print_element_flag_info (element);
-  print_implementation_info (element);
   print_clocking_info (element);
-  print_index_info (element);
   print_uri_handler_info (element);
   print_pad_info (element);
   print_element_properties_info (element);
   print_signal_info (element);
   print_children_info (element);
+  print_preset_list (element);
 
   gst_object_unref (element);
   gst_object_unref (factory);
   g_free (_name);
+  return 0;
+}
 
+static int
+print_typefind_info (GstPluginFeature * feature, gboolean print_names)
+{
+  GstTypeFindFactory *factory;
+  GstPlugin *plugin;
+  GstCaps *caps;
+  GstRank rank;
+  char s[20];
+  const gchar *const *extensions;
+
+  factory = GST_TYPE_FIND_FACTORY (gst_plugin_feature_load (feature));
+  if (!factory) {
+    g_print ("typefind plugin couldn't be loaded\n");
+    return -1;
+  }
+
+  if (print_names)
+    _name = g_strdup_printf ("%s: ", GST_OBJECT_NAME (factory));
+  else
+    _name = NULL;
+
+  n_print ("Factory Details:\n");
+  rank = gst_plugin_feature_get_rank (feature);
+  n_print ("  %-25s%s (%d)\n", "Rank", get_rank_name (s, rank), rank);
+  n_print ("  %-25s%s\n", "Name", GST_OBJECT_NAME (factory));
+  caps = gst_type_find_factory_get_caps (factory);
+  if (caps) {
+    gchar *caps_str = gst_caps_to_string (factory->caps);
+
+    n_print ("  %-25s%s\n", "Caps", caps_str);
+    g_free (caps_str);
+  }
+  extensions = gst_type_find_factory_get_extensions (factory);
+  if (extensions) {
+    n_print ("  %-25s", "Extensions");
+    print_typefind_extensions (extensions);
+    n_print ("\n");
+  }
+  n_print ("\n");
+
+  plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
+  if (plugin) {
+    print_plugin_info (plugin);
+    gst_object_unref (plugin);
+  }
+
+  gst_object_unref (factory);
+  g_free (_name);
   return 0;
 }
 
+static int
+print_tracer_info (GstPluginFeature * feature, gboolean print_names)
+{
+  GstTracerFactory *factory;
+  GstTracer *tracer;
+  GstPlugin *plugin;
+  gint maxlevel = 0;
+
+  factory = GST_TRACER_FACTORY (gst_plugin_feature_load (feature));
+  if (!factory) {
+    g_print ("tracer plugin couldn't be loaded\n");
+    return -1;
+  }
+
+  tracer = (GstTracer *) g_object_new (factory->type, NULL);
+  if (!tracer) {
+    gst_object_unref (factory);
+    g_print ("couldn't construct tracer for some reason\n");
+    return -1;
+  }
+
+  if (print_names)
+    _name = g_strdup_printf ("%s: ", GST_OBJECT_NAME (factory));
+  else
+    _name = NULL;
+
+  n_print ("Factory Details:\n");
+  n_print ("  %-25s%s\n", "Name", GST_OBJECT_NAME (factory));
+  n_print ("\n");
+
+  plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
+  if (plugin) {
+    print_plugin_info (plugin);
+    gst_object_unref (plugin);
+  }
+
+  print_hierarchy (G_OBJECT_TYPE (tracer), 0, &maxlevel);
+  print_interfaces (G_OBJECT_TYPE (tracer));
+
+  /* TODO: list what hooks it registers
+   * - the data is available in gsttracerutils, we need to iterate the
+   *   _priv_tracers hashtable for each probe and then check the list of hooks
+   *  for each probe whether hook->tracer == tracer :/
+   */
+
+  /* TODO: list what records it emits
+   * - in class_init tracers can create GstTracerRecord instances
+   * - those only get logged right now and there is no association with the
+   *   tracer that created them
+   * - we'd need to add them to GstTracerFactory
+   *   gst_tracer_class_add_record (klass, record);
+   *   - needs work in gstregistrychunks.
+   */
+
+  gst_object_unref (tracer);
+  gst_object_unref (factory);
+  g_free (_name);
+  return 0;
+}
 
 static void
 print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
@@ -1361,7 +1529,8 @@ print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
   GstCaps *caps = NULL;
   guint i, num;
 
-  klass = gst_element_factory_get_klass (factory);
+  klass =
+      gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS);
   g_return_if_fail (klass != NULL);
 
   if (strstr (klass, "Demuxer") ||
@@ -1505,6 +1674,12 @@ main (int argc, char *argv[])
   gboolean plugin_name = FALSE;
   gboolean print_aii = FALSE;
   gboolean uri_handlers = FALSE;
+  gboolean check_exists = FALSE;
+  gchar *min_version = NULL;
+  guint minver_maj = GST_VERSION_MAJOR;
+  guint minver_min = GST_VERSION_MINOR;
+  guint minver_micro = 0;
+  gchar *types = NULL;
 #ifndef GST_DISABLE_OPTION_PARSING
   GOptionEntry options[] = {
     {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
@@ -1518,6 +1693,15 @@ main (int argc, char *argv[])
               "installation mechanisms"), NULL},
     {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
         N_("List the plugin contents"), NULL},
+    {"types", 't', 0, G_OPTION_ARG_STRING, &types,
+        N_("A slashes ('/') separated list of types of elements (also known "
+              "as klass) to list. (unordered)"), NULL},
+    {"exists", '\0', 0, G_OPTION_ARG_NONE, &check_exists,
+        N_("Check if the specified element or plugin exists"), NULL},
+    {"atleast-version", '\0', 0, G_OPTION_ARG_STRING, &min_version,
+        N_
+          ("When checking if an element or plugin exists, also check that its "
+              "version is at least the version specified"), NULL},
     {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
           N_
           ("Print supported URI schemes, with the elements that implement them"),
@@ -1529,37 +1713,84 @@ main (int argc, char *argv[])
   GError *err = NULL;
 #endif
 
+  setlocale (LC_ALL, "");
+
 #ifdef ENABLE_NLS
   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
 #endif
 
-  gst_tools_set_prgname ("gst-inspect");
+  /* avoid glib warnings when inspecting deprecated properties */
+  g_setenv ("G_ENABLE_DIAGNOSTIC", "0", FALSE);
+
+  g_set_prgname ("gst-inspect-" GST_API_VERSION);
 
 #ifndef GST_DISABLE_OPTION_PARSING
   ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
   g_option_context_add_group (ctx, gst_init_get_option_group ());
   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
-    g_print ("Error initializing: %s\n", err->message);
-    exit (1);
+    g_printerr ("Error initializing: %s\n", err->message);
+    g_clear_error (&err);
+    g_option_context_free (ctx);
+    return -1;
   }
   g_option_context_free (ctx);
 #else
   gst_init (&argc, &argv);
 #endif
 
-  gst_tools_print_version ("gst-inspect");
+  gst_tools_print_version ();
 
   if (print_all && argc > 1) {
-    g_print ("-a requires no extra arguments\n");
-    return 1;
+    g_printerr ("-a requires no extra arguments\n");
+    return -1;
   }
 
   if (uri_handlers && argc > 1) {
-    g_print ("-u requires no extra arguments\n");
-    exit (1);
+    g_printerr ("-u requires no extra arguments\n");
+    return -1;
+  }
+
+  /* --atleast-version implies --exists */
+  if (min_version != NULL) {
+    if (sscanf (min_version, "%u.%u.%u", &minver_maj, &minver_min,
+            &minver_micro) < 2) {
+      g_printerr ("Can't parse version '%s' passed to --atleast-version\n",
+          min_version);
+      return -1;
+    }
+    check_exists = TRUE;
+  }
+
+  if (check_exists) {
+    int exit_code;
+
+    if (argc == 1) {
+      g_printerr ("--exists requires an extra command line argument\n");
+      exit_code = -1;
+    } else {
+      if (!plugin_name) {
+        GstPluginFeature *feature;
+
+        feature = gst_registry_lookup_feature (gst_registry_get (), argv[1]);
+        if (feature != NULL && gst_plugin_feature_check_version (feature,
+                minver_maj, minver_min, minver_micro)) {
+          exit_code = 0;
+        } else {
+          exit_code = 1;
+        }
+
+        if (feature)
+          gst_object_unref (feature);
+      } else {
+        /* FIXME: support checking for plugins too */
+        g_printerr ("Checking for plugins is not supported yet\n");
+        exit_code = -1;
+      }
+    }
+    return exit_code;
   }
 
   /* if no arguments, print out list of elements */
@@ -1572,32 +1803,20 @@ main (int argc, char *argv[])
       if (print_aii)
         print_all_plugin_automatic_install_info ();
       else
-        print_element_list (print_all);
+        print_element_list (print_all, types);
     }
   } else {
     /* else we try to get a factory */
-    GstElementFactory *factory;
-    GstPlugin *plugin;
     const char *arg = argv[argc - 1];
-    int retval;
+    int retval = -1;
 
     if (!plugin_name) {
-      factory = gst_element_factory_find (arg);
-
-      /* if there's a factory, print out the info */
-      if (factory) {
-        retval = print_element_info (factory, print_all);
-        gst_object_unref (factory);
-      } else {
-        retval = print_element_features (arg);
-      }
-    } else {
-      retval = -1;
+      retval = print_feature_info (arg, print_all);
     }
 
     /* otherwise check if it's a plugin */
     if (retval) {
-      plugin = gst_registry_find_plugin (gst_registry_get (), arg);
+      GstPlugin *plugin = gst_registry_find_plugin (gst_registry_get (), arg);
 
       /* if there is such a plugin, print out info */
       if (plugin) {
@@ -1621,12 +1840,12 @@ main (int argc, char *argv[])
               print_plugin_features (plugin);
             }
           } else {
-            g_print (_("Could not load plugin file: %s\n"), error->message);
-            g_error_free (error);
+            g_printerr (_("Could not load plugin file: %s\n"), error->message);
+            g_clear_error (&error);
             return -1;
           }
         } else {
-          g_print (_("No such element or plugin '%s'\n"), arg);
+          g_printerr (_("No such element or plugin '%s'\n"), arg);
           return -1;
         }
       }