-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipc.h
More file actions
90 lines (57 loc) · 1.86 KB
/
ipc.h
File metadata and controls
90 lines (57 loc) · 1.86 KB
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
/*! @file ipc.h
* @brief Interprocess communication class
*/
#ifndef IPC_H_
#define IPC_H_
#include <sys/stat.h>
#include <sys/types.h>
#include "camera.h"
#include "image_processing.h"
#define BUFFER_SIZE (1024)
/*! @brief File permissions of the server socket file node. */
#define SERV_SOCKET_PERMISSIONS \
(S_IXUSR | S_IRUSR | S_IWUSR | \
S_IXGRP | S_IRGRP | S_IWGRP | \
S_IXOTH | S_IROTH | S_IWOTH)
#define INIT_EXPOSURE_TIME 10000
/* settings that can be changed over the web */
struct WEB_SETTINGS {
int exposure_time; // [us]
};
enum HTML_HEADER_TYPE {
HEADER_TEXT_PLAIN,
HEADER_IMAGE_BMP
};
class CIPC {
public:
CIPC(CCamera& camera);
~CIPC();
OSC_ERR Init();
const WEB_SETTINGS& WebSettings() const { return(m_web_settings); }
/*! @brief answer cgi requests from webapp */
OSC_ERR handleIpcRequests();
int img_count;
private:
void ProcessRequest(char* request);
void WriteHtmlHeader(HTML_HEADER_TYPE type, int content_length=0);
bool m_bHeader_written;
/* returns begin to header or NULL
* request will be set to next line */
char* ReadHeader(char ** request);
OSC_ERR ReadArgument(char ** pBuffer, char ** pKey, char ** pValue);
OSC_ERR WriteArgument(const char * pKey, const char * pValue);
OSC_ERR WriteArgument(const char * pKey, int value);
OSC_ERR WriteBMP(const IplImage* img);
int IpcWrite(const void* buf, size_t count); /* write to socket, returns > 0 on success */
int m_fd; //file handle
/*! @brief Strips whitespace from the beginning and the end of a string and returns the new beginning of the string. Be advised, that the original string gets mangled! */
char* strtrim(char* str);
CCamera& m_camera;
int m_socket_fd;
static const int m_buffer_count=1024;
char m_buffer[m_buffer_count];
bool m_bInit;
WEB_SETTINGS m_web_settings;
CImageProcessor m_img_process;
};
#endif // #ifndef IPC_H_