spandsp
0.0.6
Main Page
Related Pages
Classes
Files
File List
File Members
super_tone_rx.h
1
/*
2
* SpanDSP - a series of DSP components for telephony
3
*
4
* super_tone_rx.h - Flexible telephony supervisory tone detection.
5
*
6
* Written by Steve Underwood <steveu@coppice.org>
7
*
8
* Copyright (C) 2003 Steve Underwood
9
*
10
* All rights reserved.
11
*
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU Lesser General Public License version 2.1,
14
* as published by the Free Software Foundation.
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
20
*
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with this program; if not, write to the Free Software
23
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
*/
25
26
#if !defined(_SPANDSP_SUPER_TONE_RX_H_)
27
#define _SPANDSP_SUPER_TONE_RX_H_
28
29
/*! \page super_tone_rx_page Supervisory tone detection
30
31
\section super_tone_rx_page_sec_1 What does it do?
32
33
The supervisory tone detector may be configured to detect most of the world's
34
telephone supervisory tones - things like ringback, busy, number unobtainable,
35
and so on.
36
37
\section super_tone_rx_page_sec_2 How does it work?
38
39
The supervisory tone detector is passed a series of data structures describing
40
the tone patterns - the frequencies and cadencing - of the tones to be searched
41
for. It constructs one or more Goertzel filters to monitor the required tones.
42
If tones are close in frequency a single Goertzel set to the centre of the
43
frequency range will be used. This optimises the efficiency of the detector. The
44
Goertzel filters are applied without applying any special window functional
45
(i.e. they use a rectangular window), so they have a sinc like response.
46
However, for most tone patterns their rejection qualities are adequate.
47
48
The detector aims to meet the need of the standard call progress tones, to
49
ITU-T E.180/Q.35 (busy, dial, ringback, reorder). Also, the extended tones,
50
to ITU-T E.180, Supplement 2 and EIA/TIA-464-A (recall dial tone, special
51
ringback tone, intercept tone, call waiting tone, busy verification tone,
52
executive override tone, confirmation tone).
53
*/
54
55
/*! Tone detection indication callback routine */
56
typedef
void (*tone_report_func_t)(
void
*user_data,
int
code,
int
level,
int
delay);
57
58
typedef
struct
super_tone_rx_segment_s
super_tone_rx_segment_t
;
59
60
typedef
struct
super_tone_rx_descriptor_s
super_tone_rx_descriptor_t
;
61
62
typedef
struct
super_tone_rx_state_s
super_tone_rx_state_t
;
63
64
#if defined(__cplusplus)
65
extern
"C"
66
{
67
#endif
68
69
/*! Create a new supervisory tone detector descriptor.
70
\param desc The supervisory tone set desciptor. If NULL, the routine will allocate space for a
71
descriptor.
72
\return The supervisory tone set descriptor.
73
*/
74
SPAN_DECLARE(
super_tone_rx_descriptor_t
*)
super_tone_rx_make_descriptor
(
super_tone_rx_descriptor_t
*desc);
75
76
/*! Free a supervisory tone detector descriptor.
77
\param desc The supervisory tone set desciptor.
78
\return 0 for OK, -1 for fail.
79
*/
80
SPAN_DECLARE(
int
)
super_tone_rx_free_descriptor
(
super_tone_rx_descriptor_t
*desc);
81
82
/*! Add a new tone pattern to a supervisory tone detector set.
83
\param desc The supervisory tone set descriptor.
84
\return The new tone ID. */
85
SPAN_DECLARE(
int
)
super_tone_rx_add_tone
(
super_tone_rx_descriptor_t
*desc);
86
87
/*! Add a new tone pattern element to a tone pattern in a supervisory tone detector.
88
\param desc The supervisory tone set desciptor.
89
\param tone The tone ID within the descriptor.
90
\param f1 Frequency 1 (-1 for a silent period).
91
\param f2 Frequency 2 (-1 for a silent period, or only one frequency).
92
\param min The minimum duration, in ms.
93
\param max The maximum duration, in ms.
94
\return The new number of elements in the tone description.
95
*/
96
SPAN_DECLARE(
int
)
super_tone_rx_add_element
(
super_tone_rx_descriptor_t
*desc,
97
int
tone,
98
int
f1,
99
int
f2,
100
int
min,
101
int
max);
102
103
/*! Initialise a supervisory tone detector.
104
\param s The supervisory tone detector context.
105
\param desc The tone descriptor.
106
\param callback The callback routine called to report the valid detection or termination of
107
one of the monitored tones.
108
\param user_data An opaque pointer passed when calling the callback routine.
109
\return The supervisory tone detector context.
110
*/
111
SPAN_DECLARE(
super_tone_rx_state_t
*)
super_tone_rx_init
(
super_tone_rx_state_t
*s,
112
super_tone_rx_descriptor_t
*desc,
113
tone_report_func_t callback,
114
void
*user_data);
115
116
/*! Release a supervisory tone detector.
117
\param s The supervisory tone context.
118
\return 0 for OK, -1 for fail.
119
*/
120
SPAN_DECLARE(
int
)
super_tone_rx_release
(
super_tone_rx_state_t
*s);
121
122
/*! Free a supervisory tone detector.
123
\param s The supervisory tone context.
124
\return 0 for OK, -1 for fail.
125
*/
126
SPAN_DECLARE(
int
)
super_tone_rx_free
(
super_tone_rx_state_t
*s);
127
128
/*! Define a callback routine to be called each time a tone pattern element is complete. This is
129
mostly used when analysing a tone.
130
\param s The supervisory tone context.
131
\param callback The callback routine.
132
*/
133
SPAN_DECLARE(
void
)
super_tone_rx_segment_callback
(
super_tone_rx_state_t
*s,
134
void
(*callback)(
void
*data,
int
f1,
int
f2,
int
duration));
135
136
/*! Apply supervisory tone detection processing to a block of audio samples.
137
\brief Apply supervisory tone detection processing to a block of audio samples.
138
\param super The supervisory tone context.
139
\param amp The audio sample buffer.
140
\param samples The number of samples in the buffer.
141
\return The number of samples processed.
142
*/
143
SPAN_DECLARE(
int
)
super_tone_rx
(
super_tone_rx_state_t
*super, const int16_t amp[],
int
samples);
144
145
#if defined(__cplusplus)
146
}
147
#endif
148
149
#endif
150
/*- End of file ------------------------------------------------------------*/
src
spandsp
super_tone_rx.h
Generated on Thu Mar 20 2014 13:57:28 for spandsp by
1.8.1.2