[aravis] fake_gv_camera: correctly handle packet size.



commit 568fc343705d27f44b9391c8204f1fbba8568aba
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Thu May 12 21:43:12 2011 +0200

    fake_gv_camera: correctly handle packet size.

 src/arvfakecamera.c   |    5 ++++-
 src/arvfakecamera.h   |    3 ++-
 src/arvfakegvcamera.c |    6 ++++--
 src/arvfakestream.c   |    2 +-
 4 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/arvfakecamera.c b/src/arvfakecamera.c
index 30b5004..6d0003f 100644
--- a/src/arvfakecamera.c
+++ b/src/arvfakecamera.c
@@ -226,7 +226,7 @@ arv_fake_camera_set_fill_pattern (ArvFakeCamera *camera,
 }
 
 void
-arv_fake_camera_fill_buffer (ArvFakeCamera *camera, ArvBuffer *buffer)
+arv_fake_camera_fill_buffer (ArvFakeCamera *camera, ArvBuffer *buffer, guint32 *packet_size)
 {
 	struct timespec time;
 	guint32 width;
@@ -267,6 +267,9 @@ arv_fake_camera_fill_buffer (ArvFakeCamera *camera, ArvBuffer *buffer)
 	camera->priv->fill_pattern_callback (buffer, camera->priv->fill_pattern_data,
 					     exposure_time_us, gain, pixel_format);
 	g_mutex_unlock (camera->priv->fill_pattern_mutex);
+
+	if (packet_size != NULL)
+		*packet_size = _get_register (camera, ARV_GVBS_STREAM_CHANNEL_0_PACKET_SIZE_OFFSET);
 }
 
 void
diff --git a/src/arvfakecamera.h b/src/arvfakecamera.h
index 35b6738..195ae3f 100644
--- a/src/arvfakecamera.h
+++ b/src/arvfakecamera.h
@@ -113,7 +113,8 @@ gboolean	arv_fake_camera_write_register 	(ArvFakeCamera *camera, guint32 address
 
 size_t 		arv_fake_camera_get_payload 		(ArvFakeCamera *camera);
 void 		arv_fake_camera_wait_for_next_frame 	(ArvFakeCamera *camera);
-void		arv_fake_camera_fill_buffer		(ArvFakeCamera *camera, ArvBuffer *buffer);
+void		arv_fake_camera_fill_buffer		(ArvFakeCamera *camera, ArvBuffer *buffer,
+							 guint32 *packet_size);
 
 guint32 	arv_fake_camera_get_acquisition_status 	(ArvFakeCamera *camera);
 GSocketAddress *arv_fake_camera_get_stream_address 	(ArvFakeCamera *camera);
diff --git a/src/arvfakegvcamera.c b/src/arvfakegvcamera.c
index ab95de8..7d53f95 100644
--- a/src/arvfakegvcamera.c
+++ b/src/arvfakegvcamera.c
@@ -96,6 +96,7 @@ arv_fake_gv_camera_thread (void *user_data)
 	guint32 frame_id = 0;
 	guint16 block_id;
 	ptrdiff_t offset;
+	guint32 gv_packet_size;
 
 	packet_buffer = g_malloc (ARV_FAKE_GV_CAMERA_BUFFER_SIZE);
 
@@ -130,7 +131,7 @@ arv_fake_gv_camera_thread (void *user_data)
 			}
 
 			arv_fake_camera_wait_for_next_frame (gv_camera->camera);
-			arv_fake_camera_fill_buffer (gv_camera->camera, image_buffer);
+			arv_fake_camera_fill_buffer (gv_camera->camera, image_buffer, &gv_packet_size);
 
 			block_id = 0;
 
@@ -158,7 +159,8 @@ arv_fake_gv_camera_thread (void *user_data)
 			while (offset < payload) {
 				size_t data_size;
 
-				data_size = MIN (1500, payload - offset);
+				data_size = MIN (gv_packet_size - ARV_GVSP_PACKET_PROTOCOL_OVERHEAD,
+						 payload - offset);
 
 				packet_size = ARV_FAKE_GV_CAMERA_BUFFER_SIZE;
 				arv_gvsp_packet_new_data_block (image_buffer->frame_id, block_id,
diff --git a/src/arvfakestream.c b/src/arvfakestream.c
index 8f0116e..c86d25a 100644
--- a/src/arvfakestream.c
+++ b/src/arvfakestream.c
@@ -71,7 +71,7 @@ arv_fake_stream_thread (void *data)
 		arv_fake_camera_wait_for_next_frame (thread_data->camera);
 		buffer = arv_stream_pop_input_buffer (thread_data->stream);
 		if (buffer != NULL) {
-			arv_fake_camera_fill_buffer (thread_data->camera, buffer);
+			arv_fake_camera_fill_buffer (thread_data->camera, buffer, NULL);
 			if (buffer->status == ARV_BUFFER_STATUS_SUCCESS)
 				thread_data->n_completed_buffers++;
 			else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]