[Freeswitch-svn] [commit] r10533 - in freeswitch/trunk/src: . include mod/applications/mod_commands mod/endpoints/mod_sofia
FreeSWITCH SVN
anthm at freeswitch.org
Tue Nov 25 09:53:35 PST 2008
Author: anthm
Date: Tue Nov 25 12:53:35 2008
New Revision: 10533
Log:
update
Modified:
freeswitch/trunk/src/include/switch_rtp.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/switch_core_state_machine.c
freeswitch/trunk/src/switch_ivr_bridge.c
freeswitch/trunk/src/switch_rtp.c
Modified: freeswitch/trunk/src/include/switch_rtp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_rtp.h (original)
+++ freeswitch/trunk/src/include/switch_rtp.h Tue Nov 25 12:53:35 2008
@@ -351,6 +351,8 @@
*/
SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_frame_t *frame, switch_io_flag_t io_flags);
+SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session);
+
/*!
\brief Enable VAD on an RTP Session
\param rtp_session the RTP session
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Tue Nov 25 12:53:35 2008
@@ -568,6 +568,7 @@
SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ,
SWITCH_MESSAGE_INDICATE_DISPLAY,
SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY,
+ SWITCH_MESSAGE_INDICATE_AUDIO_SYNC,
SWITCH_MESSAGE_INVALID
} switch_core_session_message_types_t;
@@ -742,7 +743,7 @@
CF_PROXY_MODE = (1 << 13) - Channel has no media
CF_SUSPEND = (1 << 14) - Suspend i/o
CF_EVENT_PARSE = (1 << 15) - Suspend control events
-CF_REPEAT_STATE = (1 << 16) - Tell the state machine to repeat a state
+CF_USE_ME = (1 << 16) - use me
CF_GEN_RINGBACK = (1 << 17) - Channel is generating it's own ringback
CF_RING_READY = (1 << 18) - Channel is ready to send ringback
CF_BREAK = (1 << 19) - Channel should stop what it's doing
@@ -773,7 +774,7 @@
CF_PROXY_MODE = (1 << 13),
CF_SUSPEND = (1 << 14),
CF_EVENT_PARSE = (1 << 15),
- CF_REPEAT_STATE = (1 << 16),
+ CF_USE_ME = (1 << 16),
CF_GEN_RINGBACK = (1 << 17),
CF_RING_READY = (1 << 18),
CF_BREAK = (1 << 19),
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Tue Nov 25 12:53:35 2008
@@ -1127,8 +1127,8 @@
} else if (!strcasecmp(arg, "both")) {
if (uuid && (other_session = switch_core_session_locate(uuid))) {
switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
- switch_channel_set_flag(other_channel, CF_TRANSFER);
- switch_channel_set_flag(channel, CF_TRANSFER);
+ switch_channel_set_flag(other_channel, CF_REDIRECT);
+ switch_channel_set_flag(channel, CF_REDIRECT);
switch_ivr_session_transfer(other_session, dest, dp, context);
switch_core_session_rwunlock(other_session);
}
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 Nov 25 12:53:35 2008
@@ -936,21 +936,11 @@
goto end;
case SWITCH_MESSAGE_INDICATE_BRIDGE:
- /*
- if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
- switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
- }
- */
- goto end;
-
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
- /*
- if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
- switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
- }
- */
+ case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
+ if (switch_rtp_ready(tech_pvt->rtp_session)) {
+ rtp_flush_read_buffer(tech_pvt->rtp_session);
+ }
goto end;
case SWITCH_MESSAGE_INDICATE_ANSWER:
Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c (original)
+++ freeswitch/trunk/src/switch_core_state_machine.c Tue Nov 25 12:53:35 2008
@@ -360,19 +360,15 @@
switch_mutex_lock(session->mutex);
while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
- uint8_t exception = 0;
midstate = state;
- if (switch_channel_test_flag(session->channel, CF_REPEAT_STATE)) {
- switch_channel_clear_flag(session->channel, CF_REPEAT_STATE);
- exception = 1;
- }
- if (state != switch_channel_get_running_state(session->channel) || state == CS_HANGUP || exception) {
+ if (state != switch_channel_get_running_state(session->channel) || state == CS_HANGUP) {
int index = 0;
int proceed = 1;
int do_extra_handlers = 1;
switch_channel_set_running_state(session->channel, state);
switch_channel_clear_flag(session->channel, CF_TRANSFER);
+ switch_channel_clear_flag(session->channel, CF_REDIRECT);
switch (state) {
case CS_NEW: /* Just created, Waiting for first instructions */
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Tue Nov 25 12:53:35 2008
@@ -209,11 +209,11 @@
goto end_of_bridge_loop;
}
- if (switch_channel_test_flag(chan_a, CF_TRANSFER) || switch_channel_test_flag(chan_a, CF_REDIRECT)) {
+ if (switch_channel_test_flag(chan_a, CF_TRANSFER)) {
data->clean_exit = 1;
}
- if (data->clean_exit || switch_channel_test_flag(chan_b, CF_TRANSFER) || switch_channel_test_flag(chan_b, CF_REDIRECT)) {
+ if (data->clean_exit || switch_channel_test_flag(chan_b, CF_TRANSFER)) {
switch_channel_clear_flag(chan_a, CF_HOLD);
switch_channel_clear_flag(chan_a, CF_SUSPEND);
goto end_of_bridge_loop;
@@ -461,15 +461,16 @@
switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers);
state = switch_channel_get_state(channel);
-
+
if (state < CS_HANGUP && switch_true(switch_channel_get_variable(channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
switch_ivr_park_session(session);
} else {
- if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) && bd && !bd->clean_exit && state != CS_PARK &&
- state != CS_ROUTING && !switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
+ if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) && bd && !bd->clean_exit
+ && state != CS_PARK && state != CS_ROUTING && !switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- }
+ }
}
+
if (switch_true(switch_channel_get_variable(channel, SWITCH_COPY_XML_CDR_VARIABLE))) {
switch_xml_t cdr;
@@ -528,8 +529,6 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM RESET\n", switch_channel_get_name(channel));
- switch_channel_clear_flag(channel, CF_REDIRECT);
-
switch_channel_clear_flag(channel, CF_ORIGINATING);
if (switch_channel_test_flag(channel, CF_ORIGINATOR)) {
@@ -621,9 +620,11 @@
}
switch_ivr_multi_threaded_bridge(session, other_session, NULL, NULL, NULL);
-
+
state = switch_channel_get_state(channel);
- if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) && state < CS_HANGUP && state != CS_ROUTING && state != CS_PARK) {
+ if (!switch_channel_test_flag(channel, CF_TRANSFER) &&
+ !switch_channel_test_flag(channel, CF_REDIRECT) && state < CS_HANGUP
+ && state != CS_ROUTING && state != CS_PARK) {
switch_channel_set_state(channel, CS_EXECUTE);
}
switch_core_session_rwunlock(other_session);
@@ -956,10 +957,12 @@
}
if (switch_channel_test_flag(caller_channel, CF_REDIRECT)) {
- switch_channel_set_state(caller_channel, CS_RESET);
+ state = switch_channel_get_state(caller_channel);
+ if (!(state == CS_RESET || state == CS_PARK || state == CS_ROUTING)) {
+ switch_channel_set_state(caller_channel, CS_RESET);
+ }
}
-
-
+
return status;
}
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Tue Nov 25 12:53:35 2008
@@ -1263,6 +1263,40 @@
}
}
+SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session)
+{
+ int was_blocking = 0;
+ switch_size_t bytes;
+ switch_status_t status;
+
+ if (!switch_rtp_ready(rtp_session)) {
+ return;
+ }
+
+ READ_INC(rtp_session);
+
+ if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
+ was_blocking = 1;
+ switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+ switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE);
+ }
+
+ do {
+ bytes = sizeof(rtp_msg_t);
+ status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes);
+ } while(bytes);
+
+ if (was_blocking) {
+ switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+ switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
+ }
+
+ READ_DEC(rtp_session);
+
+
+
+}
+
#define return_cng_frame() do_cng = 1; goto timer_check
static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags)
@@ -1315,6 +1349,7 @@
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) {
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
do_2833(rtp_session);
+ rtp_flush_read_buffer(rtp_session);
bytes = 0;
return_cng_frame();
}
@@ -1323,6 +1358,10 @@
continue;
}
+ if (bytes && rtp_session->recv_msg.header.m) {
+ rtp_flush_read_buffer(rtp_session);
+ }
+
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
if (++rtp_session->autoadj_tally >= 10) {
const char *tx_host;
More information about the Freeswitch-svn
mailing list