libspandsp 0.0.4

t31.c File Reference

#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <time.h>
#include <memory.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <tiffio.h>
#include "spandsp/telephony.h"
#include "spandsp/logging.h"
#include "spandsp/bit_operations.h"
#include "spandsp/dc_restore.h"
#include "spandsp/queue.h"
#include "spandsp/power_meter.h"
#include "spandsp/complex.h"
#include "spandsp/tone_generate.h"
#include "spandsp/async.h"
#include "spandsp/hdlc.h"
#include "spandsp/silence_gen.h"
#include "spandsp/fsk.h"
#include "spandsp/v29rx.h"
#include "spandsp/v29tx.h"
#include "spandsp/v27ter_rx.h"
#include "spandsp/v27ter_tx.h"
#include "spandsp/v17rx.h"
#include "spandsp/v17tx.h"
#include "spandsp/t4.h"
#include "spandsp/t30.h"
#include "spandsp/t30_logging.h"
#include "spandsp/t38_core.h"
#include "spandsp/at_interpreter.h"
#include "spandsp/t31.h"

Defines

#define MS_PER_TX_CHUNK   30
#define INDICATOR_TX_COUNT   3
#define DATA_TX_COUNT   1
#define DATA_END_TX_COUNT   3
#define DEFAULT_DTE_TIMEOUT   5
#define MAX_OCTETS_PER_UNPACED_CHUNK   300
#define MID_RX_TIMEOUT   15000
#define HDLC_FRAMING_OK_THRESHOLD   5
#define ETX   0x03
#define DLE   0x10
#define SUB   0x1A

Typedefs

typedef const char *(* at_cmd_service_t )(t31_state_t *s, const char *cmd)

Enumerations

enum  {
  T31_FLUSH, T31_SILENCE_TX, T31_SILENCE_RX, T31_CED_TONE,
  T31_CNG_TONE, T31_NOCNG_TONE, T31_V21_TX, T31_V17_TX,
  T31_V27TER_TX, T31_V29_TX, T31_V21_RX, T31_V17_RX,
  T31_V27TER_RX, T31_V29_RX
}
enum  {
  T38_TIMED_STEP_NONE = 0, T38_TIMED_STEP_NON_ECM_MODEM, T38_TIMED_STEP_NON_ECM_MODEM_2, T38_TIMED_STEP_NON_ECM_MODEM_3,
  T38_TIMED_STEP_NON_ECM_MODEM_4, T38_TIMED_STEP_NON_ECM_MODEM_5, T38_TIMED_STEP_HDLC_MODEM, T38_TIMED_STEP_HDLC_MODEM_2,
  T38_TIMED_STEP_HDLC_MODEM_3, T38_TIMED_STEP_HDLC_MODEM_4, T38_TIMED_STEP_CED, T38_TIMED_STEP_CED_2,
  T38_TIMED_STEP_CNG, T38_TIMED_STEP_CNG_2, T38_TIMED_STEP_PAUSE
}

Functions

int t31_t38_send_timeout (t31_state_t *s, int samples)
void t31_call_event (t31_state_t *s, int event)
int t31_at_rx (t31_state_t *s, const char *t, int len)
int t31_rx (t31_state_t *s, int16_t amp[], int len)
 Process a block of received T.31 modem audio samples.
int t31_tx (t31_state_t *s, int16_t amp[], int max_len)
 Generate a block of T.31 modem audio samples.
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.
void t31_set_tep_mode (t31_state_t *s, int use_tep)
 Select whether TEP mode will be used.
void t31_set_t38_config (t31_state_t *s, int without_pacing)
 Select whether T.38 data will be paced.
t31_state_tt31_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.
int t31_release (t31_state_t *s)
 Release a T.31 context.

Detailed Description


Function Documentation

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.

Initialise a T.31 context. This must be called before the first use of the context, to initialise its contents.

Parameters:
sThe T.31 context.
at_tx_handlerA callback routine to handle AT interpreter channel output.
at_tx_user_dataAn opaque pointer passed in called to at_tx_handler.
modem_control_handlerA callback routine to handle control of the modem (off-hook, etc).
modem_control_user_dataAn opaque pointer passed in called to modem_control_handler.
tx_t38_packet_handler???
tx_t38_packet_user_data???
Returns:
A pointer to the T.31 context.

References at_init(), t31_state_s::call_samples, at_state_s::dte_inactivity_timeout, t31_state_s::logging, power_meter_init(), power_meter_level_dbm0(), queue_init(), QUEUE_READ_ATOMIC, QUEUE_WRITE_ATOMIC, t31_state_s::rx_handler, t31_state_s::rx_power, at_state_s::rx_signal_present, at_state_s::rx_trained, t31_state_s::silence_awaited, silence_gen(), t31_state_s::silence_gen, silence_gen_init(), t31_state_s::silence_heard, t31_set_t38_config(), t31_state_s::tx_handler, t31_state_s::v17_rx, v17_rx_init(), t31_state_s::v17_tx, v17_tx_init(), t31_state_s::v27ter_rx, v27ter_rx_init(), t31_state_s::v27ter_tx, v27ter_tx_init(), t31_state_s::v29_rx, v29_rx_init(), v29_rx_signal_cutoff(), t31_state_s::v29_tx, and v29_tx_init().

int t31_release ( t31_state_t s)

Release a T.31 context.

Release a T.31 context.

Parameters:
sThe T.31 context.
Returns:
0 for OK
int t31_rx ( t31_state_t s,
int16_t  amp[],
int  len 
)

Process a block of received T.31 modem audio samples.

Process a block of received T.31 modem audio samples.

Parameters:
sThe T.31 modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns:
The number of samples unprocessed.

References t31_state_s::call_samples, power_meter_update(), t31_state_s::rx_handler, t31_state_s::rx_power, and t31_state_s::silence_heard.

void t31_set_t38_config ( t31_state_t s,
int  without_pacing 
)

Select whether T.38 data will be paced.

Select whether T.38 data will be paced as it is transmitted.

Parameters:
sThe T.31 modem context.
without_pacingTRUE if data is to be sent as fast as possible. FALSE if it is to be paced.

References t31_state_s::data_end_tx_count, and t31_state_s::indicator_tx_count.

Referenced by t31_init().

void t31_set_tep_mode ( t31_state_t s,
int  use_tep 
)

Select whether TEP mode will be used.

Select whether TEP mode will be used (or time allowed for it (when transmitting).

Parameters:
sThe T.31 modem context.
use_tepTRUE if TEP is to be ised.

References t31_state_s::use_tep.

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.

Select whether silent audio will be sent when transmit is idle.

Parameters:
sThe T.31 modem context.
transmit_on_idleTRUE if silent audio should be output when the transmitter is idle. FALSE to transmit zero length audio when the transmitter is idle. The default behaviour is FALSE.

References t31_state_s::transmit_on_idle.

int t31_tx ( t31_state_t s,
int16_t  amp[],
int  max_len 
)

Generate a block of T.31 modem audio samples.

Generate a block of T.31 modem audio samples.

Parameters:
sThe T.31 modem context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns:
The number of samples actually generated.

References AT_MODEM_CONTROL_HANGUP, t31_state_s::transmit_on_idle, and t31_state_s::tx_handler.