[Freeswitch-branches] [commit] r5241 - in freeswitch/branches/greenlizard/src: . include include/private mod/applications/mod_commands mod/applications/mod_esf mod/applications/mod_playback mod/endpoints/mod_sofia mod/endpoints/mod_wanpipe mod/languages/mod_python mod/languages/mod_spidermonkey

Freeswitch SVN greenlizard at freeswitch.org
Fri Jun 1 14:05:18 EDT 2007


Author: greenlizard
Date: Fri Jun  1 14:05:17 2007
New Revision: 5241

Modified:
   freeswitch/branches/greenlizard/src/include/private/switch_core_pvt.h
   freeswitch/branches/greenlizard/src/include/switch.h
   freeswitch/branches/greenlizard/src/include/switch_apr.h
   freeswitch/branches/greenlizard/src/include/switch_core.h
   freeswitch/branches/greenlizard/src/include/switch_ivr.h
   freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_esf/mod_esf.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_playback/mod_playback.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_wanpipe/Makefile
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_python/Makefile
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/greenlizard/src/switch_apr.c
   freeswitch/branches/greenlizard/src/switch_buffer.c
   freeswitch/branches/greenlizard/src/switch_caller.c
   freeswitch/branches/greenlizard/src/switch_core_io.c
   freeswitch/branches/greenlizard/src/switch_core_media_bug.c
   freeswitch/branches/greenlizard/src/switch_core_session.c
   freeswitch/branches/greenlizard/src/switch_ivr_async.c
   freeswitch/branches/greenlizard/src/switch_ivr_originate.c
   freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
   freeswitch/branches/greenlizard/src/switch_loadable_module.c
   freeswitch/branches/greenlizard/src/switch_log.c
   freeswitch/branches/greenlizard/src/switch_rtp.c

Log:
merge in changes from trunk 5202 to 5240.  Revert to trunk vrsion of python Makefile. No other changes.

Modified: freeswitch/branches/greenlizard/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/private/switch_core_pvt.h	(original)
+++ freeswitch/branches/greenlizard/src/include/private/switch_core_pvt.h	Fri Jun  1 14:05:17 2007
@@ -136,6 +136,7 @@
 	void *user_data;
 	uint32_t flags;
 	uint8_t ready;
+	time_t stop_time;
 	struct switch_media_bug *next;
 };
 

Modified: freeswitch/branches/greenlizard/src/include/switch.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch.h	Fri Jun  1 14:05:17 2007
@@ -52,8 +52,13 @@
 #define FREESWITCH_ITAD "543"
 #define __EXTENSIONS__ 1
 #ifndef MACOSX
+#ifndef _XOPEN_SOURCE
 #define _XOPEN_SOURCE 600
 #endif
+#ifndef __BSD_VISIBLE
+#define __BSD_VISIBLE 1
+#endif
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>

Modified: freeswitch/branches/greenlizard/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_apr.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_apr.h	Fri Jun  1 14:05:17 2007
@@ -732,6 +732,7 @@
  * be returned.  APR_EINTR is never returned.
  */
 SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t * thefile, const void *buf, switch_size_t *nbytes);
+SWITCH_DECLARE(int) switch_file_printf(switch_file_t *thefile, const char *format, ...);
 
 SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool);
 

Modified: freeswitch/branches/greenlizard/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_core.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_core.h	Fri Jun  1 14:05:17 2007
@@ -130,7 +130,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session,
 														  switch_media_bug_callback_t callback,
-														  void *user_data, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug);
+														  void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug);
 /*!
   \brief Obtain private data from a media bug
   \param bug the bug to get the data from

Modified: freeswitch/branches/greenlizard/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_ivr.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_ivr.h	Fri Jun  1 14:05:17 2007
@@ -198,7 +198,7 @@
   \param fh file handle to use (NULL for builtin one)
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, switch_file_handle_t *fh);
+SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh);
 
 /*!
   \brief Stop Recording a session

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c	Fri Jun  1 14:05:17 2007
@@ -550,6 +550,7 @@
 	char *mycmd = NULL, *argv[4] = { 0 };
 	char *uuid = NULL, *action = NULL, *path = NULL;
 	int argc = 0;
+	uint32_t limit = 0;
 
 	if (session) {
 		return SWITCH_STATUS_FALSE;
@@ -570,7 +571,8 @@
 	uuid = argv[0];
 	action = argv[1];
 	path = argv[2];
-
+	limit = argv[3] ? atoi(argv[3]) : 0;
+	
 	if (!(rsession = switch_core_session_locate(uuid))) {
 		stream->write_function(stream, "-Error Cannot locate session!\n");
 		return SWITCH_STATUS_SUCCESS;
@@ -581,7 +583,7 @@
 	}
 
 	if (!strcasecmp(action, "start")) {
-		switch_ivr_record_session(rsession, path, NULL);
+		switch_ivr_record_session(rsession, path, limit, NULL);
 	} else if (!strcasecmp(action, "stop")) {
 		switch_ivr_stop_record_session(rsession, path);
 	} else {
@@ -1230,7 +1232,7 @@
 	/*.interface_name */ "session_record",
 	/*.desc */ "session record",
 	/*.function */ session_record_function,
