Asterisk - The Open Source Telephony Project GIT-master-80b953f
Loading...
Searching...
No Matches
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_R2_BACKWARD   (1 << 3)
 
#define DSP_DIGITMODE_R2_FORWARD   (1 << 2)
 
#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.
 
int ast_dsp_call_progress (struct ast_dsp *dsp, struct ast_frame *inf)
 Scans for progress indication in audio.
 
int ast_dsp_digitdetect (struct ast_dsp *dsp, struct ast_frame *f)
 Return non-zero if DTMF hit was found.
 
void ast_dsp_digitreset (struct ast_dsp *dsp)
 Reset DTMF detector.
 
void ast_dsp_free (struct ast_dsp *dsp)
 
int ast_dsp_get_features (struct ast_dsp *dsp)
 Get features.
 
unsigned int ast_dsp_get_sample_rate (const struct ast_dsp *dsp)
 Retrieve the sample rate this DSP structure was created with.
 
int ast_dsp_get_tcount (struct ast_dsp *dsp)
 Get tcount (Threshold counter)
 
int ast_dsp_get_threshold_from_settings (enum threshold which)
 Get silence threshold from dsp.conf.
 
int ast_dsp_get_tstate (struct ast_dsp *dsp)
 Get tstate (Tone State)
 
int ast_dsp_getdigits (struct ast_dsp *dsp, char *buf, int max)
 Get pending DTMF/MF digits.
 
struct ast_dspast_dsp_new (void)
 Allocates a new dsp, assumes 8khz for internal sample rate.
 
struct ast_dspast_dsp_new_with_rate (unsigned int sample_rate)
 Allocates a new dsp with a specific internal sample rate used during processing.
 
