gstutils.h 23 KB
Newer Older
1 2 3
/* GStreamer
 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
 *                    2000 Wim Taymans <wtay@chello.be>
4
 *                    2002 Thomas Vander Stichele <thomas@apestaart.org>
5 6
 *
 * gstutils.h: Header for various utility functions
Erik Walthinsen's avatar
Erik Walthinsen committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */


#ifndef __GST_UTILS_H__
#define __GST_UTILS_H__

28 29
#include <gst/gstconfig.h>

30
#include <glib.h>
31
#include <gst/gstbin.h>
Erik Walthinsen's avatar
Erik Walthinsen committed
32

33
G_BEGIN_DECLS
34

35
void		gst_util_set_value_from_string	(GValue *value, const gchar *value_str);
36 37
void		gst_util_set_object_arg		(GObject *object, const gchar *name, const gchar *value);
void		gst_util_dump_mem		(const guchar *mem, guint size);
Erik Walthinsen's avatar
Erik Walthinsen committed
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
guint64         gst_util_gdouble_to_guint64     (gdouble value);
gdouble         gst_util_guint64_to_gdouble     (guint64 value);

/**
 * gst_guint64_to_gdouble:
 * @value: the #guint64 value to convert
 *
 * Convert @value to a gdouble.
 *
 * Returns: @value converted to a #gdouble.
 */

/**
 * gst_gdouble_to_guint64:
 * @value: the #gdouble value to convert
 *
 * Convert @value to a guint64.
 *
 * Returns: @value converted to a #guint64.
 */
59
#ifdef WIN32
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
60 61
#define         gst_gdouble_to_guint64(value)   gst_util_gdouble_to_guint64(value)
#define         gst_guint64_to_gdouble(value)   gst_util_guint64_to_gdouble(value)
62
#else
63 64
#define         gst_gdouble_to_guint64(value)   ((guint64) (value))
#define         gst_guint64_to_gdouble(value)   ((gdouble) (value))
65 66
#endif

67 68
guint64		gst_util_uint64_scale		(guint64 val, guint64 num, guint64 denom);

Jan Schmidt's avatar
Jan Schmidt committed
69
guint64         gst_util_uint64_scale_int       (guint64 val, gint num, gint denom);
70

71 72
void		gst_print_pad_caps		(GString *buf, gint indent, GstPad *pad);
void		gst_print_element_args		(GString *buf, gint indent, GstElement *element);
73

74

Wim Taymans's avatar
Wim Taymans committed
75
/* Macros for defining classes.  Ideas taken from Bonobo, which took theirs
76 77
   from Nautilus and GOB. */

78 79 80 81 82 83
/**
 * GST_BOILERPLATE_FULL:
 * @type: the name of the type struct
 * @type_as_function: the prefix for the functions
 * @parent_type: the parent type struct name
 * @parent_type_macro: the parent type macro
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
84
 * @additional_initializations: function pointer in the form of
85 86 87 88 89 90 91 92 93 94 95 96
 * void additional_initializations (GType type) that can be used for
 * initializing interfaces and the like
 *
 * Define the boilerplate type stuff to reduce typos and code size.  Defines
 * the get_type method and the parent_class static variable.
 *
 * <informalexample>
 * <programlisting>
 *   GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, _do_init);
 * </programlisting>
 * </informalexample>
 */
Wim Taymans's avatar
Wim Taymans committed
97 98 99 100
#define GST_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations)	\
									\
static void type_as_function ## _base_init     (gpointer      g_class);	\
static void type_as_function ## _class_init    (type ## Class *g_class);\
101 102
static void type_as_function ## _init	       (type          *object,	\
                                                type ## Class *g_class);\
Wim Taymans's avatar
Wim Taymans committed
103 104 105 106 107 108 109 110 111 112
static parent_type ## Class *parent_class = NULL;			\
static void								\
type_as_function ## _class_init_trampoline (gpointer g_class,		\
					    gpointer data)		\
{									\
  parent_class = (parent_type ## Class *)				\
      g_type_class_peek_parent (g_class);				\
  type_as_function ## _class_init ((type ## Class *)g_class);		\
}									\
									\
113 114
GType type_as_function ## _get_type (void);				\
									\
Wim Taymans's avatar
Wim Taymans committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
GType									\
type_as_function ## _get_type (void)					\
{									\
  static GType object_type = 0;						\
  if (object_type == 0) {						\
    static const GTypeInfo object_info = {				\
      sizeof (type ## Class),						\
      type_as_function ## _base_init,					\
      NULL,		  /* base_finalize */				\
      type_as_function ## _class_init_trampoline,			\
      NULL,		  /* class_finalize */				\
      NULL,               /* class_data */				\
      sizeof (type),							\
      0,                  /* n_preallocs */				\
      (GInstanceInitFunc) type_as_function ## _init			\
    };									\
    object_type = g_type_register_static (parent_type_macro, #type,	\
	&object_info, (GTypeFlags) 0);					\
    additional_initializations (object_type);				\
  }									\
  return object_type;							\
136 137 138
}

#define __GST_DO_NOTHING(type)	/* NOP */
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155

/**
 * GST_BOILERPLATE:
 * @type: the name of the type struct
 * @type_as_function: the prefix for the functions
 * @parent_type: the parent type struct name
 * @parent_type_macro: the parent type macro
 *
 * Define the boilerplate type stuff to reduce typos and code size.  Defines
 * the get_type method and the parent_class static variable.
 *
 * <informalexample>
 * <programlisting>
 *   GST_BOILERPLATE (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT);
 * </programlisting>
 * </informalexample>
 */
156 157 158 159
#define GST_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro)	\
  GST_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro,	\
      __GST_DO_NOTHING)

160 161 162 163 164 165
/* Like GST_BOILERPLATE, but makes the type 1) implement an interface, and 2)
 * implement GstImplementsInterface for that type
 *
 * After this you will need to implement interface_as_function ## _supported
 * and interface_as_function ## _interface_init
 */
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
/**
 * GST_BOILERPLATE_WITH_INTERFACE:
 * @type: the name of the type struct
 * @type_as_function: the prefix for the functions
 * @parent_type: the parent type struct name
 * @parent_type_as_macro: the parent type macro
 * @interface_type: the name of the interface type struct
 * @interface_type_as_macro: the interface type macro
 * @interface_as_function: the interface function name prefix
 *
 * Like GST_BOILERPLATE, but makes the type 1) implement an interface, and 2)
 * implement GstImplementsInterface for that type.
 *
 * After this you will need to implement interface_as_function ## _supported
 * and interface_as_function ## _interface_init
 */
182 183 184 185
#define GST_BOILERPLATE_WITH_INTERFACE(type, type_as_function,		\
    parent_type, parent_type_as_macro, interface_type,			\
    interface_type_as_macro, interface_as_function)			\
                                                                        \
186 187
static void interface_as_function ## _interface_init (interface_type ## Class *klass);  \
static gboolean interface_as_function ## _supported (type *object, GType iface_type);   \
188 189
                                                                        \
static void                                                             \
190
type_as_function ## _implements_interface_init (GstImplementsInterfaceClass *klass)     \
191
{                                                                       \
192
  klass->supported = (gboolean (*)(GstImplementsInterface*, GType))interface_as_function ## _supported;     \
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
}                                                                       \
                                                                        \
static void                                                             \
type_as_function ## _init_interfaces (GType type)                       \
{                                                                       \
  static const GInterfaceInfo implements_iface_info = {                 \
    (GInterfaceInitFunc) type_as_function ## _implements_interface_init,\
    NULL,                                                               \
    NULL,                                                               \
  };                                                                    \
  static const GInterfaceInfo iface_info = {                            \
    (GInterfaceInitFunc) interface_as_function ## _interface_init,      \
    NULL,                                                               \
    NULL,                                                               \
  };                                                                    \
                                                                        \
  g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,     \
      &implements_iface_info);                                          \
  g_type_add_interface_static (type, interface_type_as_macro,		\
      &iface_info);							\
}                                                                       \
                                                                        \
