summaryrefslogtreecommitdiff
path: root/toxav/toxmsi.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxav/toxmsi.h')
-rwxr-xr-xtoxav/toxmsi.h231
1 files changed, 231 insertions, 0 deletions
diff --git a/toxav/toxmsi.h b/toxav/toxmsi.h
new file mode 100755
index 00000000..c45662a6
--- /dev/null
+++ b/toxav/toxmsi.h
@@ -0,0 +1,231 @@
1/** toxmsi.h
2 *
3 * Copyright (C) 2013 Tox project All Rights Reserved.
4 *
5 * This file is part of Tox.
6 *
7 * Tox is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Tox is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 * Report bugs/suggestions to me ( mannol ) at either #tox-dev @ freenode.net:6667 or
22 * my email: eniz_vukovic@hotmail.com
23 */
24
25#ifndef __TOXMSI
26#define __TOXMSI
27
28#include <inttypes.h>
29#include "../toxcore/tox.h"
30#include <pthread.h>
31
32/* define size for call_id */
33#define CALL_ID_LEN 12
34
35
36typedef void* ( *MSICallback ) ( void* arg );
37
38
39/**
40 * @brief Call type identifier. Also used as rtp callback prefix.
41 */
42typedef enum {
43 type_audio = 70,
44 type_video,
45} MSICallType;
46
47
48/**
49 * @brief Call state identifiers.
50 */
51typedef enum {
52 call_inviting, /* when sending call invite */
53 call_starting, /* when getting call invite */
54 call_active,
55 call_hold
56
57} MSICallState;
58
59
60
61/**
62 * @brief The call struct.
63 *
64 */
65typedef struct _MSICall { /* Call info structure */
66 MSICallState state;
67
68 MSICallType type_local; /* Type of payload user is ending */
69 MSICallType* type_peer; /* Type of payload others are sending */
70
71 uint8_t id[CALL_ID_LEN]; /* Random value identifying the call */
72
73 uint8_t* key_local; /* The key for encryption */
74 uint8_t* key_peer; /* The key for decryption */
75
76 uint8_t* nonce_local; /* Local nonce */
77 uint8_t* nonce_peer; /* Peer nonce */
78
79 int ringing_tout_ms; /* Ringing timeout in ms */
80
81 int request_timer_id; /* Timer id for outgoing request/action */
82 int ringing_timer_id; /* Timer id for ringing timeout */
83
84 pthread_mutex_t mutex; /* It's to be assumed that call will have
85 * seperate thread so add mutex
86 */
87 uint32_t* peers;
88 uint16_t peer_count;
89
90
91} MSICall;
92
93
94/**
95 * @brief Control session struct
96 *
97 */
98typedef struct _MSISession {
99
100 /* Call handler */
101 struct _MSICall* call;
102
103 int last_error_id; /* Determine the last error */
104 const uint8_t* last_error_str;
105
106 const uint8_t* user_agent;
107
108 void* agent_handler; /* Pointer to an object that is handling msi */
109 Tox* messenger_handle;
110
111 uint32_t frequ;
112 uint32_t call_timeout; /* Time of the timeout for some action to end; 0 if infinite */
113
114
115} MSISession;
116
117
118/**
119 * @brief Callbacks ids that handle the states
120 */
121typedef enum {
122 /* Requests */
123 cb_oninvite,
124 cb_onstart,
125 cb_oncancel,
126 cb_onreject,
127 cb_onend,
128
129 /* Responses */
130 cb_ringing,
131 cb_starting,
132 cb_ending,
133
134 /* Protocol */
135 cb_error,
136 cb_timeout,
137
138} MSICallbackID;
139
140
141/**
142 * @brief Callback setter.
143 *
144 * @param callback The callback.
145 * @param id The id.
146 * @return void
147 */
148void msi_register_callback(MSICallback callback, MSICallbackID id);
149
150
151/**
152 * @brief Start the control session.
153 *
154 * @param messenger Tox* object.
155 * @param user_agent User agent, i.e. 'Venom'; 'QT-gui'
156 * @return MSISession* The created session.
157 * @retval NULL Error occured.
158 */
159MSISession* msi_init_session ( Tox* messenger, const uint8_t* user_agent );
160
161
162/**
163 * @brief Terminate control session.
164 *
165 * @param session The session
166 * @return int
167 */
168int msi_terminate_session ( MSISession* session );
169
170
171/**
172 * @brief Send invite request to friend_id.
173 *
174 * @param session Control session.
175 * @param call_type Type of the call. Audio or Video(both audio and video)
176 * @param rngsec Ringing timeout.
177 * @param friend_id The friend.
178 * @return int
179 */
180int msi_invite ( MSISession* session, MSICallType call_type, uint32_t rngsec, uint32_t friend_id );
181
182
183/**
184 * @brief Hangup active call.
185 *
186 * @param session Control session.
187 * @return int
188 * @retval -1 Error occured.
189 * @retval 0 Success.
190 */
191int msi_hangup ( MSISession* session );
192
193
194/**
195 * @brief Answer active call request.
196 *
197 * @param session Control session.
198 * @param call_type Answer with Audio or Video(both).
199 * @return int
200 */
201int msi_answer ( MSISession* session, MSICallType call_type );
202
203
204/**
205 * @brief Cancel request.
206 *
207 * @param session Control session.
208 * @param friend_id The friend.
209 * @return int
210 */
211int msi_cancel ( MSISession* session, int friend_id );
212
213
214/**
215 * @brief Reject request.
216 *
217 * @param session Control session.
218 * @return int
219 */
220int msi_reject ( MSISession* session );
221
222
223/**
224 * @brief Terminate the current call.
225 *
226 * @param session Control session.
227 * @return int
228 */
229int msi_stopcall ( MSISession* session );
230
231#endif /* __TOXMSI */