[Freeswitch-svn] [commit] r5382 - in freeswitch/branches/greenlizard: build libs/libteletone libs/libteletone/src src src/include src/mod/applications/mod_commands src/mod/applications/mod_dptools src/mod/applications/mod_soundtouch src/mod/asr_tts/mod_lumenvox src/mod/endpoints/mod_sofia src/mod/endpoints/mod_wanpipe src/mod/event_handlers/mod_radius_cdr src/mod/event_handlers/mod_radius_cdr/radius src/mod/languages/mod_python src/mod/languages/mod_spidermonkey src/mod/languages/mod_spidermonkey_core_db src/mod/languages/mod_spidermonkey_etpan src/mod/languages/mod_spidermonkey_odbc src/mod/languages/mod_spidermonkey_skel src/mod/languages/mod_spidermonkey_teletone

Freeswitch SVN greenlizard at freeswitch.org
Sat Jun 16 17:05:08 EDT 2007


Author: greenlizard
Date: Sat Jun 16 17:05:07 2007
New Revision: 5382

Added:
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/Makefile.am
      - copied unchanged from r5381, /freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/Makefile.am
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/README
      - copied unchanged from r5381, /freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/README
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c
      - copied unchanged from r5381, /freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.conf.xml
      - copied unchanged from r5381, /freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.conf.xml
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h
      - copied unchanged from r5381, /freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/radius/
      - copied from r5381, /freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/radius/
   freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/radius/dictionary
      - copied unchanged from r5381, /freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/radius/dictionary
Modified:
   freeswitch/branches/greenlizard/build/modules.conf.in
   freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.c
   freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.h
   freeswitch/branches/greenlizard/libs/libteletone/teletone.def
   freeswitch/branches/greenlizard/src/include/switch_cpp.h
   freeswitch/branches/greenlizard/src/include/switch_ivr.h
   freeswitch/branches/greenlizard/src/include/switch_types.h
   freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
   freeswitch/branches/greenlizard/src/mod/asr_tts/mod_lumenvox/Makefile
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
   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_python/freeswitch.py
   freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
   freeswitch/branches/greenlizard/src/switch_core_codec.c
   freeswitch/branches/greenlizard/src/switch_core_io.c
   freeswitch/branches/greenlizard/src/switch_cpp.cpp
   freeswitch/branches/greenlizard/src/switch_event.c
   freeswitch/branches/greenlizard/src/switch_ivr_async.c
   freeswitch/branches/greenlizard/src/switch_rtp.c

Log:
merge trunk 5360 to 5381

Modified: freeswitch/branches/greenlizard/build/modules.conf.in
==============================================================================
--- freeswitch/branches/greenlizard/build/modules.conf.in	(original)
+++ freeswitch/branches/greenlizard/build/modules.conf.in	Sat Jun 16 17:05:07 2007
@@ -38,6 +38,7 @@
 formats/mod_sndfile
 #formats/mod_shout
 #languages/mod_perl
+#languages/mod_python
 #languages/mod_spidermonkey
 #languages/mod_spidermonkey_teletone
 #languages/mod_spidermonkey_core_db

Modified: freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.c
==============================================================================
--- freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.c	(original)
+++ freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.c	Sat Jun 16 17:05:07 2007
@@ -106,9 +106,8 @@
 static teletone_detection_descriptor_t dtmf_detect_row_2nd[GRID_FACTOR];
 static teletone_detection_descriptor_t dtmf_detect_col_2nd[GRID_FACTOR];
 
-static teletone_process_t dtmf_row[] = {697.0,  770.0,  852.0,  941.0};
-static teletone_process_t dtmf_col[] = {1209.0, 1336.0, 1477.0, 1633.0};
-
+static float dtmf_row[] = {697.0f,  770.0f,  852.0f,  941.0f};
+static float dtmf_col[] = {1209.0f, 1336.0f, 1477.0f, 1633.0f};
 
 static char dtmf_positions[] = "123A" "456B" "789C" "*0#D";
 
@@ -122,39 +121,36 @@
 							  int samples)
 {
     int i;
-    teletone_process_t v1;
+    float v1;
     
     for (i = 0;  i < samples;  i++) {
         v1 = goertzel_state->v2;
         goertzel_state->v2 = goertzel_state->v3;
-        goertzel_state->v3 = goertzel_state->fac*goertzel_state->v2 - v1 + sample_buffer[i];
+        goertzel_state->v3 = (float)(goertzel_state->fac*goertzel_state->v2 - v1 + sample_buffer[i]);
     }
 }
 
-teletone_process_t teletone_goertzel_result (teletone_goertzel_state_t *goertzel_state)
-{
-    return goertzel_state->v3 * goertzel_state->v3 + goertzel_state->v2 * goertzel_state->v2 - goertzel_state->v2 * goertzel_state->v3 * goertzel_state->fac;
-}
+#define teletone_goertzel_result(gs) ((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac)
 
 void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate)
 {
     int i;
-    teletone_process_t theta;
+    float theta;
 
     dtmf_detect_state->hit1 = dtmf_detect_state->hit2 = 0;
 
     for (i = 0;  i < GRID_FACTOR;  i++) {
-        theta = M_TWO_PI*(dtmf_row[i]/(teletone_process_t)sample_rate);
-        dtmf_detect_row[i].fac = 2.0*cos(theta);
+        theta = (float)(M_TWO_PI*(dtmf_row[i]/(float)sample_rate));
+        dtmf_detect_row[i].fac = (float)(2.0f*cos(theta));
 
-        theta = M_TWO_PI*(dtmf_col[i]/(teletone_process_t)sample_rate);
-        dtmf_detect_col[i].fac = 2.0*cos(theta);
+        theta = (float)(M_TWO_PI*(dtmf_col[i]/(float)sample_rate));
+        dtmf_detect_col[i].fac = (float)(2.0f*cos(theta));
     
-        theta = M_TWO_PI*(dtmf_row[i]*2.0/(teletone_process_t)sample_rate);
-        dtmf_detect_row_2nd[i].fac = 2.0*cos(theta);
+        theta = (float)(M_TWO_PI*(dtmf_row[i]*2.0/(float)sample_rate));
+        dtmf_detect_row_2nd[i].fac = (float)(2.0f*cos(theta));
 
-        theta = M_TWO_PI*(dtmf_col[i]*2.0/(teletone_process_t)sample_rate);
-        dtmf_detect_col_2nd[i].fac = 2.0*cos(theta);
+        theta = (float)(M_TWO_PI*(dtmf_col[i]*2.0/(float)sample_rate));
+        dtmf_detect_col_2nd[i].fac = (float)(2.0f*cos(theta));
     
 		goertzel_init (&dtmf_detect_state->row_out[i], &dtmf_detect_row[i]);
     	goertzel_init (&dtmf_detect_state->col_out[i], &dtmf_detect_col[i]);
@@ -172,7 +168,7 @@
 
 void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map)
 {
-	teletone_process_t theta = 0;
+	float theta = 0;
 	int x = 0;
 
 	if(!mt->min_samples) {
@@ -200,8 +196,8 @@
 			break;
 		}
 		mt->tone_count++;
-		theta = M_TWO_PI*(map->freqs[x]/(teletone_process_t)mt->sample_rate);
-		mt->tdd[x].fac = 2.0 * cos(theta);
+		theta = (float)(M_TWO_PI*(map->freqs[x]/(float)mt->sample_rate));
+		mt->tdd[x].fac = (float)(2.0f * cos(theta));
 		goertzel_init (&mt->gs[x], &mt->tdd[x]);
 		goertzel_init (&mt->gs2[x], &mt->tdd[x]);
 	}
@@ -213,8 +209,8 @@
 								int samples)
 {
 	int sample, limit, j, x = 0;
-	teletone_process_t v1, famp;
-	teletone_process_t eng_sum = 0, eng_all[TELETONE_MAX_TONES];
+	float v1, famp;
+	float eng_sum = 0, eng_all[TELETONE_MAX_TONES];
 	int gtest = 0, see_hit = 0;
 
     for (sample = 0;  sample < samples;  sample = limit) {
@@ -234,11 +230,11 @@
 			for(x = 0; x < mt->tone_count; x++) {
 				v1 = mt->gs[x].v2;
 				mt->gs[x].v2 = mt->gs[x].v3;
-				mt->gs[x].v3 = mt->gs[x].fac * mt->gs[x].v2 - v1 + famp;
+				mt->gs[x].v3 = (float)(mt->gs[x].fac * mt->gs[x].v2 - v1 + famp);
     
 				v1 = mt->gs2[x].v2;
 				mt->gs2[x].v2 = mt->gs2[x].v3;
-				mt->gs2[x].v3 = mt->gs2[x].fac*mt->gs2[x].v2 - v1 + famp;
+				mt->gs2[x].v3 = (float)(mt->gs2[x].fac*mt->gs2[x].v2 - v1 + famp);
 			}
 		}
 
@@ -249,7 +245,7 @@
 
 		eng_sum = 0;
 		for(x = 0; x < mt->tone_count; x++) {
-			eng_all[x] = teletone_goertzel_result (&mt->gs[x]);
+			eng_all[x] = (float)(teletone_goertzel_result (&mt->gs[x]));
 			eng_sum += eng_all[x];
 		}
 
@@ -299,10 +295,10 @@
 						  int16_t sample_buffer[],
 						  int samples)
 {
-    teletone_process_t row_energy[GRID_FACTOR];
-    teletone_process_t col_energy[GRID_FACTOR];
-    teletone_process_t famp;
-    teletone_process_t v1;
+    float row_energy[GRID_FACTOR];
+    float col_energy[GRID_FACTOR];
+    float famp;
+    float v1;
     int i;
     int j;
     int sample;
@@ -329,19 +325,19 @@
 			for(x = 0; x < GRID_FACTOR; x++) {
 				v1 = dtmf_detect_state->row_out[x].v2;
 				dtmf_detect_state->row_out[x].v2 = dtmf_detect_state->row_out[x].v3;
-				dtmf_detect_state->row_out[x].v3 = dtmf_detect_state->row_out[x].fac*dtmf_detect_state->row_out[x].v2 - v1 + famp;
+				dtmf_detect_state->row_out[x].v3 = (float)(dtmf_detect_state->row_out[x].fac*dtmf_detect_state->row_out[x].v2 - v1 + famp);
     
 				v1 = dtmf_detect_state->col_out[x].v2;
 				dtmf_detect_state->col_out[x].v2 = dtmf_detect_state->col_out[x].v3;
-				dtmf_detect_state->col_out[x].v3 = dtmf_detect_state->col_out[x].fac*dtmf_detect_state->col_out[x].v2 - v1 + famp;
+				dtmf_detect_state->col_out[x].v3 = (float)(dtmf_detect_state->col_out[x].fac*dtmf_detect_state->col_out[x].v2 - v1 + famp);
 
 				v1 = dtmf_detect_state->col_out2nd[x].v2;
 				dtmf_detect_state->col_out2nd[x].v2 = dtmf_detect_state->col_out2nd[x].v3;
-				dtmf_detect_state->col_out2nd[x].v3 = dtmf_detect_state->col_out2nd[x].fac*dtmf_detect_state->col_out2nd[x].v2 - v1 + famp;
+				dtmf_detect_state->col_out2nd[x].v3 = (float)(dtmf_detect_state->col_out2nd[x].fac*dtmf_detect_state->col_out2nd[x].v2 - v1 + famp);
         
 				v1 = dtmf_detect_state->row_out2nd[x].v2;
 				dtmf_detect_state->row_out2nd[x].v2 = dtmf_detect_state->row_out2nd[x].v3;
-				dtmf_detect_state->row_out2nd[x].v3 = dtmf_detect_state->row_out2nd[x].fac*dtmf_detect_state->row_out2nd[x].v2 - v1 + famp;
+				dtmf_detect_state->row_out2nd[x].v3 = (float)(dtmf_detect_state->row_out2nd[x].fac*dtmf_detect_state->row_out2nd[x].v2 - v1 + famp);
 			}
 
         }
