Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Convenient Signal Processing routines. More...
Go to the source code of this file.
Data Structures | |
struct | ast_dsp_busy_pattern |
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_dsp * | ast_dsp_new (void) |
Allocates a new dsp, assumes 8khz for internal sample rate. More... | |
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. More... | |
int | ast_dsp_noise (struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise) |
Process the audio frame for noise. More... | |
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. 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... | |
Convenient Signal Processing routines.
Definition in file dsp.h.
#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_FEATURE_CALL_PROGRESS (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION) |
#define DSP_FEATURE_FREQ_DETECT (1 << 21) |
#define DSP_FEATURE_WAITDIALTONE (1 << 20) |
#define DSP_PROGRESS_CONGESTION (1 << 19) |
#define DSP_PROGRESS_RINGING (1 << 17) |
enum threshold |
Enumerator | |
---|---|
THRESHOLD_SILENCE | |
THRESHOLD_MAX |
Definition at line 71 of file dsp.h.
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 1299 of file dsp.c.
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().
Scans for progress indication in audio.
Definition at line 1219 of file dsp.c.
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.
Return non-zero if DTMF hit was found.
void ast_dsp_digitreset | ( | struct ast_dsp * | dsp | ) |
Reset DTMF detector.
Definition at line 1810 of file dsp.c.
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().
void ast_dsp_free | ( | struct ast_dsp * | dsp | ) |
Definition at line 1783 of file dsp.c.
References ast_free.
Referenced by __ast_play_and_record(), analog_ss_thread(), background_detect_exec(), chan_pjsip_cng_tone_detected(), chan_pjsip_read_stream(), conf_run(), dahdi_hangup(), datastore_destroy_cb(), destroy_callback(), destroy_faxdetect(), destroy_session(), do_waiting(), handle_recordfile(), isAnsweringMachine(), mbl_load_device(), my_all_subchannels_hungup(), my_dsp_set_digitmode(), ooh323_destroy(), pjsip_acf_dtmf_mode_write(), read_mf_digits(), read_sf_digits(), record_exec(), scan_exec(), session_destructor(), set_caps(), set_softmix_bridge_data(), softmix_bridge_leave(), unload_module(), and wait_exec().
int ast_dsp_get_features | ( | struct ast_dsp * | dsp | ) |
Get features.
Definition at line 1777 of file dsp.c.
References ast_dsp::features.
Referenced by chan_pjsip_cng_tone_detected(), chan_pjsip_read_stream(), pjsip_acf_dtmf_mode_write(), and set_caps().
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 1730 of file dsp.c.
References ast_dsp::sample_rate.
int ast_dsp_get_tcount | ( | struct ast_dsp * | dsp | ) |
Get tcount (Threshold counter)
Definition at line 1916 of file dsp.c.
References ast_dsp::tcount.
Referenced by dahdi_read(), detect_callback(), and scan_exec().
int ast_dsp_get_threshold_from_settings | ( | enum threshold | which | ) |
Get silence threshold from dsp.conf.
Definition at line 2009 of file dsp.c.
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().
int ast_dsp_get_tstate | ( | struct ast_dsp * | dsp | ) |
Get tstate (Tone State)
Definition at line 1911 of file dsp.c.
References ast_dsp::tstate.
Referenced by dahdi_read(), detect_callback(), and scan_exec().
int ast_dsp_getdigits | ( | struct ast_dsp * | dsp, |
char * | buf, | ||
int | max | ||
) |
Get pending DTMF/MF digits.
struct ast_dsp * ast_dsp_new | ( | void | ) |
Allocates a new dsp, assumes 8khz for internal sample rate.
Definition at line 1758 of file dsp.c.
References __ast_dsp_new(), and DEFAULT_SAMPLE_RATE.
Referenced by __ast_play_and_record(), ast_sip_session_alloc(), background_detect_exec(), conf_run(), dahdi_new(), detect_write(), do_waiting(), fax_detect_new(), fax_session_new(), handle_recordfile(), isAnsweringMachine(), mbl_load_device(), my_dsp_set_digitmode(), my_set_waitingfordt(), ooh323_new(), pjsip_acf_dtmf_mode_write(), read_mf_digits(), read_sf_digits(), record_exec(), scan_exec(), and wait_exec().
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 1763 of file dsp.c.
References __ast_dsp_new(), and ast_dsp::sample_rate.
Referenced by set_softmix_bridge_data(), and set_talk_detect().
Process the audio frame for noise.
dsp | DSP processing audio media. |
f | Audio frame to process. |
totalnoise | Variable to set to the total accumulated noise in ms seen by the DSP since the last silence. |
Definition at line 1493 of file dsp.c.
References ast_dsp_silence_noise_with_energy(), and NULL.
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 1499 of file dsp.c.
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().
void ast_dsp_reset | ( | struct ast_dsp * | dsp | ) |
Reset total silence count.
Definition at line 1843 of file dsp.c.
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().
void ast_dsp_set_busy_count | ( | struct ast_dsp * | dsp, |
int | cadences | ||
) |
Set number of required cadences for busy.
Definition at line 1793 of file dsp.c.
References ast_dsp::busycount, cadences, and DSP_HISTORY.
Referenced by dahdi_new().
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 1804 of file dsp.c.
References ast_debug, ast_dsp::busy_cadence, ast_dsp_busy_pattern::length, and ast_dsp_busy_pattern::pattern.
Referenced by dahdi_new().
int ast_dsp_set_call_progress_zone | ( | struct ast_dsp * | dsp, |
char * | zone | ||
) |
Set zone for doing progress detection.
Definition at line 1892 of file dsp.c.
References aliases, ARRAY_LEN, ast_dsp_prog_reset(), progalias::mode, name, and ast_dsp::progmode.
Referenced by dahdi_new(), and scan_exec().
int ast_dsp_set_digitmode | ( | struct ast_dsp * | dsp, |
int | digitmode | ||
) |
Set digit mode.
Definition at line 1857 of file dsp.c.
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().
int ast_dsp_set_faxmode | ( | struct ast_dsp * | dsp, |
int | faxmode | ||
) |
Set fax mode.
Definition at line 1883 of file dsp.c.
References ast_fax_detect_init(), and ast_dsp::faxmode.
Referenced by fax_detect_new(), ooh323_new(), and scan_exec().
void ast_dsp_set_features | ( | struct ast_dsp * | dsp, |
int | features | ||
) |
Select feature set.
Definition at line 1768 of file dsp.c.
References ast_dsp::display_inband_dtmf_warning, DSP_FEATURE_DIGIT_DETECT, and ast_dsp::features.
Referenced by ast_sip_session_alloc(), chan_pjsip_cng_tone_detected(), chan_pjsip_read_stream(), dahdi_dtmf_detect_disable(), dahdi_dtmf_detect_enable(), dahdi_handle_dtmf(), dahdi_new(), dahdi_read(), dahdi_setoption(), detect_write(), fax_detect_new(), mbl_load_device(), my_handle_dtmf(), my_set_waitingfordt(), ooh323_new(), pjsip_acf_dtmf_mode_write(), read_mf_digits(), read_sf_digits(), scan_exec(), set_caps(), and wait_exec().
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 1872 of file dsp.c.
References ast_freq_detect_init(), db, and ast_dsp::freqmode.
Referenced by detect_write(), read_sf_digits(), scan_exec(), and wait_exec().
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 1788 of file dsp.c.
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().
Process the audio frame for silence.
dsp | DSP processing audio media. |
f | Audio frame to process. |
totalsilence | Variable to set to the total accumulated silence in ms seen by the DSP since the last noise. |
Definition at line 1488 of file dsp.c.
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().
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.
dsp | DSP processing audio media. |
f | Audio frame to process. |
totalsilence | Variable to set to the total accumulated silence in ms seen by the DSP since the last noise. |
frames_energy | Variable to set to the average energy of the samples in the frame. |
Definition at line 1483 of file dsp.c.
References ast_dsp_silence_noise_with_energy().
Referenced by softmix_bridge_write_voice().
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.
Definition at line 1906 of file dsp.c.
References ast_dsp::mute_fragments.
Referenced by dahdi_read().