Updates to the new props API

Original commit message from CVS:
Updates to the new props API
Some more info in -inspect
This commit is contained in:
Wim Taymans 2002-03-30 17:06:45 +00:00
parent f0326eea55
commit 0e40bc56b6
2 changed files with 117 additions and 49 deletions

View file

@ -1,60 +1,93 @@
#include <gst/gst.h> #include <gst/gst.h>
#include <string.h> #include <string.h>
/* this must be built within the gstreamer dir, else this will fail */
#include <gst/gstpropsprivate.h>
static void static void
print_prop (GstPropsEntry *prop, gboolean showname, gchar *pfx) print_prop (GstPropsEntry *prop, gboolean showname, gchar *pfx)
{ {
GList *list; GstPropsType type;
GstPropsEntry *listentry;
gchar *longprefix;
if (showname) if (showname)
printf("%s%s: ",pfx,g_quark_to_string(prop->propid)); printf("%s%s: ", pfx, gst_props_entry_get_name (prop));
else else
printf(pfx); printf(pfx);
switch (prop->propstype) { type = gst_props_entry_get_type (prop);
case GST_PROPS_INT_ID:
printf("Integer: %d\n",prop->data.int_data); switch (type) {
case GST_PROPS_INT_TYPE:
{
gint val;
gst_props_entry_get_int (prop, &val);
printf("Integer: %d\n", val);
break; break;
case GST_PROPS_INT_RANGE_ID:
printf("Integer range: %d - %d\n",prop->data.int_range_data.min,
prop->data.int_range_data.max);
break;
case GST_PROPS_FLOAT_ID:
printf("Float: %f\n",prop->data.float_data);
break;
case GST_PROPS_FLOAT_RANGE_ID:
printf("Float range: %f - %f\n",prop->data.float_range_data.min,
prop->data.float_range_data.max);
break;
case GST_PROPS_BOOL_ID:
printf("Boolean: %s\n",prop->data.bool_data ? "TRUE" : "FALSE");
break;
case GST_PROPS_STRING_ID:
printf("String: %s\n",prop->data.string_data.string);
break;
case GST_PROPS_FOURCC_ID:
printf("FourCC: '%c%c%c%c'\n",
prop->data.fourcc_data & 0xff,prop->data.fourcc_data>>8 & 0xff,
prop->data.fourcc_data>>16 & 0xff,prop->data.fourcc_data>>24 & 0xff);
break;
case GST_PROPS_LIST_ID:
printf("List:\n");
longprefix = g_strdup_printf("%s ",pfx);
list = prop->data.list_data.entries;
while (list) {
listentry = (GstPropsEntry*)(list->data);
list = g_list_next(list);
print_prop(listentry,FALSE,longprefix);
} }
g_free(longprefix); case GST_PROPS_INT_RANGE_TYPE:
{
gint min, max;
gst_props_entry_get_int_range (prop, &min, &max);
printf("Integer range: %d - %d\n", min, max);
break; break;
}
case GST_PROPS_FLOAT_TYPE:
{
gfloat val;
gst_props_entry_get_float (prop, &val);
printf("Float: %f\n", val);
break;
}
case GST_PROPS_FLOAT_RANGE_TYPE:
{
gfloat min, max;
gst_props_entry_get_float_range (prop, &min, &max);
printf("Float range: %f - %f\n", min, max);
break;
}
case GST_PROPS_BOOL_TYPE:
{
gboolean val;
gst_props_entry_get_boolean (prop, &val);
printf("Boolean: %s\n", val ? "TRUE" : "FALSE");
break;
}
case GST_PROPS_STRING_TYPE:
{
const gchar *val;
gst_props_entry_get_string (prop, &val);
printf("String: %s\n", val);
break;
}
case GST_PROPS_FOURCC_TYPE:
{
guint32 val;
gst_props_entry_get_fourcc_int (prop, &val);
printf("FourCC: '%c%c%c%c'\n",
(gchar)( val & 0xff),
(gchar)((val >> 8) & 0xff),
(gchar)((val >> 16) & 0xff),
(gchar)((val >> 24) & 0xff));
break;
}
case GST_PROPS_LIST_TYPE:
{
const GList *list;
gchar *longprefix;
gst_props_entry_get_list (prop, &list);
printf ("List:\n");
longprefix = g_strdup_printf ("%s ", pfx);
while (list) {
GstPropsEntry *listentry;
listentry = (GstPropsEntry*) (list->data);
print_prop (listentry, FALSE, longprefix);
list = g_list_next (list);
}
g_free (longprefix);
break;
}
default: default:
printf("unknown props %d\n", prop->propstype); printf("unknown props %d\n", type);
} }
} }
@ -190,7 +223,7 @@ print_element_info (GstElementFactory *factory)
have_flags = FALSE; have_flags = FALSE;
printf("Element Flags:\n"); printf("\nElement Flags:\n");
if (GST_FLAG_IS_SET(element,GST_ELEMENT_COMPLEX)) { if (GST_FLAG_IS_SET(element,GST_ELEMENT_COMPLEX)) {
printf(" GST_ELEMENT_COMPLEX\n"); printf(" GST_ELEMENT_COMPLEX\n");
have_flags = TRUE; have_flags = TRUE;
@ -210,6 +243,24 @@ print_element_info (GstElementFactory *factory)
if (!have_flags) if (!have_flags)
printf(" no flags set\n"); printf(" no flags set\n");
if (GST_IS_BIN (element)) {
printf("\nBin Flags:\n");
if (GST_FLAG_IS_SET(element,GST_BIN_FLAG_MANAGER)) {
printf(" GST_BIN_FLAG_MANAGER\n");
have_flags = TRUE;
}
if (GST_FLAG_IS_SET(element,GST_BIN_SELF_SCHEDULABLE)) {
printf(" GST_BIN_SELF_SCHEDULABLE\n");
have_flags = TRUE;
}
if (GST_FLAG_IS_SET(element,GST_BIN_FLAG_PREFER_COTHREADS)) {
printf(" GST_BIN_FLAG_PREFER_COTHREADS\n");
have_flags = TRUE;
}
if (!have_flags)
printf(" no flags set\n");
}
printf("\nElement Implementation:\n"); printf("\nElement Implementation:\n");
@ -228,6 +279,23 @@ print_element_info (GstElementFactory *factory)
GST_DEBUG_FUNCPTR_NAME(gstobject_class->restore_thyself)); GST_DEBUG_FUNCPTR_NAME(gstobject_class->restore_thyself));
#endif #endif
have_flags = FALSE;
printf("\nClocking Interaction:\n");
if (element->setclockfunc) {
printf(" element requires a clock\n");
have_flags = TRUE;
}
if (element->getclockfunc) {
GstClock *clock;
clock = gst_element_get_clock (element);
printf(" element provides a clock: %s\n", GST_OBJECT_NAME(clock));
have_flags = TRUE;
}
if (!have_flags) {
printf(" none\n");
}
printf("\nPads:\n"); printf("\nPads:\n");
@ -292,8 +360,10 @@ print_element_info (GstElementFactory *factory)
GValue value = { 0, }; GValue value = { 0, };
GParamSpec *param = property_specs[i]; GParamSpec *param = property_specs[i];
if (param->flags & G_PARAM_READABLE) {
g_value_init (&value, param->value_type); g_value_init (&value, param->value_type);
g_object_get_property (G_OBJECT (element), param->name, &value); g_object_get_property (G_OBJECT (element), param->name, &value);
}
printf(" %-40.40s: ",param->name); printf(" %-40.40s: ",param->name);
switch (G_VALUE_TYPE (&value)) { switch (G_VALUE_TYPE (&value)) {
@ -323,7 +393,7 @@ print_element_info (GstElementFactory *factory)
/* g_type_class_unref (ec); */ /* g_type_class_unref (ec); */
} }
else else
printf("unknown %d", param->value_type); printf("unknown %ld", param->value_type);
break; break;
} }
printf("\n"); printf("\n");

