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