int ast_dsp_noise (struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
 Process the audio frame for noise.
 
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.
 
void ast_dsp_reset (struct ast_dsp *dsp)
 Reset total silence count.
 
void ast_dsp_set_busy_count (struct ast_dsp *dsp, int cadences)
 Set number of required cadences for busy.
 
void ast_dsp_set_busy_pattern (struct ast_dsp *dsp, const struct ast_dsp_busy_pattern *cadence)
 Set expected lengths of the busy tone.
 
int ast_dsp_set_call_progress_zone (struct ast_dsp *dsp, char *zone)
 Set zone for doing progress detection.
 
int ast_dsp_set_digitmode (struct ast_dsp *dsp, int digitmode)
 Set digit mode.
 
int ast_dsp_set_faxmode (struct ast_dsp *dsp, int faxmode)
 Set fax mode.
 
void ast_dsp_set_features (struct ast_dsp *dsp, int features)
 Select feature set.
 
int ast_dsp_set_freqmode (struct ast_dsp *dsp, int freq, int dur, int db, int squelch)
 Set arbitrary frequency detection mode.
 
void ast_dsp_set_threshold (struct ast_dsp *dsp, int threshold)
 Set the minimum average magnitude threshold to determine talking by the DSP.
 
int ast_dsp_silence (struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
 Process the audio frame for silence.
 
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.
 
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.
 

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 37 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 38 of file dsp.h.

◆ DSP_DIGITMODE_NOQUELCH

#define DSP_DIGITMODE_NOQUELCH   (1 << 8)

Do not quelch DTMF from in-band

Definition at line 36 of file dsp.h.

◆ DSP_DIGITMODE_R2_BACKWARD

#define DSP_DIGITMODE_R2_BACKWARD   (1 << 3)

Detect R2 backward signaling

Definition at line 34 of file dsp.h.

◆ DSP_DIGITMODE_R2_FORWARD

#define DSP_DIGITMODE_R2_FORWARD   (1 << 2)

Detect R2 forward signaling

Definition at line 33 of file dsp.h.

◆ DSP_DIGITMODE_RELAXDTMF

#define DSP_DIGITMODE_RELAXDTMF   (1 << 11)

"Radio" mode (relaxed DTMF)

Definition at line 39 of file dsp.h.

◆ DSP_FAXMODE_DETECT_ALL

#define DSP_FAXMODE_DETECT_ALL   (DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED)

Definition at line 52 of file dsp.h.

◆ DSP_FAXMODE_DETECT_CED

#define DSP_FAXMODE_DETECT_CED   (1 << 1)

Definition at line 50 of file dsp.h.

◆ DSP_FAXMODE_DETECT_CNG

#define DSP_FAXMODE_DETECT_CNG   (1 << 0)

Definition at line 49 of file dsp.h.

◆ DSP_FAXMODE_DETECT_SQUELCH

#define DSP_FAXMODE_DETECT_SQUELCH   (1 << 2)

Definition at line 51 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 45 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 47 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 46 of file dsp.h.

◆ DSP_PROGRESS_BUSY

#define DSP_PROGRESS_BUSY   (1 << 18)

Enable busy tone detection

Definition at line 43 of file dsp.h.

◆ DSP_PROGRESS_CONGESTION

#define DSP_PROGRESS_CONGESTION   (1 << 19)

Enable congestion tone detection

Definition at line 44 of file dsp.h.

◆ DSP_PROGRESS_RINGING

#define DSP_PROGRESS_RINGING   (1 << 17)

Enable calling tone detection

Definition at line 42 of file dsp.h.

◆ DSP_PROGRESS_TALK

#define DSP_PROGRESS_TALK   (1 << 16)

Enable talk detection

Definition at line 41 of file dsp.h.

◆ DSP_TONE_STATE_BUSY

#define DSP_TONE_STATE_BUSY   4

Definition at line 58 of file dsp.h.

◆ DSP_TONE_STATE_DIALTONE

#define DSP_TONE_STATE_DIALTONE   2

Definition at line 56 of file dsp.h.

◆ DSP_TONE_STATE_HUNGUP

#define DSP_TONE_STATE_HUNGUP   8

Definition at line 62 of file dsp.h.

◆ DSP_TONE_STATE_RINGING

#define DSP_TONE_STATE_RINGING   1

Definition at line 55 of file dsp.h.

◆ DSP_TONE_STATE_SILENCE

#define DSP_TONE_STATE_SILENCE   0

Definition at line 54 of file dsp.h.

◆ DSP_TONE_STATE_SPECIAL1

#define DSP_TONE_STATE_SPECIAL1   5

Definition at line 59 of file dsp.h.

◆ DSP_TONE_STATE_SPECIAL2

#define DSP_TONE_STATE_SPECIAL2   6

Definition at line 60 of file dsp.h.

◆ DSP_TONE_STATE_SPECIAL3

#define DSP_TONE_STATE_SPECIAL3   7

Definition at line 61 of file dsp.h.

◆ DSP_TONE_STATE_TALKING

#define DSP_TONE_STATE_TALKING   3

Definition at line 57 of file dsp.h.

Enumeration Type Documentation

◆ threshold

enum threshold
Enumerator
THRESHOLD_SILENCE 
THRESHOLD_MAX 

Definition at line 73 of file dsp.h.

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

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 1483 of file dsp.c.

1484{
1485 int res = 0, x;
1486#ifndef BUSYDETECT_TONEONLY
1487 int avgsilence = 0, hitsilence = 0;
1488#endif
1489 int avgtone = 0, hittone = 0;
1490
1491 /* if we have a 4 length pattern, the way busymaybe is set doesn't help us. */
1492 if (dsp->busy_cadence.length != 4) {
1493 if (!dsp->busymaybe) {
1494 return res;
1495 }
1496 }
1497
1498 for (x = DSP_HISTORY - dsp->busycount; x < DSP_HISTORY; x++) {
1499#ifndef BUSYDETECT_TONEONLY
1500 avgsilence += dsp->historicsilence[x];
1501#endif
1502 avgtone += dsp->historicnoise[x];
1503 }
1504#ifndef BUSYDETECT_TONEONLY
1505 avgsilence /= dsp->busycount;
1506#endif
1507 avgtone /= dsp->busycount;
1508 for (x = DSP_HISTORY - dsp->busycount; x < DSP_HISTORY; x++) {
1509#ifndef BUSYDETECT_TONEONLY
1510 if (avgsilence > dsp->historicsilence[x]) {
1511 if (avgsilence - (avgsilence * BUSY_PERCENT / 100) <= dsp->historicsilence[x]) {
1512 hitsilence++;
1513 }
1514 } else {
1515 if (avgsilence + (avgsilence * BUSY_PERCENT / 100) >= dsp->historicsilence[x]) {
1516 hitsilence++;
1517 }
1518 }
1519#endif
1520 if (avgtone > dsp->historicnoise[x]) {
1521 if (avgtone - (avgtone * BUSY_PERCENT / 100) <= dsp->historicnoise[x]) {
1522 hittone++;
1523 }
1524 } else {
1525 if (avgtone + (avgtone * BUSY_PERCENT / 100) >= dsp->historicnoise[x]) {
1526 hittone++;
1527 }
1528 }
1529 }
1530#ifndef BUSYDETECT_TONEONLY
1531 if ((hittone >= dsp->busycount - 1) && (hitsilence >= dsp->busycount - 1) &&
1532 (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX) &&
1533 (avgsilence >= BUSY_MIN && avgsilence <= BUSY_MAX))
1534#else
1535 if ((hittone >= dsp->busycount - 1) && (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX))
1536#endif
1537 {
1538#ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE
1539 if (avgtone > avgsilence) {
1540 if (avgtone - avgtone*BUSY_PERCENT/100 <= avgsilence) {
1541 res = 1;
1542 }
1543 } else {
1544 if (avgtone + avgtone*BUSY_PERCENT/100 >= avgsilence) {
1545 res = 1;
1546 }
1547 }
1548#else
1549 res = 1;
1550#endif
1551 }
1552
1553 /* If we have a 4-length pattern, we can go ahead and just check it in a different way. */
1554 if (dsp->busy_cadence.length == 4) {
1555 int x;
1556 int errors = 0;
1557 int errors_max = ((4 * dsp->busycount) / 100.0) * BUSY_PAT_PERCENT;
1558
1559 for (x = DSP_HISTORY - (dsp->busycount); x < DSP_HISTORY; x += 2) {
1560 int temp_error;
1561 temp_error = abs(dsp->historicnoise[x] - dsp->busy_cadence.pattern[0]);
1562 if ((temp_error * 100) / dsp->busy_cadence.pattern[0] > BUSY_PERCENT) {
1563 errors++;
1564 }
1565
1566 temp_error = abs(dsp->historicnoise[x + 1] - dsp->busy_cadence.pattern[2]);
1567 if ((temp_error * 100) / dsp->busy_cadence.pattern[2] > BUSY_PERCENT) {
1568 errors++;
1569 }
1570
1571 temp_error = abs(dsp->historicsilence[x] - dsp->busy_cadence.pattern[1]);
1572 if ((temp_error * 100) / dsp->busy_cadence.pattern[1] > BUSY_PERCENT) {
1573 errors++;
1574 }
1575
1576 temp_error = abs(dsp->historicsilence[x + 1] - dsp->busy_cadence.pattern[3]);
1577 if ((temp_error * 100) / dsp->busy_cadence.pattern[3] > BUSY_PERCENT) {
1578 errors++;
1579 }
1580 }
1581
1582 ast_debug(5, "errors = %d max = %d\n", errors, errors_max);
1583
1584 if (errors <= errors_max) {
1585 return 1;
1586 }
1587 }
1588
1589 /* If we know the expected busy tone length, check we are in the range */
1590 if (res && (dsp->busy_cadence.pattern[0] > 0)) {
1591 if (abs(avgtone - dsp->busy_cadence.pattern[0]) > MAX(dsp->busy_cadence.pattern[0]*BUSY_PAT_PERCENT/100, 20)) {
1592#ifdef BUSYDETECT_DEBUG
1593 ast_debug(5, "busy detector: avgtone of %d not close enough to desired %d\n",
1594 avgtone, dsp->busy_cadence.pattern[0]);
1595#endif
1596 res = 0;
1597 }
1598 }
1599#ifndef BUSYDETECT_TONEONLY
1600 /* If we know the expected busy tone silent-period length, check we are in the range */
1601 if (res && (dsp->busy_cadence.pattern[1] > 0)) {
1602 if (abs(avgsilence - dsp->busy_cadence.pattern[1]) > MAX(dsp->busy_cadence.pattern[1]*BUSY_PAT_PERCENT/100, 20)) {
1603#ifdef BUSYDETECT_DEBUG
1604 ast_debug(5, "busy detector: avgsilence of %d not close enough to desired %d\n",
1605 avgsilence, dsp->busy_cadence.pattern[1]);
1606#endif
1607 res = 0;
1608 }
1609 }
1610#endif
1611#if !defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_DEBUG)
1612 if (res) {
1613 ast_debug(5, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1614 } else {
1615 ast_debug(5, "busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1616 }
1617#endif
1618 return res;
1619}
@ 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:70
int historicnoise[DSP_HISTORY]
Definition dsp.c:433
int busymaybe
Definition dsp.c:430
int busycount
Definition dsp.c:431
int historicsilence[DSP_HISTORY]
Definition dsp.c:434
struct ast_dsp_busy_pattern busy_cadence
Definition dsp.c:432
#define MAX(a, b)
Definition utils.h:254

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 1403 of file dsp.c.

1404{
1405 if (inf->frametype != AST_FRAME_VOICE) {
1406 ast_log(LOG_WARNING, "Can't check call progress of non-voice frames\n");
1407 return 0;
1408 }
1410 ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames, %s not supported\n",
1412 return 0;
1413 }
1414 return __ast_dsp_call_progress(dsp, inf->data.ptr, inf->datalen / 2);
1415}
#define ast_log
Definition astobj2.c:42
static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
Definition dsp.c:1261
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.
#define LOG_WARNING
struct ast_format * format
struct ast_frame_subclass subclass
enum ast_frame_type frametype
union ast_frame::@235 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 1995 of file dsp.c.

1996{
1997 int i;
1998
1999 dsp->dtmf_began = 0;
2002 /* Reinitialise the detector for the next block */
2003 for (i = 0; i < 6; i++) {
2004 goertzel_reset(&s->tone_out[i]);
2005 }
2006 s->hits[4] = s->hits[3] = s->hits[2] = s->hits[1] = s->hits[0] = 0;
2007 s->current_hit = 0;
2008 s->current_sample = 0;
2009 } else {
2011 /* Reinitialise the detector for the next block */
2012 for (i = 0; i < 4; i++) {
2013 goertzel_reset(&s->row_out[i]);
2014 goertzel_reset(&s->col_out[i]);
2015 }
2016 s->lasthit = 0;
2017 s->current_hit = 0;
2018 s->energy = 0.0;
2019 s->current_sample = 0;
2020 s->hits = 0;
2021 s->misses = 0;
2022 }
2023
2024 dsp->digit_state.digits[0] = '\0';
2025 dsp->digit_state.current_digits = 0;
2026}
static void goertzel_reset(goertzel_state_t *s)
Definition dsp.c:398
#define DSP_DIGITMODE_MF
Definition dsp.h:32
#define DSP_DIGITMODE_R2_BACKWARD
Definition dsp.h:34
#define DSP_DIGITMODE_R2_FORWARD
Definition dsp.h:33
digit_detect_state_t digit_state
Definition dsp.c:451
int digitmode
Definition dsp.c:442
int dtmf_began
Definition dsp.c:445
mf_detect_state_t mf
Definition dsp.c:322
dtmf_detect_state_t dtmf
Definition dsp.c:321
char digits[MAX_DTMF_DIGITS+1]
Definition dsp.c:314
union digit_detect_state_t::@368 td
goertzel_state_t row_out[DTMF_MATRIX_SIZE]
Definition dsp.c:292
goertzel_state_t col_out[DTMF_MATRIX_SIZE]
Definition dsp.c:293
int hits[5]
Definition dsp.c:307
goertzel_state_t tone_out[6]
Definition dsp.c:305
int current_hit
Definition dsp.c:306
int current_sample
Definition dsp.c:308

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, DSP_DIGITMODE_R2_BACKWARD, DSP_DIGITMODE_R2_FORWARD, 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 1962 of file dsp.c.

1963{
1964 return (dsp->features);
1965}
int features
Definition dsp.c:428

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 1915 of file dsp.c.

1916{
1917 return dsp->sample_rate;
1918}
unsigned int sample_rate
Definition dsp.c:449

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 2103 of file dsp.c.

2104{
2105 return dsp->tcount;
2106}
int tcount
Definition dsp.c:441

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 2196 of file dsp.c.

2197{
2198 return thresholds[which];
2199}
static int thresholds[THRESHOLD_MAX]
Definition dsp.c:344

References thresholds.

Referenced by actual_load_config(), app_exec(), ast_record_review(), conf_rec_name(), conf_run(), do_waiting(), handle_recordfile(), load_config(), 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 2098 of file dsp.c.

2099{
2100 return dsp->tstate;
2101}
int tstate
Definition dsp.c:440

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 1948 of file dsp.c.

1949{
1950 return __ast_dsp_new(sample_rate);
1951}

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 1677 of file dsp.c.

1678{
1679 return ast_dsp_silence_noise_with_energy(dsp, f, totalnoise, NULL, 1);
1680}
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:1621
#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 1683 of file dsp.c.

1684{
1685 int silence;
1686 int res;
1687 int digit = 0, fax_digit = 0, custom_freq_digit = 0;
1688 int x;
1689 short *shortdata;
1690 unsigned char *odata;
1691 int len;
1692 struct ast_frame *outf = NULL;
1693
1694 if (!af) {
1695 return NULL;
1696 }
1697 if (af->frametype != AST_FRAME_VOICE) {
1698 return af;
1699 }
1700
1701 odata = af->data.ptr;
1702 len = af->datalen;
1703 /* Make sure we have short data */
1704 if (ast_format_cache_is_slinear(af->subclass.format)) {
1705 shortdata = af->data.ptr;
1706 len = af->datalen / 2;
1707 } else if (ast_format_cmp(af->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
1708 shortdata = ast_alloca(af->datalen * 2);
1709 for (x = 0; x < len; x++) {
1710 shortdata[x] = AST_MULAW(odata[x]);
1711 }
1712 } else if (ast_format_cmp(af->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
1713 shortdata = ast_alloca(af->datalen * 2);
1714 for (x = 0; x < len; x++) {
1715 shortdata[x] = AST_ALAW(odata[x]);
1716 }
1717 } else {
1718 /* Display warning only once. Otherwise you would get hundreds of warnings every second */
1719 if (dsp->display_inband_dtmf_warning) {
1720 /* If DTMF is enabled for the DSP, try to be helpful and warn about that specifically,
1721 * otherwise emit a more generic message that covers all other cases. */
1723 ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n",
1724 ast_format_get_name(af->subclass.format));
1725 } else {
1726 ast_log(LOG_WARNING, "Can only do DSP on signed-linear, alaw or ulaw frames (%s not supported)\n",
1727 ast_format_get_name(af->subclass.format));
1728 }
1729 }
1731 return af;
1732 }
1733
1734 /* Initially we do not want to mute anything */
1735 dsp->mute_fragments = 0;
1736
1737 /* Need to run the silence detection stuff for silence suppression and busy detection */
1739 res = __ast_dsp_silence_noise(dsp, shortdata, len, &silence, NULL, NULL);
1740 }
1741
1742 if ((dsp->features & DSP_FEATURE_SILENCE_SUPPRESS) && silence) {
1743 memset(&dsp->f, 0, sizeof(dsp->f));
1744 dsp->f.frametype = AST_FRAME_NULL;
1745 ast_frfree(af);
1746 return ast_frisolate(&dsp->f);
1747 }
1750 memset(&dsp->f, 0, sizeof(dsp->f));
1753 ast_frfree(af);
1754 ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", ast_channel_name(chan));
1755 return ast_frisolate(&dsp->f);
1756 }
1757
1758 if ((dsp->features & DSP_FEATURE_FAX_DETECT)) {
1759 if ((dsp->faxmode & DSP_FAXMODE_DETECT_CNG) && tone_detect(dsp, &dsp->cng_tone_state, shortdata, len)) {
1760 fax_digit = 'f';
1761 }
1762
1763 if ((dsp->faxmode & DSP_FAXMODE_DETECT_CED) && tone_detect(dsp, &dsp->ced_tone_state, shortdata, len)) {
1764 fax_digit = 'e';
1765 }
1766 }
1767
1768 if ((dsp->features & DSP_FEATURE_FREQ_DETECT)) {
1769 if ((dsp->freqmode) && tone_detect(dsp, &dsp->cng_tone_state, shortdata, len)) {
1770 custom_freq_digit = 'q';
1771 }
1772 }
1773
1777 } else if (dsp->digitmode & DSP_DIGITMODE_MF) {
1778 digit = mf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
1779 } else {
1780 digit = dtmf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
1781 }
1782
1783 if (dsp->digit_state.current_digits) {
1784 int event = 0, event_len = 0;
1785 char event_digit = 0;
1786
1787 if (!dsp->dtmf_began) {
1788 /* We have not reported DTMF_BEGIN for anything yet */
1789
1791 event = AST_FRAME_DTMF_BEGIN;
1792 event_digit = dsp->digit_state.digits[0];
1793 }
1794 dsp->dtmf_began = 1;
1795 } else if (dsp->digit_state.current_digits > 1 || digit != dsp->digit_state.digits[0]) {
1796 /* Digit changed. This means digit we have reported with DTMF_BEGIN ended */
1798 event = AST_FRAME_DTMF_END;
1799 event_digit = dsp->digit_state.digits[0];
1800 event_len = dsp->digit_state.digitlen[0] * 1000 / dsp->sample_rate;
1801 }
1802 memmove(&dsp->digit_state.digits[0], &dsp->digit_state.digits[1], dsp->digit_state.current_digits);
1803 memmove(&dsp->digit_state.digitlen[0], &dsp->digit_state.digitlen[1], dsp->digit_state.current_digits * sizeof(dsp->digit_state.digitlen[0]));
1805 dsp->dtmf_began = 0;
1806
1807 if (dsp->features & DSP_FEATURE_BUSY_DETECT) {
1808 /* Reset Busy Detector as we have some confirmed activity */
1809 memset(dsp->historicsilence, 0, sizeof(dsp->historicsilence));
1810 memset(dsp->historicnoise, 0, sizeof(dsp->historicnoise));
1811 ast_debug(1, "DTMF Detected - Reset busydetector\n");
1812 }
1813 }
1814
1815 if (event) {
1816 memset(&dsp->f, 0, sizeof(dsp->f));
1817 dsp->f.frametype = event;
1818 dsp->f.subclass.integer = event_digit;
1819 dsp->f.len = event_len;
1820 outf = &dsp->f;
1821 goto done;
1822 }
1823 }
1824 }
1825
1826 if (fax_digit) {
1827 /* Fax was detected - digit is either 'f' or 'e' */
1828
1829 memset(&dsp->f, 0, sizeof(dsp->f));
1830 dsp->f.frametype = AST_FRAME_DTMF;
1831 dsp->f.subclass.integer = fax_digit;
1832 outf = &dsp->f;
1833 goto done;
1834 }
1835
1836 if (custom_freq_digit) {
1837 /* Custom frequency was detected - digit is 'q' */
1838
1839 memset(&dsp->f, 0, sizeof(dsp->f));
1840 dsp->f.frametype = AST_FRAME_DTMF;
1841 dsp->f.subclass.integer = custom_freq_digit;
1842 outf = &dsp->f;
1843 goto done;
1844 }
1845
1846 if ((dsp->features & DSP_FEATURE_CALL_PROGRESS)) {
1847 res = __ast_dsp_call_progress(dsp, shortdata, len);
1848 if (res) {
1849 switch (res) {
1850 case AST_CONTROL_ANSWER:
1851 case AST_CONTROL_BUSY:
1854 case AST_CONTROL_HANGUP:
1855 memset(&dsp->f, 0, sizeof(dsp->f));
1857 dsp->f.subclass.integer = res;
1858 dsp->f.src = "dsp_progress";
1859 if (chan) {
1860 ast_queue_frame(chan, &dsp->f);
1861 }
1862 break;
1863 default:
1864 ast_log(LOG_WARNING, "Don't know how to represent call progress message %d\n", res);
1865 }
1866 }
1867 } else if ((dsp->features & DSP_FEATURE_WAITDIALTONE)) {
1868 res = __ast_dsp_call_progress(dsp, shortdata, len);
1869 }
1870
1871done:
1872 /* Mute fragment of the frame */
1873 for (x = 0; x < dsp->mute_fragments; x++) {
1874 memset(shortdata + dsp->mute_data[x].start, 0, sizeof(int16_t) * (dsp->mute_data[x].end - dsp->mute_data[x].start));
1875 }
1876
1877 if (ast_format_cmp(af->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
1878 for (x = 0; x < len; x++) {
1879 odata[x] = AST_LIN2MU((unsigned short) shortdata[x]);
1880 }
1881 } else if (ast_format_cmp(af->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
1882 for (x = 0; x < len; x++) {
1883 odata[x] = AST_LIN2A((unsigned short) shortdata[x]);
1884 }
1885 }
1886
1887 if (outf) {
1888 if (chan) {
1889 ast_queue_frame(chan, af);
1890 }
1891 ast_frfree(af);
1892 return ast_frisolate(outf);
1893 } else {
1894 return af;
1895 }
1896}
#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:1171
@ 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:605
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:937
static int r2_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax, const char *r2_positions)
Definition dsp.c:1088
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:729
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:1483
static const char r2_mf_positions[]
Definition dsp.c:343
static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *totalsilence, int *totalnoise, int *frames_energy)
Definition dsp.c:1417
#define DSP_FEATURE_WAITDIALTONE
Definition dsp.h:46
#define DSP_FEATURE_BUSY_DETECT
Definition dsp.h:27
#define DSP_DIGITMODE_NOQUELCH
Definition dsp.h:36
#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:50
#define DSP_FEATURE_CALL_PROGRESS
Definition dsp.h:45
#define DSP_FAXMODE_DETECT_CNG
Definition dsp.h:49
#define DSP_FEATURE_SILENCE_SUPPRESS
Definition dsp.h:26
#define DSP_FEATURE_FREQ_DETECT
Definition dsp.h:47
#define DSP_DIGITMODE_DTMF
Definition dsp.h:31
#define DSP_DIGITMODE_RELAXDTMF
Definition dsp.h:39
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.
struct ast_format * ast_format_alaw
Built-in cached alaw format.
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_DTMF_END
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_CONTROL
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_ANSWER
@ AST_CONTROL_RINGING
@ AST_CONTROL_HANGUP
fragment_t mute_data[5]
Definition dsp.c:450
int faxmode
Definition dsp.c:443
int mute_fragments
Definition dsp.c:448
struct ast_frame f
Definition dsp.c:422
tone_detect_state_t ced_tone_state
Definition dsp.c:453
int display_inband_dtmf_warning
Definition dsp.c:446
int freqmode
Definition dsp.c:444
tone_detect_state_t cng_tone_state
Definition dsp.c:452
Data structure associated with a single frame of data.
int digitlen[MAX_DTMF_DIGITS+1]
Definition dsp.c:315
int start
Definition dsp.c:404
int end
Definition dsp.c:405
int done
#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_R2_BACKWARD, DSP_DIGITMODE_R2_FORWARD, 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, r2_detect(), r2_mf_positions, 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 2028 of file dsp.c.

