private/t31.h
/*
* SpanDSP - a series of DSP components for telephony
*
* private/t31.h - A T.31 compatible class 1 FAX modem interface.
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2004 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.
*/
#if !defined(_SPANDSP_PRIVATE_T31_H_)
#define _SPANDSP_PRIVATE_T31_H_
/*!
Analogue FAX front end channel descriptor. This defines the state of a single working
instance of an analogue line FAX front end.
*/
typedef struct
{
fax_modems_state_t modems;
//v8_state_t v8;
/*! The transmit signal handler to be used when the current one has finished sending. */
span_tx_handler_t *next_tx_handler;
void *next_tx_user_data;
/*! \brief No of data bits in current_byte. */
int bit_no;
/*! \brief The current data byte in progress. */
int current_byte;
/*! \brief Rx power meter, used to detect silence. */
power_meter_t rx_power;
/*! \brief Last sample, used for an elementary HPF for the power meter. */
int16_t last_sample;
/*! \brief The current silence threshold. */
int32_t silence_threshold_power;
/*! \brief Samples of silence heard */
int silence_heard;
} t31_audio_front_end_state_t;
/*!
Analogue FAX front end channel descriptor. This defines the state of a single working
instance of an analogue line FAX front end.
*/
typedef struct
{
/*! \brief Internet Aware FAX mode bit mask. */
int iaf;
/*! \brief Required time between T.38 transmissions, in ms. */
int ms_per_tx_chunk;
/*! \brief Bit fields controlling the way data is packed into chunked for transmission. */
int chunking_modes;
/*! \brief Core T.38 IFP support */
t38_core_state_t t38;
/*! \brief The current transmit step being timed */
int timed_step;
/*! \brief TRUE is there has been some T.38 data missed */
int rx_data_missing;
/*! \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 An HDLC context used when sending HDLC messages to the terminal port
(ECM mode support). */
hdlc_tx_state_t hdlc_tx_term;
/*! \brief An HDLC context used when receiving HDLC messages from the terminal port.
(ECM mode support). */
hdlc_rx_state_t hdlc_rx_term;
struct
{
uint8_t buf[T31_T38_MAX_HDLC_LEN];
int len;
} hdlc_rx;
struct
{
/*! \brief The number of extra bits in a fully stuffed version of the
contents of the HDLC transmit buffer. This is needed to accurately
estimate the playout time for this frame, through an analogue modem. */
int extra_bits;
} hdlc_tx;
/*! \brief TRUE if we are using ECM mode. This is used to select HDLC faking, necessary
with clunky class 1 modems. */
int ecm_mode;
/*! \brief Counter for trailing non-ECM bytes, used to flush out the far end's modem. */
int non_ecm_trailer_bytes;
/*! \brief The next queued tramsit indicator */
int next_tx_indicator;
/*! \brief The current T.38 data type being transmitted */
int current_tx_data_type;
/*! \brief The current operating mode of the receiver. */
int current_rx_type;
/*! \brief The current operating mode of the transmitter. */
int current_tx_type;
/*! \brief Current transmission bit rate. */
int tx_bit_rate;
/*! \brief A "sample" count, used to time events. */
int32_t samples;
/*! \brief The value for samples at the next transmission point. */
int32_t next_tx_samples;
/*! \brief The current receive timeout. */
int32_t timeout_rx_samples;
} t31_t38_front_end_state_t;
/*!
T.31 descriptor. This defines the working state for a single instance of
a T.31 FAX modem.
*/
struct t31_state_s
{
at_state_t at_state;
t31_modem_control_handler_t *modem_control_handler;
void *modem_control_user_data;
t31_audio_front_end_state_t audio;
t31_t38_front_end_state_t t38_fe;
/*! TRUE if working in T.38 mode. */
int t38_mode;
/*! HDLC buffer, for composing an HDLC frame from the computer to the channel. */
struct
{
uint8_t buf[T31_MAX_HDLC_LEN];
int len;
int ptr;
/*! \brief TRUE when the end of HDLC data from the computer has been detected. */
int final;
} hdlc_tx;
/*! Buffer for data from the computer to the channel. */
struct
{
uint8_t data[T31_TX_BUF_LEN];
/*! \brief The number of bytes stored in transmit buffer. */
int in_bytes;
/*! \brief The number of bytes sent from the transmit buffer. */
int out_bytes;
/*! \brief TRUE if the flow of real data has started. */
int data_started;
/*! \brief TRUE if holding up further data into the buffer, for flow control. */
int holding;
/*! \brief TRUE when the end of non-ECM data from the computer has been detected. */
int final;
} tx;
/*! TRUE if DLE prefix just used */
int dled;
/*! \brief Samples of silence awaited, as specified in a "wait for silence" command */
int silence_awaited;
/*! \brief The current bit rate for the FAX fast message transfer modem. */
int bit_rate;
/*! \brief TRUE if a valid HDLC frame has been received in the current reception period. */
int rx_frame_received;
/*! \brief Samples elapsed in the current call */
int64_t call_samples;
int64_t dte_data_timeout;
/*! \brief The currently queued modem type. */
int modem;
/*! \brief TRUE when short training mode has been selected by the computer. */
int short_train;
queue_state_t *rx_queue;
/*! \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
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::hdlc_tx
struct t31_state_s::@235175340341373377210214253177304222322155230167 hdlc_tx
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::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