2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstbuffer.c: Buffer operations
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
Changes made to the DEBUG system. New header file gstdebug.h holds the stuff to keep it out of gst.h's hair. DEBUG ...
Original commit message from CVS:
Changes made to the DEBUG system. New header file gstdebug.h holds the
stuff to keep it out of gst.h's hair. DEBUG prints out the process id,
cothread id, source filename and line number. Two new macros DEBUG_ENTER
and DEBUG_LEAVE are used to show the entry and exit of a given function.
This eventually might be used to construct call trace graphs, even taking
cothreads into account. This would be quite useful in visualizing the
scheduling mechanism.
Minor changes to various debug messages.
Also sitting in gstdebug.h is a prototypical DEBUG_ENTER that's capable of
performing DEBUG_LEAVE automatically. It does this by utilizing a
little-known GCC extension that allows one to call a function with the
same parameters as the current function. The macro uses this to basically
call itself. A boolean is used to ensure that when it calls itself it
actually runs the body of the function. In the meantime it prints stuff
out before and after the real function, as well as constructing a
debugging string. This can be used eventually to provide call-wide data
on the DEBUG lines, instead of having to replicate data on each call to
DEBUG. More research is needed into how this would most cleanly be fit
into some other chunk of code, like GStreamer (I think of this DEBUG trick
as a separate project, sorta).
Unfortunately, the aforementioned DEBUG trick interacts quite poorly with
cothreads. Almost any time it's used in a function that has anything
remotely to do with a cothread context (as in, it runs in one), a segfault
results from the __builtin_apply call, which is the heart of the whole
thing. If someone who really knows assembly could analyze the resulting
code to see what's really going on, we might find a way to fix either the
macro or the cothreads (I'm thinking that there's something we missed in
constructing the cothreads themselves) so this works in all cases.
In the meantime, please insert both DEBUG_ENTER and DEBUG_LEAVE in your
functions. Be sure to put DEBUG_ENTER after your variable declarations
and before any functional code, not to put the function name in any DEBUG
strings (it's already there, trust me), and put a DEBUG_LEAVE if you care
enough.
Changes are going to happen in the way DEBUGs and other printouts occur,
so stay tuned.
2000-12-04 09:35:08 +00:00
|
|
|
/* this file makes too much noise for most debugging sessions */
|
|
|
|
#define GST_DEBUG_FORCE_DISABLE
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstbuffer.h"
|
2002-03-13 23:16:06 +00:00
|
|
|
#include "gstobject.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-03-15 23:41:18 +00:00
|
|
|
static GMemChunk *_buffer_chunk = NULL;
|
2001-10-17 10:21:27 +00:00
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
void
|
2002-03-13 23:16:06 +00:00
|
|
|
_gst_buffer_initialize (void)
|
2001-12-22 21:18:17 +00:00
|
|
|
{
|
2002-03-13 23:16:06 +00:00
|
|
|
gint buffersize = sizeof (GstBuffer);
|
2002-03-15 23:41:18 +00:00
|
|
|
if (_buffer_chunk == NULL)
|
2002-03-13 23:16:06 +00:00
|
|
|
{
|
2002-03-15 23:41:18 +00:00
|
|
|
_buffer_chunk = g_mem_chunk_new ("GstBufferChunk", buffersize, buffersize * 128, G_ALLOC_AND_FREE);
|
2002-03-13 23:16:06 +00:00
|
|
|
GST_INFO (GST_CAT_BUFFER, "Buffers are initialized now");
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2002-03-15 23:41:18 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_alloc:
|
|
|
|
*
|
|
|
|
* Allocate space for a new buffer. Works the same way
|
|
|
|
* as g_malloc.
|
|
|
|
* Buffers allocated with gst_buffer_alloc must be freed
|
|
|
|
* with gst_buffer_free.
|
|
|
|
*
|
|
|
|
* Returns: A new buffer or NULL on failure
|
|
|
|
*/
|
|
|
|
GstBuffer *
|
|
|
|
gst_buffer_alloc (void)
|
|
|
|
{
|
|
|
|
return g_mem_chunk_alloc (_buffer_chunk);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* gst_buffer_free:
|
|
|
|
* @buffer: The buffer to free.
|
|
|
|
*
|
|
|
|
* Frees a buffer that wa previously allocated with gst_buffer_alloc.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_buffer_free (GstBuffer *buffer)
|
|
|
|
{
|
|
|
|
g_mem_chunk_free (_buffer_chunk, buffer);
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
2002-03-13 23:16:06 +00:00
|
|
|
* gst_buffer_init:
|
|
|
|
* @buffer: The buffer to be initialized
|
2002-03-15 23:41:18 +00:00
|
|
|
* @pool: The bufferpool to initialize from
|
2002-03-13 23:16:06 +00:00
|
|
|
*
|
2002-03-15 23:41:18 +00:00
|
|
|
* Initializes a buffer from a given bufferpool.
|
|
|
|
* This function is a convenience function to be used in buffer_new
|
|
|
|
* routines of bufferpools.
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2002-03-13 23:16:06 +00:00
|
|
|
void
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_buffer_init (GstBuffer *buffer, GstBufferPool *pool)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2002-03-15 23:41:18 +00:00
|
|
|
GST_DEBUG (GST_CAT_BUFFER, "initializing new buffer %p", buffer);
|
|
|
|
gst_data_ref (GST_DATA (pool));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-03-13 23:16:06 +00:00
|
|
|
gst_data_init (GST_DATA (buffer));
|
2002-03-15 23:41:18 +00:00
|
|
|
GST_DATA (buffer)->type = GST_DATA_BUFFER;
|
|
|
|
GST_DATA (buffer)->dispose = pool->buffer_dispose;
|
|
|
|
GST_DATA (buffer)->free = pool->buffer_free;
|
2002-03-13 23:16:06 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
buffer->data = NULL;
|
|
|
|
buffer->size = 0;
|
|
|
|
buffer->parent = NULL;
|
2002-03-15 23:41:18 +00:00
|
|
|
buffer->pool = pool;
|
2001-09-04 04:34:32 +00:00
|
|
|
buffer->pool_private = NULL;
|
2002-03-13 23:16:06 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* gst_buffer_dispose:
|
|
|
|
* @buffer: The buffer to be disposed
|
|
|
|
*
|
2002-03-15 23:41:18 +00:00
|
|
|
* Disposes a buffer.
|
|
|
|
* This function is a convenience function to be used in buffer_dispose
|
|
|
|
* routines of bufferpools.
|
2002-03-13 23:16:06 +00:00
|
|
|
*/
|
|
|
|
void
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_buffer_dispose (GstData *buffer)
|
2002-03-13 23:16:06 +00:00
|
|
|
{
|
|
|
|
/* unreference the parent if there is one */
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_buffer_unparent (GST_BUFFER (buffer));
|
|
|
|
|
|
|
|
gst_data_unref (GST_DATA (GST_BUFFER (buffer)->pool));
|
|
|
|
gst_data_dispose (buffer);
|
2002-03-13 23:16:06 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* gst_buffer_new:
|
2002-03-15 23:41:18 +00:00
|
|
|
* @pool: bufferpool to create the buffer from
|
|
|
|
* @size: size of the data, 0 if no data initialization
|
2002-03-13 23:16:06 +00:00
|
|
|
*
|
2002-03-15 23:41:18 +00:00
|
|
|
* Create a new buffer from the given bufferpool. If the bufferpool
|
|
|
|
* is set to NULL, the default pool is used.
|
2002-03-13 23:16:06 +00:00
|
|
|
*
|
2002-03-15 23:41:18 +00:00
|
|
|
* Returns: new buffer or NULL, if buffer couldn't be created.
|
2002-03-13 23:16:06 +00:00
|
|
|
*/
|
|
|
|
GstBuffer*
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_buffer_new (GstBufferPool *pool, guint size)
|
2002-03-13 23:16:06 +00:00
|
|
|
{
|
2002-03-15 23:41:18 +00:00
|
|
|
if (pool == NULL)
|
|
|
|
{
|
|
|
|
GstBufferPool *def = gst_buffer_pool_default ();
|
|
|
|
return def->buffer_new (def, size);
|
|
|
|
} else {
|
|
|
|
return pool->buffer_new (pool, size);
|
|
|
|
}
|
2002-03-13 23:16:06 +00:00
|
|
|
}
|
2000-09-14 20:31:03 +00:00
|
|
|
/**
|
2002-03-15 23:41:18 +00:00
|
|
|
* gst_buffer_set_parent:
|
|
|
|
* @buffer: buffer to set the parent for
|
|
|
|
* @parent: parent to set
|
2000-09-14 20:31:03 +00:00
|
|
|
*
|
2002-03-15 23:41:18 +00:00
|
|
|
* Sets the buffers parent to the given one.
|
2000-09-14 20:31:03 +00:00
|
|
|
*/
|
2002-03-15 23:41:18 +00:00
|
|
|
void
|
|
|
|
gst_buffer_set_parent (GstBuffer *buffer, GstBuffer *parent, guint offset, guint size)
|
2000-08-14 10:55:35 +00:00
|
|
|
{
|
2002-03-15 23:41:18 +00:00
|
|
|
/* make sure we get valid data */
|
|
|
|
g_return_if_fail (buffer != NULL);
|
|
|
|
g_return_if_fail (parent != NULL);
|
|
|
|
g_return_if_fail (buffer != parent);
|
|
|
|
/* make sure we can get the data from the parent */
|
|
|
|
g_return_if_fail (parent->size >= offset + size);
|
|
|
|
/* do not reset the parent */
|
|
|
|
if (buffer->parent == parent)
|
|
|
|
return;
|
|
|
|
/* if we have a parent, remove it */
|
|
|
|
if (buffer->parent != NULL)
|
|
|
|
gst_buffer_unparent (buffer);
|
|
|
|
/* make sure buffer contains no data */
|
|
|
|
g_return_if_fail (buffer->data == NULL);
|
|
|
|
g_return_if_fail (buffer->size == 0);
|
2001-08-27 04:19:58 +00:00
|
|
|
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_data_ref (GST_DATA (parent));
|
|
|
|
buffer->data = parent->data + offset;
|
|
|
|
buffer->size = size;
|
|
|
|
/* make sure we're child from a root buffer */
|
|
|
|
while (parent->parent)
|
|
|
|
{
|
|
|
|
parent = parent->parent;
|
|
|
|
}
|
|
|
|
buffer->parent = parent;
|
|
|
|
/* make sure nobody overwrites data in two buffers */
|
|
|
|
GST_DATA_FLAG_SET(buffer, GST_DATA_READONLY);
|
|
|
|
if (GST_DATA_IS_WRITABLE (parent))
|
|
|
|
GST_DATA_FLAG_SET(parent, GST_DATA_READONLY);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* gst_buffer_unset_parent:
|
|
|
|
* @buffer: buffer to unset the parent for
|
|
|
|
*
|
|
|
|
* Unsets the buffers parent and clears the data.
|
|
|
|
* If the buffer has no parent, it simply returns.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_buffer_unparent (GstBuffer *buffer)
|
|
|
|
{
|
|
|
|
g_return_if_fail (buffer != NULL);
|
|
|
|
if (buffer->parent == NULL)
|
|
|
|
return;
|
2001-08-27 04:19:58 +00:00
|
|
|
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_data_unref (GST_DATA (buffer->parent));
|
|
|
|
buffer->parent = NULL;
|
|
|
|
buffer->data = NULL;
|
|
|
|
buffer->size = 0;
|
2000-08-14 10:55:35 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_create_sub:
|
|
|
|
* @parent: parent buffer
|
|
|
|
* @offset: offset into parent buffer
|
|
|
|
* @size: size of new subbuffer
|
|
|
|
*
|
|
|
|
* Creates a sub-buffer from the parent at a given offset.
|
|
|
|
*
|
|
|
|
* Returns: new buffer
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
GstBuffer*
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstBuffer *buffer;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_val_if_fail (parent != NULL, NULL);
|
2001-10-17 10:21:27 +00:00
|
|
|
g_return_val_if_fail (GST_BUFFER_REFCOUNT(parent) > 0, NULL);
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_val_if_fail (size > 0, NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-03-15 23:41:18 +00:00
|
|
|
buffer = gst_buffer_new (parent->pool, 0);
|
2001-08-11 08:25:05 +00:00
|
|
|
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_buffer_set_parent (buffer, parent, offset, size);
|
2001-10-17 10:21:27 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2001-08-11 08:25:05 +00:00
|
|
|
|
2000-08-14 10:55:35 +00:00
|
|
|
/**
|
2000-09-14 20:31:03 +00:00
|
|
|
* gst_buffer_append:
|
2000-08-14 10:55:35 +00:00
|
|
|
* @buffer: a buffer
|
|
|
|
* @append: the buffer to append
|
|
|
|
*
|
2000-09-14 20:31:03 +00:00
|
|
|
* Creates a new buffer by appending the data of append to the
|
|
|
|
* existing data of buffer.
|
2000-08-14 10:55:35 +00:00
|
|
|
*
|
|
|
|
* Returns: new buffer
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
GstBuffer*
|
|
|
|
gst_buffer_append (GstBuffer *buffer,
|
|
|
|
GstBuffer *append)
|
|
|
|
{
|
2000-08-14 10:55:35 +00:00
|
|
|
GstBuffer *newbuf;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_val_if_fail (buffer != NULL, NULL);
|
|
|
|
g_return_val_if_fail (append != NULL, NULL);
|
|
|
|
g_return_val_if_fail (buffer->pool == NULL, NULL);
|
2001-10-17 10:21:27 +00:00
|
|
|
g_return_val_if_fail (GST_BUFFER_REFCOUNT(buffer) > 0, NULL);
|
|
|
|
g_return_val_if_fail (GST_BUFFER_REFCOUNT(append) > 0, NULL);
|
2000-08-14 10:55:35 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_INFO (GST_CAT_BUFFER,"appending buffers %p and %p",buffer,append);
|
2000-12-30 02:41:15 +00:00
|
|
|
|
2002-03-15 23:41:18 +00:00
|
|
|
newbuf = gst_buffer_merge (buffer, append);
|
|
|
|
gst_data_unref (GST_DATA (buffer));
|
|
|
|
|
|
|
|
return newbuf;
|
2000-08-14 10:55:35 +00:00
|
|
|
}
|
2001-04-22 01:41:40 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_copy:
|
|
|
|
* @buffer: the orignal GstBuffer to make a copy of
|
|
|
|
*
|
|
|
|
* Make a full copy of the give buffer, data and all.
|
|
|
|
*
|
|
|
|
* Returns: new buffer
|
|
|
|
*/
|
2001-04-22 01:30:19 +00:00
|
|
|
GstBuffer *
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_buffer_copy (const GstBuffer *buffer)
|
2001-04-22 01:30:19 +00:00
|
|
|
{
|
2001-10-17 10:21:27 +00:00
|
|
|
g_return_val_if_fail (GST_BUFFER_REFCOUNT(buffer) > 0, NULL);
|
|
|
|
|
2002-03-15 23:41:18 +00:00
|
|
|
return buffer->pool->buffer_copy (buffer);
|
2001-04-22 01:30:19 +00:00
|
|
|
}
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_is_span_fast:
|
2001-09-10 19:46:01 +00:00
|
|
|
* @buf1: first source buffer
|
|
|
|
* @buf2: second source buffer
|
|
|
|
*
|
|
|
|
* Determines whether a gst_buffer_span is free, or requires a memcpy.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the buffers are contiguous, FALSE if a copy would be required.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2)
|
|
|
|
{
|
2001-10-17 10:21:27 +00:00
|
|
|
g_return_val_if_fail (GST_BUFFER_REFCOUNT(buf1) > 0, FALSE);
|
|
|
|
g_return_val_if_fail (GST_BUFFER_REFCOUNT(buf2) > 0, FALSE);
|
|
|
|
|
|
|
|
return (buf1->parent && buf2->parent &&
|
|
|
|
(buf1->parent == buf2->parent) &&
|
2001-09-10 19:46:01 +00:00
|
|
|
((buf1->data + buf1->size) == buf2->data));
|
|
|
|
}
|
2001-09-04 04:34:32 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_span:
|
|
|
|
* @buf1: first source buffer to merge
|
|
|
|
* @offset: offset in first buffer to start new buffer
|
|
|
|
* @buf2: second source buffer to merge
|
|
|
|
* @len: length of new buffer
|
|
|
|
*
|
|
|
|
* Create a new buffer that consists of part of buf1 and buf2.
|
|
|
|
* Logically, buf1 and buf2 are concatenated into a single larger
|
|
|
|
* buffer, and a new buffer is created at the given offset inside
|
|
|
|
* this space, with a given length.
|
|
|
|
*
|
|
|
|
* If the two source buffers are children of the same larger buffer,
|
|
|
|
* and are contiguous, the new buffer will be a child of the shared
|
|
|
|
* parent, and thus no copying is necessary.
|
|
|
|
*
|
|
|
|
* Returns: new buffer that spans the two source buffers
|
|
|
|
*/
|
2001-12-14 22:59:21 +00:00
|
|
|
/* FIXME need to think about CoW and such... */
|
2001-08-11 08:25:05 +00:00
|
|
|
GstBuffer *
|
2002-03-15 23:41:18 +00:00
|
|
|
gst_buffer_span (GstBuffer *buf1, guint offset, GstBuffer *buf2, guint len)
|
2001-08-11 08:25:05 +00:00
|
|
|
{
|
|
|
|
GstBuffer *newbuf;
|
|
|
|
|
2001-10-17 10:21:27 +00:00
|
|
|
g_return_val_if_fail (GST_BUFFER_REFCOUNT(buf1) > 0, NULL);
|
|
|
|
g_return_val_if_fail (GST_BUFFER_REFCOUNT(buf2) > 0, NULL);
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* if the two buffers have the same parent and are adjacent */
|
2001-09-10 19:46:01 +00:00
|
|
|
if (gst_buffer_is_span_fast(buf1,buf2)) {
|
2001-12-14 22:59:21 +00:00
|
|
|
/* we simply create a subbuffer of the common parent */
|
2002-03-15 23:41:18 +00:00
|
|
|
newbuf = gst_buffer_create_sub (buf1->parent, buf1->data - buf1->parent->data + offset, len);
|
2001-08-11 08:25:05 +00:00
|
|
|
}
|
2001-10-17 10:21:27 +00:00
|
|
|
else {
|
2001-12-14 22:59:21 +00:00
|
|
|
/* g_print ("slow path taken in buffer_span\n"); */
|
|
|
|
/* otherwise we simply have to brute-force copy the buffers */
|
2002-03-15 23:41:18 +00:00
|
|
|
newbuf = gst_buffer_new (buf1->pool, len);
|
2001-08-11 08:25:05 +00:00
|
|
|
|
2002-03-13 23:16:06 +00:00
|
|
|
/* copy relevant stuff from data struct of buffer1 */
|
|
|
|
gst_data_copy (GST_DATA (newbuf), GST_DATA (buf1));
|
2001-12-14 22:59:21 +00:00
|
|
|
/* copy the first buffer's data across */
|
2002-03-15 23:41:18 +00:00
|
|
|
memcpy (newbuf->data, buf1->data + offset, buf1->size - offset);
|
2001-12-14 22:59:21 +00:00
|
|
|
/* copy the second buffer's data across */
|
2002-03-15 23:41:18 +00:00
|
|
|
memcpy (newbuf->data + (buf1->size - offset), buf2->data, len - (buf1->size - offset));
|
2001-10-17 10:21:27 +00:00
|
|
|
}
|
2001-08-11 08:25:05 +00:00
|
|
|
|
|
|
|
return newbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-04 04:34:32 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_merge:
|
|
|
|
* @buf1: first source buffer to merge
|
|
|
|
* @buf2: second source buffer to merge
|
|
|
|
*
|
|
|
|
* Create a new buffer that is the concatenation of the two source
|
|
|
|
* buffers. The original source buffers will not be modified or
|
|
|
|
* unref'd.
|
|
|
|
*
|
|
|
|
* Internally is nothing more than a specialized gst_buffer_span,
|
|
|
|
* so the same optimizations can occur.
|
|
|
|
*
|
|
|
|
* Returns: new buffer that's the concatenation of the source buffers
|
|
|
|
*/
|
2001-08-11 08:25:05 +00:00
|
|
|
GstBuffer *
|
|
|
|
gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2)
|
|
|
|
{
|
2002-03-15 23:41:18 +00:00
|
|
|
guint i;
|
2001-12-04 22:12:50 +00:00
|
|
|
GstBuffer *result;
|
2001-12-14 22:59:21 +00:00
|
|
|
/* we're just a specific case of the more general gst_buffer_span() */
|
2001-12-04 22:12:50 +00:00
|
|
|
result = gst_buffer_span (buf1, 0, buf2, buf1->size + buf2->size);
|
|
|
|
|
2002-03-15 23:41:18 +00:00
|
|
|
/* but we can include offset info */
|
|
|
|
for (i = 0; i < GST_OFFSET_TYPES; i++)
|
|
|
|
{
|
|
|
|
GST_DATA (result)->offset[i] = GST_DATA (buf1)->offset[i];
|
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
|
|
|
|
return result;
|
2001-08-11 08:25:05 +00:00
|
|
|
}
|