diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-05-10 18:00:49 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-05-10 18:00:49 +0200 |
commit | 9bb910a370725696cc3169c795f903c24e7d126f (patch) | |
tree | 3c63f103a0b883f71007c697aa19c18c8e4c9330 /auto_tests/toxav_many_test.c | |
parent | 0fa03b924030c5791599451389ba84b81be84da8 (diff) |
This should work
Diffstat (limited to 'auto_tests/toxav_many_test.c')
-rw-r--r-- | auto_tests/toxav_many_test.c | 81 |
1 files changed, 31 insertions, 50 deletions
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 7ffa5138..77f3717e 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -131,12 +131,9 @@ void* in_thread_call (void* arg) | |||
131 | int step = 0,running = 1; | 131 | int step = 0,running = 1; |
132 | int call_idx; | 132 | int call_idx; |
133 | 133 | ||
134 | int16_t sample_payload[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; | ||
135 | vpx_image_t *sample_image = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, 128, 128, 1); | ||
136 | 134 | ||
137 | memcpy(sample_image->planes[VPX_PLANE_Y], sample_payload, 10); | 135 | int16_t sample_payload[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
138 | memcpy(sample_image->planes[VPX_PLANE_U], sample_payload, 10); | 136 | uint8_t prepared_payload[1000]; |
139 | memcpy(sample_image->planes[VPX_PLANE_V], sample_payload, 10); | ||
140 | 137 | ||
141 | 138 | ||
142 | /* NOTE: CALLEE WILL ALWAHYS NEED CALL_IDX == 0 */ | 139 | /* NOTE: CALLEE WILL ALWAHYS NEED CALL_IDX == 0 */ |
@@ -159,60 +156,43 @@ void* in_thread_call (void* arg) | |||
159 | if (this_call->Caller.status == InCall) { /* I think this is okay */ | 156 | if (this_call->Caller.status == InCall) { /* I think this is okay */ |
160 | call_print(call_idx, "Sending rtp ..."); | 157 | call_print(call_idx, "Sending rtp ..."); |
161 | 158 | ||
159 | ToxAvCodecSettings cast = av_DefaultSettings; | ||
160 | |||
162 | c_sleep(1000); /* We have race condition here */ | 161 | c_sleep(1000); /* We have race condition here */ |
163 | toxav_prepare_transmission(this_call->Callee.av, 0, 1); | 162 | toxav_prepare_transmission(this_call->Callee.av, 0, &cast, 1); |
164 | toxav_prepare_transmission(this_call->Caller.av, call_idx, 1); | 163 | toxav_prepare_transmission(this_call->Caller.av, call_idx, &cast, 1); |
164 | |||
165 | int payload_size = toxav_prepare_audio_frame(this_call->Caller.av, call_idx, prepared_payload, 1000, sample_payload, 120); | ||
166 | if (!( payload_size > 0 )) { | ||
167 | ck_assert_msg ( 0, "Failed to encode payload" ); | ||
168 | } | ||
165 | 169 | ||
166 | while (time(NULL) - start < 10) { /* 10 seconds */ | 170 | while (time(NULL) - start < 10) { /* 10 seconds */ |
167 | /* Both send */ | 171 | /* Both send */ |
168 | toxav_send_audio(this_call->Caller.av, call_idx, sample_payload, 10); | 172 | toxav_send_audio(this_call->Caller.av, call_idx, prepared_payload, payload_size); |
169 | toxav_send_video(this_call->Caller.av, call_idx, sample_image); | ||
170 | 173 | ||
171 | toxav_send_audio(this_call->Callee.av, 0, sample_payload, 10); | 174 | toxav_send_audio(this_call->Callee.av, 0, prepared_payload, payload_size); |
172 | toxav_send_video(this_call->Callee.av, 0, sample_image); | ||
173 | 175 | ||
176 | call_print(time(NULL) - start, "Blaaah"); | ||
174 | /* Both receive */ | 177 | /* Both receive */ |
175 | int16_t storage[10]; | 178 | int16_t storage[1000]; |
176 | vpx_image_t *video_storage; | ||
177 | int recved; | 179 | int recved; |
178 | 180 | ||
179 | /* Payload from CALLEE */ | ||
180 | recved = toxav_recv_audio(this_call->Caller.av, call_idx, 10, storage); | ||
181 | |||
182 | if ( recved ) { | ||
183 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLEE is invalid");*/ | ||
184 | memset(storage, 0, 10); | ||
185 | } | ||
186 | |||
187 | /* Video payload */ | ||
188 | toxav_recv_video(this_call->Caller.av, call_idx, &video_storage); | ||
189 | |||
190 | if ( video_storage ) { | ||
191 | /*ck_assert_msg( memcmp(video_storage->planes[VPX_PLANE_Y], sample_payload, 10) == 0 || | ||
192 | * memcmp(video_storage->planes[VPX_PLANE_U], sample_payload, 10) == 0 || | ||
193 | * memcmp(video_storage->planes[VPX_PLANE_V], sample_payload, 10) == 0 , "Payload from CALLEE is invalid");*/ | ||
194 | vpx_img_free(video_storage); | ||
195 | } | ||
196 | |||
197 | |||
198 | |||
199 | /* Payload from CALLER */ | 181 | /* Payload from CALLER */ |
200 | recved = toxav_recv_audio(this_call->Callee.av, 0, 10, storage); | 182 | recved = toxav_recv_audio(this_call->Callee.av, 0, 120, storage); |
201 | 183 | ||
202 | if ( recved ) { | 184 | if ( recved ) { |
203 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLER is invalid");*/ | 185 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLER is invalid");*/ |
204 | } | 186 | } |
205 | 187 | ||
206 | /* Video payload */ | 188 | /* Payload from CALLEE */ |
207 | toxav_recv_video(this_call->Callee.av, 0, &video_storage); | 189 | recved = toxav_recv_audio(this_call->Caller.av, call_idx, 120, storage); |
208 | |||
209 | if ( video_storage ) { | ||
210 | /*ck_assert_msg( memcmp(video_storage->planes[VPX_PLANE_Y], sample_payload, 10) == 0 || | ||
211 | * memcmp(video_storage->planes[VPX_PLANE_U], sample_payload, 10) == 0 || | ||
212 | * memcmp(video_storage->planes[VPX_PLANE_V], sample_payload, 10) == 0 , "Payload from CALLER is invalid");*/ | ||
213 | vpx_img_free(video_storage); | ||
214 | } | ||
215 | 190 | ||
191 | if ( recved ) { | ||
192 | /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLEE is invalid");*/ | ||
193 | } | ||
194 | |||
195 | //c_sleep(20); | ||
216 | } | 196 | } |
217 | 197 | ||
218 | step++; /* This terminates the loop */ | 198 | step++; /* This terminates the loop */ |
@@ -247,6 +227,7 @@ void* in_thread_call (void* arg) | |||
247 | 227 | ||
248 | 228 | ||
249 | START_TEST(test_AV_three_calls) | 229 | START_TEST(test_AV_three_calls) |
230 | // void test_AV_three_calls() | ||
250 | { | 231 | { |
251 | long long unsigned int cur_time = time(NULL); | 232 | long long unsigned int cur_time = time(NULL); |
252 | Tox *bootstrap_node = tox_new(0); | 233 | Tox *bootstrap_node = tox_new(0); |
@@ -306,23 +287,20 @@ START_TEST(test_AV_three_calls) | |||
306 | 287 | ||
307 | printf("All set after %llu seconds! Starting call...\n", time(NULL) - cur_time); | 288 | printf("All set after %llu seconds! Starting call...\n", time(NULL) - cur_time); |
308 | 289 | ||
309 | 290 | ToxAv* uniqcallerav = toxav_new(caller, 3); | |
310 | ToxAvCodecSettings cast = av_DefaultSettings; | ||
311 | |||
312 | ToxAv* uniqcallerav = toxav_new(caller, &cast, 3); | ||
313 | 291 | ||
314 | Status status_control = { | 292 | Status status_control = { |
315 | 0, | 293 | 0, |
316 | {none, uniqcallerav, 0}, | 294 | {none, uniqcallerav, 0}, |
317 | {none, toxav_new(callees[0], &cast, 1), 0}, | 295 | {none, toxav_new(callees[0], 1), 0}, |
318 | 296 | ||
319 | 0, | 297 | 0, |
320 | {none, uniqcallerav}, | 298 | {none, uniqcallerav}, |
321 | {none, toxav_new(callees[1], &cast, 1), 1}, | 299 | {none, toxav_new(callees[1], 1), 1}, |
322 | 300 | ||
323 | 0, | 301 | 0, |
324 | {none, uniqcallerav}, | 302 | {none, uniqcallerav}, |
325 | {none, toxav_new(callees[2], &cast, 1), 2} | 303 | {none, toxav_new(callees[2], 1), 2} |
326 | }; | 304 | }; |
327 | 305 | ||
328 | 306 | ||
@@ -404,4 +382,7 @@ int main(int argc, char *argv[]) | |||
404 | 382 | ||
405 | return number_failed; | 383 | return number_failed; |
406 | 384 | ||
385 | // test_AV_three_calls(); | ||
386 | // | ||
387 | // return 0; | ||
407 | } \ No newline at end of file | 388 | } \ No newline at end of file |