00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * t38_terminal.h - T.38 termination, less the packet exchange part 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2005 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License version 2, as 00014 * published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 * 00025 * $Id: t38_terminal.h,v 1.27 2007/12/14 13:41:17 steveu Exp $ 00026 */ 00027 00028 /*! \file */ 00029 00030 #if !defined(_SPANDSP_T38_TERMINAL_H_) 00031 #define _SPANDSP_T38_TERMINAL_H_ 00032 00033 /*! \page t38_terminal_page T.38 real time FAX over IP termination 00034 \section t38_terminal_page_sec_1 What does it do? 00035 00036 \section t38_terminal_page_sec_2 How does it work? 00037 */ 00038 00039 /* Make sure the HDLC frame buffers are big enough for ECM frames. */ 00040 #define T38_MAX_HDLC_LEN 260 00041 00042 /*! 00043 T.38 terminal state. 00044 */ 00045 typedef struct 00046 { 00047 /*! Core T.38 support */ 00048 t38_core_state_t t38; 00049 00050 /*! \brief Use (actually allow time for) talker echo protection when transmitting. */ 00051 int use_tep; 00052 00053 /*! \brief HDLC transmit buffer */ 00054 uint8_t tx_buf[T38_MAX_HDLC_LEN]; 00055 /*! \brief The length of the contents of the HDLC transmit buffer */ 00056 int tx_len; 00057 /*! \brief Current pointer within the contents of the HDLC transmit buffer */ 00058 int tx_ptr; 00059 00060 /*! \brief HDLC receive buffer */ 00061 uint8_t rx_buf[T38_MAX_HDLC_LEN]; 00062 /*! \brief The length of the contents of the HDLC receive buffer */ 00063 int rx_len; 00064 00065 /*! \brief The current transmit step being timed */ 00066 int timed_step; 00067 00068 /*! \brief The next queued tramsit indicator */ 00069 int next_tx_indicator; 00070 /*! \brief The current T.38 data type being transmitted */ 00071 int current_tx_data_type; 00072 00073 /*! \brief TRUE if a carrier is present. Otherwise FALSE. */ 00074 int rx_signal_present; 00075 00076 /*! \brief The T.30 back-end */ 00077 t30_state_t t30_state; 00078 00079 /*! \brief The current operating mode of the receiver. */ 00080 int current_rx_type; 00081 /*! \brief The current operating mode of the transmitter. */ 00082 int current_tx_type; 00083 00084 /*! \brief Counter for trailing bytes, used to flush the far end's modem */ 00085 int trailer_bytes; 00086 00087 /*! \brief TRUE is there has been some T.38 data missed (i.e. lost packets) */ 00088 int missing_data; 00089 00090 /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current 00091 rate and the current specified packet interval. */ 00092 int octets_per_data_packet; 00093 00094 /*! \brief The time between T.38 transmissions, in ms. */ 00095 int ms_per_tx_chunk; 00096 /*! \brief TRUE if multiple data fields should be merged into a single T.38 IFP packet. */ 00097 int merge_tx_fields; 00098 00099 /*! \brief The number of times an indicator packet will be sent. Numbers greater than one 00100 will increase reliability for UDP transmission. Zero is valid, to suppress all 00101 indicator packets for TCP transmission. */ 00102 int indicator_tx_count; 00103 00104 /*! \brief The number of times a data packet which ends transmission will be sent. Numbers 00105 greater than one will increase reliability for UDP transmission. Zero is not valid. */ 00106 int data_end_tx_count; 00107 00108 /*! \brief A "sample" count, used to time events. */ 00109 int32_t samples; 00110 /*! \brief The value for samples at the next transmission point. */ 00111 int32_t next_tx_samples; 00112 int32_t timeout_rx_samples; 00113 00114 /*! \brief Internet Aware FAX mode bit mask. */ 00115 int iaf; 00116 00117 logging_state_t logging; 00118 } t38_terminal_state_t; 00119 00120 #if defined(__cplusplus) 00121 extern "C" 00122 { 00123 #endif 00124 00125 int t38_terminal_send_timeout(t38_terminal_state_t *s, int samples); 00126 00127 void t38_terminal_set_config(t38_terminal_state_t *s, int without_pacing); 00128 00129 /*! Select whether the time for talker echo protection tone will be allowed for when sending. 00130 \brief Select whether TEP time will be allowed for. 00131 \param s The T.38 context. 00132 \param use_tep TRUE if TEP should be allowed for. 00133 */ 00134 void t38_terminal_set_tep_mode(t38_terminal_state_t *s, int use_tep); 00135 00136 00137 /*! Select whether non-ECM fill bits are to be removed during transmission. 00138 \brief Select whether non-ECM fill bits are to be removed during transmission. 00139 \param s The T.38 context. 00140 \param remove TRUE if fill bits are to be removed. 00141 */ 00142 void t38_terminal_set_fill_bit_removal(t38_terminal_state_t *s, int remove); 00143 00144 /*! \brief Initialise a termination mode T.38 context. 00145 \param s The T.38 context. 00146 \param calling_party TRUE if the context is for a calling party. FALSE if the 00147 context is for an answering party. 00148 \param tx_packet_handler A callback routine to encapsulate and transmit T.38 packets. 00149 \param tx_packet_user_data An opaque pointer passed to the tx_packet_handler routine. 00150 \return A pointer to the termination mode T.38 context, or NULL if there was a problem. */ 00151 t38_terminal_state_t *t38_terminal_init(t38_terminal_state_t *s, 00152 int calling_party, 00153 t38_tx_packet_handler_t *tx_packet_handler, 00154 void *tx_packet_user_data); 00155 00156 /*! Release a termination mode T.38 context. 00157 \brief Release a T.38 context. 00158 \param s The T.38 context. 00159 \return 0 for OK, else -1. */ 00160 int t38_terminal_release(t38_terminal_state_t *s); 00161 00162 /*! Free a a termination mode T.38 context. 00163 \brief Free a T.38 context. 00164 \param s The T.38 context. 00165 \return 0 for OK, else -1. */ 00166 int t38_terminal_free(t38_terminal_state_t *s); 00167 00168 #if defined(__cplusplus) 00169 } 00170 #endif 00171 00172 #endif 00173 /*- End of file ------------------------------------------------------------*/