2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
20 * \brief Convenient Signal Processing routines
23 #ifndef _ASTERISK_DSP_H
24 #define _ASTERISK_DSP_H
26 #define DSP_FEATURE_SILENCE_SUPPRESS (1 << 0)
27 #define DSP_FEATURE_BUSY_DETECT (1 << 1)
28 #define DSP_FEATURE_DTMF_DETECT (1 << 3)
29 #define DSP_FEATURE_FAX_DETECT (1 << 4)
31 #define DSP_DIGITMODE_DTMF 0 /*!< Detect DTMF digits */
32 #define DSP_DIGITMODE_MF 1 /*!< Detect MF digits */
34 #define DSP_DIGITMODE_NOQUELCH (1 << 8) /*!< Do not quelch DTMF from in-band */
35 #define DSP_DIGITMODE_MUTECONF (1 << 9) /*!< Mute conference */
36 #define DSP_DIGITMODE_MUTEMAX (1 << 10) /*!< Delay audio by a frame to try to extra quelch */
37 #define DSP_DIGITMODE_RELAXDTMF (1 << 11) /*!< "Radio" mode (relaxed DTMF) */
39 #define DSP_PROGRESS_TALK (1 << 16) /*!< Enable talk detection */
40 #define DSP_PROGRESS_RINGING (1 << 17) /*!< Enable calling tone detection */
41 #define DSP_PROGRESS_BUSY (1 << 18) /*!< Enable busy tone detection */
42 #define DSP_PROGRESS_CONGESTION (1 << 19) /*!< Enable congestion tone detection */
43 #define DSP_FEATURE_CALL_PROGRESS (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION)
45 #define DSP_FAXMODE_DETECT_CNG (1 << 0)
46 #define DSP_FAXMODE_DETECT_CED (1 << 1)
47 #define DSP_FAXMODE_DETECT_ALL (DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED)
49 #define DSP_TONE_STATE_SILENCE 0
50 #define DSP_TONE_STATE_RINGING 1
51 #define DSP_TONE_STATE_DIALTONE 2
52 #define DSP_TONE_STATE_TALKING 3
53 #define DSP_TONE_STATE_BUSY 4
54 #define DSP_TONE_STATE_SPECIAL1 5
55 #define DSP_TONE_STATE_SPECIAL2 6
56 #define DSP_TONE_STATE_SPECIAL3 7
57 #define DSP_TONE_STATE_HUNGUP 8
61 struct ast_dsp *ast_dsp_new(void);
62 void ast_dsp_free(struct ast_dsp *dsp);
64 /*! \brief Set threshold value for silence */
65 void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold);
67 /*! \brief Set number of required cadences for busy */
68 void ast_dsp_set_busy_count(struct ast_dsp *dsp, int cadences);
70 /*! \brief Set expected lengths of the busy tone */
71 void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, int tonelength, int quietlength);
73 /*! \brief Scans for progress indication in audio */
74 int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf);
76 /*! \brief Set zone for doing progress detection */
77 int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone);
79 /*! \brief Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on
80 busies, and call progress, all dependent upon which features are enabled */
81 struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf);
83 /*! \brief Return non-zero if this is silence. Updates "totalsilence" with the total
84 number of seconds of silence */
85 int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence);
87 /*! \brief Return non-zero if historically this should be a busy, request that
88 ast_dsp_silence has already been called */
89 int ast_dsp_busydetect(struct ast_dsp *dsp);
91 /*! \brief Return non-zero if DTMF hit was found */
92 int ast_dsp_digitdetect(struct ast_dsp *dsp, struct ast_frame *f);
94 /*! \brief Reset total silence count */
95 void ast_dsp_reset(struct ast_dsp *dsp);
97 /*! \brief Reset DTMF detector */
98 void ast_dsp_digitreset(struct ast_dsp *dsp);
100 /*! \brief Select feature set */
101 void ast_dsp_set_features(struct ast_dsp *dsp, int features);
103 /*! \brief Get pending DTMF/MF digits */
104 int ast_dsp_getdigits(struct ast_dsp *dsp, char *buf, int max);
106 /*! \brief Set digit mode */
107 int ast_dsp_digitmode(struct ast_dsp *dsp, int digitmode);
109 /*! \brief Set fax mode */
110 int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode);
112 /*! \brief Get tstate (Tone State) */
113 int ast_dsp_get_tstate(struct ast_dsp *dsp);
115 /*! \brief Get tcount (Threshold counter) */
116 int ast_dsp_get_tcount(struct ast_dsp *dsp);
118 #endif /* _ASTERISK_DSP_H */