[Freeswitch-svn] [commit] r7707 - in freeswitch/trunk/src: . mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Tue Feb 19 22:57:02 EST 2008
Author: anthm
Date: Tue Feb 19 22:57:01 2008
New Revision: 7707
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_ivr_bridge.c
freeswitch/trunk/src/switch_ivr_originate.c
Log:
better handling of negotiation errs
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 Feb 19 22:57:01 2008
@@ -354,7 +354,7 @@
sofia_glue_tech_prepare_codecs(tech_pvt);
if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
- nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ //nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
return SWITCH_STATUS_FALSE;
}
}
@@ -967,7 +967,7 @@
}
break;
case SWITCH_MESSAGE_INDICATE_ANSWER:
- sofia_answer_channel(session);
+ return sofia_answer_channel(session);
break;
case SWITCH_MESSAGE_INDICATE_PROGRESS:
{
@@ -975,7 +975,7 @@
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 */
if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
const char *sdp = NULL;
@@ -985,13 +985,15 @@
} else {
if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
+
if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
+
tech_pvt->num_codecs = 0;
sofia_glue_tech_prepare_codecs(tech_pvt);
if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
- nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ //nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
return SWITCH_STATUS_FALSE;
}
}
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Tue Feb 19 22:57:01 2008
@@ -1390,9 +1390,11 @@
msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
msg.from = channel->name;
status = switch_core_session_receive_message(channel->session, &msg);
-
+
if (status == SWITCH_STATUS_SUCCESS) {
- status = switch_channel_perform_mark_pre_answered(channel, file, func, line);
+ switch_channel_perform_mark_pre_answered(channel, file, func, line);
+ } else {
+ switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
return status;
@@ -1423,6 +1425,8 @@
if (status == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
+ } else {
+ switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
return status;
@@ -1487,17 +1491,17 @@
return SWITCH_STATUS_SUCCESS;
}
-
msg.message_id = SWITCH_MESSAGE_INDICATE_ANSWER;
msg.from = channel->name;
status = switch_core_session_receive_message(channel->session, &msg);
if (status == SWITCH_STATUS_SUCCESS) {
- return switch_channel_perform_mark_answered(channel, file, func, line);
+ switch_channel_perform_mark_answered(channel, file, func, line);
+ } else {
+ switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
- return SWITCH_STATUS_FALSE;
-
+ return status;
}
#define resize(l) {\
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Tue Feb 19 22:57:01 2008
@@ -209,10 +209,16 @@
if (!ans_a && originator) {
if (!ans_b && switch_channel_test_flag(chan_b, CF_ANSWERED)) {
- switch_channel_answer(chan_a);
+ if (switch_channel_answer(chan_a) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(chan_a));
+ break;
+ }
ans_a++;
} else if (!pre_b && switch_channel_test_flag(chan_b, CF_EARLY_MEDIA)) {
- switch_channel_pre_answer(chan_a);
+ if (switch_channel_pre_answer(chan_a) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(chan_a));
+ break;
+ }
pre_b++;
}
if (!pre_b) {
@@ -605,6 +611,8 @@
int stream_id = 0;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_channel_state_t state;
+ switch_event_t *event;
+ int br = 0;
switch_channel_set_flag(caller_channel, CF_ORIGINATOR);
switch_channel_clear_flag(caller_channel, CF_TRANSFER);
@@ -630,7 +638,6 @@
if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) ||
switch_channel_test_flag(peer_channel, CF_RING_READY)) {
- switch_event_t *event;
switch_core_session_message_t msg = { 0 };
const switch_application_interface_t *application_interface;
const char *app, *data;
@@ -640,8 +647,9 @@
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(caller_channel, event);
switch_event_fire(&event);
+ br = 1;
}
-
+
if (switch_core_session_read_lock(peer_session) == SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
@@ -713,11 +721,6 @@
switch_channel_set_state(peer_channel, CS_LOOPBACK);
audio_bridge_thread(NULL, (void *) a_leg);
- if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
- switch_channel_event_set_data(caller_channel, event);
- switch_event_fire(&event);
- }
-
switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
//make sure this doesnt break anything
@@ -747,6 +750,11 @@
done:
+ if (br && switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(caller_channel, event);
+ switch_event_fire(&event);
+ }
+
state = switch_channel_get_state(caller_channel);
if (!switch_channel_test_flag(caller_channel, CF_TRANSFER)) {
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Tue Feb 19 22:57:01 2008
@@ -908,7 +908,10 @@
if (ringback_data && !switch_channel_test_flag(caller_channel, CF_ANSWERED)
&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
- switch_channel_pre_answer(caller_channel);
+ if ((status = switch_channel_pre_answer(caller_channel)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(caller_channel));
+ goto done;
+ }
}
if (session && (read_codec = switch_core_session_get_read_codec(session)) &&
@@ -1132,9 +1135,16 @@
if (caller_channel) {
if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
- switch_channel_answer(caller_channel);
+ status = switch_channel_answer(caller_channel);
} else if (switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
- switch_channel_pre_answer(caller_channel);
+ status = switch_channel_pre_answer(caller_channel);
+ } else {
+ status = SWITCH_STATUS_SUCCESS;
+ }
+
+ if (status != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(caller_channel));
+ switch_channel_hangup(peer_channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
}
More information about the Freeswitch-svn
mailing list