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 #define GST_MAKE_FOURCC(a,b,c,d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24)
29 #define GST_STR_FOURCC(f) (guint32)(((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24))
31 #define GST_FOURCC_FORMAT "%c%c%c%c"
32 #define GST_FOURCC_ARGS(fourcc) \
33 ((gchar) ((fourcc) &0xff)), \
34 ((gchar) (((fourcc)>>8 )&0xff)), \
35 ((gchar) (((fourcc)>>16)&0xff)), \
36 ((gchar) (((fourcc)>>24)&0xff))
38 #define GST_VALUE_HOLDS_FOURCC(x) (G_VALUE_HOLDS(x, gst_type_fourcc))
39 #define GST_VALUE_HOLDS_INT_RANGE(x) (G_VALUE_HOLDS(x, gst_type_int_range))
40 #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS(x, gst_type_double_range))
41 #define GST_VALUE_HOLDS_LIST(x) (G_VALUE_HOLDS(x, gst_type_list))
42 #define GST_VALUE_HOLDS_FIXED_LIST(x) (G_VALUE_HOLDS(x, gst_type_fixed_list))
43 #define GST_VALUE_HOLDS_CAPS(x) (G_VALUE_HOLDS(x, GST_TYPE_CAPS))
45 #define GST_TYPE_FOURCC gst_type_fourcc
46 #define GST_TYPE_INT_RANGE gst_type_int_range
47 #define GST_TYPE_DOUBLE_RANGE gst_type_double_range
48 #define GST_TYPE_LIST gst_type_list
49 #define GST_TYPE_FIXED_LIST gst_type_fixed_list
51 #define GST_VALUE_LESS_THAN (-1)
52 #define GST_VALUE_EQUAL 0
53 #define GST_VALUE_GREATER_THAN 1
54 #define GST_VALUE_UNORDERED 2
56 typedef int (* GstValueCompareFunc) (const GValue *value1,
57 const GValue *value2);
58 typedef char * (* GstValueSerializeFunc) (const GValue *value1);
59 typedef gboolean (* GstValueDeserializeFunc) (GValue *dest,
61 typedef int (* GstValueUnionFunc) (GValue *dest,
63 const GValue *value2);
64 typedef int (* GstValueIntersectFunc) (GValue *dest,
66 const GValue *value2);
67 typedef int (* GstValueSubtractFunc) (GValue *dest,
68 const GValue *minuend,
69 const GValue *subtrahend);
71 typedef struct _GstValueTable GstValueTable;
72 struct _GstValueTable {
74 GstValueCompareFunc compare;
75 GstValueSerializeFunc serialize;
76 GstValueDeserializeFunc deserialize;
78 void *_gst_reserved [GST_PADDING];
81 extern GType gst_type_fourcc;
82 extern GType gst_type_int_range;
83 extern GType gst_type_double_range;
84 extern GType gst_type_list;
85 extern GType gst_type_fixed_list;
87 void gst_value_register (const GstValueTable *table);
88 void gst_value_init_and_copy (GValue *dest,
91 gchar * gst_value_serialize (const GValue *value);
92 gboolean gst_value_deserialize (GValue *dest,
96 void gst_value_list_append_value (GValue *value,
97 const GValue *append_value);
98 void gst_value_list_prepend_value (GValue *value,
99 const GValue *prepend_value);
100 void gst_value_list_concat (GValue *dest,
101 const GValue *value1,
102 const GValue *value2);
103 guint gst_value_list_get_size (const GValue *value);
104 G_CONST_RETURN GValue * gst_value_list_get_value (const GValue *value,
108 void gst_value_set_fourcc (GValue *value,
110 guint32 gst_value_get_fourcc (const GValue *value);
113 void gst_value_set_int_range (GValue *value,
116 int gst_value_get_int_range_min (const GValue *value);
117 int gst_value_get_int_range_max (const GValue *value);
120 void gst_value_set_double_range (GValue *value,
123 double gst_value_get_double_range_min (const GValue *value);
124 double gst_value_get_double_range_max (const GValue *value);
127 G_CONST_RETURN GstCaps * gst_value_get_caps (const GValue *value);
128 void gst_value_set_caps (GValue *value,
129 const GstCaps *caps);
132 int gst_value_compare (const GValue *value1,
133 const GValue *value2);
134 gboolean gst_value_can_compare (const GValue *value1,
135 const GValue *value2);
138 gboolean gst_value_union (GValue *dest,
139 const GValue *value1,
140 const GValue *value2);
141 gboolean gst_value_can_union (const GValue *value1,
142 const GValue *value2);
143 void gst_value_register_union_func (GType type1,
145 GstValueUnionFunc func);
148 gboolean gst_value_intersect (GValue *dest,
149 const GValue *value1,
150 const GValue *value2);
151 gboolean gst_value_can_intersect (const GValue *value1,
152 const GValue *value2);
153 void gst_value_register_intersect_func (GType type1,
155 GstValueIntersectFunc func);
158 gboolean gst_value_subtract (GValue *dest,
159 const GValue *minuend,
160 const GValue *subtrahend);
161 gboolean gst_value_can_subtract (const GValue *minuend,
162 const GValue *subtrahend);
163 void gst_value_register_subtract_func (GType minuend_type,
164 GType subtrahend_type,
165 GstValueSubtractFunc func);
168 gboolean gst_type_is_fixed (GType type);
171 void _gst_value_initialize (void);