Index: /pjproject/trunk/pjmedia/include/pjmedia/config.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 657)
+++ /pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 658)
@@ -162,4 +162,14 @@
 
 /**
+ * Suggested or default threshold to be set for fixed silence detection
+ * or as starting threshold for adaptive silence detection. The threshold
+ * has the range from zero to 255.
+ */
+#ifndef PJMEDIA_SILENCE_DET_THRESHOLD
+#   define PJMEDIA_SILENCE_DET_THRESHOLD	4
+#endif
+
+
+/**
  * G.711 Appendix I Packet Lost Concealment (PLC).
  * Enabled only when floating point is enabled.
@@ -176,4 +186,25 @@
 #ifndef PJMEDIA_HAS_SPEEX_AEC
 #   define PJMEDIA_HAS_SPEEX_AEC		1
+#endif
+
+
+/**
+ * Initial signal threshold to be applied to echo suppressor. When
+ * playback signal level is greater than this threshold, the microphone
+ * signal will be reduced or cut.
+ */
+#ifndef PJMEDIA_ECHO_SUPPRESS_THRESHOLD
+#   define PJMEDIA_ECHO_SUPPRESS_THRESHOLD	PJMEDIA_SILENCE_DET_THRESHOLD
+#endif
+
+
+/**
+ * The signal reduction factor to be applied into the microphone signal
+ * when the mic signal needs to be reduced. Valid values are [1-16], where
+ * 1 will leave signal as it is (thus probably transmitting the echo) and
+ * 16 will effectively zero the signal.
+ */
+#ifndef PJMEDIA_ECHO_SUPPRESS_FACTOR
+#   define PJMEDIA_ECHO_SUPPRESS_FACTOR		4
 #endif
 
Index: /pjproject/trunk/pjmedia/include/pjmedia/silencedet.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/silencedet.h	(revision 657)
+++ /pjproject/trunk/pjmedia/include/pjmedia/silencedet.h	(revision 658)
@@ -44,11 +44,4 @@
 typedef struct pjmedia_silence_det pjmedia_silence_det;
 
-
-/**
- * Suggested or default threshold to be set for fixed silence detection
- * or as starting threshold for adaptive silence detection. The threshold
- * has the range from zero to 255.
- */
-#define PJMEDIA_SILENCE_DET_THRESHOLD	4
 
 
Index: /pjproject/trunk/pjmedia/include/pjmedia/sound_port.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/sound_port.h	(revision 657)
+++ /pjproject/trunk/pjmedia/include/pjmedia/sound_port.h	(revision 658)
@@ -198,10 +198,12 @@
  *			    miliseconds. If zero is specified, the EC would
  *			    be disabled.
+ * @param options	    The options to be passed to #pjmedia_echo_create().
  *
  * @return		    PJ_SUCCESS on success.
  */
-PJ_DECL(pj_status_t) pjmedia_snd_port_set_ec_tail(pjmedia_snd_port *snd_port,
-						  pj_pool_t *pool,
-						  unsigned tail_ms);
+PJ_DECL(pj_status_t) pjmedia_snd_port_set_ec( pjmedia_snd_port *snd_port,
+					      pj_pool_t *pool,
+					      unsigned tail_ms,
+					      unsigned options);
 
 
Index: /pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c	(revision 657)
+++ /pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c	(revision 658)
@@ -28,5 +28,4 @@
 
 #define THIS_FILE			    "echo_suppress.c"
-#define PJMEDIA_ECHO_SUPPRESS_THRESHOLD	    PJMEDIA_SILENCE_DET_THRESHOLD
 
 
@@ -160,5 +159,13 @@
 
     if (delay_ms < ec->tail_ms) {
+#if defined(PJMEDIA_ECHO_SUPPRESS_FACTOR) && PJMEDIA_ECHO_SUPPRESS_FACTOR!=0
+	unsigned i;
+	for (i=0; i<ec->samples_per_frame; ++i) {
+	    rec_frm[i] = (pj_int16_t)(rec_frm[i] >> 
+				      PJMEDIA_ECHO_SUPPRESS_FACTOR);
+	}
+#else
 	pjmedia_zero_samples(rec_frm, ec->samples_per_frame);
+#endif
     }
 
