update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2401 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
ac2b1e2269
commit
f83a8ecf46
|
@ -111,7 +111,7 @@ static void playback_function(switch_core_session_t *session, char *data)
|
|||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_channel_answer(channel);
|
||||
switch_channel_pre_answer(channel);
|
||||
|
||||
if (switch_ivr_play_file(session, NULL, file_name, timer_name, on_dtmf, NULL, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
|
|
|
@ -205,7 +205,7 @@ static void attach_private(switch_core_session_t *session,
|
|||
private_object_t *tech_pvt,
|
||||
char *channame);
|
||||
|
||||
static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause);
|
||||
static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line);
|
||||
|
||||
static switch_status_t tech_choose_port(private_object_t *tech_pvt);
|
||||
|
||||
|
@ -358,16 +358,17 @@ static void attach_private(switch_core_session_t *session,
|
|||
switch_channel_set_name(channel, name);
|
||||
}
|
||||
|
||||
static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause)
|
||||
static void terminate_session(switch_core_session_t **session, switch_call_cause_t cause, int line)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Term called from line: %d\n", line);
|
||||
if (*session) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(*session);
|
||||
switch_channel_state_t state = switch_channel_get_state(channel);
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
||||
tech_pvt = switch_core_session_get_private(*session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
if (tech_pvt) {
|
||||
if (state > CS_INIT && state < CS_HANGUP) {
|
||||
switch_channel_hangup(channel, cause);
|
||||
}
|
||||
|
@ -376,14 +377,14 @@ static void terminate_session(switch_core_session_t **session, switch_call_cause
|
|||
if (state > CS_INIT && state < CS_HANGUP) {
|
||||
sofia_on_hangup(*session);
|
||||
}
|
||||
|
||||
switch_core_session_destroy(session);
|
||||
|
||||
}
|
||||
} else {
|
||||
switch_core_session_destroy(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t tech_choose_port(private_object_t *tech_pvt)
|
||||
{
|
||||
char *ip = tech_pvt->profile->rtpip;
|
||||
|
@ -404,7 +405,7 @@ static switch_status_t tech_choose_port(private_object_t *tech_pvt)
|
|||
char *stun_ip = tech_pvt->profile->extrtpip + 5;
|
||||
if (!stun_ip) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! NO STUN SERVER\n");
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
if (switch_stun_lookup(&ip,
|
||||
|
@ -414,7 +415,7 @@ static switch_status_t tech_choose_port(private_object_t *tech_pvt)
|
|||
&err,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, err);
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success [%s]:[%d]\n", ip, sdp_port);
|
||||
|
@ -457,9 +458,9 @@ static void do_invite(switch_core_session_t *session)
|
|||
}
|
||||
|
||||
/*
|
||||
State methods they get called when the state changes to the specific state
|
||||
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
|
||||
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
|
||||
State methods they get called when the state changes to the specific state
|
||||
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
|
||||
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
|
||||
*/
|
||||
static switch_status_t sofia_on_init(switch_core_session_t *session)
|
||||
{
|
||||
|
@ -608,7 +609,7 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
|
|||
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");
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
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,
|
||||
|
@ -620,7 +621,7 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
|
|||
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");
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
int ms;
|
||||
|
@ -683,7 +684,7 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
|
|||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
terminate_session(&tech_pvt->session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
@ -980,13 +981,13 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
|||
assert(tech_pvt != NULL);
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
|
||||
/* Transmit 183 Progress with SDP */
|
||||
tech_choose_port(tech_pvt);
|
||||
set_local_sdp(tech_pvt);
|
||||
activate_rtp(tech_pvt);
|
||||
//help me this 183 line will not work. The resulting 183 has no sdp, sigh...
|
||||
nua_respond(tech_pvt->nh, SIP_183_SESSION_PROGRESS, SOATAG_LOCAL_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
|
||||
nua_respond(tech_pvt->nh, SIP_183_SESSION_PROGRESS, SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
|
||||
//nua_respond(tech_pvt->nh, SIP_200_OK, SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), TAG_END());
|
||||
}
|
||||
}
|
||||
|
@ -1056,7 +1057,7 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw
|
|||
|
||||
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");
|
||||
terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -1065,7 +1066,7 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw
|
|||
|
||||
if (!(dest = strchr(profile_name, '/'))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
|
||||
terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1074,7 @@ static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, sw
|
|||
|
||||
if (!(profile = (sofia_profile_t *) switch_core_hash_find(globals.profile_hash, profile_name))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n");
|
||||
terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
terminate_session(&nsession, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -1224,7 +1225,7 @@ static void sip_i_state(int status,
|
|||
if (match) {
|
||||
tech_choose_port(tech_pvt);
|
||||
activate_rtp(tech_pvt);
|
||||
switch_channel_set_variable(channel, "endpoint_disposition", "PROGRESS");
|
||||
switch_channel_set_variable(channel, "endpoint_disposition", "EARLY MEDIA");
|
||||
switch_channel_pre_answer(channel);
|
||||
return;
|
||||
}
|
||||
|
@ -1273,7 +1274,8 @@ static void sip_i_state(int status,
|
|||
case nua_callstate_completed:
|
||||
break;
|
||||
case nua_callstate_ready:
|
||||
if (session && r_sdp) {
|
||||
if (session) {
|
||||
if (r_sdp) {
|
||||
su_home_t home[1] = { SU_HOME_INIT(home) };
|
||||
sdp_parser_t *parser = sdp_parse(home, r_sdp, (int)strlen(r_sdp), 0);
|
||||
sdp_session_t *sdp;
|
||||
|
@ -1300,6 +1302,11 @@ static void sip_i_state(int status,
|
|||
switch_channel_answer(channel);
|
||||
return;
|
||||
}
|
||||
} else if (switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
|
||||
switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
|
||||
switch_channel_answer(channel);
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch_channel_set_variable(channel, "endpoint_disposition", "NO CODECS");
|
||||
nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
|
||||
|
@ -1309,7 +1316,7 @@ static void sip_i_state(int status,
|
|||
case nua_callstate_terminated:
|
||||
if (session) {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_BYE);
|
||||
terminate_session(&session, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
terminate_session(&session, SWITCH_CAUSE_NORMAL_CLEARING, __LINE__);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1338,7 +1345,7 @@ static void sip_i_invite(nua_t *nua,
|
|||
|
||||
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");
|
||||
terminate_session(&session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
terminate_session(&session, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1523,6 +1530,7 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
|
|||
profile, /* Additional data to pass to callback */
|
||||
NUTAG_URL(profile->url),
|
||||
NUTAG_EARLY_MEDIA(1),
|
||||
SIPTAG_SUPPORTED_STR("100rel, precondition"),
|
||||
TAG_END()); /* Last tag should always finish the sequence */
|
||||
|
||||
for (node = profile->aliases; node; node = node->next) {
|
||||
|
@ -1531,6 +1539,7 @@ static void *SWITCH_THREAD_FUNC profile_thread_run(switch_thread_t *thread, void
|
|||
profile, /* Additional data to pass to callback */
|
||||
NUTAG_URL(node->url),
|
||||
NUTAG_EARLY_MEDIA(1),
|
||||
SIPTAG_SUPPORTED_STR("100rel, precondition"),
|
||||
TAG_END()); /* Last tag should always finish the sequence */
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue