t31.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * t31.h - A T.31 compatible class 1 FAX modem interface.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2004 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: t31.h,v 1.59 2009/03/13 12:59:26 steveu Exp $
00026  */
00027 
00028 /*! \file */
00029 
00030 #if !defined(_SPANDSP_T31_H_)
00031 #define _SPANDSP_T31_H_
00032 
00033 /*! \page t31_page T.31 Class 1 FAX modem protocol handling
00034 \section t31_page_sec_1 What does it do?
00035 The T.31 class 1 FAX modem modules implements a class 1 interface to the FAX
00036 modems in spandsp.
00037 
00038 \section t31_page_sec_2 How does it work?
00039 */
00040 
00041 /*!
00042     T.31 descriptor. This defines the working state for a single instance of
00043     a T.31 FAX modem.
00044 */
00045 typedef struct t31_state_s t31_state_t;
00046 
00047 typedef int (t31_modem_control_handler_t)(t31_state_t *s, void *user_data, int op, const char *num);
00048 
00049 #define T31_TX_BUF_LEN          (4096)
00050 #define T31_TX_BUF_HIGH_TIDE    (4096 - 1024)
00051 #define T31_TX_BUF_LOW_TIDE     (1024)
00052 #define T31_MAX_HDLC_LEN        284
00053 #define T31_T38_MAX_HDLC_LEN    260
00054 
00055 #if defined(__cplusplus)
00056 extern "C"
00057 {
00058 #endif
00059 
00060 SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event);
00061 
00062 SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len);
00063 
00064 /*! Process a block of received T.31 modem audio samples.
00065     \brief Process a block of received T.31 modem audio samples.
00066     \param s The T.31 modem context.
00067     \param amp The audio sample buffer.
00068     \param len The number of samples in the buffer.
00069     \return The number of samples unprocessed. */
00070 SPAN_DECLARE(int) t31_rx(t31_state_t *s, int16_t amp[], int len);
00071 
00072 /*! Fake processing of a missing block of received T.31 modem audio samples
00073     (e.g due to packet loss).
00074     \brief Fake processing of a missing block of received T.31 modem audio samples.
00075     \param s The T.31 modem context.
00076     \param len The number of samples to fake.
00077     \return The number of samples unprocessed. */
00078 SPAN_DECLARE(int) t31_rx_fillin(t31_state_t *s, int len);
00079 
00080 /*! Generate a block of T.31 modem audio samples.
00081     \brief Generate a block of T.31 modem audio samples.
00082     \param s The T.31 modem context.
00083     \param amp The audio sample buffer.
00084     \param max_len The number of samples to be generated.
00085     \return The number of samples actually generated.
00086 */
00087 SPAN_DECLARE(int) t31_tx(t31_state_t *s, int16_t amp[], int max_len);
00088 
00089 SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples);
00090 
00091 /*! Select whether silent audio will be sent when transmit is idle.
00092     \brief Select whether silent audio will be sent when transmit is idle.
00093     \param s The T.31 modem context.
00094     \param transmit_on_idle TRUE if silent audio should be output when the transmitter is
00095            idle. FALSE to transmit zero length audio when the transmitter is idle. The default
00096            behaviour is FALSE.
00097 */
00098 SPAN_DECLARE(void) t31_set_transmit_on_idle(t31_state_t *s, int transmit_on_idle);
00099 
00100 /*! Select whether TEP mode will be used (or time allowed for it (when transmitting).
00101     \brief Select whether TEP mode will be used.
00102     \param s The T.31 modem context.
00103     \param use_tep TRUE if TEP is to be ised.
00104 */
00105 SPAN_DECLARE(void) t31_set_tep_mode(t31_state_t *s, int use_tep);
00106 
00107 /*! Select whether T.38 data will be paced as it is transmitted.
00108     \brief Select whether T.38 data will be paced.
00109     \param s The T.31 modem context.
00110     \param without_pacing TRUE if data is to be sent as fast as possible. FALSE if it is
00111            to be paced.
00112 */
00113 SPAN_DECLARE(void) t31_set_t38_config(t31_state_t *s, int without_pacing);
00114 
00115 SPAN_DECLARE(void) t31_set_mode(t31_state_t *s, int t38_mode);
00116 
00117 /*! Get a pointer to the logging context associated with a T.31 context.
00118     \brief Get a pointer to the logging context associated with a T.31 context.
00119     \param s The T.31 context.
00120     \return A pointer to the logging context, or NULL.
00121 */
00122 SPAN_DECLARE(logging_state_t *) t31_get_logging_state(t31_state_t *s);
00123 
00124 SPAN_DECLARE(t38_core_state_t *) t31_get_t38_core_state(t31_state_t *s);
00125 
00126 /*! Initialise a T.31 context. This must be called before the first
00127     use of the context, to initialise its contents.
00128     \brief Initialise a T.31 context.
00129     \param s The T.31 context.
00130     \param at_tx_handler A callback routine to handle AT interpreter channel output.
00131     \param at_tx_user_data An opaque pointer passed in called to at_tx_handler.
00132     \param modem_control_handler A callback routine to handle control of the modem (off-hook, etc).
00133     \param modem_control_user_data An opaque pointer passed in called to modem_control_handler.
00134     \param tx_t38_packet_handler ???
00135     \param tx_t38_packet_user_data ???
00136     \return A pointer to the T.31 context. */
00137 SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s,
00138                                      at_tx_handler_t *at_tx_handler,
00139                                      void *at_tx_user_data,
00140                                      t31_modem_control_handler_t *modem_control_handler,
00141                                      void *modem_control_user_data,
00142                                      t38_tx_packet_handler_t *tx_t38_packet_handler,
00143                                      void *tx_t38_packet_user_data);
00144 
00145 /*! Release a T.31 context.
00146     \brief Release a T.31 context.
00147     \param s The T.31 context.
00148     \return 0 for OK */
00149 SPAN_DECLARE(int) t31_release(t31_state_t *s);
00150 
00151 /*! Free a T.31 context.
00152     \brief Release a T.31 context.
00153     \param s The T.31 context.
00154     \return 0 for OK */
00155 SPAN_DECLARE(int) t31_free(t31_state_t *s);
00156 
00157 #if defined(__cplusplus)
00158 }
00159 #endif
00160 
00161 #endif
00162 /*- End of file ------------------------------------------------------------*/

Generated on Tue Aug 4 03:36:06 2009 for spandsp by  doxygen 1.5.9