[Freeswitch-svn] [commit] r4955 - freeswitch/trunk/src/mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Tue Apr 17 02:08:40 EDT 2007
Author: anthm
Date: Tue Apr 17 02:08:39 2007
New Revision: 4955
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
Log:
</refactor>
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Apr 17 02:08:39 2007
@@ -300,7 +300,9 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
} 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 @@
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 @@
} 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 @@
} 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 {
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Tue Apr 17 02:08:39 2007
@@ -309,6 +309,7 @@
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_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[]);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Apr 17 02:08:39 2007
@@ -36,6 +36,9 @@
#include "mod_sofia.h"
extern su_log_t tport_log[];
+static void sofia_handle_sip_i_state(switch_core_session_t *session, 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_event_callback(nua_event_t event,
int status,
@@ -144,7 +147,7 @@
case nua_i_prack:
break;
case nua_i_state:
- sofia_handle_sip_i_state(status, phrase, nua, profile, nh, sofia_private, sip, tags);
+ sofia_handle_sip_i_state(session, status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_message:
sofia_presence_handle_sip_i_message(status, phrase, nua, profile, nh, sofia_private, sip, tags);
@@ -177,7 +180,18 @@
done:
if (session) {
- switch_core_session_rwunlock(session);
+ if (tech_pvt->hangup_status) {
+ if (!switch_core_session_running(session)) {
+ switch_core_session_rwunlock(session);
+ switch_core_session_destroy(&session);
+ } else {
+ switch_channel_hangup(channel, sofia_glue_sip_cause_to_freeswitch(tech_pvt->hangup_status));
+ switch_core_session_rwunlock(session);
+ }
+ tech_pvt->hangup_status = 0;
+ } else {
+ switch_core_session_rwunlock(session);
+ }
}
}
@@ -801,16 +815,15 @@
}
-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[])
+static void sofia_handle_sip_i_state(switch_core_session_t *session, 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[])
{
const char *l_sdp = NULL, *r_sdp = NULL;
int offer_recv = 0, answer_recv = 0, offer_sent = 0, answer_sent = 0;
int ss_state = nua_callstate_init;
switch_channel_t *channel = NULL;
private_object_t *tech_pvt = NULL;
- switch_core_session_t *session = NULL;
const char *replaces_str = NULL;
char *uuid;
switch_core_session_t *other_session = NULL;
@@ -818,16 +831,6 @@
char st[80] = "";
- if (sofia_private) {
- if (!switch_strlen_zero(sofia_private->uuid)) {
- if (!(session = switch_core_session_locate(sofia_private->uuid))) {
- /* too late */
- return;
- }
- }
- }
-
-
tl_gets(tags,
NUTAG_CALLSTATE_REF(ss_state),
NUTAG_OFFER_RECV_REF(offer_recv),
@@ -916,6 +919,7 @@
if (sofia_glue_tech_media(tech_pvt, (char *) r_sdp) != SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
}
goto done;
@@ -942,20 +946,19 @@
switch_core_session_thread_launch(session);
goto done;
} else {
- sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
+ sdp_parser_t *parser;
sdp_session_t *sdp;
uint8_t match = 0;
if (tech_pvt->num_codecs) {
- if ((sdp = sdp_session(parser))) {
- match = negotiate_sdp(session, sdp);
+ if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
+ if ((sdp = sdp_session(parser))) {
+ match = sofia_glue_negotiate_sdp(session, sdp);
+ }
+ sdp_parser_free(parser);
}
}
-
- if (parser) {
- sdp_parser_free(parser);
- }
-
+
if (match) {
nua_handle_t *bnh;
sip_replaces_t *replaces;
@@ -1023,13 +1026,16 @@
if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
goto done;
} else {
- sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
+ sdp_parser_t *parser;
sdp_session_t *sdp;
uint8_t match = 0;
if (tech_pvt->num_codecs) {
- if ((sdp = sdp_session(parser))) {
- match = negotiate_sdp(session, sdp);
+ if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
+ if ((sdp = sdp_session(parser))) {
+ match = sofia_glue_negotiate_sdp(session, sdp);
+ }
+ sdp_parser_free(parser);
}
}
if (match) {
@@ -1038,11 +1044,14 @@
}
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
- sofia_glue_activate_rtp(tech_pvt);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Processing Reinvite\n");
- if (parser) {
- sdp_parser_free(parser);
+ if (sofia_glue_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reinvite RTP Error!\n");
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Processing Reinvite\n");
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reinvite Codec Error!\n");
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
}
}
@@ -1055,7 +1064,10 @@
tech_pvt->nh = tech_pvt->nh2;
tech_pvt->nh2 = NULL;
if (sofia_glue_tech_choose_port(tech_pvt) == SWITCH_STATUS_SUCCESS) {
- sofia_glue_activate_rtp(tech_pvt);
+ if (sofia_glue_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cheater Reinvite RTP Error!\n");
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ }
}
goto done;
}
@@ -1091,26 +1103,28 @@
}
goto done;
} else {
- sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
+ sdp_parser_t *parser;
sdp_session_t *sdp;
uint8_t match = 0;
if (tech_pvt->num_codecs) {
- if ((sdp = sdp_session(parser))) {
- match = negotiate_sdp(session, sdp);
+ if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
+ if ((sdp = sdp_session(parser))) {
+ match = sofia_glue_negotiate_sdp(session, sdp);
+ }
+ sdp_parser_free(parser);
}
}
- if (parser) {
- sdp_parser_free(parser);
- }
-
-
if (match) {
switch_set_flag_locked(tech_pvt, TFLAG_ANS);
if (sofia_glue_tech_choose_port(tech_pvt) == SWITCH_STATUS_SUCCESS) {
- sofia_glue_activate_rtp(tech_pvt);
- switch_channel_mark_answered(channel);
+ if (sofia_glue_activate_rtp(tech_pvt) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_mark_answered(channel);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP Error!\n");
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ }
goto done;
}
}
@@ -1128,25 +1142,26 @@
case nua_callstate_terminated:
if (session) {
if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
-
switch_set_flag_locked(tech_pvt, TFLAG_BYE);
if (switch_test_flag(tech_pvt, TFLAG_NOHUP)) {
switch_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
} else {
snprintf(st, sizeof(st), "%d", status);
switch_channel_set_variable(channel, "sip_term_status", st);
- sofia_glue_terminate_session(&session, sofia_glue_sip_cause_to_freeswitch(status), __LINE__);
+ tech_pvt->hangup_status = status;
}
}
if (tech_pvt->sofia_private) {
- if (sofia_private->home) {
- su_home_unref(sofia_private->home);
+ if (tech_pvt->sofia_private->home) {
+ su_home_unref(tech_pvt->sofia_private->home);
}
free(tech_pvt->sofia_private);
tech_pvt->sofia_private = NULL;
}
+
tech_pvt->nh = NULL;
+
} else if (sofia_private) {
if (sofia_private->home) {
su_home_unref(sofia_private->home);
@@ -1163,9 +1178,7 @@
done:
- if (session) {
- switch_core_session_rwunlock(session);
- }
+ return;
}
@@ -1277,10 +1290,11 @@
tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(session, br_b_tech_pvt->remote_sdp_audio_ip);
tech_pvt->remote_sdp_audio_port = br_b_tech_pvt->remote_sdp_audio_port;
- sofia_glue_activate_rtp(tech_pvt);
-
- br_b_tech_pvt->kick = switch_core_session_strdup(br_b_session, switch_core_session_get_uuid(session));
-
+ if (sofia_glue_activate_rtp(tech_pvt) == SWITCH_STATUS_SUCCESS) {
+ br_b_tech_pvt->kick = switch_core_session_strdup(br_b_session, switch_core_session_get_uuid(session));
+ } else {
+ switch_channel_hangup(channel_a, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ }
switch_core_session_rwunlock(br_b_session);
}
@@ -1586,7 +1600,7 @@
if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END());
- sofia_glue_terminate_session(&session, SWITCH_CAUSE_SWITCH_CONGESTION, __LINE__);
+ sofia_glue_terminate_session(&session, SWITCH_CAUSE_SWITCH_CONGESTION, __FILE__, __LINE__);
return;
}
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
@@ -1650,7 +1664,7 @@
}
sofia_glue_attach_private(session, profile, tech_pvt, channel_name);
- sofia_glue_sofia_glue_tech_set_codecs(tech_pvt);
+ sofia_glue_tech_prepare_codecs(tech_pvt);
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL");
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Tue Apr 17 02:08:39 2007
@@ -139,7 +139,7 @@
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 @@
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 @@
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 @@
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 @@
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_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_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_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 @@
} 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 @@
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 @@
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 @@
-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;
More information about the Freeswitch-svn
mailing list