GST_BOILERPLATE_FULL (type, type_as_function, parent_type,              \
216 217
    parent_type_as_macro, type_as_function ## _init_interfaces)

Stefan Kost's avatar
Stefan Kost committed
218 219 220 221 222 223 224
/**
 * GST_CALL_PARENT:
 * @parent_class_cast: the name of the class cast macro for the parent type
 * @name: name of the function to call
 * @args: arguments enclosed in '( )'
 *
 * Just call the parent handler.  This assumes that there is a variable
225 226
 * named parent_class that points to the (duh!) parent class.  Note that
 * this macro is not to be used with things that return something, use
Stefan Kost's avatar
Stefan Kost committed
227 228
 * the _WITH_DEFAULT version for that
 */
229 230
#define GST_CALL_PARENT(parent_class_cast, name, args)			\
	((parent_class_cast(parent_class)->name != NULL) ?		\
231 232
	 parent_class_cast(parent_class)->name args : (void) 0)

Stefan Kost's avatar
Stefan Kost committed
233 234 235 236 237 238 239 240 241 242 243
/**
 * GST_CALL_PARENT_WITH_DEFAULT:
 * @parent_class_cast: the name of the class cast macro for the parent type
 * @name: name of the function to call
 * @args: arguments enclosed in '( )'
 * @def_return: default result
 *
 * Same as GST_CALL_PARENT(), but in case there is no implementation, it
 * evaluates to @def_return.
 */
#define GST_CALL_PARENT_WITH_DEFAULT(parent_class_cast, name, args, def_return)\
244
	((parent_class_cast(parent_class)->name != NULL) ?		\
245 246
	 parent_class_cast(parent_class)->name args : def_return)

247 248 249 250 251 252 253
/* Define possibly unaligned memory access method whether the type of
 * architecture. */
#if GST_HAVE_UNALIGNED_ACCESS

#define _GST_GET(__data, __size, __end) \
    (GUINT##__size##_FROM_##__end (* ((guint##__size *) (__data))))

Stefan Kost's avatar
Stefan Kost committed
254 255 256 257 258 259
/**
 * GST_READ_UINT64_BE:
 * @data: memory location
 *
 * Read a 64 bit unsigned integer value in big endian format from the memory buffer.
 */
260
#define GST_READ_UINT64_BE(data)	_GST_GET (data, 64, BE)
Stefan Kost's avatar
Stefan Kost committed
261 262 263 264 265 266
/**
 * GST_READ_UINT64_LE:
 * @data: memory location
 *
 * Read a 64 bit unsigned integer value in little endian format from the memory buffer.
 */
267
#define GST_READ_UINT64_LE(data)	_GST_GET (data, 64, LE)
Stefan Kost's avatar
Stefan Kost committed
268 269 270 271 272 273
/**
 * GST_READ_UINT32_BE:
 * @data: memory location
 *
 * Read a 32 bit unsigned integer value in big endian format from the memory buffer.
 */
274
#define GST_READ_UINT32_BE(data)	_GST_GET (data, 32, BE)
Stefan Kost's avatar
Stefan Kost committed
275 276 277 278 279 280
/**
 * GST_READ_UINT32_LE:
 * @data: memory location
 *
 * Read a 32 bit unsigned integer value in little endian format from the memory buffer.
 */
281
#define GST_READ_UINT32_LE(data)        _GST_GET (data, 32, LE)
Stefan Kost's avatar
Stefan Kost committed
282 283 284 285 286 287
/**
 * GST_READ_UINT16_BE:
 * @data: memory location
 *
 * Read a 16 bit unsigned integer value in big endian format from the memory buffer.
 */
288
#define GST_READ_UINT16_BE(data)        _GST_GET (data, 16, BE)
Stefan Kost's avatar
Stefan Kost committed
289 290 291 292 293 294
/**
 * GST_READ_UINT16_LE:
 * @data: memory location
 *
 * Read a 16 bit unsigned integer value in little endian format from the memory buffer.
 */
295
#define GST_READ_UINT16_LE(data)        _GST_GET (data, 16, LE)
Stefan Kost's avatar
Stefan Kost committed
296 297 298 299 300 301
/**
 * GST_READ_UINT8:
 * @data: memory location
 *
 * Read an 8 bit unsigned integer value from the memory buffer.
 */
302
#define GST_READ_UINT8(data)		(* ((guint8 *) (data)))
303 304 305 306

#define _GST_PUT(__data, __size, __end, __num) \
    ((* (guint##__size *) (__data)) = GUINT##__size##_TO_##__end (__num))

Stefan Kost's avatar
Stefan Kost committed
307 308 309 310 311 312 313
/**
 * GST_WRITE_UINT64_BE:
 * @data: memory location
 * @num: value to store
 *
 * Store a 64 bit unsigned integer value in big endian format into the memory buffer.
 */
314
#define GST_WRITE_UINT64_BE(data, num)	_GST_PUT(data, 64, BE, num)
Stefan Kost's avatar
Stefan Kost committed
315 316 317 318 319 320 321
/**
 * GST_WRITE_UINT64_LE:
 * @data: memory location
 * @num: value to store
 *
 * Store a 64 bit unsigned integer value in little endian format into the memory buffer.
 */
322
#define GST_WRITE_UINT64_LE(data, num)  _GST_PUT(data, 64, LE, num)
Stefan Kost's avatar
Stefan Kost committed
323 324 325 326 327 328 329
/**
 * GST_WRITE_UINT32_BE:
 * @data: memory location
 * @num: value to store
 *
 * Store a 32 bit unsigned integer value in big endian format into the memory buffer.
 */
330
#define GST_WRITE_UINT32_BE(data, num)  _GST_PUT(data, 32, BE, num)
Stefan Kost's avatar
Stefan Kost committed
331 332 333 334 335 336 337
/**
 * GST_WRITE_UINT32_LE:
 * @data: memory location
 * @num: value to store
 *
 * Store a 32 bit unsigned integer value in little endian format into the memory buffer.
 */
338
#define GST_WRITE_UINT32_LE(data, num)  _GST_PUT(data, 32, LE, num)
Stefan Kost's avatar
Stefan Kost committed
339 340 341 342 343 344 345
/**
 * GST_WRITE_UINT16_BE:
 * @data: memory location
 * @num: value to store
 *
 * Store a 16 bit unsigned integer value in big endian format into the memory buffer.
 */
346
#define GST_WRITE_UINT16_BE(data, num)  _GST_PUT(data, 16, BE, num)
Stefan Kost's avatar
Stefan Kost committed
347 348 349 350 351 352 353
/**
 * GST_WRITE_UINT16_LE:
 * @data: memory location
 * @num: value to store
 *
 * Store a 16 bit unsigned integer value in little endian format into the memory buffer.
 */
354
#define GST_WRITE_UINT16_LE(data, num)  _GST_PUT(data, 16, LE, num)
Stefan Kost's avatar
Stefan Kost committed
355 356 357 358 359 360 361
/**
 * GST_WRITE_UINT8:
 * @data: memory location
 * @num: value to store
 *
 * Store an 8 bit unsigned integer value into the memory buffer.
 */
362
#define GST_WRITE_UINT8(data, num)	((* (guint8 *) (data)) = (num))
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405

#else /* GST_HAVE_UNALIGNED_ACCESS */

#define _GST_GET(__data, __idx, __size, __shift) \
    (((guint##__size) (((guint8 *) (__data))[__idx])) << __shift)

#define GST_READ_UINT64_BE(data)	(_GST_GET (data, 0, 64, 56) | \
					 _GST_GET (data, 1, 64, 48) | \
					 _GST_GET (data, 2, 64, 40) | \
					 _GST_GET (data, 3, 64, 32) | \
					 _GST_GET (data, 4, 64, 24) | \
					 _GST_GET (data, 5, 64, 16) | \
					 _GST_GET (data, 6, 64,  8) | \
					 _GST_GET (data, 7, 64,  0))

#define GST_READ_UINT64_LE(data)	(_GST_GET (data, 7, 64, 56) | \
					 _GST_GET (data, 6, 64, 48) | \
					 _GST_GET (data, 5, 64, 40) | \
					 _GST_GET (data, 4, 64, 32) | \
					 _GST_GET (data, 3, 64, 24) | \
					 _GST_GET (data, 2, 64, 16) | \
					 _GST_GET (data, 1, 64,  8) | \
					 _GST_GET (data, 0, 64,  0))

#define GST_READ_UINT32_BE(data)	(_GST_GET (data, 0, 32, 24) | \
					 _GST_GET (data, 1, 32, 16) | \
					 _GST_GET (data, 2, 32,  8) | \
					 _GST_GET (data, 3, 32,  0))

#define GST_READ_UINT32_LE(data)	(_GST_GET (data, 3, 32, 24) | \
					 _GST_GET (data, 2, 32, 16) | \
					 _GST_GET (data, 1, 32,  8) | \
					 _GST_GET (data, 0, 32,  0))

#define GST_READ_UINT16_BE(data)	(_GST_GET (data, 0, 16,  8) | \
					 _GST_GET (data, 1, 16,  0))

#define GST_READ_UINT16_LE(data)	(_GST_GET (data, 1, 16,  8) | \
					 _GST_GET (data, 0, 16,  0))

#define GST_READ_UINT8(data)		(_GST_GET (data, 0,  8,  0))

#define _GST_PUT(__data, __idx, __size, __shift, __num) \
406
    (((guint8 *) (__data))[__idx] = (((guint##__size) __num) >> __shift) & 0xff)
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458

#define GST_WRITE_UINT64_BE(data, num)	do { \
					  _GST_PUT (data, 0, 64, 56, num); \
					  _GST_PUT (data, 1, 64, 48, num); \
					  _GST_PUT (data, 2, 64, 40, num); \
					  _GST_PUT (data, 3, 64, 32, num); \
					  _GST_PUT (data, 4, 64, 24, num); \
					  _GST_PUT (data, 5, 64, 16, num); \
					  _GST_PUT (data, 6, 64,  8, num); \
					  _GST_PUT (data, 7, 64,  0, num); \
					} while (0)

#define GST_WRITE_UINT64_LE(data, num)	do { \
					  _GST_PUT (data, 0, 64,  0, num); \
					  _GST_PUT (data, 1, 64,  8, num); \
					  _GST_PUT (data, 2, 64, 16, num); \
					  _GST_PUT (data, 3, 64, 24, num); \
					  _GST_PUT (data, 4, 64, 32, num); \
					  _GST_PUT (data, 5, 64, 40, num); \
					  _GST_PUT (data, 6, 64, 48, num); \
					  _GST_PUT (data, 7, 64, 56, num); \
					} while (0)

#define GST_WRITE_UINT32_BE(data, num)	do { \
					  _GST_PUT (data, 0, 32, 24, num); \
					  _GST_PUT (data, 1, 32, 16, num); \
					  _GST_PUT (data, 2, 32,  8, num); \
					  _GST_PUT (data, 3, 32,  0, num); \
					} while (0)

#define GST_WRITE_UINT32_LE(data, num)	do { \
					  _GST_PUT (data, 0, 32,  0, num); \
					  _GST_PUT (data, 1, 32,  8, num); \
					  _GST_PUT (data, 2, 32, 16, num); \
					  _GST_PUT (data, 3, 32, 24, num); \
					} while (0)

#define GST_WRITE_UINT16_BE(data, num)	do { \
					  _GST_PUT (data, 0, 16,  8, num); \
					  _GST_PUT (data, 1, 16,  0, num); \
					} while (0)

#define GST_WRITE_UINT16_LE(data, num)	do { \
					  _GST_PUT (data, 0, 16,  0, num); \
					  _GST_PUT (data, 1, 16,  8, num); \
					} while (0)

