]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6159 -resolve mod_rayo: prompt, input, output components return hangup cause if...
authorChris Rienzo <chris@rienzo.com>
Wed, 29 Jan 2014 05:41:21 +0000 (00:41 -0500)
committerChris Rienzo <chris@rienzo.com>
Wed, 29 Jan 2014 05:41:21 +0000 (00:41 -0500)
src/mod/event_handlers/mod_rayo/mod_rayo.h
src/mod/event_handlers/mod_rayo/rayo_input_component.c
src/mod/event_handlers/mod_rayo/rayo_output_component.c
src/mod/event_handlers/mod_rayo/rayo_prompt_component.c

index d5dcdc4e8db50090b4cb712cc7b3f508bb9bfc4b..43ed7d3dbc503e1b831f6c0998d6ea6405dcd5df 100644 (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 */
index d5631e43a4e88577bccb8fa1bbe4684c5f6a9194..7941c124fb562ea267a3f9014075b0b9310ae1e9 100644 (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);
index 971dd296cf7df495423f0b6dc6df311fe2f4a7a9..30a4eb025b21047ccf399d333d4b715859a7c0a5 100644 (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);
index 3debe39c3e5b72f4f9098e3b739228e18a418baf..c35b1cfe3d84d5c654711ab404b8ce6616fcb641 100644 (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;