]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: add configuration option for DTMF debug directory
authorMoises Silva <moy@sangoma.com>
Fri, 18 Mar 2011 18:47:49 +0000 (14:47 -0400)
committerMoises Silva <moy@sangoma.com>
Fri, 18 Mar 2011 18:47:49 +0000 (14:47 -0400)
libs/freetdm/conf/freetdm.conf
libs/freetdm/src/ftdm_io.c

index 2f9643dedda2ebc9f02ddc051bfe5b6ffe9473a7..cd269b7736a1a7296733d37b9d84fd5c3311df0c 100644 (file)
@@ -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 <span type> <span name>]
 ; the span type can either be zt, wanpipe or pika
 ; the span name can be any unique string
index 1951678d73852b20378771dfd5e975498ae65caa..52cfa98c9de726382d01f68455dce817cd8d32ca 100644 (file)
@@ -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);