Changeset 3306 for pjproject/trunk


Ignore:
Timestamp:
Sep 7, 2010 10:00:49 AM (14 years ago)
Author:
nanang
Message:

Misc (re #1110):

  • Added sound device echo test into pjsystest.
  • Renamed pjsystest log file, from PJSYSTEST.LOG to PJSYSTEST.TXT, as commonly built-in text editors recognize TXT ext more than LOG ext.
Location:
pjproject/trunk/pjsip-apps/src/pjsystest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsystest/systest.c

    r3175 r3306  
    3939static void systest_audio_test(void); 
    4040static void systest_latency_test(void); 
     41static void systest_aec_test(void); 
    4142static void exit_app(void); 
    4243 
     
    5152static gui_menu menu_audtest = { "Device Test", &systest_audio_test }; 
    5253static gui_menu menu_calclat = { "Latency Test", &systest_latency_test }; 
     54static gui_menu menu_sndaec = { "AEC/AES Test", &systest_aec_test }; 
    5355 
    5456static gui_menu menu_listdev = { "View Devices", &systest_list_audio_devs }; 
     
    5759static gui_menu menu_tests = {  
    5860    "Tests", NULL,  
    59     9,  
     61    10,  
    6062    { 
    6163        &menu_wizard, 
     
    6668        &menu_recaud, 
    6769        &menu_calclat, 
     70        &menu_sndaec, 
    6871        NULL,  
    6972        &menu_exit 
     
    914917 
    915918 
     919static 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 
     1023on_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 
    9161055 
    9171056/**************************************************************************** 
     
    10851224    systest.play_id = PLAY_DEV_ID; 
    10861225    systest.media_cfg.ec_tail_len = 0; 
     1226    systest.media_cfg.snd_auto_close_time = 0; 
    10871227 
    10881228#if defined(OVERRIDE_AUDDEV_PLAY_LAT) && OVERRIDE_AUDDEV_PLAY_LAT!=0 
     
    11371277    systest_audio_test(); 
    11381278    systest_latency_test(); 
     1279    systest_aec_test(); 
    11391280    gui_msgbox("Test wizard", "Test wizard complete.", WITH_OK); 
    11401281} 
  • pjproject/trunk/pjsip-apps/src/pjsystest/systest.h

    r3258 r3306  
    4848 
    4949#if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE 
    50     #define LOG_OUT_PATH                "\\PJSYSTEST.LOG" 
     50    #define LOG_OUT_PATH                "\\PJSYSTEST.TXT" 
    5151    #define RESULT_OUT_PATH             "\\PJSYSTEST_RESULT.TXT" 
    5252    #define WAV_PLAYBACK_PATH           "\\Program Files\\pjsystest\\input.8.wav" 
     
    5555    #define WAV_LATENCY_OUT_PATH        "\\PJSYSTEST_LATREC.WAV" 
    5656    #define ALT_PATH1                   "" 
     57    #define AEC_REC_PATH                "\\PJSYSTEST_AECREC.WAV" 
    5758#else 
    58     #define LOG_OUT_PATH                "PJSYSTEST.LOG" 
     59    #define LOG_OUT_PATH                "PJSYSTEST.TXT" 
    5960    #define RESULT_OUT_PATH             "PJSYSTEST_RESULT.TXT" 
    6061    #define WAV_PLAYBACK_PATH           "input.8.wav" 
     
    6364    #define WAV_LATENCY_OUT_PATH        "PJSYSTEST_LATREC.WAV" 
    6465    #define ALT_PATH1                   "../../tests/pjsua/wavs/" 
     66    #define AEC_REC_PATH                "PJSYSTEST_AECREC.WAV" 
    6567#endif 
    6668 
Note: See TracChangeset for help on using the changeset viewer.