add park_state

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6771 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-12-13 22:17:20 +00:00
parent 3953014f24
commit 911db88a6e
8 changed files with 95 additions and 8 deletions

View 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);
/** @} */

View 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 */

View 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,

View 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, "");

View 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);

View 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:

View 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;

View 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;