@@ -352,15 +348,15 @@
 		}
         /* We are at the end of a DTMF detection block */
         /* Find the peak row and the peak column */
-        row_energy[0] = teletone_goertzel_result (&dtmf_detect_state->row_out[0]);
-        col_energy[0] = teletone_goertzel_result (&dtmf_detect_state->col_out[0]);
+        row_energy[0] = (float)(teletone_goertzel_result (&dtmf_detect_state->row_out[0]));
+        col_energy[0] = (float)(teletone_goertzel_result (&dtmf_detect_state->col_out[0]));
 
 		for (best_row = best_col = 0, i = 1;  i < GRID_FACTOR;  i++) {
-    	    row_energy[i] = teletone_goertzel_result (&dtmf_detect_state->row_out[i]);
+    	    row_energy[i] = (float)(teletone_goertzel_result (&dtmf_detect_state->row_out[i]));
             if (row_energy[i] > row_energy[best_row]) {
                 best_row = i;
 			}
-    	    col_energy[i] = teletone_goertzel_result (&dtmf_detect_state->col_out[i]);
+    	    col_energy[i] = (float)(teletone_goertzel_result (&dtmf_detect_state->col_out[i]));
             if (col_energy[i] > col_energy[best_col]) {
                 best_col = i;
 			}

Modified: freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.h
==============================================================================
--- freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.h	(original)
+++ freeswitch/branches/greenlizard/libs/libteletone/src/libteletone_detect.h	Sat Jun 16 17:05:07 2007
@@ -136,9 +136,9 @@
 
 	/*! \brief A continer for the elements of a Goertzel Algorithm (The names are from his formula) */
 	typedef struct {
-		teletone_process_t v2;
-		teletone_process_t v3;
-		teletone_process_t fac;
+		float v2;
+		float v3;
+		double fac;
 	} teletone_goertzel_state_t;
 	
 	/*! \brief A container for a DTMF detection state.*/
@@ -153,7 +153,7 @@
 		teletone_goertzel_state_t col_out[GRID_FACTOR];
 		teletone_goertzel_state_t row_out2nd[GRID_FACTOR];
 		teletone_goertzel_state_t col_out2nd[GRID_FACTOR];
-		teletone_process_t energy;
+		float energy;
     
 		int current_sample;
 		char digits[TELETONE_MAX_DTMF_DIGITS + 1];
@@ -165,7 +165,7 @@
 
 	/*! \brief An abstraction to store the coefficient of a tone frequency */
 	typedef struct {
-		teletone_process_t fac;
+		float fac;
 	} teletone_detection_descriptor_t;
 
 	/*! \brief A container for a single multi-tone detection 
@@ -180,7 +180,7 @@
 		teletone_goertzel_state_t gs2[TELETONE_MAX_TONES];
 		int tone_count;
 
-		teletone_process_t energy;
+		float energy;
 		int current_sample;
 	
 		int min_samples;
@@ -253,13 +253,6 @@
 								  int16_t sample_buffer[],
 								  int samples);
 
-	/*! 
-	  \brief Compute the result of the last applied step of the Goertzel Algorithm
-	  \param goertzel_state the goertzel state to retrieve from
-	  \return the computed value for consideration in furthur audio tests
-	*/
-	teletone_process_t teletone_goertzel_result (teletone_goertzel_state_t *goertzel_state);
-
 
 
 #ifdef __cplusplus

Modified: freeswitch/branches/greenlizard/libs/libteletone/teletone.def
==============================================================================
--- freeswitch/branches/greenlizard/libs/libteletone/teletone.def	(original)
+++ freeswitch/branches/greenlizard/libs/libteletone/teletone.def	Sat Jun 16 17:05:07 2007
@@ -5,7 +5,6 @@
 teletone_init_session
 teletone_set_map
 teletone_set_tone
-teletone_goertzel_result
 teletone_goertzel_update
 teletone_dtmf_get
 teletone_dtmf_detect

Modified: freeswitch/branches/greenlizard/src/include/switch_cpp.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_cpp.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_cpp.h	Sat Jun 16 17:05:07 2007
@@ -28,7 +28,7 @@
                               // eg, PyThreadState *threadState
     void *extra;              // currently used to store a switch_file_handle_t
     char *funcargs;           // extra string that will be passed to callback function 
-};
+} input_callback_state;
 
 
 class CoreSession {

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	Sat Jun 16 17:05:07 2007
@@ -200,6 +200,9 @@
 */
 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_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags);
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, char *file);
+
 /*!
   \brief Stop Recording a session
   \param session the session to stop recording
@@ -230,18 +233,27 @@
 SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session);
 
 /*!
-  \brief Stop looking for FAX CNG
+  \brief Stop looking for TONES
   \param session the session to stop looking
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_stop_fax_detect_session(switch_core_session_t *session);
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_tone_detect_session(switch_core_session_t *session);
 
 /*!
-  \brief Start looking for FAX CNG
+  \brief Start looking for TONES
   \param session the session to start looking
+  \param key the name of the tone.
+  \param tone_spec comma sep list of tone freqs
+  \param flags one or both of 'r' and 'w'
+  \param timeout timeout
+  \param app optional application to execute when tone is found
+  \param data optional data for appliaction
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_fax_detect_session(switch_core_session_t *session);
+SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session, 
+															   const char *key, const char *tone_spec,
+															   const char *flags, time_t timeout,
+															   const char *app, const char *data);
 
 
 

Modified: freeswitch/branches/greenlizard/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_types.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_types.h	Sat Jun 16 17:05:07 2007
@@ -852,7 +852,7 @@
 	SWITCH_EVENT_CODEC				- Codec Change
 	SWITCH_EVENT_BACKGROUND_JOB		- Background Job
 	SWITCH_EVENT_DETECTED_SPEECH	- Detected Speech
-	SWITCH_EVENT_DETECTED_FAX       - Detected Fax CNG Tone
+	SWITCH_EVENT_DETECTED_TONE      - Detected Tone
 	SWITCH_EVENT_PRIVATE_COMMAND	- A private command event 
 	SWITCH_EVENT_HEARTBEAT			- Machine is alive
 	SWITCH_EVENT_TRAP				- Error Trap
@@ -902,7 +902,7 @@
 	SWITCH_EVENT_CODEC,
 	SWITCH_EVENT_BACKGROUND_JOB,
 	SWITCH_EVENT_DETECTED_SPEECH,
-	SWITCH_EVENT_DETECTED_FAX,
+	SWITCH_EVENT_DETECTED_TONE,
 	SWITCH_EVENT_PRIVATE_COMMAND,
 	SWITCH_EVENT_HEARTBEAT,
 	SWITCH_EVENT_TRAP,

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	Sat Jun 16 17:05:07 2007
@@ -276,6 +276,54 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+SWITCH_STANDARD_API(tone_detect_session_function)
+{
+	char *argv[6] = { 0 };
+	int argc;
+	char *mydata = NULL;
+	time_t to = 0;
+	switch_core_session_t *rsession;
+	
+	mydata = strdup(cmd);
+	assert(mydata != NULL);
+
+	if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 3) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
+	}
+
+	if (!(rsession = switch_core_session_locate(argv[0]))) {
+		stream->write_function(stream, "-Error Cannot locate session!\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	if (argv[4]) {
+		uint32_t mto;
+		if (*argv[4] == '+') {
+			if ((mto = atoi(argv[4]+1)) > 0) {
+				to = time(NULL) + mto;
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
+				goto done;
+			}
+		} else {
+			if ((to = atoi(argv[4])) < time(NULL)) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
+				to = 0;
+				goto done;
+			}
+		}
+	}
+
+	switch_ivr_tone_detect_session(rsession, argv[1], argv[2], argv[3], to, argv[5], argv[6]);
+	stream->write_function(stream, "Enabling tone detection '%s' '%s' '%s'\n", argv[1], argv[2], argv[3]);
+
+ done:
+
+	free(mydata);
+	switch_core_session_rwunlock(rsession);
+
+	return SWITCH_STATUS_SUCCESS;
+}
 
 SWITCH_STANDARD_API(sched_transfer_function)
 {
@@ -565,7 +613,7 @@
 		goto usage;
 	}
 
-	if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 3) {
+	if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 3) {
 		goto usage;
 	}
 
@@ -609,6 +657,73 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+
+SWITCH_STANDARD_API(session_displace_function)
+{
+	switch_core_session_t *rsession = NULL;
+	char *mycmd = NULL, *argv[5] = { 0 };
+	char *uuid = NULL, *action = NULL, *path = NULL;
+	int argc = 0;
+	uint32_t limit = 0;
+	char *flags = NULL;
+
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (switch_strlen_zero(cmd)) {
+		goto usage;
+	}
+
+	if (!(mycmd = strdup(cmd))) {
+		goto usage;
+	}
+
+	if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 3) {
+		goto usage;
+	}
+
+	uuid = argv[0];
+	action = argv[1];
+	path = argv[2];
+	limit = argv[3] ? atoi(argv[3]) : 0;
+	flags = argv[4];
+
+	if (!(rsession = switch_core_session_locate(uuid))) {
+		stream->write_function(stream, "-Error Cannot locate session!\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
+	
+	if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
+		goto usage;
+	}
+
+	if (!strcasecmp(action, "start")) {
+		switch_ivr_displace_session(rsession, path, limit, flags);
+	} else if (!strcasecmp(action, "stop")) {
+		switch_ivr_stop_displace_session(rsession, path);
+	} else {
+		goto usage;
+	}
+
+	goto done;
+
+  usage:
+
+	stream->write_function(stream, "INVALID SYNTAX\n");
+	switch_safe_free(mycmd);
+
+
+  done:
+
+	if (rsession) {
+		switch_core_session_rwunlock(rsession);
+	}
+
+	switch_safe_free(mycmd);
+	return SWITCH_STATUS_SUCCESS;
+}
+
 SWITCH_STANDARD_API(pause_function)
 {
 	switch_core_session_t *psession = NULL;
@@ -1237,12 +1352,20 @@
 	/*.next */ &broadcast_api_interface
 };
 
