43 switch_xml_t cfg, xml = NULL, language = NULL, macros = NULL, phrases = NULL, macro, input, action;
45 const char *old_sound_prefix = NULL, *sound_path = NULL, *tts_engine = NULL, *tts_voice = NULL;
46 const char *module_name = NULL, *chan_lang = NULL;
48 uint8_t done = 0, searched = 0;
50 const char *pause_val;
52 const char *group_macro_name = NULL;
53 const char *local_macro_name = macro_name;
98 module_name = chan_lang;
101 if (!(sound_path = (
char *)
switch_xml_attr(language,
"sound-prefix"))) {
102 if (!(sound_path = (
char *)
switch_xml_attr(language,
"sound-path"))) {
107 if (!(tts_engine = (
char *)
switch_xml_attr(language,
"tts-engine"))) {
116 if (language != macros) {
119 const char *group_sound_path;
120 const char *sound_prefix_enforced_str;
122 if ((p = strchr(macro_name_dup,
'@'))) {
124 local_macro_name = macro_name_dup;
125 group_macro_name = p;
134 sound_path = group_sound_path;
149 if (sound_path && sound_prefix_enforced ==
SWITCH_FALSE) {
153 old_sound_prefix = p;
158 int tmp = atoi(pause_val);
178 char *field_expanded = NULL;
179 char *field_expanded_alloc = NULL;
181 int proceed = 0, ovector[100];
186 field = (
char *) data;
194 if (field_expanded_alloc == field) {
195 field_expanded_alloc = NULL;
196 field_expanded = field;
198 field_expanded = field_expanded_alloc;
207 if ((proceed =
switch_regex_perform(field_expanded, pattern, &re, ovector,
sizeof(ovector) /
sizeof(ovector[0])))) {
218 char *substituted = NULL;
221 char *expanded = NULL;
223 if (strchr(pattern,
'(') && strchr(adata,
'$') && proceed > 0) {
224 len = (uint32_t) (strlen(data) + strlen(adata) + 10) * proceed;
225 if (!(substituted = malloc(len))) {
231 memset(substituted, 0, len);
244 if (expanded == odata) {
253 if (!strcasecmp(func,
"play-file")) {
255 }
else if (!strcasecmp(func,
"phrase")) {
258 }
else if (!strcasecmp(func,
"break")) {
260 }
else if (!strcasecmp(func,
"execute")) {
262 char *cmd, *cmd_args;
278 }
else if (!strcasecmp(func,
"say")) {
290 status = si->
say_function(session, odata, &say_args, args);
294 }
else if (!strcasecmp(func,
"speak-text")) {
298 if (!my_tts_engine) {
299 my_tts_engine = tts_engine;
303 my_tts_voice = tts_voice;
305 if (
zstr(tts_engine) ||
zstr(tts_voice)) {
338 if (searched && !matches) {
342 if (old_sound_prefix) {
371 uint32_t org_silence_hits = 0;
373 int32_t sample_start = 0;
374 int waste_resources = 1400, fill_cng = 0;
381 int restart_limit_on_dtmf = 0;
382 const char *prefix, *var, *video_file = NULL;
415 if (fh->samples > 0) {
416 sample_start = fh->samples;
427 fh->samplerate = tmp;
441 while (*file ==
'{') {
445 while(*file ==
' ') file++;
455 if ((ext = strrchr(file,
'.'))) {
502 fh->mm.vw = vid_params.
width;
503 fh->mm.vh = vid_params.
height;
504 fh->mm.fps = vid_params.
fps;
516 if (!strcasecmp(p,
"true")) {
519 if ((fill_cng = atoi(p)) < 0) {
527 waste_resources = 1400;
540 if (!strcasecmp(p,
"true")) {
541 waste_resources = 1400;
543 if ((waste_resources = atoi(p)) < 0) {
549 if (fill_cng || waste_resources) {
564 write_frame.
codec = &write_codec;
584 memset(&vfh, 0,
sizeof(vfh));
594 memset(&vfh, 0,
sizeof(vfh));
609 if (sample_start > 0) {
677 "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate,
705 if (fh->silence_hits) {
710 org_silence_hits = fh->silence_hits;
748 if (limit && restart_limit_on_dtmf) {
752 if (!args->input_callback && !args->buf && !args->dmachine) {
758 if (args->dmachine) {
759 char ds[2] = {dtmf.
digit,
'\0'};
765 if (args->input_callback) {
767 }
else if (args->buf) {
768 *((
char *) args->buf) = dtmf.
digit;
773 if (args->input_callback) {
796 if (args && args->dmachine) {
802 if (args && (args->read_frame_callback)) {
818 memset(&vfh, 0,
sizeof(vfh));
822 memset(&vfh, 0,
sizeof(vfh));
833 memset(&vfh, 0,
sizeof(vfh));
841 if (!asis && fh->thresh) {
842 int16_t *fdata = (int16_t *) read_frame->
data;
843 uint32_t samples = read_frame->
datalen /
sizeof(*fdata);
844 uint32_t score, count = 0, j = 0;
849 energy += abs(fdata[j++]);
852 score = (uint32_t) (energy / (samples / divisor));
854 if (score < fh->thresh) {
855 if (!--fh->silence_hits) {
860 fh->silence_hits = org_silence_hits;
877 }
else if (fill_cng) {
879 }
else if (waste_resources) {
884 int16_t *data = read_frame->
data;
891 len = write_frame.
datalen / 2 / fh->channels;
905 if (fill_cng || waste_resources) {
924 char *data, *expanded = NULL;
929 if ((data = strchr(cmd,
':'))) {
936 if (expanded && expanded != data) {
1010 memset(&ts, 0,
sizeof(ts));
1011 write_frame.
codec = &write_codec;
1012 write_frame.
data = data;
1013 write_frame.
buflen =
sizeof(data);
1045 if (args && args->dmachine) {
1051 if (args && (args->read_frame_callback)) {
1065 if (!args->input_callback && !args->buf && !args->dmachine) {
1071 if (args->dmachine) {
1072 char ds[2] = {dtmf.
digit,
'\0'};
1078 if (args->input_callback) {
1080 }
else if (args->buf) {
1081 *((
char *) args->buf) = dtmf.
digit;
1086 if (args->input_callback) {
1149 #define FILE_STARTSAMPLES 1024 * 32
1150 #define FILE_BLOCKSIZE 1024 * 8
1151 #define FILE_BUFSIZE 1024 * 64
1156 int16_t *abuf = NULL;
1158 uint32_t interval = 0, samples = 0, framelen, sample_start = 0, channels = 1;
1172 const char *timer_name;
1174 const char *alt = NULL;
1175 const char *sleep_val;
1176 const char *play_delimiter_val;
1177 char play_delimiter = 0;
1178 int sleep_val_i = 250;
1184 char *argv[128] = { 0 };
1188 int timeout_samples = 0;
1193 uint32_t test_native = 0, last_native = 0;
1204 int tmp = atoi(var);
1216 play_delimiter = *play_delimiter_val;
1219 int tmp = atoi(sleep_val);
1239 if (play_delimiter) {
1244 argv[0] = (
char *) file;
1249 memset(fh, 0,
sizeof(lfh));
1252 if (fh->samples > 0) {
1253 sample_start = fh->samples;
1265 fh->samples = sample_start = 0;
1276 if ((alt = strchr(file,
':'))) {
1279 if (!strncasecmp(file,
"phrase:", 7)) {
1286 if ((arg = strchr(dup,
':'))) {
1298 }
else if (!strncasecmp(file,
"say:", 4)) {
1299 char *engine = NULL, *voice = NULL, *text = NULL;
1304 if (!
zstr(engine)) {
1305 if ((voice = strchr(engine,
':'))) {
1307 if (!
zstr(voice) && (text = strchr(voice,
':'))) {
1322 if (engine && text) {
1348 while (*file ==
'{') {
1352 while(*file ==
' ') file++;
1362 if ((ext = strrchr(file,
'.'))) {
1371 int maybe = atoi(prebuf);
1379 fh->prefix = prefix;
1410 write_frame.
data = abuf;
1413 if (sample_start > 0) {
1452 if (!fh->audio_buffer) {
1474 "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name,
1497 if (framelen == 0) {
1513 write_frame.
codec = &codec;
1519 last_native = test_native;
1524 len = samples * 2 * channels;
1543 write_frame.
rate = fh->samplerate;
1544 write_frame.
channels = fh->channels;
1550 ilen = samples * channels;
1554 if (!strncasecmp(file,
"local_stream:", 13)) {
1557 if (!strncasecmp(file,
"tone_stream:", 12)) {
1569 int last_speed = -1;
1596 if (!args->input_callback && !args->buf && !args->dmachine) {
1603 if (args->dmachine) {
1604 char ds[2] = {dtmf.
digit,
'\0'};
1610 if (args->input_callback) {
1612 }
else if (args->buf) {
1613 *((
char *) args->buf) = dtmf.
digit;
1618 if (args->input_callback) {
1637 buflen =
FILE_STARTSAMPLES *
sizeof(*abuf) * fh->cur_channels ? fh->cur_channels : fh->channels;
1639 if (buflen > write_frame.
buflen) {
1640 abuf = realloc(abuf, buflen);
1641 write_frame.
data = abuf;
1649 memset(abuf, 255, framelen);
1661 if (bread < framelen) {
1662 memset(abuf + bread, 255, framelen - bread);
1678 if (bread < framelen) {
1679 memset(abuf + bread, 255, framelen - bread);
1706 if (test_native != last_native) {
1711 if (framelen == 0) {
1717 write_frame.
codec = &codec;
1724 last_native = test_native;
1728 fh->offset_pos += (uint32_t)(olen / 2);
1736 if (done || olen <= 0) {
1741 if (fh->speed > 2) {
1743 }
else if (fh->speed < -2) {
1760 float factor = 0.25f * abs(fh->speed);
1762 short *bp = write_frame.
data;
1765 supplement = (int) (factor * olen);
1769 newlen = (fh->speed > 0) ? olen - supplement : olen + supplement;
1771 step = (fh->speed > 0) ? (newlen / supplement) : (olen / supplement);
1773 if (!fh->sp_audio_buffer) {
1777 while ((wrote + step) < newlen) {
1781 if (fh->speed > 0) {
1786 f = (float) (*bp + *(bp + 1) + *(bp - 1));
1793 if (wrote < newlen) {
1798 last_speed = fh->speed;
1803 uint8_t *dp = (uint8_t *) write_frame.
data;
1804 memset(dp + (
int) olen, 255, (int) (llen - olen));
1829 if (args && args->dmachine) {
1835 if (args && (args->read_frame_callback)) {
1850 write_frame.
samples = (uint32_t) olen;
1853 write_frame.
datalen = (uint32_t) olen;
1864 #if SWITCH_BYTE_ORDER == __BIG_ENDIAN
1881 if (timeout_samples) {
1882 timeout_samples -= write_frame.
samples;
1883 if (timeout_samples <= 0) {
1884 timeout_samples = 0;
1886 if (timeout_as_success) {
1921 if (!strncasecmp(file,
"local_stream:", 13)) {
1924 if (!strncasecmp(file,
"tone_stream:", 12)) {
1946 if (fh->audio_buffer) {
1950 if (fh->sp_audio_buffer) {
1975 uint32_t silence_hits, uint32_t listen_hits, uint32_t timeout_ms, const
char *file)
1977 uint32_t score, count = 0, j = 0;
1981 uint32_t org_silence_hits = silence_hits;
1986 uint32_t listening = 0;
1989 int16_t *abuf = NULL;
1992 int32_t sample_count = 0;
2010 write_frame.
data = abuf;
2028 write_frame.
codec = &raw_codec;
2045 if (sample_count <= 0) {
2061 write_frame.
samples = (uint32_t) olen;
2062 write_frame.
datalen = (uint32_t) (olen *
sizeof(int16_t) * fh.
channels);
2078 data = (int16_t *) read_frame->
data;
2080 for (energy = 0, j = 0, count = 0; count < read_frame->
samples; count++) {
2081 energy += abs(data[j++]);
2085 score = (uint32_t) (energy / (read_frame->
samples / divisor));
2087 if (score >= thresh) {
2091 if (listening > listen_hits && score < thresh) {
2092 if (!--silence_hits) {
2096 silence_hits = org_silence_hits;
2115 uint32_t min_digits,
2116 uint32_t max_digits,
2117 const
char *prompt_audio_file,
2118 const
char *var_name,
2122 const
char *valid_terminators,
2123 uint32_t digit_timeout)
2131 int term_required = 0;
2134 if (valid_terminators && *valid_terminators ==
'=') {
2140 if (!digit_timeout) {
2141 digit_timeout = timeout;
2144 if (max_digits < min_digits) {
2146 "Max digits %u is less than Min %u, forcing Max to %u\n", max_digits, min_digits, min_digits);
2147 max_digits = min_digits;
2157 if ((min_digits && digit_buffer_length < min_digits) || digit_buffer_length < max_digits) {
2166 memset(digit_buffer, 0, digit_buffer_length);
2167 args.
buf = digit_buffer;
2168 args.
buflen = (uint32_t) digit_buffer_length;
2170 if (!
zstr(prompt_audio_file) && strcasecmp(prompt_audio_file,
"silence")) {
2180 len = strlen(digit_buffer);
2182 if ((min_digits && len < min_digits) || len < max_digits) {
2183 args.
buf = digit_buffer + len;
2184 args.
buflen = (uint32_t) (digit_buffer_length - len);
2186 len ? digit_timeout : timeout, digit_timeout, 0);
2195 if (!
zstr(valid_terminators) && (p = strchr(valid_terminators, tb[0]))) {
2196 if (p >= (valid_terminators + 1) && (*(p - 1) ==
'+' || *(p - 1) ==
'x')) {
2197 switch_snprintf(digit_buffer + strlen(digit_buffer), digit_buffer_length - strlen(digit_buffer),
"%s", tb);
2198 if (*(p - 1) ==
'x') {
2203 }
else if (term_required) {
2207 len = strlen(digit_buffer);
2208 if ((min_digits && len < min_digits)) {
2227 if (status !=
SWITCH_STATUS_RESTART && max_digits == 1 && len == 1 && valid_terminators && strchr(valid_terminators, *digit_buffer)) {
2228 *digit_buffer =
'\0';
2231 if (var_name && !
zstr(digit_buffer)) {
2240 uint32_t min_digits,
2241 uint32_t max_digits,
2244 const
char *valid_terminators,
2245 const
char *prompt_audio_file,
2246 const
char *bad_input_audio_file,
2247 const
char *var_name,
2249 uint32_t digit_buffer_length,
2250 const
char *digits_regex,
2251 uint32_t digit_timeout,
2252 const
char *transfer_on_failure)
2259 memset(digit_buffer, 0, digit_buffer_length);
2261 status =
switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name,
2262 digit_buffer, digit_buffer_length, timeout, valid_terminators, digit_timeout);
2279 if (!
zstr(digit_buffer)) {
2280 char *invalid_var = NULL;
2281 if (
zstr(digits_regex)) {
2308 memset(digit_buffer, 0, digit_buffer_length);
2313 if (!
zstr(transfer_on_failure)) {
2314 const char *failure_ext = NULL;
2315 const char *failure_dialplan = NULL;
2316 const char *failure_context = NULL;
2329 failure_ext = target[0];
2333 failure_dialplan = target[1];
2337 failure_context = target[2];
2341 "PAGD failure! Transfer to: %s / %s / %s\n", failure_ext, failure_dialplan, failure_context);
2364 char *p, *tmp = NULL;
2365 const char *star, *pound;
2382 write_frame.
data = abuf;
2383 write_frame.
buflen =
sizeof(abuf);
2385 len = sh->samples * 2 * sh->channels;
2395 starlen = strlen(star);
2396 poundlen = strlen(pound);
2399 for (p = text; p && *p; p++) {
2402 }
else if (*p ==
'#') {
2410 tmp = malloc(mylen);
2417 for (p = text; p && *p; p++) {
2419 strncat(tp, star, starlen);
2421 }
else if (*p ==
'#') {
2422 strncat(tp, pound, poundlen);
2437 write_frame.
rate = sh->rate;
2440 write_frame.
samples = len / 2;
2441 write_frame.
codec = codec;
2474 if (!args->input_callback && !args->buf && !args->dmachine) {
2479 if (args->buf && !strcasecmp(args->buf,
"_break_")) {
2484 if (args->dmachine) {
2485 char ds[2] = {dtmf.
digit,
'\0'};
2491 if (args->input_callback) {
2493 }
else if (args->buf) {
2494 *((
char *) args->buf) = dtmf.
digit;
2500 if (args->input_callback) {
2534 if (args && args->dmachine) {
2540 if (args && (args->read_frame_callback)) {
2564 write_frame.
datalen = (uint32_t) ilen;
2565 write_frame.
samples = (uint32_t) (ilen / 2 / sh->channels);
2567 write_frame.
timestamp = timer->samplecount;
2595 if (args && args->dmachine) {
2601 if (args && (args->read_frame_callback)) {
2662 const char *timer_name, *var;
2664 int need_create = 1, need_alloc = 1;
2681 if (!strcasecmp(cache_obj->
tts_name, tts_name)) {
2696 sh = &cache_obj->
sh;
2697 codec = &cache_obj->
codec;
2698 timer = &cache_obj->
timer;
2710 memset(sh, 0,
sizeof(*sh));
2718 }
else if (cache_obj && strcasecmp(cache_obj->
voice_name, voice_name)) {
2801 char *stop_key = (
char *) buf;
2807 if (dtmf->
digit == *stop_key) {
2823 const char *other_uuid, *moh = NULL;
2827 args.
buf = (
void *) unhold_key;
2828 args.
buflen = (uint32_t) strlen(unhold_key);
2855 if (!
zstr(moh) && strcasecmp(moh,
"silence")) {
switch_status_t switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt,...)
switch_status_t switch_core_speech_read_tts(switch_speech_handle_t *sh, void *data, switch_size_t *datalen, switch_speech_flag_t *flags)
Read rendered audio from the TTS module.
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
void switch_core_thread_session_end(_In_ switch_core_session_t *session)
Signal a thread using a thread session to terminate.
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
#define switch_regex_safe_free(re)
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
switch_status_t switch_core_session_io_write_lock(switch_core_session_t *session)
A module interface to implement an application.
void switch_channel_set_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag)
const char * switch_xml_attr_soft(_In_ switch_xml_t xml, _In_z_ const char *attr)
returns the value of the requested tag attribute, or "" if not found
char * switch_core_session_sprintf(_In_ switch_core_session_t *session, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the session ...
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_event_expand_headers(_event, _in)
switch_status_t switch_core_timer_init(switch_timer_t *timer, const char *timer_name, int interval, int samples, switch_memory_pool_t *pool)
Request a timer handle using given time module.
void switch_core_session_reset(_In_ switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec)
Reset the buffers and resampler on a session.
switch_size_t switch_buffer_read(_In_ switch_buffer_t *buffer, _In_ void *data, _In_ switch_size_t datalen)
Read data from a switch_buffer_t up to the ammount of datalen if it is available. Remove read data fr...
switch_xml_t switch_xml_find_child(_In_ switch_xml_t node, _In_z_ const char *childname, _In_opt_z_ const char *attrname, _In_opt_z_ const char *value)
find a child tag in a node called 'childname' with an attribute 'attrname' which equals 'value' ...
char * switch_find_end_paren(const char *s, char open, char close)
switch_status_t switch_ivr_gentones(switch_core_session_t *session, const char *script, int32_t loops, switch_input_args_t *args)
switch_say_callback_t say_function
const char * switch_xml_attr(_In_opt_ switch_xml_t xml, _In_opt_z_ const char *attr)
returns the value of the requested tag attribute, or NULL if not found
static switch_status_t hold_on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
switch_status_t switch_play_and_get_digits(switch_core_session_t *session, uint32_t min_digits, uint32_t max_digits, uint32_t max_tries, uint32_t timeout, const char *valid_terminators, const char *prompt_audio_file, const char *bad_input_audio_file, const char *var_name, char *digit_buffer, uint32_t digit_buffer_length, const char *digits_regex, uint32_t digit_timeout, const char *transfer_on_failure)
Play a sound and gather digits with the number of retries specified if the user doesn't give digits i...
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
switch_status_t switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info)
Set private data on channel.
void switch_perform_substitution(switch_regex_t *re, int match_count, const char *data, const char *field_data, char *substituted, switch_size_t len, int *ovector)
An abstraction to store a tone mapping.
switch_status_t switch_buffer_create_dynamic(_Out_ switch_buffer_t **buffer, _In_ switch_size_t blocksize, _In_ switch_size_t start_len, _In_ switch_size_t max_len)
Allocate a new dynamic switch_buffer.
switch_status_t switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_bool_t sync, switch_input_args_t *args)
Wait for time to pass for a specified number of milliseconds.
#define switch_channel_stop_broadcast(_channel)
teletone_audio_t * buffer
switch_status_t switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t digit_timeout, uint32_t abs_timeout)
Wait for DTMF digits calling a pluggable callback function when digits are collected.
uint32_t switch_speech_flag_t
#define SWITCH_RECOMMENDED_BUFFER_SIZE
void switch_channel_event_set_data(_In_ switch_channel_t *channel, _In_ switch_event_t *event)
Add information about a given channel to an event object.
switch_status_t switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language)
switch_status_t switch_core_session_set_read_codec(_In_ switch_core_session_t *session, switch_codec_t *codec)
Assign the read codec to a given session.
#define SWITCH_URL_SEPARATOR
switch_status_t switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
Execute a registered API command.
switch_status_t switch_ivr_broadcast(const char *uuid, const char *path, switch_media_flag_t flags)
Signal the session to broadcast audio.
switch_say_method_t method
uint32_t decoded_bytes_per_packet
switch_memory_pool_t * pool
Representation of an event.
#define switch_channel_ready(_channel)
#define arg_recursion_check_stop(_args)
void switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t channels, uint32_t divisor)
Generate static noise.
switch_status_t switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
Feed text to the TTS module.
int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map)
Execute a single tone generation instruction.
#define switch_channel_media_ready(_channel)
switch_status_t switch_core_session_exec(_In_ switch_core_session_t *session, _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg)
Execute an application on a session.
int teletone_destroy_session(teletone_generation_session_t *ts)
Free the buffer allocated by a tone generation session.
switch_status_t switch_ivr_parse_event(_In_ switch_core_session_t *session, _In_ switch_event_t *event)
Parse command from an event.
switch_status_t switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
play a file from the disk to the session
A representation of an XML tree.
switch_status_t switch_core_codec_destroy(switch_codec_t *codec)
Destroy an initalized codec handle.
switch_status_t switch_ivr_speak_text(switch_core_session_t *session, const char *tts_name, const char *voice_name, char *text, switch_input_args_t *args)
Speak given text with given tts engine.
struct real_pcre switch_regex_t
void switch_core_speech_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
Set a text parameter on a TTS handle.
switch_status_t switch_ivr_parse_all_events(switch_core_session_t *session)
Parse all commands from an event.
Abstract handler to a timer module.
switch_status_t switch_ivr_speak_text_handle(switch_core_session_t *session, switch_speech_handle_t *sh, switch_codec_t *codec, switch_timer_t *timer, char *text, switch_input_args_t *args)
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
switch_size_t switch_buffer_write(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen) const void *data, _In_ switch_size_t datalen)
Write data into a switch_buffer_t up to the length of datalen.
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_status_t switch_core_session_read_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
Read a frame from a session.
switch_codec_t * switch_core_session_get_read_codec(_In_ switch_core_session_t *session)
Retrieve the read codec from a given session.
switch_status_t switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
Transfer an existing session to another location.
#define SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME
switch_status_t switch_core_session_io_read_lock(switch_core_session_t *session)
void switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
Change the volume of a signed linear audio frame.
switch_status_t switch_core_session_write_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
Write a frame to a session.
int teletone_run(teletone_generation_session_t *ts, const char *cmd)
Execute a tone generation script and call callbacks after each instruction.
switch_status_t switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
#define UNPROTECT_INTERFACE(_it)
switch_status_t switch_core_session_io_rwunlock(switch_core_session_t *session)
int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data)
Initilize a tone generation session.
switch_status_t switch_core_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags)
Close an open speech handle.
#define SWITCH_PATH_SEPARATOR
#define SWITCH_CACHE_SPEECH_HANDLES_VARIABLE
const switch_codec_implementation_t * implementation
if((uint32_t)(unpack->cur-unpack->buf) > unpack->buflen)
switch_status_t switch_ivr_collect_digits_count(switch_core_session_t *session, char *buf, switch_size_t buflen, switch_size_t maxdigits, const char *terminators, char *terminator, uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout)
Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up...
switch_byte_t switch_byte_t * buf
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
#define switch_channel_audio_sync(_c)
unsigned int switch_separate_string(_In_ char *buf, char delim, _Post_count_(return) char **array, unsigned int arraylen)
Separate a string into an array based on a character delimiter.
const char * switch_channel_get_hold_music(switch_channel_t *channel)
switch_application_interface_t * switch_loadable_module_get_application_interface(const char *name)
Retrieve the application interface by it's registered name.
Abstract interface to a say module.
#define SWITCH_READ_RESULT_VARIABLE
void switch_event_merge(switch_event_t *event, switch_event_t *tomerge)
uint32_t actual_samples_per_second
void switch_buffer_set_loops(_In_ switch_buffer_t *buffer, _In_ int32_t loops)
Assign a number of loops to read.
#define switch_channel_get_variable(_c, _v)
switch_status_t switch_channel_dequeue_dtmf(_In_ switch_channel_t *channel, _In_ switch_dtmf_t *dtmf)
Retrieve DTMF digits from a given channel.
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_zmalloc(ptr, len)
switch_size_t switch_buffer_read_loop(_In_ switch_buffer_t *buffer, _In_ void *data, _In_ switch_size_t datalen)
Read data endlessly from a switch_buffer_t.
static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
switch_speech_interface_t * speech_interface
switch_status_t switch_core_session_dequeue_private_event(_In_ switch_core_session_t *session, _Out_ switch_event_t **event)
DE-Queue a private event on a given session.
void switch_buffer_zero(_In_ switch_buffer_t *buffer)
Remove all data from the buffer.
An abstraction of a data frame.
#define arg_recursion_check_start(_args)
#define switch_set_flag_locked(obj, flag)
Set a flag on an arbitrary object while locked.
void switch_swap_linear(int16_t *buf, int len)
Perform a byteswap on a buffer of 16 bit samples.
switch_byte_t switch_byte_t uint32_t buflen
#define switch_core_codec_init(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, _flags, _codec_settings, _pool)
Initialize a codec handle.
switch_speech_handle_t sh
#define SWITCH_STANDARD_STREAM(s)
#define switch_core_service_session(_s)
int microseconds_per_packet
int switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen)
char * switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size)
switch_say_gender_t gender
switch_status_t switch_core_timer_destroy(switch_timer_t *timer)
Destroy an allocated timer.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_directories SWITCH_GLOBAL_dirs
void switch_core_speech_flush_tts(switch_speech_handle_t *sh)
Flush TTS audio on a given handle.
#define switch_str_nil(s)
Make a null string a blank string instead.
#define SWITCH_READ_TERMINATOR_USED_VARIABLE
switch_status_t switch_core_timer_next(switch_timer_t *timer)
Wait for one cycle on an existing timer.
char * switch_separate_paren_args(char *str)
#define switch_channel_expand_variables(_channel, _in)
uint32_t samples_per_packet
switch_status_t switch_core_session_request_video_refresh(switch_core_session_t *session)
#define switch_clear_flag_locked(obj, flag)
Clear a flag on an arbitrary object.
uint8_t number_of_channels
uint32_t samples_per_second
switch_status_t
Common return values.
void * switch_channel_get_private(switch_channel_t *channel, const char *key)
Retrieve private from a given channel.
switch_status_t switch_ivr_wait_for_silence(switch_core_session_t *session, uint32_t thresh, uint32_t silence_hits, uint32_t listen_hits, uint32_t timeout_ms, const char *file)
switch_status_t switch_core_session_dequeue_event(_In_ switch_core_session_t *session, _Out_ switch_event_t **event, switch_bool_t force)
DE-Queue an event on a given session.
switch_say_interface_t * switch_loadable_module_get_say_interface(const char *name)
Retrieve the say interface by it's registered name.
switch_size_t switch_channel_has_dtmf(_In_ switch_channel_t *channel)
Test for presence of DTMF on a given channel.
#define switch_core_session_locate(uuid_str)
Locate a session based on it's uuid.
static int write_buf(int fd, const char *buf)
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
uint32_t encoded_bytes_per_packet
switch_status_t switch_core_speech_open(_In_ switch_speech_handle_t *sh, const char *module_name, const char *voice_name, _In_ unsigned int rate, _In_ unsigned int interval, _In_ unsigned int channels, switch_speech_flag_t *flags, _In_opt_ switch_memory_pool_t *pool)
Open a speech handle.
static switch_bool_t switch_is_file_path(const char *file)
#define switch_event_get_header(_e, _h)
#define switch_channel_set_flag(_c, _f)
switch_xml_t switch_xml_child(_In_ switch_xml_t xml, _In_z_ const char *name)
returns the first child tag (one level deeper) with the given name or NULL \ if not found ...
An abstraction to store a tone generation session.
switch_status_t switch_ivr_record_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args, uint32_t limit)
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
#define FILE_STARTSAMPLES
struct apr_pool_t switch_memory_pool_t
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_channel_clear_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag)
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
A table of settings and callbacks that define a paticular implementation of a codec.
#define switch_is_valid_rate(_tmp)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
void switch_event_destroy(switch_event_t **event)
Destroy an event.
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
#define switch_channel_set_variable(_channel, _var, _val)
#define switch_channel_pre_answer(channel)
Indicate progress on a channel to attempt early media.
switch_size_t switch_buffer_inuse(_In_ switch_buffer_t *buffer)
Get the in use amount of a switch_buffer_t.
void switch_buffer_destroy(switch_buffer_t **buffer)
Destroy the buffer.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
#define SWITCH_READ_ACCEPTABLE(status)
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.
switch_status_t switch_regex_match(const char *target, const char *expression)
Function to evaluate an expression against a string.
#define SWITCH_DEFAULT_FILE_BUFFER_LEN
void switch_ivr_clear_speech_cache(switch_core_session_t *session)
switch_status_t switch_core_timer_sync(switch_timer_t *timer)
switch_status_t switch_ivr_parse_all_messages(switch_core_session_t *session)