]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use realtime text when it is negotiated
authorTerry Wilson <twilson@digium.com>
Mon, 29 Aug 2011 17:28:59 +0000 (17:28 +0000)
committerTerry Wilson <twilson@digium.com>
Mon, 29 Aug 2011 17:28:59 +0000 (17:28 +0000)
This patch make use of wirte_text() realtime text instead of
send_text() if T.140 is in native formats. ASTERISK-17937

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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@333681 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
main/channel.c

diff --git a/CHANGES b/CHANGES
index 5e5c1f3c58f969e4eed859efdc485435a8ba22f1..5fecf5ac6373a10e39b37f9726b12af1a6fa43b2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,10 @@ Text Messaging
    The MESSAGE() dialplan function and MessageSend() application have been
    added to go along with this functionality.  More detailed usage information
    can be found on the Asterisk wiki (http://wiki.asterisk.org/).
+ * If real-time text support (T.140) is negotiated, it will be preferred for
+   sending text via the SendText application. For example, via SIP, messages
+   that were once sent via the SIP MESSAGE request would be sent via RTP if
+   T.140 text is negotiated for a call.
 
 Parking
 -------
index 1bc3b7977f8eaa0e795548e31602e15c024e3727..b1d09a8059e50932588c07bd42027907e3e15b44 100644 (file)
@@ -4586,9 +4586,29 @@ int ast_sendtext(struct ast_channel *chan, const char *text)
                ast_channel_unlock(chan);
                return -1;
        }
+
+       if (ast_strlen_zero(text)) {
+               ast_channel_unlock(chan);
+               return 0;
+       }
+
        CHECK_BLOCKING(chan);
-       if (chan->tech->send_text)
+       if (chan->tech->write_text && (ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_TEXT))) {
+               struct ast_frame f;
+
+               f.frametype = AST_FRAME_TEXT;
+               f.src = "DIALPLAN";
+               f.mallocd = AST_MALLOCD_DATA;
+               f.datalen = strlen(text);
+               f.data.ptr = ast_strdup(text);
+               f.offset = 0;
+               f.seqno = 0;
+
+               ast_format_set(&f.subclass.format, AST_FORMAT_T140, 0);
+               res = chan->tech->write_text(chan, &f);
+       } else if (chan->tech->send_text) {
                res = chan->tech->send_text(chan, text);
+       }
        ast_clear_flag(chan, AST_FLAG_BLOCKING);
        ast_channel_unlock(chan);
        return res;