2029{
2030 int x;
2031
2032 dsp->totalsilence = 0;
2033 dsp->gsamps = 0;
2034 for (x = 0; x < 4; x++) {
2035 dsp->freqs[x].v2 = dsp->freqs[x].v3 = 0.0;
2036 }
2037 memset(dsp->historicsilence, 0, sizeof(dsp->historicsilence));
2038 memset(dsp->historicnoise, 0, sizeof(dsp->historicnoise));
2039 dsp->ringtimeout = 0;
2040}
int totalsilence
Definition dsp.c:425
goertzel_state_t freqs[FREQ_ARRAY_SIZE]
Definition dsp.c:435
int gsamps
Definition dsp.c:437
int ringtimeout
Definition dsp.c:429

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 1978 of file dsp.c.

1979{
1980 if (cadences < 4) {
1981 cadences = 4;
1982 }
1983 if (cadences > DSP_HISTORY) {
1985 }
1986 dsp->busycount = cadences;
1987}
static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX]
Definition chan_dahdi.c:820

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 1989 of file dsp.c.

1990{
1991 dsp->busy_cadence = *cadence;
1992 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);
1993}

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 2079 of file dsp.c.

2080{
2081 int x;
2082
2083 for (x = 0; x < ARRAY_LEN(aliases); x++) {
2084 if (!strcasecmp(aliases[x].name, zone)) {
2085 dsp->progmode = aliases[x].mode;
2086 ast_dsp_prog_reset(dsp);
2087 return 0;
2088 }
2089 }
2090 return -1;
2091}
static struct progalias aliases[]
static void ast_dsp_prog_reset(struct ast_dsp *dsp)
Definition dsp.c:1898
static const char name[]
Definition format_mp3.c:68
enum prog_mode progmode
Definition dsp.c:439
enum prog_mode mode
Definition dsp.c:106
#define ARRAY_LEN(a)
Definition utils.h:706

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 2044 of file dsp.c.

