+ * gst_adapter_get_list:
+ * @adapter: a #GstAdapter
+ * @nbytes: the number of bytes to get
+ *
+ * Returns a #GList of buffers containing the first @nbytes bytes of the
+ * @adapter, but does not flush them from the adapter. See
+ * gst_adapter_take_list() for details.
+ *
+ * Caller owns returned list and contained buffers. gst_buffer_unref() each
+ * buffer in the list before freeing the list after usage.
+ *
+ * Returns: (element-type Gst.Buffer) (transfer full) (nullable): a #GList of
+ * buffers containing the first @nbytes of the adapter, or %NULL if @nbytes
+ * bytes are not available
+ *
+ * Since: 1.6
+ */
+GList *
+gst_adapter_get_list (GstAdapter * adapter, gsize nbytes)
+{
+ GQueue queue = G_QUEUE_INIT;
+ GstBuffer *cur, *buffer;
+ gsize hsize, skip, cur_size;
+ guint idx;
+
+ g_return_val_if_fail (GST_IS_ADAPTER (adapter), NULL);
+ g_return_val_if_fail (nbytes <= adapter->size, NULL);
+
+ GST_LOG_OBJECT (adapter, "getting %" G_GSIZE_FORMAT " bytes", nbytes);
+
+ idx = 0;
+ skip = adapter->skip;
+
+ while (nbytes > 0) {
+ cur = gst_queue_array_peek_nth (adapter->bufqueue, idx++);
+ cur_size = gst_buffer_get_size (cur);
+ hsize = MIN (nbytes, cur_size - skip);
+
+ if (skip == 0 && cur_size == hsize) {
+ GST_LOG_OBJECT (adapter,
+ "inserting a buffer of %" G_GSIZE_FORMAT " bytes", hsize);
+ buffer = gst_buffer_ref (cur);
+ } else {
+ GST_LOG_OBJECT (adapter, "inserting a buffer of %" G_GSIZE_FORMAT " bytes"
+ " via region copy", hsize);
+ buffer = gst_buffer_copy_region (cur, GST_BUFFER_COPY_ALL, skip, hsize);
+ }
+
+ g_queue_push_tail (&queue, buffer);
+
+ nbytes -= hsize;
+ skip = 0;
+ }
+
+ return queue.head;
+}
+
+/**
+ * gst_adapter_take_buffer_list:
+ * @adapter: a #GstAdapter
+ * @nbytes: the number of bytes to take
+ *
+ * Returns a #GstBufferList of buffers containing the first @nbytes bytes of
+ * the @adapter. The returned bytes will be flushed from the adapter.
+ * When the caller can deal with individual buffers, this function is more
+ * performant because no memory should be copied.
+ *
+ * Caller owns the returned list. Call gst_buffer_list_unref() to free
+ * the list after usage.
+ *
+ * Returns: (transfer full) (nullable): a #GstBufferList of buffers containing
+ * the first @nbytes of the adapter, or %NULL if @nbytes bytes are not
+ * available
+ *
+ * Since: 1.6
+ */
+GstBufferList *
+gst_adapter_take_buffer_list (GstAdapter * adapter, gsize nbytes)
+{
+ GstBufferList *buffer_list;
+ GstBuffer *cur;
+ gsize hsize, skip, cur_size;
+ guint n_bufs;
+
+ g_return_val_if_fail (GST_IS_ADAPTER (adapter), NULL);
+
+ if (nbytes > adapter->size)
+ return NULL;
+
+ GST_LOG_OBJECT (adapter, "taking %" G_GSIZE_FORMAT " bytes", nbytes);
+
+ /* try to create buffer list with sufficient size, so no resize is done later */
+ if (adapter->count < 64)
+ n_bufs = adapter->count;
+ else
+ n_bufs = (adapter->count * nbytes * 1.2 / adapter->size) + 1;
+
+ buffer_list = gst_buffer_list_new_sized (n_bufs);
+
+ while (nbytes > 0) {
+ cur = gst_queue_array_peek_head (adapter->bufqueue);
+ skip = adapter->skip;
+ cur_size = gst_buffer_get_size (cur);
+ hsize = MIN (nbytes, cur_size - skip);
+
+ gst_buffer_list_add (buffer_list, gst_adapter_take_buffer (adapter, hsize));
+ nbytes -= hsize;
+ }
+ return buffer_list;
+}
+
+/**
+ * gst_adapter_get_buffer_list:
+ * @adapter: a #GstAdapter
+ * @nbytes: the number of bytes to get
+ *
+ * Returns a #GstBufferList of buffers containing the first @nbytes bytes of
+ * the @adapter but does not flush them from the adapter. See
+ * gst_adapter_take_buffer_list() for details.
+ *
+ * Caller owns the returned list. Call gst_buffer_list_unref() to free
+ * the list after usage.
+ *
+ * Returns: (transfer full) (nullable): a #GstBufferList of buffers containing
+ * the first @nbytes of the adapter, or %NULL if @nbytes bytes are not
+ * available
+ *
+ * Since: 1.6
+ */
+GstBufferList *
+gst_adapter_get_buffer_list (GstAdapter * adapter, gsize nbytes)
+{
+ GstBufferList *buffer_list;
+ GstBuffer *cur, *buffer;
+ gsize hsize, skip, cur_size;
+ guint n_bufs;
+ guint idx;
+
+ g_return_val_if_fail (GST_IS_ADAPTER (adapter), NULL);
+
+ if (nbytes > adapter->size)
+ return NULL;
+
+ GST_LOG_OBJECT (adapter, "getting %" G_GSIZE_FORMAT " bytes", nbytes);
+
+ /* try to create buffer list with sufficient size, so no resize is done later */
+ if (adapter->count < 64)
+ n_bufs = adapter->count;
+ else
+ n_bufs = (adapter->count * nbytes * 1.2 / adapter->size) + 1;
+
+ buffer_list = gst_buffer_list_new_sized (n_bufs);
+
+ idx = 0;
+ skip = adapter->skip;
+
+ while (nbytes > 0) {
+ cur = gst_queue_array_peek_nth (adapter->bufqueue, idx++);
+ cur_size = gst_buffer_get_size (cur);
+ hsize = MIN (nbytes, cur_size - skip);
+
+ if (skip == 0 && cur_size == hsize) {
+ GST_LOG_OBJECT (adapter,
+ "inserting a buffer of %" G_GSIZE_FORMAT " bytes", hsize);
+ buffer = gst_buffer_ref (cur);
+ } else {
+ GST_LOG_OBJECT (adapter, "inserting a buffer of %" G_GSIZE_FORMAT " bytes"
+ " via region copy", hsize);
+ buffer = gst_buffer_copy_region (cur, GST_BUFFER_COPY_ALL, skip, hsize);
+ }
+
+ gst_buffer_list_add (buffer_list, buffer);
+
+ nbytes -= hsize;
+ skip = 0;
+ }
+
+ return buffer_list;
+}
+
+/**