Index: /pjproject/trunk/pjmedia/include/pjmedia/config.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 6004)
+++ /pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 6005)
@@ -1223,4 +1223,28 @@
 
 
+/**
+ * Specify the number of identical consecutive error that will be ignored when 
+ * receiving RTP/RTCP data before the library tries to restart the transport.
+ *
+ * When receiving RTP/RTCP data, the library will ignore error besides 
+ * PJ_EPENDING or PJ_ECANCELLED and continue the loop to receive the data. 
+ * If the OS always return error, then the loop will continue non stop.
+ * This setting will limit the number of the identical consecutive error, 
+ * before the library start to restart the transport. If error still happens
+ * after transport restart, then PJMEDIA_EVENT_MEDIA_TP_ERR event will be 
+ * publish as a notification.
+ *
+ * If PJ_ESOCKETSTOP is raised, then transport will be restarted regardless
+ * of this setting.
+ * 
+ * To always ignore the error when receving RTP/RTCP, set this to 0.
+ *
+ * Default : 20
+ */
+#ifndef PJMEDIA_IGNORE_RECV_ERR_CNT
+#   define PJMEDIA_IGNORE_RECV_ERR_CNT		20
+#endif
+
+
 /*
  * .... new stuffs ...
Index: /pjproject/trunk/pjmedia/include/pjmedia/event.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/event.h	(revision 6004)
+++ /pjproject/trunk/pjmedia/include/pjmedia/event.h	(revision 6005)
@@ -94,5 +94,10 @@
      * Audio device stopped on error.
      */
-    PJMEDIA_EVENT_AUD_DEV_ERROR = PJMEDIA_FOURCC('A', 'E', 'R', 'R')
+    PJMEDIA_EVENT_AUD_DEV_ERROR = PJMEDIA_FOURCC('A', 'E', 'R', 'R'),
+
+    /**
+     * Transport media error.
+     */
+    PJMEDIA_EVENT_MEDIA_TP_ERR = PJMEDIA_FOURCC('T', 'E', 'R', 'R')
 
 } pjmedia_event_type;
@@ -155,4 +160,24 @@
     pj_status_t		     status;
 } pjmedia_event_aud_dev_err_data;
+
+/**
+ * Additional data/parameters for media transmit error event.
+ */
+typedef struct pjmedia_event_media_tp_err_data
+{
+    /** The media type		*/
+    pjmedia_type	    type;
+
+    /** RTP/RTCP?		*/
+    pj_bool_t		    is_rtp;
+
+    /** Media direction		*/
+    pjmedia_dir		    dir;
+
+    /** The error code		*/
+    pj_status_t		    status;
+
+} pjmedia_event_media_tp_err_data;
+
 
 /** Additional parameters for window changed event. */
@@ -243,4 +268,7 @@
 	/** Storage for user event data */
 	pjmedia_event_user_data			user;
+
+	/** Media transport error event data */
+	pjmedia_event_media_tp_err_data		med_tp_err;
 
 	/** Pointer to storage to user event data, if it's outside
Index: /pjproject/trunk/pjmedia/src/pjmedia/stream.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/stream.c	(revision 6004)
+++ /pjproject/trunk/pjmedia/src/pjmedia/stream.c	(revision 6005)
@@ -75,4 +75,7 @@
 /* Number of DTMF E bit transmissions */
 #define DTMF_EBIT_RETRANSMIT_CNT	3
+
+/*  Number of send error before repeat the report. */
+#define SEND_ERR_COUNT_TO_REPORT	50
 
 /**
@@ -234,6 +237,6 @@
     pj_sockaddr		     rem_rtp_addr;     /**< Remote RTP address	    */
     unsigned		     rem_rtp_flag;     /**< Indicator flag about
-						    packet from this addr. 
-						    0=no pkt, 1=good ssrc, 
+						    packet from this addr.
+						    0=no pkt, 1=good ssrc,
 						    2=bad ssrc pkts	    */
     unsigned		     rtp_src_cnt;      /**< How many pkt from
@@ -245,8 +248,10 @@
 #endif
 
-    pj_uint32_t		     rtp_rx_last_ts;        /**< Last received RTP timestamp*/
-    pj_status_t		     rtp_rx_last_err;       /**< Last RTP recv() error */
-    pj_status_t		     rtp_tx_last_err;       /**< Last RTP send() error */
-    pj_status_t		     rtcp_tx_last_err;      /**< Last RTCP send() error */
+    pj_uint32_t		     rtp_rx_last_ts;        /**< Last received RTP
+							 timestamp	    */
+    pj_uint32_t		     rtp_tx_err_cnt;        /**< The number of RTP
+							 send() error	    */
+    pj_uint32_t		     rtcp_tx_err_cnt;       /**< The number of RTCP
+							 send() error	    */
 
     /* RTCP Feedback */
@@ -263,5 +268,5 @@
 				   '4', '5', '6', '7',
 				   '8', '9', '*', '#',
-				   'A', 'B', 'C', 'D', 
+				   'A', 'B', 'C', 'D',
 				   'R'};
 
@@ -462,5 +467,5 @@
     /* Send RTCP */
     send_rtcp(stream, PJ_TRUE, PJ_FALSE, PJ_FALSE, PJ_FALSE);
-    
+
     /* Update stats in case the stream is paused */
     stream->rtcp.stat.rtp_tx_last_seq = pj_ntohs(stream->enc->rtp.out_hdr.seq);
@@ -538,5 +543,5 @@
 	    			      stream->dec_buf_pos;
 	    unsigned nsamples_copy = PJ_MIN(nsamples_req, nsamples_avail);
