FS-6159 -resolve mod_rayo: prompt, input, output components return hangup cause if stopped by hangup

This commit is contained in:
Chris Rienzo 2014-01-29 00:41:21 -05:00
parent 915e8eaba1
commit 5be81aef74
4 changed files with 32 additions and 11 deletions

View File

@ -114,8 +114,6 @@ struct rayo_actor {
struct rayo_component {
/** base actor class */
struct rayo_actor base;
/** component type (input/output/prompt/etc) */
const char *type;
/** parent to this component */
struct rayo_actor *parent;
/** owning client JID */

View File

@ -1,6 +1,6 @@
/*
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013, Grasshopper
* Copyright (C) 2013-2014, Grasshopper
*
* Version: MPL 1.1
*
@ -360,7 +360,7 @@ static switch_bool_t input_handler_bug_callback(switch_media_bug_t *bug, void *u
const void *jid;
void *component;
switch_core_hash_this(hi, &jid, NULL, &component);
rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP);
rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_HANGUP);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Removing DTMF callback\n");
switch_core_event_hook_remove_recv_dtmf(session, input_handler_on_dtmf);

View File

@ -516,9 +516,26 @@ static switch_status_t rayo_file_close(switch_file_handle_t *handle)
if (output->stop) {
rayo_component_send_complete(context->component, COMPONENT_COMPLETE_STOP);
} else {
rayo_component_send_complete(context->component, OUTPUT_FINISH);
if (!strcmp(RAYO_ACTOR(context->component)->type, RAT_CALL_COMPONENT)) {
/* call output... check for hangup */
switch_core_session_t *session = switch_core_session_locate(context->component->parent->id);
if (session) {
if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) {
rayo_component_send_complete(context->component, COMPONENT_COMPLETE_HANGUP);
} else {
rayo_component_send_complete(context->component, OUTPUT_FINISH);
}
switch_core_session_rwunlock(session);
} else {
/* session is gone */
rayo_component_send_complete(context->component, COMPONENT_COMPLETE_HANGUP);
}
} else {
/* mixer output... finished */
rayo_component_send_complete(context->component, OUTPUT_FINISH);
}
}
/* TODO hangup / timed out */
/* TODO timed out */
/* cleanup internals */
switch_safe_free(context->ssml);

View File

@ -192,14 +192,12 @@ static iks *prompt_component_handle_input_start(struct rayo_actor *prompt, struc
PROMPT_COMPONENT(prompt)->state = PCS_INPUT_OUTPUT;
/* send ref to client */
rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq);
iks_delete(PROMPT_COMPONENT(prompt)->iq);
break;
case PCS_START_INPUT_TIMERS:
PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid);
PROMPT_COMPONENT(prompt)->state = PCS_INPUT;
/* send ref to client */
rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq);
iks_delete(PROMPT_COMPONENT(prompt)->iq);
start_input_timers(PROMPT_COMPONENT(prompt));
break;
case PCS_DONE:
@ -272,16 +270,22 @@ static iks *prompt_component_handle_input_error(struct rayo_actor *prompt, struc
RAYO_SEND_REPLY(prompt, RAYO_COMPONENT(prompt)->client_jid, iq);
/* done */
iks_delete(PROMPT_COMPONENT(prompt)->iq);
RAYO_UNLOCK(prompt);
RAYO_DESTROY(prompt);
break;
case PCS_START_INPUT:
/* send presence error to client */
PROMPT_COMPONENT(prompt)->state = PCS_DONE;
iks_delete(PROMPT_COMPONENT(prompt)->iq);
rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_ERROR);
if (iks_find(error, "item-not-found")) {
/* call is gone (hangup) */
rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_HANGUP);
} else {
/* send presence error to client */
rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_ERROR);
}
break;
case PCS_START_INPUT_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT;
@ -335,6 +339,7 @@ static iks *prompt_component_handle_output_error(struct rayo_actor *prompt, stru
RAYO_SEND_REPLY(prompt, RAYO_COMPONENT(prompt)->client_jid, iq);
/* done */
iks_delete(PROMPT_COMPONENT(prompt)->iq);
RAYO_UNLOCK(prompt);
RAYO_DESTROY(prompt);
@ -421,6 +426,7 @@ static iks *prompt_component_handle_input_complete(struct rayo_actor *prompt, st
presence = iks_copy(presence);
iks_insert_attrib(presence, "from", RAYO_JID(prompt));
iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid);
iks_delete(PROMPT_COMPONENT(prompt)->iq);
rayo_component_send_complete_event(RAYO_COMPONENT(prompt), presence);
break;
case PCS_OUTPUT:
@ -466,7 +472,6 @@ static iks *prompt_component_handle_output_complete(struct rayo_actor *prompt, s
PROMPT_COMPONENT(prompt)->state = PCS_START_INPUT;
/* start input with timers enabled and barge events disabled */
start_input(PROMPT_COMPONENT(prompt), 1, 0);
iks_delete(PROMPT_COMPONENT(prompt)->iq);
break;
case PCS_START_INPUT_OUTPUT:
/* output finished before input started */
@ -482,6 +487,7 @@ static iks *prompt_component_handle_output_complete(struct rayo_actor *prompt, s
break;
case PCS_DONE_STOP_OUTPUT:
if (PROMPT_COMPONENT(prompt)->complete) {
iks_delete(PROMPT_COMPONENT(prompt)->iq);
rayo_component_send_complete_event(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->complete);
}
break;