private/t31.h

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 
00026 #if !defined(_SPANDSP_PRIVATE_T31_H_)
00027 #define _SPANDSP_PRIVATE_T31_H_
00028 
00029 /*!
00030     Analogue FAX front end channel descriptor. This defines the state of a single working
00031     instance of an analogue line FAX front end.
00032 */
00033 typedef struct
00034 {
00035     fax_modems_state_t modems;
00036     //v8_state_t v8;
00037 
00038     /*! The transmit signal handler to be used when the current one has finished sending. */
00039     span_tx_handler_t *next_tx_handler;
00040     void *next_tx_user_data;
00041 
00042     /*! \brief No of data bits in current_byte. */
00043     int bit_no;
00044     /*! \brief The current data byte in progress. */
00045     int current_byte;
00046 
00047     /*! \brief Rx power meter, used to detect silence. */
00048     power_meter_t rx_power;
00049     /*! \brief Last sample, used for an elementary HPF for the power meter. */
00050     int16_t last_sample;
00051     /*! \brief The current silence threshold. */
00052     int32_t silence_threshold_power;
00053 
00054     /*! \brief Samples of silence heard */
00055     int silence_heard;
00056 } t31_audio_front_end_state_t;
00057 
00058 /*!
00059     Analogue FAX front end channel descriptor. This defines the state of a single working
00060     instance of an analogue line FAX front end.
00061 */
00062 typedef struct
00063 {
00064     /*! \brief Internet Aware FAX mode bit mask. */
00065     int iaf;
00066     /*! \brief Required time between T.38 transmissions, in ms. */
00067     int ms_per_tx_chunk;
00068     /*! \brief Bit fields controlling the way data is packed into chunked for transmission. */
00069     int chunking_modes;
00070 
00071     /*! \brief Core T.38 IFP support */
00072     t38_core_state_t t38;
00073 
00074     /*! \brief The current transmit step being timed */
00075     int timed_step;
00076 
00077     /*! \brief TRUE is there has been some T.38 data missed */
00078     int rx_data_missing;
00079 
00080     /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current
00081                rate and the current specified packet interval. */
00082     int octets_per_data_packet;
00083 
00084     /*! \brief An HDLC context used when sending HDLC messages to the terminal port
00085                (ECM mode support). */
00086     hdlc_tx_state_t hdlc_tx_term;
00087     /*! \brief An HDLC context used when receiving HDLC messages from the terminal port.
00088                (ECM mode support). */
00089     hdlc_rx_state_t hdlc_rx_term;
00090 
00091     struct
00092     {
00093         uint8_t buf[T31_T38_MAX_HDLC_LEN];
00094         int len;
00095     } hdlc_rx;
00096 
00097     struct
00098     {
00099         /*! \brief The number of extra bits in a fully stuffed version of the
00100                    contents of the HDLC transmit buffer. This is needed to accurately
00101                    estimate the playout time for this frame, through an analogue modem. */
00102         int extra_bits;
00103     } hdlc_tx;
00104 
00105     /*! \brief TRUE if we are using ECM mode. This is used to select HDLC faking, necessary
00106                with clunky class 1 modems. */
00107     int ecm_mode;
00108 
00109     /*! \brief Counter for trailing non-ECM bytes, used to flush out the far end's modem. */
00110     int non_ecm_trailer_bytes;
00111 
00112     /*! \brief The next queued tramsit indicator */
00113     int next_tx_indicator;
00114     /*! \brief The current T.38 data type being transmitted */
00115     int current_tx_data_type;
00116 
00117     /*! \brief The current operating mode of the receiver. */
00118     int current_rx_type;
00119     /*! \brief The current operating mode of the transmitter. */
00120     int current_tx_type;
00121 
00122     /*! \brief Current transmission bit rate. */
00123     int tx_bit_rate;
00124     /*! \brief A "sample" count, used to time events. */
00125     int32_t samples;
00126     /*! \brief The value for samples at the next transmission point. */
00127     int32_t next_tx_samples;
00128     /*! \brief The current receive timeout. */
00129     int32_t timeout_rx_samples;
00130 } t31_t38_front_end_state_t;
00131 
00132 /*!
00133     T.31 descriptor. This defines the working state for a single instance of
00134     a T.31 FAX modem.
00135 */
00136 struct t31_state_s
00137 {
00138     at_state_t at_state;
00139     t31_modem_control_handler_t *modem_control_handler;
00140     void *modem_control_user_data;
00141 
00142     t31_audio_front_end_state_t audio;
00143     t31_t38_front_end_state_t t38_fe;
00144     /*! TRUE if working in T.38 mode. */
00145     int t38_mode;
00146 
00147     /*! HDLC buffer, for composing an HDLC frame from the computer to the channel. */
00148     struct
00149     {
00150         uint8_t buf[T31_MAX_HDLC_LEN];
00151         int len;
00152         int ptr;
00153         /*! \brief TRUE when the end of HDLC data from the computer has been detected. */
00154         int final;
00155     } hdlc_tx;
00156     /*! Buffer for data from the computer to the channel. */
00157     struct
00158     {
00159         uint8_t data[T31_TX_BUF_LEN];
00160         /*! \brief The number of bytes stored in transmit buffer. */
00161         int in_bytes;
00162         /*! \brief The number of bytes sent from the transmit buffer. */
00163         int out_bytes;
00164         /*! \brief TRUE if the flow of real data has started. */
00165         int data_started;
00166         /*! \brief TRUE if holding up further data into the buffer, for flow control. */
00167         int holding;
00168         /*! \brief TRUE when the end of non-ECM data from the computer has been detected. */
00169         int final;
00170     } tx;
00171 
00172     /*! TRUE if DLE prefix just used */
00173     int dled;
00174 
00175         /*! \brief Samples of silence awaited, as specified in a "wait for silence" command */
00176     int silence_awaited;
00177 
00178     /*! \brief The current bit rate for the FAX fast message transfer modem. */
00179     int bit_rate;
00180     /*! \brief TRUE if a valid HDLC frame has been received in the current reception period. */
00181     int rx_frame_received;
00182 
00183     /*! \brief Samples elapsed in the current call */
00184     int64_t call_samples;
00185     int64_t dte_data_timeout;
00186 
00187     /*! \brief The currently queued modem type. */
00188     int modem;
00189     /*! \brief TRUE when short training mode has been selected by the computer. */
00190     int short_train;
00191     queue_state_t *rx_queue;
00192 
00193     /*! \brief Error and flow logging control */
00194     logging_state_t logging;
00195 };
00196 
00197 #endif
00198 /*- End of file ------------------------------------------------------------*/

Generated on 18 Oct 2012 for spandsp by  doxygen 1.6.1