#define GST_WRITE_UINT8(data, num)	do { \
					  _GST_PUT (data, 0,  8,  0, num); \
					} while (0)

#endif /* GST_HAVE_UNALIGNED_ACCESS */
459

460 461

/* Miscellaneous utility macros */
Stefan Kost's avatar
Stefan Kost committed
462 463 464 465 466 467 468

/**
 * GST_ROUND_UP_2:
 * @num: value round up
 *
 * Make number divideable by two without a rest.
 */
469
#define GST_ROUND_UP_2(num)  (((num)+1)&~1)
Stefan Kost's avatar
Stefan Kost committed
470 471 472 473 474 475
/**
 * GST_ROUND_UP_4:
 * @num: value round up
 *
 * Make number divideable by four without a rest.
 */
476
#define GST_ROUND_UP_4(num)  (((num)+3)&~3)
Stefan Kost's avatar
Stefan Kost committed
477 478 479 480 481 482
/**
 * GST_ROUND_UP_8:
 * @num: value round up
 *
 * Make number divideable by eight without a rest.
 */
483
#define GST_ROUND_UP_8(num)  (((num)+7)&~7)
Stefan Kost's avatar
Stefan Kost committed
484 485 486 487 488 489
/**
 * GST_ROUND_UP_16:
 * @num: value round up
 *
 * Make number divideable by 16 without a rest.
 */
