<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/9510">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_rtp_asterisk: Avoid merging command and regular T.140 text packets<br><br>When realtime text packets are to be sent, the text is accumulated in a<br>buffer and sent regularly by a timer. It can happen that commands such as<br>a backspace, CR, or LF get merged with regular text. This breaks some<br>UAs.<br><br>The proposed change:<br>* We test if the current packet contains a command. If so we send the<br>buffer immediately.<br>* We test if the buffer contained a command. If so we send the buffer<br>immediately.<br>* We accumulate the text (or the command) in the buffer.<br><br>ASTERISK-27970<br><br>Change-Id: Ifbe993311410fa855cb8aa4a12084db75f413462<br>---<br>M res/res_rtp_asterisk.c<br>1 file changed, 22 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c</span><br><span>index 1a1307f..d101fcb 100644</span><br><span>--- a/res/res_rtp_asterisk.c</span><br><span>+++ b/res/res_rtp_asterisk.c</span><br><span>@@ -6101,9 +6101,29 @@</span><br><span> static int rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame)</span><br><span> {</span><br><span> struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);</span><br><span style="color: hsl(120, 100%, 40%);">+ struct rtp_red *red = rtp->red;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (frame->datalen > -1) {</span><br><span style="color: hsl(0, 100%, 40%);">- struct rtp_red *red = rtp->red;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!red) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (frame->datalen > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (red->t140.datalen > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ const unsigned char *primary = red->buf_data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* There is something already in the T.140 buffer */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (primary[0] == 0x08 || primary[0] == 0x0a || primary[0] == 0x0d) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Flush the previous T.140 packet if it is a command */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_rtp_write(instance, &rtp->red->t140);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ primary = frame->data.ptr;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (primary[0] == 0x08 || primary[0] == 0x0a || primary[0] == 0x0d) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Flush the previous T.140 packet if we are buffering a command now */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_rtp_write(instance, &rtp->red->t140);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> memcpy(&red->buf_data[red->t140.datalen], frame->data.ptr, frame->datalen);</span><br><span> red->t140.datalen += frame->datalen;</span><br><span> red->t140.ts = frame->ts;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9510">change 9510</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9510"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ifbe993311410fa855cb8aa4a12084db75f413462 </div>
<div style="display:none"> Gerrit-Change-Number: 9510 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: Emmanuel BUU <emmanuel.buu@ives.fr> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>