- Refactor the caps print function in -inspect

Original commit message from CVS:
- Refactor the caps print function in -inspect
- fix a leak in -launch
This commit is contained in:
Wim Taymans 2002-09-17 21:32:26 +00:00
parent 1debaf2b59
commit d9e80e999a
2 changed files with 43 additions and 39 deletions

View file

@ -3,7 +3,7 @@
#include <string.h> #include <string.h>
static void static void
print_prop (GstPropsEntry *prop, gboolean showname, gchar *pfx) print_prop (GstPropsEntry *prop, gboolean showname, const gchar *pfx)
{ {
GstPropsType type; GstPropsType type;
@ -93,7 +93,7 @@ print_prop (GstPropsEntry *prop, gboolean showname, gchar *pfx)
} }
static void static void
print_props (GstProps *properties, gchar *pfx) print_props (GstProps *properties, const gchar *pfx)
{ {
GList *props; GList *props;
GstPropsEntry *prop; GstPropsEntry *prop;
@ -107,6 +107,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 static void
print_formats (const GstFormat *formats) print_formats (const GstFormat *formats)
{ {
@ -306,8 +332,18 @@ print_element_properties (GstElement *element)
break; break;
} }
default: default:
if (param->value_type == GST_TYPE_FILENAME) if (param->value_type == GST_TYPE_FILENAME) {
g_print("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)) { else if (G_IS_PARAM_SPEC_ENUM (param)) {
GEnumValue *values; GEnumValue *values;
guint j = 0; guint j = 0;
@ -386,7 +422,6 @@ print_element_info (GstElementFactory *factory)
GstObjectClass *gstobject_class; GstObjectClass *gstobject_class;
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
GList *pads; GList *pads;
GstCaps *caps;
GstPad *pad; GstPad *pad;
GstRealPad *realpad; GstRealPad *realpad;
GstPadTemplate *padtemplate; GstPadTemplate *padtemplate;
@ -443,23 +478,7 @@ print_element_info (GstElementFactory *factory)
if (padtemplate->caps) { if (padtemplate->caps) {
g_print (" Capabilities:\n"); g_print (" Capabilities:\n");
caps = padtemplate->caps; print_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;
}
} }
g_print ("\n"); g_print ("\n");
@ -610,23 +629,7 @@ print_element_info (GstElementFactory *factory)
if (realpad->caps) { if (realpad->caps) {
g_print (" Capabilities:\n"); g_print (" Capabilities:\n");
caps = realpad->caps; print_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;
}
} }
} }
} else } else

View file

@ -137,6 +137,7 @@ main(int argc, char *argv[])
} else { } else {
pipeline = (GstElement*) gst_parse_launchv ((const gchar**)argvn, &error); pipeline = (GstElement*) gst_parse_launchv ((const gchar**)argvn, &error);
} }
g_free (argvn);
if (!pipeline) { if (!pipeline) {
if (error) if (error)