490
#define GST_ROUND_UP_16(num) (((num)+15)&~15)
Stefan Kost's avatar
Stefan Kost committed
491 492 493 494 495 496
/**
 * GST_ROUND_UP_32:
 * @num: value round up
 *
 * Make number divideable by 32 without a rest.
 */
497
#define GST_ROUND_UP_32(num) (((num)+31)&~31)
Stefan Kost's avatar
Stefan Kost committed
498 499 500 501 502 503
/**
 * GST_ROUND_UP_64:
 * @num: value round up
 *
 * Make number divideable by 64 without a rest.
 */
504 505
#define GST_ROUND_UP_64(num) (((num)+63)&~63)

506
void			gst_object_default_error	(GstObject * source,
507 508 509
							 GError * error, gchar * debug);

/* element functions */
510
void                    gst_element_create_all_pads     (GstElement *element);
511 512
GstPad*                 gst_element_get_compatible_pad  (GstElement *element, GstPad *pad,
		                                         const GstCaps *caps);
513 514 515

GstPadTemplate*         gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl);

516
G_CONST_RETURN gchar*   gst_element_state_get_name      (GstState state);
517 518 519

gboolean		gst_element_link                (GstElement *src, GstElement *dest);
gboolean		gst_element_link_many           (GstElement *element_1,
520
		                                         GstElement *element_2, ...) G_GNUC_NULL_TERMINATED;
