mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-04 01:37:14 +00:00
FS-10328: [freeswitch-core] Add method to allow orphaned B legs during originate to transfer to another extension #resolve
This commit is contained in:
parent
ba43392462
commit
198eb824cc
@ -4111,6 +4111,41 @@ SWITCH_STANDARD_API(uuid_send_info_function)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define XFER_ZOMBIE_SYNTAX "<uuid>"
|
||||||
|
SWITCH_STANDARD_API(uuid_xfer_zombie)
|
||||||
|
{
|
||||||
|
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||||
|
char *mycmd = NULL, *argv[2] = { 0 };
|
||||||
|
int argc = 0;
|
||||||
|
|
||||||
|
if (!zstr(cmd) && (mycmd = strdup(cmd))) {
|
||||||
|
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc < 1) {
|
||||||
|
stream->write_function(stream, "-USAGE: %s\n", XFER_ZOMBIE_SYNTAX);
|
||||||
|
} else {
|
||||||
|
switch_core_session_t *lsession = NULL;
|
||||||
|
|
||||||
|
if ((lsession = switch_core_session_locate(argv[0]))) {
|
||||||
|
switch_channel_t *channel = switch_core_session_get_channel(lsession);
|
||||||
|
|
||||||
|
switch_channel_set_flag(channel, CF_XFER_ZOMBIE);
|
||||||
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
switch_core_session_rwunlock(lsession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == SWITCH_STATUS_SUCCESS) {
|
||||||
|
stream->write_function(stream, "+OK Success\n");
|
||||||
|
} else {
|
||||||
|
stream->write_function(stream, "-ERR Operation Failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_safe_free(mycmd);
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#define VIDEO_REFRESH_SYNTAX "<uuid>"
|
#define VIDEO_REFRESH_SYNTAX "<uuid>"
|
||||||
SWITCH_STANDARD_API(uuid_video_refresh_function)
|
SWITCH_STANDARD_API(uuid_video_refresh_function)
|
||||||
@ -4129,6 +4164,7 @@ SWITCH_STANDARD_API(uuid_video_refresh_function)
|
|||||||
switch_core_session_t *lsession = NULL;
|
switch_core_session_t *lsession = NULL;
|
||||||
|
|
||||||
if ((lsession = switch_core_session_locate(argv[0]))) {
|
if ((lsession = switch_core_session_locate(argv[0]))) {
|
||||||
|
switch_channel_set_flag(switch_core_session_get_channel(lsession), CF_XFER_ZOMBIE);
|
||||||
switch_core_session_request_video_refresh(lsession);
|
switch_core_session_request_video_refresh(lsession);
|
||||||
switch_core_media_gen_key_frame(lsession);
|
switch_core_media_gen_key_frame(lsession);
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
@ -7264,6 +7300,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
|||||||
SWITCH_ADD_API(commands_api_interface, "uuid_simplify", "Try to cut out of a call path / attended xfer", uuid_simplify_function, SIMPLIFY_SYNTAX);
|
SWITCH_ADD_API(commands_api_interface, "uuid_simplify", "Try to cut out of a call path / attended xfer", uuid_simplify_function, SIMPLIFY_SYNTAX);
|
||||||
SWITCH_ADD_API(commands_api_interface, "uuid_jitterbuffer", "uuid_jitterbuffer", uuid_jitterbuffer_function, JITTERBUFFER_SYNTAX);
|
SWITCH_ADD_API(commands_api_interface, "uuid_jitterbuffer", "uuid_jitterbuffer", uuid_jitterbuffer_function, JITTERBUFFER_SYNTAX);
|
||||||
SWITCH_ADD_API(commands_api_interface, "uuid_zombie_exec", "Set zombie_exec flag on the specified uuid", uuid_zombie_exec_function, "<uuid>");
|
SWITCH_ADD_API(commands_api_interface, "uuid_zombie_exec", "Set zombie_exec flag on the specified uuid", uuid_zombie_exec_function, "<uuid>");
|
||||||
|
SWITCH_ADD_API(commands_api_interface, "uuid_xfer_zombie", "Allow A leg to hangup and continue originating", uuid_xfer_zombie, XFER_ZOMBIE_SYNTAX);
|
||||||
SWITCH_ADD_API(commands_api_interface, "xml_flush_cache", "Clear xml cache", xml_flush_function, "<id> <key> <val>");
|
SWITCH_ADD_API(commands_api_interface, "xml_flush_cache", "Clear xml cache", xml_flush_function, "<id> <key> <val>");
|
||||||
SWITCH_ADD_API(commands_api_interface, "xml_locate", "Find some xml", xml_locate_function, "[root | <section> <tag> <tag_attr_name> <tag_attr_val>]");
|
SWITCH_ADD_API(commands_api_interface, "xml_locate", "Find some xml", xml_locate_function, "[root | <section> <tag> <tag_attr_name> <tag_attr_val>]");
|
||||||
SWITCH_ADD_API(commands_api_interface, "xml_wrap", "Wrap another api command in xml", xml_wrap_api_function, "<command> <args>");
|
SWITCH_ADD_API(commands_api_interface, "xml_wrap", "Wrap another api command in xml", xml_wrap_api_function, "<command> <args>");
|
||||||
@ -7454,6 +7491,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
|||||||
switch_console_set_complete("add uuid_dual_transfer ::console::list_uuid");
|
switch_console_set_complete("add uuid_dual_transfer ::console::list_uuid");
|
||||||
switch_console_set_complete("add uuid_video_refresh ::console::list_uuid");
|
switch_console_set_complete("add uuid_video_refresh ::console::list_uuid");
|
||||||
switch_console_set_complete("add uuid_video_bitrate ::console::list_uuid");
|
switch_console_set_complete("add uuid_video_bitrate ::console::list_uuid");
|
||||||
|
switch_console_set_complete("add uuid_xfer_zombie ::console::list_uuid");
|
||||||
switch_console_set_complete("add version");
|
switch_console_set_complete("add version");
|
||||||
switch_console_set_complete("add uuid_warning ::console::list_uuid");
|
switch_console_set_complete("add uuid_warning ::console::list_uuid");
|
||||||
switch_console_set_complete("add ...");
|
switch_console_set_complete("add ...");
|
||||||
|
@ -886,7 +886,20 @@ static switch_status_t audio_bridge_on_exchange_media(switch_core_session_t *ses
|
|||||||
switch_channel_hangup(channel, SWITCH_CAUSE_PICKED_OFF);
|
switch_channel_hangup(channel, SWITCH_CAUSE_PICKED_OFF);
|
||||||
} else {
|
} else {
|
||||||
if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
|
if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
if (switch_channel_execute_on(channel, "execute_on_orphaned_bleg") == SWITCH_STATUS_SUCCESS) {
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_channel_api_on(channel, "api_on_orphaned_bleg") == SWITCH_STATUS_SUCCESS) {
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!x) {
|
||||||
switch_channel_hangup(channel, SWITCH_CAUSE_ORIGINATOR_CANCEL);
|
switch_channel_hangup(channel, SWITCH_CAUSE_ORIGINATOR_CANCEL);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||||
}
|
}
|
||||||
|
@ -2179,6 +2179,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
const char *cdr_var;
|
const char *cdr_var;
|
||||||
const char *json_cdr_var;
|
const char *json_cdr_var;
|
||||||
|
|
||||||
|
if (switch_channel_var_true(caller_channel, "originate_xfer_zombie")) {
|
||||||
|
switch_channel_set_flag(caller_channel, CF_XFER_ZOMBIE);
|
||||||
|
oglobals.early_ok = 0;
|
||||||
|
oglobals.ignore_early_media = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((cdr_var = switch_channel_get_variable(caller_channel, "failed_xml_cdr_prefix"))) {
|
if ((cdr_var = switch_channel_get_variable(caller_channel, "failed_xml_cdr_prefix"))) {
|
||||||
char buf[128] = "";
|
char buf[128] = "";
|
||||||
switch_snprintf(buf, sizeof(buf), "%s_total", cdr_var);
|
switch_snprintf(buf, sizeof(buf), "%s_total", cdr_var);
|
||||||
@ -3624,7 +3630,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (caller_channel) {
|
if (caller_channel) {
|
||||||
if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
|
|
||||||
|
if (switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) && !switch_channel_up(caller_channel)) {
|
||||||
|
if (switch_channel_media_up(peer_channel)) {
|
||||||
|
oglobals.idx = IDX_XFER;
|
||||||
|
reason = force_reason = SWITCH_CAUSE_ATTENDED_TRANSFER;
|
||||||
|
switch_channel_execute_on(peer_channel, "execute_on_orphaned_bleg");
|
||||||
|
switch_channel_api_on(peer_channel, "api_on_orphaned_bleg");
|
||||||
|
}
|
||||||
|
} else if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
|
||||||
switch_channel_pass_callee_id(peer_channel, caller_channel);
|
switch_channel_pass_callee_id(peer_channel, caller_channel);
|
||||||
if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) {
|
if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) {
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user