From b9bdea7105a538fc7bdde48ab7b94aa8a9ec58a6 Mon Sep 17 00:00:00 2001
From: "Michael L. Young" <elgueromexicano@gmail.com>
Date: Wed, 5 Sep 2012 04:52:10 +0000
Subject: [PATCH] Fix Incrementing Sequence Number For Retransmitted DTMF End
 Packets

In Asterisk 1.4+, a fix was put in place to increment the sequence number for
retransmitted DTMF end packets.  With the introduction of the RTP engine API in
1.8, the sequence number was no longer being incremented.  This patch fixes this
regression as well as cleans up a few lines that were not doing anything.

(closes issue ASTERISK-20295)
Reported by: Nitesh Bansal
Tested by: Michael L. Young
Patches:
01_rtp_event_seq_num.patch uploaded by Nitesh Bansal (license 6418)
asterisk-20295-dtmf-fix-cleanup.diff uploaded by Michael L. Young (license 5026)

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

Merged revisions 372185 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 372198 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@372199 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 res/res_rtp_asterisk.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index fad313c2b6..57dd8a3066 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -1386,11 +1386,10 @@ static int ast_rtp_dtmf_continuation(struct ast_rtp_instance *instance)
 	}
 
 	/* Actually create the packet we will be sending */
-	rtpheader[0] = htonl((2 << 30) | (1 << 23) | (rtp->send_payload << 16) | (rtp->seqno));
+	rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
 	rtpheader[1] = htonl(rtp->lastdigitts);
 	rtpheader[2] = htonl(rtp->ssrc);
 	rtpheader[3] = htonl((rtp->send_digit << 24) | (0xa << 16) | (rtp->send_duration));
-	rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
 
 	/* Boom, send it on out */
 	res = rtp_sendto(instance, (void *) rtpheader, hdrlen + 4, 0, &remote_address, &ice);
@@ -1456,18 +1455,18 @@ static int ast_rtp_dtmf_end_with_duration(struct ast_rtp_instance *instance, cha
 	}
 
 	/* Construct the packet we are going to send */
-	rtpheader[0] = htonl((2 << 30) | (1 << 23) | (rtp->send_payload << 16) | (rtp->seqno));
 	rtpheader[1] = htonl(rtp->lastdigitts);
 	rtpheader[2] = htonl(rtp->ssrc);
 	rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (rtp->send_duration));
 	rtpheader[3] |= htonl((1 << 23));
-	rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
 
 	/* Send it 3 times, that's the magical number */
 	for (i = 0; i < 3; i++) {
 		int ice;
 
-		res = rtp_sendto(instance, (void *) rtpheader, hdrlen + 4, 0, &remote_address, &ice);
+		rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
+
+		res = rtp_sendto(instance, (void *) rtpheader, hdrlen + 4, 0, &remote_address);
 
 		if (res < 0) {
 			ast_log(LOG_ERROR, "RTP Transmission error to %s: %s\n",
@@ -1483,6 +1482,8 @@ static int ast_rtp_dtmf_end_with_duration(struct ast_rtp_instance *instance, cha
 				    ice ? " (via ICE)" : "",
 				    rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 		}
+
+		rtp->seqno++;
 	}
 
 	/* Oh and we can't forget to turn off the stuff that says we are sending DTMF */
-- 
GitLab