summaryrefslogtreecommitdiffstats
path: root/src/uca.c
blob: 7889fe2fc796fa453d36883feded9b2b2f3a6279 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdlib.h>

#include "uca.h"

#ifdef HAVE_PCO_EDGE
#include "cameras/uca_pco.h"
#endif

#ifdef HAVE_PHOTON_FOCUS
#include "cameras/uca_pf.h"
#endif

#ifdef HAVE_IPE_CAM
#include "cameras/uca_ipe.h"
#endif


struct uca_t *uca_init()
{
    struct uca_t *uca = (struct uca_t *) malloc(sizeof(struct uca_t));

    uca_cam_init inits[] = {
#ifdef HAVE_PCO_EDGE
        uca_pco_init,
#elif HAVE_PHOTON_FOCUS
        uca_pf_init,
#elif HAVE_IPE_CAM
        uca_ipe_init,
#endif
    NULL };

    int i = 0;
    while (inits[i] != NULL) {
        uca_cam_init init = inits[i];
        if (init(uca))
            return uca;
        i++;
    }

    /* No camera found then return nothing */
    free(uca);
    return NULL;
}

void uca_destroy(struct uca_t *uca)
{
    uca->cam_destroy(uca);
    free(uca);
}