[Asterisk-code-review] bridge softmix: Forward TEXT frames (asterisk[master])

George Joseph asteriskteam at digium.com
Wed Sep 27 12:04:03 CDT 2017


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/6617


Change subject: bridge_softmix:  Forward TEXT frames
......................................................................

bridge_softmix:  Forward TEXT frames

res_pjsip_messaging queues TEXT frames to the channel when it
receives an in-dialog MESSAGE from an endpoint and chan_pjsip will
send an MESSAGE when it gets a TEXT frame.  On a normal
point-to-point call, the frames are forwarded between the two
correctly.  bridge_softmix was not though so messages weren't
getting forwarded to conference bridge participants.

* bridge_softmix now does a ast_bridge_queue_everyone_else.  It also
forwards the frame back to the sender as a confirmation and to make
client side development a little easier.

Change-Id: Idacf5900bfd5f22ab8cd235aa56dfad090d18489
---
M bridges/bridge_softmix.c
M channels/chan_pjsip.c
M main/bridge_channel.c
M res/res_pjsip_messaging.c
4 files changed, 37 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/17/6617/1

diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index 5e0a485..55008d0 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -1103,6 +1103,25 @@
 
 /*!
  * \internal
+ * \brief Determine what to do with a text frame.
+ * \since 13.18.0
+ * \since 14.7.0
+ * \since 15.1.0
+ *
+ * \param bridge Which bridge is getting the frame
+ * \param bridge_channel Which channel is writing the frame.
+ * \param frame What is being written.
+ *
+ * \return Nothing
+ */
+static void softmix_bridge_write_text(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+{
+	ast_bridge_queue_everyone_else(bridge, bridge_channel, frame);
+	ast_bridge_channel_queue_frame(bridge_channel, frame);
+}
+
+/*!
+ * \internal
  * \brief Determine what to do with a control frame.
  * \since 12.0.0
  *
@@ -1184,6 +1203,11 @@
 	case AST_FRAME_VIDEO:
 		softmix_bridge_write_video(bridge, bridge_channel, frame);
 		break;
+	case AST_FRAME_TEXT:
+		ast_debug(1, "Received TEXT frame from channel %s: %*.s\n",
+			ast_channel_name(bridge_channel->chan), frame->datalen, (char *)frame->data.ptr);
+		softmix_bridge_write_text(bridge, bridge_channel, frame);
+		break;
 	case AST_FRAME_CONTROL:
 		res = softmix_bridge_write_control(bridge, bridge_channel, frame);
 		break;
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 7520c2b..2ac5b88 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -2517,8 +2517,6 @@
 			data->session->inv_session->cause,
 			pjsip_get_status_text(data->session->inv_session->cause)->ptr);
 	} else {
-		ast_debug(3, "Sending in dialog SIP message\n");
-
 		ast_sip_create_request("MESSAGE", data->session->inv_session->dlg, data->session->endpoint, NULL, NULL, &tdata);
 		ast_sip_add_body(tdata, &body);
 		ast_sip_send_request(tdata, data->session->inv_session->dlg, data->session->endpoint, NULL, NULL);
@@ -2537,6 +2535,8 @@
 	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast);
 	struct sendtext_data *data = sendtext_data_create(channel->session, text);
 
+	ast_debug(3, "Sending MESSAGE to %s: %s\n", ast_channel_name(ast), text);
+
 	if (!data) {
 		return -1;
 	}
diff --git a/main/bridge_channel.c b/main/bridge_channel.c
index 89e5571..71e9c53 100644
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -1053,7 +1053,10 @@
 		bridge_frame_free(dup);
 		return 0;
 	}
-
+	if (fr->frametype == AST_FRAME_TEXT) {
+		ast_debug(3, "Queuing TEXT frame to %s: %*.s\n", ast_channel_name(bridge_channel->chan),
+			fr->datalen, (char *)fr->data.ptr);
+	}
 	AST_LIST_INSERT_TAIL(&bridge_channel->wr_queue, dup, frame_list);
 	if (ast_alertpipe_write(bridge_channel->alert_pipe)) {
 		ast_log(LOG_ERROR, "We couldn't write alert pipe for %p(%s)... something is VERY wrong\n",
@@ -2380,6 +2383,7 @@
 	AST_LIST_TRAVERSE_SAFE_END;
 
 	ast_bridge_channel_unlock(bridge_channel);
+
 	if (!fr) {
 		/*
 		 * Wait some to reduce CPU usage from a tight loop
@@ -2403,6 +2407,11 @@
 		break;
 	case AST_FRAME_NULL:
 		break;
+	case AST_FRAME_TEXT:
+		ast_debug(3, "Sending TEXT frame to %s: %*.s\n", ast_channel_name(bridge_channel->chan),
+			fr->datalen, (char *)fr->data.ptr);
+		ast_sendtext(bridge_channel->chan, fr->data.ptr);
+		break;
 	default:
 		/* Assume that there is no mapped stream for this */
 		num = -1;
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index b6e7a64..f8bd39c 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -778,7 +778,7 @@
 		return 0;
 	}
 
-	ast_debug(3, "Received in dialog SIP message\n");
+	ast_debug(3, "Received in-dialog MESSAGE from %s: %s\n", ast_channel_name(session->channel), buf);
 
 	memset(&f, 0, sizeof(f));
 	f.frametype = AST_FRAME_TEXT;

-- 
To view, visit https://gerrit.asterisk.org/6617
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idacf5900bfd5f22ab8cd235aa56dfad090d18489
Gerrit-Change-Number: 6617
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170927/c9b46b71/attachment.html>


More information about the asterisk-code-review mailing list