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))
44 #define GST_VALUE_HOLDS_FRACTION(x) (G_VALUE_HOLDS(x, gst_type_fraction))
46 #define GST_TYPE_FOURCC gst_type_fourcc
47 #define GST_TYPE_INT_RANGE gst_type_int_range
48 #define GST_TYPE_DOUBLE_RANGE gst_type_double_range
49 #define GST_TYPE_LIST gst_type_list
50 #define GST_TYPE_FIXED_LIST gst_type_fixed_list
51 #define GST_TYPE_FRACTION gst_type_fraction
53 #define GST_VALUE_LESS_THAN (-1)
54 #define GST_VALUE_EQUAL 0
55 #define GST_VALUE_GREATER_THAN 1
56 #define GST_VALUE_UNORDERED 2
58 typedef int (* GstValueCompareFunc) (const GValue *value1,
59 const GValue *value2);
60 typedef char * (* GstValueSerializeFunc) (const GValue *value1);
61 typedef gboolean (* GstValueDeserializeFunc) (GValue *dest,
63 typedef int (* GstValueUnionFunc) (GValue *dest,
65 const GValue *value2);
66 typedef int (* GstValueIntersectFunc) (GValue *dest,
68 const GValue *value2);
69 typedef int (* GstValueSubtractFunc) (GValue *dest,
70 const GValue *minuend,
71 const GValue *subtrahend);
73 typedef struct _GstValueTable GstValueTable;
74 struct _GstValueTable {
76 GstValueCompareFunc compare;
77 GstValueSerializeFunc serialize;
78 GstValueDeserializeFunc deserialize;
80 void *_gst_reserved [GST_PADDING];
83 extern GType gst_type_fourcc;
84 extern GType gst_type_int_range;
85 extern GType gst_type_double_range;
86 extern GType gst_type_list;
87 extern GType gst_type_fixed_list;
88 extern GType gst_type_fraction;
90 void gst_value_register (const GstValueTable *table);
91 void gst_value_init_and_copy (GValue *dest,
94 gchar * gst_value_serialize (const GValue *value);
95 gboolean gst_value_deserialize (GValue *dest,
99 void gst_value_list_append_value (GValue *value,
100 const GValue *append_value);
101 void gst_value_list_prepend_value (GValue *value,
102 const GValue *prepend_value);
103 void gst_value_list_concat (GValue *dest,
104 const GValue *value1,
105 const GValue *value2);
106 guint gst_value_list_get_size (const GValue *value);
107 G_CONST_RETURN GValue *
108 gst_value_list_get_value (const GValue *value,
112 void gst_value_set_fourcc (GValue *value,
114 guint32 gst_value_get_fourcc (const GValue *value);
117 void gst_value_set_int_range (GValue *value,
120 int gst_value_get_int_range_min (const GValue *value);
121 int gst_value_get_int_range_max (const GValue *value);
124 void gst_value_set_double_range (GValue *value,
127 double gst_value_get_double_range_min (const GValue *value);
128 double gst_value_get_double_range_max (const GValue *value);
131 G_CONST_RETURN GstCaps *
132 gst_value_get_caps (const GValue *value);
133 void gst_value_set_caps (GValue *value,
134 const GstCaps *caps);
137 void gst_value_set_fraction (GValue *value,
140 int gst_value_get_fraction_numerator (const GValue *value);
141 int gst_value_get_fraction_denominator(const GValue *value);
142 gboolean gst_value_fraction_multiply (GValue *product,
143 const GValue *factor1,
144 const GValue *factor2);
147 int gst_value_compare (const GValue *value1,
148 const GValue *value2);
149 gboolean gst_value_can_compare (const GValue *value1,
150 const GValue *value2);
153 gboolean gst_value_union (GValue *dest,
154 const GValue *value1,
155 const GValue *value2);
156 gboolean gst_value_can_union (const GValue *value1,
157 const GValue *value2);
158 void gst_value_register_union_func (GType type1,
160 GstValueUnionFunc func);
163 gboolean gst_value_intersect (GValue *dest,
164 const GValue *value1,
165 const GValue *value2);
166 gboolean gst_value_can_intersect (const GValue *value1,
167 const GValue *value2);
168 void gst_value_register_intersect_func (GType type1,
170 GstValueIntersectFunc func);
173 gboolean gst_value_subtract (GValue *dest,
174 const GValue *minuend,
175 const GValue *subtrahend);
176 gboolean gst_value_can_subtract (const GValue *minuend,
177 const GValue *subtrahend);
178 void gst_value_register_subtract_func (GType minuend_type,
179 GType subtrahend_type,
180 GstValueSubtractFunc func);
183 gboolean gst_type_is_fixed (GType type);
186 void _gst_value_initialize (void);