diff options
Diffstat (limited to 'testing/av_test.c')
-rw-r--r-- | testing/av_test.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/testing/av_test.c b/testing/av_test.c index ce982e32..0d61edec 100644 --- a/testing/av_test.c +++ b/testing/av_test.c | |||
@@ -111,7 +111,7 @@ struct toxav_thread_data { | |||
111 | }; | 111 | }; |
112 | 112 | ||
113 | static const char *vdout = "AV Test"; /* Video output */ | 113 | static const char *vdout = "AV Test"; /* Video output */ |
114 | static PaStream *adout = NULL; /* Audio output */ | 114 | static PaStream *adout = nullptr; /* Audio output */ |
115 | 115 | ||
116 | typedef struct { | 116 | typedef struct { |
117 | uint16_t size; | 117 | uint16_t size; |
@@ -139,7 +139,7 @@ static void *pa_write_thread(void *d) | |||
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | return NULL; | 142 | return nullptr; |
143 | } | 143 | } |
144 | 144 | ||
145 | /** | 145 | /** |
@@ -224,7 +224,7 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const | |||
224 | void *userdata) | 224 | void *userdata) |
225 | { | 225 | { |
226 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { | 226 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { |
227 | assert(tox_friend_add_norequest(m, public_key, NULL) != (uint32_t) ~0); | 227 | assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) ~0); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
@@ -235,8 +235,8 @@ static void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceC | |||
235 | Tox *Alice; | 235 | Tox *Alice; |
236 | Tox *Bob; | 236 | Tox *Bob; |
237 | 237 | ||
238 | struct Tox_Options *opts = tox_options_new(NULL); | 238 | struct Tox_Options *opts = tox_options_new(nullptr); |
239 | assert(opts != NULL); | 239 | assert(opts != nullptr); |
240 | 240 | ||
241 | tox_options_set_end_port(opts, 0); | 241 | tox_options_set_end_port(opts, 0); |
242 | tox_options_set_ipv6_enabled(opts, false); | 242 | tox_options_set_ipv6_enabled(opts, false); |
@@ -261,7 +261,7 @@ static void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceC | |||
261 | 261 | ||
262 | printf("Created 3 instances of Tox\n"); | 262 | printf("Created 3 instances of Tox\n"); |
263 | printf("Preparing network...\n"); | 263 | printf("Preparing network...\n"); |
264 | long long unsigned int cur_time = time(NULL); | 264 | long long unsigned int cur_time = time(nullptr); |
265 | 265 | ||
266 | uint32_t to_compare = 974536; | 266 | uint32_t to_compare = 974536; |
267 | uint8_t address[TOX_ADDRESS_SIZE]; | 267 | uint8_t address[TOX_ADDRESS_SIZE]; |
@@ -270,7 +270,7 @@ static void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceC | |||
270 | tox_self_get_address(Alice, address); | 270 | tox_self_get_address(Alice, address); |
271 | 271 | ||
272 | 272 | ||
273 | assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); | 273 | assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); |
274 | 274 | ||
275 | uint8_t off = 1; | 275 | uint8_t off = 1; |
276 | 276 | ||
@@ -282,12 +282,12 @@ static void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceC | |||
282 | if (tox_self_get_connection_status(*bootstrap) && | 282 | if (tox_self_get_connection_status(*bootstrap) && |
283 | tox_self_get_connection_status(Alice) && | 283 | tox_self_get_connection_status(Alice) && |
284 | tox_self_get_connection_status(Bob) && off) { | 284 | tox_self_get_connection_status(Bob) && off) { |
285 | printf("Toxes are online, took %llu seconds\n", time(NULL) - cur_time); | 285 | printf("Toxes are online, took %llu seconds\n", time(nullptr) - cur_time); |
286 | off = 0; | 286 | off = 0; |
287 | } | 287 | } |
288 | 288 | ||
289 | if (tox_friend_get_connection_status(Alice, 0, NULL) == TOX_CONNECTION_UDP && | 289 | if (tox_friend_get_connection_status(Alice, 0, nullptr) == TOX_CONNECTION_UDP && |
290 | tox_friend_get_connection_status(Bob, 0, NULL) == TOX_CONNECTION_UDP) { | 290 | tox_friend_get_connection_status(Bob, 0, nullptr) == TOX_CONNECTION_UDP) { |
291 | break; | 291 | break; |
292 | } | 292 | } |
293 | 293 | ||
@@ -321,7 +321,7 @@ static void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceC | |||
321 | 321 | ||
322 | 322 | ||
323 | printf("Created 2 instances of ToxAV\n"); | 323 | printf("Created 2 instances of ToxAV\n"); |
324 | printf("All set after %llu seconds!\n", time(NULL) - cur_time); | 324 | printf("All set after %llu seconds!\n", time(nullptr) - cur_time); |
325 | } | 325 | } |
326 | static int iterate_tox(Tox *bootstrap, ToxAV *AliceAV, ToxAV *BobAV, void *userdata) | 326 | static int iterate_tox(Tox *bootstrap, ToxAV *AliceAV, ToxAV *BobAV, void *userdata) |
327 | { | 327 | { |
@@ -364,7 +364,7 @@ static void *iterate_toxav(void *data) | |||
364 | cvDestroyWindow(vdout); | 364 | cvDestroyWindow(vdout); |
365 | #endif | 365 | #endif |
366 | 366 | ||
367 | pthread_exit(NULL); | 367 | pthread_exit(nullptr); |
368 | } | 368 | } |
369 | 369 | ||
370 | static int send_opencv_img(ToxAV *av, uint32_t friend_number, const IplImage *img) | 370 | static int send_opencv_img(ToxAV *av, uint32_t friend_number, const IplImage *img) |
@@ -399,7 +399,7 @@ static int send_opencv_img(ToxAV *av, uint32_t friend_number, const IplImage *im | |||
399 | } | 399 | } |
400 | 400 | ||
401 | int rc = toxav_video_send_frame(av, friend_number, img->width, img->height, | 401 | int rc = toxav_video_send_frame(av, friend_number, img->width, img->height, |
402 | planes[0], planes[1], planes[2], NULL); | 402 | planes[0], planes[1], planes[2], nullptr); |
403 | free(planes[0]); | 403 | free(planes[0]); |
404 | free(planes[1]); | 404 | free(planes[1]); |
405 | free(planes[2]); | 405 | free(planes[2]); |
@@ -441,8 +441,8 @@ int main(int argc, char **argv) | |||
441 | struct stat st; | 441 | struct stat st; |
442 | 442 | ||
443 | /* AV files for testing */ | 443 | /* AV files for testing */ |
444 | const char *af_name = NULL; | 444 | const char *af_name = nullptr; |
445 | const char *vf_name = NULL; | 445 | const char *vf_name = nullptr; |
446 | long audio_out_dev_idx = -1; | 446 | long audio_out_dev_idx = -1; |
447 | 447 | ||
448 | int32_t audio_frame_duration = 20; | 448 | int32_t audio_frame_duration = 20; |
@@ -574,8 +574,8 @@ CHECK_ARG: | |||
574 | memset(&AliceCC, 0, sizeof(CallControl)); | 574 | memset(&AliceCC, 0, sizeof(CallControl)); |
575 | memset(&BobCC, 0, sizeof(CallControl)); | 575 | memset(&BobCC, 0, sizeof(CallControl)); |
576 | 576 | ||
577 | pthread_mutex_init(AliceCC.arb_mutex, NULL); | 577 | pthread_mutex_init(AliceCC.arb_mutex, nullptr); |
578 | pthread_mutex_init(BobCC.arb_mutex, NULL); | 578 | pthread_mutex_init(BobCC.arb_mutex, nullptr); |
579 | 579 | ||
580 | AliceCC.arb = rb_new(16); | 580 | AliceCC.arb = rb_new(16); |
581 | BobCC.arb = rb_new(16); | 581 | BobCC.arb = rb_new(16); |
@@ -591,7 +591,7 @@ CHECK_ARG: | |||
591 | } | 591 | } |
592 | 592 | ||
593 | while (!BobCC.incoming) { | 593 | while (!BobCC.incoming) { |
594 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); | 594 | iterate_tox(bootstrap, AliceAV, BobAV, nullptr); |
595 | } | 595 | } |
596 | 596 | ||
597 | { /* Answer */ | 597 | { /* Answer */ |
@@ -605,20 +605,20 @@ CHECK_ARG: | |||
605 | } | 605 | } |
606 | 606 | ||
607 | while (AliceCC.state == 0) { | 607 | while (AliceCC.state == 0) { |
608 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); | 608 | iterate_tox(bootstrap, AliceAV, BobAV, nullptr); |
609 | } | 609 | } |
610 | 610 | ||
611 | /* Open audio file */ | 611 | /* Open audio file */ |
612 | af_handle = sf_open(af_name, SFM_READ, &af_info); | 612 | af_handle = sf_open(af_name, SFM_READ, &af_info); |
613 | 613 | ||
614 | if (af_handle == NULL) { | 614 | if (af_handle == nullptr) { |
615 | printf("Failed to open the file.\n"); | 615 | printf("Failed to open the file.\n"); |
616 | exit(1); | 616 | exit(1); |
617 | } | 617 | } |
618 | 618 | ||
619 | int16_t PCM[5760]; | 619 | int16_t PCM[5760]; |
620 | 620 | ||
621 | time_t start_time = time(NULL); | 621 | time_t start_time = time(nullptr); |
622 | time_t expected_time = af_info.frames / af_info.samplerate + 2; | 622 | time_t expected_time = af_info.frames / af_info.samplerate + 2; |
623 | 623 | ||
624 | 624 | ||
@@ -630,7 +630,7 @@ CHECK_ARG: | |||
630 | }; | 630 | }; |
631 | 631 | ||
632 | pthread_t dect; | 632 | pthread_t dect; |
633 | pthread_create(&dect, NULL, iterate_toxav, &data); | 633 | pthread_create(&dect, nullptr, iterate_toxav, &data); |
634 | pthread_detach(dect); | 634 | pthread_detach(dect); |
635 | 635 | ||
636 | int frame_size = (af_info.samplerate * audio_frame_duration / 1000) * af_info.channels; | 636 | int frame_size = (af_info.samplerate * audio_frame_duration / 1000) * af_info.channels; |
@@ -640,24 +640,24 @@ CHECK_ARG: | |||
640 | output.channelCount = af_info.channels; | 640 | output.channelCount = af_info.channels; |
641 | output.sampleFormat = paInt16; | 641 | output.sampleFormat = paInt16; |
642 | output.suggestedLatency = audio_dev->defaultHighOutputLatency; | 642 | output.suggestedLatency = audio_dev->defaultHighOutputLatency; |
643 | output.hostApiSpecificStreamInfo = NULL; | 643 | output.hostApiSpecificStreamInfo = nullptr; |
644 | 644 | ||
645 | PaError err = Pa_OpenStream(&adout, NULL, &output, af_info.samplerate, frame_size, paNoFlag, NULL, NULL); | 645 | PaError err = Pa_OpenStream(&adout, nullptr, &output, af_info.samplerate, frame_size, paNoFlag, nullptr, nullptr); |
646 | assert(err == paNoError); | 646 | assert(err == paNoError); |
647 | 647 | ||
648 | err = Pa_StartStream(adout); | 648 | err = Pa_StartStream(adout); |
649 | assert(err == paNoError); | 649 | assert(err == paNoError); |
650 | 650 | ||
651 | // toxav_audio_bit_rate_set(AliceAV, 0, 64, false, NULL); | 651 | // toxav_audio_bit_rate_set(AliceAV, 0, 64, false, nullptr); |
652 | 652 | ||
653 | /* Start write thread */ | 653 | /* Start write thread */ |
654 | pthread_t t; | 654 | pthread_t t; |
655 | pthread_create(&t, NULL, pa_write_thread, &BobCC); | 655 | pthread_create(&t, nullptr, pa_write_thread, &BobCC); |
656 | pthread_detach(t); | 656 | pthread_detach(t); |
657 | 657 | ||
658 | printf("Sample rate %d\n", af_info.samplerate); | 658 | printf("Sample rate %d\n", af_info.samplerate); |
659 | 659 | ||
660 | while (start_time + expected_time > time(NULL)) { | 660 | while (start_time + expected_time > time(nullptr)) { |
661 | uint64_t enc_start_time = current_time_monotonic(); | 661 | uint64_t enc_start_time = current_time_monotonic(); |
662 | int64_t count = sf_read_short(af_handle, PCM, frame_size); | 662 | int64_t count = sf_read_short(af_handle, PCM, frame_size); |
663 | 663 | ||
@@ -670,11 +670,11 @@ CHECK_ARG: | |||
670 | } | 670 | } |
671 | } | 671 | } |
672 | 672 | ||
673 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); | 673 | iterate_tox(bootstrap, AliceAV, BobAV, nullptr); |
674 | c_sleep((audio_frame_duration - (current_time_monotonic() - enc_start_time) - 1)); | 674 | c_sleep((audio_frame_duration - (current_time_monotonic() - enc_start_time) - 1)); |
675 | } | 675 | } |
676 | 676 | ||
677 | printf("Played file in: %lu; stopping stream...\n", time(NULL) - start_time); | 677 | printf("Played file in: %lu; stopping stream...\n", time(nullptr) - start_time); |
678 | 678 | ||
679 | Pa_StopStream(adout); | 679 | Pa_StopStream(adout); |
680 | sf_close(af_handle); | 680 | sf_close(af_handle); |
@@ -689,7 +689,7 @@ CHECK_ARG: | |||
689 | } | 689 | } |
690 | } | 690 | } |
691 | 691 | ||
692 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); | 692 | iterate_tox(bootstrap, AliceAV, BobAV, nullptr); |
693 | assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED); | 693 | assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED); |
694 | 694 | ||
695 | /* Stop decode thread */ | 695 | /* Stop decode thread */ |
@@ -702,7 +702,7 @@ CHECK_ARG: | |||
702 | pthread_mutex_destroy(AliceCC.arb_mutex); | 702 | pthread_mutex_destroy(AliceCC.arb_mutex); |
703 | pthread_mutex_destroy(BobCC.arb_mutex); | 703 | pthread_mutex_destroy(BobCC.arb_mutex); |
704 | 704 | ||
705 | void *f = NULL; | 705 | void *f = nullptr; |
706 | 706 | ||
707 | while (rb_read(AliceCC.arb, &f)) { | 707 | while (rb_read(AliceCC.arb, &f)) { |
708 | free(f); | 708 | free(f); |
@@ -732,7 +732,7 @@ CHECK_ARG: | |||
732 | } | 732 | } |
733 | 733 | ||
734 | while (!BobCC.incoming) { | 734 | while (!BobCC.incoming) { |
735 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); | 735 | iterate_tox(bootstrap, AliceAV, BobAV, nullptr); |
736 | } | 736 | } |
737 | 737 | ||
738 | { /* Answer */ | 738 | { /* Answer */ |
@@ -745,7 +745,7 @@ CHECK_ARG: | |||
745 | } | 745 | } |
746 | } | 746 | } |
747 | 747 | ||
748 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); | 748 | iterate_tox(bootstrap, AliceAV, BobAV, nullptr); |
749 | 749 | ||
750 | /* Start decode thread */ | 750 | /* Start decode thread */ |
751 | struct toxav_thread_data data = { | 751 | struct toxav_thread_data data = { |
@@ -755,7 +755,7 @@ CHECK_ARG: | |||
755 | }; | 755 | }; |
756 | 756 | ||
757 | pthread_t dect; | 757 | pthread_t dect; |
758 | pthread_create(&dect, NULL, iterate_toxav, &data); | 758 | pthread_create(&dect, nullptr, iterate_toxav, &data); |
759 | pthread_detach(dect); | 759 | pthread_detach(dect); |
760 | 760 | ||
761 | CvCapture *capture = cvCreateFileCapture(vf_name); | 761 | CvCapture *capture = cvCreateFileCapture(vf_name); |
@@ -766,12 +766,12 @@ CHECK_ARG: | |||
766 | } | 766 | } |
767 | 767 | ||
768 | #if 0 | 768 | #if 0 |
769 | toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL); | 769 | toxav_video_bit_rate_set(AliceAV, 0, 5000, false, nullptr); |
770 | #endif | 770 | #endif |
771 | 771 | ||
772 | time_t start_time = time(NULL); | 772 | time_t start_time = time(nullptr); |
773 | 773 | ||
774 | while (start_time + 90 > time(NULL)) { | 774 | while (start_time + 90 > time(nullptr)) { |
775 | IplImage *frame = cvQueryFrame(capture); | 775 | IplImage *frame = cvQueryFrame(capture); |
776 | 776 | ||
777 | if (!frame) { | 777 | if (!frame) { |
@@ -779,7 +779,7 @@ CHECK_ARG: | |||
779 | } | 779 | } |
780 | 780 | ||
781 | send_opencv_img(AliceAV, 0, frame); | 781 | send_opencv_img(AliceAV, 0, frame); |
782 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); | 782 | iterate_tox(bootstrap, AliceAV, BobAV, nullptr); |
783 | c_sleep(10); | 783 | c_sleep(10); |
784 | } | 784 | } |
785 | 785 | ||
@@ -795,7 +795,7 @@ CHECK_ARG: | |||
795 | } | 795 | } |
796 | } | 796 | } |
797 | 797 | ||
798 | iterate_tox(bootstrap, AliceAV, BobAV, NULL); | 798 | iterate_tox(bootstrap, AliceAV, BobAV, nullptr); |
799 | assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED); | 799 | assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED); |
800 | 800 | ||
801 | /* Stop decode thread */ | 801 | /* Stop decode thread */ |