-	    
+
 	    pjmedia_copy_samples(p_out_samp + samples_count,
 		      		 stream->dec_buf + stream->dec_buf_pos,
@@ -1013,4 +1018,31 @@
 
 
+/**
+ * Publish transport error event.
+ */
+static void publish_tp_event(pjmedia_event_type event_type,
+			     pj_status_t status,
+			     pj_bool_t is_rtp,
+			     pjmedia_dir dir,
+			     pjmedia_stream *stream)
+{
+    pjmedia_event ev;
+    pj_timestamp ts_now;
+
+    pj_get_timestamp(&ts_now);
+    pj_bzero(&ev.data.med_tp_err, sizeof(ev.data.med_tp_err));
+
+    /* Publish event. */
+    pjmedia_event_init(&ev, event_type,
+		       &ts_now, stream);
+    ev.data.med_tp_err.type = PJMEDIA_TYPE_AUDIO;
+    ev.data.med_tp_err.is_rtp = is_rtp;
+    ev.data.med_tp_err.dir = dir;
+    ev.data.med_tp_err.status = status;
+
+    pjmedia_event_publish(NULL, stream, &ev, 0);
+}
+
+
 static pj_status_t send_rtcp(pjmedia_stream *stream,
 			     pj_bool_t with_sdes,
@@ -1134,13 +1166,10 @@
     status = pjmedia_transport_send_rtcp(stream->transport, pkt, len);
     if (status != PJ_SUCCESS) {
-	if (stream->rtcp_tx_last_err != status) {
-	    PJ_PERROR(4,(stream->port.info.name.ptr, status,
-			 "Error sending RTCP"));
-	    stream->rtcp_tx_last_err = status;
-	}
-    } else {
-	if (stream->rtcp_tx_last_err != PJ_SUCCESS) {
-	    PJ_LOG(4,(stream->port.info.name.ptr, "Sending RTCP resumed"));
-	    stream->rtcp_tx_last_err = PJ_SUCCESS;
+	if (stream->rtcp_tx_err_cnt++ == 0) {
+	    LOGERR_((stream->port.info.name.ptr, status,
+		     "Error sending RTCP"));
+	}
+	if (stream->rtcp_tx_err_cnt > SEND_ERR_COUNT_TO_REPORT) {
+	    stream->rtcp_tx_err_cnt = 0;
 	}
     }
@@ -1484,16 +1513,13 @@
                                         frame_out.size +
 					    sizeof(pjmedia_rtp_hdr));
+
     if (status != PJ_SUCCESS) {
-	if (stream->rtp_tx_last_err != status) {
-	    PJ_PERROR(4,(stream->port.info.name.ptr, status,
-			 "Error sending RTP"));
-	    stream->rtp_tx_last_err = status;
+	if (stream->rtp_tx_err_cnt++ == 0) {
+	    LOGERR_((stream->port.info.name.ptr, status, "Error sending RTP"));
+	}
+	if (stream->rtp_tx_err_cnt > SEND_ERR_COUNT_TO_REPORT) {
+	    stream->rtp_tx_err_cnt = 0;
 	}
 	return PJ_SUCCESS;
-    } else {
-	if (stream->rtp_tx_last_err != PJ_SUCCESS) {
-	    PJ_LOG(4,(stream->port.info.name.ptr, "Sending RTP resumed"));
-	    stream->rtp_tx_last_err = PJ_SUCCESS;
-	}
     }
 
@@ -1680,5 +1706,5 @@
 #else
     if (event->event > 15) {
-#endif    
+#endif
 	PJ_LOG(5,(stream->port.info.name.ptr,
 		  "Ignored RTP pkt with bad DTMF event %d",
@@ -1744,15 +1770,14 @@
 	    return;
 	}
-	if (stream->rtp_rx_last_err != status) {
-	    char errmsg[PJ_ERR_MSG_SIZE];
-	    pj_strerror(status, errmsg, sizeof(errmsg));
-	    PJ_LOG(4,(stream->port.info.name.ptr,
-		      "Unable to receive RTP packet, recv() returned %d: %s",
-		      status, errmsg));
-	    stream->rtp_rx_last_err = status;
+
+	LOGERR_((stream->port.info.name.ptr, status,
+		 "Unable to receive RTP packet"));
+
+	if (status == PJ_ESOCKETSTOP) {
+	    /* Publish receive error event. */
+	    publish_tp_event(PJMEDIA_EVENT_MEDIA_TP_ERR, status, PJ_TRUE,
+			     PJMEDIA_DIR_DECODING, stream);
 	}
 	return;
-    } else {
-	stream->rtp_rx_last_err = PJ_SUCCESS;
     }
 
@@ -1769,5 +1794,5 @@
 	return;
     }
-    
+
     /* Check if multiplexing is allowed and the payload indicates RTCP. */
     if (stream->si.rtcp_mux && hdr->pt >= 64 && hdr->pt <= 95) {
@@ -1838,5 +1863,5 @@
     }
 
-    /* See if source address of RTP packet is different than the 
+    /* See if source address of RTP packet is different than the
      * configured address, and check if we need to tell the
      * media transport to switch RTP remote address.
@@ -1852,5 +1877,5 @@
 	} else {
 	    stream->rtp_src_cnt++;
-	    
+
 	    if (stream->rtp_src_cnt < PJMEDIA_RTP_NAT_PROBATION_CNT) {
 	    	if (stream->rem_rtp_flag == 1 ||
@@ -1865,5 +1890,5 @@
 	    	    pkt_discarded = PJ_TRUE;
 	    	    goto on_return;
-	    	}	    	
+	    	}
 	    	if (stream->si.has_rem_ssrc && !seq_st.status.flag.badssrc &&
 	    	    stream->rem_rtp_flag != 1)
@@ -1927,5 +1952,5 @@
 	{
 	    unsigned dec_ptime;
-	    
+
 	    PJ_LOG(4, (stream->port.info.name.ptr, "codec decode "
 	               "ptime change detected"));
@@ -2106,10 +2131,19 @@
 {
     pjmedia_stream *stream = (pjmedia_stream*) data;
+    pj_status_t status;
 
     /* Check for errors */
     if (bytes_read < 0) {
-	if (bytes_read != -PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) {
-	    LOGERR_((stream->port.info.name.ptr, (pj_status_t)-bytes_read,
-		     "RTCP recv() error"));
+	status = (pj_status_t)-bytes_read;
+	if (status == PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) {
+	    return;
+	}
+	LOGERR_((stream->port.info.name.ptr, status,
+			 "Unable to receive RTCP packet"));
+
+	if (status == PJ_ESOCKETSTOP) {
+	    /* Publish receive error event. */
+	    publish_tp_event(PJMEDIA_EVENT_MEDIA_TP_ERR, status, PJ_FALSE,
+			     PJMEDIA_DIR_DECODING, stream);
 	}
 	return;
@@ -2220,5 +2254,5 @@
 	if (stream->rtcp_fb_nack_cap_idx < 0)
 	    return PJ_SUCCESS;
-	
+
 	data->cap = stream->si.loc_rtcp_fb.caps[stream->rtcp_fb_nack_cap_idx];
     }
@@ -2636,5 +2670,5 @@
     pj_sockaddr_cp(&stream->rem_rtp_addr, &info->rem_addr);
     if (stream->si.rtcp_mux) {
-	pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr);    	
+	pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr);
     } else if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) {
 	pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp);
@@ -3128,5 +3162,5 @@
 		pt = 11;
 	    }
-#if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0	    
+#if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0
 	    else if (dig == 'r')
 	    {
Index: /pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c	(revision 6004)
+++ /pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c	(revision 6005)
@@ -19,4 +19,5 @@
  */
 #include <pjmedia/transport_udp.h>
+#include <pj/compat/socket.h>
 #include <pj/addr_resolv.h>
 #include <pj/assert.h>
@@ -27,5 +28,4 @@
 #include <pj/rand.h>
 #include <pj/string.h>
-
 
 /* Maximum size of incoming RTP packet */
@@ -155,10 +155,6 @@
 				       unsigned pct_lost);
 static pj_status_t transport_destroy  (pjmedia_transport *tp);
-
-#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
-	    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
 static pj_status_t transport_restart  (pj_bool_t is_rtp, 
 				       struct transport_udp *udp);
-#endif
 
 static pjmedia_transport_op transport_udp_op = 
@@ -454,4 +450,44 @@
 }
 
