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")) {
257 int32_t volume = atoi(volume_str);
265 }
else if (!strcasecmp(func,
"phrase")) {
268 }
else if (!strcasecmp(func,
"break")) {
270 }
else if (!strcasecmp(func,
"execute")) {
272 char *cmd, *cmd_args;
288 }
else if (!strcasecmp(func,
"say")) {
300 status = si->
say_function(session, odata, &say_args, args);
304 }
else if (!strcasecmp(func,
"speak-text")) {
308 if (!my_tts_engine) {
309 my_tts_engine = tts_engine;
313 my_tts_voice = tts_voice;
315 if (
zstr(tts_engine) ||
zstr(tts_voice)) {
348 if (searched && !matches) {
352 if (old_sound_prefix) {
372 char *vvar = NULL, *vval = NULL;
374 vvar = (
char *) hi->
name;
375 vval = (
char *) hi->
value;
386 const char *val = NULL;
390 if (!val && fh && fh->
params) {
419 uint32_t org_silence_hits = 0;
421 int32_t sample_start = 0;
422 int waste_resources = 1400, fill_cng = 0;
429 int restart_limit_on_dtmf = 0;
430 const char *prefix, *var, *video_file = NULL;
433 const char *file_trimmed_ms = NULL;
434 const char *file_size = NULL;
435 const char *file_trimmed = NULL;
496 while (*file ==
'{') {
500 while(*file ==
' ') file++;
510 if ((ext = strrchr(file,
'.'))) {
572 if (!strcasecmp(p,
"true")) {
575 if ((fill_cng = atoi(p)) < 0) {
583 waste_resources = 1400;
595 if (!strcasecmp(p,
"true")) {
596 waste_resources = 1400;
598 if ((waste_resources = atoi(p)) < 0) {
604 if (fill_cng || waste_resources) {
619 write_frame.
codec = &write_codec;
637 memset(&vfh, 0,
sizeof(vfh));
647 memset(&vfh, 0,
sizeof(vfh));
662 if (sample_start > 0) {
674 restart_limit_on_dtmf =
recording_var_true(channel, vars, fh,
"record_restart_limit_on_dtmf");
730 "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->
samplerate,
775 const char *app_exec = NULL;
810 if (limit && restart_limit_on_dtmf) {
821 char ds[2] = {dtmf.
digit,
'\0'};
829 }
else if (args->
buf) {
880 memset(&vfh, 0,
sizeof(vfh));
884 memset(&vfh, 0,
sizeof(vfh));
895 memset(&vfh, 0,
sizeof(vfh));
903 if (!asis && fh->
thresh) {
904 int16_t *fdata = (int16_t *) read_frame->
data;
905 uint32_t samples = read_frame->
datalen /
sizeof(*fdata);
906 uint32_t score,
count = 0, j = 0;
911 energy += abs(fdata[j++]);
914 score = (uint32_t) (energy / (samples / divisor));
916 if (score < fh->thresh) {
939 }
else if (fill_cng) {
941 }
else if (waste_resources) {
946 int16_t *data = read_frame->
data;
967 if (fill_cng || waste_resources) {
985 if (file_trimmed_ms) {
1002 char *data, *expanded = NULL;
1007 if ((data = strchr(cmd,
':'))) {
1014 if (expanded && expanded != data) {
1038 const char *app_exec = NULL;
1063 if (!audio_buffer) {
1104 memset(&ts, 0,
sizeof(ts));
1105 write_frame.
codec = &write_codec;
1106 write_frame.
data = data;
1107 write_frame.
buflen =
sizeof(data);
1163 char ds[2] = {dtmf.
digit,
'\0'};
1171 }
else if (args->
buf) {
1172 *((
char *) args->
buf) = dtmf.
digit;
1240 #define FILE_STARTSAMPLES 1024 * 32 1241 #define FILE_BLOCKSIZE 1024 * 8 1242 #define FILE_BUFSIZE 1024 * 64 1247 int16_t *abuf = NULL;
1249 uint32_t interval = 0, samples = 0, framelen, sample_start = 0, channels = 1;
1262 char *backup_file = NULL;
1263 const char *backup_ext;
1265 const char *timer_name;
1267 const char *alt = NULL;
1268 const char *sleep_val;
1269 const char *play_delimiter_val;
1270 char play_delimiter = 0;
1271 int sleep_val_i = 250;
1276 char *argv[128] = { 0 };
1280 int timeout_samples = 0;
1285 uint32_t test_native = 0, last_native = 0;
1289 int last_speed = -1;
1298 int tmp = atoi(var);
1305 int tmp = atoi(var);
1317 play_delimiter = *play_delimiter_val;
1320 int tmp = atoi(sleep_val);
1336 if (play_delimiter) {
1341 argv[0] = (
char *) file;
1346 memset(fh, 0,
sizeof(lfh));
1362 fh->
samples = sample_start = 0;
1373 if (strchr(file,
':')) {
1376 if (!strncasecmp(file,
"phrase:", 7)) {
1383 if ((arg = strchr(dup,
':'))) {
1394 }
else if (!strncasecmp(file,
"say:", 4)) {
1395 const char *engine = NULL, *voice = NULL, *text = NULL;
1402 if (engine && text) {
1427 while (*file ==
'{') {
1431 while(*file ==
' ') file++;
1441 if ((ext = strrchr(file,
'.'))) {
1456 int maybe = atoi(prebuf);
1509 write_frame.
data = abuf;
1512 if (sample_start > 0) {
1568 "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name,
1591 if (framelen == 0) {
1607 write_frame.
codec = &codec;
1613 last_native = test_native;
1618 len = samples * 2 * channels;
1644 ilen = samples * channels;
1648 if (!strncasecmp(file,
"local_stream:", 13)) {
1651 if (!strncasecmp(file,
"tone_stream:", 12)) {
1702 char ds[2] = {dtmf.
digit,
'\0'};
1710 }
else if (args->
buf) {
1711 *((
char *) args->
buf) = dtmf.
digit;
1737 if (buflen > write_frame.
buflen) {
1738 abuf = realloc(abuf, buflen);
1739 write_frame.
data = abuf;
1747 memset(abuf, 255, framelen);
1759 if (bread < framelen) {
1760 memset(abuf + bread, 255, framelen - bread);
1776 if (bread < framelen) {
1777 memset(abuf + bread, 255, framelen - bread);
1804 if (test_native != last_native) {
1808 if (framelen == 0) {
1814 write_frame.
codec = &codec;
1820 last_native = test_native;
1832 if (done || olen <= 0) {
1837 if (fh->
speed > 2) {
1839 }
else if (fh->
speed < -2) {
1856 float factor = 0.25f * abs(fh->
speed);
1858 short *bp = write_frame.
data;
1861 supplement = (int) (factor * olen);
1865 newlen = (fh->
speed > 0) ? olen - supplement : olen + supplement;
1867 step = (fh->
speed > 0) ? (newlen / supplement) : (olen / supplement);
1873 while ((wrote + step) < newlen) {
1877 if (fh->
speed > 0) {
1882 f = (float) (*bp + *(bp + 1) + *(bp - 1));
1889 if (wrote < newlen) {
1893 last_speed = fh->
speed;
1898 uint8_t *dp = (uint8_t *) write_frame.
data;
1899 memset(dp + (
int) olen, 255, (int) (llen - olen));
1945 write_frame.
samples = (uint32_t) olen;
1948 write_frame.
datalen = (uint32_t) olen;
1959 #if SWITCH_BYTE_ORDER == __BIG_ENDIAN 1968 }
else if (fh->
vol) {
1980 if (timeout_samples) {
1981 timeout_samples -= write_frame.
samples;
1982 if (timeout_samples <= 0) {
1983 timeout_samples = 0;
1985 if (timeout_as_success) {
2022 if (!strncasecmp(file,
"local_stream:", 13)) {
2025 if (!strncasecmp(file,
"tone_stream:", 12)) {
2072 if (timeout_samples && cumulative) {
2081 uint32_t silence_hits, uint32_t listen_hits, uint32_t timeout_ms,
const char *file)
2083 uint32_t score,
count = 0, j = 0;
2087 uint32_t org_silence_hits = silence_hits;
2092 uint32_t listening = 0;
2095 int16_t *abuf = NULL;
2098 int32_t sample_count = 0;
2117 write_frame.
data = abuf;
2136 write_frame.
codec = &raw_codec;
2157 if (sample_count <= 0) {
2162 "switch_ivr_wait_for_silence: TIMEOUT after %d ms at %d listen hits, %d silence hits, %d countdown\n",
2163 timeout_ms, listening, (org_silence_hits - silence_hits), countdown);
2176 write_frame.
samples = (uint32_t) olen;
2177 write_frame.
datalen = (uint32_t) (olen *
sizeof(int16_t) * fh.
channels);
2196 data = (int16_t *) read_frame->
data;
2199 if (read_frame->
seq) {
2200 for (energy = 0, j = 0, count = 0; count < read_frame->
samples; count++) {
2201 energy += abs(data[j++]);
2206 score = (uint32_t) (energy / (read_frame->
samples / divisor));
2208 if (score >= thresh) {
2212 if (((listen_hits == 0) || (listening > listen_hits)) && (score < thresh)) {
2213 if (!--silence_hits) {
2217 silence_hits = org_silence_hits;
2236 uint32_t audio_hits, uint32_t timeout_ms,
const char *file)
2238 uint32_t score,
count = 0, j = 0;
2248 int16_t *abuf = NULL;
2251 int32_t sample_count = 0;
2269 write_frame.
data = abuf;
2288 write_frame.
codec = &raw_codec;
2306 if (sample_count <= 0) {
2310 "switch_ivr_detect_audio: TIMEOUT after %d ms at %d hits\n",
2324 write_frame.
samples = (uint32_t) olen;
2325 write_frame.
datalen = (uint32_t) (olen *
sizeof(int16_t) * fh.
channels);
2332 data = (int16_t *) read_frame->
data;
2334 for (energy = 0, j = 0, count = 0; count < read_frame->
samples; count++) {
2335 energy += abs(data[j++]);
2339 score = (uint32_t) (energy / (read_frame->
samples / divisor));
2341 if (score >= thresh) {
2347 if (hits > audio_hits) {
2369 uint32_t silence_hits, uint32_t timeout_ms,
const char *file)
2371 uint32_t score,
count = 0, j = 0;
2381 int16_t *abuf = NULL;
2384 int32_t sample_count = 0;
2403 write_frame.
data = abuf;
2422 write_frame.
codec = &raw_codec;
2440 if (sample_count <= 0) {
2444 "switch_ivr_detect_silence: TIMEOUT after %d ms at %d hits\n",
2458 write_frame.
samples = (uint32_t) olen;
2459 write_frame.
datalen = (uint32_t) (olen *
sizeof(int16_t) * fh.
channels);
2466 data = (int16_t *) read_frame->
data;
2468 for (energy = 0, j = 0, count = 0; count < read_frame->
samples; count++) {
2469 energy += abs(data[j++]);
2473 score = (uint32_t) (energy / (read_frame->
samples / divisor));
2475 if (score <= thresh) {
2481 if (hits > silence_hits) {
2503 uint32_t min_digits,
2504 uint32_t max_digits,
2505 const char *prompt_audio_file,
2506 const char *var_name,
2510 const char *valid_terminators,
2511 uint32_t digit_timeout)
2519 int term_required = 0;
2522 if (valid_terminators && *valid_terminators ==
'=') {
2528 if (!digit_timeout) {
2529 digit_timeout = timeout;
2532 if (max_digits < min_digits) {
2534 "Max digits %u is less than Min %u, forcing Max to %u\n", max_digits, min_digits, min_digits);
2535 max_digits = min_digits;
2545 if ((min_digits && digit_buffer_length < min_digits) || digit_buffer_length < max_digits) {
2554 memset(digit_buffer, 0, digit_buffer_length);
2555 args.
buf = digit_buffer;
2556 args.
buflen = (uint32_t) digit_buffer_length;
2558 if (!
zstr(prompt_audio_file) && strcasecmp(prompt_audio_file,
"silence")) {
2568 len = strlen(digit_buffer);
2570 if ((min_digits && len < min_digits) || len < max_digits) {
2571 args.
buf = digit_buffer + len;
2572 args.
buflen = (uint32_t) (digit_buffer_length - len);
2574 len ? digit_timeout : timeout, digit_timeout, 0);
2583 if (!
zstr(valid_terminators) && (p = strchr(valid_terminators, tb[0]))) {
2584 if (p >= (valid_terminators + 1) && (*(p - 1) ==
'+' || *(p - 1) ==
'x')) {
2585 switch_snprintf(digit_buffer + strlen(digit_buffer), digit_buffer_length - strlen(digit_buffer),
"%s", tb);
2586 if (*(p - 1) ==
'x') {
2591 }
else if (term_required) {
2595 len = strlen(digit_buffer);
2596 if ((min_digits && len < min_digits)) {
2615 if (status !=
SWITCH_STATUS_RESTART && max_digits == 1 && len == 1 && valid_terminators && strchr(valid_terminators, *digit_buffer)) {
2616 *digit_buffer =
'\0';
2619 if (var_name && !
zstr(digit_buffer)) {
2628 uint32_t min_digits,
2629 uint32_t max_digits,
2632 const char *valid_terminators,
2633 const char *prompt_audio_file,
2634 const char *bad_input_audio_file,
2635 const char *var_name,
2637 uint32_t digit_buffer_length,
2638 const char *digits_regex,
2639 uint32_t digit_timeout,
2640 const char *transfer_on_failure)
2643 char *var_name_invalid = NULL;
2645 if (!
zstr(digits_regex) && !
zstr(var_name)) {
2654 memset(digit_buffer, 0, digit_buffer_length);
2656 status =
switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name,
2657 digit_buffer, digit_buffer_length, timeout, valid_terminators, digit_timeout);
2674 if (!
zstr(digit_buffer)) {
2675 if (
zstr(digits_regex)) {
2684 if (!
zstr(var_name)) {
2702 memset(digit_buffer, 0, digit_buffer_length);
2707 if (!
zstr(transfer_on_failure)) {
2708 const char *failure_ext = NULL;
2709 const char *failure_dialplan = NULL;
2710 const char *failure_context = NULL;
2723 failure_ext = target[0];
2727 failure_dialplan = target[1];
2731 failure_context = target[2];
2735 "PAGD failure! Transfer to: %s / %s / %s\n", failure_ext, failure_dialplan, failure_context);
2758 const char *star, *pound, *p;
2775 write_frame.
data = abuf;
2776 write_frame.
buflen =
sizeof(abuf);
2788 starlen = strlen(star);
2789 poundlen = strlen(pound);
2792 for (p = text; p && *p; p++) {
2795 }
else if (*p ==
'#') {
2803 tmp = malloc(mylen);
2810 for (p = text; p && *p; p++) {
2812 snprintf(tp + strlen(tp),
sizeof(tp) - strlen(tp),
"%s", star);
2814 }
else if (*p ==
'#') {
2815 snprintf(tp + strlen(tp),
sizeof(tp) - strlen(tp),
"%s", pound);
2833 write_frame.
samples = len / 2;
2834 write_frame.
codec = codec;
2868 if (args->
buf && !strcasecmp(args->
buf,
"_break_")) {
2874 char ds[2] = {dtmf.
digit,
'\0'};
2882 }
else if (args->
buf) {
2883 *((
char *) args->
buf) = dtmf.
digit;
2948 write_frame.
datalen = (uint32_t) ilen;
3041 const char *timer_name, *var;
3043 int need_create = 1, need_alloc = 1;
3060 if (!strcasecmp(cache_obj->
tts_name, tts_name)) {
3075 sh = &cache_obj->
sh;
3076 codec = &cache_obj->
codec;
3077 timer = &cache_obj->
timer;
3089 memset(sh, 0,
sizeof(*sh));
3097 }
else if (cache_obj && strcasecmp(cache_obj->
voice_name, voice_name)) {
3180 char *stop_key = (
char *) buf;
3186 if (dtmf->
digit == *stop_key) {
3202 const char *other_uuid, *moh = NULL;
3208 args.
buf = (
void *) unhold_key;
3209 args.
buflen = (uint32_t) strlen(unhold_key);
3236 if (!
zstr(moh) && strcasecmp(moh,
"silence")) {
3302 const char *speech_type = NULL;
3313 if (!strcasecmp(speech_type,
"detected-speech")) {
3321 if (!
zstr(result)) {
3334 }
else if (!strcasecmp(speech_type,
"detected-partial-speech")) {
3335 }
else if (!strcasecmp(
"closed", speech_type)) {
3339 }
else if (!strcasecmp(speech_type,
"begin-speaking")) {
3378 int digits_collected = strlen(state->
digits);
3380 if (digits_collected < state->max_digits) {
3386 if (digits_collected + 1 >= state->
max_digits) {
3413 const char *recognizer_mod_name,
3414 const char *recognizer_grammar,
3417 const char *terminators,
3418 uint32_t digit_timeout,
3419 cJSON **recognition_result,
3420 char **digits_collected,
3421 char *terminator_collected,
3432 if (digit_timeout <= 0) digit_timeout = 5000;
3433 if (min_digits < 0) {
3438 if (min_digits > 0) {
3439 if (max_digits < min_digits) {
3440 max_digits = min_digits;
3442 if (max_digits > 100) {
3453 if (!
zstr(terminators)) {
3454 if (!strcasecmp(terminators,
"any")) {
3456 }
else if (!strcasecmp(terminators,
"none")) {
3464 if (recognizer_grammar && recognizer_mod_name) {
3488 myargs.
buf = &state;
3489 myargs.
buflen =
sizeof(state);
3508 int sleep_time = digit_timeout;
3534 sleep_time = digit_timeout;
3543 if (sleep_time >= digit_timeout) {
3552 sleep_time = digit_timeout;
3555 sleep_time = digit_timeout - sleep_time;
3582 if (digits_collected) {
3583 *digits_collected = state.
digits;
3591 if (recognition_result) {
3598 if (terminator_collected && state.
terminator != 0) {
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.
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
switch_status_t switch_core_speech_feed_tts(switch_speech_handle_t *sh, const char *text, switch_speech_flag_t *flags)
Feed text to 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)
switch_status_t switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)
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 ...
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_event_expand_headers(_event, _in)
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
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
switch_status_t switch_ivr_detect_silence(switch_core_session_t *session, uint32_t thresh, uint32_t silence_hits, uint32_t timeout_ms, const char *file)
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
switch_status_t switch_channel_execute_on_value(switch_channel_t *channel, const char *variable_value)
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.
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_bool_t switch_is_number(const char *str)
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.
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.
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.
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_status_t switch_ivr_speak_text(switch_core_session_t *session, const char *tts_name, const char *voice_name, const char *text, switch_input_args_t *args)
Speak given text with given tts engine.
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)
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data)
Initilize a tone generation session.
#define switch_normalize_volume_granular(x)
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
static const char * get_recording_var(switch_channel_t *channel, switch_event_t *vars, switch_file_handle_t *fh, const char *name)
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
if((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen)
#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_collect_input_flags_t
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)
char * switch_event_get_body(switch_event_t *event)
Retrieve the body value from an event.
#define switch_core_session_request_video_refresh(_s)
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.
switch_status_t switch_ivr_pause_detect_speech(switch_core_session_t *session)
Pause background Speech detection on a session.
#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
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.
const char * cJSON_GetObjectCstr(const cJSON *object, const char *string)
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_ivr_detect_speech(switch_core_session_t *session, const char *mod_name, const char *grammar, const char *name, const char *dest, switch_asr_handle_t *ah)
Engage background Speech detection on a session.
switch_status_t switch_core_timer_destroy(switch_timer_t *timer)
Destroy an allocated timer.
switch_buffer_t * audio_buffer
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
static switch_status_t switch_collect_input_callback(switch_core_session_t *session, void *input, switch_input_type_t input_type, void *data, unsigned int len)
void switch_core_speech_flush_tts(switch_speech_handle_t *sh)
Flush TTS audio on a given handle.
static void merge_recording_variables(switch_event_t *vars, switch_event_t *event)
#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
#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_detect_audio(switch_core_session_t *session, uint32_t thresh, uint32_t audio_hits, uint32_t timeout_ms, const char *file)
const cJSON *const target
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_buffer_t * sp_audio_buffer
void switch_change_sln_volume_granular(int16_t *data, uint32_t samples, int32_t vol)
Change the volume of a signed linear audio frame with more granularity.
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.
switch_size_t samples_out
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
#define FILE_STARTSAMPLES
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
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, const char *text, switch_input_args_t *args)
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)
static void deliver_asr_event(switch_core_session_t *session, switch_event_t *event, switch_input_args_t *args)
struct fspr_pool_t switch_memory_pool_t
#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)
switch_status_t switch_ivr_record_file_event(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args, uint32_t limit, switch_event_t *vars)
switch_size_t pre_buffer_datalen
#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.
switch_status_t switch_channel_api_on(switch_channel_t *channel, const char *variable_prefix)
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_ivr_detect_speech_start_input_timers(switch_core_session_t *session)
Start input timers on a background speech detection handle.
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
switch_event_header_t * headers
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)
static int recording_var_true(switch_channel_t *channel, switch_event_t *vars, switch_file_handle_t *fh, const char *name)