summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-07-07 19:55:06 -0400
committerirungentoo <irungentoo@gmail.com>2014-07-07 19:55:06 -0400
commit909db029412ddbd499281711a9cd46c3df4fe5a0 (patch)
treeb453c6fc5444b8cbe4024415342d9ce9b995cd6a /auto_tests
parentb4f43b4222eb033ee9af940641a00535f6091e95 (diff)
parentb90ecb377d59384770a594abc5c5e3022e99adc8 (diff)
Merge branch 'split-video' of https://github.com/notsecure/toxcore
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/toxav_basic_test.c48
-rw-r--r--auto_tests/toxav_many_test.c36
2 files changed, 60 insertions, 24 deletions
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c
index 0a710746..bf130ecb 100644
--- a/auto_tests/toxav_basic_test.c
+++ b/auto_tests/toxav_basic_test.c
@@ -138,6 +138,15 @@ void callback_requ_timeout ( int32_t call_index, void *_arg )
138{ 138{
139 ck_assert_msg(0, "No answer!"); 139 ck_assert_msg(0, "No answer!");
140} 140}
141
142static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length)
143{
144}
145
146static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img)
147{
148}
149
141/*************************************************************************************************/ 150/*************************************************************************************************/
142 151
143/* Alice calls bob and the call starts. 152/* Alice calls bob and the call starts.
@@ -222,6 +231,10 @@ START_TEST(test_AV_flows)
222 toxav_register_callstate_callback(callback_recv_error, av_OnError, &status_control); 231 toxav_register_callstate_callback(callback_recv_error, av_OnError, &status_control);
223 toxav_register_callstate_callback(callback_requ_timeout, av_OnRequestTimeout, &status_control); 232 toxav_register_callstate_callback(callback_requ_timeout, av_OnRequestTimeout, &status_control);
224 233
234 toxav_register_audio_recv_callback(status_control.Alice.av, callback_audio);
235 toxav_register_video_recv_callback(status_control.Alice.av, callback_video);
236 toxav_register_audio_recv_callback(status_control.Bob.av, callback_audio);
237 toxav_register_video_recv_callback(status_control.Bob.av, callback_video);
225 238
226 const int frame_size = (av_DefaultSettings.audio_sample_rate * av_DefaultSettings.audio_frame_duration / 1000); 239 const int frame_size = (av_DefaultSettings.audio_sample_rate * av_DefaultSettings.audio_frame_duration / 1000);
227 int16_t sample_payload[frame_size]; 240 int16_t sample_payload[frame_size];
@@ -267,21 +280,22 @@ START_TEST(test_AV_flows)
267 toxav_send_audio(status_control.Bob.av, status_control.Bob.call_index, prepared_payload, payload_size); 280 toxav_send_audio(status_control.Bob.av, status_control.Bob.call_index, prepared_payload, payload_size);
268 281
269 /* Both receive */ 282 /* Both receive */
270 int16_t storage[frame_size]; 283 /*int16_t storage[frame_size];
271 int recved; 284 int recved;
272 285
273 /* Payload from Bob */ 286 /* Payload from Bob */
274 recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, frame_size, storage); 287
288 /*recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, frame_size, storage);
275 289
276 if ( recved ) { 290 if ( recved ) {
277 /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ 291 //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
278 } 292 }
279 293
280 recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, frame_size, storage); 294 recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, frame_size, storage);
281 295
282 if ( recved ) { 296 if ( recved ) {
283 /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ 297 //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
284 } 298 }*/
285 299
286 if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */ 300 if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */
287 step++; /* This terminates the loop */ 301 step++; /* This terminates the loop */
@@ -326,11 +340,11 @@ START_TEST(test_AV_flows)
326 int recved; 340 int recved;
327 341
328 /* Payload from Bob */ 342 /* Payload from Bob */
329 recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, frame_size, storage); 343 /*recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, frame_size, storage);
330 344
331 if ( recved ) { 345 if ( recved ) {
332 /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ 346 //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
333 } 347 }*/
334 348
335 /* Video payload */ 349 /* Video payload */
336// toxav_recv_video(status_control.Alice.av, status_control.Alice.call_index, &video_storage); 350// toxav_recv_video(status_control.Alice.av, status_control.Alice.call_index, &video_storage);
@@ -346,11 +360,11 @@ START_TEST(test_AV_flows)
346 360
347 361
348 /* Payload from Alice */ 362 /* Payload from Alice */
349 recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, frame_size, storage); 363 /*recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, frame_size, storage);
350 364
351 if ( recved ) { 365 if ( recved ) {
352 /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ 366 //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
353 } 367 }*/
354 368
355 if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */ 369 if (time(NULL) - cur_time > 10) { /* Transmit for 10 seconds */
356 step++; /* This terminates the loop */ 370 step++; /* This terminates the loop */
@@ -397,11 +411,11 @@ START_TEST(test_AV_flows)
397 int recved; 411 int recved;
398 412
399 /* Payload from Bob */ 413 /* Payload from Bob */
400 recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, frame_size, storage); 414 /*recved = toxav_recv_audio(status_control.Alice.av, status_control.Alice.call_index, frame_size, storage);
401 415
402 if ( recved ) { 416 if ( recved ) {
403 /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");*/ 417 //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
404 } 418 }*/
405 419
406 /* Video payload */ 420 /* Video payload */
407// toxav_recv_video(status_control.Alice.av, status_control.Alice.call_index, &video_storage); 421// toxav_recv_video(status_control.Alice.av, status_control.Alice.call_index, &video_storage);
@@ -417,11 +431,11 @@ START_TEST(test_AV_flows)
417 431
418 432
419 /* Payload from Alice */ 433 /* Payload from Alice */
420 recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, frame_size, storage); 434 /*recved = toxav_recv_audio(status_control.Bob.av, status_control.Bob.call_index, frame_size, storage);
421 435
422 if ( recved ) { 436 if ( recved ) {
423 /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");*/ 437 ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
424 } 438 }*/
425 439
426 /* Video payload */ 440 /* Video payload */
427// toxav_recv_video(status_control.Bob.av, status_control.Bob.call_index, &video_storage); 441// toxav_recv_video(status_control.Bob.av, status_control.Bob.call_index, &video_storage);
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c
index 2a931cb0..3195d1ed 100644
--- a/auto_tests/toxav_many_test.c
+++ b/auto_tests/toxav_many_test.c
@@ -24,6 +24,7 @@
24#define c_sleep(x) usleep(1000*x) 24#define c_sleep(x) usleep(1000*x)
25#endif 25#endif
26 26
27pthread_mutex_t muhmutex;
27 28
28typedef enum _CallStatus { 29typedef enum _CallStatus {
29 none, 30 none,
@@ -124,6 +125,14 @@ void callback_requ_timeout ( int32_t call_index, void *_arg )
124{ 125{
125 ck_assert_msg(0, "No answer!"); 126 ck_assert_msg(0, "No answer!");
126} 127}
128
129static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length)
130{
131}
132
133static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img)
134{
135}
127/*************************************************************************************************/ 136/*************************************************************************************************/
128 137
129 138
@@ -142,6 +151,11 @@ void *in_thread_call (void *arg)
142 151
143 uint8_t prepared_payload[RTP_PAYLOAD_SIZE]; 152 uint8_t prepared_payload[RTP_PAYLOAD_SIZE];
144 153
154 toxav_register_audio_recv_callback(this_call->Caller.av, callback_audio);
155 toxav_register_video_recv_callback(this_call->Caller.av, callback_video);
156 toxav_register_audio_recv_callback(this_call->Callee.av, callback_audio);
157 toxav_register_video_recv_callback(this_call->Callee.av, callback_video);
158
145 159
146 /* NOTE: CALLEE WILL ALWAHYS NEED CALL_IDX == 0 */ 160 /* NOTE: CALLEE WILL ALWAHYS NEED CALL_IDX == 0 */
147 while (running) { 161 while (running) {
@@ -192,26 +206,28 @@ void *in_thread_call (void *arg)
192 int recved; 206 int recved;
193 207
194 /* Payload from CALLER */ 208 /* Payload from CALLER */
195 recved = toxav_recv_audio(this_call->Callee.av, 0, frame_size, storage); 209 /*recved = toxav_recv_audio(this_call->Callee.av, 0, frame_size, storage);
196 210
197 if ( recved ) { 211 if ( recved ) {
198 /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLER is invalid");*/ 212 //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLER is invalid");
199 } 213 }*/
200 214
201 /* Payload from CALLEE */ 215 /* Payload from CALLEE */
202 recved = toxav_recv_audio(this_call->Caller.av, call_idx, frame_size, storage); 216 /*recved = toxav_recv_audio(this_call->Caller.av, call_idx, frame_size, storage);
203 217
204 if ( recved ) { 218 if ( recved ) {
205 /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLEE is invalid");*/ 219 //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLEE is invalid");
206 } 220 }*/
207 221
208 c_sleep(20); 222 c_sleep(20);
209 } 223 }
210 224
211 step++; /* This terminates the loop */ 225 step++; /* This terminates the loop */
212 226
227 pthread_mutex_lock(&muhmutex);
213 toxav_kill_transmission(this_call->Callee.av, 0); 228 toxav_kill_transmission(this_call->Callee.av, 0);
214 toxav_kill_transmission(this_call->Caller.av, call_idx); 229 toxav_kill_transmission(this_call->Caller.av, call_idx);
230 pthread_mutex_unlock(&muhmutex);
215 231
216 /* Call over CALLER hangs up */ 232 /* Call over CALLER hangs up */
217 toxav_hangup(this_call->Caller.av, call_idx); 233 toxav_hangup(this_call->Caller.av, call_idx);
@@ -335,6 +351,8 @@ START_TEST(test_AV_three_calls)
335 toxav_register_callstate_callback(callback_requ_timeout, av_OnRequestTimeout, &status_control); 351 toxav_register_callstate_callback(callback_requ_timeout, av_OnRequestTimeout, &status_control);
336 352
337 353
354 pthread_mutex_init(&muhmutex, NULL);
355
338 356
339 for ( i = 0; i < 3; i++ ) 357 for ( i = 0; i < 3; i++ )
340 pthread_create(&status_control.calls[i].tid, NULL, in_thread_call, &status_control.calls[i]); 358 pthread_create(&status_control.calls[i].tid, NULL, in_thread_call, &status_control.calls[i]);
@@ -350,11 +368,15 @@ START_TEST(test_AV_three_calls)
350 status_control.calls[1].Callee.status != Ended && status_control.calls[1].Caller.status != Ended && 368 status_control.calls[1].Callee.status != Ended && status_control.calls[1].Caller.status != Ended &&
351 status_control.calls[2].Callee.status != Ended && status_control.calls[2].Caller.status != Ended 369 status_control.calls[2].Callee.status != Ended && status_control.calls[2].Caller.status != Ended
352 ) { 370 ) {
371 pthread_mutex_lock(&muhmutex);
372
353 tox_do(bootstrap_node); 373 tox_do(bootstrap_node);
354 tox_do(caller); 374 tox_do(caller);
355 tox_do(callees[0]); 375 tox_do(callees[0]);
356 tox_do(callees[1]); 376 tox_do(callees[1]);
357 tox_do(callees[2]); 377 tox_do(callees[2]);
378
379 pthread_mutex_unlock(&muhmutex);
358 c_sleep(20); 380 c_sleep(20);
359 } 381 }
360 382
@@ -403,4 +425,4 @@ int main(int argc, char *argv[])
403// test_AV_three_calls(); 425// test_AV_three_calls();
404// 426//
405// return 0; 427// return 0;
406} \ No newline at end of file 428}