+/* Call RTP cb. */
+static void call_rtp_cb(struct transport_udp *udp, pj_ssize_t bytes_read, 
+			pj_bool_t *rem_switch)
+{
+    void (*cb)(void*,void*,pj_ssize_t);
+    void (*cb2)(pjmedia_tp_cb_param*);
+    void *user_data;
+
+    cb = udp->rtp_cb;
+    cb2 = udp->rtp_cb2;
+    user_data = udp->user_data;
+
+    if (cb2) {
+	pjmedia_tp_cb_param param;
+
+	param.user_data = user_data;
+	param.pkt = udp->rtp_pkt;
+	param.size = bytes_read;
+	param.src_addr = &udp->rtp_src_addr;
+	param.rem_switch = PJ_FALSE;
+	(*cb2)(&param);
+	if (rem_switch)
+	    *rem_switch = param.rem_switch;
+    } else if (cb) {
+	(*cb)(user_data, udp->rtp_pkt, bytes_read);
+    }
+}
+
+/* Call RTCP cb. */
+static void call_rtcp_cb(struct transport_udp *udp, pj_ssize_t bytes_read)
+{
+    void(*cb)(void*, void*, pj_ssize_t);
+    void *user_data;
+
+    cb = udp->rtcp_cb;
+    user_data = udp->user_data;
+
+    if (cb)
+	(*cb)(user_data, udp->rtcp_pkt, bytes_read);
+}
 
 /* Notification from ioqueue about incoming RTP packet */
@@ -463,4 +499,7 @@
     pj_status_t status;
     pj_bool_t rem_switch = PJ_FALSE;
+    pj_bool_t transport_restarted = PJ_FALSE;
+    unsigned num_err = 0;
+    pj_status_t last_err = PJ_SUCCESS;
 
     PJ_UNUSED_ARG(op_key);
@@ -470,29 +509,16 @@
     udp = (struct transport_udp*) pj_ioqueue_get_user_data(key);
 
-#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
-	    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
     if (-bytes_read == PJ_ESOCKETSTOP) {
 	/* Try to recover by restarting the transport. */
-	PJ_LOG(4, (udp->base.name, "Restarting RTP transport"));
 	status = transport_restart(PJ_TRUE, udp);
-	if (status == PJ_SUCCESS) {
-	    PJ_LOG(4, (udp->base.name, "Success restarting RTP transport"));
-	} else {
-	    PJ_PERROR(1, (udp->base.name, status, 
-			  "Error restarting RTP transport"));
+	if (status != PJ_SUCCESS) {
+	    bytes_read = -PJ_ESOCKETSTOP;
+	    call_rtp_cb(udp, bytes_read, NULL);
 	}
 	return;
     }
-#endif
 
     do {
-	void (*cb)(void*,void*,pj_ssize_t);
-	void (*cb2)(pjmedia_tp_cb_param*);
-	void *user_data;
 	pj_bool_t discard = PJ_FALSE;
-
-	cb = udp->rtp_cb;
-	cb2 = udp->rtp_cb2;
-	user_data = udp->user_data;
 
 	/* Simulate packet lost on RX direction */
@@ -507,18 +533,8 @@
 
 	//if (!discard && udp->attached && cb)
-	if (!discard) {
-	    if (cb2) {
-		pjmedia_tp_cb_param param;
-
-	    	param.user_data = user_data;
-	    	param.pkt = udp->rtp_pkt;
-	    	param.size = bytes_read;
-	    	param.src_addr = &udp->rtp_src_addr;
-	    	param.rem_switch = PJ_FALSE;
-	    	(*cb2)(&param);
-	    	rem_switch = param.rem_switch;
-	    } else if (cb) {
-	    	(*cb)(user_data, udp->rtp_pkt, bytes_read);
-	    }
+	if (!discard && 
+	    (-bytes_read != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL))) 
+	{
+	    call_rtp_cb(udp, bytes_read, &rem_switch);
 	}
 
@@ -566,11 +582,37 @@
 	udp->rtp_addrlen = sizeof(udp->rtp_src_addr);
 	status = pj_ioqueue_recvfrom(udp->rtp_key, &udp->rtp_read_op,
-				     udp->rtp_pkt, &bytes_read, 0,
-				     &udp->rtp_src_addr, 
-				     &udp->rtp_addrlen);
-
-	if (status != PJ_EPENDING && status != PJ_SUCCESS)
+					udp->rtp_pkt, &bytes_read, 0,
+					&udp->rtp_src_addr,
+					&udp->rtp_addrlen);
+
+	if (status != PJ_EPENDING && status != PJ_SUCCESS) {	    
+	    if (transport_restarted && last_err == status) {
+		/* Still the same error after restart */
+		bytes_read = -PJ_ESOCKETSTOP;
+		call_rtp_cb(udp, bytes_read, NULL);
+		break;
+	    } else if (PJMEDIA_IGNORE_RECV_ERR_CNT) {
+		if (last_err == status) {
+		    ++num_err;
+		} else {
+		    num_err = 1;
+		    last_err = status;
+		}
+
+		if (status == PJ_ESOCKETSTOP ||
+		    num_err > PJMEDIA_IGNORE_RECV_ERR_CNT)
+		{
+		    status = transport_restart(PJ_TRUE, udp);		    
+		    if (status != PJ_SUCCESS) {
+			bytes_read = -PJ_ESOCKETSTOP;
+			call_rtp_cb(udp, bytes_read, NULL);
+			break;
+		    }
+		    transport_restarted = PJ_TRUE;
+		    num_err = 0;
+		}
+	    }
 	    bytes_read = -status;
-
+	}
     } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
 	     udp->started);
