[Freeswitch-svn] [commit] r12244 - in freeswitch/trunk/src: . include mod/applications/mod_conference mod/applications/mod_fifo mod/endpoints/mod_alsa mod/endpoints/mod_dingaling mod/endpoints/mod_iax mod/endpoints/mod_loopback mod/endpoints/mod_opal mod/endpoints/mod_portaudio mod/endpoints/mod_reference mod/endpoints/mod_skypiax mod/endpoints/mod_skypiax/asterisk mod/endpoints/mod_sofia mod/endpoints/mod_unicall

FreeSWITCH SVN anthm at freeswitch.org
Mon Feb 23 08:31:59 PST 2009


Author: anthm
Date: Mon Feb 23 10:31:59 2009
New Revision: 12244

Log:
add direction col to sql db, add direction param to session_create, log dtmf digits to digits_dialed variable for cdr

Modified:
   freeswitch/trunk/src/include/switch_channel.h
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
   freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c
   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_loopback/mod_loopback.c
   freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp
   freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c
   freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c
   freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_core_sqldb.c
   freeswitch/trunk/src/switch_event.c

Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h	(original)
+++ freeswitch/trunk/src/include/switch_channel.h	Mon Feb 23 10:31:59 2009
@@ -139,7 +139,7 @@
   \param pool memory_pool to use for allocation
   \return SWITCH_STATUS_SUCCESS if successful
 */
-SWITCH_DECLARE(switch_status_t) switch_channel_alloc(_In_ switch_channel_t **channel, _In_ switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_channel_alloc(_In_ switch_channel_t **channel, _In_ switch_call_direction_t direction, _In_ switch_memory_pool_t *pool);
 
 /*!
   \brief Connect a newly allocated channel to a session object and setup it's initial state

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Mon Feb 23 10:31:59 2009
@@ -529,9 +529,10 @@
   \param pool the pool to use for the allocation (a new one will be used if NULL)
   \return the newly created session
 */
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface,
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface, 
+																		 _In_ switch_call_direction_t direction,
 																		 _Inout_opt_ switch_memory_pool_t **pool, _In_opt_z_ const char *use_uuid);
-#define switch_core_session_request(_ep, _p) switch_core_session_request_uuid(_ep, _p, NULL)
+#define switch_core_session_request(_ep, _d, _p) switch_core_session_request_uuid(_ep, _d, _p, NULL)
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_set_uuid(switch_core_session_t *session, const char *use_uuid);
 
