diff options
Diffstat (limited to 'toxav/msi.h')
-rwxr-xr-x | toxav/msi.h | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/toxav/msi.h b/toxav/msi.h index 39a9c792..2d4929a6 100755 --- 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 | ||
36 | typedef void ( *MSICallback ) ( void *arg ); | 36 | typedef void ( *MSICallback ) ( int32_t, void *arg ); |
37 | 37 | ||
38 | 38 | ||
39 | /** | 39 | /** |
@@ -62,32 +62,35 @@ typedef enum { | |||
62 | * @brief The call struct. | 62 | * @brief The call struct. |
63 | * | 63 | * |
64 | */ | 64 | */ |
65 | typedef struct _MSICall { /* Call info structure */ | 65 | typedef struct _MSICall { /* Call info structure */ |
66 | MSICallState state; | 66 | struct _MSISession* session; /* Session pointer */ |
67 | |||
68 | MSICallState state; | ||
67 | 69 | ||
68 | MSICallType type_local; /* Type of payload user is ending */ | 70 | MSICallType type_local; /* Type of payload user is ending */ |
69 | MSICallType *type_peer; /* Type of payload others are sending */ | 71 | MSICallType *type_peer; /* Type of payload others are sending */ |
70 | 72 | ||
71 | uint8_t id[CALL_ID_LEN]; /* Random value identifying the call */ | 73 | uint8_t id[CALL_ID_LEN]; /* Random value identifying the call */ |
72 | 74 | ||
73 | uint8_t *key_local; /* The key for encryption */ | 75 | uint8_t *key_local; /* The key for encryption */ |
74 | uint8_t *key_peer; /* The key for decryption */ | 76 | uint8_t *key_peer; /* The key for decryption */ |
75 | 77 | ||
76 | uint8_t *nonce_local; /* Local nonce */ | 78 | uint8_t *nonce_local; /* Local nonce */ |
77 | uint8_t *nonce_peer; /* Peer nonce */ | 79 | uint8_t *nonce_peer; /* Peer nonce */ |
78 | 80 | ||
79 | int ringing_tout_ms; /* Ringing timeout in ms */ | 81 | int ringing_tout_ms; /* Ringing timeout in ms */ |
80 | 82 | ||
81 | int request_timer_id; /* Timer id for outgoing request/action */ | 83 | int request_timer_id; /* Timer id for outgoing request/action */ |
82 | int ringing_timer_id; /* Timer id for ringing timeout */ | 84 | int ringing_timer_id; /* Timer id for ringing timeout */ |
83 | 85 | ||
84 | pthread_mutex_t mutex; /* It's to be assumed that call will have | ||
85 | * separate thread so add mutex | ||
86 | */ | ||
87 | uint32_t *peers; | ||
88 | uint16_t peer_count; | ||
89 | 86 | ||
87 | pthread_mutex_t mutex; /* It's to be assumed that call will have | ||
88 | * separate thread so add mutex | ||
89 | */ | ||
90 | uint32_t *peers; | ||
91 | uint16_t peer_count; | ||
90 | 92 | ||
93 | int32_t call_idx; /* Index of this call in MSISession */ | ||
91 | } MSICall; | 94 | } MSICall; |
92 | 95 | ||
93 | 96 | ||
@@ -97,8 +100,9 @@ typedef struct _MSICall { /* Call info structure */ | |||
97 | */ | 100 | */ |
98 | typedef struct _MSISession { | 101 | typedef struct _MSISession { |
99 | 102 | ||
100 | /* Call handler */ | 103 | /* Call handlers */ |
101 | struct _MSICall *call; | 104 | struct _MSICall **calls; |
105 | int32_t max_calls; | ||
102 | 106 | ||
103 | int last_error_id; /* Determine the last error */ | 107 | int last_error_id; /* Determine the last error */ |
104 | const uint8_t *last_error_str; | 108 | const uint8_t *last_error_str; |
@@ -151,10 +155,11 @@ void msi_register_callback(MSICallback callback, MSICallbackID id, void* userdat | |||
151 | * @brief Start the control session. | 155 | * @brief Start the control session. |
152 | * | 156 | * |
153 | * @param messenger Tox* object. | 157 | * @param messenger Tox* object. |
158 | * @param max_calls Amount of calls possible | ||
154 | * @return MSISession* The created session. | 159 | * @return MSISession* The created session. |
155 | * @retval NULL Error occurred. | 160 | * @retval NULL Error occurred. |
156 | */ | 161 | */ |
157 | MSISession *msi_init_session ( Messenger *messenger ); | 162 | MSISession *msi_init_session ( Messenger *messenger, int32_t max_calls ); |
158 | 163 | ||
159 | 164 | ||
160 | /** | 165 | /** |
@@ -170,62 +175,68 @@ int msi_terminate_session ( MSISession *session ); | |||
170 | * @brief Send invite request to friend_id. | 175 | * @brief Send invite request to friend_id. |
171 | * | 176 | * |
172 | * @param session Control session. | 177 | * @param session Control session. |
178 | * @param call_index Set to new call index. | ||
173 | * @param call_type Type of the call. Audio or Video(both audio and video) | 179 | * @param call_type Type of the call. Audio or Video(both audio and video) |
174 | * @param rngsec Ringing timeout. | 180 | * @param rngsec Ringing timeout. |
175 | * @param friend_id The friend. | 181 | * @param friend_id The friend. |
176 | * @return int | 182 | * @return int |
177 | */ | 183 | */ |
178 | int msi_invite ( MSISession *session, MSICallType call_type, uint32_t rngsec, uint32_t friend_id ); | 184 | int msi_invite ( MSISession *session, int32_t* call_index, MSICallType call_type, uint32_t rngsec, uint32_t friend_id ); |
179 | 185 | ||
180 | 186 | ||
181 | /** | 187 | /** |
182 | * @brief Hangup active call. | 188 | * @brief Hangup active call. |
183 | * | 189 | * |
184 | * @param session Control session. | 190 | * @param session Control session. |
191 | * @param call_index To which call is this action handled. | ||
185 | * @return int | 192 | * @return int |
186 | * @retval -1 Error occurred. | 193 | * @retval -1 Error occurred. |
187 | * @retval 0 Success. | 194 | * @retval 0 Success. |
188 | */ | 195 | */ |
189 | int msi_hangup ( MSISession *session ); | 196 | int msi_hangup ( MSISession *session, int32_t call_index ); |
190 | 197 | ||
191 | 198 | ||
192 | /** | 199 | /** |
193 | * @brief Answer active call request. | 200 | * @brief Answer active call request. |
194 | * | 201 | * |
195 | * @param session Control session. | 202 | * @param session Control session. |
203 | * @param call_index To which call is this action handled. | ||
196 | * @param call_type Answer with Audio or Video(both). | 204 | * @param call_type Answer with Audio or Video(both). |
197 | * @return int | 205 | * @return int |
198 | */ | 206 | */ |
199 | int msi_answer ( MSISession *session, MSICallType call_type ); | 207 | int msi_answer ( MSISession *session, int32_t call_index, MSICallType call_type ); |
200 | 208 | ||
201 | 209 | ||
202 | /** | 210 | /** |
203 | * @brief Cancel request. | 211 | * @brief Cancel request. |
204 | * | 212 | * |
205 | * @param session Control session. | 213 | * @param session Control session. |
214 | * @param call_index To which call is this action handled. | ||
206 | * @param peer To which peer. | 215 | * @param peer To which peer. |
207 | * @param reason Set optional reason header. Pass NULL if none. | 216 | * @param reason Set optional reason header. Pass NULL if none. |
208 | * @return int | 217 | * @return int |
209 | */ | 218 | */ |
210 | int msi_cancel ( MSISession* session, uint32_t peer, const char* reason ); | 219 | int msi_cancel ( MSISession* session, int32_t call_index, uint32_t peer, const char* reason ); |
211 | 220 | ||
212 | 221 | ||
213 | /** | 222 | /** |
214 | * @brief Reject request. | 223 | * @brief Reject request. |
215 | * | 224 | * |
216 | * @param session Control session. | 225 | * @param session Control session. |
226 | * @param call_index To which call is this action handled. | ||
217 | * @param reason Set optional reason header. Pass NULL if none. | 227 | * @param reason Set optional reason header. Pass NULL if none. |
218 | * @return int | 228 | * @return int |
219 | */ | 229 | */ |
220 | int msi_reject ( MSISession *session, const uint8_t *reason ); | 230 | int msi_reject ( MSISession *session, int32_t call_index, const uint8_t *reason ); |
221 | 231 | ||
222 | 232 | ||
223 | /** | 233 | /** |
224 | * @brief Terminate the current call. | 234 | * @brief Terminate the current call. |
225 | * | 235 | * |
226 | * @param session Control session. | 236 | * @param session Control session. |
237 | * @param call_index To which call is this action handled. | ||
227 | * @return int | 238 | * @return int |
228 | */ | 239 | */ |
229 | int msi_stopcall ( MSISession *session ); | 240 | int msi_stopcall ( MSISession *session, int32_t call_index ); |
230 | 241 | ||
231 | #endif /* __TOXMSI */ | 242 | #endif /* __TOXMSI */ |