git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7865 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-03-11 21:32:56 +00:00
parent a363915441
commit 495deafd32
4 changed files with 127 additions and 2 deletions

View File

@ -747,6 +747,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
uint32_t timeout,
const char *valid_terminators);
SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, const char *app);
SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session);
/** @} */
SWITCH_END_EXTERN_C

View File

@ -79,6 +79,26 @@ SWITCH_STANDARD_APP(exe_function)
}
}
#define BIND_SYNTAX "<key> <app>"
SWITCH_STANDARD_APP(dtmf_bind_function)
{
char *argv[2] = { 0 };
int argc;
char *lbuf = NULL;
if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 2) {
int kval = atoi(argv[0]);
if (switch_ivr_bind_dtmf_meta_session(session, kval, argv[1]) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bound: %s %s\n", argv[0], argv[1]);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bind Error!\n");
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", BIND_SYNTAX);
}
}
#define INTERCEPT_SYNTAX "<uuid>"
SWITCH_STANDARD_APP(intercept_function)
{
@ -1609,6 +1629,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
SWITCH_ADD_APP(app_interface, "sched_broadcast", SCHED_BROADCAST_DESCR, SCHED_BROADCAST_DESCR, sched_broadcast_function, "[+]<time> <path> [aleg|bleg|both]", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "sched_transfer", SCHED_TRANSF_DESCR, SCHED_TRANSF_DESCR, sched_transfer_function, "[+]<time> <extension> <dialplan> <context>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "execute_extension", "Execute an extension", "Execute an extension", exe_function, EXE_SYNTAX, SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "bind_meta_app", "Bind a key to an application", "Bind a key to an application", dtmf_bind_function, BIND_SYNTAX, SAF_NONE);
SWITCH_ADD_APP(app_interface, "intercept", "intercept", "intercept", intercept_function, INTERCEPT_SYNTAX, SAF_NONE);
SWITCH_ADD_APP(app_interface, "eavesdrop", "eavesdrop on a uuid", "eavesdrop on a uuid", eavesdrop_function, eavesdrop_SYNTAX, SAF_NONE);
SWITCH_ADD_APP(app_interface, "three_way", "three way call with a uuid", "three way call with a uuid", three_way_function, eavesdrop_SYNTAX, SAF_NONE);

View File

@ -1913,8 +1913,10 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *
switch_time_t uduration = 0, legbillusec = 0, billusec = 0;
time_t tt_created = 0, tt_answered = 0, tt_hungup = 0, mtt_created = 0, mtt_answered = 0, mtt_hungup = 0, tt_prof_created, mtt_prof_created;
if (!(caller_profile = switch_channel_get_caller_profile(channel))) {
return SWITCH_STATUS_FALSE;
}
caller_profile = switch_channel_get_caller_profile(channel);
if (!(ocp = switch_channel_get_originatee_caller_profile(channel))) {
ocp = switch_channel_get_originator_caller_profile(channel);
}

View File

@ -1258,6 +1258,104 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi
return SWITCH_STATUS_SUCCESS;
}
typedef struct {
const char *app;
} dtmf_meta_app_t;
typedef struct {
dtmf_meta_app_t map[10];
time_t last_digit;
switch_bool_t meta_on;
} dtmf_meta_data_t;
#define SWITCH_META_VAR_KEY "__dtmf_meta"
static switch_status_t meta_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
dtmf_meta_data_t *md = switch_channel_get_private(channel, SWITCH_META_VAR_KEY);
time_t now = switch_timestamp(NULL);
char digit[2] = "";
int dval;
if (!md) {
return SWITCH_STATUS_SUCCESS;
}
if (md->meta_on && now - md->last_digit > 5) {
md->meta_on = SWITCH_FALSE;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Meta digit timeout parsing %c\n", switch_channel_get_name(channel), dtmf->digit);
return SWITCH_STATUS_SUCCESS;
}
md->last_digit = now;
if (dtmf->digit == '*') {
if (md->meta_on) {
md->meta_on = SWITCH_FALSE;
return SWITCH_STATUS_SUCCESS;
} else {
md->meta_on = SWITCH_TRUE;
return SWITCH_STATUS_FALSE;
}
}
if (md->meta_on) {
if (dtmf->digit >= '0' && dtmf->digit <= '9') {
*digit = dtmf->digit;
dval = atoi(digit);
if (md->map[dval].app) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n",
switch_channel_get_name(channel), dtmf->digit, md->map[dval].app);
switch_ivr_broadcast(switch_core_session_get_uuid(session), md->map[dval].app, SMF_ECHO_ALEG);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Ignoring meta digit '%c' not mapped\n",
switch_channel_get_name(channel), dtmf->digit);
}
}
md->meta_on = SWITCH_FALSE;
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_set_private(channel, SWITCH_META_VAR_KEY, NULL);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, const char *app)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
dtmf_meta_data_t *md = switch_channel_get_private(channel, SWITCH_META_VAR_KEY);
if (key > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid key %u\n", key);
return SWITCH_STATUS_FALSE;
}
if (!md) {
md = switch_core_session_alloc(session, sizeof(*md));
switch_channel_set_private(channel, SWITCH_META_VAR_KEY, md);
switch_core_event_hook_add_recv_dtmf(session, meta_on_dtmf);
}
if (!switch_strlen_zero(app)) {
md->map[key].app = switch_core_session_strdup(session, app);
} else {
md->map[key].app = NULL;
}
return SWITCH_STATUS_SUCCESS;
}
struct speech_thread_handle {
switch_core_session_t *session;
switch_asr_handle_t *ah;