]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add park_state
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 13 Dec 2007 22:17:20 +0000 (22:17 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 13 Dec 2007 22:17:20 +0000 (22:17 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6771 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_ivr.h
src/include/switch_module_interfaces.h
src/include/switch_types.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_dptools/mod_dptools.c
src/switch_channel.c
src/switch_core_state_machine.c
src/switch_ivr.c

index 0dfeebff63829e0d4162c9d85152fb0344b93f17..bbc05e087e5232737efb1a278e8885b8d99d74da 100644 (file)
@@ -719,6 +719,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
                                                                                                                switch_input_args_t *args);
 SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms);
 SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid);
+SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session);
 
 /** @} */
 
index 4611b673f7a56e03172e0759d496223444199b2a..39134a29f22cb7d91be3e9c7f918b9ea378b9899 100644 (file)
@@ -53,6 +53,7 @@ typedef enum {
        SWITCH_SHN_ON_HANGUP,
        SWITCH_SHN_ON_LOOPBACK,
        SWITCH_SHN_ON_TRANSMIT,
+       SWITCH_SHN_ON_PARK,
        SWITCH_SHN_ON_HOLD,
        SWITCH_SHN_ON_HIBERNATE,
        SWITCH_SHN_ON_RESET
@@ -71,6 +72,8 @@ struct switch_state_handler_table {
        switch_state_handler_t on_loopback;
        /*! executed when the state changes to transmit */
        switch_state_handler_t on_transmit;
+       /*! executed when the state changes to park */
+       switch_state_handler_t on_park;
        /*! executed when the state changes to hold */
        switch_state_handler_t on_hold;
        /*! executed when the state changes to hibernate */
index 03c406688685260741f6d4bf8dcd57c05967454b..0f9a5127346d200311b380006abac5ad9c0740c5 100644 (file)
@@ -560,6 +560,7 @@ CS_RING      - Channel is looking for a dialplan
 CS_TRANSMIT  - Channel is in a passive transmit state
 CS_EXECUTE   - Channel is executing it's dialplan 
 CS_LOOPBACK  - Channel is in loopback
+CS_PARK      - Channel is parked
 CS_HOLD                 - Channel is on hold
 CS_HIBERNATE - Channel is in a sleep state
 CS_RESET        - Channel is in a reset state
@@ -574,6 +575,7 @@ typedef enum {
        CS_TRANSMIT,
        CS_EXECUTE,
        CS_LOOPBACK,
+       CS_PARK,
        CS_HOLD,
        CS_HIBERNATE,
        CS_RESET,
index c69ba889413bd21eb14e80cb0945f4c839e255b2..e88185bd1842481fca0342cf9825bba079ca9cd1 100644 (file)
@@ -685,6 +685,29 @@ SWITCH_STANDARD_API(kill_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
+
+#define PARK_SYNTAX "<uuid>"
+SWITCH_STANDARD_API(park_function)
+{
+       switch_core_session_t *ksession = NULL;
+
+       if (session) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       if (!cmd) {
+               stream->write_function(stream, "-USAGE: %s\n", PARK_SYNTAX);
+       } else if ((ksession = switch_core_session_locate(cmd))) {
+               switch_ivr_park_session(ksession);
+               switch_core_session_rwunlock(ksession);
+               stream->write_function(stream, "+OK\n");
+       } else {
+               stream->write_function(stream, "-ERR No Such Channel!\n");
+       }
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
 #define TRANSFER_SYNTAX "<uuid> [-bleg|-both] <dest-exten> [<dialplan>] [<context>]"
 SWITCH_STANDARD_API(transfer_function)
 {
@@ -1994,11 +2017,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
 
        SWITCH_ADD_API(commands_api_interface, "originate", "Originate a Call", originate_function, ORIGINATE_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "tone_detect", "Start Tone Detection on a channel", tone_detect_session_function, TONE_DETECT_SYNTAX);
-       SWITCH_ADD_API(commands_api_interface, "killchan", "Kill Channel", kill_function, KILL_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "killchan", "Kill Channel (depricated)", kill_function, KILL_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_kill", "Kill Channel", kill_function, KILL_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_park", "Park Channel", park_function, PARK_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "reloadxml", "Reload XML", reload_function, "");
        SWITCH_ADD_API(commands_api_interface, "unload", "Unload Module", unload_function, LOAD_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "load", "Load Module", load_function, LOAD_SYNTAX);
-       SWITCH_ADD_API(commands_api_interface, "transfer", "Transfer Module", transfer_function, TRANSFER_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "transfer", "Transfer (depricated)", transfer_function, TRANSFER_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_transfer", "Transfer a session", transfer_function, TRANSFER_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "pause", "Pause", pause_function, PAUSE_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "break", "Break", break_function, BREAK_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "show", "Show", show_function, SHOW_SYNTAX);
@@ -2008,11 +2034,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "uuid_getvar", "uuid_getvar", uuid_getvar_function, GETVAR_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "global_setvar", "global_setvar", global_setvar_function, GLOBAL_SETVAR_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "global_getvar", "global_getvar", global_getvar_function, GLOBAL_GETVAR_SYNTAX);
-       SWITCH_ADD_API(commands_api_interface, "session_displace", "session displace", session_displace_function, "<uuid> [start|stop] <path> [<limit>] [mux]");
-       SWITCH_ADD_API(commands_api_interface, "session_record", "session record", session_record_function, SESS_REC_SYNTAX);
-       SWITCH_ADD_API(commands_api_interface, "broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX);
-       SWITCH_ADD_API(commands_api_interface, "hold", "hold", uuid_hold_function, HOLD_SYNTAX);
-       SWITCH_ADD_API(commands_api_interface, "media", "media", uuid_media_function, MEDIA_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "session_displace", "session displace (depricated)", 
+                                  session_displace_function, "<uuid> [start|stop] <path> [<limit>] [mux]");
+       SWITCH_ADD_API(commands_api_interface, "uuid_displace", "session displace", session_displace_function, "<uuid> [start|stop] <path> [<limit>] [mux]");
+       SWITCH_ADD_API(commands_api_interface, "session_record", "session record (depricated)", session_record_function, SESS_REC_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_record", "session record", session_record_function, SESS_REC_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "broadcast", "broadcast (depricated)", uuid_broadcast_function, BROADCAST_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "hold", "hold (depricated)", uuid_hold_function, HOLD_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "media", "media (depricated)", uuid_media_function, MEDIA_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid media", "media", uuid_media_function, MEDIA_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "help", "Show help for all the api commands", help_function, "");
        SWITCH_ADD_API(commands_api_interface, "version", "Show version of the switch", version_function, "");
index 2ebe74375f3db63ab152ac76bd6bd7f2e3738872..f7ac9ee165c87392867a2ee3a95b5aa75ba4de8b 100644 (file)
@@ -1027,6 +1027,12 @@ SWITCH_STANDARD_APP(park_function)
 
 }
 
+SWITCH_STANDARD_APP(park_state_function)
+{
+       switch_ivr_park_session(session);
+
+}
+
 /********************************************************************************/
 /*                                             Playback/Record Functions                                                               */
 /********************************************************************************/
@@ -1637,7 +1643,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
        SWITCH_ADD_APP(app_interface, "fax_detect", "Detect faxes", "Detect fax send tone", fax_detect_session_function, "", SAF_NONE);
        SWITCH_ADD_APP(app_interface, "tone_detect", "Detect tones", "Detect tones", tone_detect_session_function, "", SAF_NONE);
        SWITCH_ADD_APP(app_interface, "echo", "Echo", "Perform an echo test against the calling channel", echo_function, "", SAF_NONE);
-       SWITCH_ADD_APP(app_interface, "park", NULL, NULL, park_function, NULL, SAF_NONE);
+       SWITCH_ADD_APP(app_interface, "park", "Park", "Park", park_function, "", SAF_NONE);
+       SWITCH_ADD_APP(app_interface, "park_state", "Park State", "Park State", park_state_function, "", SAF_NONE);
        SWITCH_ADD_APP(app_interface, "gentones", "Generate Tones", "Generate tones to the channel", gentones_function, "<tgml_script>[|<loops>]", SAF_NONE);
        SWITCH_ADD_APP(app_interface, "playback", "Playback File", "Playback a file to the channel", playback_function, "<path>", SAF_NONE);
        SWITCH_ADD_APP(app_interface, "stop_record_session", "Stop Record Session", STOP_SESS_REC_DESC, stop_record_session_function, "<path>", SAF_NONE);
index 1a2f715e6bc28a3b1df0901b0e9605fae31f691b..3e6556c4776ed8101d6da79c9917bde01d6c8c3a 100644 (file)
@@ -553,6 +553,7 @@ static const char *state_names[] = {
        "CS_TRANSMIT",
        "CS_EXECUTE",
        "CS_LOOPBACK",
+       "CS_PARK",
        "CS_HOLD",
        "CS_HIBERNATE",
        "CS_RESET",
@@ -666,6 +667,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                case CS_TRANSMIT:
                case CS_RING:
                case CS_EXECUTE:
+               case CS_PARK:
                case CS_HOLD:
                case CS_HIBERNATE:
                case CS_RESET:
@@ -680,6 +682,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                case CS_TRANSMIT:
                case CS_RING:
                case CS_EXECUTE:
+               case CS_PARK:
                case CS_HOLD:
                case CS_HIBERNATE:
                case CS_RESET:
@@ -694,6 +697,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                case CS_LOOPBACK:
                case CS_RING:
                case CS_EXECUTE:
+               case CS_PARK:
                case CS_HOLD:
                case CS_HIBERNATE:
                case CS_RESET:
@@ -703,6 +707,21 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                }
                break;
 
+       case CS_PARK:
+               switch (state) {
+               case CS_LOOPBACK:
+               case CS_RING:
+               case CS_EXECUTE:
+               case CS_TRANSMIT:
+               case CS_HIBERNATE:
+               case CS_RESET:
+               case CS_HOLD:
+                       ok++;
+               default:
+                       break;
+               }
+               break;
+
        case CS_HOLD:
                switch (state) {
                case CS_LOOPBACK:
@@ -711,6 +730,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                case CS_TRANSMIT:
                case CS_HIBERNATE:
                case CS_RESET:
+               case CS_PARK:
                        ok++;
                default:
                        break;
@@ -723,6 +743,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                case CS_RING:
                case CS_EXECUTE:
                case CS_TRANSMIT:
+               case CS_PARK:
                case CS_HOLD:
                case CS_RESET:
                        ok++;
@@ -737,6 +758,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                case CS_LOOPBACK:
                case CS_EXECUTE:
                case CS_TRANSMIT:
+               case CS_PARK:
                case CS_HOLD:
                case CS_HIBERNATE:
                case CS_RESET:
@@ -751,6 +773,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                case CS_LOOPBACK:
                case CS_TRANSMIT:
                case CS_RING:
+               case CS_PARK:
                case CS_HOLD:
                case CS_HIBERNATE:
                case CS_RESET:
index d608f78699be3b1ee8ea67114e0fab91519a1412..2b7e65edf4530278e697890f2ba5417bdd54b431 100644 (file)
@@ -205,6 +205,15 @@ static void switch_core_standard_on_transmit(switch_core_session_t *session)
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard TRANSMIT\n");
 }
 
+static void switch_core_standard_on_park(switch_core_session_t *session)
+{
+       switch_assert(session != NULL);
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard PARK\n");
+       switch_channel_clear_flag(session->channel, CF_TRANSFER);
+       switch_core_session_reset(session);
+       switch_ivr_park(session, NULL);
+}
+
 static void switch_core_standard_on_hold(switch_core_session_t *session)
 {
        switch_assert(session != NULL);
@@ -419,6 +428,9 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
                        case CS_TRANSMIT:       /* send/recieve data to/from another channel */
                                STATE_MACRO(transmit, "TRANSMIT");
                                break;
+                       case CS_PARK:           /* wait in limbo */
+                               STATE_MACRO(park, "PARK");
+                               break;
                        case CS_HOLD:           /* wait in limbo */
                                STATE_MACRO(hold, "HOLD");
                                break;
index d9fea5ed3180f13bb1d6f1d2afc255116bf8bef6..693f0fb8efe15a8bad8b759b326a48ef5e1285ca 100644 (file)
@@ -1494,6 +1494,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_
        return SWITCH_STATUS_FALSE;
 }
 
+SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session)
+{
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       switch_channel_set_state_flag(channel, CF_TRANSFER);
+       switch_channel_set_state(channel, CS_PARK);
+}
+
 SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms)
 {
        stfu_instance_t *jb;