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
|
/**
* @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
*
* <PRE>
* 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
* </PRE>
*
*/
#ifndef __O3000_PRIVATE_H
#define __O3000_PRIVATE_H
#include <libusb-1.0/libusb.h>
#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
|