]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add direction col to sql db, add direction param to session_create, log dtmf digits...
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 23 Feb 2009 16:31:59 +0000 (16:31 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 23 Feb 2009 16:31:59 +0000 (16:31 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12244 d0543943-73ff-0310-b7d9-9358b9ac24b2

22 files changed:
src/include/switch_channel.h
src/include/switch_core.h
src/include/switch_types.h
src/mod/applications/mod_conference/mod_conference.c
src/mod/applications/mod_fifo/mod_fifo.c
src/mod/endpoints/mod_alsa/mod_alsa.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_iax/mod_iax.c
src/mod/endpoints/mod_loopback/mod_loopback.c
src/mod/endpoints/mod_opal/mod_opal.cpp
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/endpoints/mod_reference/mod_reference.c
src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c
src/mod/endpoints/mod_skypiax/mod_skypiax.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/mod/endpoints/mod_unicall/mod_unicall.c
src/switch_channel.c
src/switch_core_session.c
src/switch_core_sqldb.c
src/switch_event.c

index 822e4a1b51c1eef52d012431dc094f4a6bebd6df..eb0290bb4a206978e163e95b3890d0f957aca7df 100644 (file)
@@ -139,7 +139,7 @@ SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(_In_ s
   \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
index b4a72cd12ff18a0a060b38bb23a1cb003edeffe6..0168c50228630d83ec86b12ad4a2129adde48612 100644 (file)
@@ -529,9 +529,10 @@ SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(_In_ switch_
   \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 @@ SWITCH_DECLARE(switch_size_t) switch_core_session_id(void);
   \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
index 45aedde952f2032710c5f89ef693c80ade267075..4a493b5a1c7128fe0a1596ff468426441207609e 100644 (file)
@@ -168,6 +168,7 @@ SWITCH_BEGIN_EXTERN_C
 #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;
 
@@ -176,6 +177,11 @@ typedef struct {
        uint32_t duration;
 } 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),
index 967059a44799dd7e18acd6c9749bf104f55405c3..a5650e28f51c5a05119d0bcf8d4deaf21e1d6797 100644 (file)
@@ -604,7 +604,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
                        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);
                }
 
index 14fd4ca5d904821b9a7fef0be69755b86a5110fd..15e63fd9b14d3bc9ba08d240e5865c93caeeeff8 100644 (file)
@@ -617,7 +617,7 @@ static void send_presence(fifo_node_t *node)
                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);
        }
 }
index 4d992ee62af7fcc9df8d8e147d07aef735b2cd49..3308cc25b49bd90dbb1b72b8c4e20ca02c940b9f 100644 (file)
@@ -757,7 +757,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                                                                                                        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 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
        }
        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;
index 7d8381d92d8fb96d58c35a3e69ae49d5e4a52c97..cf9a4cb4db1f2d5b53851a70aa174af5a0595c49 100644 (file)
@@ -1569,7 +1569,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                                                                                                        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 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
                        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) {
index cd338c0aa44fb2e4006bcdda444875be6de68b4d..1cec64993b3a4d0040ae5d17b0c53e118af0da9a 100644 (file)
@@ -702,7 +702,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                                                                                                        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_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
                                        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);
index 7ad243573f53d42e85079838678bb105b3c5da94..b4e41aaa41610d92055d057d18af55c9ffe6b467 100644 (file)
@@ -214,7 +214,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
        
        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 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                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;
