From 35bbb8e560522d12ac37614dfaa932d0a7666a85 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Thu, 22 Aug 2013 17:46:15 -0400
Subject: [PATCH] * #29004: dtmf over rtp: send 3 identical end packets

---
 daemon/src/audio/audiortp/audio_rtp_session.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/daemon/src/audio/audiortp/audio_rtp_session.cpp b/daemon/src/audio/audiortp/audio_rtp_session.cpp
index 04bce53c96..7ae1c2b415 100644
--- a/daemon/src/audio/audiortp/audio_rtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_rtp_session.cpp
@@ -129,7 +129,11 @@ void AudioRtpSession::sendDtmfEvent()
     if (dtmf.newevent)
         queue_.setMark(true);
 
-    queue_.sendImmediate(timestamp_, (const unsigned char *)(& (dtmf.payload)), sizeof(ost::RTPPacket::RFC2833Payload));
+    // Send end packet three times (without changing it). Sequence number is
+    // incremented automatically by ccrtp, which is the correct behaviour.
+    const unsigned repetitions = dtmf.payload.ebit ? 3 : 1;
+    for (unsigned i = 0; i < repetitions; ++i)
+        queue_.sendImmediate(timestamp_, (const unsigned char *)(& (dtmf.payload)), sizeof(ost::RTPPacket::RFC2833Payload));
 
     // This is no longer a new event
     if (dtmf.newevent) {
@@ -145,7 +149,7 @@ void AudioRtpSession::sendDtmfEvent()
     dtmf.length -= increment;
     dtmf.payload.duration++;
 
-    // next packet is going to be the last one
+    // next packet is going to be the end packet (transmitted 3 times)
     if ((dtmf.length - increment) < increment)
         dtmf.payload.ebit = true;
 
-- 
GitLab