00001 /* 00002 * Asterisk -- A telephony toolkit for Linux. 00003 * 00004 * TTY/TDD Generation support 00005 * 00006 * Copyright (C) 1999, Mark Spencer 00007 * 00008 * Mark Spencer <markster@linux-support.net> 00009 * 00010 * This program is free software, distributed under the terms of 00011 * the GNU General Public License. 00012 * 00013 * Includes code and algorithms from the Zapata library. 00014 * 00015 */ 00016 00017 #ifndef _TDD_H 00018 #define _TDD_H 00019 00020 #define TDD_BYTES_PER_CHAR 2700 00021 00022 struct tdd_state; 00023 typedef struct tdd_state TDDSTATE; 00024 00025 //! CallerID Initialization 00026 /*! 00027 * Initializes the TDD system. Mostly stuff for inverse FFT 00028 */ 00029 extern void tdd_init(void); 00030 00031 //! Generates a CallerID FSK stream in ulaw format suitable for transmission. 00032 /*! 00033 * \param buf Buffer to use. This needs to be large enough to accomodate all the generated samples. 00034 * \param string This is the string to send. 00035 * This function creates a stream of TDD data in ulaw format. It returns the size 00036 * (in bytes) of the data (if it returns a size of 0, there is probably an error) 00037 */ 00038 extern int tdd_generate(struct tdd_state *tdd, unsigned char *buf, char *string); 00039 00040 //! Create a TDD state machine 00041 /*! 00042 * This function returns a malloc'd instance of the tdd_state data structure. 00043 * Returns a pointer to a malloc'd tdd_state structure, or NULL on error. 00044 */ 00045 extern struct tdd_state *tdd_new(void); 00046 00047 //! Read samples into the state machine, and return character (if any). 00048 /*! 00049 * \param tdd Which state machine to act upon 00050 * \param buffer containing your samples 00051 * \param samples number of samples contained within the buffer. 00052 * 00053 * Send received audio to the TDD demodulator. 00054 * Returns -1 on error, 0 for "needs more samples", 00055 * and > 0 (the character) if reception of a character is complete. 00056 */ 00057 extern int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples); 00058 00059 //! Free a TDD state machine 00060 /*! 00061 * \param tdd This is the tdd_state state machine to free 00062 * This function frees tdd_state tdd. 00063 */ 00064 extern void tdd_free(struct tdd_state *tdd); 00065 00066 //! Generate Echo Canceller diable tone (2100HZ) 00067 /*! 00068 * \param outbuf This is the buffer to receive the tone data 00069 * \param len This is the length (in samples) of the tone data to generate 00070 * Returns 0 if no error, and -1 if error. 00071 */ 00072 extern int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len); 00073 00074 #endif