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_CONST;
39 gdouble gst_util_guint64_to_gdouble (guint64 value) G_GNUC_CONST;
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);
67 guint64 gst_util_uint64_scale_round (guint64 val, guint64 num, guint64 denom);
68 guint64 gst_util_uint64_scale_ceil (guint64 val, guint64 num, guint64 denom);
70 guint64 gst_util_uint64_scale_int (guint64 val, gint num, gint denom);
71 guint64 gst_util_uint64_scale_int_round (guint64 val, gint num, gint denom);
72 guint64 gst_util_uint64_scale_int_ceil (guint64 val, gint num, gint denom);
74 guint32 gst_util_seqnum_next (void);
75 gint32 gst_util_seqnum_compare (guint32 s1, guint32 s2);
77 void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad);
78 void gst_print_element_args (GString *buf, gint indent, GstElement *element);
83 * @parent_class_cast: the name of the class cast macro for the parent type
84 * @name: name of the function to call
85 * @args: arguments enclosed in '( )'
87 * Just call the parent handler. This assumes that there is a variable
88 * named parent_class that points to the (duh!) parent class. Note that
89 * this macro is not to be used with things that return something, use
90 * the _WITH_DEFAULT version for that
92 #define GST_CALL_PARENT(parent_class_cast, name, args) \
93 ((parent_class_cast(parent_class)->name != NULL) ? \
94 parent_class_cast(parent_class)->name args : (void) 0)
97 * GST_CALL_PARENT_WITH_DEFAULT:
98 * @parent_class_cast: the name of the class cast macro for the parent type
99 * @name: name of the function to call
100 * @args: arguments enclosed in '( )'
101 * @def_return: default result
103 * Same as GST_CALL_PARENT(), but in case there is no implementation, it
104 * evaluates to @def_return.
106 #define GST_CALL_PARENT_WITH_DEFAULT(parent_class_cast, name, args, def_return)\
107 ((parent_class_cast(parent_class)->name != NULL) ? \
108 parent_class_cast(parent_class)->name args : def_return)
110 /* Define PUT and GET functions for unaligned memory */
111 #define _GST_GET(__data, __idx, __size, __shift) \
112 (((guint##__size) (((const guint8 *) (__data))[__idx])) << (__shift))
114 #define _GST_PUT(__data, __idx, __size, __shift, __num) \
115 (((guint8 *) (__data))[__idx] = (((guint##__size) (__num)) >> (__shift)) & 0xff)
118 * GST_READ_UINT64_BE:
119 * @data: memory location
121 * Read a 64 bit unsigned integer value in big endian format from the memory buffer.
123 #define GST_READ_UINT64_BE(data) (_GST_GET (data, 0, 64, 56) | \
124 _GST_GET (data, 1, 64, 48) | \
125 _GST_GET (data, 2, 64, 40) | \
126 _GST_GET (data, 3, 64, 32) | \
127 _GST_GET (data, 4, 64, 24) | \
128 _GST_GET (data, 5, 64, 16) | \
129 _GST_GET (data, 6, 64, 8) | \
130 _GST_GET (data, 7, 64, 0))
133 * GST_READ_UINT64_LE:
134 * @data: memory location
136 * Read a 64 bit unsigned integer value in little endian format from the memory buffer.
138 #define GST_READ_UINT64_LE(data) (_GST_GET (data, 7, 64, 56) | \
139 _GST_GET (data, 6, 64, 48) | \
140 _GST_GET (data, 5, 64, 40) | \
141 _GST_GET (data, 4, 64, 32) | \
142 _GST_GET (data, 3, 64, 24) | \
143 _GST_GET (data, 2, 64, 16) | \
144 _GST_GET (data, 1, 64, 8) | \
145 _GST_GET (data, 0, 64, 0))
148 * GST_READ_UINT32_BE:
149 * @data: memory location
151 * Read a 32 bit unsigned integer value in big endian format from the memory buffer.
153 #define GST_READ_UINT32_BE(data) (_GST_GET (data, 0, 32, 24) | \
154 _GST_GET (data, 1, 32, 16) | \
155 _GST_GET (data, 2, 32, 8) | \
156 _GST_GET (data, 3, 32, 0))
159 * GST_READ_UINT32_LE:
160 * @data: memory location
162 * Read a 32 bit unsigned integer value in little endian format from the memory buffer.
164 #define GST_READ_UINT32_LE(data) (_GST_GET (data, 3, 32, 24) | \
165 _GST_GET (data, 2, 32, 16) | \
166 _GST_GET (data, 1, 32, 8) | \
167 _GST_GET (data, 0, 32, 0))
170 * GST_READ_UINT24_BE:
171 * @data: memory location
173 * Read a 24 bit unsigned integer value in big endian format from the memory buffer.
177 #define GST_READ_UINT24_BE(data) (_GST_GET (data, 0, 32, 16) | \
178 _GST_GET (data, 1, 32, 8) | \
179 _GST_GET (data, 2, 32, 0))
182 * GST_READ_UINT24_LE:
183 * @data: memory location
185 * Read a 24 bit unsigned integer value in little endian format from the memory buffer.
189 #define GST_READ_UINT24_LE(data) (_GST_GET (data, 2, 32, 16) | \
190 _GST_GET (data, 1, 32, 8) | \
191 _GST_GET (data, 0, 32, 0))
194 * GST_READ_UINT16_BE:
195 * @data: memory location
197 * Read a 16 bit unsigned integer value in big endian format from the memory buffer.
199 #define GST_READ_UINT16_BE(data) (_GST_GET (data, 0, 16, 8) | \
200 _GST_GET (data, 1, 16, 0))
203 * GST_READ_UINT16_LE:
204 * @data: memory location
206 * Read a 16 bit unsigned integer value in little endian format from the memory buffer.
208 #define GST_READ_UINT16_LE(data) (_GST_GET (data, 1, 16, 8) | \
209 _GST_GET (data, 0, 16, 0))
213 * @data: memory location
215 * Read an 8 bit unsigned integer value from the memory buffer.
217 #define GST_READ_UINT8(data) (_GST_GET (data, 0, 8, 0))
220 * GST_WRITE_UINT64_BE:
221 * @data: memory location
222 * @num: value to store
224 * Store a 64 bit unsigned integer value in big endian format into the memory buffer.
226 #define GST_WRITE_UINT64_BE(data, num) do { \
227 _GST_PUT (data, 0, 64, 56, num); \
228 _GST_PUT (data, 1, 64, 48, num); \
229 _GST_PUT (data, 2, 64, 40, num); \
230 _GST_PUT (data, 3, 64, 32, num); \
231 _GST_PUT (data, 4, 64, 24, num); \
232 _GST_PUT (data, 5, 64, 16, num); \
233 _GST_PUT (data, 6, 64, 8, num); \
234 _GST_PUT (data, 7, 64, 0, num); \
238 * GST_WRITE_UINT64_LE:
239 * @data: memory location
240 * @num: value to store
242 * Store a 64 bit unsigned integer value in little endian format into the memory buffer.
244 #define GST_WRITE_UINT64_LE(data, num) do { \
245 _GST_PUT (data, 0, 64, 0, num); \
246 _GST_PUT (data, 1, 64, 8, num); \
247 _GST_PUT (data, 2, 64, 16, num); \
248 _GST_PUT (data, 3, 64, 24, num); \
249 _GST_PUT (data, 4, 64, 32, num); \
250 _GST_PUT (data, 5, 64, 40, num); \
251 _GST_PUT (data, 6, 64, 48, num); \
252 _GST_PUT (data, 7, 64, 56, num); \
256 * GST_WRITE_UINT32_BE:
257 * @data: memory location
258 * @num: value to store
260 * Store a 32 bit unsigned integer value in big endian format into the memory buffer.
262 #define GST_WRITE_UINT32_BE(data, num) do { \
263 _GST_PUT (data, 0, 32, 24, num); \
264 _GST_PUT (data, 1, 32, 16, num); \
265 _GST_PUT (data, 2, 32, 8, num); \
266 _GST_PUT (data, 3, 32, 0, num); \
270 * GST_WRITE_UINT32_LE:
271 * @data: memory location
272 * @num: value to store
274 * Store a 32 bit unsigned integer value in little endian format into the memory buffer.
276 #define GST_WRITE_UINT32_LE(data, num) do { \
277 _GST_PUT (data, 0, 32, 0, num); \
278 _GST_PUT (data, 1, 32, 8, num); \
279 _GST_PUT (data, 2, 32, 16, num); \
280 _GST_PUT (data, 3, 32, 24, num); \
284 * GST_WRITE_UINT24_BE:
285 * @data: memory location
286 * @num: value to store
288 * Store a 24 bit unsigned integer value in big endian format into the memory buffer.
292 #define GST_WRITE_UINT24_BE(data, num) do { \
293 _GST_PUT (data, 0, 32, 16, num); \
294 _GST_PUT (data, 1, 32, 8, num); \
295 _GST_PUT (data, 2, 32, 0, num); \
299 * GST_WRITE_UINT24_LE:
300 * @data: memory location
301 * @num: value to store
303 * Store a 24 bit unsigned integer value in little endian format into the memory buffer.
307 #define GST_WRITE_UINT24_LE(data, num) do { \
308 _GST_PUT (data, 0, 32, 0, num); \
309 _GST_PUT (data, 1, 32, 8, num); \
310 _GST_PUT (data, 2, 32, 16, num); \
314 * GST_WRITE_UINT16_BE:
315 * @data: memory location
316 * @num: value to store
318 * Store a 16 bit unsigned integer value in big endian format into the memory buffer.
320 #define GST_WRITE_UINT16_BE(data, num) do { \
321 _GST_PUT (data, 0, 16, 8, num); \
322 _GST_PUT (data, 1, 16, 0, num); \
326 * GST_WRITE_UINT16_LE:
327 * @data: memory location
328 * @num: value to store
330 * Store a 16 bit unsigned integer value in little endian format into the memory buffer.
332 #define GST_WRITE_UINT16_LE(data, num) do { \
333 _GST_PUT (data, 0, 16, 0, num); \
334 _GST_PUT (data, 1, 16, 8, num); \
339 * @data: memory location
340 * @num: value to store
342 * Store an 8 bit unsigned integer value into the memory buffer.
344 #define GST_WRITE_UINT8(data, num) do { \
345 _GST_PUT (data, 0, 8, 0, num); \
348 /* Float endianness conversion macros */
350 /* FIXME: Remove this once we depend on a GLib version with this */
351 #ifndef GFLOAT_FROM_LE
356 * Swap byte order of a 32-bit floating point value (float).
358 * Returns: @in byte-swapped.
363 #ifdef _FOOL_GTK_DOC_
364 G_INLINE_FUNC gfloat GFLOAT_SWAP_LE_BE (gfloat in);
368 GFLOAT_SWAP_LE_BE(gfloat in)
377 u.i = GUINT32_SWAP_LE_BE (u.i);
382 * GDOUBLE_SWAP_LE_BE:
385 * Swap byte order of a 64-bit floating point value (double).
387 * Returns: @in byte-swapped.
392 #ifdef _FOOL_GTK_DOC_
393 G_INLINE_FUNC gdouble GDOUBLE_SWAP_LE_BE (gdouble in);
396 inline static gdouble
397 GDOUBLE_SWAP_LE_BE(gdouble in)
406 u.i = GUINT64_SWAP_LE_BE (u.i);
414 * Convert 64-bit floating point value (double) from native byte order into
415 * little endian byte order.
424 * Convert 64-bit floating point value (double) from native byte order into
425 * big endian byte order.
434 * Convert 64-bit floating point value (double) from little endian byte order
435 * into native byte order.
444 * Convert 64-bit floating point value (double) from big endian byte order
445 * into native byte order.
455 * Convert 32-bit floating point value (float) from native byte order into
456 * little endian byte order.
465 * Convert 32-bit floating point value (float) from native byte order into
466 * big endian byte order.
475 * Convert 32-bit floating point value (float) from little endian byte order
476 * into native byte order.
485 * Convert 32-bit floating point value (float) from big endian byte order
486 * into native byte order.
492 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
493 #define GFLOAT_TO_LE(val) ((gfloat) (val))
494 #define GFLOAT_TO_BE(val) (GFLOAT_SWAP_LE_BE (val))
495 #define GDOUBLE_TO_LE(val) ((gdouble) (val))
496 #define GDOUBLE_TO_BE(val) (GDOUBLE_SWAP_LE_BE (val))
498 #elif G_BYTE_ORDER == G_BIG_ENDIAN
499 #define GFLOAT_TO_LE(val) (GFLOAT_SWAP_LE_BE (val))
500 #define GFLOAT_TO_BE(val) ((gfloat) (val))
501 #define GDOUBLE_TO_LE(val) (GDOUBLE_SWAP_LE_BE (val))
502 #define GDOUBLE_TO_BE(val) ((gdouble) (val))
504 #else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
505 #error unknown ENDIAN type
506 #endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
508 #define GFLOAT_FROM_LE(val) (GFLOAT_TO_LE (val))
509 #define GFLOAT_FROM_BE(val) (GFLOAT_TO_BE (val))
510 #define GDOUBLE_FROM_LE(val) (GDOUBLE_TO_LE (val))
511 #define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val))
513 #endif /* !defined(GFLOAT_FROM_LE) */
517 * @data: memory location
519 * Read a 32 bit float value in little endian format from the memory buffer.
521 * Returns: The floating point value read from @data
526 #ifdef _FOOL_GTK_DOC_
527 G_INLINE_FUNC gfloat GST_READ_FLOAT_LE (const guint8 *data);
531 GST_READ_FLOAT_LE(const guint8 *data)
539 u.i = GST_READ_UINT32_LE (data);
545 * @data: memory location
547 * Read a 32 bit float value in big endian format from the memory buffer.
549 * Returns: The floating point value read from @data
554 #ifdef _FOOL_GTK_DOC_
555 G_INLINE_FUNC gfloat GST_READ_FLOAT_BE (const guint8 *data);
559 GST_READ_FLOAT_BE(const guint8 *data)
567 u.i = GST_READ_UINT32_BE (data);
572 * GST_READ_DOUBLE_LE:
573 * @data: memory location
575 * Read a 64 bit double value in little endian format from the memory buffer.
577 * Returns: The double-precision floating point value read from @data
582 #ifdef _FOOL_GTK_DOC_
583 G_INLINE_FUNC gdouble GST_READ_DOUBLE_LE (const guint8 *data);
586 inline static gdouble
587 GST_READ_DOUBLE_LE(const guint8 *data)
595 u.i = GST_READ_UINT64_LE (data);
600 * GST_READ_DOUBLE_BE:
601 * @data: memory location
603 * Read a 64 bit double value in big endian format from the memory buffer.
605 * Returns: The double-precision floating point value read from @data
610 #ifdef _FOOL_GTK_DOC_
611 G_INLINE_FUNC gdouble GST_READ_DOUBLE_BE (const guint8 *data);
614 inline static gdouble
615 GST_READ_DOUBLE_BE(const guint8 *data)
623 u.i = GST_READ_UINT64_BE (data);
628 * GST_WRITE_FLOAT_LE:
629 * @data: memory location
630 * @num: value to store
632 * Store a 32 bit float value in little endian format into the memory buffer.
637 #ifdef _FOOL_GTK_DOC_
638 G_INLINE_FUNC void GST_WRITE_FLOAT_LE (guint8 *data, gfloat num);
642 GST_WRITE_FLOAT_LE(guint8 *data, gfloat num)
651 GST_WRITE_UINT32_LE (data, u.i);
655 * GST_WRITE_FLOAT_BE:
656 * @data: memory location
657 * @num: value to store
659 * Store a 32 bit float value in big endian format into the memory buffer.
664 #ifdef _FOOL_GTK_DOC_
665 G_INLINE_FUNC void GST_WRITE_FLOAT_BE (guint8 *data, gfloat num);
669 GST_WRITE_FLOAT_BE(guint8 *data, gfloat num)
678 GST_WRITE_UINT32_BE (data, u.i);
682 * GST_WRITE_DOUBLE_LE:
683 * @data: memory location
684 * @num: value to store
686 * Store a 64 bit double value in little endian format into the memory buffer.
691 #ifdef _FOOL_GTK_DOC_
692 G_INLINE_FUNC void GST_WRITE_DOUBLE_LE (guint8 *data, gdouble num);
696 GST_WRITE_DOUBLE_LE(guint8 *data, gdouble num)
705 GST_WRITE_UINT64_LE (data, u.i);
709 * GST_WRITE_DOUBLE_BE:
710 * @data: memory location
711 * @num: value to store
713 * Store a 64 bit double value in big endian format into the memory buffer.
718 #ifdef _FOOL_GTK_DOC_
719 G_INLINE_FUNC void GST_WRITE_DOUBLE_BE (guint8 *data, gdouble num);
723 GST_WRITE_DOUBLE_BE(guint8 *data, gdouble num)
732 GST_WRITE_UINT64_BE (data, u.i);
735 /* Miscellaneous utility macros */
739 * @num: integer value to round up
741 * Rounds an integer value up to the next multiple of 2.
743 #define GST_ROUND_UP_2(num) (((num)+1)&~1)
746 * @num: integer value to round up
748 * Rounds an integer value up to the next multiple of 4.
750 #define GST_ROUND_UP_4(num) (((num)+3)&~3)
753 * @num: integer value to round up
755 * Rounds an integer value up to the next multiple of 8.
757 #define GST_ROUND_UP_8(num) (((num)+7)&~7)
760 * @num: integer value to round up
762 * Rounds an integer value up to the next multiple of 16.
764 #define GST_ROUND_UP_16(num) (((num)+15)&~15)
767 * @num: integer value to round up
769 * Rounds an integer value up to the next multiple of 32.
771 #define GST_ROUND_UP_32(num) (((num)+31)&~31)
774 * @num: integer value to round up
776 * Rounds an integer value up to the next multiple of 64.
778 #define GST_ROUND_UP_64(num) (((num)+63)&~63)
782 * @num: integer value to round down
784 * Rounds an integer value down to the next multiple of 2.
788 #define GST_ROUND_DOWN_2(num) ((num)&(~1))
791 * @num: integer value to round down
793 * Rounds an integer value down to the next multiple of 4.
797 #define GST_ROUND_DOWN_4(num) ((num)&(~3))
800 * @num: integer value to round down
802 * Rounds an integer value down to the next multiple of 8.
806 #define GST_ROUND_DOWN_8(num) ((num)&(~7))
809 * @num: integer value to round down
811 * Rounds an integer value down to the next multiple of 16.
815 #define GST_ROUND_DOWN_16(num) ((num)&(~15))
818 * @num: integer value to round down
820 * Rounds an integer value down to the next multiple of 32.
824 #define GST_ROUND_DOWN_32(num) ((num)&(~31))
827 * @num: integer value to round down
829 * Rounds an integer value down to the next multiple of 64.
833 #define GST_ROUND_DOWN_64(num) ((num)&(~63))
835 void gst_object_default_error (GstObject * source,
836 const GError * error,
837 const gchar * debug);
839 /* element functions */
840 void gst_element_create_all_pads (GstElement *element);
841 GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad,
844 GstPadTemplate* gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl);
846 const gchar* gst_element_state_get_name (GstState state);
847 const gchar * gst_element_state_change_return_get_name (GstStateChangeReturn state_ret);
849 gboolean gst_element_link (GstElement *src, GstElement *dest);
850 gboolean gst_element_link_many (GstElement *element_1,
851 GstElement *element_2, ...) G_GNUC_NULL_TERMINATED;
852 gboolean gst_element_link_filtered (GstElement * src,
855 void gst_element_unlink (GstElement *src, GstElement *dest);
856 void gst_element_unlink_many (GstElement *element_1,
857 GstElement *element_2, ...) G_GNUC_NULL_TERMINATED;
859 gboolean gst_element_link_pads (GstElement *src, const gchar *srcpadname,
860 GstElement *dest, const gchar *destpadname);
861 gboolean gst_element_link_pads_full (GstElement *src, const gchar *srcpadname,
862 GstElement *dest, const gchar *destpadname,
863 GstPadLinkCheck flags);
864 void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname,
865 GstElement *dest, const gchar *destpadname);
867 gboolean gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
868 GstElement * dest, const gchar * destpadname,
871 gboolean gst_element_seek_simple (GstElement *element,
873 GstSeekFlags seek_flags,
876 /* util elementfactory functions */
877 gboolean gst_element_factory_can_sink_all_caps (GstElementFactory *factory, const GstCaps *caps);
878 gboolean gst_element_factory_can_src_all_caps (GstElementFactory *factory, const GstCaps *caps);
879 gboolean gst_element_factory_can_sink_any_caps (GstElementFactory *factory, const GstCaps *caps);
880 gboolean gst_element_factory_can_src_any_caps (GstElementFactory *factory, const GstCaps *caps);
882 /* util query functions */
883 gboolean gst_element_query_position (GstElement *element, GstFormat format, gint64 *cur);
884 gboolean gst_element_query_duration (GstElement *element, GstFormat format, gint64 *duration);
885 gboolean gst_element_query_convert (GstElement *element, GstFormat src_format, gint64 src_val,
886 GstFormat dest_format, gint64 *dest_val);
889 void gst_pad_use_fixed_caps (GstPad *pad);
890 GstElement* gst_pad_get_parent_element (GstPad *pad);
892 /* util query functions */
893 gboolean gst_pad_proxy_query_accept_caps (GstPad *pad, GstQuery *query);
894 gboolean gst_pad_proxy_query_caps (GstPad *pad, GstQuery *query);
896 gboolean gst_pad_query_position (GstPad *pad, GstFormat format, gint64 *cur);
897 gboolean gst_pad_query_duration (GstPad *pad, GstFormat format, gint64 *duration);
898 gboolean gst_pad_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
899 GstFormat dest_format, gint64 *dest_val);
900 GstCaps * gst_pad_query_caps (GstPad *pad, GstCaps *filter);
901 gboolean gst_pad_query_accept_caps (GstPad *pad, GstCaps *caps);
904 gboolean gst_pad_peer_query_position (GstPad *pad, GstFormat format, gint64 *cur);
905 gboolean gst_pad_peer_query_duration (GstPad *pad, GstFormat format, gint64 *duration);
906 gboolean gst_pad_peer_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
907 GstFormat dest_format, gint64 *dest_val);
908 GstCaps * gst_pad_peer_query_caps (GstPad * pad, GstCaps *filter);
909 gboolean gst_pad_peer_query_accept_caps (GstPad * pad, GstCaps *caps);
912 void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
913 void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
914 GstPad * gst_bin_find_unlinked_pad (GstBin *bin, GstPadDirection direction);
916 /* parse utility functions */
917 GstElement * gst_parse_bin_from_description (const gchar * bin_description,
918 gboolean ghost_unlinked_pads,
921 GstElement * gst_parse_bin_from_description_full (const gchar * bin_description,
922 gboolean ghost_unlinked_pads,
923 GstParseContext * context,
927 GstClockTime gst_util_get_timestamp (void);
931 * @GST_SEARCH_MODE_EXACT : Only search for exact matches.
932 * @GST_SEARCH_MODE_BEFORE: Search for an exact match or the element just before.
933 * @GST_SEARCH_MODE_AFTER : Search for an exact match or the element just after.
935 * The different search modes.
940 GST_SEARCH_MODE_EXACT = 0,
941 GST_SEARCH_MODE_BEFORE,
942 GST_SEARCH_MODE_AFTER
945 gpointer gst_util_array_binary_search (gpointer array, guint num_elements,
946 gsize element_size, GCompareDataFunc search_func,
947 GstSearchMode mode, gconstpointer search_data,
950 /* fraction operations */
951 gint gst_util_greatest_common_divisor (gint a, gint b);
952 gint64 gst_util_greatest_common_divisor_int64 (gint64 a, gint64 b);
954 void gst_util_fraction_to_double (gint src_n, gint src_d, gdouble *dest);
955 void gst_util_double_to_fraction (gdouble src, gint *dest_n, gint *dest_d);
957 gboolean gst_util_fraction_multiply (gint a_n, gint a_d, gint b_n, gint b_d,
958 gint *res_n, gint *res_d);
959 gboolean gst_util_fraction_add (gint a_n, gint a_d, gint b_n, gint b_d,
960 gint *res_n, gint *res_d);
961 gint gst_util_fraction_compare (gint a_n, gint a_d, gint b_n, gint b_d);
966 #endif /* __GST_UTILS_H__ */