2 * Copyright (C) <2003> David A. Schleef <ds@schleef.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __GST_VALUE_H__
21 #define __GST_VALUE_H__
23 #include <gst/gstconfig.h>
24 #include <gst/gstcaps.h>
28 typedef int (* GstValueCompareFunc) (const GValue *value1,
29 const GValue *value2);
30 typedef char * (* GstValueSerializeFunc) (const GValue *value1);
31 typedef gboolean (* GstValueDeserializeFunc) (GValue *dest, const char *s);
32 typedef int (* GstValueUnionFunc) (GValue *dest, const GValue *value1,
33 const GValue *value2);
34 typedef int (* GstValueIntersectFunc) (GValue *dest, const GValue *value1,
35 const GValue *value2);
37 typedef struct _GstValueTable GstValueTable;
38 struct _GstValueTable {
40 GstValueCompareFunc compare;
41 GstValueSerializeFunc serialize;
42 GstValueDeserializeFunc unserialize;
44 void *_gst_reserved [GST_PADDING];
48 #define GST_MAKE_FOURCC(a,b,c,d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24)
49 #define GST_STR_FOURCC(f) (guint32)(((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24))
51 #define GST_FOURCC_FORMAT "%c%c%c%c"
52 #define GST_FOURCC_ARGS(fourcc) \
53 ((gchar) ((fourcc) &0xff)), \
54 ((gchar) (((fourcc)>>8 )&0xff)), \
55 ((gchar) (((fourcc)>>16)&0xff)), \
56 ((gchar) (((fourcc)>>24)&0xff))
58 #define GST_VALUE_HOLDS_FOURCC(x) (G_VALUE_HOLDS(x, gst_type_fourcc))
59 #define GST_VALUE_HOLDS_INT_RANGE(x) (G_VALUE_HOLDS(x, gst_type_int_range))
60 #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS(x, gst_type_double_range))
61 #define GST_VALUE_HOLDS_LIST(x) (G_VALUE_HOLDS(x, gst_type_list))
62 #define GST_VALUE_HOLDS_CAPS(x) TRUE /* FIXME */
64 #define GST_TYPE_FOURCC gst_type_fourcc
65 #define GST_TYPE_INT_RANGE gst_type_int_range
66 #define GST_TYPE_DOUBLE_RANGE gst_type_double_range
67 #define GST_TYPE_LIST gst_type_list
69 #define GST_VALUE_LESS_THAN (-1)
70 #define GST_VALUE_EQUAL 0
71 #define GST_VALUE_GREATER_THAN 1
72 #define GST_VALUE_UNORDERED 2
74 extern GType gst_type_fourcc;
75 extern GType gst_type_int_range;
76 extern GType gst_type_double_range;
77 extern GType gst_type_list;
81 void gst_value_list_prepend_value (GValue *value, const GValue *prepend_value);
82 void gst_value_list_append_value (GValue *value, const GValue *append_value);
83 guint gst_value_list_get_size (const GValue *value);
84 G_CONST_RETURN GValue *gst_value_list_get_value (const GValue *value, guint index);
85 void gst_value_list_concat (GValue *dest, const GValue *value1, const GValue *value2);
89 void gst_value_set_fourcc (GValue *value, guint32 fourcc);
90 guint32 gst_value_get_fourcc (const GValue *value);
94 void gst_value_set_int_range (GValue *value, int start, int end);
95 int gst_value_get_int_range_min (const GValue *value);
96 int gst_value_get_int_range_max (const GValue *value);
100 void gst_value_set_double_range (GValue *value, double start, double end);
101 double gst_value_get_double_range_min (const GValue *value);
102 double gst_value_get_double_range_max (const GValue *value);
106 G_CONST_RETURN GstCaps *gst_value_get_caps (const GValue *value);
107 void gst_value_set_caps (GValue *calue, const GstCaps *caps);
111 gboolean gst_value_can_compare (const GValue *value1, const GValue *value2);
112 int gst_value_compare (const GValue *value1, const GValue *value2);
116 gboolean gst_value_can_union (const GValue *value1, const GValue *value2);
117 gboolean gst_value_union (GValue *dest, const GValue *value1, const GValue *value2);
118 void gst_value_register_union_func (GType type1, GType type2, GstValueUnionFunc func);
122 gboolean gst_value_can_intersect (const GValue *value1, const GValue *value2);
123 gboolean gst_value_intersect (GValue *dest, const GValue *value1, const GValue *value2);
124 void gst_value_register_intersect_func (GType type1, GType type2, GstValueIntersectFunc func);
128 void gst_value_register (const GstValueTable *table);
129 void gst_value_init_and_copy (GValue *dest, const GValue *src);
130 void _gst_value_initialize (void);
132 gchar * gst_value_serialize (const GValue *value);
133 gboolean gst_value_deserialize (GValue *dest, const gchar *src);