Asterisk - The Open Source Telephony Project GIT-master-0deac78
Data Structures | Macros | Enumerations | Functions
dsp.h File Reference

Convenient Signal Processing routines. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_dsp_busy_pattern
 

Macros

#define DSP_DIGITMODE_DTMF   0
 
#define DSP_DIGITMODE_MF   1
 
#define DSP_DIGITMODE_MUTECONF   (1 << 9)
 
#define DSP_DIGITMODE_MUTEMAX   (1 << 10)
 
#define DSP_DIGITMODE_NOQUELCH   (1 << 8)
 
#define DSP_DIGITMODE_RELAXDTMF   (1 << 11)
 
#define DSP_FAXMODE_DETECT_ALL   (DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED)
 
#define DSP_FAXMODE_DETECT_CED   (1 << 1)
 
#define DSP_FAXMODE_DETECT_CNG   (1 << 0)
 
#define DSP_FAXMODE_DETECT_SQUELCH   (1 << 2)
 
#define DSP_FEATURE_BUSY_DETECT   (1 << 1)
 
#define DSP_FEATURE_CALL_PROGRESS   (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION)
 
#define DSP_FEATURE_DIGIT_DETECT   (1 << 3)
 
#define DSP_FEATURE_FAX_DETECT   (1 << 4)
 
#define DSP_FEATURE_FREQ_DETECT   (1 << 21)
 
#define DSP_FEATURE_SILENCE_SUPPRESS   (1 << 0)
 
#define DSP_FEATURE_WAITDIALTONE   (1 << 20)
 
#define DSP_PROGRESS_BUSY   (1 << 18)
 
#define DSP_PROGRESS_CONGESTION   (1 << 19)
 
#define DSP_PROGRESS_RINGING   (1 << 17)
 
#define DSP_PROGRESS_TALK   (1 << 16)
 
#define DSP_TONE_STATE_BUSY   4
 
#define DSP_TONE_STATE_DIALTONE   2
 
#define DSP_TONE_STATE_HUNGUP   8
 
#define DSP_TONE_STATE_RINGING   1
 
#define DSP_TONE_STATE_SILENCE   0
 
#define DSP_TONE_STATE_SPECIAL1   5
 
#define DSP_TONE_STATE_SPECIAL2   6
 
#define DSP_TONE_STATE_SPECIAL3   7
 
#define DSP_TONE_STATE_TALKING   3
 

Enumerations

enum  threshold { THRESHOLD_SILENCE = 0 , THRESHOLD_MAX = 1 }
 

Functions

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 called. More...
 
int ast_dsp_call_progress (struct ast_dsp *dsp, struct ast_frame *inf)
 Scans for progress indication in audio. More...
 
int ast_dsp_digitdetect (struct ast_dsp *dsp, struct ast_frame *f)
 Return non-zero if DTMF hit was found. More...
 
void ast_dsp_digitreset (struct ast_dsp *dsp)
 Reset DTMF detector. More...
 
void ast_dsp_free (struct ast_dsp *dsp)
 
int ast_dsp_get_features (struct ast_dsp *dsp)
 Get features. More...
 
unsigned int ast_dsp_get_sample_rate (const struct ast_dsp *dsp)
 Retrieve the sample rate this DSP structure was created with. More...
 
int ast_dsp_get_tcount (struct ast_dsp *dsp)
 Get tcount (Threshold counter) More...
 
int ast_dsp_get_threshold_from_settings (enum threshold which)
 Get silence threshold from dsp.conf. More...
 
int ast_dsp_get_tstate (struct ast_dsp *dsp)
 Get tstate (Tone State) More...
 
int ast_dsp_getdigits (struct ast_dsp *dsp, char *buf, int max)
 Get pending DTMF/MF digits. More...
 
struct ast_dspast_dsp_new (void)
 Allocates a new dsp, assumes 8khz for internal sample rate. More...
 
struct ast_dspast_dsp_new_with_rate (unsigned int sample_rate)
 Allocates a new dsp with a specific internal sample rate used during processing. More...
 
