Index: pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/symbian_sound_aps.cpp
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/symbian_sound_aps.cpp	(revision 2456)
+++ pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/symbian_sound_aps.cpp	(revision 2460)
@@ -708,5 +708,5 @@
     pjmedia_frame_ext *frame = (pjmedia_frame_ext*) strm->rec_buf;
     
-    switch(strm->setting.format.u32) {
+    switch(strm->setting.format.id) {
     case PJMEDIA_FORMAT_AMR:
 	{
@@ -757,5 +757,5 @@
 	    unsigned samples_got;
 	    
-	    samples_got = strm->setting.mode == 30? 240 : 160;
+	    samples_got = strm->setting.format.bitrate == 15200? 160 : 240;
 	    
 	    /* Check if we got a normal frame. */
@@ -836,5 +836,5 @@
     buf.iBuffer.Zero();
 
-    switch(strm->setting.format.u32) {
+    switch(strm->setting.format.id) {
     case PJMEDIA_FORMAT_AMR:
 	{
@@ -949,6 +949,9 @@
 		sf = pjmedia_frame_ext_get_subframe(frame, 0);
 		samples_cnt = frame->samples_cnt / frame->subframe_cnt;
-		pj_assert((strm->setting.mode == 30 && samples_cnt == 240) ||
-			  (strm->setting.mode == 20 && samples_cnt == 160));
+		
+		pj_assert((strm->setting.format.bitrate == 15200 && 
+			   samples_cnt == 160) ||
+			  (strm->setting.format.bitrate != 15200 &&
+			   samples_cnt == 240));
 		
 		if (sf->data && sf->bitlen) {
@@ -1006,5 +1009,5 @@
 		    } else {
 			pj_uint8_t silc;
-			silc = (strm->setting.format.u32==PJMEDIA_FORMAT_PCMU)?
+			silc = (strm->setting.format.id==PJMEDIA_FORMAT_PCMU)?
 				pjmedia_linear2ulaw(0) : pjmedia_linear2alaw(0);
 			buf.iBuffer.AppendFill(silc, samples_cnt);
@@ -1017,5 +1020,5 @@
 		    pj_uint8_t silc;
 		    
-		    silc = (strm->setting.format.u32==PJMEDIA_FORMAT_PCMU)?
+		    silc = (strm->setting.format.id==PJMEDIA_FORMAT_PCMU)?
 			    pjmedia_linear2ulaw(0) : pjmedia_linear2alaw(0);
 		    buf.iBuffer.AppendFill(silc, samples_req - samples_ready);
@@ -1106,28 +1109,39 @@
 
     /* Set audio engine fourcc. */
-    if (strm->setting.format.u32 == PJMEDIA_FORMAT_PCMU ||
-	strm->setting.format.u32 == PJMEDIA_FORMAT_PCMA ||
-	strm->setting.format.u32 == PJMEDIA_FORMAT_L16)
+    switch(strm->setting.format.id) {
+    case PJMEDIA_FORMAT_L16:
+    case PJMEDIA_FORMAT_PCMU:
+    case PJMEDIA_FORMAT_PCMA:
+	aps_setting.fourcc = TFourCC(KMCPFourCCIdG711);
+	break;
+    case PJMEDIA_FORMAT_AMR:
+	aps_setting.fourcc = TFourCC(KMCPFourCCIdAMRNB);
+	break;
+    case PJMEDIA_FORMAT_G729:
+	aps_setting.fourcc = TFourCC(KMCPFourCCIdG729);
+	break;
+    case PJMEDIA_FORMAT_ILBC:
+	aps_setting.fourcc = TFourCC(KMCPFourCCIdILBC);
+	break;
+    default:
+	aps_setting.fourcc = 0;
+	break;
+    }
+
+    /* Set audio engine mode. */
+    if (strm->setting.format.id == PJMEDIA_FORMAT_AMR)
     {
-	aps_setting.fourcc = TFourCC(KMCPFourCCIdG711);
-    } else {
-	aps_setting.fourcc = TFourCC(strm->setting.format.u32);
-    }
-
-    /* Set audio engine mode. */
-    if (strm->setting.format.u32 == PJMEDIA_FORMAT_AMR)
-    {
-	aps_setting.mode = (TAPSCodecMode)strm->setting.bitrate;
+	aps_setting.mode = (TAPSCodecMode)strm->setting.format.bitrate;
     } 
-    else if (strm->setting.format.u32 == PJMEDIA_FORMAT_PCMU ||
-	     strm->setting.format.u32 == PJMEDIA_FORMAT_L16 ||
-	    (strm->setting.format.u32 == PJMEDIA_FORMAT_ILBC  &&
-	     strm->setting.mode == 30))
+    else if (strm->setting.format.id == PJMEDIA_FORMAT_PCMU ||
+	     strm->setting.format.id == PJMEDIA_FORMAT_L16 ||
+	    (strm->setting.format.id == PJMEDIA_FORMAT_ILBC  &&
+	     strm->setting.format.bitrate != 15200))
     {
 	aps_setting.mode = EULawOr30ms;
     } 
-    else if (strm->setting.format.u32 == PJMEDIA_FORMAT_PCMA ||
-	    (strm->setting.format.u32 == PJMEDIA_FORMAT_ILBC &&
-	     strm->setting.mode == 20))
+    else if (strm->setting.format.id == PJMEDIA_FORMAT_PCMA ||
+	    (strm->setting.format.id == PJMEDIA_FORMAT_ILBC &&
+	     strm->setting.format.bitrate == 15200))
     {
 	aps_setting.mode = EALawOr20ms;
@@ -1135,20 +1149,20 @@
 
     /* Disable VAD on L16 and G711. */
-    if (strm->setting.format.u32 == PJMEDIA_FORMAT_PCMU ||
-	strm->setting.format.u32 == PJMEDIA_FORMAT_PCMA ||
-	strm->setting.format.u32 == PJMEDIA_FORMAT_L16)
+    if (strm->setting.format.id == PJMEDIA_FORMAT_PCMU ||
+	strm->setting.format.id == PJMEDIA_FORMAT_PCMA ||
+	strm->setting.format.id == PJMEDIA_FORMAT_L16)
     {
 	aps_setting.vad = EFalse;
     } else {
-	aps_setting.vad = strm->setting.vad;
+	aps_setting.vad = strm->setting.format.vad;
     }
     
     /* Set other audio engine attributes. */
     aps_setting.plc = strm->setting.plc;
-    aps_setting.cng = strm->setting.cng;
-    aps_setting.loudspk = strm->setting.loudspk;
+    aps_setting.cng = aps_setting.vad;
+    aps_setting.loudspk = strm->setting.route == PJMEDIA_SND_ROUTE_LOUDSPEAKER;
 
     /* Set audio engine callbacks. */
-    if (strm->setting.format.u32 == PJMEDIA_FORMAT_L16) {
+    if (strm->setting.format.id == PJMEDIA_FORMAT_L16) {
 	aps_play_cb = &PlayCbPcm;
 	aps_rec_cb  = &RecCbPcm;
@@ -1180,5 +1194,5 @@
     strm->rec_buf_len = 0;
 
-    if (strm->setting.format.u32 == PJMEDIA_FORMAT_G729) {
+    if (strm->setting.format.id == PJMEDIA_FORMAT_G729) {
 	TBitStream *g729_bitstream = new TBitStream;
 	
@@ -1212,5 +1226,5 @@
 
     pj_bzero(&setting, sizeof(setting));
-    setting.format.u32 = PJMEDIA_FORMAT_L16;
+    setting.format.id = PJMEDIA_FORMAT_L16;
     
     return sound_open(PJMEDIA_DIR_CAPTURE, clock_rate, channel_count,
@@ -1234,5 +1248,5 @@
 
     pj_bzero(&setting, sizeof(setting));
-    setting.format.u32 = PJMEDIA_FORMAT_L16;
+    setting.format.id = PJMEDIA_FORMAT_L16;
 
     return sound_open(PJMEDIA_DIR_PLAYBACK, clock_rate, channel_count,
@@ -1259,5 +1273,5 @@
 
     pj_bzero(&setting, sizeof(setting));
-    setting.format.u32 = PJMEDIA_FORMAT_L16;
+    setting.format.id = PJMEDIA_FORMAT_L16;
 
     return sound_open(PJMEDIA_DIR_CAPTURE_PLAYBACK, clock_rate, channel_count,
@@ -1347,5 +1361,5 @@
     stream->engine = NULL;
 
-    if (stream->setting.format.u32 == PJMEDIA_FORMAT_G729) {
+    if (stream->setting.format.id == PJMEDIA_FORMAT_G729) {
 	TBitStream *g729_bitstream = (TBitStream*)stream->strm_data;
 	stream->strm_data = NULL;
