summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-03-30 16:47:55 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2011-03-30 16:47:55 +0200
commitebb14d95b2e6c8501df0ec25a17ca2fcdd043bd9 (patch)
tree65fec929350bc2eef6b9d6f6f98fb8052c326ad2
parentcf4117b24022cff627a3981ddb1dfb7738c8edb1 (diff)
buffer: more API tweaks
_trim -> _resize _create_sub -> copy_region
-rw-r--r--gst/gstbuffer.c70
-rw-r--r--gst/gstbuffer.h21
-rw-r--r--gst/gstcompat.h2
-rw-r--r--gst/gstmemory.c41
-rw-r--r--gst/gstmemory.h28
-rw-r--r--libs/gst/base/gstadapter.c6
-rw-r--r--libs/gst/base/gstbasetransform.c4
-rw-r--r--libs/gst/base/gstcollectpads.c3
-rw-r--r--plugins/elements/gstcapsfilter.c4
-rw-r--r--plugins/elements/gstfakesrc.c4
-rw-r--r--tests/check/gst/gstbuffer.c34
-rw-r--r--tests/check/gst/gstmeta.c4
-rw-r--r--tests/check/libs/adapter.c8
-rw-r--r--win32/common/libgstreamer.def8
14 files changed, 115 insertions, 122 deletions
diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c
index 4b87bf0e4..5f657a572 100644
--- a/gst/gstbuffer.c
+++ b/gst/gstbuffer.c
@@ -26,10 +26,10 @@
* @see_also: #GstPad, #GstMiniObject
*
* Buffers are the basic unit of data transfer in GStreamer. The #GstBuffer
- * type provides all the state necessary to define a region of memory as part
- * of a stream. Sub-buffers are also supported, allowing a smaller region of a
- * buffer to become its own buffer, with mechanisms in place to ensure that
- * neither memory space goes away prematurely.
+ * type provides all the state necessary to define the regions of memory as
+ * part of a stream. Region copies are also supported, allowing a smaller
+ * region of a buffer to become its own buffer, with mechanisms in place to
+ * ensure that neither memory space goes away prematurely.
*
* Buffers are usually created with gst_buffer_new(). After a buffer has been
* created one will typically allocate memory for it and set the size of the
@@ -85,33 +85,29 @@
* next element.
*
* To efficiently create a smaller buffer out of an existing one, you can
- * use gst_buffer_create_sub().
+ * use gst_buffer_copy_region().
*
- * If a plug-in wants to modify the buffer data in-place, it should first obtain
- * a buffer that is safe to modify by using gst_buffer_make_writable(). This
- * function is optimized so that a copy will only be made when it is necessary.
- *
- * A plugin that only wishes to modify the metadata of a buffer, such as the
- * offset, timestamp or caps, should use gst_buffer_make_metadata_writable(),
- * which will create a subbuffer of the original buffer to ensure the caller
- * has sole ownership, and not copy the buffer data.
+ * If a plug-in wants to modify the buffer data or metadata in-place, it should
+ * first obtain a buffer that is safe to modify by using
+ * gst_buffer_make_writable(). This function is optimized so that a copy will
+ * only be made when it is necessary.
*
* Several flags of the buffer can be set and unset with the
* GST_BUFFER_FLAG_SET() and GST_BUFFER_FLAG_UNSET() macros. Use
* GST_BUFFER_FLAG_IS_SET() to test if a certain #GstBufferFlag is set.
*
* Buffers can be efficiently merged into a larger buffer with
- * gst_buffer_merge() and gst_buffer_span() if the gst_buffer_is_span_fast()
+ * gst_buffer_span(), which avoids memory copies when the gst_buffer_is_span_fast()
* function returns TRUE.
*
* An element should either unref the buffer or push it out on a src pad
* using gst_pad_push() (see #GstPad).
*
* Buffers are usually freed by unreffing them with gst_buffer_unref(). When
- * the refcount drops to 0, any data pointed to by GST_BUFFER_MALLOCDATA() will
- * also be freed.
+ * the refcount drops to 0, any data pointed to by the buffer is unreffed as
+ * well.
*
- * Last reviewed on August 11th, 2006 (0.10.10)
+ * Last reviewed on March 30, 2011 (0.11.0)
*/
#include "gst_private.h"
@@ -318,7 +314,7 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
len = GST_BUFFER_MEM_LEN (src);
left = size;
- /* copy and subbuffer */
+ /* copy and make regions of the memory */
for (i = 0; i < len && left > 0; i++) {
mem = GST_BUFFER_MEM_PTR (src, i);
bsize = gst_memory_get_sizes (mem, NULL);
@@ -332,7 +328,7 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
tocopy = MIN (bsize - offset, left);
if (tocopy < bsize) {
/* we need to clip something */
- mem = gst_memory_sub (mem, offset, tocopy);
+ mem = gst_memory_share (mem, offset, tocopy);
} else {
mem = gst_memory_ref (mem);
}
@@ -547,7 +543,7 @@ gst_buffer_new_and_alloc (guint size)
gst_memory_unmap (mem, data, asize);
/* strip off the buffer */
- gst_memory_trim (mem, sizeof (GstBufferImpl), size);
+ gst_memory_resize (mem, sizeof (GstBufferImpl), size);
newbuf = GST_BUFFER_CAST (data);
@@ -697,7 +693,7 @@ gst_buffer_get_size (GstBuffer * buffer)
}
/**
- * gst_buffer_trim:
+ * gst_buffer_resize:
* @buffer: a #GstBuffer.
* @offset: the new offset
* @size: the new size
@@ -705,7 +701,7 @@ gst_buffer_get_size (GstBuffer * buffer)
* Set the total size of the buffer
*/
void
-gst_buffer_trim (GstBuffer * buffer, gsize offset, gsize size)
+gst_buffer_resize (GstBuffer * buffer, gsize offset, gsize size)
{
guint len;
guint si, di;
@@ -741,10 +737,10 @@ gst_buffer_trim (GstBuffer * buffer, gsize offset, gsize size)
if (tocopy < bsize) {
/* we need to clip something */
if (GST_MEMORY_IS_WRITABLE (mem)) {
- gst_memory_trim (mem, offset, tocopy);
+ gst_memory_resize (mem, offset, tocopy);
} else {
GstMemory *tmp;
- tmp = gst_memory_sub (mem, offset, tocopy);
+ tmp = gst_memory_share (mem, offset, tocopy);
gst_memory_unref (mem);
mem = tmp;
}
@@ -1035,7 +1031,7 @@ gst_buffer_set_caps (GstBuffer * buffer, GstCaps * caps)
}
/**
- * gst_buffer_create_sub:
+ * gst_buffer_copy_region:
* @parent: a #GstBuffer.
* @offset: the offset into parent #GstBuffer at which the new sub-buffer
* begins.
@@ -1056,28 +1052,22 @@ gst_buffer_set_caps (GstBuffer * buffer, GstCaps * caps)
* invalid.
*/
GstBuffer *
-gst_buffer_create_sub (GstBuffer * buffer, gsize offset, gsize size)
+gst_buffer_copy_region (GstBuffer * buffer, GstBufferCopyFlags flags,
+ gsize offset, gsize size)
{
- GstBuffer *subbuffer;
- gsize bufsize;
+ GstBuffer *copy;
g_return_val_if_fail (buffer != NULL, NULL);
- g_return_val_if_fail (buffer->mini_object.refcount > 0, NULL);
- bufsize = gst_buffer_get_size (buffer);
- g_return_val_if_fail (bufsize >= offset, NULL);
- if (size == -1)
- size = bufsize - offset;
- g_return_val_if_fail (bufsize >= offset + size, NULL);
/* create the new buffer */
- subbuffer = gst_buffer_new ();
+ copy = gst_buffer_new ();
- GST_CAT_LOG (GST_CAT_BUFFER, "new subbuffer %p of %p %" G_GSIZE_FORMAT
- "-%" G_GSIZE_FORMAT, subbuffer, buffer, offset, size);
+ GST_CAT_LOG (GST_CAT_BUFFER, "new region copy %p of %p %" G_GSIZE_FORMAT
+ "-%" G_GSIZE_FORMAT, copy, buffer, offset, size);
- gst_buffer_copy_into (subbuffer, buffer, GST_BUFFER_COPY_ALL, offset, size);
+ gst_buffer_copy_into (copy, buffer, flags, offset, size);
- return subbuffer;
+ return copy;
}
static gboolean
@@ -1129,7 +1119,7 @@ _gst_buffer_arr_span (GstMemory ** mem[], gsize len[], guint n, gsize offset,
if (!writable
&& _gst_buffer_arr_is_span_fast (mem, len, n, &poffset, &parent)) {
- span = gst_memory_sub (parent, offset + poffset, size);
+ span = gst_memory_share (parent, offset + poffset, size);
} else {
gsize count, left;
guint8 *dest, *ptr;
diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h
index b4cc88ef6..6e9cc1d39 100644
--- a/gst/gstbuffer.h
+++ b/gst/gstbuffer.h
@@ -237,13 +237,12 @@ typedef enum {
/**
* GstBuffer:
* @mini_object: the parent structure
- * @data: pointer to the buffer data
- * @size: size of buffer data
+ * @pool: pointer to the pool owner of the buffer
+ * @caps: the #GstCaps describing the data format in this buffer
* @timestamp: timestamp of the buffer, can be #GST_CLOCK_TIME_NONE when the
* timestamp is not known or relevant.
* @duration: duration in time of the buffer data, can be #GST_CLOCK_TIME_NONE
* when the duration is not known or relevant.
- * @caps: the #GstCaps describing the data format in this buffer
* @offset: a media specific offset for the buffer data.
* For video frames, this is the frame number of this buffer.
* For audio samples, this is the offset of the first sample in this buffer.
@@ -251,11 +250,6 @@ typedef enum {
* byte in this buffer.
* @offset_end: the last offset contained in this buffer. It has the same
* format as @offset.
- * @malloc_data: a pointer to the allocated memory associated with this buffer.
- * When the buffer is freed, this data will freed with @free_func.
- * @free_func: a custom function that will be called with @malloc_data, defaults
- * to g_free(). Since 0.10.22.
- * @parent: the parent buffer if this is a subbuffer. Since 0.10.26.
*
* The structure of a #GstBuffer. Use the associated macros to access the public
* variables.
@@ -302,7 +296,7 @@ void gst_buffer_extract (GstBuffer *buffer, gsize offset,
gpointer dest, gsize size);
gsize gst_buffer_get_size (GstBuffer *buffer);
-void gst_buffer_trim (GstBuffer *buffer, gsize offset, gsize size);
+void gst_buffer_resize (GstBuffer *buffer, gsize offset, gsize size);
/**
* gst_buffer_remove_memory:
@@ -312,7 +306,7 @@ void gst_buffer_trim (GstBuffer *buffer, gsize offset, gsi
* Set the size of @b to @s. This will remove or trim the memory blocks
* in the buffer.
*/
-#define gst_buffer_set_size(b,s) gst_buffer_trim ((b), 0, (s))
+#define gst_buffer_set_size(b,s) gst_buffer_resize ((b), 0, (s))
/* getting memory */
gpointer gst_buffer_map (GstBuffer *buffer, gsize *size, gsize *maxsize,
@@ -386,6 +380,7 @@ gst_buffer_copy (const GstBuffer * buf)
/**
* GstBufferCopyFlags:
+ * @GST_BUFFER_COPY_NONE: copy nothing
* @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied
* @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer timestamp, duration,
* offset and offset_end should be copied
@@ -399,6 +394,7 @@ gst_buffer_copy (const GstBuffer * buf)
* function to specify which items should be copied.
*/
typedef enum {
+ GST_BUFFER_COPY_NONE = 0,
GST_BUFFER_COPY_FLAGS = (1 << 0),
GST_BUFFER_COPY_TIMESTAMPS = (1 << 1),
GST_BUFFER_COPY_CAPS = (1 << 2),
@@ -474,8 +470,9 @@ G_STMT_START { \
GstCaps* gst_buffer_get_caps (GstBuffer *buffer);
void gst_buffer_set_caps (GstBuffer *buffer, GstCaps *caps);
-/* creating a subbuffer */
-GstBuffer* gst_buffer_create_sub (GstBuffer *parent, gsize offset, gsize size);
+/* creating a region */
+GstBuffer* gst_buffer_copy_region (GstBuffer *parent, GstBufferCopyFlags flags,
+ gsize offset, gsize size);
/* span, two buffers, intelligently */
gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2);
diff --git a/gst/gstcompat.h b/gst/gstcompat.h
index 07f5cc23e..8d0c457f7 100644
--- a/gst/gstcompat.h
+++ b/gst/gstcompat.h
@@ -47,6 +47,8 @@ G_BEGIN_DECLS
#define gst_pad_get_caps_reffed(p) gst_pad_get_caps(p)
#define gst_pad_peer_get_caps_reffed(p) gst_pad_peer_get_caps(p)
+//#define gst_buffer_create_sub(b,o,s) gst_buffer_copy_region(b,GST_BUFFER_COPY_ALL,o,s)
+
#ifndef GST_DISABLE_DEPRECATED
#endif /* not GST_DISABLE_DEPRECATED */
diff --git a/gst/gstmemory.c b/gst/gstmemory.c
index 75b94ab3a..af94ab847 100644
--- a/gst/gstmemory.c
+++ b/gst/gstmemory.c
@@ -44,14 +44,14 @@ typedef struct
} GstMemoryDefault;
static const GstMemoryImpl *_default_mem_impl;
-static const GstMemoryImpl *_default_sub_impl;
+static const GstMemoryImpl *_default_share_impl;
static void
_default_mem_init (GstMemoryDefault * mem, GstMemoryFlags flags,
GstMemory * parent, gsize slice_size, gpointer data,
GFreeFunc free_func, gsize maxsize, gsize offset, gsize size)
{
- mem->mem.impl = data ? _default_mem_impl : _default_sub_impl;
+ mem->mem.impl = data ? _default_mem_impl : _default_share_impl;
mem->mem.flags = flags;
mem->mem.refcount = 1;
mem->mem.parent = parent ? gst_memory_ref (parent) : NULL;
@@ -114,7 +114,7 @@ _default_mem_get_sizes (GstMemoryDefault * mem, gsize * maxsize)
}
static void
-_default_mem_trim (GstMemoryDefault * mem, gsize offset, gsize size)
+_default_mem_resize (GstMemoryDefault * mem, gsize offset, gsize size)
{
g_return_if_fail (size + mem->offset + offset <= mem->maxsize);
@@ -135,7 +135,7 @@ _default_mem_map (GstMemoryDefault * mem, gsize * size, gsize * maxsize,
}
static gpointer
-_default_sub_map (GstMemoryDefault * mem, gsize * size, gsize * maxsize,
+_default_share_map (GstMemoryDefault * mem, gsize * size, gsize * maxsize,
GstMapFlags flags)
{
guint8 *data;
@@ -158,7 +158,7 @@ _default_mem_unmap (GstMemoryDefault * mem, gpointer data, gsize size)
}
static gboolean
-_default_sub_unmap (GstMemoryDefault * mem, gpointer data, gsize size)
+_default_share_unmap (GstMemoryDefault * mem, gpointer data, gsize size)
{
gboolean res;
guint8 *ptr = data;
@@ -197,7 +197,7 @@ _default_mem_copy (GstMemoryDefault * mem, gsize offset, gsize size)
}
static GstMemoryDefault *
-_default_mem_sub (GstMemoryDefault * mem, gsize offset, gsize size)
+_default_mem_share (GstMemoryDefault * mem, gsize offset, gsize size)
{
GstMemoryDefault *sub;
GstMemory *parent;
@@ -244,7 +244,7 @@ _fallback_copy (GstMemory * mem, gsize offset, gsize size)
}
static GstMemory *
-_fallback_sub (GstMemory * mem, gsize offset, gsize size)
+_fallback_share (GstMemory * mem, gsize offset, gsize size)
{
GstMemoryDefault *sub;
GstMemory *parent;
@@ -268,19 +268,19 @@ _gst_memory_init (void)
{
static const GstMemoryInfo _mem_info = {
(GstMemoryGetSizesFunction) _default_mem_get_sizes,
- (GstMemoryTrimFunction) _default_mem_trim,
+ (GstMemoryResizeFunction) _default_mem_resize,
(GstMemoryMapFunction) _default_mem_map,
(GstMemoryUnmapFunction) _default_mem_unmap,
(GstMemoryFreeFunction) _default_mem_free,
(GstMemoryCopyFunction) _default_mem_copy,
- (GstMemorySubFunction) _default_mem_sub,
+ (GstMemoryShareFunction) _default_mem_share,
(GstMemoryIsSpanFunction) _default_mem_is_span
};
- static const GstMemoryInfo _sub_info = {
+ static const GstMemoryInfo _share_info = {
(GstMemoryGetSizesFunction) _default_mem_get_sizes,
- (GstMemoryTrimFunction) _default_mem_trim,
- (GstMemoryMapFunction) _default_sub_map,
- (GstMemoryUnmapFunction) _default_sub_unmap,
+ (GstMemoryResizeFunction) _default_mem_resize,
+ (GstMemoryMapFunction) _default_share_map,
+ (GstMemoryUnmapFunction) _default_share_unmap,
(GstMemoryFreeFunction) _default_mem_free,
NULL,
NULL,
@@ -288,7 +288,8 @@ _gst_memory_init (void)
};
_default_mem_impl = gst_memory_register ("GstMemoryDefault", &_mem_info);
- _default_sub_impl = gst_memory_register ("GstMemorySubbuffer", &_sub_info);
+ _default_share_impl =
+ gst_memory_register ("GstMemorySharebuffer", &_share_info);
}
/**
@@ -309,7 +310,7 @@ gst_memory_register (const gchar * name, const GstMemoryInfo * info)
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (info != NULL, NULL);
g_return_val_if_fail (info->get_sizes != NULL, NULL);
- g_return_val_if_fail (info->trim != NULL, NULL);
+ g_return_val_if_fail (info->resize != NULL, NULL);
g_return_val_if_fail (info->map != NULL, NULL);
g_return_val_if_fail (info->unmap != NULL, NULL);
g_return_val_if_fail (info->free != NULL, NULL);
@@ -318,7 +319,7 @@ gst_memory_register (const gchar * name, const GstMemoryInfo * info)
impl->name = g_quark_from_string (name);
impl->info = *info;
INSTALL_FALLBACK (copy);
- INSTALL_FALLBACK (sub);
+ INSTALL_FALLBACK (share);
INSTALL_FALLBACK (is_span);
GST_DEBUG ("register \"%s\" of size %" G_GSIZE_FORMAT, name);
@@ -437,19 +438,19 @@ gst_memory_copy (GstMemory * mem, gsize offset, gsize size)
}
void
-gst_memory_trim (GstMemory * mem, gsize offset, gsize size)
+gst_memory_resize (GstMemory * mem, gsize offset, gsize size)
{
g_return_if_fail (mem != NULL);
- mem->impl->info.trim (mem, offset, size);
+ mem->impl->info.resize (mem, offset, size);
}
GstMemory *
-gst_memory_sub (GstMemory * mem, gsize offset, gsize size)
+gst_memory_share (GstMemory * mem, gsize offset, gsize size)
{
g_return_val_if_fail (mem != NULL, NULL);
- return mem->impl->info.sub (mem, offset, size);
+ return mem->impl->info.share (mem, offset, size);
}
gboolean
diff --git a/gst/gstmemory.h b/gst/gstmemory.h
index 80d537dac..6c78aaa02 100644
--- a/gst/gstmemory.h
+++ b/gst/gstmemory.h
@@ -46,7 +46,7 @@ typedef enum {
* GstMemory:
* @impl: pointer to the #GstMemoryImpl
* @refcount: refcount
- * @paret: parent memory block
+ * @parent: parent memory block
*
* Base structure for memory implementations. Custom memory will put this structure
* as the first member of their structure.
@@ -73,18 +73,17 @@ typedef enum {
*/
#define GST_MEMORY_TRACE_NAME "GstMemory"
-typedef gsize (*GstMemoryGetSizesFunction) (GstMemory *mem, gsize *maxsize);
-
-typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize *size, gsize *maxsize,
- GstMapFlags flags);
-typedef gboolean (*GstMemoryUnmapFunction) (GstMemory *mem, gpointer data, gsize size);
+typedef gsize (*GstMemoryGetSizesFunction) (GstMemory *mem, gsize *maxsize);
+typedef void (*GstMemoryResizeFunction) (GstMemory *mem, gsize offset, gsize size);
+typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize *size, gsize *maxsize,
+ GstMapFlags flags);
+typedef gboolean (*GstMemoryUnmapFunction) (GstMemory *mem, gpointer data, gsize size);
typedef void (*GstMemoryFreeFunction) (GstMemory *mem);
+
typedef GstMemory * (*GstMemoryCopyFunction) (GstMemory *mem, gsize offset, gsize size);
-typedef void (*GstMemoryTrimFunction) (GstMemory *mem, gsize offset, gsize size);
-typedef GstMemory * (*GstMemorySubFunction) (GstMemory *mem, gsize offset, gsize size);
-typedef gboolean (*GstMemoryIsSpanFunction) (GstMemory *mem1, GstMemory *mem2,
- gsize *offset);
+typedef GstMemory * (*GstMemoryShareFunction) (GstMemory *mem, gsize offset, gsize size);
+typedef gboolean (*GstMemoryIsSpanFunction) (GstMemory *mem1, GstMemory *mem2, gsize *offset);
/**
* GstMemoryInfo:
@@ -94,13 +93,13 @@ typedef gboolean (*GstMemoryIsSpanFunction) (GstMemory *mem1, GstMemory *mem2
*/
struct _GstMemoryInfo {
GstMemoryGetSizesFunction get_sizes;
- GstMemoryTrimFunction trim;
+ GstMemoryResizeFunction resize;
GstMemoryMapFunction map;
GstMemoryUnmapFunction unmap;
GstMemoryFreeFunction free;
GstMemoryCopyFunction copy;
- GstMemorySubFunction sub;
+ GstMemoryShareFunction share;
GstMemoryIsSpanFunction is_span;
};
@@ -119,7 +118,7 @@ void gst_memory_unref (GstMemory *mem);
/* getting/setting memory properties */
gsize gst_memory_get_sizes (GstMemory *mem, gsize *maxsize);
-void gst_memory_trim (GstMemory *mem, gsize offset, gsize size);
+void gst_memory_resize (GstMemory *mem, gsize offset, gsize size);
/* retriveing data */
gpointer gst_memory_map (GstMemory *mem, gsize *size, gsize *maxsize,
@@ -128,10 +127,11 @@ gboolean gst_memory_unmap (GstMemory *mem, gpointer data, gsize size);
/* copy and subregions */
GstMemory * gst_memory_copy (GstMemory *mem, gsize offset, gsize size);
-GstMemory * gst_memory_sub (GstMemory *mem, gsize offset, gsize size);
+GstMemory * gst_memory_share (GstMemory *mem, gsize offset, gsize size);
/* span memory */
gboolean gst_memory_is_span (GstMemory *mem1, GstMemory *mem2, gsize *offset);
+
GstMemory * gst_memory_span (GstMemory **mem1, gsize len1, gsize offset,
GstMemory **mem2, gsize len2, gsize size);
diff --git a/libs/gst/base/gstadapter.c b/libs/gst/base/gstadapter.c
index 8a053eca8..446345f46 100644
--- a/libs/gst/base/gstadapter.c
+++ b/libs/gst/base/gstadapter.c
@@ -716,9 +716,9 @@ gst_adapter_take_buffer (GstAdapter * adapter, gsize nbytes)
buffer = gst_buffer_ref (cur);
goto done;
} else if (hsize >= nbytes + skip) {
- GST_LOG_OBJECT (adapter, "providing buffer of %d bytes via sub-buffer",
+ GST_LOG_OBJECT (adapter, "providing buffer of %d bytes via region copy",
nbytes);
- buffer = gst_buffer_create_sub (cur, skip, nbytes);
+ buffer = gst_buffer_copy_region (cur, GST_BUFFER_COPY_ALL, skip, nbytes);
goto done;
}
@@ -728,7 +728,7 @@ gst_adapter_take_buffer (GstAdapter * adapter, gsize nbytes)
if (gst_buffer_get_size (cur) >= nbytes + skip) {
GST_LOG_OBJECT (adapter, "providing buffer of %d bytes via sub-buffer",
nbytes);
- buffer = gst_buffer_create_sub (cur, skip, nbytes);
+ buffer = gst_buffer_copy_region (cur, GST_BUFFER_COPY_ALL, skip, nbytes);
goto done;
}
}
diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c
index 296ba94cd..52c3e2f61 100644
--- a/libs/gst/base/gstbasetransform.c
+++ b/libs/gst/base/gstbasetransform.c
@@ -1598,9 +1598,9 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
if (setcaps || copymeta) {
GST_DEBUG_OBJECT (trans, "setcaps %d, copymeta %d", setcaps, copymeta);
if (!gst_buffer_is_writable (*out_buf)) {
- GST_DEBUG_OBJECT (trans, "buffer metadata %p not writable", *out_buf);
+ GST_DEBUG_OBJECT (trans, "buffer %p not writable", *out_buf);
if (in_buf == *out_buf)
- *out_buf = gst_buffer_create_sub (in_buf, 0, insize);
+ *out_buf = gst_buffer_copy (in_buf);
else
*out_buf = gst_buffer_make_writable (*out_buf);
}
diff --git a/libs/gst/base/gstcollectpads.c b/libs/gst/base/gstcollectpads.c
index ceba51f71..e0f25eab4 100644
--- a/libs/gst/base/gstcollectpads.c
+++ b/libs/gst/base/gstcollectpads.c
@@ -923,7 +923,8 @@ gst_collect_pads_read_buffer (GstCollectPads * pads, GstCollectData * data,
if (data->pos == 0 && readsize == bufsize)
return gst_buffer_ref (buffer);
else
- return gst_buffer_create_sub (buffer, data->pos, readsize);
+ return gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, data->pos,
+ readsize);
}
/**
diff --git a/plugins/elements/gstcapsfilter.c b/plugins/elements/gstcapsfilter.c
index 97028ea33..950df3f45 100644
--- a/plugins/elements/gstcapsfilter.c
+++ b/plugins/elements/gstcapsfilter.c
@@ -341,7 +341,7 @@ gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
gst_buffer_ref (input);
} else {
GST_DEBUG_OBJECT (trans, "Creating sub-buffer and setting caps");
- *buf = gst_buffer_create_sub (input, 0, gst_buffer_get_size (input));
+ *buf = gst_buffer_copy (input);
gst_buffer_set_caps (*buf, caps);
}
} else {
@@ -373,7 +373,7 @@ gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
*buf = input;
} else {
GST_DEBUG_OBJECT (trans, "Creating sub-buffer and setting caps");
- *buf = gst_buffer_create_sub (input, 0, gst_buffer_get_size (input));
+ *buf = gst_buffer_copy (input);
}
GST_BUFFER_CAPS (*buf) = out_caps;
diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c
index bbc2039ae..6e2c2f3a5 100644
--- a/plugins/elements/gstfakesrc.c
+++ b/plugins/elements/gstfakesrc.c
@@ -741,7 +741,9 @@ gst_fake_src_create_buffer (GstFakeSrc * src, gsize * bufsize)
}
/* see if it's large enough */
if ((src->parentsize - src->parentoffset) >= size) {
- buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
+ buf =
+ gst_buffer_copy_region (src->parent, GST_BUFFER_COPY_ALL,
+ src->parentoffset, size);
src->parentoffset += size;
} else {
/* the parent is useless now */
diff --git a/tests/check/gst/gstbuffer.c b/tests/check/gst/gstbuffer.c
index a327380d5..b43f73770 100644
--- a/tests/check/gst/gstbuffer.c
+++ b/tests/check/gst/gstbuffer.c
@@ -98,8 +98,8 @@ GST_START_TEST (test_subbuffer)
GST_BUFFER_OFFSET (buffer) = 3;
GST_BUFFER_OFFSET_END (buffer) = 4;
- sub = gst_buffer_create_sub (buffer, 1, 2);
- fail_if (sub == NULL, "create_sub of buffer returned NULL");
+ sub = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 1, 2);
+ fail_if (sub == NULL, "copy region of buffer returned NULL");
sdata = gst_buffer_map (sub, &ssize, NULL, GST_MAP_READ);
fail_unless (ssize == 2, "subbuffer has wrong size");
@@ -116,8 +116,8 @@ GST_START_TEST (test_subbuffer)
gst_buffer_unref (sub);
/* create a subbuffer of size 0 */
- sub = gst_buffer_create_sub (buffer, 1, 0);
- fail_if (sub == NULL, "create_sub of buffer returned NULL");
+ sub = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 1, 0);
+ fail_if (sub == NULL, "copy_region of buffer returned NULL");
sdata = gst_buffer_map (sub, &ssize, NULL, GST_MAP_READ);
fail_unless (ssize == 0, "subbuffer has wrong size");
fail_unless (memcmp (data + 1, sdata, 0) == 0,
@@ -128,8 +128,8 @@ GST_START_TEST (test_subbuffer)
/* test if metadata is coppied, not a complete buffer copy so only the
* timestamp and offset fields are copied. */
- sub = gst_buffer_create_sub (buffer, 0, 1);
- fail_if (sub == NULL, "create_sub of buffer returned NULL");
+ sub = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, 1);
+ fail_if (sub == NULL, "copy_region of buffer returned NULL");
fail_unless (gst_buffer_get_size (sub) == 1, "subbuffer has wrong size");
fail_unless (GST_BUFFER_TIMESTAMP (sub) == 1,
"subbuffer has wrong timestamp");
@@ -141,8 +141,8 @@ GST_START_TEST (test_subbuffer)
/* test if metadata is coppied, a complete buffer is copied so all the timing
* fields should be copied. */
- sub = gst_buffer_create_sub (buffer, 0, 4);
- fail_if (sub == NULL, "create_sub of buffer returned NULL");
+ sub = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, 4);
+ fail_if (sub == NULL, "copy_region of buffer returned NULL");
fail_unless (gst_buffer_get_size (sub) == 4, "subbuffer has wrong size");
fail_unless (GST_BUFFER_TIMESTAMP (sub) == 1,
"subbuffer has wrong timestamp");
@@ -166,11 +166,11 @@ GST_START_TEST (test_is_span_fast)
buffer = gst_buffer_new_and_alloc (4);
- sub1 = gst_buffer_create_sub (buffer, 0, 2);
- fail_if (sub1 == NULL, "create_sub of buffer returned NULL");
+ sub1 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, 2);
+ fail_if (sub1 == NULL, "copy_region of buffer returned NULL");
- sub2 = gst_buffer_create_sub (buffer, 2, 2);
- fail_if (sub2 == NULL, "create_sub of buffer returned NULL");
+ sub2 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 2, 2);
+ fail_if (sub2 == NULL, "copy_region of buffer returned NULL");
fail_if (gst_buffer_is_span_fast (buffer, sub2) == TRUE,
"a parent buffer can't be span_fasted");
@@ -206,11 +206,11 @@ GST_START_TEST (test_span)
ASSERT_CRITICAL (gst_buffer_span (NULL, 1, buffer, 2));
ASSERT_CRITICAL (gst_buffer_span (buffer, 0, buffer, 10));
- sub1 = gst_buffer_create_sub (buffer, 0, 2);
- fail_if (sub1 == NULL, "create_sub of buffer returned NULL");
+ sub1 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, 2);
+ fail_if (sub1 == NULL, "copy_region of buffer returned NULL");
- sub2 = gst_buffer_create_sub (buffer, 2, 2);
- fail_if (sub2 == NULL, "create_sub of buffer returned NULL");
+ sub2 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 2, 2);
+ fail_if (sub2 == NULL, "copy_region of buffer returned NULL");
ASSERT_BUFFER_REFCOUNT (buffer, "parent", 1);
ASSERT_BUFFER_REFCOUNT (sub1, "sub1", 1);
@@ -339,7 +339,7 @@ GST_START_TEST (test_subbuffer_make_writable)
/* create sub-buffer of read-only buffer and make it writable */
buf = create_read_only_buffer ();
- sub_buf = gst_buffer_create_sub (buf, 0, 8);
+ sub_buf = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, 0, 8);
data = gst_buffer_map (sub_buf, &size, NULL, GST_MAP_WRITE);
fail_if (data == NULL);
diff --git a/tests/check/gst/gstmeta.c b/tests/check/gst/gstmeta.c
index df77f35ab..10041efa8 100644
--- a/tests/check/gst/gstmeta.c
+++ b/tests/check/gst/gstmeta.c
@@ -157,7 +157,7 @@ GST_START_TEST (test_meta_test)
gst_buffer_unref (copy);
/* make subbuffer */
- subbuf = gst_buffer_create_sub (buffer, 0, 1);
+ subbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, 1);
/* get metadata of the buffer */
meta = GST_META_TEST_GET (subbuf);
fail_if (meta == NULL);
@@ -168,7 +168,7 @@ GST_START_TEST (test_meta_test)
gst_buffer_unref (subbuf);
/* make another subbuffer */
- subbuf = gst_buffer_create_sub (buffer, 1, 3);
+ subbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 1, 3);
/* get metadata of the buffer */
meta = GST_META_TEST_GET (subbuf);
fail_if (meta == NULL);
diff --git a/tests/check/libs/adapter.c b/tests/check/libs/adapter.c
index e221814a9..b456473f5 100644
--- a/tests/check/libs/adapter.c
+++ b/tests/check/libs/adapter.c
@@ -231,13 +231,13 @@ GST_START_TEST (test_take3)
fail_unless (size == 100);
/* set up and push subbuffers */
- buffer2 = gst_buffer_create_sub (buffer, 0, 25);
+ buffer2 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, 25);
gst_adapter_push (adapter, buffer2);
- buffer2 = gst_buffer_create_sub (buffer, 25, 25);
+ buffer2 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 25, 25);
gst_adapter_push (adapter, buffer2);
- buffer2 = gst_buffer_create_sub (buffer, 50, 25);
+ buffer2 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 50, 25);
gst_adapter_push (adapter, buffer2);
- buffer2 = gst_buffer_create_sub (buffer, 75, 25);
+ buffer2 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 75, 25);
gst_adapter_push (adapter, buffer2);
gst_buffer_unref (buffer);
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index 4ab8c7f26..2f65396ba 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -92,7 +92,7 @@ EXPORTS
gst_buffer_add_meta
gst_buffer_copy_flags_get_type
gst_buffer_copy_into
- gst_buffer_create_sub
+ gst_buffer_copy_region
gst_buffer_extract
gst_buffer_fill
gst_buffer_flag_get_type
@@ -138,10 +138,10 @@ EXPORTS
gst_buffer_pool_set_config
gst_buffer_remove_memory_range
gst_buffer_remove_meta
+ gst_buffer_resize
gst_buffer_set_caps
gst_buffer_span
gst_buffer_take_memory
- gst_buffer_trim
gst_buffer_unmap
gst_buffering_mode_get_type
gst_bus_add_signal_watch
@@ -540,8 +540,8 @@ EXPORTS
gst_memory_new_wrapped
gst_memory_ref
gst_memory_register
- gst_memory_sub
- gst_memory_trim
+ gst_memory_resize
+ gst_memory_share
gst_memory_unmap
gst_memory_unref
gst_message_get_seqnum