diff options
author | Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de> | 2011-03-18 10:42:11 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de> | 2011-03-18 10:42:11 +0100 |
commit | a95fb6dad12ef73b05e79198763465f418090e99 (patch) | |
tree | 08cc1f9d142c1352570958518dfb874aa1e841c7 /src | |
parent | 384d9c7e478ed9b6b64b050a4251475519fc9580 (diff) | |
download | uca-a95fb6dad12ef73b05e79198763465f418090e99.tar.gz uca-a95fb6dad12ef73b05e79198763465f418090e99.tar.bz2 uca-a95fb6dad12ef73b05e79198763465f418090e99.tar.xz uca-a95fb6dad12ef73b05e79198763465f418090e99.zip |
Add (possible) meta data transmission and integrate callback in pco and pf
Diffstat (limited to 'src')
-rw-r--r-- | src/cameras/dummy.c | 8 | ||||
-rw-r--r-- | src/cameras/ipe.c | 15 | ||||
-rw-r--r-- | src/cameras/pco.c | 13 | ||||
-rw-r--r-- | src/cameras/pf.c | 13 | ||||
-rw-r--r-- | src/grabbers/me4.c | 26 | ||||
-rw-r--r-- | src/uca-cam.h | 22 | ||||
-rw-r--r-- | src/uca-grabber.h | 17 |
7 files changed, 80 insertions, 34 deletions
diff --git a/src/cameras/dummy.c b/src/cameras/dummy.c index 226e476..5361301 100644 --- a/src/cameras/dummy.c +++ b/src/cameras/dummy.c @@ -139,7 +139,7 @@ static void *uca_dummy_grab_thread(void *arg) while (dc->thread_running) { uca_dummy_memcpy(cam, dc->buffer); gettimeofday(&start, NULL); - cam->callback(cam->current_frame, dc->buffer, cam->user_callback); + cam->callback(cam->current_frame, dc->buffer, NULL, cam->callback_user); gettimeofday(&stop, NULL); call_time = uca_dummy_time_diff(&start, &stop); @@ -253,7 +253,7 @@ uint32_t uca_dummy_register_callback(struct uca_camera *cam, uca_cam_grab_callba { if (cam->callback == NULL) { cam->callback = cb; - cam->user_callback = user; + cam->callback_user = user; } else return UCA_ERR_GRABBER_CALLBACK_ALREADY_REGISTERED; @@ -261,7 +261,7 @@ uint32_t uca_dummy_register_callback(struct uca_camera *cam, uca_cam_grab_callba return UCA_NO_ERROR; } -uint32_t uca_dummy_grab(struct uca_camera *cam, char *buffer) +uint32_t uca_dummy_grab(struct uca_camera *cam, char *buffer, void *meta_data) { if (cam->callback != NULL) return UCA_ERR_GRABBER_CALLBACK_ALREADY_REGISTERED; @@ -295,7 +295,7 @@ uint32_t uca_dummy_init(struct uca_camera **cam, struct uca_grabber *grabber) uca->current_frame = 0; uca->grabber = NULL; uca->callback = NULL; - uca->user_callback = NULL; + uca->callback_user = NULL; struct dummy_cam *dummy_cam = (struct dummy_cam *) malloc(sizeof(struct dummy_cam)); dummy_cam->bitdepth = 8; diff --git a/src/cameras/ipe.c b/src/cameras/ipe.c index 4b3d021..a9f1ff2 100644 --- a/src/cameras/ipe.c +++ b/src/cameras/ipe.c @@ -88,11 +88,21 @@ static uint32_t uca_ipe_stop_recording(struct uca_camera *cam) return UCA_NO_ERROR; } -static uint32_t uca_ipe_grab(struct uca_camera *cam, char *buffer) +static uint32_t uca_ipe_grab(struct uca_camera *cam, char *buffer, void *meta_data) { return UCA_NO_ERROR; } +static uint32_t uca_ipe_register_callback(struct uca_camera *cam, uca_cam_grab_callback cb, void *user) +{ + if (cam->callback == NULL) { + cam->callback = cb; + cam->callback_user = user; + return UCA_NO_ERROR; + } + return UCA_ERR_GRABBER_CALLBACK_ALREADY_REGISTERED; +} + static uint32_t uca_ipe_destroy(struct uca_camera *cam) { pcilib_close(GET_HANDLE(cam)); @@ -118,7 +128,10 @@ uint32_t uca_ipe_init(struct uca_camera **cam, struct uca_grabber *grabber) uca->start_recording = &uca_ipe_start_recording; uca->stop_recording = &uca_ipe_stop_recording; uca->grab = &uca_ipe_grab; + uca->register_callback = &uca_ipe_register_callback; + uca->callback = NULL; + uca_>callback_user = NULL; uca->state = UCA_CAM_CONFIGURABLE; uca->user = handle; *cam = uca; diff --git a/src/cameras/pco.c b/src/cameras/pco.c index 1ca16f4..59c689d 100644 --- a/src/cameras/pco.c +++ b/src/cameras/pco.c @@ -212,7 +212,7 @@ uint32_t uca_pco_stop_recording(struct uca_camera *cam) return UCA_NO_ERROR; } -uint32_t uca_pco_grab(struct uca_camera *cam, char *buffer) +uint32_t uca_pco_grab(struct uca_camera *cam, char *buffer, void *meta_data) { uint16_t *frame; uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame); @@ -224,6 +224,17 @@ uint32_t uca_pco_grab(struct uca_camera *cam, char *buffer) return UCA_NO_ERROR; } +uint32_t uca_pco_register_callback(struct uca_camera *cam, uca_cam_grab_callback callback, void *user) +{ + if (cam->callback == NULL) { + cam->callback = callback; + cam->callback_user = user; + cam->grabber->register_callback(cam->grabber, callback, NULL, user); + return UCA_NO_ERROR; + } + return UCA_ERR_GRABBER_CALLBACK_ALREADY_REGISTERED; +} + uint32_t uca_pco_init(struct uca_camera **cam, struct uca_grabber *grabber) { if (grabber == NULL) diff --git a/src/cameras/pf.c b/src/cameras/pf.c index 7f6ad0f..ab6a490 100644 --- a/src/cameras/pf.c +++ b/src/cameras/pf.c @@ -171,7 +171,7 @@ uint32_t uca_pf_stop_recording(struct uca_camera *cam) return UCA_NO_ERROR; } -uint32_t uca_pf_grab(struct uca_camera *cam, char *buffer) +uint32_t uca_pf_grab(struct uca_camera *cam, char *buffer, void *metadata) { uint16_t *frame; uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame); @@ -182,6 +182,17 @@ uint32_t uca_pf_grab(struct uca_camera *cam, char *buffer) return UCA_NO_ERROR; } +uint32_t uca_pf_register_callback(struct uca_camera *cam, uca_cam_grab_callback callback, void *user) +{ + if (cam->callback == NULL) { + cam->callback = callback; + cam->callback_user = user; + cam->grabber->register_callback(cam->grabber, callback, NULL, user); + return UCA_NO_ERROR; + } + return UCA_ERR_GRABBER_CALLBACK_ALREADY_REGISTERED; +} + static uint32_t uca_pf_destroy(struct uca_camera *cam) { pfDeviceClose(0); diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c index 03a0a3c..8868deb 100644 --- a/src/grabbers/me4.c +++ b/src/grabbers/me4.c @@ -9,9 +9,13 @@ #include "uca-grabber.h" struct fg_apc_data { - Fg_Struct *fg; - dma_mem *mem; - uca_grabber_grab_callback cb; + Fg_Struct *fg; + dma_mem *mem; + + /* End-user related callback variables */ + uca_cam_grab_callback callback; + void *meta_data; + void *user; }; struct uca_sisofg_map_t { @@ -149,15 +153,19 @@ uint32_t uca_me4_grab(struct uca_grabber *grabber, void **buffer, uint32_t *fram static int uca_me4_callback(frameindex_t frame, struct fg_apc_data *apc) { - apc->cb(frame, Fg_getImagePtr(apc->fg, frame, PORT_A)); + apc->callback(frame, Fg_getImagePtr(apc->fg, frame, PORT_A), apc->meta_data, apc->user); return 0; } -uint32_t uca_me4_register_callback(struct uca_grabber *grabber, uca_grabber_grab_callback cb) +uint32_t uca_me4_register_callback(struct uca_grabber *grabber, uca_cam_grab_callback callback, void *meta_data, void *user) { if (grabber->callback == NULL) { - grabber->callback = cb; - ((struct fg_apc_data *) grabber->user)->cb = cb; + grabber->callback = callback; + + struct fg_apc_data *apc_data = (struct fg_apc_data *) grabber->user; + apc_data->callback = callback; + apc_data->meta_data = meta_data; + apc_data->user = user; struct FgApcControl ctrl; ctrl.version = 0; @@ -186,7 +194,9 @@ uint32_t uca_me4_init(struct uca_grabber **grabber) me4->fg = fg; me4->mem = NULL; - me4->cb = NULL; + me4->callback = NULL; + me4->meta_data = NULL; + me4->user = NULL; uca->user = me4; uca->destroy = &uca_me4_destroy; diff --git a/src/uca-cam.h b/src/uca-cam.h index 4ccb07e..ec84c27 100644 --- a/src/uca-cam.h +++ b/src/uca-cam.h @@ -138,9 +138,14 @@ typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera *cam); * * \param[in] buffer Image data * + * \param[in] meta_data Meta data provided by the camera specifying per-frame + * data. + * * \param[in] user User data registered in uca_cam_register_callback() + * + * \note The meta data parameter is not yet specified but just a place holder. */ -typedef void (*uca_cam_grab_callback) (uint32_t image_number, void *buffer, void *user); +typedef void (*uca_cam_grab_callback) (uint32_t image_number, void *buffer, void *meta_data, void *user); /** * Register callback for given frame grabber. To actually start receiving @@ -148,11 +153,11 @@ typedef void (*uca_cam_grab_callback) (uint32_t image_number, void *buffer, void * * \param[in] grabber The grabber for which the callback should be installed * - * \param[in] cb Callback function for when a frame arrived + * \param[in] callback Callback function for when a frame arrived * * \param[in] user User data that is passed to the callback function */ -typedef uint32_t (*uca_cam_register_callback) (struct uca_camera *cam, uca_cam_grab_callback cb, void *user); +typedef uint32_t (*uca_cam_register_callback) (struct uca_camera *cam, uca_cam_grab_callback callback, void *user); /** * \brief Grab one image from the camera @@ -162,8 +167,13 @@ typedef uint32_t (*uca_cam_register_callback) (struct uca_camera *cam, uca_cam_g * * \param[in] buffer Destination buffer * + * \param[in] meta_data Meta data provided by the camera specifying per-frame + * data. + * + * \note The meta data parameter is not yet specified but just a place holder. + * */ -typedef uint32_t (*uca_cam_grab) (struct uca_camera *cam, char *buffer); +typedef uint32_t (*uca_cam_grab) (struct uca_camera *cam, char *buffer, void *meta_data); /** @@ -230,9 +240,9 @@ typedef struct uca_camera { uint32_t current_frame; /**< last grabbed frame number */ uca_cam_grab_callback callback; - void *user_callback; /**< user data for callback */ + void *callback_user; /**< user data for callback */ - void *user; /**< private user data to be used by the camera driver */ + void *user; /**< private user data to be used by the camera driver */ } uca_camera_t; diff --git a/src/uca-grabber.h b/src/uca-grabber.h index 30fc9dd..b7a8736 100644 --- a/src/uca-grabber.h +++ b/src/uca-grabber.h @@ -2,6 +2,7 @@ #define __UNIFIED_CAMERA_ACCESS_GRABBER_H #include <stdbool.h> +#include "uca-cam.h" /** * \file uca-grabber.h @@ -32,6 +33,7 @@ enum uca_grabber_constants { UCA_TRIGGER_FREERUN }; + /* * --- virtual methods -------------------------------------------------------- */ @@ -99,17 +101,6 @@ typedef uint32_t (*uca_grabber_stop_acquire) (struct uca_grabber *grabber); */ typedef uint32_t (*uca_grabber_grab) (struct uca_grabber *grabber, void **buffer, uint32_t *frame_number); -/** - * Function pointer to a grab callback. - * - * Register such a callback function with uca_grabber_register_callback() to - * receive data as soon as it is delivered. - * - * \param[in] image_number Current frame number - * - * \param[in] buffer Image data - */ -typedef void (*uca_grabber_grab_callback) (uint32_t image_number, void *buffer); /** * Register callback for given frame grabber. To actually start receiving @@ -119,7 +110,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 *grabber, uca_grabber_grab_callback cb); +typedef uint32_t (*uca_grabber_register_callback) (struct uca_grabber *grabber, uca_cam_grab_callback cb, void *meta_data, void *user); /** @@ -144,7 +135,7 @@ typedef struct uca_grabber { uca_grabber_register_callback register_callback; /* Private */ - uca_grabber_grab_callback callback; + uca_cam_grab_callback callback; bool asynchronous; void *user; } uca_grabber_t; |