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_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_partner(_channel, _var, _val) switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE)
#define SWITCH_PROXY_MEDIA_VARIABLE "proxy_media"
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition"
#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_BRIDGE_EXPORT_VARS_VARIABLE "bridge_export_vars"
#define SWITCH_R_SDP_VARIABLE "switch_r_sdp"
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)
{
int kval = 0;
if (key) {
- kval = atoi(key);
+ kval = switch_dtmftoi(key);
}
switch_ivr_unbind_dtmf_meta_session(session, kval);
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
&& (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;
if (strchr(argv[1], 'a')) {
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");
}
const char *moh_a = NULL, *moh_b = NULL;
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_music"))) {
- moh_a = switch_channel_get_variable(channel, "hold_music");
+ moh_a = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
}
}
static switch_status_t spy_on_park(switch_core_session_t *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) {
if (moh) {
}
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)
music = tmp;
hotline = val;
} else if (!strcasecmp(var, "dial_regex")) {
dial_regex = val;
- } else if (!strcasecmp(var, "hold_music")) {
+ } else if (!strcasecmp(var, SWITCH_HOLD_MUSIC_VARIABLE)) {
hold_music = val;
} else if (!strcasecmp(var, "fail_dial_regex")) {
fail_dial_regex = val;
}
+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)
{
const char *v = NULL, *r = NULL;
} dtmf_meta_app_t;
typedef struct {
- dtmf_meta_app_t map[10];
+ dtmf_meta_app_t map[14];
time_t last_digit;
switch_bool_t meta_on;
char meta;
if (meta != '*' && 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);
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);
return SWITCH_STATUS_FALSE;
}
md->sr[SWITCH_DTMF_RECV].map[key].app = switch_core_session_strdup(session, app);
md->sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
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)) {
md->sr[SWITCH_DTMF_SEND].meta = meta;
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].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 {
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;
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "UnBound: B-Leg %c%d\n", meta, key);
if (moh_b) {
moh = moh_b;
} 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 (moh_a) {
moh = moh_a;
} 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")) {