Debian Codegraph @

gstreamer/gstreamermm/allocator.cc

raw symbols SCIP
1 // Generated by gmmproc 2.50.1 -- DO NOT MODIFY!
2
3
4 #include <glibmm.h>
5
6 #include <gstreamermm/allocator.h>
7 #include <gstreamermm/private/allocator_p.h>
8
9
10 /* gstreamermm - a C++ wrapper for gstreamer
11 *
12 * Copyright 2014-2015 The gstreamermm Development Team
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 */
28
29 #include <gstreamermm/memory.h>
30
31
32 namespace Gst
33 {
34 AllocationParams::AllocationParams()
35 {
36 GstAllocationParams params;
37 gst_allocation_params_init(&params);
38 gobject_ = gst_allocation_params_copy(&params);
39 }
40
41 Glib::RefPtr<Gst::Allocator> Allocator::get_default_allocator()
42 {
43 return Glib::wrap(gst_allocator_find(nullptr), false);
44 }
45
46 void Allocator::set_default()
47 {
48 reference();
49 gst_allocator_set_default(gobj());
50 }
51
52 void Allocator_Class::free_vfunc_callback(GstAllocator* self, GstMemory* memory)
53 {
54 Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
55 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
56
57 // Non-gtkmmproc-generated custom classes implicitly call the default
58 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
59 // generated classes can use this optimisation, which avoids the unnecessary
60 // parameter conversions if there is no possibility of the virtual function
61 // being overridden:
62 if(obj_base && obj_base->is_derived_())
63 {
64 CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
65 if(obj) // This can be NULL during destruction.
66 {
67 #ifdef GLIBMM_EXCEPTIONS_ENABLED
68 try // Trap C++ exceptions which would normally be lost because this is a C callback.
69 {
70 #endif //GLIBMM_EXCEPTIONS_ENABLED
71 // Call the virtual member method, which derived classes might override.
72 Glib::RefPtr<Gst::Memory> mem = Glib::wrap(memory);
73 obj->free_vfunc(std::move(mem));
74 return;
75 #ifdef GLIBMM_EXCEPTIONS_ENABLED
76 }
77 catch(...)
78 {
79 Glib::exception_handlers_invoke();
80 }
81 #endif //GLIBMM_EXCEPTIONS_ENABLED
82 }
83 }
84
85 BaseClassType *const base = static_cast<BaseClassType*>(
86 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
87 );
88
89 // Call the original underlying C function:
90 if(base && base->free)
91 {
92 (*base->free)(self, memory);
93 }
94
95 }
96
97 void Gst::Allocator::free_vfunc(Glib::RefPtr<Gst::Memory>&& memory)
98 {
99 BaseClassType *const base = static_cast<BaseClassType*>(
100 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_))
101 );
102
103 if(base && base->free)
104 {
105 GstMemory* mem_gobj = memory.release()->gobj();
106 (*base->free)(gobj(), mem_gobj);
107 }
108 }
109
110 }
111
112 namespace
113 {
114 } // anonymous namespace
115
116
117 namespace Glib
118 {
119
120 Gst::AllocationParams wrap(GstAllocationParams* object, bool take_copy)
121 {
122 return Gst::AllocationParams(object, take_copy);
123 }
124
125 } // namespace Glib
126
127
128 namespace Gst
129 {
130
131
132 // static
133 GType AllocationParams::get_type()
134 {
135 return gst_allocation_params_get_type();
136 }
137
138
139 AllocationParams::AllocationParams(const AllocationParams& other)
140 :
141 gobject_ ((other.gobject_) ? gst_allocation_params_copy(other.gobject_) : nullptr)
142 {}
143
144 AllocationParams::AllocationParams(AllocationParams&& other) noexcept
145 :
146 gobject_(other.gobject_)
147 {
148 other.gobject_ = nullptr;
149 }
150
151 AllocationParams& AllocationParams::operator=(AllocationParams&& other) noexcept
152 {
153 AllocationParams temp (other);
154 swap(temp);
155 return *this;
156 }
157
158 AllocationParams::AllocationParams(GstAllocationParams* gobject, bool make_a_copy)
159 :
160 // For BoxedType wrappers, make_a_copy is true by default. The static
161 // BoxedType wrappers must always take a copy, thus make_a_copy = true
162 // ensures identical behaviour if the default argument is used.
163 gobject_ ((make_a_copy && gobject) ? gst_allocation_params_copy(gobject) : gobject)
164 {}
165
166 AllocationParams& AllocationParams::operator=(const AllocationParams& other)
167 {
168 AllocationParams temp (other);
169 swap(temp);
170 return *this;
171 }
172
173 AllocationParams::~AllocationParams() noexcept
174 {
175 if(gobject_)
176 gst_allocation_params_free(gobject_);
177 }
178
179 void AllocationParams::swap(AllocationParams& other) noexcept
180 {
181 std::swap(gobject_, other.gobject_);
182 }
183
184 GstAllocationParams* AllocationParams::gobj_copy() const
185 {
186 return gst_allocation_params_copy(gobject_);
187 }
188
189
190 void AllocationParams::init()
191 {
192 gst_allocation_params_init(gobj());
193 }
194
195 MemoryFlags AllocationParams::get_flags() const
196 {
197 return ((MemoryFlags)(gobj()->flags));
198 }
199
200 void AllocationParams::set_flags(const MemoryFlags& value)
201 {
202 gobj()->flags = ((GstMemoryFlags)(value));
203 }
204
205 gsize AllocationParams::get_align() const
206 {
207 return gobj()->align;
208 }
209
210 void AllocationParams::set_align(const gsize& value)
211 {
212 gobj()->align = value;
213 }
214
215 gsize AllocationParams::get_prefix() const
216 {
217 return gobj()->prefix;
218 }
219
220 void AllocationParams::set_prefix(const gsize& value)
221 {
222 gobj()->prefix = value;
223 }
224
225 gsize AllocationParams::get_padding() const
226 {
227 return gobj()->padding;
228 }
229
230 void AllocationParams::set_padding(const gsize& value)
231 {
232 gobj()->padding = value;
233 }
234
235
236 } // namespace Gst
237
238
239 namespace Glib
240 {
241
242 Glib::RefPtr<Gst::Allocator> wrap(GstAllocator* object, bool take_copy)
243 {
244 return Glib::RefPtr<Gst::Allocator>( dynamic_cast<Gst::Allocator*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
245 //We use dynamic_cast<> in case of multiple inheritance.
246 }
247
248 } /* namespace Glib */
249
250
251 namespace Gst
252 {
253
254
255 /* The *_Class implementation: */
256
257 const Glib::Class& Allocator_Class::init()
258 {
259 if(!gtype_) // create the GType if necessary
260 {
261 // Glib::Class has to know the class init function to clone custom types.
262 class_init_func_ = &Allocator_Class::class_init_function;
263
264 // This is actually just optimized away, apparently with no harm.
265 // Make sure that the parent type has been created.
266 //CppClassParent::CppObjectType::get_type();
267
268 // Create the wrapper type, with the same class/instance size as the base type.
269 register_derived_type(gst_allocator_get_type());
270
271 // Add derived versions of interfaces, if the C type implements any interfaces:
272
273 }
274
275 return *this;
276 }
277
278
279 void Allocator_Class::class_init_function(void* g_class, void* class_data)
280 {
281 const auto klass = static_cast<BaseClassType*>(g_class);
282 CppClassParent::class_init_function(klass, class_data);
283
284 klass->alloc = &alloc_vfunc_callback;
285 klass->free = &free_vfunc_callback;
286
287 }
288
289 GstMemory* Allocator_Class::alloc_vfunc_callback(GstAllocator* self, gsize size, GstAllocationParams* params)
290 {
291 const auto obj_base = static_cast<Glib::ObjectBase*>(
292 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
293
294 // Non-gtkmmproc-generated custom classes implicitly call the default
295 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
296 // generated classes can use this optimisation, which avoids the unnecessary
297 // parameter conversions if there is no possibility of the virtual function
298 // being overridden:
299 if(obj_base && obj_base->is_derived_())
300 {
301 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
302 if(obj) // This can be NULL during destruction.
303 {
304 try // Trap C++ exceptions which would normally be lost because this is a C callback.
305 {
306 // Call the virtual member method, which derived classes might override.
307 return Glib::unwrap_copy(obj->alloc_vfunc(size, Gst::AllocationParams(params, true)
308 ));
309 }
310 catch(...)
311 {
312 Glib::exception_handlers_invoke();
313 }
314 }
315 }
316
317 BaseClassType *const base = static_cast<BaseClassType*>(
318 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
319 );
320
321 // Call the original underlying C function:
322 if(base && base->alloc)
323 return (*base->alloc)(self, size, params);
324
325 using RType = GstMemory*;
326 return RType();
327 }
328
329
330 Glib::ObjectBase* Allocator_Class::wrap_new(GObject* object)
331 {
332 return new Allocator((GstAllocator*)object);
333 }
334
335
336 /* The implementation: */
337
338 GstAllocator* Allocator::gobj_copy()
339 {
340 reference();
341 return gobj();
342 }
343
344 Allocator::Allocator(const Glib::ConstructParams& construct_params)
345 :
346 Gst::Object(construct_params)
347 {
348
349 }
350
351 Allocator::Allocator(GstAllocator* castitem)
352 :
353 Gst::Object((GstObject*)(castitem))
354 {}
355
356
357 Allocator::Allocator(Allocator&& src) noexcept
358 : Gst::Object(std::move(src))
359 {}
360
361 Allocator& Allocator::operator=(Allocator&& src) noexcept
362 {
363 Gst::Object::operator=(std::move(src));
364 return *this;
365 }
366
367
368 Allocator::~Allocator() noexcept
369 {}
370
371
372 Allocator::CppClassType Allocator::allocator_class_; // initialize static member
373
374 GType Allocator::get_type()
375 {
376 return allocator_class_.init().get_type();
377 }
378
379
380 GType Allocator::get_base_type()
381 {
382 return gst_allocator_get_type();
383 }
384
385 Glib::RefPtr<Gst::Allocator> Allocator::find(const Glib::ustring& name)
386 {
387 return Glib::wrap(gst_allocator_find(name.c_str()));
388 }
389
390 void Allocator::register_allocator(const Glib::ustring& name, Glib::RefPtr<Gst::Allocator>&& allocator)
391 {
392 gst_allocator_register(name.c_str(), (allocator) ? allocator.release()->gobj() : nullptr);
393 }
394
395 void Allocator::free(Glib::RefPtr<Gst::Memory>&& memory)
396 {
397 gst_allocator_free(gobj(), (memory) ? memory.release()->gobj() : nullptr);
398 }
399
400 Glib::RefPtr<Gst::Memory> Allocator::alloc(gsize size, const Gst::AllocationParams& params)
401 {
402 return Glib::wrap(gst_allocator_alloc(gobj(), size, const_cast<GstAllocationParams*>(params.gobj())));
403 }
404
405 Glib::RefPtr<Gst::Memory> Allocator::alloc(gsize size)
406 {
407 return Glib::wrap(gst_allocator_alloc(gobj(), size, nullptr));
408 }
409
410
411 Glib::RefPtr<Gst::Memory> Gst::Allocator::alloc_vfunc(gsize size, const Gst::AllocationParams& params)
412 {
413 const auto base = static_cast<BaseClassType*>(
414 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
415 );
416
417 if(base && base->alloc)
418 {
419 Glib::RefPtr<Gst::Memory> retval(Glib::wrap((*base->alloc)(gobj(),size,const_cast<GstAllocationParams*>(params.gobj()))));
420 return retval;
421 }
422
423 using RType = Glib::RefPtr<Gst::Memory>;
424 return RType();
425 }
426
427
428 } // namespace Gst
429
430