source: trunk/third/gstreamer/gst/gstdata.h @ 21005

Revision 21005, 3.3 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1/* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 *                    2000 Wim Taymans <wim.taymans@chello.be>
4 *
5 * gstdata.h: Header for GstData objects (used for data passing)
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23
24#ifndef __GST_DATA_H__
25#define __GST_DATA_H__
26
27#include <glib-object.h>
28#include <gst/gstatomic.h>
29#include <gst/gsttypes.h>
30
31G_BEGIN_DECLS
32
33/* type */
34#define GST_DATA(data)          ((GstData*)(data))
35#define GST_DATA_TYPE(data)     (GST_DATA(data)->type)
36
37/* flags */
38#define GST_DATA_FLAGS(data)            (GST_DATA(data)->flags)
39#define GST_DATA_FLAG_SHIFT(flag)       (1<<(flag))
40#define GST_DATA_FLAG_IS_SET(data,flag) (GST_DATA_FLAGS(data) & (1<<(flag)))
41#define GST_DATA_FLAG_SET(data,flag)    G_STMT_START{ (GST_DATA_FLAGS(data) |= (1<<(flag))); }G_STMT_END
42#define GST_DATA_FLAG_UNSET(data,flag)  G_STMT_START{ (GST_DATA_FLAGS(data) &= ~(1<<(flag))); }G_STMT_END
43
44/* Macros for the GType */
45#define GST_TYPE_DATA                   (gst_data_get_type ())
46
47typedef struct _GstData GstData;
48
49typedef void            (*GstDataFreeFunction)          (GstData *data);
50typedef GstData*        (*GstDataCopyFunction)          (const GstData *data);
51
52typedef enum
53{
54  GST_DATA_READONLY     = 1,
55
56  /* insert more */
57  GST_DATA_FLAG_LAST    = 8
58} GstDataFlags;
59
60/* refcount */
61#define GST_DATA_REFCOUNT(data)                 ((GST_DATA(data))->refcount)
62#define GST_DATA_REFCOUNT_VALUE(data)           (gst_atomic_int_read (&(GST_DATA(data))->refcount))
63
64/* copy/free functions */
65#define GST_DATA_COPY_FUNC(data)                (GST_DATA(data)->copy)
66#define GST_DATA_FREE_FUNC(data)                (GST_DATA(data)->free)
67
68
69struct _GstData {
70  GType                  type;
71
72  /* refcounting */
73  GstAtomicInt           refcount;
74
75  guint16                flags;
76 
77  /* utility function pointers, can override default */
78  GstDataFreeFunction    free;          /* free the data */
79  GstDataCopyFunction    copy;          /* copy the data */
80
81  gpointer _gst_reserved[GST_PADDING];
82};
83
84/* function used by subclasses only */
85void                    gst_data_init                   (GstData *data, GType type, guint16 flags,
86                                                         GstDataFreeFunction free,
87                                                         GstDataCopyFunction copy);
88void                    gst_data_dispose                (GstData *data);
89void                    gst_data_copy_into              (const GstData *data, GstData *target);
90
91/* basic operations on data */
92GstData*                gst_data_copy                   (const GstData *data);
93gboolean                gst_data_is_writable            (GstData *data);
94GstData*                gst_data_copy_on_write          (GstData *data);
95
96/* reference counting */
97GstData*                gst_data_ref                    (GstData* data);
98GstData*                gst_data_ref_by_count           (GstData* data, gint count);
99void                    gst_data_unref                  (GstData* data);
100
101/* GType for GstData */
102GType                   gst_data_get_type               (void) G_GNUC_CONST;
103
104G_END_DECLS
105
106#endif /* __GST_DATA_H__ */
Note: See TracBrowser for help on using the repository browser.