2001-10-17 10:21:27 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wim.taymans@chello.be>
|
|
|
|
*
|
|
|
|
* gstdata.h: Header for GstData objects (used for data passing)
|
|
|
|
*
|
|
|
|
* 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_DATA_H__
|
|
|
|
#define __GST_DATA_H__
|
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
#include <glib-object.h>
|
|
|
|
#include <gst/gstatomic.h>
|
2003-10-07 21:58:42 +00:00
|
|
|
#include <gst/gsttypes.h>
|
2001-10-17 10:21:27 +00:00
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
G_BEGIN_DECLS
|
2001-10-17 10:21:27 +00:00
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
/* type */
|
|
|
|
#define GST_DATA(data) ((GstData*)(data))
|
|
|
|
#define GST_DATA_TYPE(data) (GST_DATA(data)->type)
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
#define GST_DATA_FLAGS(data) (GST_DATA(data)->flags)
|
|
|
|
#define GST_DATA_FLAG_SHIFT(flag) (1<<(flag))
|
|
|
|
#define GST_DATA_FLAG_IS_SET(data,flag) (GST_DATA_FLAGS(data) & (1<<(flag)))
|
|
|
|
#define GST_DATA_FLAG_SET(data,flag) G_STMT_START{ (GST_DATA_FLAGS(data) |= (1<<(flag))); }G_STMT_END
|
|
|
|
#define GST_DATA_FLAG_UNSET(data,flag) G_STMT_START{ (GST_DATA_FLAGS(data) &= ~(1<<(flag))); }G_STMT_END
|
2001-10-17 10:21:27 +00:00
|
|
|
|
2004-02-27 17:58:24 +00:00
|
|
|
/* Macros for the GType */
|
|
|
|
#define GST_TYPE_DATA (gst_data_get_type ())
|
|
|
|
|
2001-10-17 10:21:27 +00:00
|
|
|
typedef struct _GstData GstData;
|
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
typedef void (*GstDataFreeFunction) (GstData *data);
|
|
|
|
typedef GstData* (*GstDataCopyFunction) (const GstData *data);
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_DATA_READONLY = 1,
|
|
|
|
|
|
|
|
/* insert more */
|
2002-10-24 09:00:12 +00:00
|
|
|
GST_DATA_FLAG_LAST = 8
|
2002-07-08 19:22:02 +00:00
|
|
|
} GstDataFlags;
|
|
|
|
|
|
|
|
/* refcount */
|
|
|
|
#define GST_DATA_REFCOUNT(data) ((GST_DATA(data))->refcount)
|
2002-12-31 03:21:08 +00:00
|
|
|
#define GST_DATA_REFCOUNT_VALUE(data) (gst_atomic_int_read (&(GST_DATA(data))->refcount))
|
2002-07-08 19:22:02 +00:00
|
|
|
|
|
|
|
/* copy/free functions */
|
|
|
|
#define GST_DATA_COPY_FUNC(data) (GST_DATA(data)->copy)
|
|
|
|
#define GST_DATA_FREE_FUNC(data) (GST_DATA(data)->free)
|
|
|
|
|
|
|
|
|
2001-10-17 10:21:27 +00:00
|
|
|
struct _GstData {
|
2002-07-08 19:22:02 +00:00
|
|
|
GType type;
|
|
|
|
|
|
|
|
/* refcounting */
|
|
|
|
GstAtomicInt refcount;
|
|
|
|
|
|
|
|
guint16 flags;
|
|
|
|
|
|
|
|
/* utility function pointers, can override default */
|
|
|
|
GstDataFreeFunction free; /* free the data */
|
2002-07-13 23:12:22 +00:00
|
|
|
GstDataCopyFunction copy; /* copy the data */
|
2003-10-07 21:58:42 +00:00
|
|
|
|
2003-12-09 02:39:31 +00:00
|
|
|
gpointer _gst_reserved[GST_PADDING];
|
2001-10-17 10:21:27 +00:00
|
|
|
};
|
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
/* function used by subclasses only */
|
2002-07-13 23:12:22 +00:00
|
|
|
void gst_data_init (GstData *data, GType type, guint16 flags,
|
2002-07-08 19:22:02 +00:00
|
|
|
GstDataFreeFunction free,
|
|
|
|
GstDataCopyFunction copy);
|
2002-07-13 23:12:22 +00:00
|
|
|
void gst_data_dispose (GstData *data);
|
|
|
|
void gst_data_copy_into (const GstData *data, GstData *target);
|
2002-07-08 19:22:02 +00:00
|
|
|
|
|
|
|
/* basic operations on data */
|
|
|
|
GstData* gst_data_copy (const GstData *data);
|
2003-04-16 18:35:57 +00:00
|
|
|
gboolean gst_data_is_writable (GstData *data);
|
2002-07-25 18:47:48 +00:00
|
|
|
GstData* gst_data_copy_on_write (GstData *data);
|
2002-07-08 19:22:02 +00:00
|
|
|
|
|
|
|
/* reference counting */
|
|
|
|
GstData* gst_data_ref (GstData* data);
|
|
|
|
GstData* gst_data_ref_by_count (GstData* data, gint count);
|
|
|
|
void gst_data_unref (GstData* data);
|
|
|
|
|
2004-02-27 17:58:24 +00:00
|
|
|
/* GType for GstData */
|
|
|
|
GType gst_data_get_type (void) G_GNUC_CONST;
|
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
G_END_DECLS
|
2001-10-17 10:21:27 +00:00
|
|
|
|
|
|
|
#endif /* __GST_DATA_H__ */
|