Mercurial > hg > audiostuff
comparison spandsp-0.0.3/spandsp-0.0.3/src/spandsp/fax.h @ 5:f762bf195c4b
import spandsp-0.0.3
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 16:00:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:26cd8f1ef0b1 | 5:f762bf195c4b |
---|---|
1 /* | |
2 * SpanDSP - a series of DSP components for telephony | |
3 * | |
4 * fax.h - definitions for analogue line ITU T.30 fax processing | |
5 * | |
6 * Written by Steve Underwood <steveu@coppice.org> | |
7 * | |
8 * Copyright (C) 2005 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 * $Id: fax.h,v 1.20 2006/10/24 13:45:28 steveu Exp $ | |
26 */ | |
27 | |
28 /*! \file */ | |
29 | |
30 #if !defined(_FAX_H_) | |
31 #define _FAX_H_ | |
32 | |
33 /*! \page fax_page FAX over analogue modem handling | |
34 | |
35 \section fax_page_sec_1 What does it do? | |
36 | |
37 \section fax_page_sec_2 How does it work? | |
38 */ | |
39 | |
40 typedef struct fax_state_s fax_state_t; | |
41 | |
42 typedef void (fax_flush_handler_t)(fax_state_t *s, void *user_data, int which); | |
43 | |
44 /*! | |
45 Analogue line T.30 FAX channel descriptor. This defines the state of a single working | |
46 instance of an analogue line soft-FAX machine. | |
47 */ | |
48 struct fax_state_s | |
49 { | |
50 /* This must be kept the first thing in the structure, so it can be pointed | |
51 to reliably as the structures change over time. */ | |
52 t30_state_t t30_state; | |
53 | |
54 /*! TRUE is talker echo protection should be sent for the image modems */ | |
55 int use_tep; | |
56 | |
57 fax_flush_handler_t *flush_handler; | |
58 void *flush_user_data; | |
59 | |
60 /*! The current receive signal handler */ | |
61 span_rx_handler_t *rx_handler; | |
62 void *rx_user_data; | |
63 | |
64 /*! The current transmit signal handler */ | |
65 span_tx_handler_t *tx_handler; | |
66 void *tx_user_data; | |
67 int tx_hdlc_preamble_len; | |
68 /*! The transmit signal handler to be used when the current one has finished sending. */ | |
69 span_tx_handler_t *next_tx_handler; | |
70 void *next_tx_user_data; | |
71 | |
72 /*! If TRUE, transmission is in progress */ | |
73 int transmit; | |
74 | |
75 /*! If TRUE, transmit silence when there is nothing else to transmit. If FALSE return only | |
76 the actual generated audio. Note that this only affects untimed silences. Timed silences | |
77 (e.g. the 75ms silence between V.21 and a high speed modem) will alway be transmitted as | |
78 silent audio. */ | |
79 int transmit_on_idle; | |
80 | |
81 /*! \brief A tone generator context used to generate supervisory tones during | |
82 FAX handling. */ | |
83 tone_gen_state_t tone_gen; | |
84 /*! \brief An HDLC context used when receiving HDLC over V.21 messages. */ | |
85 hdlc_rx_state_t hdlcrx; | |
86 /*! \brief An HDLC context used when transmitting HDLC over V.21 messages. */ | |
87 hdlc_tx_state_t hdlctx; | |
88 /*! \brief A V.21 FSK modem context used when transmitting HDLC over V.21 | |
89 messages. */ | |
90 fsk_tx_state_t v21tx; | |
91 /*! \brief A V.21 FSK modem context used when receiving HDLC over V.21 | |
92 messages. */ | |
93 fsk_rx_state_t v21rx; | |
94 #if defined(ENABLE_V17) | |
95 /*! \brief A V.17 modem context used when sending FAXes at 7200bps, 9600bps | |
96 12000bps or 14400bps*/ | |
97 v17_tx_state_t v17tx; | |
98 /*! \brief A V.29 modem context used when receiving FAXes at 7200bps, 9600bps | |
99 12000bps or 14400bps*/ | |
100 v17_rx_state_t v17rx; | |
101 #endif | |
102 /*! \brief A V.27ter modem context used when sending FAXes at 2400bps or | |
103 4800bps */ | |
104 v27ter_tx_state_t v27ter_tx; | |
105 /*! \brief A V.27ter modem context used when receiving FAXes at 2400bps or | |
106 4800bps */ | |
107 v27ter_rx_state_t v27ter_rx; | |
108 /*! \brief A V.29 modem context used when sending FAXes at 7200bps or | |
109 9600bps */ | |
110 v29_tx_state_t v29tx; | |
111 /*! \brief A V.29 modem context used when receiving FAXes at 7200bps or | |
112 9600bps */ | |
113 v29_rx_state_t v29rx; | |
114 /*! \brief Used to insert timed silences. */ | |
115 silence_gen_state_t silence_gen; | |
116 /*! \brief */ | |
117 dc_restore_state_t dc_restore; | |
118 | |
119 /*! \brief TRUE is the short training sequence should be used. */ | |
120 int short_train; | |
121 | |
122 /*! The currently select receiver type */ | |
123 int current_rx_type; | |
124 /*! The currently select transmitter type */ | |
125 int current_tx_type; | |
126 | |
127 int first_tx_hdlc_frame; | |
128 | |
129 /*! Audio logging file handles */ | |
130 int fax_audio_rx_log; | |
131 int fax_audio_tx_log; | |
132 /*! \brief Error and flow logging control */ | |
133 logging_state_t logging; | |
134 }; | |
135 | |
136 #ifdef __cplusplus | |
137 extern "C" { | |
138 #endif | |
139 | |
140 /*! Apply T.30 receive processing to a block of audio samples. | |
141 \brief Apply T.30 receive processing to a block of audio samples. | |
142 \param s The FAX context. | |
143 \param amp The audio sample buffer. | |
144 \param len The number of samples in the buffer. | |
145 \return The number of samples unprocessed. This should only be non-zero if | |
146 the software has reached the end of the FAX call. | |
147 */ | |
148 int fax_rx(fax_state_t *s, int16_t *amp, int len); | |
149 | |
150 /*! Apply T.30 transmit processing to generate a block of audio samples. | |
151 \brief Apply T.30 transmit processing to generate a block of audio samples. | |
152 \param s The FAX context. | |
153 \param amp The audio sample buffer. | |
154 \param max_len The number of samples to be generated. | |
155 \return The number of samples actually generated. This will be zero when | |
156 there is nothing to send. | |
157 */ | |
158 int fax_tx(fax_state_t *s, int16_t *amp, int max_len); | |
159 | |
160 void fax_set_flush_handler(fax_state_t *s, fax_flush_handler_t *handler, void *user_data); | |
161 | |
162 /*! Select whether silent audio will be sent when FAX transmit is idle. | |
163 \brief Select whether silent audio will be sent when FAX transmit is idle. | |
164 \param s The FAX context. | |
165 \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is | |
166 idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default | |
167 behaviour is FALSE. | |
168 */ | |
169 void fax_set_transmit_on_idle(fax_state_t *s, int transmit_on_idle); | |
170 | |
171 /*! Select whether talker echo protection tone will be sent for the image modems. | |
172 \brief Select whether TEP will be sent for the image modems. | |
173 \param s The FAX context. | |
174 \param use_tep TRUE if TEP should be sent. | |
175 */ | |
176 void fax_set_tep_mode(fax_state_t *s, int use_tep); | |
177 | |
178 /*! Initialise a FAX context. | |
179 \brief Initialise a FAX context. | |
180 \param s The FAX context. | |
181 \param calling_party TRUE if the context is for a calling party. FALSE if the | |
182 context is for an answering party. | |
183 \return 0 for OK, else -1. | |
184 */ | |
185 int fax_init(fax_state_t *s, int calling_party); | |
186 | |
187 /*! Release a FAX context. | |
188 \brief Release a FAX context. | |
189 \param s The FAX context. */ | |
190 int fax_release(fax_state_t *s); | |
191 | |
192 #ifdef __cplusplus | |
193 } | |
194 #endif | |
195 | |
196 #endif | |
197 /*- End of file ------------------------------------------------------------*/ |