|
1 /* GStreamer |
|
2 * Copyright (C) 2005 David Schleef <ds@schleef.org> |
|
3 * |
|
4 * gstminiobject.h: Header for GstMiniObject |
|
5 * |
|
6 * This library is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Library General Public |
|
8 * License as published by the Free Software Foundation; either |
|
9 * version 2 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This library is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Library General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Library General Public |
|
17 * License along with this library; if not, write to the |
|
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
19 * Boston, MA 02111-1307, USA. |
|
20 */ |
|
21 |
|
22 |
|
23 #ifndef __GST_MINI_OBJECT_H__ |
|
24 #define __GST_MINI_OBJECT_H__ |
|
25 |
|
26 #include <gst/gstconfig.h> |
|
27 |
|
28 #include <glib-object.h> |
|
29 |
|
30 G_BEGIN_DECLS |
|
31 |
|
32 #define GST_TYPE_MINI_OBJECT (gst_mini_object_get_type()) |
|
33 #define GST_IS_MINI_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MINI_OBJECT)) |
|
34 #define GST_IS_MINI_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MINI_OBJECT)) |
|
35 #define GST_MINI_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MINI_OBJECT, GstMiniObjectClass)) |
|
36 #define GST_MINI_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MINI_OBJECT, GstMiniObject)) |
|
37 #define GST_MINI_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MINI_OBJECT, GstMiniObjectClass)) |
|
38 #define GST_MINI_OBJECT_CAST(obj) ((GstMiniObject*)(obj)) |
|
39 |
|
40 typedef struct _GstMiniObject GstMiniObject; |
|
41 typedef struct _GstMiniObjectClass GstMiniObjectClass; |
|
42 |
|
43 /** |
|
44 * GstMiniObjectCopyFunction: |
|
45 * @obj: MiniObject to copy |
|
46 * |
|
47 * Virtual function prototype for methods to create copies of instances. |
|
48 * |
|
49 * Returns: reference to cloned instance. |
|
50 */ |
|
51 typedef GstMiniObject * (*GstMiniObjectCopyFunction) (const GstMiniObject *obj); |
|
52 /** |
|
53 * GstMiniObjectFinalizeFunction: |
|
54 * @obj: MiniObject to finalize |
|
55 * |
|
56 * Virtual function prototype for methods to free ressources used by |
|
57 * mini-objects. Subclasses of the mini object are allowed to revive the |
|
58 * passed object by doing a gst_mini_object_ref(). If the object is not |
|
59 * revived after the finalize function, the memory associated with the |
|
60 * object is freed. |
|
61 */ |
|
62 typedef void (*GstMiniObjectFinalizeFunction) (GstMiniObject *obj); |
|
63 |
|
64 /** |
|
65 * GST_MINI_OBJECT_FLAGS: |
|
66 * @obj: MiniObject to return flags for. |
|
67 * |
|
68 * This macro returns the entire set of flags for the mini-object. |
|
69 */ |
|
70 #define GST_MINI_OBJECT_FLAGS(obj) (GST_MINI_OBJECT_CAST(obj)->flags) |
|
71 /** |
|
72 * GST_MINI_OBJECT_FLAG_IS_SET: |
|
73 * @obj: MiniObject to check for flags. |
|
74 * @flag: Flag to check for |
|
75 * |
|
76 * This macro checks to see if the given flag is set. |
|
77 */ |
|
78 #define GST_MINI_OBJECT_FLAG_IS_SET(obj,flag) !!(GST_MINI_OBJECT_FLAGS (obj) & (flag)) |
|
79 /** |
|
80 * GST_MINI_OBJECT_FLAG_SET: |
|
81 * @obj: MiniObject to set flag in. |
|
82 * @flag: Flag to set, can by any number of bits in guint32. |
|
83 * |
|
84 * This macro sets the given bits. |
|
85 */ |
|
86 #define GST_MINI_OBJECT_FLAG_SET(obj,flag) (GST_MINI_OBJECT_FLAGS (obj) |= (flag)) |
|
87 /** |
|
88 * GST_MINI_OBJECT_FLAG_UNSET: |
|
89 * @obj: MiniObject to unset flag in. |
|
90 * @flag: Flag to set, must be a single bit in guint32. |
|
91 * |
|
92 * This macro usets the given bits. |
|
93 */ |
|
94 #define GST_MINI_OBJECT_FLAG_UNSET(obj,flag) (GST_MINI_OBJECT_FLAGS (obj) &= ~(flag)) |
|
95 |
|
96 /** |
|
97 * GST_VALUE_HOLDS_MINI_OBJECT: |
|
98 * @value: the #GValue to check |
|
99 * |
|
100 * Checks if the given #GValue contains a #GST_TYPE_MINI_OBJECT value. |
|
101 */ |
|
102 #define GST_VALUE_HOLDS_MINI_OBJECT(value) (G_VALUE_HOLDS(value, GST_TYPE_MINI_OBJECT)) |
|
103 |
|
104 /** |
|
105 * GstMiniObjectFlags: |
|
106 * @GST_MINI_OBJECT_FLAG_READONLY: is the miniobject readonly or writable |
|
107 * @GST_MINI_OBJECT_FLAG_LAST: first flag that can be used by subclasses. |
|
108 * |
|
109 * Flags for the padtemplate |
|
110 */ |
|
111 |
|
112 typedef enum |
|
113 { |
|
114 GST_MINI_OBJECT_FLAG_READONLY = (1<<0), |
|
115 /* padding */ |
|
116 GST_MINI_OBJECT_FLAG_LAST = (1<<4) |
|
117 } GstMiniObjectFlags; |
|
118 |
|
119 /** |
|
120 * GST_MINI_OBJECT_REFCOUNT: |
|
121 * @obj: a #GstMiniObject |
|
122 * |
|
123 * Get access to the reference count field of the mini-object. |
|
124 */ |
|
125 #define GST_MINI_OBJECT_REFCOUNT(obj) ((GST_MINI_OBJECT_CAST(obj))->refcount) |
|
126 /** |
|
127 * GST_MINI_OBJECT_REFCOUNT_VALUE: |
|
128 * @obj: a #GstMiniObject |
|
129 * |
|
130 * Get the reference count value of the mini-object. |
|
131 */ |
|
132 #define GST_MINI_OBJECT_REFCOUNT_VALUE(obj) (g_atomic_int_get (&(GST_MINI_OBJECT_CAST(obj))->refcount)) |
|
133 |
|
134 /** |
|
135 * GstMiniObject: |
|
136 * @instance: type instance |
|
137 * @refcount: atomic refcount |
|
138 * @flags: extra flags. |
|
139 * |
|
140 * Base class for refcounted lightweight objects. |
|
141 */ |
|
142 struct _GstMiniObject { |
|
143 GTypeInstance instance; |
|
144 /*< public >*/ /* with COW */ |
|
145 gint refcount; |
|
146 guint flags; |
|
147 |
|
148 /*< private >*/ |
|
149 gpointer _gst_reserved; |
|
150 }; |
|
151 |
|
152 struct _GstMiniObjectClass { |
|
153 GTypeClass type_class; |
|
154 |
|
155 GstMiniObjectCopyFunction copy; |
|
156 GstMiniObjectFinalizeFunction finalize; |
|
157 |
|
158 /*< private >*/ |
|
159 gpointer _gst_reserved; |
|
160 }; |
|
161 #ifdef __SYMBIAN32__ |
|
162 IMPORT_C |
|
163 #endif |
|
164 |
|
165 |
|
166 GType gst_mini_object_get_type (void); |
|
167 #ifdef __SYMBIAN32__ |
|
168 IMPORT_C |
|
169 #endif |
|
170 |
|
171 |
|
172 GstMiniObject* gst_mini_object_new (GType type); |
|
173 #ifdef __SYMBIAN32__ |
|
174 IMPORT_C |
|
175 #endif |
|
176 |
|
177 GstMiniObject* gst_mini_object_copy (const GstMiniObject *mini_object); |
|
178 #ifdef __SYMBIAN32__ |
|
179 IMPORT_C |
|
180 #endif |
|
181 |
|
182 gboolean gst_mini_object_is_writable (const GstMiniObject *mini_object); |
|
183 #ifdef __SYMBIAN32__ |
|
184 IMPORT_C |
|
185 #endif |
|
186 |
|
187 GstMiniObject* gst_mini_object_make_writable (GstMiniObject *mini_object); |
|
188 |
|
189 /* refcounting */ |
|
190 #ifdef __SYMBIAN32__ |
|
191 IMPORT_C |
|
192 #endif |
|
193 |
|
194 GstMiniObject* gst_mini_object_ref (GstMiniObject *mini_object); |
|
195 #ifdef __SYMBIAN32__ |
|
196 IMPORT_C |
|
197 #endif |
|
198 |
|
199 void gst_mini_object_unref (GstMiniObject *mini_object); |
|
200 #ifdef __SYMBIAN32__ |
|
201 IMPORT_C |
|
202 #endif |
|
203 |
|
204 void gst_mini_object_replace (GstMiniObject **olddata, GstMiniObject *newdata); |
|
205 |
|
206 /* GParamSpec */ |
|
207 #ifdef __SYMBIAN32__ |
|
208 IMPORT_C |
|
209 #endif |
|
210 |
|
211 GParamSpec* gst_param_spec_mini_object (const char *name, const char *nick, |
|
212 const char *blurb, GType object_type, |
|
213 GParamFlags flags); |
|
214 |
|
215 /* GValue stuff */ |
|
216 #ifdef __SYMBIAN32__ |
|
217 IMPORT_C |
|
218 #endif |
|
219 |
|
220 void gst_value_set_mini_object (GValue *value, GstMiniObject *mini_object); |
|
221 #ifdef __SYMBIAN32__ |
|
222 IMPORT_C |
|
223 #endif |
|
224 |
|
225 void gst_value_take_mini_object (GValue *value, GstMiniObject *mini_object); |
|
226 #ifdef __SYMBIAN32__ |
|
227 IMPORT_C |
|
228 #endif |
|
229 |
|
230 GstMiniObject* gst_value_get_mini_object (const GValue *value); |
|
231 |
|
232 |
|
233 G_END_DECLS |
|
234 |
|
235 #endif |
|
236 |