[aravis] fake: add a way to customize the test pattern function.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] fake: add a way to customize the test pattern function.
- Date: Fri, 25 Jun 2010 12:29:45 +0000 (UTC)
commit ad74a69fca6235abf2ebf1b8926141d97a88b3c0
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Fri Jun 25 14:29:14 2010 +0200
fake: add a way to customize the test pattern function.
docs/reference/aravis/aravis-sections.txt | 11 ++++++
src/arvfakecamera.c | 52 ++++++++++++++++++++++++++--
src/arvfakecamera.h | 6 +++
3 files changed, 65 insertions(+), 4 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index d410b32..f233139 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -516,6 +516,13 @@ arv_fake_camera_write_register
arv_fake_camera_wait_for_next_frame
arv_fake_camera_fill_buffer
arv_fake_camera_set_inet_address
+arv_fake_camera_get_acquisition_status
+arv_fake_camera_get_control_channel_privilege
+arv_fake_camera_get_heartbeat_timeout
+arv_fake_camera_get_payload
+arv_fake_camera_get_stream_address
+arv_fake_camera_set_control_channel_privilege
+arv_fake_camera_set_fill_pattern
arv_set_fake_camera_genicam_filename
arv_get_fake_camera_genicam_data
<SUBSECTION Standard>
@@ -559,6 +566,7 @@ ARV_FAKE_CAMERA_REGISTER_GAIN_RAW
ARV_FAKE_CAMERA_REGISTER_GAIN_MODE
ArvFakeCameraClass
ArvFakeCameraPrivate
+ArvFakeCameraFillPatern
</SECTION>
<SECTION>
@@ -767,6 +775,9 @@ ArvDebugLevel
<FILE>arvgvsp</FILE>
<TITLE>ArvGvsp</TITLE>
arv_gvsp_packet_debug
+arv_gvsp_packet_new_data_block
+arv_gvsp_packet_new_data_leader
+arv_gvsp_packet_new_data_trailer
<SUBSECTION Private>
ArvGvspPacket
ArvGvspPacketType
diff --git a/src/arvfakecamera.c b/src/arvfakecamera.c
index d7f3206..460e67f 100644
--- a/src/arvfakecamera.c
+++ b/src/arvfakecamera.c
@@ -47,6 +47,10 @@ struct _ArvFakeCameraPrivate {
guint32 frame_id;
double trigger_frequency;
+
+ GMutex *fill_pattern_mutex;
+ ArvFakeCameraFillPattern fill_pattern;
+ void *fill_pattern_data;
};
static const char *arv_fake_camera_genicam_filename = NULL;
@@ -156,6 +160,42 @@ arv_fake_camera_wait_for_next_frame (ArvFakeCamera *camera)
nanosleep (&sleep_time, NULL);
}
+static void
+arv_fake_camera_grey_diagonal_ramp (ArvBuffer *buffer, void *fill_pattern_data)
+{
+ guint32 x, y;
+ guint32 width;
+ guint32 height;
+
+ if (buffer == NULL)
+ return;
+
+ width = buffer->width;
+ height = buffer->height;
+
+ for (y = 0; y < height; y++)
+ for (x = 0; x < width; x++)
+ ((char *) buffer->data)[y * width + x] = (x + buffer->frame_id + y) % 255;
+}
+
+void
+arv_fake_camera_set_fill_pattern (ArvFakeCamera *camera,
+ ArvFakeCameraFillPattern fill_pattern,
+ void *fill_pattern_data)
+{
+ g_return_if_fail (ARV_IS_FAKE_CAMERA (camera));
+
+ g_mutex_lock (camera->priv->fill_pattern_mutex);
+ if (fill_pattern != NULL) {
+ camera->priv->fill_pattern = fill_pattern;
+ camera->priv->fill_pattern_data = fill_pattern_data;
+ } else {
+ camera->priv->fill_pattern = arv_fake_camera_grey_diagonal_ramp;
+ camera->priv->fill_pattern_data = NULL;
+ }
+ g_mutex_unlock (camera->priv->fill_pattern_mutex);
+}
+
void
arv_fake_camera_fill_buffer (ArvFakeCamera *camera, ArvBuffer *buffer)
{
@@ -164,7 +204,6 @@ arv_fake_camera_fill_buffer (ArvFakeCamera *camera, ArvBuffer *buffer)
guint32 height;
guint32 x_offset, y_offset;
size_t payload;
- guint32 x, y;
if (camera == NULL || buffer == NULL)
return;
@@ -189,9 +228,9 @@ arv_fake_camera_fill_buffer (ArvFakeCamera *camera, ArvBuffer *buffer)
buffer->frame_id = camera->priv->frame_id++;
buffer->pixel_format = _get_register (camera, ARV_FAKE_CAMERA_REGISTER_PIXEL_FORMAT);
- for (y = 0; y < height; y++)
- for (x = 0; x < width; x++)
- ((char *) buffer->data)[y * width + x] = (x + buffer->frame_id + y) % 255;
+ g_mutex_lock (camera->priv->fill_pattern_mutex);
+ camera->priv->fill_pattern (buffer, camera->priv->fill_pattern_data);
+ g_mutex_unlock (camera->priv->fill_pattern_mutex);
}
void
@@ -331,6 +370,10 @@ arv_fake_camera_new (const char *serial_number)
memory = g_malloc0 (ARV_FAKE_CAMERA_MEMORY_SIZE);
+ fake_camera->priv->fill_pattern_mutex = g_mutex_new ();
+ fake_camera->priv->fill_pattern = arv_fake_camera_grey_diagonal_ramp;
+ fake_camera->priv->fill_pattern_data = NULL;
+
fake_camera->priv->genicam_data = arv_get_fake_camera_genicam_data (&fake_camera->priv->genicam_data_size);
fake_camera->priv->memory = memory;
@@ -394,6 +437,7 @@ arv_fake_camera_finalize (GObject *object)
ArvFakeCamera *fake_camera = ARV_FAKE_CAMERA (object);
g_free (fake_camera->priv->memory);
+ g_mutex_free (fake_camera->priv->fill_pattern_mutex);
parent_class->finalize (object);
}
diff --git a/src/arvfakecamera.h b/src/arvfakecamera.h
index e458c56..47c4fbc 100644
--- a/src/arvfakecamera.h
+++ b/src/arvfakecamera.h
@@ -28,6 +28,8 @@
G_BEGIN_DECLS
+typedef void (*ArvFakeCameraFillPattern) (ArvBuffer *buffer, void *fill_pattern_data);
+
#define ARV_FAKE_CAMERA_MEMORY_SIZE 0x1000
/* To keep in sync with arv-fake-camera.xml */
@@ -117,6 +119,10 @@ guint32 arv_fake_camera_get_control_channel_privilege (ArvFakeCamera *camera);
void arv_fake_camera_set_control_channel_privilege (ArvFakeCamera *camera, guint32 privilege);
guint32 arv_fake_camera_get_heartbeat_timeout (ArvFakeCamera *camera);
+void arv_fake_camera_set_fill_pattern (ArvFakeCamera *camera,
+ ArvFakeCameraFillPattern fill_pattern,
+ void *fill_pattern_data);
+
void arv_set_fake_camera_genicam_filename (const char *filename);
const char * arv_get_fake_camera_genicam_data (size_t *size);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]