spandsp  0.0.6
t4_tx.h
Go to the documentation of this file.
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * t4_tx.h - definitions for T.4 FAX transmit 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_T4_TX_H_)
29 #define _SPANDSP_T4_TX_H_
30 
31 typedef int (*t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len);
32 
33 #if defined(__cplusplus)
34 extern "C" {
35 #endif
36 
37 /*! \brief Prepare for transmission of a document.
38  \param s The T.4 context.
39  \param file The name of the file to be sent.
40  \param start_page The first page to send. -1 for no restriction.
41  \param stop_page The last page to send. -1 for no restriction.
42  \return A pointer to the context, or NULL if there was a problem. */
43 SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start_page, int stop_page);
44 
45 /*! \brief Prepare to send the next page of the current document.
46  \param s The T.4 context.
47  \return zero for success, -1 for failure. */
48 SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s);
49 
50 /*! \brief Prepare the current page for a resend.
51  \param s The T.4 context.
52  \return zero for success, -1 for failure. */
53 SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s);
54 
55 /*! \brief Check for the existance of the next page, and whether its format is like the
56  current one. This information can be needed before it is determined that the current
57  page is finished with.
58  \param s The T.4 context.
59  \return 0 for next page found with the same format as the current page.
60  1 for next page found with different format from the current page.
61  -1 for no page found, or file failure. */
63 
64 /*! \brief Complete the sending of a page.
65  \param s The T.4 context.
66  \return zero for success, -1 for failure. */
67 SPAN_DECLARE(int) t4_tx_end_page(t4_state_t *s);
68 
69 /*! \brief Return the next bit of the current document page, without actually
70  moving forward in the buffer. The document will be padded for the
71  current minimum scan line time.
72  \param s The T.4 context.
73  \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is
74  set (i.e. the returned value is 2 or 3). */
75 SPAN_DECLARE(int) t4_tx_check_bit(t4_state_t *s);
76 
77 /*! \brief Get the next bit of the current document page. The document will
78  be padded for the current minimum scan line time.
79  \param s The T.4 context.
80  \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is
81  set (i.e. the returned value is 2 or 3). */
82 SPAN_DECLARE(int) t4_tx_get_bit(t4_state_t *s);
83 
84 /*! \brief Get the next byte of the current document page. The document will
85  be padded for the current minimum scan line time.
86  \param s The T.4 context.
87  \return The next byte. For the last byte of data, bit 8 is
88  set. In this case, one or more bits of the byte may be padded with
89  zeros, to complete the byte. */
90 SPAN_DECLARE(int) t4_tx_get_byte(t4_state_t *s);
91 
92 /*! \brief Get the next chunk of the current document page. The document will
93  be padded for the current minimum scan line time.
94  \param s The T.4 context.
95  \param buf The buffer into which the chunk is to written.
96  \param max_len The maximum length of the chunk.
97  \return The actual length of the chunk. If this is less than max_len it
98  indicates that the end of the document has been reached. */
99 SPAN_DECLARE(int) t4_tx_get_chunk(t4_state_t *s, uint8_t buf[], int max_len);
100 
101 /*! \brief End the transmission of a document. Tidy up and close the file.
102  This should be used to end T.4 transmission started with t4_tx_init.
103  \param s The T.4 context.
104  \return 0 for success, otherwise -1. */
105 SPAN_DECLARE(int) t4_tx_release(t4_state_t *s);
106 
107 /*! \brief End the transmission of a document. Tidy up, close the file and
108  free the context. This should be used to end T.4 transmission
109  started with t4_tx_init.
110  \param s The T.4 context.
111  \return 0 for success, otherwise -1. */
112 SPAN_DECLARE(int) t4_tx_free(t4_state_t *s);
113 
114 /*! \brief Set the encoding for the encoded data.
115  \param s The T.4 context.
116  \param encoding The encoding. */
117 SPAN_DECLARE(void) t4_tx_set_tx_encoding(t4_state_t *s, int encoding);
118 
119 /*! \brief Set the minimum number of encoded bits per row. This allows the
120  makes the encoding process to be set to comply with the minimum row
121  time specified by a remote receiving machine.
122  \param s The T.4 context.
123  \param bits The minimum number of bits per row. */
124 SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_state_t *s, int bits);
125 
126 /*! \brief Set the identity of the local machine, for inclusion in page headers.
127  \param s The T.4 context.
128  \param ident The identity string. */
129 SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident);
130 
131 /*! Set the info field, included in the header line included in each page of an encoded
132  FAX. This is a string of up to 50 characters. Other information (date, local ident, etc.)
133  are automatically included in the header. If the header info is set to NULL or a zero
134  length string, no header lines will be added to the encoded FAX.
135  \brief Set the header info.
136  \param s The T.4 context.
137  \param info A string, of up to 50 bytes, which will form the info field. */
138 SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info);
139 
140 /*! Set the time zone for the time stamp in page header lines. If this function is not used
141  the current time zone of the program's environment is used.
142  \brief Set the header timezone.
143  \param s The T.4 context.
144  \param info A POSIX timezone description string. */
145 SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, const char *tzstring);
146 
147 /*! \brief Set the row read handler for a T.4 transmit context.
148  \param s The T.4 transmit context.
149  \param handler A pointer to the handler routine.
150  \param user_data An opaque pointer passed to the handler routine.
151  \return 0 for success, otherwise -1. */
152 SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_state_t *s, t4_row_read_handler_t handler, void *user_data);
153 
154 /*! \brief Get the row-to-row (y) resolution of the current page.
155  \param s The T.4 context.
156  \return The resolution, in pixels per metre. */
157 SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_state_t *s);
158 
159 /*! \brief Get the column-to-column (x) resolution of the current page.
160  \param s The T.4 context.
161  \return The resolution, in pixels per metre. */
162 SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_state_t *s);
163 
164 /*! \brief Get the width of the current page, in pixel columns.
165  \param s The T.4 context.
166  \return The number of columns. */
167 SPAN_DECLARE(int) t4_tx_get_image_width(t4_state_t *s);
168 
169 /*! \brief Get the number of pages in the file.
170  \param s The T.4 context.
171  \return The number of pages, or -1 if there is an error. */
172 SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s);
173 
174 /*! \brief Get the currnet page number in the file.
175  \param s The T.4 context.
176  \return The page number, or -1 if there is an error. */
177 SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s);
178 
179 /*! Get the current image transfer statistics.
180  \brief Get the current transfer statistics.
181  \param s The T.4 context.
182  \param t A pointer to a statistics structure. */
183 SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_state_t *s, t4_stats_t *t);
184 
185 #if defined(__cplusplus)
186 }
187 #endif
188 
189 #endif
190 /*- End of file ------------------------------------------------------------*/