<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/2033/">https://reviewboard.asterisk.org/r/2033/</a>
</td>
</tr>
</table>
<br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers and Olle E Johansson.</div>
<div>By Matt Jordan.</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">As ASTERISK-18404 notes, the current implementation of RFC2833 DTMF handling in res_rtp_asterisk will, if a packet arrives out of order, drop the packet. This is to prevent duplicate tone generation in the Asterisk core. Since the RTP layer does not buffer data itself, this is the only option the RTP layer currently has for handling packets that arrive out of order.
For certain sequences of DTMF packets - most notably when, for a particular digit, an END packet arrives before any BEGIN packet for that digit - this causes the entire digit to be lost. The END packet is erroneously dropped, even though it occurs before any BEGIN packets for that digit, because the DTMF handling in res_rtp_asterisk assumes that we must have at least one BEGIN packet before an END. If it receives an END and no digit is currently being 'handled', it will drop the END packet.
Originally, we thought of using a DTMF aware jitter buffer to handle this situation, and allowing all frames to pass up through the RTP layer to the Asterisk core where they would be re-ordered by the jitter buffer (see https://reviewboard.asterisk.org/r/2010/). While this worked, it did introduce a delay in the DTMF processing, required timestamps on the DTMF frames (along with some mild manipulation of said timestamps), and was relatively complex, in that it required substantial changes to func_jitterbuffer.
Olle hit upon a simpler solution - simply trust the END packet to convey the information required. If we receive an END packet, and it:
* Has a timestamp greater then the last timestamp received from an END packet
* Does not have the same sequence number as the last received sequence number (and is thus not an END packet retransmitted)
Then send the END frame up to the Asterisk core. It contains the appropriate DTMF duration and sufficient information for Asterisk to produce the DTMF digit.
On the other hand, if we receive a BEGIN or continuation packet that occurs with a timestamp equal to the last END timestamp, then we've received something out of order - probably the END packet. Since the END packet contained all of the information we needed, drop the BEGIN/continuation packets that were for that DTMF digit.
This patch uses Olle's approach (and cleans up some handling in the process_dtmf_rfc2833 code as well - the rtp->lastevent field was used as both a timestamp and a sequence number, which is just wrong). It handles the situation described in ASTERISK-18404.
This review resolves the intent of https://reviewboard.asterisk.org/r/2010/, thereby replacing it. As such, that review - and the tests that went along with it - will be closed out. The unit tests/functional tests for that patch will be refactored to apply only to voice jitter buffers, as they are still useful.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Passed the Test Suite's rfc2833_dtmf_detect test.
Passed a modified DTMF pcap which consisted of:
Digit Seqno Timestamp Mark
1 8318 3659342064 End
1 8315 3659342064
1 8316 3659342064
1 8314 3659342064
1 8317 3659342064
1 8319 3659342064 End
1 8320 3659342064 End
Without this patch, this digit will not be detected by the current DTMF handling. Because the END packet arrived before a BEGIN, it gets dropped, but not before it sets the last known seqno to 8318. All BEGIN packets after that occur before that seqno, and are dropped as out of order. The last two END packets are then dropped as well, as no BEGIN packet was 'seen'.</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-18404">ASTERISK-18404</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/res/res_rtp_asterisk.c <span style="color: grey">(369992)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2033/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>