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 module gstreamer.BufferList;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gstreamer.Buffer;
30 private import gstreamerc.gstreamer;
31 public  import gstreamerc.gstreamertypes;
32 
33 
34 /**
35  * Buffer lists are an object containing a list of buffers.
36  * 
37  * Buffer lists are created with gst_buffer_list_new() and filled with data
38  * using a gst_buffer_list_insert().
39  * 
40  * Buffer lists can be pushed on a srcpad with gst_pad_push_list(). This is
41  * interesting when multiple buffers need to be pushed in one go because it
42  * can reduce the amount of overhead for pushing each buffer individually.
43  */
44 public class BufferList
45 {
46 	/** the main Gtk struct */
47 	protected GstBufferList* gstBufferList;
48 
49 	/** Get the main Gtk struct */
50 	public GstBufferList* getBufferListStruct()
51 	{
52 		return gstBufferList;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected void* getStruct()
57 	{
58 		return cast(void*)gstBufferList;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GstBufferList* gstBufferList)
65 	{
66 		this.gstBufferList = gstBufferList;
67 	}
68 
69 	/**
70 	 */
71 
72 	public static GType getType()
73 	{
74 		return gst_buffer_list_get_type();
75 	}
76 
77 	/**
78 	 * Creates a new, empty #GstBufferList. The caller is responsible for unreffing
79 	 * the returned #GstBufferList.
80 	 *
81 	 * Free-function: gst_buffer_list_unref
82 	 *
83 	 * Return: the new #GstBufferList. gst_buffer_list_unref()
84 	 *     after usage.
85 	 *
86 	 * Throws: ConstructionException GTK+ fails to create the object.
87 	 */
88 	public this()
89 	{
90 		auto p = gst_buffer_list_new();
91 		
92 		if(p is null)
93 		{
94 			throw new ConstructionException("null returned by new");
95 		}
96 		
97 		this(cast(GstBufferList*) p);
98 	}
99 
100 	/**
101 	 * Creates a new, empty #GstBufferList. The caller is responsible for unreffing
102 	 * the returned #GstBufferList. The list will have @size space preallocated so
103 	 * that memory reallocations can be avoided.
104 	 *
105 	 * Free-function: gst_buffer_list_unref
106 	 *
107 	 * Params:
108 	 *     size = an initial reserved size
109 	 *
110 	 * Return: the new #GstBufferList. gst_buffer_list_unref()
111 	 *     after usage.
112 	 *
113 	 * Throws: ConstructionException GTK+ fails to create the object.
114 	 */
115 	public this(uint size)
116 	{
117 		auto p = gst_buffer_list_new_sized(size);
118 		
119 		if(p is null)
120 		{
121 			throw new ConstructionException("null returned by new_sized");
122 		}
123 		
124 		this(cast(GstBufferList*) p);
125 	}
126 
127 	/**
128 	 * Create a copy of the given buffer list. This will make a newly allocated
129 	 * copy of the buffer that the source buffer list contains.
130 	 *
131 	 * Return: a new copy of @list.
132 	 *
133 	 * Since: 1.6
134 	 */
135 	public BufferList copyDeep()
136 	{
137 		auto p = gst_buffer_list_copy_deep(gstBufferList);
138 		
139 		if(p is null)
140 		{
141 			return null;
142 		}
143 		
144 		return ObjectG.getDObject!(BufferList)(cast(GstBufferList*) p);
145 	}
146 
147 	/**
148 	 * Call @func with @data for each buffer in @list.
149 	 *
150 	 * @func can modify the passed buffer pointer or its contents. The return value
151 	 * of @func define if this function returns or if the remaining buffers in
152 	 * the list should be skipped.
153 	 *
154 	 * Params:
155 	 *     func = a #GstBufferListFunc to call
156 	 *     userData = user data passed to @func
157 	 *
158 	 * Return: %TRUE when @func returned %TRUE for each buffer in @list or when
159 	 *     @list is empty.
160 	 */
161 	public bool foreac(GstBufferListFunc func, void* userData)
162 	{
163 		return gst_buffer_list_foreach(gstBufferList, func, userData) != 0;
164 	}
165 
166 	/**
167 	 * Get the buffer at @idx.
168 	 *
169 	 * Params:
170 	 *     idx = the index
171 	 *
172 	 * Return: the buffer at @idx in @group
173 	 *     or %NULL when there is no buffer. The buffer remains valid as
174 	 *     long as @list is valid and buffer is not removed from the list.
175 	 */
176 	public Buffer get(uint idx)
177 	{
178 		auto p = gst_buffer_list_get(gstBufferList, idx);
179 		
180 		if(p is null)
181 		{
182 			return null;
183 		}
184 		
185 		return ObjectG.getDObject!(Buffer)(cast(GstBuffer*) p);
186 	}
187 
188 	/**
189 	 * Insert @buffer at @idx in @list. Other buffers are moved to make room for
190 	 * this new buffer.
191 	 *
192 	 * A -1 value for @idx will append the buffer at the end.
193 	 *
194 	 * Params:
195 	 *     idx = the index
196 	 *     buffer = a #GstBuffer
197 	 */
198 	public void insert(int idx, Buffer buffer)
199 	{
200 		gst_buffer_list_insert(gstBufferList, idx, (buffer is null) ? null : buffer.getBufferStruct());
201 	}
202 
203 	/**
204 	 * Returns the number of buffers in @list.
205 	 *
206 	 * Return: the number of buffers in the buffer list
207 	 */
208 	public uint length()
209 	{
210 		return gst_buffer_list_length(gstBufferList);
211 	}
212 
213 	/**
214 	 * Remove @length buffers starting from @idx in @list. The following buffers
215 	 * are moved to close the gap.
216 	 *
217 	 * Params:
218 	 *     idx = the index
219 	 *     length = the amount to remove
220 	 */
221 	public void remove(uint idx, uint length)
222 	{
223 		gst_buffer_list_remove(gstBufferList, idx, length);
224 	}
225 }