spandsp 0.0.6
|
00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * fax_tester.h 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2008 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_tester.h,v 1.9 2008/09/12 14:41:55 steveu Exp $ 00026 */ 00027 00028 /*! \file */ 00029 00030 #if !defined(_SPANDSP_FAX_TESTER_H_) 00031 #define _SPANDSP_FAX_TESTER_H_ 00032 00033 /*! \page fax_tester_page FAX over analogue modem handling 00034 00035 \section fax_tester_page_sec_1 What does it do? 00036 00037 \section fax_tester_page_sec_2 How does it work? 00038 */ 00039 00040 typedef struct faxtester_state_s faxtester_state_t; 00041 00042 typedef void (faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, int which); 00043 00044 /*! 00045 FAX tester real time frame handler. 00046 \brief FAX tester real time frame handler. 00047 \param s The FAX tester context. 00048 \param user_data An opaque pointer. 00049 \param direction TRUE for incoming, FALSE for outgoing. 00050 \param msg The HDLC message. 00051 \param len The length of the message. 00052 */ 00053 typedef void (faxtester_real_time_frame_handler_t)(faxtester_state_t *s, 00054 void *user_data, 00055 int direction, 00056 const uint8_t *msg, 00057 int len); 00058 00059 typedef void (faxtester_front_end_step_complete_handler_t)(faxtester_state_t *s, void *user_data); 00060 00061 /*! 00062 FAX tester descriptor. 00063 */ 00064 struct faxtester_state_s 00065 { 00066 /*! \brief Pointer to our current step in the test. */ 00067 xmlNodePtr cur; 00068 00069 faxtester_flush_handler_t *flush_handler; 00070 void *flush_user_data; 00071 00072 /*! \brief A pointer to a callback routine to be called when frames are 00073 exchanged. */ 00074 faxtester_real_time_frame_handler_t *real_time_frame_handler; 00075 /*! \brief An opaque pointer supplied in real time frame callbacks. */ 00076 void *real_time_frame_user_data; 00077 00078 faxtester_front_end_step_complete_handler_t *front_end_step_complete_handler; 00079 void *front_end_step_complete_user_data; 00080 00081 faxtester_front_end_step_complete_handler_t *front_end_step_timeout_handler; 00082 void *front_end_step_timeout_user_data; 00083 00084 const uint8_t *image_buffer; 00085 int image_len; 00086 int image_ptr; 00087 int image_bit_ptr; 00088 00089 int ecm_frame_size; 00090 int corrupt_crc; 00091 00092 int final_delayed; 00093 00094 fax_modems_state_t modems; 00095 00096 /*! If TRUE, transmission is in progress */ 00097 int transmit; 00098 00099 /*! \brief TRUE is the short training sequence should be used. */ 00100 int short_train; 00101 00102 /*! \brief The currently select receiver type */ 00103 int current_rx_type; 00104 /*! \brief The currently select transmitter type */ 00105 int current_tx_type; 00106 00107 int wait_for_silence; 00108 00109 int tone_state; 00110 int64_t tone_on_time; 00111 00112 int64_t timer; 00113 int64_t timeout; 00114 00115 /*! \brief Error and flow logging control */ 00116 logging_state_t logging; 00117 }; 00118 00119 #if defined(__cplusplus) 00120 extern "C" 00121 { 00122 #endif 00123 00124 /*! Apply T.30 receive processing to a block of audio samples. 00125 \brief Apply T.30 receive processing to a block of audio samples. 00126 \param s The FAX tester context. 00127 \param amp The audio sample buffer. 00128 \param len The number of samples in the buffer. 00129 \return The number of samples unprocessed. This should only be non-zero if 00130 the software has reached the end of the FAX call. 00131 */ 00132 int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len); 00133 00134 /*! Apply T.30 transmit processing to generate a block of audio samples. 00135 \brief Apply T.30 transmit processing to generate a block of audio samples. 00136 \param s The FAX tester context. 00137 \param amp The audio sample buffer. 00138 \param max_len The number of samples to be generated. 00139 \return The number of samples actually generated. This will be zero when 00140 there is nothing to send. 00141 */ 00142 int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len); 00143 00144 void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc); 00145 00146 void faxtester_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc); 00147 00148 void faxtest_set_rx_silence(faxtester_state_t *s); 00149 00150 void faxtester_send_hdlc_flags(faxtester_state_t *s, int flags); 00151 00152 void faxtester_send_hdlc_msg(faxtester_state_t *s, const uint8_t *msg, int len, int crc_ok); 00153 00154 void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t *handler, void *user_data); 00155 00156 /*! Select whether silent audio will be sent when FAX transmit is idle. 00157 \brief Select whether silent audio will be sent when FAX transmit is idle. 00158 \param s The FAX tester context. 00159 \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is 00160 idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default 00161 behaviour is FALSE. 00162 */ 00163 void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle); 00164 00165 /*! Select whether talker echo protection tone will be sent for the image modems. 00166 \brief Select whether TEP will be sent for the image modems. 00167 \param s The FAX tester context. 00168 \param use_tep TRUE if TEP should be sent. 00169 */ 00170 void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep); 00171 00172 void faxtester_set_real_time_frame_handler(faxtester_state_t *s, faxtester_real_time_frame_handler_t *handler, void *user_data); 00173 00174 void faxtester_set_front_end_step_complete_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t *handler, void *user_data); 00175 00176 void faxtester_set_front_end_step_timeout_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t *handler, void *user_data); 00177 00178 void faxtester_set_timeout(faxtester_state_t *s, int timeout); 00179 00180 void faxtester_set_non_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len); 00181 00182 void faxtester_set_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len, int block, int frame_size, int crc_hit); 00183 00184 /*! Initialise a FAX context. 00185 \brief Initialise a FAX context. 00186 \param s The FAX tester context. 00187 \param calling_party TRUE if the context is for a calling party. FALSE if the 00188 context is for an answering party. 00189 \return A pointer to the FAX context, or NULL if there was a problem. 00190 */ 00191 faxtester_state_t *faxtester_init(faxtester_state_t *s, int calling_party); 00192 00193 /*! Release a FAX context. 00194 \brief Release a FAX context. 00195 \param s The FAX tester context. 00196 \return 0 for OK, else -1. */ 00197 int faxtester_release(faxtester_state_t *s); 00198 00199 /*! Free a FAX context. 00200 \brief Free a FAX context. 00201 \param s The FAX tester context. 00202 \return 0 for OK, else -1. */ 00203 int faxtester_free(faxtester_state_t *s); 00204 00205 #if defined(__cplusplus) 00206 } 00207 #endif 00208 00209 #endif 00210 /*- End of file ------------------------------------------------------------*/