bufferlist: fix a comment
[platform/upstream/gstreamer.git] / gst / gstbufferlist.h
1 /* GStreamer
2  * Copyright (C) 2009 Axis Communications <dev-gstreamer at axis dot com>
3  * @author Jonas Holmberg <jonas dot holmberg at axis dot com>
4  *
5  * gstbufferlist.h: Header for GstBufferList object
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 #ifndef __GST_BUFFER_LIST_H__
24 #define __GST_BUFFER_LIST_H__
25
26 #include <gst/gstbuffer.h>
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_BUFFER_LIST (gst_buffer_list_get_type ())
31 #define GST_IS_BUFFER_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_LIST))
32 #define GST_IS_BUFFER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_LIST))
33 #define GST_BUFFER_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_LIST, GstBufferListClass))
34 #define GST_BUFFER_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_LIST, GstBufferList))
35 #define GST_BUFFER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_LIST, GstBufferListClass))
36 #define GST_BUFFER_LIST_CAST(obj) ((GstBufferList *)obj)
37
38 typedef struct _GstBufferList GstBufferList;
39 typedef struct _GstBufferListClass GstBufferListClass;
40 typedef struct _GstBufferListIterator GstBufferListIterator;
41
42 /**
43  * GstBufferListDoFunction:
44  * @buffer: the #GstBuffer
45  *
46  * A function for accessing the last buffer returned by
47  * gst_buffer_list_iterator_next(). The function can leave @buffer in the list,
48  * replace @buffer in the list or remove @buffer from the list, depending on
49  * the return value. If the function returns NULL, @buffer will be removed from
50  * the list, otherwise @buffer will be replaced with the returned buffer.
51  *
52  * The last buffer returned by gst_buffer_list_iterator_next() will be replaced
53  * with the buffer returned from the function. The function takes ownership of
54  * @buffer and if a different value than @buffer is returned, @buffer must be
55  * unreffed. If NULL is returned, the buffer will be removed from the list. The
56  * list must be writable.
57  *
58  * Returns: the buffer to replace @buffer in the list, or NULL to remove @buffer
59  * from the list
60  */
61 typedef GstBuffer* (*GstBufferListDoFunction) (GstBuffer * buffer);
62
63 /**
64  * GstBufferListDoDataFunction:
65  * @buffer: the #GstBuffer
66  * @data: the gpointer to optional user data.
67  *
68  * A function for accessing the last buffer returned by
69  * gst_buffer_list_iterator_next(). The function can leave @buffer in the list,
70  * replace @buffer in the list or remove @buffer from the list, depending on
71  * the return value. If the function returns NULL, @buffer will be removed from
72  * the list, otherwise @buffer will be replaced with the returned buffer.
73  *
74  * The last buffer returned by gst_buffer_list_iterator_next() will be replaced
75  * with the buffer returned from the function. The function takes ownership of
76  * @buffer and if a different value than @buffer is returned, @buffer must be
77  * unreffed. If NULL is returned, the buffer will be removed from the list. The
78  * list must be writable.
79  *
80  * Returns: the buffer to replace @buffer in the list, or NULL to remove @buffer
81  * from the list
82  */
83 typedef GstBuffer* (*GstBufferListDoDataFunction) (GstBuffer * buffer, gpointer data);
84
85 /**
86  * GstBufferList:
87  * @mini_object: the parent structure
88  *
89  * List of grouped buffers.
90  */
91 struct _GstBufferList {
92   GstMiniObject mini_object;
93
94   /*< private >*/
95   GList *buffers;
96
97   gpointer _gst_reserved[GST_PADDING];
98 };
99
100 struct _GstBufferListClass {
101   GstMiniObjectClass mini_object_class;
102 };
103
104 GType gst_buffer_list_get_type (void);
105
106 /* allocation */
107 GstBufferList *gst_buffer_list_new (void);
108
109 /* refcounting */
110 /**
111  * gst_buffer_list_ref:
112  * @list: a #GstBufferList
113  *
114  * Increases the refcount of the given buffer list by one.
115  *
116  * Note that the refcount affects the writeability of @list and its data, see
117  * gst_buffer_list_make_writable(). It is important to note that keeping
118  * additional references to GstBufferList instances can potentially increase
119  * the number of memcpy operations in a pipeline.
120  *
121  * Returns: @list
122  */
123 #ifdef _FOOL_GTK_DOC_
124 G_INLINE_FUNC GstBufferList * gst_buffer_list_ref (GstBufferList * list);
125 #endif
126
127 static inline GstBufferList *
128 gst_buffer_list_ref (GstBufferList * list)
129 {
130   return GST_BUFFER_LIST_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (
131       list)));
132 }
133
134 /**
135  * gst_buffer_list_unref:
136  * @list: a #GstBufferList
137  *
138  * Decreases the refcount of the buffer list. If the refcount reaches 0, the
139  * buffer list will be freed.
140  */
141 #ifdef _FOOL_GTK_DOC_
142 G_INLINE_FUNC void gst_buffer_list_unref (GstBufferList * list);
143 #endif
144
145 static inline void
146 gst_buffer_list_unref (GstBufferList * list)
147 {
148   gst_mini_object_unref (GST_MINI_OBJECT_CAST (list));
149 }
150
151 /* copy */
152 /**
153  * gst_buffer_list_copy:
154  * @list: a #GstBufferList
155  *
156  * Create a shallow copy of the given buffer list. This will make a newly
157  * allocated copy of the source list with copies of buffer pointers. The
158  * refcount of buffers pointed to will be increased by one.
159  *
160  * Returns: a new copy of @list.
161  */
162 #ifdef _FOOL_GTK_DOC_
163 G_INLINE_FUNC GstBufferList * gst_buffer_list_copy (const GstBufferList * list);
164 #endif
165
166 static inline GstBufferList *
167 gst_buffer_list_copy (const GstBufferList * list)
168 {
169   return GST_BUFFER_LIST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (list)));
170 }
171
172 /**
173  * gst_buffer_list_is_writable:
174  * @list: a #GstBufferList
175  *
176  * Tests if you can safely add buffers and groups into a buffer list.
177  */
178 #define gst_buffer_list_is_writable(list) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (list))
179
180 /**
181  * gst_buffer_list_make_writable:
182  * @list: a #GstBufferList
183  *
184  * Makes a writable buffer list from the given buffer list. If the source buffer
185  * list is already writable, this will simply return the same buffer list. A
186  * copy will otherwise be made using gst_buffer_list_copy().
187  */
188 #define gst_buffer_list_make_writable(list) GST_BUFFER_LIST_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (list)))
189
190 guint                    gst_buffer_list_n_groups              (GstBufferList *list);
191
192 /* iterator */
193 GstBufferListIterator *  gst_buffer_list_iterate               (GstBufferList *list);
194 void                     gst_buffer_list_iterator_free         (GstBufferListIterator *it);
195
196 guint                    gst_buffer_list_iterator_n_buffers    (const GstBufferListIterator *it);
197 GstBuffer *              gst_buffer_list_iterator_next         (GstBufferListIterator *it);
198 gboolean                 gst_buffer_list_iterator_next_group   (GstBufferListIterator *it);
199
200 void                     gst_buffer_list_iterator_add          (GstBufferListIterator *it, GstBuffer *buffer);
201 void                     gst_buffer_list_iterator_add_group    (GstBufferListIterator *it);
202 void                     gst_buffer_list_iterator_remove       (GstBufferListIterator *it);
203 GstBuffer *              gst_buffer_list_iterator_steal        (GstBufferListIterator *it);
204 void                     gst_buffer_list_iterator_take         (GstBufferListIterator *it, GstBuffer *buffer);
205
206 GstBuffer *              gst_buffer_list_iterator_do           (GstBufferListIterator *it, GstBufferListDoFunction do_func);
207 GstBuffer *              gst_buffer_list_iterator_do_data      (GstBufferListIterator *it, GstBufferListDoDataFunction do_func,
208                                                                 gpointer data, GDestroyNotify data_notify);
209
210 /* conversion */
211 GstBuffer *              gst_buffer_list_iterator_merge_group  (const GstBufferListIterator *it);
212
213 G_END_DECLS
214
215 #endif /* __GST_BUFFER_LIST_H__ */