[aravis/buffer] buffer: add a binding friendly data accessor
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis/buffer] buffer: add a binding friendly data accessor
- Date: Thu, 12 Jun 2014 08:55:22 +0000 (UTC)
commit c833e089473921541fa920a25456ac6dfeed06d4
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Thu Jun 12 10:54:25 2014 +0200
buffer: add a binding friendly data accessor
docs/reference/aravis/aravis-sections.txt | 1 +
src/arvbuffer.c | 23 +++++++++++++++++++++++
src/arvbuffer.h | 3 ++-
tests/python/arv-single-buffer-test.py | 4 +++-
4 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index c26017d..a335008 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -78,6 +78,7 @@ ArvPixelFormat
arv_buffer_new
arv_buffer_new_full
arv_buffer_new_allocate
+arv_buffer_get_data
ARV_PIXEL_FORMAT_BIT_PER_PIXEL
ARV_PIXEL_FORMAT_BAYER_BG_10
ARV_PIXEL_FORMAT_BAYER_BG_12
diff --git a/src/arvbuffer.c b/src/arvbuffer.c
index 626ae93..50f7aa5 100644
--- a/src/arvbuffer.c
+++ b/src/arvbuffer.c
@@ -134,6 +134,29 @@ arv_buffer_clear (ArvBuffer *buffer)
buffer->status = ARV_BUFFER_STATUS_CLEARED;
}
+/**
+ * arv_buffer_get_data:
+ * @buffer: a #ArvBuffer
+ * @size: (allow-none): location to store data size, or %NULL
+ *
+ * Buffer data accessor.
+ *
+ * Returns: (array length=size) (element-type guint8): a pointer to the buffer data.
+ *
+ * Since: 0.3.3
+ **/
+
+const void *
+arv_buffer_get_data (ArvBuffer *buffer, size_t *size)
+{
+ g_return_val_if_fail (ARV_IS_BUFFER (buffer), NULL);
+
+ if (size != NULL)
+ *size = buffer->size;
+
+ return buffer->data;
+}
+
static void
arv_buffer_init (ArvBuffer *buffer)
{
diff --git a/src/arvbuffer.h b/src/arvbuffer.h
index b57f31b..c454486 100644
--- a/src/arvbuffer.h
+++ b/src/arvbuffer.h
@@ -66,7 +66,7 @@ struct _ArvBuffer {
size_t size;
gboolean is_preallocated;
- char *data;
+ void *data;
void *user_data;
GDestroyNotify user_data_destroy_func;
@@ -94,6 +94,7 @@ ArvBuffer * arv_buffer_new_allocate (size_t size);
ArvBuffer * arv_buffer_new (size_t size, void *preallocated);
ArvBuffer * arv_buffer_new_full (size_t size, void *preallocated,
void *user_data, GDestroyNotify user_data_destroy_func);
+const void * arv_buffer_get_data (ArvBuffer *buffer, size_t *size);
G_END_DECLS
diff --git a/tests/python/arv-single-buffer-test.py b/tests/python/arv-single-buffer-test.py
index bbe3704..8ba66cd 100644
--- a/tests/python/arv-single-buffer-test.py
+++ b/tests/python/arv-single-buffer-test.py
@@ -97,7 +97,9 @@ print "Acquisition"
buffer = stream.pop_buffer ()
-DumpBuffer (buffer.data, buffer.size, "Image buffer")
+data = buffer.get_data ()
+
+DumpBuffer (data, len(data), "Image buffer")
print "Stop acquisition"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]