taglist: Remove (scope call) annotation from gst_tag_register()
[platform/upstream/gstreamer.git] / gst / gstbufferlist.h
index 10c4a1f..3e2bcbc 100644 (file)
@@ -16,8 +16,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #ifndef __GST_BUFFER_LIST_H__
 
 G_BEGIN_DECLS
 
-#define GST_TYPE_BUFFER_LIST (gst_buffer_list_get_type ())
-#define GST_IS_BUFFER_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_LIST))
-#define GST_IS_BUFFER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_LIST))
-#define GST_BUFFER_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_LIST, GstBufferListClass))
-#define GST_BUFFER_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_LIST, GstBufferList))
-#define GST_BUFFER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_LIST, GstBufferListClass))
-#define GST_BUFFER_LIST_CAST(obj) ((GstBufferList *)obj)
+GST_API GType _gst_buffer_list_type;
 
-#define GST_TYPE_BUFFER_LIST_ITERATOR (gst_buffer_list_iterator_get_type ())
+#define GST_TYPE_BUFFER_LIST      (_gst_buffer_list_type)
+#define GST_IS_BUFFER_LIST(obj)   (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_BUFFER_LIST))
+#define GST_BUFFER_LIST_CAST(obj) ((GstBufferList *)obj)
+#define GST_BUFFER_LIST(obj)      (GST_BUFFER_LIST_CAST(obj))
 
 typedef struct _GstBufferList GstBufferList;
-typedef struct _GstBufferListClass GstBufferListClass;
-typedef struct _GstBufferListIterator GstBufferListIterator;
-
-/**
- * GstBufferListDoFunction:
- * @buffer: (transfer full): the #GstBuffer
- * @user_data: user data
- *
- * A function for accessing the last buffer returned by
- * gst_buffer_list_iterator_next(). The function can leave @buffer in the list,
- * replace @buffer in the list or remove @buffer from the list, depending on
- * the return value. If the function returns NULL, @buffer will be removed from
- * the list, otherwise @buffer will be replaced with the returned buffer.
- *
- * The last buffer returned by gst_buffer_list_iterator_next() will be replaced
- * with the buffer returned from the function. The function takes ownership of
- * @buffer and if a different value than @buffer is returned, @buffer must be
- * unreffed. If NULL is returned, the buffer will be removed from the list. The
- * list must be writable.
- *
- * Returns: (transfer full): the buffer to replace @buffer in the list, or NULL
- *     to remove @buffer from the list
- *
- * Since: 0.10.24
- */
-typedef GstBuffer* (*GstBufferListDoFunction) (GstBuffer * buffer, gpointer user_data);
-
-/**
- * GstBufferListItem:
- * @GST_BUFFER_LIST_CONTINUE:   Retrieve next buffer
- * @GST_BUFFER_LIST_SKIP_GROUP: Skip to next group
- * @GST_BUFFER_LIST_END:        End iteration
- *
- * The result of the #GstBufferListFunc.
- *
- * Since: 0.10.24
- */
-typedef enum {
-  GST_BUFFER_LIST_CONTINUE,
-  GST_BUFFER_LIST_SKIP_GROUP,
-  GST_BUFFER_LIST_END
-} GstBufferListItem;
 
 /**
  * GstBufferListFunc:
- * @buffer: pointer the buffer
- * @group: the group index of @buffer
- * @idx: the index in @group of @buffer
+ * @buffer: (out) (nullable): pointer the buffer
+ * @idx: the index of @buffer
  * @user_data: user data passed to gst_buffer_list_foreach()
  *
  * A function that will be called from gst_buffer_list_foreach(). The @buffer
- * field will point to a the reference of the buffer at @idx in @group.
+ * field will point to a the reference of the buffer at @idx.
  *
- * When this function returns #GST_BUFFER_LIST_CONTINUE, the next buffer will be
- * returned. When #GST_BUFFER_LIST_SKIP_GROUP is returned, all remaining buffers
- * in the current group will be skipped and the first buffer of the next group
- * is returned (if any). When GST_BUFFER_LIST_END is returned,
- * gst_buffer_list_foreach() will return.
+ * When this function returns %TRUE, the next buffer will be
+ * returned. When %FALSE is returned, gst_buffer_list_foreach() will return.
  *
- * When @buffer is set to NULL, the item will be removed from the bufferlist.
+ * When @buffer is set to %NULL, the item will be removed from the bufferlist.
  * 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.
  *
- * Returns: a #GstBufferListItem
- *
- * Since: 0.10.24
+ * Returns: %FALSE when gst_buffer_list_foreach() should stop
  */
-typedef GstBufferListItem (*GstBufferListFunc)   (GstBuffer **buffer, guint group, guint idx,
-                                                  gpointer user_data);
-
+typedef gboolean   (*GstBufferListFunc)   (GstBuffer **buffer, guint idx,
+                                           gpointer user_data);
 
