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 change21 // find conversion definition on APILookup.txt22 // implement new conversion functionalities on the wrap.utils pakage23 24 25 modulegstreamer.Allocator;
26 27 privateimportglib.Str;
28 privateimportgobject.ObjectG;
29 privateimportgstreamer.AllocationParams;
30 privateimportgstreamer.Memory;
31 privateimportgstreamer.ObjectGst;
32 privateimportgstreamer.c.functions;
33 publicimportgstreamer.c.types;
34 publicimportgstreamerc.gstreamertypes;
35 36 37 /**
38 * Memory is usually created by allocators with a gst_allocator_alloc()
39 * method call. When %NULL is used as the allocator, the default allocator will
40 * be used.
41 *
42 * New allocators can be registered with gst_allocator_register().
43 * Allocators are identified by name and can be retrieved with
44 * gst_allocator_find(). gst_allocator_set_default() can be used to change the
45 * default allocator.
46 *
47 * New memory can be created with gst_memory_new_wrapped() that wraps the memory
48 * allocated elsewhere.
49 */50 publicclassAllocator : ObjectGst51 {
52 /** the main Gtk struct */53 protectedGstAllocator* gstAllocator;
54 55 /** Get the main Gtk struct */56 publicGstAllocator* getAllocatorStruct(booltransferOwnership = false)
57 {
58 if (transferOwnership)
59 ownedRef = false;
60 returngstAllocator;
61 }
62 63 /** the main Gtk struct as a void* */64 protectedoverridevoid* getStruct()
65 {
66 returncast(void*)gstAllocator;
67 }
68 69 /**
70 * Sets our main struct and passes it to the parent class.
71 */72 publicthis (GstAllocator* gstAllocator, boolownedRef = false)
73 {
74 this.gstAllocator = gstAllocator;
75 super(cast(GstObject*)gstAllocator, ownedRef);
76 }
77 78 79 /** */80 publicstaticGTypegetType()
81 {
82 returngst_allocator_get_type();
83 }
84 85 /**
86 * Find a previously registered allocator with @name. When @name is %NULL, the
87 * default allocator will be returned.
88 *
89 * Params:
90 * name = the name of the allocator
91 *
92 * Returns: a #GstAllocator or %NULL when
93 * the allocator with @name was not registered. Use gst_object_unref()
94 * to release the allocator after usage.
95 */96 publicstaticAllocatorfind(stringname)
97 {
98 autop = gst_allocator_find(Str.toStringz(name));
99 100 if(pisnull)
101 {
102 returnnull;
103 }
104 105 returnObjectG.getDObject!(Allocator)(cast(GstAllocator*) p, true);
106 }
107 108 /**
109 * Registers the memory @allocator with @name. This function takes ownership of
110 * @allocator.
111 *
112 * Params:
113 * name = the name of the allocator
114 * allocator = #GstAllocator
115 */116 publicstaticvoidregister(stringname, Allocatorallocator)
117 {
118 gst_allocator_register(Str.toStringz(name), (allocatorisnull) ? null : allocator.getAllocatorStruct());
119 }
120 121 /**
122 * Use @allocator to allocate a new memory block with memory that is at least
123 * @size big.
124 *
125 * The optional @params can specify the prefix and padding for the memory. If
126 * %NULL is passed, no flags, no extra prefix/padding and a default alignment is
127 * used.
128 *
129 * The prefix/padding will be filled with 0 if flags contains
130 * #GST_MEMORY_FLAG_ZERO_PREFIXED and #GST_MEMORY_FLAG_ZERO_PADDED respectively.
131 *
132 * When @allocator is %NULL, the default allocator will be used.
133 *
134 * The alignment in @params is given as a bitmask so that @align + 1 equals
135 * the amount of bytes to align to. For example, to align to 8 bytes,
136 * use an alignment of 7.
137 *
138 * Params:
139 * size = size of the visible memory area
140 * params = optional parameters
141 *
142 * Returns: a new #GstMemory.
143 */144 publicMemoryalloc(size_tsize, AllocationParamsparams)
145 {
146 autop = gst_allocator_alloc(gstAllocator, size, (paramsisnull) ? null : params.getAllocationParamsStruct());
147 148 if(pisnull)
149 {
150 returnnull;
151 }
152 153 returnObjectG.getDObject!(Memory)(cast(GstMemory*) p, true);
154 }
155 156 /**
157 * Free @memory that was previously allocated with gst_allocator_alloc().
158 *
159 * Params:
160 * memory = the memory to free
161 */162 publicvoidfree(Memorymemory)
163 {
164 gst_allocator_free(gstAllocator, (memoryisnull) ? null : memory.getMemoryStruct());
165 }
166 167 /**
168 * Set the default allocator. This function takes ownership of @allocator.
169 */170 publicvoidsetDefault()
171 {
172 gst_allocator_set_default(gstAllocator);
173 }
174 }