private/t38_gateway.h
Go to the documentation of this file.
/*
* SpanDSP - a series of DSP components for telephony
*
* private/t38_gateway.h - A T.38, less the packet exchange part
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2005, 2006, 2007 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*! \file */
#if !defined(_SPANDSP_PRIVATE_T38_GATEWAY_H_)
#define _SPANDSP_PRIVATE_T38_GATEWAY_H_
/*!
T.38 gateway T.38 side channel descriptor.
*/
typedef struct
{
/*! \brief Core T.38 IFP support */
t38_core_state_t t38;
/*! \brief TRUE if the NSF, NSC, and NSS are to be suppressed by altering
their contents to something the far end will not recognise. */
int suppress_nsx_len[2];
/*! \brief TRUE if we need to corrupt the HDLC frame in progress, so the receiver cannot
interpret it. The two values are for the two directions. */
int corrupt_current_frame[2];
/*! \brief the current class of field being received - i.e. none, non-ECM or HDLC */
int current_rx_field_class;
/*! \brief The T.38 indicator currently in use */
int in_progress_rx_indicator;
/*! \brief The current T.38 data type being sent. */
int current_tx_data_type;
} t38_gateway_t38_state_t;
/*!
T.38 gateway audio side channel descriptor.
*/
typedef struct
{
/*! \brief The FAX modem set for the audio side fo the gateway. */
fax_modems_state_t modems;
/*! \brief The current receive signal handler. Actual receiving hops between this
and a dummy receive routine. */
span_rx_handler_t *base_rx_handler;
span_rx_fillin_handler_t *base_rx_fillin_handler;
} t38_gateway_audio_state_t;
/*!
T.38 gateway T.38 side state.
*/
typedef struct
{
/*! \brief non-ECM and HDLC modem receive data buffer. */
uint8_t data[T38_RX_BUF_LEN];
/*! \brief Current pointer into the data buffer. */
int data_ptr;
/*! \brief The current octet being received as non-ECM data. */
unsigned int bit_stream;
/*! \brief The number of bits taken from the modem for the current scan row. This
is used during non-ECM transmission will fill bit removal to see that
T.38 packet transmissions do not stretch too far apart. */
int bits_absorbed;
/*! \brief The current bit number in the current non-ECM octet. */
int bit_no;
/*! \brief Progressively calculated CRC for HDLC messages received from a modem. */
uint16_t crc;
/*! \brief TRUE if non-ECM fill bits are to be stripped when sending image data. */
int fill_bit_removal;
/*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current
rate and the current specified packet interval. */
int octets_per_data_packet;
/*! \brief Bits into the non-ECM buffer */
int in_bits;
/*! \brief Octets fed out from the non-ECM buffer */
int out_octets;
} t38_gateway_to_t38_state_t;
/*!
T.38 gateway HDLC buffer.
*/
typedef struct
{
/*! \brief HDLC message buffers. */
uint8_t buf[T38_MAX_HDLC_LEN];
/*! \brief HDLC message lengths. */
int len;
/*! \brief HDLC message status flags. */
int flags;
/*! \brief HDLC buffer contents. */
int contents;
} t38_gateway_hdlc_buf_t;
/*!
T.38 gateway HDLC state.
*/
typedef struct
{
/*! \brief HDLC message buffers. */
t38_gateway_hdlc_buf_t buf[T38_TX_HDLC_BUFS];
#if 0
/*! \brief HDLC message buffers. */
uint8_t buf[T38_TX_HDLC_BUFS][T38_MAX_HDLC_LEN];
/*! \brief HDLC message lengths. */
int len[T38_TX_HDLC_BUFS];
/*! \brief HDLC message status flags. */
int flags[T38_TX_HDLC_BUFS];
/*! \brief HDLC buffer contents. */
int contents[T38_TX_HDLC_BUFS];
#endif
/*! \brief HDLC buffer number for input. */
int in;
/*! \brief HDLC buffer number for output. */
int out;
} t38_gateway_hdlc_state_t;
/*!
T.38 gateway core descriptor.
*/
typedef struct
{
/*! \brief A bit mask of the currently supported modem types. */
int supported_modems;
/*! \brief TRUE if ECM FAX mode is allowed through the gateway. */
int ecm_allowed;
/*! \brief Required time between T.38 transmissions, in ms. */
int ms_per_tx_chunk;
/*! \brief TRUE if in image data modem is to use short training. This usually
follows image_data_mode, but in ECM mode T.30 defines recovery
conditions in which long training is used for image data. */
int short_train;
/*! \brief TRUE if in image data mode, as opposed to TCF mode. */
int image_data_mode;
/*! \brief The minimum permitted bits per FAX scan line row. */
int min_row_bits;
/*! \brief TRUE if we should count the next MCF as a page end, else FALSE */
int count_page_on_mcf;
/*! \brief The number of pages for which a confirm (MCF) message was returned. */
int pages_confirmed;
/*! \brief TRUE if we are in error correcting (ECM) mode */
int ecm_mode;
/*! \brief The current bit rate for the fast modem. */
int fast_bit_rate;
/*! \brief The current fast receive modem type. */
int fast_rx_modem;
/*! \brief The type of fast receive modem currently active, which may be T38_NONE */
int fast_rx_active;
/*! \brief The current timed operation. */
int timed_mode;
/*! \brief The number of samples until the next timeout event */
int samples_to_timeout;
/*! Buffer for HDLC and non-ECM data going to the T.38 channel */
t38_gateway_to_t38_state_t to_t38;
/*! Buffer for data going to an HDLC modem. */
t38_gateway_hdlc_state_t hdlc_to_modem;
/*! Buffer for data going to a non-ECM mode modem. */
t38_non_ecm_buffer_state_t non_ecm_to_modem;
/*! \brief A pointer to a callback routine to be called when frames are
exchanged. */
t38_gateway_real_time_frame_handler_t *real_time_frame_handler;
/*! \brief An opaque pointer supplied in real time frame callbacks. */
void *real_time_frame_user_data;
} t38_gateway_core_state_t;
/*!
T.38 gateway state.
*/
struct t38_gateway_state_s
{
/*! T.38 side state */
t38_gateway_t38_state_t t38x;
/*! Audio side state */
t38_gateway_audio_state_t audio;
/*! T.38 core state */
t38_gateway_core_state_t core;
/*! \brief Error and flow logging control */
logging_state_t logging;
};
#endif
/*- End of file ------------------------------------------------------------*/
fax_modems_state_t
struct fax_modems_state_s fax_modems_state_t
Definition fax_modems.h:53
logging_state_t
struct logging_state_s logging_state_t
Definition logging.h:75
t38_gateway_audio_state_t
Definition private/t38_gateway.h:59
t38_gateway_audio_state_t::modems
fax_modems_state_t modems
The FAX modem set for the audio side fo the gateway.
Definition private/t38_gateway.h:61
t38_gateway_audio_state_t::base_rx_handler
span_rx_handler_t * base_rx_handler
The current receive signal handler. Actual receiving hops between this and a dummy receive routine.
Definition private/t38_gateway.h:64
t38_gateway_core_state_t
Definition private/t38_gateway.h:141
t38_gateway_core_state_t::real_time_frame_handler
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:186
t38_gateway_core_state_t::to_t38
t38_gateway_to_t38_state_t to_t38
Definition private/t38_gateway.h:178
t38_gateway_core_state_t::non_ecm_to_modem
t38_non_ecm_buffer_state_t non_ecm_to_modem
Definition private/t38_gateway.h:182
t38_gateway_core_state_t::timed_mode
int timed_mode
The current timed operation.
Definition private/t38_gateway.h:173
t38_gateway_core_state_t::hdlc_to_modem
t38_gateway_hdlc_state_t hdlc_to_modem
Definition private/t38_gateway.h:180
t38_gateway_core_state_t::ecm_mode
int ecm_mode
TRUE if we are in error correcting (ECM) mode.
Definition private/t38_gateway.h:164
t38_gateway_core_state_t::short_train
int short_train
TRUE if in image data modem is to use short training. This usually follows image_data_mode,...
Definition private/t38_gateway.h:152
t38_gateway_core_state_t::fast_bit_rate
int fast_bit_rate
The current bit rate for the fast modem.
Definition private/t38_gateway.h:166
t38_gateway_core_state_t::min_row_bits
int min_row_bits
The minimum permitted bits per FAX scan line row.
Definition private/t38_gateway.h:156
t38_gateway_core_state_t::count_page_on_mcf
int count_page_on_mcf
TRUE if we should count the next MCF as a page end, else FALSE.
Definition private/t38_gateway.h:159
t38_gateway_core_state_t::fast_rx_active
int fast_rx_active
The type of fast receive modem currently active, which may be T38_NONE.
Definition private/t38_gateway.h:170
t38_gateway_core_state_t::fast_rx_modem
int fast_rx_modem
The current fast receive modem type.
Definition private/t38_gateway.h:168
t38_gateway_core_state_t::real_time_frame_user_data
void * real_time_frame_user_data
An opaque pointer supplied in real time frame callbacks.
Definition private/t38_gateway.h:188
t38_gateway_core_state_t::samples_to_timeout
int samples_to_timeout
The number of samples until the next timeout event.
Definition private/t38_gateway.h:175
t38_gateway_core_state_t::pages_confirmed
int pages_confirmed
The number of pages for which a confirm (MCF) message was returned.
Definition private/t38_gateway.h:161
t38_gateway_core_state_t::ms_per_tx_chunk
int ms_per_tx_chunk
Required time between T.38 transmissions, in ms.
Definition private/t38_gateway.h:147
t38_gateway_core_state_t::image_data_mode
int image_data_mode
TRUE if in image data mode, as opposed to TCF mode.
Definition private/t38_gateway.h:154
t38_gateway_core_state_t::supported_modems
int supported_modems
A bit mask of the currently supported modem types.
Definition private/t38_gateway.h:143
t38_gateway_core_state_t::ecm_allowed
int ecm_allowed
TRUE if ECM FAX mode is allowed through the gateway.
Definition private/t38_gateway.h:145
t38_gateway_hdlc_buf_t
Definition private/t38_gateway.h:103
t38_gateway_hdlc_buf_t::contents
int contents
HDLC buffer contents.
Definition private/t38_gateway.h:111
t38_gateway_hdlc_buf_t::len
int len
HDLC message lengths.
Definition private/t38_gateway.h:107
t38_gateway_hdlc_buf_t::flags
int flags
HDLC message status flags.
Definition private/t38_gateway.h:109
t38_gateway_hdlc_buf_t::buf
uint8_t buf[T38_MAX_HDLC_LEN]
HDLC message buffers.
Definition private/t38_gateway.h:105
t38_gateway_hdlc_state_t
Definition private/t38_gateway.h:118
t38_gateway_hdlc_state_t::in
int in
HDLC buffer number for input.
Definition private/t38_gateway.h:132
t38_gateway_hdlc_state_t::buf
t38_gateway_hdlc_buf_t buf[T38_TX_HDLC_BUFS]
HDLC message buffers.
Definition private/t38_gateway.h:120
t38_gateway_hdlc_state_t::out
int out
HDLC buffer number for output.
Definition private/t38_gateway.h:134
t38_gateway_state_s
Definition private/t38_gateway.h:195
t38_gateway_state_s::t38x
t38_gateway_t38_state_t t38x
Definition private/t38_gateway.h:197
t38_gateway_state_s::logging
logging_state_t logging
Error and flow logging control.
Definition private/t38_gateway.h:204
t38_gateway_state_s::core
t38_gateway_core_state_t core
Definition private/t38_gateway.h:201
t38_gateway_state_s::audio
t38_gateway_audio_state_t audio
Definition private/t38_gateway.h:199
t38_gateway_t38_state_t
Definition private/t38_gateway.h:35
t38_gateway_t38_state_t::in_progress_rx_indicator
int in_progress_rx_indicator
The T.38 indicator currently in use.
Definition private/t38_gateway.h:49
t38_gateway_t38_state_t::corrupt_current_frame
int corrupt_current_frame[2]
TRUE if we need to corrupt the HDLC frame in progress, so the receiver cannot interpret it....
Definition private/t38_gateway.h:44
t38_gateway_t38_state_t::current_tx_data_type
int current_tx_data_type
The current T.38 data type being sent.
Definition private/t38_gateway.h:52
t38_gateway_t38_state_t::current_rx_field_class
int current_rx_field_class
the current class of field being received - i.e. none, non-ECM or HDLC
Definition private/t38_gateway.h:47
t38_gateway_t38_state_t::suppress_nsx_len
int suppress_nsx_len[2]
TRUE if the NSF, NSC, and NSS are to be suppressed by altering their contents to something the far en...
Definition private/t38_gateway.h:41
t38_gateway_t38_state_t::t38
t38_core_state_t t38
Core T.38 IFP support.
Definition private/t38_gateway.h:37
t38_gateway_to_t38_state_t
Definition private/t38_gateway.h:72
t38_gateway_to_t38_state_t::in_bits
int in_bits
Bits into the non-ECM buffer.
Definition private/t38_gateway.h:94
t38_gateway_to_t38_state_t::fill_bit_removal
int fill_bit_removal
TRUE if non-ECM fill bits are to be stripped when sending image data.
Definition private/t38_gateway.h:88
t38_gateway_to_t38_state_t::bit_no
int bit_no
The current bit number in the current non-ECM octet.
Definition private/t38_gateway.h:84
t38_gateway_to_t38_state_t::crc
uint16_t crc
Progressively calculated CRC for HDLC messages received from a modem.
Definition private/t38_gateway.h:86
t38_gateway_to_t38_state_t::data_ptr
int data_ptr
Current pointer into the data buffer.
Definition private/t38_gateway.h:76
t38_gateway_to_t38_state_t::out_octets
int out_octets
Octets fed out from the non-ECM buffer.
Definition private/t38_gateway.h:96
t38_gateway_to_t38_state_t::bits_absorbed
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:82
t38_gateway_to_t38_state_t::bit_stream
unsigned int bit_stream
The current octet being received as non-ECM data.
Definition private/t38_gateway.h:78
t38_gateway_to_t38_state_t::data
uint8_t data[T38_RX_BUF_LEN]
non-ECM and HDLC modem receive data buffer.
Definition private/t38_gateway.h:74
t38_gateway_to_t38_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/t38_gateway.h:91
t38_core_state_t
struct t38_core_state_s t38_core_state_t
Definition t38_core.h:202
T38_TX_HDLC_BUFS
#define T38_TX_HDLC_BUFS
Definition t38_gateway.h:44
t38_gateway_real_time_frame_handler_t
void t38_gateway_real_time_frame_handler_t(t38_gateway_state_t *s, void *user_data, int direction, const uint8_t *msg, int len)
T.30 real time frame handler.
Definition t38_gateway.h:59
T38_MAX_HDLC_LEN
#define T38_MAX_HDLC_LEN
Definition t38_gateway.h:46
t38_non_ecm_buffer_state_t
struct t38_non_ecm_buffer_state_s t38_non_ecm_buffer_state_t
A flow controlled non-ECM image data buffer, for buffering T.38 to analogue modem data.
Definition t38_non_ecm_buffer.h:77