Revision
14981
Author
brian
Date
2009-09-25 14:07:20 -0500 (Fri, 25 Sep 2009)

Log Message

 MODAPP-325 part 1 

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_cpp.h (14980 => 14981)


--- freeswitch/trunk/src/include/switch_cpp.h	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/include/switch_cpp.h	2009-09-25 19:07:20 UTC (rev 14981)
@@ -286,7 +286,8 @@
 	 * For timeout milliseconds, call the dtmf function set previously
 	 * by setDTMFCallback whenever a dtmf or event is received
 	 */
-		 SWITCH_DECLARE(int) collectDigits(int timeout);
+		 SWITCH_DECLARE(int) collectDigits(int abs_timeout);
+		 SWITCH_DECLARE(int) collectDigits(int digit_timeout, int abs_timeout);
 
 	/** 
 	 * Collect up to maxdigits digits worth of digits

Modified: freeswitch/trunk/src/include/switch_ivr.h (14980 => 14981)


--- freeswitch/trunk/src/include/switch_ivr.h	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/include/switch_ivr.h	2009-09-25 19:07:20 UTC (rev 14981)
@@ -122,7 +122,7 @@
   \param timeout a timeout in milliseconds
   \return SWITCH_STATUS_SUCCESS to keep the collection moving.
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t timeout);
+SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t digit_timeout, uint32_t abs_timeout);
 
 /*!
   \brief Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up.

Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (14980 => 14981)


--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	2009-09-25 19:07:20 UTC (rev 14981)
@@ -1011,7 +1011,7 @@
 					goto abort;
 				}
 			} else {
-				switch_ivr_collect_digits_callback(session, &args, 0);
+				switch_ivr_collect_digits_callback(session, &args, 0, 0);
 			}
 
 			if (caller_exit_key && *buf == *caller_exit_key) {

Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx (14980 => 14981)


--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx	2009-09-25 19:07:20 UTC (rev 14981)
@@ -22136,17 +22136,19 @@
 }
 
 
-SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_collect_digits_callback(void * jarg1, void * jarg2, unsigned long jarg3) {
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_collect_digits_callback(void * jarg1, void * jarg2, unsigned long jarg3, unsigned long jarg4) {
   int jresult ;
   switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
   switch_input_args_t *arg2 = (switch_input_args_t *) 0 ;
   uint32_t arg3 ;
+  uint32_t arg4 ;
   switch_status_t result;
   
   arg1 = (switch_core_session_t *)jarg1; 
   arg2 = (switch_input_args_t *)jarg2; 
   arg3 = (uint32_t)jarg3; 
-  result = (switch_status_t)switch_ivr_collect_digits_callback(arg1,arg2,arg3);
+  arg4 = (uint32_t)jarg4; 
+  result = (switch_status_t)switch_ivr_collect_digits_callback(arg1,arg2,arg3,arg4);
   jresult = result; 
   return jresult;
 }
@@ -28912,7 +28914,7 @@
 }
 
 
-SWIGEXPORT int SWIGSTDCALL CSharp_CoreSession_CollectDigits(void * jarg1, int jarg2) {
+SWIGEXPORT int SWIGSTDCALL CSharp_CoreSession_CollectDigits__SWIG_0(void * jarg1, int jarg2) {
   int jresult ;
   CoreSession *arg1 = (CoreSession *) 0 ;
   int arg2 ;
@@ -28926,6 +28928,22 @@
 }
 
 
+SWIGEXPORT int SWIGSTDCALL CSharp_CoreSession_CollectDigits__SWIG_1(void * jarg1, int jarg2, int jarg3) {
+  int jresult ;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int arg2 ;
+  int arg3 ;
+  int result;
+  
+  arg1 = (CoreSession *)jarg1; 
+  arg2 = (int)jarg2; 
+  arg3 = (int)jarg3; 
+  result = (int)(arg1)->collectDigits(arg2,arg3);
+  jresult = result; 
+  return jresult;
+}
+
+
 SWIGEXPORT char * SWIGSTDCALL CSharp_CoreSession_GetDigits__SWIG_0(void * jarg1, int jarg2, char * jarg3, int jarg4) {
   char * jresult ;
   CoreSession *arg1 = (CoreSession *) 0 ;

Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs (14980 => 14981)


--- freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs	2009-09-25 19:07:20 UTC (rev 14981)
@@ -282,11 +282,16 @@
     freeswitchPINVOKE.CoreSession_SetTtsParameters(swigCPtr, tts_name, voice_name);
   }
 
-  public int CollectDigits(int timeout) {
-    int ret = freeswitchPINVOKE.CoreSession_CollectDigits(swigCPtr, timeout);
+  public int CollectDigits(int abs_timeout) {
+    int ret = freeswitchPINVOKE.CoreSession_CollectDigits__SWIG_0(swigCPtr, abs_timeout);
     return ret;
   }
 
+  public int CollectDigits(int digit_timeout, int abs_timeout) {
+    int ret = freeswitchPINVOKE.CoreSession_CollectDigits__SWIG_1(swigCPtr, digit_timeout, abs_timeout);
+    return ret;
+  }
+
   public string GetDigits(int maxdigits, string terminators, int timeout) {
     string ret = freeswitchPINVOKE.CoreSession_GetDigits__SWIG_0(swigCPtr, maxdigits, terminators, timeout);
     return ret;
@@ -3178,8 +3183,8 @@
     return ret;
   }
 
-  public static switch_status_t switch_ivr_collect_digits_callback(SWIGTYPE_p_switch_core_session session, switch_input_args_t args, uint timeout) {
-    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_collect_digits_callback(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_input_args_t.getCPtr(args), timeout);
+  public static switch_status_t switch_ivr_collect_digits_callback(SWIGTYPE_p_switch_core_session session, switch_input_args_t args, uint digit_timeout, uint abs_timeout) {
+    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_collect_digits_callback(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_input_args_t.getCPtr(args), digit_timeout, abs_timeout);
     return ret;
   }
 
@@ -9901,7 +9906,7 @@
   public static extern int switch_ivr_park(HandleRef jarg1, HandleRef jarg2);
 
   [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_collect_digits_callback")]
-  public static extern int switch_ivr_collect_digits_callback(HandleRef jarg1, HandleRef jarg2, uint jarg3);
+  public static extern int switch_ivr_collect_digits_callback(HandleRef jarg1, HandleRef jarg2, uint jarg3, uint jarg4);
 
   [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_collect_digits_count")]
   public static extern int switch_ivr_collect_digits_count(HandleRef jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4, string jarg5, string jarg6, uint jarg7, uint jarg8, uint jarg9);
@@ -11430,9 +11435,12 @@
   [DllImport("mod_managed", EntryPoint="CSharp_CoreSession_SetTtsParameters")]
   public static extern void CoreSession_SetTtsParameters(HandleRef jarg1, string jarg2, string jarg3);
 
-  [DllImport("mod_managed", EntryPoint="CSharp_CoreSession_CollectDigits")]
-  public static extern int CoreSession_CollectDigits(HandleRef jarg1, int jarg2);
+  [DllImport("mod_managed", EntryPoint="CSharp_CoreSession_CollectDigits__SWIG_0")]
+  public static extern int CoreSession_CollectDigits__SWIG_0(HandleRef jarg1, int jarg2);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_CoreSession_CollectDigits__SWIG_1")]
+  public static extern int CoreSession_CollectDigits__SWIG_1(HandleRef jarg1, int jarg2, int jarg3);
+
   [DllImport("mod_managed", EntryPoint="CSharp_CoreSession_GetDigits__SWIG_0")]
   public static extern string CoreSession_GetDigits__SWIG_0(HandleRef jarg1, int jarg2, string jarg3, int jarg4);
 

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (14980 => 14981)


--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	2009-09-25 19:07:20 UTC (rev 14981)
@@ -1463,7 +1463,9 @@
 	switch_channel_t *channel;
 	void *bp = NULL;
 	int len = 0;
-	int32 to = 0;
+	int32 abs_timeout = 0;
+	int32 digit_timeout = 0;
+
 	switch_input_callback_function_t dtmf_func = NULL;
 	struct input_callback_state cb_state = { 0 };
 	JSFunction *function;
@@ -1494,8 +1496,11 @@
 		}
 	}
 
-	if (argc > 2) {
-		JS_ValueToInt32(jss->cx, argv[2], &to);
+	if (argc == 3) {
+		JS_ValueToInt32(jss->cx, argv[2], &abs_timeout);
+	} else if (argc > 3) {
+		JS_ValueToInt32(jss->cx, argv[2], &digit_timeout);
+		JS_ValueToInt32(jss->cx, argv[3], &abs_timeout);
 	}
 
 	cb_state.saveDepth = JS_SuspendRequest(cx);
@@ -1503,7 +1508,7 @@
 	args.buf = bp;
 	args.buflen = len;
 
-	switch_ivr_collect_digits_callback(jss->session, &args, to);
+	switch_ivr_collect_digits_callback(jss->session, &args, digit_timeout, abs_timeout);
 	JS_ResumeRequest(cx, cb_state.saveDepth);
 	check_hangup_hook(jss, &ret);
 	*rval = cb_state.ret;

Modified: freeswitch/trunk/src/switch_cpp.cpp (14980 => 14981)


--- freeswitch/trunk/src/switch_cpp.cpp	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/switch_cpp.cpp	2009-09-25 19:07:20 UTC (rev 14981)
@@ -684,11 +684,15 @@
 
 
 
-SWITCH_DECLARE(int) CoreSession::collectDigits(int timeout) {
+SWITCH_DECLARE(int) CoreSession::collectDigits(int abs_timeout) {
+	return collectDigits(0, abs_timeout);
+}
+
+SWITCH_DECLARE(int) CoreSession::collectDigits(int digit_timeout, int abs_timeout) {
 	this_check(-1);
 	sanity_check(-1);
     begin_allow_threads();
-	switch_ivr_collect_digits_callback(session, ap, timeout);
+	switch_ivr_collect_digits_callback(session, ap, digit_timeout, abs_timeout);
     end_allow_threads();
     return SWITCH_STATUS_SUCCESS;
 } 

Modified: freeswitch/trunk/src/switch_ivr.c (14980 => 14981)


--- freeswitch/trunk/src/switch_ivr.c	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/switch_ivr.c	2009-09-25 19:07:20 UTC (rev 14981)
@@ -815,21 +815,23 @@
 	return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t timeout)
+SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t digit_timeout, uint32_t abs_timeout)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-	switch_time_t started = 0;
-	uint32_t elapsed;
+	switch_time_t abs_started = 0, digit_started = 0;
+	uint32_t abs_elapsed = 0, digit_elapsed = 0;
 
 	if (!args || !args->input_callback) {
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (timeout) {
-		started = switch_micro_time_now();
+	if (abs_timeout) {
+		abs_started = switch_micro_time_now();
 	}
-
+	if (digit_timeout) {
+		digit_started = switch_micro_time_now();
+	}
 	while (switch_channel_ready(channel)) {
 		switch_frame_t *read_frame = NULL;
 		switch_event_t *event;
@@ -841,12 +843,20 @@
 			break;
 		}
 
-		if (timeout) {
-			elapsed = (uint32_t) ((switch_micro_time_now() - started) / 1000);
-			if (elapsed >= timeout) {
+		if (abs_timeout) {
+			abs_elapsed = (uint32_t) ((switch_micro_time_now() - abs_started) / 1000);
+			if (abs_elapsed >= abs_timeout) {
+				status = SWITCH_STATUS_TIMEOUT;
 				break;
 			}
 		}
+		if (digit_timeout) {
+			digit_elapsed = (uint32_t) ((switch_micro_time_now() - digit_started) / 1000);
+			if (digit_elapsed >= digit_timeout) {
+				status = SWITCH_STATUS_TIMEOUT;
+				break;
+			}
+		}
 
 		if (switch_core_session_private_event_count(session)) {
 			switch_ivr_parse_all_events(session);
@@ -855,6 +865,9 @@
 		if (switch_channel_has_dtmf(channel)) {
 			switch_channel_dequeue_dtmf(channel, &dtmf);
 			status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
+			if (digit_timeout) {
+				digit_started = switch_micro_time_now();
+			}
 		}
 
 		if (switch_core_session_dequeue_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {

Modified: freeswitch/trunk/src/switch_ivr_play_say.c (14980 => 14981)


--- freeswitch/trunk/src/switch_ivr_play_say.c	2009-09-25 18:26:47 UTC (rev 14980)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	2009-09-25 19:07:20 UTC (rev 14981)
@@ -2223,7 +2223,7 @@
 			if (!switch_strlen_zero(moh) && strcasecmp(moh, "silence")) {
 				switch_ivr_play_file(session, NULL, moh, &args);
 			} else {
-				switch_ivr_collect_digits_callback(session, &args, 0);
+				switch_ivr_collect_digits_callback(session, &args, 0, 0);
 			}
 
 			if (moh_br) {