Index: /pjproject/trunk/pjlib/include/pj/config_site_sample.h
===================================================================
--- /pjproject/trunk/pjlib/include/pj/config_site_sample.h	(revision 2832)
+++ /pjproject/trunk/pjlib/include/pj/config_site_sample.h	(revision 2833)
@@ -223,7 +223,8 @@
     #define PJMEDIA_CONF_USE_SWITCH_BOARD	1
 
-    /* Enable APS sound device backend and disable MDA */
+    /* Enable APS sound device backend and disable MDA & VAS */
     #define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA	0
     #define PJMEDIA_AUDIO_DEV_HAS_SYMB_APS	1
+    #define PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS	0
 
     /* Enable passthrough codec framework */
@@ -251,6 +252,7 @@
     #define PJMEDIA_CONF_USE_SWITCH_BOARD	1
 
-    /* Enable APS sound device backend and disable MDA */
+    /* Enable VAS sound device backend and disable MDA & APS */
     #define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA	0
+    #define PJMEDIA_AUDIO_DEV_HAS_SYMB_APS	0
     #define PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS	1
 
Index: /pjproject/trunk/pjmedia/include/pjmedia-audiodev/config.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia-audiodev/config.h	(revision 2832)
+++ /pjproject/trunk/pjmedia/include/pjmedia-audiodev/config.h	(revision 2833)
@@ -72,4 +72,14 @@
 #ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS
 #   define PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS	0
+#endif
+
+/**
+ * This setting controls Symbian VAS version to be used. Currently, valid
+ * values are only 1 (for VAS 1.0) and 2 (for VAS 2.0).
+ *
+ * Default: 1 (VAS version 1.0)
+ */
+#ifndef PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION
+#   define PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION	1
 #endif
 
Index: /pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp	(revision 2832)
+++ /pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp	(revision 2833)
@@ -313,5 +313,5 @@
 {
     TInt err;
-    const TVersion ver(1, 0, 0);
+    const TVersion ver(1, 0, 0); /* Not really used at this time */
 
     err = CVoIPUtilityFactory::CreateFactory(iFactory);
@@ -396,5 +396,9 @@
     if (err != KErrNone)
 	return err;
-
+    
+    err = enc_fmt_if->SetObserver(*this);
+    if (err != KErrNone)
+	return err;
+    
     return iVoIPUplink->Open(*this);
 }