-	/*.syntax */ "<uuid> [start|stop] <path>",
+	/*.syntax */ "<uuid> [start|stop] <path> [<limit>]",
 	/*.next */ &broadcast_api_interface
 };
 

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_esf/mod_esf.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_esf/mod_esf.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_esf/mod_esf.c	Fri Jun  1 14:05:17 2007
@@ -57,7 +57,7 @@
 {
 	switch_channel_t *channel;
 	switch_socket_t *socket;
-	switch_sockaddr_t *audio_addr, *control_packet_addr;
+	switch_sockaddr_t *audio_addr = NULL, *control_packet_addr;
 	switch_frame_t *read_frame;
 	switch_status_t status;
 	switch_size_t bytes;
@@ -65,7 +65,7 @@
 	switch_codec_t *read_codec;
 	uint32_t flags = 0;
 	const char *err;
-	switch_rtp_t *rtp_session;
+	switch_rtp_t *rtp_session = NULL;
 	switch_port_t rtp_port;
 	char guess_ip[25];
 	ls_how_t ready = SEND_TYPE_UNKNOWN;
@@ -215,7 +215,7 @@
 
  fail:
 
-	if (ready == SEND_TYPE_RTP && switch_rtp_ready(rtp_session)) {
+	if (rtp_session && ready == SEND_TYPE_RTP && switch_rtp_ready(rtp_session)) {
 		switch_rtp_destroy(&rtp_session);
 	}	
 

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_playback/mod_playback.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_playback/mod_playback.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_playback/mod_playback.c	Fri Jun  1 14:05:17 2007
@@ -142,6 +142,11 @@
 
 	path = switch_core_session_strdup(session, data);
 	if ((p = strchr(path, '+'))) {
+		char *q = p - 1;
+		while(q && *q == ' ') {
+			*q = '\0';
+			q--;
+		}
 		*p++ = '\0';
 		limit = atoi(p);
 	}
@@ -158,10 +163,24 @@
 static void record_session_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel;
+	char *p, *path = NULL;
+	uint32_t limit = 0;
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-	switch_ivr_record_session(session, data, NULL);
+	path = switch_core_session_strdup(session, data);
+	if ((p = strchr(path, '+'))) {
+		char *q = p - 1;
+		while(q && *q == ' ') {
+			*q = '\0';
+			q--;
+		}
+		*p++ = '\0';
+		limit = atoi(p);
+	}
+	
+	switch_ivr_record_session(session, path, limit, NULL);
 }
 
 

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c	Fri Jun  1 14:05:17 2007
@@ -317,7 +317,7 @@
 		}
 
 		nua_respond(tech_pvt->nh, SIP_200_OK,
-					SIPTAG_CONTACT_STR(tech_pvt->profile->url),
+					SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 					SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
 
 	}
@@ -680,7 +680,7 @@
 			sofia_glue_set_local_sdp(tech_pvt, ip, atoi(port), msg->string_arg, 1);
 		}
 		nua_respond(tech_pvt->nh, SIP_200_OK,
-					SIPTAG_CONTACT_STR(tech_pvt->profile->url),
+					SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 					SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
 		switch_channel_mark_answered(channel);
 	}

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.h	Fri Jun  1 14:05:17 2007
@@ -114,6 +114,11 @@
 	PFLAG_RESPAWN = (1 << 9)
 } PFLAGS;
 
+
+typedef enum {
+	PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 1)
+} sofia_NDLB_t;
+
 typedef enum {
 	TFLAG_IO = (1 << 0),
 	TFLAG_CHANGE_MEDIA = (1 << 1),
@@ -223,6 +228,7 @@
 	int dtmf_duration;
 	unsigned int flags;
 	unsigned int pflags;
+	unsigned int ndlb;
 	uint32_t max_calls;
 	uint32_t nonce_ttl;
 	nua_t *nua;
@@ -287,6 +293,7 @@
 	switch_port_t adv_sdp_audio_port;
 	char *proxy_sdp_audio_ip;
 	switch_port_t proxy_sdp_audio_port;
+	char *reply_contact;
 	char *from_uri;
 	char *to_uri;
 	char *from_address;

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c	Fri Jun  1 14:05:17 2007
@@ -110,6 +110,28 @@
 			su_root_break(profile->s_root);
 		}
 		break;
+
+	case nua_r_message:
+		{
+			if (status == 503) {
+				const char *user = NULL, *host = NULL;
+				char *sql;
+
+				if (sip->sip_to && sip->sip_to->a_url) {
+					user = sip->sip_to->a_url->url_user;
+					host = sip->sip_to->a_url->url_host;
+					
+					sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", user, host);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Deleting registration for %s@%s\n", user, host);
+					sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
+					switch_safe_free(sql);
+				}
+			} 
+
+			nua_handle_destroy(nh);
+			
+		}
+		break;
 	case nua_r_get_params:
 	case nua_r_invite:
 	case nua_r_unregister:
@@ -120,7 +142,6 @@
 	case nua_i_bye:
 	case nua_r_unsubscribe:
 	case nua_r_publish:
