Index: /pjproject/trunk/build.symbian/bld.inf
===================================================================
--- /pjproject/trunk/build.symbian/bld.inf	(revision 1964)
+++ /pjproject/trunk/build.symbian/bld.inf	(revision 1965)
@@ -5,4 +5,6 @@
 
 prj_mmpfiles
+
+// libraries
 pjlib.mmp
 pjlib_util.mmp
@@ -16,6 +18,10 @@
 pjsip_ua.mmp
 pjsua_lib.mmp
+
+// codecs
 libgsmcodec.mmp
+libspeexcodec.mmp
 
+// applications
 pjlib_test.mmp
 symbian_ua.mmp
Index: /pjproject/trunk/build.symbian/pjmedia.mmp
===================================================================
--- /pjproject/trunk/build.symbian/pjmedia.mmp	(revision 1964)
+++ /pjproject/trunk/build.symbian/pjmedia.mmp	(revision 1965)
@@ -22,4 +22,9 @@
 
 //OPTION		CW -lang c++
+
+//
+// GCCE optimization setting
+//
+OPTION		GCCE -O2 -fno-unit-at-a-time
 
 MACRO		PJ_M_I386=1
Index: /pjproject/trunk/build.symbian/symbian_audio.mmp
===================================================================
--- /pjproject/trunk/build.symbian/symbian_audio.mmp	(revision 1964)
+++ /pjproject/trunk/build.symbian/symbian_audio.mmp	(revision 1965)
@@ -26,4 +26,9 @@
 OPTION		CW -lang c++
 
+//
+// GCCE optimization setting
+//
+OPTION		GCCE -O2 -fno-unit-at-a-time
+
 MACRO		PJ_M_I386=1
 MACRO		PJ_SYMBIAN=1
Index: /pjproject/trunk/build.symbian/symbian_ua.mmp
===================================================================
--- /pjproject/trunk/build.symbian/symbian_ua.mmp	(revision 1964)
+++ /pjproject/trunk/build.symbian/symbian_ua.mmp	(revision 1965)
@@ -39,5 +39,5 @@
 	STATICLIBRARY	pjnath.lib pjlib_util.lib pjlib.lib
 	STATICLIBRARY	symbian_audio.lib
-	STATICLIBRARY	libgsmcodec.lib
+	STATICLIBRARY	libgsmcodec.lib libspeexcodec.lib
 #endif
 
Index: /pjproject/trunk/pjlib/include/pj/config_site_sample.h
===================================================================
--- /pjproject/trunk/pjlib/include/pj/config_site_sample.h	(revision 1964)
+++ /pjproject/trunk/pjlib/include/pj/config_site_sample.h	(revision 1965)
@@ -57,5 +57,5 @@
 #   define PJMEDIA_HAS_L16_CODEC	0
 #   define PJMEDIA_HAS_ILBC_CODEC	0
-#   define PJMEDIA_HAS_SPEEX_CODEC	0
+#   define PJMEDIA_HAS_SPEEX_CODEC	1
 #   define PJMEDIA_HAS_G722_CODEC	0
 
Index: /pjproject/trunk/pjmedia/include/pjmedia-codec/config.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia-codec/config.h	(revision 1964)
+++ /pjproject/trunk/pjmedia/include/pjmedia-codec/config.h	(revision 1965)
@@ -52,4 +52,18 @@
 #endif
 
+/**
+ * Speex codec default complexity setting.
+ */
+#ifndef PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY
+#   define PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY   2
+#endif
+
+/**
+ * Speex codec default quality setting.
+ */
+#ifndef PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY
+#   define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY	    5
+#endif
+
 
 /**
Index: /pjproject/trunk/pjmedia/include/pjmedia-codec/speex.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia-codec/speex.h	(revision 1964)
+++ /pjproject/trunk/pjmedia/include/pjmedia-codec/speex.h	(revision 1965)
@@ -62,7 +62,7 @@
  * @param options	Bitmask of pjmedia_speex_options (default=0).
  * @param quality	Specify encoding quality, or use -1 for default 
- *			(default=8).
+ *			(@see PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY).
  * @param complexity	Specify encoding complexity , or use -1 for default 
- *			(default=8).
+ *			(@see PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY).
  *
  * @return		PJ_SUCCESS on success.
@@ -85,4 +85,19 @@
 
 
+/**
+ * Change the settings of Speex codec.
+ *
+ * @param clock_rate	Clock rate of Speex mode to be set.
+ * @param quality	Specify encoding quality, or use -1 for default 
+ *			(@see PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY).
+ * @param complexity	Specify encoding complexity , or use -1 for default 
+ *			(@see PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY).
+ *
+ * @return		PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_speex_set_param(unsigned clock_rate,
+						   int quality,
+						   int complexity);
+
 
 /**
Index: /pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c	(revision 1964)
+++ /pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c	(revision 1965)
@@ -37,7 +37,4 @@
 
 #define THIS_FILE   "speex_codec.c"
-
-#define DEFAULT_QUALITY	    10
-#define DEFAULT_COMPLEXITY  10
 
 /* Prototypes for Speex factory */