+static switch_api_interface_t session_displace_api_interface = {
+	/*.interface_name */ "session_displace",
+	/*.desc */ "session displace",
+	/*.function */ session_displace_function,
+	/*.syntax */ "<uuid> [start|stop] <path> [<limit>] [mux]",
+	/*.next */ &broadcast_api_interface
+};
+
 static switch_api_interface_t uuid_bridge_api_interface = {
 	/*.interface_name */ "uuid_bridge",
 	/*.desc */ "uuid_bridge",
 	/*.function */ uuid_bridge_function,
 	/*.syntax */ "<uuid> <other_uuid>",
-	/*.next */ &session_record_api_interface
+	/*.next */ &session_displace_api_interface
 };
 
 static switch_api_interface_t status_api_interface = {
@@ -1310,13 +1433,22 @@
 	/*.next */ &reload_api_interface
 };
 
+static switch_api_interface_t tone_detect_session_interface = {
+	/*.interface_name */ "tone_detect",
+	/*.desc */ "Start Tone Detection on a channel",
+	/*.function */ tone_detect_session_function,
+	/*.syntax */
+	"<uuid> <key> <tone_spec> [<flags> <timeout> <app> <args>]",
+	/*.next */ &kill_api_interface
+};
+
 static switch_api_interface_t originate_api_interface = {
 	/*.interface_name */ "originate",
 	/*.desc */ "Originate a Call",
 	/*.function */ originate_function,
 	/*.syntax */
 	"<call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]",
-	/*.next */ &kill_api_interface
+	/*.next */ &tone_detect_session_interface
 };
 
 static switch_loadable_module_interface_t commands_module_interface = {

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c	Sat Jun 16 17:05:07 2007
@@ -664,14 +664,45 @@
 
 static void fax_detect_session_function(switch_core_session_t *session, char *data)
 {
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enabling fax detection\n");
-	switch_ivr_fax_detect_session(session);
+	switch_ivr_tone_detect_session(session, "fax", "1100.0", "r", 0, NULL, NULL);
+}
+
+static void tone_detect_session_function(switch_core_session_t *session, char *data)
+{
+	char *argv[6] = { 0 };
+	int argc;
+	char *mydata = NULL;
+	time_t to = 0;
+
+	mydata = switch_core_session_strdup(session, data);
+	if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 2) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
+	}
+	if (argv[3]) {
+		uint32_t mto;
+		if (*argv[3] == '+') {
+			if ((mto = atol(argv[3]+1)) > 0) {
+				to = time(NULL) + mto;
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
+			}
+		} else {
+			if ((to = atol(argv[3])) < time(NULL)) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
+				to = 0;
+			}
+		}
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enabling tone detection '%s' '%s'\n", argv[0], argv[1]);
+	
+	switch_ivr_tone_detect_session(session, argv[0], argv[1], argv[2], to, argv[4], argv[5]);
 }
 
 static void stop_fax_detect_session_function(switch_core_session_t *session, char *data)
 {
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disabling fax detection\n");
-	switch_ivr_stop_fax_detect_session(session);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Disabling tone detection\n");
+	switch_ivr_stop_tone_detect_session(session);
 }
 
 static void echo_function(switch_core_session_t *session, char *data)
@@ -789,6 +820,43 @@
 
 }
 
+static void displace_session_function(switch_core_session_t *session, char *data)
+{
+	switch_channel_t *channel;
+	char *path = NULL;
+	uint32_t limit = 0;
+    char *argv[6];
+	int x, argc;
+	char *lbuf = NULL;
+	char *flags = NULL;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	if (data && (lbuf = switch_core_session_strdup(session, data))
+		&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+		path = argv[0];
+		for(x = 0; x < argc; x++) {
+			if (strchr(argv[x], '+')) {
+				limit = atoi(argv[x]);
+			} else if (!switch_strlen_zero(argv[x])) {
+				flags = argv[x];
+			}
+		}
+		switch_ivr_displace_session(session, path, limit, flags);
+	}
+}
+
+
+static void stop_displace_session_function(switch_core_session_t *session, char *data)
+{
+	switch_channel_t *channel;
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	switch_ivr_stop_displace_session(session, data);
+}
+
 
 static void record_function(switch_core_session_t *session, char *data)
 {
@@ -995,6 +1063,26 @@
 	&bridge_application_interface
 };
 
+static switch_application_interface_t displace_application_interface = {
+	/*.interface_name */ "displace",
+	/*.application_function */ displace_session_function,
+	/* long_desc */ "Displace audio from a file to the channels input",
+	/* short_desc */ "Displace File",
+	/* syntax */ "<path> [+time_limit_ms] [mux]",
+	/* flags */ SAF_NONE,
+	&speak_application_interface
+};
+
+static switch_application_interface_t stop_displace_application_interface = {
+	/*.interface_name */ "displace",
+	/*.application_function */ stop_displace_session_function,
+	/* long_desc */ "Stop Displacing to a file",
+	/* short_desc */ "Stop Displace File",
+	/* syntax */ "<path>",
+	/* flags */ SAF_NONE,
+	&displace_application_interface
+};
+
 static switch_application_interface_t record_application_interface = {
 	/*.interface_name */ "record",
 	/*.application_function */ record_function,
@@ -1002,7 +1090,7 @@
 	/* short_desc */ "Record File",
 	/* syntax */ "<path> [+time_limit_ms]",
 	/* flags */ SAF_NONE,
-	&speak_application_interface
+	&stop_displace_application_interface
 };
 
 
@@ -1056,6 +1144,17 @@
 	/*.next */ &park_application_interface
 };
 
+
+static switch_application_interface_t tone_detect_application_interface = {
+	/*.interface_name */ "tone_detect",
+	/*.application_function */ tone_detect_session_function,
+	/* long_desc */ "Detect tones",
+	/* short_desc */ "Detect tones",
+	/* syntax */ "",
+	/* flags */ SAF_NONE,
+	/*.next */ &echo_application_interface
+};
+
 static switch_application_interface_t fax_detect_application_interface = {
 	/*.interface_name */ "fax_detect",
 	/*.application_function */ fax_detect_session_function,
@@ -1063,14 +1162,14 @@
 	/* short_desc */ "Detect faxes",
 	/* syntax */ "",
 	/* flags */ SAF_NONE,
-	/*.next */ &echo_application_interface
+	/*.next */ &tone_detect_application_interface
 };
 
-static switch_application_interface_t stop_fax_detect_application_interface = {
-	/*.interface_name */ "stop_fax_detect",
+static switch_application_interface_t stop_tone_detect_application_interface = {
+	/*.interface_name */ "stop_tone_detect",
 	/*.application_function */ stop_fax_detect_session_function,
-	/* long_desc */ "Stop detecting fax send tones",
-	/* short_desc */ "stop detecting faxes",
+	/* long_desc */ "Stop detecting tones",
+	/* short_desc */ "stop detecting tones",
 	/* syntax */ "",
 	/* flags */ SAF_NONE,
 	/* next */ &fax_detect_application_interface
@@ -1083,7 +1182,7 @@
 	/* short_desc */ "Detect dtmf",
 	/* syntax */ "",
 	/* flags */ SAF_NONE,
-	/* next */ &stop_fax_detect_application_interface
+	/* next */ &stop_tone_detect_application_interface
 };
 
 static switch_application_interface_t stop_dtmf_application_interface = {

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp	Sat Jun 16 17:05:07 2007
@@ -257,8 +257,13 @@
 	char *lbuf = NULL;
     int x;
  
-    if (switch_channel_get_private(channel, "_soundtouch_")) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
+    if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
+        if (!switch_strlen_zero(data) && !strcasecmp(data, "stop")) {
+            switch_channel_set_private(channel, "_soundtouch_", NULL);
+            switch_core_media_bug_remove(session, &bug);
+        } else {
+            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
+        }
         return;
     }
 

Modified: freeswitch/branches/greenlizard/src/mod/asr_tts/mod_lumenvox/Makefile
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/asr_tts/mod_lumenvox/Makefile	(original)
+++ freeswitch/branches/greenlizard/src/mod/asr_tts/mod_lumenvox/Makefile	Sat Jun 16 17:05:07 2007
@@ -3,7 +3,9 @@
 
 # and define these variables to impact your build
 
-LVENGINE_DIR=/opt/lumenvox/engine_7.0
+LVENGINE_DIR=/opt/lumenvox/engine_7.5
+LVINCLUDE=$(LVENGINE_DIR)/include
+LVLIB=$(LVENGINE_DIR)/lib
 LOCAL_CFLAGS= -fpermissive -Wno-deprecated -Wno-conversion -fpermissive -Wno-unused
 LOCAL_CFLAGS+= -Wno-comment -Wno-sign-compare -Wno-conversion -Wno-reorder -I$(LVINCLUDE)
 LOCAL_LDFLAGS= -L$(LVLIB) -llv_lvspeechport

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	Sat Jun 16 17:05:07 2007
@@ -913,6 +913,20 @@
 		uint8_t vad_out = switch_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0;
 		uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
 
+		if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_enable_vad_in")) && switch_true(val)) {
+			vad_in = 1;
+		}
+		if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_enable_vad_out")) && switch_true(val)) {
+			vad_out = 1;
+		}
+
+		if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_disable_vad_in")) && switch_true(val)) {
+			vad_in = 0;
+		}
+		if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_disable_vad_out")) && switch_true(val)) {
+			vad_out = 0;
+		}
+
 		tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
 		switch_set_flag_locked(tech_pvt, TFLAG_RTP);
 		switch_set_flag_locked(tech_pvt, TFLAG_IO);

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	Sat Jun 16 17:05:07 2007
@@ -111,7 +111,8 @@
 	uint32_t samples_per_frame;
 	int dtmf_on;
 	int dtmf_off;
