[asterisk-commits] trunk r27559 - in /trunk: channels/chan_sip.c include/asterisk/rtp.h rtp.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 16 15:11:02 MST 2006


Author: kpfleming
Date: Tue May 16 17:11:02 2006
New Revision: 27559

URL: http://svn.digium.com/view/asterisk?rev=27559&view=rev
Log:
mark RTP sessions that are not carrying DTMF
allow native bridging of RTP sessions that are not carrying DTMF even when the bridge needs to listen to DTMF (when SIP INFO is used for DTMF, for example)

Modified:
    trunk/channels/chan_sip.c
    trunk/include/asterisk/rtp.h
    trunk/rtp.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=27559&r1=27558&r2=27559&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue May 16 17:11:02 2006
@@ -2195,6 +2195,7 @@
 		ast_rtp_destroy(r->vrtp);
 		r->vrtp = NULL;
 	}
+	ast_rtp_setdtmf(r->rtp, ast_test_flag(&r->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
 	r->prefs = peer->prefs;
 	natflags = ast_test_flag(&r->flags[0], SIP_NAT) & SIP_NAT_ROUTE;
 	if (r->rtp) {
@@ -3524,9 +3525,12 @@
 			free(p);
 			return NULL;
 		}
+		ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
 		ast_rtp_settos(p->rtp, global_tos_audio);
-		if (p->vrtp)
+		if (p->vrtp) {
 			ast_rtp_settos(p->vrtp, global_tos_video);
+			ast_rtp_setdtmf(p->vrtp, 0);
+		}
 		p->rtptimeout = global_rtptimeout;
 		p->rtpholdtimeout = global_rtpholdtimeout;
 		p->rtpkeepalive = global_rtpkeepalive;
@@ -11170,6 +11174,7 @@
 		get_rdnis(p, NULL);			/* Get redirect information */
 		extract_uri(p, req);			/* Get the Contact URI */
 		build_contact(p);			/* Build our contact header */
+		ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
 
 		if (gotdest) {
 			if (gotdest == 1 && ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWOVERLAP)) {

Modified: trunk/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/rtp.h?rev=27559&r1=27558&r2=27559&view=diff
==============================================================================
--- trunk/include/asterisk/rtp.h (original)
+++ trunk/include/asterisk/rtp.h Tue May 16 17:11:02 2006
@@ -151,6 +151,9 @@
 
 void ast_rtp_setnat(struct ast_rtp *rtp, int nat);
 
+/*! \brief Indicate whether this RTP session is carrying DTMF or not */
+void ast_rtp_setdtmf(struct ast_rtp *rtp, int dtmf);
+
 int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
 
 int ast_rtp_proto_register(struct ast_rtp_protocol *proto);

Modified: trunk/rtp.c
URL: http://svn.digium.com/view/asterisk/trunk/rtp.c?rev=27559&r1=27558&r2=27559&view=diff
==============================================================================
--- trunk/rtp.c (original)
+++ trunk/rtp.c Tue May 16 17:11:02 2006
@@ -86,6 +86,7 @@
 #define FLAG_NAT_ACTIVE			(3 << 1)
 #define FLAG_NAT_INACTIVE		(0 << 1)
 #define FLAG_NAT_INACTIVE_NOWARN	(1 << 1)
+#define FLAG_HAS_DTMF			(1 << 3)
 
 /*! \brief RTP session description */
 struct ast_rtp {
@@ -434,6 +435,11 @@
 	rtp->nat = nat;
 }
 
+void ast_rtp_setdtmf(struct ast_rtp *rtp, int dtmf)
+{
+	ast_set2_flag(rtp, dtmf ? 1 : 0, FLAG_HAS_DTMF);
+}
+
 static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
 {
 	char iabuf[INET_ADDRSTRLEN];
@@ -1344,6 +1350,7 @@
 	rtp->s = rtp_socket();
 	rtp->ssrc = ast_random();
 	rtp->seqno = ast_random() & 0xffff;
+	ast_set_flag(rtp, FLAG_HAS_DTMF);
 	if (rtp->s < 0) {
 		free(rtp);
 		ast_log(LOG_ERROR, "Unable to allocate socket: %s\n", strerror(errno));
@@ -1921,10 +1928,6 @@
 	memset(&vac0, 0, sizeof(vac0));
 	memset(&vac1, 0, sizeof(vac1));
 
-	/* if need DTMF, cant native bridge */
-	if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))
-		return AST_BRIDGE_FAILED_NOWARN;
-
 	/* Lock channels */
 	ast_channel_lock(c0);
 	while(ast_channel_trylock(c1)) {
@@ -1966,6 +1969,25 @@
 		ast_channel_unlock(c1);
 		return AST_BRIDGE_FAILED_NOWARN;
 	}
+
+	if (ast_test_flag(p0, FLAG_HAS_DTMF) && (flags & AST_BRIDGE_DTMF_CHANNEL_0)) {
+		/* can't bridge, we are carrying DTMF for this channel and the bridge
+		   needs it
+		*/
+		ast_channel_unlock(c0);
+		ast_channel_unlock(c1);
+		return AST_BRIDGE_FAILED_NOWARN;
+	}
+
+	if (ast_test_flag(p1, FLAG_HAS_DTMF) && (flags & AST_BRIDGE_DTMF_CHANNEL_1)) {
+		/* can't bridge, we are carrying DTMF for this channel and the bridge
+		   needs it
+		*/
+		ast_channel_unlock(c0);
+		ast_channel_unlock(c1);
+		return AST_BRIDGE_FAILED_NOWARN;
+	}
+
 	/* Get codecs from both sides */
 	codec0 = pr0->get_codec ? pr0->get_codec(c0) : 0;
 	codec1 = pr1->get_codec ? pr1->get_codec(c1) : 0;



More information about the asterisk-commits mailing list