spandsp 3.0.0
private/t31.h
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
26#if !defined(_SPANDSP_PRIVATE_T31_H_)
27#define _SPANDSP_PRIVATE_T31_H_
28
29#define T31_TX_BUF_LEN (4096)
30#define T31_TX_BUF_HIGH_TIDE (4096 - 1024)
31#define T31_TX_BUF_LOW_TIDE (1024)
32
33#define T31_MAX_HDLC_LEN 284
34/*! The maximum length of an HDLC frame buffer. This must be big enough for ECM frames. */
35#define T31_T38_MAX_HDLC_LEN 260
36/*! The number of HDLC transmit buffers */
37#define T31_TX_HDLC_BUFS 256
38
39/*!
40 T.31 T.38 HDLC buffer.
41*/
42typedef struct
43{
44 /*! \brief HDLC message buffers. */
45 uint8_t buf[T31_MAX_HDLC_LEN];
46 /*! \brief HDLC message lengths. */
47 int16_t len;
49
50/*!
51 T.31 T.38 HDLC state.
52*/
53typedef struct
54{
55 /*! \brief HDLC message buffers. */
56 t31_hdlc_buf_t buf[T31_TX_HDLC_BUFS];
57 /*! \brief HDLC buffer number for input. */
58 int in;
59 /*! \brief HDLC buffer number for output. */
60 int out;
62
63/*!
64 Analogue FAX front end channel descriptor. This defines the state of a single working
65 instance of an analogue line FAX front end.
66*/
67typedef struct
68{
69 fax_modems_state_t modems;
70 v8_state_t v8;
71
72 /*! The transmit signal handler to be used when the current one has finished sending. */
73 span_tx_handler_t next_tx_handler;
74 void *next_tx_user_data;
75
76 /*! \brief No of data bits in current_byte. */
77 int bit_no;
78 /*! \brief The current data byte in progress. */
80
81 /*! \brief Rx power meter, used to detect silence. */
82 power_meter_t rx_power;
83 /*! \brief Last sample, used for an elementary HPF for the power meter. */
84 int16_t last_sample;
85 /*! \brief The current silence threshold. */
87
88 /*! \brief Samples of silence heard */
91
92/*!
93 Analogue FAX front end channel descriptor. This defines the state of a single working
94 instance of an analogue line FAX front end.
95*/
96typedef struct
97{
98 /*! \brief Internet Aware FAX mode bit mask. */
99 int iaf;
100 /*! \brief Required time between T.38 transmissions, in us. */
102 /*! \brief Bit fields controlling the way data is packed into chunked for transmission. */
104
105 /*! \brief Core T.38 IFP support */
107
108 /*! \brief The current transmit step being timed */
110
111 /*! \brief True is there has been some T.38 data missed */
113
114 /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current
115 rate and the current specified packet interval. */
117
118 /*! \brief An HDLC context used when sending HDLC messages to the terminal port
119 as if it were non-ECM data (ECM mode support). */
121 /*! \brief An HDLC context used when receiving HDLC messages from the terminal port.
122 as if it were non-ECM data (ECM mode support). */
124
125 struct
126 {
127 uint8_t buf[T31_T38_MAX_HDLC_LEN];
128 int len;
129 } hdlc_rx;
130
131 struct
132 {
133 /*! \brief The number of extra bits in a fully stuffed version of the
134 contents of the HDLC transmit buffer. This is needed to accurately
135 estimate the playout time for this frame, through an analogue modem. */
137 } hdlc_tx;
138
139 t31_hdlc_state_t hdlc_from_t31;
140
141 /*! \brief True if we are using ECM mode. This is used to select HDLC faking, which is
142 necessary with clunky class 1 modems. */
144
145 /*! \brief Counter for trailing non-ECM bytes, used to flush out the far end's modem. */
147
148 /*! \brief The next queued tramsit indicator */
150 /*! \brief The current T.38 data type being transmitted */
152
153 /*! \brief The current operating mode of the receiver. */
155 /*! \brief The current operating mode of the transmitter. */
157
158 /*! \brief Current transmission bit rate. */
160 /*! \brief A "sample" count, used to time events. */
161 int32_t samples;
162 /*! \brief The value for samples at the next transmission point. */
164 /*! \brief The current transmit timeout. */
166 /*! \brief The current receive timeout. */
169
170/*!
171 T.31 descriptor. This defines the working state for a single instance of
172 a T.31 FAX modem.
173*/
175{
176 at_state_t at_state;
177 t31_modem_control_handler_t modem_control_handler;
178 void *modem_control_user_data;
179
182 /*! True if working in T.38 mode. */
184
185 /*! HDLC buffer, for composing an HDLC frame from the computer to the channel. */
186 struct
187 {
188 /*! \brief The HDLC transmit buffer. */
189 uint8_t buf[T31_MAX_HDLC_LEN];
190 int len;
191 int ptr;
192 /*! \brief True when the end of HDLC data from the computer has been detected. */
193 bool final;
195 /*! Buffer for data from the computer to the channel. */
196 struct
197 {
198 /*! \brief The transmit buffer. */
199 uint8_t buf[T31_TX_BUF_LEN];
200 /*! \brief The number of bytes stored in the transmit buffer. */
202 /*! \brief The number of bytes sent from the transmit buffer. */
204 /*! \brief True if the flow of real data has started. */
206 /*! \brief True if holding up further data into the buffer, for flow control. */
208 /*! \brief True when the end of non-ECM data from the computer has been detected. */
209 bool final;
211
212 /*! True if DLE prefix just used */
213 bool dled;
214
215 /*! \brief Samples of silence awaited, as specified in a "wait for silence" command */
217
218 /*! \brief The current bit rate for the FAX fast message transfer modem. */
220 /*! \brief True if a valid HDLC frame has been received in the current reception period. */
222
223 /*! \brief Samples elapsed in the current call */
225 int64_t dte_data_timeout;
226
227 /*! \brief The currently queued modem type. */
228 int modem;
229 /*! \brief True when short training mode has been selected by the computer. */
231 queue_state_t *rx_queue;
232
233 /*! \brief Error and flow logging control */
235};
236
237#endif
238/*- End of file ------------------------------------------------------------*/
struct fax_modems_state_s fax_modems_state_t
Definition fax_modems.h:59
struct hdlc_rx_state_s hdlc_rx_state_t
Definition hdlc.h:54
struct hdlc_tx_state_s hdlc_tx_state_t
Definition hdlc.h:77
struct logging_state_s logging_state_t
Definition logging.h:72
struct queue_state_s queue_state_t
Definition queue.h:54
Definition private/t31.h:68
int32_t silence_threshold_power
The current silence threshold.
Definition private/t31.h:86
int16_t last_sample
Last sample, used for an elementary HPF for the power meter.
Definition private/t31.h:84
int bit_no
No of data bits in current_byte.
Definition private/t31.h:77
span_tx_handler_t next_tx_handler
Definition private/t31.h:73
int silence_heard
Samples of silence heard.
Definition private/t31.h:89
int current_byte
The current data byte in progress.
Definition private/t31.h:79
power_meter_t rx_power
Rx power meter, used to detect silence.
Definition private/t31.h:82
Definition private/t31.h:43
uint8_t buf[284]
HDLC message buffers.
Definition private/t31.h:45
int16_t len
HDLC message lengths.
Definition private/t31.h:47
Definition private/t31.h:54
int out
HDLC buffer number for output.
Definition private/t31.h:60
t31_hdlc_buf_t buf[256]
HDLC message buffers.
Definition private/t31.h:56
int in
HDLC buffer number for input.
Definition private/t31.h:58
Definition private/t31.h:175
bool rx_frame_received
True if a valid HDLC frame has been received in the current reception period.
Definition private/t31.h:221
logging_state_t logging
Error and flow logging control.
Definition private/t31.h:234
int bit_rate
The current bit rate for the FAX fast message transfer modem.
Definition private/t31.h:219
int out_bytes
The number of bytes sent from the transmit buffer.
Definition private/t31.h:203
int in_bytes
The number of bytes stored in the transmit buffer.
Definition private/t31.h:201
int64_t call_samples
Samples elapsed in the current call.
Definition private/t31.h:224
int silence_awaited
Samples of silence awaited, as specified in a "wait for silence" command.
Definition private/t31.h:216
struct t31_state_s::@030267137150153235241163205262064300000176033236 hdlc_tx
bool t38_mode
Definition private/t31.h:183
bool short_train
True when short training mode has been selected by the computer.
Definition private/t31.h:230
int modem
The currently queued modem type.
Definition private/t31.h:228
bool holding
True if holding up further data into the buffer, for flow control.
Definition private/t31.h:207
bool data_started
True if the flow of real data has started.
Definition private/t31.h:205
bool dled
Definition private/t31.h:213
struct t31_state_s::@200300101117240345174342157131303063006160072010 non_ecm_tx
uint8_t buf[284]
The HDLC transmit buffer.
Definition private/t31.h:189
Definition private/t31.h:97
hdlc_rx_state_t hdlc_rx_non_ecm
An HDLC context used when receiving HDLC messages from the terminal port. as if it were non-ECM data ...
Definition private/t31.h:123
int timed_step
The current transmit step being timed.
Definition private/t31.h:109
int non_ecm_trailer_bytes
Counter for trailing non-ECM bytes, used to flush out the far end's modem.
Definition private/t31.h:146
int current_tx_type
The current operating mode of the transmitter.
Definition private/t31.h:156
int ecm_mode
True if we are using ECM mode. This is used to select HDLC faking, which is necessary with clunky cla...
Definition private/t31.h:143
int current_tx_data_type
The current T.38 data type being transmitted.
Definition private/t31.h:151
int32_t samples
A "sample" count, used to time events.
Definition private/t31.h:161
bool rx_data_missing
True is there has been some T.38 data missed.
Definition private/t31.h:112
int next_tx_indicator
The next queued tramsit indicator.
Definition private/t31.h:149
t38_core_state_t t38
Core T.38 IFP support.
Definition private/t31.h:106
int32_t timeout_tx_samples
The current transmit timeout.
Definition private/t31.h:165
int32_t timeout_rx_samples
The current receive timeout.
Definition private/t31.h:167
int iaf
Internet Aware FAX mode bit mask.
Definition private/t31.h:99
int current_rx_type
The current operating mode of the receiver.
Definition private/t31.h:154
int octets_per_data_packet
The number of octets to send in each image packet (non-ECM or ECM) at the current rate and the curren...
Definition private/t31.h:116
int tx_bit_rate
Current transmission bit rate.
Definition private/t31.h:159
int extra_bits
The number of extra bits in a fully stuffed version of the contents of the HDLC transmit buffer....
Definition private/t31.h:136
int us_per_tx_chunk
Required time between T.38 transmissions, in us.
Definition private/t31.h:101
int32_t next_tx_samples
The value for samples at the next transmission point.
Definition private/t31.h:163
int chunking_modes
Bit fields controlling the way data is packed into chunked for transmission.
Definition private/t31.h:103
hdlc_tx_state_t hdlc_tx_non_ecm
An HDLC context used when sending HDLC messages to the terminal port as if it were non-ECM data (ECM ...
Definition private/t31.h:120
struct t38_core_state_s t38_core_state_t
Definition t38_core.h:202