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>
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.
104 #define GST_VALUE_HOLDS_INT64_RANGE(x) (G_VALUE_HOLDS((x), gst_int64_range_get_type ()))
107 * GST_VALUE_HOLDS_DOUBLE_RANGE:
108 * @x: the #GValue to check
110 * Checks if the given #GValue contains a #GST_TYPE_DOUBLE_RANGE value.
112 #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS((x), gst_double_range_get_type ()))
115 * GST_VALUE_HOLDS_FRACTION_RANGE:
116 * @x: the #GValue to check
118 * Checks if the given #GValue contains a #GST_TYPE_FRACTION_RANGE value.
120 #define GST_VALUE_HOLDS_FRACTION_RANGE(x) (G_VALUE_HOLDS((x), gst_fraction_range_get_type ()))
123 * GST_VALUE_HOLDS_LIST:
124 * @x: the #GValue to check
126 * Checks if the given #GValue contains a #GST_TYPE_LIST value.
128 #define GST_VALUE_HOLDS_LIST(x) (G_VALUE_HOLDS((x), gst_value_list_get_type ()))
131 * GST_VALUE_HOLDS_ARRAY:
132 * @x: the #GValue to check
134 * Checks if the given #GValue contains a #GST_TYPE_ARRAY value.
136 #define GST_VALUE_HOLDS_ARRAY(x) (G_VALUE_HOLDS((x), gst_value_array_get_type ()))
139 * GST_VALUE_HOLDS_CAPS:
140 * @x: the #GValue to check
142 * Checks if the given #GValue contains a #GST_TYPE_CAPS value.
144 #define GST_VALUE_HOLDS_CAPS(x) (G_VALUE_HOLDS((x), GST_TYPE_CAPS))
147 * GST_VALUE_HOLDS_STRUCTURE:
148 * @x: the #GValue to check
150 * Checks if the given #GValue contains a #GST_TYPE_STRUCTURE value.
154 #define GST_VALUE_HOLDS_STRUCTURE(x) (G_VALUE_HOLDS((x), GST_TYPE_STRUCTURE))
157 * GST_VALUE_HOLDS_BUFFER:
158 * @x: the #GValue to check
160 * Checks if the given #GValue contains a #GST_TYPE_BUFFER value.
162 #define GST_VALUE_HOLDS_BUFFER(x) (G_VALUE_HOLDS((x), GST_TYPE_BUFFER))
165 * GST_VALUE_HOLDS_SAMPLE:
166 * @x: the #GValue to check
168 * Checks if the given #GValue contains a #GST_TYPE_SAMPLE value.
170 #define GST_VALUE_HOLDS_SAMPLE(x) (G_VALUE_HOLDS((x), GST_TYPE_SAMPLE))
173 * GST_VALUE_HOLDS_FRACTION:
174 * @x: the #GValue to check
176 * Checks if the given #GValue contains a #GST_TYPE_FRACTION value.
178 #define GST_VALUE_HOLDS_FRACTION(x) (G_VALUE_HOLDS((x), gst_fraction_get_type ()))
181 * GST_VALUE_HOLDS_DATE_TIME:
182 * @x: the #GValue to check
184 * Checks if the given #GValue contains a #GST_TYPE_DATE_TIME value.
188 #define GST_VALUE_HOLDS_DATE_TIME(x) (G_VALUE_HOLDS((x), gst_date_time_get_type ()))
191 * GST_VALUE_HOLDS_BITMASK:
192 * @x: the #GValue to check
194 * Checks if the given #GValue contains a #GST_TYPE_BITMASK value.
196 #define GST_VALUE_HOLDS_BITMASK(x) (G_VALUE_HOLDS((x), gst_bitmask_get_type ()))
199 * GST_TYPE_INT_RANGE:
201 * a #GValue type that represents an integer range
203 * Returns: the #GType of GstIntRange
205 #define GST_TYPE_INT_RANGE gst_int_range_get_type ()
208 * GST_TYPE_INT64_RANGE:
210 * a #GValue type that represents an #gint64 range
212 * Returns: the #GType of GstInt64Range
216 #define GST_TYPE_INT64_RANGE gst_int64_range_get_type ()
219 * GST_TYPE_DOUBLE_RANGE:
221 * a #GValue type that represents a floating point range with double precission
223 * Returns: the #GType of GstIntRange
225 #define GST_TYPE_DOUBLE_RANGE gst_double_range_get_type ()
228 * GST_TYPE_FRACTION_RANGE:
230 * a #GValue type that represents a GstFraction range
232 * Returns: the #GType of GstFractionRange
234 #define GST_TYPE_FRACTION_RANGE gst_fraction_range_get_type ()
239 * a #GValue type that represents an unordered list of #GValue values. This
240 * is used for example to express a list of possible values for a field in
241 * a caps structure, like a list of possible sample rates, of which only one
242 * will be chosen in the end. This means that all values in the list are
243 * meaningful on their own.
245 * Returns: the #GType of GstValueList (which is not explicitly typed)
247 #define GST_TYPE_LIST gst_value_list_get_type ()
252 * a #GValue type that represents an ordered list of #GValue values. This is
253 * used to express a set of values that is meaningful only in their specific
254 * combination and order of values. Each value on its own is not particularly
255 * meaningful, only the ordered array in its entirety is meaningful. This is
256 * used for example to express channel layouts for multichannel audio where
257 * each channel needs to be mapped to a position in the room.
259 * Returns: the #GType of GstArrayList (which is not explicitly typed)
261 #define GST_TYPE_ARRAY gst_value_array_get_type ()
266 * a #GValue type that represents a fraction of an integer numerator over
267 * an integer denominator
269 * Returns: the #GType of GstFraction (which is not explicitly typed)
272 #define GST_TYPE_FRACTION gst_fraction_get_type ()
275 * GST_TYPE_DATE_TIME:
277 * a boxed #GValue type for #GstDateTime that represents a date and time.
279 * Returns: the #GType of GstDateTime
283 #define GST_TYPE_DATE_TIME gst_date_time_get_type ()
288 * a #GValue type that represents a 64-bit bitmask.
290 * Returns: the #GType of GstBitmask (which is not explicitly typed)
293 #define GST_TYPE_BITMASK gst_bitmask_get_type ()
296 * GST_VALUE_LESS_THAN:
298 * Indicates that the first value provided to a comparison function
299 * (gst_value_compare()) is lesser than the second one.
301 #define GST_VALUE_LESS_THAN (-1)
306 * Indicates that the first value provided to a comparison function
307 * (gst_value_compare()) is equal to the second one.
309 #define GST_VALUE_EQUAL 0
312 * GST_VALUE_GREATER_THAN:
314 * Indicates that the first value provided to a comparison function
315 * (gst_value_compare()) is greater than the second one.
317 #define GST_VALUE_GREATER_THAN 1
320 * GST_VALUE_UNORDERED:
322 * Indicates that the comparison function (gst_value_compare()) can not
323 * determine a order for the two provided values.
325 #define GST_VALUE_UNORDERED 2
328 * GstValueCompareFunc:
329 * @value1: first value for comparison
330 * @value2: second value for comparison
332 * Used together with gst_value_compare() to compare #GValue items.
334 * Returns: one of GST_VALUE_LESS_THAN, GST_VALUE_EQUAL, GST_VALUE_GREATER_THAN
335 * or GST_VALUE_UNORDERED
337 typedef gint (* GstValueCompareFunc) (const GValue *value1,
338 const GValue *value2);
341 * GstValueSerializeFunc:
344 * Used by gst_value_serialize() to obtain a non-binary form of the #GValue.
346 * Free-function: g_free
348 * Returns: (transfer full): the string representation of the value
350 typedef gchar * (* GstValueSerializeFunc) (const GValue *value1);
353 * GstValueDeserializeFunc:
357 * Used by gst_value_deserialize() to parse a non-binary form into the #GValue.
359 * Returns: %TRUE for success
361 typedef gboolean (* GstValueDeserializeFunc) (GValue *dest,
364 typedef struct _GstValueTable GstValueTable;
368 * @compare: a #GstValueCompareFunc
369 * @serialize: a #GstValueSerializeFunc
370 * @deserialize: a #GstValueDeserializeFunc
372 * VTable for the #GValue @type.
374 struct _GstValueTable {
376 GstValueCompareFunc compare;
377 GstValueSerializeFunc serialize;
378 GstValueDeserializeFunc deserialize;
381 gpointer _gst_reserved [GST_PADDING];
384 GType gst_int_range_get_type (void);
385 GType gst_int64_range_get_type (void);
386 GType gst_double_range_get_type (void);
387 GType gst_fraction_range_get_type (void);
388 GType gst_fraction_get_type (void);
389 GType gst_value_list_get_type (void);
390 GType gst_value_array_get_type (void);
391 GType gst_bitmask_get_type (void);
393 GType gst_date_time_get_type (void);
395 void gst_value_register (const GstValueTable *table);
396 void gst_value_init_and_copy (GValue *dest,
399 gchar * gst_value_serialize (const GValue *value) G_GNUC_MALLOC;
400 gboolean gst_value_deserialize (GValue *dest,
404 void gst_value_list_append_value (GValue *value,
405 const GValue *append_value);
406 void gst_value_list_prepend_value (GValue *value,
407 const GValue *prepend_value);
408 void gst_value_list_concat (GValue *dest,
409 const GValue *value1,
410 const GValue *value2);
411 void gst_value_list_merge (GValue *dest,
412 const GValue *value1,
413 const GValue *value2);
414 guint gst_value_list_get_size (const GValue *value);
415 const GValue * gst_value_list_get_value (const GValue *value,
419 void gst_value_array_append_value (GValue *value,
420 const GValue *append_value);
421 void gst_value_array_prepend_value (GValue *value,
422 const GValue *prepend_value);
423 guint gst_value_array_get_size (const GValue *value);
424 const GValue * gst_value_array_get_value (const GValue *value,
428 void gst_value_set_int_range (GValue *value,
431 void gst_value_set_int_range_step (GValue *value,
435 gint gst_value_get_int_range_min (const GValue *value);
436 gint gst_value_get_int_range_max (const GValue *value);
437 gint gst_value_get_int_range_step (const GValue *value);
440 void gst_value_set_int64_range (GValue *value,
443 void gst_value_set_int64_range_step (GValue *value,
447 gint64 gst_value_get_int64_range_min (const GValue *value);
448 gint64 gst_value_get_int64_range_max (const GValue *value);
449 gint64 gst_value_get_int64_range_step (const GValue *value);
452 void gst_value_set_double_range (GValue *value,
455 gdouble gst_value_get_double_range_min (const GValue *value);
456 gdouble gst_value_get_double_range_max (const GValue *value);
459 const GstCaps * gst_value_get_caps (const GValue *value);
460 void gst_value_set_caps (GValue *value,
461 const GstCaps *caps);
465 gst_value_get_structure (const GValue *value);
466 void gst_value_set_structure (GValue *value,
467 const GstStructure *structure);
470 void gst_value_set_fraction (GValue *value,
473 gint gst_value_get_fraction_numerator (const GValue *value);
474 gint gst_value_get_fraction_denominator (const GValue *value);
475 gboolean gst_value_fraction_multiply (GValue *product,
476 const GValue *factor1,
477 const GValue *factor2);
478 gboolean gst_value_fraction_subtract (GValue * dest,
479 const GValue * minuend,
480 const GValue * subtrahend);
483 void gst_value_set_fraction_range (GValue *value,
486 void gst_value_set_fraction_range_full (GValue *value,
487 gint numerator_start,
488 gint denominator_start,
490 gint denominator_end);
491 const GValue *gst_value_get_fraction_range_min (const GValue *value);
492 const GValue *gst_value_get_fraction_range_max (const GValue *value);
495 guint64 gst_value_get_bitmask (const GValue *value);
496 void gst_value_set_bitmask (GValue *value,
500 gint gst_value_compare (const GValue *value1,
501 const GValue *value2);
502 gboolean gst_value_can_compare (const GValue *value1,
503 const GValue *value2);
504 gboolean gst_value_is_subset (const GValue *value1,
505 const GValue *value2);
508 gboolean gst_value_union (GValue *dest,
509 const GValue *value1,
510 const GValue *value2);
511 gboolean gst_value_can_union (const GValue *value1,
512 const GValue *value2);
515 gboolean gst_value_intersect (GValue *dest,
516 const GValue *value1,
517 const GValue *value2);
518 gboolean gst_value_can_intersect (const GValue *value1,
519 const GValue *value2);
522 gboolean gst_value_subtract (GValue *dest,
523 const GValue *minuend,
524 const GValue *subtrahend);
525 gboolean gst_value_can_subtract (const GValue *minuend,
526 const GValue *subtrahend);
529 gboolean gst_value_is_fixed (const GValue *value);
530 gboolean gst_value_fixate (GValue *dest,