View file

@ -1,10 +1,6 @@
#include <glib.h>
#include <gst/gst.h>
#include <gst/gstparse.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <gst/gstpropsprivate.h> #include <gst/gst.h>
#include <sys/time.h>
static int launch_argc; static int launch_argc;
static char **launch_argv; static char **launch_argv;
@ -18,16 +14,16 @@ gboolean
idle_func (gpointer data) idle_func (gpointer data)
{ {
gboolean busy; gboolean busy;
struct timeval tfthen, tfnow; GTimeVal tfthen, tfnow;
guint64 diff; GstClockTimeDiff diff;
gettimeofday (&tfthen, (struct timezone *)NULL); g_get_current_time (&tfthen);
busy = gst_bin_iterate (GST_BIN (data)); busy = gst_bin_iterate (GST_BIN (data));
iterations++; iterations++;
gettimeofday (&tfnow, (struct timezone *)NULL); g_get_current_time (&tfnow);
diff = ((guint64)tfnow.tv_sec*1000000LL+tfnow.tv_usec) - diff = GST_TIMEVAL_TO_TIME (tfnow) -
((guint64)tfthen.tv_sec*1000000LL+tfthen.tv_usec); GST_TIMEVAL_TO_TIME (tfthen);
sum += diff; sum += diff;
min = MIN (min, diff); min = MIN (min, diff);
@ -166,6 +162,8 @@ main(int argc, char *argv[])
launch_argc = argc; launch_argc = argc;
launch_argv = argv; launch_argv = argv;
//gst_schedulerfactory_set_default_name ("fast");
/* make a null-terminated version of argv */ /* make a null-terminated version of argv */
argvn = g_new0 (char *,argc); argvn = g_new0 (char *,argc);
memcpy (argvn, argv+1, sizeof (char*) * (argc-1)); memcpy (argvn, argv+1, sizeof (char*) * (argc-1));