2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstutils.h: Header for various utility functions
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* 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__
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
#include <glib.h>
|
2004-12-08 17:40:37 +00:00
|
|
|
#include <gst/gstbin.h>
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-07-08 19:07:30 +00:00
|
|
|
G_BEGIN_DECLS
|
2001-02-25 03:42:51 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
void gst_util_set_value_from_string (GValue *value, const gchar *value_str);
|
|
|
|
void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar *value);
|
|
|
|
|
2004-03-22 22:23:50 +00:00
|
|
|
void gst_util_dump_mem (const guchar *mem, guint size);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad);
|
|
|
|
void gst_print_element_args (GString *buf, gint indent, GstElement *element);
|
2001-09-17 23:44:58 +00:00
|
|
|
|
2004-01-08 04:10:18 +00:00
|
|
|
|
|
|
|
/* Macros for defining classes. Ideas taken from Bonobo, which took theirs
|
|
|
|
from Nautilus and GOB. */
|
|
|
|
|
|
|
|
/* Define the boilerplate type stuff to reduce typos and code size. Defines
|
|
|
|
the get_type method and the parent_class static variable.
|
|
|
|
void additional_initializations (GType type) is for initializing interfaces
|
|
|
|
and stuff like that */
|
|
|
|
|
2004-04-16 01:34:05 +00:00
|
|
|
#define GST_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations) \
|
2004-01-08 04:10:18 +00:00
|
|
|
\
|
|
|
|
static void type_as_function ## _base_init (gpointer g_class); \
|
|
|
|
static void type_as_function ## _class_init (type ## Class *g_class); \
|
|
|
|
static void type_as_function ## _init (type *object); \
|
|
|
|
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); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
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, \
|
2004-03-30 18:02:38 +00:00
|
|
|
&object_info, (GTypeFlags) 0); \
|
2004-01-08 04:10:18 +00:00
|
|
|
additional_initializations (object_type); \
|
|
|
|
} \
|
|
|
|
return object_type; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define __GST_DO_NOTHING(type) /* NOP */
|
|
|
|
#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)
|
|
|
|
|
|
|
|
/* Just call the parent handler. This assumes that there is a variable
|
|
|
|
* 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
|
|
|
|
* the _WITH_DEFAULT version for that */
|
|
|
|
#define GST_CALL_PARENT(parent_class_cast, name, args) \
|
|
|
|
((parent_class_cast(parent_class)->name != NULL) ? \
|
|
|
|
parent_class_cast(parent_class)->name args : (void) 0)
|
|
|
|
|
|
|
|
/* Same as above, 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) \
|
|
|
|
((parent_class_cast(parent_class)->name != NULL) ? \
|
|
|
|
parent_class_cast(parent_class)->name args : def_return)
|
|
|
|
|
2004-04-20 00:17:26 +00:00
|
|
|
/* 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))))
|
|
|
|
|
|
|
|
#define GST_READ_UINT64_BE(data) _GST_GET (data, 64, BE)
|
|
|
|
#define GST_READ_UINT64_LE(data) _GST_GET (data, 64, LE)
|
|
|
|
#define GST_READ_UINT32_BE(data) _GST_GET (data, 32, BE)
|
|
|
|
#define GST_READ_UINT32_LE(data) _GST_GET (data, 32, LE)
|
|
|
|
#define GST_READ_UINT16_BE(data) _GST_GET (data, 16, BE)
|
|
|
|
#define GST_READ_UINT16_LE(data) _GST_GET (data, 16, LE)
|
|
|
|
#define GST_READ_UINT8(data) (* ((guint8 *) (data)))
|
|
|
|
|
|
|
|
#define _GST_PUT(__data, __size, __end, __num) \
|
|
|
|
((* (guint##__size *) (__data)) = GUINT##__size##_TO_##__end (__num))
|
|
|
|
|
|
|
|
#define GST_WRITE_UINT64_BE(data, num) _GST_PUT(data, 64, BE, num)
|
|
|
|
#define GST_WRITE_UINT64_LE(data, num) _GST_PUT(data, 64, LE, num)
|
|
|
|
#define GST_WRITE_UINT32_BE(data, num) _GST_PUT(data, 32, BE, num)
|
|
|
|
#define GST_WRITE_UINT32_LE(data, num) _GST_PUT(data, 32, LE, num)
|
|
|
|
#define GST_WRITE_UINT16_BE(data, num) _GST_PUT(data, 16, BE, num)
|
|
|
|
#define GST_WRITE_UINT16_LE(data, num) _GST_PUT(data, 16, LE, num)
|
|
|
|
#define GST_WRITE_UINT8(data, num) ((* (guint8 *) (data)) = (num))
|
|
|
|
|
|
|
|
#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) \
|
2004-05-20 14:01:45 +00:00
|
|
|
(((guint8 *) (__data))[__idx] = (((guint##__size) __num) >> __shift) & 0xff)
|
2004-04-20 00:17:26 +00:00
|
|
|
|
|
|
|
#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 */
|
2004-01-08 04:10:18 +00:00
|
|
|
|
2004-12-08 17:40:37 +00:00
|
|
|
void gst_object_default_error (GstObject * source,
|
|
|
|
GError * error, gchar * debug);
|
|
|
|
|
|
|
|
|
|
|
|
/* element functions */
|
|
|
|
GstFlowReturn gst_element_abort_preroll (GstElement *element);
|
add gst_caps_copy_nth as a more general replacement for copy_1.
Original commit message from CVS:
* docs/design/part-TODO.txt:
* gst/elements/gstfakesink.c: (gst_fakesink_event),
(gst_fakesink_chain):
* gst/elements/gstfakesink.h:
* gst/elements/gstfakesrc.c: (gst_fakesrc_loop),
(gst_fakesrc_activate):
* gst/elements/gstfilesrc.c: (gst_filesrc_getrange),
(gst_filesrc_open_file), (gst_filesrc_loop),
(gst_filesrc_activate), (gst_filesrc_change_state),
(filesrc_find_peek), (gst_filesrc_type_find):
* gst/gstcaps.c: (gst_caps_copy_nth):
* gst/gstcaps.h:
* gst/gstelement.c: (gst_element_add_pad),
(gst_element_remove_pad), (iterate_pad),
(gst_element_get_state_func), (gst_element_commit_state),
(gst_element_set_state), (gst_element_pads_activate),
(gst_element_change_state), (gst_element_dispose):
* gst/gstutils.c: (gst_element_finish_preroll):
* gst/gstutils.h:
* tools/gst-launch.c: (check_intr):
add gst_caps_copy_nth as a more general replacement for
copy_1.
Slightly change the finish_preroll helper function to
include pad flush/active.
Small cleanups in fakesrc.
Add STREAM_LOCK in filesrc.
2005-02-16 15:18:18 +00:00
|
|
|
GstFlowReturn gst_element_finish_preroll (GstElement *element, GstPad *pad);
|
2004-12-08 17:40:37 +00:00
|
|
|
|
|
|
|
GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad);
|
|
|
|
GstPad* gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
|
|
|
|
const GstCaps *filtercaps);
|
|
|
|
|
|
|
|
GstPadTemplate* gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl);
|
|
|
|
|
|
|
|
G_CONST_RETURN gchar* gst_element_state_get_name (GstElementState state);
|
|
|
|
|
|
|
|
GstPadLinkReturn gst_element_link (GstElement *src, GstElement *dest);
|
|
|
|
GstPadLinkReturn gst_element_link_many (GstElement *element_1,
|
|
|
|
GstElement *element_2, ...);
|
|
|
|
GstPadLinkReturn gst_element_link_filtered (GstElement *src, GstElement *dest,
|
|
|
|
const GstCaps *filtercaps);
|
|
|
|
void gst_element_unlink (GstElement *src, GstElement *dest);
|
|
|
|
void gst_element_unlink_many (GstElement *element_1,
|
|
|
|
GstElement *element_2, ...);
|
|
|
|
|
|
|
|
GstPadLinkReturn gst_element_link_pads (GstElement *src, const gchar *srcpadname,
|
|
|
|
GstElement *dest, const gchar *destpadname);
|
|
|
|
GstPadLinkReturn gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname,
|
|
|
|
GstElement *dest, const gchar *destpadname,
|
|
|
|
const GstCaps *filtercaps);
|
|
|
|
void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname,
|
|
|
|
GstElement *dest, const gchar *destpadname);
|
|
|
|
|
2005-02-01 17:26:44 +00:00
|
|
|
/* element class functions */
|
|
|
|
void gst_element_class_install_std_props (GstElementClass * klass,
|
|
|
|
const gchar * first_name, ...);
|
|
|
|
|
2004-12-08 17:40:37 +00:00
|
|
|
/* pad functions */
|
|
|
|
gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad);
|
|
|
|
gboolean gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
|
|
|
|
|
gst/: Inline refcounting.. not sure why it wasn't before.
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_intersect):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstinfo.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness), (gst_object_get_path_string):
* gst/gstutils.c: (gst_element_finish_preroll),
(gst_element_get_compatible_pad_filtered),
(gst_element_link_pads_filtered), (gst_element_unlink),
(gst_pad_use_fixed_caps), (gst_pad_get_fixed_caps_func):
* gst/gstutils.h:
Inline refcounting.. not sure why it wasn't before.
Added use_fixed_caps method to change default getcaps
behaviour.
2005-02-03 17:05:21 +00:00
|
|
|
void gst_pad_use_fixed_caps (GstPad *pad);
|
|
|
|
GstCaps* gst_pad_get_fixed_caps_func (GstPad *pad);
|
2004-12-08 17:40:37 +00:00
|
|
|
|
|
|
|
/* bin functions */
|
|
|
|
void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...);
|
|
|
|
void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...);
|
|
|
|
|
2005-02-11 16:21:46 +00:00
|
|
|
/* buffer functions */
|
|
|
|
GstBuffer * gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2);
|
|
|
|
void gst_buffer_stamp (GstBuffer * dest, const GstBuffer * src);
|
2005-02-11 16:39:14 +00:00
|
|
|
void gst_buffer_stamp (GstBuffer * dest, const GstBuffer * src);
|
2005-02-11 16:21:46 +00:00
|
|
|
|
2004-12-08 17:40:37 +00:00
|
|
|
|
2002-07-08 19:07:30 +00:00
|
|
|
G_END_DECLS
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
#endif /* __GST_UTILS_H__ */
|