| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2008-2015 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 |
|
| 20 |
#include <gstreamermm/miniobject.h> |
| 21 |
|
| 22 |
_DEFS(gstreamermm,gst) |
| 23 |
|
| 24 |
namespace Gst |
| 25 |
{ |
| 26 |
|
| 27 |
class Buffer; |
| 28 |
|
| 29 |
/** A grouped scatter data buffer type for data-passing. |
| 30 |
* Buffer lists are units of grouped scatter/gather data transfer in GStreamer. |
| 31 |
* |
| 32 |
* Buffer lists are created with create() and filled with data using a |
| 33 |
* Gst::BufferListIterator. The iterator has no current buffer; its cursor |
| 34 |
* position lies between buffers, immediately before the buffer that would be |
| 35 |
* returned by Gst::BufferListIterator::next(). After iterating to the end of a group the iterator must |
| 36 |
* be advanced to the next group by a call to |
| 37 |
* Gst::BufferListIterator::next_group() before any further calls to |
| 38 |
* Gst::BufferListIterator::next() can return buffers again. The cursor |
| 39 |
* position of a newly created iterator lies before the first group; a call to |
| 40 |
* Gst::BufferListIterator::next_group() is necessary before calls to |
| 41 |
* Gst::BufferListIterator::next() can return buffers. |
| 42 |
* |
| 43 |
* For more details, see the C API docs. |
| 44 |
*/ |
| 45 |
class BufferList : public MiniObject |
| 46 |
{ |
| 47 |
_CLASS_OPAQUE_REFCOUNTED(BufferList, GstBufferList, gst_buffer_list_new, gst_buffer_list_ref, gst_buffer_list_unref) |
| 48 |
_IGNORE(gst_buffer_list_ref, gst_buffer_list_unref) |
| 49 |
|
| 50 |
public: |
| 51 |
/** For example, |
| 52 |
* Gst::BufferListItem on_foreach(const Glib::RefPtr<Gst::Buffer>& buffer, |
| 53 |
* guint group, guint idx);. |
| 54 |
* A slot that will be called from foreach(). The buffer field will be a |
| 55 |
* reference to the buffer at idx in group. |
| 56 |
* |
| 57 |
* When this function returns Gst::BUFFER_LIST_CONTINUE, the next buffer will |
| 58 |
* be returned. When Gst::BUFFER_LIST_SKIP_GROUP is returned, all remaining |
| 59 |
* buffers in the current group will be skipped and the first buffer of the |
| 60 |
* next group is returned (if any). When Gst::BUFFER_LIST_END is returned, |
| 61 |
* foreach() will return. |
| 62 |
* |
| 63 |
* When the buffer is set to 0, the item will be removed from the bufferlist. |
| 64 |
* When the buffer has been made writable, the new buffer reference can be |
| 65 |
* assigned to the buffer. |
| 66 |
*/ |
| 67 |
typedef sigc::slot< bool, Glib::RefPtr<Gst::Buffer>&, guint> SlotForeach; |
| 68 |
|
| 69 |
public: |
| 70 |
|
| 71 |
_WRAP_METHOD(void remove(guint idx, guint length), gst_buffer_list_remove) |
| 72 |
|
| 73 |
_WRAP_METHOD(Glib::RefPtr<Gst::Buffer> remove(guint idx), gst_buffer_list_get) |
| 74 |
|
| 75 |
_WRAP_METHOD(guint length() const, gst_buffer_list_length) |
| 76 |
|
| 77 |
_WRAP_METHOD(void copy() const, gst_buffer_list_copy) |
| 78 |
|
| 79 |
_WRAP_METHOD(void copy_deep() const, gst_buffer_list_copy_deep) |
| 80 |
|
| 81 |
_WRAP_METHOD(void insert(gint idx, Glib::RefPtr<Gst::Buffer>&& buffer), gst_buffer_list_insert) |
| 82 |
|
| 83 |
/// A insert() convenience overload. Allows to re-use @a buffer parameter after function call. |
| 84 |
void insert(gint idx, const Glib::RefPtr<Gst::Buffer>& buffer); |
| 85 |
|
| 86 |
/** Call @a slot for each buffer in @a list. |
| 87 |
* |
| 88 |
* @a slot can modify the passed buffer pointer or its contents. The return |
| 89 |
* value of @a slot define if this function returns or if the remaining |
| 90 |
* buffers in a group should be skipped. |
| 91 |
* |
| 92 |
* @param slot A SlotForeach to call on each buffer. |
| 93 |
* |
| 94 |
* Since 0.10.24 |
| 95 |
*/ |
| 96 |
void foreach(const SlotForeach& slot); |
| 97 |
_IGNORE(gst_buffer_list_foreach) |
| 98 |
|
| 99 |
_WRAP_METHOD(Glib::RefPtr<Gst::Buffer> get(guint idx), gst_buffer_list_get) |
| 100 |
_WRAP_METHOD(Glib::RefPtr<const Gst::Buffer> get(guint idx) const, gst_buffer_list_get, constversion) |
| 101 |
|
| 102 |
}; |
| 103 |
|
| 104 |
} // namespace Gst |