]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
get uuid from apr-utils for channel events
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 22 Dec 2005 01:57:32 +0000 (01:57 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 22 Dec 2005 01:57:32 +0000 (01:57 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@190 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch.h
src/include/switch_core.h
src/include/switch_types.h
src/switch_channel.c
src/switch_core.c
src/switch_event.c

index 449ec62f85046e92d95ccc84a57477c08888949c..bcdb11e757e5e47d7413bff6741352f119c6b6f1 100644 (file)
@@ -59,6 +59,8 @@ extern "C" {
 #include <apr_strings.h>
 #include <apr_network_io.h>
 #include <apr_poll.h>
+#include <apr_queue.h>
+#include <apr_uuid.h>
 #include <assert.h>
 #include <sqlite3.h>
 
index 786300df157c0e2309c25017362df4bea7e53f34..0dcf1b08a2b06dc6ba68fe90d5a83ff0dd1e7551 100644 (file)
@@ -122,6 +122,7 @@ SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_se
 SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *session);
 SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup);
 SWITCH_DECLARE(switch_core_db *) switch_core_db_open_file(char *filename);
+SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session *session);
 
 #define SWITCH_CORE_DB "core"
 #define switch_core_db_handle() switch_core_db_open_file(SWITCH_CORE_DB)
index 77b49e0d50c15d1079d0f6d5d5fa4c0f2fbe4649..61ca2077fd26d74f9163a0a9d85ba2c00e5bb16d 100644 (file)
@@ -65,7 +65,7 @@ typedef enum {
 #endif
 #endif
 
-       
+#define SWITCH_UUID_FORMATTED_LENGTH APR_UUID_FORMATTED_LENGTH         
 #define SWITCH_CHANNEL_CONSOLE SWITCH_CHANNEL_ID_CONSOLE, __FILE__, __FUNCTION__, __LINE__
 #define SWITCH_CHANNEL_CONSOLE_CLEAN SWITCH_CHANNEL_ID_CONSOLE_CLEAN, __FILE__, __FUNCTION__, __LINE__
 #define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __FUNCTION__, __LINE__
@@ -193,6 +193,8 @@ typedef switch_status (*switch_api_function)(char *in, char *out, size_t outlen)
    The pieces of apr we allow ppl to pass around between modules we typedef into our namespace and wrap all the functions
    any other apr code should be as hidden as possible.
 */
+typedef apr_uuid_t switch_uuid_t;
+typedef apr_queue_t switch_queue_t;
 typedef apr_hash_t switch_hash;
 typedef apr_pool_t switch_memory_pool;
 typedef apr_thread_t switch_thread;
@@ -226,6 +228,9 @@ typedef apr_hash_index_t switch_hash_index_t;
 #define switch_thread_cond_broadcast apr_thread_cond_broadcast
 #define switch_thread_cond_destroy apr_thread_cond_destroy
 
+#define switch_uuid_format apr_uuid_format
+#define switch_uuid_get apr_uuid_get
+#define switch_uuid_parse apr_uuid_parse
 #define switch_queue_create apr_queue_create
 #define switch_queue_interrupt_all apr_queue_interrupt_all
 #define switch_queue_pop apr_queue_pop
index df572d0645f96f8d4b3f9489fb1b94a289ad5853..d5603d929de149aaad864ce373e140c1ce5a6bc0 100644 (file)
@@ -65,7 +65,8 @@ SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, swi
        switch_core_hash_init(&(*channel)->variables, pool);
        switch_buffer_create(pool, &(*channel)->dtmf_buffer, 128);
        switch_mutex_init(&(*channel)->dtmf_mutex, SWITCH_MUTEX_NESTED, pool);
-       
+
+
        return SWITCH_STATUS_SUCCESS;
 }
 
@@ -406,6 +407,8 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
        
        switch_event_add_header(event, "channel_state", (char *) switch_channel_state_name(channel->state));
        switch_event_add_header(event, "channel_name", switch_channel_get_name(channel));
+       switch_event_add_header(event, "unique_id", switch_core_session_get_uuid(channel->session));
+
 
        /* Index Caller's Profile */    
        if (caller_profile) {
index 21cada090f70787b024130f8d349599ad49a6f58..1c312ec9b41f5d6705fd6088c65154d352c557f0 100644 (file)
@@ -74,6 +74,7 @@ struct switch_core_session {
        switch_mutex_t *mutex;
        switch_thread_cond_t *cond;
 
+       char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1];
        void *private;
 };
 
@@ -179,6 +180,11 @@ SWITCH_DECLARE(switch_status) switch_core_do_perl(char *txt)
 #endif
 
 
+SWITCH_DECLARE(char *) switch_core_session_get_uuid(switch_core_session *session)
+{
+       return session->uuid_str;
+}
+
 SWITCH_DECLARE(switch_status) switch_core_session_set_read_codec(switch_core_session *session, switch_codec *codec)
 {
        assert(session != NULL);
@@ -1490,6 +1496,7 @@ SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_e
 {
        switch_memory_pool *usepool;
        switch_core_session *session;
+       switch_uuid_t uuid;
 
        assert(endpoint_interface != NULL);
 
@@ -1517,6 +1524,9 @@ SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_e
        /* The session *IS* the pool you may not alter it because you have no idea how
           its all private it will be passed to the thread run function */
 
+       switch_uuid_get(&uuid);
+       switch_uuid_format(session->uuid_str, &uuid);
+
        session->pool = usepool;
        session->endpoint_interface = endpoint_interface;
 
index 05e314d229699fd8a9c492532fb3b6a97f892393..1fb5c068a51b3e1a16954ad554b57450f5905302 100644 (file)
@@ -60,22 +60,6 @@ static char *EVENT_NAMES[] = {
 };
 
 
-#if 0
-static void debug_hash(void) {
-       switch_hash_index_t* hi;
-       void *val;
-       const void *var;
-       for (hi = switch_hash_first(EPOOL, CUSTOM_HASH); hi; hi = switch_hash_next(hi)) {
-               switch_event_subclass *subclass;
-               switch_hash_this(hi, &var, NULL, &val);
-               subclass = val;
-               switch_console_printf(SWITCH_CHANNEL_CONSOLE, "***WTF %s=%s\n", (char *) var, subclass->name);
-       }
-}
-#endif
-
-
-
 static int switch_events_match(switch_event *event, switch_event_node *node)
 {
        int match = 0;