summaryrefslogtreecommitdiffstats
path: root/src/uca.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-28 11:09:43 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-28 11:09:43 +0100
commitf200da9c7915521f77c6c23e825181da73db474d (patch)
treee44d75bf6dc82284e7b089cc20b1a0e616e44356 /src/uca.c
parenta10b4d2abbb2aafbcb398f659975d673b0181e8c (diff)
downloaduca-f200da9c7915521f77c6c23e825181da73db474d.tar.gz
uca-f200da9c7915521f77c6c23e825181da73db474d.tar.bz2
uca-f200da9c7915521f77c6c23e825181da73db474d.tar.xz
uca-f200da9c7915521f77c6c23e825181da73db474d.zip
Add support for multiple cameras
Diffstat (limited to 'src/uca.c')
-rw-r--r--src/uca.c89
1 files changed, 51 insertions, 38 deletions
diff --git a/src/uca.c b/src/uca.c
index 73dd79e..0e9e184 100644
--- a/src/uca.c
+++ b/src/uca.c
@@ -19,6 +19,7 @@
struct uca_t *uca_init()
{
struct uca_t *uca = (struct uca_t *) malloc(sizeof(struct uca_t));
+ uca->cameras = NULL;
uca_cam_init inits[] = {
#ifdef HAVE_PCO_EDGE
@@ -32,58 +33,70 @@ struct uca_t *uca_init()
#endif
NULL };
- /* Set all function pointers to NULL and thus make the class abstract */
- uca->cam_set_property = NULL;
- uca->cam_get_property = NULL;
- uca->cam_alloc = NULL;
- uca->cam_acquire_image = NULL;
-
int i = 0;
+ struct uca_camera_t* current = NULL;
+
while (inits[i] != NULL) {
+ struct uca_camera_t *cam = NULL;
uca_cam_init init = inits[i];
- if (init(uca) != UCA_ERR_INIT_NOT_FOUND)
- return uca;
+ if (init(&cam) != UCA_ERR_INIT_NOT_FOUND) {
+ if (current == NULL)
+ uca->cameras = current = cam;
+ else {
+ current->next = cam;
+ current = cam;
+ }
+ current->next = NULL;
+ }
i++;
}
- /* No camera found then indicate error */
- free(uca);
- return NULL;
+ if (uca->cameras == NULL) {
+ free(uca);
+ return NULL;
+ }
+ return uca;
}
void uca_destroy(struct uca_t *uca)
{
if (uca != NULL) {
- uca->cam_destroy(uca);
+ struct uca_camera_t *current = uca->cameras, *tmp;
+ while (current != NULL) {
+ tmp = current;
+ current->destroy(current);
+ current = current->next;
+ free(tmp);
+ }
free(uca);
}
}
-static struct uca_property_t property_map[UCA_PROP_LAST] = {
- { "name", uca_na, uca_string },
- { "width", uca_pixel, uca_uint32t },
- { "width.min", uca_pixel, uca_uint32t },
- { "width.max", uca_pixel, uca_uint32t },
- { "height", uca_pixel, uca_uint32t },
- { "height.min", uca_pixel, uca_uint32t },
- { "height.max", uca_pixel, uca_uint32t },
- { "offset.x", uca_pixel, uca_uint32t },
- { "offset.y", uca_pixel, uca_uint32t },
- { "bit-depth", uca_pixel, uca_uint8t },
- { "exposure", uca_us, uca_uint32t },
- { "exposure.min", uca_ns, uca_uint32t },
- { "exposure.max", uca_ms, uca_uint32t },
- { "delay", uca_us, uca_uint32t },
- { "delay.min", uca_ns, uca_uint32t },
- { "delay.max", uca_ms, uca_uint32t },
- { "frame-rate", uca_na, uca_uint32t },
- { "trigger-mode", uca_na, uca_uint32t },
- { "timestamp-mode", uca_na, uca_uint32t },
- { "scan-mode", uca_na, uca_uint32t },
- { "interlace.sample-rate", uca_na, uca_uint32t },
+static struct uca_property_t property_map[UCA_PROP_LAST+1] = {
+ { "name", uca_na, uca_string },
+ { "width", uca_pixel, uca_uint32t },
+ { "width.min", uca_pixel, uca_uint32t },
+ { "width.max", uca_pixel, uca_uint32t },
+ { "height", uca_pixel, uca_uint32t },
+ { "height.min", uca_pixel, uca_uint32t },
+ { "height.max", uca_pixel, uca_uint32t },
+ { "offset.x", uca_pixel, uca_uint32t },
+ { "offset.y", uca_pixel, uca_uint32t },
+ { "bitdepth", uca_bits, uca_uint8t },
+ { "exposure", uca_us, uca_uint32t },
+ { "exposure.min", uca_ns, uca_uint32t },
+ { "exposure.max", uca_ms, uca_uint32t },
+ { "delay", uca_us, uca_uint32t },
+ { "delay.min", uca_ns, uca_uint32t },
+ { "delay.max", uca_ms, uca_uint32t },
+ { "framerate", uca_na, uca_uint32t },
+ { "triggermode", uca_na, uca_uint32t },
+ { "timestampmode", uca_na, uca_uint32t },
+ { "scan-mode", uca_na, uca_uint32t },
+ { "interlace.samplerate", uca_na, uca_uint32t },
{ "interlace.threshold.pixel", uca_na, uca_uint32t },
{ "interlace.threshold.row", uca_na, uca_uint32t },
- { "correction-mode", uca_na, uca_uint32t },
+ { "correctionmode", uca_na, uca_uint32t },
{ NULL, 0, 0 }
};
@@ -96,7 +109,7 @@ int32_t uca_get_property_id(const char *property_name)
return i;
i++;
}
- return UCA_PROP_INVALID;
+ return UCA_ERR_PROP_INVALID;
}
struct uca_property_t *uca_get_full_property(int32_t property_id)
@@ -108,6 +121,6 @@ struct uca_property_t *uca_get_full_property(int32_t property_id)
const char* uca_get_property_name(int32_t property_id)
{
- /* TODO: guard that thing */
- return property_map[property_id].name;
+ if ((property_id >= 0) && (property_id < UCA_PROP_LAST))
+ return property_map[property_id].name;
}