[Freeswitch-svn] [commit] r3504 - in freeswitch/trunk/src: . include mod/applications/mod_enum mod/languages/mod_spidermonkey

Freeswitch SVN anthm at freeswitch.org
Fri Dec 1 10:26:37 EST 2006


Author: anthm
Date: Fri Dec  1 10:26:37 2006
New Revision: 3504

Modified:
   freeswitch/trunk/src/include/switch_caller.h
   freeswitch/trunk/src/include/switch_channel.h
   freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/trunk/src/switch_channel.c

Log:
adjustments to the core do a make sure

Modified: freeswitch/trunk/src/include/switch_caller.h
==============================================================================
--- freeswitch/trunk/src/include/switch_caller.h	(original)
+++ freeswitch/trunk/src/include/switch_caller.h	Fri Dec  1 10:26:37 2006
@@ -88,6 +88,9 @@
 	char *context;
 	/*! flags */
 	switch_caller_profile_flag_t flags;
+	struct switch_caller_profile *originator_caller_profile;
+	struct switch_caller_profile *originatee_caller_profile;
+	struct switch_channel_timetable *times;
 	struct switch_caller_profile *next;
 };
 

Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h	(original)
+++ freeswitch/trunk/src/include/switch_channel.h	Fri Dec  1 10:26:37 2006
@@ -46,6 +46,7 @@
 	switch_time_t created;
 	switch_time_t answered;
 	switch_time_t hungup;
+	switch_time_t transferred;
 	struct switch_channel_timetable *next;
 };
 
@@ -428,9 +429,6 @@
 */
 SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel, char *in);
 
-// These may go away
-SWITCH_DECLARE(switch_status_t) switch_channel_set_raw_mode (switch_channel_t *channel, int freq, int bits, int channels, int ms, int kbps);
-SWITCH_DECLARE(switch_status_t) switch_channel_get_raw_mode (switch_channel_t *channel, int *freq, int *bits, int *channels, int *ms, int *kbps);
 /** @} */
 
 SWITCH_END_EXTERN_C

Modified: freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c	Fri Dec  1 10:26:37 2006
@@ -570,7 +570,7 @@
 	char vbuf[1024] = "";
 	char *rbp = rbuf;
 	switch_size_t l = 0, rbl = sizeof(rbuf);
-	uint32_t cnt = 0;
+	uint32_t cnt = 1;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 
 	assert(channel != NULL);
@@ -583,10 +583,21 @@
 		dest = argv[0];
         root = argv[1] ? argv[1] : globals.root;
 		if (enum_lookup(root, data, &results) == SWITCH_STATUS_SUCCESS) {
+			switch_hash_index_t *hi;
+			void *vval;
+			const void *vvar;
+
+			for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
+				switch_hash_this(hi, &vvar, NULL, &vval);
+				if (vvar && !strncmp(vvar, "enum_", 5)) {
+					switch_channel_set_variable(channel, (char *) vvar, NULL);
+				}
+			}
+
 			for(rtp = globals.route_order; rtp; rtp = rtp->next) {
 				for(rp = results; rp; rp = rp->next) {
 					if (!strcmp(rtp->service, rp->service)) {
-						snprintf(vbuf, sizeof(vbuf), "enum_route_%d", ++cnt);
+						snprintf(vbuf, sizeof(vbuf), "enum_route_%d", cnt++);
 						switch_channel_set_variable(channel, vbuf, rp->route);
 
 						snprintf(rbp, rbl, "%s|", rp->route);
@@ -596,6 +607,8 @@
 					}
 				}
 			}
+			snprintf(vbuf, sizeof(vbuf), "%d", cnt);
+			switch_channel_set_variable(channel, "enum_route_count", vbuf);
 			*(rbuf+strlen(rbuf)-1) = '\0';
 			switch_channel_set_variable(channel, "enum_auto_route", rbuf);
 			free_results(&results);	

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Fri Dec  1 10:26:37 2006
@@ -862,14 +862,14 @@
         }
 
         if (argc > 4) {
-            int32_t thresh;
-            JS_ValueToInt32(cx, argv[4], &(int32)thresh);
+            int32 thresh;
+            JS_ValueToInt32(cx, argv[4], &thresh);
             fh.thresh = thresh;
         }
 
         if (argc > 5) {
-            int32_t silence_hits;
-            JS_ValueToInt32(cx, argv[5], &(int32)silence_hits);
+            int32 silence_hits;
+            JS_ValueToInt32(cx, argv[5], &silence_hits);
             fh.silence_hits = silence_hits;
         }
 	}

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Fri Dec  1 10:26:37 2006
@@ -108,20 +108,12 @@
 	uint32_t flags;
 	uint32_t state_flags;
 	switch_caller_profile_t *caller_profile;
