mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
add block_dtmf and unblock_dtmf apps
This commit is contained in:
@@ -2180,6 +2180,7 @@ typedef struct {
|
||||
} dtmf_meta_data_t;
|
||||
|
||||
#define SWITCH_META_VAR_KEY "__dtmf_meta"
|
||||
#define SWITCH_BLOCK_DTMF_KEY "__dtmf_block"
|
||||
|
||||
typedef struct {
|
||||
switch_core_session_t *session;
|
||||
@@ -2355,6 +2356,44 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t block_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
uint8_t enabled = (intptr_t)switch_channel_get_private(channel, SWITCH_BLOCK_DTMF_KEY);
|
||||
|
||||
if (!enabled || switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_unblock_dtmf_session(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
uint8_t enabled = (intptr_t)switch_channel_get_private(channel, SWITCH_BLOCK_DTMF_KEY);
|
||||
|
||||
if (enabled) {
|
||||
switch_channel_set_private(channel, SWITCH_BLOCK_DTMF_KEY, NULL);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_block_dtmf_session(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
uint8_t enabled = (intptr_t)switch_channel_get_private(channel, SWITCH_BLOCK_DTMF_KEY);
|
||||
|
||||
if (!enabled) {
|
||||
switch_channel_set_private(channel, SWITCH_BLOCK_DTMF_KEY, (void *)(intptr_t)1);
|
||||
switch_core_event_hook_add_send_dtmf(session, block_on_dtmf);
|
||||
switch_core_event_hook_add_recv_dtmf(session, block_on_dtmf);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key,
|
||||
switch_bind_flag_t bind_flags, const char *app)
|
||||
{
|
||||
|
Reference in New Issue
Block a user