| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | |
| 3 | |
| 4 | #include <glibmm.h> |
| 5 | |
| 6 | #include <gstreamermm/bufferlist.h> |
| 7 | #include <gstreamermm/private/bufferlist_p.h> |
| 8 | |
| 9 | |
| 10 | /* gstreamermm - a C++ wrapper for gstreamer |
| 11 | * |
| 12 | * Copyright 2008-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/buffer.h> |
| 30 | |
| 31 | |
| 32 | extern "C" |
| 33 | { |
| 34 | |
| 35 | static gboolean BufferList_Foreach_gstreamermm_callback(GstBuffer** buffer, guint idx, void* data) |
| 36 | { |
| 37 | Gst::BufferList::SlotForeach* the_slot = |
| 38 | static_cast<Gst::BufferList::SlotForeach*>(data); |
| 39 | |
| 40 | try |
| 41 | { |
| 42 | // First wrap the original buffer. |
| 43 | Glib::RefPtr<Gst::Buffer> temp = Glib::wrap(*buffer, true); |
| 44 | |
| 45 | // Call the slot which can modify the buffer (ie. set it to a new one or |
| 46 | // clear it altogether). |
| 47 | bool result = |
| 48 | static_cast<bool>((*the_slot)(temp, idx)); |
| 49 | |
| 50 | // Set the reference to the buffer according to how the temp buffer has |
| 51 | // been altered. |
| 52 | if(!temp) |
| 53 | { |
| 54 | // Clear the reference to the original buffer also. |
| 55 | *buffer = nullptr; |
| 56 | } |
| 57 | else if(*buffer != temp->gobj()) |
| 58 | { |
| 59 | // The temp buffer has been set to a new one so make the reference point |
| 60 | // to it and take an extra reference for when the temp wrapper is |
| 61 | // destroyed (I think that's right). |
| 62 | *buffer = temp->gobj(); |
| 63 | temp->reference(); |
| 64 | } |
| 65 | |
| 66 | return result; |
| 67 | } |
| 68 | catch(...) |
| 69 | { |
| 70 | Glib::exception_handlers_invoke(); |
| 71 | } |
| 72 | |
| 73 | return true; // continue |
| 74 | } |
| 75 | |
| 76 | } // extern "C" |
| 77 | |
| 78 | |
| 79 | namespace Gst |
| 80 | { |
| 81 | void BufferList::insert(gint idx, const Glib::RefPtr<Gst::Buffer>& buffer) |
| 82 | { |
| 83 | buffer->reference(); |
| 84 | gst_buffer_list_insert(gobj(), idx, buffer->gobj()); |
| 85 | } |
| 86 | |
| 87 | void BufferList::foreach(const SlotForeach& slot) |
| 88 | { |
| 89 | gst_buffer_list_foreach(gobj(), &BufferList_Foreach_gstreamermm_callback, |
| 90 | const_cast<SlotForeach*>(&slot)); |
| 91 | } |
| 92 | |
| 93 | } //namespace Gst |
| 94 | |
| 95 | namespace |
| 96 | { |
| 97 | } // anonymous namespace |
| 98 | |
| 99 | |
| 100 | /* Why reinterpret_cast<BufferList*>(gobject) is needed: |
| 101 | * |
| 102 | * A BufferList instance is in fact always a GstBufferList instance. |
| 103 | * Unfortunately, GstBufferList cannot be a member of BufferList, |
| 104 | * because it is an opaque struct. Also, the C interface does not provide |
| 105 | * any hooks to install a destroy notification handler, thus we cannot |
| 106 | * wrap it dynamically either. |
| 107 | * |
| 108 | * The cast works because BufferList does not have any member data, and |
| 109 | * it is impossible to derive from it. This is ensured by using final on the |
| 110 | * class and by using = delete on the default constructor. |
| 111 | */ |
| 112 | |
| 113 | namespace Glib |
| 114 | { |
| 115 | |
| 116 | Glib::RefPtr<Gst::BufferList> wrap(GstBufferList* object, bool take_copy) |
| 117 | { |
| 118 | if(take_copy && object) |
| 119 | gst_buffer_list_ref(object); |
| 120 | |
| 121 | // See the comment at the top of this file, if you want to know why the cast works. |
| 122 | return Glib::RefPtr<Gst::BufferList>(reinterpret_cast<Gst::BufferList*>(object)); |
| 123 | } |
| 124 | |
| 125 | } // namespace Glib |
| 126 | |
| 127 | |
| 128 | namespace Gst |
| 129 | { |
| 130 | |
| 131 | |
| 132 | // static |
| 133 | Glib::RefPtr<BufferList> BufferList::create() |
| 134 | { |
| 135 | // See the comment at the top of this file, if you want to know why the cast works. |
| 136 | return Glib::RefPtr<BufferList>(reinterpret_cast<BufferList*>(gst_buffer_list_new())); |
| 137 | } |
| 138 | |
| 139 | void BufferList::reference() const |
| 140 | { |
| 141 | // See the comment at the top of this file, if you want to know why the cast works. |
| 142 | gst_buffer_list_ref(reinterpret_cast<GstBufferList*>(const_cast<BufferList*>(this))); |
| 143 | } |
| 144 | |
| 145 | void BufferList::unreference() const |
| 146 | { |
| 147 | // See the comment at the top of this file, if you want to know why the cast works. |
| 148 | gst_buffer_list_unref(reinterpret_cast<GstBufferList*>(const_cast<BufferList*>(this))); |
| 149 | } |
| 150 | |
| 151 | GstBufferList* BufferList::gobj() |
| 152 | { |
| 153 | // See the comment at the top of this file, if you want to know why the cast works. |
| 154 | return reinterpret_cast<GstBufferList*>(this); |
| 155 | } |
| 156 | |
| 157 | const GstBufferList* BufferList::gobj() const |
| 158 | { |
| 159 | // See the comment at the top of this file, if you want to know why the cast works. |
| 160 | return reinterpret_cast<const GstBufferList*>(this); |
| 161 | } |
| 162 | |
| 163 | GstBufferList* BufferList::gobj_copy() const |
| 164 | { |
| 165 | // See the comment at the top of this file, if you want to know why the cast works. |
| 166 | const auto gobject = reinterpret_cast<GstBufferList*>(const_cast<BufferList*>(this)); |
| 167 | gst_buffer_list_ref(gobject); |
| 168 | return gobject; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | void BufferList::remove(guint idx, guint length) |
| 173 | { |
| 174 | gst_buffer_list_remove(gobj(), idx, length); |
| 175 | } |
| 176 | |
| 177 | Glib::RefPtr<Gst::Buffer> BufferList::remove(guint idx) |
| 178 | { |
| 179 | return Glib::wrap(gst_buffer_list_get(gobj(), idx)); |
| 180 | } |
| 181 | |
| 182 | guint BufferList::length() const |
| 183 | { |
| 184 | return gst_buffer_list_length(const_cast<GstBufferList*>(gobj())); |
| 185 | } |
| 186 | |
| 187 | void BufferList::copy() const |
| 188 | { |
| 189 | gst_buffer_list_copy(const_cast<GstBufferList*>(gobj())); |
| 190 | } |
| 191 | |
| 192 | void BufferList::copy_deep() const |
| 193 | { |
| 194 | gst_buffer_list_copy_deep(const_cast<GstBufferList*>(gobj())); |
| 195 | } |
| 196 | |
| 197 | void BufferList::insert(gint idx, Glib::RefPtr<Gst::Buffer>&& buffer) |
| 198 | { |
| 199 | gst_buffer_list_insert(gobj(), idx, (buffer) ? buffer.release()->gobj() : nullptr); |
| 200 | } |
| 201 | |
| 202 | Glib::RefPtr<Gst::Buffer> BufferList::get(guint idx) |
| 203 | { |
| 204 | return Glib::wrap(gst_buffer_list_get(gobj(), idx)); |
| 205 | } |
| 206 | |
| 207 | Glib::RefPtr<const Gst::Buffer> BufferList::get(guint idx) const |
| 208 | { |
| 209 | return const_cast<BufferList*>(this)->get(idx); |
| 210 | } |
| 211 | |
| 212 | |
| 213 | } // namespace Gst |
| 214 | |
| 215 |