spandsp  0.0.6
private/t30.h
Go to the documentation of this file.
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * private/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_PRIVATE_T30_H_)
29 #define _SPANDSP_PRIVATE_T30_H_
30 
31 /*!
32  T.30 FAX channel descriptor. This defines the state of a single working
33  instance of a T.30 FAX channel.
34 */
36 {
37  /*! \brief T.4 context for reading or writing image data. */
38  union
39  {
40  t4_state_t rx;
41  t4_state_t tx;
42  } t4;
43  /*! \brief The type of FAX operation currently in progress */
45 
46  /*! \brief TRUE if behaving as the calling party */
48 
49  /*! \brief Internet aware FAX mode bit mask. */
50  int iaf;
51  /*! \brief A bit mask of the currently supported modem types. */
53  /*! \brief A bit mask of the currently supported image compression modes. */
55  /*! \brief A bit mask of the currently supported image resolutions. */
57  /*! \brief A bit mask of the currently supported image sizes. */
59  /*! \brief A bit mask of the currently supported T.30 special features. */
61  /*! \brief TRUE is ECM mode handling is enabled. */
63  /*! \brief TRUE if we are capable of retransmitting pages */
65 
66  /*! \brief The received DCS, formatted as an ASCII string, for inclusion
67  in the TIFF file. */
69  /*! \brief The text which will be used in FAX page header. No text results
70  in no header line. */
72  /*! \brief TRUE for FAX page headers to overlay (i.e. replace) the beginning of the
73  page image. FALSE for FAX page headers to add to the overall length of
74  the page. */
76  /*! \brief TRUE if remote T.30 procedural interrupts are allowed. */
78 
79  /*! \brief The information fields received. */
81  /*! \brief The information fields to be transmitted. */
83  /*! \brief The country of origin of the remote machine, if known, else NULL. */
84  const char *country;
85  /*! \brief The vendor of the remote machine, if known, else NULL. */
86  const char *vendor;
87  /*! \brief The model of the remote machine, if known, else NULL. */
88  const char *model;
89 
90  /*! \brief A pointer to a callback routine to be called when phase B events
91  occur. */
93  /*! \brief An opaque pointer supplied in event B callbacks. */
95  /*! \brief A pointer to a callback routine to be called when phase D events
96  occur. */
98  /*! \brief An opaque pointer supplied in event D callbacks. */
100  /*! \brief A pointer to a callback routine to be called when phase E events
101  occur. */
103  /*! \brief An opaque pointer supplied in event E callbacks. */
105  /*! \brief A pointer to a callback routine to be called when frames are
106  exchanged. */
108  /*! \brief An opaque pointer supplied in real time frame callbacks. */
110 
111  /*! \brief A pointer to a callback routine to be called when document events
112  (e.g. end of transmitted document) occur. */
114  /*! \brief An opaque pointer supplied in document callbacks. */
116 
117  /*! \brief The handler for changes to the receive mode */
119  /*! \brief An opaque pointer passed to the handler for changes to the receive mode */
121  /*! \brief The handler for changes to the transmit mode */
123  /*! \brief An opaque pointer passed to the handler for changes to the transmit mode */
125 
126  /*! \brief The transmitted HDLC frame handler. */
128  /*! \brief An opaque pointer passed to the transmitted HDLC frame handler. */
130 
131  /*! \brief The DIS code for the minimum scan row time we require. This is usually 0ms,
132  but if we are trying to simulate another type of FAX machine, we may need a non-zero
133  value here. */
135 
136  /*! \brief The current T.30 phase. */
137  int phase;
138  /*! \brief The T.30 phase to change to when the current phase ends. */
140  /*! \brief The current state of the T.30 state machine. */
141  int state;
142  /*! \brief The step in sending a sequence of HDLC frames. */
143  int step;
144 
145  /*! \brief The preparation buffer for the DCS message to be transmitted. */
147  /*! \brief The length of the DCS message to be transmitted. */
148  int dcs_len;
149  /*! \brief The preparation buffer for DIS or DTC message to be transmitted. */
151  /*! \brief The length of the DIS or DTC message to be transmitted. */
153  /*! \brief The last DIS or DTC message received form the far end. */
155  /*! \brief The length of the last DIS or DTC message received form the far end. */
157  /*! \brief TRUE if a valid DIS has been received from the far end. */
159 
160  /*! \brief TRUE if the short training sequence should be used. */
162 
163  /*! \brief A count of the number of bits in the trainability test. This counts down to zero when
164  sending TCF, and counts up when receiving it. */
166  /*! \brief The current count of consecutive received zero bits, during the trainability test. */
168  /*! \brief The maximum consecutive received zero bits seen to date, during the trainability test. */
170 
171  /*! \brief The current fallback step for the fast message transfer modem. */
173  /*! \brief The subset of supported modems allowed at the current time, allowing for negotiation. */
175  /*! \brief TRUE if a carrier is present. Otherwise FALSE. */
177  /*! \brief TRUE if a modem has trained correctly. */
179  /*! \brief TRUE if a valid HDLC frame has been received in the current reception period. */
181 
182  /*! \brief Current reception mode. */
184  /*! \brief Current transmission mode. */
186 
187  /*! \brief T0 is the answer timeout when calling another FAX machine.
188  Placing calls is handled outside the FAX processing, but this timeout keeps
189  running until V.21 modulation is sent or received.
190  T1 is the remote terminal identification timeout (in audio samples). */
192  /*! \brief T2, T2A and T2B are the HDLC command timeouts.
193  T4, T4A and T4B are the HDLC response timeouts (in audio samples). */
195  /*! \brief A value specifying which of the possible timers is currently running in timer_t2_t4 */
197  /*! \brief Procedural interrupt timeout (in audio samples). */
198  int timer_t3;
199  /*! \brief This is only used in error correcting mode. */
200  int timer_t5;
201  /*! \brief This is only used in full duplex (e.g. ISDN) modes. */
202  int timer_t6;
203  /*! \brief This is only used in full duplex (e.g. ISDN) modes. */
204  int timer_t7;
205  /*! \brief This is only used in full duplex (e.g. ISDN) modes. */
206  int timer_t8;
207 
208  /*! \brief TRUE once the far end FAX entity has been detected. */
210 
211  /*! \brief TRUE if a local T.30 interrupt is pending. */
213  /*! \brief The image coding being used on the line. */
215  /*! \brief The image coding being used for output files. */
217  /*! \brief The current DCS message minimum scan time code. */
219  /*! \brief The X direction resolution of the current image, in pixels per metre. */
221  /*! \brief The Y direction resolution of the current image, in pixels per metre. */
223  /*! \brief The width of the current image, in pixels. */
225  /*! \brief Current number of retries of the action in progress. */
226  int retries;
227  /*! \brief TRUE if error correcting mode is used. */
229  /*! \brief The number of HDLC frame retries, if error correcting mode is used. */
231  /*! \brief The current count of consecutive T30_PPR messages. */
233  /*! \brief The current count of consecutive T30_RNR messages. */
235  /*! \brief The number of octets to be used per ECM frame. */
237  /*! \brief The ECM partial page buffer. */
238  uint8_t ecm_data[256][260];
239  /*! \brief The lengths of the frames in the ECM partial page buffer. */
240  int16_t ecm_len[256];
241  /*! \brief A bit map of the OK ECM frames, constructed as a PPR frame. */
242  uint8_t ecm_frame_map[3 + 32];
243 
244  /*! \brief The current page number for receiving, in ECM or non-ECM mode. This is reset at the start of a call. */
246  /*! \brief The current page number for sending, in ECM or non-ECM mode. This is reset at the start of a call. */
248  /*! \brief The current block number, in ECM mode */
250  /*! \brief The number of frames in the current block number, in ECM mode */
252  /*! \brief The number of frames sent in the current burst of image transmission, in ECM mode */
254  /*! \brief The current ECM frame, during ECM transmission. */
256  /*! \brief TRUE if we are at the end of an ECM page to se sent - i.e. there are no more
257  partial pages still to come. */
259 
260  /*! \brief The transmission step queued to follow the one in progress. */
262  /*! \brief The FCF for the next receive step. */
263  uint8_t next_rx_step;
264  /*! \brief Image file name for image reception. */
265  char rx_file[256];
266  /*! \brief The last page we are prepared accept for a received image file. -1 means no restriction. */
268  /*! \brief Image file name to be sent. */
269  char tx_file[256];
270  /*! \brief The first page to be sent from the image file. -1 means no restriction. */
272  /*! \brief The last page to be sent from the image file. -1 means no restriction. */
274  /*! \brief The current completion status. */
276 
277  /*! \brief The number of RTP events */
279  /*! \brief The number of RTN events */
281 
282  /*! \brief the FCF2 field of the last PPS message we received. */
283  uint8_t last_pps_fcf2;
284  /*! \brief TRUE if all frames of the current received ECM block are now OK */
286  /*! \brief A count of successfully received ECM frames, to assess progress as a basis for
287  deciding whether to continue error correction when PPRs keep repeating. */
289 
290  /*! \brief Error and flow logging control */
292 };
293 
294 #endif
295 /*- End of file ------------------------------------------------------------*/