[Freeswitch-svn] [commit] r4944 - in freeswitch/trunk/src: . include mod/endpoints/mod_dingaling mod/endpoints/mod_iax mod/endpoints/mod_portaudio mod/endpoints/mod_sofia mod/endpoints/mod_wanpipe mod/endpoints/mod_woomera

Freeswitch SVN anthm at freeswitch.org
Mon Apr 16 12:53:30 EDT 2007


Author: anthm
Date: Mon Apr 16 12:53:30 2007
New Revision: 4944

Modified:
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/include/switch_core_event_hook.h
   freeswitch/trunk/src/include/switch_module_interfaces.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
   freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_core_event_hook.c
   freeswitch/trunk/src/switch_core_session.c

Log:
<refactor>

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Mon Apr 16 12:53:30 2007
@@ -527,6 +527,14 @@
 SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session, switch_core_session_message_t *message);
 
 /*! 
+  \brief pass an indication message on a session
+  \param session the session to pass the message across
+  \param indication the indication message to pass
+  \return SWITCH_STATUS_SUCCESS if the message was passed
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(switch_core_session_t *session, switch_core_session_message_types_t indication);
+
+/*! 
   \brief Queue an indication message on a session
   \param session the session to queue the message to
   \param indication the indication message to queue
@@ -640,13 +648,6 @@
 																		 switch_core_session_t **new_session, switch_memory_pool_t **pool);
 
 /*! 
-  \brief Answer the channel of a given session
-  \param session the session to answer the channel of
-  \return SWITCH_STATUS_SUCCESS if the channel was answered
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session);
-
-/*! 
   \brief Receive a message on a given session
   \param session the session to receive the message from
   \param message the message to recieve

Modified: freeswitch/trunk/src/include/switch_core_event_hook.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core_event_hook.h	(original)
+++ freeswitch/trunk/src/include/switch_core_event_hook.h	Mon Apr 16 12:53:30 2007
@@ -35,7 +35,6 @@
 SWITCH_BEGIN_EXTERN_C typedef struct switch_io_event_hooks switch_io_event_hooks_t;
 
 typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
-typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel_t;
 typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
 typedef struct switch_io_event_hook_receive_event switch_io_event_hook_receive_event_t;
 typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_t;
@@ -48,7 +47,6 @@
 
 
 typedef switch_status_t (*switch_outgoing_channel_hook_t) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
-typedef switch_status_t (*switch_answer_channel_hook_t) (switch_core_session_t *);
 typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *);
 typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
 typedef switch_status_t (*switch_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
@@ -67,23 +65,16 @@
 	struct switch_io_event_hook_outgoing_channel *next;
 };
 
-/*! \brief Node in which to store custom answer channel callback hooks */
-struct switch_io_event_hook_answer_channel {
-	/*! the answer channel callback hook */
-	switch_answer_channel_hook_t answer_channel;
-	struct switch_io_event_hook_answer_channel *next;
-};
-
 /*! \brief Node in which to store custom receive message callback hooks */
 struct switch_io_event_hook_receive_message {
-	/*! the answer channel callback hook */
+	/*! the message callback hook */
 	switch_receive_message_hook_t receive_message;
 	struct switch_io_event_hook_receive_message *next;
 };
 
 /*! \brief Node in which to store custom receive message callback hooks */
 struct switch_io_event_hook_receive_event {
-	/*! the answer channel callback hook */
+	/*! the event callback hook */
 	switch_receive_event_hook_t receive_event;
 	struct switch_io_event_hook_receive_event *next;
 };
@@ -141,8 +132,6 @@
 struct switch_io_event_hooks {
 	/*! a list of outgoing channel hooks */
 	switch_io_event_hook_outgoing_channel_t *outgoing_channel;
-	/*! a list of answer channel hooks */
-	switch_io_event_hook_answer_channel_t *answer_channel;
 	/*! a list of receive message hooks */
 	switch_io_event_hook_receive_message_t *receive_message;
 	/*! a list of queue message hooks */
@@ -181,14 +170,6 @@
 																			switch_outgoing_channel_hook_t outgoing_channel);
 
 /*! 
-  \brief Add an event hook to be executed when a session answers a channel
-  \param session session to bind hook to
-  \param answer_channel hook to bind
-  \return SWITCH_STATUS_SUCCESS on suceess
-*/
-SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_answer_channel(switch_core_session_t *session, switch_answer_channel_hook_t answer_channel);
-
-/*! 
   \brief Add an event hook to be executed when a session sends a message
   \param session session to bind hook to
   \param receive_message hook to bind
@@ -250,7 +231,7 @@
   \param state_change hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
-SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_answer_channel_hook_t state_change);
+SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_state_change_hook_t state_change);
 ///\}
 
 SWITCH_END_EXTERN_C

Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h	Mon Apr 16 12:53:30 2007
@@ -81,8 +81,6 @@
 struct switch_io_routines {
 	/*! creates an outgoing session from given session, caller profile */
 	switch_call_cause_t (*outgoing_channel) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **);