@@ -402,4 +406,6 @@
 TInt CPjAudioEngine::StartPlay()
 {
+    TInt err;
+    
     pj_assert(iVoIPDnlink);
     pj_assert(dn_state_ == STATE_READY);
@@ -408,10 +414,10 @@
     switch (setting_.format) {
     case EG711:
-    //case EG711_10MS:
 	{
 	    CVoIPG711DecoderIntfc *g711dec_if = (CVoIPG711DecoderIntfc*)
 						dec_fmt_if;
-	    g711dec_if->SetMode((CVoIPFormatIntfc::TG711CodecMode)
-				setting_.mode);
+	    err = g711dec_if->SetMode((CVoIPFormatIntfc::TG711CodecMode)
+				      setting_.mode);
+	    pj_assert(err == KErrNone);
 	}
 	break;
@@ -421,6 +427,7 @@
 	    CVoIPILBCDecoderIntfc *ilbcdec_if = (CVoIPILBCDecoderIntfc*)
 						dec_fmt_if;
-	    ilbcdec_if->SetMode((CVoIPFormatIntfc::TILBCCodecMode)
-				setting_.mode);
+	    err = ilbcdec_if->SetMode((CVoIPFormatIntfc::TILBCCodecMode)
+				      setting_.mode);
+	    pj_assert(err == KErrNone);
 	}
 	break;
@@ -434,5 +441,5 @@
 
     /* Start player */
-    TInt err = iVoIPDnlink->Start();
+    err = iVoIPDnlink->Start();
     
     if (err == KErrNone) {
@@ -448,19 +455,18 @@
 TInt CPjAudioEngine::StartRec()
 {
+    TInt err;
+    
     pj_assert(iVoIPUplink);
     pj_assert(up_state_ == STATE_READY);
 
-    /* Configure general codec setting */
-    enc_fmt_if->SetVAD(setting_.vad);
-    
     /* Configure specific codec setting */
     switch (setting_.format) {
     case EG711:
-    //case EG711_10MS:
 	{
 	    CVoIPG711EncoderIntfc *g711enc_if = (CVoIPG711EncoderIntfc*)
 						enc_fmt_if;
-	    g711enc_if->SetMode((CVoIPFormatIntfc::TG711CodecMode)
-				setting_.mode);
+	    err = g711enc_if->SetMode((CVoIPFormatIntfc::TG711CodecMode)
+				      setting_.mode);
+	    pj_assert(err == KErrNone);
 	}
 	break;
@@ -470,6 +476,7 @@
 	    CVoIPILBCEncoderIntfc *ilbcenc_if = (CVoIPILBCEncoderIntfc*)
 						enc_fmt_if;
-	    ilbcenc_if->SetMode((CVoIPFormatIntfc::TILBCCodecMode)
-				setting_.mode);
+	    err = ilbcenc_if->SetMode((CVoIPFormatIntfc::TILBCCodecMode)
+				      setting_.mode);
+	    pj_assert(err == KErrNone);
 	}
 	break;
@@ -479,6 +486,9 @@
     }
     
+    /* Configure general codec setting */
+    enc_fmt_if->SetVAD(setting_.vad);
+    
     /* Start recorder */
-    TInt err = iVoIPUplink->Start();
+    err = iVoIPUplink->Start();
     
     if (err == KErrNone) {
@@ -601,5 +611,5 @@
     case MVoIPDownlinkObserver::KOpenComplete:
 	if (aError == KErrNone) {
-	    State last_state = up_state_;
+	    State last_state = dn_state_;
 
 	    dn_state_ = STATE_READY;
@@ -944,5 +954,5 @@
 	{
 	    /* Check if we got a normal or SID frame. */
-	    if (buffer[0] != 0 || buffer[1] != 0) {
+	    if (buffer[0] != 0) {
 		enum { NORMAL_LEN = 22, SID_LEN = 8 };
 		TBitStream *bitstream = (TBitStream*)strm->strm_data;
@@ -950,5 +960,5 @@
 		
 		pj_assert(src_len == NORMAL_LEN || src_len == SID_LEN);
-
+		
 		const TDesC8& p = bitstream->CompressG729Frame(
 					    buffer.Right(src_len), 
@@ -976,6 +986,6 @@
 	    samples_got = strm->param.ext_fmt.bitrate == 15200? 160 : 240;
 	    
-	    /* Check if we got a normal frame. */
-	    if (buffer[0] == 1 && buffer[1] == 0) {
+	    /* Check if we got a normal or SID frame. */
+	    if (buffer[0] != 0) {
 		const pj_uint8_t *p = (const pj_uint8_t*)buffer.Ptr() + 2;
 		unsigned len = buffer.Length() - 2;
@@ -1126,6 +1136,6 @@
 								   sid_frame); 
 		    if (sid_frame) {
+			buffer.Append(2);
 			buffer.Append(0);
-			buffer.Append(1);
 		    } else {
 			buffer.Append(1);
@@ -1134,6 +1144,8 @@
 		    buffer.Append(dst);
 		} else {
+		    buffer.Append(2);
 		    buffer.Append(0);
-		    buffer.Append(0);
+
+		    buffer.AppendFill(0, 22);
 		}
 
@@ -1141,9 +1153,8 @@
 	    
 	    } else { /* PJMEDIA_FRAME_TYPE_NONE */
+		buffer.Append(2);
 		buffer.Append(0);
-		buffer.Append(0);
-		
-		frame->samples_cnt = 0;
-		frame->subframe_cnt = 0;
+		
+		buffer.AppendFill(0, 22);
 	    }
 	}
@@ -1176,6 +1187,12 @@
 		    buffer.Append((TUint8*)sf->data, sf->bitlen>>3);
 		} else {
+		    unsigned frame_len;
+		    
+		    buffer.Append(1);
 		    buffer.Append(0);
-		    buffer.Append(0);
+		    
+		    /* VAS iLBC frame is 20ms or 30ms */
+		    frame_len = strm->param.ext_fmt.bitrate == 15200? 38 : 50;
+		    buffer.AppendFill(0, frame_len);
 		}
 
@@ -1183,9 +1200,14 @@
 	    
 	    } else { /* PJMEDIA_FRAME_TYPE_NONE */
+		
+		unsigned frame_len;
+		
+		buffer.Append(1);
 		buffer.Append(0);
-		buffer.Append(0);
-		
-		frame->samples_cnt = 0;
-		frame->subframe_cnt = 0;
+		
+		/* VAS iLBC frame is 20ms or 30ms */
+		frame_len = strm->param.ext_fmt.bitrate == 15200? 38 : 50;
+		buffer.AppendFill(0, frame_len);
+
 	    }
 	}
@@ -1289,6 +1311,9 @@
     struct vas_factory *af = (struct vas_factory*)f;
     CVoIPUtilityFactory *vas_factory;
+    CVoIPAudioUplinkStream *vas_uplink;
+    CVoIPAudioDownlinkStream *vas_dnlink;
     RArray<TVoIPCodecFormat> uplink_formats, dnlink_formats;
     unsigned ext_fmt_cnt = 0;
+    TVersion vas_version(1, 0, 0); /* Not really used at this time */
     TInt err;
 
@@ -1312,4 +1337,19 @@
 	goto on_error;
 
+    /* On VAS 2.0, uplink & downlink stream should be instantiated before 
+     * querying formats.
+     */
+    err = vas_factory->CreateUplinkStream(vas_version, 
+				          CVoIPUtilityFactory::EVoIPCall,
+				          vas_uplink);
+    if (err != KErrNone)
+	goto on_error;
+    
+    err = vas_factory->CreateDownlinkStream(vas_version, 
+				            CVoIPUtilityFactory::EVoIPCall,
+				            vas_dnlink);
+    if (err != KErrNone)
+	goto on_error;
+    
     uplink_formats.Reset();
     err = vas_factory->GetSupportedUplinkFormats(uplink_formats);
@@ -1322,4 +1362,10 @@
 	goto on_error;
 
+    /* Free the streams, they are just used for querying formats */
+    delete vas_uplink;
+    vas_uplink = NULL;
+    delete vas_dnlink;
+    vas_dnlink = NULL;
+    
     for (TInt i = 0; i < dnlink_formats.Count(); i++) {
 	/* Format must be supported by both downlink & uplink. */
@@ -1347,4 +1393,7 @@
 
 	case EG711:
+#if PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION==2
+	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;
@@ -1541,10 +1590,11 @@
     }
 
-    /* Disable VAD on L16, G711, and also G729 (G729's VAD potentially 
-     * causes noise?).
+    /* Disable VAD on L16, G711, iLBC, and also G729 (G729's SID 
+     * potentially cause noise?).
      */
     if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMU ||
 	strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMA ||
 	strm->param.ext_fmt.id == PJMEDIA_FORMAT_L16 ||
+	strm->param.ext_fmt.id == PJMEDIA_FORMAT_ILBC ||
 	strm->param.ext_fmt.id == PJMEDIA_FORMAT_G729)
     {
