t30.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <tgmath.h>
#include <tiffio.h>
#include "spandsp/telephony.h"
#include "spandsp/logging.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/fsk.h"
#include "spandsp/v29rx.h"
#include "spandsp/v29tx.h"
#include "spandsp/v27ter_rx.h"
#include "spandsp/v27ter_tx.h"
#include "spandsp/t4.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/t35.h"
#include "spandsp/t30.h"

Defines

#define MAXMESSAGE   (MAXFRAME + 4)
#define MAX_MESSAGE_TRIES   3
#define ms_to_samples(t)   (((t)*SAMPLE_RATE)/1000)
#define DISBIT1   0x01
#define DISBIT2   0x02
#define DISBIT3   0x04
#define DISBIT4   0x08
#define DISBIT5   0x10
#define DISBIT6   0x20
#define DISBIT7   0x40
#define DISBIT8   0x80
#define DEFAULT_TIMER_T0   60000
#define DEFAULT_TIMER_T1   35000
#define DEFAULT_TIMER_T2   6000
#define DEFAULT_TIMER_T3   10000
#define DEFAULT_TIMER_T4   3000
#define DEFAULT_TIMER_T5   60000
#define DEFAULT_TIMER_SIG_ON   3000
#define T30_V29_FALLBACK_START   0
#define T30_V27TER_FALLBACK_START   2

Enumerations

enum  {
  T30_PHASE_IDLE = 0, T30_PHASE_A_CED, T30_PHASE_A_CNG, T30_PHASE_BDE_RX,
  T30_PHASE_BDE_TX, T30_PHASE_C_RX, T30_PHASE_C_TX, T30_PHASE_E,
  T30_PHASE_CALL_FINISHED
}
enum  {
  T30_STATE_B = 1, T30_STATE_C, T30_STATE_D, T30_STATE_D_TCF,
  T30_STATE_F, T30_STATE_F_TCF, T30_STATE_F_MPS_MCF, T30_STATE_F_EOP_MCF,
  T30_STATE_R, T30_STATE_T, T30_STATE_I, T30_STATE_II,
  T30_STATE_II_MPS, T30_STATE_II_EOP, T30_STATE_II_EOM
}
enum  { T30_MODE_SEND_DOC = 1, T30_MODE_RECEIVE_DOC }
enum  { T30_MODEM_V27TER = 0, T30_MODEM_V29, T30_MODEM_V17 }

Functions

char * t30_completion_code_to_str (int result)
 Convert a phase E completion code to a short text description.
char * t30_frametype (uint8_t x)
 Return a text name for a T.30 frame type.
void t30_decode_dis_dtc_dcs (t30_state_t *s, const uint8_t *pkt, int len)
 Decode a DIS, DTC or DCS frame, and log the contents.
int fax_init (t30_state_t *s, int calling_party, void *user_data)
 Initialise a T.30 context.
void fax_release (t30_state_t *s)
 Release a T.30 context.
int fax_rx (t30_state_t *s, int16_t *buf, int len)
 Apply FAX receive processing to a block of audio samples.
int fax_tx (t30_state_t *s, int16_t *buf, int max_len)
 Apply FAX transmit processing to generate a block of audio samples.
int t30_set_header_info (t30_state_t *s, const char *info)
 Set the header information associated with a T.30 context.
int t30_set_local_ident (t30_state_t *s, const char *id)
 Set the local identifier associated with a T.30 context.
int t30_set_sub_address (t30_state_t *s, const char *sub_address)
 Set the sub-address associated with a T.30 context.
int t30_get_sub_address (t30_state_t *s, char *sub_address)
 Get the sub-address associated with a T.30 context.
int t30_get_header_info (t30_state_t *s, char *info)
 Get the header information associated with a T.30 context.
int t30_get_local_ident (t30_state_t *s, char *id)
 Get the local identifier associated with a T.30 context.
int t30_get_far_ident (t30_state_t *s, char *id)
 Get the remote identifier associated with a T.30 context.
void t30_get_transfer_statistics (t30_state_t *s, t30_stats_t *t)
 Get the current transfer statistics.
void t30_set_phase_b_handler (t30_state_t *s, t30_phase_b_handler_t *handler, void *user_data)
 Set a callback function for T.30 phase B handling.
void t30_set_phase_d_handler (t30_state_t *s, t30_phase_d_handler_t *handler, void *user_data)
 Set a callback function for T.30 phase D handling.
void t30_set_phase_e_handler (t30_state_t *s, t30_phase_e_handler_t *handler, void *user_data)
 Set a callback function for T.30 phase E handling.
void t30_set_rx_file (t30_state_t *s, const char *file, int stop_page)
 Set next receive file name.
void t30_set_tx_file (t30_state_t *s, const char *file, int start_page, int stop_page)
 Set next transmit file name.
void t30_local_interrupt_request (t30_state_t *s, int state)
 Request a local interrupt of FAX exchange.
void fax_set_flush_handler (t30_state_t *s, t30_flush_handler_t *handler, void *user_data)

Detailed Description


Function Documentation

int fax_init ( t30_state_t s,
int  calling_party,
void *  user_data 
)

Initialise a T.30 context.

Initialise a T.30 context.

Parameters:
s The T.30 context.
calling_party TRUE if the context is for a calling party. FALSE if the context is for an answering party.
user_data An opaque pointer which is associated with the T.30 context, and supplied in callbacks.
Returns:
0 for OK, else -1.

void fax_release ( t30_state_t s  ) 

Release a T.30 context.

Release a T.30 context.

Parameters:
s The T.30 context.

int fax_rx ( t30_state_t s,
int16_t *  buf,
int  len 
)

Apply FAX receive processing to a block of audio samples.

Apply FAX receive processing to a block of audio samples.

