Index: pjproject/trunk/pjmedia/include/pjmedia-audiodev/audiodev.h
===================================================================
--- pjproject/trunk/pjmedia/include/pjmedia-audiodev/audiodev.h	(revision 4242)
+++ pjproject/trunk/pjmedia/include/pjmedia-audiodev/audiodev.h	(revision 4243)
@@ -424,4 +424,10 @@
      */
     pj_bool_t cng_enabled;
+
+    /** 
+     * Enable/disable VAD. This setting is optional, and will only be used
+     * if PJMEDIA_AUD_DEV_CAP_VAD is set in the flags.
+     */
+    pj_bool_t vad_enabled;
 
 } pjmedia_aud_param;
Index: pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp	(revision 4242)
+++ pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp	(revision 4243)
@@ -974,5 +974,6 @@
 	    unsigned samples_got;
 	    
-	    samples_got = strm->param.ext_fmt.bitrate == 15200? 160 : 240;
+	    samples_got =
+	        strm->param.ext_fmt.det.aud.avg_bps == 15200? 160 : 240;
 	    
 	    /* Check if we got a normal frame. */
@@ -1172,7 +1173,7 @@
 		samples_cnt = frame->samples_cnt / frame->subframe_cnt;
 		
-		pj_assert((strm->param.ext_fmt.bitrate == 15200 && 
+		pj_assert((strm->param.ext_fmt.det.aud.avg_bps == 15200 && 
 			   samples_cnt == 160) ||
-			  (strm->param.ext_fmt.bitrate != 15200 &&
+			  (strm->param.ext_fmt.det.aud.avg_bps != 15200 &&
 			   samples_cnt == 240));
 		
@@ -1392,32 +1393,39 @@
 
 	if (supported) {
+	    pjmedia_format ext_fmt;
+	    
 	    switch(i) {
 	    case 0: /* AMRNB */
-		af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_AMR;
-		af->dev_info.ext_fmt[fmt_cnt].bitrate = 7400;
-		af->dev_info.ext_fmt[fmt_cnt].vad = PJ_TRUE;
+		pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_AMR,
+					  8000, 1, 16, 20, 7400, 12200);
+		af->dev_info.ext_fmt[fmt_cnt] = ext_fmt;
+		//af->dev_info.ext_fmt[fmt_cnt].vad = PJ_TRUE;
 		++fmt_cnt;
 		break;
 	    case 1: /* G.711 */
-		af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_PCMU;
-		af->dev_info.ext_fmt[fmt_cnt].bitrate = 64000;
-		af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE;
+		pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_PCMU,
+					  8000, 1, 16, 20, 64000, 64000);
+		af->dev_info.ext_fmt[fmt_cnt] = ext_fmt;
+		//af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE;
 		++fmt_cnt;
-		af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_PCMA;
-		af->dev_info.ext_fmt[fmt_cnt].bitrate = 64000;
-		af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE;
+		pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_PCMA,
+					  8000, 1, 16, 20, 64000, 64000);
+		af->dev_info.ext_fmt[fmt_cnt] = ext_fmt;
+		//af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE;
 		++fmt_cnt;
 		g711_supported = PJ_TRUE;
 		break;
 	    case 2: /* G.729 */
-		af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_G729;
-		af->dev_info.ext_fmt[fmt_cnt].bitrate = 8000;
-		af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE;
+		pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_G729,
+					  8000, 1, 16, 20, 8000, 8000);
+		af->dev_info.ext_fmt[fmt_cnt] = ext_fmt;
+		//af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE;
 		++fmt_cnt;
 		break;
 	    case 3: /* iLBC */
-		af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_ILBC;
-		af->dev_info.ext_fmt[fmt_cnt].bitrate = 13333;
-		af->dev_info.ext_fmt[fmt_cnt].vad = PJ_TRUE;
+		pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_ILBC,
+					  8000, 1, 16, 30, 13333, 15200);
+		af->dev_info.ext_fmt[fmt_cnt] = ext_fmt;
+		//af->dev_info.ext_fmt[fmt_cnt].vad = PJ_TRUE;
 		++fmt_cnt;
 		break;
@@ -1571,10 +1579,10 @@
     if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_AMR)
     {
-	aps_setting.mode = (TAPSCodecMode)strm->param.ext_fmt.bitrate;
+	aps_setting.mode = (TAPSCodecMode)strm->param.ext_fmt.det.aud.avg_bps;
     } 
     else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMU ||
 	     strm->param.ext_fmt.id == PJMEDIA_FORMAT_L16 ||
 	    (strm->param.ext_fmt.id == PJMEDIA_FORMAT_ILBC  &&
-	     strm->param.ext_fmt.bitrate != 15200))
+	     strm->param.ext_fmt.det.aud.avg_bps != 15200))
     {
 	aps_setting.mode = EULawOr30ms;
@@ -1582,5 +1590,5 @@
     else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMA ||
 	    (strm->param.ext_fmt.id == PJMEDIA_FORMAT_ILBC &&
-	     strm->param.ext_fmt.bitrate == 15200))
+	     strm->param.ext_fmt.det.aud.avg_bps == 15200))
     {
 	aps_setting.mode = EALawOr20ms;
@@ -1597,9 +1605,11 @@
 	aps_setting.vad = EFalse;
     } else {
-	aps_setting.vad = strm->param.ext_fmt.vad;
+	aps_setting.vad = (strm->param.flags & PJMEDIA_AUD_DEV_CAP_VAD) &&
+			  strm->param.vad_enabled;
     }
     
     /* Set other audio engine attributes. */
