00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * private/t31.h - A T.31 compatible class 1 FAX modem interface. 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2004 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: t31.h,v 1.1 2008/10/13 13:14:01 steveu Exp $ 00026 */ 00027 00028 #if !defined(_SPANDSP_PRIVATE_T31_H_) 00029 #define _SPANDSP_PRIVATE_T31_H_ 00030 00031 /*! 00032 Analogue FAX front end channel descriptor. This defines the state of a single working 00033 instance of an analogue line FAX front end. 00034 */ 00035 typedef struct 00036 { 00037 fax_modems_state_t modems; 00038 00039 /*! The transmit signal handler to be used when the current one has finished sending. */ 00040 span_tx_handler_t *next_tx_handler; 00041 void *next_tx_user_data; 00042 00043 /*! \brief No of data bits in current_byte. */ 00044 int bit_no; 00045 /*! \brief The current data byte in progress. */ 00046 int current_byte; 00047 00048 /*! \brief Rx power meter, used to detect silence. */ 00049 power_meter_t rx_power; 00050 /*! \brief Last sample, used for an elementary HPF for the power meter. */ 00051 int16_t last_sample; 00052 /*! \brief The current silence threshold. */ 00053 int32_t silence_threshold_power; 00054 00055 /*! \brief Samples of silence heard */ 00056 int silence_heard; 00057 } t31_audio_front_end_state_t; 00058 00059 /*! 00060 Analogue FAX front end channel descriptor. This defines the state of a single working 00061 instance of an analogue line FAX front end. 00062 */ 00063 typedef struct 00064 { 00065 t38_core_state_t t38; 00066 00067 /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current 00068 rate and the current specified packet interval. */ 00069 int octets_per_data_packet; 00070 00071 int timed_step; 00072 00073 int ms_per_tx_chunk; 00074 int merge_tx_fields; 00075 00076 /*! \brief TRUE is there has been some T.38 data missed */ 00077 int missing_data; 00078 00079 /*! \brief The number of times an indicator packet will be sent. Numbers greater than one 00080 will increase reliability for UDP transmission. Zero is valid, to suppress all 00081 indicator packets for TCP transmission. */ 00082 int indicator_tx_count; 00083 00084 /*! \brief The number of times a data packet which ends transmission will be sent. Numbers 00085 greater than one will increase reliability for UDP transmission. Zero is not valid. */ 00086 int data_end_tx_count; 00087 00088 /*! \brief The current T.38 data type being transmitted */ 00089 int current_tx_data_type; 00090 /*! \brief The next queued tramsit indicator */ 00091 int next_tx_indicator; 00092 00093 int trailer_bytes; 00094 00095 struct 00096 { 00097 uint8_t buf[T31_T38_MAX_HDLC_LEN]; 00098 int len; 00099 } hdlc_rx; 00100 00101 int current_rx_type; 00102 int current_tx_type; 00103 00104 int32_t next_tx_samples; 00105 int32_t timeout_rx_samples; 00106 /*! \brief A "sample" count, used to time events */ 00107 int32_t samples; 00108 } t31_t38_front_end_state_t; 00109 00110 /*! 00111 T.31 descriptor. This defines the working state for a single instance of 00112 a T.31 FAX modem. 00113 */ 00114 struct t31_state_s 00115 { 00116 at_state_t at_state; 00117 t31_modem_control_handler_t *modem_control_handler; 00118 void *modem_control_user_data; 00119 00120 t31_audio_front_end_state_t audio; 00121 t31_t38_front_end_state_t t38_fe; 00122 /*! TRUE if working in T.38 mode. */ 00123 int t38_mode; 00124 00125 /*! HDLC buffer, for composing an HDLC frame from the computer to the channel. */ 00126 struct 00127 { 00128 uint8_t buf[T31_MAX_HDLC_LEN]; 00129 int len; 00130 int ptr; 00131 /*! \brief TRUE when the end of HDLC data from the computer has been detected. */ 00132 int final; 00133 } hdlc_tx; 00134 /*! Buffer for data from the computer to the channel. */ 00135 struct 00136 { 00137 uint8_t data[T31_TX_BUF_LEN]; 00138 /*! \brief The number of bytes stored in transmit buffer. */ 00139 int in_bytes; 00140 /*! \brief The number of bytes sent from the transmit buffer. */ 00141 int out_bytes; 00142 /*! \brief TRUE if the flow of real data has started. */ 00143 int data_started; 00144 /*! \brief TRUE if holding up further data into the buffer, for flow control. */ 00145 int holding; 00146 /*! \brief TRUE when the end of non-ECM data from the computer has been detected. */ 00147 int final; 00148 } tx; 00149 00150 /*! TRUE if DLE prefix just used */ 00151 int dled; 00152 00153 /*! \brief Samples of silence awaited, as specified in a "wait for silence" command */ 00154 int silence_awaited; 00155 00156 /*! \brief The current bit rate for the FAX fast message transfer modem. */ 00157 int bit_rate; 00158 /*! \brief TRUE if a valid HDLC frame has been received in the current reception period. */ 00159 int rx_frame_received; 00160 00161 /*! \brief Samples elapsed in the current call */ 00162 int64_t call_samples; 00163 int64_t dte_data_timeout; 00164 00165 /*! \brief The currently queued modem type. */ 00166 int modem; 00167 /*! \brief TRUE when short training mode has been selected by the computer. */ 00168 int short_train; 00169 queue_state_t *rx_queue; 00170 00171 /*! \brief Error and flow logging control */ 00172 logging_state_t logging; 00173 }; 00174 00175 #endif 00176 /*- End of file ------------------------------------------------------------*/