@@ -585,4 +627,7 @@
     struct transport_udp *udp;
     pj_status_t status = PJ_SUCCESS;
+    pj_bool_t transport_restarted = PJ_FALSE;
+    unsigned num_err = 0;
+    pj_status_t last_err = PJ_SUCCESS;
 
     PJ_UNUSED_ARG(op_key);
@@ -592,30 +637,16 @@
     udp = (struct transport_udp*) pj_ioqueue_get_user_data(key);
 
-#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
-	    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
     if (-bytes_read == PJ_ESOCKETSTOP) {
 	/* Try to recover by restarting the transport. */
-	PJ_LOG(4, (udp->base.name, "Restarting RTCP transport"));
 	status = transport_restart(PJ_FALSE, udp);
-	if (status == PJ_SUCCESS) {
-	    PJ_LOG(4, (udp->base.name, "Success restarting RTCP transport"));
-	} else {
-	    PJ_PERROR(1, (udp->base.name, status, 
-			  "Error restarting RTCP transport"));
+	if (status != PJ_SUCCESS) {
+	    bytes_read = -PJ_ESOCKETSTOP;
+	    call_rtcp_cb(udp, bytes_read);
 	}
 	return;
     }
-#endif
 
     do {
-	void (*cb)(void*,void*,pj_ssize_t);
-	void *user_data;
-
-	cb = udp->rtcp_cb;
-	user_data = udp->user_data;
-
-	//if (udp->attached && cb)
-	if (cb)
-	    (*cb)(user_data, udp->rtcp_pkt, bytes_read);
+	call_rtcp_cb(udp, bytes_read);
 
 #if defined(PJMEDIA_TRANSPORT_SWITCH_REMOTE_ADDR) && \
@@ -656,7 +687,34 @@
 				     &udp->rtcp_src_addr, 
 				     &udp->rtcp_addr_len);
-	if (status != PJ_EPENDING && status != PJ_SUCCESS)
+
+	if (status != PJ_EPENDING && status != PJ_SUCCESS) {
+	    if (transport_restarted && last_err == status) {
+		/* Still the same error after restart */
+		bytes_read = -PJ_ESOCKETSTOP;
+		call_rtcp_cb(udp, bytes_read);
+		break;
+	    } else if (PJMEDIA_IGNORE_RECV_ERR_CNT) {
+		if (last_err == status) {
+		    ++num_err;
+		} else {
+		    num_err = 1;
+		    last_err = status;
+		}
+
+		if (status == PJ_ESOCKETSTOP ||
+		    num_err > PJMEDIA_IGNORE_RECV_ERR_CNT)
+		{
+		    status = transport_restart(PJ_FALSE, udp);		    
+		    if (status != PJ_SUCCESS) {
+			bytes_read = -PJ_ESOCKETSTOP;
+			call_rtcp_cb(udp, bytes_read);
+			break;
+		    }
+		    transport_restarted = PJ_TRUE;
+		    num_err = 0;
+		}
+	    }
 	    bytes_read = -status;
-
+	}	
     } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
 	     udp->started);
@@ -928,4 +986,8 @@
     PJ_ASSERT_RETURN(size <= PJMEDIA_MAX_MTU, PJ_ETOOBIG);
 
