Changeset 3306 for pjproject/trunk
- Timestamp:
- Sep 7, 2010 10:00:49 AM (14 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/pjsystest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsystest/systest.c
r3175 r3306 39 39 static void systest_audio_test(void); 40 40 static void systest_latency_test(void); 41 static void systest_aec_test(void); 41 42 static void exit_app(void); 42 43 … … 51 52 static gui_menu menu_audtest = { "Device Test", &systest_audio_test }; 52 53 static gui_menu menu_calclat = { "Latency Test", &systest_latency_test }; 54 static gui_menu menu_sndaec = { "AEC/AES Test", &systest_aec_test }; 53 55 54 56 static gui_menu menu_listdev = { "View Devices", &systest_list_audio_devs }; … … 57 59 static gui_menu menu_tests = { 58 60 "Tests", NULL, 59 9,61 10, 60 62 { 61 63 &menu_wizard, … … 66 68 &menu_recaud, 67 69 &menu_calclat, 70 &menu_sndaec, 68 71 NULL, 69 72 &menu_exit … … 914 917 915 918 919 static void systest_aec_test(void) 920 { 921 const char *ref_wav_paths[] = { add_path(res_path, WAV_PLAYBACK_PATH), 922 ALT_PATH1 WAV_PLAYBACK_PATH }; 923 pjsua_player_id player_id = PJSUA_INVALID_ID; 924 pjsua_recorder_id writer_id = PJSUA_INVALID_ID; 925 enum gui_key key; 926 test_item_t *ti; 927 const char *title = "AEC/AES Test"; 928 unsigned last_ec_tail = 0; 929 pj_status_t status; 930 pj_str_t tmp; 931 932 ti = systest_alloc_test_item(title); 933 if (!ti) 934 return; 935 936 key = gui_msgbox(title, 937 "This test will try to find whether the AEC/AES " 938 "works good on this system. Test will play a file " 939 "while recording from mic. The recording will be " 940 "played back later so you can check if echo is there. " 941 "Press OK to start.", 942 WITH_OKCANCEL); 943 if (key != KEY_OK) { 944 ti->skipped = PJ_TRUE; 945 return; 946 } 947 948 /* Save current EC tail */ 949 status = pjsua_get_ec_tail(&last_ec_tail); 950 if (status != PJ_SUCCESS) 951 goto on_return; 952 953 /* Set EC tail setting to default */ 954 status = pjsua_set_ec(PJSUA_DEFAULT_EC_TAIL_LEN, 0); 955 if (status != PJ_SUCCESS) 956 goto on_return; 957 958 /* 959 * Create player and recorder 960 */ 961 status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths, 962 &player_id); 963 if (status != PJ_SUCCESS) { 964 PJ_PERROR(1,(THIS_FILE, status, "Error opening WAV file %s", 965 WAV_PLAYBACK_PATH)); 966 goto on_return; 967 } 968 969 status = pjsua_recorder_create(pj_cstr(&tmp, AEC_REC_PATH), 0, 0, -1, 970 0, &writer_id); 971 if (status != PJ_SUCCESS) { 972 PJ_PERROR(1,(THIS_FILE, status, "Error writing WAV file %s", 973 AEC_REC_PATH)); 974 goto on_return; 975 } 976 977 /* 978 * Start playback and recording. 979 */ 980 pjsua_conf_connect(pjsua_player_get_conf_port(player_id), 0); 981 pj_thread_sleep(100); 982 pjsua_conf_connect(0, pjsua_recorder_get_conf_port(writer_id)); 983 984 /* Wait user signal */ 985 gui_msgbox(title, "AEC/AES test is running. Press OK to stop this test.", 986 WITH_OK); 987 988 /* 989 * Stop and close playback and recorder 990 */ 991 pjsua_conf_disconnect(0, pjsua_recorder_get_conf_port(writer_id)); 992 pjsua_conf_disconnect(pjsua_player_get_conf_port(player_id), 0); 993 pjsua_recorder_destroy(writer_id); 994 pjsua_player_destroy(player_id); 995 player_id = PJSUA_INVALID_ID; 996 writer_id = PJSUA_INVALID_ID; 997 998 /* 999 * Play the result. 1000 */ 1001 status = pjsua_player_create(pj_cstr(&tmp, AEC_REC_PATH), 0, &player_id); 1002 if (status != PJ_SUCCESS) { 1003 PJ_PERROR(1,(THIS_FILE, status, "Error opening WAV file %s", AEC_REC_PATH)); 1004 goto on_return; 1005 } 1006 pjsua_conf_connect(pjsua_player_get_conf_port(player_id), 0); 1007 1008 /* Wait user signal */ 1009 gui_msgbox(title, "We are now playing the captured audio from the mic. " 1010 "Check if echo (of the audio played back previously) is " 1011 "present in the audio. The recording is stored in " 1012 AEC_REC_PATH " for offline analysis. " 1013 "Press OK to stop.", 1014 WITH_OK); 1015 1016 pjsua_conf_disconnect(pjsua_player_get_conf_port(player_id), 0); 1017 1018 key = gui_msgbox(title, 1019 "Did you notice any echo in the recording?", 1020 WITH_YESNO); 1021 1022 1023 on_return: 1024 if (player_id != PJSUA_INVALID_ID) 1025 pjsua_player_destroy(player_id); 1026 if (writer_id != PJSUA_INVALID_ID) 1027 pjsua_recorder_destroy(writer_id); 1028 1029 /* Wait until sound device closed before restoring back EC tail setting */ 1030 while (pjsua_snd_is_active()) 1031 pj_thread_sleep(10); 1032 pjsua_set_ec(last_ec_tail, 0); 1033 1034 1035 if (status != PJ_SUCCESS) { 1036 systest_perror("Sorry we encountered an error: ", status); 1037 ti->success = PJ_FALSE; 1038 pj_strerror(status, ti->reason, sizeof(ti->reason)); 1039 } else if (key == KEY_YES) { 1040 ti->success = PJ_FALSE; 1041 if (!ti->success) { 1042 pj_ansi_strcpy(ti->reason, USER_ERROR); 1043 } 1044 } else { 1045 char msg[200]; 1046 1047 pj_ansi_snprintf(msg, sizeof(msg), "Test succeeded.\r\n"); 1048 1049 ti->success = PJ_TRUE; 1050 pj_ansi_strncpy(ti->reason, msg, sizeof(ti->reason)); 1051 ti->reason[sizeof(ti->reason)-1] = '\0'; 1052 } 1053 } 1054 916 1055 917 1056 /**************************************************************************** … … 1085 1224 systest.play_id = PLAY_DEV_ID; 1086 1225 systest.media_cfg.ec_tail_len = 0; 1226 systest.media_cfg.snd_auto_close_time = 0; 1087 1227 1088 1228 #if defined(OVERRIDE_AUDDEV_PLAY_LAT) && OVERRIDE_AUDDEV_PLAY_LAT!=0 … … 1137 1277 systest_audio_test(); 1138 1278 systest_latency_test(); 1279 systest_aec_test(); 1139 1280 gui_msgbox("Test wizard", "Test wizard complete.", WITH_OK); 1140 1281 } -
pjproject/trunk/pjsip-apps/src/pjsystest/systest.h
r3258 r3306 48 48 49 49 #if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE 50 #define LOG_OUT_PATH "\\PJSYSTEST. LOG"50 #define LOG_OUT_PATH "\\PJSYSTEST.TXT" 51 51 #define RESULT_OUT_PATH "\\PJSYSTEST_RESULT.TXT" 52 52 #define WAV_PLAYBACK_PATH "\\Program Files\\pjsystest\\input.8.wav" … … 55 55 #define WAV_LATENCY_OUT_PATH "\\PJSYSTEST_LATREC.WAV" 56 56 #define ALT_PATH1 "" 57 #define AEC_REC_PATH "\\PJSYSTEST_AECREC.WAV" 57 58 #else 58 #define LOG_OUT_PATH "PJSYSTEST. LOG"59 #define LOG_OUT_PATH "PJSYSTEST.TXT" 59 60 #define RESULT_OUT_PATH "PJSYSTEST_RESULT.TXT" 60 61 #define WAV_PLAYBACK_PATH "input.8.wav" … … 63 64 #define WAV_LATENCY_OUT_PATH "PJSYSTEST_LATREC.WAV" 64 65 #define ALT_PATH1 "../../tests/pjsua/wavs/" 66 #define AEC_REC_PATH "PJSYSTEST_AECREC.WAV" 65 67 #endif 66 68
Note: See TracChangeset
for help on using the changeset viewer.