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