spandsp 0.0.6

v18.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * v18.h - V.18 text telephony for the deaf.
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2004-2009 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/*! \page v18_page The V.18 text telephony protocols
29\section v18_page_sec_1 What does it do?
30
31\section v18_page_sec_2 How does it work?
32*/
33
34#if !defined(_SPANDSP_V18_H_)
35#define _SPANDSP_V18_H_
36
37 typedef struct v18_state_s v18_state_t;
38
39 enum
40{
41 V18_MODE_NONE = 0,
42 /* V.18 Annex A - Weitbrecht TDD at 45.45bps, half-duplex, 5 bit baudot. */
43 V18_MODE_5BIT_45 = 1,
44 /* V.18 Annex A - Weitbrecht TDD at 50bps, half-duplex, 5 bit baudot. */
45 V18_MODE_5BIT_50 = 2,
46 /* V.18 Annex B - DTMF encoding of ASCII. */
47 V18_MODE_DTMF = 3,
48 /* V.18 Annex C - EDT 110bps, V.21, half-duplex, ASCII. */
49 V18_MODE_EDT = 4,
50 /* V.18 Annex D - 300bps, Bell 103, duplex, ASCII. */
51 V18_MODE_BELL103 = 5,
52 /* V.18 Annex E - 1200bps Videotex terminals, ASCII. */
53 V18_MODE_V23VIDEOTEX = 6,
54 /* V.18 Annex F - V.21 text telephone, V.21, duplex, ASCII. */
55 V18_MODE_V21TEXTPHONE = 7,
56 /* V.18 Annex G - V.18 text telephone mode. */
57 V18_MODE_V18TEXTPHONE = 8
58};
59
60#if defined(__cplusplus)
61 extern "C"
62{
63#endif
64
65SPAN_DECLARE(logging_state_t *) v18_get_logging_state(v18_state_t *s);
66
67/*! Initialise a V.18 context.
68 \brief Initialise a V.18 context.
69 \param s The V.18 context.
70 \param calling_party TRUE if caller mode, else answerer mode.
71 \param mode Mode of operation.
72 \param put_msg A callback routine called to deliver the received text
73 to the application.
74 \param user_data An opaque pointer for the callback routine.
75 \return A pointer to the V.18 context, or NULL if there was a problem. */
76SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
77 int calling_party,
78 int mode,
79 put_msg_func_t put_msg,
80 void *user_data);
81
82/*! Release a V.18 context.
83 \brief Release a V.18 context.
84 \param s The V.18 context.
85 \return 0 for OK. */
86SPAN_DECLARE(int) v18_release(v18_state_t *s);
87
88/*! Free a V.18 context.
89 \brief Release a V.18 context.
90 \param s The V.18 context.
91 \return 0 for OK. */
92SPAN_DECLARE(int) v18_free(v18_state_t *s);
93
94/*! Generate a block of V.18 audio samples.
95 \brief Generate a block of V.18 audio samples.
96 \param s The V.18 context.
97 \param amp The audio sample buffer.
98 \param max_len The number of samples to be generated.
99 \return The number of samples actually generated.
100*/
101 SPAN_DECLARE_NONSTD(int) v18_tx(v18_state_t *s, int16_t amp[], int max_len);
102
103/*! Process a block of received V.18 audio samples.
104 \brief Process a block of received V.18 audio samples.
105 \param s The V.18 context.
106 \param amp The audio sample buffer.
107 \param len The number of samples in the buffer.
108*/
109 SPAN_DECLARE_NONSTD(int) v18_rx(v18_state_t *s, const int16_t amp[], int len);
110
111/*! \brief Put a string to a V.18 context's input buffer.
112 \param s The V.18 context.
113 \param msg The string to be added.
114 \param len The length of the string. If negative, the string is
115 assumed to be a NULL terminated string.
116 \return The number of characters actually added. This may be less than the
117 length of the digit string, if the buffer fills up. If the string is
118 invalid, this function will return -1. */
119SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len);
120
121/*! Convert a text string to a V.18 DTMF string.
122 \brief Convert a text string to a V.18 DTMF string.
123 \param s The V.18 context.
124 \param dtmf The resulting DTMF string.
125 \param msg The text string to be converted.
126 \return The length of the DTMF string.
127*/
128SPAN_DECLARE(int) v18_encode_dtmf(v18_state_t *s, char dtmf[], const char msg[]);
129
130/*! Convert a V.18 DTMF string to a text string.
131 \brief Convert a V.18 DTMF string to a text string.
132 \param s The V.18 context.
133 \param msg The resulting test string.
134 \param dtmf The DTMF string to be converted.
135 \return The length of the text string.
136*/
137SPAN_DECLARE(int) v18_decode_dtmf(v18_state_t *s, char msg[], const char dtmf[]);
138
139SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch);
140
141SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch);
142
143/*! \brief Return a short name for an V.18 mode
144 \param mode The code for the V.18 mode.
145 \return A pointer to the name.
146*/
147SPAN_DECLARE(const char *) v18_mode_to_str(int mode);
148
149#if defined(__cplusplus)
150}
151#endif
152
153#endif
154/*- 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.
put_msg_func_t
void(* put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition async.h:93
logging_state_t
struct logging_state_s logging_state_t
Definition logging.h:75
v18_state_s
Definition private/v18.h:30
v18_state_s::calling_party
int calling_party
TRUE if we are the calling modem.
Definition private/v18.h:32
v18_free
int v18_free(v18_state_t *s)
Release a V.18 context.
Definition v18.c:908
v18_mode_to_str
const char * v18_mode_to_str(int mode)
Return a short name for an V.18 mode.
Definition v18.c:915
v18_encode_dtmf
int v18_encode_dtmf(v18_state_t *s, char dtmf[], const char msg[])
Convert a text string to a V.18 DTMF string.
Definition v18.c:387
v18_decode_dtmf
int v18_decode_dtmf(v18_state_t *s, char msg[], const char dtmf[])
Convert a V.18 DTMF string to a text string.
Definition v18.c:408
v18_init
v18_state_t * v18_init(v18_state_t *s, int calling_party, int mode, put_msg_func_t put_msg, void *user_data)
Initialise a V.18 context.
Definition v18.c:826
v18_put
int v18_put(v18_state_t *s, const char msg[], int len)
Put a string to a V.18 context's input buffer.
Definition v18.c:779
v18_release
int v18_release(v18_state_t *s)
Release a V.18 context.
Definition v18.c:902