-	/*! answers the given session's channel */
-	switch_status_t (*answer_channel) (switch_core_session_t *);
 	/*! read a frame from a session */
 	switch_status_t (*read_frame) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
 	/*! write a frame to a session */

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Mon Apr 16 12:53:30 2007
@@ -349,6 +349,7 @@
 <pre>
 	SWITCH_MESSAGE_REDIRECT_AUDIO     - Indication to redirect audio to another location if possible
 	SWITCH_MESSAGE_TRANSMIT_TEXT      - A text message
+	SWITCH_MESSAGE_INDICATE_ANSWER    - indicate answer
 	SWITCH_MESSAGE_INDICATE_PROGRESS  - indicate progress 
 	SWITCH_MESSAGE_INDICATE_BRIDGE    - indicate a bridge starting
 	SWITCH_MESSAGE_INDICATE_UNBRIDGE  - indicate a bridge ending
@@ -363,6 +364,7 @@
 typedef enum {
 	SWITCH_MESSAGE_REDIRECT_AUDIO,
 	SWITCH_MESSAGE_TRANSMIT_TEXT,
+	SWITCH_MESSAGE_INDICATE_ANSWER,
 	SWITCH_MESSAGE_INDICATE_PROGRESS,
 	SWITCH_MESSAGE_INDICATE_BRIDGE,
 	SWITCH_MESSAGE_INDICATE_UNBRIDGE,

Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Mon Apr 16 12:53:30 2007
@@ -1513,6 +1513,9 @@
 	assert(tech_pvt != NULL);
 
 	switch (msg->message_id) {
+	case SWITCH_MESSAGE_INDICATE_ANSWER:
+		channel_answer_channel(session);
+		break;
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
 		if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
 			switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
@@ -1571,7 +1574,6 @@
 
 static const switch_io_routines_t channel_io_routines = {
 	/*.outgoing_channel */ channel_outgoing_channel,
-	/*.answer_channel */ channel_answer_channel,
 	/*.read_frame */ channel_read_frame,
 	/*.write_frame */ channel_write_frame,
 	/*.kill_channel */ channel_kill_channel,

Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	Mon Apr 16 12:53:30 2007
@@ -747,6 +747,29 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+
+static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
+{
+	switch_channel_t *channel;
+	private_t *tech_pvt;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+			
+	tech_pvt = (private_t *) switch_core_session_get_private(session);
+	assert(tech_pvt != NULL);
+
+	switch (msg->message_id) {
+	case SWITCH_MESSAGE_INDICATE_ANSWER:
+		channel_answer_channel(session);
+		break;
+	default:
+		break;
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
 static const switch_state_handler_table_t channel_event_handlers = {
 	/*.on_init */ channel_on_init,
 	/*.on_ring */ channel_on_ring,
@@ -758,13 +781,13 @@
 
 static const switch_io_routines_t channel_io_routines = {
 	/*.outgoing_channel */ channel_outgoing_channel,
-	/*.answer_channel */ channel_answer_channel,
 	/*.read_frame */ channel_read_frame,
 	/*.write_frame */ channel_write_frame,
 	/*.kill_channel */ channel_kill_channel,
 	/*.waitfor_read */ channel_waitfor_read,
 	/*.waitfor_write */ channel_waitfor_write,
-	/*.send_dtmf */ channel_send_dtmf
+	/*.send_dtmf */ channel_send_dtmf,
+	/*.receive_message*/ channel_receive_message
 };
 
 static const switch_endpoint_interface_t channel_endpoint_interface = {

Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c	Mon Apr 16 12:53:30 2007
@@ -718,6 +718,9 @@
 
 
 	switch (msg->message_id) {
+	case SWITCH_MESSAGE_INDICATE_ANSWER:
+		channel_answer_channel(session);
+		break;
 	case SWITCH_MESSAGE_INDICATE_PROGRESS:
 		{
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engage Early Media\n");
@@ -788,7 +791,6 @@
 
 static const switch_io_routines_t channel_io_routines = {
 	/*.outgoing_channel */ channel_outgoing_channel,
-	/*.answer_channel */ channel_answer_channel,
 	/*.read_frame */ channel_read_frame,
 	/*.write_frame */ channel_write_frame,
 	/*.kill_channel */ channel_kill_channel,

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 Apr 16 12:53:30 2007
@@ -675,9 +675,14 @@
 		break;
 	case SWITCH_MESSAGE_INDICATE_RINGING:
 		nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
+		switch_channel_mark_ring_ready(channel);
+		break;
+	case SWITCH_MESSAGE_INDICATE_ANSWER:
+		sofia_answer_channel(session);
 		break;
 	case SWITCH_MESSAGE_INDICATE_PROGRESS:{
 			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);
 
@@ -708,7 +713,7 @@
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ring SDP:\n%s\n", tech_pvt->local_sdp_str);
 					}
 				}
-
+				switch_channel_mark_pre_answered(channel);
 				nua_respond(tech_pvt->nh,
 							SIP_183_SESSION_PROGRESS,
 							SIPTAG_CONTACT_STR(tech_pvt->profile->url),
@@ -754,7 +759,6 @@
 
 static const switch_io_routines_t sofia_io_routines = {
 	/*.outgoing_channel */ sofia_outgoing_channel,
-	/*.answer_channel */ sofia_answer_channel,
 	/*.read_frame */ sofia_read_frame,
 	/*.write_frame */ sofia_write_frame,
 	/*.kill_channel */ sofia_kill_channel,

Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	Mon Apr 16 12:53:30 2007
@@ -930,6 +930,9 @@
 		break;
 	case SWITCH_MESSAGE_INDICATE_REDIRECT:
 		break;
+	case SWITCH_MESSAGE_INDICATE_ANSWER:
+		wanpipe_answer_channel(session);
+		break;
 	case SWITCH_MESSAGE_INDICATE_PROGRESS:
 		break;
 	case SWITCH_MESSAGE_INDICATE_RINGING:
@@ -969,7 +972,6 @@
 
 static const switch_io_routines_t wanpipe_io_routines = {
 	/*.outgoing_channel */ wanpipe_outgoing_channel,
-	/*.answer_channel */ wanpipe_answer_channel,
 	/*.read_frame */ wanpipe_read_frame,
 	/*.write_frame */ wanpipe_write_frame,
 	/*.kill_channel */ wanpipe_kill_channel,
@@ -1422,16 +1424,8 @@
 		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_PROGRESS;
-			msg->from = __FILE__;
-			switch_core_session_queue_message(session, msg);
-			switch_set_flag(msg, SCSMF_DYNAMIC);
-			switch_channel_mark_pre_answered(channel);
-		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-		}
+		switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_PROGRESS);
+		switch_channel_mark_pre_answered(channel);
 		
 		switch_core_session_rwunlock(session);
 	} else {
@@ -1457,7 +1451,7 @@
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
 
-		switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
+		switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
 		switch_channel_mark_ring_ready(channel);
 
 		switch_core_session_rwunlock(session);

Modified: freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c	Mon Apr 16 12:53:30 2007
@@ -447,7 +447,6 @@
 
 static const switch_io_routines_t woomera_io_routines = {
 	/*.outgoing_channel */ woomera_outgoing_channel,
-	/*.answer_channel */ NULL,
 	/*.read_frame */ woomera_read_frame,
 	/*.write_frame */ woomera_write_frame,
 	/*.kill_channel */ woomera_kill_channel,

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Mon Apr 16 12:53:30 2007
@@ -1080,7 +1080,6 @@
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, const char *file, const char *func, int line)
 {
 	switch_core_session_message_t msg;
-	char *uuid = switch_core_session_get_uuid(channel->session);
 	switch_status_t status;
 
 	assert(channel != NULL);
@@ -1099,7 +1098,7 @@
 
 	msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
 	msg.from = channel->name;
-	status = switch_core_session_message_send(uuid, &msg);
+	status = switch_core_session_receive_message(channel->session, &msg);
 
 	if (status == SWITCH_STATUS_SUCCESS) {
 		status = switch_channel_perform_mark_pre_answered(channel, file, func, line);
@@ -1111,7 +1110,6 @@
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line)
 {
 	switch_core_session_message_t msg;
-	char *uuid = switch_core_session_get_uuid(channel->session);
 	switch_status_t status;
 
 	assert(channel != NULL);
@@ -1130,7 +1128,7 @@
 
 	msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
 	msg.from = channel->name;
-	status = switch_core_session_message_send(uuid, &msg);
+	status = switch_core_session_receive_message(channel->session, &msg);
 
 	if (status == SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
@@ -1185,6 +1183,9 @@
 
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line)
 {
+	switch_core_session_message_t msg;
+	switch_status_t status;
+
 	assert(channel != NULL);
 
 	if (channel->hangup_cause || channel->state >= CS_HANGUP) {
@@ -1195,7 +1196,12 @@
 		return SWITCH_STATUS_SUCCESS;
 	}
 
-	if (switch_core_session_answer_channel(channel->session) == SWITCH_STATUS_SUCCESS) {
+
+	msg.message_id = SWITCH_MESSAGE_INDICATE_ANSWER;
+	msg.from = channel->name;
+	status = switch_core_session_receive_message(channel->session, &msg);
+
+	if (status == SWITCH_STATUS_SUCCESS) {
 		return switch_channel_perform_mark_answered(channel, file, func, line);
 	}
 

Modified: freeswitch/trunk/src/switch_core_event_hook.c
==============================================================================
--- freeswitch/trunk/src/switch_core_event_hook.c	(original)
+++ freeswitch/trunk/src/switch_core_event_hook.c	Mon Apr 16 12:53:30 2007
@@ -52,29 +52,7 @@
 	return SWITCH_STATUS_MEMERR;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_answer_channel(switch_core_session_t *session, switch_answer_channel_hook_t answer_channel)
-{
-	switch_io_event_hook_answer_channel_t *hook, *ptr;
-
-	assert(answer_channel != NULL);
-	if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
-		hook->answer_channel = answer_channel;
-		if (!session->event_hooks.answer_channel) {
-			session->event_hooks.answer_channel = hook;
-		} else {
-			for (ptr = session->event_hooks.answer_channel; ptr && ptr->next; ptr = ptr->next);
-			ptr->next = hook;
-
-		}
-
-		return SWITCH_STATUS_SUCCESS;
-	}
-
-	return SWITCH_STATUS_MEMERR;
-
-}
-
-SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_answer_channel_hook_t state_change)
+SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_state_change_hook_t state_change)
 {
 	switch_io_event_hook_state_change_t *hook, *ptr;
 

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Mon Apr 16 12:53:30 2007
@@ -320,50 +320,52 @@
 	return cause;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session)
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message)
 {
-	switch_io_event_hook_answer_channel_t *ptr;
+	switch_io_event_hook_receive_message_t *ptr;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	assert(session != NULL);
 
-	if (session->endpoint_interface->io_routines->answer_channel) {
-		status = session->endpoint_interface->io_routines->answer_channel(session);
+	if (session->endpoint_interface->io_routines->receive_message) {
+		status = session->endpoint_interface->io_routines->receive_message(session, message);
+
 	}
 
 	if (status == SWITCH_STATUS_SUCCESS) {
-		for (ptr = session->event_hooks.answer_channel; ptr; ptr = ptr->next) {
-			if ((status = ptr->answer_channel(session)) != SWITCH_STATUS_SUCCESS) {
+		for (ptr = session->event_hooks.receive_message; ptr; ptr = ptr->next) {
+			if ((status = ptr->receive_message(session, message)) != SWITCH_STATUS_SUCCESS) {
 				break;
 			}
 		}
 	}
 
-
+	switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message)
+SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(switch_core_session_t *session, switch_core_session_message_types_t indication)
 {
-	switch_io_event_hook_receive_message_t *ptr;
+	switch_core_session_message_t msg = {0};
+	switch_core_session_t *other_session;
+	char *uuid;
+	switch_channel_t *channel;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	assert(session != NULL);
+	
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
 
-	if (session->endpoint_interface->io_routines->receive_message) {
-		status = session->endpoint_interface->io_routines->receive_message(session, message);
-
-	}
-
-	if (status == SWITCH_STATUS_SUCCESS) {
-		for (ptr = session->event_hooks.receive_message; ptr; ptr = ptr->next) {
-			if ((status = ptr->receive_message(session, message)) != SWITCH_STATUS_SUCCESS) {
-				break;
-			}
-		}
+	if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+		msg.message_id = indication;
+		msg.from = __FILE__;
+		status = switch_core_session_receive_message(other_session, &msg);
+		switch_core_session_rwunlock(other_session);
+	} else {
+		status = SWITCH_STATUS_FALSE;
 	}
 
-	switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
 	return status;
 }
 
@@ -375,8 +377,8 @@
 		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);
+		switch_core_session_queue_message(session, msg);
 		return SWITCH_STATUS_SUCCESS;
 	}
 



More information about the Freeswitch-svn mailing list