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>
26 #include <gst/gstcapsfeatures.h>
32 * @a: the first character
33 * @b: the second character
34 * @c: the third character
35 * @d: the fourth character
37 * Transform four characters into a #guint32 fourcc value with host
41 * guint32 fourcc = GST_MAKE_FOURCC ('M', 'J', 'P', 'G');
45 #define GST_MAKE_FOURCC(a,b,c,d) ((guint32)((a)|(b)<<8|(c)<<16|(d)<<24))
49 * @f: a string with at least four characters
51 * Transform an input string into a #guint32 fourcc value with host
53 * Caller is responsible for ensuring the input string consists of at least
57 * guint32 fourcc = GST_STR_FOURCC ("MJPG");
61 #define GST_STR_FOURCC(f) ((guint32)(((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24)))
66 * Can be used together with #GST_FOURCC_ARGS to properly output a
67 * #guint32 fourcc value in a printf()-style text message.
70 * printf ("fourcc: %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (fcc));
74 #define GST_FOURCC_FORMAT "c%c%c%c"
78 * @fourcc: a #guint32 fourcc value to output
80 * Can be used together with #GST_FOURCC_FORMAT to properly output a
81 * #guint32 fourcc value in a printf()-style text message.
83 #define GST_FOURCC_ARGS(fourcc) \
84 ((gchar) ((fourcc) &0xff)), \
85 ((gchar) (((fourcc)>>8 )&0xff)), \
86 ((gchar) (((fourcc)>>16)&0xff)), \
87 ((gchar) (((fourcc)>>24)&0xff))
90 * GST_VALUE_HOLDS_INT_RANGE:
91 * @x: the #GValue to check
93 * Checks if the given #GValue contains a #GST_TYPE_INT_RANGE value.
95 #define GST_VALUE_HOLDS_INT_RANGE(x) (G_VALUE_HOLDS((x), gst_int_range_get_type ()))
98 * GST_VALUE_HOLDS_INT64_RANGE:
99 * @x: the #GValue to check
101 * Checks if the given #GValue contains a #GST_TYPE_INT64_RANGE value.
103 #define GST_VALUE_HOLDS_INT64_RANGE(x) (G_VALUE_HOLDS((x), gst_int64_range_get_type ()))
106 * GST_VALUE_HOLDS_DOUBLE_RANGE:
107 * @x: the #GValue to check
109 * Checks if the given #GValue contains a #GST_TYPE_DOUBLE_RANGE value.
111 #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS((x), gst_double_range_get_type ()))
114 * GST_VALUE_HOLDS_FRACTION_RANGE:
115 * @x: the #GValue to check
117 * Checks if the given #GValue contains a #GST_TYPE_FRACTION_RANGE value.
119 #define GST_VALUE_HOLDS_FRACTION_RANGE(x) (G_VALUE_HOLDS((x), gst_fraction_range_get_type ()))
122 * GST_VALUE_HOLDS_LIST:
123 * @x: the #GValue to check
125 * Checks if the given #GValue contains a #GST_TYPE_LIST value.
127 #define GST_VALUE_HOLDS_LIST(x) (G_VALUE_HOLDS((x), gst_value_list_get_type ()))
130 * GST_VALUE_HOLDS_ARRAY:
131 * @x: the #GValue to check
133 * Checks if the given #GValue contains a #GST_TYPE_ARRAY value.
135 #define GST_VALUE_HOLDS_ARRAY(x) (G_VALUE_HOLDS((x), gst_value_array_get_type ()))
138 * GST_VALUE_HOLDS_CAPS:
139 * @x: the #GValue to check
141 * Checks if the given #GValue contains a #GST_TYPE_CAPS value.
143 #define GST_VALUE_HOLDS_CAPS(x) (G_VALUE_HOLDS((x), GST_TYPE_CAPS))
146 * GST_VALUE_HOLDS_STRUCTURE:
147 * @x: the #GValue to check
149 * Checks if the given #GValue contains a #GST_TYPE_STRUCTURE value.
151 #define GST_VALUE_HOLDS_STRUCTURE(x) (G_VALUE_HOLDS((x), GST_TYPE_STRUCTURE))
154 * GST_VALUE_HOLDS_CAPS_FEATURES:
155 * @x: the #GValue to check
157 * Checks if the given #GValue contains a #GST_TYPE_CAPS_FEATURES value.
159 #define GST_VALUE_HOLDS_CAPS_FEATURES(x) (G_VALUE_HOLDS((x), GST_TYPE_CAPS_FEATURES))
162 * GST_VALUE_HOLDS_BUFFER:
163 * @x: the #GValue to check
165 * Checks if the given #GValue contains a #GST_TYPE_BUFFER value.
167 #define GST_VALUE_HOLDS_BUFFER(x) (G_VALUE_HOLDS((x), GST_TYPE_BUFFER))
170 * GST_VALUE_HOLDS_SAMPLE:
171 * @x: the #GValue to check
173 * Checks if the given #GValue contains a #GST_TYPE_SAMPLE value.
175 #define GST_VALUE_HOLDS_SAMPLE(x) (G_VALUE_HOLDS((x), GST_TYPE_SAMPLE))
178 * GST_VALUE_HOLDS_FRACTION:
179 * @x: the #GValue to check
181 * Checks if the given #GValue contains a #GST_TYPE_FRACTION value.
183 #define GST_VALUE_HOLDS_FRACTION(x) (G_VALUE_HOLDS((x), gst_fraction_get_type ()))
186 * GST_VALUE_HOLDS_DATE_TIME:
187 * @x: the #GValue to check
189 * Checks if the given #GValue contains a #GST_TYPE_DATE_TIME value.
191 #define GST_VALUE_HOLDS_DATE_TIME(x) (G_VALUE_HOLDS((x), gst_date_time_get_type ()))
194 * GST_VALUE_HOLDS_BITMASK:
195 * @x: the #GValue to check
197 * Checks if the given #GValue contains a #GST_TYPE_BITMASK value.
199 #define GST_VALUE_HOLDS_BITMASK(x) (G_VALUE_HOLDS((x), gst_bitmask_get_type ()))
202 * GST_TYPE_INT_RANGE:
204 * a #GValue type that represents an integer range
206 * Returns: the #GType of GstIntRange
208 #define GST_TYPE_INT_RANGE gst_int_range_get_type ()
211 * GST_TYPE_INT64_RANGE:
213 * a #GValue type that represents an #gint64 range
215 * Returns: the #GType of GstInt64Range
217 #define GST_TYPE_INT64_RANGE gst_int64_range_get_type ()
220 * GST_TYPE_DOUBLE_RANGE:
222 * a #GValue type that represents a floating point range with double precission
224 * Returns: the #GType of GstIntRange
226 #define GST_TYPE_DOUBLE_RANGE gst_double_range_get_type ()
229 * GST_TYPE_FRACTION_RANGE:
231 * a #GValue type that represents a GstFraction range
233 * Returns: the #GType of GstFractionRange
235 #define GST_TYPE_FRACTION_RANGE gst_fraction_range_get_type ()
240 * a #GValue type that represents an unordered list of #GValue values. This
241 * is used for example to express a list of possible values for a field in
242 * a caps structure, like a list of possible sample rates, of which only one
243 * will be chosen in the end. This means that all values in the list are
244 * meaningful on their own.
246 * Returns: the #GType of GstValueList (which is not explicitly typed)
248 #define GST_TYPE_LIST gst_value_list_get_type ()
253 * a #GValue type that represents an ordered list of #GValue values. This is
254 * used to express a set of values that is meaningful only in their specific
255 * combination and order of values. Each value on its own is not particularly
256 * meaningful, only the ordered array in its entirety is meaningful. This is
257 * used for example to express channel layouts for multichannel audio where
258 * each channel needs to be mapped to a position in the room.
260 * Returns: the #GType of GstArrayList (which is not explicitly typed)
262 #define GST_TYPE_ARRAY gst_value_array_get_type ()
267 * a #GValue type that represents a fraction of an integer numerator over
268 * an integer denominator
270 * Returns: the #GType of GstFraction (which is not explicitly typed)
273 #define GST_TYPE_FRACTION gst_fraction_get_type ()
276 * GST_TYPE_DATE_TIME:
278 * a boxed #GValue type for #GstDateTime that represents a date and time.
280 * 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 ()
298 * a boxed #GValue type for #GThread that represents a thread.
300 * Returns: the #GType of GstGThread
303 #define GST_TYPE_G_THREAD gst_g_thread_get_type ()
306 * GST_VALUE_LESS_THAN:
308 * Indicates that the first value provided to a comparison function
309 * (gst_value_compare()) is lesser than the second one.
311 #define GST_VALUE_LESS_THAN (-1)
316 * Indicates that the first value provided to a comparison function
317 * (gst_value_compare()) is equal to the second one.
319 #define GST_VALUE_EQUAL 0
322 * GST_VALUE_GREATER_THAN:
324 * Indicates that the first value provided to a comparison function
325 * (gst_value_compare()) is greater than the second one.
327 #define GST_VALUE_GREATER_THAN 1
330 * GST_VALUE_UNORDERED:
332 * Indicates that the comparison function (gst_value_compare()) can not
333 * determine a order for the two provided values.
335 #define GST_VALUE_UNORDERED 2
338 * GstValueCompareFunc:
339 * @value1: first value for comparison
340 * @value2: second value for comparison
342 * Used together with gst_value_compare() to compare #GValue items.
344 * Returns: one of GST_VALUE_LESS_THAN, GST_VALUE_EQUAL, GST_VALUE_GREATER_THAN
345 * or GST_VALUE_UNORDERED
347 typedef gint (* GstValueCompareFunc) (const GValue *value1,
348 const GValue *value2);
351 * GstValueSerializeFunc:
354 * Used by gst_value_serialize() to obtain a non-binary form of the #GValue.
356 * Free-function: g_free
358 * Returns: (transfer full): the string representation of the value
360 typedef gchar * (* GstValueSerializeFunc) (const GValue *value1);
363 * GstValueDeserializeFunc:
367 * Used by gst_value_deserialize() to parse a non-binary form into the #GValue.
369 * Returns: %TRUE for success
371 typedef gboolean (* GstValueDeserializeFunc) (GValue *dest,
374 typedef struct _GstValueTable GstValueTable;
378 * @compare: a #GstValueCompareFunc
379 * @serialize: a #GstValueSerializeFunc
380 * @deserialize: a #GstValueDeserializeFunc
382 * VTable for the #GValue @type.
384 struct _GstValueTable {
386 GstValueCompareFunc compare;
387 GstValueSerializeFunc serialize;
388 GstValueDeserializeFunc deserialize;
391 gpointer _gst_reserved [GST_PADDING];
394 GType gst_int_range_get_type (void);
395 GType gst_int64_range_get_type (void);
396 GType gst_double_range_get_type (void);
397 GType gst_fraction_range_get_type (void);
398 GType gst_fraction_get_type (void);
399 GType gst_value_list_get_type (void);
400 GType gst_value_array_get_type (void);
401 GType gst_bitmask_get_type (void);
403 /* Hide this compatibility type from introspection */
404 #ifndef __GI_SCANNER__
405 GType gst_g_thread_get_type (void);
408 GType gst_date_time_get_type (void);
410 void gst_value_register (const GstValueTable *table);
411 void gst_value_init_and_copy (GValue *dest,
414 gchar * gst_value_serialize (const GValue *value) G_GNUC_MALLOC;
415 gboolean gst_value_deserialize (GValue *dest,
419 void gst_value_list_append_value (GValue *value,
420 const GValue *append_value);
421 void gst_value_list_prepend_value (GValue *value,
422 const GValue *prepend_value);
423 void gst_value_list_concat (GValue *dest,
424 const GValue *value1,
425 const GValue *value2);
426 void gst_value_list_merge (GValue *dest,
427 const GValue *value1,
428 const GValue *value2);
429 guint gst_value_list_get_size (const GValue *value);
430 const GValue * gst_value_list_get_value (const GValue *value,
434 void gst_value_array_append_value (GValue *value,
435 const GValue *append_value);
436 void gst_value_array_prepend_value (GValue *value,
437 const GValue *prepend_value);
438 guint gst_value_array_get_size (const GValue *value);
439 const GValue * gst_value_array_get_value (const GValue *value,
443 void gst_value_set_int_range (GValue *value,
446 void gst_value_set_int_range_step (GValue *value,
450 gint gst_value_get_int_range_min (const GValue *value);
451 gint gst_value_get_int_range_max (const GValue *value);
452 gint gst_value_get_int_range_step (const GValue *value);
455 void gst_value_set_int64_range (GValue *value,
458 void gst_value_set_int64_range_step (GValue *value,
462 gint64 gst_value_get_int64_range_min (const GValue *value);
463 gint64 gst_value_get_int64_range_max (const GValue *value);
464 gint64 gst_value_get_int64_range_step (const GValue *value);
467 void gst_value_set_double_range (GValue *value,
470 gdouble gst_value_get_double_range_min (const GValue *value);
471 gdouble gst_value_get_double_range_max (const GValue *value);
474 const GstCaps * gst_value_get_caps (const GValue *value);
475 void gst_value_set_caps (GValue *value,
476 const GstCaps *caps);
480 gst_value_get_structure (const GValue *value);
481 void gst_value_set_structure (GValue *value,
482 const GstStructure *structure);
485 const GstCapsFeatures *
486 gst_value_get_caps_features (const GValue *value);
487 void gst_value_set_caps_features (GValue *value,
488 const GstCapsFeatures *features);
491 void gst_value_set_fraction (GValue *value,
494 gint gst_value_get_fraction_numerator (const GValue *value);
495 gint gst_value_get_fraction_denominator (const GValue *value);
496 gboolean gst_value_fraction_multiply (GValue *product,
497 const GValue *factor1,
498 const GValue *factor2);
499 gboolean gst_value_fraction_subtract (GValue * dest,
500 const GValue * minuend,
501 const GValue * subtrahend);
504 void gst_value_set_fraction_range (GValue *value,
507 void gst_value_set_fraction_range_full (GValue *value,
508 gint numerator_start,
509 gint denominator_start,
511 gint denominator_end);
512 const GValue *gst_value_get_fraction_range_min (const GValue *value);
513 const GValue *gst_value_get_fraction_range_max (const GValue *value);
516 guint64 gst_value_get_bitmask (const GValue *value);
517 void gst_value_set_bitmask (GValue *value,
521 gint gst_value_compare (const GValue *value1,
522 const GValue *value2);
523 gboolean gst_value_can_compare (const GValue *value1,
524 const GValue *value2);
525 gboolean gst_value_is_subset (const GValue *value1,
526 const GValue *value2);
529 gboolean gst_value_union (GValue *dest,
530 const GValue *value1,
531 const GValue *value2);
532 gboolean gst_value_can_union (const GValue *value1,
533 const GValue *value2);
536 gboolean gst_value_intersect (GValue *dest,
537 const GValue *value1,
538 const GValue *value2);
539 gboolean gst_value_can_intersect (const GValue *value1,
540 const GValue *value2);
543 gboolean gst_value_subtract (GValue *dest,
544 const GValue *minuend,
545 const GValue *subtrahend);
546 gboolean gst_value_can_subtract (const GValue *minuend,
547 const GValue *subtrahend);
550 gboolean gst_value_is_fixed (const GValue *value);
551 gboolean gst_value_fixate (GValue *dest,