spandsp 3.0.0
t30.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * t30.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
26/*! \file */
27
28#if !defined(_SPANDSP_T30_H_)
29#define _SPANDSP_T30_H_
30
31/*! \page t30_page T.30 FAX protocol handling
32
33\section t30_page_sec_1 What does it do?
34The T.30 protocol is the core protocol used for FAX transmission. This module
35implements most of its key features. It does not interface to the outside world.
36Seperate modules do that for T.38, analogue line, and other forms of FAX
37communication.
38
39Current features of this module include:
40
41 - FAXing to and from multi-page TIFF/F files, whose images are one of the standard
42 FAX sizes.
43 - V.27ter, V.29 and V.17 modes (2400bps, to 14,400bps).
44 - T.4 1D (MH), T.4 2D,(MR) and T.6 (MMR) compression.
45 - Error correction mode (ECM).
46 - All standard horizonal resolutions (R8, R16, 300dpi, 600dpi, 800dpi, 1200dpi).
47 - All standard vertical resolutions (standard, fine, superfine, 300dpi, 600dpi, 800dpi, 1200dpi).
48 - All standard page widths (A4, B4, A3).
49 - All standard page lengths (A4, B4, North American letter, North American legal, continuous).
50 - Monitoring and sending identifier strings (CSI, TSI, and CIG).
51 - Monitoring and sending sub-address strings (SUB).
52 - Monitoring and sending polling sub-addresses (SEP).
53 - Monitoring and sending polled sub-addresses (PSA).
54 - Monitoring and sending sender identifications (SID).
55 - Monitoring and sending passwords (PWD).
56 - Monitoring of non-standard facility frames (NSF, NSC, and NSS).
57 - Sending custom non-standard facility frames (NSF, NSC, and NSS).
58 - Analogue modem and T.38 operation.
59
60\section t30_page_sec_2 How does it work?
61
62Some of the following is paraphrased from some notes found a while ago on the Internet.
63I cannot remember exactly where they came from, but they are useful.
64
65\subsection t30_page_sec_2a The answer (CED) tone
66
67The T.30 standard says an answering fax device must send CED (a 2100Hz tone) for
68approximately 3 seconds before sending the first handshake message. Some machines
69send an 1100Hz or 1850Hz tone, and some send no tone at all. In fact, this answer
70tone is so unpredictable, it cannot really be used. It should, however, always be
71generated according to the specification.
72
73\subsection t30_page_sec_2b Common Timing Deviations
74
75The T.30 spec. specifies a number of time-outs. For example, after dialing a number,
76a calling fax system should listen for a response for 35 seconds before giving up.
77These time-out periods are as follows:
78
79 - T1 - 35+-5s: the maximum time for which two fax system will attempt to identify each other
80 - T2 - 6+-1s: a time-out used to start the sequence for changing transmit parameters
81 - T3 - 10+-5s: a time-out used in handling operator interrupts
82 - T5 - 60+-5s: a time-out used in error correction mode
83
84These time-outs are sometimes misinterpreted. In addition, they are routinely
85ignored, sometimes with good reason. For example, after placing a call, the
86calling fax system is supposed to wait for 35 seconds before giving up. If the
87answering unit does not answer on the first ring or if a voice answering machine
88is connected to the line, or if there are many delays through the network,
89the delay before answer can be much longer than 35 seconds.
90
91Fax units that support error correction mode (ECM) can respond to a post-image
92handshake message with a receiver not ready (RNR) message. The calling unit then
93queries the receiving fax unit with a receiver ready (RR) message. If the
94answering unit is still busy (printing for example), it will repeat the RNR
95message. According to the T.30 standard, this sequence (RR/RNR RR/RNR) can be
96repeated for up to the end of T5 (60+-5s). However, many fax systems
97ignore the time-out and will continue the sequence indefinitely, unless the user
98manually overrides.
99
100All the time-outs are subject to alteration, and sometimes misuse. Good T.30
101implementations must do the right thing, and tolerate others doing the wrong thing.
102
103\subsection t30_page_sec_2c Variations in the inter-carrier gap
104
105T.30 specifies 75+-20ms of silence between signals using different modulation
106schemes. Examples are between the end of a DCS signal and the start of a TCF signal,
107and between the end of an image and the start of a post-image signal. Many fax systems
108violate this requirement, especially for the silent period between DCS and TCF.
109This may be stretched to well over 100ms. If this period is too long, it can interfere with
110handshake signal error recovery, should a packet be corrupted on the line. Systems
111should ensure they stay within the prescribed T.30 limits, and be tolerant of others
112being out of spec..
113
114\subsection t30_page_sec_2d Other timing variations
115
116Testing is required to determine the ability of a fax system to handle
117variations in the duration of pauses between unacknowledged handshake message
118repetitions, and also in the pauses between the receipt of a handshake command and
119the start of a response to that command. In order to reduce the total
120transmission time, many fax systems start sending a response message before the
121end of the command has been received.
122
123\subsection t30_page_sec_2e Other deviations from the T.30 standard
124
125There are many other commonly encountered variations between machines, including:
126
127 - frame sequence deviations
128 - preamble and flag sequence variations
129 - improper EOM usage
130 - unusual data rate fallback sequences
131 - common training pattern detection algorithms
132 - image transmission deviations
133 - use of the talker echo protect tone
134 - image padding and short lines
135 - RTP/RTN handshake message usage
136 - long duration lines
137 - nonstandard disconnect sequences
138 - DCN usage
139*/
140
141/*! The maximum length of a DIS, DTC or DCS frame */
142#define T30_MAX_DIS_DTC_DCS_LEN 22
143/*! The maximum length of the body of an ident string */
144#define T30_MAX_IDENT_LEN 20
145/*! The maximum length of the user string to insert in page headers */
146#define T30_MAX_PAGE_HEADER_INFO 50
147
148typedef struct t30_state_s t30_state_t;
149
150/*!
151 T.30 phase B callback handler. This handler can be used to process addition
152 information available in some FAX calls, such as passwords. The callback handler
153 can access whatever additional information might have been received, using
154 t30_get_received_info().
155 \brief T.30 phase B callback handler.
156 \param user_data An opaque pointer.
157 \param result The phase B event code.
158 \return The new status. Normally, T30_ERR_OK is returned.
159*/
160typedef int (*t30_phase_b_handler_t)(void *user_data, int result);
161
162/*!
163 T.30 phase D callback handler.
164 \brief T.30 phase D callback handler.
165 \param user_data An opaque pointer.
166 \param result The phase D event code.
167 \return The new status. Normally, T30_ERR_OK is returned.
168*/
169typedef int (*t30_phase_d_handler_t)(void *user_data, int result);
170
171/*!
172 T.30 phase E callback handler.
173 \brief T.30 phase E callback handler.
174 \param user_data An opaque pointer.
175 \param completion_code The phase E completion code.
176*/
177typedef void (*t30_phase_e_handler_t)(void *user_data, int completion_code);
178
179/*!
180 T.30 real time frame handler.
181 \brief T.30 real time frame handler.
182 \param user_data An opaque pointer.
183 \param incoming True for incoming, false for outgoing.
184 \param msg The HDLC message.
185 \param len The length of the message.
186*/
187typedef void (*t30_real_time_frame_handler_t)(void *user_data,
188 bool direction,
189 const uint8_t msg[],
190 int len);
191
192/*!
193 T.30 document handler.
194 \brief T.30 document handler.
195 \param user_data An opaque pointer.
196 \param result The document event code.
197*/
198typedef int (*t30_document_handler_t)(void *user_data, int status);
199
200/*!
201 T.30 set a receive or transmit type handler.
202 \brief T.30 set a receive or transmit type handler.
203 \param user_data An opaque pointer.
204 \param type The modem, tone or silence to be sent or received.
205 \param bit_rate The bit rate of the modem to be sent or received.
206 \param short_train True if the short training sequence should be used (where one exists).
207 \param use_hdlc False for bit stream, true for HDLC framing.
208*/
209typedef void (*t30_set_handler_t)(void *user_data, int type, int bit_rate, int short_train, int use_hdlc);
210
211/*!
212 T.30 send HDLC handler.
213 \brief T.30 send HDLC handler.
214 \param user_data An opaque pointer.
215 \param msg The HDLC message.
216 \param len The length of the message. -1 to flush the HDLC queue.
217*/
218typedef void (*t30_send_hdlc_handler_t)(void *user_data, const uint8_t msg[], int len);
219
220/*!
221 T.30 send document handler.
222 \brief T.30 send document handler.
223 \param user_data An opaque pointer.
224 \param msg The document chunk.
225 \param len The length of the chunk.
226 \return The actual length of the chunk.
227*/
228typedef int (*t30_document_get_handler_t)(void *user_data, uint8_t msg[], int len);
229
230/*!
231 T.30 deliver document handler.
232 \brief T.30 deliver handler.
233 \param user_data An opaque pointer.
234 \param msg The document chunk.
235 \param len The length of the chunk.
236 \return The delivery status.
237*/
238typedef int (*t30_document_put_handler_t)(void *user_data, const uint8_t msg[], int len);
239
240/*!
241 T.30 protocol completion codes, at phase E.
242*/
243enum
244{
245 T30_ERR_OK = 0, /*! OK */
246
247 /* Link problems */
248 T30_ERR_CEDTONE, /*! The CED tone exceeded 5s */
249 T30_ERR_T0_EXPIRED, /*! Timed out waiting for initial communication */
250 T30_ERR_T1_EXPIRED, /*! Timed out waiting for the first message */
251 T30_ERR_T3_EXPIRED, /*! Timed out waiting for procedural interrupt */
252 T30_ERR_HDLC_CARRIER, /*! The HDLC carrier did not stop in a timely manner */
253 T30_ERR_CANNOT_TRAIN, /*! Failed to train with any of the compatible modems */
254 T30_ERR_OPER_INT_FAIL, /*! Operator intervention failed */
255 T30_ERR_INCOMPATIBLE, /*! Far end is not compatible */
256 T30_ERR_RX_INCAPABLE, /*! Far end is not able to receive */
257 T30_ERR_TX_INCAPABLE, /*! Far end is not able to transmit */
258 T30_ERR_NORESSUPPORT, /*! Far end cannot receive at the resolution of the image */
259 T30_ERR_NOSIZESUPPORT, /*! Far end cannot receive at the size of image */
260 T30_ERR_UNEXPECTED, /*! Unexpected message received */
261
262 /* Phase E status values returned to a transmitter */
263 T30_ERR_TX_BADDCS, /*! Received bad response to DCS or training */
264 T30_ERR_TX_BADPG, /*! Received a DCN from remote after sending a page */
265 T30_ERR_TX_ECMPHD, /*! Invalid ECM response received from receiver */
266 T30_ERR_TX_GOTDCN, /*! Received a DCN while waiting for a DIS */
267 T30_ERR_TX_INVALRSP, /*! Invalid response after sending a page */
268 T30_ERR_TX_NODIS, /*! Received other than DIS while waiting for DIS */
269 T30_ERR_TX_PHBDEAD, /*! Received no response to DCS, training or TCF */
270 T30_ERR_TX_PHDDEAD, /*! No response after sending a page */
271 T30_ERR_TX_T5EXP, /*! Timed out waiting for receiver ready (ECM mode) */
272
273 /* Phase E status values returned to a receiver */
274 T30_ERR_RX_ECMPHD, /*! Invalid ECM response received from transmitter */
275 T30_ERR_RX_GOTDCS, /*! DCS received while waiting for DTC */
276 T30_ERR_RX_INVALCMD, /*! Unexpected command after page received */
277 T30_ERR_RX_NOCARRIER, /*! Carrier lost during fax receive */
278 T30_ERR_RX_NOEOL, /*! Timed out while waiting for EOL (end of line) */
279 T30_ERR_RX_NOFAX, /*! Timed out while waiting for first line */
280 T30_ERR_RX_T2EXPDCN, /*! Timer T2 expired while waiting for DCN */
281 T30_ERR_RX_T2EXPD, /*! Timer T2 expired while waiting for phase D */
282 T30_ERR_RX_T2EXPFAX, /*! Timer T2 expired while waiting for fax page */
283 T30_ERR_RX_T2EXPMPS, /*! Timer T2 expired while waiting for next fax page */
284 T30_ERR_RX_T2EXPRR, /*! Timer T2 expired while waiting for RR command */
285 T30_ERR_RX_T2EXP, /*! Timer T2 expired while waiting for NSS, DCS or MCF */
286 T30_ERR_RX_DCNWHY, /*! Unexpected DCN while waiting for DCS or DIS */
287 T30_ERR_RX_DCNDATA, /*! Unexpected DCN while waiting for image data */
288 T30_ERR_RX_DCNFAX, /*! Unexpected DCN while waiting for EOM, EOP or MPS */
289 T30_ERR_RX_DCNPHD, /*! Unexpected DCN after EOM or MPS sequence */
290 T30_ERR_RX_DCNRRD, /*! Unexpected DCN after RR/RNR sequence */
291 T30_ERR_RX_DCNNORTN, /*! Unexpected DCN after requested retransmission */
292
293 /* TIFF file problems */
294 T30_ERR_FILEERROR, /*! TIFF/F file cannot be opened */
295 T30_ERR_NOPAGE, /*! TIFF/F page not found */
296 T30_ERR_BADTIFF, /*! TIFF/F format is not compatible */
297 T30_ERR_BADPAGE, /*! TIFF/F page number tag missing */
298 T30_ERR_BADTAG, /*! Incorrect values for TIFF/F tags */
299 T30_ERR_BADTIFFHDR, /*! Bad TIFF/F header - incorrect values in fields */
300 T30_ERR_NOMEM, /*! Cannot allocate memory for more pages */
301
302 /* General problems */
303 T30_ERR_RETRYDCN, /*! Disconnected after permitted retries */
304 T30_ERR_CALLDROPPED, /*! The call dropped prematurely */
305
306 /* Feature negotiation issues */
307 T30_ERR_NOPOLL, /*! Poll not accepted */
308 T30_ERR_IDENT_UNACCEPTABLE, /*! Far end's ident is not acceptable */
309 T30_ERR_SUB_UNACCEPTABLE, /*! Far end's sub-address is not acceptable */
310 T30_ERR_SEP_UNACCEPTABLE, /*! Far end's selective polling address is not acceptable */
311 T30_ERR_PSA_UNACCEPTABLE, /*! Far end's polled sub-address is not acceptable */
312 T30_ERR_SID_UNACCEPTABLE, /*! Far end's sender identification is not acceptable */
313 T30_ERR_PWD_UNACCEPTABLE, /*! Far end's password is not acceptable */
314 T30_ERR_TSA_UNACCEPTABLE, /*! Far end's transmitting subscriber internet address is not acceptable */
315 T30_ERR_IRA_UNACCEPTABLE, /*! Far end's internet routing address is not acceptable */
316 T30_ERR_CIA_UNACCEPTABLE, /*! Far end's calling subscriber internet address is not acceptable */
317 T30_ERR_ISP_UNACCEPTABLE, /*! Far end's internet selective polling address is not acceptable */
318 T30_ERR_CSA_UNACCEPTABLE /*! Far end's called subscriber internet address is not acceptable */
319};
320
321/*!
322 I/O modes for the T.30 protocol.
323 These are allocated such that the lower 4 bits represents the variant of the modem - e.g. the
324 particular bit rate selected.
325*/
326enum
327{
328 T30_MODEM_NONE = 0,
329 T30_MODEM_PAUSE,
330 T30_MODEM_CED,
331 T30_MODEM_CNG,
332 T30_MODEM_V21,
333 T30_MODEM_V27TER,
334 T30_MODEM_V29,
335 T30_MODEM_V17,
336 T30_MODEM_V34HDX,
337 T30_MODEM_DONE
338};
339
340enum
341{
342 /*! Support the V.27ter modem (2400, and 4800bps) for image transfer. */
344 /*! Support the V.29 modem (9600, and 7200bps) for image transfer. */
346 /*! Support the V.17 modem (14400, 12000, 9600 and 7200bps) for image transfer. */
348 /*! Support the V.34 modem (up to 33,600bps) for image transfer. */
350 /*! Support the Internet aware FAX mode (no bit rate limit) for image transfer. */
352};
353
354enum
355{
356 T30_FRONT_END_SEND_STEP_COMPLETE = 0,
357 /*! The current receive has completed. This is only needed to report an
358 unexpected end of the receive operation, as might happen with T.38
359 dying. */
361 T30_FRONT_END_SIGNAL_PRESENT,
362 T30_FRONT_END_SIGNAL_ABSENT,
363 T30_FRONT_END_CED_PRESENT,
364 T30_FRONT_END_CNG_PRESENT
365};
366
367enum
368{
369 /*! Enable support of identification, through the SID and/or PWD frames. */
371 /*! Enable support of selective polling, through the SEP frame. */
373 /*! Enable support of polling sub-addressing, through the PSA frame. */
375 /*! Enable support of multiple selective polling, through repeated used of the SEP and PSA frames. */
377 /*! Enable support of sub-addressing, through the SUB frame. */
379 /*! Enable support of transmitting subscriber internet address, through the TSA frame. */
381 /*! Enable support of internet routing address, through the IRA frame. */
383 /*! Enable support of calling subscriber internet address, through the CIA frame. */
385 /*! Enable support of internet selective polling address, through the ISP frame. */
387 /*! Enable support of called subscriber internet address, through the CSA frame. */
389 /*! Enable support of the field not valid (FNV) frame. */
391 /*! Enable support of the command repeat (CRP) frame. */
393};
394
395enum
396{
397 T30_IAF_MODE_T37 = 0x01,
398 T30_IAF_MODE_T38 = 0x02,
399 T30_IAF_MODE_FLOW_CONTROL = 0x04,
400 /*! Continuous flow mode means data is sent as fast as possible, usually across
401 the Internet, where speed is not constrained by a PSTN modem. */
403 /*! No TCF means TCF is not exchanged. The end points must sort out usable speed
404 issues locally. */
406 /*! No fill bits means do not insert fill bits, even if the T.30 messages request
407 them. */
409 /*! No indicators means do not send indicator messages when using T.38. */
411 /*! Use relaxed timers for T.38. This is appropriate when using TCP/TPKT for T.38,
412 as there is no point in anything but a long backstop timeout in such a mode. */
414};
415
416typedef struct
417{
418 /*! \brief The identifier string (CSI, TSI, CIG). */
420 /*! \brief The sub-address string (SUB). */
422 /*! \brief The selective polling sub-address (SEP). */
424 /*! \brief The polled sub-address (PSA). */
426 /*! \brief The sender identification (SID). */
428 /*! \brief The password (PWD). */
430 /*! \brief Non-standard facilities (NSF). */
431 uint8_t *nsf;
432 size_t nsf_len;
433 /*! \brief Non-standard facilities command (NSC). */
434 uint8_t *nsc;
435 size_t nsc_len;
436 /*! \brief Non-standard facilities set-up (NSS). */
437 uint8_t *nss;
438 size_t nss_len;
439 /*! \brief Transmitting subscriber internet address (TSA). */
441 char *tsa;
442 size_t tsa_len;
443 /*! \brief Internet routing address (IRA). */
445 char *ira;
446 size_t ira_len;
447 /*! \brief Calling subscriber internet address (CIA). */
449 char *cia;
450 size_t cia_len;
451 /*! \brief Internet selective polling address (ISP). */
453 char *isp;
454 size_t isp_len;
455 /*! \brief Called subscriber internet address (CSA). */
457 char *csa;
458 size_t csa_len;
460
461typedef struct
462{
463 /*! \brief The current bit rate for image transfer. */
465 /*! \brief True if error correcting mode is used. */
467 /*! \brief The number of pages sent so far. */
469 /*! \brief The number of pages received so far. */
471 /*! \brief The number of pages in the file (<0 if not known). */
473 /*! \brief The type of image of the most recent file page */
475 /*! \brief The horizontal column-to-column resolution of the most recent file page, in pixels per metre */
477 /*! \brief The vertical row-to-row resolution of the most recent file page, in pixels per metre */
479 /*! \brief The number of horizontal pixels in the most recent file page. */
481 /*! \brief The number of vertical pixels in the most recent file page. */
483 /*! \brief The type of image of the most recent exchanged page */
484 int type;
485 /*! \brief The horizontal column-to-column resolution of the most recent exchanged page, in pixels per metre */
487 /*! \brief The vertical row-to-row resolution of the most recent exchanged page, in pixels per metre */
489 /*! \brief The number of horizontal pixels in the most recent exchanged page. */
490 int width;
491 /*! \brief The number of vertical pixels in the most recent exchanged page. */
493 /*! \brief The size of the image, in bytes */
495 /*! \brief The type of compression used between the FAX machines */
497 /*! \brief The number of bad pixel rows in the most recent page. */
499 /*! \brief The largest number of bad pixel rows in a block in the most recent page. */
501 /*! \brief The number of HDLC frame retries, if error correcting mode is used. */
503 /*! \brief Current status. */
505 /*! \brief The number of RTP events in this call. */
507 /*! \brief The number of RTN events in this call. */
510
511#if defined(__cplusplus)
512extern "C"
513{
514#endif
515
516/*! Initialise a T.30 context.
517 \brief Initialise a T.30 context.
518 \param s The T.30 context.
519 \param calling_party True if the context is for a calling party. False if the
520 context is for an answering party.
521 \param set_rx_type_handler
522 \param set_rx_type_user_data
523 \param set_tx_type_handler
524 \param set_tx_type_user_data
525 \param send_hdlc_handler
526 \param send_hdlc_user_data
527 \return A pointer to the context, or NULL if there was a problem. */
528SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s,
529 bool calling_party,
535 void *send_hdlc_user_data);
536
537/*! Release a T.30 context.
538 \brief Release a T.30 context.
539 \param s The T.30 context.
540 \return 0 for OK, else -1. */
541SPAN_DECLARE(int) t30_release(t30_state_t *s);
542
543/*! Free a T.30 context.
544 \brief Free a T.30 context.
545 \param s The T.30 context.
546 \return 0 for OK, else -1. */
547SPAN_DECLARE(int) t30_free(t30_state_t *s);
548
549/*! Restart a T.30 context.
550 \brief Restart a T.30 context.
551 \param s The T.30 context.
552 \param calling_party True if the context is for a calling party. False if the
553 context is for an answering party.
554 \return 0 for OK, else -1. */
555SPAN_DECLARE(int) t30_restart(t30_state_t *s, bool calling_party);
556
557/*! Check if a T.30 call is still active. This may be used to regularly poll
558 if the job has finished.
559 \brief Check if a T.30 call is still active.
560 \param s The T.30 context.
561 \return True for call still active, or false for call completed. */
562SPAN_DECLARE(int) t30_call_active(t30_state_t *s);
563
564/*! Cleanup a T.30 context if the call terminates.
565 \brief Cleanup a T.30 context if the call terminates.
566 \param s The T.30 context. */
567SPAN_DECLARE(void) t30_terminate(t30_state_t *s);
568
569/*! Inform the T.30 engine of a status change in the front end (end of tx, rx signal change, etc.).
570 \brief Inform the T.30 engine of a status change in the front end (end of tx, rx signal change, etc.).
571 \param user_data The T.30 context.
572 \param status The type of status change which occured. */
573SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status);
574
575/*! Get a bit of received non-ECM image data.
576 \brief Get a bit of received non-ECM image data.
577 \param user_data An opaque pointer, which must point to the T.30 context.
578 \return The next bit to transmit. */
579SPAN_DECLARE(int) t30_non_ecm_get_bit(void *user_data);
580
581/*! Get a chunk of received non-ECM image data.
582 \brief Get a bit of received non-ECM image data.
583 \param user_data An opaque pointer, which must point to the T.30 context.
584 \param buf The buffer to contain the data.
585 \param max_len The maximum length of the chunk.
586 \return The actual length of the chunk. */
587SPAN_DECLARE(int) t30_non_ecm_get(void *user_data, uint8_t buf[], int max_len);
588
589/*! Process a bit of received non-ECM image data.
590 \brief Process a bit of received non-ECM image data
591 \param user_data An opaque pointer, which must point to the T.30 context.
592 \param bit The received bit. */
593SPAN_DECLARE(void) t30_non_ecm_put_bit(void *user_data, int bit);
594
595/*! Process a chunk of received non-ECM image data.
596 \brief Process a chunk of received non-ECM image data
597 \param user_data An opaque pointer, which must point to the T.30 context.
598 \param buf The buffer containing the received data.
599 \param len The length of the data in buf. */
600SPAN_DECLARE(void) t30_non_ecm_put(void *user_data, const uint8_t buf[], int len);
601
602/*! Process a received HDLC frame.
603 \brief Process a received HDLC frame.
604 \param user_data The T.30 context.
605 \param msg The HDLC message.
606 \param len The length of the message, in octets.
607 \param ok True if the frame was received without error. */
608SPAN_DECLARE(void) t30_hdlc_accept(void *user_data, const uint8_t msg[], int len, int ok);
609
610/*! Report the passage of time to the T.30 engine.
611 \brief Report the passage of time to the T.30 engine.
612 \param s The T.30 context.
613 \param samples The time change in 1/8000th second steps. */
614SPAN_DECLARE(void) t30_timer_update(t30_state_t *s, int samples);
615
616/*! Get the current transfer statistics for the file being sent or received.
617 \brief Get the current transfer statistics.
618 \param s The T.30 context.
619 \param t A pointer to a buffer for the statistics. */
620SPAN_DECLARE(void) t30_get_transfer_statistics(t30_state_t *s, t30_stats_t *t);
621
622/*! Request a local interrupt of FAX exchange.
623 \brief Request a local interrupt of FAX exchange.
624 \param s The T.30 context.
625 \param state True to enable interrupt request, else false. */
626SPAN_DECLARE(void) t30_local_interrupt_request(t30_state_t *s, int state);
627
628/*! Allow remote interrupts of FAX exchange.
629 \brief Allow remote interrupts of FAX exchange.
630 \param s The T.30 context.
631 \param state True to allow interruptd, else false. */
632SPAN_DECLARE(void) t30_remote_interrupts_allowed(t30_state_t *s, int state);
633
634#if defined(__cplusplus)
635}
636#endif
637
638#endif
639/*- End of file ------------------------------------------------------------*/
Definition t30.h:417
uint8_t * nsf
Non-standard facilities (NSF).
Definition t30.h:431
int ira_type
Internet routing address (IRA).
Definition t30.h:444
int isp_type
Internet selective polling address (ISP).
Definition t30.h:452
uint8_t * nsc
Non-standard facilities command (NSC).
Definition t30.h:434
int cia_type
Calling subscriber internet address (CIA).
Definition t30.h:448
char polled_sub_address[20+1]
The polled sub-address (PSA).
Definition t30.h:425
char ident[20+1]
The identifier string (CSI, TSI, CIG).
Definition t30.h:419
int tsa_type
Transmitting subscriber internet address (TSA).
Definition t30.h:440
char sub_address[20+1]
The sub-address string (SUB).
Definition t30.h:421
uint8_t * nss
Non-standard facilities set-up (NSS).
Definition t30.h:437
char selective_polling_address[20+1]
The selective polling sub-address (SEP).
Definition t30.h:423
char password[20+1]
The password (PWD).
Definition t30.h:429
int csa_type
Called subscriber internet address (CSA).
Definition t30.h:456
char sender_ident[20+1]
The sender identification (SID).
Definition t30.h:427
Definition private/t30.h:36
t30_set_handler_t set_tx_type_handler
The handler for changes to the transmit mode.
Definition private/t30.h:136
void * set_tx_type_user_data
An opaque pointer passed to the handler for changes to the transmit mode.
Definition private/t30.h:138
bool short_train
True if the short training sequence should be used.
Definition private/t30.h:182
bool calling_party
True if behaving as the calling party.
Definition private/t30.h:47
t30_send_hdlc_handler_t send_hdlc_handler
The transmitted HDLC frame handler.
Definition private/t30.h:141
void * send_hdlc_user_data
An opaque pointer passed to the transmitted HDLC frame handler.
Definition private/t30.h:143
void * set_rx_type_user_data
An opaque pointer passed to the handler for changes to the receive mode.
Definition private/t30.h:134
t30_set_handler_t set_rx_type_handler
The handler for changes to the receive mode.
Definition private/t30.h:132
Definition t30.h:462
int error_correcting_mode_retries
The number of HDLC frame retries, if error correcting mode is used.
Definition t30.h:502
int bit_rate
The current bit rate for image transfer.
Definition t30.h:464
int image_size
The size of the image, in bytes.
Definition t30.h:494
int current_status
Current status.
Definition t30.h:504
int width
The number of horizontal pixels in the most recent exchanged page.
Definition t30.h:490
int image_width
The number of horizontal pixels in the most recent file page.
Definition t30.h:480
int type
The type of image of the most recent exchanged page.
Definition t30.h:484
int image_type
The type of image of the most recent file page.
Definition t30.h:474
int error_correcting_mode
True if error correcting mode is used.
Definition t30.h:466
int longest_bad_row_run
The largest number of bad pixel rows in a block in the most recent page.
Definition t30.h:500
int y_resolution
The vertical row-to-row resolution of the most recent exchanged page, in pixels per metre.
Definition t30.h:488
int length
The number of vertical pixels in the most recent exchanged page.
Definition t30.h:492
int pages_in_file
The number of pages in the file (<0 if not known).
Definition t30.h:472
int rtn_events
The number of RTN events in this call.
Definition t30.h:508
int pages_tx
The number of pages sent so far.
Definition t30.h:468
int image_length
The number of vertical pixels in the most recent file page.
Definition t30.h:482
int image_x_resolution
The horizontal column-to-column resolution of the most recent file page, in pixels per metre.
Definition t30.h:476
int x_resolution
The horizontal column-to-column resolution of the most recent exchanged page, in pixels per metre.
Definition t30.h:486
int bad_rows
The number of bad pixel rows in the most recent page.
Definition t30.h:498
int compression
The type of compression used between the FAX machines.
Definition t30.h:496
int pages_rx
The number of pages received so far.
Definition t30.h:470
int image_y_resolution
The vertical row-to-row resolution of the most recent file page, in pixels per metre.
Definition t30.h:478
int rtp_events
The number of RTP events in this call.
Definition t30.h:506
void t30_remote_interrupts_allowed(t30_state_t *s, int state)
Allow remote interrupts of FAX exchange.
Definition t30.c:7290
void t30_terminate(t30_state_t *s)
Cleanup a T.30 context if the call terminates.
Definition t30.c:7193
@ T30_IAF_MODE_NO_FILL_BITS
Definition t30.h:408
@ T30_IAF_MODE_NO_INDICATORS
Definition t30.h:410
@ T30_IAF_MODE_CONTINUOUS_FLOW
Definition t30.h:402
@ T30_IAF_MODE_RELAXED_TIMERS
Definition t30.h:413
@ T30_IAF_MODE_NO_TCF
Definition t30.h:405
@ T30_ERR_RX_T2EXPDCN
Definition t30.h:280
@ T30_ERR_NOSIZESUPPORT
Definition t30.h:259
@ T30_ERR_TX_PHBDEAD
Definition t30.h:269
@ T30_ERR_IRA_UNACCEPTABLE
Definition t30.h:315
@ T30_ERR_TX_INCAPABLE
Definition t30.h:257
@ T30_ERR_T0_EXPIRED
Definition t30.h:249
@ T30_ERR_RX_NOFAX
Definition t30.h:279
@ T30_ERR_ISP_UNACCEPTABLE
Definition t30.h:317
@ T30_ERR_CSA_UNACCEPTABLE
Definition t30.h:318
@ T30_ERR_CEDTONE
Definition t30.h:248
@ T30_ERR_RX_NOEOL
Definition t30.h:278
@ T30_ERR_NOPOLL
Definition t30.h:307
@ T30_ERR_PWD_UNACCEPTABLE
Definition t30.h:313
@ T30_ERR_RX_DCNNORTN
Definition t30.h:291
@ T30_ERR_SEP_UNACCEPTABLE
Definition t30.h:310
@ T30_ERR_INCOMPATIBLE
Definition t30.h:255
@ T30_ERR_TX_T5EXP
Definition t30.h:271
@ T30_ERR_NOPAGE
Definition t30.h:295
@ T30_ERR_RETRYDCN
Definition t30.h:303
@ T30_ERR_RX_DCNPHD
Definition t30.h:289
@ T30_ERR_BADTIFF
Definition t30.h:296
@ T30_ERR_FILEERROR
Definition t30.h:294
@ T30_ERR_NOMEM
Definition t30.h:300
@ T30_ERR_BADTIFFHDR
Definition t30.h:299
@ T30_ERR_TSA_UNACCEPTABLE
Definition t30.h:314
@ T30_ERR_BADTAG
Definition t30.h:298
@ T30_ERR_RX_DCNFAX
Definition t30.h:288
@ T30_ERR_UNEXPECTED
Definition t30.h:260
@ T30_ERR_SUB_UNACCEPTABLE
Definition t30.h:309
@ T30_ERR_HDLC_CARRIER
Definition t30.h:252
@ T30_ERR_RX_T2EXPD
Definition t30.h:281
@ T30_ERR_T1_EXPIRED
Definition t30.h:250
@ T30_ERR_RX_GOTDCS
Definition t30.h:275
@ T30_ERR_TX_PHDDEAD
Definition t30.h:270
@ T30_ERR_RX_T2EXPFAX
Definition t30.h:282
@ T30_ERR_RX_DCNWHY
Definition t30.h:286
@ T30_ERR_NORESSUPPORT
Definition t30.h:258
@ T30_ERR_TX_NODIS
Definition t30.h:268
@ T30_ERR_IDENT_UNACCEPTABLE
Definition t30.h:308
@ T30_ERR_RX_DCNDATA
Definition t30.h:287
@ T30_ERR_RX_T2EXPRR
Definition t30.h:284
@ T30_ERR_CANNOT_TRAIN
Definition t30.h:253
@ T30_ERR_TX_BADPG
Definition t30.h:264
@ T30_ERR_T3_EXPIRED
Definition t30.h:251
@ T30_ERR_CALLDROPPED
Definition t30.h:304
@ T30_ERR_SID_UNACCEPTABLE
Definition t30.h:312
@ T30_ERR_RX_NOCARRIER
Definition t30.h:277
@ T30_ERR_TX_BADDCS
Definition t30.h:263
@ T30_ERR_RX_ECMPHD
Definition t30.h:274
@ T30_ERR_TX_GOTDCN
Definition t30.h:266
@ T30_ERR_BADPAGE
Definition t30.h:297
@ T30_ERR_OPER_INT_FAIL
Definition t30.h:254
@ T30_ERR_RX_DCNRRD
Definition t30.h:290
@ T30_ERR_RX_T2EXPMPS
Definition t30.h:283
@ T30_ERR_TX_INVALRSP
Definition t30.h:267
@ T30_ERR_TX_ECMPHD
Definition t30.h:265
@ T30_ERR_RX_T2EXP
Definition t30.h:285
@ T30_ERR_RX_INVALCMD
Definition t30.h:276
@ T30_ERR_PSA_UNACCEPTABLE
Definition t30.h:311
@ T30_ERR_CIA_UNACCEPTABLE
Definition t30.h:316
@ T30_ERR_RX_INCAPABLE
Definition t30.h:256
void t30_timer_update(t30_state_t *s, int samples)
Report the passage of time to the T.30 engine.
Definition t30.c:7114
int t30_release(t30_state_t *s)
Release a T.30 context.
Definition t30.c:7388
int t30_restart(t30_state_t *s, bool calling_party)
Restart a T.30 context.
Definition t30.c:7296
void t30_front_end_status(void *user_data, int status)
Inform the T.30 engine of a status change in the front end (end of tx, rx signal change,...
Definition t30.c:6799
int t30_call_active(t30_state_t *s)
Check if a T.30 call is still active.
Definition t30.c:7405
void(* t30_phase_e_handler_t)(void *user_data, int completion_code)
T.30 phase E callback handler.
Definition t30.h:177
int(* t30_phase_d_handler_t)(void *user_data, int result)
T.30 phase D callback handler.
Definition t30.h:169
#define T30_MAX_IDENT_LEN
Definition t30.h:144
t30_state_t * t30_init(t30_state_t *s, bool calling_party, t30_set_handler_t set_rx_type_handler, void *set_rx_type_user_data, t30_set_handler_t set_tx_type_handler, void *set_tx_type_user_data, t30_send_hdlc_handler_t send_hdlc_handler, void *send_hdlc_user_data)
Initialise a T.30 context.
Definition t30.c:7338
void t30_non_ecm_put_bit(void *user_data, int bit)
Process a bit of received non-ECM image data.
Definition t30.c:6416
void(* t30_real_time_frame_handler_t)(void *user_data, bool direction, const uint8_t msg[], int len)
T.30 real time frame handler.
Definition t30.h:187
void t30_get_transfer_statistics(t30_state_t *s, t30_stats_t *t)
Get the current transfer statistics.
Definition t30.c:7229
int t30_non_ecm_get_bit(void *user_data)
Get a bit of received non-ECM image data.
Definition t30.c:6514
void(* t30_send_hdlc_handler_t)(void *user_data, const uint8_t msg[], int len)
T.30 send HDLC handler.
Definition t30.h:218
int(* t30_phase_b_handler_t)(void *user_data, int result)
T.30 phase B callback handler.
Definition t30.h:160
@ T30_FRONT_END_RECEIVE_COMPLETE
Definition t30.h:360
void(* t30_set_handler_t)(void *user_data, int type, int bit_rate, int short_train, int use_hdlc)
T.30 set a receive or transmit type handler.
Definition t30.h:209
int t30_free(t30_state_t *s)
Free a T.30 context.
Definition t30.c:7397
void t30_non_ecm_put(void *user_data, const uint8_t buf[], int len)
Process a chunk of received non-ECM image data.
Definition t30.c:6465
void t30_hdlc_accept(void *user_data, const uint8_t msg[], int len, int ok)
Process a received HDLC frame.
@ T30_SUPPORT_POLLED_SUB_ADDRESSING
Definition t30.h:374
@ T30_SUPPORT_INTERNET_ROUTING_ADDRESS
Definition t30.h:382
@ T30_SUPPORT_MULTIPLE_SELECTIVE_POLLING
Definition t30.h:376
@ T30_SUPPORT_TRANSMITTING_SUBSCRIBER_INTERNET_ADDRESS
Definition t30.h:380
@ T30_SUPPORT_IDENTIFICATION
Definition t30.h:370
@ T30_SUPPORT_CALLING_SUBSCRIBER_INTERNET_ADDRESS
Definition t30.h:384
@ T30_SUPPORT_COMMAND_REPEAT
Definition t30.h:392
@ T30_SUPPORT_SELECTIVE_POLLING
Definition t30.h:372
@ T30_SUPPORT_SUB_ADDRESSING
Definition t30.h:378
@ T30_SUPPORT_FIELD_NOT_VALID
Definition t30.h:390
@ T30_SUPPORT_CALLED_SUBSCRIBER_INTERNET_ADDRESS
Definition t30.h:388
@ T30_SUPPORT_INTERNET_SELECTIVE_POLLING_ADDRESS
Definition t30.h:386
void t30_local_interrupt_request(t30_state_t *s, int state)
Request a local interrupt of FAX exchange.
Definition t30.c:7277
int t30_non_ecm_get(void *user_data, uint8_t buf[], int max_len)
Get a bit of received non-ECM image data.
Definition t30.c:6551
int(* t30_document_get_handler_t)(void *user_data, uint8_t msg[], int len)
T.30 send document handler.
Definition t30.h:228
@ T30_SUPPORT_V34HDX
Definition t30.h:349
@ T30_SUPPORT_IAF
Definition t30.h:351
@ T30_SUPPORT_V27TER
Definition t30.h:343
@ T30_SUPPORT_V17
Definition t30.h:347
@ T30_SUPPORT_V29
Definition t30.h:345
int(* t30_document_handler_t)(void *user_data, int status)
T.30 document handler.
Definition t30.h:198
int(* t30_document_put_handler_t)(void *user_data, const uint8_t msg[], int len)
T.30 deliver handler.
Definition t30.h:238