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);
81 GType gst_type_register_static_full (GType parent_type,
82 const gchar *type_name,
84 GBaseInitFunc base_init,
85 GBaseFinalizeFunc base_finalize,
86 GClassInitFunc class_init,
87 GClassFinalizeFunc class_finalize,
88 gconstpointer class_data,
91 GInstanceInitFunc instance_init,
92 const GTypeValueTable *value_table,
97 * @parent_class_cast: the name of the class cast macro for the parent type
98 * @name: name of the function to call
99 * @args: arguments enclosed in '( )'
101 * Just call the parent handler. This assumes that there is a variable
102 * named parent_class that points to the (duh!) parent class. Note that
103 * this macro is not to be used with things that return something, use
104 * the _WITH_DEFAULT version for that
106 #define GST_CALL_PARENT(parent_class_cast, name, args) \
107 ((parent_class_cast(parent_class)->name != NULL) ? \
108 parent_class_cast(parent_class)->name args : (void) 0)
111 * GST_CALL_PARENT_WITH_DEFAULT:
112 * @parent_class_cast: the name of the class cast macro for the parent type
113 * @name: name of the function to call
114 * @args: arguments enclosed in '( )'
115 * @def_return: default result
117 * Same as GST_CALL_PARENT(), but in case there is no implementation, it
118 * evaluates to @def_return.
120 #define GST_CALL_PARENT_WITH_DEFAULT(parent_class_cast, name, args, def_return)\
121 ((parent_class_cast(parent_class)->name != NULL) ? \
122 parent_class_cast(parent_class)->name args : def_return)
124 /* Define PUT and GET functions for unaligned memory */
125 #define _GST_GET(__data, __idx, __size, __shift) \
126 (((guint##__size) (((const guint8 *) (__data))[__idx])) << (__shift))
128 #define _GST_PUT(__data, __idx, __size, __shift, __num) \
129 (((guint8 *) (__data))[__idx] = (((guint##__size) (__num)) >> (__shift)) & 0xff)
132 * GST_READ_UINT64_BE:
133 * @data: memory location
135 * Read a 64 bit unsigned integer value in big endian format from the memory buffer.
137 #define GST_READ_UINT64_BE(data) (_GST_GET (data, 0, 64, 56) | \
138 _GST_GET (data, 1, 64, 48) | \
139 _GST_GET (data, 2, 64, 40) | \
140 _GST_GET (data, 3, 64, 32) | \
141 _GST_GET (data, 4, 64, 24) | \
142 _GST_GET (data, 5, 64, 16) | \
143 _GST_GET (data, 6, 64, 8) | \
144 _GST_GET (data, 7, 64, 0))
147 * GST_READ_UINT64_LE:
148 * @data: memory location
150 * Read a 64 bit unsigned integer value in little endian format from the memory buffer.
152 #define GST_READ_UINT64_LE(data) (_GST_GET (data, 7, 64, 56) | \
153 _GST_GET (data, 6, 64, 48) | \
154 _GST_GET (data, 5, 64, 40) | \
155 _GST_GET (data, 4, 64, 32) | \
156 _GST_GET (data, 3, 64, 24) | \
157 _GST_GET (data, 2, 64, 16) | \
158 _GST_GET (data, 1, 64, 8) | \
159 _GST_GET (data, 0, 64, 0))
162 * GST_READ_UINT32_BE:
163 * @data: memory location
165 * Read a 32 bit unsigned integer value in big endian format from the memory buffer.
167 #define GST_READ_UINT32_BE(data) (_GST_GET (data, 0, 32, 24) | \
168 _GST_GET (data, 1, 32, 16) | \
169 _GST_GET (data, 2, 32, 8) | \
170 _GST_GET (data, 3, 32, 0))
173 * GST_READ_UINT32_LE:
174 * @data: memory location
176 * Read a 32 bit unsigned integer value in little endian format from the memory buffer.
178 #define GST_READ_UINT32_LE(data) (_GST_GET (data, 3, 32, 24) | \
179 _GST_GET (data, 2, 32, 16) | \
180 _GST_GET (data, 1, 32, 8) | \
181 _GST_GET (data, 0, 32, 0))
184 * GST_READ_UINT24_BE:
185 * @data: memory location
187 * Read a 24 bit unsigned integer value in big endian format from the memory buffer.
191 #define GST_READ_UINT24_BE(data) (_GST_GET (data, 0, 32, 16) | \
192 _GST_GET (data, 1, 32, 8) | \
193 _GST_GET (data, 2, 32, 0))
196 * GST_READ_UINT24_LE:
197 * @data: memory location
199 * Read a 24 bit unsigned integer value in little endian format from the memory buffer.
203 #define GST_READ_UINT24_LE(data) (_GST_GET (data, 2, 32, 16) | \
204 _GST_GET (data, 1, 32, 8) | \
205 _GST_GET (data, 0, 32, 0))
208 * GST_READ_UINT16_BE:
209 * @data: memory location
211 * Read a 16 bit unsigned integer value in big endian format from the memory buffer.
213 #define GST_READ_UINT16_BE(data) (_GST_GET (data, 0, 16, 8) | \
214 _GST_GET (data, 1, 16, 0))
217 * GST_READ_UINT16_LE:
218 * @data: memory location
220 * Read a 16 bit unsigned integer value in little endian format from the memory buffer.
222 #define GST_READ_UINT16_LE(data) (_GST_GET (data, 1, 16, 8) | \
223 _GST_GET (data, 0, 16, 0))
227 * @data: memory location
229 * Read an 8 bit unsigned integer value from the memory buffer.
231 #define GST_READ_UINT8(data) (_GST_GET (data, 0, 8, 0))
234 * GST_WRITE_UINT64_BE:
235 * @data: memory location
236 * @num: value to store
238 * Store a 64 bit unsigned integer value in big endian format into the memory buffer.
240 #define GST_WRITE_UINT64_BE(data, num) do { \
241 _GST_PUT (data, 0, 64, 56, num); \
242 _GST_PUT (data, 1, 64, 48, num); \
243 _GST_PUT (data, 2, 64, 40, num); \
244 _GST_PUT (data, 3, 64, 32, num); \
245 _GST_PUT (data, 4, 64, 24, num); \
246 _GST_PUT (data, 5, 64, 16, num); \
247 _GST_PUT (data, 6, 64, 8, num); \
248 _GST_PUT (data, 7, 64, 0, num); \
252 * GST_WRITE_UINT64_LE:
253 * @data: memory location
254 * @num: value to store
256 * Store a 64 bit unsigned integer value in little endian format into the memory buffer.
258 #define GST_WRITE_UINT64_LE(data, num) do { \
259 _GST_PUT (data, 0, 64, 0, num); \
260 _GST_PUT (data, 1, 64, 8, num); \
261 _GST_PUT (data, 2, 64, 16, num); \
262 _GST_PUT (data, 3, 64, 24, num); \
263 _GST_PUT (data, 4, 64, 32, num); \
264 _GST_PUT (data, 5, 64, 40, num); \
265 _GST_PUT (data, 6, 64, 48, num); \
266 _GST_PUT (data, 7, 64, 56, num); \
270 * GST_WRITE_UINT32_BE:
271 * @data: memory location
272 * @num: value to store
274 * Store a 32 bit unsigned integer value in big endian format into the memory buffer.
276 #define GST_WRITE_UINT32_BE(data, num) do { \
277 _GST_PUT (data, 0, 32, 24, num); \
278 _GST_PUT (data, 1, 32, 16, num); \
279 _GST_PUT (data, 2, 32, 8, num); \
280 _GST_PUT (data, 3, 32, 0, num); \
284 * GST_WRITE_UINT32_LE:
285 * @data: memory location
286 * @num: value to store
288 * Store a 32 bit unsigned integer value in little endian format into the memory buffer.
290 #define GST_WRITE_UINT32_LE(data, num) do { \
291 _GST_PUT (data, 0, 32, 0, num); \
292 _GST_PUT (data, 1, 32, 8, num); \
293 _GST_PUT (data, 2, 32, 16, num); \
294 _GST_PUT (data, 3, 32, 24, num); \
298 * GST_WRITE_UINT24_BE:
299 * @data: memory location
300 * @num: value to store
302 * Store a 24 bit unsigned integer value in big endian format into the memory buffer.
306 #define GST_WRITE_UINT24_BE(data, num) do { \
307 _GST_PUT (data, 0, 32, 16, num); \
308 _GST_PUT (data, 1, 32, 8, num); \
309 _GST_PUT (data, 2, 32, 0, num); \
313 * GST_WRITE_UINT24_LE:
314 * @data: memory location
315 * @num: value to store
317 * Store a 24 bit unsigned integer value in little endian format into the memory buffer.
321 #define GST_WRITE_UINT24_LE(data, num) do { \
322 _GST_PUT (data, 0, 32, 0, num); \
323 _GST_PUT (data, 1, 32, 8, num); \
324 _GST_PUT (data, 2, 32, 16, num); \
328 * GST_WRITE_UINT16_BE:
329 * @data: memory location
330 * @num: value to store
332 * Store a 16 bit unsigned integer value in big endian format into the memory buffer.
334 #define GST_WRITE_UINT16_BE(data, num) do { \
335 _GST_PUT (data, 0, 16, 8, num); \
336 _GST_PUT (data, 1, 16, 0, num); \
340 * GST_WRITE_UINT16_LE:
341 * @data: memory location
342 * @num: value to store
344 * Store a 16 bit unsigned integer value in little endian format into the memory buffer.
346 #define GST_WRITE_UINT16_LE(data, num) do { \
347 _GST_PUT (data, 0, 16, 0, num); \
348 _GST_PUT (data, 1, 16, 8, num); \
353 * @data: memory location
354 * @num: value to store
356 * Store an 8 bit unsigned integer value into the memory buffer.
358 #define GST_WRITE_UINT8(data, num) do { \
359 _GST_PUT (data, 0, 8, 0, num); \
362 /* Float endianness conversion macros */
364 /* FIXME: Remove this once we depend on a GLib version with this */
365 #ifndef GFLOAT_FROM_LE
370 * Swap byte order of a 32-bit floating point value (float).
372 * Returns: @in byte-swapped.
377 #ifdef _FOOL_GTK_DOC_
378 G_INLINE_FUNC gfloat GFLOAT_SWAP_LE_BE (gfloat in);
382 GFLOAT_SWAP_LE_BE(gfloat in)
391 u.i = GUINT32_SWAP_LE_BE (u.i);
396 * GDOUBLE_SWAP_LE_BE:
399 * Swap byte order of a 64-bit floating point value (double).
401 * Returns: @in byte-swapped.
406 #ifdef _FOOL_GTK_DOC_
407 G_INLINE_FUNC gdouble GDOUBLE_SWAP_LE_BE (gdouble in);
410 inline static gdouble
411 GDOUBLE_SWAP_LE_BE(gdouble in)
420 u.i = GUINT64_SWAP_LE_BE (u.i);
428 * Convert 64-bit floating point value (double) from native byte order into
429 * little endian byte order.
438 * Convert 64-bit floating point value (double) from native byte order into
439 * big endian byte order.
448 * Convert 64-bit floating point value (double) from little endian byte order
449 * into native byte order.
458 * Convert 64-bit floating point value (double) from big endian byte order
459 * into native byte order.
469 * Convert 32-bit floating point value (float) from native byte order into
470 * little endian byte order.
479 * Convert 32-bit floating point value (float) from native byte order into
480 * big endian byte order.
489 * Convert 32-bit floating point value (float) from little endian byte order
490 * into native byte order.
499 * Convert 32-bit floating point value (float) from big endian byte order
500 * into native byte order.
506 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
507 #define GFLOAT_TO_LE(val) ((gfloat) (val))
508 #define GFLOAT_TO_BE(val) (GFLOAT_SWAP_LE_BE (val))
509 #define GDOUBLE_TO_LE(val) ((gdouble) (val))
510 #define GDOUBLE_TO_BE(val) (GDOUBLE_SWAP_LE_BE (val))
512 #elif G_BYTE_ORDER == G_BIG_ENDIAN
513 #define GFLOAT_TO_LE(val) (GFLOAT_SWAP_LE_BE (val))
514 #define GFLOAT_TO_BE(val) ((gfloat) (val))
515 #define GDOUBLE_TO_LE(val) (GDOUBLE_SWAP_LE_BE (val))
516 #define GDOUBLE_TO_BE(val) ((gdouble) (val))
518 #else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
519 #error unknown ENDIAN type
520 #endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
522 #define GFLOAT_FROM_LE(val) (GFLOAT_TO_LE (val))
523 #define GFLOAT_FROM_BE(val) (GFLOAT_TO_BE (val))
524 #define GDOUBLE_FROM_LE(val) (GDOUBLE_TO_LE (val))
525 #define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val))
527 #endif /* !defined(GFLOAT_FROM_LE) */
531 * @data: memory location
533 * Read a 32 bit float value in little endian format from the memory buffer.
535 * Returns: The floating point value read from @data
540 #ifdef _FOOL_GTK_DOC_
541 G_INLINE_FUNC gfloat GST_READ_FLOAT_LE (const guint8 *data);
545 GST_READ_FLOAT_LE(const guint8 *data)
553 u.i = GST_READ_UINT32_LE (data);
559 * @data: memory location
561 * Read a 32 bit float value in big endian format from the memory buffer.
563 * Returns: The floating point value read from @data
568 #ifdef _FOOL_GTK_DOC_
569 G_INLINE_FUNC gfloat GST_READ_FLOAT_BE (const guint8 *data);
573 GST_READ_FLOAT_BE(const guint8 *data)
581 u.i = GST_READ_UINT32_BE (data);
586 * GST_READ_DOUBLE_LE:
587 * @data: memory location
589 * Read a 64 bit double value in little endian format from the memory buffer.
591 * Returns: The double-precision floating point value read from @data
596 #ifdef _FOOL_GTK_DOC_
597 G_INLINE_FUNC gdouble GST_READ_DOUBLE_LE (const guint8 *data);
600 inline static gdouble
601 GST_READ_DOUBLE_LE(const guint8 *data)
609 u.i = GST_READ_UINT64_LE (data);
614 * GST_READ_DOUBLE_BE:
615 * @data: memory location
617 * Read a 64 bit double value in big endian format from the memory buffer.
619 * Returns: The double-precision floating point value read from @data
624 #ifdef _FOOL_GTK_DOC_
625 G_INLINE_FUNC gdouble GST_READ_DOUBLE_BE (const guint8 *data);
628 inline static gdouble
629 GST_READ_DOUBLE_BE(const guint8 *data)
637 u.i = GST_READ_UINT64_BE (data);
642 * GST_WRITE_FLOAT_LE:
643 * @data: memory location
644 * @num: value to store
646 * Store a 32 bit float value in little endian format into the memory buffer.
651 #ifdef _FOOL_GTK_DOC_
652 G_INLINE_FUNC void GST_WRITE_FLOAT_LE (guint8 *data, gfloat num);
656 GST_WRITE_FLOAT_LE(guint8 *data, gfloat num)
665 GST_WRITE_UINT32_LE (data, u.i);
669 * GST_WRITE_FLOAT_BE:
670 * @data: memory location
671 * @num: value to store
673 * Store a 32 bit float value in big endian format into the memory buffer.
678 #ifdef _FOOL_GTK_DOC_
679 G_INLINE_FUNC void GST_WRITE_FLOAT_BE (guint8 *data, gfloat num);
683 GST_WRITE_FLOAT_BE(guint8 *data, gfloat num)
692 GST_WRITE_UINT32_BE (data, u.i);
696 * GST_WRITE_DOUBLE_LE:
697 * @data: memory location
698 * @num: value to store
700 * Store a 64 bit double value in little endian format into the memory buffer.
705 #ifdef _FOOL_GTK_DOC_
706 G_INLINE_FUNC void GST_WRITE_DOUBLE_LE (guint8 *data, gdouble num);
710 GST_WRITE_DOUBLE_LE(guint8 *data, gdouble num)
719 GST_WRITE_UINT64_LE (data, u.i);
723 * GST_WRITE_DOUBLE_BE:
724 * @data: memory location
725 * @num: value to store
727 * Store a 64 bit double value in big endian format into the memory buffer.
732 #ifdef _FOOL_GTK_DOC_
733 G_INLINE_FUNC void GST_WRITE_DOUBLE_BE (guint8 *data, gdouble num);
737 GST_WRITE_DOUBLE_BE(guint8 *data, gdouble num)
746 GST_WRITE_UINT64_BE (data, u.i);
749 /* Miscellaneous utility macros */
753 * @num: integer value to round up
755 * Rounds an integer value up to the next multiple of 2.
757 #define GST_ROUND_UP_2(num) (((num)+1)&~1)
760 * @num: integer value to round up
762 * Rounds an integer value up to the next multiple of 4.
764 #define GST_ROUND_UP_4(num) (((num)+3)&~3)
767 * @num: integer value to round up
769 * Rounds an integer value up to the next multiple of 8.
771 #define GST_ROUND_UP_8(num) (((num)+7)&~7)
774 * @num: integer value to round up
776 * Rounds an integer value up to the next multiple of 16.
778 #define GST_ROUND_UP_16(num) (((num)+15)&~15)
781 * @num: integer value to round up
783 * Rounds an integer value up to the next multiple of 32.
785 #define GST_ROUND_UP_32(num) (((num)+31)&~31)
788 * @num: integer value to round up
790 * Rounds an integer value up to the next multiple of 64.
792 #define GST_ROUND_UP_64(num) (((num)+63)&~63)
796 * @num: integer value to round down
798 * Rounds an integer value down to the next multiple of 2.
802 #define GST_ROUND_DOWN_2(num) ((num)&(~1))
805 * @num: integer value to round down
807 * Rounds an integer value down to the next multiple of 4.
811 #define GST_ROUND_DOWN_4(num) ((num)&(~3))
814 * @num: integer value to round down
816 * Rounds an integer value down to the next multiple of 8.
820 #define GST_ROUND_DOWN_8(num) ((num)&(~7))
823 * @num: integer value to round down
825 * Rounds an integer value down to the next multiple of 16.
829 #define GST_ROUND_DOWN_16(num) ((num)&(~15))
832 * @num: integer value to round down
834 * Rounds an integer value down to the next multiple of 32.
838 #define GST_ROUND_DOWN_32(num) ((num)&(~31))
841 * @num: integer value to round down
843 * Rounds an integer value down to the next multiple of 64.
847 #define GST_ROUND_DOWN_64(num) ((num)&(~63))
849 void gst_object_default_error (GstObject * source,
850 const GError * error,
851 const gchar * debug);
853 /* element functions */
854 void gst_element_create_all_pads (GstElement *element);
855 GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad,
856 const GstCaps *caps);
858 GstPadTemplate* gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl);
860 const gchar* gst_element_state_get_name (GstState state);
861 const gchar * gst_element_state_change_return_get_name (GstStateChangeReturn state_ret);
863 gboolean gst_element_link (GstElement *src, GstElement *dest);
864 gboolean gst_element_link_many (GstElement *element_1,
865 GstElement *element_2, ...) G_GNUC_NULL_TERMINATED;
866 gboolean gst_element_link_filtered (GstElement * src,
869 void gst_element_unlink (GstElement *src, GstElement *dest);
870 void gst_element_unlink_many (GstElement *element_1,
871 GstElement *element_2, ...) G_GNUC_NULL_TERMINATED;
873 gboolean gst_element_link_pads (GstElement *src, const gchar *srcpadname,
874 GstElement *dest, const gchar *destpadname);
875 gboolean gst_element_link_pads_full (GstElement *src, const gchar *srcpadname,
876 GstElement *dest, const gchar *destpadname,
877 GstPadLinkCheck flags);
878 void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname,
879 GstElement *dest, const gchar *destpadname);
881 gboolean gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
882 GstElement * dest, const gchar * destpadname,
885 gboolean gst_element_seek_simple (GstElement *element,
887 GstSeekFlags seek_flags,
890 /* util elementfactory functions */
891 gboolean gst_element_factory_can_sink_all_caps (GstElementFactory *factory, const GstCaps *caps);
892 gboolean gst_element_factory_can_src_all_caps (GstElementFactory *factory, const GstCaps *caps);
893 gboolean gst_element_factory_can_sink_any_caps (GstElementFactory *factory, const GstCaps *caps);
894 gboolean gst_element_factory_can_src_any_caps (GstElementFactory *factory, const GstCaps *caps);
896 /* util query functions */
897 gboolean gst_element_query_position (GstElement *element, GstFormat format, gint64 *cur);
898 gboolean gst_element_query_duration (GstElement *element, GstFormat format, gint64 *duration);
899 gboolean gst_element_query_convert (GstElement *element, GstFormat src_format, gint64 src_val,
900 GstFormat dest_format, gint64 *dest_val);
902 /* element class functions */
903 void gst_element_class_install_std_props (GstElementClass * klass,
904 const gchar * first_name, ...) G_GNUC_NULL_TERMINATED;
907 void gst_pad_use_fixed_caps (GstPad *pad);
908 GstCaps* gst_pad_proxy_getcaps (GstPad * pad, GstCaps * filter);
910 GstElement* gst_pad_get_parent_element (GstPad *pad);
912 /* util query functions */
913 gboolean gst_pad_query_position (GstPad *pad, GstFormat format, gint64 *cur);
914 gboolean gst_pad_query_duration (GstPad *pad, GstFormat format, gint64 *duration);
915 gboolean gst_pad_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
916 GstFormat dest_format, gint64 *dest_val);
918 gboolean gst_pad_query_peer_position (GstPad *pad, GstFormat format, gint64 *cur);
919 gboolean gst_pad_query_peer_duration (GstPad *pad, GstFormat format, gint64 *duration);
920 gboolean gst_pad_query_peer_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
921 GstFormat dest_format, gint64 *dest_val);
924 void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
925 void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
926 GstPad * gst_bin_find_unlinked_pad (GstBin *bin, GstPadDirection direction);
928 /* buffer functions */
929 GstBuffer * gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2);
930 GstBuffer * gst_buffer_join (GstBuffer * buf1, GstBuffer * buf2);
932 /* tag emission utility functions */
933 void gst_element_found_tags_for_pad (GstElement * element,
936 void gst_element_found_tags (GstElement * element,
939 /* parse utility functions */
940 GstElement * gst_parse_bin_from_description (const gchar * bin_description,
941 gboolean ghost_unlinked_pads,
944 GstElement * gst_parse_bin_from_description_full (const gchar * bin_description,
945 gboolean ghost_unlinked_pads,
946 GstParseContext * context,
950 GstClockTime gst_util_get_timestamp (void);
954 * @GST_SEARCH_MODE_EXACT : Only search for exact matches.
955 * @GST_SEARCH_MODE_BEFORE: Search for an exact match or the element just before.
956 * @GST_SEARCH_MODE_AFTER : Search for an exact match or the element just after.
958 * The different search modes.
963 GST_SEARCH_MODE_EXACT = 0,
964 GST_SEARCH_MODE_BEFORE,
965 GST_SEARCH_MODE_AFTER
968 gpointer gst_util_array_binary_search (gpointer array, guint num_elements,
969 gsize element_size, GCompareDataFunc search_func,
970 GstSearchMode mode, gconstpointer search_data,
973 gint gst_util_greatest_common_divisor (gint a, gint b);
974 void gst_util_fraction_to_double (gint src_n, gint src_d, gdouble *dest);
975 void gst_util_double_to_fraction (gdouble src, gint *dest_n, gint *dest_d);
976 gboolean gst_util_fraction_multiply (gint a_n, gint a_d, gint b_n, gint b_d, gint *res_n, gint *res_d);
977 gboolean gst_util_fraction_add (gint a_n, gint a_d, gint b_n, gint b_d, gint *res_n, gint *res_d);
978 gint gst_util_fraction_compare (gint a_n, gint a_d, gint b_n, gint b_d);
983 #endif /* __GST_UTILS_H__ */