t4.c File Reference

#include <stdio.h>
#include <inttypes.h>
#include <limits.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <string.h>
#include <strings.h>
#include <tgmath.h>
#include <tiffio.h>
#include "spandsp/telephony.h"
#include "spandsp/logging.h"
#include "spandsp/alaw_ulaw.h"
#include "spandsp/t4.h"
#include "faxfont.h"
#include "t4states.h"

Classes

struct  T4_tab_entry
struct  T4_table_entry

Defines

#define _GNU_SOURCE
#define S_Null   0
#define S_Pass   1
#define S_Horiz   2
#define S_V0   3
#define S_VR   4
#define S_VL   5
#define S_Ext   6
#define S_TermW   7
#define S_TermB   8
#define S_MakeUpW   9
#define S_MakeUpB   10
#define S_MakeUp   11
#define S_EOL   12
#define STATE_TRACE(x,...)
#define isAligned(p, t)   ((((unsigned long int)(p)) & (sizeof(t) - 1)) == 0)
#define EOL   0x001
#define T4CODE_EOL   -1
#define T4CODE_INVALID   -2
#define T4CODE_EOF   -3
#define T4CODE_INCOMP   -4

Functions

int t4_rx_end_page (t4_state_t *s)
 Complete the reception of a page.
int t4_rx_putbit (t4_state_t *s, int bit)
 Put a bit of the current document page.
t4_state_tt4_rx_create (const char *file, int output_encoding)
 Allocate a T.4 transmit handling context, and initialise it.
int t4_rx_init (t4_state_t *s, const char *file, int output_encoding)
 Prepare for reception of a document.
int t4_rx_start_page (t4_state_t *s)
 Prepare to receive the next page of the current document.
int t4_rx_delete (t4_state_t *s)
 End reception of a document. Tidy up, close the file and free the context. This should be used to end T.4 reception started with t4_rx_create.
int t4_rx_end (t4_state_t *s)
 End reception of a document. Tidy up and close the file. This should be used to end T.4 reception started with t4_rx_init.
void t4_rx_set_rx_encoding (t4_state_t *s, int encoding)
 Set the encoding for the received data.
void t4_rx_set_columns (t4_state_t *s, int columns)
 Set the number of pixel columns to expect in a received image.
void t4_rx_set_row_resolution (t4_state_t *s, int resolution)
 Set the row resolution to expect for a received image.
void t4_rx_set_column_resolution (t4_state_t *s, int resolution)
 Set the column resolution to expect for a received image.
void t4_rx_set_sub_address (t4_state_t *s, const char *sub_address)
 Set the sub-address of the fax, for inclusion in the file.
void t4_rx_set_far_ident (t4_state_t *s, const char *ident)
 Set the identity of the remote machine, for inclusion in the file.
void t4_rx_set_vendor (t4_state_t *s, const char *vendor)
 Set the vendor of the remote machine, for inclusion in the file.
void t4_rx_set_model (t4_state_t *s, const char *model)
 Set the model of the remote machine, for inclusion in the file.
t4_state_tt4_tx_create (const char *file, int start_page, int stop_page)
 Allocate a T.4 receive handling context, and initialise it.
int t4_tx_init (t4_state_t *s, const char *file, int start_page, int stop_page)
 Prepare for transmission of a document.
int t4_tx_start_page (t4_state_t *s)
 Prepare to send the next page of the current document.
int t4_tx_restart_page (t4_state_t *s)
 Prepare the current page for a resend.
int t4_tx_end_page (t4_state_t *s)
 Complete the sending of a page.
int t4_tx_getbit (t4_state_t *s)
 Get the next bit of the current document page. The document will be padded for the current minimum scan line time. If the file does not contain an RTC (return to control) code at the end of the page, one will be added.
int t4_tx_delete (t4_state_t *s)
 End the transmission of a document. Tidy up, close the file and free the context. This should be used to end T.4 transmission started with t4_tx_create.
int t4_tx_end (t4_state_t *s)
 End the transmission of a document. Tidy up and close the file. This should be used to end T.4 transmission started with t4_tx_init.
void t4_tx_set_tx_encoding (t4_state_t *s, int encoding)
 Set the encoding for the encoded data.
