Index: pjproject/trunk/pjsip-apps/src/pjsystest/systest.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsystest/systest.c	(revision 3305)
+++ pjproject/trunk/pjsip-apps/src/pjsystest/systest.c	(revision 3306)
@@ -39,4 +39,5 @@
 static void systest_audio_test(void);
 static void systest_latency_test(void);
+static void systest_aec_test(void);
 static void exit_app(void);
 
@@ -51,4 +52,5 @@
 static gui_menu menu_audtest = { "Device Test", &systest_audio_test };
 static gui_menu menu_calclat = { "Latency Test", &systest_latency_test };
+static gui_menu menu_sndaec = { "AEC/AES Test", &systest_aec_test };
 
 static gui_menu menu_listdev = { "View Devices", &systest_list_audio_devs };
@@ -57,5 +59,5 @@
 static gui_menu menu_tests = { 
     "Tests", NULL, 
-    9, 
+    10, 
     {
 	&menu_wizard,
@@ -66,4 +68,5 @@
 	&menu_recaud,
 	&menu_calclat,
+	&menu_sndaec,
 	NULL, 
 	&menu_exit
@@ -914,4 +917,140 @@
 
 
+static void systest_aec_test(void)
+{
+    const char *ref_wav_paths[] = { add_path(res_path, WAV_PLAYBACK_PATH),
+				    ALT_PATH1 WAV_PLAYBACK_PATH };
+    pjsua_player_id player_id = PJSUA_INVALID_ID;
+    pjsua_recorder_id writer_id = PJSUA_INVALID_ID;
+    enum gui_key key;
+    test_item_t *ti;
+    const char *title = "AEC/AES Test";
+    unsigned last_ec_tail = 0;
+    pj_status_t status;
+    pj_str_t tmp;
+
+    ti = systest_alloc_test_item(title);
+    if (!ti)
+	return;
+
+    key = gui_msgbox(title,
+		     "This test will try to find whether the AEC/AES "
+		     "works good on this system. Test will play a file "
+		     "while recording from mic. The recording will be "
+		     "played back later so you can check if echo is there. "
+		     "Press OK to start.",
+		     WITH_OKCANCEL);
+    if (key != KEY_OK) {
+	ti->skipped = PJ_TRUE;
+	return;
+    }
+
+    /* Save current EC tail */
+    status = pjsua_get_ec_tail(&last_ec_tail);
+    if (status != PJ_SUCCESS)
+	goto on_return;
+
+    /* Set EC tail setting to default */
+    status = pjsua_set_ec(PJSUA_DEFAULT_EC_TAIL_LEN, 0);
+    if (status != PJ_SUCCESS)
+	goto on_return;
+
+    /*
+     * Create player and recorder
+     */
+    status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths, 
+			   &player_id);
+    if (status != PJ_SUCCESS) {
+	PJ_PERROR(1,(THIS_FILE, status, "Error opening WAV file %s",
+		     WAV_PLAYBACK_PATH));
+	goto on_return;
+    }
+
+    status = pjsua_recorder_create(pj_cstr(&tmp, AEC_REC_PATH), 0, 0, -1,
+			           0, &writer_id);
+    if (status != PJ_SUCCESS) {
+	PJ_PERROR(1,(THIS_FILE, status, "Error writing WAV file %s",
+		     AEC_REC_PATH));
+	goto on_return;
+    }
+
+    /*
+     * Start playback and recording.
+     */
+    pjsua_conf_connect(pjsua_player_get_conf_port(player_id), 0);
+    pj_thread_sleep(100);
+    pjsua_conf_connect(0, pjsua_recorder_get_conf_port(writer_id));
+
+    /* Wait user signal */
+    gui_msgbox(title, "AEC/AES test is running. Press OK to stop this test.",
+	       WITH_OK);
+
+    /*
+     * Stop and close playback and recorder
+     */
+    pjsua_conf_disconnect(0, pjsua_recorder_get_conf_port(writer_id));
+    pjsua_conf_disconnect(pjsua_player_get_conf_port(player_id), 0);
+    pjsua_recorder_destroy(writer_id);
+    pjsua_player_destroy(player_id);
+    player_id = PJSUA_INVALID_ID;
+    writer_id = PJSUA_INVALID_ID;
+
+    /*
+     * Play the result.
+     */
+    status = pjsua_player_create(pj_cstr(&tmp, AEC_REC_PATH), 0, &player_id);
+    if (status != PJ_SUCCESS) {
+	PJ_PERROR(1,(THIS_FILE, status, "Error opening WAV file %s", AEC_REC_PATH));
+	goto on_return;
+    }
+    pjsua_conf_connect(pjsua_player_get_conf_port(player_id), 0);
+
+    /* Wait user signal */
+    gui_msgbox(title, "We are now playing the captured audio from the mic. "
+		      "Check if echo (of the audio played back previously) is "
+		      "present in the audio. The recording is stored in " 
+		      AEC_REC_PATH " for offline analysis. "
+		      "Press OK to stop.",
+		      WITH_OK);
+
+    pjsua_conf_disconnect(pjsua_player_get_conf_port(player_id), 0);
+
+    key = gui_msgbox(title,
+		     "Did you notice any echo in the recording?",
+		     WITH_YESNO);
+
+
+on_return:
+    if (player_id != PJSUA_INVALID_ID)
+	pjsua_player_destroy(player_id);
+    if (writer_id != PJSUA_INVALID_ID)
+	pjsua_recorder_destroy(writer_id);
+
+    /* Wait until sound device closed before restoring back EC tail setting */
+    while (pjsua_snd_is_active())
+	pj_thread_sleep(10);
+    pjsua_set_ec(last_ec_tail, 0);
+
+
+    if (status != PJ_SUCCESS) {
+	systest_perror("Sorry we encountered an error: ", status);
+	ti->success = PJ_FALSE;
+	pj_strerror(status, ti->reason, sizeof(ti->reason));
+    } else if (key == KEY_YES) {
+	ti->success = PJ_FALSE;
+	if (!ti->success) {
+	    pj_ansi_strcpy(ti->reason, USER_ERROR);
+	}
+    } else {
+	char msg[200];
+
+	pj_ansi_snprintf(msg, sizeof(msg), "Test succeeded.\r\n");
+
+	ti->success = PJ_TRUE;
+	pj_ansi_strncpy(ti->reason, msg, sizeof(ti->reason));
+	ti->reason[sizeof(ti->reason)-1] = '\0';
+    }
+}
+
 
 /****************************************************************************
@@ -1085,4 +1224,5 @@
     systest.play_id = PLAY_DEV_ID;
     systest.media_cfg.ec_tail_len = 0;
+    systest.media_cfg.snd_auto_close_time = 0;
 
 #if defined(OVERRIDE_AUDDEV_PLAY_LAT) && OVERRIDE_AUDDEV_PLAY_LAT!=0
@@ -1137,4 +1277,5 @@
     systest_audio_test();
     systest_latency_test();
+    systest_aec_test();
     gui_msgbox("Test wizard", "Test wizard complete.", WITH_OK);
 }
Index: pjproject/trunk/pjsip-apps/src/pjsystest/systest.h
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsystest/systest.h	(revision 3305)
+++ pjproject/trunk/pjsip-apps/src/pjsystest/systest.h	(revision 3306)
@@ -48,5 +48,5 @@
 
 #if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE
-    #define LOG_OUT_PATH		"\\PJSYSTEST.LOG"
+    #define LOG_OUT_PATH		"\\PJSYSTEST.TXT"
     #define RESULT_OUT_PATH		"\\PJSYSTEST_RESULT.TXT"
     #define WAV_PLAYBACK_PATH		"\\Program Files\\pjsystest\\input.8.wav"
@@ -55,6 +55,7 @@
     #define WAV_LATENCY_OUT_PATH	"\\PJSYSTEST_LATREC.WAV"
     #define ALT_PATH1			""
+    #define AEC_REC_PATH		"\\PJSYSTEST_AECREC.WAV"
 #else
-    #define LOG_OUT_PATH		"PJSYSTEST.LOG"
+    #define LOG_OUT_PATH		"PJSYSTEST.TXT"
     #define RESULT_OUT_PATH		"PJSYSTEST_RESULT.TXT"
     #define WAV_PLAYBACK_PATH		"input.8.wav"
@@ -63,4 +64,5 @@
     #define WAV_LATENCY_OUT_PATH	"PJSYSTEST_LATREC.WAV"
     #define ALT_PATH1			"../../tests/pjsua/wavs/"
+    #define AEC_REC_PATH		"PJSYSTEST_AECREC.WAV"
 #endif
 