-	int supress_dtmf_tone;
+	int suppress_dtmf_tone;
+	int ignore_dtmf_tone;
 	int configured_spans;
 	int configured_boost_spans;
 	char *dialplan;
@@ -524,8 +525,11 @@
 	tech_pvt->tone_session.rate = rate;
 	tech_pvt->tone_session.duration = globals.dtmf_on * (tech_pvt->tone_session.rate / 1000);
 	tech_pvt->tone_session.wait = globals.dtmf_off * (tech_pvt->tone_session.rate / 1000);
+
+	if (!globals.ignore_dtmf_tone) {	
+		teletone_dtmf_detect_init (&tech_pvt->dtmf_detect, rate);
+	}
 	
-	teletone_dtmf_detect_init (&tech_pvt->dtmf_detect, rate);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio init %s\n", switch_channel_get_name(channel));
 
 	switch_set_flag(tech_pvt, TFLAG_CODEC);
@@ -786,25 +790,26 @@
 
 	tech_pvt->read_frame.datalen = bytes;
 	tech_pvt->read_frame.samples = bytes / 2;
-
-	teletone_dtmf_detect (&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
-	teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
 	
-	if(digit_str[0]) {
-		switch_channel_queue_dtmf(channel, digit_str);
-		if (globals.debug) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
-		}
-		if (globals.supress_dtmf_tone) {
-			tech_pvt->skip_read_frames = 20;
+	if (!globals.ignore_dtmf_tone) {
+		teletone_dtmf_detect (&tech_pvt->dtmf_detect, tech_pvt->read_frame.data, tech_pvt->read_frame.samples);
+		teletone_dtmf_get(&tech_pvt->dtmf_detect, digit_str, sizeof(digit_str));
+	
+		if(digit_str[0]) {
+			switch_channel_queue_dtmf(channel, digit_str);
+			if (globals.debug) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
+			}
+			if (globals.suppress_dtmf_tone) {
+				tech_pvt->skip_read_frames = 20;
+			}
 		}
-	}
 
-	if (tech_pvt->skip_read_frames > 0) {
-		memset(tech_pvt->read_frame.data, 0, tech_pvt->read_frame.datalen);
-		tech_pvt->skip_read_frames--;
+		if (tech_pvt->skip_read_frames > 0) {
+			memset(tech_pvt->read_frame.data, 0, tech_pvt->read_frame.datalen);
+			tech_pvt->skip_read_frames--;
+		}
 	}
-
 #ifdef DOTRACE	
 	write(tech_pvt->fd2, tech_pvt->read_frame.data, (int) tech_pvt->read_frame.datalen);
 #endif
@@ -2220,8 +2225,10 @@
 				globals.dtmf_off = atoi(val);
 			} else if (!strcmp(var, "dialplan")) {
 				set_global_dialplan(val);
-			} else if (!strcmp(var, "supress-dtmf-tone")) {
-				globals.supress_dtmf_tone = switch_true(val);
+			} else if (!strcmp(var, "suppress-dtmf-tone")) {
+				globals.suppress_dtmf_tone = switch_true(val);
+			} else if (!strcmp(var, "ignore-dtmf-tone")) {
+				globals.ignore_dtmf_tone = switch_true(val);
 			}
 		}
 	}

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	Sat Jun 16 17:05:07 2007
@@ -3,8 +3,8 @@
 
 # and define these variables to impact your build
 
-LOCAL_CFLAGS=-I/usr/include/python2.4/
-LOCAL_LDFLAGS=-lpython2.4 -L/usr/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
 
@@ -13,8 +13,8 @@
 SWIGCFILE=../../../switch_swig.c
 SWIGIFILE=../../../switch_swig.i
 
-#local_depend:
-#	MAKE=$(MAKE) PY_CFLAGS=-fPIC $(BASE)/build/buildlib.sh $(BASE) install Python-2.4.3.tgz --prefix=$(PREFIX) --enable-threads
+local_depend:
+	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
@@ -26,7 +26,5 @@
 	$(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_python/freeswitch.py
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py	Sat Jun 16 17:05:07 2007
@@ -1,10 +1,16 @@
-# This file was created automatically by SWIG 1.3.29.
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 1.3.31
+#
 # Don't modify this file, modify the SWIG interface instead.
 # This file is compatible with both classic and new-style classes.
 
 import _freeswitch
 import new
 new_instancemethod = new.instancemethod
+try:
+    _swig_property = property
+except NameError:
+    pass # Python < 2.2 doesn't have 'property'.
 def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
     if (name == "thisown"): return self.this.own(value)
     if (name == "this"):
@@ -55,16 +61,16 @@
     __repr__ = _swig_repr
     __swig_setmethods__["function"] = _freeswitch.input_callback_state_function_set
     __swig_getmethods__["function"] = _freeswitch.input_callback_state_function_get
-    if _newclass:function = property(_freeswitch.input_callback_state_function_get, _freeswitch.input_callback_state_function_set)
+    if _newclass:function = _swig_property(_freeswitch.input_callback_state_function_get, _freeswitch.input_callback_state_function_set)
     __swig_setmethods__["threadState"] = _freeswitch.input_callback_state_threadState_set
     __swig_getmethods__["threadState"] = _freeswitch.input_callback_state_threadState_get
-    if _newclass:threadState = property(_freeswitch.input_callback_state_threadState_get, _freeswitch.input_callback_state_threadState_set)
+    if _newclass:threadState = _swig_property(_freeswitch.input_callback_state_threadState_get, _freeswitch.input_callback_state_threadState_set)
     __swig_setmethods__["extra"] = _freeswitch.input_callback_state_extra_set
     __swig_getmethods__["extra"] = _freeswitch.input_callback_state_extra_get
-    if _newclass:extra = property(_freeswitch.input_callback_state_extra_get, _freeswitch.input_callback_state_extra_set)
+    if _newclass:extra = _swig_property(_freeswitch.input_callback_state_extra_get, _freeswitch.input_callback_state_extra_set)
     __swig_setmethods__["funcargs"] = _freeswitch.input_callback_state_funcargs_set
     __swig_getmethods__["funcargs"] = _freeswitch.input_callback_state_funcargs_get
-    if _newclass:funcargs = property(_freeswitch.input_callback_state_funcargs_get, _freeswitch.input_callback_state_funcargs_set)
+    if _newclass:funcargs = _swig_property(_freeswitch.input_callback_state_funcargs_get, _freeswitch.input_callback_state_funcargs_set)
     def __init__(self, *args): 
         this = _freeswitch.new_input_callback_state(*args)
         try: self.this.append(this)
@@ -88,13 +94,13 @@
     __del__ = lambda self : None;
     __swig_setmethods__["session"] = _freeswitch.CoreSession_session_set
     __swig_getmethods__["session"] = _freeswitch.CoreSession_session_get
-    if _newclass:session = property(_freeswitch.CoreSession_session_get, _freeswitch.CoreSession_session_set)
+    if _newclass:session = _swig_property(_freeswitch.CoreSession_session_get, _freeswitch.CoreSession_session_set)
     __swig_setmethods__["channel"] = _freeswitch.CoreSession_channel_set
     __swig_getmethods__["channel"] = _freeswitch.CoreSession_channel_get
-    if _newclass:channel = property(_freeswitch.CoreSession_channel_get, _freeswitch.CoreSession_channel_set)
+    if _newclass:channel = _swig_property(_freeswitch.CoreSession_channel_get, _freeswitch.CoreSession_channel_set)
     __swig_setmethods__["cb_state"] = _freeswitch.CoreSession_cb_state_set
     __swig_getmethods__["cb_state"] = _freeswitch.CoreSession_cb_state_get
-    if _newclass:cb_state = property(_freeswitch.CoreSession_cb_state_get, _freeswitch.CoreSession_cb_state_set)
+    if _newclass:cb_state = _swig_property(_freeswitch.CoreSession_cb_state_get, _freeswitch.CoreSession_cb_state_set)
     def answer(*args): return _freeswitch.CoreSession_answer(*args)
     def preAnswer(*args): return _freeswitch.CoreSession_preAnswer(*args)
     def hangup(*args): return _freeswitch.CoreSession_hangup(*args)
@@ -118,10 +124,10 @@
 PythonDTMFCallback = _freeswitch.PythonDTMFCallback
 class PySession(CoreSession):
     __swig_setmethods__ = {}
-    for _s in [CoreSession]: __swig_setmethods__.update(_s.__swig_setmethods__)
+    for _s in [CoreSession]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
     __setattr__ = lambda self, name, value: _swig_setattr(self, PySession, name, value)
     __swig_getmethods__ = {}
-    for _s in [CoreSession]: __swig_getmethods__.update(_s.__swig_getmethods__)
+    for _s in [CoreSession]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
     __getattr__ = lambda self, name: _swig_getattr(self, PySession, name)
     __repr__ = _swig_repr
     def __init__(self, *args): 

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp	Sat Jun 16 17:05:07 2007
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.29
+ * Version 1.3.31
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -120,7 +120,7 @@
 #endif
 
 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
-#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
 # define _CRT_SECURE_NO_DEPRECATE
 #endif
 
@@ -137,7 +137,7 @@
 
 /* This should only be incremented when either the layout of swig_type_info changes,
    or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "2"
+#define SWIG_RUNTIME_VERSION "3"
 
 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
 #ifdef SWIG_TYPE_TABLE
@@ -714,8 +714,6 @@
 
 
 
-/* Python.h has to appear first */
-#include <Python.h>
 
 /* Add PyOS_snprintf for old Pythons */
 #if PY_VERSION_HEX < 0x02020000
@@ -796,6 +794,14 @@
 }
 #endif
 
