2 * Copyright (C) 2005 David Schleef <ds@schleef.org>
4 * gstminiobject.h: Header for GstMiniObject
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.
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.
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.
23 #ifndef __GST_MINI_OBJECT_H__
24 #define __GST_MINI_OBJECT_H__
26 #include <gst/gstconfig.h>
28 #include <glib-object.h>
32 #define GST_MINI_OBJECT_CAST(obj) ((GstMiniObject*)(obj))
33 #define GST_MINI_OBJECT_CONST_CAST(obj) ((const GstMiniObject*)(obj))
35 typedef struct _GstMiniObject GstMiniObject;
38 * GstMiniObjectCopyFunction:
39 * @obj: MiniObject to copy
41 * Virtual function prototype for methods to create copies of instances.
43 * Returns: reference to cloned instance.
45 typedef GstMiniObject * (*GstMiniObjectCopyFunction) (const GstMiniObject *obj);
47 * GstMiniObjectFreeFunction:
48 * @obj: MiniObject to free
50 * Virtual function prototype for methods to free ressources used by
51 * mini-objects. Subclasses of the mini object are allowed to revive the
52 * passed object by doing a gst_mini_object_ref(). If the object is not
53 * revived after the free function, the memory associated with the
56 typedef void (*GstMiniObjectFreeFunction) (GstMiniObject *obj);
59 * GST_MINI_OBJECT_FLAGS:
60 * @obj: MiniObject to return flags for.
62 * This macro returns the entire set of flags for the mini-object.
64 #define GST_MINI_OBJECT_TYPE(obj) (GST_MINI_OBJECT_CAST(obj)->type)
66 * GST_MINI_OBJECT_FLAGS:
67 * @obj: MiniObject to return flags for.
69 * This macro returns the entire set of flags for the mini-object.
71 #define GST_MINI_OBJECT_FLAGS(obj) (GST_MINI_OBJECT_CAST(obj)->flags)
73 * GST_MINI_OBJECT_FLAG_IS_SET:
74 * @obj: MiniObject to check for flags.
75 * @flag: Flag to check for
77 * This macro checks to see if the given flag is set.
79 #define GST_MINI_OBJECT_FLAG_IS_SET(obj,flag) !!(GST_MINI_OBJECT_FLAGS (obj) & (flag))
81 * GST_MINI_OBJECT_FLAG_SET:
82 * @obj: MiniObject to set flag in.
83 * @flag: Flag to set, can by any number of bits in guint32.
85 * This macro sets the given bits.
87 #define GST_MINI_OBJECT_FLAG_SET(obj,flag) (GST_MINI_OBJECT_FLAGS (obj) |= (flag))
89 * GST_MINI_OBJECT_FLAG_UNSET:
90 * @obj: MiniObject to unset flag in.
91 * @flag: Flag to set, must be a single bit in guint32.
93 * This macro usets the given bits.
95 #define GST_MINI_OBJECT_FLAG_UNSET(obj,flag) (GST_MINI_OBJECT_FLAGS (obj) &= ~(flag))
99 * @GST_MINI_OBJECT_FLAG_READONLY: is the miniobject readonly or writable
100 * @GST_MINI_OBJECT_FLAG_RESERVED1: a flag reserved for internal use e.g. as
101 * GST_BUFFER_FLAG_MEDIA4. Since: 0.10.33.
102 * @GST_MINI_OBJECT_FLAG_LAST: first flag that can be used by subclasses.
104 * Flags for the mini object
108 GST_MINI_OBJECT_FLAG_READONLY = (1<<0),
109 GST_MINI_OBJECT_FLAG_RESERVED1 = (1<<1),
111 GST_MINI_OBJECT_FLAG_LAST = (1<<4)
112 } GstMiniObjectFlags;
115 * GST_MINI_OBJECT_REFCOUNT:
116 * @obj: a #GstMiniObject
118 * Get access to the reference count field of the mini-object.
120 #define GST_MINI_OBJECT_REFCOUNT(obj) ((GST_MINI_OBJECT_CAST(obj))->refcount)
122 * GST_MINI_OBJECT_REFCOUNT_VALUE:
123 * @obj: a #GstMiniObject
125 * Get the reference count value of the mini-object.
127 #define GST_MINI_OBJECT_REFCOUNT_VALUE(obj) (g_atomic_int_get (&(GST_MINI_OBJECT_CAST(obj))->refcount))
131 * @instance: type instance
132 * @refcount: atomic refcount
133 * @flags: extra flags.
135 * Base class for refcounted lightweight objects.
136 * Ref Func: gst_mini_object_ref
137 * Unref Func: gst_mini_object_unref
138 * Set Value Func: gst_value_set_mini_object
139 * Get Value Func: gst_value_get_mini_object
141 struct _GstMiniObject {
144 /*< public >*/ /* with COW */
148 GstMiniObjectCopyFunction copy;
149 GstMiniObjectFreeFunction free;
152 GType gst_mini_object_get_type (void);
154 GstMiniObject* gst_mini_object_copy (const GstMiniObject *mini_object);
155 gboolean gst_mini_object_is_writable (const GstMiniObject *mini_object);
156 GstMiniObject* gst_mini_object_make_writable (GstMiniObject *mini_object);
159 GstMiniObject* gst_mini_object_ref (GstMiniObject *mini_object);
160 void gst_mini_object_unref (GstMiniObject *mini_object);
162 void gst_mini_object_replace (GstMiniObject **olddata, GstMiniObject *newdata);