[Freeswitch-svn] [commit] r2107 - in freeswitch/branches/cypromis/trunk/src: . include mod/endpoints/mod_exosip

Freeswitch SVN cypromis at freeswitch.org
Tue Jul 25 09:16:03 EDT 2006


Author: cypromis
Date: Tue Jul 25 09:16:01 2006
New Revision: 2107

Modified:
   freeswitch/branches/cypromis/trunk/src/   (props changed)
   freeswitch/branches/cypromis/trunk/src/include/switch_core.h
   freeswitch/branches/cypromis/trunk/src/include/switch_module_interfaces.h
   freeswitch/branches/cypromis/trunk/src/include/switch_types.h
   freeswitch/branches/cypromis/trunk/src/mod/endpoints/mod_exosip/Makefile
   freeswitch/branches/cypromis/trunk/src/switch_core.c

Log:
more udpates from trunk

Modified: freeswitch/branches/cypromis/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/include/switch_core.h	(original)
+++ freeswitch/branches/cypromis/trunk/src/include/switch_core.h	Tue Jul 25 09:16:01 2006
@@ -335,9 +335,17 @@
   \param event the event to send
   \return the status returned by the message handler
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t *event);
+SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event);
 
 /*! 
+  \brief Send an event to a session translating it to it's native message format
+  \param session the session to receive the event
+  \param event the event to receive
+  \return the status returned by the handler
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event);
+
+/*! 
   \brief Retrieve private user data from a session
   \param session the session to retrieve from
   \return a pointer to the private data
@@ -433,7 +441,16 @@
   \param event the event to queue
   \return the status returned by the message handler
 */
-SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t *event);
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event);
+
+/*! 
+  \brief DE-Queue an event on a given session
+  \param session the session to de-queue the message on
+  \param event the de-queued event
+  \return the  SWITCH_STATUS_SUCCESS if the event was de-queued
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event);
+
 
 /*! 
   \brief Read a frame from a session

Modified: freeswitch/branches/cypromis/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/branches/cypromis/trunk/src/include/switch_module_interfaces.h	Tue Jul 25 09:16:01 2006
@@ -93,10 +93,10 @@
 };
 
 /*! \brief Node in which to store custom receive message callback hooks */
