wcWebCamClient lib  v0.8.2
wcwebcamclient.h
Go to the documentation of this file.
1 
4 #ifndef WCWEBCAMCLIENT_H
5 #define WCWEBCAMCLIENT_H
6 
7 #define COMMON_FUNC_ONLY
8 #ifdef COMMON_FUNC_ONLY
9 #include "wcCommonCallbacks.h"
10 #else
11 #include "wcCallbacks.h"
12 #endif
13 
14 #if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
15 #define __WINDOWS__
16 #endif
17 
18 #ifdef _ANDROID_COMPILER_
19 #define DLLEXPORT
20 #else
21 #ifdef DLL_BUILD
22 #if defined(_MSC_VER)
23  // Microsoft
24  #define DLLEXPORT __declspec(dllexport)
25 #elif defined(__GNUC__)
26  // GCC
27  #ifdef __WINDOWS__
28  #define DLLEXPORT __attribute__ ((dllexport))
29  #else
30  #define DLLEXPORT __attribute__ ((visibility ("default")))
31  #endif
32 #endif
33 #else
34 #ifdef __cplusplus
35 #include <cstddef>
36 #endif
37 #if defined(_MSC_VER)
38  // Microsoft
39  #define DLLEXPORT __declspec(dllimport)
40 #elif defined(__GNUC__)
41  // GCC
42  #define DLLEXPORT
43 #endif
44 #endif
45 #endif
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
56 
59 typedef int wcStateVal;
60 
62 
65 typedef int wcRCode;
66 
68 const wcRCode WC_TRUE = 1;
69 
71 const wcRCode WC_FALSE = 0;
72 
74 const wcRCode WC_OK = 0;
75 
78 
80 const wcRCode WC_BAD_PARAM = -2;
81 
83 const wcRCode WC_BAD_VALUE = -3;
84 
87 
90 
93 
99 typedef int wcHandle;
100 
103 
105 typedef uint32_t wcTaskClass;
106 
116 const wcTaskClass WC_ALL_TASKS = 0xffffffff;
117 
119 const uint16_t WC_STREAM_FRAME_HEADER_SIZE = sizeof(uint16_t) + sizeof(uint32_t);
121 const uint16_t WC_FRAME_START_SEQ = 0xaaaa;
122 
128 #ifdef _MSC_VER
129 __pragma( pack(push, 1) )
130 #endif
131 
133 typedef enum wcCallback {
134  /* maintaining block */
143  /* streams block */
148  /* data blobs block */
152  /* JSON block */
163 #ifdef __GNUC__
164 __attribute__((__packed__))
165 #endif
173 typedef enum wcStateId {
176  wcstError = 2,
177  wcstLog = 3,
183  wcstMsgs = 9,
188  wcstSID = 13,
190  wcstProxy = 15,
196  wcstProxyPwrd = 21
197 }
198 #ifdef __GNUC__
199 __attribute__((__packed__))
200 #endif
202 
203 typedef enum wcTaskStateId {
208 }
209 #ifdef __GNUC__
210 __attribute__((__packed__))
211 #endif
215 #ifdef _MSC_VER
216 __pragma( pack(pop))
217 #endif
218 
226 typedef void (*EmptyNotifyLibFunc) (wcHandle client);
231 typedef void (*NotifyEventLibFunc) (wcHandle client, void * data);
236 typedef void (*TaskNotifyLibFunc) (wcHandle client, wcTask tsk);
241 typedef void (*ConnNotifyEventLibFunc) (wcHandle client, int state);
246 typedef void (*CStringNotifyLibFunc) (wcHandle client, const char * value);
252 typedef void (*DataNotifyEventLibFunc) (wcHandle client, wcTask tsk, void * strm);
259 typedef void (*DataAltNotifyEventLibFunc) (wcHandle client, wcTask tsk, void* data, size_t sz);
265 typedef void (*JSONStrNotifyEventLibFunc) (wcHandle client, wcTask tsk, const char * jsonStr);
266 
267 #ifndef COMMON_FUNC_ONLY
273 typedef void (*cJSONNotifyEventLibFunc) (wcHandle client, wcTask tsk, const cJSON * jsonObj);;
278 typedef void (*StringNotifyLibFunc) (wcHandle client, const std::string& value);
284 typedef void (*JSONNotifyEventLibFunc) (wcHandle client, wcTask tsk, wcJSON& jsonObj);
285 #endif
292 
297 void DLLEXPORT wcGetLibVersion(uint8_t * vmajor, uint8_t * vminor, uint16_t * vrev);
304 
311 
318 wcRCode DLLEXPORT wcClientStart(wcHandle client);
320 
329 wcRCode DLLEXPORT wcClientAuth(wcHandle client, const char * aLogin, const char * aPwrd);
331 
338 wcRCode DLLEXPORT wcClientProceed(wcHandle client);
340 
349 
357 
363 wcRCode DLLEXPORT wcClientDestroy(wcHandle client);
371 
394 wcRCode DLLEXPORT wcClientInvalidateState(wcHandle client, wcStateId aStateId);
396 
419 wcRCode DLLEXPORT wcClientGetIntState(wcHandle client, wcStateId aStateId, int * aStateVal);
421 
439 wcRCode DLLEXPORT wcClientGetBoolState(wcHandle client, wcStateId aStateId);
441 
459 wcRCode DLLEXPORT wcClientSetBoolState(wcHandle client, wcStateId aStateId, wcStateVal aStateVal);
461 
493 wcRCode DLLEXPORT wcClientGetStrValue(wcHandle client, wcStateId aStateId, char ** aStateVal);
495 
519 wcRCode DLLEXPORT wcClientGetStrNValue(wcHandle client, wcStateId aStateId, uint32_t sz, char * aStateVal);
521 
551 wcRCode DLLEXPORT wcClientSetStrValue(wcHandle client, wcStateId aStateId, const char * aStateVal);
559 
572 
587 wcRCode DLLEXPORT wcSetTaskCallback(wcHandle client, wcCallback callbackId, TaskNotifyLibFunc func);
589 
598 
610 #ifndef COMMON_FUNC_ONLY
612 
614 wcRCode DLLEXPORT wcSetStringCallback(wcHandle client, wcCallback callbackId, StringNotifyLibFunc func);
615 #endif
617 
628 #ifndef COMMON_FUNC_ONLY
630 
632 wcRCode DLLEXPORT wcSetDataCallback(wcHandle client, wcCallback callbackId, DataNotifyEventLibFunc func);
633 #endif
635 
652 #ifndef COMMON_FUNC_ONLY
654 
656 wcRCode DLLEXPORT wcSetcJSONCallback(wcHandle client, wcCallback callbackId, cJSONNotifyEventLibFunc func);
658 
660 wcRCode DLLEXPORT wcSetJSONCallback(wcHandle client, wcCallback callbackId, JSONNotifyEventLibFunc func);
661 #endif
669 
677 wcRCode DLLEXPORT wcGetConfig(wcHandle client, void * data);
679 
687 wcRCode DLLEXPORT wcSetConfig(wcHandle client, const char * cfg);
689 
698 wcRCode DLLEXPORT wcDeleteRecords(wcHandle client, const char * indices, void * data);
700 
709 wcRCode DLLEXPORT wcSendMsg(wcHandle client, const char * msg, void * data);
710 #ifndef COMMON_FUNC_ONLY
712 
721 wcRCode DLLEXPORT wcSendMsg_cJson(wcHandle client, cJSON * msg, void * data);
722 #endif
724 
733 wcRCode DLLEXPORT wcRequestRecord(wcHandle client, int rid, void * data);
735 
744 wcRCode DLLEXPORT wcRequestRecordMeta(wcHandle client, int rid, void * data);
746 
757 wcRCode DLLEXPORT wcSaveRecord(wcHandle client, const void * aBuf, size_t sz, const char * meta, void * data);
759 
769 wcRCode DLLEXPORT wcLaunchOutStream(wcHandle client, const char * subProtocol, int delta, void * data);
771 
780 wcRCode DLLEXPORT wcLaunchInStream(wcHandle client, const char * deviceName, void * data);
788 
796 wcRCode DLLEXPORT wcClientGetFrameID(wcHandle client, long * id);
798 
807 
816 
826 wcRCode DLLEXPORT wcClientFramePushData(wcHandle client, const void * data, size_t len);
828 
859 wcRCode DLLEXPORT wcClientFrameGetData(wcHandle client, void ** data, size_t * len);
867 
878 wcRCode DLLEXPORT wcTaskGetClass(wcTask task, wcTaskClass * id);
880 
887 wcRCode DLLEXPORT wcTaskGetUserData(wcTask task, void ** data);
889 
897 wcRCode DLLEXPORT wcTaskSetUserData(wcTask task, void * data);
899 
905 wcRCode DLLEXPORT wcTaskLock(wcTask task);
907 
913 wcRCode DLLEXPORT wcTaskUnLock(wcTask task);
915 
942 wcRCode DLLEXPORT wcTaskGetStrValue(wcTask task, wcTaskStateId aStateId, char ** aStateVal);
944 
968 wcRCode DLLEXPORT wcTaskGetStrNValue(wcTask task, wcTaskStateId aStateId, uint32_t sz, char * aStateVal);
976 
1020 wcRCode DLLEXPORT wcInTaskPopFrame(wcTask task, void ** data, size_t * len);
1024 #ifdef __cplusplus
1025 }
1026 #endif
1027 
1058 #endif // WCWEBCAMCLIENT_H
void(* JSONStrNotifyEventLibFunc)(wcHandle client, wcTask tsk, const char *jsonStr)
Notification callback that task is completed and returns a C-style string with a response in JSON for...
Definition: wcwebcamclient.h:265
wcRCode DLLEXPORT wcSetTaskCallback(wcHandle client, wcCallback callbackId, TaskNotifyLibFunc func)
Set specified task notify callback for client.
void(* NotifyEventLibFunc)(wcHandle client, void *data)
Notification callback with an additional data.
Definition: wcwebcamclient.h:231
wcRCode DLLEXPORT wcSetNotifyCallback(wcHandle client, wcCallback callbackId, NotifyEventLibFunc func)
Set specified notify callback for client.
void(* DataNotifyEventLibFunc)(wcHandle client, wcTask tsk, void *strm)
Notification callback that returned a wcCustomStream.
Definition: wcwebcamclient.h:252
wcRCode DLLEXPORT wcSetCStringCallback(wcHandle client, wcCallback callbackId, CStringNotifyLibFunc func)
Set specified notify callback for client to handling the C-style string values.
void(* CStringNotifyLibFunc)(wcHandle client, const char *value)
Notification callback that returned a C-style string.
Definition: wcwebcamclient.h:246
wcCallback
The list of callbacks.
Definition: wcwebcamclient.h:133
void(* TaskNotifyLibFunc)(wcHandle client, wcTask tsk)
Notification callback from the specific task.
Definition: wcwebcamclient.h:236
void(* EmptyNotifyLibFunc)(wcHandle client)
Notification callback.
Definition: wcwebcamclient.h:226
wcRCode DLLEXPORT wcSetAltDataCallback(wcHandle client, wcCallback callbackId, DataAltNotifyEventLibFunc func)
Set specified notify callback for client to handling the sized data values.
void(* DataAltNotifyEventLibFunc)(wcHandle client, wcTask tsk, void *data, size_t sz)
Notification callback that returned a sized data buffer.
Definition: wcwebcamclient.h:259
void(* ConnNotifyEventLibFunc)(wcHandle client, int state)
Notification callback that the connection status has been changed.
Definition: wcwebcamclient.h:241
wcRCode DLLEXPORT wcSetJSONStrCallback(wcHandle client, wcCallback callbackId, JSONStrNotifyEventLibFunc func)
Set specified notify callback for client to process the JSON-formatted response results represented a...
wcRCode DLLEXPORT wcSetConnCallback(wcHandle client, ConnNotifyEventLibFunc func)
Set specified connection notify callback for client.
@ wccbkAddLog
Added new log entry.
Definition: wcwebcamclient.h:140
@ wccbkSuccessDeleteRecords
The request to delete records has been completed.
Definition: wcwebcamclient.h:160
@ wccbkSuccessSendMsg
The request to send message has been completed.
Definition: wcwebcamclient.h:157
@ wccbkSynchroUpdateTask
The IO streaming task signals that a change has occurred.
Definition: wcwebcamclient.h:141
@ wccbkAfterLaunchInStream
Incoming stream started.
Definition: wcwebcamclient.h:144
@ wccbkSuccessUpdateMsgs
The request to update list of messages has been completed.
Definition: wcwebcamclient.h:156
@ wccbkSuccessRequestRecord
The request to get the media record has been completed.
Definition: wcwebcamclient.h:150
@ wccbkSuccessRequestRecordMeta
The request to get metadata for the media record has been completed.
Definition: wcwebcamclient.h:158
@ wccbkLast
Definition: wcwebcamclient.h:162
@ wccbkSuccessSaveRecord
The request to save the media record has been completed.
Definition: wcwebcamclient.h:149
@ wccbkInitCURL
Successful initialization of the multiCURL handle.
Definition: wcwebcamclient.h:135
@ wccbkConnected
The connection state has been changed.
Definition: wcwebcamclient.h:137
@ wccbkSuccessAuth
Successful authorization.
Definition: wcwebcamclient.h:136
@ wccbkAfterLaunchOutStream
Outgoing stream started.
Definition: wcwebcamclient.h:145
@ wccbkSuccessUpdateDevices
The request to update list of online devices has been completed.
Definition: wcwebcamclient.h:154
@ wccbkSuccessIOStream
IO stream terminated for some reason.
Definition: wcwebcamclient.h:146
@ wccbkSuccessUpdateRecords
The request to update list of records has been completed.
Definition: wcwebcamclient.h:153
@ wccbkDisconnect
Client has been disconnected.
Definition: wcwebcamclient.h:138
@ wccbkSuccessUpdateStreams
The request to update list of streaming devices has been completed.
Definition: wcwebcamclient.h:155
@ wccbkSIDSetted
The session id has been changed.
Definition: wcwebcamclient.h:139
@ wccbkSuccessGetConfig
The request to get actual config has been completed.
Definition: wcwebcamclient.h:159
wcRCode DLLEXPORT wcClientGetStrValue(wcHandle client, wcStateId aStateId, char **aStateVal)
Get a C-style string value for the selected client state.
wcRCode DLLEXPORT wcClientInvalidateState(wcHandle client, wcStateId aStateId)
Reset the selected client state.
wcRCode DLLEXPORT wcClientSetStrValue(wcHandle client, wcStateId aStateId, const char *aStateVal)
Set a C-style string value to the selected client state.
wcRCode DLLEXPORT wcClientGetIntState(wcHandle client, wcStateId aStateId, int *aStateVal)
Get a integer value for the selected client state.
wcRCode DLLEXPORT wcClientSetBoolState(wcHandle client, wcStateId aStateId, wcStateVal aStateVal)
Set the boolean value to the selected client state.
wcRCode DLLEXPORT wcClientGetStrNValue(wcHandle client, wcStateId aStateId, uint32_t sz, char *aStateVal)
Get a C-style string value for the selected client state.
wcRCode DLLEXPORT wcClientGetBoolState(wcHandle client, wcStateId aStateId)
Get a boolean value for the selected client state.
wcStateId
Definition: wcwebcamclient.h:173
wcTaskStateId
Definition: wcwebcamclient.h:203
@ wcstDevices
Definition: wcwebcamclient.h:180
@ wcstProxyPwrd
Definition: wcwebcamclient.h:196
@ wcstProxyHost
Definition: wcwebcamclient.h:193
@ wcstStreams
Definition: wcwebcamclient.h:179
@ wcstProxyUser
Definition: wcwebcamclient.h:195
@ wcstError
Definition: wcwebcamclient.h:176
@ wcstDeviceName
Definition: wcwebcamclient.h:187
@ wcstProxyAuth
Definition: wcwebcamclient.h:191
@ wcstMsgsStamp
Definition: wcwebcamclient.h:185
@ wcstStreaming
Definition: wcwebcamclient.h:178
@ wcstConnection
Definition: wcwebcamclient.h:174
@ wcstSID
Definition: wcwebcamclient.h:188
@ wcstProxyPort
Definition: wcwebcamclient.h:194
@ wcstProxy
Definition: wcwebcamclient.h:190
@ wcstSendWithSync
since v0.8
Definition: wcwebcamclient.h:184
@ wcstMsgs
Definition: wcwebcamclient.h:183
@ wcstMetaData
Definition: wcwebcamclient.h:186
@ wcstHostName
Definition: wcwebcamclient.h:189
@ wcstVerifyTLS
Definition: wcwebcamclient.h:175
@ wcstRecords
Definition: wcwebcamclient.h:181
@ wcstProxyProtocol
Definition: wcwebcamclient.h:192
@ wcstRecordsStamp
Definition: wcwebcamclient.h:182
@ wcstLog
Definition: wcwebcamclient.h:177
@ wctstPath
Definition: wcwebcamclient.h:205
@ wctstDeviceName
Definition: wcwebcamclient.h:207
@ wctstSubProto
Definition: wcwebcamclient.h:206
@ wctstError
Definition: wcwebcamclient.h:204
wcHandle DLLEXPORT wcClientCreate()
Create client.
wcRCode DLLEXPORT wcClientTasksProceed(wcHandle client)
Call the synchronous client update stage.
wcRCode DLLEXPORT wcClientDisconnect(wcHandle client)
Disconnect client from the server host.
wcRCode DLLEXPORT wcClientProceed(wcHandle client)
Call the asynchronous client update stage.
wcRCode DLLEXPORT wcClientAuth(wcHandle client, const char *aLogin, const char *aPwrd)
Authorize client on the server host.
wcRCode DLLEXPORT wcClientDestroy(wcHandle client)
Destroy client.
wcRCode DLLEXPORT wcClientStart(wcHandle client)
Launch client.
wcRCode DLLEXPORT wcLaunchOutStream(wcHandle client, const char *subProtocol, int delta, void *data)
Launch output stream for authorized client.
wcRCode DLLEXPORT wcRequestRecord(wcHandle client, int rid, void *data)
Request specified media record from server for authorized client.
wcRCode DLLEXPORT wcLaunchInStream(wcHandle client, const char *deviceName, void *data)
Launch task to consume incoming stream from the specified device for authorized client.
wcRCode DLLEXPORT wcSendMsg(wcHandle client, const char *msg, void *data)
Send message from authorized client.
wcRCode DLLEXPORT wcDeleteRecords(wcHandle client, const char *indices, void *data)
Delete specified media records for authorized client.
wcRCode DLLEXPORT wcRequestRecordMeta(wcHandle client, int rid, void *data)
Request metadata of specified media record from server for authorized client.
wcRCode DLLEXPORT wcSaveRecord(wcHandle client, const void *aBuf, size_t sz, const char *meta, void *data)
Send a media record to server from authorized client.
wcRCode DLLEXPORT wcSetConfig(wcHandle client, const char *cfg)
Send configuration of authorized client to the server.
wcRCode DLLEXPORT wcGetConfig(wcHandle client, void *data)
Get configuration from the server for authorized client.
void DLLEXPORT wcGetLibVersion(uint8_t *vmajor, uint8_t *vminor, uint16_t *vrev)
Get the library version.
wcRCode DLLEXPORT wcClientFrameLock(wcHandle client)
Lock the frame object for threadsafe access to the output data stack.
wcRCode DLLEXPORT wcClientFrameGetData(wcHandle client, void **data, size_t *len)
Get access to the last frame in the outgoing data stack.
wcRCode DLLEXPORT wcClientFramePushData(wcHandle client, const void *data, size_t len)
Add a new frame to the outgoing data stack to send.
wcRCode DLLEXPORT wcClientFrameUnLock(wcHandle client)
Unlock the frame object.
wcRCode DLLEXPORT wcClientGetFrameID(wcHandle client, long *id)
Get the ID of the current output frame.
wcRCode DLLEXPORT wcInTaskPopFrame(wcTask task, void **data, size_t *len)
Get access to the first frame in the incoming data stack.
const wcRCode WC_NOT_A_TASK
Definition: wcwebcamclient.h:89
int wcStateVal
Boolean operation completion codes.
Definition: wcwebcamclient.h:59
const wcRCode WC_BAD_PARAM
Definition: wcwebcamclient.h:80
const wcRCode WC_BAD_VALUE
Definition: wcwebcamclient.h:83
const wcRCode WC_OK
Definition: wcwebcamclient.h:74
int wcRCode
Operation completion codes.
Definition: wcwebcamclient.h:65
const wcRCode WC_FALSE
Definition: wcwebcamclient.h:71
const wcRCode WC_NOT_ENOUGH_MEM
Definition: wcwebcamclient.h:95
const wcRCode WC_BAD_TARGET
Definition: wcwebcamclient.h:77
const wcRCode WC_TASK_MISMATCH
Definition: wcwebcamclient.h:92
const wcRCode WC_CLIENT_NOT_STREAMING
Definition: wcwebcamclient.h:86
const wcRCode WC_TRUE
Definition: wcwebcamclient.h:68
wcRCode DLLEXPORT wcTaskGetClass(wcTask task, wcTaskClass *id)
Get the class of the task.
wcRCode DLLEXPORT wcTaskLock(wcTask task)
Lock the task object for threadsafe access.
wcRCode DLLEXPORT wcTaskSetUserData(wcTask task, void *data)
Set the user data for the task.
wcRCode DLLEXPORT wcTaskGetStrValue(wcTask task, wcTaskStateId aStateId, char **aStateVal)
Get a C-style string value for the selected task state.
wcRCode DLLEXPORT wcTaskUnLock(wcTask task)
Unlock the task object.
wcRCode DLLEXPORT wcTaskGetStrNValue(wcTask task, wcTaskStateId aStateId, uint32_t sz, char *aStateVal)
Get a C-style string value for the selected task state.
wcRCode DLLEXPORT wcTaskGetUserData(wcTask task, void **data)
Get the user data for the task.
void * wcCallbackTask
Definition: wcCommonCallbacks.h:8
const wcTaskClass WC_OUT_STREAM_TASK
The Output-stream task class (for UPLOAD requests)
Definition: wcwebcamclient.h:114
const wcTaskClass WC_BASE_TASK
The Base task class.
Definition: wcwebcamclient.h:108
const wcTaskClass WC_ALL_TASKS
All tasks classes (mask)
Definition: wcwebcamclient.h:116
const wcTaskClass WC_IN_STREAM_TASK
The Input-stream task class (for GET requests)
Definition: wcwebcamclient.h:112
int wcHandle
Client handle.
Definition: wcwebcamclient.h:99
wcCallbackTask wcTask
Pointer to task.
Definition: wcwebcamclient.h:102
const uint16_t WC_STREAM_FRAME_HEADER_SIZE
The size of frame header (6 bytes)
Definition: wcwebcamclient.h:119
const uint16_t WC_FRAME_START_SEQ
The frame header sequence.
Definition: wcwebcamclient.h:121
const wcTaskClass WC_TASK
The Simple task class (for POST requests)
Definition: wcwebcamclient.h:110
uint32_t wcTaskClass
Task class.
Definition: wcwebcamclient.h:105