mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-23 03:34:15 +00:00
FS-6833 #comment please test this branch
This commit is contained in:
1 parent
d5b906b22e
commit
2feae3fc69
8 files changed
+360
-7
No files matched your search
@@ -1548,6 +1548,114 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold_uuid(const char *uuid)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_3p_media(const char *uuid, switch_media_flag_t flags)
|
||||
{
|
||||
const char *other_uuid = NULL;
|
||||
switch_channel_t *channel, *other_channel = NULL;
|
||||
switch_core_session_t *session, *other_session;
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
switch_status_t status = SWITCH_STATUS_GENERR;
|
||||
uint8_t swap = 0;
|
||||
//switch_frame_t *read_frame = NULL;
|
||||
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_3P_MEDIA;
|
||||
msg.from = __FILE__;
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_MEDIA_TRANS)) {
|
||||
switch_core_session_rwunlock(session);
|
||||
return SWITCH_STATUS_INUSE;
|
||||
}
|
||||
|
||||
switch_channel_set_flag(channel, CF_MEDIA_TRANS);
|
||||
|
||||
if ((flags & SMF_REBRIDGE) && !switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
|
||||
swap = 1;
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
/* If we had early media in bypass mode before, it is no longer relevant */
|
||||
if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
|
||||
switch_core_session_message_t msg2 = { 0 };
|
||||
|
||||
msg2.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS;
|
||||
msg2.from = __FILE__;
|
||||
switch_core_session_receive_message(session, &msg2);
|
||||
}
|
||||
|
||||
if ((flags & SMF_REPLYONLY_A)) {
|
||||
msg.numeric_arg = 1;
|
||||
}
|
||||
|
||||
switch_channel_set_flag(channel, CF_3P_MEDIA_REQUESTED);
|
||||
|
||||
if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't re-establsh media on %s\n", switch_channel_get_name(channel));
|
||||
switch_channel_clear_flag(channel, CF_3P_MEDIA_REQUESTED);
|
||||
switch_core_session_rwunlock(session);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if ((flags & SMF_REPLYONLY_B)) {
|
||||
msg.numeric_arg = 1;
|
||||
} else {
|
||||
msg.numeric_arg = 0;
|
||||
}
|
||||
|
||||
if ((flags & SMF_IMMEDIATE)) {
|
||||
switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 250, NULL);
|
||||
switch_yield(250000);
|
||||
} else {
|
||||
switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
|
||||
switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
|
||||
switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
|
||||
//switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
}
|
||||
|
||||
if ((flags & SMF_REBRIDGE)
|
||||
&& (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))
|
||||
&& (other_session = switch_core_session_locate(other_uuid))) {
|
||||
|
||||
other_channel = switch_core_session_get_channel(other_session);
|
||||
switch_assert(other_channel != NULL);
|
||||
|
||||
switch_channel_set_flag(other_channel, CF_3P_MEDIA_REQUESTED);
|
||||
switch_channel_set_variable(other_channel, "rtp_secure_media", "optional");
|
||||
|
||||
switch_core_session_receive_message(other_session, &msg);
|
||||
switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
|
||||
switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
|
||||
switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
|
||||
//switch_core_session_read_frame(other_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
switch_channel_clear_state_handler(other_channel, NULL);
|
||||
switch_core_session_rwunlock(other_session);
|
||||
}
|
||||
if (other_channel) {
|
||||
switch_channel_clear_state_handler(channel, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
switch_channel_clear_flag(channel, CF_MEDIA_TRANS);
|
||||
switch_core_session_rwunlock(session);
|
||||
|
||||
if (other_channel) {
|
||||
if (swap) {
|
||||
switch_ivr_uuid_bridge(other_uuid, uuid);
|
||||
} else {
|
||||
switch_ivr_uuid_bridge(uuid, other_uuid);
|
||||
}
|
||||
switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
|
||||
switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_flag_t flags)
|
||||
{
|
||||
const char *other_uuid = NULL;
|
||||
@@ -1648,6 +1756,104 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_3p_nomedia(const char *uuid, switch_media_flag_t flags)
|
||||
{
|
||||
const char *other_uuid;
|
||||
switch_channel_t *channel, *other_channel = NULL;
|
||||
switch_core_session_t *session, *other_session = NULL;
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
switch_status_t status = SWITCH_STATUS_GENERR;
|
||||
uint8_t swap = 0;
|
||||
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_3P_NOMEDIA;
|
||||
msg.from = __FILE__;
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_MEDIA_TRANS)) {
|
||||
switch_core_session_rwunlock(session);
|
||||
return SWITCH_STATUS_INUSE;
|
||||
}
|
||||
|
||||
switch_channel_set_flag(channel, CF_MEDIA_TRANS);
|
||||
|
||||
if ((flags & SMF_REBRIDGE) && !switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
|
||||
swap = 1;
|
||||
}
|
||||
|
||||
if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_PROXY_MODE)) {
|
||||
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
|
||||
(other_session = switch_core_session_locate(other_uuid))) {
|
||||
other_channel = switch_core_session_get_channel(other_session);
|
||||
|
||||
switch_channel_set_flag(channel, CF_REDIRECT);
|
||||
switch_channel_set_flag(channel, CF_RESET);
|
||||
|
||||
switch_channel_set_flag(other_channel, CF_RESET);
|
||||
switch_channel_set_flag(other_channel, CF_REDIRECT);
|
||||
|
||||
switch_channel_set_flag(channel, CF_3P_NOMEDIA_REQUESTED);
|
||||
switch_core_session_receive_message(session, &msg);
|
||||
|
||||
if (!switch_core_session_in_thread(session)) {
|
||||
switch_channel_set_state(channel, CS_PARK);
|
||||
}
|
||||
switch_channel_set_state(other_channel, CS_PARK);
|
||||
if (switch_core_session_in_thread(session)) {
|
||||
switch_yield(100000);
|
||||
} else {
|
||||
switch_channel_wait_for_state(other_channel, channel, CS_PARK);
|
||||
}
|
||||
|
||||
msg.string_arg = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
|
||||
switch_channel_set_flag(other_channel, CF_3P_NOMEDIA_REQUESTED);
|
||||
switch_channel_set_flag(other_channel, CF_3P_NOMEDIA_REQUESTED_BLEG);
|
||||
|
||||
switch_core_session_receive_message(other_session, &msg);
|
||||
switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
|
||||
switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
|
||||
}
|
||||
|
||||
if (other_channel) {
|
||||
if (!switch_core_session_in_thread(session)) {
|
||||
switch_channel_wait_for_state(channel, NULL, CS_PARK);
|
||||
switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
|
||||
switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
|
||||
switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
|
||||
}
|
||||
|
||||
if (swap) {
|
||||
switch_ivr_signal_bridge(other_session, session);
|
||||
} else {
|
||||
switch_ivr_signal_bridge(session, other_session);
|
||||
}
|
||||
|
||||
if (switch_core_session_in_thread(session)) {
|
||||
switch_yield(100000);
|
||||
} else {
|
||||
switch_channel_wait_for_state(other_channel, channel, CS_HIBERNATE);
|
||||
}
|
||||
|
||||
if (!switch_core_session_in_thread(session)) {
|
||||
switch_channel_wait_for_state(channel, other_channel, CS_HIBERNATE);
|
||||
}
|
||||
switch_core_session_rwunlock(other_session);
|
||||
}
|
||||
}
|
||||
|
||||
switch_channel_clear_flag(channel, CF_MEDIA_TRANS);
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_media_flag_t flags)
|
||||
{
|
||||
const char *other_uuid;
|
||||
|
||||
Reference in new issue
Block a user