|
|
|
@ -441,8 +441,9 @@ static void ast_tone_detect_init(tone_detect_state_t *s, int freq, int duration,
|
|
|
|
|
/* Make sure we will have at least 5 periods at target frequency for analisys.
|
|
|
|
|
This may make block larger than expected packet and will make squelching impossible
|
|
|
|
|
but at least we will be detecting the tone */
|
|
|
|
|
if (periods_in_block < 5)
|
|
|
|
|
if (periods_in_block < 5) {
|
|
|
|
|
periods_in_block = 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now calculate final block size. It will contain integer number of periods */
|
|
|
|
|
s->block_size = periods_in_block * sample_rate / freq;
|
|
|
|
@ -493,8 +494,9 @@ static void ast_v21_detect_init(v21_detect_state_t *s, unsigned int sample_rate)
|
|
|
|
|
/* Make sure we will have at least 5 periods at target frequency for analisys.
|
|
|
|
|
This may make block larger than expected packet and will make squelching impossible
|
|
|
|
|
but at least we will be detecting the tone */
|
|
|
|
|
if (periods_in_block < 5)
|
|
|
|
|
if (periods_in_block < 5) {
|
|
|
|
|
periods_in_block = 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now calculate final block size. It will contain integer number of periods */
|
|
|
|
|
s->block_size = periods_in_block * sample_rate / 1850;
|
|
|
|
@ -1061,8 +1063,9 @@ static int mf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reinitialise the detector for the next block */
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
|
goertzel_reset(&s->td.mf.tone_out[i]);
|
|
|
|
|
}
|
|
|
|
|
s->td.mf.current_sample = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1603,10 +1606,11 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dsp->features & (DSP_FEATURE_DIGIT_DETECT | DSP_FEATURE_BUSY_DETECT)) {
|
|
|
|
|
if (dsp->digitmode & DSP_DIGITMODE_MF)
|
|
|
|
|
if (dsp->digitmode & DSP_DIGITMODE_MF) {
|
|
|
|
|
digit = mf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
digit = dtmf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dsp->digit_state.current_digits) {
|
|
|
|
|
int event = 0, event_len = 0;
|
|
|
|
@ -1675,8 +1679,9 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
|
|
|
|
|
dsp->f.frametype = AST_FRAME_CONTROL;
|
|
|
|
|
dsp->f.subclass.integer = res;
|
|
|
|
|
dsp->f.src = "dsp_progress";
|
|
|
|
|
if (chan)
|
|
|
|
|
if (chan) {
|
|
|
|
|
ast_queue_frame(chan, &dsp->f);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ast_log(LOG_WARNING, "Don't know how to represent call progress message %d\n", res);
|
|
|
|
@ -1907,33 +1912,34 @@ int ast_dsp_get_tcount(struct ast_dsp *dsp)
|
|
|
|
|
|
|
|
|
|
static int _dsp_init(int reload)
|
|
|
|
|
{
|
|
|
|
|
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
|
|
|
|
|
struct ast_config *cfg;
|
|
|
|
|
struct ast_variable *v;
|
|
|
|
|
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
|
|
|
|
|
int cfg_threshold;
|
|
|
|
|
|
|
|
|
|
cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags);
|
|
|
|
|
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
|
|
|
|
|
ast_verb(5, "Can't find dsp config file %s. Assuming default silencethreshold of %d.\n", CONFIG_FILE_NAME, DEFAULT_SILENCE_THRESHOLD);
|
|
|
|
|
thresholds[THRESHOLD_SILENCE] = DEFAULT_SILENCE_THRESHOLD;
|
|
|
|
|
if ((cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
|
|
|
|
|
thresholds[THRESHOLD_SILENCE] = DEFAULT_SILENCE_THRESHOLD;
|
|
|
|
|
|
|
|
|
|
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cfg) {
|
|
|
|
|
const char *value;
|
|
|
|
|
|
|
|
|
|
value = ast_variable_retrieve(cfg, "default", "silencethreshold");
|
|
|
|
|
if (value && sscanf(value, "%30d", &thresholds[THRESHOLD_SILENCE]) != 1) {
|
|
|
|
|
ast_verb(5, "%s: '%s' is not a valid silencethreshold value\n", CONFIG_FILE_NAME, value);
|
|
|
|
|
thresholds[THRESHOLD_SILENCE] = DEFAULT_SILENCE_THRESHOLD;
|
|
|
|
|
} else if (!value) {
|
|
|
|
|
thresholds[THRESHOLD_SILENCE] = DEFAULT_SILENCE_THRESHOLD;
|
|
|
|
|
for (v = ast_variable_browse(cfg, "default"); v; v = v->next) {
|
|
|
|
|
if (!strcasecmp(v->name, "silencethreshold")) {
|
|
|
|
|
if (sscanf(v->value, "%30d", &cfg_threshold) < 1) {
|
|
|
|
|
ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
|
|
|
|
|
} else if (cfg_threshold < 0) {
|
|
|
|
|
ast_log(LOG_WARNING, "Invalid silence threshold '%d' specified, using default\n", cfg_threshold);
|
|
|
|
|
} else {
|
|
|
|
|
thresholds[THRESHOLD_SILENCE] = cfg_threshold;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ast_config_destroy(cfg);
|
|
|
|
|
}
|
|
|
|
|
ast_config_destroy(cfg);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1951,4 +1957,3 @@ int ast_dsp_reload(void)
|
|
|
|
|
{
|
|
|
|
|
return _dsp_init(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|