115 #define FREQ_ARRAY_SIZE 7 140 #define DEFAULT_THRESHOLD 512 151 #define DSP_HISTORY 15 153 #define TONE_THRESH 10.0 154 #define TONE_MIN_THRESH 1e8 166 #define MAX_DTMF_DIGITS 128 180 #define DTMF_THRESHOLD 8.0e7 181 #define TONE_THRESHOLD 7.8e7 183 #define DEF_DTMF_NORMAL_TWIST 6.31 184 #define DEF_RELAX_DTMF_NORMAL_TWIST 6.31 187 #define DEF_DTMF_REVERSE_TWIST 2.51 188 #define DEF_RELAX_DTMF_REVERSE_TWIST 6.61 190 #define DEF_DTMF_REVERSE_TWIST 2.51 191 #define DEF_RELAX_DTMF_REVERSE_TWIST 3.98 194 #define DTMF_RELATIVE_PEAK_ROW 6.3 195 #define DTMF_RELATIVE_PEAK_COL 6.3 196 #define DTMF_TO_TOTAL_ENERGY 42.0 198 #define BELL_MF_THRESHOLD 1.6e9 199 #define BELL_MF_TWIST 4.0 200 #define BELL_MF_RELATIVE_PEAK 12.6 202 #if defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE) 203 #error You cant use BUSYDETECT_TONEONLY together with BUSYDETECT_COMPARE_TONE_AND_SILENCE 209 #define FAX_TONE_CNG_FREQ 1100 210 #define FAX_TONE_CNG_DURATION 500 211 #define FAX_TONE_CNG_DB 16 217 #define FAX_TONE_CED_FREQ 2100 218 #define FAX_TONE_CED_DURATION 2600 219 #define FAX_TONE_CED_DB 16 221 #define DEFAULT_SAMPLE_RATE 8000 227 #define DTMF_GSIZE 102 232 #define DEF_DTMF_HITS_TO_BEGIN 2 237 #define DEF_DTMF_MISSES_TO_END 3 245 #define CONFIG_FILE_NAME "dsp.conf" 318 697.0, 770.0, 852.0, 941.0
321 1209.0, 1336.0, 1477.0, 1633.0
324 700.0, 900.0, 1100.0, 1300.0, 1500.0, 1700.0
350 s->
v3 = (s->
fac * s->
v2) >> 15;
354 if (
abs(s->
v3) > (1 << 15)) {
373 return (
float)r.
value * (float)(1 << r.
power);
379 s->
fac = (int)(32768.0 * 2.0 *
cos(2.0 *
M_PI * freq / sample_rate));
451 int duration_samples;
453 int periods_in_block;
458 duration_samples = duration * sample_rate / 1000;
460 duration_samples = duration_samples * 9 / 10;
467 periods_in_block = s->
block_size * freq / sample_rate;
472 if (periods_in_block < 5) {
473 periods_in_block = 5;
477 s->
block_size = periods_in_block * sample_rate / freq;
504 x = pow(10.0, amp / 10.0);
525 for (i = 0; i < 4; i++) {
541 for (i = 0; i < 6; i++) {
580 for (start = 0; start < samples; start =
end) {
582 limit = samples - start;
588 for (i = limit, ptr = amp ; i > 0; i--, ptr++) {
660 if (mute.
end > samples) {
703 for (sample = 0; sample < samples; sample = limit) {
712 for (j = sample; j < limit; j++) {
735 for (best_row = best_col = 0, i = 1; i < 4; i++) {
737 if (row_energy[i] > row_energy[best_row]) {
741 if (col_energy[i] > col_energy[best_col]) {
745 ast_debug(10,
"DTMF best '%c' Erow=%.4E Ecol=%.4E Erc=%.4E Et=%.4E\n",
747 row_energy[best_row], col_energy[best_col],
748 row_energy[best_row] + col_energy[best_col], s->
td.
dtmf.
energy);
756 for (i = 0; i < 4; i++) {
757 if ((i != best_col &&
861 if (squelch && hit) {
871 for (i = 0; i < 4; i++) {
879 if (squelch && mute.
end) {
880 if (mute.
end > samples) {
891 int samples,
int squelch,
int relax)
910 for (sample = 0; sample < samples; sample = limit) {
920 for (j = sample; j < limit; j++) {
944 if (energy[0] > energy[1]) {
952 for (i = 2; i < 6; i++) {
954 if (energy[i] >= energy[best]) {
957 }
else if (energy[i] >= energy[second_best]) {
968 for (i = 0; i < 6; i++) {
969 if (i != best && i != second_best) {
980 if (second_best < best) {
985 best = best * 5 + second_best - 1;
1014 if (squelch && hit) {
1024 for (i = 0; i < 6; i++) {
1030 if (squelch && mute.
end) {
1031 if (mute.
end > samples) {
1041 static inline int pair_there(
float p1,
float p2,
float i1,
float i2,
float e)
1053 if ((p1 < i1) || (p1 < i2) || (p1 < e)) {
1057 if ((p2 < i1) || (p2 < i2) || (p2 < e)) {
1080 for (x = 0; x <
pass; x++) {
1083 for (y = 0; y < freqcount; y++) {
1099 }
else if (
pair_there(hz[HZ_440], hz[HZ_480], hz[HZ_350], hz[HZ_620], dsp->
genergy)) {
1101 }
else if (
pair_there(hz[HZ_350], hz[HZ_440], hz[HZ_480], hz[HZ_620], dsp->
genergy)) {
1140 if (newstate == dsp->
tstate) {
1183 ast_debug(1,
"Consider call as answered because of timeout after last ring\n");
1189 ast_debug(5,
"Start state %d\n", newstate);
1195 for (x = 0; x < 7; x++) {
1229 for (x = 0; x <
len; x++) {
1257 if (silence1 < silence2) {
1258 if (silence1 + silence1 *
BUSY_PERCENT / 100 >= silence2) {
1264 if (silence1 - silence1 *
BUSY_PERCENT / 100 <= silence2) {
1279 if (frames_energy) {
1280 *frames_energy = accum;
1288 #ifndef BUSYDETECT_TONEONLY 1289 int avgsilence = 0, hitsilence = 0;
1291 int avgtone = 0, hittone = 0;
1301 #ifndef BUSYDETECT_TONEONLY 1306 #ifndef BUSYDETECT_TONEONLY 1311 #ifndef BUSYDETECT_TONEONLY 1332 #ifndef BUSYDETECT_TONEONLY 1340 #ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE 1341 if (avgtone > avgsilence) {
1342 if (avgtone - avgtone*
BUSY_PERCENT/100 <= avgsilence) {
1346 if (avgtone + avgtone*
BUSY_PERCENT/100 >= avgsilence) {
1384 ast_debug(5,
"errors = %d max = %d\n", errors, errors_max);
1386 if (errors <= errors_max) {
1394 #ifdef BUSYDETECT_DEBUG 1395 ast_debug(5,
"busy detector: avgtone of %d not close enough to desired %d\n",
1401 #ifndef BUSYDETECT_TONEONLY 1405 #ifdef BUSYDETECT_DEBUG 1406 ast_debug(5,
"busy detector: avgsilence of %d not close enough to desired %d\n",
1413 #if !defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_DEBUG) 1415 ast_debug(5,
"ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1417 ast_debug(5,
"busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1428 unsigned char *odata;
1447 for (x = 0; x <
len; x++) {
1452 for (x = 0; x <
len; x++) {
1456 ast_log(
LOG_WARNING,
"Can only calculate silence on signed-linear, alaw or ulaw frames :(\n");
1488 int digit = 0, fax_digit = 0;
1491 unsigned char *odata;
1510 for (x = 0; x <
len; x++) {
1515 for (x = 0; x <
len; x++) {
1536 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1543 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1569 int event = 0, event_len = 0;
1570 char event_digit = 0;
1597 ast_debug(1,
"DTMF Detected - Reset busydetector\n");
1602 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1605 dsp->
f.
len = event_len;
1615 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1631 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1634 dsp->
f.
src =
"dsp_progress";
1654 for (x = 0; x <
len; x++) {
1655 odata[x] =
AST_LIN2MU((
unsigned short) shortdata[x]);
1658 for (x = 0; x <
len; x++) {
1659 odata[x] =
AST_LIN2A((
unsigned short) shortdata[x]);
1779 for (i = 0; i < 6; i++) {
1788 for (i = 0; i < 4; i++) {
1810 for (x = 0; x < 4; x++) {
1835 if (dsp->
faxmode != faxmode) {
1896 if (!strcasecmp(v->
name,
"silencethreshold")) {
1897 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1899 }
else if (cfg_threshold < 0) {
1900 ast_log(
LOG_WARNING,
"Invalid silence threshold '%d' specified, using default\n", cfg_threshold);
1904 }
else if (!strcasecmp(v->
name,
"dtmf_normal_twist")) {
1905 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1907 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1912 }
else if (!strcasecmp(v->
name,
"dtmf_reverse_twist")) {
1913 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1915 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1920 }
else if (!strcasecmp(v->
name,
"relax_dtmf_normal_twist")) {
1921 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1923 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1928 }
else if (!strcasecmp(v->
name,
"relax_dtmf_reverse_twist")) {
1929 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1931 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1936 }
else if (!strcasecmp(v->
name,
"dtmf_hits_to_begin")) {
1937 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1939 }
else if (cfg_threshold < 1) {
1944 }
else if (!strcasecmp(v->
name,
"dtmf_misses_to_end")) {
1945 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1947 }
else if (cfg_threshold < 1) {
1964 #ifdef TEST_FRAMEWORK 1965 static void test_tone_sample_gen(
short *slin_buf,
int samples,
int rate,
int freq,
short amplitude)
1968 double sample_step = 2.0 *
M_PI * freq / rate;
1970 for (idx = 0; idx < samples; ++idx) {
1971 slin_buf[idx] = amplitude * sin(sample_step * idx);
1976 #ifdef TEST_FRAMEWORK 1977 static void test_tone_sample_gen_add(
short *slin_buf,
int samples,
int rate,
int freq,
short amplitude)
1980 double sample_step = 2.0 *
M_PI * freq / rate;
1982 for (idx = 0; idx < samples; ++idx) {
1983 slin_buf[idx] += amplitude * sin(sample_step * idx);
1988 #ifdef TEST_FRAMEWORK 1989 static void test_dual_sample_gen(
short *slin_buf,
int samples,
int rate,
int f1,
short a1,
int f2,
short a2)
1991 test_tone_sample_gen(slin_buf, samples, rate, f1, a1);
1992 test_tone_sample_gen_add(slin_buf, samples, rate, f2, a2);
1996 #ifdef TEST_FRAMEWORK 1997 #define TONE_AMPLITUDE_MAX 0x7fff 1998 #define TONE_AMPLITUDE_MIN 80 2009 { .amp_val = TONE_AMPLITUDE_MAX, .detect = 1, },
2010 { .amp_val = 10000, .detect = 1, },
2011 { .amp_val = 1000, .detect = 1, },
2012 { .amp_val = 100, .detect = 1, },
2013 { .amp_val = TONE_AMPLITUDE_MIN, .detect = 1, },
2014 { .amp_val = 75, .detect = 0, },
2015 { .amp_val = 10, .detect = 0, },
2016 { .amp_val = 1, .detect = 0, },
2021 for (idx = 0; idx <
ARRAY_LEN(amp_tests); ++idx) {
2025 ast_debug(1,
"Test %d Hz at amplitude %d\n",
2026 tone_state->
freq, amp_tests[idx].amp_val);
2028 tone_state->
freq, amp_tests[idx].amp_val);
2031 for (duration = 0; !detected && duration < tone_state->
hits_required + 3; ++duration) {
2034 if (amp_tests[idx].detect != detected) {
2042 "Test %d Hz at amplitude %d failed. Detected: %s\n",
2043 tone_state->
freq, amp_tests[idx].amp_val,
2044 detected ?
"yes" :
"no");
2046 "Test %d Hz at amplitude %d failed. Detected: %s\n",
2047 tone_state->
freq, amp_tests[idx].amp_val,
2048 detected ?
"yes" :
"no");
2058 #ifdef TEST_FRAMEWORK 2059 static int test_dtmf_amplitude_sweep(
struct ast_test *
test,
struct ast_dsp *dsp,
int digit_index)
2074 { .amp_val = TONE_AMPLITUDE_MAX/2, .digit =
dtmf_positions[digit_index], },
2082 { .amp_val = 170, .digit = 0, },
2083 { .amp_val = 100, .digit = 0, },
2088 { .amp_val = TONE_AMPLITUDE_MIN, .digit = 0, },
2089 { .amp_val = 75, .digit = 0, },
2090 { .amp_val = 10, .digit = 0, },
2091 { .amp_val = 1, .digit = 0, },
2094 row = (digit_index >> 2) & 0x03;
2095 column = digit_index & 0x03;
2099 for (idx = 0; idx <
ARRAY_LEN(amp_tests); ++idx) {
2103 ast_debug(1,
"Test '%c' at amplitude %d\n",
2106 (
int)
dtmf_row[row], amp_tests[idx].amp_val,
2107 (
int)
dtmf_col[column], amp_tests[idx].amp_val);
2110 for (duration = 0; !digit && duration < 3; ++duration) {
2114 if (amp_tests[idx].digit != digit) {
2122 "Test '%c' at amplitude %d failed. Detected Digit: '%c'\n",
2126 "Test '%c' at amplitude %d failed. Detected Digit: '%c'\n",
2138 #ifdef TEST_FRAMEWORK 2139 static int test_dtmf_twist_sweep(
struct ast_test *
test,
struct ast_dsp *dsp,
int digit_index)
2158 { .amp_row = 1000 + 1800, .amp_col = 1000 + 0, .digit = 0, },
2159 { .amp_row = 1000 + 1700, .amp_col = 1000 + 0, .digit = 0, },
2161 { .amp_row = 1000 + 1400, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2162 { .amp_row = 1000 + 1300, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2163 { .amp_row = 1000 + 1200, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2164 { .amp_row = 1000 + 1100, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2165 { .amp_row = 1000 + 1000, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2166 { .amp_row = 1000 + 100, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2167 { .amp_row = 1000 + 0, .amp_col = 1000 + 100, .digit =
dtmf_positions[digit_index], },
2168 { .amp_row = 1000 + 0, .amp_col = 1000 + 200, .digit =
dtmf_positions[digit_index], },
2169 { .amp_row = 1000 + 0, .amp_col = 1000 + 300, .digit =
dtmf_positions[digit_index], },
2170 { .amp_row = 1000 + 0, .amp_col = 1000 + 400, .digit =
dtmf_positions[digit_index], },
2171 { .amp_row = 1000 + 0, .amp_col = 1000 + 500, .digit =
dtmf_positions[digit_index], },
2172 { .amp_row = 1000 + 0, .amp_col = 1000 + 550, .digit =
dtmf_positions[digit_index], },
2174 { .amp_row = 1000 + 0, .amp_col = 1000 + 650, .digit = 0, },
2175 { .amp_row = 1000 + 0, .amp_col = 1000 + 700, .digit = 0, },
2176 { .amp_row = 1000 + 0, .amp_col = 1000 + 800, .digit = 0, },
2178 float save_normal_twist;
2179 float save_reverse_twist;
2186 row = (digit_index >> 2) & 0x03;
2187 column = digit_index & 0x03;
2191 for (idx = 0; idx <
ARRAY_LEN(twist_tests); ++idx) {
2195 ast_debug(1,
"Test '%c' twist row %d col %d amplitudes\n",
2197 twist_tests[idx].amp_row, twist_tests[idx].amp_col);
2199 (
int)
dtmf_row[row], twist_tests[idx].amp_row,
2200 (
int)
dtmf_col[column], twist_tests[idx].amp_col);
2203 for (duration = 0; !digit && duration < 3; ++duration) {
2207 if (twist_tests[idx].digit != digit) {
2215 "Test '%c' twist row %d col %d amplitudes failed. Detected Digit: '%c'\n",
2217 twist_tests[idx].amp_row, twist_tests[idx].amp_col,
2220 "Test '%c' twist row %d col %d amplitudes failed. Detected Digit: '%c'\n",
2222 twist_tests[idx].amp_row, twist_tests[idx].amp_col,
2236 #ifdef TEST_FRAMEWORK 2246 lower_freq = tone_state->
freq - 4;
2247 upper_freq = tone_state->
freq + 4;
2252 for (freq = 100; freq <= 3500; freq += 1) {
2255 int expect_detection;
2257 if (freq == tone_state->
freq) {
2262 expect_detection = (lower_freq <= freq && freq <= upper_freq) ? 1 : 0;
2264 ast_debug(1,
"Test %d Hz detection given %d Hz tone at amplitude %d. Range:%d-%d Expect detect: %s\n",
2265 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2266 expect_detection ?
"yes" :
"no");
2271 for (duration = 0; !detected && duration < tone_state->
hits_required + 3; ++duration) {
2274 if (expect_detection != detected) {
2282 "Test %d Hz detection given %d Hz tone at amplitude %d failed. Range:%d-%d Detected: %s\n",
2283 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2284 detected ?
"yes" :
"no");
2286 "Test %d Hz detection given %d Hz tone at amplitude %d failed. Range:%d-%d Detected: %s\n",
2287 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2288 detected ?
"yes" :
"no");
2298 #ifdef TEST_FRAMEWORK 2307 info->category =
"/main/dsp/";
2308 info->summary =
"DSP fax tone detect unit test";
2310 "Tests fax tone detection code.";
2354 #ifdef TEST_FRAMEWORK 2363 info->name =
"dtmf";
2364 info->category =
"/main/dsp/";
2365 info->summary =
"DSP DTMF detect unit test";
2367 "Tests DTMF detection code.";
2381 if (test_dtmf_amplitude_sweep(
test, dsp, idx)) {
2387 if (test_dtmf_twist_sweep(
test, dsp, idx)) {
2428 .requires =
"extconfig",
int ast_dsp_was_muted(struct ast_dsp *dsp)
Returns true if DSP code was muting any fragment of the last processed frame. Muting (squelching) hap...
static void ast_digit_detect_init(digit_detect_state_t *s, int mf, unsigned int sample_rate)
static void mute_fragment(struct ast_dsp *dsp, fragment_t *fragment)
A-Law to Signed linear conversion.
struct ast_variable * next
#define DSP_PROGRESS_RINGING
Main Channel structure associated with a channel.
static float relax_dtmf_reverse_twist
static int unload_module(void)
Asterisk main include file. File version handling, generic pbx functions.
static int ast_dsp_silence_noise_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *total, int *frames_energy, int noise)
static int load_module(void)
#define DTMF_RELATIVE_PEAK_COL
struct ast_frame * ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *af)
Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress...
#define FAX_TONE_CNG_FREQ
static int reload_module(void)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
#define DSP_TONE_STATE_HUNGUP
union digit_detect_state_t::@377 td
#define DSP_DIGITMODE_DTMF
goertzel_state_t freqs[FREQ_ARRAY_SIZE]
#define DSP_FEATURE_DIGIT_DETECT
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set the minimum average magnitude threshold to determine talking by the DSP.
#define DTMF_RELATIVE_PEAK_ROW
Convenient Signal Processing routines.
#define DSP_DIGITMODE_MUTECONF
static const char bell_mf_positions[]
#define DSP_PROGRESS_BUSY
static const int DEFAULT_SILENCE_THRESHOLD
The default silence threshold we will use if an alternate configured value is not present or is inval...
int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone)
Set zone for doing progress detection.
union ast_frame::@257 data
#define DSP_PROGRESS_TALK
#define CONFIG_STATUS_FILEINVALID
#define DSP_FEATURE_CALL_PROGRESS
#define DEF_DTMF_NORMAL_TWIST
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
#define DSP_TONE_STATE_DIALTONE
#define DTMF_TO_TOTAL_ENERGY
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Structure for variables, used for configurations and for channel variables.
static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
int historicsilence[DSP_HISTORY]
#define DSP_PROGRESS_CONGESTION
#define AST_TEST_REGISTER(cb)
#define DSP_FAXMODE_DETECT_SQUELCH
#define DEF_DTMF_HITS_TO_BEGIN
static int dtmf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax)
static const char dtmf_positions[]
int freqs[FREQ_ARRAY_SIZE]
goertzel_state_t tone_out[6]
#define FAX_TONE_CNG_DURATION
#define DSP_TONE_STATE_TALKING
#define FAX_TONE_CED_FREQ
int ast_dsp_busydetect(struct ast_dsp *dsp)
Return non-zero if historically this should be a busy, request that ast_dsp_silence has already been ...
static void ast_dsp_prog_reset(struct ast_dsp *dsp)
static void goertzel_reset(goertzel_state_t *s)
void ast_dsp_reset(struct ast_dsp *dsp)
Reset total silence count.
digit_detect_state_t digit_state
int historicnoise[DSP_HISTORY]
struct ast_frame_subclass subclass
char digits[MAX_DTMF_DIGITS+1]
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Process the audio frame for silence.
static const float dtmf_col[]
int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
Process the audio frame for noise.
static int dtmf_hits_to_begin
Configuration File Parser.
#define FAX_TONE_CED_DURATION
#define DSP_DIGITMODE_RELAXDTMF
#define ast_debug(level,...)
Log a DEBUG message.
#define DEF_DTMF_REVERSE_TWIST
#define DSP_TONE_STATE_SPECIAL2
static struct progress modes[]
u-Law to Signed linear conversion
static const float dtmf_row[]
enum gsamp_size gsamp_size
General Asterisk PBX channel definitions.
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
#define DSP_TONE_STATE_RINGING
#define ast_test_status_update(a, b, c...)
static int dtmf_misses_to_end
#define DSP_TONE_STATE_BUSY
void ast_dsp_digitreset(struct ast_dsp *dsp)
Reset DTMF detector.
#define DEF_DTMF_MISSES_TO_END
#define DSP_FEATURE_SILENCE_SUPPRESS
Asterisk internal frame definitions.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define DSP_FEATURE_FAX_DETECT
static void ast_dtmf_detect_init(dtmf_detect_state_t *s, unsigned int sample_rate)
#define DSP_TONE_STATE_SPECIAL3
static struct progalias aliases[]
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
goertzel_state_t col_out[4]
#define DEFAULT_THRESHOLD
Default minimum average magnitude threshold to determine talking/noise by the DSP.
#define DEF_RELAX_DTMF_NORMAL_TWIST
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
#define CONFIG_STATUS_FILEUNCHANGED
static void store_digit(digit_detect_state_t *s, char digit)
void ast_dsp_free(struct ast_dsp *dsp)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
static void ast_tone_detect_init(tone_detect_state_t *s, int freq, int duration, int amp, unsigned int sample_rate)
static void goertzel_init(goertzel_state_t *s, float freq, unsigned int sample_rate)
static const float mf_tones[]
static float dtmf_normal_twist
#define DSP_DIGITMODE_MUTEMAX
static int mf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax)
static float relax_dtmf_normal_twist
#define DSP_TONE_STATE_SPECIAL1
#define AST_TEST_UNREGISTER(cb)
int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf)
Scans for progress indication in audio.
#define DSP_FAXMODE_DETECT_CED
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_dsp * ast_dsp_new_with_rate(unsigned int sample_rate)
Allocates a new dsp with a specific internal sample rate used during processing.
int ast_dsp_silence_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence, int *frames_energy)
Process the audio frame for silence.
static void ast_fax_detect_init(struct ast_dsp *s)
unsigned int ast_dsp_get_sample_rate(const struct ast_dsp *dsp)
Retrieve the sample rate this DSP structure was created with.
#define ast_calloc(num, len)
A wrapper for calloc()
Module could not be loaded properly.
#define DSP_FEATURE_BUSY_DETECT
static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *totalsilence, int *totalnoise, int *frames_energy)
int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode)
Set fax mode.
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
#define DEFAULT_SAMPLE_RATE
int ast_dsp_get_tcount(struct ast_dsp *dsp)
Get tcount (Threshold counter)
tone_detect_state_t ced_tone_state
Structure used to handle boolean flags.
static int _dsp_init(int reload)
int ast_dsp_get_tstate(struct ast_dsp *dsp)
Get tstate (Tone State)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
#define CONFIG_STATUS_FILEMISSING
struct ast_dsp_busy_pattern busy_cadence
static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX]
static int tone_detect(struct ast_dsp *dsp, tone_detect_state_t *s, int16_t *amp, int samples)
static void goertzel_sample(goertzel_state_t *s, short sample)
#define BELL_MF_RELATIVE_PEAK
#define BELL_MF_THRESHOLD
const char * ast_channel_name(const struct ast_channel *chan)
int display_inband_dtmf_warning
tone_detect_state_t cng_tone_state
Data structure associated with a single frame of data.
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
#define AST_TEST_DEFINE(hdr)
int digitlen[MAX_DTMF_DIGITS+1]
static float goertzel_result(goertzel_state_t *s)
Options provided by main asterisk program.
void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, const struct ast_dsp_busy_pattern *cadence)
Set expected lengths of the busy tone.
#define DSP_FAXMODE_DETECT_CNG
enum ast_frame_type frametype
#define DSP_TONE_STATE_SILENCE
#define DSP_DIGITMODE_NOQUELCH
static void ast_mf_detect_init(mf_detect_state_t *s, unsigned int sample_rate)
struct ast_format * format
#define DSP_FEATURE_WAITDIALTONE
static float dtmf_reverse_twist
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define DEF_RELAX_DTMF_REVERSE_TWIST
static int pair_there(float p1, float p2, float i1, float i2, float e)
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
void ast_dsp_set_busy_count(struct ast_dsp *dsp, int cadences)
Set number of required cadences for busy.
static struct ast_dsp * __ast_dsp_new(unsigned int sample_rate)
goertzel_state_t row_out[4]
static int thresholds[THRESHOLD_MAX]