-    aps_setting.plc = strm->param.plc_enabled;
+    aps_setting.plc = (strm->param.flags & PJMEDIA_AUD_DEV_CAP_PLC) &&
+		      strm->param.plc_enabled;
     aps_setting.cng = aps_setting.vad;
     aps_setting.loudspk = 
Index: pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp	(revision 4242)
+++ pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp	(revision 4243)
@@ -1016,5 +1016,6 @@
 	    unsigned samples_got;
 	    
-	    samples_got = strm->param.ext_fmt.bitrate == 15200? 160 : 240;
+	    samples_got =
+	        strm->param.ext_fmt.det.aud.avg_bps == 15200? 160 : 240;
 	    
 	    /* Check if we got a normal or SID frame. */
@@ -1215,7 +1216,7 @@
 		samples_cnt = frame->samples_cnt / frame->subframe_cnt;
 		
-		pj_assert((strm->param.ext_fmt.bitrate == 15200 && 
+		pj_assert((strm->param.ext_fmt.det.aud.avg_bps == 15200 && 
 			   samples_cnt == 160) ||
-			  (strm->param.ext_fmt.bitrate != 15200 &&
+			  (strm->param.ext_fmt.det.aud.avg_bps != 15200 &&
 			   samples_cnt == 240));
 		
@@ -1231,5 +1232,6 @@
 		    
 		    /* VAS iLBC frame is 20ms or 30ms */
-		    frame_len = strm->param.ext_fmt.bitrate == 15200? 38 : 50;
+		    frame_len =
+		        strm->param.ext_fmt.det.aud.avg_bps == 15200? 38 : 50;
 		    buffer.AppendFill(0, frame_len);
 		}
@@ -1245,5 +1247,6 @@
 		
 		/* VAS iLBC frame is 20ms or 30ms */
-		frame_len = strm->param.ext_fmt.bitrate == 15200? 38 : 50;
+		frame_len =
+		    strm->param.ext_fmt.det.aud.avg_bps == 15200? 38 : 50;
 		buffer.AppendFill(0, frame_len);
 
@@ -1409,4 +1412,6 @@
     
     for (TInt i = 0; i < dnlink_formats.Count(); i++) {
+	pjmedia_format ext_fmt;
+	
 	/* Format must be supported by both downlink & uplink. */
 	if (uplink_formats.Find(dnlink_formats[i]) == KErrNotFound)
@@ -1415,19 +1420,22 @@
 	switch (dnlink_formats[i]) {
 	case EAMR_NB:
-	    af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_AMR;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 7400;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_TRUE;
+	    pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_AMR,
+				      8000, 1, 16, 20, 7400, 12200);
+	    af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt;
+	    //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_TRUE;
 	    break;
 
 	case EG729:
-	    af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_G729;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 8000;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE;
+	    pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_G729,
+				      8000, 1, 16, 20, 8000, 8000);
+	    af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt;
+	    //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE;
 	    break;
 
 	case EILBC:
-	    af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_ILBC;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 13333;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_TRUE;
+	    pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_ILBC,
+				      8000, 1, 16, 30, 13333, 15200);
+	    af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt;
+	    //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_TRUE;
 	    break;
 
@@ -1436,11 +1444,13 @@
 	case EG711_10MS:
 #endif
-	    af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_PCMU;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 64000;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE;
+	    pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_PCMU,
+				      8000, 1, 16, 20, 64000, 64000);
+	    af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt;
+	    //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE;
 	    ++ext_fmt_cnt;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_PCMA;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 64000;
-	    af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE;
+	    pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_PCMA,
+				      8000, 1, 16, 20, 64000, 64000);
+	    af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt;
+	    //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE;
 	    break;
 	
@@ -1617,5 +1627,5 @@
     else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_AMR)
     {
-	vas_setting.mode = strm->param.ext_fmt.bitrate;
+	vas_setting.mode = strm->param.ext_fmt.det.aud.avg_bps;
     } 
     else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMU)
@@ -1629,5 +1639,5 @@
     else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_ILBC)
     {
-	if (strm->param.ext_fmt.bitrate == 15200)
+	if (strm->param.ext_fmt.det.aud.avg_bps == 15200)
 	    vas_setting.mode = CVoIPFormatIntfc::EiLBC20mSecFrame;
 	else
@@ -1648,9 +1658,11 @@
 	vas_setting.vad = EFalse;
     } else {
-	vas_setting.vad = strm->param.ext_fmt.vad;
+	vas_setting.vad = (strm->param.flags & PJMEDIA_AUD_DEV_CAP_VAD) &&
+			  strm->param.vad_enabled;
     }
     
     /* Set other audio engine attributes. */
-    vas_setting.plc = strm->param.plc_enabled;
+    vas_setting.plc = (strm->param.flags & PJMEDIA_AUD_DEV_CAP_PLC) &&
+		      strm->param.plc_enabled;
     vas_setting.cng = vas_setting.vad;
     vas_setting.loudspk = 
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_aud.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_aud.c	(revision 4242)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_aud.c	(revision 4243)
@@ -1573,4 +1573,12 @@
     }
 
+    /* VAD settings */
+    if (pjsua_var.media_cfg.no_vad) {
+	param->flags &= ~PJMEDIA_AUD_DEV_CAP_VAD;
+    } else {
+	param->flags |= PJMEDIA_AUD_DEV_CAP_VAD;
+	param->vad_enabled = PJ_TRUE;
+    }
+
     return PJ_SUCCESS;
 }