-GType gst_buffer_list_get_type (void);
-
-/* allocation */
-GstBufferList *gst_buffer_list_new (void);
 
 /* refcounting */
 /**
@@ -122,19 +66,13 @@ GstBufferList *gst_buffer_list_new (void);
  *
  * Increases the refcount of the given buffer list by one.
  *
- * Note that the refcount affects the writeability of @list and its data, see
+ * Note that the refcount affects the writability of @list and its data, see
  * 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.
  *
  * Returns: (transfer full): @list
- *
- * Since: 0.10.24
  */
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC GstBufferList * gst_buffer_list_ref (GstBufferList * list);
-#endif
-
 static inline GstBufferList *
 gst_buffer_list_ref (GstBufferList * list)
 {
@@ -148,19 +86,32 @@ gst_buffer_list_ref (GstBufferList * list)
  *
  * Decreases the refcount of the buffer list. If the refcount reaches 0, the
  * buffer list will be freed.
- *
- * Since: 0.10.24
  */
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC void gst_buffer_list_unref (GstBufferList * list);
-#endif
-
 static inline void
 gst_buffer_list_unref (GstBufferList * list)
 {
   gst_mini_object_unref (GST_MINI_OBJECT_CAST (list));
 }
 
+/**
+ * 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)
+{
+  gst_clear_mini_object ((GstMiniObject **) list_ptr);
+}
+
 /* copy */
 /**
  * gst_buffer_list_copy:
@@ -171,13 +122,7 @@ gst_buffer_list_unref (GstBufferList * list)
  * refcount of buffers pointed to will be increased by one.
  *
  * Returns: (transfer full): a new copy of @list.
- *
- * Since: 0.10.24
  */
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC GstBufferList * gst_buffer_list_copy (const GstBufferList * list);
-#endif
-
 static inline GstBufferList *
 gst_buffer_list_copy (const GstBufferList * list)
 {
@@ -185,12 +130,57 @@ gst_buffer_list_copy (const GstBufferList * list)
 }
 
 /**
+ * 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);
+}
+
+/**
  * gst_buffer_list_is_writable:
  * @list: a #GstBufferList
  *
  * Tests if you can safely add buffers and groups into a buffer list.
- *
- * Since: 0.10.24
  */
 #define gst_buffer_list_is_writable(list) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (list))
 
@@ -204,39 +194,50 @@ gst_buffer_list_copy (const GstBufferList * list)
  *
  * Returns: (transfer full): a writable list, which may or may not be the
  *     same as @list
- *
- * Since: 0.10.24
  */
 #define gst_buffer_list_make_writable(list) GST_BUFFER_LIST_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (list)))
 
-guint                    gst_buffer_list_n_groups              (GstBufferList *list);
+GST_API
+GType                    gst_buffer_list_get_type              (void);
 
-void                     gst_buffer_list_foreach               (GstBufferList *list,
-                                                                GstBufferListFunc func,
-                                                               gpointer user_data);
-GstBuffer *              gst_buffer_list_get                   (GstBufferList *list, guint group, guint idx);
+/* allocation */
+
+GST_API
+GstBufferList *          gst_buffer_list_new                   (void) G_GNUC_MALLOC;
 
-/* iterator */
-GType                    gst_buffer_list_iterator_get_type     (void);
-GstBufferListIterator *  gst_buffer_list_iterate               (GstBufferList *list) G_GNUC_MALLOC;
-void                     gst_buffer_list_iterator_free         (GstBufferListIterator *it);
+GST_API
+GstBufferList *          gst_buffer_list_new_sized             (guint size) G_GNUC_MALLOC;
 
-guint                    gst_buffer_list_iterator_n_buffers    (const GstBufferListIterator *it);
-GstBuffer *              gst_buffer_list_iterator_next         (GstBufferListIterator *it);
-gboolean                 gst_buffer_list_iterator_next_group   (GstBufferListIterator *it);
+GST_API
+guint                    gst_buffer_list_length                (GstBufferList *list);
 
-void                     gst_buffer_list_iterator_add          (GstBufferListIterator *it, GstBuffer *buffer);
-void                     gst_buffer_list_iterator_add_list     (GstBufferListIterator *it, GList *list);
-void                     gst_buffer_list_iterator_add_group    (GstBufferListIterator *it);
-void                     gst_buffer_list_iterator_remove       (GstBufferListIterator *it);
-GstBuffer *              gst_buffer_list_iterator_steal        (GstBufferListIterator *it);
-void                     gst_buffer_list_iterator_take         (GstBufferListIterator *it, GstBuffer *buffer);
+GST_API
+GstBuffer *              gst_buffer_list_get                   (GstBufferList *list, guint idx);
 
-GstBuffer *              gst_buffer_list_iterator_do           (GstBufferListIterator *it, GstBufferListDoFunction do_func,
-                                                                gpointer user_data);
+GST_API
+GstBuffer *              gst_buffer_list_get_writable          (GstBufferList *list, guint idx);
 
-/* conversion */
-GstBuffer *              gst_buffer_list_iterator_merge_group  (const GstBufferListIterator *it);
+GST_API
+void                     gst_buffer_list_insert                (GstBufferList *list, gint idx, GstBuffer *buffer);
+
+GST_API
+void                     gst_buffer_list_remove                (GstBufferList *list, guint idx, guint length);
+
+GST_API
+gboolean                 gst_buffer_list_foreach               (GstBufferList *list,
+                                                                GstBufferListFunc func,
+                                                               gpointer user_data);
+GST_API
+GstBufferList *          gst_buffer_list_copy_deep             (const GstBufferList * list);
+
+GST_API
+gsize                    gst_buffer_list_calculate_size        (GstBufferList * list);
+
+#define gst_buffer_list_add(l,b) gst_buffer_list_insert((l),-1,(b));
+
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstBufferList, gst_buffer_list_unref)
+#endif
 
 G_END_DECLS