int ast_dsp_noise (struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
 Process the audio frame for noise. More...
 
struct ast_frameast_dsp_process (struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf)
 Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress, all dependent upon which features are enabled. More...
 
void ast_dsp_reset (struct ast_dsp *dsp)
 Reset total silence count. More...
 
void ast_dsp_set_busy_count (struct ast_dsp *dsp, int cadences)
 Set number of required cadences for busy. More...
 
void ast_dsp_set_busy_pattern (struct ast_dsp *dsp, const struct ast_dsp_busy_pattern *cadence)
 Set expected lengths of the busy tone. More...
 
int ast_dsp_set_call_progress_zone (struct ast_dsp *dsp, char *zone)
 Set zone for doing progress detection. More...
 
int ast_dsp_set_digitmode (struct ast_dsp *dsp, int digitmode)
 Set digit mode. More...
 
int ast_dsp_set_faxmode (struct ast_dsp *dsp, int faxmode)
 Set fax mode. More...
 
void ast_dsp_set_features (struct ast_dsp *dsp, int features)
 Select feature set. More...
 
int ast_dsp_set_freqmode (struct ast_dsp *dsp, int freq, int dur, int db, int squelch)
 Set arbitrary frequency detection mode. More...
 
void ast_dsp_set_threshold (struct ast_dsp *dsp, int threshold)
 Set the minimum average magnitude threshold to determine talking by the DSP. More...
 
int ast_dsp_silence (struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
 Process the audio frame for silence. More...
 
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. More...
 
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) happens when DSP code removes DTMF/MF/generic tones from the audio. More...
 

Detailed Description

Convenient Signal Processing routines.

Definition in file dsp.h.

Macro Definition Documentation

◆ DSP_DIGITMODE_DTMF

#define DSP_DIGITMODE_DTMF   0

Detect DTMF digits

Definition at line 31 of file dsp.h.

◆ DSP_DIGITMODE_MF

#define DSP_DIGITMODE_MF   1

Detect MF digits

Definition at line 32 of file dsp.h.

◆ DSP_DIGITMODE_MUTECONF

#define DSP_DIGITMODE_MUTECONF   (1 << 9)

Mute conference

Definition at line 35 of file dsp.h.

◆ DSP_DIGITMODE_MUTEMAX

#define DSP_DIGITMODE_MUTEMAX   (1 << 10)

Delay audio by a frame to try to extra quelch

Definition at line 36 of file dsp.h.

◆ DSP_DIGITMODE_NOQUELCH

#define DSP_DIGITMODE_NOQUELCH   (1 << 8)

Do not quelch DTMF from in-band

Definition at line 34 of file dsp.h.

◆ DSP_DIGITMODE_RELAXDTMF

#define DSP_DIGITMODE_RELAXDTMF   (1 << 11)

"Radio" mode (relaxed DTMF)

Definition at line 37 of file dsp.h.

◆ DSP_FAXMODE_DETECT_ALL

#define DSP_FAXMODE_DETECT_ALL   (DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED)

Definition at line 50 of file dsp.h.

◆ DSP_FAXMODE_DETECT_CED

#define DSP_FAXMODE_DETECT_CED   (1 << 1)

Definition at line 48 of file dsp.h.

◆ DSP_FAXMODE_DETECT_CNG

#define DSP_FAXMODE_DETECT_CNG   (1 << 0)

Definition at line 47 of file dsp.h.

◆ DSP_FAXMODE_DETECT_SQUELCH

#define DSP_FAXMODE_DETECT_SQUELCH   (1 << 2)

Definition at line 49 of file dsp.h.

◆ DSP_FEATURE_BUSY_DETECT

#define DSP_FEATURE_BUSY_DETECT   (1 << 1)

Definition at line 27 of file dsp.h.

◆ DSP_FEATURE_CALL_PROGRESS

#define DSP_FEATURE_CALL_PROGRESS   (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION)

Definition at line 43 of file dsp.h.

◆ DSP_FEATURE_DIGIT_DETECT

#define DSP_FEATURE_DIGIT_DETECT   (1 << 3)

Definition at line 28 of file dsp.h.

◆ DSP_FEATURE_FAX_DETECT

#define DSP_FEATURE_FAX_DETECT   (1 << 4)

Definition at line 29 of file dsp.h.

◆ DSP_FEATURE_FREQ_DETECT

#define DSP_FEATURE_FREQ_DETECT   (1 << 21)

Enable arbitrary tone detection

Definition at line 45 of file dsp.h.

◆ DSP_FEATURE_SILENCE_SUPPRESS

#define DSP_FEATURE_SILENCE_SUPPRESS   (1 << 0)

Definition at line 26 of file dsp.h.

◆ DSP_FEATURE_WAITDIALTONE

#define DSP_FEATURE_WAITDIALTONE   (1 << 20)

Enable dial tone detection

Definition at line 44 of file dsp.h.

◆ DSP_PROGRESS_BUSY

#define DSP_PROGRESS_BUSY   (1 << 18)

Enable busy tone detection

Definition at line 41 of file dsp.h.

◆ DSP_PROGRESS_CONGESTION

#define DSP_PROGRESS_CONGESTION   (1 << 19)

Enable congestion tone detection

Definition at line 42 of file dsp.h.

◆ DSP_PROGRESS_RINGING

#define DSP_PROGRESS_RINGING   (1 << 17)

Enable calling tone detection

Definition at line 40 of file dsp.h.

◆ DSP_PROGRESS_TALK

#define DSP_PROGRESS_TALK   (1 << 16)

Enable talk detection

Definition at line 39 of file dsp.h.

◆ DSP_TONE_STATE_BUSY

#define DSP_TONE_STATE_BUSY   4

Definition at line 56 of file dsp.h.

◆ DSP_TONE_STATE_DIALTONE

#define DSP_TONE_STATE_DIALTONE   2

Definition at line 54 of file dsp.h.

◆ DSP_TONE_STATE_HUNGUP

#define DSP_TONE_STATE_HUNGUP   8

Definition at line 60 of file dsp.h.

◆ DSP_TONE_STATE_RINGING

#define DSP_TONE_STATE_RINGING   1

Definition at line 53 of file dsp.h.

◆ DSP_TONE_STATE_SILENCE

#define DSP_TONE_STATE_SILENCE   0

Definition at line 52 of file dsp.h.

◆ DSP_TONE_STATE_SPECIAL1

#define DSP_TONE_STATE_SPECIAL1   5

Definition at line 57 of file dsp.h.

◆ DSP_TONE_STATE_SPECIAL2

#define DSP_TONE_STATE_SPECIAL2   6

Definition at line 58 of file dsp.h.

◆ DSP_TONE_STATE_SPECIAL3

#define DSP_TONE_STATE_SPECIAL3   7

Definition at line 59 of file dsp.h.

◆ DSP_TONE_STATE_TALKING

#define DSP_TONE_STATE_TALKING   3

Definition at line 55 of file dsp.h.

Enumeration Type Documentation

◆ threshold

enum threshold
Enumerator
THRESHOLD_SILENCE 
THRESHOLD_MAX 

Definition at line 71 of file dsp.h.

71 {
72 /* Array offsets */
74 /* Always the last */
75 THRESHOLD_MAX = 1,
76};
@ THRESHOLD_SILENCE
Definition: dsp.h:73
@ THRESHOLD_MAX
Definition: dsp.h:75

Function Documentation

◆ ast_dsp_busydetect()

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 called.

Definition at line 1301 of file dsp.c.

1302{
1303 int res = 0, x;
1304#ifndef BUSYDETECT_TONEONLY
1305 int avgsilence = 0, hitsilence = 0;
1306#endif
1307 int avgtone = 0, hittone = 0;
1308
1309 /* if we have a 4 length pattern, the way busymaybe is set doesn't help us. */
1310 if (dsp->busy_cadence.length != 4) {
1311 if (!dsp->busymaybe) {
1312 return res;
1313 }
1314 }
1315
1316 for (x = DSP_HISTORY - dsp->busycount; x < DSP_HISTORY; x++) {
1317#ifndef BUSYDETECT_TONEONLY
1318 avgsilence += dsp->historicsilence[x];
1319#endif
1320 avgtone += dsp->historicnoise[x];
1321 }
1322#ifndef BUSYDETECT_TONEONLY
1323 avgsilence /= dsp->busycount;
1324#endif
1325 avgtone /= dsp->busycount;
1326 for (x = DSP_HISTORY - dsp->busycount; x < DSP_HISTORY; x++) {
1327#ifndef BUSYDETECT_TONEONLY
1328 if (avgsilence > dsp->historicsilence[x]) {
1329 if (avgsilence - (avgsilence * BUSY_PERCENT / 100) <= dsp->historicsilence[x]) {
1330 hitsilence++;
1331 }
1332 } else {
1333 if (avgsilence + (avgsilence * BUSY_PERCENT / 100) >= dsp->historicsilence[x]) {
1334 hitsilence++;
1335 }
1336 }
1337#endif
1338 if (avgtone > dsp->historicnoise[x]) {
1339 if (avgtone - (avgtone * BUSY_PERCENT / 100) <= dsp->historicnoise[x]) {
1340 hittone++;
1341 }
1342 } else {
1343 if (avgtone + (avgtone * BUSY_PERCENT / 100) >= dsp->historicnoise[x]) {
1344 hittone++;
1345 }
1346 }
1347 }
1348#ifndef BUSYDETECT_TONEONLY
1349 if ((hittone >= dsp->busycount - 1) && (hitsilence >= dsp->busycount - 1) &&
1350 (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX) &&
1351 (avgsilence >= BUSY_MIN && avgsilence <= BUSY_MAX))
1352#else
1353 if ((hittone >= dsp->busycount - 1) && (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX))
1354#endif
1355 {
1356#ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE
1357 if (avgtone > avgsilence) {
1358 if (avgtone - avgtone*BUSY_PERCENT/100 <= avgsilence) {
1359 res = 1;
1360 }
1361 } else {
1362 if (avgtone + avgtone*BUSY_PERCENT/100 >= avgsilence) {
1363 res = 1;
1364 }
1365 }
1366#else
1367 res = 1;
1368#endif
1369 }
1370
1371 /* If we have a 4-length pattern, we can go ahead and just check it in a different way. */
1372 if (dsp->busy_cadence.length == 4) {
1373 int x;
1374 int errors = 0;
1375 int errors_max = ((4 * dsp->busycount) / 100.0) * BUSY_PAT_PERCENT;
1376
1377 for (x = DSP_HISTORY - (dsp->busycount); x < DSP_HISTORY; x += 2) {
1378 int temp_error;
1379 temp_error = abs(dsp->historicnoise[x] - dsp->busy_cadence.pattern[0]);
1380 if ((temp_error * 100) / dsp->busy_cadence.pattern[0] > BUSY_PERCENT) {
1381 errors++;
1382 }
1383
1384 temp_error = abs(dsp->historicnoise[x + 1] - dsp->busy_cadence.pattern[2]);
1385 if ((temp_error * 100) / dsp->busy_cadence.pattern[2] > BUSY_PERCENT) {
1386 errors++;
1387 }
1388
1389 temp_error = abs(dsp->historicsilence[x] - dsp->busy_cadence.pattern[1]);
1390 if ((temp_error * 100) / dsp->busy_cadence.pattern[1] > BUSY_PERCENT) {
1391 errors++;
1392 }
1393
1394 temp_error = abs(dsp->historicsilence[x + 1] - dsp->busy_cadence.pattern[3]);
1395 if ((temp_error * 100) / dsp->busy_cadence.pattern[3] > BUSY_PERCENT) {
1396 errors++;
1397 }
1398 }
1399
1400 ast_debug(5, "errors = %d max = %d\n", errors, errors_max);
1401
1402 if (errors <= errors_max) {
1403 return 1;
1404 }
1405 }
1406
1407 /* If we know the expected busy tone length, check we are in the range */
1408 if (res && (dsp->busy_cadence.pattern[0] > 0)) {
1409 if (abs(avgtone - dsp->busy_cadence.pattern[0]) > MAX(dsp->busy_cadence.pattern[0]*BUSY_PAT_PERCENT/100, 20)) {
1410#ifdef BUSYDETECT_DEBUG
1411 ast_debug(5, "busy detector: avgtone of %d not close enough to desired %d\n",
1412 avgtone, dsp->busy_cadence.pattern[0]);
1413#endif
1414 res = 0;
1415 }
1416 }
1417#ifndef BUSYDETECT_TONEONLY
1418 /* If we know the expected busy tone silent-period length, check we are in the range */
1419 if (res && (dsp->busy_cadence.pattern[1] > 0)) {
1420 if (abs(avgsilence - dsp->busy_cadence.pattern[1]) > MAX(dsp->busy_cadence.pattern[1]*BUSY_PAT_PERCENT/100, 20)) {
1421#ifdef BUSYDETECT_DEBUG
1422 ast_debug(5, "busy detector: avgsilence of %d not close enough to desired %d\n",
1423 avgsilence, dsp->busy_cadence.pattern[1]);
1424#endif
1425 res = 0;
1426 }
1427 }
1428#endif
1429#if !defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_DEBUG)
1430 if (res) {
1431 ast_debug(5, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1432 } else {
1433 ast_debug(5, "busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1434 }
1435#endif
1436 return res;
1437}
@ BUSY_MAX
Definition: dsp.c:147
@ BUSY_PAT_PERCENT
Definition: dsp.c:144
@ BUSY_MIN
Definition: dsp.c:146
@ BUSY_PERCENT
Definition: dsp.c:143
#define DSP_HISTORY
Definition: dsp.c:151
#define abs(x)
Definition: f2c.h:195
#define ast_debug(level,...)
Log a DEBUG message.
int pattern[4]
Definition: dsp.h:68
int historicnoise[DSP_HISTORY]
Definition: dsp.c:419
int busymaybe
Definition: dsp.c:416
int busycount
Definition: dsp.c:417
int historicsilence[DSP_HISTORY]
Definition: dsp.c:420
struct ast_dsp_busy_pattern busy_cadence
Definition: dsp.c:418
#define MAX(a, b)
Definition: utils.h:251

References abs, ast_debug, ast_dsp::busy_cadence, BUSY_MAX, BUSY_MIN, BUSY_PAT_PERCENT, BUSY_PERCENT, ast_dsp::busycount, ast_dsp::busymaybe, DSP_HISTORY, ast_dsp::historicnoise, ast_dsp::historicsilence, ast_dsp_busy_pattern::length, MAX, and ast_dsp_busy_pattern::pattern.

Referenced by ast_dsp_process().

◆ ast_dsp_call_progress()

int ast_dsp_call_progress ( struct ast_dsp dsp,
struct ast_frame inf 
)

Scans for progress indication in audio.

Definition at line 1221 of file dsp.c.

1222{
1223 if (inf->frametype != AST_FRAME_VOICE) {
1224 ast_log(LOG_WARNING, "Can't check call progress of non-voice frames\n");
1225 return 0;
1226 }
1228 ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames, %s not supported\n",
1230 return 0;
1231 }
1232 return __ast_dsp_call_progress(dsp, inf->data.ptr, inf->datalen / 2);
1233}
#define ast_log
Definition: astobj2.c:42
static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
Definition: dsp.c:1079
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
int ast_format_cache_is_slinear(struct ast_format *format)
Determines if a format is one of the cached slin formats.
Definition: format_cache.c:534
@ AST_FRAME_VOICE
#define LOG_WARNING
struct ast_format * format
struct ast_frame_subclass subclass
enum ast_frame_type frametype
union ast_frame::@231 data

References __ast_dsp_call_progress(), ast_format_cache_is_slinear(), ast_format_get_name(), AST_FRAME_VOICE, ast_log, ast_frame::data, ast_frame::datalen, ast_frame_subclass::format, ast_frame::frametype, LOG_WARNING, ast_frame::ptr, and ast_frame::subclass.

◆ ast_dsp_digitdetect()

int ast_dsp_digitdetect ( struct ast_dsp dsp,
struct ast_frame f 
)

Return non-zero if DTMF hit was found.

◆ ast_dsp_digitreset()

void ast_dsp_digitreset ( struct ast_dsp dsp)

Reset DTMF detector.

Definition at line 1812 of file dsp.c.

1813{
1814 int i;
1815
1816 dsp->dtmf_began = 0;
1817 if (dsp->digitmode & DSP_DIGITMODE_MF) {
1819 /* Reinitialise the detector for the next block */
1820 for (i = 0; i < 6; i++) {
1821 goertzel_reset(&s->tone_out[i]);
1822 }
1823 s->hits[4] = s->hits[3] = s->hits[2] = s->hits[1] = s->hits[0] = 0;
1824 s->current_hit = 0;
1825 s->current_sample = 0;
1826 } else {
1828 /* Reinitialise the detector for the next block */
1829 for (i = 0; i < 4; i++) {
1830 goertzel_reset(&s->row_out[i]);
1831 goertzel_reset(&s->col_out[i]);
1832 }
1833 s->lasthit = 0;
1834 s->current_hit = 0;
1835 s->energy = 0.0;
1836 s->current_sample = 0;
1837 s->hits = 0;
1838 s->misses = 0;
1839 }
1840
1841 dsp->digit_state.digits[0] = '\0';
1842 dsp->digit_state.current_digits = 0;
1843}
static void goertzel_reset(goertzel_state_t *s)
Definition: dsp.c:384
#define DSP_DIGITMODE_MF
Definition: dsp.h:32
digit_detect_state_t digit_state
Definition: dsp.c:437
int digitmode
Definition: dsp.c:428
int dtmf_began
Definition: dsp.c:431
mf_detect_state_t mf
Definition: dsp.c:315
union digit_detect_state_t::@351 td
dtmf_detect_state_t dtmf
Definition: dsp.c:314
char digits[MAX_DTMF_DIGITS+1]
Definition: dsp.c:307
int current_digits
Definition: dsp.c:309
float energy
Definition: dsp.c:291
goertzel_state_t row_out[DTMF_MATRIX_SIZE]
Definition: dsp.c:285
goertzel_state_t col_out[DTMF_MATRIX_SIZE]
Definition: dsp.c:286
int current_sample
Definition: dsp.c:292
int hits[5]
Definition: dsp.c:300
goertzel_state_t tone_out[6]
Definition: dsp.c:298
int current_hit
Definition: dsp.c:299
int current_sample
Definition: dsp.c:301

References dtmf_detect_state_t::col_out, digit_detect_state_t::current_digits, dtmf_detect_state_t::current_hit, mf_detect_state_t::current_hit, dtmf_detect_state_t::current_sample, mf_detect_state_t::current_sample, ast_dsp::digit_state, ast_dsp::digitmode, digit_detect_state_t::digits, DSP_DIGITMODE_MF, digit_detect_state_t::dtmf, ast_dsp::dtmf_began, dtmf_detect_state_t::energy, goertzel_reset(), dtmf_detect_state_t::hits, mf_detect_state_t::hits, dtmf_detect_state_t::lasthit, digit_detect_state_t::mf, dtmf_detect_state_t::misses, dtmf_detect_state_t::row_out, digit_detect_state_t::td, and mf_detect_state_t::tone_out.

Referenced by analog_ss_thread(), mbl_new(), and my_dsp_reset_and_flush_digits().

◆ ast_dsp_free()

void ast_dsp_free ( struct ast_dsp dsp)

◆ ast_dsp_get_features()

int ast_dsp_get_features ( struct ast_dsp dsp)

Get features.

Definition at line 1779 of file dsp.c.

1780{
1781 return (dsp->features);
1782}
int features
Definition: dsp.c:414

References ast_dsp::features.

Referenced by chan_pjsip_cng_tone_detected(), chan_pjsip_read_stream(), pjsip_acf_dtmf_mode_write(), and set_caps().

◆ ast_dsp_get_sample_rate()

unsigned int ast_dsp_get_sample_rate ( const struct ast_dsp dsp)

Retrieve the sample rate this DSP structure was created with.

Definition at line 1732 of file dsp.c.

1733{
1734 return dsp->sample_rate;
1735}
unsigned int sample_rate
Definition: dsp.c:435

References ast_dsp::sample_rate.

◆ ast_dsp_get_tcount()

int ast_dsp_get_tcount ( struct ast_dsp dsp)

Get tcount (Threshold counter)

Definition at line 1918 of file dsp.c.

1919{
1920 return dsp->tcount;
1921}
int tcount
Definition: dsp.c:427

References ast_dsp::tcount.

Referenced by dahdi_read(), detect_callback(), and scan_exec().

◆ ast_dsp_get_threshold_from_settings()

int ast_dsp_get_threshold_from_settings ( enum threshold  which)

Get silence threshold from dsp.conf.

Since
1.6.1

Definition at line 2011 of file dsp.c.

2012{
2013 return thresholds[which];
2014}
static int thresholds[THRESHOLD_MAX]
Definition: dsp.c:330

References thresholds.

Referenced by actual_load_config(), app_exec(), ast_record_review(), conf_rec_name(), conf_run(), do_waiting(), handle_recordfile(), load_config(), record_exec(), setup_privacy_args(), and talk_detect_fn_write().

◆ ast_dsp_get_tstate()

int ast_dsp_get_tstate ( struct ast_dsp dsp)

Get tstate (Tone State)

Definition at line 1913 of file dsp.c.

1914{
1915 return dsp->tstate;
1916}
int tstate
Definition: dsp.c:426

References ast_dsp::tstate.

Referenced by dahdi_read(), detect_callback(), and scan_exec().

◆ ast_dsp_getdigits()

int ast_dsp_getdigits ( struct ast_dsp dsp,
char *  buf,
int  max 
)

Get pending DTMF/MF digits.

◆ ast_dsp_new()

struct ast_dsp * ast_dsp_new ( void  )

◆ ast_dsp_new_with_rate()

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.

Definition at line 1765 of file dsp.c.

1766{
1767 return __ast_dsp_new(sample_rate);
1768}

References __ast_dsp_new(), and ast_dsp::sample_rate.

Referenced by set_softmix_bridge_data(), and set_talk_detect().

◆ ast_dsp_noise()

int ast_dsp_noise ( struct ast_dsp dsp,
struct ast_frame f,
int *  totalnoise 
)

Process the audio frame for noise.

Since
1.6.1
Parameters
dspDSP processing audio media.
fAudio frame to process.
totalnoiseVariable to set to the total accumulated noise in ms seen by the DSP since the last silence.
Returns
Non-zero if the frame is silence.

Definition at line 1495 of file dsp.c.

1496{
1497 return ast_dsp_silence_noise_with_energy(dsp, f, totalnoise, NULL, 1);
1498}
static int ast_dsp_silence_noise_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *total, int *frames_energy, int noise)
Definition: dsp.c:1439
#define NULL
Definition: resample.c:96

References ast_dsp_silence_noise_with_energy(), and NULL.

◆ ast_dsp_process()

struct ast_frame * ast_dsp_process ( struct ast_channel chan,
struct ast_dsp dsp,
struct ast_frame inf 
)

Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress, all dependent upon which features are enabled.

Definition at line 1501 of file dsp.c.

1502{
1503 int silence;
1504 int res;
1505 int digit = 0, fax_digit = 0, custom_freq_digit = 0;
1506 int x;
1507 short *shortdata;
1508 unsigned char *odata;
1509 int len;
1510 struct ast_frame *outf = NULL;
1511
1512 if (!af) {
1513 return NULL;
1514 }
1515 if (af->frametype != AST_FRAME_VOICE) {
1516 return af;
1517 }
1518
1519 odata = af->data.ptr;
1520 len = af->datalen;
1521 /* Make sure we have short data */
1522 if (ast_format_cache_is_slinear(af->subclass.format)) {
1523 shortdata = af->data.ptr;
1524 len = af->datalen / 2;
1525 } else if (ast_format_cmp(af->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
1526 shortdata = ast_alloca(af->datalen * 2);
1527 for (x = 0; x < len; x++) {
1528 shortdata[x] = AST_MULAW(odata[x]);
1529 }
1530 } else if (ast_format_cmp(af->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
1531 shortdata = ast_alloca(af->datalen * 2);
1532 for (x = 0; x < len; x++) {
1533 shortdata[x] = AST_ALAW(odata[x]);
1534 }
1535 } else {
1536 /* Display warning only once. Otherwise you would get hundreds of warnings every second */
1537 if (dsp->display_inband_dtmf_warning) {
1538 /* If DTMF is enabled for the DSP, try to be helpful and warn about that specifically,
1539 * otherwise emit a more generic message that covers all other cases. */
1541 ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n",
1542 ast_format_get_name(af->subclass.format));
1543 } else {
1544 ast_log(LOG_WARNING, "Can only do DSP on signed-linear, alaw or ulaw frames (%s not supported)\n",
1545 ast_format_get_name(af->subclass.format));
1546 }
1547 }
1549 return af;
1550 }
1551
1552 /* Initially we do not want to mute anything */
1553 dsp->mute_fragments = 0;
1554
1555 /* Need to run the silence detection stuff for silence suppression and busy detection */
1557 res = __ast_dsp_silence_noise(dsp, shortdata, len, &silence, NULL, NULL);
1558 }
1559
1560 if ((dsp->features & DSP_FEATURE_SILENCE_SUPPRESS) && silence) {
1561 memset(&dsp->f, 0, sizeof(dsp->f));
1562 dsp->f.frametype = AST_FRAME_NULL;
1563 ast_frfree(af);
1564 return ast_frisolate(&dsp->f);
1565 }
1568 memset(&dsp->f, 0, sizeof(dsp->f));
1571 ast_frfree(af);
1572 ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", ast_channel_name(chan));
1573 return ast_frisolate(&dsp->f);
1574 }
1575
1576 if ((dsp->features & DSP_FEATURE_FAX_DETECT)) {
1577 if ((dsp->faxmode & DSP_FAXMODE_DETECT_CNG) && tone_detect(dsp, &dsp->cng_tone_state, shortdata, len)) {
1578 fax_digit = 'f';
1579 }
1580
1581 if ((dsp->faxmode & DSP_FAXMODE_DETECT_CED) && tone_detect(dsp, &dsp->ced_tone_state, shortdata, len)) {
1582 fax_digit = 'e';
1583 }
1584 }
1585
1586 if ((dsp->features & DSP_FEATURE_FREQ_DETECT)) {
1587 if ((dsp->freqmode) && tone_detect(dsp, &dsp->cng_tone_state, shortdata, len)) {
1588 custom_freq_digit = 'q';
1589 }
1590 }
1591
1593 if (dsp->digitmode & DSP_DIGITMODE_MF) {
1594 digit = mf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
1595 } else {
1596 digit = dtmf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
1597 }
1598
1599 if (dsp->digit_state.current_digits) {
1600 int event = 0, event_len = 0;
1601 char event_digit = 0;
1602
1603 if (!dsp->dtmf_began) {
1604 /* We have not reported DTMF_BEGIN for anything yet */
1605
1607 event = AST_FRAME_DTMF_BEGIN;
1608 event_digit = dsp->digit_state.digits[0];
1609 }
1610 dsp->dtmf_began = 1;
1611
1612 } else if (dsp->digit_state.current_digits > 1 || digit != dsp->digit_state.digits[0]) {
1613 /* Digit changed. This means digit we have reported with DTMF_BEGIN ended */
1615 event = AST_FRAME_DTMF_END;
1616 event_digit = dsp->digit_state.digits[0];
1617 event_len = dsp->digit_state.digitlen[0] * 1000 / dsp->sample_rate;
1618 }
1619 memmove(&dsp->digit_state.digits[0], &dsp->digit_state.digits[1], dsp->digit_state.current_digits);
1620 memmove(&dsp->digit_state.digitlen[0], &dsp->digit_state.digitlen[1], dsp->digit_state.current_digits * sizeof(dsp->digit_state.digitlen[0]));
1622 dsp->dtmf_began = 0;
1623
1624 if (dsp->features & DSP_FEATURE_BUSY_DETECT) {
1625 /* Reset Busy Detector as we have some confirmed activity */
1626 memset(dsp->historicsilence, 0, sizeof(dsp->historicsilence));
1627 memset(dsp->historicnoise, 0, sizeof(dsp->historicnoise));
1628 ast_debug(1, "DTMF Detected - Reset busydetector\n");
1629 }
1630 }
1631
1632 if (event) {
1633 memset(&dsp->f, 0, sizeof(dsp->f));
1634 dsp->f.frametype = event;
1635 dsp->f.subclass.integer = event_digit;
1636 dsp->f.len = event_len;
1637 outf = &dsp->f;
1638 goto done;
1639 }
1640 }
1641 }
1642
1643 if (fax_digit) {
1644 /* Fax was detected - digit is either 'f' or 'e' */
1645
1646 memset(&dsp->f, 0, sizeof(dsp->f));
1647 dsp->f.frametype = AST_FRAME_DTMF;
1648 dsp->f.subclass.integer = fax_digit;
1649 outf = &dsp->f;
1650 goto done;
1651 }
1652
1653 if (custom_freq_digit) {
1654 /* Custom frequency was detected - digit is 'q' */
1655
1656 memset(&dsp->f, 0, sizeof(dsp->f));
1657 dsp->f.frametype = AST_FRAME_DTMF;
1658 dsp->f.subclass.integer = custom_freq_digit;
1659 outf = &dsp->f;
1660 goto done;
1661 }
1662
1663 if ((dsp->features & DSP_FEATURE_CALL_PROGRESS)) {
1664 res = __ast_dsp_call_progress(dsp, shortdata, len);
1665 if (res) {
1666 switch (res) {
1667 case AST_CONTROL_ANSWER:
1668 case AST_CONTROL_BUSY:
1671 case AST_CONTROL_HANGUP:
1672 memset(&dsp->f, 0, sizeof(dsp->f));
1674 dsp->f.subclass.integer = res;
1675 dsp->f.src = "dsp_progress";
1676 if (chan) {
1677 ast_queue_frame(chan, &dsp->f);
1678 }
1679 break;
1680 default:
1681 ast_log(LOG_WARNING, "Don't know how to represent call progress message %d\n", res);
1682 }
1683 }
1684 } else if ((dsp->features & DSP_FEATURE_WAITDIALTONE)) {
1685 res = __ast_dsp_call_progress(dsp, shortdata, len);
1686 }
1687
1688done:
1689 /* Mute fragment of the frame */
1690 for (x = 0; x < dsp->mute_fragments; x++) {
1691 memset(shortdata + dsp->mute_data[x].start, 0, sizeof(int16_t) * (dsp->mute_data[x].end - dsp->mute_data[x].start));
1692 }
1693
1694 if (ast_format_cmp(af->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
1695 for (x = 0; x < len; x++) {
1696 odata[x] = AST_LIN2MU((unsigned short) shortdata[x]);
1697 }
1698 } else if (ast_format_cmp(af->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
1699 for (x = 0; x < len; x++) {
1700 odata[x] = AST_LIN2A((unsigned short) shortdata[x]);
1701 }
1702 }
1703
1704 if (outf) {
1705 if (chan) {
1706 ast_queue_frame(chan, af);
1707 }
1708 ast_frfree(af);
1709 return ast_frisolate(outf);
1710 } else {
1711 return af;
1712 }
1713}
#define AST_LIN2A(a)
Definition: alaw.h:50
#define AST_ALAW(a)
Definition: alaw.h:84
char digit
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
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.
Definition: channel.c:1170
@ AST_SOFTHANGUP_DEV
Definition: channel.h:1141
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
static int tone_detect(struct ast_dsp *dsp, tone_detect_state_t *s, int16_t *amp, int samples)
Definition: dsp.c:575
static int mf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax)
Definition: dsp.c:905
static int dtmf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax)
Definition: dsp.c:697
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 ...
Definition: dsp.c:1301
static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *totalsilence, int *totalnoise, int *frames_energy)
Definition: dsp.c:1235
#define DSP_FEATURE_WAITDIALTONE
Definition: dsp.h:44
#define DSP_FEATURE_BUSY_DETECT
Definition: dsp.h:27
#define DSP_DIGITMODE_NOQUELCH
Definition: dsp.h:34
#define DSP_FEATURE_DIGIT_DETECT
Definition: dsp.h:28
#define DSP_FEATURE_FAX_DETECT
Definition: dsp.h:29
#define DSP_FAXMODE_DETECT_CED
Definition: dsp.h:48
#define DSP_FEATURE_CALL_PROGRESS
Definition: dsp.h:43
#define DSP_FAXMODE_DETECT_CNG
Definition: dsp.h:47
#define DSP_FEATURE_SILENCE_SUPPRESS
Definition: dsp.h:26
#define DSP_FEATURE_FREQ_DETECT
Definition: dsp.h:45
#define DSP_DIGITMODE_DTMF
Definition: dsp.h:31
#define DSP_DIGITMODE_RELAXDTMF
Definition: dsp.h:37
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
@ AST_FORMAT_CMP_EQUAL
Definition: format.h:36
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_FRAME_DTMF
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
#define ast_frfree(fr)
@ AST_FRAME_NULL
@ AST_FRAME_DTMF_END
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_CONTROL
@ AST_CONTROL_BUSY
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_ANSWER
@ AST_CONTROL_RINGING
@ AST_CONTROL_HANGUP
fragment_t mute_data[5]
Definition: dsp.c:436
int faxmode
Definition: dsp.c:429
int mute_fragments
Definition: dsp.c:434
struct ast_frame f
Definition: dsp.c:408
tone_detect_state_t ced_tone_state
Definition: dsp.c:439
int display_inband_dtmf_warning
Definition: dsp.c:432
int freqmode
Definition: dsp.c:430
tone_detect_state_t cng_tone_state
Definition: dsp.c:438
Data structure associated with a single frame of data.
const char * src
int digitlen[MAX_DTMF_DIGITS+1]
Definition: dsp.c:308
Definition: astman.c:222
int start
Definition: dsp.c:390
int end
Definition: dsp.c:391
int done
Definition: test_amihooks.c:48
#define AST_MULAW(a)
Definition: ulaw.h:85
#define AST_LIN2MU(a)
Definition: ulaw.h:49

