Changeset 4728 for pjproject/trunk/pjsip-apps/src/pjsystest/systest.c
- Timestamp:
- Feb 4, 2014 10:13:56 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsystest/systest.c
r4537 r4728 1 1 /* $Id$ */ 2 /* 2 /* 3 3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 4 4 * … … 15 15 * You should have received a copy of the GNU General Public License 16 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 19 #include "systest.h" … … 57 57 static gui_menu menu_getsets = { "View Settings", &systest_display_settings }; 58 58 59 static gui_menu menu_tests = { 60 "Tests", NULL, 61 10, 59 static gui_menu menu_tests = { 60 "Tests", NULL, 61 10, 62 62 { 63 63 &menu_wizard, 64 &menu_audtest, 64 &menu_audtest, 65 65 &menu_playtn, 66 66 &menu_playwv1, … … 69 69 &menu_calclat, 70 70 &menu_sndaec, 71 NULL, 71 NULL, 72 72 &menu_exit 73 73 } 74 74 }; 75 75 76 static gui_menu menu_options = { 77 "Options", NULL, 78 2, 76 static gui_menu menu_options = { 77 "Options", NULL, 78 2, 79 79 { 80 80 &menu_listdev, … … 83 83 }; 84 84 85 static gui_menu root_menu = { 86 "Root", NULL, 2, {&menu_tests, &menu_options} 85 static gui_menu root_menu = { 86 "Root", NULL, 2, {&menu_tests, &menu_options} 87 87 }; 88 88 … … 134 134 else 135 135 errmsg[0] = '\0'; 136 136 137 137 strcpy(themsg, title); 138 138 strncat(themsg, errmsg, sizeof(themsg)-1); … … 159 159 160 160 /***************************************************************************** 161 * test: play simple ringback tone and hear it 161 * test: play simple ringback tone and hear it 162 162 */ 163 163 static void systest_play_tone(void) … … 202 202 203 203 pool = pjsua_pool_create("ringback", 512, 512); 204 samples_per_frame = systest.media_cfg.audio_frame_ptime * 204 samples_per_frame = systest.media_cfg.audio_frame_ptime * 205 205 systest.media_cfg.clock_rate * 206 206 systest.media_cfg.channel_count / 1000; … … 208 208 /* Ringback tone (call is ringing) */ 209 209 name = pj_str("ringback"); 210 status = pjmedia_tonegen_create2(pool, &name, 210 status = pjmedia_tonegen_create2(pool, &name, 211 211 systest.media_cfg.clock_rate, 212 systest.media_cfg.channel_count, 212 systest.media_cfg.channel_count, 213 213 samples_per_frame, 214 16, PJMEDIA_TONEGEN_LOOP, 214 16, PJMEDIA_TONEGEN_LOOP, 215 215 &ringback_port); 216 216 if (status != PJ_SUCCESS) … … 270 270 * the file. 271 271 */ 272 static pj_status_t create_player(unsigned path_cnt, const char *paths[], 272 static pj_status_t create_player(unsigned path_cnt, const char *paths[], 273 273 pjsua_player_id *p_id) 274 274 { … … 365 365 366 366 /***************************************************************************** 367 * test: record audio 367 * test: record audio 368 368 */ 369 369 static void systest_rec_audio(void) … … 388 388 "from the microphone, and playback the " 389 389 "audio to the speaker. Press OK to start recording, " 390 "CANCEL to skip.", 390 "CANCEL to skip.", 391 391 WITH_OKCANCEL); 392 392 if (key != KEY_OK) { … … 433 433 "The recorded audio is being played now to " 434 434 "the speaker device, in a loop. Listen for " 435 "any audio impairments. Press OK to stop.", 435 "any audio impairments. Press OK to stop.", 436 436 WITH_OK); 437 437 … … 526 526 param.clock_rate = systest.media_cfg.snd_clock_rate; 527 527 param.channel_count = systest.media_cfg.channel_count; 528 param.samples_per_frame = param.clock_rate * param.channel_count * 528 param.samples_per_frame = param.clock_rate * param.channel_count * 529 529 systest.media_cfg.audio_frame_ptime / 1000; 530 530 531 531 /* Latency settings */ 532 param.flags |= (PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY | 532 param.flags |= (PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY | 533 533 PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY); 534 534 param.input_latency_ms = systest.media_cfg.snd_rec_latency; … … 554 554 555 555 if (result.rec.frame_cnt==0) { 556 problems[problem_count++] = 556 problems[problem_count++] = 557 557 "No audio frames were captured from the microphone. " 558 558 "This means the audio device is not working properly."; 559 559 } else { 560 pj_ansi_snprintf(textbuf+textbufpos, 560 pj_ansi_snprintf(textbuf+textbufpos, 561 561 sizeof(textbuf)-textbufpos, 562 562 "Rec : interval (min/max/avg/dev)=\r\n" … … 571 571 572 572 if (result.rec.max_burst > GOOD_MAX_INTERVAL) { 573 problems[problem_count++] = 573 problems[problem_count++] = 574 574 "Recording max burst is quite high"; 575 575 } … … 577 577 578 578 if (result.play.frame_cnt==0) { 579 problems[problem_count++] = 579 problems[problem_count++] = 580 580 "No audio frames were played to the speaker. " 581 581 "This means the audio device is not working properly."; 582 582 } else { 583 pj_ansi_snprintf(textbuf+textbufpos, 583 pj_ansi_snprintf(textbuf+textbufpos, 584 584 sizeof(textbuf)-textbufpos, 585 585 "Play: interval (min/max/avg/dev)=\r\n" … … 594 594 595 595 if (result.play.max_burst > GOOD_MAX_INTERVAL) { 596 problems[problem_count++] = 596 problems[problem_count++] = 597 597 "Playback max burst is quite high"; 598 598 } … … 601 601 if (result.rec_drift_per_sec) { 602 602 const char *which = result.rec_drift_per_sec>=0 ? "faster" : "slower"; 603 unsigned drift = result.rec_drift_per_sec>=0 ? 603 unsigned drift = result.rec_drift_per_sec>=0 ? 604 604 result.rec_drift_per_sec : 605 605 -result.rec_drift_per_sec; … … 614 614 615 615 if (problem_count == 0) { 616 pj_ansi_snprintf(textbuf+textbufpos, 616 pj_ansi_snprintf(textbuf+textbufpos, 617 617 sizeof(textbuf)-textbufpos, 618 618 "\r\nThe sound device seems to be okay!"); … … 624 624 625 625 pj_ansi_snprintf(textbuf+textbufpos, 626 sizeof(textbuf)-textbufpos, 626 sizeof(textbuf)-textbufpos, 627 627 "There could be %d problem(s) with the " 628 628 "sound device:\r\n", … … 632 632 for (i=0; i<problem_count; ++i) { 633 633 pj_ansi_snprintf(textbuf+textbufpos, 634 sizeof(textbuf)-textbufpos, 634 sizeof(textbuf)-textbufpos, 635 635 " %d: %s\r\n", i+1, problems[i]); 636 636 textbufpos = strlen(textbuf); … … 650 650 */ 651 651 static int calculate_latency(pj_pool_t *pool, pjmedia_port *wav, 652 unsigned *lat_sum, unsigned *lat_cnt, 652 unsigned *lat_sum, unsigned *lat_cnt, 653 653 unsigned *lat_min, unsigned *lat_max) 654 654 { … … 689 689 } 690 690 691 /* Zero the first 500ms to remove loud click noises 691 /* Zero the first 500ms to remove loud click noises 692 692 * (keypad press, etc.) 693 693 */ … … 784 784 return; 785 785 } 786 key = gui_msgbox(title, 786 key = gui_msgbox(title, 787 787 "For this test to work, we must be able to capture " 788 788 "the audio played in the speaker (the echo), and only" … … 798 798 PJ_LOG(3,(THIS_FILE, "Running %s", title)); 799 799 800 status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths, 800 status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths, 801 801 &play_id); 802 802 if (status != PJ_SUCCESS) … … 817 817 status = pjsua_conf_connect(0, rec_slot); 818 818 status = pjsua_conf_connect(play_slot, rec_slot); 819 819 820 820 821 821 /* We're running */ … … 870 870 goto on_return; 871 871 872 status = calculate_latency(pool, wav_port, &lat_sum, &lat_cnt, 872 status = calculate_latency(pool, wav_port, &lat_sum, &lat_cnt, 873 873 &lat_min, &lat_max); 874 874 if (status != PJ_SUCCESS) … … 913 913 msglen = strlen(msg); 914 914 } 915 915 916 916 key = gui_msgbox(title, msg, WITH_OK); 917 917 … … 965 965 * Create player and recorder 966 966 */ 967 status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths, 967 status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths, 968 968 &player_id); 969 969 if (status != PJ_SUCCESS) { … … 1018 1018 gui_msgbox(title, "We are now playing the captured audio from the mic. " 1019 1019 "Check if echo (of the audio played back previously) is " 1020 "present in the audio. The recording is stored in " 1020 "present in the audio. The recording is stored in " 1021 1021 AEC_REC_PATH " for offline analysis. " 1022 1022 "Press OK to stop.", … … 1074 1074 enum gui_key key; 1075 1075 const char *title = "Audio Device List"; 1076 1076 1077 1077 ti = systest_alloc_test_item(title); 1078 1078 if (!ti) … … 1083 1083 dev_count = pjmedia_aud_dev_count(); 1084 1084 if (dev_count == 0) { 1085 key = gui_msgbox(title, 1085 key = gui_msgbox(title, 1086 1086 "No audio devices are found", WITH_OK); 1087 1087 ti->success = PJ_FALSE; … … 1107 1107 pj_ansi_snprintf(ti->reason+len, sizeof(ti->reason)-len, 1108 1108 " %2d: %s [%s] (%d/%d)\r\n", 1109 i, info.driver, info.name, 1109 i, info.driver, info.name, 1110 1110 info.input_count, info.output_count); 1111 1111 len = strlen(ti->reason); … … 1114 1114 ti->reason[len] = '\0'; 1115 1115 key = gui_msgbox(title, ti->reason, WITH_OK); 1116 PJ_UNUSED_ARG(key); 1116 1117 1117 1118 ti->success = PJ_TRUE; … … 1205 1206 ti->reason[sizeof(ti->reason)-1] = '\0'; 1206 1207 key = gui_msgbox(title, textbuf, WITH_OK); 1207 1208 PJ_UNUSED_ARG(key); /* Warning about unused var */ 1208 1209 } 1209 1210 … … 1243 1244 systest.media_cfg.snd_rec_latency = OVERRIDE_AUDDEV_REC_LAT; 1244 1245 #endif 1245 1246 1246 1247 status = pjsua_init(&systest.ua_cfg, &log_cfg, &systest.media_cfg); 1247 1248 if (status != PJ_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.