[Freeswitch-svn] [commit] r3461 - in freeswitch/trunk/src: . include mod/applications/mod_bridgecall mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Mon Nov 27 16:52:39 EST 2006
Author: anthm
Date: Mon Nov 27 16:52:38 2006
New Revision: 3461
Modified:
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/switch_ivr.c
Log:
no_media/ringback tweaks
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Mon Nov 27 16:52:38 2006
@@ -465,7 +465,8 @@
CF_CONTROLLED = (1 << 12),
CF_NOMEDIA = (1 << 13),
CF_SUSPEND = (1 << 14),
- CF_EVENT_PARSE = (1 << 15)
+ CF_EVENT_PARSE = (1 << 15),
+ CF_NO_INDICATE = (1 << 16)
} switch_channel_flag_t;
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 Mon Nov 27 16:52:38 2006
@@ -42,6 +42,7 @@
switch_core_session_t *peer_session;
unsigned int timelimit = 60;
char *var;
+ uint8_t no_media_bridge = 0;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
caller_channel = switch_core_session_get_channel(session);
@@ -50,9 +51,14 @@
if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
timelimit = atoi(var);
}
-
- if ((var = switch_channel_get_variable(caller_channel, "no_media"))) {
- switch_channel_set_flag(caller_channel, CF_NOMEDIA);
+
+ if ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var)) {
+ if (!switch_channel_test_flag(caller_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
+ switch_channel_set_flag(caller_channel, CF_NOMEDIA);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying point-to-point mode 'till both legs are up.\n");
+ no_media_bridge = 1;
+ }
}
if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
@@ -61,10 +67,17 @@
switch_channel_hangup(caller_channel, cause);
return;
} else {
- if (switch_channel_test_flag(caller_channel, CF_NOMEDIA)) {
- switch_ivr_signal_bridge(session, peer_session);
+ if (no_media_bridge) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting media to point-to-point mode.\n");
+ switch_ivr_nomedia(switch_core_session_get_uuid(session), SMF_FORCE);
+ switch_ivr_nomedia(switch_core_session_get_uuid(peer_session), SMF_FORCE);
+ switch_ivr_signal_bridge(session, peer_session);
} else {
- switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
+ if (switch_channel_test_flag(caller_channel, CF_NOMEDIA)) {
+ switch_ivr_signal_bridge(session, peer_session);
+ } else {
+ switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
+ }
}
}
}
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 Mon Nov 27 16:52:38 2006
@@ -2441,9 +2441,10 @@
if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
}
+
if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (
switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
- switch_channel_test_flag(other_channel, CF_NOMEDIA) &&
+ //switch_channel_test_flag(other_channel, CF_NOMEDIA) &&
switch_channel_test_flag(channel, CF_OUTBOUND) &&
switch_channel_test_flag(channel, CF_NOMEDIA))) {
switch_ivr_nomedia(val, SMF_FORCE);
@@ -2526,7 +2527,7 @@
break;
case nua_callstate_proceeding:
if (channel) {
- if (status == 180) {
+ if (status == 180 && !(switch_channel_test_flag(channel, CF_NO_INDICATE))) {
if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
switch_core_session_message_t msg;
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Mon Nov 27 16:52:38 2006
@@ -2443,6 +2443,8 @@
peer_channels[i] = switch_core_session_get_channel(peer_sessions[i]);
assert(peer_channels[i] != NULL);
+ //switch_channel_set_flag(peer_channels[i], CF_NO_INDICATE);
+
if (table == &noop_state_handler) {
table = NULL;
} else if (!table) {
@@ -2501,7 +2503,7 @@
switch_channel_pre_answer(caller_channel);
}
- if (session && !switch_channel_test_flag(caller_channel, CF_NOMEDIA)) {
+ 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);
@@ -2527,6 +2529,7 @@
if (ringback_data) {
char *tmp_data = NULL;
+
switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
switch_buffer_create_dynamic(&ringback.loop_buffer, 512, 1024, 0);
@@ -2581,7 +2584,7 @@
}
}
}
-
+
while ((!caller_channel || switch_channel_ready(caller_channel)) &&
check_channel_status(peer_channels, peer_sessions, and_argc, &idx, file, key, ringback_data)) {
@@ -2603,13 +2606,14 @@
}
/* read from the channel while we wait if the audio is up on it */
- if (session && !switch_channel_test_flag(caller_channel, CF_NOMEDIA) &&
+ if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA)) &&
(switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {
switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
}
+
if (read_frame && !pass && !switch_test_flag(read_frame, SFF_CNG) && read_frame->datalen > 1) {
if (ringback.fh) {
uint8_t abuf[1024];
@@ -2653,7 +2657,8 @@
break;
}
}
- }
+ }
+
if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
break;
}
@@ -2674,7 +2679,7 @@
idx = IDX_CANCEL;
}
- if (session && !switch_channel_test_flag(caller_channel, CF_NOMEDIA)) {
+ if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
switch_core_session_reset(session);
}
More information about the Freeswitch-svn
mailing list