Properly play a holdtime message if the announce-holdtime option is
[asterisk-bristuff.git] / include / asterisk / dsp.h
blobccc484c1426d22a6b5bf8119b3a0591e58d1109b
1 /*
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.
19 /*! \file
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_TONE_STATE_SILENCE 0
46 #define DSP_TONE_STATE_RINGING 1
47 #define DSP_TONE_STATE_DIALTONE 2
48 #define DSP_TONE_STATE_TALKING 3
49 #define DSP_TONE_STATE_BUSY 4
50 #define DSP_TONE_STATE_SPECIAL1 5
51 #define DSP_TONE_STATE_SPECIAL2 6
52 #define DSP_TONE_STATE_SPECIAL3 7
53 #define DSP_TONE_STATE_HUNGUP 8
55 struct ast_dsp;
57 struct ast_dsp *ast_dsp_new(void);
58 void ast_dsp_free(struct ast_dsp *dsp);
60 /*! \brief Set threshold value for silence */
61 void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold);
63 /*! \brief Set number of required cadences for busy */
64 void ast_dsp_set_busy_count(struct ast_dsp *dsp, int cadences);
66 /*! \brief Set expected lengths of the busy tone */
67 void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, int tonelength, int quietlength);
69 /*! \brief Scans for progress indication in audio */
70 int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf);
72 /*! \brief Set zone for doing progress detection */
73 int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone);
75 /*! \brief Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on
76 busies, and call progress, all dependent upon which features are enabled */
77 struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf);
79 /*! \brief Return non-zero if this is silence. Updates "totalsilence" with the total
80 number of seconds of silence */
81 int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence);
83 /*! \brief Return non-zero if historically this should be a busy, request that
84 ast_dsp_silence has already been called */
85 int ast_dsp_busydetect(struct ast_dsp *dsp);
87 /*! \brief Return non-zero if DTMF hit was found */
88 int ast_dsp_digitdetect(struct ast_dsp *dsp, struct ast_frame *f);
90 /*! \brief Reset total silence count */
91 void ast_dsp_reset(struct ast_dsp *dsp);
93 /*! \brief Reset DTMF detector */
94 void ast_dsp_digitreset(struct ast_dsp *dsp);
96 /*! \brief Select feature set */
97 void ast_dsp_set_features(struct ast_dsp *dsp, int features);
99 /*! \brief Get pending DTMF/MF digits */
100 int ast_dsp_getdigits(struct ast_dsp *dsp, char *buf, int max);
102 /*! \brief Set digit mode */
103 int ast_dsp_digitmode(struct ast_dsp *dsp, int digitmode);
105 /*! \brief Get tstate (Tone State) */
106 int ast_dsp_get_tstate(struct ast_dsp *dsp);
108 /*! \brief Get tcount (Threshold counter) */
109 int ast_dsp_get_tcount(struct ast_dsp *dsp);
112 * \brief Hint that a frame from a dsp was freed
114 * This is called from ast_frame_free if AST_FRFLAG_FROM_DSP is set. This occurs
115 * because it is possible for the dsp to be freed while someone still holds a reference
116 * to the frame that is in that dsp. This has been known to happen when the dsp on a Zap
117 * channel detects a busy signal. The channel is hung up, and the application that read the
118 * frame to begin with still has a reference to the frame.
120 * \return nothing
122 void ast_dsp_frame_freed(struct ast_frame *fr);
124 #endif /* _ASTERISK_DSP_H */