gst/gstvalue.h: Fix prototypes.
[platform/upstream/gstreamer.git] / gst / gstvalue.h
1 /* GStreamer
2  * Copyright (C) <2003> David A. Schleef <ds@schleef.org>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifndef __GST_VALUE_H__
21 #define __GST_VALUE_H__
22
23 #include <gst/gstconfig.h>
24 #include <gst/gstcaps.h>
25
26 G_BEGIN_DECLS
27
28 /**
29  * GST_MAKE_FOURCC:
30  * @a: the first character
31  * @b: the second character
32  * @c: the third character
33  * @d: the fourth character
34  *
35  * Transform four characters into a #guint32 fourcc value with host
36  * endianness.
37  * <informalexample>
38  * <programlisting>
39  * guint32 fourcc = GST_MAKE_FOURCC ('M', 'J', 'P', 'G');
40  * </programlisting>
41  * </informalexample>
42  */
43 #define GST_MAKE_FOURCC(a,b,c,d)        (guint32)((a)|(b)<<8|(c)<<16|(d)<<24)
44
45 /**
46  * GST_STR_FOURCC:
47  * @f: a string with at least four characters
48  *
49  * Transform an input string into a #guint32 fourcc value with host
50  * endianness.
51  * Caller is responsible for ensuring the input string consists of at least
52  * four characters.
53  * <informalexample>
54  * <programlisting>
55  * guint32 fourcc = GST_STR_FOURCC ("MJPG");
56  * </programlisting>
57  * </informalexample>
58  */
59 #define GST_STR_FOURCC(f)               (guint32)(((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24))
60
61 /**
62  * GST_FOURCC_FORMAT:
63  *
64  * Can be used together with #GST_FOURCC_ARGS to properly output a
65  * #guint32 fourcc value in a printf()-style text message.
66  * <informalexample>
67  * <programlisting>
68  * printf ("fourcc: %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (fcc));
69  * </programlisting>
70  * </informalexample>
71  */
72 #define GST_FOURCC_FORMAT "%c%c%c%c"
73
74 /**
75  * GST_FOURCC_ARGS:
76  * @fourcc: a #guint32 fourcc value to output
77  *
78  * Can be used together with #GST_FOURCC_FORMAT to properly output a
79  * #guint32 fourcc value in a printf()-style text message.
80  */
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))
86
87 /**
88  * GST_VALUE_HOLDS_FOURCC:
89  * @x: the #GValue to check
90  *
91  * Checks if the given #GValue contains a #GST_TYPE_FOURCC value.
92  */
93 #define GST_VALUE_HOLDS_FOURCC(x)       (G_VALUE_HOLDS(x, gst_fourcc_get_type ()))
94
95 /**
96  * GST_VALUE_HOLDS_INT_RANGE:
97  * @x: the #GValue to check
98  *
99  * Checks if the given #GValue contains a #GST_TYPE_INT_RANGE value.
100  */
101 #define GST_VALUE_HOLDS_INT_RANGE(x)    (G_VALUE_HOLDS(x, gst_int_range_get_type ()))
102
103 /**
104  * GST_VALUE_HOLDS_DOUBLE_RANGE:
105  * @x: the #GValue to check
106  *
107  * Checks if the given #GValue contains a #GST_TYPE_DOUBLE_RANGE value.
108  */
109 #define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS(x, gst_double_range_get_type ()))
110
111 /**
112  * GST_VALUE_HOLDS_LIST:
113  * @x: the #GValue to check
114  *
115  * Checks if the given #GValue contains a #GST_TYPE_LIST value.
116  */
117 #define GST_VALUE_HOLDS_LIST(x)         (G_VALUE_HOLDS(x, gst_value_list_get_type ()))
118
119 /**
120  * GST_VALUE_HOLDS_ARRAY:
121  * @x: the #GValue to check
122  *
123  * Checks if the given #GValue contains a #GST_TYPE_ARRAY value.
124  */
125 #define GST_VALUE_HOLDS_ARRAY(x)        (G_VALUE_HOLDS(x, gst_value_array_get_type ()))
126
127 /**
128  * GST_VALUE_HOLDS_CAPS:
129  * @x: the #GValue to check
130  *
131  * Checks if the given #GValue contains a #GST_TYPE_CAPS value.
132  */
133 #define GST_VALUE_HOLDS_CAPS(x)         (G_VALUE_HOLDS(x, GST_TYPE_CAPS))
134
135 /**
136  * GST_VALUE_HOLDS_BUFFER:
137  * @x: the #GValue to check
138  *
139  * Checks if the given #GValue contains a #GST_TYPE_BUFFER value.
140  */
141 #define GST_VALUE_HOLDS_BUFFER(x)       (G_VALUE_HOLDS(x, GST_TYPE_BUFFER))
142
143 /**
144  * GST_VALUE_HOLDS_FRACTION:
145  * @x: the #GValue to check
146  *
147  * Checks if the given #GValue contains a #GST_TYPE_FRACTION value.
148  */
149 #define GST_VALUE_HOLDS_FRACTION(x)     (G_VALUE_HOLDS(x, gst_fraction_get_type ()))
150
151 /**
152  * GST_VALUE_HOLDS_DATE:
153  * @x: the #GValue to check
154  *
155  * Checks if the given #GValue contains a #GST_TYPE_DATE value.
156  */
157 #define GST_VALUE_HOLDS_DATE(x)         (G_VALUE_HOLDS(x, gst_date_get_type ()))
158
159 /**
160  * GST_TYPE_FOURCC:
161  *
162  * a #GValue type that represents 4 byte identifier (e.g. used for codecs)
163  *
164  * Returns: the #GType of GstFourcc
165  */
166 #define GST_TYPE_FOURCC                  gst_fourcc_get_type ()
167
168 /**
169  * GST_TYPE_INT_RANGE:
170  *
171  * a #GValue type that represents an integer range
172  *
173  * Returns: the #GType of GstIntRange
174  */
175 #define GST_TYPE_INT_RANGE               gst_int_range_get_type ()
176
177 /**
178  * GST_TYPE_DOUBLE_RANGE:
179  *
180  * a #GValue type that represents a floating point range with double precission
181  *
182  * Returns: the #GType of GstIntRange
183  */
184 #define GST_TYPE_DOUBLE_RANGE            gst_double_range_get_type ()
185
186 /**
187  * GST_TYPE_LIST:
188  *
189  * a #GValue type that represents an unordered list of #GValue values
190  *
191  * Returns: the #GType of GstValueList (which is not explicitly typed)
192  */
193 #define GST_TYPE_LIST                    gst_value_list_get_type ()
194
195 /**
196  * GST_TYPE_ARRAY:
197  *
198  * a #GValue type that represents an ordered list of #GValue values
199  *
200  * Returns: the #GType of GstArrayList (which is not explicitly typed)
201  */
202 #define GST_TYPE_ARRAY                   gst_value_array_get_type ()
203
204 /**
205  * GST_TYPE_FRACTION:
206  *
207  * a #GValue type that represents a fraction of an integer numerator over
208  * an integer denominator
209  *
210  * Returns: the #GType of GstFraction (which is not explicitly typed)
211  */
212
213 #define GST_TYPE_FRACTION                gst_fraction_get_type ()
214
215 /**
216  * GST_TYPE_DATE:
217  *
218  * a boxed #GValue type for #GDate that represents a date.
219  *
220  * Returns: the #GType of GstDate
221  */
222
223 #define GST_TYPE_DATE                    gst_date_get_type ()
224
225 /**
226  * GST_VALUE_LESS_THAN:
227  *
228  * Indicates that the first value provided to a comparison function
229  * (gst_value_compare()) is lesser than the second one.
230  */
231 #define GST_VALUE_LESS_THAN              (-1)
232
233 /**
234  * GST_VALUE_EQUAL:
235  *
236  * Indicates that the first value provided to a comparison function
237  * (gst_value_compare()) is equal to the second one.
238  */
239 #define GST_VALUE_EQUAL                   0
240
241 /**
242  * GST_VALUE_GREATER_THAN:
243  *
244  * Indicates that the first value provided to a comparison function
245  * (gst_value_compare()) is greater than the second one.
246  */
247 #define GST_VALUE_GREATER_THAN            1
248
249 /**
250  * GST_VALUE_UNORDERED:
251  *
252  * Indicates that the comparison function (gst_value_compare()) can not
253  * determine a order for the two provided values.
254  */
255 #define GST_VALUE_UNORDERED               2
256
257 /**
258  * GstValueCompareFunc:
259  * @value1: first value for comparission
260  * @value2: second value for comparission
261  *
262  * Used together with gst_value_compare() to compare #GValues.
263  *
264  * Returns: one of GST_VALUE_LESS_THAN, GST_VALUE_EQUAL, GST_VALUE_GREATER_THAN
265  * or GST_VALUE_UNORDERED
266  */
267 typedef int      (* GstValueCompareFunc)     (const GValue *value1,
268                                               const GValue *value2);
269
270 typedef char *   (* GstValueSerializeFunc)   (const GValue *value1);
271
272 typedef gboolean (* GstValueDeserializeFunc) (GValue       *dest,
273                                               const char   *s);
274
275 typedef int      (* GstValueUnionFunc)       (GValue       *dest,
276                                               const GValue *value1,
277                                               const GValue *value2);
278
279 typedef int      (* GstValueIntersectFunc)   (GValue       *dest,
280                                               const GValue *value1,
281                                               const GValue *value2);
282
283 typedef int      (* GstValueSubtractFunc)    (GValue       *dest,
284                                               const GValue *minuend,
285                                               const GValue *subtrahend);
286
287 typedef struct _GstValueTable GstValueTable;
288 struct _GstValueTable {
289   GType type;
290   GstValueCompareFunc compare;
291   GstValueSerializeFunc serialize;
292   GstValueDeserializeFunc deserialize;
293
294   /*< private >*/
295   void *_gst_reserved [GST_PADDING];
296 };
297
298 GType gst_int_range_get_type (void);
299 GType gst_double_range_get_type (void);
300 GType gst_fourcc_get_type (void);
301 GType gst_fraction_get_type (void);
302 GType gst_value_list_get_type (void);
303 GType gst_value_array_get_type (void);
304
305 GType gst_date_get_type (void);
306
307 void            gst_value_register              (const GstValueTable   *table);
308 void            gst_value_init_and_copy         (GValue                *dest,
309                                                  const GValue          *src);
310
311 gchar *         gst_value_serialize             (const GValue          *value);
312 gboolean        gst_value_deserialize           (GValue                *dest,
313                                                  const gchar           *src);
314
315 /* list */
316 void            gst_value_list_append_value     (GValue         *value,
317                                                  const GValue   *append_value);
318 void            gst_value_list_prepend_value    (GValue         *value,
319                                                  const GValue   *prepend_value);
320 void            gst_value_list_concat           (GValue         *dest,
321                                                  const GValue   *value1,
322                                                  const GValue   *value2);
323 guint           gst_value_list_get_size         (const GValue   *value);
324 G_CONST_RETURN GValue *
325                 gst_value_list_get_value        (const GValue   *value,
326                                                  guint          index);
327
328 /* fourcc */
329 void            gst_value_set_fourcc            (GValue         *value,
330                                                  guint32        fourcc);
331 guint32         gst_value_get_fourcc            (const GValue   *value);
332
333 /* int range */
334 void            gst_value_set_int_range         (GValue         *value,
335                                                  int            start,
336                                                  int            end);
337 int             gst_value_get_int_range_min     (const GValue   *value);
338 int             gst_value_get_int_range_max     (const GValue   *value);
339
340 /* double range */
341 void            gst_value_set_double_range      (GValue         *value,
342                                                  double         start,
343                                                  double         end);
344 double          gst_value_get_double_range_min  (const GValue   *value);
345 double          gst_value_get_double_range_max  (const GValue   *value);
346
347 /* caps */
348 G_CONST_RETURN GstCaps *
349                 gst_value_get_caps              (const GValue   *value);
350 void            gst_value_set_caps              (GValue         *value,
351                                                  const GstCaps  *caps);
352
353 /* fraction */
354 void            gst_value_set_fraction          (GValue         *value,
355                                                  int            numerator,
356                                                  int            denominator);
357 int             gst_value_get_fraction_numerator (const GValue  *value);
358 int             gst_value_get_fraction_denominator(const GValue *value);
359 gboolean        gst_value_fraction_multiply     (GValue         *product,
360                                                  const GValue   *factor1,
361                                                  const GValue   *factor2);
362
363 /* date */
364 G_CONST_RETURN GDate *
365                 gst_value_get_date              (const GValue   *value);
366 void            gst_value_set_date              (GValue         *value,
367                                                  const GDate    *date);
368
369 /* compare */
370 int             gst_value_compare               (const GValue   *value1,
371                                                  const GValue   *value2);
372 gboolean        gst_value_can_compare           (const GValue   *value1,
373                                                  const GValue   *value2);
374
375 /* union */
376 gboolean        gst_value_union                 (GValue         *dest,
377                                                  const GValue   *value1,
378                                                  const GValue   *value2);
379 gboolean        gst_value_can_union             (const GValue   *value1,
380                                                  const GValue   *value2);
381 void            gst_value_register_union_func   (GType          type1,
382                                                  GType          type2,
383                                                  GstValueUnionFunc func);
384
385 /* intersection */
386 gboolean        gst_value_intersect             (GValue         *dest,
387                                                  const GValue   *value1,
388                                                  const GValue   *value2);
389 gboolean        gst_value_can_intersect         (const GValue   *value1,
390                                                  const GValue   *value2);
391 void            gst_value_register_intersect_func (GType        type1,
392                                                 GType           type2,
393                                                 GstValueIntersectFunc func);
394
395 /* subtraction */
396 gboolean        gst_value_subtract              (GValue         *dest,
397                                                  const GValue   *minuend,
398                                                  const GValue   *subtrahend);
399 gboolean        gst_value_can_subtract          (const GValue   *minuend,
400                                                  const GValue   *subtrahend);
401 void            gst_value_register_subtract_func (GType         minuend_type,
402                                                 GType           subtrahend_type,
403                                                 GstValueSubtractFunc func);
404
405 /* fixation */
406 gboolean        gst_value_is_fixed              (const GValue   *value);
407
408 /* private */
409 void            _gst_value_initialize           (void);
410
411 G_END_DECLS
412
413 #endif
414
415