summaryrefslogtreecommitdiff
path: root/apps/app_agent_pool.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2014-11-06 19:22:22 +0000
committerRichard Mudgett <rmudgett@digium.com>2014-11-06 19:22:22 +0000
commita2d6e15af88a548517100b8a2c4902c8babb1210 (patch)
treef717c671755315ebbca7a39edb35d0326a468a69 /apps/app_agent_pool.c
parent2878554bccbd279a86b7510d3561f2a82419e469 (diff)
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/ ........ Merged revisions 427508 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@427512 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_agent_pool.c')
-rw-r--r--apps/app_agent_pool.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/apps/app_agent_pool.c b/apps/app_agent_pool.c
index 8e432d175..ad1745d8d 100644
--- a/apps/app_agent_pool.c
+++ b/apps/app_agent_pool.c
@@ -1733,7 +1733,10 @@ static void agent_alert(struct ast_bridge_channel *bridge_channel, const void *p
{
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 @@ static void agent_alert(struct ast_bridge_channel *bridge_channel, const void *p
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)