[aravis] viewer: move GstBuffer creation from ArvBuffer in a dedicated function
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] viewer: move GstBuffer creation from ArvBuffer in a dedicated function
- Date: Wed, 17 Sep 2014 18:41:55 +0000 (UTC)
commit c9b651bfce3febd9bd3dd14d5cb708c94ed479dd
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Wed Sep 17 20:41:08 2014 +0200
viewer: move GstBuffer creation from ArvBuffer in a dedicated function
viewer/arvviewer.c | 75 ++++++++++++++++++++++++++++++---------------------
1 files changed, 44 insertions(+), 31 deletions(-)
---
diff --git a/viewer/arvviewer.c b/viewer/arvviewer.c
index 502d5dc..781486f 100644
--- a/viewer/arvviewer.c
+++ b/viewer/arvviewer.c
@@ -138,50 +138,63 @@ arv_viewer_update_device_list_cb (ArvViewer *viewer)
gtk_widget_set_sensitive (viewer->camera_combo_box, FALSE);
}
+static GstBuffer *
+_arv_to_gst_buffer (ArvBuffer *arv_buffer)
+{
+ GstBuffer *buffer;
+ int arv_row_stride;
+ int width, height;
+ char *buffer_data;
+ size_t buffer_size;
+
+ buffer_data = (char *) arv_buffer_get_data (arv_buffer, &buffer_size);
+ arv_buffer_get_image_region (arv_buffer, NULL, NULL, &width, &height);
+ arv_row_stride = width * ARV_PIXEL_FORMAT_BIT_PER_PIXEL (arv_buffer_get_image_pixel_format
(arv_buffer)) / 8;
+
+ /* Gstreamer requires row stride to be a multiple of 4 */
+ if ((arv_row_stride & 0x3) != 0) {
+ int gst_row_stride;
+ size_t size;
+ void *data;
+ int i;
+
+ gst_row_stride = (arv_row_stride & ~(0x3)) + 4;
+
+ size = height * gst_row_stride;
+ data = g_malloc (size);
+
+ for (i = 0; i < height; i++)
+ memcpy (((char *) data) + i * gst_row_stride, buffer_data + i * arv_row_stride,
arv_row_stride);
+
+ buffer = gst_buffer_new_wrapped (data, size);
+ } else {
+ buffer = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
+ buffer_data, buffer_size,
+ 0, buffer_size, NULL, NULL);
+ }
+
+ GST_BUFFER_DTS (buffer) = 0;
+ GST_BUFFER_DURATION (buffer) = 0;
+
+ return buffer;
+}
+
void
arv_viewer_new_buffer_cb (ArvStream *stream, ArvViewer *viewer)
{
ArvBuffer *arv_buffer;
- GstBuffer *buffer;
arv_buffer = arv_stream_pop_buffer (stream);
if (arv_buffer == NULL)
return;
if (arv_buffer_get_status (arv_buffer) == ARV_BUFFER_STATUS_SUCCESS) {
- int arv_row_stride;
- int width, height;
- char *buffer_data;
- size_t buffer_size;
+ GstBuffer *buffer;
guint64 timestamp_ns;
- timestamp_ns = g_get_real_time () * 1000LL;
-
- buffer_data = (char *) arv_buffer_get_data (arv_buffer, &buffer_size);
- arv_buffer_get_image_region (arv_buffer, NULL, NULL, &width, &height);
- arv_row_stride = width * ARV_PIXEL_FORMAT_BIT_PER_PIXEL (arv_buffer_get_image_pixel_format
(arv_buffer)) / 8;
+ buffer = _arv_to_gst_buffer (arv_buffer);
- /* Gstreamer requires row stride to be a multiple of 4 */
- if ((arv_row_stride & 0x3) != 0) {
- int gst_row_stride;
- size_t size;
- void *data;
- int i;
-
- gst_row_stride = (arv_row_stride & ~(0x3)) + 4;
-
- size = height * gst_row_stride;
- data = g_malloc (size);
-
- for (i = 0; i < height; i++)
- memcpy (((char *) data) + i * gst_row_stride, buffer_data + i *
arv_row_stride, arv_row_stride);
-
- buffer = gst_buffer_new_wrapped (data, size);
- } else {
- buffer = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
- buffer_data, buffer_size,
- 0, buffer_size, NULL, NULL);
- }
+ timestamp_ns = g_get_real_time () * 1000LL;
if (viewer->timestamp_offset == 0) {
viewer->timestamp_offset = timestamp_ns;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]