Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/private/t30.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 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 * $Id: t30.h,v 1.5.4.1 2009/12/19 09:47:56 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 #if !defined(_SPANDSP_PRIVATE_T30_H_) | |
| 31 #define _SPANDSP_PRIVATE_T30_H_ | |
| 32 | |
| 33 /*! | |
| 34 T.30 FAX channel descriptor. This defines the state of a single working | |
| 35 instance of a T.30 FAX channel. | |
| 36 */ | |
| 37 struct t30_state_s | |
| 38 { | |
| 39 /* This must be kept the first thing in the structure, so it can be pointed | |
| 40 to reliably as the structures change over time. */ | |
| 41 /*! \brief T.4 context for reading or writing image data. */ | |
| 42 t4_state_t t4; | |
| 43 | |
| 44 /*! \brief The type of FAX operation currently in progress */ | |
| 45 int operation_in_progress; | |
| 46 | |
| 47 /*! \brief TRUE if behaving as the calling party */ | |
| 48 int calling_party; | |
| 49 | |
| 50 /*! \brief The received DCS, formatted as an ASCII string, for inclusion | |
| 51 in the TIFF file. */ | |
| 52 char rx_dcs_string[T30_MAX_DIS_DTC_DCS_LEN*3 + 1]; | |
| 53 /*! \brief The text which will be used in FAX page header. No text results | |
| 54 in no header line. */ | |
| 55 char header_info[T30_MAX_PAGE_HEADER_INFO + 1]; | |
| 56 /*! \brief The information fields received. */ | |
| 57 t30_exchanged_info_t rx_info; | |
| 58 /*! \brief The information fields to be transmitted. */ | |
| 59 t30_exchanged_info_t tx_info; | |
| 60 /*! \brief The country of origin of the remote machine, if known, else NULL. */ | |
| 61 const char *country; | |
| 62 /*! \brief The vendor of the remote machine, if known, else NULL. */ | |
| 63 const char *vendor; | |
| 64 /*! \brief The model of the remote machine, if known, else NULL. */ | |
| 65 const char *model; | |
| 66 | |
| 67 /*! \brief A pointer to a callback routine to be called when phase B events | |
| 68 occur. */ | |
| 69 t30_phase_b_handler_t *phase_b_handler; | |
| 70 /*! \brief An opaque pointer supplied in event B callbacks. */ | |
| 71 void *phase_b_user_data; | |
| 72 /*! \brief A pointer to a callback routine to be called when phase D events | |
| 73 occur. */ | |
| 74 t30_phase_d_handler_t *phase_d_handler; | |
| 75 /*! \brief An opaque pointer supplied in event D callbacks. */ | |
| 76 void *phase_d_user_data; | |
| 77 /*! \brief A pointer to a callback routine to be called when phase E events | |
| 78 occur. */ | |
| 79 t30_phase_e_handler_t *phase_e_handler; | |
| 80 /*! \brief An opaque pointer supplied in event E callbacks. */ | |
| 81 void *phase_e_user_data; | |
| 82 /*! \brief A pointer to a callback routine to be called when frames are | |
| 83 exchanged. */ | |
| 84 t30_real_time_frame_handler_t *real_time_frame_handler; | |
| 85 /*! \brief An opaque pointer supplied in real time frame callbacks. */ | |
| 86 void *real_time_frame_user_data; | |
| 87 | |
| 88 /*! \brief A pointer to a callback routine to be called when document events | |
| 89 (e.g. end of transmitted document) occur. */ | |
| 90 t30_document_handler_t *document_handler; | |
| 91 /*! \brief An opaque pointer supplied in document callbacks. */ | |
| 92 void *document_user_data; | |
| 93 | |
| 94 /*! \brief The handler for changes to the receive mode */ | |
| 95 t30_set_handler_t *set_rx_type_handler; | |
| 96 /*! \brief An opaque pointer passed to the handler for changes to the receive mode */ | |
| 97 void *set_rx_type_user_data; | |
| 98 /*! \brief The handler for changes to the transmit mode */ | |
| 99 t30_set_handler_t *set_tx_type_handler; | |
| 100 /*! \brief An opaque pointer passed to the handler for changes to the transmit mode */ | |
| 101 void *set_tx_type_user_data; | |
| 102 | |
| 103 /*! \brief The transmitted HDLC frame handler. */ | |
| 104 t30_send_hdlc_handler_t *send_hdlc_handler; | |
| 105 /*! \brief An opaque pointer passed to the transmitted HDLC frame handler. */ | |
| 106 void *send_hdlc_user_data; | |
| 107 | |
| 108 /*! \brief The DIS code for the minimum scan row time we require. This is usually 0ms, | |
| 109 but if we are trying to simulate another type of FAX machine, we may need a non-zero | |
| 110 value here. */ | |
| 111 uint8_t local_min_scan_time_code; | |
| 112 | |
| 113 /*! \brief The current T.30 phase. */ | |
| 114 int phase; | |
| 115 /*! \brief The T.30 phase to change to when the current phase ends. */ | |
| 116 int next_phase; | |
| 117 /*! \brief The current state of the T.30 state machine. */ | |
| 118 int state; | |
| 119 /*! \brief The step in sending a sequence of HDLC frames. */ | |
| 120 int step; | |
| 121 | |
| 122 /*! \brief The preparation buffer for the DCS message to be transmitted. */ | |
| 123 uint8_t dcs_frame[T30_MAX_DIS_DTC_DCS_LEN]; | |
| 124 /*! \brief The length of the DCS message to be transmitted. */ | |
| 125 int dcs_len; | |
| 126 /*! \brief The preparation buffer for DIS or DTC message to be transmitted. */ | |
| 127 uint8_t local_dis_dtc_frame[T30_MAX_DIS_DTC_DCS_LEN]; | |
| 128 /*! \brief The length of the DIS or DTC message to be transmitted. */ | |
| 129 int local_dis_dtc_len; | |
| 130 /*! \brief The last DIS or DTC message received form the far end. */ | |
| 131 uint8_t far_dis_dtc_frame[T30_MAX_DIS_DTC_DCS_LEN]; | |
| 132 /*! \brief The length of the last DIS or DTC message received form the far end. */ | |
| 133 int far_dis_dtc_len; | |
| 134 /*! \brief TRUE if a valid DIS has been received from the far end. */ | |
| 135 int dis_received; | |
| 136 | |
| 137 /*! \brief A flag to indicate a message is in progress. */ | |
| 138 int in_message; | |
| 139 | |
| 140 /*! \brief TRUE if the short training sequence should be used. */ | |
| 141 int short_train; | |
| 142 | |
| 143 /*! \brief A count of the number of bits in the trainability test. This counts down to zero when | |
| 144 sending TCF, and counts up when receiving it. */ | |
| 145 int tcf_test_bits; | |
| 146 /*! \brief The current count of consecutive received zero bits, during the trainability test. */ | |
| 147 int tcf_current_zeros; | |
| 148 /*! \brief The maximum consecutive received zero bits seen to date, during the trainability test. */ | |
| 149 int tcf_most_zeros; | |
| 150 | |
| 151 /*! \brief The current fallback step for the fast message transfer modem. */ | |
| 152 int current_fallback; | |
| 153 /*! \brief The subset of supported modems allowed at the current time, allowing for negotiation. */ | |
| 154 int current_permitted_modems; | |
| 155 /*! \brief TRUE if a carrier is present. Otherwise FALSE. */ | |
| 156 int rx_signal_present; | |
| 157 /*! \brief TRUE if a modem has trained correctly. */ | |
| 158 int rx_trained; | |
| 159 /*! \brief TRUE if a valid HDLC frame has been received in the current reception period. */ | |
| 160 int rx_frame_received; | |
| 161 | |
| 162 /*! \brief Current reception mode. */ | |
| 163 int current_rx_type; | |
| 164 /*! \brief Current transmission mode. */ | |
| 165 int current_tx_type; | |
| 166 | |
| 167 /*! \brief T0 is the answer timeout when calling another FAX machine. | |
| 168 Placing calls is handled outside the FAX processing, but this timeout keeps | |
| 169 running until V.21 modulation is sent or received. | |
| 170 T1 is the remote terminal identification timeout (in audio samples). */ | |
| 171 int timer_t0_t1; | |
| 172 /*! \brief T2, T2A and T2B are the HDLC command timeouts. | |
| 173 T4, T4A and T4B are the HDLC response timeouts (in audio samples). */ | |
| 174 int timer_t2_t4; | |
| 175 /*! \brief A value specifying which of the possible timers is currently running in timer_t2_t4 */ | |
| 176 int timer_t2_t4_is; | |
| 177 /*! \brief Procedural interrupt timeout (in audio samples). */ | |
| 178 int timer_t3; | |
| 179 /*! \brief This is only used in error correcting mode. */ | |
| 180 int timer_t5; | |
| 181 /*! \brief This is only used in full duplex (e.g. ISDN) modes. */ | |
| 182 int timer_t6; | |
| 183 /*! \brief This is only used in full duplex (e.g. ISDN) modes. */ | |
| 184 int timer_t7; | |
| 185 /*! \brief This is only used in full duplex (e.g. ISDN) modes. */ | |
| 186 int timer_t8; | |
| 187 | |
| 188 /*! \brief TRUE once the far end FAX entity has been detected. */ | |
| 189 int far_end_detected; | |
| 190 | |
| 191 /*! \brief TRUE if a local T.30 interrupt is pending. */ | |
| 192 int local_interrupt_pending; | |
| 193 /*! \brief The image coding being used on the line. */ | |
| 194 int line_encoding; | |
| 195 /*! \brief The image coding being used for output files. */ | |
| 196 int output_encoding; | |
| 197 /*! \brief The current DCS message minimum scan time code. */ | |
| 198 uint8_t min_scan_time_code; | |
| 199 /*! \brief The X direction resolution of the current image, in pixels per metre. */ | |
| 200 int x_resolution; | |
| 201 /*! \brief The Y direction resolution of the current image, in pixels per metre. */ | |
| 202 int y_resolution; | |
| 203 /*! \brief The width of the current image, in pixels. */ | |
| 204 t4_image_width_t image_width; | |
| 205 /*! \brief Current number of retries of the action in progress. */ | |
| 206 int retries; | |
| 207 /*! \brief TRUE if error correcting mode is used. */ | |
| 208 int error_correcting_mode; | |
| 209 /*! \brief The number of HDLC frame retries, if error correcting mode is used. */ | |
| 210 int error_correcting_mode_retries; | |
| 211 /*! \brief The current count of consecutive T30_PPR messages. */ | |
| 212 int ppr_count; | |
| 213 /*! \brief The current count of consecutive T30_RNR messages. */ | |
| 214 int receiver_not_ready_count; | |
| 215 /*! \brief The number of octets to be used per ECM frame. */ | |
| 216 int octets_per_ecm_frame; | |
| 217 /*! \brief The ECM partial page buffer. */ | |
| 218 uint8_t ecm_data[256][260]; | |
| 219 /*! \brief The lengths of the frames in the ECM partial page buffer. */ | |
| 220 int16_t ecm_len[256]; | |
| 221 /*! \brief A bit map of the OK ECM frames, constructed as a PPR frame. */ | |
| 222 uint8_t ecm_frame_map[3 + 32]; | |
| 223 | |
| 224 /*! \brief The current page number for receiving, in ECM or non-ECM mode. This is reset at the start of a call. */ | |
| 225 int rx_page_number; | |
| 226 /*! \brief The current page number for sending, in ECM or non-ECM mode. This is reset at the start of a call. */ | |
| 227 int tx_page_number; | |
| 228 /*! \brief The current block number, in ECM mode */ | |
| 229 int ecm_block; | |
| 230 /*! \brief The number of frames in the current block number, in ECM mode */ | |
| 231 int ecm_frames; | |
| 232 /*! \brief The number of frames sent in the current burst of image transmission, in ECM mode */ | |
| 233 int ecm_frames_this_tx_burst; | |
| 234 /*! \brief The current ECM frame, during ECM transmission. */ | |
| 235 int ecm_current_tx_frame; | |
| 236 /*! \brief TRUE if we are at the end of an ECM page to se sent - i.e. there are no more | |
| 237 partial pages still to come. */ | |
| 238 int ecm_at_page_end; | |
| 239 | |
| 240 /*! \brief The transmission step queued to follow the one in progress. */ | |
| 241 int next_tx_step; | |
| 242 /*! \brief The FCF for the next receive step. */ | |
| 243 uint8_t next_rx_step; | |
| 244 /*! \brief Image file name for image reception. */ | |
| 245 char rx_file[256]; | |
| 246 /*! \brief The last page we are prepared accept for a received image file. -1 means no restriction. */ | |
| 247 int rx_stop_page; | |
| 248 /*! \brief Image file name to be sent. */ | |
| 249 char tx_file[256]; | |
| 250 /*! \brief The first page to be sent from the image file. -1 means no restriction. */ | |
| 251 int tx_start_page; | |
| 252 /*! \brief The last page to be sent from the image file. -1 means no restriction. */ | |
| 253 int tx_stop_page; | |
| 254 /*! \brief The current completion status. */ | |
| 255 int current_status; | |
| 256 /*! \brief Internet aware FAX mode bit mask. */ | |
| 257 int iaf; | |
| 258 /*! \brief A bit mask of the currently supported modem types. */ | |
| 259 int supported_modems; | |
| 260 /*! \brief A bit mask of the currently supported image compression modes. */ | |
| 261 int supported_compressions; | |
| 262 /*! \brief A bit mask of the currently supported image resolutions. */ | |
| 263 int supported_resolutions; | |
| 264 /*! \brief A bit mask of the currently supported image sizes. */ | |
| 265 int supported_image_sizes; | |
| 266 /*! \brief A bit mask of the currently supported T.30 special features. */ | |
| 267 int supported_t30_features; | |
| 268 /*! \brief TRUE is ECM mode handling is enabled. */ | |
| 269 int ecm_allowed; | |
| 270 | |
| 271 /*! \brief the FCF2 field of the last PPS message we received. */ | |
| 272 uint8_t last_pps_fcf2; | |
| 273 /*! \brief The number of the first ECM frame which we do not currently received correctly. For | |
| 274 a partial page received correctly, this will be one greater than the number of frames it | |
| 275 contains. */ | |
| 276 int ecm_first_bad_frame; | |
| 277 /*! \brief A count of successfully received ECM frames, to assess progress as a basis for | |
| 278 deciding whether to continue error correction when PPRs keep repeating. */ | |
| 279 int ecm_progress; | |
| 280 | |
| 281 /*! \brief Error and flow logging control */ | |
| 282 logging_state_t logging; | |
| 283 }; | |
| 284 | |
| 285 #endif | |
| 286 /*- End of file ------------------------------------------------------------*/ |
