[Asterisk-Dev] The Almighty X-Lite DTMF Problem [PATCH]

Christopher Heiser cheeseman00 at hotmail.com
Thu Aug 14 11:34:32 MST 2003


Do not use my previous patch.  Use this one.
My previous patch had a small bug that will appear in high packet loss 
situations or when dtmf digits are extremely short.

--Chris


>From: "Christopher Heiser" <cheeseman00 at hotmail.com>
>Reply-To: asterisk-dev at lists.digium.com
>To: asterisk-dev at lists.digium.com
>Subject: RE: [Asterisk-Dev] The Almighty X-Lite DTMF Problem [PATCH]
>Date: Thu, 14 Aug 2003 12:55:00 -0400
>
>Patch added to Bug ID: 0000095
>
>
>>From: "Christopher Heiser" <cheeseman00 at hotmail.com>
>>Reply-To: asterisk-dev at lists.digium.com
>>To: asterisk-dev at lists.digium.com
>>Subject: RE: [Asterisk-Dev] The Almighty X-Lite DTMF Problem [PATCH]
>>Date: Thu, 14 Aug 2003 12:40:12 -0400
>>
>>Here is my final patch.
>>I will be submitting this to bugs.digium.com
>>
>>The patch includes the following fixes:
>>
>>Recognize the "End" bit on an RFC2833 telephone-event packet as the end of 
>>a DTMF digit
>>Track the DTMF duration count.  If a DTMF event comes in with a smaller 
>>duration, recognize the previous DTMF event as complete.
>>
>>This solves Xten's problems and will also still detect repeated DTMF 
>>digits without the "End" bit set (in case we lose that packet).
>>
>>--Chris
>>
>>
>>>From: "Chris Heiser" <cheeseman00 at hotmail.com>
>>>Reply-To: asterisk-dev at lists.digium.com
>>>To: <asterisk-dev at lists.digium.com>
>>>Subject: RE: [Asterisk-Dev] The Almighty X-Lite DTMF Problem
>>>Date: Wed, 13 Aug 2003 16:19:26 -0400
>>>
>>>Pete,
>>>
>>>Try this patch below...  I noticed that eStara's softphone has the same
>>>problem as xten's softphone when it comes to DTMF.  Seems as though 
>>>Asterisk
>>>is not looking for the "end" bit per RFC2833.  So try this fix.  It 
>>>should
>>>do the trick (at least... it fixed mine).
>>>
>>>--Chris
>>>
>>>Index: rtp.c
>>>===================================================================
>>>RCS file: /usr/cvsroot/asterisk/rtp.c,v
>>>retrieving revision 1.22
>>>diff -r1.22 rtp.c
>>>205a206
>>> >       unsigned int event_end;
>>>209a211,213
>>> >       event_end = ntohl(*((unsigned int *)(data)));
>>> >       event_end <<= 8;
>>> >       event_end >>= 24;
>>>224a229,234
>>> >       else if(event_end & 0x80)
>>> >       {
>>> >               f = send_dtmf(rtp);
>>> >               resp = 0;
>>> >       }
>>> >
>>>
>>> > -----Original Message-----
>>> > From: asterisk-dev-admin at lists.digium.com [mailto:asterisk-dev-
>>> > admin at lists.digium.com] On Behalf Of pgrace at fierymoon.com
>>> > Sent: Tuesday, August 12, 2003 2:35 PM
>>> > To: asterisk-dev at lists.digium.com
>>> > Subject: [Asterisk-Dev] The Almighty X-Lite DTMF Problem
>>> >
>>> > Hey guys,
>>> >
>>> > I just was told by Rob at xten that the timestamp problem is fixed in 
>>>the
>>> > rfc2833 implementation.  I'm still having the exact same problems with
>>> > voicemail(2) that I was before.  Can someone please un-resolve bug 14 
>>>and
>>> > maybe I can work with someone to help debug what's happening?
>>> >
>>> > Chris H, if you're still following this topic, fire me off an e-mail 
>>>if
>>> > you want to see new debugs..
>>> >
>>> > Thanks,
>>> > Pete (km-)
>>> > _______________________________________________
>>> > Asterisk-Dev mailing list
>>> > Asterisk-Dev at lists.digium.com
>>> > http://lists.digium.com/mailman/listinfo/asterisk-dev
>>>_______________________________________________
>>>Asterisk-Dev mailing list
>>>Asterisk-Dev at lists.digium.com
>>>http://lists.digium.com/mailman/listinfo/asterisk-dev
>>
>>_________________________________________________________________
>>STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
>>http://join.msn.com/?page=features/junkmail
>><< rtp.c.diff >>
>
>_________________________________________________________________
>Protect your PC - get McAfee.com VirusScan Online  
>http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>_______________________________________________
>Asterisk-Dev mailing list
>Asterisk-Dev at lists.digium.com
>http://lists.digium.com/mailman/listinfo/asterisk-dev

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail
-------------- next part --------------
Index: rtp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/rtp.c,v
retrieving revision 1.22
diff -u -r1.22 rtp.c
--- rtp.c	13 Aug 2003 15:25:16 -0000	1.22
+++ rtp.c	14 Aug 2003 18:55:04 -0000
@@ -68,6 +68,7 @@
	int lasttxformat;
	int lastrxformat;
	int dtmfcount;
+	unsigned int dtmfduration;
	int nat;
	struct sockaddr_in us;
	struct sockaddr_in them;
@@ -169,6 +170,7 @@
	rtp->f.mallocd = 0;
	rtp->f.src = "RTP";
	rtp->resp = 0;
+	rtp->dtmfduration = 0;
	return &rtp->f;

}
@@ -203,10 +205,17 @@
static struct ast_frame *process_rfc2833(struct ast_rtp *rtp, unsigned char 
*data, int len)
{
	unsigned int event;
+	unsigned int event_end;
+	unsigned int duration;
	char resp = 0;
	struct ast_frame *f = NULL;
	event = ntohl(*((unsigned int *)(data)));
	event >>= 24;
+	event_end = ntohl(*((unsigned int *)(data)));
+	event_end <<= 8;
+	event_end >>= 24;
+	duration = ntohl(*((unsigned int *)(data)));
+	duration &= 0xFFFF;
#if 0
	printf("Event: %08x (len = %d)\n", event, len);
#endif
@@ -222,8 +231,20 @@
	if (rtp->resp && (rtp->resp != resp)) {
		f = send_dtmf(rtp);
	}
+	else if(event_end & 0x80)
+	{
+		f = send_dtmf(rtp);
+		resp = 0;
+		duration = 0;
+	}
+	else if(rtp->dtmfduration && (duration < rtp->dtmfduration))
+	{
+		f = send_dtmf(rtp);
+	}
+
	rtp->resp = resp;
	rtp->dtmfcount = dtmftimeout;
+	rtp->dtmfduration = duration;
	return f;
}




More information about the asterisk-dev mailing list