[asterisk-commits] rmudgett: branch 12 r427508 - /branches/12/apps/app_agent_pool.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 6 13:21:29 CST 2014


Author: rmudgett
Date: Thu Nov  6 13:21:26 2014
New Revision: 427508

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=427508
Log:
app_agent_pool: Made agent alert interruptable by DTMF.

Made agent able to interrupt the alerting beep playback with DTMF.  Any
digit can interrupt if the call does not need to be acknowledged.  Only
the first digit of the acknowledgement can interrupt if the call needs to
be acknowledged.  The agent interrupting the alerting playback builds on
the ASTERISK-24447 patch because it knows what digit interrupted the
playback and needs to be able to pass that digit to the DTMF hook digit
collection code.

ASTERISK-24257 #close
Reported by: Steve Pitts

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

Modified:
    branches/12/apps/app_agent_pool.c

Modified: branches/12/apps/app_agent_pool.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/app_agent_pool.c?view=diff&rev=427508&r1=427507&r2=427508
==============================================================================
--- branches/12/apps/app_agent_pool.c (original)
+++ branches/12/apps/app_agent_pool.c Thu Nov  6 13:21:26 2014
@@ -1733,7 +1733,10 @@
 {
 	const char *agent_id = payload;
 	const char *playfile;
-	RAII_VAR(struct agent_pvt *, agent, NULL, ao2_cleanup);
+	const char *dtmf_accept;
+	struct agent_pvt *agent;
+	int digit;
+	char dtmf[2];
 
 	agent = ao2_find(agents, agent_id, OBJ_KEY);
 	if (!agent) {
@@ -1748,30 +1751,56 @@
 	ast_bridge_channel_establish_roles(bridge_channel);
 	ast_bridge_unlock(bridge_channel->bridge);
 
-	/* Alert the agent. */
 	agent_lock(agent);
 	playfile = ast_strdupa(agent->cfg->beep_sound);
+
+	/* Determine which DTMF digits interrupt the alerting signal. */
+	if (ast_test_flag(agent, AGENT_FLAG_ACK_CALL)
+		? agent->override_ack_call : agent->cfg->ack_call) {
+		dtmf_accept = ast_test_flag(agent, AGENT_FLAG_DTMF_ACCEPT)
+			? agent->override_dtmf_accept : agent->cfg->dtmf_accept;
+
+		/* Only the first digit of the ack will stop playback. */
+		dtmf[0] = *dtmf_accept;
+		dtmf[1] = '\0';
+		dtmf_accept = dtmf;
+	} else {
+		dtmf_accept = NULL;
+	}
 	agent_unlock(agent);
-	ast_stream_and_wait(bridge_channel->chan, playfile, AST_DIGIT_NONE);
+
+	/* Alert the agent. */
+	digit = ast_stream_and_wait(bridge_channel->chan, playfile,
+		ast_strlen_zero(dtmf_accept) ? AST_DIGIT_ANY : dtmf_accept);
+	ast_stopstream(bridge_channel->chan);
 
 	agent_lock(agent);
 	switch (agent->state) {
 	case AGENT_STATE_CALL_PRESENT:
-		if (ast_test_flag(agent, AGENT_FLAG_ACK_CALL)
-			? agent->override_ack_call : agent->cfg->ack_call) {
+		if (!ast_strlen_zero(dtmf_accept)) {
 			agent->state = AGENT_STATE_CALL_WAIT_ACK;
 			agent->ack_time = ast_tvnow();
+
+			if (0 < digit) {
+				/* Playback was interrupted by a digit. */
+				agent_unlock(agent);
+				ao2_ref(agent, -1);
+				ast_bridge_channel_feature_digit(bridge_channel, digit);
+				return;
+			}
 			break;
 		}
 
 		/* Connect to caller now. */
 		ast_debug(1, "Agent %s: Immediately connecting to call.\n", agent->username);
 		agent_connect_caller(bridge_channel, agent);/* Will unlock agent. */
+		ao2_ref(agent, -1);
 		return;
 	default:
 		break;
 	}
 	agent_unlock(agent);
+	ao2_ref(agent, -1);
 }
 
 static int send_alert_to_agent(struct ast_bridge_channel *bridge_channel, const char *agent_id)




More information about the asterisk-commits mailing list