t38_terminal.h

Go to the documentation of this file.
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 Lesser General Public License version 2.1,
00014  * as 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 Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License 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.32 2008/05/30 14:54:42 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 HDLC transmit buffer */
00051     uint8_t tx_buf[T38_MAX_HDLC_LEN];
00052     /*! \brief The length of the contents of the HDLC transmit buffer */
00053     int tx_len;
00054     /*! \brief The number of extra bits in a fully stuffed version of the
00055                contents of the HDLC transmit buffer. */
00056     int tx_extra_bits;
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 Required time between T.38 transmissions, in ms. */
00095     int ms_per_tx_chunk;
00096     /*! \brief Bit fields controlling the way data is packed into chunked for transmission. */
00097     int chunking_modes;
00098 
00099     int spare1;
00100     /*! \brief Current bit rate. */
00101     int bit_rate;
00102     /*! \brief A "sample" count, used to time events. */
00103     int32_t samples;
00104     /*! \brief The value for samples at the next transmission point. */
00105     int32_t next_tx_samples;
00106     /*! \brief The current receive timeout. */
00107     int32_t timeout_rx_samples;
00108 
00109     /*! \brief Internet Aware FAX mode bit mask. */
00110     int iaf;
00111 
00112     logging_state_t logging;
00113 } t38_terminal_state_t;
00114 
00115 #if defined(__cplusplus)
00116 extern "C"
00117 {
00118 #endif
00119 
00120 int t38_terminal_send_timeout(t38_terminal_state_t *s, int samples);
00121 
00122 void t38_terminal_set_config(t38_terminal_state_t *s, int without_pacing);
00123 
00124 /*! Select whether the time for talker echo protection tone will be allowed for when sending.
00125     \brief Select whether TEP time will be allowed for.
00126     \param s The T.38 context.
00127     \param use_tep TRUE if TEP should be allowed for.
00128 */
00129 void t38_terminal_set_tep_mode(t38_terminal_state_t *s, int use_tep);
00130 
00131 
00132 /*! Select whether non-ECM fill bits are to be removed during transmission.
00133     \brief Select whether non-ECM fill bits are to be removed during transmission.
00134     \param s The T.38 context.
00135     \param remove TRUE if fill bits are to be removed.
00136 */
00137 void t38_terminal_set_fill_bit_removal(t38_terminal_state_t *s, int remove);
00138 
00139 /*! \brief Initialise a termination mode T.38 context.
00140     \param s The T.38 context.
00141     \param calling_party TRUE if the context is for a calling party. FALSE if the
00142            context is for an answering party.
00143     \param tx_packet_handler A callback routine to encapsulate and transmit T.38 packets.
00144     \param tx_packet_user_data An opaque pointer passed to the tx_packet_handler routine.
00145     \return A pointer to the termination mode T.38 context, or NULL if there was a problem. */
00146 t38_terminal_state_t *t38_terminal_init(t38_terminal_state_t *s,
00147                                         int calling_party,
00148                                         t38_tx_packet_handler_t *tx_packet_handler,
00149                                         void *tx_packet_user_data);
00150 
00151 /*! Release a termination mode T.38 context.
00152     \brief Release a T.38 context.
00153     \param s The T.38 context.
00154     \return 0 for OK, else -1. */
00155 int t38_terminal_release(t38_terminal_state_t *s);
00156 
00157 /*! Free a a termination mode T.38 context.
00158     \brief Free a T.38 context.
00159     \param s The T.38 context.
00160     \return 0 for OK, else -1. */
00161 int t38_terminal_free(t38_terminal_state_t *s);
00162 
00163 #if defined(__cplusplus)
00164 }
00165 #endif
00166 
00167 #endif
00168 /*- End of file ------------------------------------------------------------*/

Generated on Tue Dec 16 08:37:00 2008 for libspandsp by  doxygen 1.5.5