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>
30 * @a: the first character
31 * @b: the second character
32 * @c: the third character
33 * @d: the fourth character
35 * Transform four characters into a #guint32 fourcc value with host
39 * guint32 fourcc = GST_MAKE_FOURCC ('M', 'J', 'P', 'G');
43 #define GST_MAKE_FOURCC(a,b,c,d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24)
47 * @f: a string with at least four characters
49 * Transform an input string into a #guint32 fourcc value with host
51 * Caller is responsible for ensuring the input string consists of at least
55 * guint32 fourcc = GST_STR_FOURCC ("MJPG");
59 #define GST_STR_FOURCC(f) (guint32)(((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24))
64 * Can be used together with #GST_FOURCC_ARGS to properly output a
65 * #guint32 fourcc value in a printf()-style text message.
68 * printf ("fourcc: %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (fcc));
72 #define GST_FOURCC_FORMAT "%c%c%c%c"
76 * @fourcc: a #guint32 fourcc value to output
78 * Can be used together with #GST_FOURCC_FORMAT to properly output a
79 * #guint32 fourcc value in a printf()-style text message.
81 #define GST_FOURCC_ARGS(fourcc) \
82 ((gchar) ((fourcc) &0xff)), \
83 ((gchar) (((fourcc)>>8 )&0xff)), \
84 ((gchar) (((fourcc)>>16)&0xff)), \
85 ((gchar) (((fourcc)>>24)&0xff))
88 * GST_VALUE_HOLDS_FOURCC:
89 * @x: the #GValue to check
91 * Checks if the given #GValue contains a #GST_TYPE_FOURCC value.
93 #define GST_VALUE_HOLDS_FOURCC(x) (G_VALUE_HOLDS(x, gst_type_fourcc))
96 * GST_VALUE_HOLDS_INT_RANGE:
97 * @x: the #GValue to check
99 * Checks if the given #GValue contains a #GST_TYPE_INT_RANGE value.
101 #define GST_VALUE_HOLDS_INT_RANGE(x) (G_VALUE_HOLDS(x, gst_type_int_range))
104 * GST_VALUE_HOLDS_DOUBLE_RANGE:
105 * @x: the #GValue to check
107 * Checks if the given #GValue contains a #GST_TYPE_DOUBLE_RANGE value.
109 #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS(x, gst_type_double_range))
112 * GST_VALUE_HOLDS_LIST:
113 * @x: the #GValue to check
115 * Checks if the given #GValue contains a #GST_TYPE_LIST value.
117 #define GST_VALUE_HOLDS_LIST(x) (G_VALUE_HOLDS(x, gst_type_list))
120 * GST_VALUE_HOLDS_ARRAY:
121 * @x: the #GValue to check
123 * Checks if the given #GValue contains a #GST_TYPE_ARRAY value.
125 #define GST_VALUE_HOLDS_ARRAY(x) (G_VALUE_HOLDS(x, gst_type_array))
128 * GST_VALUE_HOLDS_CAPS:
129 * @x: the #GValue to check
131 * Checks if the given #GValue contains a #GST_TYPE_CAPS value.
133 #define GST_VALUE_HOLDS_CAPS(x) (G_VALUE_HOLDS(x, GST_TYPE_CAPS))
136 * GST_VALUE_HOLDS_BUFFER:
137 * @x: the #GValue to check
139 * Checks if the given #GValue contains a #GST_TYPE_BUFFER value.
141 #define GST_VALUE_HOLDS_BUFFER(x) (G_VALUE_HOLDS(x, GST_TYPE_BUFFER))
144 * GST_VALUE_HOLDS_FRACTION:
145 * @x: the #GValue to check
147 * Checks if the given #GValue contains a #GST_TYPE_FRACTION value.
149 #define GST_VALUE_HOLDS_FRACTION(x) (G_VALUE_HOLDS(x, gst_type_fraction))
154 * a #GValue type that represents 4 byte identifier (e.g. used for codecs)
156 * Returns: the #GType of GstFourcc
158 #define GST_TYPE_FOURCC gst_type_fourcc
161 * GST_TYPE_INT_RANGE:
163 * a #GValue type that represents an integer range
165 * Returns: the #GType of GstIntRange
167 #define GST_TYPE_INT_RANGE gst_type_int_range
170 * GST_TYPE_DOUBLE_RANGE:
172 * a #GValue type that represents a floating point range with double precission
174 * Returns: the #GType of GstIntRange
176 #define GST_TYPE_DOUBLE_RANGE gst_type_double_range
181 * a #GValue type that represents an unordered list of #GValue values
183 * Returns: the #GType of GstValueList (which is not explicitly typed)
185 #define GST_TYPE_LIST gst_type_list
190 * a #GValue type that represents an ordered list of #GValue values
192 * Returns: the #GType of GstArrayList (which is not explicitly typed)
194 #define GST_TYPE_ARRAY gst_type_array
199 * a #GValue type that represents a fraction of an integer numerator over
200 * an integer denominator
202 * Returns: the #GType of GstFraction (which is not explicitly typed)
205 #define GST_TYPE_FRACTION gst_type_fraction
209 * GST_VALUE_LESS_THAN:
211 * Indicates that the first value provided to a comparison function
212 * (gst_value_compare()) is lesser than the second one.
214 #define GST_VALUE_LESS_THAN (-1)
219 * Indicates that the first value provided to a comparison function
220 * (gst_value_compare()) is equal to the second one.
222 #define GST_VALUE_EQUAL 0
225 * GST_VALUE_GREATER_THAN:
227 * Indicates that the first value provided to a comparison function
228 * (gst_value_compare()) is greater than the second one.
230 #define GST_VALUE_GREATER_THAN 1
233 * GST_VALUE_UNORDERED:
235 * Indicates that the comparison function (gst_value_compare()) can not
236 * determine a order for the two provided values.
238 #define GST_VALUE_UNORDERED 2
241 * GstValueCompareFunc:
242 * @value1: first value for comparission
243 * @value2: second value for comparission
245 * Used together with gst_value_compare() to compare #GValues.
247 * Returns: one of GST_VALUE_LESS_THAN, GST_VALUE_EQUAL, GST_VALUE_GREATER_THAN
248 * or GST_VALUE_UNORDERED
250 typedef int (* GstValueCompareFunc) (const GValue *value1,
251 const GValue *value2);
253 typedef char * (* GstValueSerializeFunc) (const GValue *value1);
255 typedef gboolean (* GstValueDeserializeFunc) (GValue *dest,
258 typedef int (* GstValueUnionFunc) (GValue *dest,
259 const GValue *value1,
260 const GValue *value2);
262 typedef int (* GstValueIntersectFunc) (GValue *dest,
263 const GValue *value1,
264 const GValue *value2);
266 typedef int (* GstValueSubtractFunc) (GValue *dest,
267 const GValue *minuend,
268 const GValue *subtrahend);
270 typedef struct _GstValueTable GstValueTable;
271 struct _GstValueTable {
273 GstValueCompareFunc compare;
274 GstValueSerializeFunc serialize;
275 GstValueDeserializeFunc deserialize;
278 void *_gst_reserved [GST_PADDING];
281 GST_EXPORT GType gst_type_fourcc;
282 GST_EXPORT GType gst_type_int_range;
283 GST_EXPORT GType gst_type_double_range;
284 GST_EXPORT GType gst_type_list;
285 GST_EXPORT GType gst_type_array;
286 GST_EXPORT GType gst_type_fraction;
288 void gst_value_register (const GstValueTable *table);
289 void gst_value_init_and_copy (GValue *dest,
292 gchar * gst_value_serialize (const GValue *value);
293 gboolean gst_value_deserialize (GValue *dest,
297 void gst_value_list_append_value (GValue *value,
298 const GValue *append_value);
299 void gst_value_list_prepend_value (GValue *value,
300 const GValue *prepend_value);
301 void gst_value_list_concat (GValue *dest,
302 const GValue *value1,
303 const GValue *value2);
304 guint gst_value_list_get_size (const GValue *value);
305 G_CONST_RETURN GValue *
306 gst_value_list_get_value (const GValue *value,
310 void gst_value_set_fourcc (GValue *value,
312 guint32 gst_value_get_fourcc (const GValue *value);
315 void gst_value_set_int_range (GValue *value,
318 int gst_value_get_int_range_min (const GValue *value);
319 int gst_value_get_int_range_max (const GValue *value);
322 void gst_value_set_double_range (GValue *value,
325 double gst_value_get_double_range_min (const GValue *value);
326 double gst_value_get_double_range_max (const GValue *value);
329 G_CONST_RETURN GstCaps *
330 gst_value_get_caps (const GValue *value);
331 void gst_value_set_caps (GValue *value,
332 const GstCaps *caps);
335 void gst_value_set_fraction (GValue *value,
338 int gst_value_get_fraction_numerator (const GValue *value);
339 int gst_value_get_fraction_denominator(const GValue *value);
340 gboolean gst_value_fraction_multiply (GValue *product,
341 const GValue *factor1,
342 const GValue *factor2);
345 int gst_value_compare (const GValue *value1,
346 const GValue *value2);
347 gboolean gst_value_can_compare (const GValue *value1,
348 const GValue *value2);
351 gboolean gst_value_union (GValue *dest,
352 const GValue *value1,
353 const GValue *value2);
354 gboolean gst_value_can_union (const GValue *value1,
355 const GValue *value2);
356 void gst_value_register_union_func (GType type1,
358 GstValueUnionFunc func);
361 gboolean gst_value_intersect (GValue *dest,
362 const GValue *value1,
363 const GValue *value2);
364 gboolean gst_value_can_intersect (const GValue *value1,
365 const GValue *value2);
366 void gst_value_register_intersect_func (GType type1,
368 GstValueIntersectFunc func);
371 gboolean gst_value_subtract (GValue *dest,
372 const GValue *minuend,
373 const GValue *subtrahend);
374 gboolean gst_value_can_subtract (const GValue *minuend,
375 const GValue *subtrahend);
376 void gst_value_register_subtract_func (GType minuend_type,
377 GType subtrahend_type,
378 GstValueSubtractFunc func);
381 gboolean gst_value_is_fixed (const GValue *value);
384 void _gst_value_initialize (void);