+    if (!udp->started) {
+	return PJ_SUCCESS;
+    }
+
     /* Simulate packet lost on TX direction */
     if (udp->tx_drop_pct) {
@@ -985,4 +1047,8 @@
 
     //PJ_ASSERT_RETURN(udp->attached, PJ_EINVALIDOP);
+
+    if (!udp->started) {
+	return PJ_SUCCESS;
+    }
 
     if (addr == NULL) {
@@ -1181,7 +1247,5 @@
 }
 
-#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
-	    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
-static pj_status_t transport_restart(pj_bool_t is_rtp,
+static pj_status_t transport_restart(pj_bool_t is_rtp, 
 				     struct transport_udp *udp)
 {
@@ -1194,4 +1258,8 @@
     pj_ssize_t size;
 
+    PJ_LOG(4, (udp->base.name, "Restarting %s transport", 
+	      (is_rtp)?"RTP":"RTCP"));
+
+    udp->started = PJ_FALSE;
     /* Destroy existing socket, if any. */    
     if (key) {
@@ -1208,5 +1276,5 @@
 	pj_sock_close(*sock);
     }
-    *sock = PJ_INVALID_SOCKET;
+    *sock = PJ_INVALID_SOCKET;   
 
     /* Create socket */
@@ -1224,41 +1292,17 @@
     /* Set buffer size for RTP socket */
 #if PJMEDIA_TRANSPORT_SO_RCVBUF_SIZE
-    {
+    if (is_rtp) {
 	unsigned sobuf_size = PJMEDIA_TRANSPORT_SO_RCVBUF_SIZE;
 
-	status = pj_sock_setsockopt_sobuf(udp->rtp_sock, pj_SO_RCVBUF(),
-					  PJ_TRUE, &sobuf_size);
-	if (status != PJ_SUCCESS) {
-	    pj_perror(3, udp->base.name, status, "Failed setting SO_RCVBUF");
-	} else {
-	    if (sobuf_size < PJMEDIA_TRANSPORT_SO_RCVBUF_SIZE) {
-		PJ_LOG(4, (udp->base.name,
-			   "Warning! Cannot set SO_RCVBUF as configured, "
-			   "now=%d, configured=%d",
-			   sobuf_size, PJMEDIA_TRANSPORT_SO_RCVBUF_SIZE));
-	    } else {
-		PJ_LOG(5, (udp->base.name, "SO_RCVBUF set to %d", sobuf_size));
-	    }
-	}
+	pj_sock_setsockopt_sobuf(udp->rtp_sock, pj_SO_RCVBUF(), 
+				 PJ_TRUE, &sobuf_size);
     }
 #endif
 #if PJMEDIA_TRANSPORT_SO_SNDBUF_SIZE
-    {
+    if (is_rtp) {
 	unsigned sobuf_size = PJMEDIA_TRANSPORT_SO_SNDBUF_SIZE;
 
-	status = pj_sock_setsockopt_sobuf(udp->rtp_sock, pj_SO_SNDBUF(),
-					  PJ_TRUE, &sobuf_size);
-	if (status != PJ_SUCCESS) {
-	    pj_perror(3, udp->base.name, status, "Failed setting SO_SNDBUF");
-	} else {
-	    if (sobuf_size < PJMEDIA_TRANSPORT_SO_SNDBUF_SIZE) {
-		PJ_LOG(4, (udp->base.name,
-			   "Warning! Cannot set SO_SNDBUF as configured, "
-			   "now=%d, configured=%d",
-			   sobuf_size, PJMEDIA_TRANSPORT_SO_SNDBUF_SIZE));
-	    } else {
-		PJ_LOG(5, (udp->base.name, "SO_SNDBUF set to %d", sobuf_size));
-	    }
-	}
+	pj_sock_setsockopt_sobuf(udp->rtp_sock, pj_SO_SNDBUF(), 
+				 PJ_TRUE, &sobuf_size);
     }
 #endif
@@ -1296,5 +1340,7 @@
 	goto on_error;
 
-
+    udp->started = PJ_TRUE;
+    PJ_LOG(4, (udp->base.name, "Success restarting %s transport", 
+	      (is_rtp)?"RTP":"RTCP"));
     return PJ_SUCCESS;
 on_error:
@@ -1303,5 +1349,6 @@
 	*sock = PJ_INVALID_SOCKET;
     }
+    PJ_PERROR(1, (udp->base.name, status, 
+		 "Error restarting %s transport", (is_rtp)?"RTP":"RTCP"));
     return status;
 }
-#endif
Index: /pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c	(revision 6004)
+++ /pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c	(revision 6005)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com)
  *
@@ -15,5 +15,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <pjmedia/vid_stream.h>
@@ -75,4 +75,6 @@
 #define MIN_CHUNKS_PER_FRM	30
 
+/*  Number of send error before repeat the report. */
+#define SEND_ERR_COUNT_TO_REPORT	50
 
 /**
@@ -115,5 +117,4 @@
 
     pjmedia_transport	    *transport;	    /**< Stream transport.	    */
-    unsigned		     send_err_cnt;  /**< Send error count.          */
 
     pj_mutex_t		    *jb_mutex;
@@ -137,5 +138,5 @@
     pjmedia_event            fmt_event;	    /**< Buffered fmt_changed event
                                                  to avoid deadlock	    */
-    pjmedia_event            miss_keyframe_event; 
+    pjmedia_event            miss_keyframe_event;
 					    /**< Buffered missing keyframe
                                                  event for delayed republish*/
@@ -148,9 +149,9 @@
 					         frame assembly.	    */
     pj_bool_t		     force_keyframe;/**< Forced to encode keyframe? */
-    unsigned		     num_keyframe;  /**< The number of keyframe needed 
+    unsigned		     num_keyframe;  /**< The number of keyframe needed
 						 to be sent, after the stream
 						 is created. */
-    pj_timestamp	     last_keyframe_tx;  
-					    /**< Timestamp of the last 
+    pj_timestamp	     last_keyframe_tx;
+					    /**< Timestamp of the last
 						 keyframe. */
 
@@ -172,5 +173,8 @@
     pj_uint32_t		     last_dec_ts;   /**< Last decoded timestamp.    */
     int			     last_dec_seq;  /**< Last decoded sequence.     */
-    pj_status_t		     rtp_rx_last_err; /**< Last RTP recv() error.   */
+    pj_uint32_t		     rtp_tx_err_cnt;/**< The number of RTP
+						 send() error		    */
+    pj_uint32_t		     rtcp_tx_err_cnt;/**< The number of RTCP
+						  send() error		    */
 
     pj_timestamp	     ts_freq;	    /**< Timestamp frequency.	    */
@@ -178,6 +182,6 @@
     pj_sockaddr		     rem_rtp_addr;  /**< Remote RTP address	    */
     unsigned		     rem_rtp_flag;  /**< Indicator flag about
-						 packet from this addr. 
-						 0=no pkt, 1=good ssrc pkts, 
+						 packet from this addr.
+						 0=no pkt, 1=good ssrc pkts,
 						 2=bad ssrc pkts	    */
     pj_sockaddr		     rtp_src_addr;  /**< Actual packet src addr.    */
@@ -203,5 +207,5 @@
 
 static void on_rx_rtcp( void *data,
-                        void *pkt, 
+                        void *pkt,
                         pj_ssize_t bytes_read);
 
@@ -233,5 +237,5 @@
 }
 
-PJ_INLINE(int) trace_jb_print_state(pjmedia_vid_stream *stream, 
+PJ_INLINE(int) trace_jb_print_state(pjmedia_vid_stream *stream,
 				    char **buf, pj_ssize_t len)
 {
@@ -405,4 +409,30 @@
 }
 
+/**
+ * Publish transport error event.
+ */
+static void publish_tp_event(pjmedia_event_type event_type,
+			     pj_status_t status,
+			     pj_bool_t is_rtp,
+			     pjmedia_dir dir,
+			     pjmedia_vid_stream *stream)
+{
+    pjmedia_event ev;
+    pj_timestamp ts_now;
+
+    pj_get_timestamp(&ts_now);
+    pj_bzero(&ev.data.med_tp_err, sizeof(ev.data.med_tp_err));
+
+    /* Publish event. */
+    pjmedia_event_init(&ev, event_type,
+		       &ts_now, stream);
+    ev.data.med_tp_err.type = PJMEDIA_TYPE_VIDEO;
+    ev.data.med_tp_err.is_rtp = is_rtp;
+    ev.data.med_tp_err.dir = dir;
+    ev.data.med_tp_err.status = status;
+
+    pjmedia_event_publish(NULL, stream, &ev, 0);
+}
+
 #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA != 0
 /*
@@ -462,5 +492,5 @@
 
 #else
-    
+
     PJ_UNUSED_ARG(stream);
 
@@ -478,4 +508,5 @@
     int len, max_len;
     pj_status_t status;
+    pjmedia_vid_channel *channel = stream->enc;
 
     /* Build RTCP RR/SR packet */
@@ -526,5 +557,13 @@
     /* Send! */
     status = pjmedia_transport_send_rtcp(stream->transport, pkt, len);
-
+    if (status != PJ_SUCCESS) {
+	if (stream->rtcp_tx_err_cnt++ == 0) {
+	    LOGERR_((channel->port.info.name.ptr, status,
+		     "Error sending RTCP"));
+	}
+	if (stream->rtcp_tx_err_cnt > SEND_ERR_COUNT_TO_REPORT) {
+	    stream->rtcp_tx_err_cnt = 0;
+	}
+    }
     return status;
 }
@@ -539,5 +578,5 @@
 static void check_tx_rtcp(pjmedia_vid_stream *stream, pj_uint32_t timestamp)
 {
-    /* Note that timestamp may represent local or remote timestamp, 
+    /* Note that timestamp may represent local or remote timestamp,
      * depending on whether this function is called from put_frame()
      * or get_frame().
@@ -546,10 +585,10 @@
 
     if (stream->rtcp_last_tx == 0) {
-	
+
 	stream->rtcp_last_tx = timestamp;
 
     } else if (timestamp - stream->rtcp_last_tx >= stream->rtcp_interval) {
 	pj_status_t status;
-	
+
 	status = send_rtcp(stream, !stream->rtcp_sdes_bye_disabled, PJ_FALSE);
 	if (status != PJ_SUCCESS) {
@@ -591,5 +630,5 @@
 /*
  * This callback is called by stream transport on receipt of packets
- * in the RTP socket. 
+ * in the RTP socket.
  */
 static void on_rx_rtp( pjmedia_tp_cb_param *param)
@@ -612,15 +651,14 @@
 	    return;
 	}
-	if (stream->rtp_rx_last_err != status) {
-	    char errmsg[PJ_ERR_MSG_SIZE];
-	    pj_strerror(status, errmsg, sizeof(errmsg));
-	    PJ_LOG(4,(channel->port.info.name.ptr,
-		      "Unable to receive RTP packet, recv() returned %d: %s",
-		      status, errmsg));
-	    stream->rtp_rx_last_err = status;
+
+	LOGERR_((channel->port.info.name.ptr, status,
+		 "Unable to receive RTP packet"));
+
+	if (status == PJ_ESOCKETSTOP) {
+	    /* Publish receive error event. */
+	    publish_tp_event(PJMEDIA_EVENT_MEDIA_TP_ERR, status, PJ_TRUE,
+			     PJMEDIA_DIR_DECODING, stream);
 	}
 	return;
-    } else {
-	stream->rtp_rx_last_err = PJ_SUCCESS;
     }
 
@@ -653,7 +691,7 @@
     pjmedia_rtp_session_update2(&channel->rtp, hdr, &seq_st, PJ_TRUE);
     if (seq_st.status.value) {
-	TRC_  ((channel->port.info.name.ptr, 
+	TRC_  ((channel->port.info.name.ptr,
 		"RTP status: badpt=%d, badssrc=%d, dup=%d, "
-		"outorder=%d, probation=%d, restart=%d", 
+		"outorder=%d, probation=%d, restart=%d",
 		seq_st.status.flag.badpt,
 		seq_st.status.flag.badssrc,
@@ -691,5 +729,5 @@
     }
 
-    /* See if source address of RTP packet is different than the 
+    /* See if source address of RTP packet is different than the
      * configured address, and check if we need to tell the
      * media transport to switch RTP remote address.
@@ -705,5 +743,5 @@
 	} else {
 	    stream->rtp_src_cnt++;
-	    
+
 	    if (stream->rtp_src_cnt < PJMEDIA_RTP_NAT_PROBATION_CNT) {
 	    	if (stream->rem_rtp_flag == 1 ||
@@ -718,5 +756,5 @@
 	    	    pkt_discarded = PJ_TRUE;
 	    	    goto on_return;
-	    	}	    	
+	    	}
 	    	if (stream->info.has_rem_ssrc && !seq_st.status.flag.badssrc
 	    	    && stream->rem_rtp_flag != 1)
@@ -793,5 +831,5 @@
     } else {
 	/* Just put the payload into jitter buffer */
-	pjmedia_jbuf_put_frame3(stream->jb, payload, payloadlen, 0, 
+	pjmedia_jbuf_put_frame3(stream->jb, payload, payloadlen, 0,
 				pj_ntohs(hdr->seq), pj_ntohl(hdr->ts), NULL);
 
@@ -844,17 +882,24 @@
 /*
  * This callback is called by stream transport on receipt of packets
- * in the RTCP socket. 
+ * in the RTCP socket.
  */
 static void on_rx_rtcp( void *data,
-                        void *pkt, 
+                        void *pkt,
                         pj_ssize_t bytes_read)
 {
     pjmedia_vid_stream *stream = (pjmedia_vid_stream*) data;
+    pj_status_t status;
 
     /* Check for errors */
     if (bytes_read < 0) {
-	if (bytes_read != -PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) {
-	    LOGERR_((stream->cname.ptr, (pj_status_t)-bytes_read,
-		     "RTCP recv() error"));
+	status = (pj_status_t)-bytes_read;
+	if (status == PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) {
+	    return;
+	}
+	LOGERR_((stream->cname.ptr, status, "Unable to receive RTCP packet"));
+	if (status == PJ_ESOCKETSTOP) {
+	    /* Publish receive error event. */
+	    publish_tp_event(PJMEDIA_EVENT_MEDIA_TP_ERR, status, PJ_FALSE,
+			     PJMEDIA_DIR_DECODING, stream);
 	}
 	return;
@@ -889,5 +934,5 @@
 	pj_uint32_t dtx_duration;
 
-	dtx_duration = pj_timestamp_diff32(&stream->last_frm_ts_sent, 
+	dtx_duration = pj_timestamp_diff32(&stream->last_frm_ts_sent,
 					   &frame->timestamp);
 
@@ -922,7 +967,7 @@
 
     /* Check if need to send keyframe. */
-    if (stream->num_keyframe && 
-	(pj_cmp_timestamp(&null_ts, &stream->last_keyframe_tx) != 0)) 
-    {	
+    if (stream->num_keyframe &&
+	(pj_cmp_timestamp(&null_ts, &stream->last_keyframe_tx) != 0))
+    {
 	unsigned elapse_time;
 	pj_timestamp now;
@@ -935,5 +980,5 @@
 	{
 	    stream->force_keyframe = PJ_TRUE;
-	    --stream->num_keyframe;		
+	    --stream->num_keyframe;
 	}
     }
@@ -965,10 +1010,10 @@
 	return status;
     }
-    
+
     pj_get_timestamp(&initial_time);
 
-    if ((stream->num_keyframe) && 
-	((frame_out.bit_info & PJMEDIA_VID_FRM_KEYFRAME) 
-						  == PJMEDIA_VID_FRM_KEYFRAME)) 
+    if ((stream->num_keyframe) &&
+	((frame_out.bit_info & PJMEDIA_VID_FRM_KEYFRAME)
+						  == PJMEDIA_VID_FRM_KEYFRAME))
     {
 	stream->last_keyframe_tx = initial_time;
@@ -1003,14 +1048,12 @@
 						    sizeof(pjmedia_rtp_hdr));
 	    if (status != PJ_SUCCESS) {
-		enum { COUNT_TO_REPORT = 20 };
-		if (stream->send_err_cnt++ == 0) {
+		if (stream->rtp_tx_err_cnt++ == 0) {
 		    LOGERR_((channel->port.info.name.ptr, status,
-			     "Transport send_rtp() error"));
+			     "Error sending RTP"));
 		}
-		if (stream->send_err_cnt > COUNT_TO_REPORT)
-		    stream->send_err_cnt = 0;
-		/* Ignore this error */
+		if (stream->rtp_tx_err_cnt > SEND_ERR_COUNT_TO_REPORT) {
+		    stream->rtp_tx_err_cnt = 0;
+		}
 	    }
-
 	    pjmedia_rtcp_tx_rtp(&stream->rtcp, (unsigned)frame_out.size);
 	    total_sent += frame_out.size;
@@ -1082,5 +1125,5 @@
 #endif
 
-    /* Check if now is the time to transmit RTCP SR/RR report. 
+    /* Check if now is the time to transmit RTCP SR/RR report.
      * We only do this when stream direction is not "decoding only", because
      * when it is, check_tx_rtcp() will be handled by get_frame().
@@ -1244,5 +1287,5 @@
 
 	    ts_diff = frm_ts - stream->last_dec_ts;
-	    
+
 	    /* Calculate new FPS based on RTP timestamp diff */
 	    if (stream->info.codec_info.clock_rate % ts_diff == 0) {
@@ -1273,5 +1316,5 @@
 		    pjmedia_jbuf_get_state(stream->jb, &jb_state);
 
-		    stream->dec_delay_cnt = 
+		    stream->dec_delay_cnt =
 				    ((PJMEDIA_VID_STREAM_DECODE_MIN_DELAY_MSEC *
 				      vfd->fps.num) +
@@ -1425,5 +1468,5 @@
     char fourcc_name[5];
     pjmedia_port_info *pi;
-    
+
     pj_assert(info->type == PJMEDIA_TYPE_VIDEO);
     pj_assert(dir == PJMEDIA_DIR_DECODING || dir == PJMEDIA_DIR_ENCODING);
@@ -1450,5 +1493,5 @@
     channel->paused = 1;
     channel->pt = pt;
-    
+
     /* Allocate buffer for outgoing packet. */
     if (dir == PJMEDIA_DIR_ENCODING) {
@@ -1553,9 +1596,9 @@
     /* Init stream/port name */
     stream->name.ptr = (char*) pj_pool_alloc(pool, M);
-    stream->name.slen = pj_ansi_snprintf(stream->name.ptr, M, 
+    stream->name.slen = pj_ansi_snprintf(stream->name.ptr, M,
 					 "vstrm%p", stream);
 
     /* Create and initialize codec: */
-    status = pjmedia_vid_codec_mgr_alloc_codec(stream->codec_mgr, 
+    status = pjmedia_vid_codec_mgr_alloc_codec(stream->codec_mgr,
 					       &info->codec_info,
 					       &stream->codec);
@@ -1567,5 +1610,5 @@
 	pjmedia_vid_codec_param def_param;
 
-	status = pjmedia_vid_codec_mgr_get_default_param(stream->codec_mgr, 
+	status = pjmedia_vid_codec_mgr_get_default_param(stream->codec_mgr,
 						         &info->codec_info,
 						         &def_param);
@@ -1642,5 +1685,5 @@
     stream->frame_size = vfd_enc->max_bps/8 * vfd_enc->fps.denum /
 			 vfd_enc->fps.num;
-    
+
     /* As the maximum frame_size is not represented directly by maximum bps
      * (which includes intra and predicted frames), let's increase the
@@ -1651,5 +1694,5 @@
 
     /* Validate the frame size */
-    if (stream->frame_size == 0 || 
+    if (stream->frame_size == 0 ||
 	stream->frame_size > PJMEDIA_MAX_VIDEO_ENC_FRAME_SIZE)
     {
@@ -1686,5 +1729,5 @@
 
     /* Create decoder channel */
-    status = create_channel( pool, stream, PJMEDIA_DIR_DECODING, 
+    status = create_channel( pool, stream, PJMEDIA_DIR_DECODING,
 			     info->rx_pt, info, &stream->dec);
     if (status != PJ_SUCCESS)
@@ -1692,5 +1735,5 @@
 
     /* Create encoder channel */
-    status = create_channel( pool, stream, PJMEDIA_DIR_ENCODING, 
+    status = create_channel( pool, stream, PJMEDIA_DIR_ENCODING,
 			     info->tx_pt, info, &stream->enc);
     if (status != PJ_SUCCESS)
@@ -1793,8 +1836,8 @@
     pj_sockaddr_cp(&stream->rem_rtp_addr, &info->rem_addr);
     if (info->rtcp_mux) {
-	pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr);    	
+	pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr);
     } else if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) {
 	pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp);
-    }    
+    }
     att_param.addr_len = pj_sockaddr_get_len(&info->rem_addr);
     att_param.rtp_cb2 = &on_rx_rtp;
@@ -1824,5 +1867,5 @@
 	pj_ssize_t len;
 
-	pj_ansi_snprintf(trace_name, sizeof(trace_name), 
+	pj_ansi_snprintf(trace_name, sizeof(trace_name),
 			 TRACE_JB_PATH_PREFIX "%s.csv",
 			 channel->port.info.name.ptr);
@@ -1832,5 +1875,5 @@
 	    stream->trace_jb_fd = TRACE_JB_INVALID_FD;
 	    PJ_PERROR(3,(THIS_FILE, status,
-			 "Failed creating RTP trace file '%s'", 
+			 "Failed creating RTP trace file '%s'",
 			 trace_name));
 	} else {
@@ -1876,5 +1919,5 @@
 
 	total_time = pj_elapsed_msec(&stream->tx_start, &stream->tx_end);
-	PJ_LOG(5, (stream->name.ptr, 
+	PJ_LOG(5, (stream->name.ptr,
 		   "RC stat: pkt_cnt=%.2f/image, sleep=%.2fms/s, fps=%.2f",
 		   stream->rc_total_pkt*1.0/stream->rc_total_img,
@@ -1889,5 +1932,5 @@
     }
 
-    /* Detach from transport 
+    /* Detach from transport
      * MUST NOT hold stream mutex while detaching from transport, as
      * it may cause deadlock. See ticket #460 for the details.
@@ -1913,5 +1956,5 @@
 
     /* Free mutex */
-    
+
     if (stream->jb_mutex) {
 	pj_mutex_destroy(stream->jb_mutex);
Index: /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 6004)
+++ /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 6005)
@@ -905,4 +905,17 @@
 }
 
+static char *get_media_dir(pjmedia_dir dir) {
+    switch (dir) {
+    case PJMEDIA_DIR_ENCODING:
+	return "TX";
+    case PJMEDIA_DIR_DECODING:
+	return "RX";
+    case PJMEDIA_DIR_ENCODING+PJMEDIA_DIR_DECODING:
+	return "TX+RX";
+    default:
+	return "unknown dir";
+    }    
+}
+
 /* Callback on media events */
 static void on_call_media_event(pjsua_call_id call_id,
@@ -915,6 +928,16 @@
 	      pjmedia_fourcc_name(event->type, event_name)));
 
+    if (event->type == PJMEDIA_EVENT_MEDIA_TP_ERR) {
+	pjmedia_event_media_tp_err_data *err_data;
+
+	err_data = &event->data.med_tp_err;
+	PJ_PERROR(3, (THIS_FILE, err_data->status, 
+		  "Media transport error event (%s %s %s)",
+		  (err_data->type==PJMEDIA_TYPE_AUDIO)?"Audio":"Video",
+		  (err_data->is_rtp)?"RTP":"RTCP",
+		  get_media_dir(err_data->dir)));
+    }
 #if PJSUA_HAS_VIDEO
-    if (event->type == PJMEDIA_EVENT_FMT_CHANGED) {
+    else if (event->type == PJMEDIA_EVENT_FMT_CHANGED) {
 	/* Adjust renderer window size to original video size */
 	pjsua_call_info ci;
@@ -931,5 +954,5 @@
 	    wid = ci.media[med_idx].stream.vid.win_in;
 	    pjsua_vid_win_get_info(wid, &win_info);
-	    
+
 	    size = event->data.fmt_changed.new_fmt.det.vid.size;
 	    if (size.w != win_info.size.w || size.h != win_info.size.h) {
@@ -943,6 +966,5 @@
 #else
     PJ_UNUSED_ARG(call_id);
-    PJ_UNUSED_ARG(med_idx);
-    PJ_UNUSED_ARG(event);
+    PJ_UNUSED_ARG(med_idx);    
 #endif
 }
