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., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef __GST_VALUE_H__
21 #define __GST_VALUE_H__
23 #include <gst/gstconfig.h>
24 #include <gst/gstcaps.h>
25 #include <gst/gststructure.h>
31 * @a: the first character
32 * @b: the second character
33 * @c: the third character
34 * @d: the fourth character
36 * Transform four characters into a #guint32 fourcc value with host
40 * guint32 fourcc = GST_MAKE_FOURCC ('M', 'J', 'P', 'G');
44 #define GST_MAKE_FOURCC(a,b,c,d) ((guint32)((a)|(b)<<8|(c)<<16|(d)<<24))
48 * @f: a string with at least four characters
50 * Transform an input string into a #guint32 fourcc value with host
52 * Caller is responsible for ensuring the input string consists of at least
56 * guint32 fourcc = GST_STR_FOURCC ("MJPG");
60 #define GST_STR_FOURCC(f) ((guint32)(((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24)))
65 * Can be used together with #GST_FOURCC_ARGS to properly output a
66 * #guint32 fourcc value in a printf()-style text message.
69 * printf ("fourcc: %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (fcc));
73 #define GST_FOURCC_FORMAT "c%c%c%c"
77 * @fourcc: a #guint32 fourcc value to output
79 * Can be used together with #GST_FOURCC_FORMAT to properly output a
80 * #guint32 fourcc value in a printf()-style text message.
82 #define GST_FOURCC_ARGS(fourcc) \
83 ((gchar) ((fourcc) &0xff)), \
84 ((gchar) (((fourcc)>>8 )&0xff)), \
85 ((gchar) (((fourcc)>>16)&0xff)), \
86 ((gchar) (((fourcc)>>24)&0xff))
89 * GST_VALUE_HOLDS_INT_RANGE:
90 * @x: the #GValue to check
92 * Checks if the given #GValue contains a #GST_TYPE_INT_RANGE value.
94 #define GST_VALUE_HOLDS_INT_RANGE(x) (G_VALUE_HOLDS((x), gst_int_range_get_type ()))
97 * GST_VALUE_HOLDS_INT64_RANGE:
98 * @x: the #GValue to check
100 * Checks if the given #GValue contains a #GST_TYPE_INT64_RANGE value.
102 #define GST_VALUE_HOLDS_INT64_RANGE(x) (G_VALUE_HOLDS((x), gst_int64_range_get_type ()))
105 * GST_VALUE_HOLDS_DOUBLE_RANGE:
106 * @x: the #GValue to check
108 * Checks if the given #GValue contains a #GST_TYPE_DOUBLE_RANGE value.
110 #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS((x), gst_double_range_get_type ()))
113 * GST_VALUE_HOLDS_FRACTION_RANGE:
114 * @x: the #GValue to check
116 * Checks if the given #GValue contains a #GST_TYPE_FRACTION_RANGE value.
118 #define GST_VALUE_HOLDS_FRACTION_RANGE(x) (G_VALUE_HOLDS((x), gst_fraction_range_get_type ()))
121 * GST_VALUE_HOLDS_LIST:
122 * @x: the #GValue to check
124 * Checks if the given #GValue contains a #GST_TYPE_LIST value.
126 #define GST_VALUE_HOLDS_LIST(x) (G_VALUE_HOLDS((x), gst_value_list_get_type ()))
129 * GST_VALUE_HOLDS_ARRAY:
130 * @x: the #GValue to check
132 * Checks if the given #GValue contains a #GST_TYPE_ARRAY value.
134 #define GST_VALUE_HOLDS_ARRAY(x) (G_VALUE_HOLDS((x), gst_value_array_get_type ()))
137 * GST_VALUE_HOLDS_CAPS:
138 * @x: the #GValue to check
140 * Checks if the given #GValue contains a #GST_TYPE_CAPS value.
142 #define GST_VALUE_HOLDS_CAPS(x) (G_VALUE_HOLDS((x), GST_TYPE_CAPS))
145 * GST_VALUE_HOLDS_STRUCTURE:
146 * @x: the #GValue to check
148 * Checks if the given #GValue contains a #GST_TYPE_STRUCTURE value.
150 #define GST_VALUE_HOLDS_STRUCTURE(x) (G_VALUE_HOLDS((x), GST_TYPE_STRUCTURE))
153 * GST_VALUE_HOLDS_BUFFER:
154 * @x: the #GValue to check
156 * Checks if the given #GValue contains a #GST_TYPE_BUFFER value.
158 #define GST_VALUE_HOLDS_BUFFER(x) (G_VALUE_HOLDS((x), GST_TYPE_BUFFER))
161 * GST_VALUE_HOLDS_SAMPLE:
162 * @x: the #GValue to check
164 * Checks if the given #GValue contains a #GST_TYPE_SAMPLE value.
166 #define GST_VALUE_HOLDS_SAMPLE(x) (G_VALUE_HOLDS((x), GST_TYPE_SAMPLE))
169 * GST_VALUE_HOLDS_FRACTION:
170 * @x: the #GValue to check
172 * Checks if the given #GValue contains a #GST_TYPE_FRACTION value.
174 #define GST_VALUE_HOLDS_FRACTION(x) (G_VALUE_HOLDS((x), gst_fraction_get_type ()))
177 * GST_VALUE_HOLDS_DATE_TIME:
178 * @x: the #GValue to check
180 * Checks if the given #GValue contains a #GST_TYPE_DATE_TIME value.
182 #define GST_VALUE_HOLDS_DATE_TIME(x) (G_VALUE_HOLDS((x), gst_date_time_get_type ()))
185 * GST_VALUE_HOLDS_BITMASK:
186 * @x: the #GValue to check
188 * Checks if the given #GValue contains a #GST_TYPE_BITMASK value.
190 #define GST_VALUE_HOLDS_BITMASK(x) (G_VALUE_HOLDS((x), gst_bitmask_get_type ()))
193 * GST_TYPE_INT_RANGE:
195 * a #GValue type that represents an integer range
197 * Returns: the #GType of GstIntRange
199 #define GST_TYPE_INT_RANGE gst_int_range_get_type ()
202 * GST_TYPE_INT64_RANGE:
204 * a #GValue type that represents an #gint64 range
206 * Returns: the #GType of GstInt64Range
208 #define GST_TYPE_INT64_RANGE gst_int64_range_get_type ()
211 * GST_TYPE_DOUBLE_RANGE:
213 * a #GValue type that represents a floating point range with double precission
215 * Returns: the #GType of GstIntRange
217 #define GST_TYPE_DOUBLE_RANGE gst_double_range_get_type ()
220 * GST_TYPE_FRACTION_RANGE:
222 * a #GValue type that represents a GstFraction range
224 * Returns: the #GType of GstFractionRange
226 #define GST_TYPE_FRACTION_RANGE gst_fraction_range_get_type ()
231 * a #GValue type that represents an unordered list of #GValue values. This
232 * is used for example to express a list of possible values for a field in
233 * a caps structure, like a list of possible sample rates, of which only one
234 * will be chosen in the end. This means that all values in the list are
235 * meaningful on their own.
237 * Returns: the #GType of GstValueList (which is not explicitly typed)
239 #define GST_TYPE_LIST gst_value_list_get_type ()
244 * a #GValue type that represents an ordered list of #GValue values. This is
245 * used to express a set of values that is meaningful only in their specific
246 * combination and order of values. Each value on its own is not particularly
247 * meaningful, only the ordered array in its entirety is meaningful. This is
248 * used for example to express channel layouts for multichannel audio where
249 * each channel needs to be mapped to a position in the room.
251 * Returns: the #GType of GstArrayList (which is not explicitly typed)
253 #define GST_TYPE_ARRAY gst_value_array_get_type ()
258 * a #GValue type that represents a fraction of an integer numerator over
259 * an integer denominator
261 * Returns: the #GType of GstFraction (which is not explicitly typed)
264 #define GST_TYPE_FRACTION gst_fraction_get_type ()
267 * GST_TYPE_DATE_TIME:
269 * a boxed #GValue type for #GstDateTime that represents a date and time.
271 * Returns: the #GType of GstDateTime
274 #define GST_TYPE_DATE_TIME gst_date_time_get_type ()
279 * a #GValue type that represents a 64-bit bitmask.
281 * Returns: the #GType of GstBitmask (which is not explicitly typed)
284 #define GST_TYPE_BITMASK gst_bitmask_get_type ()
289 * a boxed #GValue type for #GThread that represents a thread.
291 * Returns: the #GType of GstGThread
294 #define GST_TYPE_G_THREAD gst_g_thread_get_type ()
297 * GST_VALUE_LESS_THAN:
299 * Indicates that the first value provided to a comparison function
300 * (gst_value_compare()) is lesser than the second one.
302 #define GST_VALUE_LESS_THAN (-1)
307 * Indicates that the first value provided to a comparison function
308 * (gst_value_compare()) is equal to the second one.
310 #define GST_VALUE_EQUAL 0
313 * GST_VALUE_GREATER_THAN:
315 * Indicates that the first value provided to a comparison function
316 * (gst_value_compare()) is greater than the second one.
318 #define GST_VALUE_GREATER_THAN 1
321 * GST_VALUE_UNORDERED:
323 * Indicates that the comparison function (gst_value_compare()) can not
324 * determine a order for the two provided values.
326 #define GST_VALUE_UNORDERED 2
329 * GstValueCompareFunc:
330 * @value1: first value for comparison
331 * @value2: second value for comparison
333 * Used together with gst_value_compare() to compare #GValue items.
335 * Returns: one of GST_VALUE_LESS_THAN, GST_VALUE_EQUAL, GST_VALUE_GREATER_THAN
336 * or GST_VALUE_UNORDERED
338 typedef gint (* GstValueCompareFunc) (const GValue *value1,
339 const GValue *value2);
342 * GstValueSerializeFunc:
345 * Used by gst_value_serialize() to obtain a non-binary form of the #GValue.
347 * Free-function: g_free
349 * Returns: (transfer full): the string representation of the value
351 typedef gchar * (* GstValueSerializeFunc) (const GValue *value1);
354 * GstValueDeserializeFunc:
358 * Used by gst_value_deserialize() to parse a non-binary form into the #GValue.
360 * Returns: %TRUE for success
362 typedef gboolean (* GstValueDeserializeFunc) (GValue *dest,
365 typedef struct _GstValueTable GstValueTable;
369 * @compare: a #GstValueCompareFunc
370 * @serialize: a #GstValueSerializeFunc
371 * @deserialize: a #GstValueDeserializeFunc
373 * VTable for the #GValue @type.
375 struct _GstValueTable {
377 GstValueCompareFunc compare;
378 GstValueSerializeFunc serialize;
379 GstValueDeserializeFunc deserialize;
382 gpointer _gst_reserved [GST_PADDING];
385 GType gst_int_range_get_type (void);
386 GType gst_int64_range_get_type (void);
387 GType gst_double_range_get_type (void);
388 GType gst_fraction_range_get_type (void);
389 GType gst_fraction_get_type (void);
390 GType gst_value_list_get_type (void);
391 GType gst_value_array_get_type (void);
392 GType gst_bitmask_get_type (void);
394 /* Hide this compatibility type from introspection */
395 #ifndef __GI_SCANNER__
396 GType gst_g_thread_get_type (void);
399 GType gst_date_time_get_type (void);
401 void gst_value_register (const GstValueTable *table);
402 void gst_value_init_and_copy (GValue *dest,
405 gchar * gst_value_serialize (const GValue *value) G_GNUC_MALLOC;
406 gboolean gst_value_deserialize (GValue *dest,
410 void gst_value_list_append_value (GValue *value,
411 const GValue *append_value);
412 void gst_value_list_prepend_value (GValue *value,
413 const GValue *prepend_value);
414 void gst_value_list_concat (GValue *dest,
415 const GValue *value1,
416 const GValue *value2);
417 void gst_value_list_merge (GValue *dest,
418 const GValue *value1,
419 const GValue *value2);
420 guint gst_value_list_get_size (const GValue *value);
421 const GValue * gst_value_list_get_value (const GValue *value,
425 void gst_value_array_append_value (GValue *value,
426 const GValue *append_value);
427 void gst_value_array_prepend_value (GValue *value,
428 const GValue *prepend_value);
429 guint gst_value_array_get_size (const GValue *value);
430 const GValue * gst_value_array_get_value (const GValue *value,
434 void gst_value_set_int_range (GValue *value,
437 void gst_value_set_int_range_step (GValue *value,
441 gint gst_value_get_int_range_min (const GValue *value);
442 gint gst_value_get_int_range_max (const GValue *value);
443 gint gst_value_get_int_range_step (const GValue *value);
446 void gst_value_set_int64_range (GValue *value,
449 void gst_value_set_int64_range_step (GValue *value,
453 gint64 gst_value_get_int64_range_min (const GValue *value);
454 gint64 gst_value_get_int64_range_max (const GValue *value);
455 gint64 gst_value_get_int64_range_step (const GValue *value);
458 void gst_value_set_double_range (GValue *value,
461 gdouble gst_value_get_double_range_min (const GValue *value);
462 gdouble gst_value_get_double_range_max (const GValue *value);
465 const GstCaps * gst_value_get_caps (const GValue *value);
466 void gst_value_set_caps (GValue *value,
467 const GstCaps *caps);
471 gst_value_get_structure (const GValue *value);
472 void gst_value_set_structure (GValue *value,
473 const GstStructure *structure);
476 void gst_value_set_fraction (GValue *value,
479 gint gst_value_get_fraction_numerator (const GValue *value);
480 gint gst_value_get_fraction_denominator (const GValue *value);
481 gboolean gst_value_fraction_multiply (GValue *product,
482 const GValue *factor1,
483 const GValue *factor2);
484 gboolean gst_value_fraction_subtract (GValue * dest,
485 const GValue * minuend,
486 const GValue * subtrahend);
489 void gst_value_set_fraction_range (GValue *value,
492 void gst_value_set_fraction_range_full (GValue *value,
493 gint numerator_start,
494 gint denominator_start,
496 gint denominator_end);
497 const GValue *gst_value_get_fraction_range_min (const GValue *value);
498 const GValue *gst_value_get_fraction_range_max (const GValue *value);
501 guint64 gst_value_get_bitmask (const GValue *value);
502 void gst_value_set_bitmask (GValue *value,
506 gint gst_value_compare (const GValue *value1,
507 const GValue *value2);
508 gboolean gst_value_can_compare (const GValue *value1,
509 const GValue *value2);
510 gboolean gst_value_is_subset (const GValue *value1,
511 const GValue *value2);
514 gboolean gst_value_union (GValue *dest,
515 const GValue *value1,
516 const GValue *value2);
517 gboolean gst_value_can_union (const GValue *value1,
518 const GValue *value2);
521 gboolean gst_value_intersect (GValue *dest,
522 const GValue *value1,
523 const GValue *value2);
524 gboolean gst_value_can_intersect (const GValue *value1,
525 const GValue *value2);
528 gboolean gst_value_subtract (GValue *dest,
529 const GValue *minuend,
530 const GValue *subtrahend);
531 gboolean gst_value_can_subtract (const GValue *minuend,
532 const GValue *subtrahend);
535 gboolean gst_value_is_fixed (const GValue *value);
536 gboolean gst_value_fixate (GValue *dest,