00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * t38_terminal.h - An implementation of T.38, 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.20 2007/10/18 15:08:06 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 /*! \brief TRUE is there has been some T.38 data missed (i.e. lost packets) */ 00076 int missing_data; 00077 00078 /*! \brief The number of octets to send in each image packet (non-ECM or ECM) at the current 00079 rate and the current specified packet interval. */ 00080 int octets_per_data_packet; 00081 00082 int ms_per_tx_chunk; 00083 int merge_tx_fields; 00084 00085 /*! \brief The number of times an indicator packet will be sent. Numbers greater than one 00086 will increase reliability for UDP transmission. Zero is valid, to suppress all 00087 indicator packets for TCP transmission. */ 00088 int indicator_tx_count; 00089 00090 /*! \brief The number of times a data packet which ends transmission will be sent. Numbers 00091 greater than one will increase reliability for UDP transmission. Zero is not valid. */ 00092 int data_end_tx_count; 00093 00094 /*! \brief A "sample" count, used to time events */ 00095 int32_t samples; 00096 int32_t next_tx_samples; 00097 int32_t timeout_rx_samples; 00098 00099 logging_state_t logging; 00100 } t38_terminal_state_t; 00101 00102 #if defined(__cplusplus) 00103 extern "C" 00104 { 00105 #endif 00106 00107 int t38_terminal_send_timeout(t38_terminal_state_t *s, int samples); 00108 00109 void t38_terminal_set_config(t38_terminal_state_t *s, int without_pacing); 00110 00111 /*! Select whether the time for talker echo protection tone will be allowed for when sending. 00112 \brief Select whether TEP time will be allowed for. 00113 \param s The T.38 context. 00114 \param use_tep TRUE if TEP should be allowed for. 00115 */ 00116 void t38_terminal_set_tep_mode(t38_terminal_state_t *s, int use_tep); 00117 00118 /*! \brief Initialise a termination mode T.38 context. 00119 \param s The T.38 context. 00120 \param calling_party TRUE if the context is for a calling party. FALSE if the 00121 context is for an answering party. 00122 \param tx_packet_handler A callback routine to encapsulate and transmit T.38 packets. 00123 \param tx_packet_user_data An opaque pointer passed to the tx_packet_handler routine. 00124 \return A pointer to the termination mode T.38 context, or NULL if there was a problem. */ 00125 t38_terminal_state_t *t38_terminal_init(t38_terminal_state_t *s, 00126 int calling_party, 00127 t38_tx_packet_handler_t *tx_packet_handler, 00128 void *tx_packet_user_data); 00129 00130 #if defined(__cplusplus) 00131 } 00132 #endif 00133 00134 #endif 00135 /*- End of file ------------------------------------------------------------*/