diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 0d47984a5f..df14f2bfd5 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -690,6 +690,7 @@ typedef enum { SWITCH_MESSAGE_INDICATE_PROXY_MEDIA, SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC, SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE, + SWITCH_MESSAGE_INDICATE_AUTOANSWER, SWITCH_MESSAGE_INVALID } switch_core_session_message_types_t; diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 23fbaf23a4..3be030deed 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2347,6 +2347,37 @@ SWITCH_STANDARD_API(uuid_simplify_function) } +#define AUTOANSWER_SYNTAX "" +SWITCH_STANDARD_API(uuid_autoanswer_function) +{ + switch_status_t status = SWITCH_STATUS_SUCCESS; + + if (zstr(cmd)) { + stream->write_function(stream, "-USAGE: %s\n", AUTOANSWER_SYNTAX); + } else { + switch_core_session_message_t msg = { 0 }; + switch_core_session_t *lsession = NULL; + + msg.message_id = SWITCH_MESSAGE_INDICATE_AUTOANSWER; + msg.string_arg = cmd; + msg.from = __FILE__; + + if ((lsession = switch_core_session_locate(cmd))) { + status = switch_core_session_receive_message(lsession, &msg); + switch_core_session_rwunlock(lsession); + } + } + + if (status == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+OK Success\n"); + } else { + stream->write_function(stream, "-ERR Operation Failed\n"); + } + + return SWITCH_STATUS_SUCCESS; +} + + #define DEBUG_AUDIO_SYNTAX " " SWITCH_STANDARD_API(uuid_debug_audio_function) { @@ -4202,6 +4233,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "user_data", "find user data", user_data_function, "@ [var|param|attr] "); SWITCH_ADD_API(commands_api_interface, "user_exists", "find a user", user_exists_function, " "); SWITCH_ADD_API(commands_api_interface, "uuid_audio", "uuid_audio", session_audio_function, AUDIO_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "uuid_autoanswer", "Force a ringing channel offhook", uuid_autoanswer_function, AUTOANSWER_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_break", "Break", break_function, BREAK_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_bridge", "uuid_bridge", uuid_bridge_function, ""); SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX); @@ -4300,6 +4332,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add uuid_audio ::console::list_uuid start write mute"); switch_console_set_complete("add uuid_audio ::console::list_uuid start write level"); switch_console_set_complete("add uuid_audio ::console::list_uuid stop"); + switch_console_set_complete("add uuid_autoanswer ::console::list_uuid"); switch_console_set_complete("add uuid_break ::console::list_uuid all"); switch_console_set_complete("add uuid_break ::console::list_uuid both"); switch_console_set_complete("add uuid_bridge ::console::list_uuid ::console::list_uuid"); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 0f0abfa09a..91432ab672 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1496,6 +1496,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } break; + case SWITCH_MESSAGE_INDICATE_AUTOANSWER: + { + nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), NUTAG_SUBSTATE(nua_substate_active), SIPTAG_EVENT_STR("talk"), TAG_END()); + } + break; case SWITCH_MESSAGE_INDICATE_SIMPLIFY: { char *ref_to, *ref_by; diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 863b928092..46adc7d442 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -555,6 +555,7 @@ static const char *message_names[] = { "PROXY_MEDIA", "APPLICATION_EXEC", "APPLICATION_EXEC_COMPLETE", + "AUTOANSWER", "INVALID" };