mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 20:51:58 +00:00
add transfer capability and small ways to test it
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1290 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -64,6 +64,7 @@ static void audio_bridge_function(switch_core_session *session, char *data)
|
||||
NULL,
|
||||
caller_caller_profile->rdnis,
|
||||
caller_caller_profile->source,
|
||||
caller_caller_profile->context,
|
||||
chan_data);
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ static switch_status kill_function(char *dest, char *out, size_t outlen)
|
||||
switch_channel *channel = switch_core_session_get_channel(session);
|
||||
switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
switch_core_session_rwunlock(session);
|
||||
snprintf(out, outlen, "OK\n");
|
||||
} else {
|
||||
snprintf(out, outlen, "No Such Channel!\n");
|
||||
@@ -58,11 +59,96 @@ static switch_status kill_function(char *dest, char *out, size_t outlen)
|
||||
}
|
||||
|
||||
|
||||
static switch_status transfer_function(char *cmd, char *out, size_t outlen)
|
||||
{
|
||||
switch_core_session *session = NULL;
|
||||
char *argv[4] = {0};
|
||||
int argc = 0;
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (argc < 2 || argc > 4) {
|
||||
snprintf(out, outlen, "Invalid Parameters\n");
|
||||
} else {
|
||||
char *uuid = argv[0];
|
||||
char *dest = argv[1];
|
||||
char *dp = argv[2];
|
||||
char *context = argv[3];
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
|
||||
if (switch_ivr_session_transfer(session, dest, dp, context) == SWITCH_STATUS_SUCCESS) {
|
||||
snprintf(out, outlen, "OK\n");
|
||||
} else {
|
||||
snprintf(out, outlen, "ERROR\n");
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(session);
|
||||
|
||||
} else {
|
||||
snprintf(out, outlen, "No Such Channel!\n");
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static switch_status pause_function(char *cmd, char *out, size_t outlen)
|
||||
{
|
||||
switch_core_session *session = NULL;
|
||||
char *argv[4] = {0};
|
||||
int argc = 0;
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (argc < 2) {
|
||||
snprintf(out, outlen, "Invalid Parameters\n");
|
||||
} else {
|
||||
char *uuid = argv[0];
|
||||
char *dest = argv[1];
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
switch_channel *channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (!strcasecmp(dest, "on")) {
|
||||
switch_channel_set_flag(channel, CF_HOLD);
|
||||
} else {
|
||||
switch_channel_clear_flag(channel, CF_HOLD);
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(session);
|
||||
|
||||
} else {
|
||||
snprintf(out, outlen, "No Such Channel!\n");
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static struct switch_api_interface pause_api_interface = {
|
||||
/*.interface_name */ "pause",
|
||||
/*.desc */ "Pause",
|
||||
/*.function */ pause_function,
|
||||
/*.next */ NULL
|
||||
};
|
||||
|
||||
static struct switch_api_interface transfer_api_interface = {
|
||||
/*.interface_name */ "transfer",
|
||||
/*.desc */ "Transfer",
|
||||
/*.function */ transfer_function,
|
||||
/*.next */ &pause_api_interface
|
||||
};
|
||||
|
||||
static struct switch_api_interface load_api_interface = {
|
||||
/*.interface_name */ "load",
|
||||
/*.desc */ "Load Modile",
|
||||
/*.function */ load_function,
|
||||
/*.next */ NULL
|
||||
/*.next */ &transfer_api_interface
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -87,6 +87,12 @@ static switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
||||
if (strcasecmp(exten_name, caller_profile->source)) {
|
||||
skip = 1;
|
||||
}
|
||||
} else if (*exten_name == 'c' && *(exten_name+1) == ':') {
|
||||
exten_name += 2;
|
||||
if (strcasecmp(exten_name, caller_profile->context)) {
|
||||
skip = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ struct mdl_profile {
|
||||
char *extip;
|
||||
char *lanaddr;
|
||||
char *exten;
|
||||
char *context;
|
||||
ldl_handle_t *handle;
|
||||
unsigned int flags;
|
||||
};
|
||||
@@ -1246,6 +1247,8 @@ static switch_status load_config(void)
|
||||
profile->lanaddr = switch_core_strdup(module_pool, val);
|
||||
} else if (!strcmp(var, "exten")) {
|
||||
profile->exten = switch_core_strdup(module_pool, val);
|
||||
} else if (!strcmp(var, "context")) {
|
||||
profile->context = switch_core_strdup(module_pool, val);
|
||||
} else if (!strcmp(var, "vad")) {
|
||||
if (!strcasecmp(val, "in")) {
|
||||
switch_set_flag(profile, TFLAG_VAD_IN);
|
||||
@@ -1341,6 +1344,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||
NULL,
|
||||
NULL,
|
||||
(char *)modname,
|
||||
profile->context,
|
||||
profile->exten)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "DingaLing/%s-%04x", tech_pvt->caller_profile->destination_number,
|
||||
|
||||
@@ -1193,6 +1193,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
||||
NULL,
|
||||
NULL,
|
||||
(char *)modname,
|
||||
NULL,
|
||||
event->request->req_uri->username)) != 0) {
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
}
|
||||
|
||||
@@ -1004,6 +1004,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
||||
NULL,
|
||||
NULL,
|
||||
(char *)modname,
|
||||
NULL,
|
||||
iaxevent->ies.called_number)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number,
|
||||
|
||||
@@ -811,7 +811,7 @@ static switch_status place_call(char *dest, char *out, size_t outlen)
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
globals.dialplan,
|
||||
globals.cid_name,
|
||||
globals.cid_num, NULL, NULL, NULL, NULL, (char *)modname, dest)) != 0) {
|
||||
globals.cid_num, NULL, NULL, NULL, NULL, (char *)modname, NULL, dest)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "PortAudio/%s-%04x",
|
||||
tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->
|
||||
|
||||
@@ -1135,6 +1135,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
|
||||
NULL,
|
||||
NULL,
|
||||
(char *)modname,
|
||||
NULL,
|
||||
event->ring.callednum))) {
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
}
|
||||
|
||||
@@ -1068,7 +1068,7 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
||||
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
tech_pvt->profile->dialplan,
|
||||
cid_name, cid_num, ip, NULL, NULL, NULL, (char *)modname, exten)) != 0) {
|
||||
cid_name, cid_num, ip, NULL, NULL, NULL, (char *)modname, NULL, exten)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number,
|
||||
rand() & 0xffff);
|
||||
|
||||
@@ -45,7 +45,7 @@ static void event_handler(switch_event *event)
|
||||
return;
|
||||
default:
|
||||
switch_event_serialize(event, buf, sizeof(buf), NULL);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nEVENT\n--------------------------------\n%s\n", buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT\n--------------------------------\n%s\n", buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,6 +980,7 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
char *ani = "";
|
||||
char *ani2 = "";
|
||||
char *rdnis = "";
|
||||
char *context = "";
|
||||
|
||||
*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
|
||||
|
||||
@@ -997,30 +998,34 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
|
||||
}
|
||||
if (argc > 4) {
|
||||
cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
|
||||
context = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
|
||||
}
|
||||
if (argc > 5) {
|
||||
cid_num = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
|
||||
cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
|
||||
}
|
||||
if (argc > 6) {
|
||||
network_addr = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
|
||||
cid_num = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
|
||||
}
|
||||
if (argc > 7) {
|
||||
ani = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
|
||||
network_addr = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
|
||||
}
|
||||
if (argc > 8) {
|
||||
ani2 = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
|
||||
ani = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
|
||||
}
|
||||
if (argc > 9) {
|
||||
rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
|
||||
ani2 = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
|
||||
}
|
||||
if (argc > 10) {
|
||||
rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
caller_profile = switch_caller_profile_new(pool, dialplan, cid_name, cid_num, network_addr, ani, ani2, rdnis, (char *)modname, dest);
|
||||
caller_profile = switch_caller_profile_new(pool, dialplan, cid_name, cid_num, network_addr, ani, ani2, rdnis, (char *)modname, context, dest);
|
||||
if (switch_core_session_outgoing_channel(session, channel_type, caller_profile, &peer_session, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
jss = switch_core_session_alloc(peer_session, sizeof(*jss));
|
||||
jss->session = peer_session;
|
||||
|
||||
Reference in New Issue
Block a user