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