spandsp 0.0.6

fax.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * fax.h - definitions for analogue line ITU T.30 fax processing
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2005 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_FAX_H_)
29#define _SPANDSP_FAX_H_
30
31/*! \page fax_page FAX over analogue modem handling
32
33\section fax_page_sec_1 What does it do?
34
35\section fax_page_sec_2 How does it work?
36*/
37
38 typedef struct fax_state_s fax_state_t;
39
40#if defined(__cplusplus)
41 extern "C"
42{
43#endif
44
45/*! Apply T.30 receive processing to a block of audio samples.
46 \brief Apply T.30 receive processing to a block of audio samples.
47 \param s The FAX context.
48 \param amp The audio sample buffer.
49 \param len The number of samples in the buffer.
50 \return The number of samples unprocessed. This should only be non-zero if
51 the software has reached the end of the FAX call.
52*/
53 SPAN_DECLARE_NONSTD(int) fax_rx(fax_state_t *s, int16_t *amp, int len);
54
55/*! Apply fake T.30 receive processing when a block of audio samples is missing (e.g due
56 to packet loss).
57 \brief Apply fake T.30 receive processing.
58 \param s The FAX context.
59 \param len The number of samples to fake.
60 \return The number of samples unprocessed. This should only be non-zero if
61 the software has reached the end of the FAX call.
62*/
63 SPAN_DECLARE_NONSTD(int) fax_rx_fillin(fax_state_t *s, int len);
64
65/*! Apply T.30 transmit processing to generate a block of audio samples.
66 \brief Apply T.30 transmit processing to generate a block of audio samples.
67 \param s The FAX context.
68 \param amp The audio sample buffer.
69 \param max_len The number of samples to be generated.
70 \return The number of samples actually generated. This will be zero when
71 there is nothing to send.
72*/
73 SPAN_DECLARE_NONSTD(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len);
74
75/*! Select whether silent audio will be sent when FAX transmit is idle.
76 \brief Select whether silent audio will be sent when FAX transmit is idle.
77 \param s The FAX context.
78 \param transmit_on_idle TRUE if silent audio should be output when the FAX transmitter is
79 idle. FALSE to transmit zero length audio when the FAX transmitter is idle. The default
80 behaviour is FALSE.
81*/
82SPAN_DECLARE(void) fax_set_transmit_on_idle(fax_state_t *s, int transmit_on_idle);
83
84/*! Select whether talker echo protection tone will be sent for the image modems.
85 \brief Select whether TEP will be sent for the image modems.
86 \param s The FAX context.
87 \param use_tep TRUE if TEP should be sent.
88*/
89SPAN_DECLARE(void) fax_set_tep_mode(fax_state_t *s, int use_tep);
90
91/*! Get a pointer to the T.30 engine associated with a FAX context.
92 \brief Get a pointer to the T.30 engine associated with a FAX context.
93 \param s The FAX context.
94 \return A pointer to the T.30 context, or NULL.
95*/
96SPAN_DECLARE(t30_state_t *) fax_get_t30_state(fax_state_t *s);
97
98/*! Get a pointer to the logging context associated with a FAX context.
99 \brief Get a pointer to the logging context associated with a FAX context.
100 \param s The FAX context.
101 \return A pointer to the logging context, or NULL.
102*/
103SPAN_DECLARE(logging_state_t *) fax_get_logging_state(fax_state_t *s);
104
105/*! Restart a FAX context.
106 \brief Restart a FAX context.
107 \param s The FAX context.
108 \param calling_party TRUE if the context is for a calling party. FALSE if the
109 context is for an answering party.
110 \return 0 for OK, else -1. */
111SPAN_DECLARE(int) fax_restart(fax_state_t *s, int calling_party);
112
113/*! Initialise a FAX context.
114 \brief Initialise a FAX context.
115 \param s The FAX context.
116 \param calling_party TRUE if the context is for a calling party. FALSE if the
117 context is for an answering party.
118 \return A pointer to the FAX context, or NULL if there was a problem.
119*/
120SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party);
121
122/*! Release a FAX context.
123 \brief Release a FAX context.
124 \param s The FAX context.
125 \return 0 for OK, else -1. */
126SPAN_DECLARE(int) fax_release(fax_state_t *s);
127
128/*! Free a FAX context.
129 \brief Free a FAX context.
130 \param s The FAX context.
131 \return 0 for OK, else -1. */
132SPAN_DECLARE(int) fax_free(fax_state_t *s);
133
134#if defined(__cplusplus)
135}
136#endif
137
138#endif
139/*- End of file ------------------------------------------------------------*/
SPAN_DECLARE_NONSTD
SPAN_DECLARE_NONSTD(void) async_rx_put_bit(void *user_data
Accept a bit from a received serial bit stream.
fax_get_t30_state
t30_state_t * fax_get_t30_state(fax_state_t *s)
Get a pointer to the T.30 engine associated with a FAX context.
Definition fax.c:591
fax_init
fax_state_t * fax_init(fax_state_t *s, int calling_party)
Initialise a FAX context.
Definition fax.c:664
fax_set_transmit_on_idle
void fax_set_transmit_on_idle(fax_state_t *s, int transmit_on_idle)
Select whether silent audio will be sent when FAX transmit is idle.
Definition fax.c:579
fax_restart
int fax_restart(fax_state_t *s, int calling_party)
Restart a FAX context.
Definition fax.c:603
fax_free
int fax_free(fax_state_t *s)
Free a FAX context.
Definition fax.c:726
fax_get_logging_state
logging_state_t * fax_get_logging_state(fax_state_t *s)
Get a pointer to the logging context associated with a FAX context.
Definition fax.c:597
fax_release
int fax_release(fax_state_t *s)
Release a FAX context.
Definition fax.c:719
fax_set_tep_mode
void fax_set_tep_mode(fax_state_t *s, int use_tep)
Select whether TEP will be sent for the image modems.
Definition fax.c:585
logging_state_t
struct logging_state_s logging_state_t
Definition logging.h:75
fax_state_s
Definition private/fax.h:36