00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * t4_tx.h - definitions for T.4 FAX transmit processing 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2003 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 * 00025 * $Id: t4_tx.h,v 1.2.2.3 2009/12/21 17:18:40 steveu Exp $ 00026 */ 00027 00028 /*! \file */ 00029 00030 #if !defined(_SPANDSP_T4_TX_H_) 00031 #define _SPANDSP_T4_TX_H_ 00032 00033 typedef int (*t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len); 00034 00035 #if defined(__cplusplus) 00036 extern "C" { 00037 #endif 00038 00039 /*! \brief Prepare for transmission of a document. 00040 \param s The T.4 context. 00041 \param file The name of the file to be sent. 00042 \param start_page The first page to send. -1 for no restriction. 00043 \param stop_page The last page to send. -1 for no restriction. 00044 \return A pointer to the context, or NULL if there was a problem. */ 00045 SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start_page, int stop_page); 00046 00047 /*! \brief Prepare to send the next page of the current document. 00048 \param s The T.4 context. 00049 \return zero for success, -1 for failure. */ 00050 SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s); 00051 00052 /*! \brief Prepare the current page for a resend. 00053 \param s The T.4 context. 00054 \return zero for success, -1 for failure. */ 00055 SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s); 00056 00057 /*! \brief Check for the existance of the next page, and whether its format is like the 00058 current one. This information can be needed before it is determined that the current 00059 page is finished with. 00060 \param s The T.4 context. 00061 \return 0 for next page found with the same format as the current page. 00062 1 for next page found with different format from the current page. 00063 -1 for no page found, or file failure. */ 00064 SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_state_t *s); 00065 00066 /*! \brief Complete the sending of a page. 00067 \param s The T.4 context. 00068 \return zero for success, -1 for failure. */ 00069 SPAN_DECLARE(int) t4_tx_end_page(t4_state_t *s); 00070 00071 /*! \brief Return the next bit of the current document page, without actually 00072 moving forward in the buffer. The document will be padded for the 00073 current minimum scan line time. 00074 \param s The T.4 context. 00075 \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is 00076 set (i.e. the returned value is 2 or 3). */ 00077 SPAN_DECLARE(int) t4_tx_check_bit(t4_state_t *s); 00078 00079 /*! \brief Get the next bit of the current document page. The document will 00080 be padded for the current minimum scan line time. 00081 \param s The T.4 context. 00082 \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is 00083 set (i.e. the returned value is 2 or 3). */ 00084 SPAN_DECLARE(int) t4_tx_get_bit(t4_state_t *s); 00085 00086 /*! \brief Get the next byte of the current document page. The document will 00087 be padded for the current minimum scan line time. 00088 \param s The T.4 context. 00089 \return The next byte. For the last byte of data, bit 8 is 00090 set. In this case, one or more bits of the byte may be padded with 00091 zeros, to complete the byte. */ 00092 SPAN_DECLARE(int) t4_tx_get_byte(t4_state_t *s); 00093 00094 /*! \brief Get the next chunk of the current document page. The document will 00095 be padded for the current minimum scan line time. 00096 \param s The T.4 context. 00097 \param buf The buffer into which the chunk is to written. 00098 \param max_len The maximum length of the chunk. 00099 \return The actual length of the chunk. If this is less than max_len it 00100 indicates that the end of the document has been reached. */ 00101 SPAN_DECLARE(int) t4_tx_get_chunk(t4_state_t *s, uint8_t buf[], int max_len); 00102 00103 /*! \brief End the transmission of a document. Tidy up and close the file. 00104 This should be used to end T.4 transmission started with t4_tx_init. 00105 \param s The T.4 context. 00106 \return 0 for success, otherwise -1. */ 00107 SPAN_DECLARE(int) t4_tx_release(t4_state_t *s); 00108 00109 /*! \brief End the transmission of a document. Tidy up, close the file and 00110 free the context. This should be used to end T.4 transmission 00111 started with t4_tx_init. 00112 \param s The T.4 context. 00113 \return 0 for success, otherwise -1. */ 00114 SPAN_DECLARE(int) t4_tx_free(t4_state_t *s); 00115 00116 /*! \brief Set the encoding for the encoded data. 00117 \param s The T.4 context. 00118 \param encoding The encoding. */ 00119 SPAN_DECLARE(void) t4_tx_set_tx_encoding(t4_state_t *s, int encoding); 00120 00121 /*! \brief Set the minimum number of encoded bits per row. This allows the 00122 makes the encoding process to be set to comply with the minimum row 00123 time specified by a remote receiving machine. 00124 \param s The T.4 context. 00125 \param bits The minimum number of bits per row. */ 00126 SPAN_DECLARE(void) t4_tx_set_min_row_bits(t4_state_t *s, int bits); 00127 00128 /*! \brief Set the identity of the local machine, for inclusion in page headers. 00129 \param s The T.4 context. 00130 \param ident The identity string. */ 00131 SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident); 00132 00133 /*! Set the info field, included in the header line included in each page of an encoded 00134 FAX. This is a string of up to 50 characters. Other information (date, local ident, etc.) 00135 are automatically included in the header. If the header info is set to NULL or a zero 00136 length string, no header lines will be added to the encoded FAX. 00137 \brief Set the header info. 00138 \param s The T.4 context. 00139 \param info A string, of up to 50 bytes, which will form the info field. */ 00140 SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info); 00141 00142 /*! \brief Set the row read handler for a T.4 transmit context. 00143 \param s The T.4 transmit context. 00144 \param handler A pointer to the handler routine. 00145 \param user_data An opaque pointer passed to the handler routine. 00146 \return 0 for success, otherwise -1. */ 00147 SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_state_t *s, t4_row_read_handler_t handler, void *user_data); 00148 00149 /*! \brief Get the row-to-row (y) resolution of the current page. 00150 \param s The T.4 context. 00151 \return The resolution, in pixels per metre. */ 00152 SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_state_t *s); 00153 00154 /*! \brief Get the column-to-column (x) resolution of the current page. 00155 \param s The T.4 context. 00156 \return The resolution, in pixels per metre. */ 00157 SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_state_t *s); 00158 00159 /*! \brief Get the width of the current page, in pixel columns. 00160 \param s The T.4 context. 00161 \return The number of columns. */ 00162 SPAN_DECLARE(int) t4_tx_get_image_width(t4_state_t *s); 00163 00164 /*! \brief Get the number of pages in the file. 00165 \param s The T.4 context. 00166 \return The number of pages, or -1 if there is an error. */ 00167 SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s); 00168 00169 /*! \brief Get the currnet page number in the file. 00170 \param s The T.4 context. 00171 \return The page number, or -1 if there is an error. */ 00172 SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s); 00173 00174 #if defined(__cplusplus) 00175 } 00176 #endif 00177 00178 #endif 00179 /*- End of file ------------------------------------------------------------*/