2003-11-03 09:10:07 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2003> 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 Library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2004-02-12 16:49:16 +00:00
|
|
|
#include <stdlib.h>
|
2003-11-04 19:00:54 +00:00
|
|
|
#include <string.h>
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gobject/gvaluecollector.h>
|
|
|
|
|
2003-11-04 19:00:54 +00:00
|
|
|
|
|
|
|
typedef struct _GstValueUnionInfo GstValueUnionInfo;
|
2004-03-13 15:27:01 +00:00
|
|
|
struct _GstValueUnionInfo
|
|
|
|
{
|
2003-11-04 19:00:54 +00:00
|
|
|
GType type1;
|
|
|
|
GType type2;
|
|
|
|
GstValueUnionFunc func;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _GstValueIntersectInfo GstValueIntersectInfo;
|
2004-03-13 15:27:01 +00:00
|
|
|
struct _GstValueIntersectInfo
|
|
|
|
{
|
2003-11-04 19:00:54 +00:00
|
|
|
GType type1;
|
|
|
|
GType type2;
|
|
|
|
GstValueIntersectFunc func;
|
|
|
|
};
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
GType gst_type_fourcc;
|
|
|
|
GType gst_type_int_range;
|
|
|
|
GType gst_type_double_range;
|
2003-11-29 06:31:10 +00:00
|
|
|
GType gst_type_list;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static GArray *gst_value_table;
|
|
|
|
static GArray *gst_value_union_funcs;
|
|
|
|
static GArray *gst_value_intersect_funcs;
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/*************************************/
|
2003-11-24 02:09:23 +00:00
|
|
|
/* list */
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_init_list (GValue * value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
value->data[0].v_pointer = g_array_new (FALSE, TRUE, sizeof (GValue));
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GArray *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_list_array_copy (const GArray * src)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GArray *dest;
|
2004-02-07 15:51:39 +00:00
|
|
|
gint i;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
dest = g_array_sized_new (FALSE, TRUE, sizeof (GValue), src->len);
|
2003-11-24 02:09:23 +00:00
|
|
|
g_array_set_size (dest, src->len);
|
|
|
|
for (i = 0; i < src->len; i++) {
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_init_and_copy (&g_array_index (dest, GValue, i),
|
2004-03-15 19:27:17 +00:00
|
|
|
&g_array_index (src, GValue, i));
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_copy_list (const GValue * src_value, GValue * dest_value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
dest_value->data[0].v_pointer =
|
|
|
|
gst_value_list_array_copy ((GArray *) src_value->data[0].v_pointer);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_free_list (GValue * value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2004-02-07 15:51:39 +00:00
|
|
|
gint i;
|
2003-11-24 02:09:23 +00:00
|
|
|
GArray *src = (GArray *) value->data[0].v_pointer;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
if ((value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) == 0) {
|
|
|
|
for (i = 0; i < src->len; i++) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_value_unset (&g_array_index (src, GValue, i));
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
g_array_free (src, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gpointer
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_list_peek_pointer (const GValue * value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
return value->data[0].v_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_collect_list (GValue * value, guint n_collect_values,
|
|
|
|
GTypeCValue * collect_values, guint collect_flags)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
|
|
|
|
value->data[0].v_pointer = collect_values[0].v_pointer;
|
|
|
|
value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
|
|
|
|
} else {
|
2004-03-13 15:27:01 +00:00
|
|
|
value->data[0].v_pointer =
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_value_list_array_copy ((GArray *) collect_values[0].v_pointer);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_lcopy_list (const GValue * value, guint n_collect_values,
|
|
|
|
GTypeCValue * collect_values, guint collect_flags)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GArray **dest = collect_values[0].v_pointer;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
if (!dest)
|
|
|
|
return g_strdup_printf ("value location for `%s' passed as NULL",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_VALUE_TYPE_NAME (value));
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!value->data[0].v_pointer)
|
2003-11-24 02:09:23 +00:00
|
|
|
return g_strdup_printf ("invalid value given for `%s'",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_VALUE_TYPE_NAME (value));
|
2003-11-24 02:09:23 +00:00
|
|
|
if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
|
|
|
|
*dest = (GArray *) value->data[0].v_pointer;
|
|
|
|
} else {
|
|
|
|
*dest = gst_value_list_array_copy ((GArray *) value->data[0].v_pointer);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_list_prepend_value:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GstValueList to prepend a value to
|
|
|
|
* @prepend_value: the value to prepend
|
|
|
|
*
|
|
|
|
* Prepends @prepend_value to the GstValueList in @value.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
gst_value_list_prepend_value (GValue * value, const GValue * prepend_value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_VALUE_HOLDS_LIST (value));
|
|
|
|
|
|
|
|
g_array_prepend_vals ((GArray *) value->data[0].v_pointer, prepend_value, 1);
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_list_append_value:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GstValueList to append a value to
|
|
|
|
* @apppend_value: the value to append
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Appends @append_value to the GstValueList in @value.
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
gst_value_list_append_value (GValue * value, const GValue * append_value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_VALUE_HOLDS_LIST (value));
|
|
|
|
|
|
|
|
g_array_append_vals ((GArray *) value->data[0].v_pointer, append_value, 1);
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_list_get_size:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GstValueList
|
|
|
|
*
|
|
|
|
* Gets the number of values contained in @value.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Returns: the number of values
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
guint
|
|
|
|
gst_value_list_get_size (const GValue * value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value), 0);
|
|
|
|
|
|
|
|
return ((GArray *) value->data[0].v_pointer)->len;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_list_get_value:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GstValueList
|
|
|
|
* @index
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Gets the value that is a member of the list contained in @value and
|
|
|
|
* has the index @index.
|
|
|
|
*
|
|
|
|
* Returns: the value at the given index
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-24 02:09:23 +00:00
|
|
|
const GValue *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_list_get_value (const GValue * value, guint index)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value), NULL);
|
|
|
|
g_return_val_if_fail (index < gst_value_list_get_size (value), NULL);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return (const GValue *) &g_array_index ((GArray *) value->data[0].v_pointer,
|
|
|
|
GValue, index);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_list_concat:
|
|
|
|
* @dest: an uninitialized #GValue to take the result
|
|
|
|
* @value1: first value to put into the union
|
|
|
|
* @value2: second value to put into the union
|
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Concatenates copies of value1 and value2 into a list. The value
|
|
|
|
* @dest is initialized to the type GST_TYPE_LIST.
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_list_concat (GValue * dest, const GValue * value1,
|
|
|
|
const GValue * value2)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
guint i, value1_length, value2_length;
|
|
|
|
GArray *array;
|
|
|
|
|
|
|
|
g_return_if_fail (dest != NULL);
|
|
|
|
g_return_if_fail (G_VALUE_TYPE (dest) == 0);
|
|
|
|
g_return_if_fail (G_IS_VALUE (value1));
|
|
|
|
g_return_if_fail (G_IS_VALUE (value2));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
value1_length =
|
|
|
|
(GST_VALUE_HOLDS_LIST (value1) ? gst_value_list_get_size (value1) : 1);
|
|
|
|
value2_length =
|
|
|
|
(GST_VALUE_HOLDS_LIST (value2) ? gst_value_list_get_size (value2) : 1);
|
2003-11-29 06:31:10 +00:00
|
|
|
g_value_init (dest, GST_TYPE_LIST);
|
2003-11-24 02:09:23 +00:00
|
|
|
array = (GArray *) dest->data[0].v_pointer;
|
|
|
|
g_array_set_size (array, value1_length + value2_length);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
if (GST_VALUE_HOLDS_LIST (value1)) {
|
|
|
|
for (i = 0; i < value1_length; i++) {
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_init_and_copy (&g_array_index (array, GValue, i),
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_value_list_get_value (value1, i));
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_init_and_copy (&g_array_index (array, GValue, 0), value1);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
if (GST_VALUE_HOLDS_LIST (value2)) {
|
|
|
|
for (i = 0; i < value2_length; i++) {
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_init_and_copy (&g_array_index (array, GValue,
|
2004-03-15 19:27:17 +00:00
|
|
|
i + value1_length), gst_value_list_get_value (value2, i));
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_init_and_copy (&g_array_index (array, GValue, value1_length),
|
2004-03-15 19:27:17 +00:00
|
|
|
value2);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_transform_list_string (const GValue * src_value, GValue * dest_value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
|
|
|
GValue *list_value;
|
|
|
|
GArray *array;
|
|
|
|
GString *s;
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2003-12-23 20:58:05 +00:00
|
|
|
char *list_s;
|
|
|
|
|
|
|
|
array = src_value->data[0].v_pointer;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
s = g_string_new ("{ ");
|
|
|
|
for (i = 0; i < array->len; i++) {
|
|
|
|
list_value = &g_array_index (array, GValue, i);
|
2003-12-23 20:58:05 +00:00
|
|
|
|
|
|
|
if (i != 0) {
|
|
|
|
g_string_append (s, ", ");
|
|
|
|
}
|
|
|
|
list_s = g_strdup_value_contents (list_value);
|
|
|
|
g_string_append (s, list_s);
|
|
|
|
g_free (list_s);
|
|
|
|
}
|
|
|
|
g_string_append (s, " }");
|
|
|
|
|
|
|
|
dest_value->data[0].v_pointer = g_string_free (s, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare_list (const GValue * value1, const GValue * value2)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
int i, j;
|
2003-12-23 20:58:05 +00:00
|
|
|
GArray *array1 = value1->data[0].v_pointer;
|
|
|
|
GArray *array2 = value2->data[0].v_pointer;
|
|
|
|
GValue *v1;
|
|
|
|
GValue *v2;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (array1->len != array2->len)
|
|
|
|
return GST_VALUE_UNORDERED;
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < array1->len; i++) {
|
2003-12-23 20:58:05 +00:00
|
|
|
v1 = &g_array_index (array1, GValue, i);
|
2004-03-13 15:27:01 +00:00
|
|
|
for (j = 0; j < array1->len; j++) {
|
2003-12-23 20:58:05 +00:00
|
|
|
v2 = &g_array_index (array2, GValue, j);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (gst_value_compare (v1, v2) == GST_VALUE_EQUAL)
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
if (j == array1->len) {
|
2003-12-23 20:58:05 +00:00
|
|
|
return GST_VALUE_UNORDERED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_VALUE_EQUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize_list (const GValue * value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
GArray *array = value->data[0].v_pointer;
|
|
|
|
GString *s;
|
|
|
|
GValue *v;
|
|
|
|
gchar *s_val;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
s = g_string_new ("{ ");
|
|
|
|
for (i = 0; i < array->len; i++) {
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
v = &g_array_index (array, GValue, i);
|
|
|
|
s_val = gst_value_serialize (v);
|
|
|
|
g_string_append (s, s_val);
|
|
|
|
g_free (s_val);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (i < array->len - 1) {
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
g_string_append (s, ", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_string_append (s, " }");
|
|
|
|
return g_string_free (s, FALSE);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize_list (GValue * dest, const char *s)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("unimplemented");
|
2003-12-23 20:58:05 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************/
|
2003-11-24 02:09:23 +00:00
|
|
|
/* fourcc */
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_value_init_fourcc (GValue * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
value->data[0].v_int = 0;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_copy_fourcc (const GValue * src_value, GValue * dest_value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
dest_value->data[0].v_int = src_value->data[0].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_collect_fourcc (GValue * value, guint n_collect_values,
|
|
|
|
GTypeCValue * collect_values, guint collect_flags)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
value->data[0].v_int = collect_values[0].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_lcopy_fourcc (const GValue * value, guint n_collect_values,
|
|
|
|
GTypeCValue * collect_values, guint collect_flags)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
guint32 *fourcc_p = collect_values[0].v_pointer;
|
|
|
|
|
|
|
|
if (!fourcc_p)
|
|
|
|
return g_strdup_printf ("value location for `%s' passed as NULL",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_VALUE_TYPE_NAME (value));
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
*fourcc_p = value->data[0].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_set_fourcc:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_FOURCC
|
|
|
|
* @fourcc: the fourcc to set
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Sets @value to @fourcc.
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-03 09:10:07 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_set_fourcc (GValue * value, guint32 fourcc)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_VALUE_HOLDS_FOURCC (value));
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
value->data[0].v_int = fourcc;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_get_fourcc:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_FOURCC
|
|
|
|
*
|
|
|
|
* Gets the fourcc contained in @value.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Returns: the fourcc contained in @value.
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-03 09:10:07 +00:00
|
|
|
guint32
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_get_fourcc (const GValue * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_FOURCC (value), 0);
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
return value->data[0].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_transform_fourcc_string (const GValue * src_value,
|
|
|
|
GValue * dest_value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
|
|
|
guint32 fourcc = src_value->data[0].v_int;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (g_ascii_isprint ((fourcc >> 0) & 0xff) &&
|
|
|
|
g_ascii_isprint ((fourcc >> 8) & 0xff) &&
|
|
|
|
g_ascii_isprint ((fourcc >> 16) & 0xff) &&
|
|
|
|
g_ascii_isprint ((fourcc >> 24) & 0xff)) {
|
|
|
|
dest_value->data[0].v_pointer =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_strdup_printf (GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
|
2003-12-23 20:58:05 +00:00
|
|
|
} else {
|
2004-03-13 15:27:01 +00:00
|
|
|
dest_value->data[0].v_pointer = g_strdup_printf ("0x%08x", fourcc);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare_fourcc (const GValue * value1, const GValue * value2)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
if (value2->data[0].v_int == value1->data[0].v_int)
|
|
|
|
return GST_VALUE_EQUAL;
|
2003-12-23 20:58:05 +00:00
|
|
|
return GST_VALUE_UNORDERED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize_fourcc (const GValue * value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
guint32 fourcc = value->data[0].v_int;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (g_ascii_isalnum ((fourcc >> 0) & 0xff) &&
|
|
|
|
g_ascii_isalnum ((fourcc >> 8) & 0xff) &&
|
|
|
|
g_ascii_isalnum ((fourcc >> 16) & 0xff) &&
|
|
|
|
g_ascii_isalnum ((fourcc >> 24) & 0xff)) {
|
|
|
|
return g_strdup_printf (GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
} else {
|
2004-03-13 15:27:01 +00:00
|
|
|
return g_strdup_printf ("0x%08x", fourcc);
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
}
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize_fourcc (GValue * dest, const char *s)
|
2003-12-23 20:58:05 +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
2004-01-29 01:20:23 +00:00
|
|
|
gboolean ret = FALSE;
|
|
|
|
guint32 fourcc = 0;
|
|
|
|
char *end;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (strlen (s) == 4) {
|
|
|
|
fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
|
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
2004-01-29 01:20:23 +00:00
|
|
|
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;
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************/
|
2003-11-03 09:10:07 +00:00
|
|
|
/* int range */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_value_init_int_range (GValue * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
value->data[0].v_int = 0;
|
|
|
|
value->data[1].v_int = 0;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_copy_int_range (const GValue * src_value, GValue * dest_value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
dest_value->data[0].v_int = src_value->data[0].v_int;
|
|
|
|
dest_value->data[1].v_int = src_value->data[1].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_collect_int_range (GValue * value, guint n_collect_values,
|
|
|
|
GTypeCValue * collect_values, guint collect_flags)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
/* FIXME */
|
|
|
|
value->data[0].v_int = collect_values[0].v_int;
|
|
|
|
value->data[1].v_int = collect_values[1].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_lcopy_int_range (const GValue * value, guint n_collect_values,
|
|
|
|
GTypeCValue * collect_values, guint collect_flags)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
guint32 *int_range_start = collect_values[0].v_pointer;
|
|
|
|
guint32 *int_range_end = collect_values[1].v_pointer;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
if (!int_range_start)
|
|
|
|
return g_strdup_printf ("start value location for `%s' passed as NULL",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_VALUE_TYPE_NAME (value));
|
2003-12-22 01:39:35 +00:00
|
|
|
if (!int_range_end)
|
|
|
|
return g_strdup_printf ("end value location for `%s' passed as NULL",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_VALUE_TYPE_NAME (value));
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
*int_range_start = value->data[0].v_int;
|
|
|
|
*int_range_end = value->data[1].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_set_int_range:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_INT_RANGE
|
|
|
|
* @start: the start of the range
|
|
|
|
* @end: the end of the range
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Sets @value to the range specified by @start and @end.
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-03 09:10:07 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_set_int_range (GValue * value, int start, int end)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_if_fail (GST_VALUE_HOLDS_INT_RANGE (value));
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
value->data[0].v_int = start;
|
|
|
|
value->data[1].v_int = end;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_get_int_range_min:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_INT_RANGE
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Gets the minimum of the range specified by @value.
|
|
|
|
*
|
|
|
|
* Returns: the minumum of the range
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-03 09:10:07 +00:00
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_get_int_range_min (const GValue * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_INT_RANGE (value), 0);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
return value->data[0].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_get_int_range_max:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_INT_RANGE
|
|
|
|
*
|
|
|
|
* Gets the maximum of the range specified by @value.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Returns: the maxumum of the range
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-03 09:10:07 +00:00
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_get_int_range_max (const GValue * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_INT_RANGE (value), 0);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
return value->data[1].v_int;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_transform_int_range_string (const GValue * src_value,
|
|
|
|
GValue * dest_value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
dest_value->data[0].v_pointer = g_strdup_printf ("[%d,%d]",
|
|
|
|
(int) src_value->data[0].v_int, (int) src_value->data[1].v_int);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare_int_range (const GValue * value1, const GValue * value2)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
|
|
|
if (value2->data[0].v_int == value1->data[0].v_int &&
|
2004-03-13 15:27:01 +00:00
|
|
|
value2->data[0].v_int == value1->data[0].v_int)
|
|
|
|
return GST_VALUE_EQUAL;
|
2003-12-23 20:58:05 +00:00
|
|
|
return GST_VALUE_UNORDERED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize_int_range (const GValue * value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
return g_strdup_printf ("[ %d, %d ]", value->data[0].v_int,
|
|
|
|
value->data[1].v_int);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize_int_range (GValue * dest, const char *s)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("unimplemented");
|
2003-12-23 20:58:05 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************/
|
2003-11-24 02:09:23 +00:00
|
|
|
/* double range */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_value_init_double_range (GValue * value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
value->data[0].v_double = 0;
|
|
|
|
value->data[1].v_double = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_copy_double_range (const GValue * src_value, GValue * dest_value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
dest_value->data[0].v_double = src_value->data[0].v_double;
|
|
|
|
dest_value->data[1].v_double = src_value->data[1].v_double;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_collect_double_range (GValue * value, guint n_collect_values,
|
|
|
|
GTypeCValue * collect_values, guint collect_flags)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
value->data[0].v_double = collect_values[0].v_double;
|
|
|
|
value->data[1].v_double = collect_values[1].v_double;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_lcopy_double_range (const GValue * value, guint n_collect_values,
|
|
|
|
GTypeCValue * collect_values, guint collect_flags)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
gdouble *double_range_start = collect_values[0].v_pointer;
|
|
|
|
gdouble *double_range_end = collect_values[1].v_pointer;
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
if (!double_range_start)
|
|
|
|
return g_strdup_printf ("start value location for `%s' passed as NULL",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_VALUE_TYPE_NAME (value));
|
2003-12-22 01:39:35 +00:00
|
|
|
if (!double_range_end)
|
|
|
|
return g_strdup_printf ("end value location for `%s' passed as NULL",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_VALUE_TYPE_NAME (value));
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
*double_range_start = value->data[0].v_double;
|
|
|
|
*double_range_end = value->data[1].v_double;
|
2003-11-24 02:09:23 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_set_double_range:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_DOUBLE_RANGE
|
|
|
|
* @start: the start of the range
|
|
|
|
* @end: the end of the range
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Sets @value to the range specified by @start and @end.
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-24 02:09:23 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_set_double_range (GValue * value, double start, double end)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value));
|
|
|
|
|
|
|
|
value->data[0].v_double = start;
|
|
|
|
value->data[1].v_double = end;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_get_double_range_min:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_DOUBLE_RANGE
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Gets the minimum of the range specified by @value.
|
|
|
|
*
|
|
|
|
* Returns: the minumum of the range
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-24 02:09:23 +00:00
|
|
|
double
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_get_double_range_min (const GValue * value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value), 0);
|
|
|
|
|
|
|
|
return value->data[0].v_double;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_get_double_range_max:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_DOUBLE_RANGE
|
|
|
|
*
|
|
|
|
* Gets the maximum of the range specified by @value.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Returns: the maxumum of the range
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-24 02:09:23 +00:00
|
|
|
double
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_get_double_range_max (const GValue * value)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value), 0);
|
|
|
|
|
|
|
|
return value->data[1].v_double;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_transform_double_range_string (const GValue * src_value,
|
|
|
|
GValue * dest_value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
char s1[G_ASCII_DTOSTR_BUF_SIZE], s2[G_ASCII_DTOSTR_BUF_SIZE];
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dest_value->data[0].v_pointer = g_strdup_printf ("[%s,%s]",
|
2003-12-23 20:58:05 +00:00
|
|
|
g_ascii_dtostr (s1, G_ASCII_DTOSTR_BUF_SIZE,
|
2004-03-15 19:27:17 +00:00
|
|
|
src_value->data[0].v_double),
|
2003-12-23 20:58:05 +00:00
|
|
|
g_ascii_dtostr (s2, G_ASCII_DTOSTR_BUF_SIZE,
|
2004-03-15 19:27:17 +00:00
|
|
|
src_value->data[1].v_double));
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare_double_range (const GValue * value1, const GValue * value2)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
|
|
|
if (value2->data[0].v_double == value1->data[0].v_double &&
|
|
|
|
value2->data[0].v_double == value1->data[0].v_double)
|
|
|
|
return GST_VALUE_EQUAL;
|
|
|
|
return GST_VALUE_UNORDERED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize_double_range (const GValue * value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
char d1[G_ASCII_DTOSTR_BUF_SIZE];
|
|
|
|
char d2[G_ASCII_DTOSTR_BUF_SIZE];
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
g_ascii_dtostr (d1, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double);
|
|
|
|
g_ascii_dtostr (d2, G_ASCII_DTOSTR_BUF_SIZE, value->data[1].v_double);
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
return g_strdup_printf ("[ %s, %s ]", d1, d2);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize_double_range (GValue * dest, const char *s)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("unimplemented");
|
2003-12-23 20:58:05 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************/
|
2003-11-29 06:31:10 +00:00
|
|
|
/* GstCaps */
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_set_caps:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_CAPS
|
|
|
|
* @caps: the caps to set the value to
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Sets the contents of @value to coorespond to @caps. The actual
|
|
|
|
* #GstCaps structure is copied before it is used.
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-29 06:31:10 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_set_caps (GValue * value, const GstCaps * caps)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
2004-02-20 00:38:24 +00:00
|
|
|
g_return_if_fail (G_VALUE_TYPE (value) == GST_TYPE_CAPS);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-02-20 00:38:24 +00:00
|
|
|
g_value_set_boxed (value, caps);
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_get_caps:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value: a GValue initialized to GST_TYPE_CAPS
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Gets the contents of @value.
|
|
|
|
*
|
|
|
|
* Returns: the contents of @value
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-12-22 01:39:35 +00:00
|
|
|
const GstCaps *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_get_caps (const GValue * value)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
2004-02-20 00:38:24 +00:00
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (value) == GST_TYPE_CAPS, NULL);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-02-20 00:38:24 +00:00
|
|
|
return (GstCaps *) g_value_get_boxed (value);
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/*************************************/
|
|
|
|
/* boolean */
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare_boolean (const GValue * value1, const GValue * value2)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
if ((value1->data[0].v_int != 0) == (value2->data[0].v_int != 0))
|
2003-12-23 20:58:05 +00:00
|
|
|
return GST_VALUE_EQUAL;
|
|
|
|
return GST_VALUE_UNORDERED;
|
|
|
|
}
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static char *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize_boolean (const GValue * value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
if (value->data[0].v_int) {
|
|
|
|
return g_strdup ("true");
|
|
|
|
}
|
|
|
|
return g_strdup ("false");
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize_boolean (GValue * dest, const char *s)
|
2003-11-03 09:10:07 +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
2004-01-29 01:20:23 +00:00
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
if (g_ascii_strcasecmp (s, "true") == 0 ||
|
|
|
|
g_ascii_strcasecmp (s, "yes") == 0 ||
|
2004-03-13 15:27:01 +00:00
|
|
|
g_ascii_strcasecmp (s, "t") == 0 || strcmp (s, "1") == 0) {
|
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
2004-01-29 01:20:23 +00:00
|
|
|
g_value_set_boolean (dest, TRUE);
|
|
|
|
ret = TRUE;
|
|
|
|
} else if (g_ascii_strcasecmp (s, "false") == 0 ||
|
|
|
|
g_ascii_strcasecmp (s, "no") == 0 ||
|
2004-03-13 15:27:01 +00:00
|
|
|
g_ascii_strcasecmp (s, "f") == 0 || strcmp (s, "0") == 0) {
|
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
2004-01-29 01:20:23 +00:00
|
|
|
g_value_set_boolean (dest, FALSE);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
2004-03-13 15:27:01 +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
2004-01-29 01:20:23 +00:00
|
|
|
return ret;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/*************************************/
|
|
|
|
/* int */
|
|
|
|
|
|
|
|
static int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare_int (const GValue * value1, const GValue * value2)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
2003-12-23 20:58:05 +00:00
|
|
|
if (value1->data[0].v_int > value2->data[0].v_int)
|
|
|
|
return GST_VALUE_GREATER_THAN;
|
|
|
|
if (value1->data[0].v_int < value2->data[0].v_int)
|
|
|
|
return GST_VALUE_LESS_THAN;
|
|
|
|
return GST_VALUE_EQUAL;
|
|
|
|
}
|
2003-12-22 19:28:07 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static char *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize_int (const GValue * value)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
return g_strdup_printf ("%d", value->data[0].v_int);
|
2003-11-29 06:31:10 +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
2004-01-29 01:20:23 +00:00
|
|
|
static int
|
|
|
|
gst_strtoi (const char *s, char **end, int base)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (s[0] == '-') {
|
2004-03-13 15:27:01 +00:00
|
|
|
i = -(int) strtoul (s + 1, end, base);
|
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
2004-01-29 01:20:23 +00:00
|
|
|
} else {
|
|
|
|
i = strtoul (s, end, base);
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize_int (GValue * dest, const char *s)
|
2003-11-29 06:31:10 +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
2004-01-29 01:20:23 +00:00
|
|
|
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;
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/*************************************/
|
|
|
|
/* double */
|
2003-11-04 19:00:54 +00:00
|
|
|
|
|
|
|
static int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare_double (const GValue * value1, const GValue * value2)
|
2003-11-04 19:00:54 +00:00
|
|
|
{
|
2003-11-24 02:09:23 +00:00
|
|
|
if (value1->data[0].v_double > value2->data[0].v_double)
|
|
|
|
return GST_VALUE_GREATER_THAN;
|
|
|
|
if (value1->data[0].v_double < value2->data[0].v_double)
|
|
|
|
return GST_VALUE_LESS_THAN;
|
|
|
|
if (value1->data[0].v_double == value2->data[0].v_double)
|
|
|
|
return GST_VALUE_EQUAL;
|
|
|
|
return GST_VALUE_UNORDERED;
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static char *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize_double (const GValue * value)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
char d[G_ASCII_DTOSTR_BUF_SIZE];
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
g_ascii_dtostr (d, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double);
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
return g_strdup (d);
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize_double (GValue * dest, const char *s)
|
2003-11-29 06:31:10 +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
2004-01-29 01:20:23 +00:00
|
|
|
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;
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/*************************************/
|
|
|
|
/* string */
|
2003-11-29 06:31:10 +00:00
|
|
|
|
|
|
|
static int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare_string (const GValue * value1, const GValue * value2)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
int x = strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer);
|
|
|
|
|
|
|
|
if (x < 0)
|
|
|
|
return GST_VALUE_LESS_THAN;
|
|
|
|
if (x > 0)
|
|
|
|
return GST_VALUE_GREATER_THAN;
|
2003-11-29 06:31:10 +00:00
|
|
|
return GST_VALUE_EQUAL;
|
|
|
|
}
|
|
|
|
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
#define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
|
|
|
|
((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
|
|
|
|
((c) == '.'))
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gst_string_wrap (const char *s)
|
|
|
|
{
|
|
|
|
const gchar *t;
|
|
|
|
int len;
|
|
|
|
gchar *d, *e;
|
|
|
|
gboolean wrap = FALSE;
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
t = s;
|
|
|
|
while (*t) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (GST_ASCII_IS_STRING (*t)) {
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
len++;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (*t < 0x20 || *t >= 0x7f) {
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
wrap = TRUE;
|
|
|
|
len += 4;
|
|
|
|
} else {
|
|
|
|
wrap = TRUE;
|
|
|
|
len += 2;
|
|
|
|
}
|
|
|
|
t++;
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!wrap)
|
|
|
|
return strdup (s);
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
e = d = g_malloc (len + 3);
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
|
|
|
|
*e++ = '\"';
|
|
|
|
t = s;
|
|
|
|
while (*t) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (GST_ASCII_IS_STRING (*t)) {
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
*e++ = *t++;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (*t < 0x20 || *t >= 0x7f) {
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
*e++ = '\\';
|
2004-03-13 15:27:01 +00:00
|
|
|
*e++ = '0' + ((*t) >> 6);
|
|
|
|
*e++ = '0' + (((*t) >> 3) & 0x7);
|
|
|
|
*e++ = '0' + ((*t++) & 0x7);
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
} else {
|
|
|
|
*e++ = '\\';
|
|
|
|
*e++ = *t++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*e++ = '\"';
|
|
|
|
*e = 0;
|
|
|
|
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static char *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize_string (const GValue * value)
|
2003-11-04 19:00:54 +00:00
|
|
|
{
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
return gst_string_wrap (value->data[0].v_pointer);
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize_string (GValue * dest, const char *s)
|
2003-11-04 19:00:54 +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
2004-01-29 01:20:23 +00:00
|
|
|
g_value_set_string (dest, s);
|
|
|
|
|
|
|
|
return TRUE;
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/*************************************/
|
|
|
|
/* unions */
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/*************************************/
|
2003-11-04 19:00:54 +00:00
|
|
|
/* intersection */
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_intersect_int_int_range (GValue * dest, const GValue * src1,
|
|
|
|
const GValue * src2)
|
2003-11-04 19:00:54 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (src1) == G_TYPE_INT, FALSE);
|
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_INT_RANGE, FALSE);
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
if (src2->data[0].v_int <= src1->data[0].v_int &&
|
2004-03-13 15:27:01 +00:00
|
|
|
src2->data[1].v_int >= src1->data[0].v_int) {
|
2003-12-22 07:00:25 +00:00
|
|
|
gst_value_init_and_copy (dest, src1);
|
2003-11-04 19:00:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_intersect_int_range_int_range (GValue * dest, const GValue * src1,
|
|
|
|
const GValue * src2)
|
2003-11-04 19:00:54 +00:00
|
|
|
{
|
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (src1) == GST_TYPE_INT_RANGE, FALSE);
|
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_INT_RANGE, FALSE);
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
min = MAX (src1->data[0].v_int, src2->data[0].v_int);
|
|
|
|
max = MIN (src1->data[1].v_int, src2->data[1].v_int);
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (min < max) {
|
|
|
|
g_value_init (dest, GST_TYPE_INT_RANGE);
|
|
|
|
gst_value_set_int_range (dest, min, max);
|
2003-11-04 19:00:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
if (min == max) {
|
|
|
|
g_value_init (dest, G_TYPE_INT);
|
|
|
|
g_value_set_int (dest, min);
|
2003-11-04 19:00:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_intersect_double_double_range (GValue * dest, const GValue * src1,
|
|
|
|
const GValue * src2)
|
2003-12-22 01:39:35 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (src1) == G_TYPE_DOUBLE, FALSE);
|
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_DOUBLE_RANGE, FALSE);
|
2003-12-22 01:39:35 +00:00
|
|
|
|
|
|
|
if (src2->data[0].v_double <= src1->data[0].v_double &&
|
2004-03-13 15:27:01 +00:00
|
|
|
src2->data[1].v_double >= src1->data[0].v_double) {
|
2003-12-22 07:00:25 +00:00
|
|
|
gst_value_init_and_copy (dest, src1);
|
2003-12-22 01:39:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_intersect_double_range_double_range (GValue * dest,
|
|
|
|
const GValue * src1, const GValue * src2)
|
2003-12-22 01:39:35 +00:00
|
|
|
{
|
|
|
|
double min;
|
|
|
|
double max;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (src1) == GST_TYPE_DOUBLE_RANGE, FALSE);
|
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_DOUBLE_RANGE, FALSE);
|
2003-12-22 01:39:35 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
min = MAX (src1->data[0].v_double, src2->data[0].v_double);
|
|
|
|
max = MIN (src1->data[1].v_double, src2->data[1].v_double);
|
2003-12-22 01:39:35 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (min < max) {
|
|
|
|
g_value_init (dest, GST_TYPE_DOUBLE_RANGE);
|
|
|
|
gst_value_set_double_range (dest, min, max);
|
2003-12-22 01:39:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
if (min == max) {
|
|
|
|
g_value_init (dest, G_TYPE_DOUBLE);
|
|
|
|
g_value_set_int (dest, min);
|
2003-12-22 01:39:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_intersect_list (GValue * dest, const GValue * value1,
|
|
|
|
const GValue * value2)
|
2003-12-22 01:39:35 +00:00
|
|
|
{
|
|
|
|
guint i, size;
|
|
|
|
GValue intersection = { 0, };
|
|
|
|
gboolean ret = FALSE;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value1), FALSE);
|
|
|
|
|
|
|
|
size = gst_value_list_get_size (value1);
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
const GValue *cur = gst_value_list_get_value (value1, i);
|
|
|
|
|
|
|
|
if (gst_value_intersect (&intersection, cur, value2)) {
|
|
|
|
/* append value */
|
|
|
|
if (!ret) {
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_value_init_and_copy (dest, &intersection);
|
|
|
|
ret = TRUE;
|
2003-12-22 01:39:35 +00:00
|
|
|
} else if (GST_VALUE_HOLDS_LIST (dest)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_value_list_append_value (dest, &intersection);
|
2003-12-22 01:39:35 +00:00
|
|
|
} else {
|
2004-03-15 19:27:17 +00:00
|
|
|
GValue temp = { 0, };
|
2003-12-22 01:39:35 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_value_init_and_copy (&temp, dest);
|
|
|
|
g_value_unset (dest);
|
|
|
|
gst_value_list_concat (dest, &temp, &intersection);
|
2003-12-22 01:39:35 +00:00
|
|
|
}
|
|
|
|
g_value_unset (&intersection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
|
|
|
|
/*************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_can_compare:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value1: a value to compare
|
|
|
|
* @value2: another value to compare
|
|
|
|
*
|
|
|
|
* Determines if @value1 and @value2 can be compared.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Returns: TRUE if the values can be compared
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_can_compare (const GValue * value1, const GValue * value2)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
|
|
|
GstValueTable *table;
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
|
|
|
|
return FALSE;
|
|
|
|
for (i = 0; i < gst_value_table->len; i++) {
|
|
|
|
table = &g_array_index (gst_value_table, GstValueTable, i);
|
|
|
|
if (table->type == G_VALUE_TYPE (value1) && table->compare)
|
|
|
|
return TRUE;
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_compare:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value1: a value to compare
|
|
|
|
* @value2: another value to compare
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Compares @value1 and @value2. If @value1 and @value2 cannot be
|
|
|
|
* compared, the function returns GST_VALUE_UNORDERED. Otherwise,
|
|
|
|
* if @value1 is greater than @value2, GST_VALUE_GREATER is returned.
|
|
|
|
* If @value1 is less than @value2, GST_VALUE_LESSER is returned.
|
|
|
|
* If the values are equal, GST_VALUE_EQUAL is returned.
|
|
|
|
*
|
|
|
|
* Returns: A GstValueCompareType value
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_compare (const GValue * value1, const GValue * value2)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
|
|
|
GstValueTable *table;
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
|
|
|
|
return GST_VALUE_UNORDERED;
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < gst_value_table->len; i++) {
|
|
|
|
table = &g_array_index (gst_value_table, GstValueTable, i);
|
|
|
|
if (table->type != G_VALUE_TYPE (value1) || table->compare == NULL)
|
|
|
|
continue;
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return table->compare (value1, value2);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_critical ("unable to compare values of type %s\n",
|
2003-12-23 20:58:05 +00:00
|
|
|
g_type_name (G_VALUE_TYPE (value1)));
|
|
|
|
return GST_VALUE_UNORDERED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* union */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_can_union:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @value1: a value to union
|
|
|
|
* @value2: another value to union
|
|
|
|
*
|
|
|
|
* Determines if @value1 and @value2 can be non-trivially unioned.
|
|
|
|
* Any two values can be trivially unioned by adding both of them
|
|
|
|
* to a GstValueList. However, certain types have the possibility
|
|
|
|
* to be unioned in a simpler way. For example, an integer range
|
|
|
|
* and an integer can be unioned if the integer is a subset of the
|
|
|
|
* integer range. If there is the possibility that two values can
|
|
|
|
* be unioned, this function returns TRUE.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Returns: TRUE if there is a function allowing the two values to
|
|
|
|
* be unioned.
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_can_union (const GValue * value1, const GValue * value2)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
|
|
|
GstValueUnionInfo *union_info;
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < gst_value_union_funcs->len; i++) {
|
|
|
|
union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i);
|
|
|
|
if (union_info->type1 == G_VALUE_TYPE (value1) &&
|
2004-03-15 19:27:17 +00:00
|
|
|
union_info->type2 == G_VALUE_TYPE (value2))
|
2004-03-13 15:27:01 +00:00
|
|
|
return TRUE;
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_union:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @dest: the destination value
|
|
|
|
* @value1: a value to union
|
|
|
|
* @value2: another value to union
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Creates a GValue cooresponding to the union of @value1 and @value2.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the values could be unioned
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_union (GValue * dest, const GValue * value1, const GValue * value2)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
|
|
|
GstValueUnionInfo *union_info;
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < gst_value_union_funcs->len; i++) {
|
|
|
|
union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i);
|
|
|
|
if (union_info->type1 == G_VALUE_TYPE (value1) &&
|
2004-03-15 19:27:17 +00:00
|
|
|
union_info->type2 == G_VALUE_TYPE (value2)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
return union_info->func (dest, value1, value2);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value_list_concat (dest, value1, value2);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_register_union_func:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @type1: a type to union
|
|
|
|
* @type2: another type to union
|
|
|
|
* @func: a function that implments creating a union between the two types
|
|
|
|
*
|
|
|
|
* Registers a union function that can create a union between GValues
|
|
|
|
* of the type @type1 and @type2.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_value_register_union_func (GType type1, GType type2, GstValueUnionFunc func)
|
|
|
|
{
|
|
|
|
GstValueUnionInfo union_info;
|
|
|
|
|
|
|
|
union_info.type1 = type1;
|
|
|
|
union_info.type2 = type2;
|
|
|
|
union_info.func = func;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_array_append_val (gst_value_union_funcs, union_info);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* intersection */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_can_intersect:
|
|
|
|
*
|
|
|
|
*/
|
2003-11-04 19:00:54 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_can_intersect (const GValue * value1, const GValue * value2)
|
2003-11-04 19:00:54 +00:00
|
|
|
{
|
|
|
|
GstValueIntersectInfo *intersect_info;
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
/* special cases */
|
2004-03-13 15:27:01 +00:00
|
|
|
if (GST_VALUE_HOLDS_LIST (value1) || GST_VALUE_HOLDS_LIST (value2))
|
2003-12-22 01:39:35 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < gst_value_intersect_funcs->len; i++) {
|
|
|
|
intersect_info = &g_array_index (gst_value_intersect_funcs,
|
2004-03-15 19:27:17 +00:00
|
|
|
GstValueIntersectInfo, i);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (intersect_info->type1 == G_VALUE_TYPE (value1) &&
|
2004-03-15 19:27:17 +00:00
|
|
|
intersect_info->type2 == G_VALUE_TYPE (value2))
|
2004-03-13 15:27:01 +00:00
|
|
|
return TRUE;
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
return gst_value_can_compare (value1, value2);
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_intersect:
|
2004-03-26 03:46:16 +00:00
|
|
|
* @dest: the destination value for intersection
|
|
|
|
* @value1: a value to intersect
|
|
|
|
* @value2: another value to intersect
|
|
|
|
*
|
|
|
|
* Calculates the intersection of the two values.
|
2003-12-23 20:58:05 +00:00
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Returns: TRUE if the intersection is non-empty
|
2003-12-23 20:58:05 +00:00
|
|
|
*/
|
2003-11-24 02:09:23 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_intersect (GValue * dest, const GValue * value1,
|
|
|
|
const GValue * value2)
|
2003-11-04 19:00:54 +00:00
|
|
|
{
|
|
|
|
GstValueIntersectInfo *intersect_info;
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2003-11-29 06:31:10 +00:00
|
|
|
int ret = FALSE;
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
/* special cases first */
|
|
|
|
if (GST_VALUE_HOLDS_LIST (value1))
|
|
|
|
return gst_value_intersect_list (dest, value1, value2);
|
|
|
|
if (GST_VALUE_HOLDS_LIST (value2))
|
|
|
|
return gst_value_intersect_list (dest, value2, value1);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
for (i = 0; i < gst_value_intersect_funcs->len; i++) {
|
|
|
|
intersect_info = &g_array_index (gst_value_intersect_funcs,
|
2004-03-15 19:27:17 +00:00
|
|
|
GstValueIntersectInfo, i);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (intersect_info->type1 == G_VALUE_TYPE (value1) &&
|
2004-03-15 19:27:17 +00:00
|
|
|
intersect_info->type2 == G_VALUE_TYPE (value2)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
ret = intersect_info->func (dest, value1, value2);
|
2003-12-22 01:39:35 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
if (intersect_info->type1 == G_VALUE_TYPE (value2) &&
|
2004-03-15 19:27:17 +00:00
|
|
|
intersect_info->type2 == G_VALUE_TYPE (value1)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
ret = intersect_info->func (dest, value2, value1);
|
2003-11-29 06:31:10 +00:00
|
|
|
return ret;
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL) {
|
2003-12-22 07:00:25 +00:00
|
|
|
gst_value_init_and_copy (dest, value1);
|
2003-11-29 06:31:10 +00:00
|
|
|
ret = TRUE;
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
2003-11-29 06:31:10 +00:00
|
|
|
return ret;
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_register_intersection_func:
|
|
|
|
*
|
|
|
|
*/
|
2003-11-04 19:00:54 +00:00
|
|
|
void
|
|
|
|
gst_value_register_intersect_func (GType type1, GType type2,
|
|
|
|
GstValueIntersectFunc func)
|
|
|
|
{
|
|
|
|
GstValueIntersectInfo intersect_info;
|
|
|
|
|
|
|
|
intersect_info.type1 = type1;
|
|
|
|
intersect_info.type2 = type2;
|
|
|
|
intersect_info.func = func;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_array_append_val (gst_value_intersect_funcs, intersect_info);
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
/**
|
|
|
|
* gst_value_register:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_register (const GstValueTable * table)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_array_append_val (gst_value_table, *table);
|
2003-12-23 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_init_and_copy:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_init_and_copy (GValue * dest, const GValue * src)
|
2003-12-23 20:58:05 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_value_init (dest, G_VALUE_TYPE (src));
|
2003-12-23 20:58:05 +00:00
|
|
|
g_value_copy (src, dest);
|
|
|
|
}
|
|
|
|
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
/**
|
|
|
|
* gst_value_serialize:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_serialize (const GValue * value)
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
{
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
GValue s_val = { 0 };
|
|
|
|
GstValueTable *table;
|
|
|
|
char *s;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < gst_value_table->len; i++) {
|
|
|
|
table = &g_array_index (gst_value_table, GstValueTable, i);
|
|
|
|
if (table->type != G_VALUE_TYPE (value) || table->serialize == NULL)
|
|
|
|
continue;
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return table->serialize (value);
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init (&s_val, G_TYPE_STRING);
|
|
|
|
g_value_transform (value, &s_val);
|
|
|
|
s = gst_string_wrap (g_value_get_string (&s_val));
|
|
|
|
g_value_unset (&s_val);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_value_deserialize:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_deserialize (GValue * dest, const gchar * src)
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +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
2004-01-29 01:20:23 +00:00
|
|
|
GstValueTable *table;
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
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
2004-01-29 01:20:23 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
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;
|
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
2004-01-29 01:20:23 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return table->deserialize (dest, src);
|
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
2004-01-29 01:20:23 +00:00
|
|
|
}
|
|
|
|
|
gst/gststructure.c: Convert function to use gst_value_serialize().
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_to_string):
Convert function to use gst_value_serialize().
* gst/gstvalue.c: (gst_value_serialize_list),
(gst_value_serialize_fourcc), (gst_value_serialize_int_range),
(gst_value_serialize_double_range), (gst_value_serialize_boolean),
(gst_value_serialize_int), (gst_value_serialize_double),
(gst_string_wrap), (gst_value_serialize_string),
(gst_value_serialize), (gst_value_deserialize):
* gst/gstvalue.h:
Add implementations for serialize.
2004-01-20 09:14:25 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
void
|
|
|
|
_gst_value_initialize (void)
|
|
|
|
{
|
|
|
|
GTypeInfo info = {
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
//const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_table = g_array_new (FALSE, FALSE, sizeof (GstValueTable));
|
|
|
|
gst_value_union_funcs = g_array_new (FALSE, FALSE,
|
|
|
|
sizeof (GstValueUnionInfo));
|
|
|
|
gst_value_intersect_funcs = g_array_new (FALSE, FALSE,
|
|
|
|
sizeof (GstValueIntersectInfo));
|
2003-12-23 20:58:05 +00:00
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
static const GTypeValueTable value_table = {
|
|
|
|
gst_value_init_fourcc,
|
|
|
|
NULL,
|
|
|
|
gst_value_copy_fourcc,
|
|
|
|
NULL,
|
|
|
|
"i",
|
|
|
|
gst_value_collect_fourcc,
|
|
|
|
"p",
|
|
|
|
gst_value_lcopy_fourcc
|
|
|
|
};
|
2003-12-23 20:58:05 +00:00
|
|
|
static GstValueTable gst_value = {
|
|
|
|
0,
|
|
|
|
gst_value_compare_fourcc,
|
|
|
|
gst_value_serialize_fourcc,
|
|
|
|
gst_value_deserialize_fourcc,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
info.value_table = &value_table;
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_fourcc =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_type_register_static (G_TYPE_BOXED, "GstFourcc", &info, 0);
|
2003-12-23 21:22:38 +00:00
|
|
|
gst_value.type = gst_type_fourcc;
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value_register (&gst_value);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static const GTypeValueTable value_table = {
|
|
|
|
gst_value_init_int_range,
|
|
|
|
NULL,
|
|
|
|
gst_value_copy_int_range,
|
|
|
|
NULL,
|
2003-12-22 01:39:35 +00:00
|
|
|
"ii",
|
2003-11-03 09:10:07 +00:00
|
|
|
gst_value_collect_int_range,
|
2003-12-22 01:39:35 +00:00
|
|
|
"pp",
|
2003-11-03 09:10:07 +00:00
|
|
|
gst_value_lcopy_int_range
|
|
|
|
};
|
2003-12-23 20:58:05 +00:00
|
|
|
static GstValueTable gst_value = {
|
|
|
|
0,
|
|
|
|
gst_value_compare_int_range,
|
|
|
|
gst_value_serialize_int_range,
|
|
|
|
gst_value_deserialize_int_range,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
info.value_table = &value_table;
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_int_range =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_type_register_static (G_TYPE_BOXED, "GstIntRange", &info, 0);
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value.type = gst_type_int_range;
|
|
|
|
gst_value_register (&gst_value);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
static const GTypeValueTable value_table = {
|
|
|
|
gst_value_init_double_range,
|
|
|
|
NULL,
|
|
|
|
gst_value_copy_double_range,
|
|
|
|
NULL,
|
2003-12-22 01:39:35 +00:00
|
|
|
"dd",
|
2003-11-24 02:09:23 +00:00
|
|
|
gst_value_collect_double_range,
|
2003-12-22 01:39:35 +00:00
|
|
|
"pp",
|
2003-11-24 02:09:23 +00:00
|
|
|
gst_value_lcopy_double_range
|
|
|
|
};
|
2003-12-23 20:58:05 +00:00
|
|
|
static GstValueTable gst_value = {
|
|
|
|
0,
|
|
|
|
gst_value_compare_double_range,
|
|
|
|
gst_value_serialize_double_range,
|
|
|
|
gst_value_deserialize_double_range,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
info.value_table = &value_table;
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_double_range =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_type_register_static (G_TYPE_BOXED, "GstDoubleRange", &info, 0);
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value.type = gst_type_double_range;
|
|
|
|
gst_value_register (&gst_value);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
static const GTypeValueTable value_table = {
|
|
|
|
gst_value_init_list,
|
|
|
|
gst_value_free_list,
|
|
|
|
gst_value_copy_list,
|
|
|
|
gst_value_list_peek_pointer,
|
|
|
|
"p",
|
|
|
|
gst_value_collect_list,
|
|
|
|
"p",
|
|
|
|
gst_value_lcopy_list
|
|
|
|
};
|
2003-12-23 20:58:05 +00:00
|
|
|
static GstValueTable gst_value = {
|
|
|
|
0,
|
|
|
|
gst_value_compare_list,
|
|
|
|
gst_value_serialize_list,
|
|
|
|
gst_value_deserialize_list,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
info.value_table = &value_table;
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_list =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_type_register_static (G_TYPE_BOXED, "GstValueList", &info, 0);
|
2003-12-23 21:22:38 +00:00
|
|
|
gst_value.type = gst_type_list;
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value_register (&gst_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static const GstValueTable gst_value = {
|
|
|
|
G_TYPE_INT,
|
|
|
|
gst_value_compare_int,
|
|
|
|
gst_value_serialize_int,
|
|
|
|
gst_value_deserialize_int,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value_register (&gst_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static const GstValueTable gst_value = {
|
|
|
|
G_TYPE_DOUBLE,
|
|
|
|
gst_value_compare_double,
|
|
|
|
gst_value_serialize_double,
|
|
|
|
gst_value_deserialize_double,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value_register (&gst_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static const GstValueTable gst_value = {
|
|
|
|
G_TYPE_STRING,
|
|
|
|
gst_value_compare_string,
|
|
|
|
gst_value_serialize_string,
|
|
|
|
gst_value_deserialize_string,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value_register (&gst_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static const GstValueTable gst_value = {
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
gst_value_compare_boolean,
|
|
|
|
gst_value_serialize_boolean,
|
|
|
|
gst_value_deserialize_boolean,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-12-23 20:58:05 +00:00
|
|
|
gst_value_register (&gst_value);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
g_value_register_transform_func (GST_TYPE_FOURCC, G_TYPE_STRING,
|
|
|
|
gst_value_transform_fourcc_string);
|
|
|
|
g_value_register_transform_func (GST_TYPE_INT_RANGE, G_TYPE_STRING,
|
|
|
|
gst_value_transform_int_range_string);
|
2003-11-29 06:31:10 +00:00
|
|
|
g_value_register_transform_func (GST_TYPE_DOUBLE_RANGE, G_TYPE_STRING,
|
|
|
|
gst_value_transform_double_range_string);
|
|
|
|
g_value_register_transform_func (GST_TYPE_LIST, G_TYPE_STRING,
|
|
|
|
gst_value_transform_list_string);
|
2003-11-04 19:00:54 +00:00
|
|
|
|
|
|
|
gst_value_register_intersect_func (G_TYPE_INT, GST_TYPE_INT_RANGE,
|
|
|
|
gst_value_intersect_int_int_range);
|
|
|
|
gst_value_register_intersect_func (GST_TYPE_INT_RANGE, GST_TYPE_INT_RANGE,
|
|
|
|
gst_value_intersect_int_range_int_range);
|
2003-12-22 01:39:35 +00:00
|
|
|
gst_value_register_intersect_func (G_TYPE_DOUBLE, GST_TYPE_DOUBLE_RANGE,
|
|
|
|
gst_value_intersect_double_double_range);
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_register_intersect_func (GST_TYPE_DOUBLE_RANGE,
|
|
|
|
GST_TYPE_DOUBLE_RANGE, gst_value_intersect_double_range_double_range);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|