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 = GstAllocator.html 27 * outPack = gstreamer 28 * outFile = Allocator 29 * strct = GstAllocator 30 * realStrct= 31 * ctorStrct= 32 * clss = Allocator 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_allocator_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gstreamer.Memory 48 * structWrap: 49 * - GstAllocator* -> Allocator 50 * - GstMemory* -> Memory 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module gstreamer.Allocator; 57 58 public import gstreamerc.gstreamertypes; 59 60 private import gstreamerc.gstreamer; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 65 private import glib.Str; 66 private import gstreamer.Memory; 67 68 69 70 private import gstreamer.ObjectGst; 71 72 /** 73 * Memory is usually created by allocators with a gst_allocator_alloc() 74 * method call. When NULL is used as the allocator, the default allocator will 75 * be used. 76 * 77 * New allocators can be registered with gst_allocator_register(). 78 * Allocators are identified by name and can be retrieved with 79 * gst_allocator_find(). gst_allocator_set_default() can be used to change the 80 * default allocator. 81 * 82 * New memory can be created with gst_memory_new_wrapped() that wraps the memory 83 * allocated elsewhere. 84 * 85 * Last reviewed on 2012-07-09 (0.11.3) 86 */ 87 public class Allocator : ObjectGst 88 { 89 90 /** the main Gtk struct */ 91 protected GstAllocator* gstAllocator; 92 93 94 public GstAllocator* getAllocatorStruct() 95 { 96 return gstAllocator; 97 } 98 99 100 /** the main Gtk struct as a void* */ 101 protected override void* getStruct() 102 { 103 return cast(void*)gstAllocator; 104 } 105 106 /** 107 * Sets our main struct and passes it to the parent class 108 */ 109 public this (GstAllocator* gstAllocator) 110 { 111 super(cast(GstObject*)gstAllocator); 112 this.gstAllocator = gstAllocator; 113 } 114 115 protected override void setStruct(GObject* obj) 116 { 117 super.setStruct(obj); 118 gstAllocator = cast(GstAllocator*)obj; 119 } 120 121 /** 122 */ 123 124 /** 125 * Find a previously registered allocator with name. When name is NULL, the 126 * default allocator will be returned. 127 * Params: 128 * name = the name of the allocator. [allow-none] 129 * Returns: a GstAllocator or NULL when the allocator with name was not registered. Use gst_object_unref() to release the allocator after usage. [transfer full] 130 */ 131 public static Allocator find(string name) 132 { 133 // GstAllocator * gst_allocator_find (const gchar *name); 134 auto p = gst_allocator_find(Str.toStringz(name)); 135 136 if(p is null) 137 { 138 return null; 139 } 140 141 return ObjectG.getDObject!(Allocator)(cast(GstAllocator*) p); 142 } 143 144 /** 145 * Registers the memory allocator with name. This function takes ownership of 146 * allocator. 147 * Params: 148 * name = the name of the allocator 149 * allocator = GstAllocator. [transfer full] 150 */ 151 public static void register(string name, Allocator allocator) 152 { 153 // void gst_allocator_register (const gchar *name, GstAllocator *allocator); 154 gst_allocator_register(Str.toStringz(name), (allocator is null) ? null : allocator.getAllocatorStruct()); 155 } 156 157 /** 158 * Set the default allocator. This function takes ownership of allocator. 159 */ 160 public void setDefault() 161 { 162 // void gst_allocator_set_default (GstAllocator *allocator); 163 gst_allocator_set_default(gstAllocator); 164 } 165 166 /** 167 * Initialize params to its default values 168 * Params: 169 * params = a GstAllocationParams 170 */ 171 public static void gstAllocationParamsInit(GstAllocationParams* params) 172 { 173 // void gst_allocation_params_init (GstAllocationParams *params); 174 gst_allocation_params_init(params); 175 } 176 177 /** 178 * Create a copy of params. 179 * Free-function: gst_allocation_params_free 180 * Params: 181 * params = a GstAllocationParams. [transfer none] 182 * Returns: a new #GstAllocationParams, free with gst_allocation_params_free(). [transfer full] 183 */ 184 public static GstAllocationParams* gstAllocationParamsCopy(GstAllocationParams* params) 185 { 186 // GstAllocationParams * gst_allocation_params_copy (const GstAllocationParams *params); 187 return gst_allocation_params_copy(params); 188 } 189 190 /** 191 * Free params 192 * Params: 193 * params = a GstAllocationParams. [in][transfer full] 194 */ 195 public static void gstAllocationParamsFree(GstAllocationParams* params) 196 { 197 // void gst_allocation_params_free (GstAllocationParams *params); 198 gst_allocation_params_free(params); 199 } 200 201 /** 202 * Use allocator to allocate a new memory block with memory that is at least 203 * size big. 204 * The optional params can specify the prefix and padding for the memory. If 205 * NULL is passed, no flags, no extra prefix/padding and a default alignment is 206 * used. 207 * The prefix/padding will be filled with 0 if flags contains 208 * GST_MEMORY_FLAG_ZERO_PREFIXED and GST_MEMORY_FLAG_ZERO_PADDED respectively. 209 * When allocator is NULL, the default allocator will be used. 210 * The alignment in params is given as a bitmask so that align + 1 equals 211 * the amount of bytes to align to. For example, to align to 8 bytes, 212 * use an alignment of 7. 213 * Params: 214 * size = size of the visible memory area 215 * params = optional parameters. [transfer none][allow-none] 216 * Returns: a new GstMemory. [transfer full] 217 */ 218 public Memory alloc(gsize size, GstAllocationParams* params) 219 { 220 // GstMemory * gst_allocator_alloc (GstAllocator *allocator, gsize size, GstAllocationParams *params); 221 auto p = gst_allocator_alloc(gstAllocator, size, params); 222 223 if(p is null) 224 { 225 return null; 226 } 227 228 return ObjectG.getDObject!(Memory)(cast(GstMemory*) p); 229 } 230 231 /** 232 * Free memory that was previously allocated with gst_allocator_alloc(). 233 * Params: 234 * memory = the memory to free. [transfer full] 235 */ 236 public void free(Memory memory) 237 { 238 // void gst_allocator_free (GstAllocator *allocator, GstMemory *memory); 239 gst_allocator_free(gstAllocator, (memory is null) ? null : memory.getMemoryStruct()); 240 } 241 242 /** 243 * Allocate a new memory block that wraps the given data. 244 * The prefix/padding must be filled with 0 if flags contains 245 * GST_MEMORY_FLAG_ZERO_PREFIXED and GST_MEMORY_FLAG_ZERO_PADDED respectively. 246 * Params: 247 * flags = GstMemoryFlags 248 * data = data to 249 * wrap. [array length=size][element-type guint8][transfer none] 250 * maxsize = allocated size of data 251 * offset = offset in data 252 * size = size of valid data 253 * userData = user_data. [allow-none] 254 * notify = called with user_data when the memory is freed. [allow-none][scope async][closure user_data] 255 * Returns: a new GstMemory. [transfer full] 256 */ 257 public static Memory gstMemoryNewWrapped(GstMemoryFlags flags, void* data, gsize maxsize, gsize offset, gsize size, void* userData, GDestroyNotify notify) 258 { 259 // GstMemory * gst_memory_new_wrapped (GstMemoryFlags flags, gpointer data, gsize maxsize, gsize offset, gsize size, gpointer user_data, GDestroyNotify notify); 260 auto p = gst_memory_new_wrapped(flags, data, maxsize, offset, size, userData, notify); 261 262 if(p is null) 263 { 264 return null; 265 } 266 267 return ObjectG.getDObject!(Memory)(cast(GstMemory*) p); 268 } 269 }