summaryrefslogtreecommitdiffstats
path: root/src/uca-cam.h
blob: 0e07c29b14f0f92e3b92fcc28e78d017c1c3ae07 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* Copyright (C) 2011, 2012 Matthias Vogelgesang <matthias.vogelgesang@kit.edu>
   (Karlsruhe Institute of Technology)

   This library is free software; you can redistribute it and/or modify it
   under the terms of the GNU Lesser General Public License as published by the
   Free Software Foundation; either version 2.1 of the License, or (at your
   option) any later version.

   This library is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
   details.

   You should have received a copy of the GNU Lesser General Public License along
   with this library; if not, write to the Free Software Foundation, Inc., 51
   Franklin St, Fifth Floor, Boston, MA 02110, USA */

#ifndef __UNIFIED_CAMERA_ACCESS_CAM_H
#define __UNIFIED_CAMERA_ACCESS_CAM_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \file uca-cam.h
 * \brief Abstract camera model
 *
 * The uca_camera_priv_t structure represents a common interface for cameras regardless of
 * their connectivity. Each camera that adheres to this model must provide an
 * initialization function implementing uca_cam_init() that probes the device
 * and sets all function pointers to their respective implementations.
 */

enum uca_property_ids;

/*
 * --- non-virtual methods ----------------------------------------------------
 */
typedef uint32_t (*uca_cam_init) (struct uca_camera_priv **cam, struct uca_grabber_priv *grabber);

/**
 * Allocates memory for a new uca_camera_priv structure and initializes all fields to
 * sane values.
 *
 * \return Pointer to block of memory for a uca_camera_priv structure
 *
 * \note This is is a utility function used internally by drivers
 */
struct uca_camera_priv *uca_cam_new(void);

/**
 * Represents a camera abstraction, that concrete cameras must implement.
 */
typedef struct uca_camera_priv {
    /**
     * \see ufo_destroy()
     */
    uint32_t (*destroy) (struct uca_camera_priv *cam);

    /**
     * \see ufo_cam_set_property()
     */
    uint32_t (*set_property) (struct uca_camera_priv *cam, uca_property_ids property, void *data);

    /**
     * \see ufo_cam_get_property()
     */
    uint32_t (*get_property) (struct uca_camera_priv *cam, uca_property_ids property, void *data, size_t num);

    /**
     * \see ufo_cam_start_recording()
     */
    uint32_t (*start_recording) (struct uca_camera_priv *cam);

    /**
     * \see ufo_cam_stop_recording()
     */
    uint32_t (*stop_recording) (struct uca_camera_priv *cam);

    /**
     * \see ufo_cam_trigger()
     */
    uint32_t (*trigger) (struct uca_camera_priv *cam);

    /**
     * \see ufo_cam_register_callback()
     */
    uint32_t (*register_callback) (struct uca_camera_priv *cam, uca_cam_grab_callback callback, void *user);

    /**
     * \see ufo_cam_release_buffer()
     */
    uint32_t (*release_buffer) (struct uca_camera_priv *cam, void *buffer);

    /**
     * \see ufo_cam_grab()
     */
    uint32_t (*grab) (struct uca_camera_priv *cam, char *buffer, void *meta_data);

    /**
     * \see ufo_cam_readout()
     */
    uint32_t (*readout) (struct uca_camera_priv *cam);

    struct uca_grabber_priv *grabber;       /**< grabber associated with this camera */
    uca_cam_state           state;          /**< camera state handled in uca.c */
    uint32_t                frame_width;    /**< current frame width */
    uint32_t                frame_height;   /**< current frame height */
    uint64_t                current_frame;  /**< last grabbed frame number */

    uca_cam_grab_callback   callback;
    void                    *callback_user; /**< user data for callback */

    void                    *user;          /**< private user data to be used by the camera driver */
} uca_camera_priv_t;


#ifdef __cplusplus
}
#endif

#endif