diff --git a/src/include/switch_types.h b/src/include/switch_types.h index bfe5adde70..baa8271b2f 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -102,6 +102,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_URL_SEPARATOR "://" #define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE "proto_specific_hangup_cause" #define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE "execute_on_answer" +#define SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE "execute_on_ring" #define SWITCH_CALL_TIMEOUT_VARIABLE "call_timeout" #define SWITCH_HOLDING_UUID_VARIABLE "holding_uuid" #define SWITCH_API_BRIDGE_END_VARIABLE "api_after_bridge" diff --git a/src/switch_channel.c b/src/switch_channel.c index c670e7b9d3..5a469b8670 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1369,6 +1369,9 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line) { + const char *var; + char *app; + if (!switch_channel_test_flag(channel, CF_RING_READY)) { switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name); switch_channel_set_flag(channel, CF_RING_READY); @@ -1377,6 +1380,18 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch channel->caller_profile->times->progress = switch_timestamp_now(); switch_mutex_unlock(channel->profile_mutex); } + + var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE); + if (var) { + char *arg = NULL; + app = switch_core_session_strdup(channel->session, var); + if ((arg = strchr(app, ' '))) { + *arg++ = '\0'; + } + switch_core_session_execute_application(channel->session, app, arg); + } + + return SWITCH_STATUS_SUCCESS; }