00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * fax.h - definitions for analogue line ITU T.30 fax processing 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 00026 /*! \file */ 00027 00028 #if !defined(_SPANDSP_FAX_H_) 00029 #define _SPANDSP_FAX_H_ 00030 00031 /*! \page fax_page FAX over analogue modem handling 00032 00033 \section fax_page_sec_1 What does it do? 00034 00035 \section fax_page_sec_2 How does it work? 00036 */ 00037 00038 typedef struct fax_state_s fax_state_t; 00039 00040 #if defined(__cplusplus) 00041 extern "C" 00042 { 00043 #endif 00044 00045 /*! Apply T.30 receive processing to a block of audio samples. 00046 \brief Apply T.30 receive processing to a block of audio samples. 00047 \param s The FAX context. 00048 \param amp The audio sample buffer. 00049 \param len The number of samples in the buffer. 00050 \return The number of samples unprocessed. This should only be non-zero if 00051 the software has reached the end of the FAX call. 00052 */ 00053 SPAN_DECLARE_NONSTD(int) fax_rx(fax_state_t *s, int16_t *amp, int len); 00054 00055 /*! Apply fake T.30 receive processing when a block of audio samples is missing (e.g due 00056 to packet loss). 00057 \brief Apply fake T.30 receive processing. 00058 \param s The FAX context. 00059 \param len The number of samples to fake. 00060 \return The number of samples unprocessed. This should only be non-zero if 00061 the software has reached the end of the FAX call. 00062 */ 00063 SPAN_DECLARE_NONSTD(int) fax_rx_fillin(fax_state_t *s, int len); 00064 00065 /*! Apply T.30 transmit processing to generate a block of audio samples. 00066 \brief Apply T.30 transmit processing to generate a block of audio samples. 00067 \param s The FAX context. 00068 \param amp The audio sample buffer. 00069 \param max_len The number of samples to be generated. 00070 \return The number of samples actually generated. This will be zero when 00071 there is nothing to send. 00072 */ 00073 SPAN_DECLARE_NONSTD(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len); 00074 00075 /*! Select whether silent audio will be sent when FAX transmit is idle. 00076 \brief Select whether silent audio will be sent when FAX transmit is idle. 00077 \param s The FAX context. 00078 \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is 00079 idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default 00080 behaviour is FALSE. 00081 */ 00082 SPAN_DECLARE(void) fax_set_transmit_on_idle(fax_state_t *s, int transmit_on_idle); 00083 00084 /*! Select whether talker echo protection tone will be sent for the image modems. 00085 \brief Select whether TEP will be sent for the image modems. 00086 \param s The FAX context. 00087 \param use_tep TRUE if TEP should be sent. 00088 */ 00089 SPAN_DECLARE(void) fax_set_tep_mode(fax_state_t *s, int use_tep); 00090 00091 /*! Get a pointer to the T.30 engine associated with a FAX context. 00092 \brief Get a pointer to the T.30 engine associated with a FAX context. 00093 \param s The FAX context. 00094 \return A pointer to the T.30 context, or NULL. 00095 */ 00096 SPAN_DECLARE(t30_state_t *) fax_get_t30_state(fax_state_t *s); 00097 00098 /*! Get a pointer to the logging context associated with a FAX context. 00099 \brief Get a pointer to the logging context associated with a FAX context. 00100 \param s The FAX context. 00101 \return A pointer to the logging context, or NULL. 00102 */ 00103 SPAN_DECLARE(logging_state_t *) fax_get_logging_state(fax_state_t *s); 00104 00105 /*! Restart a FAX context. 00106 \brief Restart a FAX context. 00107 \param s The FAX context. 00108 \param calling_party TRUE if the context is for a calling party. FALSE if the 00109 context is for an answering party. 00110 \return 0 for OK, else -1. */ 00111 SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party); 00112 00113 /*! Initialise a FAX context. 00114 \brief Initialise a FAX context. 00115 \param s The FAX context. 00116 \param calling_party TRUE if the context is for a calling party. FALSE if the 00117 context is for an answering party. 00118 \return A pointer to the FAX context, or NULL if there was a problem. 00119 */ 00120 SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party); 00121 00122 /*! Release a FAX context. 00123 \brief Release a FAX context. 00124 \param s The FAX context. 00125 \return 0 for OK, else -1. */ 00126 SPAN_DECLARE(int) fax_release(fax_state_t *s); 00127 00128 /*! Free a FAX context. 00129 \brief Free a FAX context. 00130 \param s The FAX context. 00131 \return 0 for OK, else -1. */ 00132 SPAN_DECLARE(int) fax_free(fax_state_t *s); 00133 00134 #if defined(__cplusplus) 00135 } 00136 #endif 00137 00138 #endif 00139 /*- End of file ------------------------------------------------------------*/