References __ast_dsp_call_progress(), __ast_dsp_silence_noise(), AST_ALAW, ast_alloca, ast_channel_name(), ast_channel_softhangup_internal_flag_add(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_RINGING, ast_debug, ast_dsp_busydetect(), ast_format_alaw, ast_format_cache_is_slinear(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_format_ulaw, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_NULL, AST_FRAME_VOICE, ast_frfree, ast_frisolate, AST_LIN2A, AST_LIN2MU, ast_log, AST_MULAW, ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_dsp::ced_tone_state, ast_dsp::cng_tone_state, digit_detect_state_t::current_digits, ast_frame::data, ast_frame::datalen, digit, ast_dsp::digit_state, digit_detect_state_t::digitlen, ast_dsp::digitmode, digit_detect_state_t::digits, ast_dsp::display_inband_dtmf_warning, done, DSP_DIGITMODE_DTMF, DSP_DIGITMODE_MF, DSP_DIGITMODE_NOQUELCH, DSP_DIGITMODE_RELAXDTMF, DSP_FAXMODE_DETECT_CED, DSP_FAXMODE_DETECT_CNG, DSP_FEATURE_BUSY_DETECT, DSP_FEATURE_CALL_PROGRESS, DSP_FEATURE_DIGIT_DETECT, DSP_FEATURE_FAX_DETECT, DSP_FEATURE_FREQ_DETECT, DSP_FEATURE_SILENCE_SUPPRESS, DSP_FEATURE_WAITDIALTONE, ast_dsp::dtmf_began, dtmf_detect(), fragment_t::end, ast_dsp::f, ast_dsp::faxmode, ast_dsp::features, ast_frame_subclass::format, ast_frame::frametype, ast_dsp::freqmode, ast_dsp::historicnoise, ast_dsp::historicsilence, ast_frame_subclass::integer, len(), ast_frame::len, LOG_WARNING, mf_detect(), ast_dsp::mute_data, ast_dsp::mute_fragments, NULL, ast_frame::ptr, ast_dsp::sample_rate, ast_frame::src, fragment_t::start, ast_frame::subclass, and tone_detect().

Referenced by chan_pjsip_read_stream(), dahdi_read(), detect_callback(), fax_detect_framehook(), mbl_read(), ooh323_rtp_read(), read_mf_digits(), read_sf_digits(), scan_exec(), and wait_exec().

◆ ast_dsp_reset()

void ast_dsp_reset ( struct ast_dsp dsp)

Reset total silence count.

Definition at line 1845 of file dsp.c.

1846{
1847 int x;
1848
1849 dsp->totalsilence = 0;
1850 dsp->gsamps = 0;
1851 for (x = 0; x < 4; x++) {
1852 dsp->freqs[x].v2 = dsp->freqs[x].v3 = 0.0;
1853 }
1854 memset(dsp->historicsilence, 0, sizeof(dsp->historicsilence));
1855 memset(dsp->historicnoise, 0, sizeof(dsp->historicnoise));
1856 dsp->ringtimeout = 0;
1857}
int totalsilence
Definition: dsp.c:411
goertzel_state_t freqs[FREQ_ARRAY_SIZE]
Definition: dsp.c:421
int gsamps
Definition: dsp.c:423
int ringtimeout
Definition: dsp.c:415

References ast_dsp::freqs, ast_dsp::gsamps, ast_dsp::historicnoise, ast_dsp::historicsilence, ast_dsp::ringtimeout, ast_dsp::totalsilence, goertzel_state_t::v2, and goertzel_state_t::v3.

Referenced by debug_check_frame_for_silence().

◆ ast_dsp_set_busy_count()

void ast_dsp_set_busy_count ( struct ast_dsp dsp,
int  cadences 
)

Set number of required cadences for busy.

Definition at line 1795 of file dsp.c.

1796{
1797 if (cadences < 4) {
1798 cadences = 4;
1799 }
1800 if (cadences > DSP_HISTORY) {
1802 }
1803 dsp->busycount = cadences;
1804}
static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX]
Definition: chan_dahdi.c:765

References ast_dsp::busycount, cadences, and DSP_HISTORY.

Referenced by dahdi_new().

◆ ast_dsp_set_busy_pattern()

void ast_dsp_set_busy_pattern ( struct ast_dsp dsp,
const struct ast_dsp_busy_pattern cadence 
)

Set expected lengths of the busy tone.

Definition at line 1806 of file dsp.c.

1807{
1808 dsp->busy_cadence = *cadence;
1809 ast_debug(1, "dsp busy pattern set to %d,%d,%d,%d\n", cadence->pattern[0], cadence->pattern[1], (cadence->length == 4) ? cadence->pattern[2] : 0, (cadence->length == 4) ? cadence->pattern[3] : 0);
1810}

References ast_debug, ast_dsp::busy_cadence, ast_dsp_busy_pattern::length, and ast_dsp_busy_pattern::pattern.

Referenced by dahdi_new().

◆ ast_dsp_set_call_progress_zone()

int ast_dsp_set_call_progress_zone ( struct ast_dsp dsp,
char *  zone 
)

Set zone for doing progress detection.

Definition at line 1894 of file dsp.c.

1895{
1896 int x;
1897
1898 for (x = 0; x < ARRAY_LEN(aliases); x++) {
1899 if (!strcasecmp(aliases[x].name, zone)) {
1900 dsp->progmode = aliases[x].mode;
1901 ast_dsp_prog_reset(dsp);
1902 return 0;
1903 }
1904 }
1905 return -1;
1906}
static struct progalias aliases[]
static void ast_dsp_prog_reset(struct ast_dsp *dsp)
Definition: dsp.c:1715
static const char name[]
Definition: format_mp3.c:68
enum prog_mode progmode
Definition: dsp.c:425
enum prog_mode mode
Definition: dsp.c:106
#define ARRAY_LEN(a)
Definition: utils.h:703

References aliases, ARRAY_LEN, ast_dsp_prog_reset(), progalias::mode, name, and ast_dsp::progmode.

Referenced by dahdi_new(), and scan_exec().

◆ ast_dsp_set_digitmode()

int ast_dsp_set_digitmode ( struct ast_dsp dsp,
int  digitmode 
)

Set digit mode.

Version
1.6.1 renamed from ast_dsp_digitmode to ast_dsp_set_digitmode

Definition at line 1859 of file dsp.c.

1860{
1861 int new;
1862 int old;
1863
1866 if (old != new) {
1867 /* Must initialize structures if switching from MF to DTMF or vice-versa */
1869 }
1870 dsp->digitmode = digitmode;
1871 return 0;
1872}
static void ast_digit_detect_init(digit_detect_state_t *s, int mf, unsigned int sample_rate)
Definition: dsp.c:561
#define DSP_DIGITMODE_MUTEMAX
Definition: dsp.h:36
#define DSP_DIGITMODE_MUTECONF
Definition: dsp.h:35

References ast_digit_detect_init(), ast_dsp::digit_state, ast_dsp::digitmode, DSP_DIGITMODE_DTMF, DSP_DIGITMODE_MF, DSP_DIGITMODE_MUTECONF, DSP_DIGITMODE_MUTEMAX, and ast_dsp::sample_rate.

Referenced by analog_ss_thread(), dahdi_hangup(), dahdi_new(), dahdi_setoption(), mbl_load_device(), mkintf(), my_dsp_set_digitmode(), ooh323_new(), and read_mf_digits().

◆ ast_dsp_set_faxmode()

int ast_dsp_set_faxmode ( struct ast_dsp dsp,
int  faxmode 
)

Set fax mode.

Definition at line 1885 of file dsp.c.

1886{
1887 if (dsp->faxmode != faxmode) {
1888 dsp->faxmode = faxmode;
1890 }
1891 return 0;
1892}
static void ast_fax_detect_init(struct ast_dsp *s)
Definition: dsp.c:513

References ast_fax_detect_init(), and ast_dsp::faxmode.

Referenced by fax_detect_new(), ooh323_new(), and scan_exec().

◆ ast_dsp_set_features()

void ast_dsp_set_features ( struct ast_dsp dsp,
int  features 
)

◆ ast_dsp_set_freqmode()

int ast_dsp_set_freqmode ( struct ast_dsp dsp,
int  freq,
int  dur,
int  db,
int  squelch 
)

Set arbitrary frequency detection mode.

Definition at line 1874 of file dsp.c.

1875{
1876 if (freq > 0) {
1877 dsp->freqmode = 1;
1878 ast_freq_detect_init(dsp, freq, dur, db, squelch);
1879 } else {
1880 dsp->freqmode = 0;
1881 }
1882 return 0;
1883}
static sqlite3 * db
static void ast_freq_detect_init(struct ast_dsp *s, int freq, int dur, int db, int squelch)
Definition: dsp.c:524

References ast_freq_detect_init(), db, and ast_dsp::freqmode.

Referenced by detect_write(), read_sf_digits(), scan_exec(), and wait_exec().

◆ ast_dsp_set_threshold()

void ast_dsp_set_threshold ( struct ast_dsp dsp,
int  threshold 
)

Set the minimum average magnitude threshold to determine talking by the DSP.

Definition at line 1790 of file dsp.c.

1791{
1792 dsp->threshold = threshold;
1793}
threshold
Definition: dsp.h:71
int threshold
Definition: dsp.c:409

References ast_dsp::threshold.

Referenced by __ast_play_and_record(), do_waiting(), fax_session_new(), handle_recordfile(), isAnsweringMachine(), record_exec(), set_softmix_bridge_data(), and set_talk_detect().

◆ ast_dsp_silence()

int ast_dsp_silence ( struct ast_dsp dsp,
struct ast_frame f,
int *  totalsilence 
)

Process the audio frame for silence.

Parameters
dspDSP processing audio media.
fAudio frame to process.
totalsilenceVariable to set to the total accumulated silence in ms seen by the DSP since the last noise.
Returns
Non-zero if the frame is silence.

Definition at line 1490 of file dsp.c.

1491{
1492 return ast_dsp_silence_noise_with_energy(dsp, f, totalsilence, NULL, 0);
1493}

References ast_dsp_silence_noise_with_energy(), and NULL.

Referenced by __ast_play_and_record(), background_detect_exec(), conf_run(), debug_check_frame_for_silence(), handle_recordfile(), isAnsweringMachine(), record_exec(), and talk_detect_audiohook_cb().

◆ ast_dsp_silence_with_energy()

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.

Parameters
dspDSP processing audio media.
fAudio frame to process.
totalsilenceVariable to set to the total accumulated silence in ms seen by the DSP since the last noise.
frames_energyVariable to set to the average energy of the samples in the frame.
Returns
Non-zero if the frame is silence.

Definition at line 1485 of file dsp.c.

1486{
1487 return ast_dsp_silence_noise_with_energy(dsp, f, totalsilence, frames_energy, 0);
1488}

References ast_dsp_silence_noise_with_energy().

Referenced by softmix_bridge_write_voice().

◆ ast_dsp_was_muted()

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) happens when DSP code removes DTMF/MF/generic tones from the audio.

Since
1.6.1

Definition at line 1908 of file dsp.c.

1909{
1910 return (dsp->mute_fragments > 0);
1911}

References ast_dsp::mute_fragments.

Referenced by dahdi_read().