index 7dc5394ed1ae87b8d3feb96259760a05f205433d..6ac9d2e7ac002376a073ffba6aca3d6094cb714b 100644 (file)
@@ -483,7 +483,8 @@ FSConnection::FSConnection(OpalCall & call, FSEndPoint & endpoint, switch_caller
 {\r
     opal_private_t *tech_pvt;\r
     FSManager & mgr = (FSManager &) endpoint.GetManager();\r
-    m_fsSession = switch_core_session_request(mgr.GetSwitchInterface(), NULL);\r
+    m_fsSession = switch_core_session_request(mgr.GetSwitchInterface(), \r
+                                              outbound_profile ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND, NULL);\r
     m_fsChannel = switch_core_session_get_channel(m_fsSession);\r
 \r
     tech_pvt = (opal_private_t *) switch_core_session_alloc(m_fsSession, sizeof(*tech_pvt));\r
index ddb94ef2c7a38a3b08669cc661c034c0d3572cea..6e13b95a380765e6a04ce747ab9f85af2aeead21 100644 (file)
@@ -708,7 +708,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                                                                                                        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 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
        }
        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;
index f1768ad112421c8a315cdd6a115eb46589598877..91cf93b87d056087fbf9b08c7b256db630260bed 100644 (file)
@@ -399,7 +399,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                                                                                                        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;
index f385e9ca16f4e5ef152bf68291aa06ba10686a32..d80e8cac512283af286663d4603ee0283b868446 100644 (file)
@@ -1852,7 +1852,7 @@ int new_inbound_channel(private_t * p)
   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);
index a2bc942ca4b97fd12821fd22d25d82e646b2ae9d..7439b98d6c3bfd22dae873570eb65a1e5dfeef61 100644 (file)
@@ -506,7 +506,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * sess
                                                     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 @@ int new_inbound_channel(private_t * tech_pvt)
   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);
index a8660bbbf5d7232ebd2be2e5d1f8b5655dc95ce4..df048c199a5a00459d1e498b2132aec144a8655e 100644 (file)
@@ -2335,7 +2335,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
 
        *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;
        }
index e169546c1f31d9455bb7fe1ddb7ce548f88236e5..076f5fe7861cf75dea32d833f57f6e0db9a50db3 100644 (file)
@@ -4016,9 +4016,9 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
 
        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);
                }
        }
 
index 4d44ebaa014e8a83a5b341449a6370e641a801ea..1084bda3746a4eae96edcc267a0afa17be0510df 100644 (file)
@@ -830,7 +830,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
                        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 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
 
        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"));
index 7909e0f8e0408f9b31fc4628f4fb1995191abafc..8198b12284689c2b22d597c7c87af5000b6beaba 100644 (file)
@@ -202,7 +202,7 @@ static switch_call_cause_t unicall_incoming_channel(zap_sigmsg_t *sigmsg, switch
     
     *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 @@ static switch_call_cause_t unicall_outgoing_channel(switch_core_session_t *sessi
 
 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;
     }
index e80bd8d504c16bba325bc80eebc44349de09ff79..5dc6f8e5dd58b2041223401d0a4ac986fcd44d0c 100644 (file)
@@ -109,7 +109,9 @@ static struct switch_cause_table CAUSE_CHART[] = {
 
 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 @@ SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch
        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_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel,
        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_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel,
        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 @@ SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(switch_channel_t *ch
        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_DECLARE(void) switch_channel_flush_dtmf(switch_channel_t *channel)
 
        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_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *
        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 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *
                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;
index 59449b02bed7614fb26e8e937821a3b739ce9b51..ba866db1ec3652b09bdbea16f3c6b29c397ba0cf 100644 (file)
@@ -269,6 +269,8 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
 
                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_status_t) switch_core_session_set_uuid(switch_core_session
 }
 
 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 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_
        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_size_t) switch_core_session_id(void)
 }
 
 
-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 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(cons
                return NULL;
        }
 
-       session = switch_core_session_request(endpoint_interface, pool);
+       session = switch_core_session_request(endpoint_interface, direction, pool);
 
        UNPROTECT_INTERFACE(endpoint_interface);
 
index e47a39ca30a6e60f82e0f25bd701771c5718d3f2..1f459382f793452f13ec8f0444af4e2bb8fd796a 100644 (file)
@@ -275,8 +275,10 @@ static void core_event_handler(switch_event_t *event)
                        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 @@ void switch_core_sqldb_start(switch_memory_pool_t *pool)
                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"
index 31a31e5b1e020c5d61ae80f84b76ec509c319dd3..9cc442c81f227c1e9d59a3345db529e7eda4ca33 100644 (file)
@@ -1277,7 +1277,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(char *file,
                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;
        }