-	case nua_r_message:
 	case nua_r_notify:
 	case nua_i_notify:
 	case nua_i_cancel:
@@ -768,6 +789,10 @@
 						if (switch_true(val)) {
 							profile->pflags |= PFLAG_PRESENCE;
 						}
+					} else if (!strcasecmp(var, "NDLB-to-in-200-contact")) {
+						if (switch_true(val)) {
+							profile->ndlb |= PFLAG_NDLB_TO_IN_200_CONTACT;
+						}
 					} else if (!strcasecmp(var, "pass-rfc2833")) {
 						if (switch_true(val)) {
 							profile->pflags |= PFLAG_PASS_RFC2833;
@@ -1812,7 +1837,19 @@
 	}
 
 	if (sip->sip_to && sip->sip_to->a_url) {
+		char *val;
 		url_set_chanvars(session, sip->sip_to->a_url, sip_to);
+		if ((val = switch_channel_get_variable(channel, "sip_to_uri"))) {
+			tech_pvt->to_uri = switch_core_session_sprintf(session, "sip:%s", val);
+			if (profile->ndlb & PFLAG_NDLB_TO_IN_200_CONTACT) {
+				tech_pvt->reply_contact = tech_pvt->to_uri;
+			} else {
+				tech_pvt->to_uri = switch_core_session_strdup(session, profile->url);
+			}
+		} else {
+			tech_pvt->to_uri = switch_core_session_strdup(session, profile->url);
+			tech_pvt->reply_contact = tech_pvt->to_uri;
+		}
 	}
 
 	if (sip->sip_contact && sip->sip_contact->m_url) {
@@ -1897,7 +1934,7 @@
 				}
 			} else if (!strncasecmp(un->un_name, "Remote-Party-ID", 15)) {
 				process_rpid(un, tech_pvt);
-			} else if (!strncasecmp(un->un_name, "X-", 2)) {
+			} else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) {
 				if (!switch_strlen_zero(un->un_value)) {
 					char *new_name;
 					if ((new_name = switch_mprintf("%s%s", SOFIA_SIP_HEADER_PREFIX, un->un_name))) {

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c	Fri Jun  1 14:05:17 2007
@@ -162,10 +162,11 @@
 	}
 
 
-	if (switch_test_flag(tech_pvt, TFLAG_VIDEO)) {
+	if (switch_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding) {
 		sofia_glue_tech_choose_video_port(tech_pvt);
 		if ((v_port = tech_pvt->adv_sdp_video_port)) {
 			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "m=video %d RTP/AVP", v_port);
+			
 			sofia_glue_tech_set_video_codec(tech_pvt, 0);	
 
 
@@ -955,7 +956,6 @@
 
 		if (switch_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding) {
 			flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_NOBLOCK | SWITCH_RTP_FLAG_RAW_WRITE);
-
 			sofia_glue_tech_set_video_codec(tech_pvt, 0);
 
 			tech_pvt->video_rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip,

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_presence.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_presence.c	Fri Jun  1 14:05:17 2007
@@ -94,7 +94,7 @@
 
 
 		nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
-
+		
 
 		switch_safe_free(ffrom);
 		free(user);

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c	Fri Jun  1 14:05:17 2007
@@ -136,6 +136,24 @@
 	return 0;
 }
 
+int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+	sofia_profile_t *profile = (sofia_profile_t *) pArg;
+	nua_handle_t *nh;
+	char *contact;
+	char to[128] = "";
+
+	snprintf(to, sizeof(to), "%s@%s", argv[0], argv[1]);
+	contact = sofia_glue_get_url_from_contact(argv[2], 1);
+
+	nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(contact), SIPTAG_CONTACT_STR(profile->url), TAG_END());
+	
+	nua_message(nh, SIPTAG_CONTENT_TYPE_STR("text/plain"),
+				SIPTAG_PAYLOAD_STR("You suffer from Connectile Dysfunction.\nYou should use stun....\n"), TAG_END());
+
+	return 0;
+}
+
 int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames)
 {
 	switch_event_t *s_event;
@@ -153,6 +171,7 @@
 	return 0;
 }
 
+
 void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
 {
 	char sql[1024];
@@ -205,6 +224,16 @@
 	}
 	sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
 
+	if (now) {
+		snprintf(sql, sizeof(sql), "select * from sip_registrations where status like '%%NATHACK%%'");
+		sofia_glue_execute_sql_callback(profile,
+										SWITCH_TRUE,
+										NULL,
+										sql,
+										sofia_reg_nat_callback,
+										profile);
+	}
+
 	switch_mutex_unlock(profile->ireg_mutex);
 
 }
@@ -263,12 +292,15 @@
 	const char *rpid = "unknown";
 	const char *display = "\"user\"";
 	char network_ip[80];
+	int network_port;
+	int cd = 0;
 
 	/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
 	assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
 
 	get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
-
+	network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
+	
 	expires = sip->sip_expires;
 	authorization = sip->sip_authorization;
 	contact = sip->sip_contact;
