]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 289797 via svnmerge from
authorJeff Peeler <jpeeler@digium.com>
Fri, 1 Oct 2010 23:01:31 +0000 (23:01 +0000)
committerJeff Peeler <jpeeler@digium.com>
Fri, 1 Oct 2010 23:01:31 +0000 (23:01 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r289797 | jpeeler | 2010-10-01 17:58:38 -0500 (Fri, 01 Oct 2010) | 15 lines

  Change RFC2833 DTMF event duration on end to report actual elapsed time.

  The scenario here is with a non P2P early media session. The reported time
  length of DTMF presses are coming up short when sending to the remote side.
  Currently the event duration is a running total that is incremented when sending
  continuation packets. These continuation packets are only triggered upon
  incoming media from the remote side, which means that the running total probably
  is not going to end up matching the actual length of time Asterisk received
  DTMF. This patch changes the end event duration to be lengthened if it is
  detected that the end event is going to come up short.

  Review: https://reviewboard.asterisk.org/r/957/

  ABE-2476
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@289798 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
include/asterisk/rtp.h
main/rtp.c

index 117e5342eec93c912772c44bcaae0194473c88f1..b87d32b04fa96ed1e83af3c38413866155020fb7 100644 (file)
@@ -6441,7 +6441,7 @@ static int sip_senddigit_end(struct ast_channel *ast, char digit, unsigned int d
                break;
        case SIP_DTMF_RFC2833:
                if (p->rtp)
-                       ast_rtp_senddigit_end(p->rtp, digit);
+                       ast_rtp_senddigit_end_with_duration(p->rtp, digit, duration);
                break;
        case SIP_DTMF_INBAND:
                res = -1; /* Tell Asterisk to stop inband indications */
index aa38ee0fa1a11d5c3058e1725d7ffa583e58595c..acd40d3ec6ac8bfbbdb64c47fb79b08bc0fea6ee 100644 (file)
@@ -211,6 +211,7 @@ int ast_rtcp_fd(struct ast_rtp *rtp);
 int ast_rtp_senddigit_begin(struct ast_rtp *rtp, char digit);
 
 int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit);
+int ast_rtp_senddigit_end_with_duration(struct ast_rtp *rtp, char digit, unsigned int duration);
 
 int ast_rtp_sendcng(struct ast_rtp *rtp, int level);
 
index 2ed67776976bd6bd76272669cb4adee568753ecc..7d60ad0bd2b2051c6b1a38ceac994c8a0dfdbcc3 100644 (file)
@@ -206,6 +206,7 @@ static int ast_rtcp_write_rr(const void *data);
 static unsigned int ast_rtcp_calc_interval(struct ast_rtp *rtp);
 static int ast_rtp_senddigit_continuation(struct ast_rtp *rtp);
 int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit);
+int ast_rtp_senddigit_end_with_duration(struct ast_rtp *rtp, char digit, unsigned int duration);
 
 #define FLAG_3389_WARNING              (1 << 0)
 #define FLAG_NAT_ACTIVE                        (3 << 1)
@@ -3285,12 +3286,18 @@ static int ast_rtp_senddigit_continuation(struct ast_rtp *rtp)
        return 0;
 }
 
-/*! \brief Send end packets for DTMF */
 int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit)
+{
+       return ast_rtp_senddigit_end_with_duration(rtp, digit, 0);
+}
+
+/*! \brief Send end packets for DTMF */
+int ast_rtp_senddigit_end_with_duration(struct ast_rtp *rtp, char digit, unsigned int duration)
 {
        unsigned int *rtpheader;
        int hdrlen = 12, res = 0, i = 0;
        char data[256];
+       unsigned int measured_samples;
        
        /* If no address, then bail out */
        if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
@@ -3313,6 +3320,11 @@ int ast_rtp_senddigit_end(struct ast_rtp *rtp, char digit)
 
        rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
 
+       if (duration > 0 && (measured_samples = duration * rtp_get_rate(rtp->f.subclass) / 1000) > rtp->send_duration) {
+               ast_debug(2, "Adjusting final end duration from %u to %u\n", rtp->send_duration, measured_samples);
+               rtp->send_duration = measured_samples;
+       }
+
        rtpheader = (unsigned int *)data;
        rtpheader[1] = htonl(rtp->lastdigitts);
        rtpheader[2] = htonl(rtp->ssrc);