Index: pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/codec.h
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/codec.h	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/codec.h	(revision 2456)
@@ -276,5 +276,5 @@
        pj_uint8_t  pcm_bits_per_sample;	/**< Bits/sample in the PCM side    */
        pj_uint8_t  pt;			/**< Payload type.		    */
-       pjmedia_fourcc format;		/**< Source format, it's format of
+       pjmedia_format format;		/**< Source format, it's format of
 					     encoder input and decoder 
 					     output.			    */
Index: pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/conference.h
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/conference.h	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/conference.h	(revision 2456)
@@ -57,5 +57,5 @@
     unsigned		slot;		    /**< Slot number.		    */
     pj_str_t		name;		    /**< Port name.		    */
-    pjmedia_fourcc	format;		    /**< Format (FourCC identifier) */
+    pjmedia_format	format;		    /**< Format.		    */
     pjmedia_port_op	tx_setting;	    /**< Transmit settings.	    */
     pjmedia_port_op	rx_setting;	    /**< Receive settings.	    */
Index: pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/port.h
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/port.h	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/port.h	(revision 2456)
@@ -213,5 +213,5 @@
     pj_bool_t	    need_info;		/**< Need info on connect?	    */
     unsigned	    pt;			/**< Payload type (can be dynamic). */
-    pjmedia_fourcc  format;		/**< Format (FourCC identifier)	    */
+    pjmedia_format  format;		/**< Format.			    */
     pj_str_t	    encoding_name;	/**< Encoding name.		    */
     unsigned	    clock_rate;		/**< Sampling rate.		    */
@@ -359,5 +359,5 @@
  * @param n		    Number of first subframes to be popped out.
  *
- * @return		    PJ_SUCCESS, or PJ_ENOTFOUND if frame is empty.
+ * @return		    PJ_SUCCESS when successful.
  */
 PJ_INLINE(pj_status_t) 
