diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2012-03-08 18:08:18 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2012-03-08 18:08:18 +0100 |
commit | e56445a8a9dafabc81ca8715626f225b53262be5 (patch) | |
tree | 330da60f92237d95c213634be8006d0eacb58165 /src | |
parent | d856ae8dc3ef07e6aa568cdbc2f5a2a8296778f3 (diff) | |
download | uca-e56445a8a9dafabc81ca8715626f225b53262be5.tar.gz uca-e56445a8a9dafabc81ca8715626f225b53262be5.tar.bz2 uca-e56445a8a9dafabc81ca8715626f225b53262be5.tar.xz uca-e56445a8a9dafabc81ca8715626f225b53262be5.zip |
Fix mock camera
All unit tests pass again
Diffstat (limited to 'src')
-rw-r--r-- | src/cameras/uca-mock-camera.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/cameras/uca-mock-camera.c b/src/cameras/uca-mock-camera.c index 0040e25..e885475 100644 --- a/src/cameras/uca-mock-camera.c +++ b/src/cameras/uca-mock-camera.c @@ -31,6 +31,10 @@ enum { PROP_SENSOR_HORIZONTAL_BINNINGS, PROP_SENSOR_VERTICAL_BINNING, PROP_SENSOR_VERTICAL_BINNINGS, + PROP_ROI_X, + PROP_ROI_Y, + PROP_ROI_WIDTH, + PROP_ROI_HEIGHT, PROP_SENSOR_MAX_FRAME_RATE, PROP_HAS_STREAMING, PROP_HAS_CAMRAM_RECORDING, @@ -48,6 +52,10 @@ static const gchar *mock_overrideables[N_PROPERTIES] = { "sensor-horizontal-binnings", "sensor-vertical-binning", "sensor-vertical-binnings", + "roi-x", + "roi-y", + "roi-width", + "roi-height", "max-frame-rate", "has-streaming", "has-camram-recording" @@ -58,7 +66,7 @@ static GParamSpec *mock_properties[N_PROPERTIES - N_INTERFACE_PROPERTIES - 1] = struct _UcaMockCameraPrivate { guint width; guint height; - guint frame_rate; + gfloat frame_rate; gfloat max_frame_rate; guint16 *dummy_data; @@ -89,7 +97,7 @@ static gpointer mock_grab_func(gpointer data) UcaMockCameraPrivate *priv = UCA_MOCK_CAMERA_GET_PRIVATE(mock_camera); UcaCamera *camera = UCA_CAMERA(mock_camera); - const gulong sleep_time = G_USEC_PER_SEC / priv->frame_rate; + const gulong sleep_time = (gulong) G_USEC_PER_SEC / priv->frame_rate; while (priv->thread_running) { camera->grab_func(NULL, camera->user_data); @@ -145,7 +153,13 @@ static void uca_mock_camera_stop_recording(UcaCamera *camera, GError **error) static void uca_mock_camera_grab(UcaCamera *camera, gpointer *data, GError **error) { g_return_if_fail(UCA_IS_MOCK_CAMERA(camera)); + g_return_if_fail(data != NULL); + UcaMockCameraPrivate *priv = UCA_MOCK_CAMERA_GET_PRIVATE(camera); + + if (*data == NULL) + *data = g_malloc0(priv->width * priv->height); + g_memmove(*data, priv->dummy_data, priv->width * priv->height); } @@ -156,7 +170,7 @@ static void uca_mock_camera_set_property(GObject *object, guint property_id, con switch (property_id) { case PROP_FRAMERATE: - priv->frame_rate = g_value_get_uint(value); + priv->frame_rate = g_value_get_float(value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); @@ -190,6 +204,18 @@ static void uca_mock_camera_get_property(GObject *object, guint property_id, GVa case PROP_SENSOR_VERTICAL_BINNINGS: g_value_set_boxed(value, priv->binnings); break; + case PROP_ROI_X: + g_value_set_uint(value, 0); + break; + case PROP_ROI_Y: + g_value_set_uint(value, 0); + break; + case PROP_ROI_WIDTH: + g_value_set_uint(value, priv->width); + break; + case PROP_ROI_HEIGHT: + g_value_set_uint(value, priv->height); + break; case PROP_SENSOR_MAX_FRAME_RATE: g_value_set_float(value, priv->max_frame_rate); break; @@ -200,7 +226,7 @@ static void uca_mock_camera_get_property(GObject *object, guint property_id, GVa g_value_set_boolean(value, FALSE); break; case PROP_FRAMERATE: - g_value_set_uint(value, priv->frame_rate); + g_value_set_float(value, priv->frame_rate); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); @@ -239,10 +265,10 @@ static void uca_mock_camera_class_init(UcaMockCameraClass *klass) g_object_class_override_property(gobject_class, id, mock_overrideables[id-1]); mock_properties[PROP_FRAMERATE] = - g_param_spec_uint("frame-rate", + g_param_spec_float("frame-rate", "Frame rate", "Number of frames per second that are taken", - 1, 30, 25, + 1.0f, 100.0f, 100.0f, G_PARAM_READWRITE); for (guint id = N_INTERFACE_PROPERTIES + 1; id < N_PROPERTIES; id++) @@ -256,7 +282,7 @@ static void uca_mock_camera_init(UcaMockCamera *self) self->priv = UCA_MOCK_CAMERA_GET_PRIVATE(self); self->priv->width = 640; self->priv->height = 480; - self->priv->max_frame_rate = 100.0f; + self->priv->frame_rate = self->priv->max_frame_rate = 100.0f; self->priv->dummy_data = (guint16 *) g_malloc0(self->priv->width * self->priv->height); self->priv->grab_thread = NULL; |