521 522 523
gboolean		gst_element_link_filtered	(GstElement * src,
                                                         GstElement * dest,
                                                         GstCaps *filter);
524 525
void                    gst_element_unlink              (GstElement *src, GstElement *dest);
void                    gst_element_unlink_many         (GstElement *element_1,
526
		                                         GstElement *element_2, ...) G_GNUC_NULL_TERMINATED;
527 528 529 530 531

gboolean		gst_element_link_pads           (GstElement *src, const gchar *srcpadname,
		                                         GstElement *dest, const gchar *destpadname);
void                    gst_element_unlink_pads         (GstElement *src, const gchar *srcpadname,
		                                         GstElement *dest, const gchar *destpadname);
532

533 534 535
gboolean		gst_element_link_pads_filtered	(GstElement * src, const gchar * srcpadname,
                                                         GstElement * dest, const gchar * destpadname,
                                                         GstCaps *filter);
536 537 538 539
/* util elementfactory functions */
gboolean		gst_element_factory_can_src_caps(GstElementFactory *factory, const GstCaps *caps);
gboolean		gst_element_factory_can_sink_caps(GstElementFactory *factory, const GstCaps *caps);

540 541
/* util query functions */
gboolean                gst_element_query_position      (GstElement *element, GstFormat *format,
Wim Taymans's avatar
Wim Taymans committed
542 543 544
		                                         gint64 *cur);
