func_sayfiles: Retrieve say file names

Up until now, all of the logic used to translate
arguments to the Say applications has been
directly coupled to playback, preventing other
modules from using this logic.

This refactors code in say.c and adds a SAYFILES
function that can be used to retrieve the file
names that would be played. These can then be
used in other applications or for other purposes.

Additionally, a SayMoney application and a SayOrdinal
application are added. Both SayOrdinal and SayNumber
are also expanded to support integers greater than
one billion.

ASTERISK-29531

Change-Id: If9718c89353b8e153d84add3cc4637b79585db19
This commit is contained in:
Naveen Albert
2021-07-26 17:46:44 +00:00
committed by George Joseph
parent 698604a064
commit 11516e4b8e
6 changed files with 1056 additions and 95 deletions

View File

@@ -85,6 +85,25 @@ int ast_say_number(struct ast_channel *chan, int num,
/*! \brief Same as \ref ast_say_number() with audiofd for received audio and returns 1 on ctrlfd being readable */
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);
/*!
* \brief says an ordinal number
* \param chan channel to say them number on
* \param num ordinal number to say on the channel
* \param ints which dtmf to interrupt on
* \param lang language to speak the number
* \param options set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter
* \details
* Vocally says an ordinal number on a given channel
* \retval 0 on success
* \retval DTMF digit on interrupt
* \retval -1 on failure
*/
int ast_say_ordinal(struct ast_channel *chan, int num,
const char *ints, const char *lang, const char *options);
/*! \brief Same as \ref ast_say_number() with audiofd for received audio and returns 1 on ctrlfd being readable */
SAY_EXTERN int (* ast_say_ordinal_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_ordinal_full);
/*!
* \brief says an enumeration
* \param chan channel to say them enumeration on
@@ -142,6 +161,14 @@ int ast_say_digit_str(struct ast_channel *chan, const char *num,
/*! \brief Same as \ref ast_say_digit_str() with audiofd for received audio and returns 1 on ctrlfd being readable */
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);
/*! \brief
* function to pronounce monetary amounts
*/
int ast_say_money_str(struct ast_channel *chan, const char *num,
const char *ints, const char *lang);
SAY_EXTERN int (* ast_say_money_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_money_str_full);
/*! \brief
* the generic 'say' routine, with the first chars in the string
* defining the format to use
@@ -184,6 +211,79 @@ int ast_say_counted_noun(struct ast_channel *chan, int num, const char *noun);
int ast_say_counted_adjective(struct ast_channel *chan, int num, const char *adjective, const char *gender);
/*!
* \brief Returns an ast_str of files for SayAlpha playback.
*
* \param str Text to be translated to the corresponding audio files.
* \param lang Channel language
* \param sensitivity Case sensitivity
*
* Computes the list of files to be played by SayAlpha.
*
* \retval ampersand-separated string of Asterisk sound files that can be played back.
*/
struct ast_str* ast_get_character_str(const char *str, const char *lang, enum ast_say_case_sensitivity sensitivity);
/*!
* \brief Returns an ast_str of files for SayPhonetic playback.
*
* \param str Text to be translated to the corresponding audio files.
* \param lang Channel language
*
* Computes the list of files to be played by SayPhonetic.
*
* \retval ampersand-separated string of Asterisk sound files that can be played back.
*/
struct ast_str* ast_get_phonetic_str(const char *str, const char *lang);
/*!
* \brief Returns an ast_str of files for SayDigits playback.
*
* \param str Text to be translated to the corresponding audio files.
* \param lang Channel language
*
* Computes the list of files to be played by SayDigits.
*
* \retval ampersand-separated string of Asterisk sound files that can be played back.
*/
struct ast_str* ast_get_digit_str(const char *str, const char *lang);
/*!
* \brief Returns an ast_str of files for SayMoney playback.
*
* \param str Text to be translated to the corresponding audio files.
* \param lang Channel language
*
* Computes the list of files to be played by SayMoney.
*
* \retval ampersand-separated string of Asterisk sound files that can be played back.
*/
struct ast_str* ast_get_money_str(const char *str, const char *lang);
/*!
* \brief Returns an ast_str of files for SayNumber playback.
*
* \param num Integer to be translated to the corresponding audio files.
* \param lang Channel language
*
* Computes the list of files to be played by SayNumber.
*
* \retval ampersand-separated string of Asterisk sound files that can be played back.
*/
struct ast_str* ast_get_number_str(int num, const char *lang);
/*!
* \brief Returns an ast_str of files for SayOrdinal playback.
*
* \param num Integer to be translated to the corresponding audio files.
* \param lang Channel language
*
* Computes the list of files to be played by SayOrdinal.
*
* \retval ampersand-separated string of Asterisk sound files that can be played back.
*/
struct ast_str* ast_get_ordinal_str(int num, const char *lang);
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif