Asterisk - The Open Source Telephony Project  18.5.0
tdd.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  * \brief TTY/TDD Generation support
21  * \note Includes code and algorithms from the Zapata library.
22  */
23 
24 #ifndef _ASTERISK_TDD_H
25 #define _ASTERISK_TDD_H
26 
27 #define TDD_BYTES_PER_CHAR 2700
28 
29 struct tdd_state;
30 typedef struct tdd_state TDDSTATE;
31 
32 /*! CallerID Initialization
33  * Initializes the TDD system. Mostly stuff for inverse FFT
34  */
35 void tdd_init(void);
36 
37 /*! Generates a CallerID FSK stream in ulaw format suitable for transmission.
38  * \param tdd tdd structure
39  * \param buf Buffer to use. This needs to be large enough to accomodate all the generated samples.
40  * \param string This is the string to send.
41  * This function creates a stream of TDD data in ulaw format. It returns the size
42  * (in bytes) of the data (if it returns a size of 0, there is probably an error)
43 */
44 int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *string);
45 
46 /*! Create a TDD state machine
47  * This function returns a malloc'd instance of the tdd_state data structure.
48  * Returns a pointer to a malloc'd tdd_state structure, or NULL on error.
49  */
50 struct tdd_state *tdd_new(void);
51 
52 /*! Read samples into the state machine, and return character (if any).
53  * \param tdd Which state machine to act upon
54  * \param ubuf containing your samples
55  * \param samples number of samples contained within the buffer.
56  *
57  * Send received audio to the TDD demodulator.
58  * Returns -1 on error, 0 for "needs more samples",
59  * and > 0 (the character) if reception of a character is complete.
60  */
61 int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples);
62 
63 /*! Free a TDD state machine
64  * \param tdd This is the tdd_state state machine to free
65  * This function frees tdd_state tdd.
66  */
67 void tdd_free(struct tdd_state *tdd);
68 
69 /*! Generate Echo Canceller disable tone (2100HZ)
70  * \param outbuf This is the buffer to receive the tone data
71  * \param len This is the length (in samples) of the tone data to generate
72  * Returns 0 if no error, and -1 if error.
73  */
74 int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len);
75 
76 
77 /*! Generate hold tone
78  * \param outbuf This is the buffer to receive the tone data
79 */
80 int tdd_gen_holdtone(unsigned char* outbuf);
81 
82 #endif /* _ASTERISK_TDD_H */
void tdd_init(void)
Definition: tdd.c:94
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int tdd_gen_holdtone(unsigned char *outbuf)
Definition: tdd.c:286
int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len)
Definition: tdd.c:148
struct tdd_state * tdd_new(void)
Definition: tdd.c:103
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Definition: tdd.c:47
int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *string)
Definition: tdd.c:297
void tdd_free(struct tdd_state *tdd)
Definition: tdd.c:218
int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples)
Definition: tdd.c:161