Parameters:
s The T.30 context.
buf The audio sample buffer.
len The number of samples in the buffer.
Returns:
The number of samples unprocessed. This should only be non-zero if the software has reached the end of the FAX call.

int fax_tx ( t30_state_t s,
int16_t *  buf,
int  max_len 
)

Apply FAX transmit processing to generate a block of audio samples.

Apply FAX transmit processing to generate a block of audio samples.

Parameters:
s The T.30 context.
buf The audio sample buffer.
max_len The number of samples to be generated.
Returns:
The number of samples actually generated. This will be zero when there is nothing to send.

char* t30_completion_code_to_str ( int  err  ) 

Convert a phase E completion code to a short text description.

Convert a phase E completion code to a short text description.

Parameters:
err The error code.
Returns:
A pointer to the description.

void t30_decode_dis_dtc_dcs ( t30_state_t s,
const uint8_t *  dis,
int  len 
)

Decode a DIS, DTC or DCS frame, and log the contents.

Decode a DIS, DTC or DCS frame, and log the contents.

Parameters:
s The T.30 context.
dis A pointer to the frame to be decoded.
len The length of the frame.

char* t30_frametype ( uint8_t  x  ) 

Return a text name for a T.30 frame type.

Return a text name for a T.30 frame type.

Parameters:
x The frametype octet.
Returns:
A pointer to the text name for the frame type. If the frame type is not value, the string "???" is returned.

int t30_get_far_ident ( t30_state_t s,
char *  id 
)

Get the remote identifier associated with a T.30 context.

Get the remote FAX machine identifier associated with a T.30 context.

Parameters:
s The T.30 context.
id A pointer to a buffer for the identifier. The buffer should be at least 21 bytes long.
Returns:
the length of the string.

int t30_get_header_info ( t30_state_t s,
char *  info 
)

Get the header information associated with a T.30 context.

Get the header information associated with a T.30 context.

Parameters:
s The T.30 context.
sub_address A pointer to a buffer for the header information. The buffer should be at least 51 bytes long.
Returns:
the length of the string.

int t30_get_local_ident ( t30_state_t s,
char *  id 
)

Get the local identifier associated with a T.30 context.

Get the local FAX machine identifier associated with a T.30 context.

Parameters:
s The T.30 context.
id A pointer to a buffer for the identifier. The buffer should be at least 21 bytes long.
Returns:
the length of the string.

int t30_get_sub_address ( t30_state_t s,
char *  sub_address 
)

Get the sub-address associated with a T.30 context.

Get the sub-address associated with a T.30 context.

Parameters:
s The T.30 context.
sub_address A pointer to a buffer for the sub-address. The buffer should be at least 21 bytes long.
Returns:
the length of the string.

void t30_get_transfer_statistics ( t30_state_t s,
t30_stats_t *  t 
)

Get the current transfer statistics.

Get the current transfer statistics for the file being sent or received.

Parameters:
s The T.30 context.
t A pointer to a buffer for the statistics.

void t30_local_interrupt_request ( t30_state_t s,
int  state 
)

Request a local interrupt of FAX exchange.

Request a local interrupt of FAX exchange.

Parameters:
s The T.30 context.
state TRUE to enable interrupt request, else FALSE.

int t30_set_header_info ( t30_state_t s,
const char *  info 
)

Set the header information associated with a T.30 context.

Set the header information associated with a T.30 context.

Parameters:
s The T.30 context.
info A pointer to the information string.
Returns:
0 for OK, else -1.

int t30_set_local_ident ( t30_state_t s,
const char *  id 
)

Set the local identifier associated with a T.30 context.

Set the local identifier associated with a T.30 context.

Parameters:
s The T.30 context.
id A pointer to the identifier.
Returns:
0 for OK, else -1.

void t30_set_phase_b_handler ( t30_state_t s,
t30_phase_b_handler_t handler,
void *  user_data 
)

Set a callback function for T.30 phase B handling.

Set a callback function for T.30 phase B handling.

Parameters:
s The T.30 context.
handler The callback function
user_data An opaque pointer passed to the callback function.

void t30_set_phase_d_handler ( t30_state_t s,
t30_phase_d_handler_t handler,
void *  user_data 
)

Set a callback function for T.30 phase D handling.

Set a callback function for T.30 phase D handling.

Parameters:
s The T.30 context.
handler The callback function
user_data An opaque pointer passed to the callback function.

void t30_set_phase_e_handler ( t30_state_t s,
t30_phase_e_handler_t handler,
void *  user_data 
)

Set a callback function for T.30 phase E handling.

Set a callback function for T.30 phase E handling.

Parameters:
s The T.30 context.
handler The callback function
user_data An opaque pointer passed to the callback function.

void t30_set_rx_file ( t30_state_t s,
const char *  file,
int  stop_page 
)

Set next receive file name.

Specify the file name of the next TIFF file to be received by a T.30 context.

Parameters:
s The T.30 context.
file The file name
stop_page The maximum page to receive. -1 for no restriction.

int t30_set_sub_address ( t30_state_t s,
const char *  sub_address 
)

Set the sub-address associated with a T.30 context.

Set the sub-address associated with a T.30 context.

Parameters:
s The T.30 context.
sub_address A pointer to the sub-address.
Returns:
0 for OK, else -1.

void t30_set_tx_file ( t30_state_t s,
const char *  file,
int  start_page,
int  stop_page 
)

Set next transmit file name.

Specify the file name of the next TIFF file to be transmitted by a T.30 context.

Parameters:
s The T.30 context.
file The file name
start_page The first page to send. -1 for no restriction.
stop_page The last page to send. -1 for no restriction.


Generated on Fri Nov 10 09:40:24 2006 for libspandsp by  doxygen 1.5.1