[Asterisk-code-review] res rtp asterisk: Avoid merging command and regular T.140 te... (asterisk[13])
Joshua Colp
asteriskteam at digium.com
Fri Jul 27 05:35:08 CDT 2018
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9510 )
Change subject: res_rtp_asterisk: Avoid merging command and regular T.140 text packets
......................................................................
res_rtp_asterisk: Avoid merging command and regular T.140 text packets
When realtime text packets are to be sent, the text is accumulated in a
buffer and sent regularly by a timer. It can happen that commands such as
a backspace, CR, or LF get merged with regular text. This breaks some
UAs.
The proposed change:
* We test if the current packet contains a command. If so we send the
buffer immediately.
* We test if the buffer contained a command. If so we send the buffer
immediately.
* We accumulate the text (or the command) in the buffer.
ASTERISK-27970
Change-Id: Ifbe993311410fa855cb8aa4a12084db75f413462
---
M res/res_rtp_asterisk.c
1 file changed, 22 insertions(+), 2 deletions(-)
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
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 1a1307f..d101fcb 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -6101,9 +6101,29 @@
static int rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame)
{
struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+ struct rtp_red *red = rtp->red;
- if (frame->datalen > -1) {
- struct rtp_red *red = rtp->red;
+ if (!red) {
+ return 0;
+ }
+
+ if (frame->datalen > 0) {
+ if (red->t140.datalen > 0) {
+ const unsigned char *primary = red->buf_data;
+
+ /* There is something already in the T.140 buffer */
+ if (primary[0] == 0x08 || primary[0] == 0x0a || primary[0] == 0x0d) {
+ /* Flush the previous T.140 packet if it is a command */
+ ast_rtp_write(instance, &rtp->red->t140);
+ } else {
+ primary = frame->data.ptr;
+ if (primary[0] == 0x08 || primary[0] == 0x0a || primary[0] == 0x0d) {
+ /* Flush the previous T.140 packet if we are buffering a command now */
+ ast_rtp_write(instance, &rtp->red->t140);
+ }
+ }
+ }
+
memcpy(&red->buf_data[red->t140.datalen], frame->data.ptr, frame->datalen);
red->t140.datalen += frame->datalen;
red->t140.ts = frame->ts;
--
To view, visit https://gerrit.asterisk.org/9510
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifbe993311410fa855cb8aa4a12084db75f413462
Gerrit-Change-Number: 9510
Gerrit-PatchSet: 6
Gerrit-Owner: Emmanuel BUU <emmanuel.buu at ives.fr>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180727/d5846419/attachment.html>
More information about the asterisk-code-review
mailing list