mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-06 07:29:30 +00:00
add bind meta on A-D and refactor
This commit is contained in:
parent
96ac90adce
commit
27869d7a26
@ -256,6 +256,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner_var_check(sw
|
|||||||
const char *varname, const char *value, switch_bool_t var_check);
|
const char *varname, const char *value, switch_bool_t var_check);
|
||||||
SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname);
|
SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname);
|
||||||
|
|
||||||
|
SWITCH_DECLARE(const char *) switch_channel_get_hold_music(switch_channel_t *channel);
|
||||||
|
SWITCH_DECLARE(const char *) switch_channel_get_hold_music_partner(switch_channel_t *channel);
|
||||||
|
|
||||||
#define switch_channel_set_variable(_channel, _var, _val) switch_channel_set_variable_var_check(_channel, _var, _val, SWITCH_TRUE)
|
#define switch_channel_set_variable(_channel, _var, _val) switch_channel_set_variable_var_check(_channel, _var, _val, SWITCH_TRUE)
|
||||||
#define switch_channel_set_variable_partner(_channel, _var, _val) switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE)
|
#define switch_channel_set_variable_partner(_channel, _var, _val) switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE)
|
||||||
|
@ -156,6 +156,7 @@ SWITCH_BEGIN_EXTERN_C
|
|||||||
#define SWITCH_PROXY_MEDIA_VARIABLE "proxy_media"
|
#define SWITCH_PROXY_MEDIA_VARIABLE "proxy_media"
|
||||||
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition"
|
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition"
|
||||||
#define SWITCH_HOLD_MUSIC_VARIABLE "hold_music"
|
#define SWITCH_HOLD_MUSIC_VARIABLE "hold_music"
|
||||||
|
#define SWITCH_TEMP_HOLD_MUSIC_VARIABLE "temp_hold_music"
|
||||||
#define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
|
#define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
|
||||||
#define SWITCH_BRIDGE_EXPORT_VARS_VARIABLE "bridge_export_vars"
|
#define SWITCH_BRIDGE_EXPORT_VARS_VARIABLE "bridge_export_vars"
|
||||||
#define SWITCH_R_SDP_VARIABLE "switch_r_sdp"
|
#define SWITCH_R_SDP_VARIABLE "switch_r_sdp"
|
||||||
|
@ -184,6 +184,32 @@ static inline switch_bool_t switch_is_digit_string(const char *s)
|
|||||||
return SWITCH_TRUE;
|
return SWITCH_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline char switch_itodtmf(char i)
|
||||||
|
{
|
||||||
|
char r = i;
|
||||||
|
|
||||||
|
if (i > 9 && i < 14) {
|
||||||
|
r = i + 55;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int switch_dtmftoi(char *s)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
switch_assert(s);
|
||||||
|
|
||||||
|
if (!(r = atoi(s))) {
|
||||||
|
int l = tolower(*s);
|
||||||
|
if (l > 96 && l < 101) {
|
||||||
|
r = l - 87;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint32_t switch_known_bitrate(switch_payload_t payload)
|
static inline uint32_t switch_known_bitrate(switch_payload_t payload)
|
||||||
{
|
{
|
||||||
|
@ -389,7 +389,7 @@ SWITCH_STANDARD_APP(dtmf_unbind_function)
|
|||||||
int kval = 0;
|
int kval = 0;
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
kval = atoi(key);
|
kval = switch_dtmftoi(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_ivr_unbind_dtmf_meta_session(session, kval);
|
switch_ivr_unbind_dtmf_meta_session(session, kval);
|
||||||
@ -405,7 +405,7 @@ SWITCH_STANDARD_APP(dtmf_bind_function)
|
|||||||
|
|
||||||
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
|
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
|
||||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
|
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
|
||||||
int kval = atoi(argv[0]);
|
int kval = switch_dtmftoi(argv[0]);
|
||||||
switch_bind_flag_t bind_flags = 0;
|
switch_bind_flag_t bind_flags = 0;
|
||||||
|
|
||||||
if (strchr(argv[1], 'a')) {
|
if (strchr(argv[1], 'a')) {
|
||||||
@ -2531,7 +2531,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
|
|||||||
camp_data = (char *) data;
|
camp_data = (char *) data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(moh = switch_channel_get_variable(caller_channel, "hold_music"))) {
|
if (!(moh = switch_channel_get_variable(caller_channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
|
||||||
moh = switch_channel_get_variable(caller_channel, "campon_hold_music");
|
moh = switch_channel_get_variable(caller_channel, "campon_hold_music");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,12 +397,12 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit
|
|||||||
const char *moh_a = NULL, *moh_b = NULL;
|
const char *moh_a = NULL, *moh_b = NULL;
|
||||||
|
|
||||||
if (!(moh_b = switch_channel_get_variable(bchan, "fifo_music"))) {
|
if (!(moh_b = switch_channel_get_variable(bchan, "fifo_music"))) {
|
||||||
moh_b = switch_channel_get_variable(bchan, "hold_music");
|
moh_b = switch_channel_get_variable(bchan, SWITCH_HOLD_MUSIC_VARIABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(moh_a = switch_channel_get_variable(channel, "fifo_hold_music"))) {
|
if (!(moh_a = switch_channel_get_variable(channel, "fifo_hold_music"))) {
|
||||||
if (!(moh_a = switch_channel_get_variable(channel, "fifo_music"))) {
|
if (!(moh_a = switch_channel_get_variable(channel, "fifo_music"))) {
|
||||||
moh_a = switch_channel_get_variable(channel, "hold_music");
|
moh_a = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ static switch_status_t spy_on_exchange_media(switch_core_session_t *session)
|
|||||||
static switch_status_t spy_on_park(switch_core_session_t *session)
|
static switch_status_t spy_on_park(switch_core_session_t *session)
|
||||||
{
|
{
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
const char *moh = switch_channel_get_variable(channel, "hold_music");
|
const char *moh = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
|
||||||
|
|
||||||
while (switch_channel_ready(channel) && switch_channel_get_state(channel) == CS_PARK) {
|
while (switch_channel_ready(channel) && switch_channel_get_state(channel) == CS_PARK) {
|
||||||
if (moh) {
|
if (moh) {
|
||||||
|
@ -234,7 +234,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(tmp = switch_channel_get_variable(channel, "valet_hold_music"))) {
|
if (!(tmp = switch_channel_get_variable(channel, "valet_hold_music"))) {
|
||||||
tmp = switch_channel_get_variable(channel, "hold_music");
|
tmp = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
|
||||||
}
|
}
|
||||||
if (tmp)
|
if (tmp)
|
||||||
music = tmp;
|
music = tmp;
|
||||||
|
@ -1512,7 +1512,7 @@ static switch_status_t load_config(int reload_type)
|
|||||||
hotline = val;
|
hotline = val;
|
||||||
} else if (!strcasecmp(var, "dial_regex")) {
|
} else if (!strcasecmp(var, "dial_regex")) {
|
||||||
dial_regex = val;
|
dial_regex = val;
|
||||||
} else if (!strcasecmp(var, "hold_music")) {
|
} else if (!strcasecmp(var, SWITCH_HOLD_MUSIC_VARIABLE)) {
|
||||||
hold_music = val;
|
hold_music = val;
|
||||||
} else if (!strcasecmp(var, "fail_dial_regex")) {
|
} else if (!strcasecmp(var, "fail_dial_regex")) {
|
||||||
fail_dial_regex = val;
|
fail_dial_regex = val;
|
||||||
|
@ -646,6 +646,30 @@ SWITCH_DECLARE(void) switch_channel_mark_hold(switch_channel_t *channel, switch_
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(const char *) switch_channel_get_hold_music(switch_channel_t *channel)
|
||||||
|
{
|
||||||
|
const char *var = switch_channel_get_variable(channel, SWITCH_TEMP_HOLD_MUSIC_VARIABLE);
|
||||||
|
|
||||||
|
if (!var) {
|
||||||
|
var = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(const char *) switch_channel_get_hold_music_partner(switch_channel_t *channel)
|
||||||
|
{
|
||||||
|
switch_core_session_t *session;
|
||||||
|
const char *r = NULL;
|
||||||
|
|
||||||
|
if (switch_core_session_get_partner(channel->session, &session) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
r = switch_channel_get_hold_music(switch_core_session_get_channel(session));
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup)
|
SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup)
|
||||||
{
|
{
|
||||||
const char *v = NULL, *r = NULL;
|
const char *v = NULL, *r = NULL;
|
||||||
|
@ -2727,7 +2727,7 @@ typedef struct {
|
|||||||
} dtmf_meta_app_t;
|
} dtmf_meta_app_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
dtmf_meta_app_t map[10];
|
dtmf_meta_app_t map[14];
|
||||||
time_t last_digit;
|
time_t last_digit;
|
||||||
switch_bool_t meta_on;
|
switch_bool_t meta_on;
|
||||||
char meta;
|
char meta;
|
||||||
@ -2974,14 +2974,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se
|
|||||||
if (meta != '*' && meta != '#') {
|
if (meta != '*' && meta != '#') {
|
||||||
str[0] = meta;
|
str[0] = meta;
|
||||||
|
|
||||||
if (atoi(str) == (int)key) {
|
if (switch_dtmftoi(str) == (char)key) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid key %u, same as META CHAR\n", key);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid key %u, same as META CHAR\n", key);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (key > 9) {
|
if (key > 13) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid key %u\n", key);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid key %u\n", key);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
@ -3001,7 +3001,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se
|
|||||||
md->sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
|
md->sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
|
||||||
md->sr[SWITCH_DTMF_RECV].map[key].bind_flags = bind_flags;
|
md->sr[SWITCH_DTMF_RECV].map[key].bind_flags = bind_flags;
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Bound A-Leg: %c%d %s\n", meta, key, app);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Bound A-Leg: %c%c %s\n", meta, switch_itodtmf(key), app);
|
||||||
}
|
}
|
||||||
if ((bind_flags & SBF_DIAL_BLEG)) {
|
if ((bind_flags & SBF_DIAL_BLEG)) {
|
||||||
md->sr[SWITCH_DTMF_SEND].meta = meta;
|
md->sr[SWITCH_DTMF_SEND].meta = meta;
|
||||||
@ -3009,12 +3009,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se
|
|||||||
md->sr[SWITCH_DTMF_SEND].map[key].app = switch_core_session_strdup(session, app);
|
md->sr[SWITCH_DTMF_SEND].map[key].app = switch_core_session_strdup(session, app);
|
||||||
md->sr[SWITCH_DTMF_SEND].map[key].flags |= SMF_HOLD_BLEG;
|
md->sr[SWITCH_DTMF_SEND].map[key].flags |= SMF_HOLD_BLEG;
|
||||||
md->sr[SWITCH_DTMF_SEND].map[key].bind_flags = bind_flags;
|
md->sr[SWITCH_DTMF_SEND].map[key].bind_flags = bind_flags;
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Bound B-Leg: %c%d %s\n", meta, key, app);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Bound B-Leg: %c%c %s\n", meta, switch_itodtmf(key), app);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ((bind_flags & SBF_DIAL_ALEG)) {
|
if ((bind_flags & SBF_DIAL_ALEG)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "UnBound A-Leg: %c%d\n", meta, key);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "UnBound A-Leg: %c%c\n", meta, switch_itodtmf(key));
|
||||||
md->sr[SWITCH_DTMF_SEND].map[key].app = NULL;
|
md->sr[SWITCH_DTMF_SEND].map[key].app = NULL;
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "UnBound: B-Leg %c%d\n", meta, key);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "UnBound: B-Leg %c%d\n", meta, key);
|
||||||
|
@ -2394,7 +2394,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *sess
|
|||||||
if (moh_b) {
|
if (moh_b) {
|
||||||
moh = moh_b;
|
moh = moh_b;
|
||||||
} else {
|
} else {
|
||||||
moh = switch_channel_get_variable(other_channel, "hold_music");
|
moh = switch_channel_get_variable(other_channel, SWITCH_HOLD_MUSIC_VARIABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!zstr(moh) && strcasecmp(moh, "silence") && !switch_channel_test_flag(other_channel, CF_BROADCAST)) {
|
if (!zstr(moh) && strcasecmp(moh, "silence") && !switch_channel_test_flag(other_channel, CF_BROADCAST)) {
|
||||||
@ -2405,7 +2405,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *sess
|
|||||||
if (moh_a) {
|
if (moh_a) {
|
||||||
moh = moh_a;
|
moh = moh_a;
|
||||||
} else {
|
} else {
|
||||||
moh = switch_channel_get_variable(channel, "hold_music");
|
moh = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!zstr(moh) && strcasecmp(moh, "silence")) {
|
if (!zstr(moh) && strcasecmp(moh, "silence")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user