spandsp 3.0.0
fax_modems.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * fax_modems.h - definitions for the analogue modem set for fax processing
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2008 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_MODEMS_H_)
29#define _SPANDSP_FAX_MODEMS_H_
30
31enum
32{
33 FAX_MODEM_NONE = -1,
34 FAX_MODEM_FLUSH = 0,
35 FAX_MODEM_SILENCE_TX,
36 FAX_MODEM_SILENCE_RX,
37 FAX_MODEM_CED_TONE_TX,
38 FAX_MODEM_CNG_TONE_TX,
39 FAX_MODEM_NOCNG_TONE_TX,
40 FAX_MODEM_CED_TONE_RX,
41 FAX_MODEM_CNG_TONE_RX,
42 FAX_MODEM_V21_TX,
43 FAX_MODEM_V17_TX,
44 FAX_MODEM_V27TER_TX,
45 FAX_MODEM_V29_TX,
46 FAX_MODEM_V21_RX,
47 FAX_MODEM_V17_RX,
48 FAX_MODEM_V27TER_RX,
49 FAX_MODEM_V29_RX,
50#if defined(SPANDSP_SUPPORT_V34)
51 FAX_MODEM_V34_TX,
52 FAX_MODEM_V34_RX
53#endif
54};
55
56/*!
57 The set of modems needed for FAX, plus the auxilliary stuff, like tone generation.
58*/
60
61#if defined(__cplusplus)
62extern "C"
63{
64#endif
65
66/* TEMPORARY FUDGE */
67SPAN_DECLARE(void) fax_modems_hdlc_accept(void *user_data, const uint8_t *msg, int len, int ok);
68
69/*! Convert a FAX modem type to a short text description.
70 \brief Convert a FAX modem type to a short text description.
71 \param modem The modem code.
72 \return A pointer to the description. */
73SPAN_DECLARE(const char *) fax_modem_to_str(int modem);
74
75/* N.B. the following are currently a work in progress */
76SPAN_DECLARE(int) fax_modems_v17_v21_rx(void *user_data, const int16_t amp[], int len);
77SPAN_DECLARE(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t amp[], int len);
78SPAN_DECLARE(int) fax_modems_v29_v21_rx(void *user_data, const int16_t amp[], int len);
79SPAN_DECLARE(int) fax_modems_v17_v21_rx_fillin(void *user_data, int len);
80SPAN_DECLARE(int) fax_modems_v27ter_v21_rx_fillin(void *user_data, int len);
81SPAN_DECLARE(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len);
82
83SPAN_DECLARE(void) fax_modems_hdlc_tx_frame(void *user_data, const uint8_t *msg, int len);
84
85SPAN_DECLARE(void) fax_modems_hdlc_tx_flags(fax_modems_state_t *s, int flags);
86
87SPAN_DECLARE(void) fax_modems_start_fast_modem(fax_modems_state_t *s, int which, int bit_rate, int short_train, int hdlc_mode);
88
89SPAN_DECLARE(void) fax_modems_start_slow_modem(fax_modems_state_t *s, int which);
90
91SPAN_DECLARE(void) fax_modems_set_tep_mode(fax_modems_state_t *s, int use_tep);
92
93SPAN_DECLARE(void) fax_modems_set_put_bit(fax_modems_state_t *s, put_bit_func_t put_bit, void *user_data);
94
95SPAN_DECLARE(void) fax_modems_set_get_bit(fax_modems_state_t *s, get_bit_func_t get_bit, void *user_data);
96
97SPAN_DECLARE(void) fax_modems_set_rx_handler(fax_modems_state_t *s,
98 span_rx_handler_t rx_handler,
99 void *rx_user_data,
100 span_rx_fillin_handler_t rx_fillin_handler,
101 void *rx_fillin_user_data);
102
103SPAN_DECLARE(void) fax_modems_set_rx_active(fax_modems_state_t *s, int active);
104
105SPAN_DECLARE(void) fax_modems_set_tx_handler(fax_modems_state_t *s, span_tx_handler_t handler, void *user_data);
106
107SPAN_DECLARE(void) fax_modems_set_next_tx_handler(fax_modems_state_t *s, span_tx_handler_t handler, void *user_data);
108
109SPAN_DECLARE(int) fax_modems_set_next_tx_type(fax_modems_state_t *s);
110
111SPAN_DECLARE(int) fax_modems_restart(fax_modems_state_t *s);
112
113/*! Get a pointer to the logging context associated with a FAX modems context.
114 \brief Get a pointer to the logging context associated with a FAX modems context.
115 \param s The FAX modems context.
116 \return A pointer to the logging context, or NULL.
117*/
119
120SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s,
121 int use_tep,
122 hdlc_frame_handler_t hdlc_accept,
123 hdlc_underflow_handler_t hdlc_tx_underflow,
124 put_bit_func_t non_ecm_put_bit,
125 get_bit_func_t non_ecm_get_bit,
126 tone_report_func_t tone_callback,
127 void *user_data);
128
129SPAN_DECLARE(int) fax_modems_release(fax_modems_state_t *s);
130
131SPAN_DECLARE(int) fax_modems_free(fax_modems_state_t *s);
132
133#if defined(__cplusplus)
134}
135#endif
136
137#endif
138/*- End of file ------------------------------------------------------------*/
void(* put_bit_func_t)(void *user_data, int bit)
Definition async.h:107
int(* get_bit_func_t)(void *user_data)
Definition async.h:110
logging_state_t * fax_modems_get_logging_state(fax_modems_state_t *s)
Get a pointer to the logging context associated with a FAX modems context.
Definition fax_modems.c:601
const char * fax_modem_to_str(int modem)
Convert a FAX modem type to a short text description.
Definition fax_modems.c:104
Definition private/fax_modems.h:35
span_rx_handler_t rx_handler
The current receive signal handler.
Definition private/fax_modems.h:126
put_bit_func_t put_bit
The callback function used to put each bit received.
Definition private/fax_modems.h:105
span_rx_fillin_handler_t rx_fillin_handler
The current receive missing signal fill-in handler.
Definition private/fax_modems.h:132
bool use_tep
Definition private/fax_modems.h:37
get_bit_func_t get_bit
The callback function used to get the next bit to be transmitted.
Definition private/fax_modems.h:110
tone_report_func_t tone_callback
The callback function used to report detected tones.
Definition private/fax_modems.h:39
Definition private/logging.h:34