diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-03-15 16:20:01 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-03-15 16:20:01 +0000 |
commit | 0ac5be7919ae396936eed553381e04b093d3f5ca (patch) | |
tree | a7468ee663a7ffc6dfb9b600022c0cd7c20604de /rtp.c | |
parent | 66a2c925b565c8469f997ad5ef0f6f642e174b6f (diff) |
Mute received DTMF path
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2440 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rwxr-xr-x | rtp.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -75,6 +75,7 @@ struct ast_rtp { struct sockaddr_in them; struct timeval rxcore; struct timeval txcore; + struct timeval dtmfmute; struct ast_smoother *smoother; int *ioid; unsigned short seqno; @@ -163,7 +164,17 @@ void ast_rtp_setnat(struct ast_rtp *rtp, int nat) static struct ast_frame *send_dtmf(struct ast_rtp *rtp) { - ast_log(LOG_DEBUG, "Sending dtmf: %d (%c)\n", rtp->resp, rtp->resp); + struct timeval tv; + static struct ast_frame null_frame = { AST_FRAME_NULL, }; + gettimeofday(&tv, NULL); + if ((tv.tv_sec < rtp->dtmfmute.tv_sec) || + ((tv.tv_sec == rtp->dtmfmute.tv_sec) && (tv.tv_usec < rtp->dtmfmute.tv_usec))) { + ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", inet_ntoa(rtp->them.sin_addr)); + rtp->resp = 0; + rtp->dtmfduration = 0; + return &null_frame; + } + ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, inet_ntoa(rtp->them.sin_addr)); rtp->f.frametype = AST_FRAME_DTMF; rtp->f.subclass = rtp->resp; rtp->f.datalen = 0; @@ -897,6 +908,13 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit) if (!rtp->them.sin_addr.s_addr) return 0; + gettimeofday(&rtp->dtmfmute, NULL); + rtp->dtmfmute.tv_usec += (500 * 1000); + if (rtp->dtmfmute.tv_usec > 1000000) { + rtp->dtmfmute.tv_usec -= 1000000; + rtp->dtmfmute.tv_sec += 1; + } + ms = calc_txstamp(rtp, NULL); /* Default prediction */ pred = rtp->lastts + ms * 8; |