diff --git a/src/arvstream.c b/src/arvstream.c index 7543554a7..eb87d3ecc 100644 --- a/src/arvstream.c +++ b/src/arvstream.c @@ -79,6 +79,35 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ArvStream, arv_stream, G_TYPE_OBJECT, G_ADD_PRIVATE (ArvStream) G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, arv_stream_initable_iface_init)) +unsigned int +arv_stream_create_buffers (ArvStream *stream, unsigned int n_buffers, + void *user_data, GDestroyNotify user_data_destroy_func, + GError **error) +{ + ArvStreamClass *stream_class; + ArvStreamPrivate *priv = arv_stream_get_instance_private (stream); + size_t payload_size; + unsigned int i; + + g_return_val_if_fail (ARV_IS_STREAM (stream), 0); + g_return_val_if_fail (n_buffers > 0, 0); + g_return_val_if_fail (ARV_IS_DEVICE (priv->device), 0); + + payload_size = arv_device_get_integer_feature_value (priv->device, "PayloadSize", error); + if (payload_size < 1) + return 0; + + stream_class = ARV_STREAM_GET_CLASS (stream); + if (stream_class->create_buffers != NULL) + return stream_class->create_buffers (stream, n_buffers, payload_size, user_data, user_data_destroy_func); + + for (i = 0; i < n_buffers; i++) + arv_stream_push_buffer (stream, arv_buffer_new_full (payload_size, NULL, + user_data, user_data_destroy_func)); + + return n_buffers; +} + /** * arv_stream_push_buffer: * @stream: a #ArvStream diff --git a/src/arvstream.h b/src/arvstream.h index 0c6e85205..b7a0d463c 100644 --- a/src/arvstream.h +++ b/src/arvstream.h @@ -58,12 +58,19 @@ struct _ArvStreamClass { void (*start_thread) (ArvStream *stream); void (*stop_thread) (ArvStream *stream); + unsigned int (*create_buffers) (ArvStream *stream, unsigned int n_buffers, size_t size, + void *user_data, GDestroyNotify user_data_destroy_func); + /* signals */ void (*new_buffer) (ArvStream *stream); }; typedef void (*ArvStreamCallback) (void *user_data, ArvStreamCallbackType type, ArvBuffer *buffer); +ARV_API unsigned int arv_stream_create_buffers (ArvStream *stream, unsigned int n_buffers, + void *user_data, GDestroyNotify user_data_destroy_func, + GError **error); + ARV_API void arv_stream_push_buffer (ArvStream *stream, ArvBuffer *buffer); ARV_API ArvBuffer * arv_stream_pop_buffer (ArvStream *stream); ARV_API ArvBuffer * arv_stream_try_pop_buffer (ArvStream *stream); diff --git a/src/arvuvstream.c b/src/arvuvstream.c index 79151e9ff..e62d3c873 100644 --- a/src/arvuvstream.c +++ b/src/arvuvstream.c @@ -114,6 +114,25 @@ typedef struct { G_DEFINE_TYPE_WITH_CODE (ArvUvStream, arv_uv_stream, ARV_TYPE_STREAM, G_ADD_PRIVATE (ArvUvStream)) +typedef struct { + void *buffer; + gboolean is_dev_mem; + void *user_data; + GDestroyNotify user_data_destroy_func; +} ArvUvStreamBufferInfos; + +static void +_destroy_buffer (void *abstract_data) +{ +} + +static unsigned int +arv_uv_stream_create_buffers (ArvStream *stream, unsigned int n_buffers, size_t size, + void *user_data, GDestroyNotify user_data_destroy_func) +{ + return 0; +} + static void arv_uv_stream_buffer_context_wait_transfer_completed (ArvUvStreamBufferContext* ctx) { diff --git a/viewer/arvviewer.c b/viewer/arvviewer.c index f8abc3a28..a9559b7e2 100644 --- a/viewer/arvviewer.c +++ b/viewer/arvviewer.c @@ -1212,8 +1212,6 @@ start_video (ArvViewer *viewer) GstElement *videoconvert; GstCaps *caps; ArvPixelFormat pixel_format; - unsigned payload; - unsigned i; gint width, height; const char *caps_string; @@ -1248,9 +1246,8 @@ start_video (ArvViewer *viewer) } arv_stream_set_emit_signals (viewer->stream, TRUE); - payload = arv_camera_get_payload (viewer->camera, NULL); - for (i = 0; i < 10; i++) - arv_stream_push_buffer (viewer->stream, arv_buffer_new (payload, NULL)); + + arv_stream_create_buffers (viewer->stream, 10, NULL, NULL, NULL); set_camera_widgets(viewer); pixel_format = arv_camera_get_pixel_format (viewer->camera, NULL);