t4_tx.h

Go to the documentation of this file.
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 
00026 /*! \file */
00027 
00028 #if !defined(_SPANDSP_T4_TX_H_)
00029 #define _SPANDSP_T4_TX_H_
00030 
00031 typedef int (*t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len);
00032 
00033 #if defined(__cplusplus)
00034 extern "C" {
00035 #endif
00036 
00037 /*! \brief Prepare for transmission of a document.
00038     \param s The T.4 context.
00039     \param file The name of the file to be sent.
00040     \param start_page The first page to send. -1 for no restriction.
00041     \param stop_page The last page to send. -1 for no restriction.
00042     \return A pointer to the context, or NULL if there was a problem. */
00043 SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start_page, int stop_page);
00044 
00045 /*! \brief Prepare to send the next page of the current document.
00046     \param s The T.4 context.
00047     \return zero for success, -1 for failure. */
00048 SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s);
00049 
00050 /*! \brief Prepare the current page for a resend.
00051     \param s The T.4 context.
00052     \return zero for success, -1 for failure. */
00053 SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s);
00054 
00055 /*! \brief Check for the existance of the next page, and whether its format is like the
00056     current one. This information can be needed before it is determined that the current
00057     page is finished with.
00058     \param s The T.4 context.
00059     \return 0 for next page found with the same format as the current page.
00060             1 for next page found with different format from the current page.
00061             -1 for no page found, or file failure. */
00062 SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_state_t *s);
00063 
00064 /*! \brief Complete the sending of a page.
00065     \param s The T.4 context.
00066     \return zero for success, -1 for failure. */
00067 SPAN_DECLARE(int) t4_tx_end_page(t4_state_t *s);
00068 
00069 /*! \brief Return the next bit of the current document page, without actually
00070            moving forward in the buffer. The document will be padded for the
00071            current minimum scan line time.
00072     \param s The T.4 context.
00073     \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is
00074             set (i.e. the returned value is 2 or 3). */
00075 SPAN_DECLARE(int) t4_tx_check_bit(t4_state_t *s);
00076 
00077 /*! \brief Get the next bit of the current document page. The document will
00078            be padded for the current minimum scan line time.
00079     \param s The T.4 context.
00080     \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is
00081             set (i.e. the returned value is 2 or 3). */
00082 SPAN_DECLARE(int) t4_tx_get_bit(t4_state_t *s);
00083 
00084 /*! \brief Get the next byte of the current document page. The document will
00085            be padded for the current minimum scan line time.
00086     \param s The T.4 context.
00087     \return The next byte. For the last byte of data, bit 8 is
00088             set. In this case, one or more bits of the byte may be padded with
00089             zeros, to complete the byte. */
00090 SPAN_DECLARE(int) t4_tx_get_byte(t4_state_t *s);
00091 
00092 /*! \brief Get the next chunk of the current document page. The document will
00093            be padded for the current minimum scan line time.
00094     \param s The T.4 context.
00095     \param buf The buffer into which the chunk is to written.
00096     \param max_len The maximum length of the chunk.
00097     \return The actual length of the chunk. If this is less than max_len it 
00098             indicates that the end of the document has been reached. */
00099 SPAN_DECLARE(int) t4_tx_get_chunk(t4_state_t *s, uint8_t buf[], int max_len);
00100 
00101 /*! \brief End the transmission of a document. Tidy up and close the file.
00102            This should be used to end T.4 transmission started with t4_tx_init.
00103     \param s The T.4 context.
00104     \return 0 for success, otherwise -1. */
00105 SPAN_DECLARE(int) t4_tx_release(t4_state_t *s);
00106 
00107 /*! \brief End the transmission of a document. Tidy up, close the file and
00108            free the context. This should be used to end T.4 transmission
00109            started with t4_tx_init.
00110     \param s The T.4 context.
00111     \return 0 for success, otherwise -1. */
00112 SPAN_DECLARE(int) t4_tx_free(t4_state_t *s);
00113 
00114 /*! \brief Set the encoding for the encoded data.
00115     \param s The T.4 context.
00116     \param encoding The encoding. */
00117 SPAN_DECLARE(void) t4_tx_set_tx_encoding(t4_state_t *s, int encoding);
00118 
00119 /*! \brief Set the minimum number of encoded bits per row. This allows the
00120            makes the encoding process to be set to comply with the minimum row
00121            time specified by a remote receiving machine.
00122     \param s The T.4 context.
00123     \param bits The minimum number of bits per row. */
00124 SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_state_t *s, int bits);
00125 
00126 /*! \brief Set the identity of the local machine, for inclusion in page headers.
00127     \param s The T.4 context.
00128     \param ident The identity string. */
00129 SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident);
00130 
00131 /*! Set the info field, included in the header line included in each page of an encoded
00132     FAX. This is a string of up to 50 characters. Other information (date, local ident, etc.)
00133     are automatically included in the header. If the header info is set to NULL or a zero
00134     length string, no header lines will be added to the encoded FAX.
00135     \brief Set the header info.
00136     \param s The T.4 context.
00137     \param info A string, of up to 50 bytes, which will form the info field. */
00138 SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info);
00139 
00140 /*! Set the time zone for the time stamp in page header lines. If this function is not used
00141     the current time zone of the program's environment is used.
00142     \brief Set the header timezone.
00143     \param s The T.4 context.
00144     \param info A POSIX timezone description string. */
00145 SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, const char *tzstring);
00146 
00147 /*! \brief Set the row read handler for a T.4 transmit context.
00148     \param s The T.4 transmit context.
00149     \param handler A pointer to the handler routine.
00150     \param user_data An opaque pointer passed to the handler routine.
00151     \return 0 for success, otherwise -1. */
00152 SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_state_t *s, t4_row_read_handler_t handler, void *user_data);
00153 
00154 /*! \brief Get the row-to-row (y) 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_y_resolution(t4_state_t *s);
00158 
00159 /*! \brief Get the column-to-column (x) resolution of the current page.
00160     \param s The T.4 context.
00161     \return The resolution, in pixels per metre. */
00162 SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_state_t *s);
00163 
00164 /*! \brief Get the width of the current page, in pixel columns.
00165     \param s The T.4 context.
00166     \return The number of columns. */
00167 SPAN_DECLARE(int) t4_tx_get_image_width(t4_state_t *s);
00168 
00169 /*! \brief Get the number of pages in the file.
00170     \param s The T.4 context.
00171     \return The number of pages, or -1 if there is an error. */
00172 SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s);
00173 
00174 /*! \brief Get the currnet page number in the file.
00175     \param s The T.4 context.
00176     \return The page number, or -1 if there is an error. */
00177 SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s);
00178 
00179 /*! Get the current image transfer statistics. 
00180     \brief Get the current transfer statistics.
00181     \param s The T.4 context.
00182     \param t A pointer to a statistics structure. */
00183 SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t);
00184 
00185 #if defined(__cplusplus)
00186 }
00187 #endif
00188 
00189 #endif
00190 /*- End of file ------------------------------------------------------------*/

Generated on Thu Oct 18 15:26:53 2012 for spandsp by  doxygen 1.4.7