spandsp
0.0.6
|
00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * v27ter_rx.h - ITU V.27ter modem receive part 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2003 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 /*! \file */ 00027 00028 #if !defined(_SPANDSP_V27TER_RX_H_) 00029 #define _SPANDSP_V27TER_RX_H_ 00030 00031 /*! \page v27ter_rx_page The V.27ter receiver 00032 00033 \section v27ter_rx_page_sec_1 What does it do? 00034 The V.27ter receiver implements the receive side of a V.27ter modem. This can operate 00035 at data rates of 4800 and 2400 bits/s. The audio input is a stream of 16 bit samples, 00036 at 8000 samples/second. The transmit and receive side of V.27ter modems operate 00037 independantly. V.27ter is mostly used for FAX transmission, where it provides the 00038 standard 4800 bits/s rate (the 2400 bits/s mode is not used for FAX). 00039 00040 \section v27ter_rx_page_sec_2 How does it work? 00041 V.27ter defines two modes of operation. One uses 8-PSK at 1600 baud, giving 4800bps. 00042 The other uses 4-PSK at 1200 baud, giving 2400bps. A training sequence is specified 00043 at the start of transmission, which makes the design of a V.27ter receiver relatively 00044 straightforward. 00045 */ 00046 00047 /*! 00048 V.27ter modem receive side descriptor. This defines the working state for a 00049 single instance of a V.27ter modem receiver. 00050 */ 00051 typedef struct v27ter_rx_state_s v27ter_rx_state_t; 00052 00053 #if defined(__cplusplus) 00054 extern "C" 00055 { 00056 #endif 00057 00058 /*! Initialise a V.27ter modem receive context. 00059 \brief Initialise a V.27ter modem receive context. 00060 \param s The modem context. 00061 \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800. 00062 \param put_bit The callback routine used to put the received data. 00063 \param user_data An opaque pointer passed to the put_bit routine. 00064 \return A pointer to the modem context, or NULL if there was a problem. */ 00065 SPAN_DECLARE(v27ter_rx_state_t *) v27ter_rx_init(v27ter_rx_state_t *s, int bit_rate, put_bit_func_t put_bit, void *user_data); 00066 00067 /*! Reinitialise an existing V.27ter modem receive context. 00068 \brief Reinitialise an existing V.27ter modem receive context. 00069 \param s The modem context. 00070 \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800. 00071 \param old_train TRUE if a previous trained values are to be reused. 00072 \return 0 for OK, -1 for bad parameter */ 00073 SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_train); 00074 00075 /*! Release a V.27ter modem receive context. 00076 \brief Release a V.27ter modem receive context. 00077 \param s The modem context. 00078 \return 0 for OK */ 00079 SPAN_DECLARE(int) v27ter_rx_release(v27ter_rx_state_t *s); 00080 00081 /*! Free a V.27ter modem receive context. 00082 \brief Free a V.27ter modem receive context. 00083 \param s The modem context. 00084 \return 0 for OK */ 00085 SPAN_DECLARE(int) v27ter_rx_free(v27ter_rx_state_t *s); 00086 00087 /*! Get the logging context associated with a V.27ter modem receive context. 00088 \brief Get the logging context associated with a V.27ter modem receive context. 00089 \param s The modem context. 00090 \return A pointer to the logging context */ 00091 SPAN_DECLARE(logging_state_t *) v27ter_rx_get_logging_state(v27ter_rx_state_t *s); 00092 00093 /*! Change the put_bit function associated with a V.27ter modem receive context. 00094 \brief Change the put_bit function associated with a V.27ter modem receive context. 00095 \param s The modem context. 00096 \param put_bit The callback routine used to handle received bits. 00097 \param user_data An opaque pointer. */ 00098 SPAN_DECLARE(void) v27ter_rx_set_put_bit(v27ter_rx_state_t *s, put_bit_func_t put_bit, void *user_data); 00099 00100 /*! Change the modem status report function associated with a V.27ter modem receive context. 00101 \brief Change the modem status report function associated with a V.27ter modem receive context. 00102 \param s The modem context. 00103 \param handler The callback routine used to report modem status changes. 00104 \param user_data An opaque pointer. */ 00105 SPAN_DECLARE(void) v27ter_rx_set_modem_status_handler(v27ter_rx_state_t *s, modem_rx_status_func_t handler, void *user_data); 00106 00107 /*! Process a block of received V.27ter modem audio samples. 00108 \brief Process a block of received V.27ter modem audio samples. 00109 \param s The modem context. 00110 \param amp The audio sample buffer. 00111 \param len The number of samples in the buffer. 00112 \return The number of samples unprocessed. 00113 */ 00114 SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], int len); 00115 00116 /*! Fake processing of a missing block of received V.27ter modem audio samples. 00117 (e.g due to packet loss). 00118 \brief Fake processing of a missing block of received V.27ter modem audio samples. 00119 \param s The modem context. 00120 \param len The number of samples to fake. 00121 \return The number of samples unprocessed. 00122 */ 00123 SPAN_DECLARE_NONSTD(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len); 00124 00125 /*! Get a snapshot of the current equalizer coefficients. 00126 \brief Get a snapshot of the current equalizer coefficients. 00127 \param coeffs The vector of complex coefficients. 00128 \return The number of coefficients in the vector. */ 00129 SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs); 00130 00131 /*! Get the current received carrier frequency. 00132 \param s The modem context. 00133 \return The frequency, in Hertz. */ 00134 SPAN_DECLARE(float) v27ter_rx_carrier_frequency(v27ter_rx_state_t *s); 00135 00136 /*! Get the current symbol timing correction since startup. 00137 \param s The modem context. 00138 \return The correction. */ 00139 SPAN_DECLARE(float) v27ter_rx_symbol_timing_correction(v27ter_rx_state_t *s); 00140 00141 /*! Get a current received signal power. 00142 \param s The modem context. 00143 \return The signal power, in dBm0. */ 00144 SPAN_DECLARE(float) v27ter_rx_signal_power(v27ter_rx_state_t *s); 00145 00146 /*! Set the power level at which the carrier detection will cut in 00147 \param s The modem context. 00148 \param cutoff The signal cutoff power, in dBm0. */ 00149 SPAN_DECLARE(void) v27ter_rx_signal_cutoff(v27ter_rx_state_t *s, float cutoff); 00150 00151 /*! Set a handler routine to process QAM status reports 00152 \param s The modem context. 00153 \param handler The handler routine. 00154 \param user_data An opaque pointer passed to the handler routine. */ 00155 SPAN_DECLARE(void) v27ter_rx_set_qam_report_handler(v27ter_rx_state_t *s, qam_report_handler_t handler, void *user_data); 00156 00157 #if defined(__cplusplus) 00158 } 00159 #endif 00160 00161 #endif 00162 /*- End of file ------------------------------------------------------------*/