@@ -212,6 +209,10 @@
 
     /* Get defaults */
-    if (quality <= 0) quality = DEFAULT_QUALITY;
-    if (complexity <= 0) complexity = DEFAULT_COMPLEXITY;
+    if (quality < 0) quality = PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY;
+    if (complexity < 0) complexity = PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY;
+
+    /* Validate quality & complexity */
+    PJ_ASSERT_RETURN(quality >= 0 && quality <= 10, PJ_EINVAL);
+    PJ_ASSERT_RETURN(complexity >= 1 && complexity <= 10, PJ_EINVAL);
 
     /* Create Speex codec factory. */
@@ -298,4 +299,44 @@
 {
     return pjmedia_codec_speex_init(endpt, 0, -1, -1);
+}
+
+/*
+ * Change the settings of Speex codec.
+ */
+PJ_DEF(pj_status_t) pjmedia_codec_speex_set_param(unsigned clock_rate,
+						  int quality,
+						  int complexity)
+{
+    unsigned i;
+
+    /* Get defaults */
+    if (quality < 0) quality = PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY;
+    if (complexity < 0) complexity = PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY;
+
+    /* Validate quality & complexity */
+    PJ_ASSERT_RETURN(quality >= 0 && quality <= 10, PJ_EINVAL);
+    PJ_ASSERT_RETURN(complexity >= 1 && complexity <= 10, PJ_EINVAL);
+
+    /* Apply the settings */
+    for (i=0; i<PJ_ARRAY_SIZE(spx_factory.speex_param); ++i) {
+	if (spx_factory.speex_param[i].clock_rate == clock_rate) {
+	    pj_status_t status;
+
+	    spx_factory.speex_param[i].quality = quality;
+	    spx_factory.speex_param[i].complexity = complexity;
+
+	    /* Somehow quality<=4 is broken in linux. */
+	    if (i == PARAM_UWB && quality <= 4 && quality >= 0) {
+		PJ_LOG(5,(THIS_FILE, "Adjusting quality to 5 for uwb"));
+		spx_factory.speex_param[PARAM_UWB].quality = 5;
+	    }
+
+	    status = get_speex_info(&spx_factory.speex_param[i]);
+
+	    return status;
+	}
+    }
+
+    return PJ_EINVAL;
 }
 
Index: /pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
===================================================================
--- /pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp	(revision 1964)
+++ /pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp	(revision 1965)
@@ -335,5 +335,23 @@
 	    return status;
     }
-
+    
+    /* Adjust Speex priority and enable only the narrowband */
+    {
+        pj_str_t codec_id = pj_str("speex/8000");
+        pjmedia_codec_mgr_set_codec_priority( 
+        	pjmedia_endpt_get_codec_mgr(pjsua_var.med_endpt),
+        	&codec_id, PJMEDIA_CODEC_PRIO_NORMAL+1);
+
+        codec_id = pj_str("speex/16000");
+        pjmedia_codec_mgr_set_codec_priority( 
+        	pjmedia_endpt_get_codec_mgr(pjsua_var.med_endpt),
+        	&codec_id, PJMEDIA_CODEC_PRIO_DISABLED);
+
+        codec_id = pj_str("speex/32000");
+        pjmedia_codec_mgr_set_codec_priority( 
+        	pjmedia_endpt_get_codec_mgr(pjsua_var.med_endpt),
+        	&codec_id, PJMEDIA_CODEC_PRIO_DISABLED);
+    }
+    
     /* Add UDP transport. */
     pjsua_transport_config tcfg;
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1964)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1965)
@@ -83,8 +83,5 @@
 #if PJMEDIA_HAS_SPEEX_CODEC
     /* Register speex. */
-    status = pjmedia_codec_speex_init(pjsua_var.med_endpt, 
-				      0,
-				      pjsua_var.media_cfg.quality, 
-				      pjsua_var.media_cfg.quality);
+    status = pjmedia_codec_speex_init_default(pjsua_var.med_endpt);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Error initializing Speex codec",
