gst-inspect: Print GstValueArray properties nicely
[platform/upstream/gstreamer.git] / tools / gst-inspect.c
index 4d020ad..6640b62 100644 (file)
@@ -519,6 +519,15 @@ print_element_properties_info (GstElement * element)
               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 ("%-23.23s GstValueArray of GValues of type \"%s\"", "",
+                g_type_name (parray->element_spec->value_type));
+          } else {
+            n_print ("%-23.23s GstValueArray of GValues", "");
+          }
         } else {
           n_print ("%-23.23s Unknown type %ld \"%s\"", "",
               (glong) param->value_type, g_type_name (param->value_type));
@@ -572,8 +581,11 @@ print_pad_templates_info (GstElement * element, GstElementFactory * factory)
       n_print ("    Availability: UNKNOWN!!!\n");
 
     if (padtemplate->static_caps.string) {
+      GstCaps *caps = gst_static_caps_get (&padtemplate->static_caps);
+
       n_print ("    Capabilities:\n");
-      print_caps (gst_static_caps_get (&padtemplate->static_caps), "      ");
+      print_caps (caps, "      ");
+      gst_caps_unref (caps);
     }
 
     n_print ("\n");
@@ -738,6 +750,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)
 {
@@ -808,12 +833,7 @@ print_signal_info (GstElement * element)
       indent_len = strlen (query->signal_name) +
           strlen (g_type_name (query->return_type)) + 24;
 
-
-      if (query->return_type == G_TYPE_POINTER) {
-        pmark = "";
-      } else if (G_TYPE_FUNDAMENTAL (query->return_type) == G_TYPE_POINTER
-          || G_TYPE_IS_BOXED (query->return_type)
-          || G_TYPE_IS_OBJECT (query->return_type)) {
+      if (gtype_needs_ptr_marker (query->return_type)) {
         pmark = "* ";
         indent_len += 2;
       } else {
@@ -828,17 +848,13 @@ print_signal_info (GstElement * element)
           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) {
@@ -922,10 +938,21 @@ print_blacklist (void)
 }
 
 static void
-print_element_list (gboolean print_all)
+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) {
@@ -953,9 +980,27 @@ 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);
         else
@@ -967,6 +1012,8 @@ print_element_list (gboolean print_all)
         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),
@@ -988,6 +1035,8 @@ print_element_list (gboolean 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)));
@@ -1001,6 +1050,7 @@ print_element_list (gboolean print_all)
   }
 
   gst_plugin_list_free (orig_plugins);
+  g_strfreev (types);
 
   g_print ("\n");
   g_print (_("Total count: "));
@@ -1458,6 +1508,7 @@ main (int argc, char *argv[])
   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,
@@ -1471,6 +1522,9 @@ 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,
@@ -1578,7 +1632,7 @@ 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 */