Index: /pjproject/trunk/pjmedia/include/pjmedia-codec/types.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia-codec/types.h	(revision 570)
+++ /pjproject/trunk/pjmedia/include/pjmedia-codec/types.h	(revision 571)
@@ -30,8 +30,8 @@
 enum
 {
-    /* Telephone events must have pt=101, or otherwise some code needs
-     * to be updated (this would not affect outgoing pt).
+    /* PJMEDIA_RTP_PT_TELEPHONE_EVENTS is declared in
+     * <pjmedia/config.h>
      */
-    PJMEDIA_RTP_PT_TELEPHONE_EVENTS = 101,	/**< telephone-events	    */
+    PJMEDIA_RTP_PT_START = PJMEDIA_RTP_PT_TELEPHONE_EVENTS,
 
     PJMEDIA_RTP_PT_SPEEX_NB,			/**< Speex narrowband/8KHz  */
Index: /pjproject/trunk/pjmedia/include/pjmedia/config.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 570)
+++ /pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 571)
@@ -164,4 +164,27 @@
 
 
+/**
+ * This macro declares the payload type for telephone-event
+ * that is advertised by PJMEDIA for outgoing SDP. If this macro
+ * is set to zero, telephone events would not be advertised nor
+ * supported.
+ *
+ * If this value is changed to other number, please update the
+ * PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR too.
+ */
+#ifndef PJMEDIA_RTP_PT_TELEPHONE_EVENTS
+#   define PJMEDIA_RTP_PT_TELEPHONE_EVENTS	    101
+#endif
+
+
+/**
+ * Macro to get the string representation of the telephone-event
+ * payload type.
+ */
+#ifndef PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR
+#   define PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR	    "101"
+#endif
+
+
 
 /**
Index: /pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/endpoint.c	(revision 570)
+++ /pjproject/trunk/pjmedia/src/pjmedia/endpoint.c	(revision 571)
@@ -333,5 +333,5 @@
 
     /* Add "rtcp" attribute */
-#if 1
+#if defined(PJMEDIA_HAS_RTCP_IN_SDP) && PJMEDIA_HAS_RTCP_IN_SDP!=0
     {
 	attr = pj_pool_alloc(pool, sizeof(pjmedia_sdp_attr));
@@ -341,6 +341,6 @@
 	    pj_ansi_snprintf(attr->value.ptr, 80,
 			    ":%u IN IP4 %s",
-			    pj_ntohs(sock_info[0].rtp_addr_name.sin_port),
-			    pj_inet_ntoa(sock_info[0].rtp_addr_name.sin_addr));
+			    pj_ntohs(sock_info[0].rtcp_addr_name.sin_port),
+			    pj_inet_ntoa(sock_info[0].rtcp_addr_name.sin_addr));
 	pjmedia_sdp_attr_add(&m->attr_count, m->attr, attr);
     }
@@ -398,18 +398,24 @@
     m->attr[m->attr_count++] = attr;
 
-#if 1
+#if defined(PJMEDIA_RTP_PT_TELEPHONE_EVENTS) && \
+    PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0
+
     /*
      * Add support telephony event
      */
-    m->desc.fmt[m->desc.fmt_count++] = pj_str("101");
+    m->desc.fmt[m->desc.fmt_count++] = 
+	pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR);
+
     /* Add rtpmap. */
     attr = pj_pool_zalloc(pool, sizeof(pjmedia_sdp_attr));
     attr->name = pj_str("rtpmap");
-    attr->value = pj_str(":101 telephone-event/8000");
+    attr->value = pj_str(":" PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR 
+			 " telephone-event/8000");
     m->attr[m->attr_count++] = attr;
+
     /* Add fmtp */
     attr = pj_pool_zalloc(pool, sizeof(pjmedia_sdp_attr));
     attr->name = pj_str("fmtp");
-    attr->value = pj_str(":101 0-15");
+    attr->value = pj_str(":" PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR " 0-15");
     m->attr[m->attr_count++] = attr;
 #endif
Index: /pjproject/trunk/pjmedia/src/pjmedia/sdp.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/sdp.c	(revision 570)
+++ /pjproject/trunk/pjmedia/src/pjmedia/sdp.c	(revision 571)
@@ -35,4 +35,5 @@
 };
 #define TOKEN		"-.!%*_=`'~"
+//#define TOKEN		"'`-./:?\"#$&*;=@[]^_`{|}+~!"
 #define NTP_OFFSET	((pj_uint32_t)2208988800)
 #define THIS_FILE	"sdp.c"
@@ -67,5 +68,5 @@
 static int is_initialized;
 static pj_cis_buf_t cis_buf;
-static pj_cis_t cs_token;
+static pj_cis_t cs_digit, cs_token;
 
 static void init_sdp_parser(void)
