/** * @file o3000_private.h * @brief O-3000 Camera driver API (internal) * @author Patrick Brunner - brunner@stettbacher.ch * @author Patrick Roth - roth@stettbacher.ch * @version 1.1 * @date 2016-03-01 * @copyright 2012-2016 Stettbacher Signal Processing AG * * @remarks * *
* 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
* 
* */ #ifndef __O3000_PRIVATE_H #define __O3000_PRIVATE_H #include #include "o3000_portable.h" #include "image_header.h" #define TRUE 1 ///< TRUE value (not 0) #define FALSE 0 ///< FALSE value must be 0 /** * Maximum image size ever expected. * * @note The size must be a multiple of 512 bytes! */ #define MAX_IMAGE_SIZE (1280*964*2+IMAGE_HEADER_SIZE) /** * Image frame synchronization state */ enum image_frame_state_t { IMG_FRAME_STATE_NOSYNC = 0, ///< not synchronized (preamble not found) IMG_FRAME_STATE_SYNC, ///< synchronized (preamble found) }; /** * O-3000 session description * * Each session descripes a connection between the camera and the user application. * * @note These data are used internally and are not accessible from the user application. */ struct o3000_session_t { int id; ///< session ID libusb_context *libusb_ctx; ///< libusb context pointer struct libusb_device_handle *dev; ///< the USB device handler (a connection to this device is established) int running; ///< running flag: TRUE if driver is connected and at main-loop (function o3000_connect() is blocking) int cleanup_transfers; ///< TRUE if driver is cleaning up all USB transfers int disconnect_dev; ///< TRUE if the user wants to disconnect the USB device by software. This flag is set by o3000_disconnect(). int release_session; ///< TRUE indicates to release session when leaving main-loop (see function o3000_connect()). This flag is set by o3000_exit(). int vid; ///< USB vendor ID used for this session int pid; ///< USB product ID used for this session libusb_device **device_list; ///< USB device list with pid and vid defined above int num_device_list; ///< number of entries at device list int loglevel; ///< logging level (from @ref O3000_LOG_NONE to @ref O3000_LOG_DEBUG) void __stdcall (*xml_cb)(int id, char* buf, int len); ///< XML callback void __stdcall (*video_cb)(int id, unsigned char* buf, struct img_header_t* img_header); ///< video callback void __stdcall (*log_cb)(int id, char* msg); //< logging callback char *xml_in_buf; ///< buffer for inbound XML messages uint8_t *video_cache; ///< video data buffer int video_chunk_size; ///< chunk size of one video transfer in bytes uint8_t *frame_buf; ///< start of frame buffer, memory-adjacent to video cache unsigned int video_cache_size; ///< actual video cache size in bytes struct libusb_transfer **transfer_data; ///< generic USB transfer structures for incoming video data (dyn. allocated array of transfers) struct libusb_transfer *transfer_xml_in; ///< generic USB transfer structures for incoming XML messages enum image_frame_state_t frame_state; ///< current image frame synchronization state uint8_t *frame_start; ///< start address of image frame (in case if @ref IMG_FRAME_STATE_SYNC) int frame_rx_cnt; ///< image frame payload counter, image received if @ref frame_payload_cnt is more or equal @ref frame_size struct img_header_t *frame_img_header; ///< start address of current image header uint8_t *image_start; ///< start address of pixel data int frame_size; ///< image frame size (including image header) }; void __stdcall o3000_log(struct o3000_session_t *session, const int level, const char *fmt, ...); #endif // __O3000_PRIVATE_H