mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-25 12:10:18 +00:00
FS-3688 refactor of cancel handling code in bridge
This commit is contained in:
parent
0bf2a0e975
commit
4e014c4915
@ -1151,6 +1151,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void abort_call(switch_channel_t *caller_channel, switch_channel_t *peer_channel)
|
||||||
|
{
|
||||||
|
switch_call_cause_t cause = switch_channel_get_cause(caller_channel);
|
||||||
|
|
||||||
|
if (!cause) {
|
||||||
|
cause = SWITCH_CAUSE_ORIGINATOR_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_channel_hangup(peer_channel, cause);
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
|
SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
|
||||||
switch_core_session_t *peer_session,
|
switch_core_session_t *peer_session,
|
||||||
switch_input_callback_function_t input_callback, void *session_data,
|
switch_input_callback_function_t input_callback, void *session_data,
|
||||||
@ -1208,21 +1219,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
|||||||
switch_channel_test_flag(peer_channel, CF_RING_READY)) {
|
switch_channel_test_flag(peer_channel, CF_RING_READY)) {
|
||||||
const char *app, *data;
|
const char *app, *data;
|
||||||
|
|
||||||
if (switch_channel_get_state(peer_channel) == CS_CONSUME_MEDIA) {
|
if (!switch_channel_ready(caller_channel)) {
|
||||||
switch_channel_set_state(peer_channel, CS_HIBERNATE);
|
abort_call(caller_channel, peer_channel);
|
||||||
switch_channel_wait_for_state(peer_channel, caller_channel, CS_HIBERNATE);
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!switch_channel_ready(caller_channel)) {
|
|
||||||
switch_call_cause_t cause = switch_channel_get_cause(caller_channel);
|
|
||||||
|
|
||||||
if (cause) {
|
|
||||||
switch_channel_hangup(peer_channel, cause);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
switch_channel_set_state(peer_channel, CS_CONSUME_MEDIA);
|
switch_channel_set_state(peer_channel, CS_CONSUME_MEDIA);
|
||||||
|
|
||||||
switch_channel_set_variable(peer_channel, "call_uuid", switch_core_session_get_uuid(session));
|
switch_channel_set_variable(peer_channel, "call_uuid", switch_core_session_get_uuid(session));
|
||||||
@ -1241,6 +1242,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
|||||||
switch_channel_set_variable(caller_channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
|
switch_channel_set_variable(caller_channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
|
||||||
switch_channel_set_variable(peer_channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
|
switch_channel_set_variable(peer_channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
|
||||||
|
|
||||||
|
if (!switch_channel_ready(caller_channel)) {
|
||||||
|
abort_call(caller_channel, peer_channel);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (!switch_channel_media_ready(caller_channel) ||
|
if (!switch_channel_media_ready(caller_channel) ||
|
||||||
(!switch_channel_test_flag(peer_channel, CF_ANSWERED) && !switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
|
(!switch_channel_test_flag(peer_channel, CF_ANSWERED) && !switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
|
||||||
if ((status = switch_ivr_wait_for_answer(session, peer_session)) != SWITCH_STATUS_SUCCESS || !switch_channel_ready(caller_channel)) {
|
if ((status = switch_ivr_wait_for_answer(session, peer_session)) != SWITCH_STATUS_SUCCESS || !switch_channel_ready(caller_channel)) {
|
||||||
@ -1260,6 +1266,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
|||||||
switch_channel_hangup(caller_channel, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
|
switch_channel_hangup(caller_channel, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
abort_call(caller_channel, peer_channel);
|
||||||
switch_core_session_rwunlock(peer_session);
|
switch_core_session_rwunlock(peer_session);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -1279,6 +1286,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
|||||||
|
|
||||||
if (switch_core_session_receive_message(peer_session, &msg) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_receive_message(peer_session, &msg) != SWITCH_STATUS_SUCCESS) {
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
abort_call(caller_channel, peer_channel);
|
||||||
switch_core_session_rwunlock(peer_session);
|
switch_core_session_rwunlock(peer_session);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -1286,6 +1294,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
|||||||
msg.string_arg = switch_core_session_strdup(session, switch_core_session_get_uuid(peer_session));
|
msg.string_arg = switch_core_session_strdup(session, switch_core_session_get_uuid(peer_session));
|
||||||
if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
abort_call(caller_channel, peer_channel);
|
||||||
switch_core_session_rwunlock(peer_session);
|
switch_core_session_rwunlock(peer_session);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -3510,11 +3510,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||||||
if (*bleg) {
|
if (*bleg) {
|
||||||
switch_channel_t *bchan = switch_core_session_get_channel(*bleg);
|
switch_channel_t *bchan = switch_core_session_get_channel(*bleg);
|
||||||
|
|
||||||
if (switch_channel_get_state(bchan) == CS_CONSUME_MEDIA) {
|
|
||||||
switch_channel_set_state(bchan, CS_HIBERNATE);
|
|
||||||
switch_channel_wait_for_state(bchan, caller_channel, CS_HIBERNATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (session && caller_channel) {
|
if (session && caller_channel) {
|
||||||
switch_caller_profile_t *cloned_profile, *peer_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(*bleg));
|
switch_caller_profile_t *cloned_profile, *peer_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(*bleg));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user