Index: /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 527)
+++ /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 528)
@@ -44,5 +44,4 @@
     unsigned		    codec_cnt;
     pj_str_t		    codec_arg[32];
-    unsigned		    clock_rate;
     pj_bool_t		    null_audio;
     pj_str_t		    wav_file;
@@ -52,6 +51,4 @@
     pj_bool_t		    auto_loop;
     unsigned		    ptime;
-    unsigned		    quality;
-    unsigned		    complexity;
     unsigned		    auto_answer;
     unsigned		    duration;
@@ -113,7 +110,6 @@
     puts  ("  --auto-loop         Automatically loop incoming RTP to outgoing RTP");
     puts  ("  --rtp-port=N        Base port to try for RTP (default=4000)");
+    puts  ("  --quality=N	  Specify media quality (0-10, default=10)");
     /*
-    puts  ("  --complexity=N      Specify encoding complexity (0-10, default=none(-1))");
-    puts  ("  --quality=N         Specify encoding quality (0-10, default=4)");
     puts  ("  --ptime=MSEC        Override codec ptime to MSEC (default=specific)");
     */
@@ -562,13 +558,4 @@
 	    break;
 
-	case OPT_QUALITY:
-	    cfg->quality = my_atoi(pj_optarg);
-	    if (cfg->quality < 0 || cfg->quality > 10) {
-		PJ_LOG(1,(THIS_FILE,
-			  "Error: invalid --quality (expecting 0-10"));
-		return -1;
-	    }
-	    break;
-
 	case OPT_DURATION:
 	    cfg->duration = my_atoi(pj_optarg);
@@ -585,4 +572,13 @@
 
 	*/
+
+	case OPT_QUALITY:
+	    cfg->media_cfg.quality = my_atoi(pj_optarg);
+	    if (cfg->media_cfg.quality < 0 || cfg->media_cfg.quality > 10) {
+		PJ_LOG(1,(THIS_FILE,
+			  "Error: invalid --quality (expecting 0-10"));
+		return -1;
+	    }
+	    break;
 
 	case OPT_AUTO_ANSWER:
@@ -832,22 +828,15 @@
     }
     /* Media clock rate. */
-    if (config->clock_rate) {
+    if (config->media_cfg.clock_rate) {
 	pj_ansi_sprintf(line, "--clock-rate %d\n",
-			config->clock_rate);
+			config->media_cfg.clock_rate);
 	pj_strcat2(&cfg, line);
     }
-
-
-    /* Encoding quality and complexity */
-    if (config->quality > 0) {
+    if (config->media_cfg.quality != 10) {
 	pj_ansi_sprintf(line, "--quality %d\n",
-			config->quality);
+			config->media_cfg.quality);
 	pj_strcat2(&cfg, line);
     }
-    if (config->complexity > 0) {
-	pj_ansi_sprintf(line, "--complexity %d\n",
-			config->complexity);
-	pj_strcat2(&cfg, line);
-    }
+
 
     /* ptime */
Index: /pjproject/trunk/pjsip/build/Makefile
===================================================================
--- /pjproject/trunk/pjsip/build/Makefile	(revision 527)
+++ /pjproject/trunk/pjsip/build/Makefile	(revision 528)
@@ -127,5 +127,5 @@
 	$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $@
 
-clean depend realclean:
+clean depend:
 	$(MAKE) -f $(RULES_MAK) APP=PJSIP app=pjsip $@
 	$(MAKE) -f $(RULES_MAK) APP=PJSIP_UA app=pjsip-ua $@
Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 527)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 528)
@@ -2038,5 +2038,15 @@
     unsigned		thread_cnt;
 
-
+    /**
+     * Media quality, 0-10, according to this table:
+     *   8-10: resampling use large filter,
+     *   3-7:  resampling use small filter,
+     *   1-2:  resampling use linear.
+     * The media quality also sets speex codec quality/complexity to the
+     * number.
+     *
+     * Default: 10.
+     */
+    unsigned		quality;
 };
 
@@ -2055,4 +2065,5 @@
     cfg->has_ioqueue = PJ_TRUE;
     cfg->thread_cnt = 1;
+    cfg->quality = 10;
 }
 
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 527)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 528)
@@ -38,4 +38,5 @@
 {
     pj_str_t codec_id;
+    unsigned opt;
     pj_status_t status;
 
@@ -76,5 +77,6 @@
     status = pjmedia_codec_speex_init(pjsua_var.med_endpt, 
 				      PJMEDIA_SPEEX_NO_UWB,
-				      -1, -1);
+				      pjsua_var.media_cfg.quality, 
+				      pjsua_var.media_cfg.quality);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Error initializing Speex codec",
@@ -130,4 +132,16 @@
     pjsua_var.mconf_cfg.bits_per_sample = 16;
 
+    /* Init options for conference bridge. */
+    opt = PJMEDIA_CONF_NO_DEVICE;
+    if (pjsua_var.media_cfg.quality >= 3 &&
+	pjsua_var.media_cfg.quality <= 7)
+    {
+	opt |= PJMEDIA_CONF_SMALL_FILTER;
+    }
+    else if (pjsua_var.media_cfg.quality < 3) {
+	opt |= PJMEDIA_CONF_USE_LINEAR;
+    }
+	
+
     /* Init conference bridge. */
     status = pjmedia_conf_create(pjsua_var.pool, 
@@ -137,6 +151,5 @@
 				 pjsua_var.mconf_cfg.samples_per_frame, 
 				 pjsua_var.mconf_cfg.bits_per_sample, 
-				 PJMEDIA_CONF_NO_DEVICE,
-				 &pjsua_var.mconf);
+				 opt, &pjsua_var.mconf);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, 
@@ -533,5 +546,5 @@
 {
     pjmedia_conf_port_info cinfo;
-    unsigned i, count;
+    unsigned i;
     pj_status_t status;
 
