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

</refactor>

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4955 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 c833f033
......@@ -300,7 +300,9 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
}
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
sofia_glue_activate_rtp(tech_pvt);
if (sofia_glue_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
if (tech_pvt->nh) {
if (tech_pvt->local_sdp_str) {
......@@ -605,7 +607,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
switch_clear_flag_locked(tech_pvt, TFLAG_NOMEDIA);
tech_pvt->local_sdp_str = NULL;
if (!switch_rtp_ready(tech_pvt->rtp_session)) {
sofia_glue_sofia_glue_tech_set_codecs(tech_pvt);
sofia_glue_tech_prepare_codecs(tech_pvt);
if ((status = sofia_glue_tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
return status;
}
......@@ -645,8 +647,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
a_tech_pvt->remote_sdp_audio_port = b_tech_pvt->remote_sdp_audio_port;
a_tech_pvt->local_sdp_audio_ip = switch_core_session_strdup(a_session, b_tech_pvt->local_sdp_audio_ip);
a_tech_pvt->local_sdp_audio_port = b_tech_pvt->local_sdp_audio_port;
sofia_glue_activate_rtp(a_tech_pvt);
if (sofia_glue_activate_rtp(a_tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
b_tech_pvt->kick = switch_core_session_strdup(b_session, tech_pvt->xferto);
switch_core_session_rwunlock(a_session);
}
......@@ -708,7 +711,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
return status;
}
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
sofia_glue_activate_rtp(tech_pvt);
if (sofia_glue_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
if (tech_pvt->local_sdp_str) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ring SDP:\n%s\n", tech_pvt->local_sdp_str);
}
......@@ -843,7 +848,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
if (!(tech_pvt = (struct private_object *) switch_core_session_alloc(nsession, sizeof(*tech_pvt)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n");
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __FILE__, __LINE__);
goto done;
}
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession));
......@@ -858,7 +863,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
if (!(gw = strchr(profile_name, '/'))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __FILE__, __LINE__);
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
goto done;
}
......@@ -867,7 +872,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
if (!(dest = strchr(gw, '/'))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __FILE__, __LINE__);
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
goto done;
}
......@@ -876,7 +881,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
if (!(gateway_ptr = sofia_reg_find_gateway(gw))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Gateway\n");
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __FILE__, __LINE__);
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
goto done;
}
......@@ -892,7 +897,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
} else {
if (!(dest = strchr(profile_name, '/'))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __FILE__, __LINE__);
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
goto done;
}
......@@ -900,7 +905,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
if (!(profile = sofia_glue_find_profile(profile_name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n");
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
sofia_glue_terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __FILE__, __LINE__);
cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
goto done;
}
......@@ -922,7 +927,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest, host);
cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION;
sofia_glue_terminate_session(&nsession, cause, __LINE__);
sofia_glue_terminate_session(&nsession, cause, __FILE__, __LINE__);
goto done;
}
} else if (!strchr(dest, '@')) {
......@@ -934,7 +939,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest, profile_name);
cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION;
sofia_glue_terminate_session(&nsession, cause, __LINE__);
sofia_glue_terminate_session(&nsession, cause, __FILE__, __LINE__);
goto done;
}
} else {
......
......@@ -309,6 +309,7 @@ struct private_object {
nua_handle_t *nh;
nua_handle_t *nh2;
sip_contact_t *contact;
int hangup_status;
};
struct callback_t {
......@@ -338,25 +339,20 @@ void sofia_glue_deactivate_rtp(private_object_t *tech_pvt);
void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, char *sr, int force);
void sofia_glue_sofia_glue_tech_set_codecs(private_object_t *tech_pvt);
void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt);
void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame);
void sofia_glue_terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line);
void sofia_glue_terminate_session(switch_core_session_t **session, switch_call_cause_t cause, const char *file, int line);
switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt);
switch_status_t sofia_glue_do_invite(switch_core_session_t *session);
uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp);
uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp);
void sofia_presence_establish_presence(sofia_profile_t *profile);
void sofia_handle_sip_i_state(int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
......
......@@ -139,7 +139,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por
tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf);
}
void sofia_glue_sofia_glue_tech_set_codecs(private_object_t *tech_pvt)
void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
{
switch_channel_t *channel;
char *abs, *codec_string = NULL;
......@@ -232,13 +232,13 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
switch_channel_set_name(channel, name);
//sofia_glue_sofia_glue_tech_set_codecs(tech_pvt);
//sofia_glue_tech_prepare_codecs(tech_pvt);
}
void sofia_glue_terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line)
void sofia_glue_terminate_session(switch_core_session_t **session, switch_call_cause_t cause, const char *file, int line)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from line: %d\n", line);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from %s line: %d\n", file, line);
if (*session) {
switch_channel_t *channel = switch_core_session_get_channel(*session);
struct private_object *tech_pvt = NULL;
......@@ -306,7 +306,7 @@ switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt)
if (tech_pvt->profile->extrtpip) {
if (sofia_glue_ext_address_lookup(&ip, &sdp_port, tech_pvt->profile->extrtpip, switch_core_session_get_pool(tech_pvt->session)) !=
SWITCH_STATUS_SUCCESS) {
sofia_glue_terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
sofia_glue_terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __FILE__, __LINE__);
return SWITCH_STATUS_FALSE;
}
}
......@@ -356,7 +356,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
cid_name = (char *) caller_profile->caller_id_name;
cid_num = (char *) caller_profile->caller_id_number;
sofia_glue_sofia_glue_tech_set_codecs(tech_pvt);
sofia_glue_tech_prepare_codecs(tech_pvt);
if (!tech_pvt->from_str) {
tech_pvt->from_str = switch_core_session_sprintf(tech_pvt->session, "\"%s\" <sip:%s@%s>",
......@@ -609,7 +609,6 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
if (!tech_pvt->rm_encoding) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n");
sofia_glue_terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
return SWITCH_STATUS_FALSE;
}
......@@ -622,7 +621,6 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
sofia_glue_terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
return SWITCH_STATUS_FALSE;
} else {
if (switch_core_codec_init(&tech_pvt->write_codec,
......@@ -634,7 +632,6 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
sofia_glue_terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
return SWITCH_STATUS_FALSE;
} else {
int ms;
......@@ -643,7 +640,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set Codec %s %s/%ld %d ms\n",
switch_channel_get_name(channel), tech_pvt->rm_encoding, tech_pvt->rm_rate, tech_pvt->codec_ms);
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
tech_pvt->fmtp_out = switch_core_session_strdup(tech_pvt->session, tech_pvt->write_codec.fmtp_out);
......@@ -763,7 +760,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt)
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
sofia_glue_terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
sofia_glue_terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __FILE__, __LINE__);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
return SWITCH_STATUS_FALSE;
}
......@@ -787,7 +784,7 @@ switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, char *r_sdp)
if (tech_pvt->num_codecs) {
if ((sdp = sdp_session(parser))) {
match = negotiate_sdp(tech_pvt->session, sdp);
match = sofia_glue_negotiate_sdp(tech_pvt->session, sdp);
}
}
......@@ -799,7 +796,9 @@ switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, char *r_sdp)
if (sofia_glue_tech_choose_port(tech_pvt) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
sofia_glue_activate_rtp(tech_pvt);
if (sofia_glue_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
switch_channel_mark_pre_answered(channel);
......@@ -811,7 +810,7 @@ switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, char *r_sdp)
uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
{
uint8_t match = 0;
switch_payload_t te = 0, cng_pt = 0;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论