summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2012-06-28 11:02:19 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2012-06-28 11:02:19 +0200
commit4c6228224f6b56c665cff0d346b021fc071bef6d (patch)
treeff4c576c0da81538a9677a6b7d4938f6c14f8d3a
parentd7fdf75e137f804b5e0215eca95593f4bdc465e7 (diff)
buffer: add _append_region function
Make a gst_buffer_append_region() function that allows you to append a memory region from one buffer to another. This is a more general version of gst_buffer_append().
-rw-r--r--docs/gst/gstreamer-sections.txt1
-rw-r--r--gst/gstbuffer.c31
-rw-r--r--gst/gstbuffer.h4
-rw-r--r--win32/common/libgstreamer.def2
4 files changed, 23 insertions, 15 deletions
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
index 41213ce41..81a0a4d9f 100644
--- a/docs/gst/gstreamer-sections.txt
+++ b/docs/gst/gstreamer-sections.txt
@@ -236,6 +236,7 @@ gst_buffer_make_writable
gst_buffer_replace
gst_buffer_append
+gst_buffer_append_region
gst_buffer_get_meta
gst_buffer_add_meta
diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c
index 756c26c4d..be5f0fca4 100644
--- a/gst/gstbuffer.c
+++ b/gst/gstbuffer.c
@@ -1614,8 +1614,23 @@ gst_buffer_copy_region (GstBuffer * buffer, GstBufferCopyFlags flags,
* Returns: (transfer full): the new #GstBuffer that contains the memory
* of the two source buffers.
*/
+/**
+ * gst_buffer_append_region:
+ * @buf1: (transfer full): the first source #GstBuffer to append.
+ * @buf2: (transfer full): the second source #GstBuffer to append.
+ * @offset: the offset in @buf2
+ * @size: the size or -1 of @buf2
+ *
+ * Append @size bytes at @offset from @buf2 to @buf1. The result buffer will
+ * contain a concatenation of the memory of @buf1 and the requested region of
+ * @buf2.
+ *
+ * Returns: (transfer full): the new #GstBuffer that contains the memory
+ * of the two source buffers.
+ */
GstBuffer *
-gst_buffer_append (GstBuffer * buf1, GstBuffer * buf2)
+gst_buffer_append_region (GstBuffer * buf1, GstBuffer * buf2, gssize offset,
+ gssize size)
{
gsize i, len;
@@ -1625,6 +1640,8 @@ gst_buffer_append (GstBuffer * buf1, GstBuffer * buf2)
buf1 = gst_buffer_make_writable (buf1);
buf2 = gst_buffer_make_writable (buf2);
+ gst_buffer_resize (buf2, offset, size);
+
len = GST_BUFFER_MEM_LEN (buf2);
for (i = 0; i < len; i++) {
GstMemory *mem;
@@ -1634,18 +1651,6 @@ gst_buffer_append (GstBuffer * buf1, GstBuffer * buf2)
_memory_add (buf1, -1, mem);
}
- /* we can calculate the duration too. Also make sure we're not messing
- * with invalid DURATIONS */
- if (GST_BUFFER_DURATION_IS_VALID (buf1) &&
- GST_BUFFER_DURATION_IS_VALID (buf2)) {
- /* add duration */
- GST_BUFFER_DURATION (buf1) += GST_BUFFER_DURATION (buf2);
- }
- if (GST_BUFFER_OFFSET_END_IS_VALID (buf2)) {
- /* set offset_end */
- GST_BUFFER_OFFSET_END (buf1) = GST_BUFFER_OFFSET_END (buf2);
- }
-
GST_BUFFER_MEM_LEN (buf2) = 0;
gst_buffer_unref (buf2);
diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h
index df4647faf..ef5b1da6d 100644
--- a/gst/gstbuffer.h
+++ b/gst/gstbuffer.h
@@ -476,7 +476,9 @@ GstBuffer* gst_buffer_copy_region (GstBuffer *parent, GstBufferCop
gsize offset, gsize size);
/* append two buffers */
-GstBuffer* gst_buffer_append (GstBuffer *buf1, GstBuffer *buf2);
+GstBuffer* gst_buffer_append_region (GstBuffer *buf1, GstBuffer *buf2,
+ gssize offset, gssize size);
+#define gst_buffer_append(b1,b2) gst_buffer_append_region ((b1), (b2), 0, -1)
/* metadata */
#include <gst/gstmeta.h>
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index 825846d42..b8489b09c 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -89,7 +89,7 @@ EXPORTS
gst_bin_remove_many
gst_bitmask_get_type
gst_buffer_add_meta
- gst_buffer_append
+ gst_buffer_append_region
gst_buffer_copy_flags_get_type
gst_buffer_copy_into
gst_buffer_copy_region