aboutsummaryrefslogtreecommitdiffstats
path: root/rtp.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-14 21:55:31 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-14 21:55:31 +0000
commit11a791986885b653be5e8e215d73e3f63d2c2e09 (patch)
tree97b2f0abee07f041b3232f31fb3cd046bb149a67 /rtp.c
parenta3c14ea5fbb77270a6670f1abdf7b9b771df24b5 (diff)
Merge DTMF fixes (bug #95)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1336 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rwxr-xr-xrtp.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/rtp.c b/rtp.c
index ba40c61bc..484a4f694 100755
--- a/rtp.c
+++ b/rtp.c
@@ -68,6 +68,7 @@ struct ast_rtp {
int lasttxformat;
int lastrxformat;
int dtmfcount;
+ unsigned int dtmfduration;
int nat;
struct sockaddr_in us;
struct sockaddr_in them;
@@ -169,6 +170,7 @@ static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
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_cisco_dtmf(struct ast_rtp *rtp, unsigned char *
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 @@ static struct ast_frame *process_rfc2833(struct ast_rtp *rtp, unsigned char *dat
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;
}