diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.c b/src/mod/endpoints/mod_exosip/mod_exosip.c index 24a4c7d5f8..47fc5df860 100644 --- a/src/mod/endpoints/mod_exosip/mod_exosip.c +++ b/src/mod/endpoints/mod_exosip/mod_exosip.c @@ -468,7 +468,7 @@ static void activate_rtp(struct private_object *tech_pvt) switch_set_flag(tech_pvt, TFLAG_RTP); } else { switch_channel *channel = switch_core_session_get_channel(tech_pvt->session); - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Oh oh? [%s]\n", err); + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "RTP REPORTS ERROR: [%s]\n", err); switch_channel_hangup(channel); switch_set_flag(tech_pvt, TFLAG_BYE); switch_clear_flag(tech_pvt, TFLAG_IO); @@ -518,6 +518,8 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram size_t bytes = 0, samples = 0, frames = 0, ms = 0; switch_channel *channel = NULL; int payload = 0; + switch_time_t started = switch_time_now(); + unsigned int elapsed; channel = switch_core_session_get_channel(session); assert(channel != NULL); @@ -550,6 +552,14 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram && tech_pvt->read_frame.datalen == 0) { tech_pvt->read_frame.datalen = jrtp4c_read(tech_pvt->rtp_session, tech_pvt->read_frame.data, sizeof(tech_pvt->read_buf), &payload); + + if (timeout > -1) { + elapsed = (unsigned int)((switch_time_now() - started) / 1000); + if (elapsed >= timeout) { + return SWITCH_STATUS_SUCCESS; + } + } + /* RFC2833 ... TBD try harder to honor the duration etc.*/ if (payload == 101) { unsigned char *packet = tech_pvt->read_frame.data; @@ -578,6 +588,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram } if (globals.supress_telephony_events && payload != tech_pvt->payload_num) { + tech_pvt->read_frame.datalen = 0; switch_yield(1000); continue; } diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c index d8f7cd83b0..0925369766 100644 --- a/src/mod/endpoints/mod_iax/mod_iax.c +++ b/src/mod/endpoints/mod_iax/mod_iax.c @@ -592,6 +592,8 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra { switch_channel *channel = NULL; struct private_object *tech_pvt = NULL; + switch_time_t started = switch_time_now(); + unsigned int elapsed; channel = switch_core_session_get_channel(session); assert(channel != NULL); @@ -615,6 +617,15 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra *frame = &tech_pvt->read_frame; return SWITCH_STATUS_SUCCESS; } + + if (timeout > -1) { + elapsed = (unsigned int)((switch_time_now() - started) / 1000); + if (elapsed >= timeout) { + return SWITCH_STATUS_SUCCESS; + } + } + + switch_yield(1000); } diff --git a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c index 242d53ec9a..14c2d9bcf8 100644 --- a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c +++ b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c @@ -855,7 +855,7 @@ static const switch_loadable_module_interface wanpipe_module_interface = { static void s_pri_error(struct pri *pri, char *s) { - switch_console_printf(SWITCH_CHANNEL_CONSOLE, s); + switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, s); } static void s_pri_message(struct pri *pri, char *s) @@ -1125,8 +1125,14 @@ static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type, switch_core_session *session; struct channel_map *chanmap; + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "-- Restarting channel %d\n", event->restart.channel); + if (event->restart.channel < 1) { + return 0; + } + + chanmap = spri->private_info; if ((session = chanmap->map[event->restart.channel])) { diff --git a/src/switch_channel.c b/src/switch_channel.c index cdeb37be4b..b379365857 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -571,7 +571,12 @@ SWITCH_DECLARE(switch_status) switch_channel_pre_answer(switch_channel *channel) char *uuid = switch_core_session_get_uuid(channel->session); switch_status status; - assert(channel != NULL); + assert(channel != NULL); + + if (channel->state >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } + msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS; msg.from = channel->name; status = switch_core_session_message_send(uuid, &msg); @@ -588,6 +593,9 @@ SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel) { assert(channel != NULL); + if (channel->state >= CS_HANGUP) { + return SWITCH_STATUS_FALSE; + } if (switch_core_session_answer_channel(channel->session) == SWITCH_STATUS_SUCCESS) { switch_event *event;