mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS: * configure.ac: Add detection for HAVE_PRINTF_EXTENSION and GST_PRINTF_EXTENSION_FORMAT_DEFINE. * docs/random/ds/0.9-suggested-changes: Notes from Company. * gst/gstcaps.c: (gst_caps_to_string): Add comment. * gst/gstconfig.h.in: Add define for GST_PTR_FORMAT * gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object), (gst_debug_log_default), (_gst_info_printf_extension), (_gst_info_printf_extension_arginfo): Add printf extension. * gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P * gst/gststructure.c: (gst_structure_to_string), (_gst_structure_parse_value): Use gst_value_deserialize() and remove old code. * gst/gstvalue.c: (gst_value_deserialize_fourcc), (gst_value_deserialize_boolean), (gst_strtoi), (gst_value_deserialize_int), (gst_value_deserialize_double), (gst_value_deserialize_string), (gst_value_deserialize): Implement a bunch of deserialize functions and gst_value_deserialize. * gst/gstvalue.h: er, _de_serialize, not unserialize * testsuite/caps/string-conversions.c: (main): We don't currently handle (float) in caps, so convert these to (double). * testsuite/debug/Makefile.am: Add new test for the printf extension * testsuite/debug/printf_extension.c: (main): same
This commit is contained in:
parent
0d25cd2aa4
commit
6a096813d4
17 changed files with 372 additions and 169 deletions
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
|||
2004-01-28 David Schleef <ds@schleef.org>
|
||||
|
||||
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
|
||||
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
|
||||
* docs/random/ds/0.9-suggested-changes: Notes from Company.
|
||||
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
|
||||
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
|
||||
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
|
||||
(gst_debug_log_default), (_gst_info_printf_extension),
|
||||
(_gst_info_printf_extension_arginfo): Add printf extension.
|
||||
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
|
||||
* gst/gststructure.c: (gst_structure_to_string),
|
||||
(_gst_structure_parse_value): Use gst_value_deserialize() and
|
||||
remove old code.
|
||||
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
|
||||
(gst_value_deserialize_boolean), (gst_strtoi),
|
||||
(gst_value_deserialize_int), (gst_value_deserialize_double),
|
||||
(gst_value_deserialize_string), (gst_value_deserialize): Implement
|
||||
a bunch of deserialize functions and gst_value_deserialize.
|
||||
* gst/gstvalue.h: er, _de_serialize, not unserialize
|
||||
* testsuite/caps/string-conversions.c: (main): We don't currently
|
||||
handle (float) in caps, so convert these to (double).
|
||||
* testsuite/debug/Makefile.am: Add new test for the printf extension
|
||||
* testsuite/debug/printf_extension.c: (main): same
|
||||
|
||||
2004-01-28 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
|
||||
* docs/random/company/time:
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 0bcde342015b96d9a6ba3b9d9102e2a543399d96
|
||||
Subproject commit 5da247bb6f217c5c32e5ebab0d3a2014dfa452c3
|
11
configure.ac
11
configure.ac
|
@ -454,6 +454,17 @@ AC_CHECK_FUNC(sigaction,
|
|||
AC_DEFINE(HAVE_SIGACTION, 1,
|
||||
[Defined if we have sigaction ()]))
|
||||
|
||||
dnl test for register_printf_function
|
||||
AC_CHECK_FUNC(register_printf_function,
|
||||
[
|
||||
GST_PRINTF_EXTENSION_FORMAT_DEFINE="#define GST_PTR_FORMAT \"P\""
|
||||
AC_DEFINE(HAVE_PRINTF_EXTENSION, 1,
|
||||
[Defined if we have register_printf_function ()])
|
||||
],
|
||||
GST_PRINTF_EXTENSION_FORMAT_DEFINE="#define GST_PTR_FORMAT \"p\""
|
||||
)
|
||||
AC_SUBST(GST_PRINTF_EXTENSION_FORMAT_DEFINE)
|
||||
|
||||
dnl test if we have dladdr(); we use it for debugging
|
||||
save_cflags="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -D_GNU_SOURCE"
|
||||
|
|
|
@ -6,5 +6,27 @@ API:
|
|||
|
||||
|
||||
|
||||
caps:
|
||||
|
||||
(Company:)
|
||||
|
||||
"An idea I had once was to force registration of mimetypes and then
|
||||
only allow caps with a registered mimetype - like it's done now with caps.
|
||||
You could then add functions to those registrations like
|
||||
- gchar *get_human_readable_string (caps);
|
||||
should be kinda selfexplanatory. Would return stuff like "16bit signed
|
||||
integer audio", "MPEG2 video" or "video format in RGB colorspace" (for
|
||||
unfixed RGB)
|
||||
- GstCaps *default_fixate (const GstCaps *caps);
|
||||
A default fixation function, so we don't fixate to minimum integer
|
||||
anymore but have the ability to fixate to 320x240 for video or 44100 for
|
||||
audio rates
|
||||
- gboolean validate (const GstCaps *caps);
|
||||
check if the given caps are ok for this mimetype - debugging only function
|
||||
I'd _really_ like to have - especially during gst_register.
|
||||
|
||||
But that's 0.10 material."
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1023,6 +1023,12 @@ gchar *gst_caps_to_string (const GstCaps *caps)
|
|||
GstStructure *structure;
|
||||
GString *s;
|
||||
|
||||
/* NOTE: This function is potentially called by the debug system,
|
||||
* so any calls to gst_log() (and GST_DEBUG(), GST_LOG(), etc.)
|
||||
* should be careful to avoid recursion. This includes any functions
|
||||
* called by gst_caps_to_string. In particular, calls should
|
||||
* not use the GST_PTR_FORMAT extension. */
|
||||
|
||||
/* FIXME does this leak? */
|
||||
|
||||
if (caps == NULL) {
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
/* DOES NOT WORK */
|
||||
@GST_DISABLE_URI_DEFINE@
|
||||
|
||||
/* printf extension format */
|
||||
@GST_PRINTF_EXTENSION_FORMAT_DEFINE@
|
||||
|
||||
/***** Deal with XML stuff, we have to handle both loadsave and registry *****/
|
||||
|
||||
|
|
106
gst/gstinfo.c
106
gst/gstinfo.c
|
@ -30,6 +30,9 @@
|
|||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#ifdef HAVE_PRINTF_EXTENSION
|
||||
#include <printf.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <string.h> /* G_VA_COPY */
|
||||
#include "gstinfo.h"
|
||||
|
@ -72,6 +75,13 @@ static void gst_debug_reset_threshold (gpointer category,
|
|||
gpointer unused);
|
||||
static void gst_debug_reset_all_thresholds (void);
|
||||
|
||||
#ifdef HAVE_PRINTF_EXTENSION
|
||||
static int _gst_info_printf_extension (FILE *stream, const struct printf_info *info,
|
||||
const void *const *args);
|
||||
static int _gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n,
|
||||
int *argtypes);
|
||||
#endif
|
||||
|
||||
struct _GstDebugMessage {
|
||||
gchar * message;
|
||||
const gchar * format;
|
||||
|
@ -146,6 +156,11 @@ void _gst_debug_init (void)
|
|||
gst_atomic_int_init (&__default_level, GST_LEVEL_DEFAULT);
|
||||
gst_atomic_int_init (&__use_color, 1);
|
||||
|
||||
#ifdef HAVE_PRINTF_EXTENSION
|
||||
register_printf_function (GST_PTR_FORMAT[0], _gst_info_printf_extension,
|
||||
_gst_info_printf_extension_arginfo);
|
||||
#endif
|
||||
|
||||
/* do NOT use a single debug function before this line has been run */
|
||||
GST_CAT_DEFAULT = _gst_debug_category_new ("default",
|
||||
GST_DEBUG_UNDERLINE,
|
||||
|
@ -328,6 +343,53 @@ gst_debug_message_get (GstDebugMessage *message)
|
|||
return message->message;
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
gst_debug_print_object (gpointer ptr)
|
||||
{
|
||||
GObject *object = (GObject *)ptr;
|
||||
|
||||
#ifdef unused
|
||||
/* This is a cute trick to detect unmapped memory, but is unportable,
|
||||
* slow, screws around with madvise, and not actually that useful. */
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = madvise ((void *)((unsigned long)ptr & (~0xfff)), 4096, 0);
|
||||
if (ret == -1 && errno == ENOMEM) {
|
||||
buffer = g_strdup_printf ("%p (unmapped memory)", ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* nicely printed object */
|
||||
if (object == NULL) {
|
||||
return g_strdup ("NULL");
|
||||
}
|
||||
if (*(GType *)ptr == GST_TYPE_CAPS) {
|
||||
return gst_caps_to_string ((GstCaps *)ptr);
|
||||
}
|
||||
if (*(GType *)ptr == GST_TYPE_STRUCTURE) {
|
||||
return gst_structure_to_string ((GstStructure *)ptr);
|
||||
}
|
||||
#ifdef USE_POISONING
|
||||
if (*(int *)ptr == 0xffffffff) {
|
||||
return g_strdup_printf ("<poisoned@%p>", ptr);
|
||||
}
|
||||
#endif
|
||||
if (GST_IS_PAD (object) && GST_OBJECT_NAME (object)) {
|
||||
return g_strdup_printf ("<%s:%s>", GST_DEBUG_PAD_NAME (object));
|
||||
}
|
||||
if (GST_IS_OBJECT (object) && GST_OBJECT_NAME (object)) {
|
||||
return g_strdup_printf ("<%s>", GST_OBJECT_NAME (object));
|
||||
}
|
||||
if (G_IS_OBJECT (object)) {
|
||||
return g_strdup_printf ("<%s@%p>", G_OBJECT_TYPE_NAME(object), object);
|
||||
}
|
||||
|
||||
return g_strdup_printf ("%p", ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_debug_construct_term_color:
|
||||
* @colorinfo: the color info
|
||||
|
@ -408,18 +470,10 @@ gst_debug_log_default (GstDebugCategory *category, GstDebugLevel level,
|
|||
clear = "";
|
||||
pidcolor = g_strdup ("");
|
||||
}
|
||||
/* nicely printed object */
|
||||
if (object == NULL) {
|
||||
obj = g_strdup ("");
|
||||
} else if (GST_IS_PAD (object) && GST_OBJECT_NAME (object)) {
|
||||
obj = g_strdup_printf (" [%s:%s]", GST_DEBUG_PAD_NAME (object));
|
||||
} else if (GST_IS_OBJECT (object) && GST_OBJECT_NAME (object)) {
|
||||
obj = g_strdup_printf (" [%s]", GST_OBJECT_NAME (object));
|
||||
} else {
|
||||
obj = g_strdup_printf (" [%s@%p]", G_OBJECT_TYPE_NAME(object), object);
|
||||
}
|
||||
|
||||
g_printerr ("%s %s%15s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n",
|
||||
obj = gst_debug_print_object (object);
|
||||
|
||||
g_printerr ("%s %s%15s%s(%s%5d%s) %s%s(%d):%s: %s%s %s\n",
|
||||
gst_debug_level_get_name (level),
|
||||
color, gst_debug_category_get_name (category), clear,
|
||||
pidcolor, pid, clear,
|
||||
|
@ -949,6 +1003,36 @@ _gst_debug_register_funcptr (void *ptr, gchar *ptrname)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PRINTF_EXTENSION
|
||||
static int
|
||||
_gst_info_printf_extension (FILE *stream, const struct printf_info *info,
|
||||
const void *const *args)
|
||||
{
|
||||
char *buffer;
|
||||
int len;
|
||||
void *ptr;
|
||||
|
||||
buffer = NULL;
|
||||
ptr = *(void **)args[0];
|
||||
|
||||
buffer = gst_debug_print_object (ptr);
|
||||
len = fprintf (stream, "%*s", (info->left ? -info->width : info->width),
|
||||
buffer);
|
||||
|
||||
free (buffer);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
_gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n,
|
||||
int *argtypes)
|
||||
{
|
||||
if (n > 0)
|
||||
argtypes[0] = PA_POINTER;
|
||||
return 1;
|
||||
}
|
||||
#endif /* HAVE_PRINTF_EXTENSION */
|
||||
|
||||
#endif /* GST_DISABLE_GST_DEBUG */
|
||||
|
||||
#ifdef GST_ENABLE_FUNC_INSTRUMENTATION
|
||||
|
|
|
@ -155,6 +155,8 @@ typedef void (*GstLogFunction) (GstDebugCategory * category,
|
|||
|
||||
void _gst_debug_init (void);
|
||||
|
||||
/* note we can't use G_GNUC_PRINTF (7, 8) because gcc chokes on %P, which
|
||||
* we use for GST_PTR_FORMAT. */
|
||||
void gst_debug_log (GstDebugCategory * category,
|
||||
GstDebugLevel level,
|
||||
const gchar * file,
|
||||
|
@ -162,7 +164,7 @@ void gst_debug_log (GstDebugCategory * category,
|
|||
gint line,
|
||||
GObject * object,
|
||||
const gchar * format,
|
||||
...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
|
||||
...) G_GNUC_NO_INSTRUMENT;
|
||||
void gst_debug_log_valist (GstDebugCategory * category,
|
||||
GstDebugLevel level,
|
||||
const gchar * file,
|
||||
|
|
|
@ -552,13 +552,6 @@ gst_structure_id_get_value(const GstStructure *structure, GQuark id)
|
|||
return &field->value;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void gst_structure_get(GstStructure *structure, const gchar *fieldname, ...)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* gst_structure_remove_field:
|
||||
* @structure: a #GstStructure
|
||||
|
@ -970,6 +963,12 @@ gst_structure_to_string(const GstStructure *structure)
|
|||
GString *s;
|
||||
int i;
|
||||
|
||||
/* NOTE: This function is potentially called by the debug system,
|
||||
* so any calls to gst_log() (and GST_DEBUG(), GST_LOG(), etc.)
|
||||
* should be careful to avoid recursion. This includes any functions
|
||||
* called by gst_structure_to_string. In particular, calls should
|
||||
* not use the GST_PTR_FORMAT extension. */
|
||||
|
||||
g_return_val_if_fail(structure != NULL, NULL);
|
||||
|
||||
s = g_string_new("");
|
||||
|
@ -1050,135 +1049,6 @@ _gst_structure_parse_string (gchar *s, gchar **end, gchar **next)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
gst_strtoi (const char *s, char **end, int base)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (s[0] == '-') {
|
||||
i = - (int) strtoul (s + 1, end, base);
|
||||
} else {
|
||||
i = strtoul (s, end, base);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_value_from_string (GValue *value, const char *s)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gchar *end;
|
||||
GType type = G_VALUE_TYPE (value);
|
||||
|
||||
if (type == G_TYPE_INVALID) return FALSE;
|
||||
|
||||
switch (type) {
|
||||
case G_TYPE_INT:
|
||||
{
|
||||
int x;
|
||||
x = gst_strtoi (s, &end, 0);
|
||||
if (*end == 0) {
|
||||
ret = TRUE;
|
||||
} else {
|
||||
if (g_ascii_strcasecmp (s, "little_endian") == 0) {
|
||||
x = G_LITTLE_ENDIAN;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "big_endian") == 0) {
|
||||
x = G_BIG_ENDIAN;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "byte_order") == 0) {
|
||||
x = G_BYTE_ORDER;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "min") == 0) {
|
||||
x = G_MININT;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "max") == 0) {
|
||||
x = G_MAXINT;
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
if (ret) {
|
||||
g_value_set_int (value, x);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case G_TYPE_FLOAT:
|
||||
{
|
||||
double x;
|
||||
x = g_ascii_strtod (s, &end);
|
||||
if (*end == 0) {
|
||||
g_value_set_float (value, x);
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case G_TYPE_DOUBLE:
|
||||
{
|
||||
double x;
|
||||
x = g_ascii_strtod (s, &end);
|
||||
if (*end == 0) {
|
||||
ret = TRUE;
|
||||
} else {
|
||||
if (g_ascii_strcasecmp (s, "min") == 0) {
|
||||
x = -G_MAXDOUBLE;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "max") == 0) {
|
||||
x = G_MAXDOUBLE;
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
if (ret) {
|
||||
g_value_set_double (value, x);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case G_TYPE_BOOLEAN:
|
||||
{
|
||||
if (g_ascii_strcasecmp (s, "true") == 0 ||
|
||||
g_ascii_strcasecmp (s, "yes") == 0 ||
|
||||
g_ascii_strcasecmp (s, "t") == 0 ||
|
||||
strcmp (s, "1") == 0) {
|
||||
g_value_set_boolean (value, TRUE);
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "false") == 0 ||
|
||||
g_ascii_strcasecmp (s, "no") == 0 ||
|
||||
g_ascii_strcasecmp (s, "f") == 0 ||
|
||||
strcmp (s, "0") == 0) {
|
||||
g_value_set_boolean (value, FALSE);
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case G_TYPE_STRING:
|
||||
{
|
||||
g_value_set_string (value, s);
|
||||
ret = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* FIXME: make more general */
|
||||
if (type == GST_TYPE_FOURCC) {
|
||||
guint32 fourcc = 0;
|
||||
if (strlen(s) == 4) {
|
||||
fourcc = GST_MAKE_FOURCC(s[0], s[1], s[2], s[3]);
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_isdigit (*s)) {
|
||||
fourcc = strtoul (s, &end, 0);
|
||||
if (*end == 0) {
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
gst_value_set_fourcc (value, fourcc);
|
||||
} else {
|
||||
g_critical("type %s not handled", g_type_name(type));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean _gst_structure_parse_value (gchar *str, gchar **after,
|
||||
GValue *value, GType default_type);
|
||||
|
||||
|
@ -1384,14 +1254,14 @@ _gst_structure_parse_value (gchar *str, gchar **after, GValue *value,
|
|||
|
||||
for(i=0;i<3;i++) {
|
||||
g_value_init(value, try_types[i]);
|
||||
ret = gst_value_from_string (value, value_s);
|
||||
ret = gst_value_deserialize (value, value_s);
|
||||
if (ret) break;
|
||||
g_value_unset(value);
|
||||
}
|
||||
} else {
|
||||
g_value_init(value, type);
|
||||
|
||||
ret = gst_value_from_string (value, value_s);
|
||||
ret = gst_value_deserialize (value, value_s);
|
||||
}
|
||||
*value_end = c;
|
||||
}
|
||||
|
|
121
gst/gstvalue.c
121
gst/gstvalue.c
|
@ -415,8 +415,22 @@ gst_value_serialize_fourcc (const GValue *value)
|
|||
static gboolean
|
||||
gst_value_deserialize_fourcc (GValue *dest, const char *s)
|
||||
{
|
||||
g_warning("unimplemented");
|
||||
return FALSE;
|
||||
gboolean ret = FALSE;
|
||||
guint32 fourcc = 0;
|
||||
char *end;
|
||||
|
||||
if (strlen(s) == 4) {
|
||||
fourcc = GST_MAKE_FOURCC(s[0], s[1], s[2], s[3]);
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_isdigit (*s)) {
|
||||
fourcc = strtoul (s, &end, 0);
|
||||
if (*end == 0) {
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
gst_value_set_fourcc (dest, fourcc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
|
@ -707,8 +721,23 @@ gst_value_serialize_boolean (const GValue *value)
|
|||
static gboolean
|
||||
gst_value_deserialize_boolean (GValue *dest, const char *s)
|
||||
{
|
||||
g_warning("unimplemented");
|
||||
return FALSE;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (g_ascii_strcasecmp (s, "true") == 0 ||
|
||||
g_ascii_strcasecmp (s, "yes") == 0 ||
|
||||
g_ascii_strcasecmp (s, "t") == 0 ||
|
||||
strcmp (s, "1") == 0) {
|
||||
g_value_set_boolean (dest, TRUE);
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "false") == 0 ||
|
||||
g_ascii_strcasecmp (s, "no") == 0 ||
|
||||
g_ascii_strcasecmp (s, "f") == 0 ||
|
||||
strcmp (s, "0") == 0) {
|
||||
g_value_set_boolean (dest, FALSE);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
|
@ -730,11 +759,52 @@ gst_value_serialize_int (const GValue *value)
|
|||
return g_strdup_printf ("%d", value->data[0].v_int);
|
||||
}
|
||||
|
||||
static int
|
||||
gst_strtoi (const char *s, char **end, int base)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (s[0] == '-') {
|
||||
i = - (int) strtoul (s + 1, end, base);
|
||||
} else {
|
||||
i = strtoul (s, end, base);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_value_deserialize_int (GValue *dest, const char *s)
|
||||
{
|
||||
g_warning("unimplemented");
|
||||
return FALSE;
|
||||
int x;
|
||||
char *end;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
x = gst_strtoi (s, &end, 0);
|
||||
if (*end == 0) {
|
||||
ret = TRUE;
|
||||
} else {
|
||||
if (g_ascii_strcasecmp (s, "little_endian") == 0) {
|
||||
x = G_LITTLE_ENDIAN;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "big_endian") == 0) {
|
||||
x = G_BIG_ENDIAN;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "byte_order") == 0) {
|
||||
x = G_BYTE_ORDER;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "min") == 0) {
|
||||
x = G_MININT;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "max") == 0) {
|
||||
x = G_MAXINT;
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
if (ret) {
|
||||
g_value_set_int (dest, x);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
|
@ -763,8 +833,26 @@ gst_value_serialize_double (const GValue *value)
|
|||
static gboolean
|
||||
gst_value_deserialize_double (GValue *dest, const char *s)
|
||||
{
|
||||
g_warning("unimplemented");
|
||||
return FALSE;
|
||||
double x;
|
||||
gboolean ret = FALSE;
|
||||
char *end;
|
||||
|
||||
x = g_ascii_strtod (s, &end);
|
||||
if (*end == 0) {
|
||||
ret = TRUE;
|
||||
} else {
|
||||
if (g_ascii_strcasecmp (s, "min") == 0) {
|
||||
x = -G_MAXDOUBLE;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "max") == 0) {
|
||||
x = G_MAXDOUBLE;
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
if (ret) {
|
||||
g_value_set_double (dest, x);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
|
@ -840,8 +928,9 @@ gst_value_serialize_string (const GValue *value)
|
|||
static gboolean
|
||||
gst_value_deserialize_string (GValue *dest, const char *s)
|
||||
{
|
||||
g_warning("unimplemented");
|
||||
return FALSE;
|
||||
g_value_set_string (dest, s);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
|
@ -1217,7 +1306,17 @@ gst_value_serialize (const GValue *value)
|
|||
gboolean
|
||||
gst_value_deserialize (GValue *dest, const gchar *src)
|
||||
{
|
||||
g_warning("unimplemented");
|
||||
GstValueTable *table;
|
||||
int i;
|
||||
|
||||
for(i=0;i<gst_value_table->len;i++){
|
||||
table = &g_array_index(gst_value_table, GstValueTable, i);
|
||||
if(table->type != G_VALUE_TYPE(dest) ||
|
||||
table->deserialize == NULL) continue;
|
||||
|
||||
return table->deserialize(dest, src);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ struct _GstValueTable {
|
|||
GType type;
|
||||
GstValueCompareFunc compare;
|
||||
GstValueSerializeFunc serialize;
|
||||
GstValueDeserializeFunc unserialize;
|
||||
GstValueDeserializeFunc deserialize;
|
||||
|
||||
void *_gst_reserved [GST_PADDING];
|
||||
};
|
||||
|
|
|
@ -147,10 +147,10 @@ bla:
|
|||
|
||||
/* fixed props entries */
|
||||
test_string ("audio/raw ,test=(int)1");
|
||||
test_string ("audio/raw ,test=(float) 1");
|
||||
test_string ("audio/raw ,test=(double) 1");
|
||||
test_string ("audio/raw, test=(fourcc )1");
|
||||
test_string ("audio/raw ,test=(i)1");
|
||||
test_string ("audio/raw ,test=(f) 1");
|
||||
test_string ("audio/raw ,test=(d) 1");
|
||||
test_string ("audio/raw, test=(4 )1");
|
||||
test_string ("audio/raw,test=( fourcc ) 0x0000001");
|
||||
test_string ("audio/raw,test =(fourcc) \"RGB \"");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
include ../Rules
|
||||
|
||||
tests_pass = commandline category output
|
||||
tests_pass = commandline category output printf_extension
|
||||
tests_fail =
|
||||
|
||||
tests_inconsistent = global
|
||||
|
|
41
tests/old/testsuite/debug/printf_extension.c
Normal file
41
tests/old/testsuite/debug/printf_extension.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 2004 David A. Schleef <ds@schleef.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
gint
|
||||
main (gint argc, gchar *argv[])
|
||||
{
|
||||
GstCaps *caps;
|
||||
GstElement *element;
|
||||
int zero = 0;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
caps = gst_caps_from_string ("audio/x-raw-int, rate=44100");
|
||||
|
||||
element = gst_element_factory_make ("identity", NULL);
|
||||
|
||||
GST_ERROR ("This should print caps: %" GST_PTR_FORMAT, caps);
|
||||
GST_ERROR ("This should print an object: %" GST_PTR_FORMAT, element);
|
||||
GST_ERROR ("This should print null: %" GST_PTR_FORMAT, NULL);
|
||||
GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, &zero);
|
||||
//GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, (void *)1);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -147,10 +147,10 @@ bla:
|
|||
|
||||
/* fixed props entries */
|
||||
test_string ("audio/raw ,test=(int)1");
|
||||
test_string ("audio/raw ,test=(float) 1");
|
||||
test_string ("audio/raw ,test=(double) 1");
|
||||
test_string ("audio/raw, test=(fourcc )1");
|
||||
test_string ("audio/raw ,test=(i)1");
|
||||
test_string ("audio/raw ,test=(f) 1");
|
||||
test_string ("audio/raw ,test=(d) 1");
|
||||
test_string ("audio/raw, test=(4 )1");
|
||||
test_string ("audio/raw,test=( fourcc ) 0x0000001");
|
||||
test_string ("audio/raw,test =(fourcc) \"RGB \"");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
include ../Rules
|
||||
|
||||
tests_pass = commandline category output
|
||||
tests_pass = commandline category output printf_extension
|
||||
tests_fail =
|
||||
|
||||
tests_inconsistent = global
|
||||
|
|
41
testsuite/debug/printf_extension.c
Normal file
41
testsuite/debug/printf_extension.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 2004 David A. Schleef <ds@schleef.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
gint
|
||||
main (gint argc, gchar *argv[])
|
||||
{
|
||||
GstCaps *caps;
|
||||
GstElement *element;
|
||||
int zero = 0;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
caps = gst_caps_from_string ("audio/x-raw-int, rate=44100");
|
||||
|
||||
element = gst_element_factory_make ("identity", NULL);
|
||||
|
||||
GST_ERROR ("This should print caps: %" GST_PTR_FORMAT, caps);
|
||||
GST_ERROR ("This should print an object: %" GST_PTR_FORMAT, element);
|
||||
GST_ERROR ("This should print null: %" GST_PTR_FORMAT, NULL);
|
||||
GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, &zero);
|
||||
//GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, (void *)1);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue