ftdm_assert_return(span->fio != NULL, FTDM_EINVAL, "span with no I/O configured\n");
ftdm_assert_return(span->fio->configure_span != NULL, FTDM_NOTIMPL, "span I/O with no channel configuration implemented\n");
- currindex = span->chan_count;
+ currindex = span->chan_count;
*configured = 0;
*configured = span->fio->configure_span(span, str, chan_config->type, chan_config->name, chan_config->number);
if (!*configured) {
}
if (chan_config->debugdtmf) {
- span->channels[chan_index]->dtmfdbg.requested = 1;
+ span->channels[chan_index]->dtmfdbg.requested = 1;
}
+
+ span->channels[chan_index]->dtmfdetect.duration_ms = chan_config->dtmfdetect_ms;
}
return FTDM_SUCCESS;
memset(&chan_config, 0, sizeof(chan_config));
sprintf(chan_config.group_name, "__default");
+ chan_config.dtmfdetect_ms = 45;
if (!ftdm_config_open_file(&cfg, cfg_name)) {
return FTDM_FAIL;
} else if (!strcasecmp(var, "debugdtmf")) {
chan_config.debugdtmf = ftdm_true(val);
ftdm_log(FTDM_LOG_DEBUG, "Setting debugdtmf to '%s'\n", chan_config.debugdtmf ? "yes" : "no");
+ } else if (!strncasecmp(var, "dtmfdetect_ms", sizeof("dtmfdetect_ms")-1)) {
+ if (sscanf(val, "%d", &(chan_config.dtmfdetect_ms)) != 1) {
+ ftdm_log(FTDM_LOG_ERROR, "invalid dtmfdetect_ms: '%s'\n", val);
+ }
} else if (!strncasecmp(var, "iostats", sizeof("iostats")-1)) {
if (ftdm_true(val)) {
chan_config.iostats = FTDM_TRUE;
wp_globals.ring_off_ms = num;
}
}
+
}
return FTDM_SUCCESS;
if (tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_dtmf_type == WAN_EC_TONE_PRESENT) {
ftdm_set_flag(fchan, FTDM_CHANNEL_MUTE);
+ fchan->dtmfdetect.start_time = ftdm_current_time_in_ms();
}
if (tdm_api->wp_tdm_cmd.event.wp_tdm_api_event_dtmf_type == WAN_EC_TONE_STOP) {
ftdm_clear_flag(fchan, FTDM_CHANNEL_MUTE);
if (ftdm_test_flag(fchan, FTDM_CHANNEL_INUSE)) {
- ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c\n", tmp_dtmf[0]);
- ftdm_channel_queue_dtmf(fchan, tmp_dtmf);
+ ftdm_time_t diff = ftdm_current_time_in_ms() - fchan->dtmfdetect.start_time;
+ if (diff > fchan->dtmfdetect.duration_ms) {
+ ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c (duration:%d min:%d)\n", tmp_dtmf[0], diff, fchan->dtmfdetect.duration_ms);
+ ftdm_channel_queue_dtmf(fchan, tmp_dtmf);
+ } else {
+ ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Ignoring wanpipe DTMF: %c (duration:%d min:%d)\n", tmp_dtmf[0], diff, fchan->dtmfdetect.duration_ms);
+ }
}
}
}
FTDM_STR2ENUM_P(ftdm_str2ftdm_trunk_type, ftdm_trunk_type2str, ftdm_trunk_type_t)
/*! \brief Basic channel configuration provided to ftdm_configure_span_channels */
-typedef struct ftdm_channel_config {
+typedef struct ftdm_channel_config {
char name[FTDM_MAX_NAME_STR_SZ];
char number[FTDM_MAX_NUMBER_STR_SZ];
char group_name[FTDM_MAX_NAME_STR_SZ];
float rxgain;
float txgain;
uint8_t debugdtmf;
+ uint32_t dtmfdetect_ms;
uint8_t iostats;
} ftdm_channel_config_t;
ftdm_mutex_t *mutex;
} ftdm_dtmf_debug_t;
+typedef struct {
+ uint32_t duration_ms;
+ ftdm_time_t start_time;
+} ftdm_dtmf_detect_t;
+
/* 2^8 table size, one for each byte (sample) value */
#define FTDM_GAINS_TABLE_SIZE 256
struct ftdm_channel {
ftdm_timer_id_t hangup_timer;
ftdm_channel_iostats_t iostats;
ftdm_dtmf_debug_t dtmfdbg;
+ ftdm_dtmf_detect_t dtmfdetect;
ftdm_io_dump_t rxdump;
ftdm_io_dump_t txdump;
ftdm_interrupt_t *state_completed_interrupt; /*!< Notify when a state change is completed */