[asterisk-commits] bridge core: Add owed T.38 terminate when channel leaves a b... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 1 06:00:28 CST 2016


Joshua Colp has submitted this change and it was merged.

Change subject: bridge core: Add owed T.38 terminate when channel leaves a bridge.
......................................................................


bridge core: Add owed T.38 terminate when channel leaves a bridge.

The channel is now going to get T.38 terminated when it leaves the
bridging system and the bridged peers are going to get T.38 terminated as
well.

ASTERISK-25582

Change-Id: I77a9205979910210e3068e1ddff400dbf35c4ca7
---
M include/asterisk/bridge_channel.h
M main/bridge_channel.c
M main/channel.c
3 files changed, 72 insertions(+), 0 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, approved
  Joshua Colp: Looks good to me, but someone else must approve; Verified



diff --git a/include/asterisk/bridge_channel.h b/include/asterisk/bridge_channel.h
index 66f9be6..797be4e 100644
--- a/include/asterisk/bridge_channel.h
+++ b/include/asterisk/bridge_channel.h
@@ -162,6 +162,8 @@
 		struct timeval dtmf_tv;
 		/*! Digit currently sending into the bridge. (zero if not sending) */
 		char dtmf_digit;
+		/*! Non-zero if a T.38 session terminate is owed to the bridge. */
+		char t38_terminate;
 	} owed;
 	/*! DTMF hook sequence state */
 	struct {
diff --git a/main/bridge_channel.c b/main/bridge_channel.c
index 3f14145..8172660 100644
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -637,6 +637,8 @@
  */
 static int bridge_channel_write_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
+	const struct ast_control_t38_parameters *t38_parameters;
+
 	ast_assert(frame->frametype != AST_FRAME_BRIDGE_ACTION_SYNC);
 
 	ast_bridge_channel_lock_bridge(bridge_channel);
@@ -663,6 +665,27 @@
 		 * We explicitly will not remember HOLD/UNHOLD frames because
 		 * things like attended transfers will handle them.
 		 */
+		switch (frame->subclass.integer) {
+		case AST_CONTROL_T38_PARAMETERS:
+			t38_parameters = frame->data.ptr;
+			switch (t38_parameters->request_response) {
+			case AST_T38_REQUEST_NEGOTIATE:
+			case AST_T38_NEGOTIATED:
+				bridge_channel->owed.t38_terminate = 1;
+				break;
+			case AST_T38_REQUEST_TERMINATE:
+			case AST_T38_TERMINATED:
+			case AST_T38_REFUSED:
+				bridge_channel->owed.t38_terminate = 0;
+				break;
+			default:
+				break;
+			}
+			break;
+		default:
+			break;
+		}
+		break;
 	default:
 		break;
 	}
@@ -689,6 +712,7 @@
 static void bridge_channel_cancel_owed_events(struct ast_bridge_channel *bridge_channel)
 {
 	bridge_channel->owed.dtmf_digit = '\0';
+	bridge_channel->owed.t38_terminate = 0;
 }
 
 void bridge_channel_settle_owed_events(struct ast_bridge *orig_bridge, struct ast_bridge_channel *bridge_channel)
@@ -708,6 +732,23 @@
 			bridge_channel->owed.dtmf_digit, orig_bridge->uniqueid,
 			ast_channel_name(bridge_channel->chan), frame.len);
 		bridge_channel->owed.dtmf_digit = '\0';
+		orig_bridge->technology->write(orig_bridge, NULL, &frame);
+	}
+	if (bridge_channel->owed.t38_terminate) {
+		struct ast_control_t38_parameters t38_parameters = {
+			.request_response = AST_T38_TERMINATED,
+		};
+		struct ast_frame frame = {
+			.frametype = AST_FRAME_CONTROL,
+			.subclass.integer = AST_CONTROL_T38_PARAMETERS,
+			.data.ptr = &t38_parameters,
+			.datalen = sizeof(t38_parameters),
+			.src = "Bridge channel owed T.38 terminate",
+		};
+
+		ast_debug(1, "T.38 terminate simulated to bridge %s because %s left.\n",
+			orig_bridge->uniqueid, ast_channel_name(bridge_channel->chan));
+		bridge_channel->owed.t38_terminate = 0;
 		orig_bridge->technology->write(orig_bridge, NULL, &frame);
 	}
 }
@@ -2736,6 +2777,18 @@
 			ast_channel_sending_dtmf_tv(bridge_channel->chan), "bridge end");
 	}
 
+	/* Complete any T.38 session before exiting the bridge. */
+	if (ast_channel_is_t38_active(bridge_channel->chan)) {
+		struct ast_control_t38_parameters t38_parameters = {
+			.request_response = AST_T38_TERMINATED,
+		};
+
+		ast_debug(1, "Channel %s simulating T.38 terminate for bridge end.\n",
+			ast_channel_name(bridge_channel->chan));
+		ast_indicate_data(bridge_channel->chan, AST_CONTROL_T38_PARAMETERS,
+			&t38_parameters, sizeof(t38_parameters));
+	}
+
 	/* Indicate a source change since this channel is leaving the bridge system. */
 	ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
 
diff --git a/main/channel.c b/main/channel.c
index f9addb0..852de1a 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -4479,6 +4479,7 @@
 	 * in switch statements. */
 	enum ast_control_frame_type condition = _condition;
 	struct ast_tone_zone_sound *ts = NULL;
+	const struct ast_control_t38_parameters *t38_parameters;
 	int res;
 
 	switch (condition) {
@@ -4498,6 +4499,22 @@
 	case AST_CONTROL_UNHOLD:
 		ast_channel_hold_state_set(chan, _condition);
 		break;
+	case AST_CONTROL_T38_PARAMETERS:
+		t38_parameters = data;
+		switch (t38_parameters->request_response) {
+		case AST_T38_REQUEST_NEGOTIATE:
+		case AST_T38_NEGOTIATED:
+			ast_channel_set_is_t38_active_nolock(chan, 1);
+			break;
+		case AST_T38_REQUEST_TERMINATE:
+		case AST_T38_TERMINATED:
+		case AST_T38_REFUSED:
+			ast_channel_set_is_t38_active_nolock(chan, 0);
+			break;
+		default:
+			break;
+		}
+		break;
 	default:
 		break;
 	}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I77a9205979910210e3068e1ddff400dbf35c4ca7
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list