1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = gstreamer-GstBufferList.html
27  * outPack = gstreamer
28  * outFile = BufferList
29  * strct   = GstBufferList
30  * realStrct=
31  * ctorStrct=
32  * clss    = BufferList
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_buffer_list_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gstreamer.Buffer
47  * structWrap:
48  * 	- GstBuffer* -> Buffer
49  * 	- GstBufferList* -> BufferList
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gstreamer.BufferList;
56 
57 public  import gstreamerc.gstreamertypes;
58 
59 private import gstreamerc.gstreamer;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 private import gstreamer.Buffer;
64 
65 
66 
67 /**
68  * Buffer lists are an object containing a list of buffers.
69  *
70  * Buffer lists are created with gst_buffer_list_new() and filled with data
71  * using a gst_buffer_list_insert().
72  *
73  * Buffer lists can be pushed on a srcpad with gst_pad_push_list(). This is
74  * interesting when multiple buffers need to be pushed in one go because it
75  * can reduce the amount of overhead for pushing each buffer individually.
76  *
77  * Last reviewed on 2012-03-28 (0.11.3)
78  */
79 public class BufferList
80 {
81 	
82 	/** the main Gtk struct */
83 	protected GstBufferList* gstBufferList;
84 	
85 	
86 	/** Get the main Gtk struct */
87 	public GstBufferList* getBufferListStruct()
88 	{
89 		return gstBufferList;
90 	}
91 	
92 	
93 	/** the main Gtk struct as a void* */
94 	protected void* getStruct()
95 	{
96 		return cast(void*)gstBufferList;
97 	}
98 	
99 	/**
100 	 * Sets our main struct and passes it to the parent class
101 	 */
102 	public this (GstBufferList* gstBufferList)
103 	{
104 		this.gstBufferList = gstBufferList;
105 	}
106 	
107 	/**
108 	 */
109 	
110 	/**
111 	 * Creates a new, empty GstBufferList. The caller is responsible for unreffing
112 	 * the returned GstBufferList.
113 	 * Free-function: gst_buffer_list_unref
114 	 * Throws: ConstructionException GTK+ fails to create the object.
115 	 */
116 	public this ()
117 	{
118 		// GstBufferList * gst_buffer_list_new (void);
119 		auto p = gst_buffer_list_new();
120 		if(p is null)
121 		{
122 			throw new ConstructionException("null returned by gst_buffer_list_new()");
123 		}
124 		this(cast(GstBufferList*) p);
125 	}
126 	
127 	/**
128 	 * Creates a new, empty GstBufferList. The caller is responsible for unreffing
129 	 * the returned GstBufferList. The list will have size space preallocated so
130 	 * that memory reallocations can be avoided.
131 	 * Free-function: gst_buffer_list_unref
132 	 * Params:
133 	 * size = an initial reserved size
134 	 * Throws: ConstructionException GTK+ fails to create the object.
135 	 */
136 	public this (uint size)
137 	{
138 		// GstBufferList * gst_buffer_list_new_sized (guint size);
139 		auto p = gst_buffer_list_new_sized(size);
140 		if(p is null)
141 		{
142 			throw new ConstructionException("null returned by gst_buffer_list_new_sized(size)");
143 		}
144 		this(cast(GstBufferList*) p);
145 	}
146 	
147 	/**
148 	 * Returns the number of buffers in list.
149 	 * Returns: the number of buffers in the buffer list
150 	 */
151 	public uint length()
152 	{
153 		// guint gst_buffer_list_length (GstBufferList *list);
154 		return gst_buffer_list_length(gstBufferList);
155 	}
156 	
157 	/**
158 	 * Insert buffer at idx in list. Other buffers are moved to make room for
159 	 * this new buffer.
160 	 * A -1 value for idx will append the buffer at the end.
161 	 * Params:
162 	 * idx = the index
163 	 * buffer = a GstBuffer. [transfer full]
164 	 */
165 	public void insert(int idx, Buffer buffer)
166 	{
167 		// void gst_buffer_list_insert (GstBufferList *list,  gint idx,  GstBuffer *buffer);
168 		gst_buffer_list_insert(gstBufferList, idx, (buffer is null) ? null : buffer.getBufferStruct());
169 	}
170 	
171 	/**
172 	 * Remove length buffers starting from idx in list. The following buffers are
173 	 * moved to close the gap.
174 	 * Params:
175 	 * idx = the index
176 	 * length = the amount to remove
177 	 */
178 	public void remove(uint idx, uint length)
179 	{
180 		// void gst_buffer_list_remove (GstBufferList *list,  guint idx,  guint length);
181 		gst_buffer_list_remove(gstBufferList, idx, length);
182 	}
183 	
184 	/**
185 	 * Increases the refcount of the given buffer list by one.
186 	 * Note that the refcount affects the writeability of list and its data, see
187 	 * gst_buffer_list_make_writable(). It is important to note that keeping
188 	 * additional references to GstBufferList instances can potentially increase
189 	 * the number of memcpy operations in a pipeline.
190 	 * Returns: list. [transfer full]
191 	 */
192 	public BufferList doref()
193 	{
194 		// GstBufferList * gst_buffer_list_ref (GstBufferList *list);
195 		auto p = gst_buffer_list_ref(gstBufferList);
196 		
197 		if(p is null)
198 		{
199 			return null;
200 		}
201 		
202 		return ObjectG.getDObject!(BufferList)(cast(GstBufferList*) p);
203 	}
204 	
205 	/**
206 	 * Decreases the refcount of the buffer list. If the refcount reaches 0, the
207 	 * buffer list will be freed.
208 	 */
209 	public void unref()
210 	{
211 		// void gst_buffer_list_unref (GstBufferList *list);
212 		gst_buffer_list_unref(gstBufferList);
213 	}
214 	
215 	/**
216 	 * Create a shallow copy of the given buffer list. This will make a newly
217 	 * allocated copy of the source list with copies of buffer pointers. The
218 	 * refcount of buffers pointed to will be increased by one.
219 	 * Returns: a new copy of list. [transfer full]
220 	 */
221 	public BufferList copy()
222 	{
223 		// GstBufferList * gst_buffer_list_copy (const GstBufferList *list);
224 		auto p = gst_buffer_list_copy(gstBufferList);
225 		
226 		if(p is null)
227 		{
228 			return null;
229 		}
230 		
231 		return ObjectG.getDObject!(BufferList)(cast(GstBufferList*) p);
232 	}
233 	
234 	/**
235 	 * Call func with data for each buffer in list.
236 	 * func can modify the passed buffer pointer or its contents. The return value
237 	 * of func define if this function returns or if the remaining buffers in
238 	 * the list should be skipped.
239 	 * Params:
240 	 * func = a GstBufferListFunc to call. [scope call]
241 	 * userData = user data passed to func. [closure]
242 	 * Returns: TRUE when func returned TRUE for each buffer in list or when list is empty.
243 	 */
244 	public int foreac(GstBufferListFunc func, void* userData)
245 	{
246 		// gboolean gst_buffer_list_foreach (GstBufferList *list,  GstBufferListFunc func,  gpointer user_data);
247 		return gst_buffer_list_foreach(gstBufferList, func, userData);
248 	}
249 	
250 	/**
251 	 * Get the buffer at idx.
252 	 * Params:
253 	 * idx = the index
254 	 * Returns: the buffer at idx in group or NULL when there is no buffer. The buffer remains valid as long as list is valid. [transfer none]
255 	 */
256 	public Buffer get(uint idx)
257 	{
258 		// GstBuffer * gst_buffer_list_get (GstBufferList *list,  guint idx);
259 		auto p = gst_buffer_list_get(gstBufferList, idx);
260 		
261 		if(p is null)
262 		{
263 			return null;
264 		}
265 		
266 		return ObjectG.getDObject!(Buffer)(cast(GstBuffer*) p);
267 	}
268 }