Index: pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/sound.h
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/sound.h	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/sound.h	(revision 2456)
@@ -99,5 +99,5 @@
 typedef struct pjmedia_snd_setting
 {
-    pjmedia_fourcc	format;	  /**< Format (FourCC ID).	    */ 
+    pjmedia_format	format;	  /**< Format.			    */ 
     pj_uint32_t		bitrate;  /**< Bitrate (bps).		    */
     pj_uint32_t		mode;	  /**< Mode, e.g: iLBC format has
Index: pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/symbian_sound_aps.h
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/symbian_sound_aps.h	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/symbian_sound_aps.h	(revision 2456)
@@ -32,22 +32,4 @@
 
 /**
- * Declaration of APS sound setting.  
- */
-typedef struct pjmedia_snd_aps_setting
-{
-    pjmedia_fourcc	format;	  /**< Format (FourCC ID).	*/ 
-    pj_uint32_t		bitrate;  /**< Bitrate (bps).		*/
-    pj_uint32_t		mode;	  /**< Mode, currently only used 
-				       for specifying iLBC mode,
-				       20ms or 30ms frame size.	*/
-    pj_bool_t		plc;	  /**< PLC enabled/disabled.	*/
-    pj_bool_t		vad;	  /**< VAD enabled/disabled.	*/
-    pj_bool_t		cng;	  /**< CNG enabled/disabled.	*/
-    pj_bool_t		loudspk;  /**< Audio routed to loudspeaker.*/
-    
-} pjmedia_snd_aps_setting;
-
-
-/**
  * Activate/deactivate loudspeaker, when loudspeaker is inactive, audio
  * will be routed to earpiece.
Index: pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/types.h
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/types.h	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/types.h	(revision 2456)
@@ -180,26 +180,26 @@
 
 /**
- * Declaration of FourCC type.
- */
-typedef union pjmedia_fourcc {
+ * Declaration of format.
+ */
+typedef union pjmedia_format {
    pj_uint32_t  u32;
    char         c[4];
-} pjmedia_fourcc;
-
-
-/**
- * FourCC packing macro.
- */
-#define PJMEDIA_FOURCC_PACK(C1, C2, C3, C4) ( C4<<24 | C3<<16 | C2<<8 | C1 )
-
-/**
- * FourCC identifier definitions.
- */
-#define PJMEDIA_FOURCC_L16	PJMEDIA_FOURCC_PACK(' ', 'L', '1', '6')
-#define PJMEDIA_FOURCC_PCMA	PJMEDIA_FOURCC_PACK('A', 'L', 'A', 'W')
-#define PJMEDIA_FOURCC_PCMU	PJMEDIA_FOURCC_PACK('u', 'L', 'A', 'W')
-#define PJMEDIA_FOURCC_AMR	PJMEDIA_FOURCC_PACK(' ', 'A', 'M', 'R')
-#define PJMEDIA_FOURCC_G729	PJMEDIA_FOURCC_PACK('G', '7', '2', '9')
-#define PJMEDIA_FOURCC_ILBC	PJMEDIA_FOURCC_PACK('I', 'L', 'B', 'C')
+} pjmedia_format;
+
+
+/**
+ * Macro for packing format.
+ */
+#define PJMEDIA_FORMAT_PACK(C1, C2, C3, C4) ( C4<<24 | C3<<16 | C2<<8 | C1 )
+
+/**
+ * Format identifier definitions.
+ */
+#define PJMEDIA_FORMAT_L16	0
+#define PJMEDIA_FORMAT_PCMA	PJMEDIA_FORMAT_PACK('A', 'L', 'A', 'W')
+#define PJMEDIA_FORMAT_PCMU	PJMEDIA_FORMAT_PACK('u', 'L', 'A', 'W')
+#define PJMEDIA_FORMAT_AMR	PJMEDIA_FORMAT_PACK(' ', 'A', 'M', 'R')
+#define PJMEDIA_FORMAT_G729	PJMEDIA_FORMAT_PACK('G', '7', '2', '9')
+#define PJMEDIA_FORMAT_ILBC	PJMEDIA_FORMAT_PACK('I', 'L', 'B', 'C')
 
 
Index: pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-codec/passthrough.c
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-codec/passthrough.c	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-codec/passthrough.c	(revision 2456)
@@ -156,5 +156,5 @@
     const char	    *name;		/* Codec name.			    */
     pj_uint8_t	     pt;		/* Payload type.		    */
-    pjmedia_fourcc   format;		/* Source format.		    */
+    pjmedia_format   format;		/* Source format.		    */
     unsigned	     clock_rate;	/* Codec's clock rate.		    */
     unsigned	     channel_count;	/* Codec's channel count.	    */
@@ -173,5 +173,5 @@
 {
 #   if PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR
-    {1, "AMR",	    PJMEDIA_RTP_PT_AMR,       {PJMEDIA_FOURCC_AMR},
+    {1, "AMR",	    PJMEDIA_RTP_PT_AMR,       {PJMEDIA_FORMAT_AMR},
 		    8000, 1, 160, 
 		    7400, 12200, 2, 1, 1,
@@ -182,5 +182,5 @@
 
 #   if PJMEDIA_HAS_PASSTHROUGH_CODEC_G729
-    {1, "G729",	    PJMEDIA_RTP_PT_G729,      {PJMEDIA_FOURCC_G729},
+    {1, "G729",	    PJMEDIA_RTP_PT_G729,      {PJMEDIA_FORMAT_G729},
 		    8000, 1,  80,
 		    8000, 8000, 2, 1, 1
@@ -189,5 +189,5 @@
 
 #   if PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC
-    {1, "iLBC",	    PJMEDIA_RTP_PT_ILBC,      {PJMEDIA_FOURCC_ILBC},
+    {1, "iLBC",	    PJMEDIA_RTP_PT_ILBC,      {PJMEDIA_FORMAT_ILBC},
 		    8000, 1,  240,
 		    13333, 15200, 1, 1, 1,
@@ -198,5 +198,5 @@
 
 #   if PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU
-    {1, "PCMU",	    PJMEDIA_RTP_PT_PCMU,      {PJMEDIA_FOURCC_PCMU},
+    {1, "PCMU",	    PJMEDIA_RTP_PT_PCMU,      {PJMEDIA_FORMAT_PCMU},
 		    8000, 1,  80,
 		    64000, 64000, 2, 1, 1
@@ -205,5 +205,5 @@
 
 #   if PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA
-    {1, "PCMA",	    PJMEDIA_RTP_PT_PCMA,      {PJMEDIA_FOURCC_PCMA},
+    {1, "PCMA",	    PJMEDIA_RTP_PT_PCMA,      {PJMEDIA_FORMAT_PCMA},
 		    8000, 1,  80,
 		    64000, 64000, 2, 1, 1
Index: pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/conf_switch.c
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/conf_switch.c	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/conf_switch.c	(revision 2456)
@@ -588,4 +588,10 @@
     dst_port = conf->ports[sink_slot];
 
+    /* Source and sink format must match. */
+    if (src_port->info->format.u32 != dst_port->info->format.u32) {
+	pj_mutex_unlock(conf->mutex);
+	return PJMEDIA_ENOTCOMPATIBLE;
+    }
+
     /* Source and sink ptime must be equal or a multiplication factor. */
     if ((src_port->info->samples_per_frame % 
@@ -598,12 +604,4 @@
     }
     
-    /* Check if source and sink has compatible format */
-    if (src_slot != 0 && sink_slot != 0 && 
-	src_port->port->info.format.u32 != dst_port->port->info.format.u32)
-    {
-	pj_mutex_unlock(conf->mutex);
-	return PJMEDIA_ENOTCOMPATIBLE;
-    }
-
     /* Check if sink is listening to other ports */
     if (dst_port->transmitter_cnt > 0) {
@@ -954,6 +952,5 @@
 
     /* Level adjustment is applicable only for ports that work with raw PCM. */
-    PJ_ASSERT_RETURN(conf_port->info->format.u32 == 0 || 
-		     conf_port->info->format.u32 == PJMEDIA_FOURCC_L16,
+    PJ_ASSERT_RETURN(conf_port->info->format.u32 == PJMEDIA_FORMAT_L16,
 		     PJ_EIGNORED);
 
@@ -989,6 +986,5 @@
 
     /* Level adjustment is applicable only for ports that work with raw PCM. */
-    PJ_ASSERT_RETURN(conf_port->info->format.u32 == 0 || 
-		     conf_port->info->format.u32 == PJMEDIA_FOURCC_L16,
+    PJ_ASSERT_RETURN(conf_port->info->format.u32 == PJMEDIA_FORMAT_L16,
 		     PJ_EIGNORED);
 
@@ -1114,6 +1110,6 @@
 
 	/* Check port format. */
-	if (cport_dst->port && (cport_dst->port->info.format.u32==0 ||
-	    cport_dst->port->info.format.u32 == PJMEDIA_FOURCC_L16))
+	if (cport_dst->port &&
+	    cport_dst->port->info.format.u32 == PJMEDIA_FORMAT_L16)
 	{
 	    /* When there is already some samples in listener's TX buffer, 
@@ -1266,5 +1262,5 @@
 		}
 	    } else if (f->type == PJMEDIA_FRAME_TYPE_EXTENDED) {
-		/* For extended frame, TX level is unknown, so we just set 
+		/* For extended frame, level is unknown, so we just set 
 		 * it to NORMAL_LEVEL. 
 		 */
@@ -1474,5 +1470,5 @@
 	}
     } else if (f->type == PJMEDIA_FRAME_TYPE_EXTENDED) {
-	/* For extended frame, TX level is unknown, so we just set 
+	/* For extended frame, level is unknown, so we just set 
 	 * it to NORMAL_LEVEL. 
 	 */
Index: pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/sound_port.c
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/sound_port.c	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/sound_port.c	(revision 2456)
@@ -291,8 +291,8 @@
 
 	switch (snd_port->setting.format.u32) {
-	case PJMEDIA_FOURCC_PCMA:
+	case PJMEDIA_FORMAT_PCMA:
 	    decoder = &pjmedia_alaw_decode;
 	    break;
-	case PJMEDIA_FOURCC_PCMU:
+	case PJMEDIA_FORMAT_PCMU:
 	    decoder = &pjmedia_ulaw_decode;
 	    break;
@@ -393,8 +393,8 @@
 
     switch (snd_port->setting.format.u32) {
-    case PJMEDIA_FOURCC_PCMA:
+    case PJMEDIA_FORMAT_PCMA:
 	encoder = &pjmedia_alaw_encode;
 	break;
-    case PJMEDIA_FOURCC_PCMU:
+    case PJMEDIA_FORMAT_PCMU:
 	encoder = &pjmedia_ulaw_encode;
 	break;
@@ -435,7 +435,5 @@
 		     PJ_EBUG);
 
-    if (snd_port->setting.format.u32 == 0 ||
-	snd_port->setting.format.u32 == PJMEDIA_FOURCC_L16)
-    {
+    if (snd_port->setting.format.u32 == PJMEDIA_FORMAT_L16) {
 	snd_rec_cb = &rec_cb;
 	snd_play_cb = &play_cb;
@@ -701,7 +699,5 @@
     
 #if PJMEDIA_SOUND_USE_DELAYBUF
-    if (snd_port->setting.format.u32 == 0 ||
-	snd_port->setting.format.u32 == PJMEDIA_FOURCC_L16) 
-    {
+    if (snd_port->setting.format.u32 == PJMEDIA_FORMAT_L16) {
 	pj_status_t status;
 	unsigned ptime;
@@ -720,7 +716,5 @@
 #if !defined(PJMEDIA_SND_SUPPORT_OPEN2) || PJMEDIA_SND_SUPPORT_OPEN2==0
     /* For devices that doesn't support open2(), enable simulation */
-    if (snd_port->setting.format.u32 != 0 &&
-	snd_port->setting.format.u32 != PJMEDIA_FOURCC_L16) 
-    {
+    if (snd_port->setting.format.u32 != PJMEDIA_FORMAT_L16) {
 	snd_port->frm_buf_size = sizeof(pjmedia_frame_ext) + 
 				 (samples_per_frame << 1) +
Index: pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/stream.c
===================================================================
--- pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/stream.c	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/stream.c	(revision 2456)
@@ -868,6 +868,5 @@
     } else if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO &&
 	       frame->buf == NULL &&
-	       (stream->port.info.format.u32 == 0 ||
-	        stream->port.info.format.u32 == PJMEDIA_FOURCC_L16) &&
+	       stream->port.info.format.u32 == PJMEDIA_FORMAT_L16 &&
 	       (stream->dir & PJMEDIA_DIR_ENCODING) &&
 	       stream->codec_param.info.frm_ptime *
@@ -1609,7 +1608,5 @@
     stream->port.info.format = info->param->info.format;
     stream->port.port_data.pdata = stream;
-    if (stream->port.info.format.u32 == 0 ||
-	stream->port.info.format.u32 == PJMEDIA_FOURCC_L16)
-    {
+    if (stream->port.info.format.u32 == PJMEDIA_FORMAT_L16) {
 	stream->port.put_frame = &put_frame;
 	stream->port.get_frame = &get_frame;
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 2455)
+++ pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/symbian_sound_aps.cpp	(revision 2456)
@@ -509,5 +509,5 @@
 	iSession.Stop();
 	state_ = STATE_READY;
-	TRACE_((THIS_FILE, "Streaming stopped"));
+	TRACE_((THIS_FILE, "Sound device stopped"));
     }
 }
@@ -550,5 +550,5 @@
     if (parentStrm_->dir != PJMEDIA_DIR_CAPTURE) {
 	iSession.Write();
-	TRACE_((THIS_FILE, "Player streaming started"));
+	TRACE_((THIS_FILE, "Player started"));
     }
 
@@ -556,5 +556,5 @@
     if (parentStrm_->dir != PJMEDIA_DIR_PLAYBACK) {
 	iSession.Read();
-	TRACE_((THIS_FILE, "Recorder streaming started"));
+	TRACE_((THIS_FILE, "Recorder started"));
     }
 
@@ -569,5 +569,5 @@
 void CPjAudioEngine::InputStreamInitialized(const TInt aStatus)
 {
-    TRACE_((THIS_FILE, "InputStreamInitialized %d", aStatus));
+    TRACE_((THIS_FILE, "Recorder initialized, err=%d", aStatus));
 
     state_ = STATE_READY;
@@ -579,5 +579,5 @@
 void CPjAudioEngine::OutputStreamInitialized(const TInt aStatus)
 {
-    TRACE_((THIS_FILE, "OutputStreamInitialized %d", aStatus));
+    TRACE_((THIS_FILE, "Player initialized, err=%d", aStatus));
 
     if (aStatus == KErrNone) {
@@ -605,5 +605,5 @@
     if (state_ == STATE_READY || state_ == STATE_STREAMING) {
         iSession.ActivateLoudspeaker(active);
-        TRACE_((THIS_FILE, "Loudspeaker on/off: %d", active));
+        TRACE_((THIS_FILE, "Loudspeaker turned %s", (active? "on":"off")));
 	return KErrNone;
     }
@@ -709,5 +709,5 @@
     
     switch(strm->setting.format.u32) {
-    case PJMEDIA_FOURCC_AMR:
+    case PJMEDIA_FORMAT_AMR:
 	{
 	    const pj_uint8_t *p = (const pj_uint8_t*)buf.iBuffer.Ptr() + 1;
@@ -724,5 +724,5 @@
 	break;
 	
-    case PJMEDIA_FOURCC_G729:
+    case PJMEDIA_FORMAT_G729:
 	{
 	    /* Check if we got a normal or SID frame. */
@@ -753,5 +753,5 @@
 	break;
 
-    case PJMEDIA_FOURCC_ILBC:
+    case PJMEDIA_FORMAT_ILBC:
 	{
 	    unsigned samples_got;
@@ -779,6 +779,6 @@
 	break;
 	
-    case PJMEDIA_FOURCC_PCMU:
-    case PJMEDIA_FOURCC_PCMA:
+    case PJMEDIA_FORMAT_PCMU:
+    case PJMEDIA_FORMAT_PCMA:
 	{
 	    unsigned samples_processed = 0;
@@ -837,5 +837,5 @@
 
     switch(strm->setting.format.u32) {
-    case PJMEDIA_FOURCC_AMR:
+    case PJMEDIA_FORMAT_AMR:
 	{
 	    if (frame->samples_cnt == 0) {
@@ -884,5 +884,5 @@
 	break;
 	
-    case PJMEDIA_FOURCC_G729:
+    case PJMEDIA_FORMAT_G729:
 	{
 	    if (frame->samples_cnt == 0) {
@@ -933,5 +933,5 @@
 	break;
 	
-    case PJMEDIA_FOURCC_ILBC:
+    case PJMEDIA_FORMAT_ILBC:
 	{
 	    if (frame->samples_cnt == 0) {
@@ -973,6 +973,6 @@
 	break;
 	
-    case PJMEDIA_FOURCC_PCMU:
-    case PJMEDIA_FOURCC_PCMA:
+    case PJMEDIA_FORMAT_PCMU:
+    case PJMEDIA_FORMAT_PCMA:
 	{
 	    unsigned samples_ready = 0;
@@ -1006,5 +1006,5 @@
 		    } else {
 			pj_uint8_t silc;
-			silc = (strm->setting.format.u32==PJMEDIA_FOURCC_PCMU)?
+			silc = (strm->setting.format.u32==PJMEDIA_FORMAT_PCMU)?
 				pjmedia_linear2ulaw(0) : pjmedia_linear2alaw(0);
 			buf.iBuffer.AppendFill(silc, samples_cnt);
@@ -1017,5 +1017,5 @@
 		    pj_uint8_t silc;
 		    
-		    silc = (strm->setting.format.u32==PJMEDIA_FOURCC_PCMU)?
+		    silc = (strm->setting.format.u32==PJMEDIA_FORMAT_PCMU)?
 			    pjmedia_linear2ulaw(0) : pjmedia_linear2alaw(0);
 		    buf.iBuffer.AppendFill(silc, samples_req - samples_ready);
@@ -1105,11 +1105,8 @@
     strm->setting = *setting;
 
-    if (strm->setting.format.u32 == 0)
-	strm->setting.format.u32 = PJMEDIA_FOURCC_L16;
-
     /* Set audio engine fourcc. */
-    if (strm->setting.format.u32 == PJMEDIA_FOURCC_PCMU ||
-	strm->setting.format.u32 == PJMEDIA_FOURCC_PCMA ||
-	strm->setting.format.u32 == PJMEDIA_FOURCC_L16)
+    if (strm->setting.format.u32 == PJMEDIA_FORMAT_PCMU ||
+	strm->setting.format.u32 == PJMEDIA_FORMAT_PCMA ||
+	strm->setting.format.u32 == PJMEDIA_FORMAT_L16)
     {
 	aps_setting.fourcc = TFourCC(KMCPFourCCIdG711);
@@ -1119,17 +1116,17 @@
 
     /* Set audio engine mode. */
-    if (strm->setting.format.u32 == PJMEDIA_FOURCC_AMR)
+    if (strm->setting.format.u32 == PJMEDIA_FORMAT_AMR)
     {
 	aps_setting.mode = (TAPSCodecMode)strm->setting.bitrate;
     } 
-    else if (strm->setting.format.u32 == PJMEDIA_FOURCC_PCMU ||
-	     strm->setting.format.u32 == PJMEDIA_FOURCC_L16   ||
-	    (strm->setting.format.u32 == PJMEDIA_FOURCC_ILBC  &&
+    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))
     {
 	aps_setting.mode = EULawOr30ms;
     } 
-    else if (strm->setting.format.u32 == PJMEDIA_FOURCC_PCMA ||
-	    (strm->setting.format.u32 == PJMEDIA_FOURCC_ILBC &&
+    else if (strm->setting.format.u32 == PJMEDIA_FORMAT_PCMA ||
+	    (strm->setting.format.u32 == PJMEDIA_FORMAT_ILBC &&
 	     strm->setting.mode == 20))
     {
@@ -1138,7 +1135,7 @@
 
     /* Disable VAD on L16 and G711. */
-    if (strm->setting.format.u32 == PJMEDIA_FOURCC_PCMU ||
-	strm->setting.format.u32 == PJMEDIA_FOURCC_PCMA ||
-	strm->setting.format.u32 == PJMEDIA_FOURCC_L16)
+    if (strm->setting.format.u32 == PJMEDIA_FORMAT_PCMU ||
+	strm->setting.format.u32 == PJMEDIA_FORMAT_PCMA ||
+	strm->setting.format.u32 == PJMEDIA_FORMAT_L16)
     {
 	aps_setting.vad = EFalse;
@@ -1153,5 +1150,5 @@
 
     /* Set audio engine callbacks. */
-    if (strm->setting.format.u32 == PJMEDIA_FOURCC_L16) {
+    if (strm->setting.format.u32 == PJMEDIA_FORMAT_L16) {
 	aps_play_cb = &PlayCbPcm;
 	aps_rec_cb  = &RecCbPcm;
@@ -1183,5 +1180,5 @@
     strm->rec_buf_len = 0;
 
-    if (strm->setting.format.u32 == PJMEDIA_FOURCC_G729) {
+    if (strm->setting.format.u32 == PJMEDIA_FORMAT_G729) {
 	TBitStream *g729_bitstream = new TBitStream;
 	
@@ -1215,5 +1212,5 @@
 
     pj_bzero(&setting, sizeof(setting));
-    setting.format.u32 = PJMEDIA_FOURCC_L16;
+    setting.format.u32 = PJMEDIA_FORMAT_L16;
     
     return sound_open(PJMEDIA_DIR_CAPTURE, clock_rate, channel_count,
@@ -1237,5 +1234,5 @@
 
     pj_bzero(&setting, sizeof(setting));
-    setting.format.u32 = PJMEDIA_FOURCC_L16;
+    setting.format.u32 = PJMEDIA_FORMAT_L16;
 
     return sound_open(PJMEDIA_DIR_PLAYBACK, clock_rate, channel_count,
@@ -1262,5 +1259,5 @@
 
     pj_bzero(&setting, sizeof(setting));
-    setting.format.u32 = PJMEDIA_FOURCC_L16;
+    setting.format.u32 = PJMEDIA_FORMAT_L16;
 
     return sound_open(PJMEDIA_DIR_CAPTURE_PLAYBACK, clock_rate, channel_count,
@@ -1350,5 +1347,5 @@
     stream->engine = NULL;
 
-    if (stream->setting.format.u32 == PJMEDIA_FOURCC_G729) {
+    if (stream->setting.format.u32 == PJMEDIA_FORMAT_G729) {
 	TBitStream *g729_bitstream = (TBitStream*)stream->strm_data;
 	stream->strm_data = NULL;
Index: pjproject/branches/projects/aps-direct/pjsip-apps/src/symbian_ua/ua.cpp
===================================================================
--- pjproject/branches/projects/aps-direct/pjsip-apps/src/symbian_ua/ua.cpp	(revision 2455)
+++ pjproject/branches/projects/aps-direct/pjsip-apps/src/symbian_ua/ua.cpp	(revision 2456)
@@ -93,5 +93,5 @@
 
 static pj_pool_t *app_pool;
-static pjmedia_snd_port *snd_port;
+static pjmedia_snd_port *g_snd_port;
 
 
@@ -134,8 +134,4 @@
     	if (call_id == g_call_id)
     	    g_call_id = PJSUA_INVALID_ID;
-    	if (snd_port) {
-    	    pjmedia_snd_port_destroy(snd_port);
-    	    snd_port = NULL;
-    	}
     } else if (ci.state != PJSIP_INV_STATE_INCOMING) {
     	if (g_call_id == PJSUA_INVALID_ID)
@@ -270,4 +266,7 @@
     unsigned samples_per_frame;
     pj_status_t status;
+    
+    PJ_UNUSED_ARG(call_id);
+    PJ_UNUSED_ARG(p_port);
     
     status = pjmedia_session_get_info(sess, &sess_info);
@@ -289,5 +288,5 @@
     setting.vad = strm_info->param->setting.vad;
     setting.plc = strm_info->param->setting.plc;
-    if (setting.format.u32 == PJMEDIA_FOURCC_ILBC) {
+    if (setting.format.u32 == PJMEDIA_FORMAT_ILBC) {
 	unsigned i;
 	pjmedia_codec_fmtp *fmtp = &strm_info->param->setting.dec_fmtp;
@@ -315,7 +314,8 @@
     /* Reset conference attributes. */
     conf->info.samples_per_frame = samples_per_frame;
-    conf->info.clock_rate = 8000;
-    conf->info.channel_count = 1;
+    conf->info.clock_rate = strm_info->param->info.clock_rate;
+    conf->info.channel_count = strm_info->param->info.channel_cnt;
     conf->info.bits_per_sample = 16;
+    conf->info.format = strm_info->param->info.format;
 
     /* Reopen sound device. */
@@ -324,10 +324,10 @@
 				      0,
 				      0,
-				      8000,
-				      1,
+				      strm_info->param->info.clock_rate,
+				      strm_info->param->info.channel_cnt,
 				      samples_per_frame,
 				      16,
 				      &setting,
-				      &snd_port);
+				      &g_snd_port);
     if (status != PJ_SUCCESS) {
 	PJ_LOG(1,(THIS_FILE, "on_stream_created() failed to reopen sound "
@@ -336,9 +336,23 @@
     }
     
-    status = pjmedia_snd_port_connect(snd_port, conf);
+    status = pjmedia_snd_port_connect(g_snd_port, conf);
     if (status != PJ_SUCCESS) {
 	PJ_LOG(1,(THIS_FILE, "on_stream_created() failed to connect sound "
 			     "device to conference, status=%d", status));
 	return;
+    }
+}
+
+static void on_stream_destroyed(pjsua_call_id call_id,
+				pjmedia_session *sess, 
+				unsigned stream_idx)
+{
+    PJ_UNUSED_ARG(call_id);
+    PJ_UNUSED_ARG(sess);
+    PJ_UNUSED_ARG(stream_idx);
+
+    if (g_snd_port) {
+    	pjmedia_snd_port_destroy(g_snd_port);
+    	g_snd_port = NULL;
     }
 }
@@ -407,4 +421,5 @@
     cfg.cb.on_nat_detect = &on_nat_detect;
     cfg.cb.on_stream_created = &on_stream_created;
+    cfg.cb.on_stream_destroyed = &on_stream_destroyed;
     
     if (SIP_PROXY) {
@@ -429,5 +444,5 @@
     log_cfg.console_level = LOG_LEVEL;
     log_cfg.cb = &log_writer;
-    //log_cfg.log_filename = pj_str("C:\\data\\symbian_ua.log");
+    log_cfg.log_filename = pj_str("C:\\data\\symbian_ua.log");
 
     pjsua_media_config_default(&med_cfg);
@@ -621,9 +636,9 @@
 #   if PJMEDIA_SOUND_IMPLEMENTATION == PJMEDIA_SOUND_SYMB_APS_SOUND
     case 't':
-	if (snd_port) {
+	if (g_snd_port) {
 	    static pj_bool_t act_loudspk = PJ_TRUE;
 	    pjmedia_snd_stream *strm;
 	    
-	    strm = pjmedia_snd_port_get_snd_stream(snd_port);
+	    strm = pjmedia_snd_port_get_snd_stream(g_snd_port);
 	    pjmedia_snd_aps_activate_loudspeaker(strm, act_loudspk);
 	    act_loudspk = !act_loudspk;
@@ -998,7 +1013,7 @@
 #endif
 	
-    if (snd_port) {
-	pjmedia_snd_port_destroy(snd_port);
-	snd_port = NULL;
+    if (g_snd_port) {
+	pjmedia_snd_port_destroy(g_snd_port);
+	g_snd_port = NULL;
     }
 
