you should get more than a steak dinner if you can make asterisk do this
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16426 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
9c628e2b20
commit
98edcdb345
|
@ -703,8 +703,6 @@ SWITCH_STANDARD_APP(set_name_function)
|
|||
SWITCH_STANDARD_APP(answer_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_clear_flag(channel, CF_PROXY_MEDIA);
|
||||
switch_channel_clear_flag(channel, CF_PROXY_MODE);
|
||||
switch_channel_answer(channel);
|
||||
}
|
||||
|
||||
|
@ -731,8 +729,6 @@ SWITCH_STANDARD_APP(presence_function)
|
|||
SWITCH_STANDARD_APP(pre_answer_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_clear_flag(channel, CF_PROXY_MEDIA);
|
||||
switch_channel_clear_flag(channel, CF_PROXY_MODE);
|
||||
switch_channel_pre_answer(channel);
|
||||
}
|
||||
|
||||
|
|
|
@ -505,7 +505,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
|||
|
||||
/* Send the 200 OK */
|
||||
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
|
||||
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
|
||||
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_respond(tech_pvt->nh, SIP_200_OK,
|
||||
|
@ -1243,6 +1243,16 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
|||
const char *var;
|
||||
const char *presence_data = switch_channel_get_variable(channel, "presence_data");
|
||||
const char *presence_id = switch_channel_get_variable(channel, "presence_id");
|
||||
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "sip_enable_soa"))) {
|
||||
if (switch_true(var)) {
|
||||
sofia_set_flag(tech_pvt, TFLAG_ENABLE_SOA);
|
||||
} else {
|
||||
sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (presence_id || presence_data) {
|
||||
char *sql = switch_mprintf("update sip_dialogs set presence_id='%q',presence_data='%q' "
|
||||
|
@ -1382,7 +1392,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
|||
{
|
||||
uint32_t send_invite = 1;
|
||||
|
||||
switch_channel_clear_flag(channel, CF_PROXY_MODE);
|
||||
sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE);
|
||||
|
||||
if (!(switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) {
|
||||
|
@ -1411,6 +1420,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
|||
|
||||
if (send_invite) {
|
||||
switch_channel_set_flag(channel, CF_REQ_MEDIA);
|
||||
switch_channel_clear_flag(channel, CF_PROXY_MODE);
|
||||
sofia_glue_do_invite(session);
|
||||
}
|
||||
}
|
||||
|
@ -3287,6 +3297,14 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||
*new_session = nsession;
|
||||
cause = SWITCH_CAUSE_SUCCESS;
|
||||
|
||||
if ((hval = switch_event_get_header(var_event, "sip_enable_soa"))) {
|
||||
if (switch_true(hval)) {
|
||||
sofia_set_flag(tech_pvt, TFLAG_ENABLE_SOA);
|
||||
} else {
|
||||
sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
|
||||
}
|
||||
}
|
||||
|
||||
if ((hval = switch_event_get_header(var_event, "sip_auto_answer")) && switch_true(hval)) {
|
||||
switch_channel_set_variable_printf(nchannel, "sip_h_Call-Info", "<sip:%s>;answer-after=0", profile->sipip);
|
||||
switch_channel_set_variable(nchannel, "sip_invite_params", "intercom=true");
|
||||
|
@ -3331,6 +3349,12 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||
tech_pvt->bte = ctech_pvt->te;
|
||||
tech_pvt->bcng_pt = ctech_pvt->cng_pt;
|
||||
tech_pvt->cid_type = ctech_pvt->cid_type;
|
||||
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_ENABLE_SOA)) {
|
||||
sofia_set_flag(ctech_pvt, TFLAG_ENABLE_SOA);
|
||||
} else {
|
||||
sofia_clear_flag(ctech_pvt, TFLAG_ENABLE_SOA);
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(o_channel, CF_PROXY_MEDIA)) {
|
||||
|
|
|
@ -841,9 +841,7 @@ sofia_gateway_subscription_t *sofia_find_gateway_subscription(sofia_gateway_t *g
|
|||
void sofia_reg_release_gateway__(const char *file, const char *func, int line, sofia_gateway_t *gateway);
|
||||
#define sofia_reg_release_gateway(x) sofia_reg_release_gateway__(__FILE__, __SWITCH_FUNC__, __LINE__, x);
|
||||
|
||||
#define sofia_use_soa(_t) (sofia_test_flag(_t, TFLAG_ENABLE_SOA) \
|
||||
&& !switch_channel_test_flag(_t->channel, CF_PROXY_MODE) \
|
||||
&& !switch_channel_test_flag(_t->channel, CF_PROXY_MEDIA))
|
||||
#define sofia_use_soa(_t) sofia_test_flag(_t, TFLAG_ENABLE_SOA)
|
||||
|
||||
#define check_decode(_var, _session) do { \
|
||||
assert(_session); \
|
||||
|
|
|
@ -1435,8 +1435,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
char *route_uri = NULL;
|
||||
sofia_destination_t *dst = NULL;
|
||||
sofia_cid_type_t cid_type = tech_pvt->profile->cid_type;
|
||||
char *d_url = NULL, *url = NULL, *dest_host = NULL, *url_str = NULL;
|
||||
|
||||
|
||||
rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
|
||||
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
@ -1452,50 +1451,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
check_decode(cid_name, session);
|
||||
check_decode(cid_num, session);
|
||||
|
||||
if (zstr(tech_pvt->dest)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "URL Error!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ((d_url = sofia_glue_get_url_from_contact(tech_pvt->dest, 1))) {
|
||||
url = d_url;
|
||||
} else {
|
||||
url = tech_pvt->dest;
|
||||
}
|
||||
|
||||
url_str = url;
|
||||
|
||||
if ((dest_host = strchr(url_str, '@'))) {
|
||||
dest_host++;
|
||||
}
|
||||
|
||||
|
||||
if (!tech_pvt->from_str) {
|
||||
const char* sipip;
|
||||
const char* format;
|
||||
const char *alt = NULL;
|
||||
|
||||
sipip = tech_pvt->profile->sipip;
|
||||
|
||||
if (sofia_glue_check_nat(tech_pvt->profile, dest_host)) {
|
||||
sipip = tech_pvt->profile->extsipip;
|
||||
}
|
||||
|
||||
format = strchr(sipip, ':') ? "\"%s\" <sip:%s%s[%s]>" : "\"%s\" <sip:%s%s%s>";
|
||||
|
||||
if ((alt = switch_channel_get_variable(channel, "sip_invite_domain"))) {
|
||||
sipip = alt;
|
||||
}
|
||||
|
||||
tech_pvt->from_str =
|
||||
switch_core_session_sprintf(tech_pvt->session,
|
||||
format,
|
||||
cid_name,
|
||||
cid_num,
|
||||
!zstr(cid_num) ? "@" : "",
|
||||
sipip);
|
||||
}
|
||||
|
||||
if ((alertbuf = switch_channel_get_variable(channel, "alert_info"))) {
|
||||
alert_info = switch_core_session_sprintf(tech_pvt->session, "Alert-Info: %s", alertbuf);
|
||||
}
|
||||
|
@ -1511,7 +1467,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
sofia_set_flag_locked(tech_pvt, TFLAG_READY);
|
||||
|
||||
if (!tech_pvt->nh) {
|
||||
|
||||
char *d_url = NULL, *url = NULL, *dest_host = NULL, *url_str = NULL;
|
||||
sofia_private_t *sofia_private;
|
||||
char *invite_contact = NULL, *to_str, *use_from_str, *from_str;
|
||||
const char *t_var;
|
||||
|
@ -1525,6 +1481,52 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
const char *invite_from_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_from_params");
|
||||
const char *from_var = switch_channel_get_variable(tech_pvt->channel, "sip_from_uri");
|
||||
const char *from_display = switch_channel_get_variable(tech_pvt->channel, "sip_from_display");
|
||||
|
||||
|
||||
if (zstr(tech_pvt->dest)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "URL Error!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ((d_url = sofia_glue_get_url_from_contact(tech_pvt->dest, 1))) {
|
||||
url = d_url;
|
||||
} else {
|
||||
url = tech_pvt->dest;
|
||||
}
|
||||
|
||||
url_str = url;
|
||||
|
||||
if ((dest_host = strchr(url_str, '@'))) {
|
||||
dest_host++;
|
||||
}
|
||||
|
||||
|
||||
if (!tech_pvt->from_str) {
|
||||
const char* sipip;
|
||||
const char* format;
|
||||
const char *alt = NULL;
|
||||
|
||||
sipip = tech_pvt->profile->sipip;
|
||||
|
||||
if (sofia_glue_check_nat(tech_pvt->profile, dest_host)) {
|
||||
sipip = tech_pvt->profile->extsipip;
|
||||
}
|
||||
|
||||
format = strchr(sipip, ':') ? "\"%s\" <sip:%s%s[%s]>" : "\"%s\" <sip:%s%s%s>";
|
||||
|
||||
if ((alt = switch_channel_get_variable(channel, "sip_invite_domain"))) {
|
||||
sipip = alt;
|
||||
}
|
||||
|
||||
tech_pvt->from_str =
|
||||
switch_core_session_sprintf(tech_pvt->session,
|
||||
format,
|
||||
cid_name,
|
||||
cid_num,
|
||||
!zstr(cid_num) ? "@" : "",
|
||||
sipip);
|
||||
}
|
||||
|
||||
|
||||
if (from_var) {
|
||||
if (strncasecmp(from_var, "sip:", 4) || strncasecmp(from_var, "sips:", 5)) {
|
||||
|
|
|
@ -1810,11 +1810,11 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
|
|||
for (un = sip->sip_unknown; un; un = un->un_next) {
|
||||
if (!strncasecmp(un->un_name, "X-", 2)) {
|
||||
if (!zstr(un->un_value)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "adding %s => %s to xml_curl request\n", un->un_name, un->un_value);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "adding %s => %s to xml_curl request\n", un->un_name, un->un_value);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, un->un_name, un->un_value);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skipping %s => %s from xml_curl request\n", un->un_name, un->un_value);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "skipping %s => %s from xml_curl request\n", un->un_name, un->un_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -962,6 +962,7 @@ SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_c
|
|||
switch_assert(channel->flag_mutex);
|
||||
|
||||
switch_mutex_lock(channel->flag_mutex);
|
||||
|
||||
channel->flags[flag] = 1;
|
||||
switch_mutex_unlock(channel->flag_mutex);
|
||||
|
||||
|
@ -1051,6 +1052,7 @@ SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch
|
|||
switch_mutex_lock(channel->flag_mutex);
|
||||
channel->flags[flag] = 0;
|
||||
switch_mutex_unlock(channel->flag_mutex);
|
||||
|
||||
if (flag == CF_OUTBOUND) {
|
||||
switch_channel_set_variable(channel, "is_outbound", NULL);
|
||||
}
|
||||
|
|
|
@ -927,16 +927,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *
|
|||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
switch_channel_set_state_flag(caller_channel, CF_TRANSFER);
|
||||
switch_channel_set_state_flag(peer_channel, CF_TRANSFER);
|
||||
switch_channel_set_state_flag(caller_channel, CF_RESET);
|
||||
switch_channel_set_state_flag(peer_channel, CF_RESET);
|
||||
|
||||
switch_channel_set_state(caller_channel, CS_HIBERNATE);
|
||||
switch_channel_set_state(peer_channel, CS_HIBERNATE);
|
||||
|
||||
|
||||
#if 0
|
||||
if (switch_channel_test_flag(caller_channel, CF_BRIDGED)) {
|
||||
switch_channel_set_flag(caller_channel, CF_TRANSFER);
|
||||
switch_channel_set_flag(peer_channel, CF_TRANSFER);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch_ivr_bridge_display(session, peer_session);
|
||||
|
||||
|
@ -1164,21 +1166,37 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
|||
|
||||
state = switch_channel_get_state(caller_channel);
|
||||
|
||||
if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !switch_channel_test_flag(caller_channel, CF_REDIRECT) &&
|
||||
!switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) && !a_leg->clean_exit && !inner_bridge) {
|
||||
if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) &&
|
||||
switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP) {
|
||||
if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !switch_channel_test_flag(caller_channel, CF_REDIRECT) &&
|
||||
!switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) && !a_leg->clean_exit && !inner_bridge) {
|
||||
int hup_ok = 0;
|
||||
int x_ok = 0;
|
||||
|
||||
if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
|
||||
switch_ivr_park_session(session);
|
||||
} else if ((var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
|
||||
transfer_after_bridge(session, var);
|
||||
} else if (switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
|
||||
switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
|
||||
switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING)) {
|
||||
hup_ok = 1;
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP) {
|
||||
x_ok = 1;
|
||||
}
|
||||
|
||||
if (x_ok) {
|
||||
if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
|
||||
switch_ivr_park_session(session);
|
||||
hup_ok = 0;
|
||||
} else if ((var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
|
||||
transfer_after_bridge(session, var);
|
||||
hup_ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (hup_ok) {
|
||||
if (switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
|
||||
switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
|
||||
switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(caller_channel, CF_REDIRECT)) {
|
||||
state = switch_channel_get_state(caller_channel);
|
||||
|
|
|
@ -1722,20 +1722,25 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
|||
proxy_media = switch_channel_get_variable(caller_channel, SWITCH_PROXY_MEDIA_VARIABLE);
|
||||
bypass_media = switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_VARIABLE);
|
||||
|
||||
if (switch_true(proxy_media)) {
|
||||
switch_channel_set_flag(caller_channel, CF_PROXY_MEDIA);
|
||||
} else {
|
||||
switch_channel_clear_flag(caller_channel, CF_PROXY_MEDIA);
|
||||
if (!zstr(proxy_media)) {
|
||||
if (switch_true(proxy_media)) {
|
||||
switch_channel_set_flag(caller_channel, CF_PROXY_MEDIA);
|
||||
} else if (switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)) {
|
||||
switch_channel_clear_flag(caller_channel, CF_PROXY_MEDIA);
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_true(bypass_media)) {
|
||||
switch_channel_set_flag(caller_channel, CF_PROXY_MODE);
|
||||
} else {
|
||||
switch_channel_clear_flag(caller_channel, CF_PROXY_MODE);
|
||||
|
||||
if (!zstr(bypass_media)) {
|
||||
if (switch_true(bypass_media)) {
|
||||
switch_channel_set_flag(caller_channel, CF_PROXY_MODE);
|
||||
} else if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) {
|
||||
switch_ivr_media(switch_core_session_get_uuid(session), SMF_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
switch_channel_set_variable(caller_channel, SWITCH_B_SDP_VARIABLE, NULL);
|
||||
|
||||
|
||||
|
||||
if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && switch_channel_media_ready(caller_channel)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
|
||||
"Channel is already up, delaying proxy mode 'till both legs are answered.\n");
|
||||
|
|
Loading…
Reference in New Issue