-	switch_caller_profile_t *originator_caller_profile;
-	switch_caller_profile_t *originatee_caller_profile;
 	switch_caller_extension_t *caller_extension;
 	const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
 	int state_handler_index;
 	switch_hash_t *variables;
 	switch_hash_t *private_hash;
-	switch_channel_timetable_t *times;
 	switch_call_cause_t hangup_cause;
-	int freq;
-	int bits;
-	int channels;
-	int ms;
-	int kbps;
 };
 
 
@@ -160,8 +152,16 @@
 
 SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel_t *channel)
 {
+    switch_channel_timetable_t *times = NULL;
+
 	assert(channel != NULL);
-	return channel->times;
+    if (channel->caller_profile) {
+        switch_mutex_lock(channel->profile_mutex);
+        times = channel->caller_profile->times;
+        switch_mutex_unlock(channel->profile_mutex);
+    }
+
+	return times;
 }
 
 SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, switch_memory_pool_t *pool)
@@ -184,46 +184,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_channel_set_raw_mode(switch_channel_t *channel, int freq, int bits, int channels,
-														  int ms, int kbps)
-{
-
-	assert(channel != NULL);
-
-	channel->freq = freq;
-	channel->bits = bits;
-	channel->channels = channels;
-	channel->ms = ms;
-	channel->kbps = kbps;
-
-
-	return SWITCH_STATUS_SUCCESS;
-}
-
-SWITCH_DECLARE(switch_status_t) switch_channel_get_raw_mode(switch_channel_t *channel, int *freq, int *bits, int *channels,
-														  int *ms, int *kbps)
-{
-	if (freq) {
-		*freq = channel->freq;
-	}
-	if (bits) {
-		*bits = channel->bits;
-	}
-	if (channels) {
-		*channels = channel->channels;
-	}
-	if (ms) {
-		*ms = channel->ms;
-	}
-	if (kbps) {
-		*kbps = channel->kbps;
-	}
-
-	return SWITCH_STATUS_SUCCESS;
-
-}
-
-
 SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel_t *channel)
 {
 	switch_size_t has;
@@ -306,7 +266,6 @@
 	channel->state = state;
 	channel->flags = flags;
 	channel->session = session;
-	switch_channel_set_raw_mode(channel, 8000, 16, 1, 20, 8);
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -348,7 +307,7 @@
 	assert(channel != NULL);
 
 	if (!(v=switch_core_hash_find(channel->variables, varname))) {
-		if (!(v = switch_caller_get_field_by_name(channel->caller_profile, varname))) {
+		if (!channel->caller_profile || !(v = switch_caller_get_field_by_name(channel->caller_profile, varname))) {
 			if (!strcmp(varname, "base_dir")) {
 				return SWITCH_GLOBAL_dirs.base_dir;
 			}
@@ -710,16 +669,17 @@
 
 SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
 {
-	switch_caller_profile_t *caller_profile, *originator_caller_profile, *originatee_caller_profile;
+	switch_caller_profile_t *caller_profile, *originator_caller_profile = NULL, *originatee_caller_profile = NULL;
 	switch_hash_index_t *hi;
 	switch_codec_t *codec;
 	void *val;
 	const void *var;
 	char state_num[25];
 
-	caller_profile = switch_channel_get_caller_profile(channel);
-	originator_caller_profile = switch_channel_get_originator_caller_profile(channel);
-	originatee_caller_profile = switch_channel_get_originatee_caller_profile(channel);
+	if ((caller_profile = switch_channel_get_caller_profile(channel))) {
+        originator_caller_profile = caller_profile->originator_caller_profile;
+        originatee_caller_profile = caller_profile->originatee_caller_profile;
+    }
 
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", (char *) switch_channel_state_name(channel->state));
 	snprintf(state_num, sizeof(state_num), "%d", channel->state);
@@ -767,11 +727,10 @@
 
 SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 {
-	switch_channel_timetable_t *times;
-
 	assert(channel != NULL);
 	assert(channel->session != NULL);
 	switch_mutex_lock(channel->profile_mutex);
+	assert(caller_profile != NULL);
 
 	if (!caller_profile->uuid) {
 		caller_profile->uuid = switch_core_session_strdup(channel->session, switch_core_session_get_uuid(channel->session));
@@ -793,13 +752,15 @@
 			switch_event_fire(&event);
 		}
 	} 
-	
-	if ((times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*times)))) {
-		times->next = channel->times;
-		channel->times = times;
-	}
-	channel->times->created = switch_time_now();
+    
+    caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*caller_profile->times));
+	caller_profile->times->created = switch_time_now();
 
+    if (channel->caller_profile && channel->caller_profile->times) {
+        channel->caller_profile->times->transferred = switch_time_now();
+        caller_profile->times->answered = channel->caller_profile->times->answered;
+    }
+
 	caller_profile->next = channel->caller_profile;
 	channel->caller_profile = caller_profile;
 
@@ -822,53 +783,61 @@
 																  switch_caller_profile_t *caller_profile)
 {
 	assert(channel != NULL);
-	switch_mutex_lock(channel->profile_mutex);
-	caller_profile->next = channel->originator_caller_profile;
-	channel->originator_caller_profile = caller_profile;
-	switch_mutex_unlock(channel->profile_mutex);
+    if (channel->caller_profile) {
+        switch_mutex_lock(channel->profile_mutex);
+        caller_profile->next = channel->caller_profile->originator_caller_profile;
+        channel->caller_profile->originator_caller_profile = caller_profile;
+        switch_mutex_unlock(channel->profile_mutex);
+    }
 }
 
 SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel,
 																  switch_caller_profile_t *caller_profile)
 {
 	assert(channel != NULL);
-	switch_mutex_lock(channel->profile_mutex);
-	caller_profile->next = channel->originatee_caller_profile;
-	channel->originatee_caller_profile = caller_profile;
-	switch_mutex_unlock(channel->profile_mutex);
+    if (channel->caller_profile) {
+        switch_mutex_lock(channel->profile_mutex);
+        caller_profile->next = channel->caller_profile->originatee_caller_profile;
+        channel->caller_profile->originatee_caller_profile = caller_profile;
+        switch_mutex_unlock(channel->profile_mutex);
+    }
 }
 
 SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originator_caller_profile(switch_channel_t *channel)
 {
-	switch_caller_profile_t *profile;
+	switch_caller_profile_t *profile = NULL;
 	assert(channel != NULL);
 
-	switch_mutex_lock(channel->profile_mutex);
-	profile = channel->originator_caller_profile;
-	switch_mutex_unlock(channel->profile_mutex);
+    if (channel->caller_profile) {
+        switch_mutex_lock(channel->profile_mutex);
+        profile = channel->caller_profile->originator_caller_profile;
+        switch_mutex_unlock(channel->profile_mutex);
+    }
 
 	return profile;
 }
 
-SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel)
-{
-	assert(channel != NULL);
-	assert(channel->session != NULL);
-	return switch_core_session_get_uuid(channel->session);
-}
-
 SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originatee_caller_profile(switch_channel_t *channel)
 {
-	switch_caller_profile_t *profile;
+	switch_caller_profile_t *profile = NULL;
 	assert(channel != NULL);
 
-	switch_mutex_lock(channel->profile_mutex);
-	profile = channel->originatee_caller_profile;
-	switch_mutex_unlock(channel->profile_mutex);
+    if (channel->caller_profile) {
+        switch_mutex_lock(channel->profile_mutex);
+        profile = channel->caller_profile->originatee_caller_profile;
+        switch_mutex_unlock(channel->profile_mutex);
+    }
 
 	return profile;
 }
 
+SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel)
+{
+	assert(channel != NULL);
+	assert(channel->session != NULL);
+	return switch_core_session_get_uuid(channel->session);
+}
+
 SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel_t *channel,
 													 const switch_state_handler_table_t *state_handler)
 {
@@ -974,8 +943,10 @@
 	assert(channel != NULL);
 	switch_mutex_lock(channel->flag_mutex);
 
-	if (channel->times && !channel->times->hungup) {
-		channel->times->hungup = switch_time_now();
+	if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) {
+        switch_mutex_lock(channel->profile_mutex);
+		channel->caller_profile->times->hungup = switch_time_now();
+        switch_mutex_unlock(channel->profile_mutex);
 	}
 
 	if (channel->state < CS_HANGUP) {
@@ -1096,7 +1067,12 @@
 	if (switch_core_session_answer_channel(channel->session) == SWITCH_STATUS_SUCCESS) {
 		switch_event_t *event;
 
-		channel->times->answered = switch_time_now();
+        if (channel->caller_profile && channel->caller_profile->times) {
+            switch_mutex_lock(channel->profile_mutex);
+            channel->caller_profile->times->answered = switch_time_now();
+            switch_mutex_unlock(channel->profile_mutex);
+        }
+
 		switch_channel_set_flag(channel, CF_ANSWERED);
 		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Answer %s!\n", channel->name);
 		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {



More information about the Freeswitch-svn mailing list