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)) {
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;
}
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;
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;
} 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)) {
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;
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));
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;