say.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 Say numbers and dates (maybe words one day too)
  20. */
  21. #ifndef _ASTERISK_SAY_H
  22. #define _ASTERISK_SAY_H
  23. #include "asterisk/channel.h"
  24. #include "asterisk/file.h"
  25. #include <time.h>
  26. #if defined(__cplusplus) || defined(c_plusplus)
  27. extern "C" {
  28. #endif
  29. /*! \brief
  30. * The basic ast_say_* functions are implemented as function pointers,
  31. * initialized to the function say_stub() which simply returns an error.
  32. * Other interfaces, declared here as regular functions, are simply
  33. * wrappers around the basic functions.
  34. *
  35. * An implementation of the basic ast_say functions (e.g. from say.c or from
  36. * a dynamically loaded module) will just have to reassign the pointers
  37. * to the relevant functions to override the previous implementation.
  38. *
  39. * \todo XXX
  40. * As the conversion from the old implementation of say.c to the new
  41. * implementation will be completed, and the API suitably reworked by
  42. * removing redundant functions and/or arguments, this mechanism may be
  43. * reverted back to pure static functions, if needed.
  44. */
  45. #if defined(SAY_STUBS)
  46. /* provide declarations for the *say*() functions
  47. * and initialize them to the stub function
  48. */
  49. static int say_stub(struct ast_channel *chan, ...)
  50. {
  51. ast_log(LOG_WARNING, "no implementation for the say() functions\n");
  52. return -1;
  53. };
  54. #undef SAY_STUBS
  55. #define SAY_INIT(x) = (typeof (x))say_stub
  56. #define SAY_EXTERN
  57. #else
  58. #define SAY_INIT(x)
  59. #define SAY_EXTERN extern
  60. #endif
  61. /*!
  62. * \brief says a number
  63. * \param chan channel to say them number on
  64. * \param num number to say on the channel
  65. * \param ints which dtmf to interrupt on
  66. * \param lang language to speak the number
  67. * \param options set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural
  68. * \details
  69. * Vocally says a number on a given channel
  70. * \retval 0 on success
  71. * \retval DTMF digit on interrupt
  72. * \retval -1 on failure
  73. */
  74. int ast_say_number(struct ast_channel *chan, int num,
  75. const char *ints, const char *lang, const char *options);
  76. /*! \brief Same as \ref ast_say_number() with audiofd for received audio and returns 1 on ctrlfd being readable */
  77. SAY_EXTERN int (* ast_say_number_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_number_full);
  78. /*!
  79. * \brief says an enumeration
  80. * \param chan channel to say them enumeration on
  81. * \param num number to say on the channel
  82. * \param ints which dtmf to interrupt on
  83. * \param lang language to speak the enumeration
  84. * \param options set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural
  85. * \details
  86. * Vocally says an enumeration on a given channel (first, sencond, third, forth, thirtyfirst, hundredth, ....)
  87. * Especially useful for dates and messages. Says 'last' if num equals to INT_MAX
  88. * \retval 0 on success
  89. * \retval DTMF digit on interrupt
  90. * \retval -1 on failure
  91. */
  92. int ast_say_enumeration(struct ast_channel *chan, int num,
  93. const char *ints, const char *lang, const char *options);
  94. /*! \brief Same as \ref ast_say_enumeration() with audiofd for received audio and returns 1 on ctrlfd being readable */
  95. SAY_EXTERN int (* ast_say_enumeration_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_enumeration_full);
  96. /*!
  97. * \brief says digits
  98. * \param chan channel to act upon
  99. * \param num number to speak
  100. * \param ints which dtmf to interrupt on
  101. * \param lang language to speak
  102. * \details
  103. * Vocally says digits of a given number
  104. * \retval 0 on success
  105. * \retval DTMF if interrupted
  106. * \retval -1 on failure
  107. */
  108. int ast_say_digits(struct ast_channel *chan, int num,
  109. const char *ints, const char *lang);
  110. /*! \brief Same as \ref ast_say_digits() with audiofd for received audio and returns 1 on ctrlfd being readable */
  111. int ast_say_digits_full(struct ast_channel *chan, int num,
  112. const char *ints, const char *lang, int audiofd, int ctrlfd);
  113. /*!
  114. * \brief says digits of a string
  115. * \param chan channel to act upon
  116. * \param num string to speak
  117. * \param ints which dtmf to interrupt on
  118. * \param lang language to speak in
  119. * \details
  120. * Vocally says the digits of a given string
  121. * \retval 0 on succes
  122. * \retval DTMF if interrupted
  123. * \retval -1 on failure
  124. */
  125. int ast_say_digit_str(struct ast_channel *chan, const char *num,
  126. const char *ints, const char *lang);
  127. /*! \brief Same as \ref ast_say_digit_str() with audiofd for received audio and returns 1 on ctrlfd being readable */
  128. SAY_EXTERN int (* ast_say_digit_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_digit_str_full);
  129. /*! \brief
  130. * the generic 'say' routine, with the first chars in the string
  131. * defining the format to use
  132. */
  133. SAY_EXTERN int (* ast_say_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_full);
  134. /*!
  135. * \brief Controls how ast_say_character_str denotes the case of characters in a string
  136. */
  137. enum ast_say_case_sensitivity {
  138. AST_SAY_CASE_NONE, /*!< Do not distinguish case on any letters */
  139. AST_SAY_CASE_LOWER, /*!< Denote case only on lower case letters, upper case is assumed otherwise */
  140. AST_SAY_CASE_UPPER, /*!< Denote case only on upper case letters, lower case is assumed otherwise */
  141. AST_SAY_CASE_ALL, /*!< Denote case on all letters, upper and lower */
  142. };
  143. /*! \brief
  144. * function to pronounce character and phonetic strings
  145. */
  146. int ast_say_character_str(struct ast_channel *chan, const char *num,
  147. const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity);
  148. SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full);
  149. int ast_say_phonetic_str(struct ast_channel *chan, const char *num,
  150. const char *ints, const char *lang);
  151. SAY_EXTERN int (* ast_say_phonetic_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_phonetic_str_full);
  152. SAY_EXTERN int (* ast_say_datetime)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime);
  153. SAY_EXTERN int (* ast_say_time)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_time);
  154. SAY_EXTERN int (* ast_say_date)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_date);
  155. SAY_EXTERN int (* ast_say_datetime_from_now)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime_from_now);
  156. SAY_EXTERN int (* ast_say_date_with_format)(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *timezone) SAY_INIT(ast_say_date_with_format);
  157. int ast_say_counted_noun(struct ast_channel *chan, int num, const char *noun);
  158. int ast_say_counted_adjective(struct ast_channel *chan, int num, const char *adjective, const char *gender);
  159. #if defined(__cplusplus) || defined(c_plusplus)
  160. }
  161. #endif
  162. #endif /* _ASTERISK_SAY_H */