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