@@ -186,9 +193,16 @@
 
     if (!silence) {
+#if defined(PJMEDIA_ECHO_SUPPRESS_FACTOR) && PJMEDIA_ECHO_SUPPRESS_FACTOR!=0
+	unsigned i;
+	for (i=0; i<ec->samples_per_frame; ++i) {
+	    rec_frm[i] = (pj_int16_t)(rec_frm[i] >> 
+				      PJMEDIA_ECHO_SUPPRESS_FACTOR);
+	}
+#else
 	pjmedia_zero_samples(rec_frm, ec->samples_per_frame);
-    }
-
-    return PJ_SUCCESS;
-}
-
-
+#endif
+    }
+
+    return PJ_SUCCESS;
+}
+
Index: /pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/sound_port.c	(revision 657)
+++ /pjproject/trunk/pjmedia/src/pjmedia/sound_port.c	(revision 658)
@@ -250,12 +250,4 @@
     }
 
-    /* Create AEC only when direction is full duplex */
-    if (snd_port->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK) {
-	status = pjmedia_snd_port_set_ec_tail(snd_port, pool, AEC_TAIL);
-	if (status != PJ_SUCCESS) {
-	    PJ_LOG(4,(THIS_FILE, "Unable to create AEC"));
-	    snd_port->ec_state = NULL;
-	}
-    }
 
     /* Start sound stream. */
@@ -433,7 +425,8 @@
  * Enable AEC
  */
-PJ_DEF(pj_status_t) pjmedia_snd_port_set_ec_tail(pjmedia_snd_port *snd_port,
-					         pj_pool_t *pool,
-					         unsigned tail_ms)
+PJ_DEF(pj_status_t) pjmedia_snd_port_set_ec( pjmedia_snd_port *snd_port,
+					     pj_pool_t *pool,
+					     unsigned tail_ms,
+					     unsigned options)
 {
     pj_status_t status;
@@ -455,5 +448,5 @@
 	status = pjmedia_echo_create(pool, snd_port->clock_rate, 
 				    snd_port->samples_per_frame, 
-				    tail_ms, 0, &snd_port->ec_state);
+				    tail_ms, options, &snd_port->ec_state);
 	if (status != PJ_SUCCESS)
 	    snd_port->ec_state = NULL;
Index: /pjproject/trunk/pjsip-apps/src/pjsua_wince/pjsua_wince.cpp
===================================================================
--- /pjproject/trunk/pjsip-apps/src/pjsua_wince/pjsua_wince.cpp	(revision 657)
+++ /pjproject/trunk/pjsip-apps/src/pjsua_wince/pjsua_wince.cpp	(revision 658)
@@ -39,5 +39,5 @@
 };
 
-#define DEFAULT_URI	"sip:192.168.0.66"
+#define DEFAULT_URI	"sip:192.168.0.7"
 
 
@@ -285,5 +285,5 @@
     /* Setup media */
     media_cfg.clock_rate = 8000;
-    //media_cfg.ec_tail_len = ;
+    media_cfg.ec_options = PJMEDIA_ECHO_SIMPLE;
     media_cfg.quality = 1;
     media_cfg.ptime = 20;
Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 657)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 658)
@@ -2134,4 +2134,11 @@
 
     /**
+     * Echo canceller options (see #pjmedia_echo_create())
+     *
+     * Default: 0.
+     */
+    unsigned		ec_options;
+
+    /**
      * Echo canceller tail length, in miliseconds.
      *
@@ -2507,8 +2514,10 @@
  * @param tail_ms	The tail length, in miliseconds. Set to zero to
  *			disable AEC.
+ * @param options	Options to be passed to #pjmedia_echo_create().
+ *			Normally the value should be zero.
  *
  * @return		PJ_SUCCESS on success.
  */
-PJ_DECL(pj_status_t) pjsua_set_ec_tail(unsigned tail_ms);
+PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
 
 
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 657)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 658)
@@ -970,6 +970,7 @@
 
     /* Set AEC */
-    pjmedia_snd_port_set_ec_tail(pjsua_var.snd_port, pjsua_var.pool, 
-			         pjsua_var.media_cfg.ec_tail_len);
+    pjmedia_snd_port_set_ec( pjsua_var.snd_port, pjsua_var.pool, 
+			     pjsua_var.media_cfg.ec_tail_len, 
+			     pjsua_var.media_cfg.ec_options);
 
     /* Connect sound port to the bridge */ 	 
@@ -1045,11 +1046,11 @@
  * Configure the AEC settings of the sound port.
  */
-PJ_DEF(pj_status_t) pjsua_set_ec_tail(unsigned tail_ms)
+PJ_DEF(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options)
 {
     pjsua_var.media_cfg.ec_tail_len = tail_ms;
 
     if (pjsua_var.snd_port)
-	return pjmedia_snd_port_set_ec_tail(pjsua_var.snd_port, pjsua_var.pool,
-					    tail_ms);
+	return pjmedia_snd_port_set_ec( pjsua_var.snd_port, pjsua_var.pool,
+					tail_ms, options);
     
     return PJ_SUCCESS;
