![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
say.h
Go to the documentation of this file.
00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 1999 - 2005, Digium, Inc. 00005 * 00006 * Mark Spencer <markster@digium.com> 00007 * 00008 * See http://www.asterisk.org for more information about 00009 * the Asterisk project. Please do not directly contact 00010 * any of the maintainers of this project for assistance; 00011 * the project provides a web site, mailing lists and IRC 00012 * channels for your use. 00013 * 00014 * This program is free software, distributed under the terms of 00015 * the GNU General Public License Version 2. See the LICENSE file 00016 * at the top of the source tree. 00017 */ 00018 00019 /*! \file 00020 * \brief Say numbers and dates (maybe words one day too) 00021 */ 00022 00023 #ifndef _ASTERISK_SAY_H 00024 #define _ASTERISK_SAY_H 00025 00026 #include "asterisk/channel.h" 00027 #include "asterisk/file.h" 00028 00029 #include <time.h> 00030 00031 #if defined(__cplusplus) || defined(c_plusplus) 00032 extern "C" { 00033 #endif 00034 00035 /*! \brief 00036 * The basic ast_say_* functions are implemented as function pointers, 00037 * initialized to the function say_stub() which simply returns an error. 00038 * Other interfaces, declared here as regular functions, are simply 00039 * wrappers around the basic functions. 00040 * 00041 * An implementation of the basic ast_say functions (e.g. from say.c or from 00042 * a dynamically loaded module) will just have to reassign the pointers 00043 * to the relevant functions to override the previous implementation. 00044 * 00045 * \todo XXX 00046 * As the conversion from the old implementation of say.c to the new 00047 * implementation will be completed, and the API suitably reworked by 00048 * removing redundant functions and/or arguments, this mechanism may be 00049 * reverted back to pure static functions, if needed. 00050 */ 00051 #if defined(SAY_STUBS) 00052 /* provide declarations for the *say*() functions 00053 * and initialize them to the stub function 00054 */ 00055 static int say_stub(struct ast_channel *chan, ...) 00056 { 00057 ast_log(LOG_WARNING, "no implementation for the say() functions\n"); 00058 return -1; 00059 }; 00060 00061 #undef SAY_STUBS 00062 #define SAY_INIT(x) = (typeof (x))say_stub 00063 #define SAY_EXTERN 00064 #else 00065 #define SAY_INIT(x) 00066 #define SAY_EXTERN extern 00067 #endif 00068 00069 /* says a number 00070 * \param chan channel to say them number on 00071 * \param num number to say on the channel 00072 * \param ints which dtmf to interrupt on 00073 * \param lang language to speak the number 00074 * \param options set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural 00075 * Vocally says a number on a given channel 00076 * Returns 0 on success, DTMF digit on interrupt, -1 on failure 00077 */ 00078 int ast_say_number(struct ast_channel *chan, int num, 00079 const char *ints, const char *lang, const char *options); 00080 00081 /* Same as above with audiofd for received audio and returns 1 on ctrlfd being readable */ 00082 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); 00083 00084 /* says an enumeration 00085 * \param chan channel to say them enumeration on 00086 * \param num number to say on the channel 00087 * \param ints which dtmf to interrupt on 00088 * \param lang language to speak the enumeration 00089 * \param options set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural 00090 * Vocally says a enumeration on a given channel (first, sencond, third, forth, thirtyfirst, hundredth, ....) 00091 * especially useful for dates and messages. says 'last' if num equals to INT_MAX 00092 * Returns 0 on success, DTMF digit on interrupt, -1 on failure 00093 */ 00094 int ast_say_enumeration(struct ast_channel *chan, int num, 00095 const char *ints, const char *lang, const char *options); 00096 00097 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); 00098 00099 /* says digits 00100 * \param chan channel to act upon 00101 * \param num number to speak 00102 * \param ints which dtmf to interrupt on 00103 * \param lang language to speak 00104 * Vocally says digits of a given number 00105 * Returns 0 on success, dtmf if interrupted, -1 on failure 00106 */ 00107 int ast_say_digits(struct ast_channel *chan, int num, 00108 const char *ints, const char *lang); 00109 00110 int ast_say_digits_full(struct ast_channel *chan, int num, 00111 const char *ints, const char *lang, int audiofd, int ctrlfd); 00112 00113 /* says digits of a string 00114 * \param chan channel to act upon 00115 * \param num string to speak 00116 * \param ints which dtmf to interrupt on 00117 * \param lang language to speak in 00118 * Vocally says the digits of a given string 00119 * Returns 0 on success, dtmf if interrupted, -1 on failure 00120 */ 00121 int ast_say_digit_str(struct ast_channel *chan, const char *num, 00122 const char *ints, const char *lang); 00123 00124 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); 00125 00126 /* 00127 * the generic 'say' routine, with the first chars in the string 00128 * defining the format to use 00129 */ 00130 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); 00131 00132 /* 00133 * other function to pronounce character and phonetic strings 00134 */ 00135 int ast_say_character_str(struct ast_channel *chan, const char *num, 00136 const char *ints, const char *lang); 00137 00138 SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full); 00139 00140 int ast_say_phonetic_str(struct ast_channel *chan, const char *num, 00141 const char *ints, const char *lang); 00142 00143 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); 00144 00145 SAY_EXTERN int (* ast_say_datetime)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime); 00146 SAY_EXTERN int (* ast_say_time)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_time); 00147 00148 SAY_EXTERN int (* ast_say_date)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_date); 00149 00150 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); 00151 00152 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); 00153 00154 #if defined(__cplusplus) || defined(c_plusplus) 00155 } 00156 #endif 00157 00158 #endif /* _ASTERISK_SAY_H */