+/* Py_ssize_t for old Pythons */
+/* This code is as recommended by: */
+/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+# define PY_SSIZE_T_MAX INT_MAX
+# define PY_SSIZE_T_MIN INT_MIN
+#endif
 
 /* -----------------------------------------------------------------------------
  * error manipulation
@@ -1189,7 +1195,7 @@
 SWIGRUNTIMEINLINE PyObject * 
 _SWIG_Py_None(void)
 {
-  PyObject *none = Py_BuildValue("");
+  PyObject *none = Py_BuildValue((char*)"");
   Py_DECREF(none);
   return none;
 }
@@ -2048,7 +2054,7 @@
     void *vptr = 0;
     
     /* here we get the method pointer for callbacks */
-    char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
+    const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
     const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
     if (desc) {
       desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
@@ -2169,7 +2175,7 @@
    return;
  }
 #endif
- dict = PyObject_GetAttrString(inst, "__dict__");
+ dict = PyObject_GetAttrString(inst, (char*)"__dict__");
  PyDict_SetItem(dict, SWIG_This(), swig_this);
  Py_DECREF(dict);
 } 
@@ -2310,7 +2316,7 @@
 
 /* The python cached type query */
 SWIGRUNTIME PyObject *
-SWIG_Python_TypeCache() {
+SWIG_Python_TypeCache(void) {
   static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
   return cache;
 }
@@ -2480,7 +2486,7 @@
 
 #if (PY_VERSION_HEX <= 0x02000000)
 # if !defined(SWIG_PYTHON_CLASSIC)
-#  error "This python version requires to use swig with the '-classic' option"
+#  error "This python version requires swig to be run with the '-classic' option"
 # endif
 #endif
 
@@ -2491,7 +2497,8 @@
 
 #define SWIG_name    "_freeswitch"
 
-#define SWIGVERSION 0x010329 
+#define SWIGVERSION 0x010331 
+#define SWIG_VERSION SWIGVERSION
 
 
 #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) 
@@ -2566,7 +2573,7 @@
 
 
 SWIGINTERN swig_type_info*
-SWIG_pchar_descriptor()
+SWIG_pchar_descriptor(void)
 {
   static int init = 0;
   static swig_type_info* info = 0;
@@ -2582,7 +2589,7 @@
 SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
 {
   if (PyString_Check(obj)) {
-    char *cstr; int len;
+    char *cstr; Py_ssize_t len;
     PyString_AsStringAndSize(obj, &cstr, &len);
     if (cptr)  {
       if (alloc) {
@@ -3104,12 +3111,12 @@
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "console_log" "', argument " "1"" of type '" "char *""'");
   }
-  arg1 = buf1;
+  arg1 = reinterpret_cast< char * >(buf1);
   res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "console_log" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   console_log(arg1,arg2);
   resultobj = SWIG_Py_Void();
   if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
@@ -3135,7 +3142,7 @@
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "console_clean_log" "', argument " "1"" of type '" "char *""'");
   }
-  arg1 = buf1;
+  arg1 = reinterpret_cast< char * >(buf1);
   console_clean_log(arg1);
   resultobj = SWIG_Py_Void();
   if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
@@ -3165,14 +3172,14 @@
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "api_execute" "', argument " "1"" of type '" "char *""'");
   }
-  arg1 = buf1;
+  arg1 = reinterpret_cast< char * >(buf1);
   res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "api_execute" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   result = (char *)api_execute(arg1,arg2);
-  resultobj = SWIG_FromCharPtr(result);
+  resultobj = SWIG_FromCharPtr((const char *)result);
   if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
   return resultobj;
@@ -3196,7 +3203,7 @@
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "api_reply_delete" "', argument " "1"" of type '" "char *""'");
   }
-  arg1 = buf1;
+  arg1 = reinterpret_cast< char * >(buf1);
   api_reply_delete(arg1);
   resultobj = SWIG_Py_Void();
   if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
@@ -3229,7 +3236,7 @@
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "process_callback_result" "', argument " "1"" of type '" "char *""'");
   }
-  arg1 = buf1;
+  arg1 = reinterpret_cast< char * >(buf1);
   res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_input_callback_state, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "process_callback_result" "', argument " "2"" of type '" "input_callback_state *""'"); 
@@ -3425,11 +3432,11 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_funcargs_set" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   if (arg1->funcargs) delete[] arg1->funcargs;
   if (arg2) {
-    size_t size = strlen(arg2) + 1;
-    arg1->funcargs = reinterpret_cast< char* >(memcpy((new char[size]), arg2, sizeof(char)*(size)));
+    size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1;
+    arg1->funcargs = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size)));
   } else {
     arg1->funcargs = 0;
   }
@@ -3457,7 +3464,7 @@
   }
   arg1 = reinterpret_cast< input_callback_state * >(argp1);
   result = (char *) ((arg1)->funcargs);
-  resultobj = SWIG_FromCharPtr(result);
+  resultobj = SWIG_FromCharPtr((const char *)result);
   return resultobj;
 fail:
   return NULL;
@@ -3520,7 +3527,7 @@
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_CoreSession" "', argument " "1"" of type '" "char *""'");
   }
-  arg1 = buf1;
+  arg1 = reinterpret_cast< char * >(buf1);
   result = (CoreSession *)new CoreSession(arg1);
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CoreSession, SWIG_POINTER_NEW |  0 );
   if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
@@ -3582,7 +3589,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'new_CoreSession'");
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_CoreSession'.\n  Possible C/C++ prototypes are:\n    CoreSession(char *)\n    CoreSession(switch_core_session_t *)\n");
   return NULL;
 }
 
@@ -3834,7 +3841,7 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_hangup" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   (arg1)->hangup(arg2);
   resultobj = SWIG_Py_Void();
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
@@ -3872,12 +3879,12 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_setVariable" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
   if (!SWIG_IsOK(res3)) {
     SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_setVariable" "', argument " "3"" of type '" "char *""'");
   }
-  arg3 = buf3;
+  arg3 = reinterpret_cast< char * >(buf3);
   (arg1)->setVariable(arg2,arg3);
   resultobj = SWIG_Py_Void();
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
@@ -3913,9 +3920,9 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getVariable" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   result = (char *)(arg1)->getVariable(arg2);
-  resultobj = SWIG_FromCharPtr(result);
+  resultobj = SWIG_FromCharPtr((const char *)result);
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
   return resultobj;
 fail:
@@ -3952,12 +3959,12 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_playFile" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
   if (!SWIG_IsOK(res3)) {
     SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_playFile" "', argument " "3"" of type '" "char *""'");
   }
-  arg3 = buf3;
+  arg3 = reinterpret_cast< char * >(buf3);
   result = (int)(arg1)->playFile(arg2,arg3);
   resultobj = SWIG_From_int(static_cast< int >(result));
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
@@ -4055,7 +4062,7 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_speak" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   result = (int)(arg1)->speak(arg2);
   resultobj = SWIG_From_int(static_cast< int >(result));
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
@@ -4093,12 +4100,12 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_set_tts_parms" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
   if (!SWIG_IsOK(res3)) {
     SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_set_tts_parms" "', argument " "3"" of type '" "char *""'");
   }
-  arg3 = buf3;
+  arg3 = reinterpret_cast< char * >(buf3);
   (arg1)->set_tts_parms(arg2,arg3);
   resultobj = SWIG_Py_Void();
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
@@ -4170,7 +4177,7 @@
   if (!SWIG_IsOK(res4)) {
     SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "char *""'");
   }
-  arg4 = buf4;
+  arg4 = reinterpret_cast< char * >(buf4);
   res5 = SWIG_AsCharPtrAndSize(obj4, &t5, &n5, &alloc5);
   if (!SWIG_IsOK(res5)) {
     SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *terminator""'");
@@ -4232,17 +4239,17 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_transfer" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
   if (!SWIG_IsOK(res3)) {
     SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_transfer" "', argument " "3"" of type '" "char *""'");
   }
-  arg3 = buf3;
+  arg3 = reinterpret_cast< char * >(buf3);
   res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4);
   if (!SWIG_IsOK(res4)) {
     SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_transfer" "', argument " "4"" of type '" "char *""'");
   }
-  arg4 = buf4;
+  arg4 = reinterpret_cast< char * >(buf4);
   result = (int)(arg1)->transfer(arg2,arg3,arg4);
   resultobj = SWIG_From_int(static_cast< int >(result));
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
@@ -4338,17 +4345,17 @@
   if (!SWIG_IsOK(res6)) {
     SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_playAndGetDigits" "', argument " "6"" of type '" "char *""'");
   }
-  arg6 = buf6;
+  arg6 = reinterpret_cast< char * >(buf6);
   res7 = SWIG_AsCharPtrAndSize(obj6, &buf7, NULL, &alloc7);
   if (!SWIG_IsOK(res7)) {
     SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "CoreSession_playAndGetDigits" "', argument " "7"" of type '" "char *""'");
   }
