[Freeswitch-branches] [commit] r4395 - in freeswitch/branches/trixter/src: . include mod/endpoints/mod_sofia

Freeswitch SVN trixter at freeswitch.org
Sun Feb 25 23:15:04 EST 2007


Author: trixter
Date: Sun Feb 25 23:15:04 2007
New Revision: 4395

Modified:
   freeswitch/branches/trixter/src/include/switch_types.h
   freeswitch/branches/trixter/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/branches/trixter/src/switch_rtp.c

Log:
I think this pretty much wraps up the clean RTP transmission, adds a flag rewrite_rtp which can be specified in the profile or dialplan as a chan var that will set it up so all RTP is rewritten by FreeSWITCH so it can filter devices that otherwise wouldnt talk to each other


Modified: freeswitch/branches/trixter/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/trixter/src/include/switch_types.h	(original)
+++ freeswitch/branches/trixter/src/include/switch_types.h	Sun Feb 25 23:15:04 2007
@@ -244,7 +244,7 @@
 	SWITCH_RTP_FLAG_MINI		  - Use mini RTP when possible
 	SWITCH_RTP_FLAG_DATAWAIT	  - Do not return from reads unless there is data even when non blocking
 	SWITCH_RTP_FLAG_BUGGY_2833    - Emulate the bug in cisco equipment to allow interop
-	SWITCH_RTP_FLAG_PASS_RFC2833     - Pass 2833 (ignore it)
+	SWITCH_RTP_FLAG_PASS_RFC2833  - Pass 2833 (ignore it)
 </pre>
  */
 typedef enum {
@@ -261,7 +261,7 @@
 	SWITCH_RTP_FLAG_MINI = ( 1 << 10),
 	SWITCH_RTP_FLAG_DATAWAIT = (1 << 11),
 	SWITCH_RTP_FLAG_BUGGY_2833 = (1 << 12),
-	SWITCH_RTP_FLAG_PASS_RFC2833 = (1 << 13)
+	SWITCH_RTP_FLAG_PASS_RFC2833 = (1 << 13),
 } switch_rtp_flag_t;
 
 /*!

Modified: freeswitch/branches/trixter/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/trixter/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/branches/trixter/src/mod/endpoints/mod_sofia/mod_sofia.c	Sun Feb 25 23:15:04 2007
@@ -147,7 +147,8 @@
 	PFLAG_FULL_ID = (1 << 3),
 	PFLAG_PRESENCE = (1 << 4),
 	PFLAG_PASS_RFC2833 = (1 << 5),
-    PFLAG_DISABLE_TRANSCODING = (1 << 6)
+    PFLAG_DISABLE_TRANSCODING = (1 << 6),
+	PFLAG_REWRITE_RTP = (1 << 7)
 } PFLAGS;
 
 typedef enum {
@@ -1533,6 +1534,12 @@
         flags |= SWITCH_RTP_FLAG_PASS_RFC2833;
     }
 
+	if ((tech_pvt->profile->pflags & PFLAG_REWRITE_RTP) || (val = switch_channel_get_variable(channel, "rewrite_rtp")) && switch_true(val)) {
+		printf("\n\n\n\n\nSetting PFLAG_REWRITE_RTP\n\n\n\n\n");
+		// disable raw writes and disable 2833 passthrough
+		flags &= ~(SWITCH_RTP_FLAG_PASS_RFC2833 | SWITCH_RTP_FLAG_RAW_WRITE);
+	}
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
 					  switch_channel_get_name(channel),
 					  tech_pvt->local_sdp_audio_ip,
@@ -1582,6 +1589,7 @@
 		uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
 
 		tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
+		switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te);
 		switch_set_flag_locked(tech_pvt, TFLAG_RTP);
 		switch_set_flag_locked(tech_pvt, TFLAG_IO);
 		
@@ -2327,6 +2335,7 @@
 		//switch_channel_t *channel = switch_core_session_get_channel(session);
 		switch_ivr_transfer_variable(session, nsession, SOFIA_REPLACES_HEADER);
 		switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_HEADER_PREFIX_T);
+
 		if (switch_core_session_compare(session, nsession)) {
 			/* It's another sofia channel! so lets cache what they use as a pt for telephone event so 
 			   we can keep it the same
@@ -2335,6 +2344,8 @@
 			ctech_pvt = switch_core_session_get_private(session);
 			assert(ctech_pvt != NULL);
 			tech_pvt->bte = ctech_pvt->te;
+
+			printf("\n\n\n\n\nFlags: old 0x%08X\tnew 0x%08X\n\n\n\n\n\n", ctech_pvt->profile->pflags, tech_pvt->profile->pflags);
 		}
 	}
 
@@ -5169,6 +5180,10 @@
 						if (switch_true(val)) {
 							profile->pflags |= PFLAG_PASS_RFC2833;
 						}
+					} else if (!strcasecmp(var, "rewrite_rtp")) {
+						if (switch_true(val)) {
+							profile->pflags |= PFLAG_REWRITE_RTP;
+						}
 					} else if (!strcasecmp(var, "disable-transcoding")) {
 						if (switch_true(val)) {
 							profile->pflags |= PFLAG_DISABLE_TRANSCODING;

Modified: freeswitch/branches/trixter/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/trixter/src/switch_rtp.c	(original)
+++ freeswitch/branches/trixter/src/switch_rtp.c	Sun Feb 25 23:15:04 2007
@@ -131,6 +131,7 @@
 	
 	uint16_t seq;
 	uint16_t rseq;
+	uint32_t ssrc;
 	switch_payload_t payload;
 	switch_payload_t rpayload;
 	
@@ -454,6 +455,7 @@
 	rtp_session->recv_msg.header.x       = 0;
 	rtp_session->recv_msg.header.cc      = 0;
 
+	rtp_session->ssrc = rtp_session->send_msg.header.ssrc;
 	rtp_session->seq = (uint16_t)rtp_session->send_msg.header.seq;
 	rtp_session->payload = payload;
 	rtp_session->ms_per_packet = ms_per_packet;
@@ -1354,16 +1356,19 @@
 	void *data;
 	uint32_t len;
 
+
 	// disable sending audio while sending 2833
 	if(rtp_session->dtmf_data.sending_dtmf) {
-		return 0; // is this value correct?  rtp_write_common returns the bytes written ...
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "asked to send audio when 2833 is in progress, dumping audio frame\n");
+		return 0; // is this value correct?  rtp_write_common returns the bytes written mod_sofia doesnt seem to check though
 	}
 
 
 	if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) || !rtp_session->remote_addr) {
 		return -1;
 	}
-	
+
+
 	if (fwd && !packetize) {
 		data = frame->packet;
 		len = frame->packetlen;
@@ -1371,10 +1376,10 @@
 		data = frame->data;
 		len = frame->datalen;
 		rtp_session->ts += ts;
-		rtp_session->seq = ntohs(rtp_session->seq) + 1;
-		rtp_session->seq = htons(rtp_session->seq);
+		rtp_session->seq = htons(ntohs(rtp_session->seq) + 1);
 		rtp_session->send_msg.header.seq = rtp_session->seq;
 		rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
+	    rtp_session->send_msg.header.ssrc = htonl(rtp_session->ssrc);
 	}
 
 	return rtp_common_write(rtp_session, data, len, 0, rtp_session->payload, &frame->flags);



More information about the Freeswitch-branches mailing list