00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * private/t38_gateway.h - A T.38, less the packet exchange part 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2005, 2006, 2007 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 * $Id: t38_gateway.h,v 1.3 2009/04/12 14:18:02 steveu Exp $ 00026 */ 00027 00028 /*! \file */ 00029 00030 #if !defined(_SPANDSP_PRIVATE_T38_GATEWAY_H_) 00031 #define _SPANDSP_PRIVATE_T38_GATEWAY_H_ 00032 00033 /*! 00034 T.38 gateway T.38 side channel descriptor. 00035 */ 00036 typedef struct 00037 { 00038 /*! Core T.38 IFP support */ 00039 t38_core_state_t t38; 00040 00041 /*! \brief TRUE if the NSF, NSC, and NSS are to be suppressed by altering 00042 their contents to something the far end will not recognise. */ 00043 int suppress_nsx_len[2]; 00044 /*! \brief TRUE if we need to corrupt the HDLC frame in progress, so the receiver cannot 00045 interpret it. The two values are for the two directions. */ 00046 int corrupt_current_frame[2]; 00047 00048 /*! \brief the current class of field being received - i.e. none, non-ECM or HDLC */ 00049 int current_rx_field_class; 00050 /*! \brief The T.38 indicator currently in use */ 00051 int in_progress_rx_indicator; 00052 00053 /*! \brief The current T.38 data type being sent. */ 00054 int current_tx_data_type; 00055 } t38_gateway_t38_state_t; 00056 00057 /*! 00058 T.38 gateway audio side channel descriptor. 00059 */ 00060 typedef struct 00061 { 00062 /*! \brief The FAX modem set for the audio side fo the gateway. */ 00063 fax_modems_state_t modems; 00064 /*! \brief The current receive signal handler. Actual receiving hop between this 00065 and a dummy receive routine. */ 00066 span_rx_handler_t *base_rx_handler; 00067 } t38_gateway_audio_state_t; 00068 00069 /*! 00070 T.38 gateway T.38 side state. 00071 */ 00072 typedef struct 00073 { 00074 /*! \brief non-ECM and HDLC modem receive data buffer. */ 00075 uint8_t data[T38_RX_BUF_LEN]; 00076 /*! \brief Current pointer into the data buffer. */ 00077 int data_ptr; 00078 /*! \brief The current octet being received as non-ECM data. */ 00079 unsigned int bit_stream; 00080 /*! \brief The number of bits taken from the modem for the current scan row. This 00081 is used during non-ECM transmission will fill bit removal to see that 00082 T.38 packet transmissions do not stretch too far apart. */ 00083 int bits_absorbed; 00084 /*! \brief The current bit number in the current non-ECM octet. */ 00085 int bit_no; 00086 /*! \brief Progressively calculated CRC for HDLC messages received from a modem. */ 00087 uint16_t crc; 00088 /*! \brief TRUE if non-ECM fill bits are to be stripped when sending image data. */ 00089 int fill_bit_removal; 00090 /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current 00091 rate and the current specified packet interval. */ 00092 int octets_per_data_packet; 00093 00094 /*! \brief Bits into the non-ECM buffer */ 00095 int in_bits; 00096 /*! \brief Octets fed out from the non-ECM buffer */ 00097 int out_octets; 00098 } t38_gateway_to_t38_state_t; 00099 00100 /*! 00101 T.38 gateway HDLC buffer. 00102 */ 00103 typedef struct 00104 { 00105 /*! \brief HDLC message buffers. */ 00106 uint8_t buf[T38_MAX_HDLC_LEN]; 00107 /*! \brief HDLC message lengths. */ 00108 int len; 00109 /*! \brief HDLC message status flags. */ 00110 int flags; 00111 /*! \brief HDLC buffer contents. */ 00112 int contents; 00113 } t38_gateway_hdlc_buf_t; 00114 00115 /*! 00116 T.38 gateway HDLC state. 00117 */ 00118 typedef struct 00119 { 00120 /*! \brief HDLC message buffers. */ 00121 t38_gateway_hdlc_buf_t buf[T38_TX_HDLC_BUFS]; 00122 #if 0 00123 /*! \brief HDLC message buffers. */ 00124 uint8_t buf[T38_TX_HDLC_BUFS][T38_MAX_HDLC_LEN]; 00125 /*! \brief HDLC message lengths. */ 00126 int len[T38_TX_HDLC_BUFS]; 00127 /*! \brief HDLC message status flags. */ 00128 int flags[T38_TX_HDLC_BUFS]; 00129 /*! \brief HDLC buffer contents. */ 00130 int contents[T38_TX_HDLC_BUFS]; 00131 #endif 00132 /*! \brief HDLC buffer number for input. */ 00133 int in; 00134 /*! \brief HDLC buffer number for output. */ 00135 int out; 00136 } t38_gateway_hdlc_state_t; 00137 00138 /*! 00139 T.38 gateway core descriptor. 00140 */ 00141 typedef struct 00142 { 00143 /*! \brief A bit mask of the currently supported modem types. */ 00144 int supported_modems; 00145 /*! \brief TRUE if ECM FAX mode is allowed through the gateway. */ 00146 int ecm_allowed; 00147 00148 /*! \brief TRUE if in image data modem is to use short training. This usually 00149 follows image_data_mode, but in ECM mode T.30 defines recovery 00150 conditions in which long training is used for image data. */ 00151 int short_train; 00152 /*! \brief TRUE if in image data mode, as opposed to TCF mode. */ 00153 int image_data_mode; 00154 /*! \brief The minimum permitted bits per FAX scan line row. */ 00155 int min_row_bits; 00156 00157 /*! \brief TRUE if we should count the next MCF as a page end, else FALSE */ 00158 int count_page_on_mcf; 00159 /*! \brief The number of pages for which a confirm (MCF) message was returned. */ 00160 int pages_confirmed; 00161 00162 /*! \brief TRUE if we are in error correcting (ECM) mode */ 00163 int ecm_mode; 00164 /*! \brief The current bit rate for the fast modem. */ 00165 int fast_bit_rate; 00166 /*! \brief The current fast modem type. */ 00167 int fast_modem; 00168 /*! \brief The type of fast receive modem currently active, which may be T38_NONE */ 00169 int fast_rx_active; 00170 00171 /*! \brief TRUE if between DCS and TCF, and we want the fast image modem to 00172 start in the T.38 data at a predictable time from the end of the 00173 V.21 signal. */ 00174 int tcf_mode_predictable_modem_start; 00175 00176 /*! \brief The number of samples until the next timeout event */ 00177 int samples_to_timeout; 00178 00179 /*! Buffer for HDLC and non-ECM data going to the T.38 channel */ 00180 t38_gateway_to_t38_state_t to_t38; 00181 /*! Buffer for data going to an HDLC modem. */ 00182 t38_gateway_hdlc_state_t hdlc_to_modem; 00183 /*! Buffer for data going to a non-ECM mode modem. */ 00184 t38_non_ecm_buffer_state_t non_ecm_to_modem; 00185 00186 /*! \brief A pointer to a callback routine to be called when frames are 00187 exchanged. */ 00188 t38_gateway_real_time_frame_handler_t *real_time_frame_handler; 00189 /*! \brief An opaque pointer supplied in real time frame callbacks. */ 00190 void *real_time_frame_user_data; 00191 } t38_gateway_core_state_t; 00192 00193 /*! 00194 T.38 gateway state. 00195 */ 00196 struct t38_gateway_state_s 00197 { 00198 /*! T.38 side state */ 00199 t38_gateway_t38_state_t t38x; 00200 /*! Audio side state */ 00201 t38_gateway_audio_state_t audio; 00202 /*! T.38 core state */ 00203 t38_gateway_core_state_t core; 00204 00205 /*! \brief Error and flow logging control */ 00206 logging_state_t logging; 00207 }; 00208 00209 #endif 00210 /*- End of file ------------------------------------------------------------*/