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 
  168#define DTMF_MATRIX_SIZE    4 
  182#define DTMF_THRESHOLD      8.0e7 
  183#define TONE_THRESHOLD      7.8e7 
  185#define DEF_DTMF_NORMAL_TWIST       6.31      
  186#define DEF_RELAX_DTMF_NORMAL_TWIST 6.31      
  189#define DEF_DTMF_REVERSE_TWIST      2.51      
  190#define DEF_RELAX_DTMF_REVERSE_TWIST    6.61      
  192#define DEF_DTMF_REVERSE_TWIST      2.51      
  193#define DEF_RELAX_DTMF_REVERSE_TWIST    3.98      
  196#define DTMF_RELATIVE_PEAK_ROW  6.3      
  197#define DTMF_RELATIVE_PEAK_COL  6.3      
  198#define DTMF_TO_TOTAL_ENERGY    42.0 
  200#define BELL_MF_THRESHOLD   1.6e9 
  201#define BELL_MF_TWIST       4.0      
  202#define BELL_MF_RELATIVE_PEAK   12.6     
  204#if defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE) 
  205#error You cant use BUSYDETECT_TONEONLY together with BUSYDETECT_COMPARE_TONE_AND_SILENCE 
  211#define FAX_TONE_CNG_FREQ   1100 
  212#define FAX_TONE_CNG_DURATION   500  
  213#define FAX_TONE_CNG_DB     16 
  219#define FAX_TONE_CED_FREQ   2100 
  220#define FAX_TONE_CED_DURATION   2600     
  221#define FAX_TONE_CED_DB     16 
  223#define DEFAULT_SAMPLE_RATE     8000 
  229#define DTMF_GSIZE      102 
  234#define DEF_DTMF_HITS_TO_BEGIN  2 
  239#define DEF_DTMF_MISSES_TO_END  3 
  247#define CONFIG_FILE_NAME "dsp.conf" 
  320    697.0,  770.0,  852.0,  941.0
 
 
  323    1209.0, 1336.0, 1477.0, 1633.0
 
 
  326    700.0, 900.0, 1100.0, 1300.0, 1500.0, 1700.0
 
 
  352    s->
