docs: convert NULL, TRUE, and FALSE to %NULL, %TRUE, and %FALSE
[platform/upstream/gstreamer.git] / gst / gstbufferlist.c
index 06f817f..5f743a1 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.
  */
 
 /**
@@ -30,6 +30,9 @@
  * Buffer lists are created with gst_buffer_list_new() and filled with data
  * using a gst_buffer_list_insert().
  *
+ * Buffer lists can be pushed on a srcpad with gst_pad_push_list(). This is
+ * interesting when multiple buffers need to be pushed in one go because it
+ * can reduce the amount of overhead for pushing each buffer individually.
  */
 #include "gst_private.h"
 
@@ -42,8 +45,6 @@
  * GstBufferList:
  *
  * Opaque list of grouped buffers.
- *
- * Since: 0.10.24
  */
 struct _GstBufferList
 {
@@ -69,7 +70,7 @@ _gst_buffer_list_copy (GstBufferList * list)
   guint i, len;
 
   len = list->array->len;
-  copy = gst_buffer_list_sized_new (len);
+  copy = gst_buffer_list_new_sized (len);
 
   /* add and ref all buffers in the array */
   for (i = 0; i < len; i++) {
@@ -92,17 +93,15 @@ _gst_buffer_list_free (GstBufferList * list)
     gst_buffer_unref (g_array_index (list->array, GstBuffer *, i));
   g_array_free (list->array, TRUE);
 
-  g_slice_free1 (GST_MINI_OBJECT_SIZE (list), list);
+  g_slice_free1 (sizeof (GstBufferList), list);
 }
 
 static void
-gst_buffer_list_init (GstBufferList * list, gsize size, guint asize)
+gst_buffer_list_init (GstBufferList * list, guint asize)
 {
-  gst_mini_object_init (GST_MINI_OBJECT_CAST (list), _gst_buffer_list_type,
-      size);
-
-  list->mini_object.copy = (GstMiniObjectCopyFunction) _gst_buffer_list_copy;
-  list->mini_object.free = (GstMiniObjectFreeFunction) _gst_buffer_list_free;
+  gst_mini_object_init (GST_MINI_OBJECT_CAST (list), 0, _gst_buffer_list_type,
+      (GstMiniObjectCopyFunction) _gst_buffer_list_copy, NULL,
+      (GstMiniObjectFreeFunction) _gst_buffer_list_free);
 
   list->array = g_array_sized_new (FALSE, FALSE, sizeof (GstBuffer *), asize);
 
@@ -110,7 +109,7 @@ gst_buffer_list_init (GstBufferList * list, gsize size, guint asize)
 }
 
 /**
- * gst_buffer_list_sized_new:
+ * gst_buffer_list_new_sized:
  * @size: an initial reserved size
  *
  * Creates a new, empty #GstBufferList. The caller is responsible for unreffing
@@ -121,11 +120,9 @@ gst_buffer_list_init (GstBufferList * list, gsize size, guint asize)
  *
  * Returns: (transfer full): the new #GstBufferList. gst_buffer_list_unref()
  *     after usage.
- *
- * Since: 0.10.24
  */
 GstBufferList *
-gst_buffer_list_sized_new (guint size)
+gst_buffer_list_new_sized (guint size)
 {
   GstBufferList *list;
 
@@ -133,7 +130,7 @@ gst_buffer_list_sized_new (guint size)
 
   GST_LOG ("new %p", list);
 
-  gst_buffer_list_init (list, sizeof (GstBufferList), size);
+  gst_buffer_list_init (list, size);
 
   return list;
 }
@@ -148,27 +145,23 @@ gst_buffer_list_sized_new (guint size)
  *
  * Returns: (transfer full): the new #GstBufferList. gst_buffer_list_unref()
  *     after usage.
- *
- * Since: 0.10.24
  */
 GstBufferList *
 gst_buffer_list_new (void)
 {
-  return gst_buffer_list_sized_new (8);
+  return gst_buffer_list_new_sized (8);
 }
 
 /**
- * gst_buffer_list_len:
+ * gst_buffer_list_length:
  * @list: a #GstBufferList
  *
  * Returns the number of buffers in @list.
  *
  * Returns: the number of buffers in the buffer list
- *
- * Since: 0.10.24
  */
 guint
-gst_buffer_list_len (GstBufferList * list)
+gst_buffer_list_length (GstBufferList * list)
 {
   g_return_val_if_fail (GST_IS_BUFFER_LIST (list), 0);
 
@@ -184,24 +177,25 @@ gst_buffer_list_len (GstBufferList * list)
  * Call @func with @data for each buffer in @list.
  *
  * @func can modify the passed buffer pointer or its contents. The return value
- * of @func define if this function returns or if the remaining buffers in a
- * group should be skipped.
+ * of @func define if this function returns or if the remaining buffers in
+ * the list should be skipped.
  *
- * Since: 0.10.24
+ * Returns: %TRUE when @func returned %TRUE for each buffer in @list or when
+ * @list is empty.
  */
-void
+gboolean
 gst_buffer_list_foreach (GstBufferList * list, GstBufferListFunc func,
     gpointer user_data)
 {
   guint i, len;
+  gboolean ret = TRUE;
 
-  g_return_if_fail (GST_IS_BUFFER_LIST (list));
-  g_return_if_fail (func != NULL);
+  g_return_val_if_fail (GST_IS_BUFFER_LIST (list), FALSE);
+  g_return_val_if_fail (func != NULL, FALSE);
 
   len = list->array->len;
   for (i = 0; i < len;) {
     GstBuffer *buf, *buf_ret;
-    gboolean ret;
 
     buf = buf_ret = g_array_index (list->array, GstBuffer *, i);
     ret = func (&buf_ret, i, user_data);
@@ -210,6 +204,7 @@ gst_buffer_list_foreach (GstBufferList * list, GstBufferListFunc func,
     if (buf != buf_ret) {
       if (buf_ret == NULL) {
         g_array_remove_index (list->array, i);
+        len--;
       } else {
         g_array_index (list->array, GstBuffer *, i) = buf_ret;
       }
@@ -222,6 +217,7 @@ gst_buffer_list_foreach (GstBufferList * list, GstBufferListFunc func,
     if (buf_ret != NULL)
       i++;
   }
+  return ret;
 }
 
 /**
@@ -231,10 +227,8 @@ gst_buffer_list_foreach (GstBufferList * list, GstBufferListFunc func,
  *
  * Get the buffer at @idx.
  *
- * Returns: (transfer none): the buffer at @idx in @group or NULL when there
+ * Returns: (transfer none): the buffer at @idx in @group or %NULL when there
  *     is no buffer. The buffer remains valid as long as @list is valid.
- *
- * Since: 0.10.24
  */
 GstBuffer *
 gst_buffer_list_get (GstBufferList * list, guint idx)
@@ -250,10 +244,17 @@ gst_buffer_list_get (GstBufferList * list, guint idx)
 }
 
 /**
+ * gst_buffer_list_add:
+ * @l: a #GstBufferList
+ * @b: a #GstBuffer
+ *
+ * Append @b at the end of @l.
+ */
+/**
  * gst_buffer_list_insert:
  * @list: a #GstBufferList
  * @idx: the index
- * @buffer: a #GstBuffer
+ * @buffer: (transfer full): a #GstBuffer
  *
  * Insert @buffer at @idx in @list. Other buffers are moved to make room for
  * this new buffer.
@@ -261,7 +262,7 @@ gst_buffer_list_get (GstBufferList * list, guint idx)
  * A -1 value for @idx will append the buffer at the end.
  */
 void
-gst_buffer_list_insert (GstBufferList * list, guint idx, GstBuffer * buffer)
+gst_buffer_list_insert (GstBufferList * list, gint idx, GstBuffer * buffer)
 {
   g_return_if_fail (GST_IS_BUFFER_LIST (list));
   g_return_if_fail (buffer != NULL);
@@ -274,6 +275,15 @@ gst_buffer_list_insert (GstBufferList * list, guint idx, GstBuffer * buffer)
   }
 }
 
+/**
+ * gst_buffer_list_remove:
+ * @list: a #GstBufferList
+ * @idx: the index
+ * @length: the amount to remove
+ *
+ * Remove @length buffers starting from @idx in @list. The following buffers are
+ * moved to close the gap.
+ */
 void
 gst_buffer_list_remove (GstBufferList * list, guint idx, guint length)
 {