Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/tests/fax_tester.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * fax_tester.h | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2008 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 14 * as published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Lesser General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Lesser General Public | |
| 22 * License along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: fax_tester.h,v 1.9 2008/09/12 14:41:55 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 #if !defined(_SPANDSP_FAX_TESTER_H_) | |
| 31 #define _SPANDSP_FAX_TESTER_H_ | |
| 32 | |
| 33 /*! \page fax_tester_page FAX over analogue modem handling | |
| 34 | |
| 35 \section fax_tester_page_sec_1 What does it do? | |
| 36 | |
| 37 \section fax_tester_page_sec_2 How does it work? | |
| 38 */ | |
| 39 | |
| 40 typedef struct faxtester_state_s faxtester_state_t; | |
| 41 | |
| 42 typedef void (faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, int which); | |
| 43 | |
| 44 /*! | |
| 45 FAX tester real time frame handler. | |
| 46 \brief FAX tester real time frame handler. | |
| 47 \param s The FAX tester context. | |
| 48 \param user_data An opaque pointer. | |
| 49 \param direction TRUE for incoming, FALSE for outgoing. | |
| 50 \param msg The HDLC message. | |
| 51 \param len The length of the message. | |
| 52 */ | |
| 53 typedef void (faxtester_real_time_frame_handler_t)(faxtester_state_t *s, | |
| 54 void *user_data, | |
| 55 int direction, | |
| 56 const uint8_t *msg, | |
| 57 int len); | |
| 58 | |
| 59 typedef void (faxtester_front_end_step_complete_handler_t)(faxtester_state_t *s, void *user_data); | |
| 60 | |
| 61 /*! | |
| 62 FAX tester descriptor. | |
| 63 */ | |
| 64 struct faxtester_state_s | |
| 65 { | |
| 66 /*! \brief Pointer to our current step in the test. */ | |
| 67 xmlNodePtr cur; | |
| 68 | |
| 69 faxtester_flush_handler_t *flush_handler; | |
| 70 void *flush_user_data; | |
| 71 | |
| 72 /*! \brief A pointer to a callback routine to be called when frames are | |
| 73 exchanged. */ | |
| 74 faxtester_real_time_frame_handler_t *real_time_frame_handler; | |
| 75 /*! \brief An opaque pointer supplied in real time frame callbacks. */ | |
| 76 void *real_time_frame_user_data; | |
| 77 | |
| 78 faxtester_front_end_step_complete_handler_t *front_end_step_complete_handler; | |
| 79 void *front_end_step_complete_user_data; | |
| 80 | |
| 81 faxtester_front_end_step_complete_handler_t *front_end_step_timeout_handler; | |
| 82 void *front_end_step_timeout_user_data; | |
| 83 | |
| 84 const uint8_t *image_buffer; | |
| 85 int image_len; | |
| 86 int image_ptr; | |
| 87 int image_bit_ptr; | |
| 88 | |
| 89 int ecm_frame_size; | |
| 90 int corrupt_crc; | |
| 91 | |
| 92 int final_delayed; | |
| 93 | |
| 94 fax_modems_state_t modems; | |
| 95 | |
| 96 /*! If TRUE, transmission is in progress */ | |
| 97 int transmit; | |
| 98 | |
| 99 /*! \brief TRUE is the short training sequence should be used. */ | |
| 100 int short_train; | |
| 101 | |
| 102 /*! \brief The currently select receiver type */ | |
| 103 int current_rx_type; | |
| 104 /*! \brief The currently select transmitter type */ | |
| 105 int current_tx_type; | |
| 106 | |
| 107 int wait_for_silence; | |
| 108 | |
| 109 int tone_state; | |
| 110 int64_t tone_on_time; | |
| 111 | |
| 112 int64_t timer; | |
| 113 int64_t timeout; | |
| 114 | |
| 115 /*! \brief Error and flow logging control */ | |
| 116 logging_state_t logging; | |
| 117 }; | |
| 118 | |
| 119 #if defined(__cplusplus) | |
| 120 extern "C" | |
| 121 { | |
| 122 #endif | |
| 123 | |
| 124 /*! Apply T.30 receive processing to a block of audio samples. | |
| 125 \brief Apply T.30 receive processing to a block of audio samples. | |
| 126 \param s The FAX tester context. | |
| 127 \param amp The audio sample buffer. | |
| 128 \param len The number of samples in the buffer. | |
| 129 \return The number of samples unprocessed. This should only be non-zero if | |
| 130 the software has reached the end of the FAX call. | |
| 131 */ | |
| 132 int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len); | |
| 133 | |
| 134 /*! Apply T.30 transmit processing to generate a block of audio samples. | |
| 135 \brief Apply T.30 transmit processing to generate a block of audio samples. | |
| 136 \param s The FAX tester context. | |
| 137 \param amp The audio sample buffer. | |
| 138 \param max_len The number of samples to be generated. | |
| 139 \return The number of samples actually generated. This will be zero when | |
| 140 there is nothing to send. | |
| 141 */ | |
| 142 int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len); | |
| 143 | |
| 144 void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc); | |
| 145 | |
| 146 void faxtester_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc); | |
| 147 | |
| 148 void faxtest_set_rx_silence(faxtester_state_t *s); | |
| 149 | |
| 150 void faxtester_send_hdlc_flags(faxtester_state_t *s, int flags); | |
| 151 | |
| 152 void faxtester_send_hdlc_msg(faxtester_state_t *s, const uint8_t *msg, int len, int crc_ok); | |
| 153 | |
| 154 void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t *handler, void *user_data); | |
| 155 | |
| 156 /*! Select whether silent audio will be sent when FAX transmit is idle. | |
| 157 \brief Select whether silent audio will be sent when FAX transmit is idle. | |
| 158 \param s The FAX tester context. | |
| 159 \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is | |
| 160 idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default | |
| 161 behaviour is FALSE. | |
| 162 */ | |
| 163 void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle); | |
| 164 | |
| 165 /*! Select whether talker echo protection tone will be sent for the image modems. | |
| 166 \brief Select whether TEP will be sent for the image modems. | |
| 167 \param s The FAX tester context. | |
| 168 \param use_tep TRUE if TEP should be sent. | |
| 169 */ | |
| 170 void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep); | |
| 171 | |
| 172 void faxtester_set_real_time_frame_handler(faxtester_state_t *s, faxtester_real_time_frame_handler_t *handler, void *user_data); | |
| 173 | |
| 174 void faxtester_set_front_end_step_complete_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t *handler, void *user_data); | |
| 175 | |
| 176 void faxtester_set_front_end_step_timeout_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t *handler, void *user_data); | |
| 177 | |
| 178 void faxtester_set_timeout(faxtester_state_t *s, int timeout); | |
| 179 | |
| 180 void faxtester_set_non_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len); | |
| 181 | |
| 182 void faxtester_set_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len, int block, int frame_size, int crc_hit); | |
| 183 | |
| 184 /*! Initialise a FAX context. | |
| 185 \brief Initialise a FAX context. | |
| 186 \param s The FAX tester context. | |
| 187 \param calling_party TRUE if the context is for a calling party. FALSE if the | |
| 188 context is for an answering party. | |
| 189 \return A pointer to the FAX context, or NULL if there was a problem. | |
| 190 */ | |
| 191 faxtester_state_t *faxtester_init(faxtester_state_t *s, int calling_party); | |
| 192 | |
| 193 /*! Release a FAX context. | |
| 194 \brief Release a FAX context. | |
| 195 \param s The FAX tester context. | |
| 196 \return 0 for OK, else -1. */ | |
| 197 int faxtester_release(faxtester_state_t *s); | |
| 198 | |
| 199 /*! Free a FAX context. | |
| 200 \brief Free a FAX context. | |
| 201 \param s The FAX tester context. | |
| 202 \return 0 for OK, else -1. */ | |
| 203 int faxtester_free(faxtester_state_t *s); | |
| 204 | |
| 205 #if defined(__cplusplus) | |
| 206 } | |
| 207 #endif | |
| 208 | |
| 209 #endif | |
| 210 /*- End of file ------------------------------------------------------------*/ |
