26 #if !defined(_SPANDSP_PRIVATE_T31_H_)
27 #define _SPANDSP_PRIVATE_T31_H_
40 void *next_tx_user_data;
93 uint8_t buf[T31_T38_MAX_HDLC_LEN];
139 t31_modem_control_handler_t *modem_control_handler;
140 void *modem_control_user_data;
150 uint8_t buf[T31_MAX_HDLC_LEN];
159 uint8_t data[T31_TX_BUF_LEN];
185 int64_t dte_data_timeout;
int field_type
Definition: t38_core.h:192
const char * t38_cm_profile_to_str(int profile)
Convert the code for a CM profile code to text description.
Definition: t38_core.c:220
@ MODEM_CONNECT_TONES_ANSAM_PR
The ANSam with phase reversals tone is a version of ANS_PR with 20% of 15Hz+-0.1Hz AM modulation,...
Definition: modem_connect_tones.h:72
float v29_rx_signal_power(v29_rx_state_t *s)
Definition: v29rx.c:165
int t31_release(t31_state_t *s)
Release a T.31 context.
Definition: t31.c:2693
int fastest_image_data_rate
The fastest data rate supported by the T.38 channel.
Definition: private/t38_core.h:96
@ T30_DCS
Definition: t30_fcf.h:54
int silence_awaited
Samples of silence awaited, as specified in a "wait for silence" command.
Definition: private/t31.h:176
int tx_bit_rate
Current transmission bit rate.
Definition: private/t31.h:123
@ MODEM_CONNECT_TONES_FAX_CNG
CNG tone is a pure 1100Hz tone, in 0.5s bursts, with 3s silences in between. The bursts repeat for as...
Definition: modem_connect_tones.h:62
int rx_signal_present
TRUE if a carrier is presnt. Otherwise FALSE.
Definition: private/at_interpreter.h:108
Definition: private/queue.h:34
int v34_rate
The bit rate for V.34 operation.
Definition: private/t38_core.h:125
@ AT_MODEM_CONTROL_ANSWER
Definition: at_interpreter.h:65
int current_rx_field_type
The current receive field type - i.e. the last field_type received.
Definition: private/t38_core.h:121
int32_t timeout_rx_samples
The current receive timeout.
Definition: private/t31.h:129
@ T30_FRONT_END_RECEIVE_COMPLETE
Definition: t30.h:332
#define QUEUE_WRITE_ATOMIC
Definition: queue.h:48
int iaf
Internet Aware FAX mode bit mask.
Definition: private/t31.h:65
int ms_per_tx_chunk
Required time between T.38 transmissions, in ms.
Definition: private/t31.h:67
int dled
Definition: private/t31.h:173
logging_state_t * t31_get_logging_state(t31_state_t *s)
Get a pointer to the logging context associated with a T.31 context.
Definition: t31.c:2560
int t38_core_send_data_multi_field(t38_core_state_t *s, int data_type, const t38_data_field_t field[], int fields, int category)
Send a data packet.
Definition: t38_core.c:972
@ SIG_STATUS_ABORT
An abort signal (e.g. an HDLC abort) has been received.
Definition: async.h:73
hdlc_tx_state_t * hdlc_tx_init(hdlc_tx_state_t *s, int crc32, int inter_frame_flags, int progressive, hdlc_underflow_handler_t handler, void *user_data)
Initialise an HDLC transmitter context.
Definition: hdlc.c:626
logging_state_t logging
Error and flow logging control.
Definition: private/fax_modems.h:124
power_meter_t rx_power
Rx power meter, used to detect silence.
Definition: private/t31.h:48
@ SIG_STATUS_CARRIER_UP
The carrier signal is up. This merely indicates that carrier energy has been seen....
Definition: async.h:58
t38_core_state_t t38
Core T.38 IFP support.
Definition: private/t31.h:72
#define DATA_END_TX_COUNT
Definition: t31.c:121
float fsk_rx_signal_power(fsk_rx_state_t *s)
Definition: fsk.c:246
void t38_set_redundancy_control(t38_core_state_t *s, int category, int setting)
Send a data packet.
Definition: t38_core.c:1058
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
int current_tx_data_type
The current T.38 data type being transmitted.
Definition: private/t31.h:115
@ SIG_STATUS_TRAINING_IN_PROGRESS
The modem is training. This is an early indication that the signal seems to be of the right type....
Definition: async.h:63
v27ter_rx_state_t v27ter_rx
A V.27ter modem context used when receiving FAXes at 2400bps or 4800bps.
Definition: private/fax_modems.h:74
int t38_v34rate_to_bps(const uint8_t *data, int len)
Convert a V34rate message to an actual bit rate.
Definition: t38_core.c:272
int t38_mode
Definition: private/t31.h:145
int crc_itu16_append(uint8_t *buf, int len)
Append an ITU/CCITT CRC-16 value to a frame.
Definition: crc.c:179
int out_bytes
The number of bytes sent from the transmit buffer.
Definition: private/t31.h:163
at_state_t * at_init(at_state_t *s, at_tx_handler_t *at_tx_handler, void *at_tx_user_data, at_modem_control_handler_t *modem_control_handler, void *modem_control_user_data)
Initialise an AT interpreter context.
Definition: at_interpreter.c:5512
Definition: private/t38_core.h:33
int data_started
TRUE if the flow of real data has started.
Definition: private/t31.h:165
int32_t samples
A "sample" count, used to time events.
Definition: private/t31.h:125
int v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int short_train)
Reinitialise an existing V.17 modem transmit context.
Definition: v17tx.c:380
@ AT_MODEM_CONTROL_CALL
Definition: at_interpreter.h:63
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_PACKET_CATEGORY_CONTROL_DATA
Control data packet.
Definition: t38_core.h:176
void(* put_bit_func_t)(void *user_data, int bit)
Definition: async.h:105
const char * t30_frametype(uint8_t x)
Return a text name for a T.30 frame type.
Definition: t30_logging.c:241
struct t31_state_s::@60 hdlc_tx
int rx_data_missing
TRUE is there has been some T.38 data missed.
Definition: private/t31.h:78
int32_t power_meter_update(power_meter_t *s, int16_t amp)
Update a power meter.
Definition: power_meter.c:84
span_rx_fillin_handler_t * rx_fillin_handler
The current receive missing signal fill-in handler.
Definition: private/fax_modems.h:100
#define MODEM_CONNECT_TONES_FAX_CED
FAX CED tone is the same as ANS tone.
Definition: modem_connect_tones.h:87
@ T38_PACKET_CATEGORY_INDICATOR
Indicator packet.
Definition: t38_core.h:174
Definition: t38_core.h:190
v29_tx_state_t v29_tx
A V.29 modem context used when sending FAXes at 7200bps or 9600bps.
Definition: private/fax_modems.h:65
@ SIG_STATUS_FRAMING_OK
Packet framing (e.g. HDLC framing) is OK.
Definition: async.h:69
v27ter_tx_state_t v27ter_tx
A V.27ter modem context used when sending FAXes at 2400bps or 4800bps.
Definition: private/fax_modems.h:71
SPAN_DECLARE_NONSTD(int) async_tx_get_bit(void *user_data)
Get the next bit of a transmitted serial bit stream.
Definition: private/t31.h:34
#define DATA_TX_COUNT
Definition: t31.c:119
int64_t call_samples
Samples elapsed in the current call.
Definition: private/t31.h:184
int queue_write_msg(queue_state_t *s, const uint8_t *buf, int len)
Write a message to a queue.
Definition: queue.c:335
v17_tx_state_t v17_tx
A V.17 modem context used when sending FAXes at 7200bps, 9600bps 12000bps or 14400bps.
Definition: private/fax_modems.h:59
int v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_train)
Reinitialise an existing V.27ter modem receive context.
Definition: v27ter_rx.c:1036
Definition: power_meter.h:49
int16_t last_sample
Last sample, used for an elementary HPF for the power meter.
Definition: private/t31.h:50
silence_gen_state_t silence_gen
Used to insert timed silences.
Definition: private/fax_modems.h:77
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
int current_tx_indicator
The current transmit indicator - i.e. the last indicator transmitted.
Definition: private/t38_core.h:123
@ T38_PACKET_CATEGORY_IMAGE_DATA
Image data packet.
Definition: t38_core.h:180
int transmit_on_idle
Definition: private/fax_modems.h:43
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
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
int t31_free(t31_state_t *s)
Release a T.31 context.
Definition: t31.c:2700
span_tx_handler_t * next_tx_handler
Definition: private/t31.h:39
int rx_trained
TRUE if a modem has trained, Otherwise FALSE.
Definition: private/at_interpreter.h:110
v29_rx_state_t v29_rx
A V.29 modem context used when receiving FAXes at 7200bps or 9600bps.
Definition: private/fax_modems.h:68
int32_t silence_threshold_power
The current silence threshold.
Definition: private/t31.h:52
Definition: private/t31.h:63
int current_rx_data_type
The current receive data type - i.e. the last data type received.
Definition: private/t38_core.h:119
Definition: private/fax_modems.h:35
Definition: private/t31.h:137
@ SIG_STATUS_TRAINING_FAILED
The modem has failed to train.
Definition: async.h:67
int(* get_bit_func_t)(void *user_data)
Definition: async.h:108
queue_state_t * queue_init(queue_state_t *s, int len, int flags)
Initialise a queue.
Definition: queue.c:394
span_rx_handler_t * rx_handler
The current receive signal handler.
Definition: private/fax_modems.h:98
int current_tx_type
The current operating mode of the transmitter.
Definition: private/t31.h:120
struct t31_state_s::@61 tx
span_tx_handler_t * next_tx_handler
The next transmit signal handler, for two stage transmit operations. E.g. a short silence followed by...
Definition: private/fax_modems.h:109
@ SIG_STATUS_CARRIER_DOWN
The carrier signal has dropped.
Definition: async.h:54
void silence_gen_set(silence_gen_state_t *s, int silent_samples)
Set a silence generator context to output a specified period of silence.
Definition: silence_gen.c:79
int t38_core_send_flags_delay(t38_core_state_t *s, int indicator)
Find the delay to allow for HDLC flags after sending an indicator.
Definition: t38_core.c:932
int current_byte
The current data byte in progress.
Definition: private/t31.h:45
int v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_train)
Reinitialise an existing V.17 modem receive context.
Definition: v17rx.c:1380
int32_t next_tx_samples
The value for samples at the next transmission point.
Definition: private/t31.h:127
int current_rx_indicator
The current receive indicator - i.e. the last indicator received.
Definition: private/t38_core.h:117
Definition: private/hdlc.h:33
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
int adaptive_receive
Definition: at_interpreter.h:129
int silence_heard
Samples of silence heard.
Definition: private/t31.h:55
int t38_core_send_data(t38_core_state_t *s, int data_type, int field_type, const uint8_t field[], int field_len, int category)
Send a data packet.
Definition: t38_core.c:948
hdlc_rx_state_t hdlc_rx
An HDLC context used when receiving HDLC messages.
Definition: private/fax_modems.h:48
@ T38_PACKET_CATEGORY_CONTROL_DATA_END
Terminating control data packet.
Definition: t38_core.h:178
#define HDLC_FRAMING_OK_THRESHOLD
Definition: t38_gateway.c:175
int span_log(logging_state_t *s, int level, const char *format,...)
Generate a log entry.
Definition: logging.c:84
int queue_empty(queue_state_t *s)
Check if a queue is empty.
Definition: queue.c:46
@ AT_MODEM_CONTROL_ONHOOK
Definition: at_interpreter.h:71
int short_train
TRUE when short training mode has been selected by the computer.
Definition: private/t31.h:190
const char * t38_jm_to_str(const uint8_t *data, int len)
Convert a JM message code to text description.
Definition: t38_core.c:241
modem_connect_tones_tx_state_t * modem_connect_tones_tx_init(modem_connect_tones_tx_state_t *s, int tone_type)
Initialise an instance of the modem connect tones generator.
Definition: modem_connect_tones.c:253
hdlc_rx_state_t * hdlc_rx_init(hdlc_rx_state_t *s, int crc32, int report_bad_frames, int framing_ok_threshold, hdlc_frame_handler_t handler, void *user_data)
Initialise an HDLC receiver context.
Definition: hdlc.c:327
void silence_gen_alter(silence_gen_state_t *s, int silent_samples)
Alter the period of a silence generator context by a specified amount.
Definition: silence_gen.c:86
@ T38_PACKET_CATEGORY_IMAGE_DATA_END
Terminating image data packet.
Definition: t38_core.h:182
@ AT_MODEM_CONTROL_HANGUP
Definition: at_interpreter.h:67
fsk_rx_state_t * fsk_rx_init(fsk_rx_state_t *s, const fsk_spec_t *spec, int framing_mode, put_bit_func_t put_bit, void *user_data)
Initialise an FSK modem receive context.
Definition: fsk.c:314
void t31_set_tep_mode(t31_state_t *s, int use_tep)
Select whether TEP mode will be used.
Definition: t31.c:2520
int timed_step
The current transmit step being timed.
Definition: private/t31.h:75
int v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train)
Reinitialise an existing V.29 modem receive context.
Definition: v29rx.c:1072
fsk_tx_state_t * fsk_tx_init(fsk_tx_state_t *s, const fsk_spec_t *spec, get_bit_func_t get_bit, void *user_data)
Initialise an FSK modem transmit context.
Definition: fsk.c:153
int t38_core_send_indicator(t38_core_state_t *s, int indicator)
Send an indicator packet.
Definition: t38_core.c:889
int bit_rate
The current bit rate for the FAX fast message transfer modem.
Definition: private/t31.h:179
int queue_read_msg(queue_state_t *s, uint8_t *buf, int len)
Read a message from a queue.
Definition: queue.c:309
int v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep)
Reinitialise an existing V.27ter modem transmit context.
Definition: v27ter_tx.c:390
int32_t power_meter_level_dbm0(float level)
Get the current power meter reading, in dBm0.
Definition: power_meter.c:91
#define QUEUE_READ_ATOMIC
Definition: queue.h:45
void fsk_rx_signal_cutoff(fsk_rx_state_t *s, float cutoff)
Adjust an FSK modem receive context's carrier detect power threshold.
Definition: fsk.c:238
#define DEFAULT_DTE_TIMEOUT
Definition: t31.c:123
int chunking_modes
Bit fields controlling the way data is packed into chunked for transmission.
Definition: private/t31.h:69
logging_state_t logging
Error and flow logging control.
Definition: private/t31.h:194
void queue_flush(queue_state_t *s)
Flush the contents of a queue.
Definition: queue.c:74
int current_rx_type
The current operating mode of the receiver.
Definition: private/t31.h:118
fsk_rx_state_t v21_rx
A V.21 FSK modem context used when receiving HDLC over V.21 messages.
Definition: private/fax_modems.h:54
void bit_reverse(uint8_t to[], const uint8_t from[], int len)
Bit reverse each byte in a buffer.
Definition: bit_operations.c:79
int use_tep
Definition: private/fax_modems.h:37
int final
TRUE when the end of HDLC data from the computer has been detected.
Definition: private/t31.h:154
span_tx_handler_t * tx_handler
The current transmit signal handler.
Definition: private/fax_modems.h:104
Definition: private/hdlc.h:92
uint8_t s_regs[100]
Definition: at_interpreter.h:131
t38_core_state_t * t38_core_init(t38_core_state_t *s, t38_rx_indicator_handler_t *rx_indicator_handler, t38_rx_data_handler_t *rx_data_handler, t38_rx_missing_handler_t *rx_missing_handler, void *rx_user_data, t38_tx_packet_handler_t *tx_packet_handler, void *tx_packet_user_data)
Initialise a T.38 core context.
Definition: t38_core.c:1102
hdlc_tx_state_t hdlc_tx
An HDLC context used when transmitting HDLC messages.
Definition: private/fax_modems.h:46
const uint8_t * field
Definition: t38_core.h:194
v17_rx_state_t v17_rx
A V.29 modem context used when receiving FAXes at 7200bps, 9600bps 12000bps or 14400bps.
Definition: private/fax_modems.h:62
int bit_no
No of data bits in current_byte.
Definition: private/t31.h:43
int result_code_format
Definition: at_interpreter.h:123
int field_len
Definition: t38_core.h:196
int in_bytes
The number of bytes stored in transmit buffer.
Definition: private/t31.h:161
#define INDICATOR_TX_COUNT
Definition: t31.c:117
int holding
TRUE if holding up further data into the buffer, for flow control.
Definition: private/t31.h:167
power_meter_t * power_meter_init(power_meter_t *s, int shift)
Initialise a power meter context.
Definition: power_meter.c:50
Definition: private/at_interpreter.h:45
@ SIG_STATUS_TRAINING_SUCCEEDED
The modem has trained, and is ready for data exchange.
Definition: async.h:65
int modem
The currently queued modem type.
Definition: private/t31.h:188
void t31_set_t38_config(t31_state_t *s, int without_pacing)
Select whether T.38 data will be paced.
Definition: t31.c:2526
void t31_set_transmit_on_idle(t31_state_t *s, int transmit_on_idle)
Select whether silent audio will be sent when transmit is idle.
Definition: t31.c:2514
float v27ter_rx_signal_power(v27ter_rx_state_t *s)
Definition: v27ter_rx.c:152
#define MS_PER_TX_CHUNK
Definition: t31.c:115
Definition: private/logging.h:34
v8_state_t * v8_init(v8_state_t *s, int calling_party, v8_parms_t *parms, v8_result_handler_t result_handler, void *user_data)
Initialise a V.8 context.
Definition: v8.c:1073
int hdlc_tx_frame(hdlc_tx_state_t *s, const uint8_t *frame, size_t len)
Transmit a frame.
Definition: hdlc.c:389
modem_connect_tones_tx_state_t connect_tx
CED or CNG generator.
Definition: private/fax_modems.h:79
int next_tx_indicator
The next queued tramsit indicator.
Definition: private/t31.h:113
fsk_tx_state_t v21_tx
A V.21 FSK modem context used when transmitting HDLC over V.21 messages.
Definition: private/fax_modems.h:51
@ SIG_STATUS_END_OF_DATA
The data stream has ended.
Definition: async.h:71
int v29_tx_restart(v29_tx_state_t *s, int bit_rate, int tep)
Reinitialise an existing V.29 modem transmit context.
Definition: v29tx.c:332
int hdlc_tx_flags(hdlc_tx_state_t *s, int len)
Transmit a specified quantity of flag octets, typically as a preamble.
Definition: hdlc.c:424
@ AT_MODEM_CONTROL_CTS
Definition: at_interpreter.h:77
t31_state_t * t31_init(t31_state_t *s, at_tx_handler_t *at_tx_handler, void *at_tx_user_data, t31_modem_control_handler_t *modem_control_handler, void *modem_control_user_data, t38_tx_packet_handler_t *tx_t38_packet_handler, void *tx_t38_packet_user_data)
Initialise a T.31 context.
Definition: t31.c:2605
float v17_rx_signal_power(v17_rx_state_t *s)
Definition: v17rx.c:182
int rx_frame_received
TRUE if a valid HDLC frame has been received in the current reception period.
Definition: private/t31.h:181