diff --git a/src/include/switch_types.h b/src/include/switch_types.h index e71570c21d..b9e1d47a6f 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -155,6 +155,8 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE "execute_on_originate" #define SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE "execute_on_post_originate" #define SWITCH_CHANNEL_EXECUTE_ON_PRE_ORIGINATE_VARIABLE "execute_on_pre_originate" +#define SWITCH_CHANNEL_EXECUTE_ON_HOLD_VARIABLE "execute_on_hold" +#define SWITCH_CHANNEL_EXECUTE_ON_UNHOLD_VARIABLE "execute_on_unhold" #define SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE "execute_on_pre_bridge" #define SWITCH_CHANNEL_EXECUTE_ON_POST_BRIDGE_VARIABLE "execute_on_post_bridge" @@ -167,6 +169,8 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE "api_on_originate" #define SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE "api_on_post_originate" #define SWITCH_CHANNEL_API_ON_PRE_ORIGINATE_VARIABLE "api_on_pre_originate" +#define SWITCH_CHANNEL_API_ON_HOLD_VARIABLE "api_on_hold" +#define SWITCH_CHANNEL_API_ON_UNHOLD_VARIABLE "api_on_unhold" #define SWITCH_CALL_TIMEOUT_VARIABLE "call_timeout" #define SWITCH_HOLDING_UUID_VARIABLE "holding_uuid" diff --git a/src/switch_channel.c b/src/switch_channel.c index 66e18a323c..9a290fa44d 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -868,8 +868,12 @@ SWITCH_DECLARE(void) switch_channel_mark_hold(switch_channel_t *channel, switch_ if (on) { switch_channel_set_flag(channel, CF_LEG_HOLDING); + switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_HOLD_VARIABLE); + switch_channel_api_on(channel, SWITCH_CHANNEL_API_ON_HOLD_VARIABLE); } else { switch_channel_clear_flag(channel, CF_LEG_HOLDING); + switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_UNHOLD_VARIABLE); + switch_channel_api_on(channel, SWITCH_CHANNEL_API_ON_UNHOLD_VARIABLE); } if (switch_event_create(&event, on ? SWITCH_EVENT_CHANNEL_HOLD : SWITCH_EVENT_CHANNEL_UNHOLD) == SWITCH_STATUS_SUCCESS) { diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 1443f989cf..bba12cf20d 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1555,12 +1555,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, } } + switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_HOLD_VARIABLE); + switch_channel_api_on(channel, SWITCH_CHANNEL_API_ON_HOLD_VARIABLE); + if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HOLD) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); switch_event_fire(&event); } - return SWITCH_STATUS_SUCCESS; } @@ -1634,6 +1636,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session switch_core_session_rwunlock(b_session); } + switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_UNHOLD_VARIABLE); + switch_channel_api_on(channel, SWITCH_CHANNEL_API_ON_UNHOLD_VARIABLE); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNHOLD) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event);