summaryrefslogtreecommitdiff
path: root/toxav/msi.h
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-05-25 12:27:48 -0400
committerirungentoo <irungentoo@gmail.com>2014-05-25 12:27:48 -0400
commit82e38883a239f265089982bc255de0f9db618ce7 (patch)
tree1d38b2ff978e86246695cc7e473af309eacdba2a /toxav/msi.h
parent9d53bc5d1dabd3142f58cafd9fffa18f783f96df (diff)
parent08ca08dcd952d55a0df75e5efa25a5d8afa70e3f (diff)
Merge branch 'mannol1-Multicalls' into multi-av
Diffstat (limited to 'toxav/msi.h')
-rw-r--r--[-rwxr-xr-x]toxav/msi.h67
1 files changed, 38 insertions, 29 deletions
diff --git a/toxav/msi.h b/toxav/msi.h
index 052126d2..042f3f0f 100755..100644
--- a/toxav/msi.h
+++ b/toxav/msi.h
@@ -33,7 +33,7 @@
33#define CALL_ID_LEN 12 33#define CALL_ID_LEN 12
34 34
35 35
36typedef void ( *MSICallback ) ( void *arg ); 36typedef void ( *MSICallback ) ( int32_t, void *arg );
37 37
38 38
39/** 39/**
@@ -62,32 +62,33 @@ typedef enum {
62 * @brief The call struct. 62 * @brief The call struct.
63 * 63 *
64 */ 64 */
65typedef struct _MSICall { /* Call info structure */ 65typedef struct _MSICall { /* Call info structure */
66 MSICallState state; 66 struct _MSISession *session; /* Session pointer */
67 67
68 MSICallType type_local; /* Type of payload user is ending */ 68 MSICallState state;
69 MSICallType *type_peer; /* Type of payload others are sending */
70 69
71 uint8_t id[CALL_ID_LEN]; /* Random value identifying the call */ 70 MSICallType type_local; /* Type of payload user is ending */
71 MSICallType *type_peer; /* Type of payload others are sending */
72 72
73 uint8_t *key_local; /* The key for encryption */ 73 uint8_t id[CALL_ID_LEN]; /* Random value identifying the call */
74 uint8_t *key_peer; /* The key for decryption */
75 74
76 uint8_t *nonce_local; /* Local nonce */ 75 uint8_t *key_local; /* The key for encryption */
77 uint8_t *nonce_peer; /* Peer nonce */ 76 uint8_t *key_peer; /* The key for decryption */
78 77
79 int ringing_tout_ms; /* Ringing timeout in ms */ 78 uint8_t *nonce_local; /* Local nonce */
79 uint8_t *nonce_peer; /* Peer nonce */
80 80
81 int request_timer_id; /* Timer id for outgoing request/action */ 81 int ringing_tout_ms; /* Ringing timeout in ms */
82 int ringing_timer_id; /* Timer id for ringing timeout */
83 82
84 pthread_mutex_t mutex; /* It's to be assumed that call will have 83 int request_timer_id; /* Timer id for outgoing request/action */
85 * separate thread so add mutex 84 int ringing_timer_id; /* Timer id for ringing timeout */
86 */
87 uint32_t *peers;
88 uint16_t peer_count;
89 85
90 86
87 pthread_mutex_t mutex; /* */
88 uint32_t *peers;
89 uint16_t peer_count;
90
91 int32_t call_idx; /* Index of this call in MSISession */
91} MSICall; 92} MSICall;
92 93
93 94
@@ -97,8 +98,9 @@ typedef struct _MSICall { /* Call info structure */
97 */ 98 */
98typedef struct _MSISession { 99typedef struct _MSISession {
99 100
100 /* Call handler */ 101 /* Call handlers */
101 struct _MSICall *call; 102 struct _MSICall **calls;
103 int32_t max_calls;
102 104
103 int last_error_id; /* Determine the last error */ 105 int last_error_id; /* Determine the last error */
104 const uint8_t *last_error_str; 106 const uint8_t *last_error_str;
@@ -109,7 +111,7 @@ typedef struct _MSISession {
109 uint32_t frequ; 111 uint32_t frequ;
110 uint32_t call_timeout; /* Time of the timeout for some action to end; 0 if infinite */ 112 uint32_t call_timeout; /* Time of the timeout for some action to end; 0 if infinite */
111 113
112 114 pthread_mutex_t mutex;
113} MSISession; 115} MSISession;
114 116
115 117
@@ -144,17 +146,18 @@ typedef enum {
144 * @param id The id. 146 * @param id The id.
145 * @return void 147 * @return void
146 */ 148 */
147void msi_register_callback(MSICallback callback, MSICallbackID id, void* userdata); 149void msi_register_callback(MSICallback callback, MSICallbackID id, void *userdata);
148 150
149 151
150/** 152/**
151 * @brief Start the control session. 153 * @brief Start the control session.
152 * 154 *
153 * @param messenger Tox* object. 155 * @param messenger Tox* object.
156 * @param max_calls Amount of calls possible
154 * @return MSISession* The created session. 157 * @return MSISession* The created session.
155 * @retval NULL Error occurred. 158 * @retval NULL Error occurred.
156 */ 159 */
157MSISession *msi_init_session ( Messenger *messenger ); 160MSISession *msi_init_session ( Messenger *messenger, int32_t max_calls );
158 161
159 162
160/** 163/**
@@ -170,62 +173,68 @@ int msi_terminate_session ( MSISession *session );
170 * @brief Send invite request to friend_id. 173 * @brief Send invite request to friend_id.
171 * 174 *
172 * @param session Control session. 175 * @param session Control session.
176 * @param call_index Set to new call index.
173 * @param call_type Type of the call. Audio or Video(both audio and video) 177 * @param call_type Type of the call. Audio or Video(both audio and video)
174 * @param rngsec Ringing timeout. 178 * @param rngsec Ringing timeout.
175 * @param friend_id The friend. 179 * @param friend_id The friend.
176 * @return int 180 * @return int
177 */ 181 */
178int msi_invite ( MSISession *session, MSICallType call_type, uint32_t rngsec, uint32_t friend_id ); 182int msi_invite ( MSISession *session, int32_t *call_index, MSICallType call_type, uint32_t rngsec, uint32_t friend_id );
179 183
180 184
181/** 185/**
182 * @brief Hangup active call. 186 * @brief Hangup active call.
183 * 187 *
184 * @param session Control session. 188 * @param session Control session.
189 * @param call_index To which call is this action handled.
185 * @return int 190 * @return int
186 * @retval -1 Error occurred. 191 * @retval -1 Error occurred.
187 * @retval 0 Success. 192 * @retval 0 Success.
188 */ 193 */
189int msi_hangup ( MSISession *session ); 194int msi_hangup ( MSISession *session, int32_t call_index );
190 195
191 196
192/** 197/**
193 * @brief Answer active call request. 198 * @brief Answer active call request.
194 * 199 *
195 * @param session Control session. 200 * @param session Control session.
201 * @param call_index To which call is this action handled.
196 * @param call_type Answer with Audio or Video(both). 202 * @param call_type Answer with Audio or Video(both).
197 * @return int 203 * @return int
198 */ 204 */
199int msi_answer ( MSISession *session, MSICallType call_type ); 205int msi_answer ( MSISession *session, int32_t call_index, MSICallType call_type );
200 206
201 207
202/** 208/**
203 * @brief Cancel request. 209 * @brief Cancel request.
204 * 210 *
205 * @param session Control session. 211 * @param session Control session.
212 * @param call_index To which call is this action handled.
206 * @param peer To which peer. 213 * @param peer To which peer.
207 * @param reason Set optional reason header. Pass NULL if none. 214 * @param reason Set optional reason header. Pass NULL if none.
208 * @return int 215 * @return int
209 */ 216 */
210int msi_cancel ( MSISession* session, uint32_t peer, const char* reason ); 217int msi_cancel ( MSISession *session, int32_t call_index, uint32_t peer, const char *reason );
211 218
212 219
213/** 220/**
214 * @brief Reject request. 221 * @brief Reject request.
215 * 222 *
216 * @param session Control session. 223 * @param session Control session.
224 * @param call_index To which call is this action handled.
217 * @param reason Set optional reason header. Pass NULL if none. 225 * @param reason Set optional reason header. Pass NULL if none.
218 * @return int 226 * @return int
219 */ 227 */
220int msi_reject ( MSISession *session, const uint8_t *reason ); 228int msi_reject ( MSISession *session, int32_t call_index, const uint8_t *reason );
221 229
222 230
223/** 231/**
224 * @brief Terminate the current call. 232 * @brief Terminate the current call.
225 * 233 *
226 * @param session Control session. 234 * @param session Control session.
235 * @param call_index To which call is this action handled.
227 * @return int 236 * @return int
228 */ 237 */
229int msi_stopcall ( MSISession *session ); 238int msi_stopcall ( MSISession *session, int32_t call_index );
230 239
231#endif /* __TOXMSI */ 240#endif /* __TOXMSI */