2009-05-12 09:51:37 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2009 Axis Communications <dev-gstreamer at axis dot com>
|
|
|
|
* @author Jonas Holmberg <jonas dot holmberg at axis dot com>
|
|
|
|
*
|
|
|
|
* gstbufferlist.h: Header for GstBufferList object
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-05-12 09:51:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_BUFFER_LIST_H__
|
|
|
|
#define __GST_BUFFER_LIST_H__
|
|
|
|
|
|
|
|
#include <gst/gstbuffer.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API GType _gst_buffer_list_type;
|
2010-11-02 12:31:25 +00:00
|
|
|
|
|
|
|
#define GST_TYPE_BUFFER_LIST (_gst_buffer_list_type)
|
2009-12-07 19:32:12 +00:00
|
|
|
#define GST_IS_BUFFER_LIST(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_BUFFER_LIST))
|
2009-05-12 09:51:37 +00:00
|
|
|
#define GST_BUFFER_LIST_CAST(obj) ((GstBufferList *)obj)
|
2009-12-07 19:32:12 +00:00
|
|
|
#define GST_BUFFER_LIST(obj) (GST_BUFFER_LIST_CAST(obj))
|
2009-05-12 09:51:37 +00:00
|
|
|
|
|
|
|
typedef struct _GstBufferList GstBufferList;
|
2009-06-19 13:29:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstBufferListFunc:
|
2014-06-11 23:06:19 +00:00
|
|
|
* @buffer: (out) (nullable): pointer the buffer
|
2011-03-31 15:51:02 +00:00
|
|
|
* @idx: the index of @buffer
|
2009-06-19 13:29:14 +00:00
|
|
|
* @user_data: user data passed to gst_buffer_list_foreach()
|
|
|
|
*
|
|
|
|
* A function that will be called from gst_buffer_list_foreach(). The @buffer
|
2011-03-31 15:51:02 +00:00
|
|
|
* field will point to a the reference of the buffer at @idx.
|
2009-06-19 13:29:14 +00:00
|
|
|
*
|
2011-03-31 15:51:02 +00:00
|
|
|
* When this function returns %TRUE, the next buffer will be
|
|
|
|
* returned. When %FALSE is returned, gst_buffer_list_foreach() will return.
|
2009-06-19 13:29:14 +00:00
|
|
|
*
|
2014-05-29 21:54:34 +00:00
|
|
|
* When @buffer is set to %NULL, the item will be removed from the bufferlist.
|
2009-06-19 13:29:14 +00:00
|
|
|
* When @buffer has been made writable, the new buffer reference can be assigned
|
|
|
|
* to @buffer. This function is responsible for unreffing the old buffer when
|
|
|
|
* removing or modifying.
|
|
|
|
*
|
2011-03-31 15:51:02 +00:00
|
|
|
* Returns: %FALSE when gst_buffer_list_foreach() should stop
|
2009-06-19 13:29:14 +00:00
|
|
|
*/
|
2011-03-31 15:51:02 +00:00
|
|
|
typedef gboolean (*GstBufferListFunc) (GstBuffer **buffer, guint idx,
|
|
|
|
gpointer user_data);
|
2009-06-19 13:29:14 +00:00
|
|
|
|
2009-05-12 09:51:37 +00:00
|
|
|
|
|
|
|
/* refcounting */
|
|
|
|
/**
|
2018-08-19 22:41:41 +00:00
|
|
|
* gst_buffer_list_ref: (skip)
|
2009-05-12 09:51:37 +00:00
|
|
|
* @list: a #GstBufferList
|
|
|
|
*
|
|
|
|
* Increases the refcount of the given buffer list by one.
|
|
|
|
*
|
2013-12-07 14:38:19 +00:00
|
|
|
* Note that the refcount affects the writability of @list and its data, see
|
2009-05-12 09:51:37 +00:00
|
|
|
* gst_buffer_list_make_writable(). It is important to note that keeping
|
|
|
|
* additional references to GstBufferList instances can potentially increase
|
|
|
|
* the number of memcpy operations in a pipeline.
|
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full): @list
|
2009-05-12 09:51:37 +00:00
|
|
|
*/
|
2018-08-19 22:41:41 +00:00
|
|
|
static inline GstBufferList* gst_buffer_list_ref(GstBufferList* list);
|
2009-05-12 09:51:37 +00:00
|
|
|
static inline GstBufferList *
|
|
|
|
gst_buffer_list_ref (GstBufferList * list)
|
|
|
|
{
|
|
|
|
return GST_BUFFER_LIST_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (
|
|
|
|
list)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-19 22:41:41 +00:00
|
|
|
* gst_buffer_list_unref: (skip)
|
2010-12-07 18:35:04 +00:00
|
|
|
* @list: (transfer full): a #GstBufferList
|
2009-05-12 09:51:37 +00:00
|
|
|
*
|
|
|
|
* Decreases the refcount of the buffer list. If the refcount reaches 0, the
|
|
|
|
* buffer list will be freed.
|
|
|
|
*/
|
2018-08-19 22:41:41 +00:00
|
|
|
static inline void gst_buffer_list_unref(GstBufferList* list);
|
2009-05-12 09:51:37 +00:00
|
|
|
static inline void
|
2018-08-19 22:41:41 +00:00
|
|
|
gst_buffer_list_unref(GstBufferList* list)
|
2009-05-12 09:51:37 +00:00
|
|
|
{
|
|
|
|
gst_mini_object_unref (GST_MINI_OBJECT_CAST (list));
|
|
|
|
}
|
|
|
|
|
2018-11-04 17:52:50 +00:00
|
|
|
/**
|
|
|
|
* gst_clear_buffer_list: (skip)
|
|
|
|
* @list_ptr: a pointer to a #GstBufferList reference
|
|
|
|
*
|
|
|
|
* Clears a reference to a #GstBufferList.
|
|
|
|
*
|
|
|
|
* @list_ptr must not be %NULL.
|
|
|
|
*
|
|
|
|
* If the reference is %NULL then this function does nothing. Otherwise, the
|
|
|
|
* reference count of the list is decreased and the pointer is set to %NULL.
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
gst_clear_buffer_list (GstBufferList ** list_ptr)
|
|
|
|
{
|
2018-11-05 13:03:51 +00:00
|
|
|
gst_clear_mini_object ((GstMiniObject **) list_ptr);
|
2018-11-04 17:52:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-12 09:51:37 +00:00
|
|
|
/* copy */
|
|
|
|
/**
|
2018-08-19 22:41:41 +00:00
|
|
|
* gst_buffer_list_copy: (skip)
|
2009-05-12 09:51:37 +00:00
|
|
|
* @list: a #GstBufferList
|
|
|
|
*
|
|
|
|
* Create a shallow copy of the given buffer list. This will make a newly
|
|
|
|
* allocated copy of the source list with copies of buffer pointers. The
|
|
|
|
* refcount of buffers pointed to will be increased by one.
|
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full): a new copy of @list.
|
2009-05-12 09:51:37 +00:00
|
|
|
*/
|
2018-08-19 22:41:41 +00:00
|
|
|
static inline GstBufferList* gst_buffer_list_copy(const GstBufferList* list);
|
2009-05-12 09:51:37 +00:00
|
|
|
static inline GstBufferList *
|
|
|
|
gst_buffer_list_copy (const GstBufferList * list)
|
|
|
|
{
|
2010-09-01 23:01:25 +00:00
|
|
|
return GST_BUFFER_LIST_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (list)));
|
2009-05-12 09:51:37 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 18:13:39 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_list_replace:
|
|
|
|
* @old_list: (inout) (transfer full) (nullable): pointer to a pointer to a
|
|
|
|
* #GstBufferList to be replaced.
|
|
|
|
* @new_list: (transfer none) (allow-none): pointer to a #GstBufferList that
|
|
|
|
* will replace the buffer list pointed to by @old_list.
|
|
|
|
*
|
|
|
|
* Modifies a pointer to a #GstBufferList to point to a different
|
|
|
|
* #GstBufferList. The modification is done atomically (so this is useful for
|
|
|
|
* ensuring thread safety in some cases), and the reference counts are updated
|
|
|
|
* appropriately (the old buffer list is unreffed, the new is reffed).
|
|
|
|
*
|
|
|
|
* Either @new_list or the #GstBufferList pointed to by @old_list may be %NULL.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @new_list was different from @old_list
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
static inline gboolean
|
|
|
|
gst_buffer_list_replace (GstBufferList **old_list, GstBufferList *new_list)
|
|
|
|
{
|
|
|
|
return gst_mini_object_replace ((GstMiniObject **) old_list,
|
|
|
|
(GstMiniObject *) new_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_buffer_list_take:
|
|
|
|
* @old_list: (inout) (transfer full): pointer to a pointer to a #GstBufferList
|
|
|
|
* to be replaced.
|
|
|
|
* @new_list: (transfer full) (allow-none): pointer to a #GstBufferList
|
|
|
|
* that will replace the bufferlist pointed to by @old_list.
|
|
|
|
*
|
|
|
|
* Modifies a pointer to a #GstBufferList to point to a different
|
|
|
|
* #GstBufferList. This function is similar to gst_buffer_list_replace() except
|
|
|
|
* that it takes ownership of @new_list.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @new_list was different from @old_list
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
static inline gboolean
|
|
|
|
gst_buffer_list_take (GstBufferList **old_list, GstBufferList *new_list)
|
|
|
|
{
|
|
|
|
return gst_mini_object_take ((GstMiniObject **) old_list,
|
|
|
|
(GstMiniObject *) new_list);
|
|
|
|
}
|
|
|
|
|
2009-05-12 09:51:37 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_list_is_writable:
|
|
|
|
* @list: a #GstBufferList
|
|
|
|
*
|
|
|
|
* Tests if you can safely add buffers and groups into a buffer list.
|
|
|
|
*/
|
|
|
|
#define gst_buffer_list_is_writable(list) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (list))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_buffer_list_make_writable:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @list: (transfer full): a #GstBufferList
|
2009-05-12 09:51:37 +00:00
|
|
|
*
|
|
|
|
* Makes a writable buffer list from the given buffer list. If the source buffer
|
|
|
|
* list is already writable, this will simply return the same buffer list. A
|
|
|
|
* copy will otherwise be made using gst_buffer_list_copy().
|
2010-01-31 17:30:54 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full): a writable list, which may or may not be the
|
|
|
|
* same as @list
|
2009-05-12 09:51:37 +00:00
|
|
|
*/
|
|
|
|
#define gst_buffer_list_make_writable(list) GST_BUFFER_LIST_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (list)))
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-08-29 13:34:30 +00:00
|
|
|
GType gst_buffer_list_get_type (void);
|
|
|
|
|
2011-03-31 15:51:02 +00:00
|
|
|
/* allocation */
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-26 19:44:23 +00:00
|
|
|
GstBufferList * gst_buffer_list_new (void) G_GNUC_MALLOC;
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-26 19:44:23 +00:00
|
|
|
GstBufferList * gst_buffer_list_new_sized (guint size) G_GNUC_MALLOC;
|
2011-03-31 15:51:02 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-10-29 06:24:12 +00:00
|
|
|
guint gst_buffer_list_length (GstBufferList *list);
|
2011-03-31 15:51:02 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-03-31 15:51:02 +00:00
|
|
|
GstBuffer * gst_buffer_list_get (GstBufferList *list, guint idx);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2017-08-30 12:50:33 +00:00
|
|
|
GstBuffer * gst_buffer_list_get_writable (GstBufferList *list, guint idx);
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-07-23 14:27:34 +00:00
|
|
|
void gst_buffer_list_insert (GstBufferList *list, gint idx, GstBuffer *buffer);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-03-31 15:51:02 +00:00
|
|
|
void gst_buffer_list_remove (GstBufferList *list, guint idx, guint length);
|
2009-05-12 09:51:37 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-07-17 10:52:59 +00:00
|
|
|
gboolean gst_buffer_list_foreach (GstBufferList *list,
|
2009-06-19 13:29:14 +00:00
|
|
|
GstBufferListFunc func,
|
|
|
|
gpointer user_data);
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2015-06-24 05:18:47 +00:00
|
|
|
GstBufferList * gst_buffer_list_copy_deep (const GstBufferList * list);
|
2009-05-12 09:51:37 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2017-08-31 11:54:55 +00:00
|
|
|
gsize gst_buffer_list_calculate_size (GstBufferList * list);
|
|
|
|
|
2011-03-31 15:51:02 +00:00
|
|
|
#define gst_buffer_list_add(l,b) gst_buffer_list_insert((l),-1,(b));
|
2009-05-12 09:51:37 +00:00
|
|
|
|
2015-11-10 17:38:59 +00:00
|
|
|
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstBufferList, gst_buffer_list_unref)
|
|
|
|
#endif
|
|
|
|
|
2009-05-12 09:51:37 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_BUFFER_LIST_H__ */
|