spandsp  0.0.6
fax_tester.h
Go to the documentation of this file.
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 General Public License version 2, as
14  * 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 General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 /*! \file */
27 
28 #if !defined(_SPANDSP_FAX_TESTER_H_)
29 #define _SPANDSP_FAX_TESTER_H_
30 
31 /*! \page fax_tester_page FAX over analogue modem handling
32 
33 \section fax_tester_page_sec_1 What does it do?
34 
35 \section fax_tester_page_sec_2 How does it work?
36 */
37 
39 
40 typedef void (*faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, int which);
41 
42 /*!
43  FAX tester real time frame handler.
44  \brief FAX tester real time frame handler.
45  \param s The FAX tester context.
46  \param user_data An opaque pointer.
47  \param direction TRUE for incoming, FALSE for outgoing.
48  \param msg The HDLC message.
49  \param len The length of the message.
50 */
52  void *user_data,
53  int direction,
54  const uint8_t *msg,
55  int len);
56 
57 typedef void (*faxtester_front_end_step_complete_handler_t)(faxtester_state_t *s, void *user_data);
58 
59 /*!
60  FAX tester descriptor.
61 */
63 {
64  /*! \brief Pointer to our current step in the test. */
65  xmlNodePtr cur;
66 
67  faxtester_flush_handler_t flush_handler;
68  void *flush_user_data;
69 
70  /*! \brief A pointer to a callback routine to be called when frames are
71  exchanged. */
73  /*! \brief An opaque pointer supplied in real time frame callbacks. */
75 
76  faxtester_front_end_step_complete_handler_t front_end_step_complete_handler;
77  void *front_end_step_complete_user_data;
78 
79  faxtester_front_end_step_complete_handler_t front_end_step_timeout_handler;
80  void *front_end_step_timeout_user_data;
81 
82  const uint8_t *image_buffer;
83  int image_len;
84  int image_ptr;
85  int image_bit_ptr;
86 
87  int ecm_frame_size;
88  int corrupt_crc;
89 
90  int final_delayed;
91 
92  fax_modems_state_t modems;
93 
94  /*! If TRUE, transmission is in progress */
95  int transmit;
96 
97  /*! \brief TRUE is the short training sequence should be used. */
99 
100  /*! \brief The currently select receiver type */
102  /*! \brief The currently select transmitter type */
104 
105  int wait_for_silence;
106 
107  int tone_state;
108  int64_t tone_on_time;
109 
110  int64_t timer;
111  int64_t timeout;
112 
113  /*! \brief Error and flow logging control */
115 };
116 
117 #if defined(__cplusplus)
118 extern "C"
119 {
120 #endif
121 
122 /*! Apply T.30 receive processing to a block of audio samples.
123  \brief Apply T.30 receive processing to a block of audio samples.
124  \param s The FAX tester context.
125  \param amp The audio sample buffer.
126  \param len The number of samples in the buffer.
127  \return The number of samples unprocessed. This should only be non-zero if
128  the software has reached the end of the FAX call.
129 */
130 int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len);
131 
132 /*! Apply T.30 transmit processing to generate a block of audio samples.
133  \brief Apply T.30 transmit processing to generate a block of audio samples.
134  \param s The FAX tester context.
135  \param amp The audio sample buffer.
136  \param max_len The number of samples to be generated.
137  \return The number of samples actually generated. This will be zero when
138  there is nothing to send.
139 */
140 int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len);
141 
142 void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc);
143 
144 void faxtester_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc);
145 
146 void faxtest_set_rx_silence(faxtester_state_t *s);
147 
148 void faxtester_send_hdlc_flags(faxtester_state_t *s, int flags);
149 
150 void faxtester_send_hdlc_msg(faxtester_state_t *s, const uint8_t *msg, int len, int crc_ok);
151 
152 void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t handler, void *user_data);
153 
154 /*! Select whether silent audio will be sent when FAX transmit is idle.
155  \brief Select whether silent audio will be sent when FAX transmit is idle.
156  \param s The FAX tester context.
157  \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is
158  idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default
159  behaviour is FALSE.
160 */
161 void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle);
162 
163 /*! Select whether talker echo protection tone will be sent for the image modems.
164  \brief Select whether TEP will be sent for the image modems.
165  \param s The FAX tester context.
166  \param use_tep TRUE if TEP should be sent.
167 */
168 void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep);
169 
170 void faxtester_set_real_time_frame_handler(faxtester_state_t *s, faxtester_real_time_frame_handler_t handler, void *user_data);
171 
172 void faxtester_set_front_end_step_complete_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t handler, void *user_data);
173 
174 void faxtester_set_front_end_step_timeout_handler(faxtester_state_t *s, faxtester_front_end_step_complete_handler_t handler, void *user_data);
175 
176 void faxtester_set_timeout(faxtester_state_t *s, int timeout);
177 
178 void faxtester_set_non_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len);
179 
180 void faxtester_set_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len, int block, int frame_size, int crc_hit);
181 
182 /*! Initialise a FAX context.
183  \brief Initialise a FAX context.
184  \param s The FAX tester context.
185  \param calling_party TRUE if the context is for a calling party. FALSE if the
186  context is for an answering party.
187  \return A pointer to the FAX context, or NULL if there was a problem.
188 */
189 faxtester_state_t *faxtester_init(faxtester_state_t *s, int calling_party);
190 
191 /*! Release a FAX context.
192  \brief Release a FAX context.
193  \param s The FAX tester context.
194  \return 0 for OK, else -1. */
196 
197 /*! Free a FAX context.
198  \brief Free a FAX context.
199  \param s The FAX tester context.
200  \return 0 for OK, else -1. */
202 
203 #if defined(__cplusplus)
204 }
205 #endif
206 
207 #endif
208 /*- End of file ------------------------------------------------------------*/
int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len)
Apply T.30 transmit processing to generate a block of audio samples.
Definition: fax_tester.c:406
int short_train
TRUE is the short training sequence should be used.
Definition: fax_tester.h:98
int current_tx_type
The currently select transmitter type.
Definition: fax_tester.h:103
void(* faxtester_real_time_frame_handler_t)(faxtester_state_t *s, void *user_data, int direction, const uint8_t *msg, int len)
FAX tester real time frame handler.
Definition: fax_tester.h:51
void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep)
Select whether TEP will be sent for the image modems.
Definition: fax_tester.c:633
faxtester_state_t * faxtester_init(faxtester_state_t *s, int calling_party)
Initialise a FAX context.
Definition: fax_tester.c:696
int faxtester_release(faxtester_state_t *s)
Release a FAX context.
Definition: fax_tester.c:715
Definition: private/fax_modems.h:34
logging_state_t logging
Error and flow logging control.
Definition: fax_tester.h:114
int transmit
Definition: fax_tester.h:95
xmlNodePtr cur
Pointer to our current step in the test.
Definition: fax_tester.h:65
faxtester_real_time_frame_handler_t real_time_frame_handler
A pointer to a callback routine to be called when frames are exchanged.
Definition: fax_tester.h:72
int faxtester_free(faxtester_state_t *s)
Free a FAX context.
Definition: fax_tester.c:721
Definition: private/logging.h:33
int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len)
Apply T.30 receive processing to a block of audio samples.
Definition: fax_tester.c:386
void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle)
Select whether silent audio will be sent when FAX transmit is idle.
Definition: fax_tester.c:627
int current_rx_type
The currently select receiver type.
Definition: fax_tester.h:101
void * real_time_frame_user_data
An opaque pointer supplied in real time frame callbacks.
Definition: fax_tester.h:74
Definition: fax_tester.h:62