-  arg7 = buf7;
+  arg7 = reinterpret_cast< char * >(buf7);
   res8 = SWIG_AsCharPtrAndSize(obj7, &buf8, NULL, &alloc8);
   if (!SWIG_IsOK(res8)) {
     SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "CoreSession_playAndGetDigits" "', argument " "8"" of type '" "char *""'");
   }
-  arg8 = buf8;
+  arg8 = reinterpret_cast< char * >(buf8);
   res9 = SWIG_AsCharPtrAndSize(obj8, &t9, &n9, &alloc9);
   if (!SWIG_IsOK(res9)) {
     SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *dtmf_buf""'");
@@ -4362,7 +4369,7 @@
   if (!SWIG_IsOK(res10)) {
     SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'");
   }
-  arg10 = buf10;
+  arg10 = reinterpret_cast< char * >(buf10);
   result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
   resultobj = SWIG_From_int(static_cast< int >(result));
   arg9[128] = 0;
@@ -4408,7 +4415,7 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_streamfile" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   ecode3 = SWIG_AsVal_int(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
     SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_streamfile" "', argument " "3"" of type '" "int""'");
@@ -4473,12 +4480,12 @@
   if (!SWIG_IsOK(res2)) {
     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_execute" "', argument " "2"" of type '" "char *""'");
   }
-  arg2 = buf2;
+  arg2 = reinterpret_cast< char * >(buf2);
   res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
   if (!SWIG_IsOK(res3)) {
     SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_execute" "', argument " "3"" of type '" "char *""'");
   }
-  arg3 = buf3;
+  arg3 = reinterpret_cast< char * >(buf3);
   (arg1)->execute(arg2,arg3);
   resultobj = SWIG_Py_Void();
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
@@ -4616,7 +4623,7 @@
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_PySession" "', argument " "1"" of type '" "char *""'");
   }
-  arg1 = buf1;
+  arg1 = reinterpret_cast< char * >(buf1);
   result = (PySession *)new PySession(arg1);
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PySession, SWIG_POINTER_NEW |  0 );
   if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
@@ -4678,7 +4685,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'new_PySession'");
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_PySession'.\n  Possible C/C++ prototypes are:\n    PySession(char *)\n    PySession(switch_core_session_t *)\n");
   return NULL;
 }
 
@@ -4730,7 +4737,7 @@
   if (!SWIG_IsOK(res3)) {
     SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "PySession_setDTMFCallback" "', argument " "3"" of type '" "char *""'");
   }
-  arg3 = buf3;
+  arg3 = reinterpret_cast< char * >(buf3);
   (arg1)->setDTMFCallback(arg2,arg3);
   resultobj = SWIG_Py_Void();
   if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
@@ -4928,7 +4935,7 @@
  * structures together.
  *
  * The generated swig_type_info structures are assigned staticly to an initial 
- * array. We just loop though that array, and handle each type individually.
+ * array. We just loop through that array, and handle each type individually.
  * First we lookup if this type has been already loaded, and if so, use the
  * loaded structure instead of the generated one. Then we have to fill in the
  * cast linked list. The cast data is initially stored in something like a
@@ -4966,30 +4973,47 @@
 #define SWIGRUNTIME_DEBUG
 #endif
 
+
 SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
-  swig_module_info *module_head;
-  static int init_run = 0;
+  swig_module_info *module_head, *iter;
+  int found;
   
   clientdata = clientdata;
   
-  if (init_run) return;
-  init_run = 1;
-  
-  /* Initialize the swig_module */
-  swig_module.type_initial = swig_type_initial;
-  swig_module.cast_initial = swig_cast_initial;
+  /* check to see if the circular list has been setup, if not, set it up */
+  if (swig_module.next==0) {
+    /* Initialize the swig_module */
+    swig_module.type_initial = swig_type_initial;
+    swig_module.cast_initial = swig_cast_initial;
+    swig_module.next = &swig_module;
+  }
   
   /* Try and load any already created modules */
   module_head = SWIG_GetModule(clientdata);
-  if (module_head) {
+  if (!module_head) {
+    /* This is the first module loaded for this interpreter */
+    /* so set the swig module into the interpreter */
+    SWIG_SetModule(clientdata, &swig_module);
+    module_head = &swig_module;
+  } else {
+    /* the interpreter has loaded a SWIG module, but has it loaded this one? */
+    found=0;
+    iter=module_head;
+    do {
+      if (iter==&swig_module) {
+        found=1;
+        break;
+      }
+      iter=iter->next;
+    } while (iter!= module_head);
+    
+    /* if the is found in the list, then all is done and we may leave */
+    if (found) return;
+    /* otherwise we must add out module into the list */
     swig_module.next = module_head->next;
     module_head->next = &swig_module;
-  } else {
-    /* This is the first module loaded */
-    swig_module.next = &swig_module;
-    SWIG_SetModule(clientdata, &swig_module);
   }
   
   /* Now work on filling in swig_module.types */
@@ -5302,7 +5326,7 @@
   }
   
   SWIGINTERN PyObject *
