tdd.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2005, Digium, Inc.
  5. *
  6. * Mark Spencer <markster@digium.com>
  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. /*! \file
  19. * \brief TTY/TDD Generation support
  20. * \note Includes code and algorithms from the Zapata library.
  21. */
  22. #ifndef _ASTERISK_TDD_H
  23. #define _ASTERISK_TDD_H
  24. #define TDD_BYTES_PER_CHAR 2700
  25. struct tdd_state;
  26. typedef struct tdd_state TDDSTATE;
  27. /*! CallerID Initialization
  28. * Initializes the TDD system. Mostly stuff for inverse FFT
  29. */
  30. void tdd_init(void);
  31. /*! Generates a CallerID FSK stream in ulaw format suitable for transmission.
  32. * \param tdd tdd structure
  33. * \param buf Buffer to use. This needs to be large enough to accomodate all the generated samples.
  34. * \param string This is the string to send.
  35. * This function creates a stream of TDD data in ulaw format. It returns the size
  36. * (in bytes) of the data (if it returns a size of 0, there is probably an error)
  37. */
  38. int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *string);
  39. /*! Create a TDD state machine
  40. * This function returns a malloc'd instance of the tdd_state data structure.
  41. * Returns a pointer to a malloc'd tdd_state structure, or NULL on error.
  42. */
  43. struct tdd_state *tdd_new(void);
  44. /*! Read samples into the state machine, and return character (if any).
  45. * \param tdd Which state machine to act upon
  46. * \param ubuf containing your samples
  47. * \param samples number of samples contained within the buffer.
  48. *
  49. * Send received audio to the TDD demodulator.
  50. * Returns -1 on error, 0 for "needs more samples",
  51. * and > 0 (the character) if reception of a character is complete.
  52. */
  53. int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples);
  54. /*! Free a TDD state machine
  55. * \param tdd This is the tdd_state state machine to free
  56. * This function frees tdd_state tdd.
  57. */
  58. void tdd_free(struct tdd_state *tdd);
  59. /*! Generate Echo Canceller disable tone (2100HZ)
  60. * \param outbuf This is the buffer to receive the tone data
  61. * \param len This is the length (in samples) of the tone data to generate
  62. * Returns 0 if no error, and -1 if error.
  63. */
  64. int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len);
  65. /*! Generate hold tone
  66. * \param outbuf This is the buffer to receive the tone data
  67. */
  68. int tdd_gen_holdtone(unsigned char* outbuf);
  69. #endif /* _ASTERISK_TDD_H */