From 1fabe6fc58da35974384395fbe45465310fb5a7e Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Fri, 18 Mar 2011 14:47:49 -0400 Subject: [PATCH] freetdm: add configuration option for DTMF debug directory --- libs/freetdm/conf/freetdm.conf | 3 +++ libs/freetdm/src/ftdm_io.c | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libs/freetdm/conf/freetdm.conf b/libs/freetdm/conf/freetdm.conf index 2f9643dedd..cd269b7736 100644 --- a/libs/freetdm/conf/freetdm.conf +++ b/libs/freetdm/conf/freetdm.conf @@ -20,6 +20,9 @@ cpu_reset_alarm_threshold => 70 ; cpu_alarm_action => warn,reject cpu_alarm_action => warn +; Where to dump DTMF debug files (see per span debugdtmf=yes option) +debugdtmf_directory=/full/path/to/dtmf/directory + ; spans are defined with [span ] ; the span type can either be zt, wanpipe or pika ; the span name can be any unique string diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 1951678d73..52cfa98c9d 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -244,6 +244,7 @@ static struct { ftdm_caller_data_t *call_ids[MAX_CALLIDS+1]; ftdm_mutex_t *call_id_mutex; uint32_t last_call_id; + char dtmfdebug_directory[1024]; } globals; enum ftdm_enum_cpu_alarm_action_flags @@ -3469,7 +3470,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, cons if (!ftdmchan->dtmfdbg.file) { struct tm currtime; time_t currsec; - char dfile[512]; + char dfile[1024]; currsec = time(NULL); @@ -3480,10 +3481,18 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, cons localtime_r(&currsec, &currtime); #endif - snprintf(dfile, sizeof(dfile), "dtmf-s%dc%d-20%d-%d-%d-%d:%d:%d.%s", - ftdmchan->span_id, ftdmchan->chan_id, - currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday, - currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln"); + if (ftdm_strlen_zero(globals.dtmfdebug_directory)) { + snprintf(dfile, sizeof(dfile), "dtmf-s%dc%d-20%d-%d-%d-%d:%d:%d.%s", + ftdmchan->span_id, ftdmchan->chan_id, + currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday, + currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln"); + } else { + snprintf(dfile, sizeof(dfile), "%s/dtmf-s%dc%d-20%d-%d-%d-%d:%d:%d.%s", + globals.dtmfdebug_directory, + ftdmchan->span_id, ftdmchan->chan_id, + currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday, + currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln"); + } ftdmchan->dtmfdbg.file = fopen(dfile, "wb"); if (!ftdmchan->dtmfdbg.file) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "failed to open debug dtmf file %s\n", dfile); @@ -4697,6 +4706,9 @@ static ftdm_status_t load_config(void) globals.cpu_monitor.alarm_action_flags |= FTDM_CPU_ALARM_ACTION_WARN; } } + } else if (!strncasecmp(var, "debugdtmf_directory", sizeof("debugdtmf_directory")-1)) { + ftdm_set_string(globals.dtmfdebug_directory, val); + ftdm_log(FTDM_LOG_DEBUG, "Debug DTMF directory set to '%s'\n", globals.dtmfdebug_directory); } else if (!strncasecmp(var, "cpu_monitoring_interval", sizeof("cpu_monitoring_interval")-1)) { if (atoi(val) > 0) { globals.cpu_monitor.interval = atoi(val);