comparison spandsp-0.0.6pre17/src/spandsp/private/t31.h @ 4:26cd8f1ef0b1

import spandsp-0.0.6pre17
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 15:50:58 +0200
parents
children
comparison
equal deleted inserted replaced
3:c6c5a16ce2f2 4:26cd8f1ef0b1
1 /*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * private/t31.h - A T.31 compatible class 1 FAX modem interface.
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2004 Steve Underwood
9 *
10 * All rights reserved.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 2.1,
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * $Id: t31.h,v 1.7 2009/02/12 12:38:39 steveu Exp $
26 */
27
28 #if !defined(_SPANDSP_PRIVATE_T31_H_)
29 #define _SPANDSP_PRIVATE_T31_H_
30
31 /*!
32 Analogue FAX front end channel descriptor. This defines the state of a single working
33 instance of an analogue line FAX front end.
34 */
35 typedef struct
36 {
37 fax_modems_state_t modems;
38
39 /*! The transmit signal handler to be used when the current one has finished sending. */
40 span_tx_handler_t *next_tx_handler;
41 void *next_tx_user_data;
42
43 /*! \brief No of data bits in current_byte. */
44 int bit_no;
45 /*! \brief The current data byte in progress. */
46 int current_byte;
47
48 /*! \brief Rx power meter, used to detect silence. */
49 power_meter_t rx_power;
50 /*! \brief Last sample, used for an elementary HPF for the power meter. */
51 int16_t last_sample;
52 /*! \brief The current silence threshold. */
53 int32_t silence_threshold_power;
54
55 /*! \brief Samples of silence heard */
56 int silence_heard;
57 } t31_audio_front_end_state_t;
58
59 /*!
60 Analogue FAX front end channel descriptor. This defines the state of a single working
61 instance of an analogue line FAX front end.
62 */
63 typedef struct
64 {
65 /*! \brief Internet Aware FAX mode bit mask. */
66 int iaf;
67 /*! \brief Required time between T.38 transmissions, in ms. */
68 int ms_per_tx_chunk;
69 /*! \brief Bit fields controlling the way data is packed into chunked for transmission. */
70 int chunking_modes;
71
72 /*! \brief Core T.38 IFP support */
73 t38_core_state_t t38;
74
75 /*! \brief The current transmit step being timed */
76 int timed_step;
77
78 /*! \brief TRUE is there has been some T.38 data missed */
79 int rx_data_missing;
80
81 /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current
82 rate and the current specified packet interval. */
83 int octets_per_data_packet;
84
85 /*! \brief An HDLC context used when sending HDLC messages to the terminal port
86 (ECM mode support). */
87 hdlc_tx_state_t hdlc_tx_term;
88 /*! \brief An HDLC context used when receiving HDLC messages from the terminal port.
89 (ECM mode support). */
90 hdlc_rx_state_t hdlc_rx_term;
91
92 struct
93 {
94 uint8_t buf[T31_T38_MAX_HDLC_LEN];
95 int len;
96 } hdlc_rx;
97
98 struct
99 {
100 /*! \brief The number of extra bits in a fully stuffed version of the
101 contents of the HDLC transmit buffer. This is needed to accurately
102 estimate the playout time for this frame, through an analogue modem. */
103 int extra_bits;
104 } hdlc_tx;
105
106 /*! \brief TRUE if we are using ECM mode. This is used to select HDLC faking, necessary
107 with clunky class 1 modems. */
108 int ecm_mode;
109
110 /*! \brief Counter for trailing non-ECM bytes, used to flush out the far end's modem. */
111 int non_ecm_trailer_bytes;
112
113 /*! \brief The next queued tramsit indicator */
114 int next_tx_indicator;
115 /*! \brief The current T.38 data type being transmitted */
116 int current_tx_data_type;
117
118 /*! \brief The current operating mode of the receiver. */
119 int current_rx_type;
120 /*! \brief The current operating mode of the transmitter. */
121 int current_tx_type;
122
123 /*! \brief Current transmission bit rate. */
124 int tx_bit_rate;
125 /*! \brief A "sample" count, used to time events. */
126 int32_t samples;
127 /*! \brief The value for samples at the next transmission point. */
128 int32_t next_tx_samples;
129 /*! \brief The current receive timeout. */
130 int32_t timeout_rx_samples;
131 } t31_t38_front_end_state_t;
132
133 /*!
134 T.31 descriptor. This defines the working state for a single instance of
135 a T.31 FAX modem.
136 */
137 struct t31_state_s
138 {
139 at_state_t at_state;
140 t31_modem_control_handler_t *modem_control_handler;
141 void *modem_control_user_data;
142
143 t31_audio_front_end_state_t audio;
144 t31_t38_front_end_state_t t38_fe;
145 /*! TRUE if working in T.38 mode. */
146 int t38_mode;
147
148 /*! HDLC buffer, for composing an HDLC frame from the computer to the channel. */
149 struct
150 {
151 uint8_t buf[T31_MAX_HDLC_LEN];
152 int len;
153 int ptr;
154 /*! \brief TRUE when the end of HDLC data from the computer has been detected. */
155 int final;
156 } hdlc_tx;
157 /*! Buffer for data from the computer to the channel. */
158 struct
159 {
160 uint8_t data[T31_TX_BUF_LEN];
161 /*! \brief The number of bytes stored in transmit buffer. */
162 int in_bytes;
163 /*! \brief The number of bytes sent from the transmit buffer. */
164 int out_bytes;
165 /*! \brief TRUE if the flow of real data has started. */
166 int data_started;
167 /*! \brief TRUE if holding up further data into the buffer, for flow control. */
168 int holding;
169 /*! \brief TRUE when the end of non-ECM data from the computer has been detected. */
170 int final;
171 } tx;
172
173 /*! TRUE if DLE prefix just used */
174 int dled;
175
176 /*! \brief Samples of silence awaited, as specified in a "wait for silence" command */
177 int silence_awaited;
178
179 /*! \brief The current bit rate for the FAX fast message transfer modem. */
180 int bit_rate;
181 /*! \brief TRUE if a valid HDLC frame has been received in the current reception period. */
182 int rx_frame_received;
183
184 /*! \brief Samples elapsed in the current call */
185 int64_t call_samples;
186 int64_t dte_data_timeout;
187
188 /*! \brief The currently queued modem type. */
189 int modem;
190 /*! \brief TRUE when short training mode has been selected by the computer. */
191 int short_train;
192 queue_state_t *rx_queue;
193
194 /*! \brief Error and flow logging control */
195 logging_state_t logging;
196 };
197
198 #endif
199 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.