spandsp 3.0.0
private/t38_gateway.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * private/t38_gateway.h - A T.38, less the packet exchange part
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2005, 2006, 2007 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/*! \file */
27
28#if !defined(_SPANDSP_PRIVATE_T38_GATEWAY_H_)
29#define _SPANDSP_PRIVATE_T38_GATEWAY_H_
30
31/*! The number of HDLC transmit buffers */
32#define T38_TX_HDLC_BUFS 256
33/*! The maximum length of an HDLC frame buffer. This must be big enough for ECM frames. */
34#define T38_MAX_HDLC_LEN 260
35/*! The receive buffer length */
36#define T38_RX_BUF_LEN 2048
37
38/*!
39 T.38 gateway T.38 side channel descriptor.
40*/
41typedef struct
42{
43 /*! \brief Core T.38 IFP support */
45
46 /*! \brief If NSF, NSC, and NSS are to be suppressed by altering their contents to
47 something the far end will not recognise, this is the amount to overwrite. */
48 int suppress_nsx_len[2];
49 /*! \brief If NSF, NSC, and NSS are to be suppressed by altering their contents to
50 something the far end will not recognise, this is the string to use for overwriting. */
51 uint8_t suppress_nsx_string[2][MAX_NSX_SUPPRESSION];
52
53 /*! \brief True if we need to corrupt the HDLC frame in progress, so the receiver cannot
54 interpret it. The two values are for the two directions. */
55 bool corrupt_current_frame[2];
56
57 /*! \brief the current class of field being received - i.e. none, non-ECM or HDLC */
59 /*! \brief The T.38 indicator currently in use */
61
62 /*! \brief The current T.38 data type being sent. */
65
66/*!
67 T.38 gateway audio side channel descriptor.
68*/
69typedef struct
70{
71 /*! \brief The FAX modem set for the audio side fo the gateway. */
74
75/*!
76 T.38 gateway T.38 side state.
77*/
78typedef struct
79{
80 /*! \brief non-ECM and HDLC modem receive data buffer. */
81 uint8_t data[T38_RX_BUF_LEN];
82 /*! \brief Current pointer into the data buffer. */
84 /*! \brief The current octet being received as non-ECM data. */
85 uint16_t bit_stream;
86 /*! \brief The number of bits taken from the modem for the current scan row. This
87 is used during non-ECM transmission with fill bit removal to see that
88 T.38 packet transmissions do not stretch too far apart. */
90 /*! \brief The current bit number in the current non-ECM octet. */
91 int bit_no;
92 /*! \brief Progressively calculated CRC for HDLC messages received from a modem. */
93 uint16_t crc;
94 /*! \brief True if non-ECM fill bits are to be stripped when sending image data. */
96 /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at
97 the current rate and the current specified packet interval. */
99
100 /*! \brief The number of bits into the non-ECM buffer */
102 /*! \brief The number of octets fed out from the non-ECM buffer */
105
106/*!
107 T.38 gateway HDLC buffer.
108*/
109typedef struct
110{
111 /*! \brief HDLC message buffers. */
112 uint8_t buf[T38_MAX_HDLC_LEN];
113 /*! \brief HDLC message lengths. */
114 int16_t len;
115 /*! \brief HDLC message status flags. */
116 uint16_t flags;
117 /*! \brief HDLC buffer contents. */
118 int16_t contents;
120
121/*!
122 T.38 gateway HDLC state.
123*/
124typedef struct
125{
126 /*! \brief HDLC message buffers. */
128 /*! \brief HDLC buffer number for input. */
129 int in;
130 /*! \brief HDLC buffer number for output. */
131 int out;
133
134/*!
135 T.38 gateway core descriptor.
136*/
137typedef struct
138{
139 /*! \brief A bit mask of the currently supported modem types. */
141 /*! \brief True if ECM FAX mode is allowed through the gateway. */
143 /*! \brief Required time between T.38 transmissions, in ms. */
145
146 /*! \brief True if in image data modem is to use short training. This usually
147 follows image_data_mode, but in ECM mode T.30 defines recovery
148 conditions in which long training is used for image data. */
150 /*! \brief True if in image data mode, as opposed to TCF mode. */
152 /*! \brief The minimum permitted bits per FAX scan line row. */
154
155 /*! \brief True if we should count the next MCF as a page end, else false */
157 /*! \brief The number of pages for which a confirm (MCF) message was returned. */
159
160 /*! \brief True if we are in error correcting (ECM) mode */
162 /*! \brief The current bit rate for the fast modem. */
164 /*! \brief The current fast receive modem type. */
166 /*! \brief The type of fast receive modem currently active, which may be T38_NONE */
168
169 /*! \brief The current timed operation. */
171 /*! \brief The number of samples until the next timeout event */
173
174 /*! Buffer for HDLC and non-ECM data going to the T.38 channel */
176 /*! Buffer for data going to an HDLC modem. */
178 /*! Buffer for data going to a non-ECM mode modem. */
180
181 /*! \brief A pointer to a callback routine to be called when frames are
182 exchanged. */
184 /*! \brief An opaque pointer supplied in real time frame callbacks. */
187
188/*!
189 T.38 gateway state.
190*/
192{
193 /*! T.38 side state */
195 /*! Audio side state */
197 /*! T.38 core state */
199
200 /*! \brief Error and flow logging control */
202};
203
204#endif
205/*- End of file ------------------------------------------------------------*/
#define T38_TX_HDLC_BUFS
Definition private/t38_gateway.h:32
#define T38_RX_BUF_LEN
Definition private/t38_gateway.h:36
#define T38_MAX_HDLC_LEN
Definition private/t38_gateway.h:34
Definition private/fax_modems.h:35
Definition private/logging.h:34
Definition private/t38_core.h:33
Definition private/t38_gateway.h:70
fax_modems_state_t modems
The FAX modem set for the audio side fo the gateway.
Definition private/t38_gateway.h:72
Definition private/t38_gateway.h:138
t38_gateway_to_t38_state_t to_t38
Definition private/t38_gateway.h:175
bool ecm_mode
True if we are in error correcting (ECM) mode.
Definition private/t38_gateway.h:161
bool short_train
True if in image data modem is to use short training. This usually follows image_data_mode,...
Definition private/t38_gateway.h:149
t38_non_ecm_buffer_state_t non_ecm_to_modem
Definition private/t38_gateway.h:179
int timed_mode
The current timed operation.
Definition private/t38_gateway.h:170
bool image_data_mode
True if in image data mode, as opposed to TCF mode.
Definition private/t38_gateway.h:151
bool count_page_on_mcf
True if we should count the next MCF as a page end, else false.
Definition private/t38_gateway.h:156
t38_gateway_hdlc_state_t hdlc_to_modem
Definition private/t38_gateway.h:177
int fast_bit_rate
The current bit rate for the fast modem.
Definition private/t38_gateway.h:163
int min_row_bits
The minimum permitted bits per FAX scan line row.
Definition private/t38_gateway.h:153
int fast_rx_active
The type of fast receive modem currently active, which may be T38_NONE.
Definition private/t38_gateway.h:167
bool ecm_allowed
True if ECM FAX mode is allowed through the gateway.
Definition private/t38_gateway.h:142
int fast_rx_modem
The current fast receive modem type.
Definition private/t38_gateway.h:165
void * real_time_frame_user_data
An opaque pointer supplied in real time frame callbacks.
Definition private/t38_gateway.h:185
int samples_to_timeout
The number of samples until the next timeout event.
Definition private/t38_gateway.h:172
int pages_confirmed
The number of pages for which a confirm (MCF) message was returned.
Definition private/t38_gateway.h:158
t38_gateway_real_time_frame_handler_t real_time_frame_handler
A pointer to a callback routine to be called when frames are exchanged.
Definition private/t38_gateway.h:183
int ms_per_tx_chunk
Required time between T.38 transmissions, in ms.
Definition private/t38_gateway.h:144
int supported_modems
A bit mask of the currently supported modem types.
Definition private/t38_gateway.h:140
Definition private/t38_gateway.h:110
int16_t len
HDLC message lengths.
Definition private/t38_gateway.h:114
uint16_t flags
HDLC message status flags.
Definition private/t38_gateway.h:116
int16_t contents
HDLC buffer contents.
Definition private/t38_gateway.h:118
Definition private/t38_gateway.h:125
int in
HDLC buffer number for input.
Definition private/t38_gateway.h:129
int out
HDLC buffer number for output.
Definition private/t38_gateway.h:131
Definition private/t38_gateway.h:192
t38_gateway_t38_state_t t38x
Definition private/t38_gateway.h:194
logging_state_t logging
Error and flow logging control.
Definition private/t38_gateway.h:201
t38_gateway_core_state_t core
Definition private/t38_gateway.h:198
t38_gateway_audio_state_t audio
Definition private/t38_gateway.h:196
Definition private/t38_gateway.h:42
int in_progress_rx_indicator
The T.38 indicator currently in use.
Definition private/t38_gateway.h:60
int current_tx_data_type
The current T.38 data type being sent.
Definition private/t38_gateway.h:63
int current_rx_field_class
the current class of field being received - i.e. none, non-ECM or HDLC
Definition private/t38_gateway.h:58
t38_core_state_t t38
Core T.38 IFP support.
Definition private/t38_gateway.h:44
Definition private/t38_gateway.h:79
int in_bits
The number of bits into the non-ECM buffer.
Definition private/t38_gateway.h:101
int bit_no
The current bit number in the current non-ECM octet.
Definition private/t38_gateway.h:91
uint16_t crc
Progressively calculated CRC for HDLC messages received from a modem.
Definition private/t38_gateway.h:93
int data_ptr
Current pointer into the data buffer.
Definition private/t38_gateway.h:83
bool fill_bit_removal
True if non-ECM fill bits are to be stripped when sending image data.
Definition private/t38_gateway.h:95
int out_octets
The number of octets fed out from the non-ECM buffer.
Definition private/t38_gateway.h:103
int bits_absorbed
The number of bits taken from the modem for the current scan row. This is used during non-ECM transmi...
Definition private/t38_gateway.h:89
uint16_t bit_stream
The current octet being received as non-ECM data.
Definition private/t38_gateway.h:85
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/t38_gateway.h:98
A flow controlled non-ECM image data buffer, for buffering T.38 to analogue modem data.
Definition private/t38_non_ecm_buffer.h:34
void(* t38_gateway_real_time_frame_handler_t)(void *user_data, bool incoming, const uint8_t *msg, int len)
T.38 gateway real time frame handler.
Definition t38_gateway.h:55
#define MAX_NSX_SUPPRESSION
Definition t38_gateway.h:43