summaryrefslogtreecommitdiffstats
path: root/src/uca-cam.h
blob: 5535dd0e7c52c1f59c63c731e059ce5642927de7 (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
/* 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 {
    /* virtual methods to be overridden by concrete cameras */
    uint32_t (*destroy) (struct uca_camera_priv *cam);
    uint32_t (*set_property) (struct uca_camera_priv *cam, uca_property_ids property, void *data);
    uint32_t (*get_property) (struct uca_camera_priv *cam, uca_property_ids property, void *data, size_t num);
    uint32_t (*start_recording) (struct uca_camera_priv *cam);
    uint32_t (*stop_recording) (struct uca_camera_priv *cam);
    uint32_t (*trigger) (struct uca_camera_priv *cam);
    uint32_t (*register_callback) (struct uca_camera_priv *cam, uca_cam_grab_callback callback, void *user);
    uint32_t (*release_buffer) (struct uca_camera_priv *cam, void *buffer);
    uint32_t (*grab) (struct uca_camera_priv *cam, char *buffer, void *meta_data);
    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