diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-04-27 19:21:26 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-04-27 19:21:26 +0200 |
commit | 42b25a4d3e2fe66f03cbd8c866d8af7bd4f6e5a7 (patch) | |
tree | 161a21847a79f7fe052a9e9ad1b9b802d04defc6 /auto_tests/toxav_basic_test.c | |
parent | 736f5f80347a39f6b82cda8a4ddc1f7d88fcc2f5 (diff) |
Yeah many calls
Diffstat (limited to 'auto_tests/toxav_basic_test.c')
-rw-r--r-- | auto_tests/toxav_basic_test.c | 131 |
1 files changed, 71 insertions, 60 deletions
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index f337217c..affe4dd2 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <assert.h> | 12 | #include <assert.h> |
13 | 13 | ||
14 | #include "../toxcore/tox.h" | 14 | #include "../toxcore/tox.h" |
15 | #include "../toxcore/logger.h" | ||
15 | #include "../toxav/toxav.h" | 16 | #include "../toxav/toxav.h" |
16 | 17 | ||
17 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) | 18 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) |
@@ -22,6 +23,7 @@ | |||
22 | #endif | 23 | #endif |
23 | 24 | ||
24 | 25 | ||
26 | |||
25 | typedef enum _CallStatus { | 27 | typedef enum _CallStatus { |
26 | none, | 28 | none, |
27 | InCall, | 29 | InCall, |
@@ -36,6 +38,7 @@ typedef struct _Party { | |||
36 | CallStatus status; | 38 | CallStatus status; |
37 | ToxAv *av; | 39 | ToxAv *av; |
38 | time_t *CallStarted; | 40 | time_t *CallStarted; |
41 | int call_index; | ||
39 | } Party; | 42 | } Party; |
40 | 43 | ||
41 | typedef struct _Status { | 44 | typedef struct _Status { |
@@ -45,42 +48,41 @@ typedef struct _Status { | |||
45 | 48 | ||
46 | void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata) | 49 | void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata) |
47 | { | 50 | { |
48 | if (length == 15 && memcmp("ILIKESMALLTITS", data, 15) == 0) { | 51 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { |
49 | tox_add_friend_norequest(m, public_key); | 52 | tox_add_friend_norequest(m, public_key); |
50 | } | 53 | } |
51 | } | 54 | } |
52 | 55 | ||
53 | 56 | ||
54 | /******************************************************************************/ | 57 | /******************************************************************************/ |
55 | void callback_recv_invite ( void *_arg ) | 58 | void callback_recv_invite ( uint32_t call_index, void *_arg ) |
56 | { | 59 | { |
57 | Status *cast = _arg; | 60 | Status *cast = _arg; |
58 | 61 | ||
59 | /* Bob always receives invite */ | 62 | /* Bob always receives invite */ |
60 | cast->Bob.status = Ringing; | 63 | cast->Bob.status = Ringing; |
64 | cast->Bob.call_index = call_index; | ||
61 | } | 65 | } |
62 | void callback_recv_ringing ( void *_arg ) | 66 | void callback_recv_ringing ( uint32_t call_index, void *_arg ) |
63 | { | 67 | { |
64 | Status *cast = _arg; | 68 | Status *cast = _arg; |
65 | 69 | ||
66 | /* Alice always sends invite */ | 70 | /* Alice always sends invite */ |
67 | cast->Alice.status = Ringing; | 71 | cast->Alice.status = Ringing; |
68 | } | 72 | } |
69 | void callback_recv_starting ( void *_arg ) | 73 | void callback_recv_starting ( uint32_t call_index, void *_arg ) |
70 | { | 74 | { |
71 | Status *cast = _arg; | 75 | Status *cast = _arg; |
72 | 76 | ||
73 | /* Alice always sends invite */ | 77 | /* Alice always sends invite */ |
74 | printf("Call started on Alice side...\n"); | 78 | printf("Call started on Alice side...\n"); |
75 | cast->Alice.status = InCall; | 79 | cast->Alice.status = InCall; |
76 | toxav_prepare_transmission(cast->Alice.av, 1); | 80 | toxav_prepare_transmission(cast->Alice.av, call_index, 1); |
77 | } | 81 | } |
78 | void callback_recv_ending ( void *_arg ) | 82 | void callback_recv_ending ( uint32_t call_index, void *_arg ) |
79 | { | 83 | { |
80 | Status *cast = _arg; | 84 | Status *cast = _arg; |
81 | 85 | ||
82 | |||
83 | |||
84 | if ( cast->Alice.status == Rejected) { | 86 | if ( cast->Alice.status == Rejected) { |
85 | printf ( "Call ended for Bob!\n" ); | 87 | printf ( "Call ended for Bob!\n" ); |
86 | cast->Bob.status = Ended; | 88 | cast->Bob.status = Ended; |
@@ -90,28 +92,28 @@ void callback_recv_ending ( void *_arg ) | |||
90 | } | 92 | } |
91 | } | 93 | } |
92 | 94 | ||
93 | void callback_recv_error ( void *_arg ) | 95 | void callback_recv_error ( uint32_t call_index, void *_arg ) |
94 | { | 96 | { |
95 | ck_assert_msg(0, "AV internal error"); | 97 | ck_assert_msg(0, "AV internal error"); |
96 | } | 98 | } |
97 | 99 | ||
98 | void callback_call_started ( void *_arg ) | 100 | void callback_call_started ( uint32_t call_index, void *_arg ) |
99 | { | 101 | { |
100 | Status *cast = _arg; | 102 | Status *cast = _arg; |
101 | 103 | ||
102 | /* Alice always sends invite */ | 104 | /* Alice always sends invite */ |
103 | printf("Call started on Bob side...\n"); | 105 | printf("Call started on Bob side...\n"); |
104 | cast->Bob.status = InCall; | 106 | cast->Bob.status = InCall; |
105 | toxav_prepare_transmission(cast->Bob.av, 1); | 107 | toxav_prepare_transmission(cast->Bob.av, call_index, 1); |
106 | } | 108 | } |
107 | void callback_call_canceled ( void *_arg ) | 109 | void callback_call_canceled ( uint32_t call_index, void *_arg ) |
108 | { | 110 | { |
109 | Status *cast = _arg; | 111 | Status *cast = _arg; |
110 | 112 | ||
111 | printf ( "Call Canceled for Bob!\n" ); | 113 | printf ( "Call Canceled for Bob!\n" ); |
112 | cast->Bob.status = Cancel; | 114 | cast->Bob.status = Cancel; |
113 | } | 115 | } |
114 | void callback_call_rejected ( void *_arg ) | 116 | void callback_call_rejected ( uint32_t call_index, void *_arg ) |
115 | { | 117 | { |
116 | Status *cast = _arg; | 118 | Status *cast = _arg; |
117 | 119 | ||
@@ -120,7 +122,7 @@ void callback_call_rejected ( void *_arg ) | |||
120 | /* If Bob rejects, call is ended for alice and she sends ending */ | 122 | /* If Bob rejects, call is ended for alice and she sends ending */ |
121 | cast->Alice.status = Rejected; | 123 | cast->Alice.status = Rejected; |
122 | } | 124 | } |
123 | void callback_call_ended ( void *_arg ) | 125 | void callback_call_ended ( uint32_t call_index, void *_arg ) |
124 | { | 126 | { |
125 | Status *cast = _arg; | 127 | Status *cast = _arg; |
126 | 128 | ||
@@ -128,7 +130,7 @@ void callback_call_ended ( void *_arg ) | |||
128 | cast->Bob.status = Ended; | 130 | cast->Bob.status = Ended; |
129 | } | 131 | } |
130 | 132 | ||
131 | void callback_requ_timeout ( void *_arg ) | 133 | void callback_requ_timeout ( uint32_t call_index, void *_arg ) |
132 | { | 134 | { |
133 | ck_assert_msg(0, "No answer!"); | 135 | ck_assert_msg(0, "No answer!"); |
134 | } | 136 | } |
@@ -142,9 +144,9 @@ void callback_requ_timeout ( void *_arg ) | |||
142 | tox_do(bootstrap_node); tox_do(Alice); tox_do(Bob); \ | 144 | tox_do(bootstrap_node); tox_do(Alice); tox_do(Bob); \ |
143 | switch ( step ) {\ | 145 | switch ( step ) {\ |
144 | case 0: /* Alice */ printf("Alice is calling...\n");\ | 146 | case 0: /* Alice */ printf("Alice is calling...\n");\ |
145 | toxav_call(status_control.Alice.av, 0, AliceCallType, 10); step++; break;\ | 147 | toxav_call(status_control.Alice.av, &status_control.Alice.call_index, 0, AliceCallType, 10); step++; break;\ |
146 | case 1: /* Bob */ if (status_control.Bob.status == Ringing) { printf("Bob answers...\n");\ | 148 | case 1: /* Bob */ if (status_control.Bob.status == Ringing) { printf("Bob answers...\n");\ |
147 | cur_time = time(NULL); toxav_answer(status_control.Bob.av, BobCallType); step++; } break; \ | 149 | cur_time = time(NULL); toxav_answer(status_control.Bob.av, status_control.Bob.call_index, BobCallType); step++; } break; \ |
148 | case 2: /* Rtp transmission */ \ | 150 | case 2: /* Rtp transmission */ \ |
149 | if (status_control.Bob.status == InCall && status_control.Alice.status == InCall) | 151 | if (status_control.Bob.status == InCall && status_control.Alice.status == InCall) |
150 | 152 | ||
@@ -153,7 +155,7 @@ void callback_requ_timeout ( void *_arg ) | |||
153 | case 3: /* Wait for Both to have status ended */\ | 155 | case 3: /* Wait for Both to have status ended */\ |
154 | if (status_control.Alice.status == Ended && status_control.Bob.status == Ended) running = 0; break; } c_sleep(20); } } printf("\n"); | 156 | if (status_control.Alice.status == Ended && status_control.Bob.status == Ended) running = 0; break; } c_sleep(20); } } printf("\n"); |
155 | 157 | ||
156 | START_TEST(test_AV) | 158 | START_TEST(test_AV_flows) |
157 | { | 159 | { |
158 | long long unsigned int cur_time = time(NULL); | 160 | long long unsigned int cur_time = time(NULL); |
159 | Tox *bootstrap_node = tox_new(0); | 161 | Tox *bootstrap_node = tox_new(0); |
@@ -166,7 +168,7 @@ START_TEST(test_AV) | |||
166 | tox_callback_friend_request(Alice, accept_friend_request, &to_compare); | 168 | tox_callback_friend_request(Alice, accept_friend_request, &to_compare); |
167 | uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; | 169 | uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; |
168 | tox_get_address(Alice, address); | 170 | tox_get_address(Alice, address); |
169 | int test = tox_add_friend(Bob, address, (uint8_t *)"ILIKESMALLTITS", 15); | 171 | int test = tox_add_friend(Bob, address, (uint8_t *)"gentoo", 7); |
170 | 172 | ||
171 | ck_assert_msg(test == 0, "Failed to add friend error code: %i", test); | 173 | ck_assert_msg(test == 0, "Failed to add friend error code: %i", test); |
172 | 174 | ||
@@ -195,8 +197,8 @@ START_TEST(test_AV) | |||
195 | muhcaps.video_height = muhcaps.video_width = 128; | 197 | muhcaps.video_height = muhcaps.video_width = 128; |
196 | 198 | ||
197 | Status status_control = { | 199 | Status status_control = { |
198 | {none, toxav_new(Alice, &muhcaps), NULL}, | 200 | {none, toxav_new(Alice, &muhcaps, 1), NULL}, |
199 | {none, toxav_new(Bob, &muhcaps), NULL}, | 201 | {none, toxav_new(Bob, &muhcaps, 1), NULL}, |
200 | }; | 202 | }; |
201 | 203 | ||
202 | 204 | ||
@@ -235,23 +237,23 @@ START_TEST(test_AV) | |||
235 | */ | 237 | */ |
236 | CALL_AND_START_LOOP(TypeAudio, TypeAudio) { | 238 | CALL_AND_START_LOOP(TypeAudio, TypeAudio) { |
237 | /* Both send */ | 239 | /* Both send */ |
238 | toxav_send_audio(status_control.Alice.av, sample_payload, 10); | 240 | toxav_send_audio(status_control.Alice.av, status_control.Alice.call_index, sample_payload, 10); |
239 | toxav_send_audio(status_control.Bob.av, sample_payload, 10); | 241 | toxav_send_audio(status_control.Bob.av, status_control.Bob.call_index, sample_payload, 10); |
240 | 242 | ||
241 | /* Both receive */ | 243 | /* Both receive */ |
242 | int16_t storage[10]; | 244 | int16_t storage[10]; |
243 | int recved; | 245 | int recved; |
244 | 246 | ||
245 | /* Payload from Alice */ | 247 | /* Payload from Bob */ |
246 | recved = toxav_recv_audio(status_control.Alice.av, 10, storage); | 248 | recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, 10, storage); |
247 | 249 | ||
248 | if ( recved ) { | 250 | if ( recved ) { |
249 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ | 251 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ |
250 | memset(storage, 0, 10); | 252 | memset(storage, 0, 10); |
251 | } | 253 | } |
252 | 254 | ||
253 | /* Payload from Bob */ | 255 | /* Payload from Alice */ |
254 | recved = toxav_recv_audio(status_control.Bob.av, 10, storage); | 256 | recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, 10, storage); |
255 | 257 | ||
256 | if ( recved ) { | 258 | if ( recved ) { |
257 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ | 259 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ |
@@ -259,11 +261,11 @@ START_TEST(test_AV) | |||
259 | 261 | ||
260 | if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */ | 262 | if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */ |
261 | step++; /* This terminates the loop */ | 263 | step++; /* This terminates the loop */ |
262 | toxav_kill_transmission(status_control.Alice.av); | 264 | toxav_kill_transmission(status_control.Alice.av, status_control.Alice.call_index); |
263 | toxav_kill_transmission(status_control.Bob.av); | 265 | toxav_kill_transmission(status_control.Bob.av, status_control.Bob.call_index); |
264 | 266 | ||
265 | /* Call over Alice hangs up */ | 267 | /* Call over Alice hangs up */ |
266 | toxav_hangup(status_control.Alice.av); | 268 | toxav_hangup(status_control.Alice.av, status_control.Alice.call_index); |
267 | } | 269 | } |
268 | } | 270 | } |
269 | TERMINATE_SCOPE() | 271 | TERMINATE_SCOPE() |
@@ -274,10 +276,10 @@ START_TEST(test_AV) | |||
274 | */ | 276 | */ |
275 | CALL_AND_START_LOOP(TypeAudio, TypeVideo) { | 277 | CALL_AND_START_LOOP(TypeAudio, TypeVideo) { |
276 | /* Both send */ | 278 | /* Both send */ |
277 | toxav_send_audio(status_control.Alice.av, sample_payload, 10); | 279 | toxav_send_audio(status_control.Alice.av, status_control.Alice.call_index, sample_payload, 10); |
278 | 280 | ||
279 | toxav_send_audio(status_control.Bob.av, sample_payload, 10); | 281 | toxav_send_audio(status_control.Bob.av, status_control.Bob.call_index, sample_payload, 10); |
280 | toxav_send_video(status_control.Bob.av, sample_image); | 282 | toxav_send_video(status_control.Bob.av, status_control.Bob.call_index, sample_image); |
281 | 283 | ||
282 | /* Both receive */ | 284 | /* Both receive */ |
283 | int16_t storage[10]; | 285 | int16_t storage[10]; |
@@ -285,7 +287,7 @@ START_TEST(test_AV) | |||
285 | int recved; | 287 | int recved; |
286 | 288 | ||
287 | /* Payload from Bob */ | 289 | /* Payload from Bob */ |
288 | recved = toxav_recv_audio(status_control.Alice.av, 10, storage); | 290 | recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, 10, storage); |
289 | 291 | ||
290 | if ( recved ) { | 292 | if ( recved ) { |
291 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ | 293 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ |
@@ -293,7 +295,7 @@ START_TEST(test_AV) | |||
293 | } | 295 | } |
294 | 296 | ||
295 | /* Video payload */ | 297 | /* Video payload */ |
296 | toxav_recv_video(status_control.Alice.av, &video_storage); | 298 | toxav_recv_video(status_control.Alice.av, status_control.Alice.call_index, &video_storage); |
297 | 299 | ||
298 | if ( video_storage ) { | 300 | if ( video_storage ) { |
299 | /*ck_assert_msg( memcmp(video_storage->planes[VPX_PLANE_Y], sample_payload, 10) == 0 || | 301 | /*ck_assert_msg( memcmp(video_storage->planes[VPX_PLANE_Y], sample_payload, 10) == 0 || |
@@ -305,7 +307,7 @@ START_TEST(test_AV) | |||
305 | 307 | ||
306 | 308 | ||
307 | /* Payload from Alice */ | 309 | /* Payload from Alice */ |
308 | recved = toxav_recv_audio(status_control.Bob.av, 10, storage); | 310 | recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, 10, storage); |
309 | 311 | ||
310 | if ( recved ) { | 312 | if ( recved ) { |
311 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ | 313 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ |
@@ -313,11 +315,11 @@ START_TEST(test_AV) | |||
313 | 315 | ||
314 | if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */ | 316 | if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */ |
315 | step++; /* This terminates the loop */ | 317 | step++; /* This terminates the loop */ |
316 | toxav_kill_transmission(status_control.Alice.av); | 318 | toxav_kill_transmission(status_control.Alice.av, status_control.Alice.call_index); |
317 | toxav_kill_transmission(status_control.Bob.av); | 319 | toxav_kill_transmission(status_control.Bob.av, status_control.Bob.call_index); |
318 | 320 | ||
319 | /* Call over Alice hangs up */ | 321 | /* Call over Alice hangs up */ |
320 | toxav_hangup(status_control.Alice.av); | 322 | toxav_hangup(status_control.Alice.av, status_control.Alice.call_index); |
321 | } | 323 | } |
322 | } | 324 | } |
323 | TERMINATE_SCOPE() | 325 | TERMINATE_SCOPE() |
@@ -328,11 +330,11 @@ START_TEST(test_AV) | |||
328 | */ | 330 | */ |
329 | CALL_AND_START_LOOP(TypeVideo, TypeVideo) { | 331 | CALL_AND_START_LOOP(TypeVideo, TypeVideo) { |
330 | /* Both send */ | 332 | /* Both send */ |
331 | toxav_send_audio(status_control.Alice.av, sample_payload, 10); | 333 | toxav_send_audio(status_control.Alice.av, status_control.Alice.call_index, sample_payload, 10); |
332 | toxav_send_video(status_control.Alice.av, sample_image); | 334 | toxav_send_video(status_control.Alice.av, status_control.Alice.call_index, sample_image); |
333 | 335 | ||
334 | toxav_send_audio(status_control.Bob.av, sample_payload, 10); | 336 | toxav_send_audio(status_control.Bob.av, status_control.Bob.call_index, sample_payload, 10); |
335 | toxav_send_video(status_control.Bob.av, sample_image); | 337 | toxav_send_video(status_control.Bob.av, status_control.Bob.call_index, sample_image); |
336 | 338 | ||
337 | /* Both receive */ | 339 | /* Both receive */ |
338 | int16_t storage[10]; | 340 | int16_t storage[10]; |
@@ -340,7 +342,7 @@ START_TEST(test_AV) | |||
340 | int recved; | 342 | int recved; |
341 | 343 | ||
342 | /* Payload from Bob */ | 344 | /* Payload from Bob */ |
343 | recved = toxav_recv_audio(status_control.Alice.av, 10, storage); | 345 | recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, 10, storage); |
344 | 346 | ||
345 | if ( recved ) { | 347 | if ( recved ) { |
346 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ | 348 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ |
@@ -348,7 +350,7 @@ START_TEST(test_AV) | |||
348 | } | 350 | } |
349 | 351 | ||
350 | /* Video payload */ | 352 | /* Video payload */ |
351 | toxav_recv_video(status_control.Alice.av, &video_storage); | 353 | toxav_recv_video(status_control.Alice.av, status_control.Alice.call_index, &video_storage); |
352 | 354 | ||
353 | if ( video_storage ) { | 355 | if ( video_storage ) { |
354 | /*ck_assert_msg( memcmp(video_storage->planes[VPX_PLANE_Y], sample_payload, 10) == 0 || | 356 | /*ck_assert_msg( memcmp(video_storage->planes[VPX_PLANE_Y], sample_payload, 10) == 0 || |
@@ -360,14 +362,14 @@ START_TEST(test_AV) | |||
360 | 362 | ||
361 | 363 | ||
362 | /* Payload from Alice */ | 364 | /* Payload from Alice */ |
363 | recved = toxav_recv_audio(status_control.Bob.av, 10, storage); | 365 | recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, 10, storage); |
364 | 366 | ||
365 | if ( recved ) { | 367 | if ( recved ) { |
366 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ | 368 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ |
367 | } | 369 | } |
368 | 370 | ||
369 | /* Video payload */ | 371 | /* Video payload */ |
370 | toxav_recv_video(status_control.Bob.av, &video_storage); | 372 | toxav_recv_video(status_control.Bob.av, status_control.Bob.call_index, &video_storage); |
371 | 373 | ||
372 | if ( video_storage ) { | 374 | if ( video_storage ) { |
373 | /*ck_assert_msg( memcmp(video_storage->planes[VPX_PLANE_Y], sample_payload, 10) == 0 || | 375 | /*ck_assert_msg( memcmp(video_storage->planes[VPX_PLANE_Y], sample_payload, 10) == 0 || |
@@ -378,11 +380,11 @@ START_TEST(test_AV) | |||
378 | 380 | ||
379 | if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */ | 381 | if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */ |
380 | step++; /* This terminates the loop */ | 382 | step++; /* This terminates the loop */ |
381 | toxav_kill_transmission(status_control.Alice.av); | 383 | toxav_kill_transmission(status_control.Alice.av, status_control.Alice.call_index); |
382 | toxav_kill_transmission(status_control.Bob.av); | 384 | toxav_kill_transmission(status_control.Bob.av, status_control.Bob.call_index); |
383 | 385 | ||
384 | /* Call over Alice hangs up */ | 386 | /* Call over Alice hangs up */ |
385 | toxav_hangup(status_control.Alice.av); | 387 | toxav_hangup(status_control.Alice.av, status_control.Alice.call_index); |
386 | } | 388 | } |
387 | } | 389 | } |
388 | TERMINATE_SCOPE() | 390 | TERMINATE_SCOPE() |
@@ -408,7 +410,7 @@ START_TEST(test_AV) | |||
408 | switch ( step ) { | 410 | switch ( step ) { |
409 | case 0: /* Alice */ | 411 | case 0: /* Alice */ |
410 | printf("Alice is calling...\n"); | 412 | printf("Alice is calling...\n"); |
411 | toxav_call(status_control.Alice.av, 0, TypeAudio, 10); | 413 | toxav_call(status_control.Alice.av, &status_control.Alice.call_index, 0, TypeAudio, 10); |
412 | step++; | 414 | step++; |
413 | break; | 415 | break; |
414 | \ | 416 | \ |
@@ -416,7 +418,7 @@ START_TEST(test_AV) | |||
416 | case 1: /* Bob */ | 418 | case 1: /* Bob */ |
417 | if (status_control.Bob.status == Ringing) { | 419 | if (status_control.Bob.status == Ringing) { |
418 | printf("Bob rejects...\n"); | 420 | printf("Bob rejects...\n"); |
419 | toxav_reject(status_control.Bob.av, "Who likes D's anyway?"); | 421 | toxav_reject(status_control.Bob.av, status_control.Bob.call_index, "Who likes D's anyway?"); |
420 | step++; | 422 | step++; |
421 | } | 423 | } |
422 | 424 | ||
@@ -450,7 +452,7 @@ START_TEST(test_AV) | |||
450 | switch ( step ) { | 452 | switch ( step ) { |
451 | case 0: /* Alice */ | 453 | case 0: /* Alice */ |
452 | printf("Alice is calling...\n"); | 454 | printf("Alice is calling...\n"); |
453 | toxav_call(status_control.Alice.av, 0, TypeAudio, 10); | 455 | toxav_call(status_control.Alice.av, &status_control.Alice.call_index, 0, TypeAudio, 10); |
454 | step++; | 456 | step++; |
455 | break; | 457 | break; |
456 | \ | 458 | \ |
@@ -458,7 +460,7 @@ START_TEST(test_AV) | |||
458 | case 1: /* Alice again */ | 460 | case 1: /* Alice again */ |
459 | if (status_control.Bob.status == Ringing) { | 461 | if (status_control.Bob.status == Ringing) { |
460 | printf("Alice cancels...\n"); | 462 | printf("Alice cancels...\n"); |
461 | toxav_cancel(status_control.Alice.av, 0, "Who likes D's anyway?"); | 463 | toxav_cancel(status_control.Alice.av, status_control.Alice.call_index, 0, "Who likes D's anyway?"); |
462 | step++; | 464 | step++; |
463 | } | 465 | } |
464 | 466 | ||
@@ -484,20 +486,29 @@ END_TEST | |||
484 | /*************************************************************************************************/ | 486 | /*************************************************************************************************/ |
485 | 487 | ||
486 | 488 | ||
489 | /*************************************************************************************************/ | ||
490 | |||
491 | /*************************************************************************************************/ | ||
492 | |||
487 | 493 | ||
488 | Suite *tox_suite(void) | 494 | Suite *tox_suite(void) |
489 | { | 495 | { |
490 | Suite *s = suite_create("ToxAV"); | 496 | Suite *s = suite_create("ToxAV"); |
491 | 497 | ||
492 | TCase *tc_av = tcase_create("A/V"); | 498 | TCase *tc_av_flows = tcase_create("AV_flows"); |
493 | tcase_add_test(tc_av, test_AV); | 499 | tcase_add_test(tc_av_flows, test_AV_flows); |
494 | tcase_set_timeout(tc_av, 100); /* Timeout on 100 too much? */ | 500 | tcase_set_timeout(tc_av_flows, 100); /* Timeout on 100 too much? */ |
495 | suite_add_tcase(s, tc_av); | 501 | suite_add_tcase(s, tc_av_flows); |
502 | |||
503 | TCase *tc_av_three_calls = tcase_create("AV_three_calls"); | ||
504 | tcase_add_test(tc_av_three_calls, test_AV_three_calls); | ||
505 | tcase_set_timeout(tc_av_three_calls, 100); /* Timeout on 100 too much? */ | ||
506 | suite_add_tcase(s, tc_av_three_calls); | ||
496 | 507 | ||
497 | return s; | 508 | return s; |
498 | } | 509 | } |
499 | int main(int argc, char *argv[]) | 510 | int main(int argc, char *argv[]) |
500 | { | 511 | { |
501 | Suite *tox = tox_suite(); | 512 | Suite *tox = tox_suite(); |
502 | SRunner *test_runner = srunner_create(tox); | 513 | SRunner *test_runner = srunner_create(tox); |
503 | 514 | ||