-  SWIG_globals() {
+  SWIG_globals(void) {
     static PyObject *_SWIG_globals = 0; 
     if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();  
     return _SWIG_globals;
@@ -5347,11 +5371,11 @@
     swig_type_info **types_initial) {
     size_t i;
     for (i = 0; methods[i].ml_name; ++i) {
-      char *c = methods[i].ml_doc;
+      const char *c = methods[i].ml_doc;
       if (c && (c = strstr(c, "swig_ptr: "))) {
         int j;
         swig_const_info *ci = 0;
-        char *name = c + 10;
+        const char *name = c + 10;
         for (j = 0; const_table[j].type; ++j) {
           if (strncmp(const_table[j].name, name, 
               strlen(const_table[j].name)) == 0) {

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	Sat Jun 16 17:05:07 2007
@@ -37,11 +37,29 @@
 #ifdef HAVE_CURL
 #include <curl/curl.h>
 #endif
+static int foo = 0;
+
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown);
 SWITCH_MODULE_DEFINITION(mod_spidermonkey, mod_spidermonkey_load, mod_spidermonkey_shutdown, NULL);
 
+#define METHOD_SANITY_CHECK() do {												\
+if (!jss || !jss->session) {											\
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n"); \
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);									\
+	return JS_TRUE;														\
+ }																		\
+	} while(foo == 1)
+
+#define CHANNEL_SANITY_CHECK() do {				\
+		if (!switch_channel_ready(channel)) {							\
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n"); \
+			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);							\
+			return JS_TRUE;												\
+		}																\
+	} while (foo == 1)
+
 static void session_destroy(JSContext * cx, JSObject * obj);
 static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
 static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
@@ -62,7 +80,7 @@
 
 static JSClass global_class = {
 	"Global", JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
 };
 
@@ -277,7 +295,7 @@
 
 JSClass request_class = {
 	"Request", JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, request_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, request_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, request_destroy, NULL, NULL, NULL, NULL
 };
 
@@ -582,7 +600,7 @@
 
 JSClass event_class = {
 	"Event", JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, event_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, event_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, event_destroy, NULL, NULL, NULL,
 	event_construct
 };
@@ -818,11 +836,9 @@
 	uintN argc = 0;
 	jsval argv[4];
 	JSObject *Event = NULL;
+	jsval nval , *rval = &nval; 
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		return SWITCH_STATUS_FALSE;
-	}
+	METHOD_SANITY_CHECK();
 
 	jss->stack_depth++;
 
@@ -1012,11 +1028,7 @@
 	switch_size_t has;
 	switch_channel_t *channel;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -1067,20 +1079,12 @@
 	int32 limit = 0;
 	switch_input_args_t args = { 0 };
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	CHANNEL_SANITY_CHECK();
 
 
 	if (argc > 0) {
@@ -1150,21 +1154,12 @@
 	switch_input_args_t args = { 0 };
 
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
-
+	CHANNEL_SANITY_CHECK();
 
 	if (argc > 0) {
 		if ((function = JS_ValueToFunction(cx, argv[0]))) {
@@ -1217,21 +1212,12 @@
 	JSFunction *function;
 	switch_input_args_t args = { 0 };
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
-
+	CHANNEL_SANITY_CHECK();
 
 	if (argc > 0) {
 		phrase_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -1360,20 +1346,12 @@
 	switch_input_args_t args = { 0 };
 	char *prebuf;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	CHANNEL_SANITY_CHECK();
 
 
 	if (argc > 0) {
@@ -1433,11 +1411,7 @@
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -1503,21 +1477,12 @@
 	JSFunction *function;
 	switch_input_args_t args = { 0 };
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
-
+	CHANNEL_SANITY_CHECK();
 
 	if (argc > 0) {
 		tts_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -1571,21 +1536,12 @@
 	int32 digits = 0, timeout = 5000;
 	switch_channel_t *channel;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
-
+	CHANNEL_SANITY_CHECK();
 
 	if (argc > 0) {
 		char term;
@@ -1617,11 +1573,7 @@
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	if (argv[0]) {
 		JSBool tf;
@@ -1642,21 +1594,12 @@
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
-
+	CHANNEL_SANITY_CHECK();
 
 	switch_channel_answer(channel);
 	return JS_TRUE;
@@ -1671,10 +1614,7 @@
 	/*Always a pessimist... sheesh! */
 	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	if (switch_ivr_generate_xml_cdr(jss->session, &cdr) == SWITCH_STATUS_SUCCESS) {
 		char *xml_text;
@@ -1693,11 +1633,7 @@
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_channel_t *channel;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -1717,11 +1653,7 @@
 	unsigned int elapsed;
 	int32 timeout = 60;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -1760,11 +1692,7 @@
 	unsigned int elapsed;
 	int32 timeout = 60;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
@@ -1799,20 +1727,13 @@
 	switch_channel_t *channel;
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+
+	CHANNEL_SANITY_CHECK();
 
 
 	if (argc > 1) {
@@ -1822,11 +1743,7 @@
 		struct js_session *jss = JS_GetPrivate(cx, obj);
 		jsrefcount saveDepth;
 
-		if (!jss || !jss->session) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-			*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-			return JS_TRUE;
-		}
+		METHOD_SANITY_CHECK();
 
 		if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
 			if (application_interface->application_function) {
@@ -1847,11 +1764,7 @@
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_event_t *event;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	if (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
 		JSObject *Event;
@@ -1881,11 +1794,7 @@
 	JSObject *Event;
 	struct event_obj *eo;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	if (argc > 0) {
 		if (JS_ValueToObject(cx, argv[0], &Event)) {
@@ -1913,20 +1822,12 @@
 	char *cause_name = NULL;
 	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
-	if (!jss || !jss->session) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	METHOD_SANITY_CHECK();
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
-	if (!switch_channel_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
-		return JS_TRUE;
-	}
+	CHANNEL_SANITY_CHECK();
 
 	if (argc > 1) {
 		cause_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -2135,6 +2036,7 @@
 	{0}
 };
 
+
 static JSBool session_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
@@ -2228,7 +2130,7 @@
 
 JSClass session_class = {
 	"Session", JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, session_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, session_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, session_destroy, NULL, NULL, NULL,
 	session_construct
 };
@@ -2606,7 +2508,7 @@
 
 JSClass fileio_class = {
 	"FileIO", JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, fileio_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, fileio_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, fileio_destroy, NULL, NULL, NULL,
 	fileio_construct
 };

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	Sat Jun 16 17:05:07 2007
@@ -133,6 +133,11 @@
 	switch_channel_state_t hook_state;
 };
 
+JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject *obj, jsval id, jsval *vp)
+{
+	return JS_FALSE;
+}
+
 
 
 SWITCH_END_EXTERN_C

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c	Sat Jun 16 17:05:07 2007
@@ -268,7 +268,7 @@
 
 JSClass db_class = {
 	modname, JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, db_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, db_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, db_destroy, NULL, NULL, NULL,
 	db_construct
 };

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c	Sat Jun 16 17:05:07 2007
@@ -216,7 +216,7 @@
 
 JSClass etpan_class = {
 	modname, JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, etpan_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, etpan_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, etpan_destroy, NULL, NULL, NULL,
 	etpan_construct
 };

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c	Sat Jun 16 17:05:07 2007
@@ -438,7 +438,7 @@
 
 JSClass odbc_class = {
 	modname, JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, odbc_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, odbc_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, odbc_destroy, NULL, NULL, NULL,
 	odbc_construct
 };

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c	Sat Jun 16 17:05:07 2007
@@ -74,7 +74,7 @@
 
 JSClass skel_class = {
 	modname, JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, skel_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, skel_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, skel_destroy, NULL, NULL, NULL,
 	skel_construct
 };

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c	Sat Jun 16 17:05:07 2007
@@ -331,7 +331,7 @@
 
 JSClass teletone_class = {
 	modname, JSCLASS_HAS_PRIVATE,
-	JS_PropertyStub, JS_PropertyStub, teletone_getProperty, JS_PropertyStub,
+	JS_PropertyStub, JS_PropertyStub, teletone_getProperty, DEFAULT_SET_PROPERTY,
 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, teletone_destroy, NULL, NULL, NULL,
 	teletone_construct
 };

Modified: freeswitch/branches/greenlizard/src/switch_core_codec.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_codec.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_codec.c	Sat Jun 16 17:05:07 2007
@@ -50,6 +50,8 @@
 	session->read_codec = codec;
 	session->raw_read_frame.codec = session->read_codec;
 	session->raw_write_frame.codec = session->read_codec;
+	session->enc_read_frame.codec = session->read_codec;
+	session->enc_write_frame.codec = session->read_codec;
 
 	return SWITCH_STATUS_SUCCESS;
 }

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	Sat Jun 16 17:05:07 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 || (bp->stop_time && bp->stop_time >= time(NULL))) {
+						if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time <= time(NULL))) {
 							ok = SWITCH_FALSE;
 						}
 					}
@@ -241,7 +241,7 @@
 					do_bugs = 0;
 					if (bp->callback) {
 						bp->read_replace_frame_in = read_frame;
-						bp->read_replace_frame_out = NULL;
+						bp->read_replace_frame_out = read_frame;
 						if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_REPLACE)) == SWITCH_TRUE) {
 							read_frame = bp->read_replace_frame_out;
 						}
@@ -509,14 +509,14 @@
 					do_bugs = 0;
 					if (bp->callback) {
 						bp->write_replace_frame_in = write_frame;
-						bp->write_replace_frame_out = NULL;
+						bp->write_replace_frame_out = write_frame;
 						if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE_REPLACE)) == SWITCH_TRUE) {
 							write_frame = bp->write_replace_frame_out;
 						}
 					}
 				}
 
-				if (bp->stop_time && bp->stop_time >= time(NULL)) {
+				if (bp->stop_time && bp->stop_time <= time(NULL)) {
 					ok = SWITCH_FALSE;
 				}
 

Modified: freeswitch/branches/greenlizard/src/switch_cpp.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_cpp.cpp	(original)
+++ freeswitch/branches/greenlizard/src/switch_cpp.cpp	Sat Jun 16 17:05:07 2007
@@ -208,12 +208,11 @@
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
 
+
 int CoreSession::streamfile(char *file, int starting_sample_count) {
 
     switch_status_t status;
     switch_file_handle_t fh = { 0 };
-    unsigned int samps;
-    unsigned int pos = 0;
 	char *prebuf;
 
     sanity_check(-1);

Modified: freeswitch/branches/greenlizard/src/switch_event.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_event.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_event.c	Sat Jun 16 17:05:07 2007
@@ -133,7 +133,7 @@
 	"CODEC",
 	"BACKGROUND_JOB",
 	"DETECTED_SPEECH",
-	"DETECTED_FAX",
+	"DETECTED_TONE",
 	"PRIVATE_COMMAND",
 	"HEARTBEAT",
 	"TRAP",

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	Sat Jun 16 17:05:07 2007
@@ -96,6 +96,151 @@
 }
 
 
+typedef struct {
+	switch_file_handle_t fh;
+	int mux;
+} displace_helper_t;
+
+static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+{
+	displace_helper_t *dh = (displace_helper_t *) user_data;
+	uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
+	switch_frame_t frame = { 0 };
+
+	frame.data = data;
+	frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+
+	switch (type) {
+	case SWITCH_ABC_TYPE_INIT:
+		break;
+	case SWITCH_ABC_TYPE_CLOSE:
+		if (dh) {
+			switch_core_file_close(&dh->fh);
+		}
+		break;
+	case SWITCH_ABC_TYPE_READ_REPLACE:
+		{
+			switch_frame_t *frame = switch_core_media_bug_get_read_replace_frame(bug);
+			if (dh && !dh->mux) {
+				memset(frame->data, 255, frame->datalen);
+			}
+			switch_core_media_bug_set_read_replace_frame(bug, frame);
+		}
+		break;
+	case SWITCH_ABC_TYPE_WRITE_REPLACE:
+		if (dh) {
+			switch_frame_t *frame = NULL;
+			switch_size_t len;
+
+			frame = switch_core_media_bug_get_write_replace_frame(bug);
+			len = frame->samples;
+
+			if (dh->mux) {
+				int16_t buf[1024];
+				int16_t *fp = frame->data;
+				uint32_t x;
+				
+				switch_core_file_read(&dh->fh, buf, &len);
+				
+				for(x = 0; x < (uint32_t) len; x++) {
+					int32_t mixed = fp[x] + buf[x];
+					switch_normalize_to_16bit(mixed);
+					fp[x] = (int16_t) mixed;
+				}
+			} else {
+				switch_core_file_read(&dh->fh, frame->data, &len);
+				frame->samples = (uint32_t) len;
+				frame->datalen = frame->samples * 2;
+			}
+			switch_core_media_bug_set_write_replace_frame(bug, frame);
+		}
+		break;
+	case SWITCH_ABC_TYPE_WRITE:
+	default:
+		break;
+	}
+
+	return SWITCH_TRUE;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, char *file)
+{
+	switch_media_bug_t *bug;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+
+	assert(channel != NULL);
+	if ((bug = switch_channel_get_private(channel, file))) {
+		switch_channel_set_private(channel, file, NULL);
+		switch_core_media_bug_remove(session, &bug);
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_FALSE;
+
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags)
+{
+	switch_channel_t *channel;
+	switch_codec_t *read_codec;
+	switch_media_bug_t *bug;
+	switch_status_t status;
+	time_t to = 0;
+	displace_helper_t *dh;
+
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	if ((bug = switch_channel_get_private(channel, file))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Only 1 of the same file per channel please!\n");
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (!(dh = switch_core_session_alloc(session, sizeof(*dh)))) {
+		return SWITCH_STATUS_MEMERR;
+	}
+
+
+
+	read_codec = switch_core_session_get_read_codec(session);
+	assert(read_codec != NULL);
+
+	dh->fh.channels = read_codec->implementation->number_of_channels;
+	dh->fh.samplerate = read_codec->implementation->samples_per_second;
+
+
+	if (switch_core_file_open(&dh->fh,
+							  file,
+							  read_codec->implementation->number_of_channels,
+							  read_codec->implementation->samples_per_second,
+							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
+							  switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		switch_core_session_reset(session);
+		return SWITCH_STATUS_GENERR;
+	}
+
+	switch_channel_answer(channel);
+
+	if (limit) {
+		to = time(NULL) + limit;
+	}
+
+	if (flags && strchr(flags, 'm')) {
+		dh->mux++;
+	}
+
+	if ((status = switch_core_media_bug_add(session, displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
+		switch_core_file_close(&dh->fh);
+		return status;
+	}
+
+	switch_channel_set_private(channel, file, bug);
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
 
 static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
 {
@@ -158,14 +303,20 @@
 	switch_status_t status;
 	time_t to = 0;
 
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	if ((bug = switch_channel_get_private(channel, file))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Only 1 of the same file per channel please!\n");
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (!fh) {
 		if (!(fh = switch_core_session_alloc(session, sizeof(*fh)))) {
 			return SWITCH_STATUS_MEMERR;
 		}
 	}
 
-	channel = switch_core_session_get_channel(session);
-	assert(channel != NULL);
 
 	read_codec = switch_core_session_get_read_codec(session);
 	assert(read_codec != NULL);
@@ -326,117 +477,212 @@
 }
 
 
+#define MAX_TONES 16
 typedef struct {
-  switch_core_session_t *session;
-  teletone_multi_tone_t mt;
-} switch_fax_detect_t;
-
-static switch_bool_t fax_detect_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
-{
-  switch_fax_detect_t *pvt = (switch_fax_detect_t *) user_data;
-  uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
-  switch_frame_t frame = { 0 };
-  //  switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
-
-  //  assert(channel != NULL);
-  frame.data = data;
-  frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
-
-  switch (type) {
-  case SWITCH_ABC_TYPE_INIT:
-    break;
-  case SWITCH_ABC_TYPE_CLOSE:
-    break;
-  case SWITCH_ABC_TYPE_READ:
-    if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
-      if(teletone_multi_tone_detect(&pvt->mt, frame.data, frame.samples)) {
-	switch_event_t *event;
+	teletone_multi_tone_t mt;
+	char *app;
+	char *data;
+	char *key;
+	teletone_tone_map_t map;
+	int up;
+} switch_tone_detect_t;
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FAX CNG DETECTED\n");
 
-	if (switch_event_create(&event, SWITCH_EVENT_DETECTED_FAX) == SWITCH_STATUS_SUCCESS) {
-	  switch_event_t *dup;
+typedef struct {
+	switch_tone_detect_t list[MAX_TONES+1];
+	int index;
+	switch_media_bug_t *bug;
+	switch_core_session_t *session;
+} switch_tone_container_t;
 
-	  switch_event_add_header(event, SWITCH_STACK_BOTTOM, "fax", "detected");
-	    
-	  if (switch_event_dup(&dup, event) == SWITCH_STATUS_SUCCESS) {
-	    switch_event_fire(&dup);
-	  }
-	    
+static switch_bool_t tone_detect_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+{
+	switch_tone_container_t *cont = (switch_tone_container_t *) user_data;
+	switch_frame_t *frame = NULL;
+	int i = 0;
 
-	  if (switch_core_session_queue_event(pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
-	    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event queue failed!\n");
-	    switch_event_add_header(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
-	    switch_event_fire(&event);
-	  }
+	switch (type) {
+	case SWITCH_ABC_TYPE_INIT:
+		break;
+	case SWITCH_ABC_TYPE_CLOSE:
+		break;
+	case SWITCH_ABC_TYPE_READ_REPLACE:
+		frame = switch_core_media_bug_get_read_replace_frame(bug);
+	case SWITCH_ABC_TYPE_WRITE_REPLACE:
+		{
+
+			if (!frame) {
+				frame = switch_core_media_bug_get_write_replace_frame(bug);
+			}
+			
+			for (i = 0 ; i < cont->index; cont++) {
+				if (cont->list[i].up && teletone_multi_tone_detect(&cont->list[i].mt, frame->data, frame->samples)) {
+					switch_event_t *event;
+					
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "TONE %s DETECTED\n", cont->list[i].key);
+					cont->list[i].up = 0;
+
+					if (cont->list[i].app) {
+						if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+							switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+							switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", cont->list[i].app);
+							switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cont->list[i].data);
+							switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+							switch_core_session_queue_private_event(cont->session, &event);
+						}
+					}
+
+					if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) {
+						switch_event_t *dup;
+						switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Detected-Tone", "%s", cont->list[i].key);
+						
+						if (switch_event_dup(&dup, event) == SWITCH_STATUS_SUCCESS) {
+							switch_event_fire(&dup);
+						}
+	    
+						if (switch_core_session_queue_event(cont->session, &event) != SWITCH_STATUS_SUCCESS) {
+							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event queue failed!\n");
+							switch_event_add_header(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
+							switch_event_fire(&event);
+						}
+					}
+				}
+			}
+		}
+		break;
+	case SWITCH_ABC_TYPE_WRITE:
+	default:
+		break;
 	}
-      }
-    }
-    break;
-  case SWITCH_ABC_TYPE_WRITE:
-  default:
-    break;
-  }
-  return SWITCH_TRUE;
+	return SWITCH_TRUE;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_stop_fax_detect_session(switch_core_session_t *session)
+SWITCH_DECLARE(switch_status_t) switch_ivr_stop_tone_detect_session(switch_core_session_t *session)
 {
-  switch_media_bug_t *bug;
-  switch_channel_t *channel = switch_core_session_get_channel(session);
-
-  assert(channel != NULL);
-  if ((bug = switch_channel_get_private(channel, "fax"))) {
-    switch_channel_set_private(channel, "fax", NULL);
-    switch_core_media_bug_remove(session, &bug);
-    return SWITCH_STATUS_SUCCESS;
-  }
-
-  return SWITCH_STATUS_FALSE;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	switch_tone_container_t *cont;
+	
+	assert(channel != NULL);
+	if ((cont = switch_channel_get_private(channel, "_tone_detect_"))) {
+		switch_channel_set_private(channel, "_tone_detect_", NULL);
+		switch_core_media_bug_remove(session, &cont->bug);
+		return SWITCH_STATUS_SUCCESS;
+	}
 
+	return SWITCH_STATUS_FALSE;
+	
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_fax_detect_session(switch_core_session_t *session)
+SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session, 
+															   const char *key, const char *tone_spec,
+															   const char *flags, time_t timeout,
+															   const char *app, const char *data)
 {
   switch_channel_t *channel;
   switch_codec_t *read_codec;
-  switch_media_bug_t *bug;
   switch_status_t status;
-  switch_fax_detect_t *pvt;
-  teletone_tone_map_t *map;
-  int i;
+  switch_tone_container_t *cont = NULL;
+  char *p, *next;
+  int i = 0, ok = 0;
+
+  switch_media_bug_flag_t bflags = 0;
 
   channel = switch_core_session_get_channel(session);
   assert(channel != NULL);
 
-
   read_codec = switch_core_session_get_read_codec(session);
   assert(read_codec != NULL);
+  
+  if (switch_strlen_zero(key)) {
+	  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Key Specified!\n");
+	  return SWITCH_STATUS_FALSE;
+  }
+  
+  if ((cont = switch_channel_get_private(channel, "_tone_detect_"))) {
+	  if (cont->index >= MAX_TONES) {
+		  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max Tones Reached!\n");
+		  return SWITCH_STATUS_FALSE;
+	  }
 
-  if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) {
-    return SWITCH_STATUS_MEMERR;
+	  for(i = 0; i < cont->index; i++) {
+		  if (!strcasecmp(key, cont->list[cont->index].key )) {
+			  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Renabling %s\n", key);
+			  cont->list[cont->index].up = 1;
+			  teletone_multi_tone_init(&cont->list[i].mt, &cont->list[i].map);
+			  return SWITCH_STATUS_SUCCESS;
+		  }
+	  }
   }
 
-  if (!(map = switch_core_session_alloc(session, sizeof(*map)))) {
-    return SWITCH_STATUS_MEMERR;
+  if (switch_strlen_zero(tone_spec)) {
+	  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Spec Specified!\n");
+	  return SWITCH_STATUS_FALSE;
   }
 
-  for(i=0;i<TELETONE_MAX_TONES;i++) {
-    map->freqs[i] = 1100.0;
+  if (!cont && !(cont = switch_core_session_alloc(session, sizeof(*cont)))) {
+	  return SWITCH_STATUS_MEMERR;
   }
-  pvt->mt.sample_rate = read_codec->implementation->samples_per_second;
-  pvt->session = session;
 
-  teletone_multi_tone_init(&pvt->mt, map);
+  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Adding tone spec %s index %d\n", tone_spec, cont->index);
 
-  switch_channel_answer(channel);
+  i = 0;
+  p = (char *) tone_spec;
+
+  do {
+	  teletone_process_t this;
+	  next = strchr(p, ',');
+	  while(*p == ' ') p++;
+	  if ((this = (teletone_process_t) atof(p))) {
+		  ok++;
+		  cont->list[cont->index].map.freqs[i++] = this;
+	  }
+	  if (next) {
+		  p = next + 1;
+	  }
+  } while (next);
+  cont->list[cont->index].map.freqs[i++] = 0;
+
+  if (!ok) {
+	  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid tone spec!\n");
+	  return SWITCH_STATUS_FALSE;
 
-  if ((status = switch_core_media_bug_add(session, fax_detect_callback, pvt, 0, SMBF_READ_STREAM, &bug)) != SWITCH_STATUS_SUCCESS) {
-    return status;
   }
 
-  switch_channel_set_private(channel, "fax", bug);
+  cont->list[cont->index].key = switch_core_session_strdup(session, key);
+
+  if (app) {
+	  cont->list[cont->index].app = switch_core_session_strdup(session, app);
+  }
+  
+  if (data) {
+	  cont->list[cont->index].data = switch_core_session_strdup(session, data);
+  }
+
+  cont->list[cont->index].up = 1;
+  cont->list[cont->index].mt.sample_rate = read_codec->implementation->samples_per_second;
+  teletone_multi_tone_init(&cont->list[cont->index].mt, &cont->list[cont->index].map);
+  cont->session = session;
+  
+  switch_channel_answer(channel);
+  
+  if (switch_strlen_zero(flags)) {
+	  bflags = SMBF_READ_REPLACE;
+  } else {
+	  if (strchr(flags, 'r')) {
+		  bflags |= SMBF_READ_REPLACE;
+	  } else if (strchr(flags, 'w')) {
+		  bflags |= SMBF_WRITE_REPLACE;
+	  }
+  }
+
+
+  if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &cont->bug)) != SWITCH_STATUS_SUCCESS) {
+	  return status;
+  }
 
+  switch_channel_set_private(channel, "_tone_detect_", cont);
+  cont->index++;
+  
   return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/branches/greenlizard/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_rtp.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_rtp.c	Sat Jun 16 17:05:07 2007
@@ -1435,6 +1435,10 @@
 			rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
 		}
 		switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void *) send_msg, &bytes);
+	} else if (!fwd) {
+		/* nevermind save this seq inc for next time */
+		rtp_session->seq--;
+		rtp_session->send_msg.header.seq = htons(rtp_session->seq);
 	}
 
 	if (rtp_session->ice_user) {



More information about the Freeswitch-svn mailing list