[gstreamermm] Gst::Buffer: copy_into method now as a static method
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Gst::Buffer: copy_into method now as a static method
- Date: Wed, 28 Jan 2015 12:46:42 +0000 (UTC)
commit 0df060a91ce70fdfd87630fc6db0ffcb7d79fb62
Author: Marcin Kolny <marcin kolny flytronic pl>
Date: Wed Jan 28 12:00:01 2015 +0100
Gst::Buffer: copy_into method now as a static method
* gstreamer/src/buffer.hg: syntax buff1->copy_into(buff2) isn't clear
for developers. It suggests, that buff1 is copied into buff2.
Reverse order might be confusing for users, who already knows
c-style syntax of copying methods, so compromise is here to make
copy_into method as a static.
* tests/test-buffer.cc: added tests for copy_into method.
gstreamer/src/buffer.hg | 2 +-
tests/test-buffer.cc | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/gstreamer/src/buffer.hg b/gstreamer/src/buffer.hg
index b0f8f91..fc71cdf 100644
--- a/gstreamer/src/buffer.hg
+++ b/gstreamer/src/buffer.hg
@@ -104,7 +104,7 @@ public:
Glib::RefPtr<Gst::Buffer> copy() const;
_IGNORE(gst_buffer_copy)
- _WRAP_METHOD(void copy_into(Glib::RefPtr<Gst::Buffer> source_buffer, BufferCopyFlags flags, gsize offset,
gsize size), gst_buffer_copy_into)
+ _WRAP_METHOD(static void copy_into(const Glib::RefPtr<Gst::Buffer>& destination_buffer, const
Glib::RefPtr<Gst::Buffer>& source_buffer, BufferCopyFlags flags, gsize offset, gsize size),
gst_buffer_copy_into)
_WRAP_METHOD(Glib::RefPtr<Gst::Buffer> copy_region(Gst::BufferCopyFlags flags, gsize offset, gsize size),
gst_buffer_copy_region)
diff --git a/tests/test-buffer.cc b/tests/test-buffer.cc
index ded6227..89cd76e 100644
--- a/tests/test-buffer.cc
+++ b/tests/test-buffer.cc
@@ -98,3 +98,24 @@ TEST(BufferTest, CheckBufferRefcountAfterCopying)
ASSERT_EQ(1, b->gobj()->mini_object.refcount);
ASSERT_EQ(1, buf->gobj()->mini_object.refcount);
}
+
+TEST(BufferTest, CheckBufferCopyIntoMethod)
+{
+ std::vector<char> data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+ Glib::RefPtr<Buffer> src = Buffer::create(data.size());
+ Glib::RefPtr<Buffer> dest = Buffer::create();
+ src->set_pts(10);
+ Glib::RefPtr<MapInfo> info(new MapInfo());
+ src->map(info, MAP_READ);
+ std::copy(data.begin(), data.end(), info->get_data());
+ src->unmap(info);
+
+ Gst::Buffer::copy_into(dest, src, BUFFER_COPY_TIMESTAMPS | BUFFER_COPY_MEMORY, 0, data.size());
+ ASSERT_EQ(dest->get_pts(), 10);
+ ASSERT_EQ(data.size(), dest->get_size());
+
+ ASSERT_EQ(0, dest->memcmp(0, data.data(), data.size()));
+
+ ASSERT_EQ(1, src->get_refcount());
+ ASSERT_EQ(1, dest->get_refcount());
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]