void t4_tx_set_min_row_bits (t4_state_t *s, int bits)
 Set the minimum number of encoded bits per row. This allows the makes the encoding process to be set to comply with the minimum row time specified by a remote receiving machine.
void t4_tx_set_local_ident (t4_state_t *s, const char *ident)
 Set the identity of the local machine, for inclusion in page headers.
int t4_tx_set_header_info (t4_state_t *s, const char *info)
 Set the header info.
const char * t4_tx_get_header_info (t4_state_t *s)
 Get the header info.
int t4_tx_get_row_resolution (t4_state_t *s)
 Get the row resolution of the current page.
int t4_tx_get_column_resolution (t4_state_t *s)
 Get the column resolution of the current page.
int t4_tx_get_columns (t4_state_t *s)
 Get the number of columns in the current page.
void t4_get_transfer_statistics (t4_state_t *s, t4_stats_t *t)
 Get the current transfer statistics.
const char * t4_encoding_to_str (int encoding)
 Get the short text name of an encoding format.

Variables

const T4_table_entry t4_white_codes []
const T4_table_entry t4_black_codes []

Detailed Description


Function Documentation

const char* t4_encoding_to_str ( int  encoding  ) 

Get the short text name of an encoding format.

Get the short text name of an encoding format.

Parameters:
encoding The encoding type.
Returns:
A pointer to the string.

void t4_get_transfer_statistics ( t4_state_t s,
t4_stats_t t 
)

Get the current transfer statistics.

Get the current image transfer statistics.

Parameters:
s The T.4 context.
t A pointer to a statistics structure.

t4_state_t* t4_rx_create ( const char *  file,
int  output_encoding 
)

Allocate a T.4 transmit handling context, and initialise it.

Parameters:
file The name of the file to be received.
output_encoding The output encoding.
Returns:
The T.4 context, or NULL.

int t4_rx_delete ( t4_state_t s  ) 

End reception of a document. Tidy up, close the file and free the context. This should be used to end T.4 reception started with t4_rx_create.

Parameters:
s The T.4 receive context.
Returns:
0 for success, otherwise -1.

int t4_rx_end ( t4_state_t s  ) 

End reception of a document. Tidy up and close the file. This should be used to end T.4 reception started with t4_rx_init.

Parameters:
s The T.4 context.
Returns:
0 for success, otherwise -1.

int t4_rx_end_page ( t4_state_t s  ) 

Complete the reception of a page.

Parameters:
s The T.4 receive context.
Returns:
0 for success, otherwise -1.

int t4_rx_init ( t4_state_t s,
const char *  file,
int  output_encoding 
)

Prepare for reception of a document.

Parameters:
s The T.4 context.
file The name of the file to be received.
output_encoding The output encoding.
Returns:
0 for success, otherwise -1.

int t4_rx_putbit ( t4_state_t s,
int  bit 
)

Put a bit of the current document page.

Parameters:
s The T.4 context.
bit The data bit.
Returns:
TRUE when the bit ends the document page, otherwise FALSE.

void t4_rx_set_column_resolution ( t4_state_t s,
int  resolution 
)

Set the column resolution to expect for a received image.

Parameters:
s The T.4 context.
resolution The resolution, in pixels per metre.

void t4_rx_set_columns ( t4_state_t s,
int  columns 
)

Set the number of pixel columns to expect in a received image.

Parameters:
s The T.4 context.
columns The number of pixels across the image.

void t4_rx_set_far_ident ( t4_state_t s,
const char *  ident 
)

Set the identity of the remote machine, for inclusion in the file.

Parameters:
s The T.4 context.
ident The identity string.

void t4_rx_set_model ( t4_state_t s,
const char *  model 
)

Set the model of the remote machine, for inclusion in the file.

Parameters:
s The T.4 context.
model The model string, or NULL.

void t4_rx_set_row_resolution ( t4_state_t s,
int  resolution 
)

Set the row resolution to expect for a received image.

Parameters:
s The T.4 context.
resolution The resolution, in pixels per metre.

void t4_rx_set_rx_encoding ( t4_state_t s,
int  encoding 
)

Set the encoding for the received data.

Parameters:
s The T.4 context.
encoding The encoding.

void t4_rx_set_sub_address ( t4_state_t s,
const char *  sub_address 
)

Set the sub-address of the fax, for inclusion in the file.

