diff options
author | irungentoo <irungentoo@gmail.com> | 2014-07-07 19:55:06 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-07-07 19:55:06 -0400 |
commit | 909db029412ddbd499281711a9cd46c3df4fe5a0 (patch) | |
tree | b453c6fc5444b8cbe4024415342d9ce9b995cd6a /auto_tests/toxav_many_test.c | |
parent | b4f43b4222eb033ee9af940641a00535f6091e95 (diff) | |
parent | b90ecb377d59384770a594abc5c5e3022e99adc8 (diff) |
Merge branch 'split-video' of https://github.com/notsecure/toxcore
Diffstat (limited to 'auto_tests/toxav_many_test.c')
-rw-r--r-- | auto_tests/toxav_many_test.c | 36 |
1 files changed, 29 insertions, 7 deletions
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 | ||
27 | pthread_mutex_t muhmutex; | ||
27 | 28 | ||
28 | typedef enum _CallStatus { | 29 | typedef 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 | |||
129 | static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length) | ||
130 | { | ||
131 | } | ||
132 | |||
133 | static 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 | } |