v3 = (s->
fac * s->
v2) >> 15;
 
  356    if (
abs(s->
v3) > (1 << 15)) {
 
 
  375    return (
float)r.
value * (float)(1 << r.
power);
 
 
  381    s->
fac = (int)(32768.0 * 2.0 * 
cos(2.0 * 
M_PI * freq / sample_rate));
 
 
  454    int duration_samples;
 
  456    int periods_in_block;
 
  461    duration_samples = duration * sample_rate / 1000;
 
  463    duration_samples = duration_samples * 9 / 10;
 
  470    periods_in_block = s->
block_size * freq / sample_rate;
 
  475    if (periods_in_block < 5) {
 
  476        periods_in_block = 5;
 
  480    s->
block_size = periods_in_block * sample_rate / freq;
 
  507    x = pow(10.0, amp / 10.0);
 
 
  553    for (i = 0; i < 6; i++) {
 
 
  592    for (start = 0; start < samples; start = 
end) {
 
  594        limit = samples - start;
 
  600        for (i = limit, ptr = amp ; i > 0; i--, ptr++) {
 
  603            s->
energy += (int32_t) samp * (int32_t) samp;
 
  676        if (mute.
end > samples) {
 
 
  719    for (sample = 0; sample < samples; sample = limit) {
 
  728        for (j = sample; j < limit; j++) {
 
  754            if (row_energy[i] > row_energy[best_row]) {
 
  758            if (col_energy[i] > col_energy[best_col]) {
 
  762        ast_debug(10, 
"DTMF best '%c' Erow=%.4E Ecol=%.4E Erc=%.4E Et=%.4E\n",
 
  764            row_energy[best_row], col_energy[best_col],
 
  765            row_energy[best_row] + col_energy[best_col], s->
td.
dtmf.
energy);
 
  774                if ((i != best_col &&
 
  878        if (squelch && hit) {
 
  896    if (squelch && mute.
end) {
 
  897        if (mute.
end > samples) {
 
 
  908        int samples, 
int squelch, 
int relax)
 
  927    for (sample = 0; sample < samples; sample = limit) {
 
  937        for (j = sample; j < limit; j++) {
 
  961        if (energy[0] > energy[1]) {
 
  969        for (i = 2; i < 6; i++) {
 
  971            if (energy[i] >= energy[best]) {
 
  974            } 
else if (energy[i] >= energy[second_best]) {
 
  985            for (i = 0; i < 6; i++) {
 
  986                if (i != best && i != second_best) {
 
  997            if (second_best < best) {
 
 1002            best = best * 5 + second_best - 1;
 
 1031        if (squelch && hit) {
 
 1041        for (i = 0; i < 6; i++) {
 
 1047    if (squelch && mute.
end) {
 
 1048        if (mute.
end > samples) {
 
 
 1058static inline int pair_there(
float p1, 
float p2, 
float i1, 
float i2, 
float e)
 
 1070    if ((p1 < i1) || (p1 < i2) || (p1 < e)) {
 
 1074    if ((p2 < i1) || (p2 < i2) || (p2 < e)) {
 
 
 1097        for (x = 0; x < 
pass; x++) {
 
 1099            dsp->
genergy += (int32_t) samp * (int32_t) samp;
 
 1100            for (y = 0; y < freqcount; y++) {
 
 1157            if (newstate == dsp->
tstate) {
 
 1174                        dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
 
 1181                        dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
 
 1188                        dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
 
 1195                        dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
 
 1200                    ast_debug(1, 
"Consider call as answered because of timeout after last ring\n");
 
 1202                    dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
 
 1206                ast_debug(5, 
"Start state %d\n", newstate);
 
 1212            for (x = 0; x < 7; x++) {
 
 
 1230        ast_log(
LOG_WARNING, 
"Can only check call progress in signed-linear frames, %s not supported\n",
 
 
 1247    for (x = 0; x < 
len; x++) {
 
 1275            if (silence1 < silence2) {
 
 1276                if (silence1 + silence1 * 
BUSY_PERCENT / 100 >= silence2) {
 
 1282                if (silence1 - silence1 * 
BUSY_PERCENT / 100 <= silence2) {
 
 1297    if (frames_energy) {
 
 1298        *frames_energy = accum;
 
 
 1306#ifndef BUSYDETECT_TONEONLY 
 1307    int avgsilence = 0, hitsilence = 0;
 
 1309    int avgtone = 0, hittone = 0;
 
 1319#ifndef BUSYDETECT_TONEONLY 
 1324#ifndef BUSYDETECT_TONEONLY 
 1329#ifndef BUSYDETECT_TONEONLY 
 1350#ifndef BUSYDETECT_TONEONLY 
 1358#ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE 
 1359        if (avgtone > avgsilence) {
 
 1360            if (avgtone - avgtone*
BUSY_PERCENT/100 <= avgsilence) {
 
 1364            if (avgtone + avgtone*
BUSY_PERCENT/100 >= avgsilence) {
 
 1402        ast_debug(5, 
"errors = %d  max = %d\n", errors, errors_max);
 
 1404        if (errors <= errors_max) {
 
 1412#ifdef BUSYDETECT_DEBUG 
 1413            ast_debug(5, 
"busy detector: avgtone of %d not close enough to desired %d\n",
 
 1419#ifndef BUSYDETECT_TONEONLY 
 1423#ifdef BUSYDETECT_DEBUG 
 1424        ast_debug(5, 
"busy detector: avgsilence of %d not close enough to desired %d\n",
 
 1431#if !defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_DEBUG) 
 1433        ast_debug(5, 
"ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
 
 1435        ast_debug(5, 
"busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
 
 
 1446    unsigned char *odata;
 
 1465            for (x = 0; x < 
len; x++) {
 
 1470            for (x = 0; x < 
len; x++) {
 
 1474            ast_log(
LOG_WARNING, 
"Can only calculate silence on signed-linear, alaw or ulaw frames, %s not supported\n",
 
 
 1507    int digit = 0, fax_digit = 0, custom_freq_digit = 0;
 
 1510    unsigned char *odata;
 
 1529        for (x = 0; x < 
len; x++) {
 
 1534        for (x = 0; x < 
len; x++) {
 
 1546                ast_log(
LOG_WARNING, 
"Can only do DSP on signed-linear, alaw or ulaw frames (%s not supported)\n",
 
 1563        memset(&dsp->
f, 0, 
sizeof(dsp->
f));
 
 1570        memset(&dsp->
f, 0, 
sizeof(dsp->
f));
 
 1590            custom_freq_digit = 
'q';
 
 1602            int event = 0, event_len = 0;
 
 1603            char event_digit = 0;
 
 1630                    ast_debug(1, 
"DTMF Detected - Reset busydetector\n");
 
 1635                memset(&dsp->
f, 0, 
sizeof(dsp->
f));
 
 1638                dsp->
f.
len = event_len;
 
 1648        memset(&dsp->
f, 0, 
sizeof(dsp->
f));
 
 1655    if (custom_freq_digit) {
 
 1658        memset(&dsp->
f, 0, 
sizeof(dsp->
f));
 
 1674                memset(&dsp->
f, 0, 
sizeof(dsp->
f));
 
 1677                dsp->
f.
src = 
"dsp_progress";
 
 1697        for (x = 0; x < 
len; x++) {
 
 1698            odata[x] = 
AST_LIN2MU((
unsigned short) shortdata[x]);
 
 1701        for (x = 0; x < 
len; x++) {
 
 1702            odata[x] = 
AST_LIN2A((
unsigned short) shortdata[x]);
 
 
 1822        for (i = 0; i < 6; i++) {
 
 1831        for (i = 0; i < 4; i++) {
 
 
 1853    for (x = 0; x < 4; x++) {
 
 
 1950        if (!strcasecmp(v->
name, 
"silencethreshold")) {
 
 1951            if (sscanf(v->
value, 
"%30d", &cfg_threshold) < 1) {
 
 1953            } 
else if (cfg_threshold < 0) {
 
 1954                ast_log(
LOG_WARNING, 
"Invalid silence threshold '%d' specified, using default\n", cfg_threshold);
 
 1958        } 
else if (!strcasecmp(v->
name, 
"dtmf_normal_twist")) {
 
 1959            if (sscanf(v->
value, 
"%30f", &cfg_twist) < 1) {
 
 1961            } 
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {      
 
 1966        } 
else if (!strcasecmp(v->
name, 
"dtmf_reverse_twist")) {
 
 1967            if (sscanf(v->
value, 
"%30f", &cfg_twist) < 1) {
 
 1969            } 
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {      
 
 1974        } 
else if (!strcasecmp(v->
name, 
"relax_dtmf_normal_twist")) {
 
 1975            if (sscanf(v->
value, 
"%30f", &cfg_twist) < 1) {
 
 1977            } 
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {      
 
 1982        } 
else if (!strcasecmp(v->
name, 
"relax_dtmf_reverse_twist")) {
 
 1983            if (sscanf(v->
value, 
"%30f", &cfg_twist) < 1) {
 
 1985            } 
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {      
 
 1990        } 
else if (!strcasecmp(v->
name, 
"dtmf_hits_to_begin")) {
 
 1991            if (sscanf(v->
value, 
"%30d", &cfg_threshold) < 1) {
 
 1993            } 
else if (cfg_threshold < 1) {     
 
 1998        } 
else if (!strcasecmp(v->
name, 
"dtmf_misses_to_end")) {
 
 1999            if (sscanf(v->
value, 
"%30d", &cfg_threshold) < 1) {
 
 2001            } 
else if (cfg_threshold < 1) {     
 
 
 2018#ifdef TEST_FRAMEWORK 
 2019static void test_tone_sample_gen(
short *slin_buf, 
int samples, 
int rate, 
int freq, 
short amplitude)
 
 2022    double sample_step = 2.0 * 
M_PI * freq / rate;
 
 2024    for (idx = 0; idx < samples; ++idx) {
 
 2025        slin_buf[idx] = amplitude * sin(sample_step * idx);
 
 2030#ifdef TEST_FRAMEWORK 
 2031static void test_tone_sample_gen_add(
short *slin_buf, 
int samples, 
int rate, 
int freq, 
short amplitude)
 
 2034    double sample_step = 2.0 * 
M_PI * freq / rate;
 
 2036    for (idx = 0; idx < samples; ++idx) {
 
 2037        slin_buf[idx] += amplitude * sin(sample_step * idx);
 
 2042#ifdef TEST_FRAMEWORK 
 2043static void test_dual_sample_gen(
short *slin_buf, 
int samples, 
int rate, 
int f1, 
short a1, 
int f2, 
short a2)
 
 2045    test_tone_sample_gen(slin_buf, samples, rate, f1, a1);
 
 2046    test_tone_sample_gen_add(slin_buf, samples, rate, f2, a2);
 
 2050#ifdef TEST_FRAMEWORK 
 2051#define TONE_AMPLITUDE_MAX  0x7fff   
 2052#define TONE_AMPLITUDE_MIN  80       
 2063        { .amp_val = TONE_AMPLITUDE_MAX,    .detect = 1, },
 
 2064        { .amp_val = 10000,                 .detect = 1, },
 
 2065        { .amp_val = 1000,                  .detect = 1, },
 
 2066        { .amp_val = 100,                   .detect = 1, },
 
 2067        { .amp_val = TONE_AMPLITUDE_MIN,    .detect = 1, },
 
 2068        { .amp_val = 75,                    .detect = 0, },
 
 2069        { .amp_val = 10,                    .detect = 0, },
 
 2070        { .amp_val = 1,                     .detect = 0, },
 
 2075    for (idx = 0; idx < 
ARRAY_LEN(amp_tests); ++idx) {
 
 2079        ast_debug(1, 
"Test %d Hz at amplitude %d\n",
 
 2080            tone_state->
freq, amp_tests[idx].amp_val);
 
 2082            tone_state->
freq, amp_tests[idx].amp_val);
 
 2085        for (duration = 0; !detected && duration < tone_state->
hits_required + 3; ++duration) {
 
 2088        if (amp_tests[idx].detect != detected) {
 
 2096                "Test %d Hz at amplitude %d failed.  Detected: %s\n",
 
 2097                tone_state->
freq, amp_tests[idx].amp_val,
 
 2098                detected ? 
"yes" : 
"no");
 
 2100                "Test %d Hz at amplitude %d failed.  Detected: %s\n",
 
 2101                tone_state->
freq, amp_tests[idx].amp_val,
 
 2102                detected ? 
"yes" : 
"no");
 
 2112#ifdef TEST_FRAMEWORK 
 2113static int test_dtmf_amplitude_sweep(
struct ast_test *
test, 
struct ast_dsp *dsp, 
int digit_index)
 
 2128        { .amp_val = TONE_AMPLITUDE_MAX/2,  .digit = 
dtmf_positions[digit_index], },
 
 2136        { .amp_val = 170,                   .digit = 0, },
 
 2137        { .amp_val = 100,                   .digit = 0, },
 
 2142        { .amp_val = TONE_AMPLITUDE_MIN,    .digit = 0, },
 
 2143        { .amp_val = 75,                    .digit = 0, },
 
 2144        { .amp_val = 10,                    .digit = 0, },
 
 2145        { .amp_val = 1,                     .digit = 0, },
 
 2148    row = (digit_index >> 2) & 0x03;
 
 2149    column = digit_index & 0x03;
 
 2153    for (idx = 0; idx < 
ARRAY_LEN(amp_tests); ++idx) {
 
 2157        ast_debug(1, 
"Test '%c' at amplitude %d\n",
 
 2160            (
int) 
dtmf_row[row], amp_tests[idx].amp_val,
 
 2161            (
int) 
dtmf_col[column], amp_tests[idx].amp_val);
 
 2164        for (duration = 0; !
digit && duration < 3; ++duration) {
 
 2176                "Test '%c' at amplitude %d failed.  Detected Digit: '%c'\n",
 
 2180                "Test '%c' at amplitude %d failed.  Detected Digit: '%c'\n",
 
 2192#ifdef TEST_FRAMEWORK 
 2193static int test_dtmf_twist_sweep(
struct ast_test *
test, 
struct ast_dsp *dsp, 
int digit_index)
 
 2212        { .amp_row = 1000 + 1800, .amp_col = 1000 +    0, .digit = 0, },
 
 2213        { .amp_row = 1000 + 1700, .amp_col = 1000 +    0, .digit = 0, },
 
 2215        { .amp_row = 1000 + 1400, .amp_col = 1000 +    0, .digit = 
dtmf_positions[digit_index], },
 
 2216        { .amp_row = 1000 + 1300, .amp_col = 1000 +    0, .digit = 
dtmf_positions[digit_index], },
 
 2217        { .amp_row = 1000 + 1200, .amp_col = 1000 +    0, .digit = 
dtmf_positions[digit_index], },
 
 2218        { .amp_row = 1000 + 1100, .amp_col = 1000 +    0, .digit = 
dtmf_positions[digit_index], },
 
 2219        { .amp_row = 1000 + 1000, .amp_col = 1000 +    0, .digit = 
dtmf_positions[digit_index], },
 
 2220        { .amp_row = 1000 +  100, .amp_col = 1000 +    0, .digit = 
dtmf_positions[digit_index], },
 
 2221        { .amp_row = 1000 +    0, .amp_col = 1000 +  100, .digit = 
dtmf_positions[digit_index], },
 
 2222        { .amp_row = 1000 +    0, .amp_col = 1000 +  200, .digit = 
dtmf_positions[digit_index], },
 
 2223        { .amp_row = 1000 +    0, .amp_col = 1000 +  300, .digit = 
dtmf_positions[digit_index], },
 
 2224        { .amp_row = 1000 +    0, .amp_col = 1000 +  400, .digit = 
dtmf_positions[digit_index], },
 
 2225        { .amp_row = 1000 +    0, .amp_col = 1000 +  500, .digit = 
dtmf_positions[digit_index], },
 
 2226        { .amp_row = 1000 +    0, .amp_col = 1000 +  550, .digit = 
dtmf_positions[digit_index], },
 
 2228        { .amp_row = 1000 +    0, .amp_col = 1000 +  650, .digit = 0, },
 
 2229        { .amp_row = 1000 +    0, .amp_col = 1000 +  700, .digit = 0, },
 
 2230        { .amp_row = 1000 +    0, .amp_col = 1000 +  800, .digit = 0, },
 
 2232    float save_normal_twist;
 
 2233    float save_reverse_twist;
 
 2240    row = (digit_index >> 2) & 0x03;
 
 2241    column = digit_index & 0x03;
 
 2245    for (idx = 0; idx < 
ARRAY_LEN(twist_tests); ++idx) {
 
 2249        ast_debug(1, 
"Test '%c' twist row %d col %d amplitudes\n",
 
 2251            twist_tests[idx].amp_row, twist_tests[idx].amp_col);
 
 2253            (
int) 
dtmf_row[row], twist_tests[idx].amp_row,
 
 2254            (
int) 
dtmf_col[column], twist_tests[idx].amp_col);
 
 2257        for (duration = 0; !
digit && duration < 3; ++duration) {
 
 2269                "Test '%c' twist row %d col %d amplitudes failed.  Detected Digit: '%c'\n",
 
 2271                twist_tests[idx].amp_row, twist_tests[idx].amp_col,
 
 2274                "Test '%c' twist row %d col %d amplitudes failed.  Detected Digit: '%c'\n",
 
 2276                twist_tests[idx].amp_row, twist_tests[idx].amp_col,
 
 2290#ifdef TEST_FRAMEWORK 
 2300    lower_freq = tone_state->
freq - 4;
 
 2301    upper_freq = tone_state->
freq + 4;
 
 2306    for (freq = 100; freq <= 3500; freq += 1) {
 
 2309        int expect_detection;
 
 2311        if (freq == tone_state->
freq) {
 
 2316        expect_detection = (lower_freq <= freq && freq <= upper_freq) ? 1 : 0;
 
 2318        ast_debug(1, 
"Test %d Hz detection given %d Hz tone at amplitude %d.  Range:%d-%d Expect detect: %s\n",
 
 2319            tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
 
 2320            expect_detection ? 
"yes" : 
"no");
 
 2325        for (duration = 0; !detected && duration < tone_state->
hits_required + 3; ++duration) {
 
 2328        if (expect_detection != detected) {
 
 2336                "Test %d Hz detection given %d Hz tone at amplitude %d failed.  Range:%d-%d Detected: %s\n",
 
 2337                tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
 
 2338                detected ? 
"yes" : 
"no");
 
 2340                "Test %d Hz detection given %d Hz tone at amplitude %d failed.  Range:%d-%d Detected: %s\n",
 
 2341                tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
 
 2342                detected ? 
"yes" : 
"no");
 
 2352#ifdef TEST_FRAMEWORK 
 2361        info->category = 
"/main/dsp/";
 
 2362        info->summary = 
"DSP fax tone detect unit test";
 
 2364            "Tests fax tone detection code.";
 
 2408#ifdef TEST_FRAMEWORK 
 2417        info->name = 
"dtmf";
 
 2418        info->category = 
"/main/dsp/";
 
 2419        info->summary = 
"DSP DTMF detect unit test";
 
 2421            "Tests DTMF detection code.";
 
 2435        if (test_dtmf_amplitude_sweep(
test, dsp, idx)) {
 
 2441        if (test_dtmf_twist_sweep(
test, dsp, idx)) {
 
 2482    .
requires = 
"extconfig",
 
A-Law to Signed linear conversion.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_calloc(num, len)
A wrapper for calloc()
static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX]
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
static void ast_mf_detect_init(mf_detect_state_t *s, unsigned int sample_rate)
static int thresholds[THRESHOLD_MAX]
#define DEF_DTMF_HITS_TO_BEGIN
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set the minimum average magnitude threshold to determine talking by the DSP.
#define BELL_MF_THRESHOLD
void ast_dsp_free(struct ast_dsp *dsp)
int ast_dsp_get_tcount(struct ast_dsp *dsp)
Get tcount (Threshold counter)
#define DEFAULT_THRESHOLD
Default minimum average magnitude threshold to determine talking/noise by the DSP.
#define DEF_DTMF_REVERSE_TWIST
static void ast_tone_detect_init(tone_detect_state_t *s, int freq, int duration, int amp, unsigned int sample_rate)
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 DTMF_TO_TOTAL_ENERGY
#define BELL_MF_RELATIVE_PEAK
#define DEF_DTMF_MISSES_TO_END
static const int DEFAULT_SILENCE_THRESHOLD
The default silence threshold we will use if an alternate configured value is not present or is inval...
static const char dtmf_positions[]
static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
static void goertzel_init(goertzel_state_t *s, float freq, unsigned int sample_rate)
static struct progalias aliases[]
static int _dsp_init(int reload)
static int tone_detect(struct ast_dsp *dsp, tone_detect_state_t *s, int16_t *amp, int samples)
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Process the audio frame for silence.
#define FAX_TONE_CNG_FREQ
void ast_dsp_digitreset(struct ast_dsp *dsp)
Reset DTMF detector.
#define DEF_RELAX_DTMF_NORMAL_TWIST
static int mf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax)
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.
#define FAX_TONE_CED_DURATION
static const char bell_mf_positions[]
static void ast_fax_detect_init(struct ast_dsp *s)
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.
#define DEF_DTMF_NORMAL_TWIST
static float goertzel_result(goertzel_state_t *s)
int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf)
Scans for progress indication in audio.
void ast_dsp_reset(struct ast_dsp *dsp)
Reset total silence count.
static void ast_freq_detect_init(struct ast_dsp *s, int freq, int dur, int db, int squelch)
void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, const struct ast_dsp_busy_pattern *cadence)
Set expected lengths of the busy tone.
unsigned int ast_dsp_get_sample_rate(const struct ast_dsp *dsp)
Retrieve the sample rate this DSP structure was created with.
#define FAX_TONE_CED_FREQ
static int reload_module(void)
#define DTMF_RELATIVE_PEAK_COL
static struct progress modes[]
static const float dtmf_row[]
static void goertzel_sample(goertzel_state_t *s, short sample)
#define DEF_RELAX_DTMF_REVERSE_TWIST
static int pair_there(float p1, float p2, float i1, float i2, float e)
static const float mf_tones[]
static float dtmf_reverse_twist
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
static int dtmf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax)
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
static void goertzel_reset(goertzel_state_t *s)
static int ast_dsp_silence_noise_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *total, int *frames_energy, int noise)
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
static void ast_dtmf_detect_init(dtmf_detect_state_t *s, unsigned int sample_rate)
static void mute_fragment(struct ast_dsp *dsp, fragment_t *fragment)
#define DTMF_RELATIVE_PEAK_ROW
static int dtmf_misses_to_end
static int dtmf_hits_to_begin
#define DEFAULT_SAMPLE_RATE
static int load_module(void)
int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
Process the audio frame for noise.
int ast_dsp_get_tstate(struct ast_dsp *dsp)
Get tstate (Tone State)
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 int unload_module(void)
static float relax_dtmf_normal_twist
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 store_digit(digit_detect_state_t *s, char digit)
int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode)
Set fax mode.
static void ast_digit_detect_init(digit_detect_state_t *s, int mf, unsigned int sample_rate)
static const float dtmf_col[]
#define FAX_TONE_CNG_DURATION
int ast_dsp_set_freqmode(struct ast_dsp *dsp, int freq, int dur, int db, int squelch)
Set arbitrary frequency detection mode.
static struct ast_dsp * __ast_dsp_new(unsigned int sample_rate)
void ast_dsp_set_busy_count(struct ast_dsp *dsp, int cadences)
Set number of required cadences for busy.
static float dtmf_normal_twist
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
static float relax_dtmf_reverse_twist
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
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_call_progress_zone(struct ast_dsp *dsp, char *zone)
Set zone for doing progress detection.
static void ast_dsp_prog_reset(struct ast_dsp *dsp)
Convenient Signal Processing routines.
#define DSP_PROGRESS_RINGING
#define DSP_TONE_STATE_SPECIAL3
#define DSP_FEATURE_WAITDIALTONE
#define DSP_TONE_STATE_SPECIAL2
#define DSP_FEATURE_BUSY_DETECT
#define DSP_TONE_STATE_DIALTONE
#define DSP_PROGRESS_TALK
#define DSP_TONE_STATE_SILENCE
#define DSP_DIGITMODE_NOQUELCH
#define DSP_TONE_STATE_BUSY
#define DSP_DIGITMODE_MUTEMAX
#define DSP_FEATURE_DIGIT_DETECT
#define DSP_PROGRESS_BUSY
#define DSP_FEATURE_FAX_DETECT
#define DSP_TONE_STATE_SPECIAL1
#define DSP_FAXMODE_DETECT_SQUELCH
#define DSP_FAXMODE_DETECT_CED
#define DSP_PROGRESS_CONGESTION
#define DSP_FEATURE_CALL_PROGRESS
#define DSP_DIGITMODE_MUTECONF
#define DSP_FAXMODE_DETECT_CNG
#define DSP_FEATURE_SILENCE_SUPPRESS
#define DSP_TONE_STATE_HUNGUP
#define DSP_FEATURE_FREQ_DETECT
#define DSP_TONE_STATE_TALKING
#define DSP_TONE_STATE_RINGING
#define DSP_DIGITMODE_DTMF
#define DSP_DIGITMODE_RELAXDTMF
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Configuration File Parser.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
#define CONFIG_STATUS_FILEMISSING
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
@ CONFIG_FLAG_FILEUNCHANGED
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Asterisk internal frame definitions.
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_FAILURE
Module could not be loaded properly.
@ AST_MODULE_LOAD_SUCCESS
Options provided by main asterisk program.
Main Channel structure associated with a channel.
int historicnoise[DSP_HISTORY]
goertzel_state_t freqs[FREQ_ARRAY_SIZE]
digit_detect_state_t digit_state
tone_detect_state_t ced_tone_state
int historicsilence[DSP_HISTORY]
enum gsamp_size gsamp_size
int display_inband_dtmf_warning
struct ast_dsp_busy_pattern busy_cadence
tone_detect_state_t cng_tone_state
Structure used to handle boolean flags.
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
union ast_frame::@239 data
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
int digitlen[MAX_DTMF_DIGITS+1]
char digits[MAX_DTMF_DIGITS+1]
union digit_detect_state_t::@372 td
goertzel_state_t row_out[DTMF_MATRIX_SIZE]
goertzel_state_t col_out[DTMF_MATRIX_SIZE]
goertzel_state_t tone_out[6]
int freqs[FREQ_ARRAY_SIZE]
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
u-Law to Signed linear conversion