[Freeswitch-svn] [commit] r8583 - in freeswitch/trunk/src: . include mod/applications/mod_dptools
Freeswitch SVN
anthm at freeswitch.org
Sat May 24 13:28:05 EDT 2008
Author: anthm
Date: Sat May 24 13:28:04 2008
New Revision: 8583
Modified:
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_bridge.c
Log:
add -bleg to intercept
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Sat May 24 13:28:04 2008
@@ -738,7 +738,8 @@
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);
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Sat May 24 13:28:04 2008
@@ -217,10 +217,36 @@
}
}
-#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
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Sat May 24 13:28:04 2008
@@ -1713,6 +1713,7 @@
return status;
}
+
/* For Emacs:
* Local Variables:
* mode:c
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Sat May 24 13:28:04 2008
@@ -929,11 +929,43 @@
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);
More information about the Freeswitch-svn
mailing list