From d9e80e999a102e6c5945e9937eb15f32bd995f86 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 17 Sep 2002 21:32:26 +0000 Subject: [PATCH 1/1] - Refactor the caps print function in -inspect Original commit message from CVS: - Refactor the caps print function in -inspect - fix a leak in -launch --- tools/gst-inspect.c | 81 +++++++++++++++++++++++++++-------------------------- tools/gst-launch.c | 1 + 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c index 8d0fc00..3ac3788 100644 --- a/tools/gst-inspect.c +++ b/tools/gst-inspect.c @@ -3,7 +3,7 @@ #include static void -print_prop (GstPropsEntry *prop, gboolean showname, gchar *pfx) +print_prop (GstPropsEntry *prop, gboolean showname, const gchar *pfx) { GstPropsType type; @@ -93,7 +93,7 @@ print_prop (GstPropsEntry *prop, gboolean showname, gchar *pfx) } static void -print_props (GstProps *properties, gchar *pfx) +print_props (GstProps *properties, const gchar *pfx) { GList *props; GstPropsEntry *prop; @@ -108,6 +108,32 @@ print_props (GstProps *properties, gchar *pfx) } static void +print_caps (const GstCaps *caps, const gchar *pfx) +{ + while (caps) { + GstType *type; + + g_print ("%s'%s': (%sfixed)\n", pfx, caps->name, (caps->fixed ? "" : "NOT ")); + + type = gst_type_find_by_id (caps->id); + if (type) + g_print ("%s MIME type: '%s':\n", pfx, type->mime); + else + g_print ("%s MIME type: 'unknown/unknown':\n", pfx); + + if (caps->properties) { + gchar *prefix = g_strdup_printf ("%s ", pfx); + + print_props(caps->properties, prefix); + + g_free (prefix); + } + + caps = caps->next; + } +} + +static void print_formats (const GstFormat *formats) { while (formats && *formats) { @@ -306,8 +332,18 @@ print_element_properties (GstElement *element) break; } default: - if (param->value_type == GST_TYPE_FILENAME) - g_print("Filename"); + if (param->value_type == GST_TYPE_FILENAME) { + g_print("%-23.23s Filename", ""); + } + if (param->value_type == GST_TYPE_CAPS) { + GstCaps *caps = g_value_peek_pointer (&value); + + if (!caps) + g_print("%-23.23s Caps (NULL)", ""); + else { + print_caps (caps, " "); + } + } else if (G_IS_PARAM_SPEC_ENUM (param)) { GEnumValue *values; guint j = 0; @@ -386,7 +422,6 @@ print_element_info (GstElementFactory *factory) GstObjectClass *gstobject_class; GstElementClass *gstelement_class; GList *pads; - GstCaps *caps; GstPad *pad; GstRealPad *realpad; GstPadTemplate *padtemplate; @@ -443,23 +478,7 @@ print_element_info (GstElementFactory *factory) if (padtemplate->caps) { g_print (" Capabilities:\n"); - caps = padtemplate->caps; - while (caps) { - GstType *type; - - g_print (" '%s':\n",caps->name); - - type = gst_type_find_by_id (caps->id); - if (type) - g_print (" MIME type: '%s':\n", type->mime); - else - g_print (" MIME type: 'unknown/unknown':\n"); - - if (caps->properties) - print_props(caps->properties, " "); - - caps = caps->next; - } + print_caps (padtemplate->caps, " "); } g_print ("\n"); @@ -610,23 +629,7 @@ print_element_info (GstElementFactory *factory) if (realpad->caps) { g_print (" Capabilities:\n"); - caps = realpad->caps; - while (caps) { - GstType *type; - - g_print (" '%s':\n", caps->name); - - type = gst_type_find_by_id (caps->id); - if (type) - g_print (" MIME type: '%s':\n", type->mime); - else - g_print (" MIME type: 'unknown/unknown':\n"); - - if (caps->properties) - print_props (caps->properties, " "); - - caps = caps->next; - } + print_caps (realpad->caps, " "); } } } else diff --git a/tools/gst-launch.c b/tools/gst-launch.c index 2f89bd3..2359aec 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -137,6 +137,7 @@ main(int argc, char *argv[]) } else { pipeline = (GstElement*) gst_parse_launchv ((const gchar**)argvn, &error); } + g_free (argvn); if (!pipeline) { if (error) -- 2.7.4