add -bleg to intercept
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8583 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c1bf2c2099
commit
57117acdbc
|
@ -738,7 +738,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_x
|
|||
SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, const char *macro_name, const char *data, const char *lang,
|
||||
switch_input_args_t *args);
|
||||
SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms);
|
||||
SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen);
|
||||
SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg);
|
||||
SWITCH_DECLARE(void) switch_ivr_park_session(switch_core_session_t *session);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session);
|
||||
|
||||
|
|
|
@ -217,10 +217,36 @@ SWITCH_STANDARD_APP(dtmf_bind_function)
|
|||
}
|
||||
}
|
||||
|
||||
#define INTERCEPT_SYNTAX "<uuid>"
|
||||
#define INTERCEPT_SYNTAX "[-bleg] <uuid>"
|
||||
SWITCH_STANDARD_APP(intercept_function)
|
||||
{
|
||||
switch_ivr_intercept_session(session, data);
|
||||
int argc;
|
||||
char *argv[4] = { 0 };
|
||||
char *mydata;
|
||||
char *uuid;
|
||||
switch_bool_t bleg = SWITCH_FALSE;
|
||||
|
||||
if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
|
||||
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
|
||||
if (!strcasecmp(argv[0], "-bleg")) {
|
||||
if (argv[1]) {
|
||||
uuid = argv[1];
|
||||
bleg = SWITCH_TRUE;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", INTERCEPT_SYNTAX);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
uuid = argv[0];
|
||||
}
|
||||
|
||||
switch_ivr_intercept_session(session, uuid, bleg);
|
||||
}
|
||||
switch_safe_free(mydata);
|
||||
return;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", INTERCEPT_SYNTAX);
|
||||
}
|
||||
|
||||
#define MAX_SPY 3000
|
||||
|
|
|
@ -1713,6 +1713,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, c
|
|||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
|
|
@ -929,11 +929,43 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu
|
|||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid)
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen)
|
||||
{
|
||||
switch_core_session_t *rsession;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
switch_assert(uuid);
|
||||
|
||||
if ((rsession = switch_core_session_locate(uuid))) {
|
||||
switch_channel_t *rchannel = switch_core_session_get_channel(rsession);
|
||||
const char *brto;
|
||||
|
||||
if ((brto = switch_channel_get_variable(rchannel, SWITCH_SIGNAL_BOND_VARIABLE))) {
|
||||
switch_copy_string(b_uuid, brto, blen);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
switch_core_session_rwunlock(rsession);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg)
|
||||
{
|
||||
switch_core_session_t *rsession, *bsession = NULL;
|
||||
switch_channel_t *channel, *rchannel, *bchannel;
|
||||
const char *buuid;
|
||||
char brto[SWITCH_UUID_FORMATTED_LENGTH + 1] = "";
|
||||
|
||||
if (bleg) {
|
||||
if (switch_ivr_find_bridged_uuid(uuid, brto, sizeof(brto)) == SWITCH_STATUS_SUCCESS) {
|
||||
uuid = brto;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no uuid bridged to %s\n", uuid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_strlen_zero(uuid) || !(rsession = switch_core_session_locate(uuid))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no uuid %s\n", uuid);
|
||||
|
|
Loading…
Reference in New Issue