00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * v18.h - V.18 text telephony for the deaf. 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2004-2009 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 /*! \page v18_page The V.18 text telephony protocols 00029 \section v18_page_sec_1 What does it do? 00030 00031 \section v18_page_sec_2 How does it work? 00032 */ 00033 00034 #if !defined(_SPANDSP_V18_H_) 00035 #define _SPANDSP_V18_H_ 00036 00037 typedef struct v18_state_s v18_state_t; 00038 00039 enum 00040 { 00041 V18_MODE_NONE = 0, 00042 /* V.18 Annex A - Weitbrecht TDD at 45.45bps (US TTY), half-duplex, 5 bit baudot (USA). */ 00043 V18_MODE_5BIT_45 = 1, 00044 /* V.18 Annex A - Weitbrecht TDD at 50bps (International TTY), half-duplex, 5 bit baudot (UK, Australia and others). */ 00045 V18_MODE_5BIT_50 = 2, 00046 /* V.18 Annex B - DTMF encoding of ASCII (Denmark, Holland and others). */ 00047 V18_MODE_DTMF = 3, 00048 /* V.18 Annex C - EDT (European Deaf Telephone) 110bps, V.21, half-duplex, ASCII (Germany, Austria, Switzerland and others). */ 00049 V18_MODE_EDT = 4, 00050 /* V.18 Annex D - 300bps, Bell 103, duplex, ASCII (USA). */ 00051 V18_MODE_BELL103 = 5, 00052 /* V.18 Annex E - 1200bps Videotex terminals, ASCII (France). */ 00053 V18_MODE_V23VIDEOTEX = 6, 00054 /* V.18 Annex F - V.21 text telephone, V.21, duplex, ASCII (Sweden, Norway and Finland). */ 00055 V18_MODE_V21TEXTPHONE = 7, 00056 /* V.18 Annex G - V.18 text telephone mode. */ 00057 V18_MODE_V18TEXTPHONE = 8 00058 }; 00059 00060 /* Automoding sequences for different countries */ 00061 enum 00062 { 00063 /* 5-bit, V.21, V.23, EDT, DTMF, Bell 103 */ 00064 V18_AUTOMODING_AUSTRALIA, 00065 V18_AUTOMODING_IRELAND, 00066 00067 /* EDT, V.21, V.23, 5-bit, DTMF, Bell 103 */ 00068 V18_AUTOMODING_GERMANY, 00069 V18_AUTOMODING_SWITZERLAND, 00070 V18_AUTOMODING_ITALY, 00071 V18_AUTOMODING_SPAIN, 00072 V18_AUTOMODING_AUSTRIA, 00073 00074 /* DTMF, V.21, V.23, 5-bit, EDT, Bell 103 */ 00075 V18_AUTOMODING_NETHERLANDS, 00076 00077 /* V.21, DTMF, 5-bit, EDT, V.23, Bell 103 */ 00078 V18_AUTOMODING_ICELAND, 00079 V18_AUTOMODING_NORWAY, 00080 V18_AUTOMODING_SWEDEN, 00081 V18_AUTOMODING_FINALND, 00082 V18_AUTOMODING_DENMARK, 00083 00084 /* V.21, 5-bit, V.23, EDT, DTMF, Bell 103 */ 00085 V18_AUTOMODING_UK, 00086 00087 /* 5-bit, Bell 103, V.21, V.23, EDT, DTMF */ 00088 V18_AUTOMODING_USA, 00089 00090 /* V.23, EDT, DTMF, 5-bit, V.21, Bell 103 */ 00091 V18_AUTOMODING_FRANCE, 00092 V18_AUTOMODING_BELGIUM 00093 }; 00094 00095 #if defined(__cplusplus) 00096 extern "C" 00097 { 00098 #endif 00099 00100 SPAN_DECLARE(logging_state_t *) v18_get_logging_state(v18_state_t *s); 00101 00102 /*! Initialise a V.18 context. 00103 \brief Initialise a V.18 context. 00104 \param s The V.18 context. 00105 \param calling_party TRUE if caller mode, else answerer mode. 00106 \param mode Mode of operation. 00107 \param put_msg A callback routine called to deliver the received text 00108 to the application. 00109 \param user_data An opaque pointer for the callback routine. 00110 \return A pointer to the V.18 context, or NULL if there was a problem. */ 00111 SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s, 00112 int calling_party, 00113 int mode, 00114 put_msg_func_t put_msg, 00115 void *user_data); 00116 00117 /*! Release a V.18 context. 00118 \brief Release a V.18 context. 00119 \param s The V.18 context. 00120 \return 0 for OK. */ 00121 SPAN_DECLARE(int) v18_release(v18_state_t *s); 00122 00123 /*! Free a V.18 context. 00124 \brief Release a V.18 context. 00125 \param s The V.18 context. 00126 \return 0 for OK. */ 00127 SPAN_DECLARE(int) v18_free(v18_state_t *s); 00128 00129 /*! Generate a block of V.18 audio samples. 00130 \brief Generate a block of V.18 audio samples. 00131 \param s The V.18 context. 00132 \param amp The audio sample buffer. 00133 \param max_len The number of samples to be generated. 00134 \return The number of samples actually generated. 00135 */ 00136 SPAN_DECLARE_NONSTD(int) v18_tx(v18_state_t *s, int16_t amp[], int max_len); 00137 00138 /*! Process a block of received V.18 audio samples. 00139 \brief Process a block of received V.18 audio samples. 00140 \param s The V.18 context. 00141 \param amp The audio sample buffer. 00142 \param len The number of samples in the buffer. 00143 */ 00144 SPAN_DECLARE_NONSTD(int) v18_rx(v18_state_t *s, const int16_t amp[], int len); 00145 00146 /*! \brief Put a string to a V.18 context's input buffer. 00147 \param s The V.18 context. 00148 \param msg The string to be added. 00149 \param len The length of the string. If negative, the string is 00150 assumed to be a NULL terminated string. 00151 \return The number of characters actually added. This may be less than the 00152 length of the digit string, if the buffer fills up. If the string is 00153 invalid, this function will return -1. */ 00154 SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len); 00155 00156 /*! Convert a text string to a V.18 DTMF string. 00157 \brief Convert a text string to a V.18 DTMF string. 00158 \param s The V.18 context. 00159 \param dtmf The resulting DTMF string. 00160 \param msg The text string to be converted. 00161 \return The length of the DTMF string. 00162 */ 00163 SPAN_DECLARE(int) v18_encode_dtmf(v18_state_t *s, char dtmf[], const char msg[]); 00164 00165 /*! Convert a V.18 DTMF string to a text string. 00166 \brief Convert a V.18 DTMF string to a text string. 00167 \param s The V.18 context. 00168 \param msg The resulting test string. 00169 \param dtmf The DTMF string to be converted. 00170 \return The length of the text string. 00171 */ 00172 SPAN_DECLARE(int) v18_decode_dtmf(v18_state_t *s, char msg[], const char dtmf[]); 00173 00174 SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch); 00175 00176 SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch); 00177 00178 /*! \brief Return a short name for an V.18 mode 00179 \param mode The code for the V.18 mode. 00180 \return A pointer to the name. 00181 */ 00182 SPAN_DECLARE(const char *) v18_mode_to_str(int mode); 00183 00184 #if defined(__cplusplus) 00185 } 00186 #endif 00187 00188 #endif 00189 /*- End of file ------------------------------------------------------------*/
1.6.1