[Asterisk-cvs] asterisk/channels chan_sip.c,1.837,1.838

markster markster
Tue Sep 6 17:04:13 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv23172/channels

Modified Files:
	chan_sip.c 
Log Message:
Allow "auto" dtmf mode to select between RFC2833 and inband based on peer's offer or answer.


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.837
retrieving revision 1.838
diff -u -d -r1.837 -r1.838
--- chan_sip.c	6 Sep 2005 20:03:31 -0000	1.837
+++ chan_sip.c	6 Sep 2005 21:04:39 -0000	1.838
@@ -489,6 +489,7 @@
 #define SIP_DTMF_RFC2833	(0 << 16)	/* RTP DTMF */
 #define SIP_DTMF_INBAND		(1 << 16)	/* Inband audio, only for ULAW/ALAW */
 #define SIP_DTMF_INFO		(2 << 16)	/* SIP Info messages */
+#define SIP_DTMF_AUTO		(3 << 16)	/* AUTO switch between rfc2833 and in-band DTMF */
 /* NAT settings */
 #define SIP_NAT			(3 << 18)	/* four settings, uses two bits */
 #define SIP_NAT_NEVER		(0 << 18)	/* No nat support */
@@ -1814,7 +1815,7 @@
 	/* Set timer T1 to RTT for this peer (if known by qualify=) */
 	if (peer->maxms && peer->lastms)
 		r->timer_t1 = peer->lastms;
-	if (ast_test_flag(r, SIP_DTMF) == SIP_DTMF_RFC2833)
+	if ((ast_test_flag(r, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(r, SIP_DTMF) == SIP_DTMF_AUTO))
 		r->noncodeccapability |= AST_RTP_DTMF;
 	else
 		r->noncodeccapability &= ~AST_RTP_DTMF;
@@ -2976,7 +2977,7 @@
 	/* Assign default music on hold class */
 	strcpy(p->musicclass, global_musicclass);
 	p->capability = global_capability;
-	if (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833)
+	if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO))
 		p->noncodeccapability |= AST_RTP_DTMF;
 	strcpy(p->context, default_context);
 
@@ -3418,6 +3419,16 @@
 	p->peercapability = (peercapability | vpeercapability);
 	p->noncodeccapability = noncodeccapability & peernoncodeccapability;
 	
+	if (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO) {
+		ast_clear_flag(p, SIP_DTMF);
+		if (p->noncodeccapability & AST_RTP_DTMF) {
+			/* XXX Would it be reasonable to drop the DSP at this point? XXX */
+			ast_set_flag(p, SIP_DTMF_RFC2833);
+		} else {
+			ast_set_flag(p, SIP_DTMF_INBAND);
+		}
+	}
+	
 	if (debug) {
 		/* shame on whoever coded this.... */
 		const unsigned slen=512;
@@ -6589,7 +6600,7 @@
 			p->jointcapability = user->capability;
 			if (p->peercapability)
 				p->jointcapability &= p->peercapability;
-			if (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833)
+			if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO))
 				p->noncodeccapability |= AST_RTP_DTMF;
 			else
 				p->noncodeccapability &= ~AST_RTP_DTMF;
@@ -6691,7 +6702,7 @@
 				p->jointcapability = peer->capability;
 				if (p->peercapability)
 					p->jointcapability &= p->peercapability;
-				if (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833)
+				if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO))
 					p->noncodeccapability |= AST_RTP_DTMF;
 				else
 					p->noncodeccapability &= ~AST_RTP_DTMF;
@@ -7134,6 +7145,8 @@
 		return "info";
 	case SIP_DTMF_INBAND:
 		return "inband";
+	case SIP_DTMF_AUTO:
+		return "auto";
 	}
 	return "<error>";
 }
@@ -10834,6 +10847,8 @@
 			ast_set_flag(flags, SIP_DTMF_RFC2833);
 		else if (!strcasecmp(v->value, "info"))
 			ast_set_flag(flags, SIP_DTMF_INFO);
+		else if (!strcasecmp(v->value, "auto"))
+			ast_set_flag(flags, SIP_DTMF_AUTO);
 		else {
 			ast_log(LOG_WARNING, "Unknown dtmf mode '%s' on line %d, using rfc2833\n", v->value, v->lineno);
 			ast_set_flag(flags, SIP_DTMF_RFC2833);




More information about the svn-commits mailing list