Index: pjproject/trunk/pjmedia/include/pjmedia/rtcp.h
===================================================================
--- pjproject/trunk/pjmedia/include/pjmedia/rtcp.h	(revision 2240)
+++ pjproject/trunk/pjmedia/include/pjmedia/rtcp.h	(revision 2241)
@@ -211,4 +211,7 @@
     
     pj_math_stat	     rtt;   /**< Round trip delay statistic(in usec)*/
+
+    pj_uint32_t		     rtp_tx_last_ts; /**< Last TX RTP timestamp.    */
+    pj_uint16_t		     rtp_tx_last_seq;/**< Last TX RTP sequence.	    */
 };
 
Index: pjproject/trunk/pjmedia/include/pjmedia/rtp.h
===================================================================
--- pjproject/trunk/pjmedia/include/pjmedia/rtp.h	(revision 2240)
+++ pjproject/trunk/pjmedia/include/pjmedia/rtp.h	(revision 2241)
@@ -221,4 +221,24 @@
 };
 
+
+/**
+ * RTP session settings.
+ */
+typedef struct pjmedia_rtp_session_setting
+{
+    pj_uint8_t	     flags;	    /**< Bitmask flags to specify whether such
+				         field is set. Bitmask contents are:
+					 (bit #0 is LSB)
+					 bit #0: default payload type
+					 bit #1: sender SSRC
+					 bit #2: sequence
+					 bit #3: timestamp		    */
+    int		     default_pt;    /**< Default payload type.		    */
+    pj_uint32_t	     sender_ssrc;   /**< Sender SSRC.			    */
+    pj_uint16_t	     seq;	    /**< Sequence.			    */
+    pj_uint32_t	     ts;	    /**< Timestamp.			    */
+} pjmedia_rtp_session_setting;
+
+
 /**
  * @see pjmedia_rtp_status
@@ -239,4 +259,18 @@
 					       int default_pt, 
 					       pj_uint32_t sender_ssrc );
+
+/**
+ * This function will initialize the RTP session according to given parameters
+ * defined in RTP session settings.
+ *
+ * @param ses		The session.
+ * @param settings	RTP session settings.
+ *
+ * @return		PJ_SUCCESS if successfull.
+ */
+PJ_DECL(pj_status_t) pjmedia_rtp_session_init2( 
+				    pjmedia_rtp_session *ses,
+				    pjmedia_rtp_session_setting settings);
+
 
 /**
Index: pjproject/trunk/pjmedia/include/pjmedia/stream.h
===================================================================
--- pjproject/trunk/pjmedia/include/pjmedia/stream.h	(revision 2240)
+++ pjproject/trunk/pjmedia/include/pjmedia/stream.h	(revision 2241)
@@ -113,4 +113,11 @@
     int			rx_event_pt;/**< Incoming pt for telephone-events.  */
     pj_uint32_t		ssrc;	    /**< RTP SSRC.			    */
+    pj_uint32_t		rtp_ts;	    /**< Initial RTP timestamp.		    */
+    pj_uint16_t		rtp_seq;    /**< Initial RTP sequence number.	    */
+    pj_uint8_t		rtp_seq_ts_set;
+				    /**< Bitmask flags if initial RTP sequence 
+				         and/or timestamp for sender are set.
+					 bit 0/LSB : sequence flag 
+					 bit 1     : timestamp flag 	    */
     int			jb_init;    /**< Jitter buffer init delay in msec.  
 					 (-1 for default).		    */
Index: pjproject/trunk/pjmedia/src/pjmedia/rtp.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/rtp.c	(revision 2240)
+++ pjproject/trunk/pjmedia/src/pjmedia/rtp.c	(revision 2241)
@@ -85,4 +85,31 @@
 }
 
