mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Merge DTMF fixes (bug #95)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1336 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
21
rtp.c
21
rtp.c
@@ -68,6 +68,7 @@ struct ast_rtp {
|
|||||||
int lasttxformat;
|
int lasttxformat;
|
||||||
int lastrxformat;
|
int lastrxformat;
|
||||||
int dtmfcount;
|
int dtmfcount;
|
||||||
|
unsigned int dtmfduration;
|
||||||
int nat;
|
int nat;
|
||||||
struct sockaddr_in us;
|
struct sockaddr_in us;
|
||||||
struct sockaddr_in them;
|
struct sockaddr_in them;
|
||||||
@@ -169,6 +170,7 @@ static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
|
|||||||
rtp->f.mallocd = 0;
|
rtp->f.mallocd = 0;
|
||||||
rtp->f.src = "RTP";
|
rtp->f.src = "RTP";
|
||||||
rtp->resp = 0;
|
rtp->resp = 0;
|
||||||
|
rtp->dtmfduration = 0;
|
||||||
return &rtp->f;
|
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)
|
static struct ast_frame *process_rfc2833(struct ast_rtp *rtp, unsigned char *data, int len)
|
||||||
{
|
{
|
||||||
unsigned int event;
|
unsigned int event;
|
||||||
|
unsigned int event_end;
|
||||||
|
unsigned int duration;
|
||||||
char resp = 0;
|
char resp = 0;
|
||||||
struct ast_frame *f = NULL;
|
struct ast_frame *f = NULL;
|
||||||
event = ntohl(*((unsigned int *)(data)));
|
event = ntohl(*((unsigned int *)(data)));
|
||||||
event >>= 24;
|
event >>= 24;
|
||||||
|
event_end = ntohl(*((unsigned int *)(data)));
|
||||||
|
event_end <<= 8;
|
||||||
|
event_end >>= 24;
|
||||||
|
duration = ntohl(*((unsigned int *)(data)));
|
||||||
|
duration &= 0xFFFF;
|
||||||
#if 0
|
#if 0
|
||||||
printf("Event: %08x (len = %d)\n", event, len);
|
printf("Event: %08x (len = %d)\n", event, len);
|
||||||
#endif
|
#endif
|
||||||
@@ -222,8 +231,20 @@ static struct ast_frame *process_rfc2833(struct ast_rtp *rtp, unsigned char *dat
|
|||||||
if (rtp->resp && (rtp->resp != resp)) {
|
if (rtp->resp && (rtp->resp != resp)) {
|
||||||
f = send_dtmf(rtp);
|
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->resp = resp;
|
||||||
rtp->dtmfcount = dtmftimeout;
|
rtp->dtmfcount = dtmftimeout;
|
||||||
|
rtp->dtmfduration = duration;
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user