-struct switch_io_event_hook_queue_event {
+struct switch_io_event_hook_receive_event {
 	/*! the answer channel callback hook*/
-	switch_queue_event_hook_t queue_event;
-	struct switch_io_event_hook_queue_event *next;
+	switch_receive_event_hook_t receive_event;
+	struct switch_io_event_hook_receive_event *next;
 };
 
 /*! \brief Node in which to store custom read frame channel callback hooks */
@@ -150,7 +150,7 @@
 	/*! a list of receive message hooks */
 	switch_io_event_hook_receive_message_t *receive_message;
 	/*! a list of queue message hooks */
-	switch_io_event_hook_queue_event_t *queue_event;
+	switch_io_event_hook_receive_event_t *receive_event;
 	/*! a list of read frame hooks */
 	switch_io_event_hook_read_frame_t *read_frame;
 	/*! a list of write frame hooks */
@@ -186,7 +186,7 @@
 	/*! receive a message from another session*/
 	switch_status_t (*receive_message)(switch_core_session_t *, switch_core_session_message_t *);
 	/*! queue a message for another session*/
-	switch_status_t (*queue_event)(switch_core_session_t *, switch_event_t *);
+	switch_status_t (*receive_event)(switch_core_session_t *, switch_event_t *);
 };
 
 /*! \brief Abstraction of an module endpoint interface

Modified: freeswitch/branches/cypromis/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/include/switch_types.h	(original)
+++ freeswitch/branches/cypromis/trunk/src/include/switch_types.h	Tue Jul 25 09:16:01 2006
@@ -573,6 +573,10 @@
 	SWITCH_EVENT_ALL
 } switch_event_types_t;
 
+typedef enum {
+	SWITCH_INPUT_TYPE_DTMF,
+	SWITCH_INPUT_TYPE_EVENT
+} switch_input_type_t;
 
 typedef enum {
 	SWITCH_CAUSE_UNALLOCATED = 1,
@@ -651,7 +655,7 @@
 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_queue_event switch_io_event_hook_queue_event_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;
 typedef struct switch_io_event_hook_write_frame switch_io_event_hook_write_frame_t;
 typedef struct switch_io_event_hook_kill_channel switch_io_event_hook_kill_channel_t;
@@ -682,7 +686,7 @@
 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_queue_event_hook_t)(switch_core_session_t *, switch_event_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);
 typedef switch_status_t (*switch_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
 typedef switch_status_t (*switch_kill_channel_hook_t)(switch_core_session_t *, int);
@@ -692,7 +696,11 @@
 typedef struct switch_stream_handle switch_stream_handle_t;
 typedef switch_status_t (*switch_stream_handle_write_function_t)(switch_stream_handle_t *handle, char *fmt, ...);
 typedef switch_status_t (*switch_api_function_t)(char *in, switch_stream_handle_t *stream);
-typedef switch_status_t (*switch_dtmf_callback_function_t)(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen);
+typedef switch_status_t (*switch_input_callback_function_t)(switch_core_session_t *session,
+															void *input,
+															switch_input_type_t input_type,
+															void *buf,
+															unsigned int buflen);
 typedef int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames);
 typedef switch_status_t (*switch_module_load_t) (switch_loadable_module_interface_t **, char *);
 typedef switch_status_t (*switch_module_reload_t) (void);

Modified: freeswitch/branches/cypromis/trunk/src/mod/endpoints/mod_exosip/Makefile
==============================================================================

Modified: freeswitch/branches/cypromis/trunk/src/switch_core.c
==============================================================================
--- freeswitch/branches/cypromis/trunk/src/switch_core.c	(original)
+++ freeswitch/branches/cypromis/trunk/src/switch_core.c	Tue Jul 25 09:16:01 2006
@@ -307,7 +307,7 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t *event)
+SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event)
 {
 	switch_core_session_t *session = NULL;
 	switch_status_t status = SWITCH_STATUS_FALSE;
@@ -1089,29 +1089,76 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t *event)
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event)
 	 
 {
-	switch_io_event_hook_queue_event_t *ptr;
-	switch_status_t status = SWITCH_STATUS_FALSE, istatus = SWITCH_STATUS_FALSE;;
+	switch_io_event_hook_receive_event_t *ptr;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	assert(session != NULL);
-	if (session->endpoint_interface->io_routines->queue_event) {
-		status = session->endpoint_interface->io_routines->queue_event(session, event);
 
-		if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
-			for (ptr = session->event_hooks.queue_event; ptr; ptr = ptr->next) {
-				if ((istatus = ptr->queue_event(session, event)) != SWITCH_STATUS_SUCCESS) {
-					break;
+	/* Acquire a read lock on the session or forget it the channel is dead */
+	if (switch_thread_rwlock_tryrdlock(session->rwlock) == SWITCH_STATUS_SUCCESS) {
+		if (switch_channel_get_state(session->channel) < CS_HANGUP) {
+			if (session->endpoint_interface->io_routines->receive_event) {
+				status = session->endpoint_interface->io_routines->receive_event(session, *event);
+			} 
+	
+			if (status == SWITCH_STATUS_SUCCESS) {
+				for (ptr = session->event_hooks.receive_event; ptr; ptr = ptr->next) {
+					if ((status = ptr->receive_event(session, *event)) != SWITCH_STATUS_SUCCESS) {
+						break;
+					}
 				}
 			}
-		}
-		
-		if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) {
-			if (!session->event_queue) {
-				switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
+
+			if (status == SWITCH_STATUS_BREAK) {
+				status = SWITCH_STATUS_SUCCESS;
 			}
-			switch_queue_push(session->event_queue, event);
+
+			if (status == SWITCH_STATUS_SUCCESS) {
+				switch_event_destroy(event);
+			}
+		}
+		switch_thread_rwlock_unlock(session->rwlock);
+	}
+	
+	return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event)
+	 
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
+	assert(session != NULL);
+
+	if (!session->event_queue) {
+		switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
+	}
+
+	if (session->event_queue) {
+		if (switch_queue_trypush(session->event_queue, *event) == SWITCH_STATUS_SUCCESS) {
+			*event = NULL;
+			status = SWITCH_STATUS_SUCCESS;
+		}
+	} 
+
+	return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event)
+	 
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+	void *pop;
+
+	assert(session != NULL);
+	
+	if (session->event_queue) {
+		if ((status = (switch_status_t) switch_queue_trypop(session->event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
+			*event = (switch_event_t *) pop;
 		}
 	}
 



More information about the Freeswitch-svn mailing list