spandsp 0.0.6
t31.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * t31.h - A T.31 compatible class 1 FAX modem interface.
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2004 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_T31_H_)
29#define _SPANDSP_T31_H_
30
31/*! \page t31_page T.31 Class 1 FAX modem protocol handling
32\section t31_page_sec_1 What does it do?
33The T.31 class 1 FAX modem modules implements a class 1 interface to the FAX
34modems in spandsp.
35
36\section t31_page_sec_2 How does it work?
37*/
38
39/*!
40 T.31 descriptor. This defines the working state for a single instance of
41 a T.31 FAX modem.
42*/
43typedef struct t31_state_s t31_state_t;
44
45typedef int (t31_modem_control_handler_t)(t31_state_t *s, void *user_data, int op, const char *num);
46
47#define T31_TX_BUF_LEN (4096)
48#define T31_TX_BUF_HIGH_TIDE (4096 - 1024)
49#define T31_TX_BUF_LOW_TIDE (1024)
50#define T31_MAX_HDLC_LEN 284
51#define T31_T38_MAX_HDLC_LEN 260
52
53#if defined(__cplusplus)
54extern "C"
55{
56#endif
57
58SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event);
59
60SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len);
61
62/*! Process a block of received T.31 modem audio samples.
63 \brief Process a block of received T.31 modem audio samples.
64 \param s The T.31 modem context.
65 \param amp The audio sample buffer.
66 \param len The number of samples in the buffer.
67 \return The number of samples unprocessed. */
68SPAN_DECLARE_NONSTD(int) t31_rx(t31_state_t *s, int16_t amp[], int len);
69
70/*! Fake processing of a missing block of received T.31 modem audio samples
71 (e.g due to packet loss).
72 \brief Fake processing of a missing block of received T.31 modem audio samples.
73 \param s The T.31 modem context.
74 \param len The number of samples to fake.
75 \return The number of samples unprocessed. */
76SPAN_DECLARE_NONSTD(int) t31_rx_fillin(t31_state_t *s, int len);
77
78/*! Generate a block of T.31 modem audio samples.
79 \brief Generate a block of T.31 modem audio samples.
80 \param s The T.31 modem context.
81 \param amp The audio sample buffer.
82 \param max_len The number of samples to be generated.
83 \return The number of samples actually generated.
84*/
85SPAN_DECLARE_NONSTD(int) t31_tx(t31_state_t *s, int16_t amp[], int max_len);
86
87SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples);
88
89/*! Select whether silent audio will be sent when transmit is idle.
90 \brief Select whether silent audio will be sent when transmit is idle.
91 \param s The T.31 modem context.
92 \param transmit_on_idle TRUE if silent audio should be output when the transmitter is
93 idle. FALSE to transmit zero length audio when the transmitter is idle. The default
94 behaviour is FALSE.
95*/
96SPAN_DECLARE(void) t31_set_transmit_on_idle(t31_state_t *s, int transmit_on_idle);
97
98/*! Select whether TEP mode will be used (or time allowed for it (when transmitting).
99 \brief Select whether TEP mode will be used.
100 \param s The T.31 modem context.
101 \param use_tep TRUE if TEP is to be ised.
102*/
103SPAN_DECLARE(void) t31_set_tep_mode(t31_state_t *s, int use_tep);
104
105/*! Select whether T.38 data will be paced as it is transmitted.
106 \brief Select whether T.38 data will be paced.
107 \param s The T.31 modem context.
108 \param without_pacing TRUE if data is to be sent as fast as possible. FALSE if it is
109 to be paced.
110*/
111SPAN_DECLARE(void) t31_set_t38_config(t31_state_t *s, int without_pacing);
112
113SPAN_DECLARE(void) t31_set_mode(t31_state_t *s, int t38_mode);
114
115/*! Get a pointer to the logging context associated with a T.31 context.
116 \brief Get a pointer to the logging context associated with a T.31 context.
117 \param s The T.31 context.
118 \return A pointer to the logging context, or NULL.
119*/
121
122SPAN_DECLARE(t38_core_state_t *) t31_get_t38_core_state(t31_state_t *s);
123
124/*! Initialise a T.31 context. This must be called before the first
125 use of the context, to initialise its contents.
126 \brief Initialise a T.31 context.
127 \param s The T.31 context.
128 \param at_tx_handler A callback routine to handle AT interpreter channel output.
129 \param at_tx_user_data An opaque pointer passed in called to at_tx_handler.
130 \param modem_control_handler A callback routine to handle control of the modem (off-hook, etc).
131 \param modem_control_user_data An opaque pointer passed in called to modem_control_handler.
132 \param tx_t38_packet_handler ???
133 \param tx_t38_packet_user_data ???
134 \return A pointer to the T.31 context. */
135SPAN_DECLARE(t31_state_t *) t31_init(t31_state_t *s,
136 at_tx_handler_t *at_tx_handler,
137 void *at_tx_user_data,
138 t31_modem_control_handler_t *modem_control_handler,
139 void *modem_control_user_data,
140 t38_tx_packet_handler_t *tx_t38_packet_handler,
141 void *tx_t38_packet_user_data);
142
143/*! Release a T.31 context.
144 \brief Release a T.31 context.
145 \param s The T.31 context.
146 \return 0 for OK */
147SPAN_DECLARE(int) t31_release(t31_state_t *s);
148
149/*! Free a T.31 context.
150 \brief Release a T.31 context.
151 \param s The T.31 context.
152 \return 0 for OK */
153SPAN_DECLARE(int) t31_free(t31_state_t *s);
154
155#if defined(__cplusplus)
156}
157#endif
158
159#endif
160/*- End of file ------------------------------------------------------------*/
SPAN_DECLARE_NONSTD(void) async_rx_put_bit(void *user_data
Accept a bit from a received serial bit stream.
struct logging_state_s logging_state_t
Definition logging.h:75
Definition private/t31.h:137
void t31_set_tep_mode(t31_state_t *s, int use_tep)
Select whether TEP mode will be used.
Definition t31.c:2520
int t31_release(t31_state_t *s)
Release a T.31 context.
Definition t31.c:2693
t31_state_t * t31_init(t31_state_t *s, at_tx_handler_t *at_tx_handler, void *at_tx_user_data, t31_modem_control_handler_t *modem_control_handler, void *modem_control_user_data, t38_tx_packet_handler_t *tx_t38_packet_handler, void *tx_t38_packet_user_data)
Initialise a T.31 context.
Definition t31.c:2605
struct t31_state_s t31_state_t
Definition t31.h:43
void t31_set_t38_config(t31_state_t *s, int without_pacing)
Select whether T.38 data will be paced.
Definition t31.c:2526
void t31_set_transmit_on_idle(t31_state_t *s, int transmit_on_idle)
Select whether silent audio will be sent when transmit is idle.
Definition t31.c:2514
int t31_free(t31_state_t *s)
Release a T.31 context.
Definition t31.c:2700
logging_state_t * t31_get_logging_state(t31_state_t *s)
Get a pointer to the logging context associated with a T.31 context.
Definition t31.c:2560
struct t38_core_state_s t38_core_state_t
Definition t38_core.h:202