spandsp 0.0.6

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