Version 0.1.10 from FTP
authorMark Spencer <markster@digium.com>
Sat, 10 Nov 2001 20:31:39 +0000 (20:31 +0000)
committerMark Spencer <markster@digium.com>
Sat, 10 Nov 2001 20:31:39 +0000 (20:31 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/gentone-ulaw.c [new file with mode: 0755]
channels/gentone.c
ecdisa.h [new file with mode: 0755]
fskmodem.c
include/asterisk/frame.h
include/asterisk/tdd.h [new file with mode: 0755]

diff --git a/channels/gentone-ulaw.c b/channels/gentone-ulaw.c
new file mode 100755 (executable)
index 0000000..b290d76
--- /dev/null
@@ -0,0 +1,157 @@
+/* Generate a header file for a particular 
+   single or double frequency */
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#define CLIP 32635
+#define BIAS 0x84
+static float loudness=16384.0;
+
+static int calc_samples(int freq)
+{
+       int x, samples;
+       /* Calculate the number of samples at 8000hz sampling
+          we need to have this wave form */
+       samples = 8000;
+       /* Take out common 2's up to six times */
+       for (x=0;x<6;x++) 
+               if (!(freq % 2)) {
+                       freq /= 2;
+                       samples /= 2;
+               }
+       /* Take out common 5's (up to three times */
+       for (x=0;x<3;x++) 
+               if (!(freq % 5)) {
+                       freq /= 5;
+                       samples /=5;
+               }
+       /* No more common factors. */
+       return samples;
+}
+
+/*
+** This routine converts from linear to ulaw
+**
+** Craig Reese: IDA/Supercomputing Research Center
+** Joe Campbell: Department of Defense
+** 29 September 1989
+**
+** References:
+** 1) CCITT Recommendation G.711  (very difficult to follow)
+** 2) "A New Digital Technique for Implementation of Any
+**     Continuous PCM Companding Law," Villeret, Michel,
+**     et al. 1973 IEEE Int. Conf. on Communications, Vol 1,
+**     1973, pg. 11.12-11.17
+** 3) MIL-STD-188-113,"Interoperability and Performance Standards
+**     for Analog-to_Digital Conversion Techniques,"
+**     17 February 1987
+**
+** Input: Signed 16 bit linear sample
+** Output: 8 bit ulaw sample
+*/
+
+#define ZEROTRAP    /* turn on the trap as per the MIL-STD */
+#define BIAS 0x84   /* define the add-in bias for 16 bit samples */
+#define CLIP 32635
+
+static unsigned char linear2ulaw(short sample) {
+static int exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
+                             4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+                             5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+                             5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+                             6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+                             6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+                             6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+                             6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+                             7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+                             7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+                             7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+                             7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+                             7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+                             7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+                             7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+                             7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
+  int sign, exponent, mantissa;
+  unsigned char ulawbyte;
+
+  /* Get the sample into sign-magnitude. */
+  sign = (sample >> 8) & 0x80;          /* set aside the sign */
+  if (sign != 0) sample = -sample;              /* get magnitude */
+  if (sample > CLIP) sample = CLIP;             /* clip the magnitude */
+
+  /* Convert from 16 bit linear to ulaw. */
+  sample = sample + BIAS;
+  exponent = exp_lut[(sample >> 7) & 0xFF];
+  mantissa = (sample >> (exponent + 3)) & 0x0F;
+  ulawbyte = ~(sign | (exponent << 4) | mantissa);
+#ifdef ZEROTRAP
+  if (ulawbyte == 0) ulawbyte = 0x02;   /* optional CCITT trap */
+#endif
+
+  return(ulawbyte);
+}
+
+int main(int argc, char *argv[])
+{
+       FILE *f;
+       int freq1, freq2;
+       float wlen1, wlen2;
+       float val;
+       int x, samples1, samples2, samples=0;
+       char fn[256];
+       if (argc < 3) {
+               fprintf(stderr, "Usage: gensound <name> <freq1> [freq2]\n");
+               exit(1);
+       }
+       freq1 = atoi(argv[2]);
+       if (argc > 3) 
+               freq2 = atoi(argv[3]);
+       else
+               freq2 = 0;
+       wlen1 = 8000.0/(float)freq1;
+       samples1 = calc_samples(freq1);
+       printf("Wavelength 1 (in samples): %10.5f\n", wlen1);
+       printf("Minimum samples (1): %d (%f.3 wavelengths)\n", samples1, samples1 / wlen1);
+       if (freq2) {
+               wlen2 = 8000.0/(float)freq2;
+               samples2 = calc_samples(freq2);
+               printf("Wavelength 1 (in samples): %10.5f\n", wlen2);
+               printf("Minimum samples (1): %d (%f.3 wavelengths)\n", samples2, samples2 / wlen2);
+       }
+       samples = samples1;
+       if (freq2) {
+               while(samples % samples2)
+                       samples += samples1;
+       }
+       printf("Need %d samples\n", samples);
+       snprintf(fn, sizeof(fn), "%s.h", argv[1]);
+       if ((f = fopen(fn, "w"))) {
+               if (freq2) 
+                       fprintf(f, "/* %s: Generated from frequencies %d and %d \n"
+                                  "   by gentone.  %d samples  */\n", fn, freq1, freq2, samples); 
+               else
+                       fprintf(f, "/* %s: Generated from frequency %d\n"
+                                  "   by gentone.  %d samples  */\n", fn, freq1, samples); 
+               fprintf(f, "static unsigned char %s[%d] = {\n\t", argv[1], samples);
+               for (x=0;x<samples;x++) {
+                       val = loudness * sin((freq1 * 2.0 * M_PI * x)/8000.0);
+                       if (freq2)
+                               val += loudness * sin((freq2 * 2.0 * M_PI * x)/8000.0);
+                       fprintf(f, "%3d, ", (int) linear2ulaw(val));
+                       if (!((x+1) % 8)) 
+                               fprintf(f, "\n\t");
+               }
+               if (x % 15)
+                       fprintf(f, "\n");
+               fprintf(f, "};\n");
+               fclose(f);
+               printf("Wrote %s\n", fn);
+       } else {
+               fprintf(stderr, "Unable to open %s for writing\n", fn);
+               return 1;
+       }
+       return 0;
+}   
index 00f5af1..530db0e 100755 (executable)
@@ -69,10 +69,10 @@ int main(int argc, char *argv[])
        if ((f = fopen(fn, "w"))) {
                if (freq2) 
                        fprintf(f, "/* %s: Generated from frequencies %d and %d \n"
-                                  "   by gensound.  %d samples  */\n", fn, freq1, freq2, samples); 
+                                  "   by gentone.  %d samples  */\n", fn, freq1, freq2, samples); 
                else
                        fprintf(f, "/* %s: Generated from frequency %d\n"
-                                  "   by gensound.  %d samples  */\n", fn, freq1, samples); 
+                                  "   by gentone.  %d samples  */\n", fn, freq1, samples); 
                fprintf(f, "static short %s[%d] = {\n\t", argv[1], samples);
                for (x=0;x<samples;x++) {
                        val = loudness * sin((freq1 * 2.0 * M_PI * x)/8000.0);
diff --git a/ecdisa.h b/ecdisa.h
new file mode 100755 (executable)
index 0000000..df6f773
--- /dev/null
+++ b/ecdisa.h
@@ -0,0 +1,15 @@
+/* ecdisa.h: Generated from frequency 2100
+   by gentone.  80 samples  */
+static unsigned char ecdisa[80] = {
+       255, 143,  58,  16, 171, 146,  34,  20, 
+       156, 151,  25,  26, 149, 159,  19,  38, 
+       145, 177,  16,  73, 143,  73,  16, 177, 
+       145,  38,  19, 159, 149,  26,  25, 151, 
+       156,  20,  34, 146, 171,  16,  58, 143, 
+       255,  15, 186, 144,  43,  18, 162, 148, 
+        28,  23, 153, 154,  21,  31, 147, 166, 
+        17,  49, 144, 201,  15, 201, 144,  49, 
+        17, 166, 147,  31,  21, 154, 153,  23, 
+        28, 148, 162,  18,  43, 144, 186,  15, 
+       
+};
index 554bb94..6d45bde 100755 (executable)
@@ -234,10 +234,15 @@ search_startbit3:
 
 getbyte:
 
-       /* Need at least 80 samples to be sure we'll have a byte */
-       if (*len < 80)
-               return 0;
-
+       /* Need at least 80 samples (for 1200) or
+               1320 (for 45.5) to be sure we'll have a byte */
+       if (fskd->nbit < 8) {
+               if (*len < 1320)
+                       return 0;
+       } else {
+               if (*len < 80)
+                       return 0;
+       }
        /* Leemos ahora los bits de datos */
        j=fskd->nbit;
        for (a=n1=0;j;j--) {
index 536f83c..44e1c30 100755 (executable)
@@ -23,20 +23,30 @@ extern "C" {
 #include <endian.h>
 #include <sys/types.h>
 
+//! Data structure associated with a single frame of data
 /* A frame of data read used to communicate between 
    between channels and applications */
 struct ast_frame {
-       int frametype;                          /* Kind of frame */
-       int subclass;                           /* Subclass, frame dependent */
-       int datalen;                            /* Length of data */
-       int timelen;                            /* Amount of time associated with this frame */
-       int mallocd;                            /* Was the data malloc'd?  i.e. should we
-                                                                  free it when we discard the frame? */
-       int offset;                                     /* How far into "data" the data really starts */
-       char *src;                                      /* Optional source of frame for debugging */
-       void *data;                                     /* Pointer to actual data */
-       struct ast_frame *prev;         /* Next/Prev for linking stand alone frames */
-       struct ast_frame *next;         /* Next/Prev for linking stand alone frames */
+       /*! Kind of frame */
+       int frametype;                          
+       /*! Subclass, frame dependent */
+       int subclass;                           
+       /*! Length of data */
+       int datalen;                            
+       /*! Amount of time associated with this frame */
+       int timelen;                            
+       /*! Was the data malloc'd?  i.e. should we free it when we discard the frame? */
+       int mallocd;                            
+       /*! How far into "data" the data really starts */
+       int offset;                             
+       /*! Optional source of frame for debugging */
+       char *src;                              
+       /*! Pointer to actual data */
+       void *data;                             
+       /*! Next/Prev for linking stand alone frames */
+       struct ast_frame *prev;                 
+       /*! Next/Prev for linking stand alone frames */
+       struct ast_frame *next;                 
                                                                /* Unused except if debugging is turned on, but left
                                                                   in the struct so that it can be turned on without
                                                                   requiring a recompile of the whole thing */
@@ -48,63 +58,109 @@ struct ast_frame_chain {
        struct ast_frame_chain *next;
 };
 
-#define AST_FRIENDLY_OFFSET    64              /* It's polite for a a new frame to
+#define AST_FRIENDLY_OFFSET    64              /*! It's polite for a a new frame to
                                                                                   have at least this number of bytes
                                                                                   of offset before your real frame data
                                                                                   so that additional headers can be
                                                                                   added. */
-
-#define AST_MALLOCD_HDR                (1 << 0)        /* Need the header be free'd? */
-#define AST_MALLOCD_DATA       (1 << 1)        /* Need the data be free'd? */
-#define AST_MALLOCD_SRC                (1 << 2)        /* Need the source be free'd? (haha!) */
+/*! Need the header be free'd? */
+#define AST_MALLOCD_HDR                (1 << 0)
+/*! Need the data be free'd? */
+#define AST_MALLOCD_DATA       (1 << 1)
+/*! Need the source be free'd? (haha!) */
+#define AST_MALLOCD_SRC                (1 << 2)
 
 /* Frame types */
-#define AST_FRAME_DTMF         1               /* A DTMF digit, subclass is the digit */
-#define AST_FRAME_VOICE                2               /* Voice data, subclass is AST_FORMAT_* */
-#define AST_FRAME_VIDEO                3               /* Video frame, maybe?? :) */
-#define AST_FRAME_CONTROL      4               /* A control frame, subclass is AST_CONTROL_* */
-#define AST_FRAME_NULL         5               /* An empty, useless frame */
-#define AST_FRAME_IAX          6               /* Inter Aterisk Exchange private frame type */
-#define AST_FRAME_TEXT         7               /* Text messages */
-#define AST_FRAME_IMAGE                8               /* Image Frames */
-#define AST_FRAME_HTML         9               /* HTML Frame */
+/*! A DTMF digit, subclass is the digit */
+#define AST_FRAME_DTMF         1
+/*! Voice data, subclass is AST_FORMAT_* */
+#define AST_FRAME_VOICE                2
+/*! Video frame, maybe?? :) */
+#define AST_FRAME_VIDEO                3
+/*! A control frame, subclass is AST_CONTROL_* */
+#define AST_FRAME_CONTROL      4
+/*! An empty, useless frame */
+#define AST_FRAME_NULL         5
+/*! Inter Aterisk Exchange private frame type */
+#define AST_FRAME_IAX          6
+/*! Text messages */
+#define AST_FRAME_TEXT         7
+/*! Image Frames */
+#define AST_FRAME_IMAGE                8
+/*! HTML Frame */
+#define AST_FRAME_HTML         9
 
 /* HTML subclasses */
-#define AST_HTML_URL           1               /* Sending a URL */
-#define AST_HTML_DATA          2               /* Data frame */
-#define AST_HTML_BEGIN         4               /* Beginning frame */
-#define AST_HTML_END           8               /* End frame */
-#define AST_HTML_LDCOMPLETE    16              /* Load is complete */
-#define AST_HTML_NOSUPPORT     17              /* Peer is unable to support HTML */
-#define AST_HTML_LINKURL       18              /* Send URL, and track */
+/*! Sending a URL */
+#define AST_HTML_URL           1
+/*! Data frame */
+#define AST_HTML_DATA          2
+/*! Beginning frame */
+#define AST_HTML_BEGIN         4
+/*! End frame */
+#define AST_HTML_END           8
+/*! Load is complete */
+#define AST_HTML_LDCOMPLETE    16
+/*! Peer is unable to support HTML */
+#define AST_HTML_NOSUPPORT     17
+/*! Send URL, and track */
+#define AST_HTML_LINKURL       18
+/*! No more HTML linkage */
+#define AST_HTML_UNLINK                19
+/*! Reject link request */
+#define AST_HTML_LINKREJECT    20
 
 /* Data formats for capabilities and frames alike */
-#define AST_FORMAT_G723_1      (1 << 0)        /* G.723.1 compression */
-#define AST_FORMAT_GSM         (1 << 1)        /* GSM compression */
-#define AST_FORMAT_ULAW                (1 << 2)        /* Raw mu-law data (G.711) */
-#define AST_FORMAT_ALAW                (1 << 3)        /* Raw A-law data (G.711) */
-#define AST_FORMAT_MP3         (1 << 4)        /* MPEG-2 layer 3 */
-#define AST_FORMAT_ADPCM       (1 << 5)        /* ADPCM (whose?) */
-#define AST_FORMAT_SLINEAR     (1 << 6)        /* Raw 16-bit Signed Linear (8000 Hz) PCM */
-#define AST_FORMAT_LPC10       (1 << 7)        /* LPC10, 180 samples/frame */
-#define AST_FORMAT_MAX_AUDIO (1 << 15) /* Maximum audio format */
-#define AST_FORMAT_JPEG                (1 << 16)       /* JPEG Images */
-#define AST_FORMAT_PNG         (1 << 17)       /* PNG Images */
-#define AST_FORMAT_H261                (1 << 18)       /* H.261 Video */
-#define AST_FORMAT_H263                (1 << 19)       /* H.263 Video */
+/*! G.723.1 compression */
+#define AST_FORMAT_G723_1      (1 << 0)
+/*! GSM compression */
+#define AST_FORMAT_GSM         (1 << 1)
+/*! Raw mu-law data (G.711) */
+#define AST_FORMAT_ULAW                (1 << 2)
+/*! Raw A-law data (G.711) */
+#define AST_FORMAT_ALAW                (1 << 3)
+/*! MPEG-2 layer 3 */
+#define AST_FORMAT_MP3         (1 << 4)
+/*! ADPCM (whose?) */
+#define AST_FORMAT_ADPCM       (1 << 5)
+/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
+#define AST_FORMAT_SLINEAR     (1 << 6)
+/*! LPC10, 180 samples/frame */
+#define AST_FORMAT_LPC10       (1 << 7)
+/*! Maximum audio format */
+#define AST_FORMAT_MAX_AUDIO   (1 << 15)
+/*! JPEG Images */
+#define AST_FORMAT_JPEG                (1 << 16)
+/*! PNG Images */
+#define AST_FORMAT_PNG         (1 << 17)
+/*! H.261 Video */
+#define AST_FORMAT_H261                (1 << 18)
+/*! H.263 Video */
+#define AST_FORMAT_H263                (1 << 19)
 
 /* Control frame types */
-#define AST_CONTROL_HANGUP             1                       /* Other end has hungup */
-#define AST_CONTROL_RING               2                       /* Local ring */
-#define AST_CONTROL_RINGING    3                       /* Remote end is ringing */
-#define AST_CONTROL_ANSWER             4                       /* Remote end has answered */
-#define AST_CONTROL_BUSY               5                       /* Remote end is busy */
-#define AST_CONTROL_TAKEOFFHOOK 6                      /* Make it go off hook */
-#define AST_CONTROL_OFFHOOK            7                       /* Line is off hook */
-#define AST_CONTROL_CONGESTION 8                       /* Congestion (circuits busy) */
-#define AST_CONTROL_FLASH              9                       /* Flash hook */
-#define AST_CONTROL_WINK               10                      /* Wink */
-#define AST_CONTROL_OPTION             11                      /* Set a low-level option */
+/*! Other end has hungup */
+#define AST_CONTROL_HANGUP             1
+/*! Local ring */
+#define AST_CONTROL_RING               2
+/*! Remote end is ringing */
+#define AST_CONTROL_RINGING            3
+/*! Remote end has answered */
+#define AST_CONTROL_ANSWER             4
+/*! Remote end is busy */
+#define AST_CONTROL_BUSY               5
+/*! Make it go off hook */
+#define AST_CONTROL_TAKEOFFHOOK                6
+/*! Line is off hook */
+#define AST_CONTROL_OFFHOOK            7
+/*! Congestion (circuits busy) */
+#define AST_CONTROL_CONGESTION         8
+/*! Flash hook */
+#define AST_CONTROL_FLASH              9
+/*! Wink */
+#define AST_CONTROL_WINK               10
+/*! Set a low-level option */
+#define AST_CONTROL_OPTION             11
 
 /* Option identifiers and flags */
 #define AST_OPTION_FLAG_REQUEST                0
@@ -112,11 +168,14 @@ struct ast_frame_chain {
 #define AST_OPTION_FLAG_REJECT         2
 #define AST_OPTION_FLAG_QUERY          4
 #define AST_OPTION_FLAG_ANSWER         5
-#define AST_OPTION_FLAG_WTF                    6
+#define AST_OPTION_FLAG_WTF            6
+
+/* Verify touchtones by muting audio transmission 
+       (and reception) and verify the tone is still present */
+#define AST_OPTION_TONE_VERIFY         1               
 
-#define AST_OPTION_TONE_VERIFY         1               /* Verify touchtones by muting audio
-                                                                                          transmission (and reception) and
-                                                                                          verify the tone is still present */
+/* Put a compatible channel into TDD (TTY for the hearing-impared) mode */
+#define        AST_OPTION_TDD                  2
 
 struct ast_option_header {
        /* Always keep in network byte order */
@@ -134,37 +193,82 @@ struct ast_option_header {
                u_int8_t data[0];
 };
 
-/* Request a frame be allocated.  source is an optional source of the frame, 
-   len is the requested length, or "0" if the caller will supply the buffer */
+// Requests a frame to be allocated
+/* 
+ * \param source 
+ * Request a frame be allocated.  source is an optional source of the frame, 
+ * len is the requested length, or "0" if the caller will supply the buffer 
+ */
+#if 0 /* Unimplemented */
 struct ast_frame *ast_fralloc(char *source, int len);
+#endif
 
-/* Free a frame, and the memory it used if applicable */
+//! Frees a frame
+/*! 
+ * \param fr Frame to free
+ * Free a frame, and the memory it used if applicable
+ * no return.
+ */
 void ast_frfree(struct ast_frame *fr);
 
-/* Take a frame, and if it's not been malloc'd, make a malloc'd copy
-   and if the data hasn't been malloced then make the
-   data malloc'd.  If you need to store frames, say for queueing, then
-   you should call this function. */
+//! Copies a frame
+/*! 
+ * \param fr frame to act upon
+ * Take a frame, and if it's not been malloc'd, make a malloc'd copy
+ * and if the data hasn't been malloced then make the
+ * data malloc'd.  If you need to store frames, say for queueing, then
+ * you should call this function.
+ * Returns a frame on success, NULL on error
+ */
 struct ast_frame *ast_frisolate(struct ast_frame *fr);
 
-/* Dupliates a frame -- should only rarely be used, typically frisolate is
-   good enough */
+//! Copies a frame
+/*! 
+ * \param fr frame to copy
+ * Dupliates a frame -- should only rarely be used, typically frisolate is good enough
+ * Returns a frame on success, NULL on error
+ */
 struct ast_frame *ast_frdup(struct ast_frame *fr);
 
+//! Chains a frame -- unimplemented
+#if 0 /* unimplemented */
 void ast_frchain(struct ast_frame_chain *fc);
+#endif
 
-/* Read a frame from a stream or packet fd, as written by fd_write */
+//! Reads a frame from an fd
+/*! 
+ * \param fd an opened fd to read from
+ * Read a frame from a stream or packet fd, as written by fd_write
+ * returns a frame on success, NULL on error
+ */
 struct ast_frame *ast_fr_fdread(int fd);
 
-/* Write a frame to an fd */
+//! Writes a frame to an fd
+/*! 
+ * \param fd Which fd to write to
+ * \param frame frame to write to the fd
+ * Write a frame to an fd
+ * Returns 0 on success, -1 on failure
+ */
 int ast_fr_fdwrite(int fd, struct ast_frame *frame);
 
-/* Send a hangup (NULL equivalent) on an fd */
+//! Sends a hangup to an fd
+/*! 
+ * \param fd fd to write to
+ * Send a hangup (NULL equivalent) on an fd
+ * Returns 0 on success, -1 on failure
+ */
 int ast_fr_fdhangup(int fd);
 
-/* Get a format by its name */
+//! Get a format from a name
+/*!
+ * \param name string of format
+ * Gets a format from a name.
+ * This returns the form of the format in binary on success, 0 on error.
+ */
 extern int ast_getformatbyname(char *name);
 
+//! Pick the best codec 
 /* Choose the best codec...  Uhhh...   Yah. */
 extern int ast_best_codec(int fmts);
 
diff --git a/include/asterisk/tdd.h b/include/asterisk/tdd.h
new file mode 100755 (executable)
index 0000000..4ee057f
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * TTY/TDD Generation support 
+ * 
+ * Copyright (C) 1999, Mark Spencer
+ *
+ * Mark Spencer <markster@linux-support.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License.
+ *
+ * Includes code and algorithms from the Zapata library.
+ *
+ */
+
+#ifndef _TDD_H
+#define _TDD_H
+
+#define        TDD_BYTES_PER_CHAR      2700
+
+struct tdd_state;
+typedef struct tdd_state TDDSTATE;
+
+//! CallerID Initialization
+/*!
+ * Initializes the TDD system.  Mostly stuff for inverse FFT
+ */
+extern void tdd_init(void);
+
+//! Generates a CallerID FSK stream in ulaw format suitable for transmission.
+/*!
+ * \param buf Buffer to use. This needs to be large enough to accomodate all the generated samples.
+ * \param string This is the string to send.
+ * This function creates a stream of TDD data in ulaw format. It returns the size
+ * (in bytes) of the data (if it returns a size of 0, there is probably an error)
+*/
+extern int tdd_generate(struct tdd_state *tdd, unsigned char *buf, char *string);
+
+//! Create a TDD state machine
+/*!
+ * This function returns a malloc'd instance of the tdd_state data structure.
+ * Returns a pointer to a malloc'd tdd_state structure, or NULL on error.
+ */
+extern struct tdd_state *tdd_new(void);
+
+//! Read samples into the state machine, and return character (if any).
+/*!
+ * \param tdd Which state machine to act upon
+ * \param buffer containing your samples
+ * \param samples number of samples contained within the buffer.
+ *
+ * Send received audio to the TDD demodulator.
+ * Returns -1 on error, 0 for "needs more samples", 
+ * and > 0 (the character) if reception of a character is complete.
+ */
+extern int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples);
+
+//! Free a TDD state machine
+/*!
+ * \param tdd This is the tdd_state state machine to free
+ * This function frees tdd_state tdd.
+ */
+extern void tdd_free(struct tdd_state *tdd);
+
+//! Generate Echo Canceller diable tone (2100HZ)
+/*!
+ * \param outbuf This is the buffer to receive the tone data
+ * \param len This is the length (in samples) of the tone data to generate
+ * Returns 0 if no error, and -1 if error.
+ */
+extern int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len);
+
+#endif