@@ -565,7 +566,9 @@
   \param pool the pool to use
   \return the newly created session
 */
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(_In_z_ const char *endpoint_name, _Inout_ switch_memory_pool_t **pool);
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(_In_z_ const char *endpoint_name, 
+																			_In_ switch_call_direction_t direction,
+																			_Inout_ switch_memory_pool_t **pool);
 
 /*! 
   \brief Launch the session thread (state machine) on a given 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 Feb 23 10:31:59 2009
@@ -168,6 +168,7 @@
 #define SWITCH_UUID_BRIDGE "uuid_bridge"
 #define SWITCH_BITS_PER_BYTE 8
 #define SWITCH_DEFAULT_FILE_BUFFER_LEN 65536
+#define SWITCH_DTMF_LOG_LEN 1000
 
 typedef uint8_t switch_byte_t;
 
@@ -177,6 +178,11 @@
 } switch_dtmf_t;
 
 typedef enum {
+	SWITCH_CALL_DIRECTION_INBOUND,
+	SWITCH_CALL_DIRECTION_OUTBOUND
+} switch_call_direction_t;
+
+typedef enum {
 	SBF_DIAL_ALEG = (1 << 0),
 	SBF_EXEC_ALEG = (1 << 1),
 	SBF_DIAL_BLEG = (1 << 2),

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Mon Feb 23 10:31:59 2009
@@ -604,7 +604,7 @@
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", conference->name);
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", conference->count == 1 ? "early" : "confirmed");
-			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", conference->count == 1 ? "outbound" : "inbound");
+			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", conference->count == 1 ? "outbound" : "inbound");
 			switch_event_fire(&event);
 		}
 

Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	Mon Feb 23 10:31:59 2009
@@ -617,7 +617,7 @@
 		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", wait_count > 0 ? "CS_ROUTING" : "CS_HANGUP");
 		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", node->name);
 		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", wait_count > 0 ? "early" : "terminated");
-		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
+		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound");
 		switch_event_fire(&event);
 	}
 }

Modified: freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c	Mon Feb 23 10:31:59 2009
@@ -757,7 +757,7 @@
 													switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
 
-	if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
+	if ((*new_session = switch_core_session_request(&channel_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
 		switch_caller_profile_t *caller_profile;
@@ -1412,7 +1412,7 @@
 	}
 	dest = argv[0];
 
-	if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
+	if ((session = switch_core_session_request(&channel_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
 		char *dialplan = globals.dialplan;

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 Feb 23 10:31:59 2009
@@ -1569,7 +1569,7 @@
 													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
-	if ((*new_session = switch_core_session_request(dingaling_endpoint_interface, pool)) != 0) {
+	if ((*new_session = switch_core_session_request(dingaling_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
 		struct private_object *tech_pvt;
 		switch_channel_t *channel;
 		switch_caller_profile_t *caller_profile = NULL;
@@ -2547,7 +2547,7 @@
 			status = LDL_STATUS_FALSE;
 			goto done;
 		}
-		if ((session = switch_core_session_request(dingaling_endpoint_interface, NULL)) != 0) {
+		if ((session = switch_core_session_request(dingaling_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
 			switch_core_session_add_stream(session, NULL);
 
 			if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {

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 Feb 23 10:31:59 2009
@@ -702,7 +702,7 @@
 													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
-	if ((*new_session = switch_core_session_request(iax_endpoint_interface, pool)) != 0) {
+	if ((*new_session = switch_core_session_request(iax_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
 		switch_caller_profile_t *caller_profile;
@@ -1008,7 +1008,7 @@
 					switch_core_session_t *session;
 
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n", iaxevent->ies.calling_name);
-					if ((session = switch_core_session_request(iax_endpoint_interface, NULL)) != 0) {
+					if ((session = switch_core_session_request(iax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
 						switch_core_session_add_stream(session, NULL);
 						if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
 							channel = switch_core_session_get_channel(session);

Modified: freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c	Mon Feb 23 10:31:59 2009
@@ -214,7 +214,7 @@
 	
 	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_BLEG)) {
 		
-		if (!(b_session = switch_core_session_request(loopback_endpoint_interface, NULL))) {
+		if (!(b_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure.\n");
 			goto end;
 		}
@@ -648,7 +648,7 @@
 		switch_channel_pre_answer(channel);
 	}
 
-	if ((*new_session = switch_core_session_request(loopback_endpoint_interface, pool)) != 0) {
+	if ((*new_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
 		switch_caller_profile_t *caller_profile;

Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp	Mon Feb 23 10:31:59 2009
@@ -483,7 +483,8 @@
 {
     opal_private_t *tech_pvt;
     FSManager & mgr = (FSManager &) endpoint.GetManager();
-    m_fsSession = switch_core_session_request(mgr.GetSwitchInterface(), NULL);
+    m_fsSession = switch_core_session_request(mgr.GetSwitchInterface(), 
+                                              outbound_profile ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND, NULL);
     m_fsChannel = switch_core_session_get_channel(m_fsSession);
 
     tech_pvt = (opal_private_t *) switch_core_session_alloc(m_fsSession, sizeof(*tech_pvt));

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 Feb 23 10:31:59 2009
@@ -708,7 +708,7 @@
 													switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
 
-	if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, pool)) != 0) {
+	if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
 		switch_caller_profile_t *caller_profile;
@@ -1668,7 +1668,7 @@
 	}
 	dest = argv[0];
 
-	if ((session = switch_core_session_request(portaudio_endpoint_interface, NULL)) != 0) {
+	if ((session = switch_core_session_request(portaudio_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
 		char *dialplan = globals.dialplan;

Modified: freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c	Mon Feb 23 10:31:59 2009
@@ -399,7 +399,7 @@
 													switch_caller_profile_t *outbound_profile,
 													switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
 {
-	if ((*new_session = switch_core_session_request(reference_endpoint_interface, pool)) != 0) {
+	if ((*new_session = switch_core_session_request(reference_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
 		private_t *tech_pvt;
 		switch_channel_t *channel;
 		switch_caller_profile_t *caller_profile;

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c	Mon Feb 23 10:31:59 2009
@@ -1852,7 +1852,7 @@
   switch_core_session_t *session = NULL;
   switch_channel_t *channel = NULL;
 
-  if ((session = switch_core_session_request(skypiax_endpoint_interface, NULL)) != 0) {
+  if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
     switch_core_session_add_stream(session, NULL);
     channel = switch_core_session_get_channel(session);
     skypiax_tech_init(tech_pvt, session);

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	Mon Feb 23 10:31:59 2009
@@ -506,7 +506,7 @@
                                                     switch_memory_pool_t ** pool,
                                                     switch_originate_flag_t flags)
 {
-  if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) {
+	if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
     private_t *tech_pvt;
     switch_channel_t *channel;
     switch_caller_profile_t *caller_profile;
@@ -1139,7 +1139,7 @@
   switch_core_session_t *session = NULL;
   switch_channel_t *channel = NULL;
 
-  if ((session = switch_core_session_request(skypiax_endpoint_interface, NULL)) != 0) {
+  if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
     switch_core_session_add_stream(session, NULL);
     channel = switch_core_session_get_channel(session);
     skypiax_tech_init(tech_pvt, 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	Mon Feb 23 10:31:59 2009
@@ -2335,7 +2335,7 @@
 
 	*new_session = NULL;
 
-	if (!(nsession = switch_core_session_request(sofia_endpoint_interface, pool))) {
+	if (!(nsession = switch_core_session_request(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n");
 		goto error;
 	}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Mon Feb 23 10:31:59 2009
@@ -4016,9 +4016,9 @@
 
 	if (sofia_endpoint_interface) {
 		if (sofia_test_pflag(profile, PFLAG_CALLID_AS_UUID)) {
-			session = switch_core_session_request_uuid(sofia_endpoint_interface, NULL, sip->sip_call_id->i_id);
+			session = switch_core_session_request_uuid(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL, sip->sip_call_id->i_id);
 		} else {
-			session = switch_core_session_request(sofia_endpoint_interface, NULL);
+			session = switch_core_session_request(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL);
 		}
 	}
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	Mon Feb 23 10:31:59 2009
@@ -830,7 +830,7 @@
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", uuid);
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", state);
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "astate", state);
-			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", direction);
+			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", direction);
 		}
 
 		switch_event_fire(&event);
@@ -1030,7 +1030,7 @@
 
 	if (helper->event) {
 		switch_stream_handle_t stream = { 0 };
-		const char *direction = switch_str_nil(switch_event_get_header(helper->event, "call-direction"));
+		const char *direction = switch_str_nil(switch_event_get_header(helper->event, "presence-call-direction"));
 		const char *uuid = switch_str_nil(switch_event_get_header(helper->event, "unique-id"));
 		const char *state = switch_str_nil(switch_event_get_header(helper->event, "channel-state"));
 		const char *event_status = switch_str_nil(switch_event_get_header(helper->event, "status"));

Modified: freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c	Mon Feb 23 10:31:59 2009
@@ -202,7 +202,7 @@
     
     *sp = NULL;
     
-    if (!(session = switch_core_session_request(openzap_endpoint_interface, NULL)))
+    if (!(session = switch_core_session_request(openzap_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)))
     {
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Initialization Error!\n");
         return ZAP_FAIL;
@@ -1540,7 +1540,7 @@
 
 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_outgoing_channel(%p)\n", (void *) session);
 
-    if ((*new_session = switch_core_session_request(unicall_endpoint_interface, pool)) == NULL)
+ if ((*new_session = switch_core_session_request(unicall_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) == NULL)
     {
         return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
     }

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Mon Feb 23 10:31:59 2009
@@ -109,7 +109,9 @@
 
 struct switch_channel {
 	char *name;
+	switch_call_direction_t direction;
 	switch_queue_t *dtmf_queue;
+	switch_queue_t *dtmf_log_queue;
 	switch_mutex_t *dtmf_mutex;
 	switch_mutex_t *flag_mutex;
 	switch_mutex_t *state_mutex;
@@ -210,7 +212,7 @@
 	return times;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, switch_call_direction_t direction, switch_memory_pool_t *pool)
 {
 	switch_assert(pool != NULL);
 
@@ -221,7 +223,8 @@
 	switch_event_create(&(*channel)->variables, SWITCH_EVENT_GENERAL);
 
 	switch_core_hash_init(&(*channel)->private_hash, pool);
-	switch_queue_create(&(*channel)->dtmf_queue, 128, pool);
+	switch_queue_create(&(*channel)->dtmf_queue, SWITCH_DTMF_LOG_LEN, pool);
+	switch_queue_create(&(*channel)->dtmf_log_queue, SWITCH_DTMF_LOG_LEN, pool);
 
 	switch_mutex_init(&(*channel)->dtmf_mutex, SWITCH_MUTEX_NESTED, pool);
 	switch_mutex_init(&(*channel)->flag_mutex, SWITCH_MUTEX_NESTED, pool);
@@ -229,6 +232,7 @@
 	switch_mutex_init(&(*channel)->profile_mutex, SWITCH_MUTEX_NESTED, pool);
 	(*channel)->hangup_cause = SWITCH_CAUSE_NONE;
 	(*channel)->name = "";
+	(*channel)->direction = direction;
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -355,7 +359,12 @@
 	if (switch_queue_trypop(channel->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 		dt = (switch_dtmf_t *) pop;
 		*dtmf = *dt;
-		free(dt);
+
+		if (switch_queue_trypush(channel->dtmf_log_queue, dt) != SWITCH_STATUS_SUCCESS) {
+			free(dt);			
+		}
+		
+		dt = NULL;
 
 		if (dtmf->duration > switch_core_max_dtmf_duration(0)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s EXCESSIVE DTMF DIGIT [%c] LEN [%d]\n",
@@ -404,14 +413,21 @@
 
 	switch_mutex_lock(channel->dtmf_mutex);
 	while (switch_queue_trypop(channel->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
-		switch_safe_free(pop);
+		switch_dtmf_t *dt = (switch_dtmf_t *) pop;
+		if (channel->state >= CS_HANGUP || switch_queue_trypush(channel->dtmf_log_queue, dt) != SWITCH_STATUS_SUCCESS) {
+			free(dt);
+		}
 	}
 	switch_mutex_unlock(channel->dtmf_mutex);
 }
 
 SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel)
 {
+	void *pop;
 	switch_channel_flush_dtmf(channel);
+	while (switch_queue_trypop(channel->dtmf_log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+		switch_safe_free(pop);
+	}
 	switch_core_hash_destroy(&channel->private_hash);
 	switch_mutex_lock(channel->profile_mutex);
 	switch_event_destroy(&channel->variables);
@@ -2234,6 +2250,9 @@
 	switch_time_t uduration = 0, legbillusec = 0, billusec = 0, progresssec = 0, progressusec = 0, progress_mediasec = 0, progress_mediausec = 0;
 	time_t tt_created = 0, tt_answered = 0, tt_progress = 0, tt_progress_media = 0, tt_hungup = 0, mtt_created = 0, mtt_answered = 0, mtt_hungup =
 		0, tt_prof_created, mtt_prof_created, mtt_progress = 0, mtt_progress_media = 0;
+	void *pop;
+	char dtstr[SWITCH_DTMF_LOG_LEN+1] = "";
+	int x = 0;
 
 	if (!(caller_profile = switch_channel_get_caller_profile(channel)) || !channel->variables) {
 		return SWITCH_STATUS_FALSE;
@@ -2256,6 +2275,22 @@
 		cid_buf = caller_profile->caller_id_number;
 	}
 
+	while (x < SWITCH_DTMF_LOG_LEN && switch_queue_trypop(channel->dtmf_log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+		switch_dtmf_t *dt = (switch_dtmf_t *) pop;
+
+		if (dt) {
+			dtstr[x++] = dt->digit;
+			free(dt);
+			dt = NULL;
+		}
+	}
+	
+	if (x) {
+		switch_channel_set_variable(channel, "digits_dialed", dtstr);
+	} else {
+		switch_channel_set_variable(channel, "digits_dialed", "none");
+	}
+
 	if (caller_profile->times) {
 		switch_time_exp_t tm;
 		switch_size_t retsize;

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Mon Feb 23 10:31:59 2009
@@ -269,6 +269,8 @@
 
 		switch_assert(channel != NULL);
 
+		switch_channel_set_flag(channel, CF_OUTBOUND);
+
 		forwardvar = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
 		if (!switch_strlen_zero(forwardvar)) {
 			forwardval = atoi(forwardvar) - 1;
@@ -1043,7 +1045,10 @@
 }
 
 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_endpoint_interface_t
-																		 *endpoint_interface, switch_memory_pool_t **pool, const char *use_uuid)
+																		 *endpoint_interface, 
+																		 switch_call_direction_t direction,
+																		 switch_memory_pool_t **pool, 
+																		 const char *use_uuid)
 {
 	switch_memory_pool_t *usepool;
 	switch_core_session_t *session;
@@ -1091,10 +1096,14 @@
 	session = switch_core_alloc(usepool, sizeof(*session));
 	session->pool = usepool;
 	
-	if (switch_channel_alloc(&session->channel, session->pool) != SWITCH_STATUS_SUCCESS) {
+	if (switch_channel_alloc(&session->channel, direction, session->pool) != SWITCH_STATUS_SUCCESS) {
 		abort();
 	}
 
+	if (direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
+		switch_channel_set_flag(session->channel, CF_OUTBOUND);
+	}
+
 	switch_channel_init(session->channel, session, CS_NEW, 0);
 
 	/* The session *IS* the pool you may not alter it because you have no idea how
@@ -1154,7 +1163,9 @@
 }
 
 
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(const char *endpoint_name, switch_memory_pool_t **pool)
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(const char *endpoint_name, 
+																			switch_call_direction_t direction, 
+																			switch_memory_pool_t **pool)
 {
 	switch_endpoint_interface_t *endpoint_interface;
 	switch_core_session_t *session;
@@ -1164,7 +1175,7 @@
 		return NULL;
 	}
 
-	session = switch_core_session_request(endpoint_interface, pool);
+	session = switch_core_session_request(endpoint_interface, direction, pool);
 
 	UNPROTECT_INTERFACE(endpoint_interface);
 

Modified: freeswitch/trunk/src/switch_core_sqldb.c
==============================================================================
--- freeswitch/trunk/src/switch_core_sqldb.c	(original)
+++ freeswitch/trunk/src/switch_core_sqldb.c	Mon Feb 23 10:31:59 2009
@@ -275,8 +275,10 @@
 			break;
 		}
 	case SWITCH_EVENT_CHANNEL_CREATE:
-		sql = switch_mprintf("insert into channels (uuid,created,created_epoch, name,state,dialplan,context) values('%q','%q','%ld','%q','%q','%q','%q')",
+		sql = switch_mprintf("insert into channels (uuid,direction,created,created_epoch, name,state,dialplan,context) "
+							 "values('%q','%q','%q','%ld','%q','%q','%q','%q')",
 							 switch_event_get_header_nil(event, "unique-id"),
+							 switch_event_get_header_nil(event, "call-direction"),
 							 switch_event_get_header_nil(event, "event-date-local"),
 							 (long)switch_epoch_time_now(NULL),							 
 							 switch_event_get_header_nil(event, "channel-name"),
@@ -434,6 +436,7 @@
 		char create_channels_sql[] =
 			"CREATE TABLE channels (\n"
 			"   uuid  VARCHAR(255),\n"
+			"   direction  VARCHAR(255),\n"
 			"   created  VARCHAR(255),\n"
 			"   created_epoch  INTEGER,\n"
 			"   name  VARCHAR(255),\n"

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Mon Feb 23 10:31:59 2009
@@ -1277,7 +1277,7 @@
 		switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "unique-id", alt_event_type);
 		switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "channel-state", channel_state);
 		switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "answer-state", answer_state);
-		switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "call-direction", call_direction);
+		switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "presence-call-direction", call_direction);
 		switch_event_fire_detailed(file, func, line, &pres_event, NULL);
 		return SWITCH_STATUS_SUCCESS;
 	}



More information about the Freeswitch-svn mailing list