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.24 2007/11/30 12:20:35 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 typedef struct 00043 { 00044 t38_core_state_t t38; 00045 00046 /*! \brief Use (actually allow time for) talker echo protection when transmitting. */ 00047 int use_tep; 00048 00049 /*! \brief HDLC transmit buffer */ 00050 uint8_t tx_buf[T38_MAX_HDLC_LEN]; 00051 int tx_len; 00052 int tx_ptr; 00053 00054 /*! \brief HDLC receive buffer */ 00055 uint8_t rx_buf[T38_MAX_HDLC_LEN]; 00056 int rx_len; 00057 00058 /*! \brief The current transmit step being timed */ 00059 int timed_step; 00060 00061 /*! \brief The next queued tramsit indicator */ 00062 int next_tx_indicator; 00063 /*! \brief The current T.38 data type being transmitted */ 00064 int current_tx_data_type; 00065 00066 /*! \brief TRUE if a carrier is present. Otherwise FALSE. */ 00067 int rx_signal_present; 00068 00069 /*! \brief The T.30 back-end */ 00070 t30_state_t t30_state; 00071 00072 int current_rx_type; 00073 int current_tx_type; 00074 00075 int trailer_bytes; 00076 00077 /*! \brief TRUE is there has been some T.38 data missed (i.e. lost packets) */ 00078 int missing_data; 00079 00080 /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current 00081 rate and the current specified packet interval. */ 00082 int octets_per_data_packet; 00083 00084 int ms_per_tx_chunk; 00085 int merge_tx_fields; 00086 00087 /*! \brief The number of times an indicator packet will be sent. Numbers greater than one 00088 will increase reliability for UDP transmission. Zero is valid, to suppress all 00089 indicator packets for TCP transmission. */ 00090 int indicator_tx_count; 00091 00092 /*! \brief The number of times a data packet which ends transmission will be sent. Numbers 00093 greater than one will increase reliability for UDP transmission. Zero is not valid. */ 00094 int data_end_tx_count; 00095 00096 /*! \brief A "sample" count, used to time events */ 00097 int32_t samples; 00098 int32_t next_tx_samples; 00099 int32_t timeout_rx_samples; 00100 00101 logging_state_t logging; 00102 } t38_terminal_state_t; 00103 00104 #if defined(__cplusplus) 00105 extern "C" 00106 { 00107 #endif 00108 00109 int t38_terminal_send_timeout(t38_terminal_state_t *s, int samples); 00110 00111 void t38_terminal_set_config(t38_terminal_state_t *s, int without_pacing); 00112 00113 /*! Select whether the time for talker echo protection tone will be allowed for when sending. 00114 \brief Select whether TEP time will be allowed for. 00115 \param s The T.38 context. 00116 \param use_tep TRUE if TEP should be allowed for. 00117 */ 00118 void t38_terminal_set_tep_mode(t38_terminal_state_t *s, int use_tep); 00119 00120 /*! \brief Initialise a termination mode T.38 context. 00121 \param s The T.38 context. 00122 \param calling_party TRUE if the context is for a calling party. FALSE if the 00123 context is for an answering party. 00124 \param tx_packet_handler A callback routine to encapsulate and transmit T.38 packets. 00125 \param tx_packet_user_data An opaque pointer passed to the tx_packet_handler routine. 00126 \return A pointer to the termination mode T.38 context, or NULL if there was a problem. */ 00127 t38_terminal_state_t *t38_terminal_init(t38_terminal_state_t *s, 00128 int calling_party, 00129 t38_tx_packet_handler_t *tx_packet_handler, 00130 void *tx_packet_user_data); 00131 00132 /*! Release a termination mode T.38 context. 00133 \brief Release a T.38 context. 00134 \param s The T.38 context. 00135 \return 0 for OK, else -1. */ 00136 int t38_terminal_release(t38_terminal_state_t *s); 00137 00138 /*! Free a a termination mode T.38 context. 00139 \brief Free a T.38 context. 00140 \param s The T.38 context. 00141 \return 0 for OK, else -1. */ 00142 int t38_terminal_free(t38_terminal_state_t *s); 00143 00144 #if defined(__cplusplus) 00145 } 00146 #endif 00147 00148 #endif 00149 /*- End of file ------------------------------------------------------------*/