summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cameras/dummy.c16
-rw-r--r--src/cameras/dummy.h5
-rw-r--r--src/cameras/ipe.c16
-rw-r--r--src/cameras/ipe.h5
-rw-r--r--src/cameras/pco.c24
-rw-r--r--src/cameras/pco.h5
-rw-r--r--src/cameras/pf.c18
-rw-r--r--src/cameras/pf.h5
-rw-r--r--src/grabbers/me4.c20
-rw-r--r--src/grabbers/me4.h4
-rw-r--r--src/uca-cam.c4
-rw-r--r--src/uca-cam.h32
-rw-r--r--src/uca-grabber.h26
-rw-r--r--src/uca.c26
-rw-r--r--src/uca.h87
-rw-r--r--test/control.c26
-rw-r--r--test/enum.c10
-rw-r--r--test/grab.c8
18 files changed, 161 insertions, 176 deletions
diff --git a/src/cameras/dummy.c b/src/cameras/dummy.c
index dd96688..d71940e 100644
--- a/src/cameras/dummy.c
+++ b/src/cameras/dummy.c
@@ -14,12 +14,12 @@ struct dummy_cam_t {
#define GET_DUMMY(uca) ((struct dummy_cam_t *)(uca->user))
#define set_void(p, type, value) { *((type *) p) = value; }
-static uint32_t uca_dummy_set_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data)
+static uint32_t uca_dummy_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data)
{
return UCA_NO_ERROR;
}
-static uint32_t uca_dummy_get_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data, size_t num)
+static uint32_t uca_dummy_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num)
{
switch (property) {
case UCA_PROP_NAME:
@@ -60,13 +60,13 @@ static uint32_t uca_dummy_get_property(struct uca_camera_t *cam, enum uca_proper
return UCA_NO_ERROR;
}
-uint32_t uca_dummy_start_recording(struct uca_camera_t *cam)
+uint32_t uca_dummy_start_recording(struct uca_camera *cam)
{
cam->current_frame = 0;
return UCA_NO_ERROR;
}
-uint32_t uca_dummy_stop_recording(struct uca_camera_t *cam)
+uint32_t uca_dummy_stop_recording(struct uca_camera *cam)
{
return UCA_NO_ERROR;
}
@@ -146,7 +146,7 @@ static void uca_dummy_print_number(struct dummy_cam_t *dummy, int number, int x,
}
}
-uint32_t uca_dummy_grab(struct uca_camera_t *cam, char *buffer)
+uint32_t uca_dummy_grab(struct uca_camera *cam, char *buffer)
{
struct dummy_cam_t *dummy = GET_DUMMY(cam);
dummy->buffer = buffer;
@@ -165,14 +165,14 @@ uint32_t uca_dummy_grab(struct uca_camera_t *cam, char *buffer)
return UCA_NO_ERROR;
}
-static uint32_t uca_dummy_destroy(struct uca_camera_t *cam)
+static uint32_t uca_dummy_destroy(struct uca_camera *cam)
{
return UCA_NO_ERROR;
}
-uint32_t uca_dummy_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
+uint32_t uca_dummy_init(struct uca_camera **cam, struct uca_grabber *grabber)
{
- struct uca_camera_t *uca = (struct uca_camera_t *) malloc(sizeof(struct uca_camera_t));
+ struct uca_camera *uca = (struct uca_camera *) malloc(sizeof(struct uca_camera));
uca->destroy = &uca_dummy_destroy;
uca->set_property = &uca_dummy_set_property;
diff --git a/src/cameras/dummy.h b/src/cameras/dummy.h
index 143bbd1..ebd2d48 100644
--- a/src/cameras/dummy.h
+++ b/src/cameras/dummy.h
@@ -1,9 +1,6 @@
#ifndef __UNIFIED_CAMERA_ACCESS_DUMMY_H
#define __UNIFIED_CAMERA_ACCESS_DUMMY_H
-struct uca_camera_t;
-struct uca_grabber_t;
-
-uint32_t uca_dummy_init(struct uca_camera_t **uca, struct uca_grabber_t *grabber);
+uint32_t uca_dummy_init(struct uca_camera **uca, struct uca_grabber *grabber);
#endif
diff --git a/src/cameras/ipe.c b/src/cameras/ipe.c
index 9f01767..4b3d021 100644
--- a/src/cameras/ipe.c
+++ b/src/cameras/ipe.c
@@ -14,12 +14,12 @@ static void uca_ipe_handle_error(const char *format, ...)
/* Do nothing, we just check errno. */
}
-static uint32_t uca_ipe_set_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data)
+static uint32_t uca_ipe_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data)
{
return UCA_NO_ERROR;
}
-static uint32_t uca_ipe_get_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data, size_t num)
+static uint32_t uca_ipe_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num)
{
pcilib_t *handle = GET_HANDLE(cam);
pcilib_register_value_t value = 0;
@@ -78,28 +78,28 @@ static uint32_t uca_ipe_get_property(struct uca_camera_t *cam, enum uca_property
return UCA_NO_ERROR;
}
-static uint32_t uca_ipe_start_recording(struct uca_camera_t *cam)
+static uint32_t uca_ipe_start_recording(struct uca_camera *cam)
{
return UCA_NO_ERROR;
}
-static uint32_t uca_ipe_stop_recording(struct uca_camera_t *cam)
+static uint32_t uca_ipe_stop_recording(struct uca_camera *cam)
{
return UCA_NO_ERROR;
}
-static uint32_t uca_ipe_grab(struct uca_camera_t *cam, char *buffer)
+static uint32_t uca_ipe_grab(struct uca_camera *cam, char *buffer)
{
return UCA_NO_ERROR;
}
-static uint32_t uca_ipe_destroy(struct uca_camera_t *cam)
+static uint32_t uca_ipe_destroy(struct uca_camera *cam)
{
pcilib_close(GET_HANDLE(cam));
return UCA_NO_ERROR;
}
-uint32_t uca_ipe_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
+uint32_t uca_ipe_init(struct uca_camera **cam, struct uca_grabber *grabber)
{
pcilib_model_t model = PCILIB_MODEL_DETECT;
pcilib_t *handle = pcilib_open("/dev/fpga0", model);
@@ -109,7 +109,7 @@ uint32_t uca_ipe_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
pcilib_set_error_handler(&uca_ipe_handle_error, &uca_ipe_handle_error);
model = pcilib_get_model(handle);
- struct uca_camera_t *uca = (struct uca_camera_t *) malloc(sizeof(struct uca_camera_t));
+ struct uca_camera *uca = (struct uca_camera *) malloc(sizeof(struct uca_camera));
/* Camera found, set function pointers... */
uca->destroy = &uca_ipe_destroy;
diff --git a/src/cameras/ipe.h b/src/cameras/ipe.h
index 15ebdea..4fc39bd 100644
--- a/src/cameras/ipe.h
+++ b/src/cameras/ipe.h
@@ -1,9 +1,6 @@
#ifndef __UNIFIED_CAMERA_ACCESS_IPE_H
#define __UNIFIED_CAMERA_ACCESS_IPE_H
-struct uca_camera_t;
-struct uca_grabber_t;
-
-uint32_t uca_ipe_init(struct uca_camera_t **uca, struct uca_grabber_t *grabber);
+uint32_t uca_ipe_init(struct uca_camera **uca, struct uca_grabber *grabber);
#endif
diff --git a/src/cameras/pco.c b/src/cameras/pco.c
index 0c13ca6..1ca16f4 100644
--- a/src/cameras/pco.c
+++ b/src/cameras/pco.c
@@ -12,7 +12,7 @@
#define set_void(p, type, value) { *((type *) p) = (type) value; }
-static uint32_t uca_pco_set_exposure(struct uca_camera_t *cam, uint32_t *exposure)
+static uint32_t uca_pco_set_exposure(struct uca_camera *cam, uint32_t *exposure)
{
uint32_t e, d;
if (pco_get_delay_exposure(GET_PCO(cam), &d, &e) != PCO_NOERROR)
@@ -22,7 +22,7 @@ static uint32_t uca_pco_set_exposure(struct uca_camera_t *cam, uint32_t *exposur
return UCA_NO_ERROR;
}
-static uint32_t uca_pco_set_delay(struct uca_camera_t *cam, uint32_t *delay)
+static uint32_t uca_pco_set_delay(struct uca_camera *cam, uint32_t *delay)
{
uint32_t e, d;
if (pco_get_delay_exposure(GET_PCO(cam), &d, &e) != PCO_NOERROR)
@@ -32,16 +32,16 @@ static uint32_t uca_pco_set_delay(struct uca_camera_t *cam, uint32_t *delay)
return UCA_NO_ERROR;
}
-static uint32_t uca_pco_destroy(struct uca_camera_t *cam)
+static uint32_t uca_pco_destroy(struct uca_camera *cam)
{
pco_set_rec_state(GET_PCO(cam), 0);
pco_destroy(GET_PCO(cam));
return UCA_NO_ERROR;
}
-static uint32_t uca_pco_set_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data)
+static uint32_t uca_pco_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data)
{
- struct uca_grabber_t *grabber = cam->grabber;
+ struct uca_grabber *grabber = cam->grabber;
switch (property) {
case UCA_PROP_WIDTH:
@@ -82,10 +82,10 @@ static uint32_t uca_pco_set_property(struct uca_camera_t *cam, enum uca_property
}
-static uint32_t uca_pco_get_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data, size_t num)
+static uint32_t uca_pco_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num)
{
struct pco_edge_t *pco = GET_PCO(cam);
- struct uca_grabber_t *grabber = cam->grabber;
+ struct uca_grabber *grabber = cam->grabber;
switch (property) {
case UCA_PROP_NAME:
@@ -195,7 +195,7 @@ static uint32_t uca_pco_get_property(struct uca_camera_t *cam, enum uca_property
return UCA_NO_ERROR;
}
-uint32_t uca_pco_start_recording(struct uca_camera_t *cam)
+uint32_t uca_pco_start_recording(struct uca_camera *cam)
{
struct pco_edge_t *pco = GET_PCO(cam);
if (pco_arm_camera(pco) != PCO_NOERROR)
@@ -205,14 +205,14 @@ uint32_t uca_pco_start_recording(struct uca_camera_t *cam)
return cam->grabber->acquire(cam->grabber, -1);
}
-uint32_t uca_pco_stop_recording(struct uca_camera_t *cam)
+uint32_t uca_pco_stop_recording(struct uca_camera *cam)
{
if (pco_set_rec_state(GET_PCO(cam), 0) != PCO_NOERROR)
return UCA_ERR_PROP_GENERAL;
return UCA_NO_ERROR;
}
-uint32_t uca_pco_grab(struct uca_camera_t *cam, char *buffer)
+uint32_t uca_pco_grab(struct uca_camera *cam, char *buffer)
{
uint16_t *frame;
uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame);
@@ -224,7 +224,7 @@ uint32_t uca_pco_grab(struct uca_camera_t *cam, char *buffer)
return UCA_NO_ERROR;
}
-uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
+uint32_t uca_pco_init(struct uca_camera **cam, struct uca_grabber *grabber)
{
if (grabber == NULL)
return UCA_ERR_CAM_NOT_FOUND;
@@ -239,7 +239,7 @@ uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
return UCA_ERR_CAM_NOT_FOUND;
}
- struct uca_camera_t *uca = (struct uca_camera_t *) malloc(sizeof(struct uca_camera_t));
+ struct uca_camera *uca = (struct uca_camera *) malloc(sizeof(struct uca_camera));
uca->user = pco;
uca->grabber = grabber;
uca->grabber->asynchronous = true;
diff --git a/src/cameras/pco.h b/src/cameras/pco.h
index 4025002..d8c2b07 100644
--- a/src/cameras/pco.h
+++ b/src/cameras/pco.h
@@ -1,9 +1,6 @@
#ifndef __UNIFIED_CAMERA_ACCESS_PCO_H
#define __UNIFIED_CAMERA_ACCESS_PCO_H
-struct uca_camera_t;
-struct uca_grabber_t;
-
-uint32_t uca_pco_init(struct uca_camera_t **uca, struct uca_grabber_t *grabber);
+uint32_t uca_pco_init(struct uca_camera **uca, struct uca_grabber *grabber);
#endif
diff --git a/src/cameras/pf.c b/src/cameras/pf.c
index 1ea3d3c..7f6ad0f 100644
--- a/src/cameras/pf.c
+++ b/src/cameras/pf.c
@@ -39,9 +39,9 @@ static struct uca_pf_map uca_to_pf[] = {
{ -1, NULL }
};
-static uint32_t uca_pf_set_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data)
+static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data)
{
- struct uca_grabber_t *grabber = cam->grabber;
+ struct uca_grabber *grabber = cam->grabber;
TOKEN t = INVALID_TOKEN;
int i = 0;
@@ -107,7 +107,7 @@ static uint32_t uca_pf_set_property(struct uca_camera_t *cam, enum uca_property_
}
-static uint32_t uca_pf_get_property(struct uca_camera_t *cam, enum uca_property_ids property, void *data, size_t num)
+static uint32_t uca_pf_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num)
{
TOKEN t; /* You gotta love developers who name types capitalized... */
PFValue value;
@@ -161,17 +161,17 @@ static uint32_t uca_pf_get_property(struct uca_camera_t *cam, enum uca_property_
return UCA_NO_ERROR;
}
-uint32_t uca_pf_start_recording(struct uca_camera_t *cam)
+uint32_t uca_pf_start_recording(struct uca_camera *cam)
{
return cam->grabber->acquire(cam->grabber, -1);
}
-uint32_t uca_pf_stop_recording(struct uca_camera_t *cam)
+uint32_t uca_pf_stop_recording(struct uca_camera *cam)
{
return UCA_NO_ERROR;
}
-uint32_t uca_pf_grab(struct uca_camera_t *cam, char *buffer)
+uint32_t uca_pf_grab(struct uca_camera *cam, char *buffer)
{
uint16_t *frame;
uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame);
@@ -182,13 +182,13 @@ uint32_t uca_pf_grab(struct uca_camera_t *cam, char *buffer)
return UCA_NO_ERROR;
}
-static uint32_t uca_pf_destroy(struct uca_camera_t *cam)
+static uint32_t uca_pf_destroy(struct uca_camera *cam)
{
pfDeviceClose(0);
return UCA_NO_ERROR;
}
-uint32_t uca_pf_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
+uint32_t uca_pf_init(struct uca_camera **cam, struct uca_grabber *grabber)
{
int num_ports;
if ((grabber == NULL) || (pfPortInit(&num_ports) < 0) || (pfDeviceOpen(0) < 0))
@@ -197,7 +197,7 @@ uint32_t uca_pf_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
/* We could check if a higher baud rate is supported, but... forget about
* it. We don't need high speed configuration. */
- struct uca_camera_t *uca = (struct uca_camera_t *) malloc(sizeof(struct uca_camera_t));
+ struct uca_camera *uca = (struct uca_camera *) malloc(sizeof(struct uca_camera));
uca->grabber = grabber;
uca->grabber->asynchronous = true;
diff --git a/src/cameras/pf.h b/src/cameras/pf.h
index c2cf7ac..d7bf85b 100644
--- a/src/cameras/pf.h
+++ b/src/cameras/pf.h
@@ -1,9 +1,6 @@
#ifndef __UNIFIED_CAMERA_ACCESS_PHOTON_H
#define __UNIFIED_CAMERA_ACCESS_PHOTON_H
-struct uca_camera_t;
-struct uca_grabber_t;
-
-uint32_t uca_pf_init(struct uca_camera_t **uca, struct uca_grabber_t *grabber);
+uint32_t uca_pf_init(struct uca_camera **uca, struct uca_grabber *grabber);
#endif
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index 23eed29..03a0a3c 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -43,7 +43,7 @@ static struct uca_sisofg_map_t uca_to_fg[] = {
#define GET_FG(grabber) (((struct fg_apc_data *) grabber->user)->fg)
#define GET_MEM(grabber) (((struct fg_apc_data *) grabber->user)->mem)
-uint32_t uca_me4_destroy(struct uca_grabber_t *grabber)
+uint32_t uca_me4_destroy(struct uca_grabber *grabber)
{
if (grabber != NULL) {
Fg_FreeMemEx(GET_FG(grabber), GET_MEM(grabber));
@@ -64,7 +64,7 @@ static struct uca_sisofg_map_t *uca_me4_find_property(enum uca_grabber_constants
return NULL;
}
-uint32_t uca_me4_set_property(struct uca_grabber_t *grabber, enum uca_grabber_constants property, void *data)
+uint32_t uca_me4_set_property(struct uca_grabber *grabber, enum uca_grabber_constants property, void *data)
{
struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property);
if (fg_prop == NULL)
@@ -82,7 +82,7 @@ uint32_t uca_me4_set_property(struct uca_grabber_t *grabber, enum uca_grabber_co
return Fg_setParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL;
}
-uint32_t uca_me4_get_property(struct uca_grabber_t *grabber, enum uca_grabber_constants property, void *data)
+uint32_t uca_me4_get_property(struct uca_grabber *grabber, enum uca_grabber_constants property, void *data)
{
struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property);
if (fg_prop == NULL)
@@ -92,7 +92,7 @@ uint32_t uca_me4_get_property(struct uca_grabber_t *grabber, enum uca_grabber_co
return Fg_getParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL;
}
-uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t pixel_size, uint32_t n_buffers)
+uint32_t uca_me4_alloc(struct uca_grabber *grabber, uint32_t pixel_size, uint32_t n_buffers)
{
if (GET_MEM(grabber) != NULL)
/* FIXME: invent better error code */
@@ -110,7 +110,7 @@ uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t pixel_size, uint3
return UCA_ERR_PROP_GENERAL;
}
-uint32_t uca_me4_acquire(struct uca_grabber_t *grabber, int32_t n_frames)
+uint32_t uca_me4_acquire(struct uca_grabber *grabber, int32_t n_frames)
{
if (GET_MEM(grabber) == NULL)
return UCA_ERR_GRABBER_NOMEM;
@@ -123,7 +123,7 @@ uint32_t uca_me4_acquire(struct uca_grabber_t *grabber, int32_t n_frames)
return UCA_ERR_GRABBER_ACQUIRE;
}
-uint32_t uca_me4_stop_acquire(struct uca_grabber_t *grabber)
+uint32_t uca_me4_stop_acquire(struct uca_grabber *grabber)
{
if (GET_MEM(grabber) != NULL)
if (Fg_stopAcquireEx(GET_FG(grabber), 0, GET_MEM(grabber), STOP_SYNC) != FG_OK)
@@ -131,7 +131,7 @@ uint32_t uca_me4_stop_acquire(struct uca_grabber_t *grabber)
return UCA_NO_ERROR;
}
-uint32_t uca_me4_grab(struct uca_grabber_t *grabber, void **buffer, uint32_t *frame_number)
+uint32_t uca_me4_grab(struct uca_grabber *grabber, void **buffer, uint32_t *frame_number)
{
int32_t last_frame;
if (grabber->asynchronous)
@@ -153,7 +153,7 @@ static int uca_me4_callback(frameindex_t frame, struct fg_apc_data *apc)
return 0;
}
-uint32_t uca_me4_register_callback(struct uca_grabber_t *grabber, uca_grabber_grab_callback cb)
+uint32_t uca_me4_register_callback(struct uca_grabber *grabber, uca_grabber_grab_callback cb)
{
if (grabber->callback == NULL) {
grabber->callback = cb;
@@ -175,13 +175,13 @@ uint32_t uca_me4_register_callback(struct uca_grabber_t *grabber, uca_grabber_gr
return UCA_NO_ERROR;
}
-uint32_t uca_me4_init(struct uca_grabber_t **grabber)
+uint32_t uca_me4_init(struct uca_grabber **grabber)
{
Fg_Struct *fg = Fg_Init("libFullAreaGray8.so", 0);
if (fg == NULL)
return UCA_ERR_GRABBER_NOT_FOUND;
- struct uca_grabber_t *uca = (struct uca_grabber_t *) malloc(sizeof(struct uca_grabber_t));
+ struct uca_grabber *uca = (struct uca_grabber *) malloc(sizeof(struct uca_grabber));
struct fg_apc_data *me4 = (struct fg_apc_data *) malloc(sizeof(struct fg_apc_data));
me4->fg = fg;
diff --git a/src/grabbers/me4.h b/src/grabbers/me4.h
index a7a7b3c..4021f6a 100644
--- a/src/grabbers/me4.h
+++ b/src/grabbers/me4.h
@@ -1,8 +1,6 @@
#ifndef __UNIFIED_CAMERA_ACCESS_ME4_H
#define __UNIFIED_CAMERA_ACCESS_ME4_H
-struct uca_grabber_t;
-
-uint32_t uca_me4_init(struct uca_grabber_t **grabber);
+uint32_t uca_me4_init(struct uca_grabber **grabber);
#endif
diff --git a/src/uca-cam.c b/src/uca-cam.c
index 7c351d1..eb76fad 100644
--- a/src/uca-cam.c
+++ b/src/uca-cam.c
@@ -4,7 +4,7 @@
#include "uca-cam.h"
#include "uca-grabber.h"
-uint32_t uca_cam_alloc(struct uca_camera_t *cam, uint32_t n_buffers)
+uint32_t uca_cam_alloc(struct uca_camera *cam, uint32_t n_buffers)
{
uint32_t bitdepth;
cam->get_property(cam, UCA_PROP_BITDEPTH, &bitdepth, 0);
@@ -14,7 +14,7 @@ uint32_t uca_cam_alloc(struct uca_camera_t *cam, uint32_t n_buffers)
return UCA_NO_ERROR;
}
-enum uca_cam_state uca_cam_get_state(struct uca_camera_t *cam)
+enum uca_cam_state uca_cam_get_state(struct uca_camera *cam)
{
return cam->state;
}
diff --git a/src/uca-cam.h b/src/uca-cam.h
index 5203f8f..822f011 100644
--- a/src/uca-cam.h
+++ b/src/uca-cam.h
@@ -17,10 +17,6 @@ extern "C" {
* and sets all function pointers to their respective implementations.
*/
-struct uca_camera_t;
-struct uca_grabber_t;
-struct uca_property_t;
-
enum uca_property_ids;
/**
@@ -33,7 +29,6 @@ enum uca_cam_state {
UCA_CAM_RECORDING, /**< Camera is currently recording */
};
-
/*
* --- non-virtual methods ----------------------------------------------------
*/
@@ -48,7 +43,7 @@ enum uca_cam_state {
*
* \param[in] n_buffers Number of sub-buffers with size frame_width*frame_height.
*/
-uint32_t uca_cam_alloc(struct uca_camera_t *cam, uint32_t n_buffers);
+uint32_t uca_cam_alloc(struct uca_camera *cam, uint32_t n_buffers);
/**
* Retrieve current state of the camera.
@@ -58,7 +53,7 @@ uint32_t uca_cam_alloc(struct uca_camera_t *cam, uint32_t n_buffers);
* \return A value from the uca_cam_state enum representing the current state of
* the camera.
*/
-enum uca_cam_state uca_cam_get_state(struct uca_camera_t *cam);
+enum uca_cam_state uca_cam_get_state(struct uca_camera *cam);
/*
@@ -79,7 +74,7 @@ enum uca_cam_state uca_cam_get_state(struct uca_camera_t *cam);
*
* \note This is a private function and should be called exclusively by uca_init().
*/
-typedef uint32_t (*uca_cam_init) (struct uca_camera_t **cam, struct uca_grabber_t *grabber);
+typedef uint32_t (*uca_cam_init) (struct uca_camera **cam, struct uca_grabber *grabber);
/**
* \brief Function pointer to free camera resources.
@@ -88,7 +83,7 @@ typedef uint32_t (*uca_cam_init) (struct uca_camera_t **cam, struct uca_grabber_
*
* \note This is a private function and should be called exclusively by uca_init().
*/
-typedef uint32_t (*uca_cam_destroy) (struct uca_camera_t *cam);
+typedef uint32_t (*uca_cam_destroy) (struct uca_camera *cam);
/**
* Function pointer to set a camera property.
@@ -102,7 +97,7 @@ typedef uint32_t (*uca_cam_destroy) (struct uca_camera_t *cam);
* \return UCA_ERR_PROP_INVALID if property is not supported on the camera or
* UCA_ERR_PROP_VALUE_OUT_OF_RANGE if value cannot be set.
*/
-typedef uint32_t (*uca_cam_set_property) (struct uca_camera_t *cam, enum uca_property_ids property, void *data);
+typedef uint32_t (*uca_cam_set_property) (struct uca_camera *cam, enum uca_property_ids property, void *data);
/**
* Function pointer to get a property.
@@ -118,7 +113,7 @@ typedef uint32_t (*uca_cam_set_property) (struct uca_camera_t *cam, enum uca_pro
*
* \return UCA_ERR_PROP_INVALID if property is not supported on the camera
*/
-typedef uint32_t (*uca_cam_get_property) (struct uca_camera_t *cam, enum uca_property_ids property, void *data, size_t num);
+typedef uint32_t (*uca_cam_get_property) (struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num);
/**
* Begin recording.
@@ -126,12 +121,12 @@ typedef uint32_t (*uca_cam_get_property) (struct uca_camera_t *cam, enum uca_pro
* Usually this also involves the frame acquisition of the frame grabber but is
* hidden by this function.
*/
-typedef uint32_t (*uca_cam_start_recording) (struct uca_camera_t *cam);
+typedef uint32_t (*uca_cam_start_recording) (struct uca_camera *cam);
/**
* Stop recording.
*/
-typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera_t *cam);
+typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera *cam);
/**
* \brief Grab one image from the camera
@@ -142,19 +137,19 @@ typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera_t *cam);
* \param[in] buffer Destination buffer
*
*/
-typedef uint32_t (*uca_cam_grab) (struct uca_camera_t *cam, char *buffer);
+typedef uint32_t (*uca_cam_grab) (struct uca_camera *cam, char *buffer);
/**
* Represents a camera abstraction, that concrete cameras must implement.
*/
-struct uca_camera_t {
+typedef struct uca_camera {
/**
* Points to the next available camera in a linked-list fashion.
*
* End of list is specified with next == NULL.
*/
- struct uca_camera_t *next;
+ struct uca_camera *next;
/* Function pointers to camera-specific methods */
/**
@@ -194,14 +189,15 @@ struct uca_camera_t {
*/
uca_cam_destroy destroy;
- struct uca_grabber_t *grabber; /**< grabber associated with this camera */
+ struct uca_grabber *grabber; /**< grabber associated with this camera */
enum uca_cam_state state; /**< camera state */
uint32_t frame_width; /**< current frame width */
uint32_t frame_height; /**< current frame height */
uint32_t current_frame; /**< last grabbed frame number */
void *user; /**< private user data to be used by the camera driver */
-};
+} uca_camera_t;
+
#ifdef __cplusplus
}
diff --git a/src/uca-grabber.h b/src/uca-grabber.h
index fdcd488..30fc9dd 100644
--- a/src/uca-grabber.h
+++ b/src/uca-grabber.h
@@ -41,12 +41,12 @@ enum uca_grabber_constants {
*
* \return UCA_ERR_INIT_NOT_FOUND if grabber is not found or could not be initialized
*/
-typedef uint32_t (*uca_grabber_init) (struct uca_grabber_t **grabber);
+typedef uint32_t (*uca_grabber_init) (struct uca_grabber **grabber);
/**
* Free frame grabber resouces.
*/
-typedef uint32_t (*uca_grabber_destroy) (struct uca_grabber_t *grabber);
+typedef uint32_t (*uca_grabber_destroy) (struct uca_grabber *grabber);
/**
* Set a frame grabber property.
@@ -56,7 +56,7 @@ typedef uint32_t (*uca_grabber_destroy) (struct uca_grabber_t *grabber);
* \return UCA_ERR_PROP_INVALID if property is not supported on the frame
* grabber or UCA_ERR_PROP_VALUE_OUT_OF_RANGE if value cannot be set.
*/
-typedef uint32_t (*uca_grabber_set_property) (struct uca_grabber_t *grabber, enum uca_grabber_constants prop, void *data);
+typedef uint32_t (*uca_grabber_set_property) (struct uca_grabber *grabber, enum uca_grabber_constants prop, void *data);
/**
* Get a frame grabber property.
@@ -65,14 +65,14 @@ typedef uint32_t (*uca_grabber_set_property) (struct uca_grabber_t *grabber, enu
*
* \return UCA_ERR_PROP_INVALID if property is not supported on the frame grabber
*/
-typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber_t *grabber, enum uca_grabber_constants prop, void *data);
+typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber *grabber, enum uca_grabber_constants prop, void *data);
/**
* Allocate buffers with current width, height and bitdepth.
*
* \warning Subsequent changes of width and height might corrupt memory.
*/
-typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber_t *grabber, uint32_t pixel_size, uint32_t n_buffers);
+typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber *grabber, uint32_t pixel_size, uint32_t n_buffers);
/**
* Begin acquiring frames.
@@ -81,12 +81,12 @@ typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber_t *grabber, uint32_t p
*
* \param[in] async Grab asynchronous if true
*/
-typedef uint32_t (*uca_grabber_acquire) (struct uca_grabber_t *grabber, int32_t n_frames);
+typedef uint32_t (*uca_grabber_acquire) (struct uca_grabber *grabber, int32_t n_frames);
/**
* Stop acquiring frames.
*/
-typedef uint32_t (*uca_grabber_stop_acquire) (struct uca_grabber_t *grabber);
+typedef uint32_t (*uca_grabber_stop_acquire) (struct uca_grabber *grabber);
/**
* Grab a frame.
@@ -97,7 +97,7 @@ typedef uint32_t (*uca_grabber_stop_acquire) (struct uca_grabber_t *grabber);
*
* \param[out] frame_number Number of the grabbed frame
*/
-typedef uint32_t (*uca_grabber_grab) (struct uca_grabber_t *grabber, void **buffer, uint32_t *frame_number);
+typedef uint32_t (*uca_grabber_grab) (struct uca_grabber *grabber, void **buffer, uint32_t *frame_number);
/**
* Function pointer to a grab callback.
@@ -119,7 +119,7 @@ typedef void (*uca_grabber_grab_callback) (uint32_t image_number, void *buffer);
*
* \param[in] cb Callback function for when a frame arrived
*/
-typedef uint32_t (*uca_grabber_register_callback) (struct uca_grabber_t *grabber, uca_grabber_grab_callback cb);
+typedef uint32_t (*uca_grabber_register_callback) (struct uca_grabber *grabber, uca_grabber_grab_callback cb);
/**
@@ -130,8 +130,8 @@ typedef uint32_t (*uca_grabber_register_callback) (struct uca_grabber_t *grabber
* uca_camera_t interface in order to keep certain duplicated properties in sync
* (e.g. image dimensions can be set on frame grabber and camera).
*/
-struct uca_grabber_t {
- struct uca_grabber_t *next;
+typedef struct uca_grabber {
+ struct uca_grabber *next;
/* Function pointers to grabber-specific methods */
uca_grabber_destroy destroy;
@@ -147,6 +147,8 @@ struct uca_grabber_t {
uca_grabber_grab_callback callback;
bool asynchronous;
void *user;
-};
+} uca_grabber_t;
+
+
#endif
diff --git a/src/uca.c b/src/uca.c
index a7a1ea6..cb76f78 100644
--- a/src/uca.c
+++ b/src/uca.c
@@ -43,7 +43,7 @@ const char *uca_unit_map[] = {
""
};
-static struct uca_property_t property_map[UCA_PROP_LAST+1] = {
+static struct uca_property property_map[UCA_PROP_LAST+1] = {
{ "General.Name", uca_na, uca_string, uca_read },
{ "Image.Width", uca_pixel, uca_uint32t, uca_readwrite },
{ "Image.Width.Min", uca_pixel, uca_uint32t, uca_read },
@@ -96,16 +96,16 @@ static pthread_mutex_t g_uca_init_lock = PTHREAD_MUTEX_INITIALIZER;
#define uca_unlock(lock)
#endif
-struct uca_t *g_uca = NULL;
+struct uca *g_uca = NULL;
-struct uca_t *uca_init(const char *config_filename)
+struct uca *uca_init(const char *config_filename)
{
uca_lock();
if (g_uca != NULL) {
uca_unlock();
return g_uca;
}
- g_uca = (struct uca_t *) malloc(sizeof(struct uca_t));
+ g_uca = (struct uca *) malloc(sizeof(struct uca));
g_uca->cameras = NULL;
uca_grabber_init grabber_inits[] = {
@@ -133,7 +133,7 @@ struct uca_t *uca_init(const char *config_filename)
/* Probe each frame grabber that is configured */
int i = 0;
- struct uca_grabber_t *grabber = NULL;
+ struct uca_grabber *grabber = NULL;
while (grabber_inits[i] != NULL) {
uca_grabber_init init = grabber_inits[i];
/* FIXME: we don't only want to take the first one */
@@ -152,11 +152,11 @@ struct uca_t *uca_init(const char *config_filename)
grabber->next = NULL;
i = 0;
- struct uca_camera_t *current = NULL;
+ struct uca_camera *current = NULL;
/* Probe each camera that is configured and append a found camera to the
* linked list. */
while (cam_inits[i] != NULL) {
- struct uca_camera_t *cam = NULL;
+ struct uca_camera *cam = NULL;
uca_cam_init init = cam_inits[i];
if (init(&cam, grabber) != UCA_ERR_CAM_NOT_FOUND) {
if (current == NULL)
@@ -180,11 +180,11 @@ struct uca_t *uca_init(const char *config_filename)
return g_uca;
}
-void uca_destroy(struct uca_t *uca)
+void uca_destroy(struct uca *u)
{
uca_lock();
- if (uca != NULL) {
- struct uca_camera_t *cam = uca->cameras, *tmp;
+ if (u != NULL) {
+ struct uca_camera *cam = u->cameras, *tmp;
while (cam != NULL) {
tmp = cam;
cam->destroy(cam);
@@ -192,7 +192,7 @@ void uca_destroy(struct uca_t *uca)
free(tmp);
}
- struct uca_grabber_t *grabber = uca->grabbers, *tmpg;
+ struct uca_grabber *grabber = u->grabbers, *tmpg;
while (grabber != NULL) {
tmpg = grabber;
grabber->destroy(grabber);
@@ -200,7 +200,7 @@ void uca_destroy(struct uca_t *uca)
free(grabber);
}
- free(uca);
+ free(u);
}
uca_unlock();
}
@@ -216,7 +216,7 @@ enum uca_property_ids uca_get_property_id(const char *property_name)
return UCA_ERR_PROP_INVALID;
}
-struct uca_property_t *uca_get_full_property(enum uca_property_ids property_id)
+struct uca_property *uca_get_full_property(enum uca_property_ids property_id)
{
if ((property_id >= 0) && (property_id < UCA_PROP_LAST))
return &property_map[property_id];
diff --git a/src/uca.h b/src/uca.h
index 1ae371a..bafcf50 100644
--- a/src/uca.h
+++ b/src/uca.h
@@ -63,10 +63,6 @@ extern "C" {
* pointers to access the camera accordingly.
*/
-struct uca_t;
-struct uca_camera_t;
-struct uca_property_t;
-
/* The property IDs must start with 0 and must be continuous. Whenever this
* library is released, the IDs must not change to guarantee binary compatibility! */
enum uca_property_ids {
@@ -120,39 +116,6 @@ enum uca_property_ids {
UCA_PROP_LAST
};
-/**
- * Initialize the unified camera access interface.
- *
- * \param[in] config_filename Configuration file in JSON format for cameras
- * relying on external calibration data. It is ignored when no JSON parser can
- * be found at compile time or config_filename is NULL.
- *
- * \return Pointer to a uca_t structure
- */
-struct uca_t *uca_init(const char *config_filename);
-
-/**
- * \brief Free resources of the unified camera access interface
- */
-void uca_destroy(struct uca_t *uca);
-
-/**
- * \brief Convert a property string to the corresponding ID
- */
-enum uca_property_ids uca_get_property_id(const char *property_name);
-
-/**
- * \brief Convert a property ID to the corresponding string
- */
-const char* uca_get_property_name(enum uca_property_ids property_id);
-
-/**
- * \brief Return the full property structure for a given ID
- */
-struct uca_property_t *uca_get_full_property(enum uca_property_ids property_id);
-
-
-
/* Possible timestamp modes for UCA_PROP_TIMESTAMP_MODE */
#define UCA_TIMESTAMP_ASCII 0x01
#define UCA_TIMESTAMP_BINARY 0x02
@@ -176,7 +139,7 @@ struct uca_property_t *uca_get_full_property(enum uca_property_ids property_id);
* frame grabbers. It basically consists of a human-readable name, a physical
* unit, a type and some access rights.
*/
-struct uca_property_t {
+typedef struct uca_property {
/**
* A human-readable string for this property.
*
@@ -229,7 +192,7 @@ struct uca_property_t {
uca_write = 0x02, /**< property can be written */
uca_readwrite = 0x01 | 0x02 /**< property can be read and written */
} access;
-};
+} uca_property_t;
extern const char *uca_unit_map[]; /**< maps unit numbers to corresponding strings */
@@ -253,12 +216,50 @@ enum uca_errors {
/**
* Keeps a list of cameras and grabbers.
*/
-struct uca_t {
- struct uca_camera_t *cameras;
+typedef struct uca {
+ struct uca_camera *cameras;
/* private */
- struct uca_grabber_t *grabbers;
-};
+ struct uca_grabber *grabbers;
+} uca_t;
+
+/**
+ * Initialize the unified camera access interface.
+ *
+ * \param[in] config_filename Configuration file in JSON format for cameras
+ * relying on external calibration data. It is ignored when no JSON parser can
+ * be found at compile time or config_filename is NULL.
+ *
+ * \return Pointer to a uca structure
+ *
+ * \note uca_init() is thread-safe if a Pthread-implementation is available.
+ */
+struct uca *uca_init(const char *config_filename);
+
+/**
+ * Free resources of the unified camera access interface
+ *
+ * \note uca_destroy() is thread-safe if a Pthread-implementation is available.
+ */
+void uca_destroy(struct uca *u);
+
+/**
+ * Convert a property string to the corresponding ID
+ */
+enum uca_property_ids uca_get_property_id(const char *property_name);
+
+/**
+ * Convert a property ID to the corresponding string
+ */
+const char* uca_get_property_name(enum uca_property_ids property_id);
+
+/**
+ * Return the full property structure for a given ID
+ */
+uca_property_t *uca_get_full_property(enum uca_property_ids property_id);
+
+
+
#ifdef __cplusplus
}
diff --git a/test/control.c b/test/control.c
index 98daffd..449c4ea 100644
--- a/test/control.c
+++ b/test/control.c
@@ -13,8 +13,8 @@ typedef struct {
int width;
int height;
int bits;
- struct uca_camera_t *cam;
- struct uca_t *uca;
+ struct uca_camera *cam;
+ struct uca *u;
} ThreadData ;
typedef struct {
@@ -65,14 +65,14 @@ static void destroy(GtkWidget *widget, gpointer data)
{
ThreadData *td = (ThreadData *) data;
td->running = FALSE;
- uca_destroy(td->uca);
+ uca_destroy(td->u);
gtk_main_quit();
}
void *grab_thread(void *args)
{
ThreadData *data = (ThreadData *) args;
- struct uca_camera_t *cam = data->cam;
+ struct uca_camera *cam = data->cam;
while (data->running) {
cam->grab(cam, (char *) data->buffer);
@@ -99,7 +99,7 @@ static void on_toolbutton_run_clicked(GtkWidget *widget, gpointer args)
data->cam->start_recording(data->cam);
if (!g_thread_create(grab_thread, data, FALSE, &error)) {
g_printerr("Failed to create thread: %s\n", error->message);
- uca_destroy(data->uca);
+ uca_destroy(data->u);
}
}
@@ -122,7 +122,7 @@ static void on_valuecell_edited(GtkCellRendererText *renderer, gchar *path, gcha
GtkTreeIter iter;
if (gtk_tree_model_get_iter(tree_model, &iter, tree_path)) {
- struct uca_camera_t *cam = value_data->thread_data->cam;
+ struct uca_camera *cam = value_data->thread_data->cam;
uint32_t prop_id;
gtk_tree_model_get(tree_model, &iter, COLUMN_UCA_ID, &prop_id, -1);
@@ -202,10 +202,10 @@ void find_recursively(GtkTreeStore *store, GtkTreeIter *root, GtkTreeIter *resul
find_recursively(store, &iter, result, tokens, depth+1);
}
-void fill_tree_store(GtkTreeStore *tree_store, struct uca_camera_t *cam)
+void fill_tree_store(GtkTreeStore *tree_store, struct uca_camera *cam)
{
GtkTreeIter iter, child;
- struct uca_property_t *property;
+ struct uca_property *property;
const size_t num_bytes = 256;
gchar *value_string = g_malloc(num_bytes);
guint8 value_8;
@@ -259,7 +259,7 @@ void value_cell_data_func(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkT
uint32_t prop_id;
gtk_tree_model_get(model, iter, COLUMN_UCA_ID, &prop_id, -1);
- struct uca_property_t *property = uca_get_full_property(prop_id);
+ struct uca_property *property = uca_get_full_property(prop_id);
if (property->access & uca_write) {
g_object_set(cell, "mode", GTK_CELL_RENDERER_MODE_EDITABLE, NULL);
g_object_set(GTK_CELL_RENDERER_TEXT(cell), "editable", TRUE, NULL);
@@ -274,14 +274,14 @@ void value_cell_data_func(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkT
int main(int argc, char *argv[])
{
- struct uca_t *uca = uca_init(NULL);
- if (uca == NULL) {
+ struct uca *u = uca_init(NULL);
+ if (u == NULL) {
g_print("Couldn't initialize frame grabber and/or cameras\n");
return 1;
}
int width, height, bits_per_sample;
- struct uca_camera_t *cam = uca->cameras;
+ struct uca_camera *cam = u->cameras;
cam->get_property(cam, UCA_PROP_WIDTH, &width, 0);
cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0);
cam->get_property(cam, UCA_PROP_BITDEPTH, &bits_per_sample, 0);
@@ -322,7 +322,7 @@ int main(int argc, char *argv[])
td.height = height;
td.bits = bits_per_sample;
td.cam = cam;
- td.uca = uca;
+ td.u = u;
td.running = FALSE;
g_signal_connect(window, "delete-event",
diff --git a/test/enum.c b/test/enum.c
index 88f226e..954b734 100644
--- a/test/enum.c
+++ b/test/enum.c
@@ -21,14 +21,14 @@ void print_level(int depth)
int main(int argc, char *argv[])
{
- struct uca_t *uca = uca_init(NULL);
- if (uca == NULL) {
+ struct uca *u = uca_init(NULL);
+ if (u == NULL) {
printf("Couldn't find a camera\n");
return 1;
}
/* take first camera */
- struct uca_camera_t *cam = uca->cameras;
+ struct uca_camera *cam = u->cameras;
const size_t num_bytes = 256;
char string_value[num_bytes];
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
while (cam != NULL) {
for (int i = 0; i < UCA_PROP_LAST; i++) {
- struct uca_property_t *prop = uca_get_full_property(i);
+ struct uca_property *prop = uca_get_full_property(i);
print_level(count_dots(prop->name));
printf("%s = ", prop->name);
switch (prop->type) {
@@ -68,6 +68,6 @@ int main(int argc, char *argv[])
cam = cam->next;
}
- uca_destroy(uca);
+ uca_destroy(u);
return 0;
}
diff --git a/test/grab.c b/test/grab.c
index 2994689..446a117 100644
--- a/test/grab.c
+++ b/test/grab.c
@@ -6,14 +6,14 @@
int main(int argc, char *argv[])
{
- struct uca_t *uca = uca_init(NULL);
- if (uca == NULL) {
+ struct uca *u = uca_init(NULL);
+ if (u == NULL) {
printf("Couldn't find a camera\n");
return 1;
}
/* take first camera */
- struct uca_camera_t *cam = uca->cameras;
+ struct uca_camera *cam = u->cameras;
uint32_t val = 1;
cam->set_property(cam, UCA_PROP_EXPOSURE, &val);
@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
cam->start_recording(cam);
cam->grab(cam, (char *) buffer);
cam->stop_recording(cam);
- uca_destroy(uca);
+ uca_destroy(u);
FILE *fp = fopen("out.raw", "wb");
fwrite(buffer, width*height, pixel_size, fp);