comparison spandsp-0.0.6pre17/src/spandsp/v18.h @ 4:26cd8f1ef0b1

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

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.