2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2002 Thomas Vander Stichele <thomas@apestaart.org>
6 * gstutils.h: Header for various utility functions
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
25 #ifndef __GST_UTILS_H__
26 #define __GST_UTILS_H__
29 #include <gst/gstbin.h>
30 #include <gst/gstparse.h>
34 void gst_util_set_value_from_string (GValue *value, const gchar *value_str);
35 void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar *value);
36 void gst_util_dump_mem (const guchar *mem, guint size);
38 guint64 gst_util_gdouble_to_guint64 (gdouble value) G_GNUC_PURE;
39 gdouble gst_util_guint64_to_gdouble (guint64 value) G_GNUC_PURE;
42 * gst_guint64_to_gdouble:
43 * @value: the #guint64 value to convert
45 * Convert @value to a gdouble.
47 * Returns: @value converted to a #gdouble.
51 * gst_gdouble_to_guint64:
52 * @value: the #gdouble value to convert
54 * Convert @value to a guint64.
56 * Returns: @value converted to a #guint64.
59 #define gst_gdouble_to_guint64(value) gst_util_gdouble_to_guint64(value)
60 #define gst_guint64_to_gdouble(value) gst_util_guint64_to_gdouble(value)
62 #define gst_gdouble_to_guint64(value) ((guint64) (value))
63 #define gst_guint64_to_gdouble(value) ((gdouble) (value))
66 guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom) G_GNUC_PURE;
68 guint64 gst_util_uint64_scale_int (guint64 val, gint num, gint denom) G_GNUC_PURE;
70 guint32 gst_util_seqnum_next (void);
71 gint32 gst_util_seqnum_compare (guint32 s1, guint32 s2);
73 void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad);
74 void gst_print_element_args (GString *buf, gint indent, GstElement *element);
77 GType gst_type_register_static_full (GType parent_type,
78 const gchar *type_name,
80 GBaseInitFunc base_init,
81 GBaseFinalizeFunc base_finalize,
82 GClassInitFunc class_init,
83 GClassFinalizeFunc class_finalize,
84 gconstpointer class_data,
87 GInstanceInitFunc instance_init,
88 const GTypeValueTable *value_table,
92 /* Macros for defining classes. Ideas taken from Bonobo, which took theirs
93 from Nautilus and GOB. */
95 #define __gst_once_init_enter(val) (g_once_init_enter (val))
96 #define __gst_once_init_leave(val,newval) (g_once_init_leave (val, newval))
99 * GST_BOILERPLATE_FULL:
100 * @type: the name of the type struct
101 * @type_as_function: the prefix for the functions
102 * @parent_type: the parent type struct name
103 * @parent_type_macro: the parent type macro
104 * @additional_initializations: function pointer in the form of
105 * void additional_initializations (GType type) that can be used for
106 * initializing interfaces and the like
108 * Define the boilerplate type stuff to reduce typos and code size. Defines
109 * the get_type method and the parent_class static variable.
113 * GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, _do_init);
117 #define GST_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations) \
119 static void type_as_function ## _base_init (gpointer g_class); \
120 static void type_as_function ## _class_init (type ## Class *g_class);\
121 static void type_as_function ## _init (type *object, \
122 type ## Class *g_class);\
123 static parent_type ## Class *parent_class = NULL; \
125 type_as_function ## _class_init_trampoline (gpointer g_class, \
128 parent_class = (parent_type ## Class *) \
129 g_type_class_peek_parent (g_class); \
130 type_as_function ## _class_init ((type ## Class *)g_class); \
133 GType type_as_function ## _get_type (void); \
136 type_as_function ## _get_type (void) \
138 /* The typedef for GType may be gulong or gsize, depending on the \
139 * system and whether the compiler is c++ or not. The g_once_init_* \
140 * functions always take a gsize * though ... */ \
141 static volatile gsize gonce_data = 0; \
142 if (__gst_once_init_enter (&gonce_data)) { \
144 _type = gst_type_register_static_full (parent_type_macro, \
145 g_intern_static_string (#type), \
146 sizeof (type ## Class), \
147 type_as_function ## _base_init, \
148 NULL, /* base_finalize */ \
149 type_as_function ## _class_init_trampoline, \
150 NULL, /* class_finalize */ \
151 NULL, /* class_data */ \
153 0, /* n_preallocs */ \
154 (GInstanceInitFunc) type_as_function ## _init, \
157 additional_initializations (_type); \
158 __gst_once_init_leave (&gonce_data, (gsize) _type); \
160 return (GType) gonce_data; \
163 #define __GST_DO_NOTHING(type) /* NOP */
167 * @type: the name of the type struct
168 * @type_as_function: the prefix for the functions
169 * @parent_type: the parent type struct name
170 * @parent_type_macro: the parent type macro
172 * Define the boilerplate type stuff to reduce typos and code size. Defines
173 * the get_type method and the parent_class static variable.
177 * GST_BOILERPLATE (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT);
181 #define GST_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro) \
182 GST_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
185 /* Like GST_BOILERPLATE, but makes the type 1) implement an interface, and 2)
186 * implement GstImplementsInterface for that type
188 * After this you will need to implement interface_as_function ## _supported
189 * and interface_as_function ## _interface_init
192 * GST_BOILERPLATE_WITH_INTERFACE:
193 * @type: the name of the type struct
194 * @type_as_function: the prefix for the functions
195 * @parent_type: the parent type struct name
196 * @parent_type_as_macro: the parent type macro
197 * @interface_type: the name of the interface type struct
198 * @interface_type_as_macro: the interface type macro
199 * @interface_as_function: the interface function name prefix
201 * Like GST_BOILERPLATE, but makes the type 1) implement an interface, and 2)
202 * implement GstImplementsInterface for that type.
204 * After this you will need to implement interface_as_function ## _supported
205 * and interface_as_function ## _interface_init
207 #define GST_BOILERPLATE_WITH_INTERFACE(type, type_as_function, \
208 parent_type, parent_type_as_macro, interface_type, \
209 interface_type_as_macro, interface_as_function) \
211 static void interface_as_function ## _interface_init (interface_type ## Class *klass); \
212 static gboolean interface_as_function ## _supported (type *object, GType iface_type); \
215 type_as_function ## _implements_interface_init (GstImplementsInterfaceClass *klass) \
217 klass->supported = (gboolean (*)(GstImplementsInterface*, GType))interface_as_function ## _supported; \
221 type_as_function ## _init_interfaces (GType type) \
223 static const GInterfaceInfo implements_iface_info = { \
224 (GInterfaceInitFunc) type_as_function ## _implements_interface_init,\
228 static const GInterfaceInfo iface_info = { \
229 (GInterfaceInitFunc) interface_as_function ## _interface_init, \
234 g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, \
235 &implements_iface_info); \
236 g_type_add_interface_static (type, interface_type_as_macro, \
240 GST_BOILERPLATE_FULL (type, type_as_function, parent_type, \
241 parent_type_as_macro, type_as_function ## _init_interfaces)
245 * @parent_class_cast: the name of the class cast macro for the parent type
246 * @name: name of the function to call
247 * @args: arguments enclosed in '( )'
249 * Just call the parent handler. This assumes that there is a variable
250 * named parent_class that points to the (duh!) parent class. Note that
251 * this macro is not to be used with things that return something, use
252 * the _WITH_DEFAULT version for that
254 #define GST_CALL_PARENT(parent_class_cast, name, args) \
255 ((parent_class_cast(parent_class)->name != NULL) ? \
256 parent_class_cast(parent_class)->name args : (void) 0)
259 * GST_CALL_PARENT_WITH_DEFAULT:
260 * @parent_class_cast: the name of the class cast macro for the parent type
261 * @name: name of the function to call
262 * @args: arguments enclosed in '( )'
263 * @def_return: default result
265 * Same as GST_CALL_PARENT(), but in case there is no implementation, it
266 * evaluates to @def_return.
268 #define GST_CALL_PARENT_WITH_DEFAULT(parent_class_cast, name, args, def_return)\
269 ((parent_class_cast(parent_class)->name != NULL) ? \
270 parent_class_cast(parent_class)->name args : def_return)
272 /* Define PUT and GET functions for unaligned memory */
273 #define _GST_GET(__data, __idx, __size, __shift) \
274 (((guint##__size) (((guint8 *) (__data))[__idx])) << __shift)
276 #define _GST_PUT(__data, __idx, __size, __shift, __num) \
277 (((guint8 *) (__data))[__idx] = (((guint##__size) __num) >> __shift) & 0xff)
280 * GST_READ_UINT64_BE:
281 * @data: memory location
283 * Read a 64 bit unsigned integer value in big endian format from the memory buffer.
285 #define GST_READ_UINT64_BE(data) (_GST_GET (data, 0, 64, 56) | \
286 _GST_GET (data, 1, 64, 48) | \
287 _GST_GET (data, 2, 64, 40) | \
288 _GST_GET (data, 3, 64, 32) | \
289 _GST_GET (data, 4, 64, 24) | \
290 _GST_GET (data, 5, 64, 16) | \
291 _GST_GET (data, 6, 64, 8) | \
292 _GST_GET (data, 7, 64, 0))
295 * GST_READ_UINT64_LE:
296 * @data: memory location
298 * Read a 64 bit unsigned integer value in little endian format from the memory buffer.
300 #define GST_READ_UINT64_LE(data) (_GST_GET (data, 7, 64, 56) | \
301 _GST_GET (data, 6, 64, 48) | \
302 _GST_GET (data, 5, 64, 40) | \
303 _GST_GET (data, 4, 64, 32) | \
304 _GST_GET (data, 3, 64, 24) | \
305 _GST_GET (data, 2, 64, 16) | \
306 _GST_GET (data, 1, 64, 8) | \
307 _GST_GET (data, 0, 64, 0))
310 * GST_READ_UINT32_BE:
311 * @data: memory location
313 * Read a 32 bit unsigned integer value in big endian format from the memory buffer.
315 #define GST_READ_UINT32_BE(data) (_GST_GET (data, 0, 32, 24) | \
316 _GST_GET (data, 1, 32, 16) | \
317 _GST_GET (data, 2, 32, 8) | \
318 _GST_GET (data, 3, 32, 0))
321 * GST_READ_UINT32_LE:
322 * @data: memory location
324 * Read a 32 bit unsigned integer value in little endian format from the memory buffer.
326 #define GST_READ_UINT32_LE(data) (_GST_GET (data, 3, 32, 24) | \
327 _GST_GET (data, 2, 32, 16) | \
328 _GST_GET (data, 1, 32, 8) | \
329 _GST_GET (data, 0, 32, 0))
332 * GST_READ_UINT24_BE:
333 * @data: memory location
335 * Read a 24 bit unsigned integer value in big endian format from the memory buffer.
339 #define GST_READ_UINT24_BE(data) (_GST_GET (data, 0, 32, 16) | \
340 _GST_GET (data, 1, 32, 8) | \
341 _GST_GET (data, 2, 32, 0))
344 * GST_READ_UINT24_LE:
345 * @data: memory location
347 * Read a 24 bit unsigned integer value in little endian format from the memory buffer.
351 #define GST_READ_UINT24_LE(data) (_GST_GET (data, 2, 32, 16) | \
352 _GST_GET (data, 1, 32, 8) | \
353 _GST_GET (data, 0, 32, 0))
356 * GST_READ_UINT16_BE:
357 * @data: memory location
359 * Read a 16 bit unsigned integer value in big endian format from the memory buffer.
361 #define GST_READ_UINT16_BE(data) (_GST_GET (data, 0, 16, 8) | \
362 _GST_GET (data, 1, 16, 0))
365 * GST_READ_UINT16_LE:
366 * @data: memory location
368 * Read a 16 bit unsigned integer value in little endian format from the memory buffer.
370 #define GST_READ_UINT16_LE(data) (_GST_GET (data, 1, 16, 8) | \
371 _GST_GET (data, 0, 16, 0))
375 * @data: memory location
377 * Read an 8 bit unsigned integer value from the memory buffer.
379 #define GST_READ_UINT8(data) (_GST_GET (data, 0, 8, 0))
382 * GST_WRITE_UINT64_BE:
383 * @data: memory location
384 * @num: value to store
386 * Store a 64 bit unsigned integer value in big endian format into the memory buffer.
388 #define GST_WRITE_UINT64_BE(data, num) do { \
389 _GST_PUT (data, 0, 64, 56, num); \
390 _GST_PUT (data, 1, 64, 48, num); \
391 _GST_PUT (data, 2, 64, 40, num); \
392 _GST_PUT (data, 3, 64, 32, num); \
393 _GST_PUT (data, 4, 64, 24, num); \
394 _GST_PUT (data, 5, 64, 16, num); \
395 _GST_PUT (data, 6, 64, 8, num); \
396 _GST_PUT (data, 7, 64, 0, num); \
400 * GST_WRITE_UINT64_LE:
401 * @data: memory location
402 * @num: value to store
404 * Store a 64 bit unsigned integer value in little endian format into the memory buffer.
406 #define GST_WRITE_UINT64_LE(data, num) do { \
407 _GST_PUT (data, 0, 64, 0, num); \
408 _GST_PUT (data, 1, 64, 8, num); \
409 _GST_PUT (data, 2, 64, 16, num); \
410 _GST_PUT (data, 3, 64, 24, num); \
411 _GST_PUT (data, 4, 64, 32, num); \
412 _GST_PUT (data, 5, 64, 40, num); \
413 _GST_PUT (data, 6, 64, 48, num); \
414 _GST_PUT (data, 7, 64, 56, num); \
418 * GST_WRITE_UINT32_BE:
419 * @data: memory location
420 * @num: value to store
422 * Store a 32 bit unsigned integer value in big endian format into the memory buffer.
424 #define GST_WRITE_UINT32_BE(data, num) do { \
425 _GST_PUT (data, 0, 32, 24, num); \
426 _GST_PUT (data, 1, 32, 16, num); \
427 _GST_PUT (data, 2, 32, 8, num); \
428 _GST_PUT (data, 3, 32, 0, num); \
432 * GST_WRITE_UINT32_LE:
433 * @data: memory location
434 * @num: value to store
436 * Store a 32 bit unsigned integer value in little endian format into the memory buffer.
438 #define GST_WRITE_UINT32_LE(data, num) do { \
439 _GST_PUT (data, 0, 32, 0, num); \
440 _GST_PUT (data, 1, 32, 8, num); \
441 _GST_PUT (data, 2, 32, 16, num); \
442 _GST_PUT (data, 3, 32, 24, num); \
446 * GST_WRITE_UINT24_BE:
447 * @data: memory location
448 * @num: value to store
450 * Store a 24 bit unsigned integer value in big endian format into the memory buffer.
454 #define GST_WRITE_UINT24_BE(data, num) do { \
455 _GST_PUT (data, 0, 32, 16, num); \
456 _GST_PUT (data, 1, 32, 8, num); \
457 _GST_PUT (data, 2, 32, 0, num); \
461 * GST_WRITE_UINT24_LE:
462 * @data: memory location
463 * @num: value to store
465 * Store a 24 bit unsigned integer value in little endian format into the memory buffer.
469 #define GST_WRITE_UINT24_LE(data, num) do { \
470 _GST_PUT (data, 0, 32, 0, num); \
471 _GST_PUT (data, 1, 32, 8, num); \
472 _GST_PUT (data, 2, 32, 16, num); \
476 * GST_WRITE_UINT16_BE:
477 * @data: memory location
478 * @num: value to store
480 * Store a 16 bit unsigned integer value in big endian format into the memory buffer.
482 #define GST_WRITE_UINT16_BE(data, num) do { \
483 _GST_PUT (data, 0, 16, 8, num); \
484 _GST_PUT (data, 1, 16, 0, num); \
488 * GST_WRITE_UINT16_LE:
489 * @data: memory location
490 * @num: value to store
492 * Store a 16 bit unsigned integer value in little endian format into the memory buffer.
494 #define GST_WRITE_UINT16_LE(data, num) do { \
495 _GST_PUT (data, 0, 16, 0, num); \
496 _GST_PUT (data, 1, 16, 8, num); \
501 * @data: memory location
502 * @num: value to store
504 * Store an 8 bit unsigned integer value into the memory buffer.
506 #define GST_WRITE_UINT8(data, num) do { \
507 _GST_PUT (data, 0, 8, 0, num); \
510 /* Float endianess conversion macros */
512 /* FIXME: Remove this once we depend on a GLib version with this */
513 #ifndef GFLOAT_FROM_LE
518 * Swap byte order of a 32-bit floating point value (float).
523 #ifdef _FOOL_GTK_DOC_
524 G_INLINE_FUNC gfloat GFLOAT_SWAP_LE_BE (gfloat in);
528 GFLOAT_SWAP_LE_BE(gfloat in)
537 u.i = GUINT32_SWAP_LE_BE (u.i);
542 * GDOUBLE_SWAP_LE_BE:
545 * Swap byte order of a 64-bit floating point value (double).
550 #ifdef _FOOL_GTK_DOC_
551 G_INLINE_FUNC gdouble GDOUBLE_SWAP_LE_BE (gdouble in);
554 inline static gdouble
555 GDOUBLE_SWAP_LE_BE(gdouble in)
564 u.i = GUINT64_SWAP_LE_BE (u.i);
572 * Convert 64-bit floating point value (double) from native byte order into
573 * little endian byte order.
582 * Convert 64-bit floating point value (double) from native byte order into
583 * big endian byte order.
592 * Convert 64-bit floating point value (double) from little endian byte order
593 * into native byte order.
602 * Convert 64-bit floating point value (double) from big endian byte order
603 * into native byte order.
613 * Convert 32-bit floating point value (float) from native byte order into
614 * little endian byte order.
623 * Convert 32-bit floating point value (float) from native byte order into
624 * big endian byte order.
633 * Convert 32-bit floating point value (float) from little endian byte order
634 * into native byte order.
643 * Convert 32-bit floating point value (float) from big endian byte order
644 * into native byte order.
650 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
651 #define GFLOAT_TO_LE(val) ((gfloat) (val))
652 #define GFLOAT_TO_BE(val) (GFLOAT_SWAP_LE_BE (val))
653 #define GDOUBLE_TO_LE(val) ((gdouble) (val))
654 #define GDOUBLE_TO_BE(val) (GDOUBLE_SWAP_LE_BE (val))
656 #elif G_BYTE_ORDER == G_BIG_ENDIAN
657 #define GFLOAT_TO_LE(val) (GFLOAT_SWAP_LE_BE (val))
658 #define GFLOAT_TO_BE(val) ((gfloat) (val))
659 #define GDOUBLE_TO_LE(val) (GDOUBLE_SWAP_LE_BE (val))
660 #define GDOUBLE_TO_BE(val) ((gdouble) (val))
662 #else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
663 #error unknown ENDIAN type
664 #endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
666 #define GFLOAT_FROM_LE(val) (GFLOAT_TO_LE (val))
667 #define GFLOAT_FROM_BE(val) (GFLOAT_TO_BE (val))
668 #define GDOUBLE_FROM_LE(val) (GDOUBLE_TO_LE (val))
669 #define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val))
671 #endif /* !defined(GFLOAT_FROM_LE) */
675 * @data: memory location
677 * Read a 32 bit float value in little endian format from the memory buffer.
682 #ifdef _FOOL_GTK_DOC_
683 G_INLINE_FUNC gfloat GST_READ_FLOAT_LE (const guint8 *data);
687 GST_READ_FLOAT_LE(const guint8 *data)
695 u.i = GST_READ_UINT32_LE (data);
701 * @data: memory location
703 * Read a 32 bit float value in big endian format from the memory buffer.
708 #ifdef _FOOL_GTK_DOC_
709 G_INLINE_FUNC gfloat GST_READ_FLOAT_BE (const guint8 *data);
713 GST_READ_FLOAT_BE(const guint8 *data)
721 u.i = GST_READ_UINT32_BE (data);
726 * GST_READ_DOUBLE_LE:
727 * @data: memory location
729 * Read a 64 bit double value in little endian format from the memory buffer.
734 #ifdef _FOOL_GTK_DOC_
735 G_INLINE_FUNC gdouble GST_READ_DOUBLE_LE (const guint8 *data);
738 inline static gdouble
739 GST_READ_DOUBLE_LE(const guint8 *data)
747 u.i = GST_READ_UINT64_LE (data);
752 * GST_READ_DOUBLE_BE:
753 * @data: memory location
755 * Read a 64 bit double value in big endian format from the memory buffer.
760 #ifdef _FOOL_GTK_DOC_
761 G_INLINE_FUNC gdouble GST_READ_DOUBLE_BE (const guint8 *data);
764 inline static gdouble
765 GST_READ_DOUBLE_BE(const guint8 *data)
773 u.i = GST_READ_UINT64_BE (data);
778 * GST_WRITE_FLOAT_LE:
779 * @data: memory location
780 * @num: value to store
782 * Store a 32 bit float value in little endian format into the memory buffer.
787 #ifdef _FOOL_GTK_DOC_
788 G_INLINE_FUNC void GST_WRITE_FLOAT_LE (guint8 *data, gfloat num);
792 GST_WRITE_FLOAT_LE(guint8 *data, gfloat num)
801 GST_WRITE_UINT32_LE (data, u.i);
805 * GST_WRITE_FLOAT_BE:
806 * @data: memory location
807 * @num: value to store
809 * Store a 32 bit float value in big endian format into the memory buffer.
814 #ifdef _FOOL_GTK_DOC_
815 G_INLINE_FUNC void GST_WRITE_FLOAT_BE (guint8 *data, gfloat num);
819 GST_WRITE_FLOAT_BE(guint8 *data, gfloat num)
828 GST_WRITE_UINT32_BE (data, u.i);
832 * GST_WRITE_DOUBLE_LE:
833 * @data: memory location
834 * @num: value to store
836 * Store a 64 bit double value in little endian format into the memory buffer.
841 #ifdef _FOOL_GTK_DOC_
842 G_INLINE_FUNC void GST_WRITE_DOUBLE_LE (guint8 *data, gdouble num);
846 GST_WRITE_DOUBLE_LE(guint8 *data, gdouble num)
855 GST_WRITE_UINT64_LE (data, u.i);
859 * GST_WRITE_DOUBLE_BE:
860 * @data: memory location
861 * @num: value to store
863 * Store a 64 bit double value in big endian format into the memory buffer.
868 #ifdef _FOOL_GTK_DOC_
869 G_INLINE_FUNC void GST_WRITE_DOUBLE_BE (guint8 *data, gdouble num);
873 GST_WRITE_DOUBLE_BE(guint8 *data, gdouble num)
882 GST_WRITE_UINT64_BE (data, u.i);
885 /* Miscellaneous utility macros */
889 * @num: integer value to round up
891 * Rounds an integer value up to the next multiple of 2.
893 #define GST_ROUND_UP_2(num) (((num)+1)&~1)
896 * @num: integer value to round up
898 * Rounds an integer value up to the next multiple of 4.
900 #define GST_ROUND_UP_4(num) (((num)+3)&~3)
903 * @num: integer value to round up
905 * Rounds an integer value up to the next multiple of 8.
907 #define GST_ROUND_UP_8(num) (((num)+7)&~7)
910 * @num: integer value to round up
912 * Rounds an integer value up to the next multiple of 16.
914 #define GST_ROUND_UP_16(num) (((num)+15)&~15)
917 * @num: integer value to round up
919 * Rounds an integer value up to the next multiple of 32.
921 #define GST_ROUND_UP_32(num) (((num)+31)&~31)
924 * @num: integer value to round up
926 * Rounds an integer value up to the next multiple of 64.
928 #define GST_ROUND_UP_64(num) (((num)+63)&~63)
932 * @num: integer value to round down
934 * Rounds an integer value down to the next multiple of 2.
938 #define GST_ROUND_DOWN_2(num) ((num)&(~1))
941 * @num: integer value to round down
943 * Rounds an integer value down to the next multiple of 4.
947 #define GST_ROUND_DOWN_4(num) ((num)&(~3))
950 * @num: integer value to round down
952 * Rounds an integer value down to the next multiple of 8.
956 #define GST_ROUND_DOWN_8(num) ((num)&(~7))
959 * @num: integer value to round down
961 * Rounds an integer value down to the next multiple of 16.
965 #define GST_ROUND_DOWN_16(num) ((num)&(~15))
968 * @num: integer value to round down
970 * Rounds an integer value down to the next multiple of 32.
974 #define GST_ROUND_DOWN_32(num) ((num)&(~31))
977 * @num: integer value to round down
979 * Rounds an integer value down to the next multiple of 64.
983 #define GST_ROUND_DOWN_64(num) ((num)&(~63))
985 void gst_object_default_error (GstObject * source,
986 GError * error, gchar * debug);
988 /* element functions */
989 void gst_element_create_all_pads (GstElement *element);
990 GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad,
991 const GstCaps *caps);
993 GstPadTemplate* gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl);
995 G_CONST_RETURN gchar* gst_element_state_get_name (GstState state);
996 G_CONST_RETURN gchar * gst_element_state_change_return_get_name (GstStateChangeReturn state_ret);
998 gboolean gst_element_link (GstElement *src, GstElement *dest);
999 gboolean gst_element_link_many (GstElement *element_1,
1000 GstElement *element_2, ...) G_GNUC_NULL_TERMINATED;
1001 gboolean gst_element_link_filtered (GstElement * src,
1004 void gst_element_unlink (GstElement *src, GstElement *dest);
1005 void gst_element_unlink_many (GstElement *element_1,
1006 GstElement *element_2, ...) G_GNUC_NULL_TERMINATED;
1008 gboolean gst_element_link_pads (GstElement *src, const gchar *srcpadname,
1009 GstElement *dest, const gchar *destpadname);
1010 void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname,
1011 GstElement *dest, const gchar *destpadname);
1013 gboolean gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
1014 GstElement * dest, const gchar * destpadname,
1017 gboolean gst_element_seek_simple (GstElement *element,
1019 GstSeekFlags seek_flags,
1022 /* util elementfactory functions */
1023 gboolean gst_element_factory_can_src_caps(GstElementFactory *factory, const GstCaps *caps);
1024 gboolean gst_element_factory_can_sink_caps(GstElementFactory *factory, const GstCaps *caps);
1026 /* util query functions */
1027 gboolean gst_element_query_position (GstElement *element, GstFormat *format,
1029 gboolean gst_element_query_duration (GstElement *element, GstFormat *format,
1031 gboolean gst_element_query_convert (GstElement *element, GstFormat src_format, gint64 src_val,
1032 GstFormat *dest_format, gint64 *dest_val);
1034 /* element class functions */
1035 void gst_element_class_install_std_props (GstElementClass * klass,
1036 const gchar * first_name, ...) G_GNUC_NULL_TERMINATED;
1039 gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad);
1041 void gst_pad_use_fixed_caps (GstPad *pad);
1042 GstCaps* gst_pad_get_fixed_caps_func (GstPad *pad);
1043 GstCaps* gst_pad_proxy_getcaps (GstPad * pad);
1044 gboolean gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps);
1046 GstElement* gst_pad_get_parent_element (GstPad *pad);
1048 /* util query functions */
1049 gboolean gst_pad_query_position (GstPad *pad, GstFormat *format,
1051 gboolean gst_pad_query_duration (GstPad *pad, GstFormat *format,
1053 gboolean gst_pad_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
1054 GstFormat *dest_format, gint64 *dest_val);
1056 gboolean gst_pad_query_peer_position (GstPad *pad, GstFormat *format,
1058 gboolean gst_pad_query_peer_duration (GstPad *pad, GstFormat *format,
1060 gboolean gst_pad_query_peer_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
1061 GstFormat *dest_format, gint64 *dest_val);
1064 void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
1065 void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
1066 GstPad * gst_bin_find_unlinked_pad (GstBin *bin, GstPadDirection direction);
1067 #ifndef GST_DISABLE_DEPRECATED
1068 GstPad * gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction);
1071 /* buffer functions */
1072 GstBuffer * gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2);
1073 GstBuffer * gst_buffer_join (GstBuffer * buf1, GstBuffer * buf2);
1074 #ifndef GST_DISABLE_DEPRECATED
1075 void gst_buffer_stamp (GstBuffer * dest, const GstBuffer * src);
1076 #endif /* GST_DISABLE_DEPRECATED */
1078 /* atomic functions */
1079 #ifndef GST_DISABLE_DEPRECATED
1080 void gst_atomic_int_set (gint * atomic_int, gint value);
1084 gulong gst_pad_add_data_probe (GstPad * pad,
1088 gulong gst_pad_add_data_probe_full (GstPad * pad,
1091 GDestroyNotify notify);
1093 void gst_pad_remove_data_probe (GstPad * pad, guint handler_id);
1095 gulong gst_pad_add_event_probe (GstPad * pad,
1099 gulong gst_pad_add_event_probe_full (GstPad * pad,
1102 GDestroyNotify notify);
1104 void gst_pad_remove_event_probe (GstPad * pad, guint handler_id);
1106 gulong gst_pad_add_buffer_probe (GstPad * pad,
1110 gulong gst_pad_add_buffer_probe_full (GstPad * pad,
1113 GDestroyNotify notify);
1115 void gst_pad_remove_buffer_probe (GstPad * pad, guint handler_id);
1117 /* tag emission utility functions */
1118 void gst_element_found_tags_for_pad (GstElement * element,
1121 void gst_element_found_tags (GstElement * element,
1124 /* parse utility functions */
1125 GstElement * gst_parse_bin_from_description (const gchar * bin_description,
1126 gboolean ghost_unlinked_pads,
1129 GstElement * gst_parse_bin_from_description_full (const gchar * bin_description,
1130 gboolean ghost_unlinked_pads,
1131 GstParseContext * context,
1132 GstParseFlags flags,
1135 GstClockTime gst_util_get_timestamp (void);
1139 * @GST_SEARCH_MODE_EXACT : Only search for exact matches.
1140 * @GST_SEARCH_MODE_BEFORE: Search for an exact match or the element just before.
1141 * @GST_SEARCH_MODE_AFTER : Search for an exact match or the element just after.
1143 * The different search modes.
1148 GST_SEARCH_MODE_EXACT = 0,
1149 GST_SEARCH_MODE_BEFORE,
1150 GST_SEARCH_MODE_AFTER
1153 gpointer gst_util_array_binary_search (gpointer array, guint num_elements, gsize element_size, GCompareDataFunc search_func, GstSearchMode mode, gconstpointer search_data, gpointer user_data);
1157 #endif /* __GST_UTILS_H__ */