+PJ_DEF(pj_status_t) pjmedia_rtp_session_init2( 
+				    pjmedia_rtp_session *ses,
+				    pjmedia_rtp_session_setting settings)
+{
+    pj_status_t status;
+    int		 pt = 0;
+    pj_uint32_t	 sender_ssrc = 0;
+
+    if (settings.flags & 1)
+	pt = settings.default_pt;
+    if (settings.flags & 2)
+	sender_ssrc = settings.sender_ssrc;
+
+    status = pjmedia_rtp_session_init(ses, pt, sender_ssrc);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    if (settings.flags & 4) {
+	ses->out_extseq = settings.seq;
+	ses->out_hdr.seq = pj_htons((pj_uint16_t)ses->out_extseq);
+    }
+    if (settings.flags & 8)
+	ses->out_hdr.ts = pj_htonl(settings.ts);
+
+    return PJ_SUCCESS;
+}
+
 
 PJ_DEF(pj_status_t) pjmedia_rtp_encode_rtp( pjmedia_rtp_session *ses, 
Index: pjproject/trunk/pjmedia/src/pjmedia/stream.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/stream.c	(revision 2240)
+++ pjproject/trunk/pjmedia/src/pjmedia/stream.c	(revision 2241)
@@ -873,4 +873,6 @@
     /* Update stat */
     pjmedia_rtcp_tx_rtp(&stream->rtcp, frame_out.size);
+    stream->rtcp.stat.rtp_tx_last_ts = pj_ntohl(stream->enc->rtp.out_hdr.ts);
+    stream->rtcp.stat.rtp_tx_last_seq = pj_ntohs(stream->enc->rtp.out_hdr.seq);
 
     return PJ_SUCCESS;
@@ -1413,5 +1415,16 @@
     /* Create RTP and RTCP sessions: */
 
-    status = pjmedia_rtp_session_init(&channel->rtp, pt, param->ssrc);
+    if (param->rtp_seq_ts_set == 0) {
+	status = pjmedia_rtp_session_init(&channel->rtp, pt, param->ssrc);
+    } else {
+	pjmedia_rtp_session_setting settings;
+
+	settings.flags = (param->rtp_seq_ts_set << 2) | 3;
+	settings.default_pt = pt;
+	settings.sender_ssrc = param->ssrc;
+	settings.seq = param->rtp_seq;
+	settings.ts = param->rtp_ts;
+	status = pjmedia_rtp_session_init2(&channel->rtp, settings);
+    }
     if (status != PJ_SUCCESS)
 	return status;
Index: pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h	(revision 2240)
+++ pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h	(revision 2241)
@@ -67,4 +67,11 @@
     int			 audio_idx; /**< Index of m=audio in SDP.	    */
     pj_uint32_t		 ssrc;	    /**< RTP SSRC			    */
+    pj_uint32_t		 rtp_tx_ts; /**< Initial RTP timestamp for sender.  */
+    pj_uint16_t		 rtp_tx_seq;/**< Initial RTP sequence for sender.   */
+    pj_uint8_t		 rtp_tx_seq_ts_set;
+				    /**< Bitmask flags if initial RTP sequence
+				         and/or timestamp for sender are set.
+					 bit 0/LSB : sequence flag 
+					 bit 1     : timestamp flag 	    */
     int			 conf_slot; /**< Slot # in conference bridge.	    */
     pjsip_evsub		*xfer_sub;  /**< Xfer server subscription, if this
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 2240)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 2241)
@@ -106,4 +106,7 @@
     call->audio_idx = -1;
     call->ssrc = pj_rand();
+    call->rtp_tx_seq = 0;
+    call->rtp_tx_ts = 0;
+    call->rtp_tx_seq_ts_set = 0;
     call->xfer_sub = NULL;
     call->last_code = (pjsip_status_code) 0;
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 2240)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 2241)
@@ -1159,4 +1159,21 @@
 
     if (call->session) {
+	pjmedia_rtcp_stat stat;
+
+	if (pjmedia_session_get_stream_stat(call->session, 
+					    call->audio_idx, 
+					    &stat) == PJ_SUCCESS)
+	{
+	    /* Save RTP timestamp & sequence, so when media session is 
+	     * restarted, those values will be restored as the initial 
+	     * RTP timestamp & sequence of the new media session. So in 
+	     * the same call session, RTP timestamp and sequence are 
+	     * guaranteed to be contigue.
+	     */
+	    call->rtp_tx_seq_ts_set = 1 | (1 << 1);
+	    call->rtp_tx_seq = stat.rtp_tx_last_seq;
+	    call->rtp_tx_ts = stat.rtp_tx_last_ts;
+	}
+
 	if (pjsua_var.ua_cfg.cb.on_stream_destroyed) {
 	    pjsua_var.ua_cfg.cb.on_stream_destroyed(call_id, call->session, 0);
@@ -1322,4 +1339,13 @@
 	/* Set SSRC */
 	si->ssrc = call->ssrc;
+
+	/* Set RTP timestamp & sequence, normally these value are intialized
+	 * automatically when stream session created, but for some cases (e.g:
+	 * call reinvite, call update) timestamp and sequence need to be kept
+	 * contigue.
+	 */
+	si->rtp_ts = call->rtp_tx_ts;
+	si->rtp_seq = call->rtp_tx_seq;
+	si->rtp_seq_ts_set = call->rtp_tx_seq_ts_set;
 
 	/* Create session based on session info. */