gboolean                gst_element_query_duration      (GstElement *element, GstFormat *format,
		                                         gint64 *duration);
545
gboolean                gst_element_query_convert       (GstElement *element, GstFormat src_format, gint64 src_val,
546
		                                         GstFormat *dest_format, gint64 *dest_val);
547 548

/* element class functions */
549
void			gst_element_class_install_std_props (GstElementClass * klass,
550
							 const gchar * first_name, ...) G_GNUC_NULL_TERMINATED;
551 552 553 554 555 556 557 558 559

/* pad functions */
gboolean                gst_pad_can_link                (GstPad *srcpad, GstPad *sinkpad);

void			gst_pad_use_fixed_caps		(GstPad *pad);
GstCaps*		gst_pad_get_fixed_caps_func	(GstPad *pad);
GstCaps*		gst_pad_proxy_getcaps		(GstPad * pad);
gboolean		gst_pad_proxy_setcaps		(GstPad * pad, GstCaps * caps);

560 561
GstElement*		gst_pad_get_parent_element	(GstPad *pad);

562 563
/* util query functions */
gboolean                gst_pad_query_position          (GstPad *pad, GstFormat *format,
Wim Taymans's avatar
Wim Taymans committed
564 565 566
		                                         gint64 *cur);
gboolean                gst_pad_query_duration          (GstPad *pad, GstFormat *format,
		                                         gint64 *duration);
567
gboolean                gst_pad_query_convert           (GstPad *pad, GstFormat src_format, gint64 src_val,
568
		                                         GstFormat *dest_format, gint64 *dest_val);
569

570
/* bin functions */
571 572 573
void                    gst_bin_add_many                (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
void                    gst_bin_remove_many             (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
GstPad *                gst_bin_find_unconnected_pad    (GstBin *bin, GstPadDirection direction);
574 575 576

/* buffer functions */
GstBuffer *		gst_buffer_merge		(GstBuffer * buf1, GstBuffer * buf2);
577
GstBuffer *		gst_buffer_join			(GstBuffer * buf1, GstBuffer * buf2);
578 579
void			gst_buffer_stamp		(GstBuffer * dest, const GstBuffer * src);

580 581
/* atomic functions */
void                    gst_atomic_int_set              (gint * atomic_int, gint value);
582

583
/* probes */
584
gulong			gst_pad_add_data_probe		(GstPad * pad,
585 586
							 GCallback handler,
							 gpointer data);
587
void			gst_pad_remove_data_probe	(GstPad * pad, guint handler_id);
588
gulong			gst_pad_add_event_probe		(GstPad * pad,
589 590
							 GCallback handler,
							 gpointer data);
591
void			gst_pad_remove_event_probe	(GstPad * pad, guint handler_id);
592
gulong			gst_pad_add_buffer_probe	(GstPad * pad,
593 594
							 GCallback handler,
							 gpointer data);
595
void			gst_pad_remove_buffer_probe	(GstPad * pad, guint handler_id);
596

597 598 599 600 601 602 603
/* tag emission utility functions */
void			gst_element_found_tags_for_pad	(GstElement * element,
							 GstPad * pad,
							 GstTagList * list);
void			gst_element_found_tags		(GstElement * element,
							 GstTagList * list);

604
#ifndef GST_DISABLE_PARSE
605 606 607 608
/* parse utility functions */
GstElement *            gst_parse_bin_from_description  (const gchar * bin_description,
                                                         gboolean ghost_unconnected_pads,
                                                         GError ** err);
609 610 611 612 613 614 615
#else /* GST_DISABLE_PARSE */

#if defined _GNUC_ && _GNUC_ >= 3
#pragma GCC poison gst_parse_bin_from_description 
#endif

#endif
616

617
G_END_DECLS
618

Erik Walthinsen's avatar
Erik Walthinsen committed
619
#endif /* __GST_UTILS_H__ */