Parameters:
s The T.4 context.
sub_address The sub-address string.

void t4_rx_set_vendor ( t4_state_t s,
const char *  vendor 
)

Set the vendor of the remote machine, for inclusion in the file.

Parameters:
s The T.4 context.
vendor The vendor string, or NULL.

int t4_rx_start_page ( t4_state_t s  ) 

Prepare to receive the next page of the current document.

Parameters:
s The T.4 context.
Returns:
zero for success, -1 for failure.

t4_state_t* t4_tx_create ( const char *  file,
int  start_page,
int  stop_page 
)

Allocate a T.4 receive handling context, and initialise it.

Parameters:
s The T.4 context.
file The name of the file to be sent.
Returns:
0 for success, otherwise -1.

int t4_tx_delete ( t4_state_t s  ) 

End the transmission of a document. Tidy up, close the file and free the context. This should be used to end T.4 transmission started with t4_tx_create.

Parameters:
s The T.4 context.
Returns:
0 for success, otherwise -1.

int t4_tx_end ( t4_state_t s  ) 

End the transmission of a document. Tidy up and close the file. This should be used to end T.4 transmission started with t4_tx_init.

Parameters:
s The T.4 context.
Returns:
0 for success, otherwise -1.

int t4_tx_end_page ( t4_state_t s  ) 

Complete the sending of a page.

Parameters:
s The T.4 context.
Returns:
zero for success, -1 for failure.

int t4_tx_get_column_resolution ( t4_state_t s  ) 

Get the column resolution of the current page.

Parameters:
s The T.4 context.
Returns:
The resolution, in pixels per metre.

int t4_tx_get_columns ( t4_state_t s  ) 

Get the number of columns in the current page.

Parameters:
s The T.4 context.
Returns:
The number of columns.

const char* t4_tx_get_header_info ( t4_state_t s  ) 

Get the header info.

Parameters:
s The T.4 context.
Returns:
A string, of up to 50 characters.

int t4_tx_get_row_resolution ( t4_state_t s  ) 

Get the row resolution of the current page.

Parameters:
s The T.4 context.
Returns:
The resolution, in pixels per metre.

int t4_tx_getbit ( t4_state_t s  ) 

Get the next bit of the current document page. The document will be padded for the current minimum scan line time. If the file does not contain an RTC (return to control) code at the end of the page, one will be added.

Parameters:
s The T.4 context.
Returns:
The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is set (i.e. the returned value is 2 or 3).

int t4_tx_init ( t4_state_t s,
const char *  file,
int  start_page,
int  stop_page 
)

Prepare for transmission of a document.

Parameters:
s The T.4 context.
file The name of the file to be sent.
start_page The first page to send. -1 for no restriction.
stop_page The last page to send. -1 for no restriction.
Returns:
The T.4 context, or NULL.

int t4_tx_restart_page ( t4_state_t s  ) 

Prepare the current page for a resend.

Parameters:
s The T.4 context.
Returns:
zero for success, -1 for failure.

int t4_tx_set_header_info ( t4_state_t s,
const char *  info 
)

Set the header info.

Set the info field, included in the header line included in each page of an encoded FAX. This is a string of up to 50 characters. Other information (date, local ident, etc.) are automatically included in the header. If the header info is set to NULL or a zero length string, no header lines will be added to the encoded FAX.

Parameters:
s The T.4 context.
info A string, of up to 50 bytes, which will form the info field.

void t4_tx_set_local_ident ( t4_state_t s,
const char *  ident 
)

Set the identity of the local machine, for inclusion in page headers.

Parameters:
s The T.4 context.
ident The identity string.

void t4_tx_set_min_row_bits ( t4_state_t s,
int  bits 
)

Set the minimum number of encoded bits per row. This allows the makes the encoding process to be set to comply with the minimum row time specified by a remote receiving machine.

Parameters:
s The T.4 context.
bits The minimum number of bits per row.

void t4_tx_set_tx_encoding ( t4_state_t s,
int  encoding 
)

Set the encoding for the encoded data.

Parameters:
s The T.4 context.
encoding The encoding.

int t4_tx_start_page ( t4_state_t s  ) 

Prepare to send the next page of the current document.

Parameters:
s The T.4 context.
Returns:
zero for success, -1 for failure.


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