spandsp 3.0.0
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
40typedef void (*faxtester_flush_handler_t)(faxtester_state_t *s, void *user_data, int which);
41
42/*!
43 FAX tester descriptor.
44*/
46{
47 /*! \brief The far end FAX context */
49 t38_terminal_state_t *far_t38;
50
51 int far_tag;
52
53 /*! \brief The far end T.38 terminal context */
55
56 t30_state_t *far_t30;
57
58 t30_exchanged_info_t expected_rx_info;
59
60 bool use_receiver_not_ready;
61 bool test_local_interrupt;
62
63 /*! \brief Path for the FAX image test files. */
64 char image_path[1024];
65
66 /*! \brief Pointer to the XML document. */
67 xmlDocPtr doc;
68 /*! \brief Pointer to our current step in the test. */
69 xmlNodePtr cur;
70
71 int repeat_min;
72 int repeat_max;
73 int repeat_count;
74 xmlNodePtr repeat_start;
75 xmlNodePtr repeat_parent;
76
77 faxtester_flush_handler_t flush_handler;
78 void *flush_user_data;
79
80 const uint8_t *image_buffer;
81 int image_len;
82 int image_ptr;
83 int image_bit_ptr;
84
85 uint8_t image[1000000];
86
87 int ecm_frame_size;
88 int corrupt_crc;
89
90 int final_delayed;
91
92 fax_modems_state_t modems;
93
94 /*! \brief CED or CNG detector */
96
97 /*! If true, transmission is in progress */
99
100 /*! \brief true if the short training sequence should be used. */
102
103 /*! \brief The currently select receiver type */
105 /*! \brief The currently select transmitter type */
107
108 int wait_for_silence;
109
110 int tone_state;
111 int64_t tone_on_time;
112
113 int64_t timer;
114 int64_t timeout;
115
116 bool test_for_call_clear;
117 int call_clear_timer;
118
119 bool far_end_cleared_call;
120
121 int timein_x;
122 int timeout_x;
123
124 uint8_t awaited[1000];
125 int awaited_len;
126
127 char next_tx_file[1000];
128
129 /*! \brief Error and flow logging control */
131};
132
133#if defined(__cplusplus)
134extern "C"
135{
136#endif
137
138/*! Apply T.30 receive processing to a block of audio samples.
139 \brief Apply T.30 receive processing to a block of audio samples.
140 \param s The FAX tester context.
141 \param amp The audio sample buffer.
142 \param len The number of samples in the buffer.
143 \return The number of samples unprocessed. This should only be non-zero if
144 the software has reached the end of the FAX call.
145*/
146int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len);
147
148/*! Apply T.30 transmit processing to generate a block of audio samples.
149 \brief Apply T.30 transmit processing to generate a block of audio samples.
150 \param s The FAX tester context.
151 \param amp The audio sample buffer.
152 \param max_len The number of samples to be generated.
153 \return The number of samples actually generated. This will be zero when
154 there is nothing to send.
155*/
156int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len);
157
158void faxtester_set_tx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc);
159
160void faxtester_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc);
161
162void faxtest_set_rx_silence(faxtester_state_t *s);
163
164void faxtester_send_hdlc_flags(faxtester_state_t *s, int flags);
165
166void faxtester_send_hdlc_msg(faxtester_state_t *s, const uint8_t *msg, int len, int crc_ok);
167
168void faxtester_set_flush_handler(faxtester_state_t *s, faxtester_flush_handler_t handler, void *user_data);
169
170/*! Select whether silent audio will be sent when FAX transmit is idle.
171 \brief Select whether silent audio will be sent when FAX transmit is idle.
172 \param s The FAX tester context.
173 \param transmit_on_idle true if silent audio should be output when the FAX transmitter is
174 idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default
175 behaviour is FALSE.
176*/
177void faxtester_set_transmit_on_idle(faxtester_state_t *s, int transmit_on_idle);
178
179/*! Select whether talker echo protection tone will be sent for the image modems.
180 \brief Select whether TEP will be sent for the image modems.
181 \param s The FAX tester context.
182 \param use_tep true if TEP should be sent.
183*/
184void faxtester_set_tep_mode(faxtester_state_t *s, int use_tep);
185
186void faxtester_set_timeout(faxtester_state_t *s, int timeout);
187
188SPAN_DECLARE(int) faxtester_next_step(faxtester_state_t *s);
189
190/*! Get the logging context associated with a FAX tester context.
191 \brief Get the logging context associated with a FAX tester context.
192 \param s The FAX tester context.
193 \return A pointer to the logging context */
195
196/*! Initialise a FAX tester context.
197 \brief Initialise a FAX tester context.
198 \param s The FAX tester context.
199 \param test_file The name of the file of XML test scripts.
200 \param test The name of the XML script test.
201 \return A pointer to the FAX context, or NULL if there was a problem.
202*/
203faxtester_state_t *faxtester_init(faxtester_state_t *s, const char *test_file, const char *test);
204
205/*! Release a FAX context.
206 \brief Release a FAX context.
207 \param s The FAX tester context.
208 \return 0 for OK, else -1. */
210
211/*! Free a FAX context.
212 \brief Free a FAX context.
213 \param s The FAX tester context.
214 \return 0 for OK, else -1. */
216
217#if defined(__cplusplus)
218}
219#endif
220
221#endif
222/*- End of file ------------------------------------------------------------*/
logging_state_t * faxtester_get_logging_state(faxtester_state_t *s)
Get the logging context associated with a FAX tester context.
Definition: fax_tester.c:1846
int faxtester_free(faxtester_state_t *s)
Free a FAX context.
Definition: fax_tester.c:1902
faxtester_state_t * faxtester_init(faxtester_state_t *s, const char *test_file, const char *test)
Initialise a FAX tester context.
Definition: fax_tester.c:1852
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:654
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:860
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:854
int faxtester_release(faxtester_state_t *s)
Release a FAX context.
Definition: fax_tester.c:1891
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:675
Definition: private/fax_modems.h:35
Definition: private/fax.h:36
Definition: fax_tester.h:46
logging_state_t logging
Error and flow logging control.
Definition: fax_tester.h:130
bool short_train
true if the short training sequence should be used.
Definition: fax_tester.h:101
xmlDocPtr doc
Pointer to the XML document.
Definition: fax_tester.h:67
char image_path[1024]
Path for the FAX image test files.
Definition: fax_tester.h:64
t38_terminal_state_t * far_t38_fax
The far end T.38 terminal context.
Definition: fax_tester.h:54
int current_rx_type
The currently select receiver type.
Definition: fax_tester.h:104
bool transmit
Definition: fax_tester.h:98
fax_state_t * far_fax
The far end FAX context.
Definition: fax_tester.h:48
int current_tx_type
The currently select transmitter type.
Definition: fax_tester.h:106
modem_connect_tones_rx_state_t connect_rx
CED or CNG detector.
Definition: fax_tester.h:95
xmlNodePtr cur
Pointer to our current step in the test.
Definition: fax_tester.h:69
Definition: private/logging.h:34
Definition: private/modem_connect_tones.h:58
Definition: t30.h:417
Definition: private/t30.h:36
Definition: private/t38_terminal.h:111