2045{
2046 int new;
2047 int old;
2048
2051 if (old != new) {
2052 /* Must initialize structures if switching from MF to DTMF or vice-versa */
2054 }
2055 dsp->digitmode = digitmode;
2056 return 0;
2057}
static void ast_digit_detect_init(digit_detect_state_t *s, int digitmode, unsigned int sample_rate)
Definition dsp.c:587
#define DSP_DIGITMODES
Definition dsp.c:2042
#define DSP_DIGITMODE_MUTEMAX
Definition dsp.h:38
#define DSP_DIGITMODE_MUTECONF
Definition dsp.h:37

References ast_digit_detect_init(), ast_dsp::digit_state, ast_dsp::digitmode, DSP_DIGITMODE_MUTECONF, DSP_DIGITMODE_MUTEMAX, DSP_DIGITMODES, 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 2070 of file dsp.c.

2071{
2072 if (dsp->faxmode != faxmode) {
2073 dsp->faxmode = faxmode;
2075 }
2076 return 0;
2077}
static void ast_fax_detect_init(struct ast_dsp *s)
Definition dsp.c:527

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 2059 of file dsp.c.

2060{
2061 if (freq > 0) {
2062 dsp->freqmode = 1;
2063 ast_freq_detect_init(dsp, freq, dur, db, squelch);
2064 } else {
2065 dsp->freqmode = 0;
2066 }
2067 return 0;
2068}
static void ast_freq_detect_init(struct ast_dsp *s, int freq, int dur, int db, int squelch)
Definition dsp.c:538

References ast_freq_detect_init(), 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 1973 of file dsp.c.

1974{
1975 dsp->threshold = threshold;
1976}
threshold
Definition dsp.h:73
int threshold
Definition dsp.c:423

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 1672 of file dsp.c.

1673{
1674 return ast_dsp_silence_noise_with_energy(dsp, f, totalsilence, NULL, 0);
1675}

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 1667 of file dsp.c.

1668{
1669 return ast_dsp_silence_noise_with_energy(dsp, f, totalsilence, frames_energy, 0);
1670}

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 2093 of file dsp.c.

2094{
2095 return (dsp->mute_fragments > 0);
2096}

References ast_dsp::mute_fragments.

Referenced by dahdi_read().