@@ -79,8 +80,12 @@
 
     pj_cis_buf_init(&cis_buf);
+
     pj_cis_init(&cis_buf, &cs_token);
     pj_cis_add_alpha(&cs_token);
     pj_cis_add_num(&cs_token);
     pj_cis_add_str(&cs_token, TOKEN);
+
+    pj_cis_init(&cis_buf, &cs_digit);
+    pj_cis_add_num(&cs_digit);
 }
 
@@ -258,4 +263,5 @@
     /* Init */
     rtpmap->pt.slen = rtpmap->param.slen = rtpmap->enc_name.slen = 0;
+    rtpmap->clock_rate = 0;
 
     /* Parse */
@@ -283,5 +289,5 @@
 
 	/* Get the clock rate. */
-	pj_scan_get(&scanner, &cs_token, &token);
+	pj_scan_get(&scanner, &cs_digit, &token);
 	rtpmap->clock_rate = pj_strtoul(&token);
 
@@ -761,4 +767,16 @@
     ctx->last_error = PJMEDIA_SDP_EINVER;
 
+    /* check equal sign */
+    if (*(scanner->curptr+1) != '=') {
+	on_scanner_error(scanner);
+	return;
+    }
+
+    /* check version is 0 */
+    if (*(scanner->curptr+2) != '0') {
+	on_scanner_error(scanner);
+	return;
+    }
+
     pj_scan_advance_n(scanner, 3, SKIP_WS);
     pj_scan_get_newline(scanner);
@@ -771,4 +789,10 @@
 
     ctx->last_error = PJMEDIA_SDP_EINORIGIN;
+
+    /* check equal sign */
+    if (*(scanner->curptr+1) != '=') {
+	on_scanner_error(scanner);
+	return;
+    }
 
     /* o= */
@@ -811,4 +835,10 @@
     ctx->last_error = PJMEDIA_SDP_EINTIME;
 
+    /* check equal sign */
+    if (*(scanner->curptr+1) != '=') {
+	on_scanner_error(scanner);
+	return;
+    }
+
     /* t= */
     pj_scan_advance_n(scanner, 2, SKIP_WS);
@@ -833,4 +863,10 @@
     ctx->last_error = PJMEDIA_SDP_EINSDP;
 
+    /* check equal sign */
+    if (*(scanner->curptr+1) != '=') {
+	on_scanner_error(scanner);
+	return;
+    }
+
     /* x= */
     pj_scan_advance_n(scanner, 2, SKIP_WS);
@@ -872,4 +908,10 @@
 
     ctx->last_error = PJMEDIA_SDP_EINMEDIA;
+
+    /* check the equal sign */
+    if (*(scanner->curptr+1) != '=') {
+	on_scanner_error(scanner);
+	return;
+    }
 
     /* m= */
@@ -926,4 +968,10 @@
 
     attr = pj_pool_alloc(pool, sizeof(pjmedia_sdp_attr));
+
+    /* check equal sign */
+    if (*(scanner->curptr+1) != '=') {
+	on_scanner_error(scanner);
+	return NULL;
+    }
 
     /* skip a= */
@@ -1013,5 +1061,10 @@
 		    break;
 		default:
-		    parse_generic_line(&scanner, &dummy, &ctx);
+		    if (cur_name >= 'a' && cur_name <= 'z')
+			parse_generic_line(&scanner, &dummy, &ctx);
+		    else  {
+			ctx.last_error = PJMEDIA_SDP_EINSDP;
+			on_scanner_error(&scanner);
+		    }
 		    break;
 		}
@@ -1104,5 +1157,5 @@
 
 #define CHECK(exp,ret)	do {			\
-			    pj_assert(exp);	\
+			    /*pj_assert(exp);*/	\
 			    if (!(exp))		\
 				return ret;	\
Index: /pjproject/trunk/pjmedia/src/pjmedia/session.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/session.c	(revision 570)
+++ /pjproject/trunk/pjmedia/src/pjmedia/session.c	(revision 571)
@@ -122,4 +122,12 @@
     }
 
+    /* Transport type must be equal */
+    if (pj_stricmp(&rem_m->desc.transport, 
+		   &local_m->desc.transport) != 0) 
+    {
+	si->type = PJMEDIA_TYPE_UNKNOWN;
+	return PJMEDIA_SDPNEG_EINVANSTP;
+    }
+
     /* Media direction: */
 
@@ -200,4 +208,6 @@
     /* Get the payload number for receive channel. */
     pt = pj_strtoul(&local_m->desc.fmt[0]);
+    pj_assert(PJMEDIA_RTP_PT_TELEPHONE_EVENTS==0 ||
+	      pt != PJMEDIA_RTP_PT_TELEPHONE_EVENTS);
 
     /* Get codec info.