@@ -333,11 +365,21 @@
 		}
 		
 		if (v_event && *v_event && (v_contact_str = switch_event_get_header(*v_event, "force-contact"))) {
-			char *p;
-			switch_copy_string(contact_str, v_contact_str, sizeof(contact_str));
-			for(p = contact_str; p && *p; p++) {
-				if (*p == '\'' || *p == '[' || *p == ']') {
-					*p = '"';
+			if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction") || !strcasecmp(v_contact_str, "NDLB-connectile-dysfunction")) {
+				if (contact->m_url->url_params) {
+					snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d;%s>",
+							 display, contact->m_url->url_user, network_ip, network_port, contact->m_url->url_params);
+				} else {
+					snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>", display, contact->m_url->url_user, network_ip, network_port);
+				}
+				cd = 1;
+			} else {
+				char *p;
+				switch_copy_string(contact_str, v_contact_str, sizeof(contact_str));
+				for(p = contact_str; p && *p; p++) {
+					if (*p == '\'' || *p == '[' || *p == ']') {
+						*p = '"';
+					}
 				}
 			}
 		}
@@ -386,8 +428,8 @@
 
 	if (exptime) {
 		if (!sofia_reg_find_reg_url(profile, from_user, from_host, buf, sizeof(buf))) {
-			sql = switch_mprintf("insert into sip_registrations values ('%q','%q','%q','Registered', '%q', %ld)",
-								 from_user, from_host, contact_str, rpid, (long) time(NULL) + (long) exptime * 2);
+			sql = switch_mprintf("insert into sip_registrations values ('%q','%q','%q','%q', '%q', %ld)",
+								 from_user, from_host, contact_str, cd ? "Registered(NATHACK)" : "Registered", rpid, (long) time(NULL) + (long) exptime * 2);
 
 		} else {
 			sql =

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_wanpipe/Makefile
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_wanpipe/Makefile	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_wanpipe/Makefile	Fri Jun  1 14:05:17 2007
@@ -3,8 +3,8 @@
 LIBPRI=libpri-1.2.4
 LIBPRI_FILE=$(LIBPRI).tar.gz
 LIBPRI_DIR=$(BASE)/libs/$(LIBPRI)
-WANPIPE=wanpipe-3.1.0.p18
-WANPIPE_HOST=ftp://ftp.sangoma.com/linux/custom/3.1
+WANPIPE=wanpipe-3.1.0
+WANPIPE_HOST=ftp://ftp.sangoma.com/linux/current_wanpipe/
 WANPIPE_FILE=$(WANPIPE).tgz
 WANPIPE_DIR=$(BASE)/libs/$(WANPIPE)
 WANPIPE_INCLUDE=$(WANPIPE_DIR)/patches/kdrivers/include
@@ -12,11 +12,25 @@
 WANPIPE_INSTALLED_KO=$(shell echo "/lib/modules/`uname -r`/kernel/drivers/net/wan/wanpipe.ko")
 LIBSANGOMA_DIR=./libsangoma
 LOCAL_CFLAGS  =-w -I$(WANPIPE_INCLUDE) -I$(LIBSANGOMA_DIR) -I/usr/local/include -I$(LIBPRI_DIR) -I/usr/src/linux/include -I. -I/usr/include 
-LOCAL_CFLAGS +=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -DAFT_A104 -DWANPIPE_TDM_API -I$(switch_srcdir)/libs/libteletone/src -D_GNUC_ -DWANPIPE_TDM_API
-LOCAL_OBJS = ss7boost_client.o $(LIBPRI_DIR)/copy_string.o $(LIBPRI_DIR)/pri.o $(LIBPRI_DIR)/q921.o $(LIBPRI_DIR)/prisched.o $(LIBPRI_DIR)/q931.o $(LIBPRI_DIR)/pri_facility.o $(LIBSANGOMA_DIR)/libsangoma.o $(LIBSANGOMA_DIR)/sangoma_pri.o 
+LOCAL_CFLAGS +=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -DAFT_A104 -DWANPIPE_TDM_API -I$(switch_srcdir)/libs/libteletone/src -D_GNUC_ -DWANPIPE_TDM_API -w -fPIC
+LOCAL_OBJS = ss7boost_client.o $(LIBPRI_DIR)/copy_string.o $(LIBPRI_DIR)/pri.o $(LIBPRI_DIR)/q921.o $(LIBPRI_DIR)/prisched.o $(LIBPRI_DIR)/q931.o $(LIBPRI_DIR)/pri_facility.o $(LIBSANGOMA_DIR)/libsangoma.o $(LIBSANGOMA_DIR)/sangoma_pri.o
+WTF=-fPIC -w -std=gnu99 -I$(BASE)/libs/wanpipe-3.1.0/patches/kdrivers/include -I./libsangoma -I/usr/local/include -I../../../../libs/libpri-1.2.4 -I/usr/src/linux/include -I. -I/usr/include -D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -DAFT_A104 -DWANPIPE_TDM_API -I$(BASE)/libs/libteletone/src -D_GNUC_ -DWANPIPE_TDM_API -w -I$(BASE)/src/include -I$(BASE)/libs/libteletone/src -fPIC -g -O2 -Wall -D_GNU_SOURCE -DHAVE_CONFIG_H
+
+
 
 include $(BASE)/build/modmake.rules 
 
+mod_wanpipe.o: mod_wanpipe.c
+	@echo Compiling $<...
+	$(CC) $(WTF) -c -o $@ $< || exit 1
+
+
+$(LIBSANGOMA_DIR)/libsangoma.o:  $(LIBSANGOMA_DIR)/libsangoma.c
+	$(CC) -c -I$(WANPIPE_DIR) $(LOCAL_CFLAGS) $(LIBSANGOMA_DIR)/libsangoma.c -o $(LIBSANGOMA_DIR)/libsangoma.o
+
+$(LIBSANGOMA_DIR)/sangoma_pri.o: $(LIBSANGOMA_DIR)/sangoma_pri.c
+	$(CC) -c -I$(WANPIPE_DIR) $(LOCAL_CFLAGS) $(LIBSANGOMA_DIR)/sangoma_pri.c -o $(LIBSANGOMA_DIR)/sangoma_pri.o
+
 testapp: testapp.c $(LIBSANGOMA_DIR)/libsangoma.o
 	$(CC) -I$(WANPIPE_DIR)/api/lib $(CFLAGS) $(LOCAL_CFLAGS) lib_api.c testapp.c $(LIBSANGOMA_DIR)/libsangoma.o -o testapp
 
@@ -27,7 +41,7 @@
 	$(GETLIB) $(WANPIPE_HOST) $(WANPIPE_FILE)
 
 $(WANPIPE_KO): $(WANPIPE_DIR)
-	cd $(WANPIPE_DIR) && $(MAKE)
+	cd $(WANPIPE_DIR) && $(MAKE) && $(MAKE) install
 	@$(TOUCH_TARGET)
 
 $(WANPIPE_INSTALLED_KO): $(WANPIPE_KO)
@@ -37,3 +51,5 @@
 
 local_install: $(WANPIPE_INSTALLED_KO)
 
+local_clean:
+	rm -f libsangoma/*.o

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	Fri Jun  1 14:05:17 2007
@@ -1568,7 +1568,6 @@
 			ret = 0;
 			goto done;
 		}
-		switch_core_session_thread_launch(session);
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create new Inbound Channel!\n");
 	}

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/Makefile
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/Makefile	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/Makefile	Fri Jun  1 14:05:17 2007
@@ -3,9 +3,8 @@
 
 # and define these variables to impact your build
 
-LOCAL_CFLAGS=-I$(PREFIX)/include/python2.4/ -I/usr/include/python2.4/
-LOCAL_LDFLAGS=-lpython2.4 -L$(PREFIX)/lib/python2.4/config/  -lutil -lstdc++
-
+LOCAL_CFLAGS=-I$(PREFIX)/include/python2.5/
+LOCAL_LDFLAGS=-lpython2.5 -L$(PREFIX)/lib/python2.5/config/  -lutil -lstdc++
 LOCAL_OBJS=freeswitch_python.o mod_python_wrap.o
 include ../../../../build/modmake.rules
 
@@ -15,17 +14,16 @@
 SWIGIFILE=../../../switch_swig.i
 
 local_depend:
-	MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install Python-2.5.1.tgz --prefix=$(PREFIX) --enable-threads CFLAGSFORSHARED="-fPIC"
+MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install Python-2.5.1.tgz --prefix=$(PREFIX) --enable-threads CFLAGSFORSHARED="-fPIC"
 
 reswig: 
-	swig -python -shadow -c++ -I../../../../src/include -o mod_python_wrap.cpp mod_python.i
+swig -python -shadow -c++ -o mod_python_wrap.cpp mod_python.i
 
 switch_swig_wrap.o: switch_swig_wrap.c Makefile
-	$(CC)  -w $(CFLAGS) -c $< -o $@
+$(CC)  -w $(CFLAGS) -c $< -o $@
 
 switch_swig.o: $(SWIGCFILE) Makefile
-	$(CC)  -w $(CFLAGS) -c $< -o $@
+$(CC)  -w $(CFLAGS) -c $< -o $@
 
 local_install:
-	cp -f freeswitch.py /usr/lib/python2.4/site-packages/
-
+cp -f freeswitch.py $(PREFIX)/lib/python2.5/site-packages/

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Fri Jun  1 14:05:17 2007
@@ -201,7 +201,7 @@
 	if (!strcasecmp(how, "xml")) {
 		switch_xml_t xml;
 		char *xmlstr;
-		if ((xml = switch_event_xmlize(ro->stream->event, NULL))) {
+		if ((xml = switch_event_xmlize(ro->stream->event, SWITCH_VA_NONE))) {
             xmlstr = switch_xml_toxml(xml);
 			*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, xmlstr));
 			return JS_TRUE;

Modified: freeswitch/branches/greenlizard/src/switch_apr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_apr.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_apr.c	Fri Jun  1 14:05:17 2007
@@ -335,6 +335,15 @@
 	return apr_file_write(thefile, buf, nbytes);
 }
 
+SWITCH_DECLARE(int) switch_file_printf(switch_file_t *thefile, const char *format, ...)
+{
+	va_list ap;
+    int ret;
+	ret = apr_file_printf(thefile, format, ap);
+	va_end(ap);
+    return ret;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool)
 {
 	return apr_file_mktemp(thefile, templ, flags, pool);

Modified: freeswitch/branches/greenlizard/src/switch_buffer.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_buffer.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_buffer.c	Fri Jun  1 14:05:17 2007
@@ -260,6 +260,7 @@
 	assert(buffer->data != NULL);
 
 	buffer->used = 0;
+	buffer->actually_used = 0;
 	buffer->head = buffer->data;
 }
 

Modified: freeswitch/branches/greenlizard/src/switch_caller.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_caller.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_caller.c	Fri Jun  1 14:05:17 2007
@@ -193,6 +193,16 @@
 		snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->chan_name);
 	}
+	if (caller_profile->times) {
+		snprintf(header_name, sizeof(header_name), "%s-Channel-Created-Time", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
+		snprintf(header_name, sizeof(header_name), "%s-Channel-Answered-Time", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
+		snprintf(header_name, sizeof(header_name), "%s-Channel-Hangup-Time", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
+		snprintf(header_name, sizeof(header_name), "%s-Channel-Transfer-Time", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
+	}
 
 	snprintf(header_name, sizeof(header_name), "%s-Screen-Bit", prefix);
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "yes" : "no");
@@ -203,7 +213,7 @@
 	snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Number", prefix);
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "yes" : "no");
 
-
+	
 
 }
 

Modified: freeswitch/branches/greenlizard/src/switch_core_io.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_io.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_io.c	Fri Jun  1 14:05:17 2007
@@ -232,7 +232,7 @@
 					switch_mutex_lock(bp->read_mutex);
 					switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
 					if (bp->callback) {
-						if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE) {
+						if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time >= time(NULL))) {
 							bp->ready = 0;
 							if (last) {
 								last->next = bp->next;
@@ -505,6 +505,11 @@
 					}
 				}
 
+				if (bp->stop_time && bp->stop_time >= time(NULL)) {
+					ok = SWITCH_FALSE;
+				}
+
+
 				if (ok == SWITCH_FALSE) {
 					bp->ready = 0;
 					if (last) {

Modified: freeswitch/branches/greenlizard/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_media_bug.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_media_bug.c	Fri Jun  1 14:05:17 2007
@@ -144,7 +144,7 @@
 #define MAX_BUG_BUFFER 1024 * 512
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session,
 														  switch_media_bug_callback_t callback,
-														  void *user_data, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
+														  void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
 {
 	switch_media_bug_t *bug, *bp;
 	switch_size_t bytes;
@@ -170,6 +170,7 @@
 	bug->session = session;
 	bug->flags = flags;
 	bug->ready = 1;
+	bug->stop_time = stop_time;
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attaching BUG to %s\n", switch_channel_get_name(session->channel));
 	bytes = session->read_codec->implementation->bytes_per_frame;
 

Modified: freeswitch/branches/greenlizard/src/switch_core_session.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_session.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_session.c	Fri Jun  1 14:05:17 2007
@@ -681,6 +681,7 @@
 	switch_core_media_bug_remove_all(*session);
 	switch_buffer_destroy(&(*session)->raw_read_buffer);
 	switch_buffer_destroy(&(*session)->raw_write_buffer);
+
 	switch_channel_uninit((*session)->channel);
 
 	pool = (*session)->pool;
@@ -717,23 +718,31 @@
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(switch_core_session_t *session)
 {
+	switch_status_t status = SWITCH_STATUS_FALSE;
 	switch_thread_t *thread;
 	switch_threadattr_t *thd_attr;;
+
 	switch_threadattr_create(&thd_attr, session->pool);
 	switch_threadattr_detach_set(thd_attr, 1);
 
+	switch_mutex_lock(session->mutex);
+	
 	if (!session->thread_running) {
+		session->thread_running = 1;
 		switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
 		if (switch_thread_create(&thread, thd_attr, switch_core_session_thread, session, session->pool) == SWITCH_STATUS_SUCCESS) {
-			return SWITCH_STATUS_SUCCESS;
+			status = SWITCH_STATUS_SUCCESS;
 		} else {
+			session->thread_running = 0;
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot create thread!\n");
 		}
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot double-launch thread!\n");
 	}
 
-	return SWITCH_STATUS_FALSE;
+	switch_mutex_unlock(session->mutex);
+
+	return status;
 }
 
 

Modified: freeswitch/branches/greenlizard/src/switch_ivr_async.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_async.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_async.c	Fri Jun  1 14:05:17 2007
@@ -147,7 +147,7 @@
 
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, switch_file_handle_t *fh)
+SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh)
 {
 	switch_channel_t *channel;
 	switch_codec_t *read_codec;
@@ -155,6 +155,7 @@
 	const char *vval;
 	switch_media_bug_t *bug;
 	switch_status_t status;
+	time_t to = 0;
 
 	if (!fh) {
 		if (!(fh = switch_core_session_alloc(session, sizeof(*fh)))) {
@@ -220,9 +221,11 @@
 		switch_channel_set_variable(channel, "RECORD_DATE", NULL);
 	}
 
+	if (limit) {
+		to = time(NULL) + limit;
+	}
 
-
-	if ((status = switch_core_media_bug_add(session, record_callback, fh, SMBF_BOTH, &bug)) != SWITCH_STATUS_SUCCESS) {
+	if ((status = switch_core_media_bug_add(session, record_callback, fh, to, SMBF_BOTH, &bug)) != SWITCH_STATUS_SUCCESS) {
 		switch_core_file_close(fh);
 		return status;
 	}
@@ -312,7 +315,7 @@
 
 	switch_channel_answer(channel);
 
-	if ((status = switch_core_media_bug_add(session, inband_dtmf_callback, pvt, SMBF_READ_STREAM, &bug)) != SWITCH_STATUS_SUCCESS) {
+	if ((status = switch_core_media_bug_add(session, inband_dtmf_callback, pvt, 0, SMBF_READ_STREAM, &bug)) != SWITCH_STATUS_SUCCESS) {
 		return status;
 	}
 
@@ -597,7 +600,7 @@
 	sth->session = session;
 	sth->ah = ah;
 
-	if ((status = switch_core_media_bug_add(session, speech_callback, sth, SMBF_READ_STREAM, &sth->bug)) != SWITCH_STATUS_SUCCESS) {
+	if ((status = switch_core_media_bug_add(session, speech_callback, sth, 0, SMBF_READ_STREAM, &sth->bug)) != SWITCH_STATUS_SUCCESS) {
 		switch_core_asr_close(ah, &flags);
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return status;

Modified: freeswitch/branches/greenlizard/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_originate.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_originate.c	Fri Jun  1 14:05:17 2007
@@ -177,13 +177,13 @@
 					(early_ok && len == 1 && switch_channel_test_flag(peer_channels[i], CF_EARLY_MEDIA))) &&
 				   !switch_channel_test_flag(peer_channels[i], CF_TAGGED)) {
 
-			if (key) {
+			if (!switch_strlen_zero(key)) {
 				struct key_collect *collect;
 
 				if ((collect = switch_core_session_alloc(peer_sessions[i], sizeof(*collect)))) {
 					switch_channel_set_flag(peer_channels[i], CF_TAGGED);
 					collect->key = key;
-					if (file) {
+					if (!switch_strlen_zero(file)) {
 						collect->file = switch_core_session_strdup(peer_sessions[i], file);
 					}
 
@@ -260,7 +260,7 @@
 	switch_codec_t write_codec = { 0 };
 	switch_frame_t write_frame = { 0 };
 	uint8_t fdata[1024], pass = 0;
-	char *file = NULL, *key = NULL, *odata, *var;
+	char key[80] = "", file[512] = "", *odata, *var;
 	switch_call_cause_t reason = SWITCH_CAUSE_UNALLOCATED;
 	uint8_t to = 0;
 	char *var_val, *vars = NULL, *ringback_data = NULL;
@@ -362,9 +362,9 @@
 	}
 
 	if ((var = switch_event_get_header(var_event, "group_confirm_key"))) {
-		key = switch_core_session_strdup(session, var);
+		switch_copy_string(key, var, sizeof(key));
 		if ((var = switch_event_get_header(var_event, "group_confirm_file"))) {
-			file = switch_core_session_strdup(session, var);
+			switch_copy_string(file, var, sizeof(file));
 		}
 	}
 	// When using the AND operator, the fail_on_single_reject flag may be set in order to indicate that a single
@@ -373,8 +373,8 @@
 		fail_on_single_reject = 1;
 	}
 
-	if (file && !strcmp(file, "undef")) {
-		file = NULL;
+	if (!switch_strlen_zero(file) && !strcmp(file, "undef")) {
+		*file = '\0';
 	}
 
 	if ((var_val = switch_event_get_header(var_event, "ignore_early_media")) && switch_true(var_val)) {
@@ -440,8 +440,6 @@
 			read_frame = NULL;
 			pool = NULL;
 			pass = 0;
-			file = NULL;
-			key = NULL;
 			var = NULL;
 			to = 0;
 

Modified: freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_play_say.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_play_say.c	Fri Jun  1 14:05:17 2007
@@ -831,7 +831,6 @@
 			status = SWITCH_STATUS_SUCCESS;
 			continue;
 		} else if (status != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Bad Write\n");
 			done = 1;
 			break;
 		}
@@ -852,6 +851,7 @@
 				switch_yield(10000);
 			}
 			status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
@@ -1043,7 +1043,6 @@
 			write_frame.timestamp = timer->samplecount;
 		}
 		if (switch_core_session_write_frame(session, &write_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Bad Write\n");
 			done = 1;
 			break;
 		}
@@ -1125,7 +1124,6 @@
 					write_frame.timestamp = timer->samplecount;
 				}
 				if (switch_core_session_write_frame(session, &write_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Bad Write\n");
 					done = 1;
 					break;
 				}
@@ -1146,7 +1144,6 @@
 			write_frame.timestamp = timer->samplecount;
 		}
 		if (switch_core_session_write_frame(session, &write_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Bad Write\n");
 			done = 1;
 			break;
 		}

Modified: freeswitch/branches/greenlizard/src/switch_loadable_module.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_loadable_module.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_loadable_module.c	Fri Jun  1 14:05:17 2007
@@ -785,7 +785,6 @@
 
 SWITCH_DECLARE(switch_status_t) switch_loadable_module_unload_module(char *dir, char *fname, const char **err)
 {
-	switch_size_t len = 0;
 	char *path = NULL;
 	char *file = NULL;
 	switch_loadable_module_t *module = NULL;
@@ -808,17 +807,9 @@
 		path = strdup(file);
 	} else {
 		if (strchr(file, '.')) {
-			len = strlen(dir);
-			len += strlen(file);
-			len += 4;
-			path = (char *) switch_core_alloc(loadable_modules.pool, len);
-			snprintf(path, len, "%s%s%s", dir, SWITCH_PATH_SEPARATOR, file);
+			path = switch_mprintf("%s%s%s", dir, SWITCH_PATH_SEPARATOR, file);
 		} else {
-			len = strlen(dir);
-			len += strlen(file);
-			len += 8;
-			path = (char *) malloc(len);
-			snprintf(path, len, "%s%s%s%s", dir, SWITCH_PATH_SEPARATOR, file, ext);
+			path = switch_mprintf("%s%s%s%s", dir, SWITCH_PATH_SEPARATOR, file, ext);
 		}
 	}
 
@@ -833,6 +824,7 @@
 			do_shutdown(module);
 		}
 	} else {
+		*err = "No such module!";
 		status = SWITCH_STATUS_FALSE;
 	}
 	switch_mutex_unlock(loadable_modules.mutex);
@@ -1259,7 +1251,7 @@
 			if (cur != name) {
 				if (strchr(cur, 'i')) {
 					interval = atoi(cur);
-				} else if (strchr(cur, 'k')) {
+				} else if (strchr(cur, 'k' || strchr(cur, 'h'))) {
 					rate = atoi(cur);
 				}
 			}

Modified: freeswitch/branches/greenlizard/src/switch_log.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_log.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_log.c	Fri Jun  1 14:05:17 2007
@@ -114,8 +114,9 @@
 static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t * thread, void *obj)
 {
 
-	/* To Be or Not To Be */
-	assert(obj == NULL || obj != NULL);
+	if (!obj) {
+		obj = NULL;
+	}
 	THREAD_RUNNING = 1;
 
 	while (THREAD_RUNNING == 1) {

Modified: freeswitch/branches/greenlizard/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_rtp.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_rtp.c	Fri Jun  1 14:05:17 2007
@@ -578,7 +578,7 @@
 
 SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te)
 {
-	if (te > 96) {
+	if (te > 95) {
 		rtp_session->te = te;
 	}
 }
@@ -752,8 +752,13 @@
 		rtp_session->dtmf_data.out_digit_packet[3] = (unsigned char) duration;
 
 
+
+		rtp_session->dtmf_data.timestamp_dtmf += samples;
+
+		
 		for (x = 0; x < loops; x++) {
 			rtp_session->dtmf_data.out_digit_seq++;
+
 			switch_rtp_write_manual(rtp_session,
 									rtp_session->dtmf_data.out_digit_packet,
 									4,
@@ -765,10 +770,13 @@
 							  loops == 1 ? "middle" : "end", rtp_session->dtmf_data.out_digit, rtp_session->dtmf_data.timestamp_dtmf,
 							  rtp_session->dtmf_data.out_digit_sofar, duration, rtp_session->dtmf_data.out_digit_seq);
 
+			
 		}
 
 		if (loops == 1) {
 			rtp_session->last_write_seq = 0;
+		} else {
+			rtp_session->dtmf_data.out_digit_seq = 0;
 		}
 	}
 
@@ -797,7 +805,7 @@
 
 
 			for (x = 0; x < 3; x++) {
-				//rtp_session->dtmf_data.out_digit_seq++;
+				rtp_session->dtmf_data.out_digit_seq++;
 				switch_rtp_write_manual(rtp_session,
 										rtp_session->dtmf_data.out_digit_packet,
 										4,
@@ -811,7 +819,7 @@
 								  rtp_session->dtmf_data.out_digit,
 								  rtp_session->dtmf_data.timestamp_dtmf, rtp_session->dtmf_data.out_digit_sofar, 0, rtp_session->dtmf_data.out_digit_seq);
 			}
-
+			rtp_session->dtmf_data.timestamp_dtmf += samples;
 			free(rdigit);
 		}
 	}
@@ -1409,7 +1417,7 @@
 	}
 
 
-	if (rtp_session->last_write_seq >0 && rtp_session->last_write_seq <= rtp_session->dtmf_data.out_digit_seq) {
+	if (rtp_session->last_write_seq > 0 && rtp_session->last_write_seq <= rtp_session->dtmf_data.out_digit_seq) {
 		send = 0;
 	}
 



More information about the Freeswitch-branches mailing list