提交 bf1ad19a authored 作者: Anthony Minessale's avatar Anthony Minessale

FSCORE-322

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12676 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 bb45a165
...@@ -510,8 +510,13 @@ struct private_object { ...@@ -510,8 +510,13 @@ struct private_object {
char *rm_fmtp; char *rm_fmtp;
char *fmtp_out; char *fmtp_out;
char *remote_sdp_str; char *remote_sdp_str;
int crypto_tag;
unsigned char local_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN];
unsigned char remote_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN];
switch_rtp_crypto_key_type_t crypto_send_type;
switch_rtp_crypto_key_type_t crypto_recv_type;
switch_rtp_crypto_key_type_t crypto_type;
char *local_sdp_str; char *local_sdp_str;
char *orig_local_sdp_str;
char *dest; char *dest;
char *dest_to; char *dest_to;
char *key; char *key;
...@@ -533,12 +538,6 @@ struct private_object { ...@@ -533,12 +538,6 @@ struct private_object {
char *stun_ip; char *stun_ip;
switch_port_t stun_port; switch_port_t stun_port;
uint32_t stun_flags; uint32_t stun_flags;
int crypto_tag;
unsigned char local_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN];
unsigned char remote_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN];
switch_rtp_crypto_key_type_t crypto_send_type;
switch_rtp_crypto_key_type_t crypto_recv_type;
switch_rtp_crypto_key_type_t crypto_type;
unsigned long rm_rate; unsigned long rm_rate;
switch_payload_t pt; switch_payload_t pt;
switch_mutex_t *flag_mutex; switch_mutex_t *flag_mutex;
...@@ -837,3 +836,4 @@ switch_status_t sofia_set_loglevel(const char *name, int level); ...@@ -837,3 +836,4 @@ switch_status_t sofia_set_loglevel(const char *name, int level);
*/ */
int sofia_get_loglevel(const char *name); int sofia_get_loglevel(const char *name);
sofia_cid_type_t sofia_cid_name2type(const char *name); sofia_cid_type_t sofia_cid_name2type(const char *name);
void sofia_glue_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_str, switch_bool_t dup);
...@@ -342,8 +342,21 @@ void sofia_event_callback(nua_event_t event, ...@@ -342,8 +342,21 @@ void sofia_event_callback(nua_event_t event,
} else if (!switch_strlen_zero(sofia_private->uuid)) { } else if (!switch_strlen_zero(sofia_private->uuid)) {
if ((session = switch_core_session_locate(sofia_private->uuid))) { if ((session = switch_core_session_locate(sofia_private->uuid))) {
tech_pvt = switch_core_session_get_private(session); tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt); channel = switch_core_session_get_channel(session);
channel = switch_core_session_get_channel(tech_pvt->session); if (tech_pvt) {
if (status >= 300) {
sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
}
switch_mutex_lock(tech_pvt->sofia_mutex);
locked = 1;
} else {
switch_core_session_rwunlock(session);
return;
}
if (status >= 180 && !*sofia_private->auth_gateway_name) { if (status >= 180 && !*sofia_private->auth_gateway_name) {
const char *gwname = switch_channel_get_variable(channel, "sip_use_gateway"); const char *gwname = switch_channel_get_variable(channel, "sip_use_gateway");
if (!switch_strlen_zero(gwname)) { if (!switch_strlen_zero(gwname)) {
...@@ -369,11 +382,6 @@ void sofia_event_callback(nua_event_t event, ...@@ -369,11 +382,6 @@ void sofia_event_callback(nua_event_t event,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already hungup.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already hungup.\n");
goto done; goto done;
} }
if (tech_pvt) {
switch_mutex_lock(tech_pvt->sofia_mutex);
locked = 1;
}
} else if (sofia_private && sofia_private->is_call) { } else if (sofia_private && sofia_private->is_call) {
sofia_private->destroy_me = 22; sofia_private->destroy_me = 22;
} }
...@@ -542,13 +550,13 @@ void sofia_event_callback(nua_event_t event, ...@@ -542,13 +550,13 @@ void sofia_event_callback(nua_event_t event,
sofia_reg_release_gateway(gateway); sofia_reg_release_gateway(gateway);
} }
if (locked && tech_pvt) {
switch_mutex_unlock(tech_pvt->sofia_mutex);
}
if (session) { if (session) {
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
} }
if (tech_pvt && locked) {
switch_mutex_unlock(tech_pvt->sofia_mutex);
}
} }
void event_handler(switch_event_t *event) void event_handler(switch_event_t *event)
...@@ -697,6 +705,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void ...@@ -697,6 +705,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
switch_thread_t *worker_thread; switch_thread_t *worker_thread;
switch_status_t st; switch_status_t st;
switch_mutex_lock(mod_sofia_globals.mutex); switch_mutex_lock(mod_sofia_globals.mutex);
mod_sofia_globals.threads++; mod_sofia_globals.threads++;
switch_mutex_unlock(mod_sofia_globals.mutex); switch_mutex_unlock(mod_sofia_globals.mutex);
...@@ -2798,13 +2808,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, ...@@ -2798,13 +2808,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if (session) { if (session) {
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
tech_pvt = switch_core_session_get_private(session); tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!tech_pvt->nh) { if (!tech_pvt || !tech_pvt->nh) {
goto done; goto done;
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s]\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s][%d]\n",
switch_channel_get_name(channel), nua_callstate_name(ss_state)); switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
if (r_sdp) { if (r_sdp) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote SDP:\n%s\n", r_sdp); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote SDP:\n%s\n", r_sdp);
...@@ -2894,7 +2904,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, ...@@ -2894,7 +2904,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) { if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp); switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp);
} }
switch_channel_pre_answer(other_channel); switch_channel_pre_answer(other_channel);
switch_core_session_rwunlock(other_session); switch_core_session_rwunlock(other_session);
} }
...@@ -3071,13 +3080,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, ...@@ -3071,13 +3080,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(uuid))) { && (other_session = switch_core_session_locate(uuid))) {
switch_core_session_message_t msg = { 0 }; switch_core_session_message_t msg = { 0 };
if (profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) { if (profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) {
tech_pvt->hold_laps = 1; tech_pvt->hold_laps = 1;
switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp); switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
switch_channel_clear_flag(channel, CF_PROXY_MODE); switch_channel_clear_flag(channel, CF_PROXY_MODE);
tech_pvt->local_sdp_str = NULL; sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE);
if (!switch_channel_media_ready(channel)) { if (!switch_channel_media_ready(channel)) {
if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
//const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE); //const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
...@@ -3329,44 +3338,44 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, ...@@ -3329,44 +3338,44 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
tech_pvt->q850_cause = SWITCH_CAUSE_MANDATORY_IE_MISSING; tech_pvt->q850_cause = SWITCH_CAUSE_MANDATORY_IE_MISSING;
} }
case nua_callstate_terminated: case nua_callstate_terminated:
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { if (sofia_test_flag(tech_pvt, TFLAG_NOHUP)) {
sofia_set_flag_locked(tech_pvt, TFLAG_BYE); sofia_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
if (sofia_test_flag(tech_pvt, TFLAG_NOHUP)) { } else if (switch_channel_up(channel)) {
sofia_clear_flag_locked(tech_pvt, TFLAG_NOHUP); int cause;
if (tech_pvt->q850_cause) {
cause = tech_pvt->q850_cause;
} else { } else {
int cause; cause = sofia_glue_sip_cause_to_freeswitch(status);
if (tech_pvt->q850_cause) { }
cause = tech_pvt->q850_cause; if (status) {
} else { switch_snprintf(st, sizeof(st), "%d", status);
cause = sofia_glue_sip_cause_to_freeswitch(status); switch_channel_set_variable(channel, "sip_term_status", st);
} switch_snprintf(st, sizeof(st), "sip:%d", status);
if (status) { switch_channel_set_variable_partner(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
switch_snprintf(st, sizeof(st), "%d", status); switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
switch_channel_set_variable(channel, "sip_term_status", st); if (phrase) {
switch_snprintf(st, sizeof(st), "sip:%d", status); switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
switch_channel_set_variable_partner(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
if (phrase) {
switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
}
} }
switch_snprintf(st, sizeof(st), "%d", cause);
switch_channel_set_variable(channel, "sip_term_cause", st);
switch_channel_hangup(channel, cause);
} }
switch_snprintf(st, sizeof(st), "%d", cause);
switch_channel_set_variable(channel, "sip_term_cause", st);
switch_channel_hangup(channel, cause);
} }
if (ss_state == nua_callstate_terminated) { if (ss_state == nua_callstate_terminated) {
if (tech_pvt->sofia_private) { if (tech_pvt->sofia_private) {
tech_pvt->sofia_private = NULL; tech_pvt->sofia_private = NULL;
} }
tech_pvt->nh = NULL; tech_pvt->nh = NULL;
if (nh) { if (nh) {
nua_handle_bind(nh, NULL); nua_handle_bind(nh, NULL);
nua_handle_destroy(nh); nua_handle_destroy(nh);
} }
} }
break; break;
} }
...@@ -4616,7 +4625,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ ...@@ -4616,7 +4625,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
} }
if (!(sofia_private = malloc(sizeof(*sofia_private)))) { if (!(sofia_private = malloc(sizeof(*sofia_private)))) {
abort(); abort();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论