[Freeswitch-svn] [commit] r4192 - in freeswitch/trunk/src: . mod/applications/mod_bridgecall mod/applications/mod_dptools mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Sat Feb 10 14:34:04 EST 2007
Author: anthm
Date: Sat Feb 10 14:34:03 2007
New Revision: 4192
Modified:
freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/switch_ivr.c
Log:
fix no_media mode
Modified: freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c Sat Feb 10 14:34:03 2007
@@ -83,7 +83,6 @@
if (no_media_bridge) {
switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
switch_frame_t *read_frame;
-
/* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */
while(switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel) && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, -1, 0);
@@ -92,7 +91,6 @@
if (SWITCH_READ_ACCEPTABLE(status) && switch_core_session_write_frame(session, read_frame, -1, 0) == SWITCH_STATUS_SUCCESS) {
bad = 0;
}
-
if (bad) {
switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Sat Feb 10 14:34:03 2007
@@ -162,6 +162,15 @@
switch_channel_answer(channel);
}
+static void pre_answer_function(switch_core_session_t *session, char *data)
+{
+ switch_channel_t *channel;
+ channel = switch_core_session_get_channel(session);
+
+ assert(channel != NULL);
+ switch_channel_pre_answer(channel);
+}
+
static void redirect_function(switch_core_session_t *session, char *data)
{
switch_core_session_message_t msg = {0};
@@ -595,13 +604,23 @@
};
+static const switch_application_interface_t pre_answer_application_interface = {
+ /*.interface_name */ "pre_answer",
+ /*.application_function */ pre_answer_function,
+ /* long_desc */ "Pre-Answer the call for a channel.",
+ /* short_desc */ "Pre-Answer the call",
+ /* syntax */ "",
+ /*.next */ &hangup_application_interface
+
+};
+
static const switch_application_interface_t eval_application_interface = {
/*.interface_name */ "eval",
/*.application_function */ eval_function,
/* long_desc */ "Do Nothing",
/* short_desc */ "Do Nothing",
/* syntax */ "",
- /*.next */ &answer_application_interface
+ /*.next */ &pre_answer_application_interface
};
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 Sat Feb 10 14:34:03 2007
@@ -1604,47 +1604,47 @@
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
- if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
- char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
- if (tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
- switch_channel_set_variable(channel, "endpoint_disposition", "CODEC NEGOTIATION ERROR");
- nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
- return SWITCH_STATUS_FALSE;
- }
- switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
- }
-
- if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
- switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
- tech_absorb_sdp(tech_pvt);
- }
-
if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
switch_set_flag_locked(tech_pvt, TFLAG_ANS);
+ if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+ char *sdp = NULL;
+ switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+ if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
+ tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
+ }
+ } else {
+ if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
+ char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
+ if (tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_set_variable(channel, "endpoint_disposition", "CODEC NEGOTIATION ERROR");
+ nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ return SWITCH_STATUS_FALSE;
+ }
+ switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
+ }
- if ((status = tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
- return status;
- }
+ if ((status = tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
+ return status;
+ }
- set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
- activate_rtp(tech_pvt);
+ set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
+ activate_rtp(tech_pvt);
- if (tech_pvt->nh) {
- if (tech_pvt->local_sdp_str) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n",
- switch_channel_get_name(channel),
+ if (tech_pvt->nh) {
+ if (tech_pvt->local_sdp_str) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n",
+ switch_channel_get_name(channel),
tech_pvt->local_sdp_str);
+ }
}
- nua_respond(tech_pvt->nh, SIP_200_OK,
- SIPTAG_CONTACT_STR(tech_pvt->profile->url),
- SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
- SOATAG_AUDIO_AUX("cn telephone-event"),
- NUTAG_INCLUDE_EXTRA_SDP(1),
- TAG_END());
-
}
+ nua_respond(tech_pvt->nh, SIP_200_OK,
+ SIPTAG_CONTACT_STR(tech_pvt->profile->url),
+ SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
+ SOATAG_AUDIO_AUX("cn telephone-event"),
+ NUTAG_INCLUDE_EXTRA_SDP(1),
+ TAG_END());
}
return SWITCH_STATUS_SUCCESS;
@@ -1842,7 +1842,9 @@
switch(sig) {
case SWITCH_SIG_BREAK:
- switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK);
+ if (switch_rtp_ready(tech_pvt->rtp_session)) {
+ switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK);
+ }
break;
case SWITCH_SIG_KILL:
default:
@@ -2024,36 +2026,38 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
- if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
- char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
- if (tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
- switch_channel_set_variable(channel, "endpoint_disposition", "CODEC NEGOTIATION ERROR");
- nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
- return SWITCH_STATUS_FALSE;
- }
- switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
- }
-
- if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA) && !switch_test_flag(tech_pvt, TFLAG_ANS)) {
+ if (!switch_test_flag(tech_pvt, TFLAG_ANS)) {
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);
-
- if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
- tech_absorb_sdp(tech_pvt);
- }
-
/* Transmit 183 Progress with SDP */
- if ((status=tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
- return status;
- }
- set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
- activate_rtp(tech_pvt);
- 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);
- }
+ if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+ char *sdp = NULL;
+ switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+ if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
+ tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
+ }
+ } else {
+ if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
+ char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
+ if (tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_set_variable(channel, "endpoint_disposition", "CODEC NEGOTIATION ERROR");
+ nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ return SWITCH_STATUS_FALSE;
+ }
+ switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
+ }
+ if ((status=tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
+ return status;
+ }
+ set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
+ activate_rtp(tech_pvt);
+ 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);
+ }
+ }
+
nua_respond(tech_pvt->nh,
SIP_183_SESSION_PROGRESS,
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
@@ -2786,24 +2790,31 @@
}
}
}
+
if (r_sdp) {
if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
switch_channel_mark_pre_answered(channel);
if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
other_channel = switch_core_session_get_channel(other_session);
+ if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
+ switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, (char *)r_sdp);
+ }
+
switch_channel_pre_answer(other_channel);
switch_core_session_rwunlock(other_session);
}
goto done;
- } else if (!switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
- if (tech_media(tech_pvt, (char *)r_sdp) != SWITCH_STATUS_SUCCESS) {
- switch_channel_set_variable(channel, "endpoint_disposition", "CODEC NEGOTIATION ERROR");
- nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
- }
- goto done;
- } else {
- switch_channel_set_variable(channel, "endpoint_disposition", "DELAYED NEGOTIATION");
+ } else {
+ if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
+ switch_channel_set_variable(channel, "endpoint_disposition", "DELAYED NEGOTIATION");
+ } else {
+ if (tech_media(tech_pvt, (char *)r_sdp) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_set_variable(channel, "endpoint_disposition", "CODEC NEGOTIATION ERROR");
+ nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ }
+ }
+ goto done;
}
}
}
@@ -2932,12 +2943,29 @@
}
if (channel) {
+ if (switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
+ switch_set_flag_locked(tech_pvt, TFLAG_ANS);
+ switch_channel_mark_answered(channel);
+ if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+ other_channel = switch_core_session_get_channel(other_session);
+ switch_channel_answer(other_channel);
+ switch_core_session_rwunlock(other_session);
+ }
+ goto done;
+ }
+
+ if (!r_sdp) {
+ r_sdp = (const char *) switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
+ }
if (r_sdp) {
if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
switch_set_flag_locked(tech_pvt, TFLAG_ANS);
switch_channel_mark_answered(channel);
if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
other_channel = switch_core_session_get_channel(other_session);
+ if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
+ switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, (char *)r_sdp);
+ }
switch_channel_answer(other_channel);
switch_core_session_rwunlock(other_session);
}
@@ -2970,16 +2998,8 @@
switch_channel_set_variable(channel, "endpoint_disposition", "NO CODECS");
nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
}
- } else if (switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
- switch_set_flag_locked(tech_pvt, TFLAG_ANS);
- switch_channel_mark_answered(channel);
- if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
- other_channel = switch_core_session_get_channel(other_session);
- switch_channel_answer(other_channel);
- switch_core_session_rwunlock(other_session);
- }
- goto done;
- } //else probably an ack
+ }
+
}
break;
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Sat Feb 10 14:34:03 2007
@@ -2552,7 +2552,7 @@
file = NULL;
}
- if ((var_val = switch_event_get_header(var_event, "noanswer_early_media")) && switch_true(var_val)) {
+ if ((var_val = switch_event_get_header(var_event, "ignore_early_media")) && switch_true(var_val)) {
early_ok = 0;
}
@@ -2755,9 +2755,8 @@
switch_channel_pre_answer(caller_channel);
}
- if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
- read_codec = switch_core_session_get_read_codec(session);
- assert(read_codec != NULL);
+ if (session && (read_codec = switch_core_session_get_read_codec(session)) &&
+ (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
if (!(pass = (uint8_t)switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
if (switch_core_codec_init(&write_codec,
More information about the Freeswitch-svn
mailing list