| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2014-2016 The gstreamermm Development Team |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library 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 GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free |
| 17 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
* |
| 19 |
* Last reviewed on 2016-04-22 (1.8.0) |
| 20 |
*/ |
| 21 |
|
| 22 |
#include <gstreamermm/object.h> |
| 23 |
#include <gstreamermm/memory.h> |
| 24 |
|
| 25 |
_DEFS(gstreamermm,gst) |
| 26 |
|
| 27 |
namespace Gst |
| 28 |
{ |
| 29 |
|
| 30 |
/** Parameters to control the allocation of memory. |
| 31 |
*/ |
| 32 |
class AllocationParams |
| 33 |
{ |
| 34 |
_CLASS_BOXEDTYPE(AllocationParams, GstAllocationParams, NONE, gst_allocation_params_copy, gst_allocation_params_free) |
| 35 |
_IGNORE(gst_allocation_params_copy, gst_allocation_params_free) |
| 36 |
public: |
| 37 |
_CUSTOM_DEFAULT_CTOR |
| 38 |
|
| 39 |
AllocationParams(); |
| 40 |
|
| 41 |
_WRAP_METHOD(void init(), gst_allocation_params_init) |
| 42 |
|
| 43 |
_MEMBER_GET(flags, flags, MemoryFlags, GstMemoryFlags) |
| 44 |
_MEMBER_SET(flags, flags, MemoryFlags, GstMemoryFlags) |
| 45 |
|
| 46 |
_MEMBER_GET(align, align, gsize, gsize) |
| 47 |
_MEMBER_SET(align, align, gsize, gsize) |
| 48 |
|
| 49 |
_MEMBER_GET(prefix, prefix, gsize, gsize) |
| 50 |
_MEMBER_SET(prefix, prefix, gsize, gsize) |
| 51 |
|
| 52 |
_MEMBER_GET(padding, padding, gsize, gsize) |
| 53 |
_MEMBER_SET(padding, padding, gsize, gsize) |
| 54 |
}; |
| 55 |
|
| 56 |
/** Allocate memory blocks. |
| 57 |
* |
| 58 |
* Memory is usually created by allocators with a alloc() |
| 59 |
* method call. When nullptr is used as the allocator, the default allocator will |
| 60 |
* be used. |
| 61 |
* |
| 62 |
* New allocators can be registered with register_allocator(). |
| 63 |
* Allocators are identified by name and can be retrieved with |
| 64 |
* find(). set_default() can be used to change the |
| 65 |
* default allocator. |
| 66 |
*/ |
| 67 |
|
| 68 |
class Allocator : public Gst::Object |
| 69 |
{ |
| 70 |
_CLASS_GOBJECT(Allocator, GstAllocator, GST_ALLOCATOR, Gst::Object, GstObject) |
| 71 |
|
| 72 |
public: |
| 73 |
_WRAP_METHOD(static Glib::RefPtr<Gst::Allocator> find(const Glib::ustring& name), gst_allocator_find) |
| 74 |
_WRAP_METHOD(static void register_allocator(const Glib::ustring& name, Glib::RefPtr<Gst::Allocator>&& allocator), gst_allocator_register) |
| 75 |
_WRAP_METHOD(void free(Glib::RefPtr<Gst::Memory>&& memory), gst_allocator_free) |
| 76 |
_WRAP_METHOD(Glib::RefPtr<Gst::Memory> alloc(gsize size, const Gst::AllocationParams& params{?}), gst_allocator_alloc) |
| 77 |
|
| 78 |
_WRAP_METHOD_DOCS_ONLY(gst_allocator_set_default) |
| 79 |
void set_default(); |
| 80 |
|
| 81 |
/** |
| 82 |
* Find default allocator. |
| 83 |
* |
| 84 |
* @return: default allocator. |
| 85 |
*/ |
| 86 |
static Glib::RefPtr<Gst::Allocator> get_default_allocator(); |
| 87 |
|
| 88 |
_WRAP_VFUNC(Glib::RefPtr<Gst::Memory> alloc(gsize size, const Gst::AllocationParams& params), "alloc", refreturn_ctype) |
| 89 |
|
| 90 |
// This vfunc is hand-coded because it takes reference to a memory. |
| 91 |
// In generally, arguments are passed to a function by copy, so |
| 92 |
// custom wrapper is necessary. |
| 93 |
virtual void free_vfunc(Glib::RefPtr<Gst::Memory>&& memory); |
| 94 |
|
| 95 |
protected: |
| 96 |
#m4begin |
| 97 |
_PUSH(SECTION_PCC_CLASS_INIT_VFUNCS) |
| 98 |
klass->free = &free_vfunc_callback; |
| 99 |
_SECTION(SECTION_PH_VFUNCS) |
| 100 |
static void free_vfunc_callback(GstAllocator* self, GstMemory* memory); |
| 101 |
_POP() |
| 102 |
#m4end |
| 103 |
}; |
| 104 |
} |