1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * t30_api.h - definitions for T.30 fax processing
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2003 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: t30_api.h,v 1.5 2008/06/18 13:28:42 steveu Exp $
26  */
27 
28 /*! \file */
29 
30 #if !defined(_SPANDSP_T30_API_H_)
31 #define _SPANDSP_T30_API_H_
32 
33 #if defined(__cplusplus)
34 extern "C"
35 {
36 #endif
37 
38 /*! Set the transmitted NSF frame to be associated with a T.30 context.
39     \brief Set the transmitted NSF frame to be associated with a T.30 context.
40     \param s The T.30 context.
41     \param nsf A pointer to the frame.
42     \param len The length of the frame.
43     \return 0 for OK, else -1. */
44 int t30_set_tx_nsf(t30_state_t *s, const uint8_t *nsf, int len);
45 
46 /*! Get an NSF frame to be associated with a T.30 context.
47     \brief Set an NSF frame to be associated with a T.30 context.
48     \param s The T.30 context.
49     \param nsf A pointer to the frame.
50     \return the length of the NSF message. */
51 size_t t30_get_tx_nsf(t30_state_t *s, const uint8_t *nsf[]);
52 
53 /*! Get an NSF frame to be associated with a T.30 context.
54     \brief Set an NSF frame to be associated with a T.30 context.
55     \param s The T.30 context.
56     \param nsf A pointer to the frame.
57     \return the length of the NSF message. */
58 size_t t30_get_rx_nsf(t30_state_t *s, const uint8_t *nsf[]);
59 
60 /*! Set the transmitted NSC frame to be associated with a T.30 context.
61     \brief Set the transmitted NSC frame to be associated with a T.30 context.
62     \param s The T.30 context.
63     \param nsf A pointer to the frame.
64     \param len The length of the frame.
65     \return 0 for OK, else -1. */
66 int t30_set_tx_nsc(t30_state_t *s, const uint8_t *nsc, int len);
67 
68 /*! Get an NSC frame to be associated with a T.30 context.
69     \brief Set an NSC frame to be associated with a T.30 context.
70     \param s The T.30 context.
71     \param nsc A pointer to the frame.
72     \return the length of the NSC message. */
73 size_t t30_get_tx_nsc(t30_state_t *s, const uint8_t *nsc[]);
74 
75 /*! Get an NSC frame to be associated with a T.30 context.
76     \brief Set an NSC frame to be associated with a T.30 context.
77     \param s The T.30 context.
78     \param nsc A pointer to the frame.
79     \return the length of the NSC message. */
80 size_t t30_get_rx_nsc(t30_state_t *s, const uint8_t *nsc[]);
81 
82 /*! Set the transmitted NSS frame to be associated with a T.30 context.
83     \brief Set the transmitted NSS frame to be associated with a T.30 context.
84     \param s The T.30 context.
85     \param nsf A pointer to the frame.
86     \param len The length of the frame.
87     \return 0 for OK, else -1. */
88 int t30_set_tx_nss(t30_state_t *s, const uint8_t *nss, int len);
89 
90 /*! Get an NSS frame to be associated with a T.30 context.
91     \brief Set an NSS frame to be associated with a T.30 context.
92     \param s The T.30 context.
93     \param nss A pointer to the frame.
94     \return the length of the NSS message. */
95 size_t t30_get_tx_nss(t30_state_t *s, const uint8_t *nss[]);
96 
97 /*! Get an NSS frame to be associated with a T.30 context.
98     \brief Set an NSS frame to be associated with a T.30 context.
99     \param s The T.30 context.
100     \param nss A pointer to the frame.
101     \return the length of the NSS message. */
102 size_t t30_get_rx_nss(t30_state_t *s, const uint8_t *nss[]);
103 
104 /*! Set the transmitted identifier associated with a T.30 context.
105     \brief Set the transmitted identifier associated with a T.30 context.
106     \param s The T.30 context.
107     \param id A pointer to the identifier.
108     \return 0 for OK, else -1. */
109 int t30_set_tx_ident(t30_state_t *s, const char *id);
110 
111 /*! Get the transmitted identifier associated with a T.30 context.
112     \brief Set the transmitted identifier associated with a T.30 context.
113     \param s The T.30 context.
114     \param id A pointer to the identifier.
115     \return 0 for OK, else -1. */
116 const char *t30_get_tx_ident(t30_state_t *s);
117 
118 /*! Get the transmitted identifier associated with a T.30 context.
119     \brief Set the transmitted identifier associated with a T.30 context.
120     \param s The T.30 context.
121     \param id A pointer to the identifier.
122     \return 0 for OK, else -1. */
123 const char *t30_get_rx_ident(t30_state_t *s);
124 
125 /*! Set the transmitted sub-address associated with a T.30 context.
126     \brief Set the transmitted sub-address associated with a T.30 context.
127     \param s The T.30 context.
128     \param sub_address A pointer to the sub-address.
129     \return 0 for OK, else -1. */
130 int t30_set_tx_sub_address(t30_state_t *s, const char *sub_address);
131 
132 /*! Get the received sub-address associated with a T.30 context.
133     \brief Get the received sub-address associated with a T.30 context.
134     \param s The T.30 context.
135     \param sub_address A pointer to the sub-address.
136     \return 0 for OK, else -1. */
137 const char *t30_get_tx_sub_address(t30_state_t *s);
138 
139 /*! Get the received sub-address associated with a T.30 context.
140     \brief Get the received sub-address associated with a T.30 context.
141     \param s The T.30 context.
142     \param sub_address A pointer to the sub-address.
143     \return 0 for OK, else -1. */
144 const char *t30_get_rx_sub_address(t30_state_t *s);
145 
146 /*! Set the transmitted selective polling address (i.e. the one we will send to the far
147     end) associated with a T.30 context.
148     \brief Set the transmitted selective polling address associated with a T.30 context.
149     \param s The T.30 context.
150     \param selective_polling_address A pointer to the selective polling address.
151     \return 0 for OK, else -1. */
152 int t30_set_tx_selective_polling_address(t30_state_t *s, const char *selective_polling_address);
153 
154 /*! Get the received selective polling address (i.e. the one we will send to the far
155     end) associated with a T.30 context.
156     \brief Get the received selective polling address associated with a T.30 context.
157     \param s The T.30 context.
158     \param selective_polling_address A pointer to the selective polling address.
159     \return 0 for OK, else -1. */
160 const char *t30_get_tx_selective_polling_address(t30_state_t *s);
161 
162 /*! Get the received selective polling address (i.e. the one we will send to the far
163     end) associated with a T.30 context.
164     \brief Get the received selective polling address associated with a T.30 context.
165     \param s The T.30 context.
166     \param selective_polling_address A pointer to the selective polling address.
167     \return 0 for OK, else -1. */
168 const char *t30_get_rx_selective_polling_address(t30_state_t *s);
169 
170 /*! Set the transmitted polled sub-address (i.e. the one we will send to the far
171     end) associated with a T.30 context.
172     \brief Set the transmitted polled sub-address associated with a T.30 context.
173     \param s The T.30 context.
174     \param polled_sub_address A pointer to the polled sub-address.
175     \return 0 for OK, else -1. */
176 int t30_set_tx_polled_sub_address(t30_state_t *s, const char *polled_sub_address);
177 
178 /*! Get the received polled sub-address (i.e. the one we will send to the far
179     end) associated with a T.30 context.
180     \brief Get the received polled sub-address associated with a T.30 context.
181     \param s The T.30 context.
182     \param polled_sub_address A pointer to the polled sub-address.
183     \return 0 for OK, else -1. */
184 const char *t30_get_tx_polled_sub_address(t30_state_t *s);
185 
186 /*! Get the received polled sub-address (i.e. the one we will send to the far
187     end) associated with a T.30 context.
188     \brief Get the received polled sub-address associated with a T.30 context.
189     \param s The T.30 context.
190     \param polled_sub_address A pointer to the polled sub-address.
191     \return 0 for OK, else -1. */
192 const char *t30_get_rx_polled_sub_address(t30_state_t *s);
193 
194 /*! Set the transmitted sender ident (i.e. the one we will send to the far
195     end) associated with a T.30 context.
196     \brief Set the transmitted sender ident associated with a T.30 context.
197     \param s The T.30 context.
198     \param sender_ident A pointer to the sender ident.
199     \return 0 for OK, else -1. */
200 int t30_set_tx_sender_ident(t30_state_t *s, const char *sender_ident);
201 
202 /*! Get the received sender ident (i.e. the one we will send to the far
203     end) associated with a T.30 context.
204     \brief Get the received sender ident associated with a T.30 context.
205     \param s The T.30 context.
206     \param sender_ident A pointer to the sender ident.
207     \return 0 for OK, else -1. */
208 const char *t30_get_tx_sender_ident(t30_state_t *s);
209 
210 /*! Get the received sender ident (i.e. the one we will send to the far
211     end) associated with a T.30 context.
212     \brief Get the received sender ident associated with a T.30 context.
213     \param s The T.30 context.
214     \param sender_ident A pointer to the sender ident.
215     \return 0 for OK, else -1. */
216 const char *t30_get_rx_sender_ident(t30_state_t *s);
217 
218 /*! Set the transmitted password (i.e. the one we will send to the far
219     end) associated with a T.30 context.
220     \brief Set the transmitted password associated with a T.30 context.
221     \param s The T.30 context.
222     \param password A pointer to the password.
223     \return 0 for OK, else -1. */
224 int t30_set_tx_password(t30_state_t *s, const char *password);
225 
226 /*! Get the received password (i.e. the one we will send to the far
227     end) associated with a T.30 context.
228     \brief Get the received password associated with a T.30 context.
229     \param s The T.30 context.
230     \param password A pointer to the password.
231     \return 0 for OK, else -1. */
232 const char *t30_get_tx_password(t30_state_t *s);
233 
234 /*! Get the received password (i.e. the one we will send to the far
235     end) associated with a T.30 context.
236     \brief Get the received password associated with a T.30 context.
237     \param s The T.30 context.
238     \param password A pointer to the password.
239     \return 0 for OK, else -1. */
240 const char *t30_get_rx_password(t30_state_t *s);
241 
242 /*! Set the transmitted ??? (i.e. the one we will send to the far
243     end) associated with a T.30 context.
244     \brief Set the transmitted ??? associated with a T.30 context.
245     \param s The T.30 context.
246     \param type The type of address.
247     \param type A pointer to the address.
248     \param len The length of the address.
249     \return 0 for OK, else -1. */
250 int t30_set_tx_tsa(t30_state_t *s, int type, const char *address, int len);
251 
252 /*! Get the received ??? (i.e. the one we will send to the far
253     end) associated with a T.30 context.
254     \brief Get the received ??? associated with a T.30 context.
255     \param s The T.30 context.
256     \param type The type of address.
257     \param type A pointer to the address.
258     \param len The length of the address.
259     \return 0 for OK, else -1. */
260 size_t t30_get_tx_tsa(t30_state_t *s, int *type, const char *address[]);
261 
262 /*! Get the received ??? (i.e. the one we will send to the far
263     end) associated with a T.30 context.
264     \brief Get the received ??? associated with a T.30 context.
265     \param s The T.30 context.
266     \param type The type of address.
267     \param type A pointer to the address.
268     \param len The length of the address.
269     \return 0 for OK, else -1. */
270 size_t t30_get_rx_tsa(t30_state_t *s, int *type, const char *address[]);
271 
272 /*! Set the transmitted ??? (i.e. the one we will send to the far
273     end) associated with a T.30 context.
274     \brief Set the transmitted ??? associated with a T.30 context.
275     \param s The T.30 context.
276     \param type The type of address.
277     \param type A pointer to the address.
278     \param len The length of the address.
279     \return 0 for OK, else -1. */
280 int t30_set_tx_ira(t30_state_t *s, int type, const char *address, int len);
281 
282 /*! Get the received ??? (i.e. the one we will send to the far
283     end) associated with a T.30 context.
284     \brief Get the received ??? associated with a T.30 context.
285     \param s The T.30 context.
286     \param type The type of address.
287     \param type A pointer to the address.
288     \param len The length of the address.
289     \return 0 for OK, else -1. */
290 size_t t30_get_tx_ira(t30_state_t *s, int *type, const char *address[]);
291 
292 /*! Get the received ??? (i.e. the one we will send to the far
293     end) associated with a T.30 context.
294     \brief Get the received ??? associated with a T.30 context.
295     \param s The T.30 context.
296     \param type The type of address.
297     \param type A pointer to the address.
298     \param len The length of the address.
299     \return 0 for OK, else -1. */
300 size_t t30_get_rx_ira(t30_state_t *s, int *type, const char *address[]);
301 
302 /*! Set the transmitted ??? (i.e. the one we will send to the far
303     end) associated with a T.30 context.
304     \brief Set the transmitted ??? associated with a T.30 context.
305     \param s The T.30 context.
306     \param type The type of address.
307     \param type A pointer to the address.
308     \param len The length of the address.
309     \return 0 for OK, else -1. */
310 int t30_set_tx_cia(t30_state_t *s, int type, const char *address, int len);
311 
312 /*! Get the received ??? (i.e. the one we will send to the far
313     end) associated with a T.30 context.
314     \brief Get the received ??? associated with a T.30 context.
315     \param s The T.30 context.
316     \param type The type of address.
317     \param type A pointer to the address.
318     \param len The length of the address.
319     \return 0 for OK, else -1. */
320 size_t t30_get_tx_cia(t30_state_t *s, int *type, const char *address[]);
321 
322 /*! Get the received ??? (i.e. the one we will send to the far
323     end) associated with a T.30 context.
324     \brief Get the received ??? associated with a T.30 context.
325     \param s The T.30 context.
326     \param type The type of address.
327     \param type A pointer to the address.
328     \param len The length of the address.
329     \return 0 for OK, else -1. */
330 size_t t30_get_rx_cia(t30_state_t *s, int *type, const char *address[]);
331 
332 /*! Set the transmitted ??? (i.e. the one we will send to the far
333     end) associated with a T.30 context.
334     \brief Set the transmitted ??? associated with a T.30 context.
335     \param s The T.30 context.
336     \param type The type of address.
337     \param type A pointer to the address.
338     \param len The length of the address.
339     \return 0 for OK, else -1. */
340 int t30_set_tx_isp(t30_state_t *s, int type, const char *address, int len);
341 
342 /*! Get the received ??? (i.e. the one we will send to the far
343     end) associated with a T.30 context.
344     \brief Get the received ??? associated with a T.30 context.
345     \param s The T.30 context.
346     \param type The type of address.
347     \param type A pointer to the address.
348     \return 0 for OK, else -1. */
349 size_t t30_get_tx_isp(t30_state_t *s, int *type, const char *address[]);
350 
351 /*! Get the received ??? (i.e. the one we will send to the far
352     end) associated with a T.30 context.
353     \brief Get the received ??? associated with a T.30 context.
354     \param s The T.30 context.
355     \param type The type of address.
356     \param type A pointer to the address.
357     \return 0 for OK, else -1. */
358 size_t t30_get_rx_isp(t30_state_t *s, int *type, const char *address[]);
359 
360 /*! Set the transmitted ??? (i.e. the one we will send to the far
361     end) associated with a T.30 context.
362     \brief Set the transmitted ??? associated with a T.30 context.
363     \param s The T.30 context.
364     \param type The type of address.
365     \param type A pointer to the address.
366     \param len The length of the address.
367     \return 0 for OK, else -1. */
368 int t30_set_tx_csa(t30_state_t *s, int type, const char *address, int len);
369 
370 /*! Get the received ??? (i.e. the one we will send to the far
371     end) associated with a T.30 context.
372     \brief Get the received ??? associated with a T.30 context.
373     \param s The T.30 context.
374     \param type The type of address.
375     \param type A pointer to the address.
376     \param len The length of the address.
377     \return 0 for OK, else -1. */
378 size_t t30_get_tx_csa(t30_state_t *s, int *type, const char *address[]);
379 
380 /*! Get the received ??? (i.e. the one we will send to the far
381     end) associated with a T.30 context.
382     \brief Get the received ??? associated with a T.30 context.
383     \param s The T.30 context.
384     \param type The type of address.
385     \param type A pointer to the address.
386     \param len The length of the address.
387     \return 0 for OK, else -1. */
388 size_t t30_get_rx_csa(t30_state_t *s, int *type, const char *address[]);
389 
390 /*! Set the transmitted header information associated with a T.30 context.
391     \brief Set the transmitted header information associated with a T.30 context.
392     \param s The T.30 context.
393     \param info A pointer to the information string.
394     \return 0 for OK, else -1. */
395 int t30_set_tx_page_header_info(t30_state_t *s, const char *info);
396 
397 /*! Get the header information associated with a T.30 context.
398     \brief Get the header information associated with a T.30 context.
399     \param s The T.30 context.
400     \param info A pointer to a buffer for the header information.  The buffer
401            should be at least 51 bytes long.
402     \return the length of the string. */
403 size_t t30_get_tx_page_header_info(t30_state_t *s, char *info);
404 
405 /*! Get the country of origin of the remote FAX machine associated with a T.30 context.
406     \brief Get the country of origin of the remote FAX machine associated with a T.30 context.
407     \param s The T.30 context.
408     \return a pointer to the country name, or NULL if the country is not known. */
409 const char *t30_get_rx_country(t30_state_t *s);
410 
411 /*! Get the name of the vendor of the remote FAX machine associated with a T.30 context.
412     \brief Get the name of the vendor of the remote FAX machine associated with a T.30 context.
413     \param s The T.30 context.
414     \return a pointer to the vendor name, or NULL if the vendor is not known. */
415 const char *t30_get_rx_vendor(t30_state_t *s);
416 
417 /*! Get the name of the model of the remote FAX machine associated with a T.30 context.
418     \brief Get the name of the model of the remote FAX machine associated with a T.30 context.
419     \param s The T.30 context.
420     \return a pointer to the model name, or NULL if the model is not known. */
421 const char *t30_get_rx_model(t30_state_t *s);
422 
423 /*! Specify the file name of the next TIFF file to be received by a T.30
424     context.
425     \brief Set next receive file name.
426     \param s The T.30 context.
427     \param file The file name
428     \param stop_page The maximum page to receive. -1 for no restriction. */
429 void t30_set_rx_file(t30_state_t *s, const char *file, int stop_page);
430 
431 /*! Specify the file name of the next TIFF file to be transmitted by a T.30
432     context.
433     \brief Set next transmit file name.
434     \param s The T.30 context.
435     \param file The file name
436     \param start_page The first page to send. -1 for no restriction.
437     \param stop_page The last page to send. -1 for no restriction. */
438 void t30_set_tx_file(t30_state_t *s, const char *file, int start_page, int stop_page);
439 
440 /*! Set Internet aware FAX (IAF) mode.
441     \brief Set Internet aware FAX (IAF) mode.
442     \param s The T.30 context.
443     \param iaf TRUE for IAF, or FALSE for non-IAF. */
444 void t30_set_iaf_mode(t30_state_t *s, int iaf);
445 
446 /*! Specify if error correction mode (ECM) is allowed by a T.30 context.
447     \brief Select ECM capability.
448     \param s The T.30 context.
449     \param enabled TRUE for ECM capable, FALSE for not ECM capable.
450     \return 0 if OK, else -1. */
451 int t30_set_ecm_capability(t30_state_t *s, int enabled);
452 
453 /*! Specify the output encoding for TIFF files created during FAX reception.
454     \brief Specify the output encoding for TIFF files created during FAX reception.
455     \param s The T.30 context.
456     \param encoding The coding required. The options are T4_COMPRESSION_ITU_T4_1D,
457            T4_COMPRESSION_ITU_T4_2D, T4_COMPRESSION_ITU_T6. T6 is usually the
458            densest option, but support for it is broken in a number of software
459            packages.
460     \return 0 if OK, else -1. */
461 int t30_set_rx_encoding(t30_state_t *s, int encoding);
462 
463 /*! Specify which modem types are supported by a T.30 context.
464     \brief Specify supported modems.
465     \param s The T.30 context.
466     \param supported_modems Bit field list of the supported modems.
467     \return 0 if OK, else -1. */
468 int t30_set_supported_modems(t30_state_t *s, int supported_modems);
469 
470 /*! Specify which compression types are supported by a T.30 context.
471     \brief Specify supported compression types.
472     \param s The T.30 context.
473     \param supported_compressions Bit field list of the supported compression types.
474     \return 0 if OK, else -1. */
475 int t30_set_supported_compressions(t30_state_t *s, int supported_compressions);
476 
477 /*! Specify which resolutions are supported by a T.30 context.
478     \brief Specify supported resolutions.
479     \param s The T.30 context.
480     \param supported_resolutions Bit field list of the supported resolutions.
481     \return 0 if OK, else -1. */
482 int t30_set_supported_resolutions(t30_state_t *s, int supported_resolutions);
483 
484 /*! Specify which images sizes are supported by a T.30 context.
485     \brief Specify supported image sizes.
486     \param s The T.30 context.
487     \param supported_image_sizes Bit field list of the supported widths and lengths.
488     \return 0 if OK, else -1. */
489 int t30_set_supported_image_sizes(t30_state_t *s, int supported_image_sizes);
490 
491 /*! Specify which special T.30 features are supported by a T.30 context.
492     \brief Specify supported T.30 features.
493     \param s The T.30 context.
494     \param supported_t30_features Bit field list of the supported features.
495     \return 0 if OK, else -1. */
496 int t30_set_supported_t30_features(t30_state_t *s, int supported_t30_features);
497 
498 /*! Set T.30 status. This may be used to adjust the status from within
499     the phase B and phase D callbacks.
500     \brief Set T.30 status.
501     \param s The T.30 context.
502     \param status The new status. */
503 void t30_set_status(t30_state_t *s, int status);
504 
505 /*! Specify a period of responding with receiver not ready.
506     \brief Specify a period of responding with receiver not ready.
507     \param s The T.30 context.
508     \param count The number of times to report receiver not ready.
509     \return 0 if OK, else -1. */
510 int t30_set_receiver_not_ready(t30_state_t *s, int count);
511 
512 /*! Set a callback function for T.30 phase B handling.
513     \brief Set a callback function for T.30 phase B handling.
514     \param s The T.30 context.
515     \param handler The callback function.
516     \param user_data An opaque pointer passed to the callback function. */
517 void t30_set_phase_b_handler(t30_state_t *s, t30_phase_b_handler_t *handler, void *user_data);
518 
519 /*! Set a callback function for T.30 phase D handling.
520     \brief Set a callback function for T.30 phase D handling.
521     \param s The T.30 context.
522     \param handler The callback function.
523     \param user_data An opaque pointer passed to the callback function. */
524 void t30_set_phase_d_handler(t30_state_t *s, t30_phase_d_handler_t *handler, void *user_data);
525 
526 /*! Set a callback function for T.30 phase E handling.
527     \brief Set a callback function for T.30 phase E handling.
528     \param s The T.30 context.
529     \param handler The callback function.
530     \param user_data An opaque pointer passed to the callback function. */
531 void t30_set_phase_e_handler(t30_state_t *s, t30_phase_e_handler_t *handler, void *user_data);
532 
533 /*! Set a callback function for T.30 end of document handling.
534     \brief Set a callback function for T.30 end of document handling.
535     \param s The T.30 context.
536     \param handler The callback function.
537     \param user_data An opaque pointer passed to the callback function. */
538 void t30_set_document_handler(t30_state_t *s, t30_document_handler_t *handler, void *user_data);
539 
540 /*! Set a callback function for T.30 frame exchange monitoring. This is called from the heart
541     of the signal processing, so don't take too long in the handler routine.
542     \brief Set a callback function for T.30 frame exchange monitoring.
543     \param s The T.30 context.
544     \param handler The callback function.
545     \param user_data An opaque pointer passed to the callback function. */
546 void t30_set_real_time_frame_handler(t30_state_t *s, t30_real_time_frame_handler_t *handler, void *user_data);
547 
548 #if defined(__cplusplus)
549 }
550 #endif
551 
552 #endif
553 /*- End of file ------------------------------------------------------------*/
554