diff --git a/src/include/switch_core.h b/src/include/switch_core.h index f91ab74597..5b783f2aff 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -514,6 +514,14 @@ SWITCH_DECLARE (switch_status_t) switch_core_session_message_send(char *uuid_str */ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session, switch_core_session_message_t *message); +/*! + \brief Queue an indication message on a session + \param session the session to queue the message to + \param indication the indication message to queue + \return SWITCH_STATUS_SUCCESS if the message was queued +*/ +SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core_session_t *session, switch_core_session_message_types_t indication); + /*! \brief DE-Queue an message on a given session \param session the session to de-queue the message on diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index d578d2d8b1..f096f792ba 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -950,6 +950,10 @@ static switch_status_t negotiate_media(switch_core_session_t *session) started = switch_time_now(); + /* jingle has no ringing indication so we will just pretend that we got one */ + switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING); + switch_channel_mark_ring_ready(channel); + if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { tech_pvt->next_cand = switch_time_now() + DL_CAND_WAIT; tech_pvt->next_desc = switch_time_now(); diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c index 46908bbac2..163a8058e1 100644 --- a/src/mod/endpoints/mod_iax/mod_iax.c +++ b/src/mod/endpoints/mod_iax/mod_iax.c @@ -1043,6 +1043,10 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Call accepted.\n"); break; case IAX_EVENT_RINGA: + if (channel) { + switch_core_session_queue_indication(tech_pvt->session, SWITCH_MESSAGE_INDICATE_RINGING); + switch_channel_mark_ring_ready(channel); + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Ringing heard.\n"); break; case IAX_EVENT_PONG: diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index c87e728bb2..5a7093699c 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -240,6 +240,9 @@ static switch_status_t channel_on_init(switch_core_session_t *session) } } + switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING); + switch_channel_mark_ring_ready(channel); + while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) { if (switch_time_now() - last >= waitsec) { char buf[512]; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 2ea53aad8f..7851e91e8a 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2823,14 +2823,7 @@ static void sip_i_state(int status, } } else { - switch_core_session_message_t *msg; - if ((msg = malloc(sizeof(*msg)))) { - memset(msg, 0, sizeof(*msg)); - msg->message_id = SWITCH_MESSAGE_INDICATE_RINGING; - msg->from = __FILE__; - switch_core_session_queue_message(session, msg); - switch_set_flag(msg, SCSMF_DYNAMIC); - } + switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING); } } } diff --git a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c index 82a72b74d3..fc6e7d46bd 100644 --- a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c +++ b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c @@ -1160,15 +1160,8 @@ static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type, channel = switch_core_session_get_channel(session); assert(channel != NULL); - if ((msg = malloc(sizeof(*msg)))) { - memset(msg, 0, sizeof(*msg)); - msg->message_id = SWITCH_MESSAGE_INDICATE_RINGING; - msg->from = __FILE__; - switch_core_session_queue_message(session, msg); - switch_set_flag(msg, SCSMF_DYNAMIC); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); - } + switch_core_session_queue_indication(tech_pvt->session, SWITCH_MESSAGE_INDICATE_RINGING); + switch_channel_mark_ring_ready(channel); switch_core_session_rwunlock(session); } else { diff --git a/src/mod/endpoints/mod_woomera/mod_woomera.c b/src/mod/endpoints/mod_woomera/mod_woomera.c index 741851eb81..ec396a62ce 100644 --- a/src/mod/endpoints/mod_woomera/mod_woomera.c +++ b/src/mod/endpoints/mod_woomera/mod_woomera.c @@ -1063,6 +1063,8 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj) } else if (!strcasecmp(wmsg.command, "PROCEED")) { /* This packet has lots of info so well keep it */ tech_pvt->call_info = wmsg; + switch_core_session_queue_indication(tech_pvt->session, SWITCH_MESSAGE_INDICATE_RINGING); + switch_channel_mark_ring_ready(channel); } else if (switch_test_flag(tech_pvt, TFLAG_PARSE_INCOMING) && !strcasecmp(wmsg.command, "INCOMING")) { char *exten; char cid_name[512]; diff --git a/src/switch_core.c b/src/switch_core.c index 921682a0eb..a43d52fe91 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1732,6 +1732,22 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_ return status; } +SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core_session_t *session, switch_core_session_message_types_t indication) +{ + switch_core_session_message_t *msg; + + if ((msg = malloc(sizeof(*msg)))) { + memset(msg, 0, sizeof(*msg)); + msg->message_id = indication; + msg->from = __FILE__; + switch_core_session_queue_message(session, msg); + switch_set_flag(msg, SCSMF_DYNAMIC); + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_FALSE; +} + SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session, switch_core_session_message_t *message) { switch_status_t status = SWITCH_STATUS_FALSE;