[Freeswitch-svn] [commit] r7077 - in freeswitch/trunk: conf/autoload_configs src/mod/applications/mod_fifo src/mod/applications/mod_voicemail

Freeswitch SVN anthm at freeswitch.org
Thu Jan 3 17:04:19 EST 2008


Author: anthm
Date: Thu Jan  3 17:04:19 2008
New Revision: 7077

Modified:
   freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml
   freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
   freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c

Log:
add min record len to voicemail

Modified: freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml	(original)
+++ freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml	Thu Jan  3 17:04:19 2008
@@ -7,6 +7,7 @@
       <param name="terminator-key" value="#"/>
       <param name="max-login-attempts" value="3"/>
       <param name="digit-timeout" value="10000"/>
+      <param name="min-record-len" value="3"/>
       <param name="max-record-len" value="300"/>
       <param name="tone-spec" value="%(1000, 0, 640)"/>
       <param name="callback-dialplan" value="XML"/>

Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	Thu Jan  3 17:04:19 2008
@@ -705,8 +705,10 @@
     void *val, *pop;
     fifo_node_t *node;
     switch_memory_pool_t *pool = globals.pool;
-    switch_mutex_lock(globals.mutex);
+    switch_mutex_t *mutex = globals.mutex;
 
+    switch_mutex_lock(mutex);
+    
     globals.running = 0;
     /* Cleanup*/
     for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
@@ -719,9 +721,8 @@
         switch_core_hash_destroy(&node->consumer_hash);
     }
     switch_core_hash_destroy(&globals.fifo_hash);
-    memset(&globals, 0, sizeof(globals));
-    switch_mutex_unlock(globals.mutex);
-    
+    memset(&globals, 0, sizeof(globals));    
+    switch_mutex_unlock(mutex);
     switch_core_destroy_memory_pool(&pool);
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c	Thu Jan  3 17:04:19 2008
@@ -96,6 +96,7 @@
 	char *date_fmt;
 	uint32_t digit_timeout;
 	uint32_t max_login_attempts;
+	uint32_t min_record_len;
 	uint32_t max_record_len;
 	switch_mutex_t *mutex;
 	uint32_t record_threshold;
@@ -289,7 +290,7 @@
 		char *record_copyright = "http://www.freeswitch.org";
 
 		switch_core_db_t *db;
-		uint32_t timeout = 10000, max_login_attempts = 3, max_record_len = 300;
+		uint32_t timeout = 10000, max_login_attempts = 3, max_record_len = 300, min_record_len = 3;
 
 		db = NULL;
 
@@ -496,6 +497,16 @@
 				} else {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10 ms\n", val);
 				}
+			} else if (!strcasecmp(var, "min-record-len")) {
+				int tmp = 0;
+				if (!switch_strlen_zero(val)) {
+					tmp = atoi(val);
+				}
+				if (tmp > 0 && tmp < 10000) {
+					min_record_len = tmp;
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10000s\n", val);
+				}
 			} else if (!strcasecmp(var, "max-record-len")) {
 				int tmp = 0;
 				if (!switch_strlen_zero(val)) {
@@ -578,6 +589,7 @@
 
 			profile->digit_timeout = timeout;
 			profile->max_login_attempts = max_login_attempts;
+			profile->min_record_len = min_record_len;
 			profile->max_record_len = max_record_len;
 			*profile->terminator_key = *terminator_key;
 			*profile->play_new_messages_key = *play_new_messages_key;
@@ -878,6 +890,7 @@
 			profile->record_file_key);
 
 record_file:
+        *message_len = 0;
 		args.input_callback = cancel_on_dtmf;
 		TRY_CODE(switch_ivr_phrase_macro(session, macro_name, NULL, NULL, NULL));
 		TRY_CODE(switch_ivr_gentones(session, profile->tone_spec, 0, NULL));
@@ -887,9 +900,14 @@
 		fh.silence_hits = profile->record_silence_hits;
 		fh.samplerate = profile->record_sample_rate;
 		switch_ivr_record_file(session, &fh, file_path, &args, profile->max_record_len);
-		*message_len = fh.sample_count / read_codec->implementation->actual_samples_per_second;
-		status = SWITCH_STATUS_SUCCESS;
-
+		if ((*message_len = fh.sample_count / read_codec->implementation->actual_samples_per_second) < profile->min_record_len) {
+            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Message is less than minimum record length: %d, discarding it.\n", 
+                              profile->min_record_len);
+            unlink(file_path);
+            goto record_file;
+        } else {
+            status = SWITCH_STATUS_SUCCESS;
+        }
 play_file:
 		memset(&fh, 0, sizeof(fh));
 		args.input_callback = control_playback;



More information about the Freeswitch-svn mailing list