summaryrefslogtreecommitdiff
path: root/toxav/msi.h
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-02-16 19:13:34 -0500
committerirungentoo <irungentoo@gmail.com>2014-02-16 19:13:34 -0500
commit9d1eb27717472f5655242fac7b8123a44f1ff33c (patch)
treefd205f1ea53749717d9930d93ddb153fc8a16929 /toxav/msi.h
parentfd3dc22ef3bd77beb78faf24cd43e9d2b9706f5d (diff)
parentf79b327fd639b2dcca9d4d2c137f93c1dce622fc (diff)
Merge branch 'av-fix' into av-good
Diffstat (limited to 'toxav/msi.h')
-rw-r--r--toxav/msi.h233
1 files changed, 233 insertions, 0 deletions
diff --git a/toxav/msi.h b/toxav/msi.h
new file mode 100644
index 00000000..5b693da4
--- /dev/null
+++ b/toxav/msi.h
@@ -0,0 +1,233 @@
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 at #tox-dev @ freenode.net:6667
22 */
23
24#ifndef __TOXMSI
25#define __TOXMSI
26
27#include <inttypes.h>
28#include <pthread.h>
29
30#include "../toxcore/Messenger.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* ua_name;
107
108 void* agent_handler; /* Pointer to an object that is handling msi */
109 Messenger* 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 MSI_OnInvite,
124 MSI_OnStart,
125 MSI_OnCancel,
126 MSI_OnReject,
127 MSI_OnEnd,
128
129 /* Responses */
130 MSI_OnRinging,
131 MSI_OnStarting,
132 MSI_OnEnding,
133
134 /* Protocol */
135 MSI_OnError,
136 MSI_OnRequestTimeout
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 ( Messenger* messenger, const uint8_t* ua_name );
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 peer To which peer.
209 * @param reason Set optional reason header. Pass NULL if none.
210 * @return int
211 */
212int msi_cancel ( MSISession* session, uint32_t peer, const uint8_t* reason );
213
214
215/**
216 * @brief Reject request.
217 *
218 * @param session Control session.
219 * @param reason Set optional reason header. Pass NULL if none.
220 * @return int
221 */
222int msi_reject ( MSISession* session, const uint8_t* reason );
223
224
225/**
226 * @brief Terminate the current call.
227 *
228 * @param session Control session.
229 * @return int
230 */
231int msi_stopcall ( MSISession* session );
232
233#endif /* __TOXMSI */