comparison spandsp-0.0.6pre17/src/spandsp/v22bis.h @ 4:26cd8f1ef0b1

import spandsp-0.0.6pre17
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 15:50:58 +0200
parents
children
comparison
equal deleted inserted replaced
3:c6c5a16ce2f2 4:26cd8f1ef0b1
1 /*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * v22bis.h - ITU V.22bis modem
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2004 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 * $Id: v22bis.h,v 1.46 2009/11/04 15:52:06 steveu Exp $
26 */
27
28 /*! \file */
29
30 /*! \page v22bis_page The V.22bis modem
31 \section v22bis_page_sec_1 What does it do?
32 The V.22bis modem is a duplex modem for general data use on the PSTN, at rates
33 of 1200 and 2400 bits/second. It is a compatible extension of the V.22 modem,
34 which is a 1200 bits/second only design. It is a band-split design, using carriers
35 of 1200Hz and 2400Hz. It is the fastest PSTN modem in general use which does not
36 use echo-cancellation.
37
38 \section v22bis__page_sec_2 How does it work?
39 V.22bis uses 4PSK modulation at 1200 bits/second or 16QAM modulation at 2400
40 bits/second. At 1200bps the symbols are so long that a fixed compromise equaliser
41 is sufficient to recover the 4PSK signal reliably. At 2400bps an adaptive
42 equaliser is necessary.
43
44 The V.22bis training sequence includes sections which allow the modems to determine
45 if the far modem can support (or is willing to support) 2400bps operation. The
46 modems will automatically use 2400bps if both ends are willing to use that speed,
47 or 1200bps if one or both ends to not acknowledge that 2400bps is OK.
48 */
49
50 #if !defined(_SPANDSP_V22BIS_H_)
51 #define _SPANDSP_V22BIS_H_
52
53 enum
54 {
55 V22BIS_GUARD_TONE_NONE,
56 V22BIS_GUARD_TONE_550HZ,
57 V22BIS_GUARD_TONE_1800HZ
58 };
59
60 /*!
61 V.22bis modem descriptor. This defines the working state for a single instance
62 of a V.22bis modem.
63 */
64 typedef struct v22bis_state_s v22bis_state_t;
65
66 extern const complexf_t v22bis_constellation[16];
67
68 #if defined(__cplusplus)
69 extern "C"
70 {
71 #endif
72
73 /*! Process a block of received V.22bis modem audio samples.
74 \brief Process a block of received V.22bis modem audio samples.
75 \param s The modem context.
76 \param amp The audio sample buffer.
77 \param len The number of samples in the buffer.
78 \return The number of samples unprocessed. */
79 SPAN_DECLARE_NONSTD(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int len);
80
81 /*! Fake processing of a missing block of received V.22bis modem audio samples.
82 (e.g due to packet loss).
83 \brief Fake processing of a missing block of received V.22bis modem audio samples.
84 \param s The modem context.
85 \param len The number of samples to fake.
86 \return The number of samples unprocessed. */
87 SPAN_DECLARE(int) v22bis_rx_fillin(v22bis_state_t *s, int len);
88
89 /*! Get a snapshot of the current equalizer coefficients.
90 \brief Get a snapshot of the current equalizer coefficients.
91 \param coeffs The vector of complex coefficients.
92 \return The number of coefficients in the vector. */
93 SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexf_t **coeffs);
94
95 /*! Get the current received carrier frequency.
96 \param s The modem context.
97 \return The frequency, in Hertz. */
98 SPAN_DECLARE(float) v22bis_rx_carrier_frequency(v22bis_state_t *s);
99
100 /*! Get the current symbol timing correction since startup.
101 \param s The modem context.
102 \return The correction. */
103 SPAN_DECLARE(float) v22bis_rx_symbol_timing_correction(v22bis_state_t *s);
104
105 /*! Get a current received signal power.
106 \param s The modem context.
107 \return The signal power, in dBm0. */
108 SPAN_DECLARE(float) v22bis_rx_signal_power(v22bis_state_t *s);
109
110 /*! Set the power level at which the carrier detection will cut in
111 \param s The modem context.
112 \param cutoff The signal cutoff power, in dBm0. */
113 SPAN_DECLARE(void) v22bis_rx_signal_cutoff(v22bis_state_t *s, float cutoff);
114
115 /*! Set a handler routine to process QAM status reports
116 \param s The modem context.
117 \param handler The handler routine.
118 \param user_data An opaque pointer passed to the handler routine. */
119 SPAN_DECLARE(void) v22bis_rx_set_qam_report_handler(v22bis_state_t *s, qam_report_handler_t handler, void *user_data);
120
121 /*! Generate a block of V.22bis modem audio samples.
122 \brief Generate a block of V.22bis modem audio samples.
123 \param s The modem context.
124 \param amp The audio sample buffer.
125 \param len The number of samples to be generated.
126 \return The number of samples actually generated. */
127 SPAN_DECLARE_NONSTD(int) v22bis_tx(v22bis_state_t *s, int16_t amp[], int len);
128
129 /*! Adjust a V.22bis modem transmit context's power output.
130 \brief Adjust a V.22bis modem transmit context's output power.
131 \param s The modem context.
132 \param power The power level, in dBm0 */
133 SPAN_DECLARE(void) v22bis_tx_power(v22bis_state_t *s, float power);
134
135 /*! Reinitialise an existing V.22bis modem context, so it may be reused.
136 \brief Reinitialise an existing V.22bis modem context.
137 \param s The modem context.
138 \param bit_rate The bit rate of the modem. Valid values are 1200 and 2400.
139 \return 0 for OK, -1 for bad parameter. */
140 SPAN_DECLARE(int) v22bis_restart(v22bis_state_t *s, int bit_rate);
141
142 /*! Request a retrain for a V.22bis modem context. A rate change may also be requested.
143 \brief Request a retrain for a V.22bis modem context.
144 \param s The modem context.
145 \param bit_rate The bit rate of the modem. Valid values are 1200 and 2400.
146 \return 0 for OK, -1 for request rejected. */
147 SPAN_DECLARE(int) v22bis_request_retrain(v22bis_state_t *s, int bit_rate);
148
149 /*! Request a loopback 2 for a V.22bis modem context.
150 \brief Request a loopback 2 for a V.22bis modem context.
151 \param s The modem context.
152 \param enable TRUE to enable loopback, or FALSE to disable it.
153 \return 0 for OK, -1 for request reject. */
154 SPAN_DECLARE(int) v22bis_remote_loopback(v22bis_state_t *s, int enable);
155
156 /*! Report the current operating bit rate of a V.22bis modem context.
157 \brief Report the current operating bit rate of a V.22bis modem context
158 \param s The modem context. */
159 SPAN_DECLARE(int) v22bis_current_bit_rate(v22bis_state_t *s);
160
161 /*! Initialise a V.22bis modem context. This must be called before the first
162 use of the context, to initialise its contents.
163 \brief Initialise a V.22bis modem context.
164 \param s The modem context.
165 \param bit_rate The bit rate of the modem. Valid values are 1200 and 2400.
166 \param guard The guard tone option. 0 = none, 1 = 550Hz, 2 = 1800Hz.
167 \param calling_party TRUE if this is the calling modem.
168 \param get_bit The callback routine used to get the data to be transmitted.
169 \param put_bit The callback routine used to get the data to be transmitted.
170 \param user_data An opaque pointer, passed in calls to the get and put routines.
171 \return A pointer to the modem context, or NULL if there was a problem. */
172 SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s,
173 int bit_rate,
174 int guard,
175 int calling_party,
176 get_bit_func_t get_bit,
177 void *get_bit_user_data,
178 put_bit_func_t put_bit,
179 void *put_bit_user_data);
180
181 /*! Release a V.22bis modem receive context.
182 \brief Release a V.22bis modem receive context.
183 \param s The modem context.
184 \return 0 for OK */
185 SPAN_DECLARE(int) v22bis_release(v22bis_state_t *s);
186
187 /*! Free a V.22bis modem receive context.
188 \brief Free a V.22bis modem receive context.
189 \param s The modem context.
190 \return 0 for OK */
191 SPAN_DECLARE(int) v22bis_free(v22bis_state_t *s);
192
193 /*! Get the logging context associated with a V.22bis modem context.
194 \brief Get the logging context associated with a V.22bis modem context.
195 \param s The modem context.
196 \return A pointer to the logging context */
197 SPAN_DECLARE(logging_state_t *) v22bis_get_logging_state(v22bis_state_t *s);
198
199 /*! Change the get_bit function associated with a V.22bis modem context.
200 \brief Change the get_bit function associated with a V.22bis modem context.
201 \param s The modem context.
202 \param get_bit The callback routine used to get the data to be transmitted.
203 \param user_data An opaque pointer. */
204 SPAN_DECLARE(void) v22bis_set_get_bit(v22bis_state_t *s, get_bit_func_t get_bit, void *user_data);
205
206 /*! Change the get_bit function associated with a V.22bis modem context.
207 \brief Change the put_bit function associated with a V.22bis modem context.
208 \param s The modem context.
209 \param put_bit The callback routine used to process the data received.
210 \param user_data An opaque pointer. */
211 SPAN_DECLARE(void) v22bis_set_put_bit(v22bis_state_t *s, put_bit_func_t put_bit, void *user_data);
212
213 /*! Change the modem status report function associated with a V.22bis modem receive context.
214 \brief Change the modem status report function associated with a V.22bis modem receive context.
215 \param s The modem context.
216 \param handler The callback routine used to report modem status changes.
217 \param user_data An opaque pointer. */
218 SPAN_DECLARE(void) v22bis_set_modem_status_handler(v22bis_state_t *s, modem_rx_status_func_t handler, void *user_data);
219
220 #if defined(__cplusplus)
221 }
222 #endif
223
224 #endif
225 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.