Modules | |
| group | IVR Menu Library |
Typedefs | |
| typedef switch_ivr_digit_stream_parser | switch_ivr_digit_stream_parser_t |
| typedef switch_ivr_digit_stream | switch_ivr_digit_stream_t |
Functions | |
| switch_status_t | switch_ivr_deactivate_unicast (switch_core_session_t *session) |
| switch_status_t | switch_ivr_activate_unicast (switch_core_session_t *session, char *local_ip, switch_port_t local_port, char *remote_ip, switch_port_t remote_port, char *transport, char *flags) |
| switch_status_t | switch_ivr_generate_xml_cdr (switch_core_session_t *session, switch_xml_t *xml_cdr) |
| Generate an XML CDR report. | |
| int | switch_ivr_set_xml_profile_data (switch_xml_t xml, switch_caller_profile_t *caller_profile, int off) |
| int | switch_ivr_set_xml_chan_vars (switch_xml_t xml, switch_channel_t *channel, int off) |
| 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_parse_all_events (switch_core_session_t *session) |
| Parse all commands from an event. | |
| switch_status_t | switch_ivr_parse_next_event (switch_core_session_t *session) |
| switch_status_t | switch_ivr_sleep (switch_core_session_t *session, uint32_t ms, switch_input_args_t *args) |
| Wait for time to pass for a specified number of milliseconds. | |
| switch_status_t | switch_ivr_park (switch_core_session_t *session, switch_input_args_t *args) |
| switch_status_t | switch_ivr_collect_digits_callback (switch_core_session_t *session, switch_input_args_t *args, uint32_t timeout) |
| Wait for DTMF digits calling a pluggable callback function when digits are collected. | |
| 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_status_t | switch_ivr_detect_speech (switch_core_session_t *session, const char *mod_name, const char *grammar, const char *path, const char *dest, switch_asr_handle_t *ah) |
| Engage background Speech detection on a session. | |
| switch_status_t | switch_ivr_stop_detect_speech (switch_core_session_t *session) |
| Stop background Speech detection on a session. | |
| switch_status_t | switch_ivr_pause_detect_speech (switch_core_session_t *session) |
| Pause background Speech detection on a session. | |
| switch_status_t | switch_ivr_resume_detect_speech (switch_core_session_t *session) |
| Resume background Speech detection on a session. | |
| switch_status_t | switch_ivr_detect_speech_load_grammar (switch_core_session_t *session, char *grammar, char *path) |
| Load a grammar on a background speech detection handle. | |
| switch_status_t | switch_ivr_detect_speech_unload_grammar (switch_core_session_t *session, const char *grammar) |
| Unload a grammar on a background speech detection handle. | |
| switch_status_t | switch_ivr_record_session (switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh) |
| Record a session to disk. | |
| switch_status_t | switch_ivr_eavesdrop_session (switch_core_session_t *session, const char *uuid, const char *require_group, switch_eavesdrop_flag_t flags) |
| Eavesdrop on a another session. | |
| switch_status_t | switch_ivr_displace_session (switch_core_session_t *session, const char *file, uint32_t limit, const char *flags) |
| displace the media for a session with the audio from a file | |
| switch_status_t | switch_ivr_stop_displace_session (switch_core_session_t *session, const char *file) |
| Stop displacing a session. | |
| switch_status_t | switch_ivr_stop_record_session (switch_core_session_t *session, const char *file) |
| Stop Recording a session. | |
| switch_status_t | switch_ivr_inband_dtmf_session (switch_core_session_t *session) |
| Start looking for DTMF inband. | |
| switch_status_t | switch_ivr_stop_inband_dtmf_session (switch_core_session_t *session) |
| Stop looking for DTMF inband. | |
| switch_status_t | switch_ivr_inband_dtmf_generate_session (switch_core_session_t *session, switch_bool_t read_stream) |
| Start generating DTMF inband. | |
| switch_status_t | switch_ivr_stop_inband_dtmf_generate_session (switch_core_session_t *session) |
| Stop generating DTMF inband. | |
| void | switch_ivr_session_echo (switch_core_session_t *session, switch_input_args_t *args) |
| |
| switch_status_t | switch_ivr_stop_tone_detect_session (switch_core_session_t *session) |
| Stop looking for TONES. | |
| switch_status_t | switch_ivr_tone_detect_session (switch_core_session_t *session, const char *key, const char *tone_spec, const char *flags, time_t timeout, const char *app, const char *data) |
| Start looking for TONES. | |
| 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 | |
| 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_ivr_gentones (switch_core_session_t *session, char *script, int32_t loops, switch_input_args_t *args) |
| switch_status_t | switch_ivr_record_file (_In_ switch_core_session_t *session, _In_ switch_file_handle_t *fh, _In_z_ const char *file, _In_opt_ switch_input_args_t *args, _In_ uint32_t limit) |
| record a file from the session to a file | |
| 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, char *valid_terminators, char *audio_file, char *bad_input_audio_file, void *digit_buffer, uint32_t digit_buffer_length, char *digits_regex) |
| Play a sound and gather digits with the number of retries specified if the user doesn't give digits in the set time. | |
| 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) |
| void | switch_ivr_clear_speech_cache (switch_core_session_t *session) |
| 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. | |
| switch_status_t | switch_ivr_originate (switch_core_session_t *session, switch_core_session_t **bleg, switch_call_cause_t *cause, const char *bridgeto, uint32_t timelimit_sec, const switch_state_handler_table_t *table, const char *cid_name_override, const char *cid_num_override, switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags) |
| Make an outgoing call. | |
| switch_status_t | switch_ivr_multi_threaded_bridge (_In_ switch_core_session_t *session, _In_ switch_core_session_t *peer_session, switch_input_callback_function_t dtmf_callback, void *session_data, void *peer_session_data) |
| Bridge Audio from one session to another. | |
| switch_status_t | switch_ivr_signal_bridge (switch_core_session_t *session, switch_core_session_t *peer_session) |
| Bridge Signalling from one session to another. | |
| 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. | |
| uint32_t | switch_ivr_schedule_transfer (time_t runtime, const char *uuid, char *extension, char *dialplan, char *context) |
| Transfer an existing session to another location in the future. | |
| uint32_t | switch_ivr_schedule_hangup (time_t runtime, const char *uuid, switch_call_cause_t cause, switch_bool_t bleg) |
| Hangup an existing session in the future. | |
| switch_status_t | switch_ivr_uuid_bridge (const char *originator_uuid, const char *originatee_uuid) |
| Bridge two existing sessions. | |
| switch_status_t | switch_ivr_media (const char *uuid, switch_media_flag_t flags) |
| Signal a session to request direct media access to it's remote end. | |
| switch_status_t | switch_ivr_nomedia (const char *uuid, switch_media_flag_t flags) |
| Signal a session to request indirect media allowing it to exchange media directly with another device. | |
| switch_status_t | switch_ivr_hold_uuid (const char *uuid, const char *message, switch_bool_t moh) |
| Signal the session with a protocol specific hold message. | |
| switch_status_t | switch_ivr_unhold_uuid (const char *uuid) |
| Signal the session with a protocol specific unhold message. | |
| switch_status_t | switch_ivr_hold (switch_core_session_t *session, const char *message, switch_bool_t moh) |
| Signal the session with a protocol specific hold message. | |
| switch_status_t | switch_ivr_unhold (switch_core_session_t *session) |
| Signal the session with a protocol specific unhold message. | |
| uint32_t | switch_ivr_schedule_broadcast (time_t runtime, char *uuid, char *path, switch_media_flag_t flags) |
| Signal the session to broadcast audio in the future. | |
| switch_status_t | switch_ivr_broadcast (const char *uuid, const char *path, switch_media_flag_t flags) |
| Signal the session to broadcast audio. | |
| switch_status_t | switch_ivr_transfer_variable (switch_core_session_t *sessa, switch_core_session_t *sessb, char *var) |
| Transfer variables from one session to another. | |
| switch_status_t | switch_ivr_digit_stream_parser_new (switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser) |
| Create a digit stream parser object. | |
| switch_status_t | switch_ivr_digit_stream_parser_destroy (switch_ivr_digit_stream_parser_t *parser) |
| Destroy a digit stream parser object. | |
| switch_status_t | switch_ivr_digit_stream_new (switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t **stream) |
| Create a new digit stream object. | |
| switch_status_t | switch_ivr_digit_stream_destroy (switch_ivr_digit_stream_t *stream) |
| Destroys a digit stream object. | |
| switch_status_t | switch_ivr_digit_stream_parser_set_event (switch_ivr_digit_stream_parser_t *parser, char *digits, void *data) |
| Set a digit string to action mapping. | |
| switch_status_t | switch_ivr_digit_stream_parser_del_event (switch_ivr_digit_stream_parser_t *parser, char *digits) |
| Delete a string to action mapping. | |
| void * | switch_ivr_digit_stream_parser_feed (switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t *stream, char digit) |
| Feed digits collected into the stream for event match testing. | |
| switch_status_t | switch_ivr_digit_stream_reset (switch_ivr_digit_stream_t *stream) |
| Reset the collected digit stream to nothing. | |
| switch_status_t | switch_ivr_digit_stream_parser_set_terminator (switch_ivr_digit_stream_parser_t *parser, char digit) |
| Set a digit string terminator. | |
|
|
|
|
|
|
|
||||||||||||||||||||||||||||||||
|
00209 {
00210 switch_channel_t *channel = switch_core_session_get_channel(session);
00211 switch_unicast_conninfo_t *conninfo = switch_core_session_alloc(session, sizeof(*conninfo));
00212 switch_codec_t *read_codec;
00213
00214 switch_assert(conninfo != NULL);
00215
00216 conninfo->local_ip = switch_core_session_strdup(session, local_ip);
00217 conninfo->local_port = local_port;
00218
00219 conninfo->remote_ip = switch_core_session_strdup(session, remote_ip);
00220 conninfo->remote_port = remote_port;
00221 conninfo->session = session;
00222
00223 if (!strcasecmp(transport, "udp")) {
00224 conninfo->type = AF_INET;
00225 conninfo->transport = SOCK_DGRAM;
00226 } else if (!strcasecmp(transport, "tcp")) {
00227 conninfo->type = AF_INET;
00228 conninfo->transport = SOCK_STREAM;
00229 } else {
00230 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid transport %s\n", transport);
00231 goto fail;
00232 }
00233
00234 if (flags) {
00235 if (strstr(flags, "native")) {
00236 switch_set_flag(conninfo, SUF_NATIVE);
00237 }
00238 }
00239
00240 switch_mutex_init(&conninfo->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
00241
00242 read_codec = switch_core_session_get_read_codec(session);
00243
00244 if (!switch_test_flag(conninfo, SUF_NATIVE)) {
00245 if (switch_core_codec_init(&conninfo->read_codec,
00246 "L16",
00247 NULL,
00248 read_codec->implementation->actual_samples_per_second,
00249 read_codec->implementation->microseconds_per_frame / 1000,
00250 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
00251 NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
00252 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
00253 "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
00254 read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
00255 } else {
00256 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
00257 read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
00258 goto fail;
00259 }
00260 }
00261
00262 conninfo->write_frame.data = conninfo->write_frame_data;
00263 conninfo->write_frame.buflen = sizeof(conninfo->write_frame_data);
00264 conninfo->write_frame.codec = switch_test_flag(conninfo, SUF_NATIVE) ? read_codec : &conninfo->read_codec;
00265
00266 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d->%s:%d\n",
00267 conninfo->local_ip, conninfo->local_port, conninfo->remote_ip, conninfo->remote_port);
00268
00269 if (switch_sockaddr_info_get(&conninfo->local_addr,
00270 conninfo->local_ip, SWITCH_UNSPEC, conninfo->local_port, 0,
00271 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
00272 goto fail;
00273 }
00274
00275 if (switch_sockaddr_info_get(&conninfo->remote_addr,
00276 conninfo->remote_ip, SWITCH_UNSPEC, conninfo->remote_port, 0,
00277 switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
00278 goto fail;
00279 }
00280
00281 if (switch_socket_create(&conninfo->socket, AF_INET, SOCK_DGRAM, 0, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
00282 if (switch_socket_bind(conninfo->socket, conninfo->local_addr) != SWITCH_STATUS_SUCCESS) {
00283 goto fail;
00284 }
00285 } else {
00286 goto fail;
00287 }
00288
00289 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created unicast connection %s:%d->%s:%d\n",
00290 conninfo->local_ip, conninfo->local_port, conninfo->remote_ip, conninfo->remote_port);
00291 switch_channel_set_private(channel, "unicast", conninfo);
00292 switch_channel_set_flag(channel, CF_UNICAST);
00293 switch_set_flag_locked(conninfo, SUF_READY);
00294 return SWITCH_STATUS_SUCCESS;
00295
00296 fail:
00297
00298 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating unicast connection %s:%d->%s:%d\n",
00299 conninfo->local_ip, conninfo->local_port, conninfo->remote_ip, conninfo->remote_port);
00300 return SWITCH_STATUS_FALSE;
00301 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Signal the session to broadcast audio.
02017 {
02018 switch_channel_t *channel;
02019 int nomedia;
02020 switch_core_session_t *session, *master;
02021 switch_event_t *event;
02022 switch_core_session_t *other_session = NULL;
02023 const char *other_uuid = NULL;
02024 char *app = "playback";
02025 char *cause = NULL;
02026 char *mypath;
02027 char *p;
02028
02029 switch_assert(path);
02030
02031 if (!(master = session = switch_core_session_locate(uuid))) {
02032 return SWITCH_STATUS_FALSE;
02033 }
02034
02035 channel = switch_core_session_get_channel(session);
02036
02037 if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
02038 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s][%s] already broadcasting...broadcast aborted\n",
02039 switch_channel_get_name(channel), path);
02040 switch_core_session_rwunlock(session);
02041 return SWITCH_STATUS_FALSE;
02042 }
02043
02044 mypath = strdup(path);
02045
02046 if (!mypath) {
02047 switch_core_session_rwunlock(session);
02048 return SWITCH_STATUS_MEMERR;
02049 }
02050
02051 if ((nomedia = switch_channel_test_flag(channel, CF_PROXY_MODE))) {
02052 switch_ivr_media(uuid, SMF_REBRIDGE);
02053 }
02054
02055 if ((p = strchr(mypath, ':')) && *(p + 1) == ':') {
02056 app = mypath;
02057 *p++ = '\0';
02058 *p++ = '\0';
02059 path = p;
02060 }
02061
02062 if ((cause = strchr(app, '!'))) {
02063 *cause++ = '\0';
02064 if (!cause) {
02065 cause = "normal_clearing";
02066 }
02067 }
02068
02069 if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
02070 && (other_session = switch_core_session_locate(other_uuid))) {
02071 if (switch_event_create(&event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
02072 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
02073 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute-app-name", app);
02074 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute-app-arg", path);
02075 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
02076 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event-lock", "true");
02077 if ((flags & SMF_LOOP)) {
02078 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
02079 }
02080 if ((flags & SMF_HOLD_BLEG)) {
02081 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hold-bleg", "true");
02082 }
02083
02084 switch_core_session_queue_private_event(other_session, &event);
02085 }
02086
02087 switch_core_session_rwunlock(other_session);
02088 master = other_session;
02089 other_session = NULL;
02090 }
02091
02092 if ((flags & SMF_ECHO_ALEG)) {
02093 if (switch_event_create(&event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
02094 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
02095 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute-app-name", app);
02096 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute-app-arg", path);
02097 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
02098 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event-lock", "true");
02099 if ((flags & SMF_LOOP)) {
02100 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
02101 }
02102 if ((flags & SMF_HOLD_BLEG)) {
02103 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hold-bleg", "true");
02104 }
02105
02106 switch_core_session_queue_private_event(session, &event);
02107 }
02108 master = session;
02109 }
02110
02111 if (nomedia) {
02112 if (switch_event_create(&event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
02113 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
02114 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", uuid);
02115 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event-lock", "true");
02116 switch_core_session_queue_private_event(master, &event);
02117 }
02118 }
02119
02120 if (cause) {
02121 if (switch_event_create(&event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
02122 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
02123 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
02124 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute-app-arg", cause);
02125 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event-lock", "true");
02126 switch_core_session_queue_private_event(session, &event);
02127 }
02128 }
02129
02130 switch_core_session_rwunlock(session);
02131 switch_safe_free(mypath);
02132
02133 return SWITCH_STATUS_SUCCESS;
02134 }
|
Here is the call graph for this function:

|
|
01822 {
01823 cached_speech_handle_t *cache_obj = NULL;
01824 switch_channel_t *channel = switch_core_session_get_channel(session);
01825
01826 if ((cache_obj = switch_channel_get_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME))) {
01827 switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
01828 if (cache_obj->timer.interval) {
01829 switch_core_timer_destroy(&cache_obj->timer);
01830 }
01831 switch_core_speech_close(&cache_obj->sh, &flags);
01832 switch_core_codec_destroy(&cache_obj->codec);
01833 switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL);
01834 }
01835 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Wait for DTMF digits calling a pluggable callback function when digits are collected.
00644 {
00645 switch_channel_t *channel = switch_core_session_get_channel(session);
00646 switch_status_t status = SWITCH_STATUS_SUCCESS;
00647 switch_time_t started = 0;
00648 uint32_t elapsed;
00649
00650 if (!args || !args->input_callback) {
00651 return SWITCH_STATUS_GENERR;
00652 }
00653
00654 if (timeout) {
00655 started = switch_timestamp_now();
00656 }
00657
00658 while (switch_channel_ready(channel)) {
00659 switch_frame_t *read_frame = NULL;
00660 switch_event_t *event;
00661 switch_dtmf_t dtmf = { 0 };
00662
00663 if (switch_channel_test_flag(channel, CF_BREAK)) {
00664 switch_channel_clear_flag(channel, CF_BREAK);
00665 status = SWITCH_STATUS_BREAK;
00666 break;
00667 }
00668
00669 if (timeout) {
00670 elapsed = (uint32_t) ((switch_timestamp_now() - started) / 1000);
00671 if (elapsed >= timeout) {
00672 break;
00673 }
00674 }
00675
00676 if (switch_core_session_private_event_count(session)) {
00677 switch_ivr_parse_all_events(session);
00678 }
00679
00680 if (switch_channel_has_dtmf(channel)) {
00681 switch_channel_dequeue_dtmf(channel, &dtmf);
00682 status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
00683 }
00684
00685 if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
00686 status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen);
00687 switch_event_destroy(&event);
00688 }
00689
00690 if (status != SWITCH_STATUS_SUCCESS) {
00691 break;
00692 }
00693
00694 if (switch_channel_test_flag(channel, CF_SERVICE)) {
00695 switch_yield(1000);
00696 } else {
00697 status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
00698 }
00699
00700 if (!SWITCH_READ_ACCEPTABLE(status)) {
00701 break;
00702 }
00703
00704 if (read_frame && args && (args->read_frame_callback)) {
00705 if (args->read_frame_callback(session, read_frame, args->user_data) != SWITCH_STATUS_SUCCESS) {
00706 break;
00707 }
00708 }
00709 }
00710
00711 return status;
00712 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||||||
|
Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up.
00720 {
00721 switch_size_t i = 0, x = strlen(buf);
00722 switch_channel_t *channel = switch_core_session_get_channel(session);
00723 switch_status_t status = SWITCH_STATUS_FALSE;
00724 switch_time_t started = 0, digit_started = 0;
00725 uint32_t abs_elapsed = 0, digit_elapsed = 0;
00726 uint32_t eff_timeout = 0;
00727
00728 if (terminator != NULL)
00729 *terminator = '\0';
00730
00731 if (!switch_strlen_zero(terminators)) {
00732 for (i = 0; i < x; i++) {
00733 if (strchr(terminators, buf[i]) && terminator != NULL) {
00734 *terminator = buf[i];
00735 buf[i] = '\0';
00736 return SWITCH_STATUS_SUCCESS;
00737 }
00738 }
00739 }
00740
00741 if (abs_timeout) {
00742 started = switch_timestamp_now();
00743 }
00744
00745 if (digit_timeout && first_timeout) {
00746 eff_timeout = first_timeout;
00747 } else if (digit_timeout && !first_timeout) {
00748 first_timeout = eff_timeout = digit_timeout;
00749 } else if (first_timeout) {
00750 digit_timeout = eff_timeout = first_timeout;
00751 }
00752
00753
00754 if (eff_timeout) {
00755 digit_started = switch_timestamp_now();
00756 }
00757
00758 while (switch_channel_ready(channel)) {
00759 switch_frame_t *read_frame;
00760
00761 if (abs_timeout) {
00762 abs_elapsed = (uint32_t) ((switch_timestamp_now() - started) / 1000);
00763 if (abs_elapsed >= abs_timeout) {
00764 break;
00765 }
00766 }
00767
00768 if (switch_core_session_private_event_count(session)) {
00769 switch_ivr_parse_all_events(session);
00770 }
00771
00772
00773 if (eff_timeout) {
00774 digit_elapsed = (uint32_t) ((switch_timestamp_now() - digit_started) / 1000);
00775 if (digit_elapsed >= eff_timeout) {
00776 status = SWITCH_STATUS_TIMEOUT;
00777 break;
00778 }
00779 }
00780
00781 if (switch_channel_has_dtmf(channel)) {
00782 switch_dtmf_t dtmf = { 0 };
00783 switch_size_t y;
00784
00785 if (eff_timeout) {
00786 eff_timeout = digit_timeout;
00787 digit_started = switch_timestamp_now();
00788 }
00789
00790 for (y = 0; y <= maxdigits; y++) {
00791 if (switch_channel_dequeue_dtmf(channel, &dtmf) != SWITCH_STATUS_SUCCESS) {
00792 break;
00793 }
00794
00795 if (!switch_strlen_zero(terminators) && strchr(terminators, dtmf.digit) && terminator != NULL) {
00796 *terminator = dtmf.digit;
00797 return SWITCH_STATUS_SUCCESS;
00798 }
00799
00800
00801 buf[x++] = dtmf.digit;
00802 buf[x] = '\0';
00803 if (x >= buflen || x >= maxdigits) {
00804 return SWITCH_STATUS_SUCCESS;
00805 }
00806 }
00807 }
00808
00809 if (switch_channel_test_flag(channel, CF_SERVICE)) {
00810 switch_yield(1000);
00811 } else {
00812 status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
00813 if (!SWITCH_READ_ACCEPTABLE(status)) {
00814 break;
00815 }
00816 }
00817 }
00818
00819 return status;
00820 }
|
Here is the call graph for this function:

|
|
00177 {
00178 switch_channel_t *channel = switch_core_session_get_channel(session);
00179 switch_unicast_conninfo_t *conninfo;
00180 int sanity = 0;
00181
00182 if (!switch_channel_test_flag(channel, CF_UNICAST)) {
00183 return SWITCH_STATUS_FALSE;
00184 }
00185
00186 if ((conninfo = switch_channel_get_private(channel, "unicast"))) {
00187 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down unicast connection\n");
00188 switch_clear_flag_locked(conninfo, SUF_READY);
00189 switch_socket_shutdown(conninfo->socket, SWITCH_SHUTDOWN_READWRITE);
00190 while (switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
00191 switch_yield(10000);
00192 if (++sanity >= 10000) {
00193 break;
00194 }
00195 }
00196 if (conninfo->read_codec.implementation) {
00197 switch_core_codec_destroy(&conninfo->read_codec);
00198 }
00199 switch_socket_close(conninfo->socket);
00200 }
00201 switch_channel_clear_flag(channel, CF_UNICAST);
00202 return SWITCH_STATUS_SUCCESS;
00203 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||
|
Engage background Speech detection on a session.
01803 {
01804 switch_channel_t *channel = switch_core_session_get_channel(session);
01805 switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
01806 switch_status_t status;
01807 switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
01808 struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
01809
01810 if (!ah) {
01811 if (!(ah = switch_core_session_alloc(session, sizeof(*ah)))) {
01812 return SWITCH_STATUS_MEMERR;
01813 }
01814 }
01815
01816 switch_assert(read_codec != NULL);
01817
01818 if ((switch_channel_get_variable(channel, "fire_asr_events"))) {
01819 switch_set_flag(ah, SWITCH_ASR_FLAG_FIRE_EVENTS);
01820 }
01821
01822 if (sth) {
01823 if (switch_core_asr_load_grammar(sth->ah, grammar, path) != SWITCH_STATUS_SUCCESS) {
01824 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
01825 switch_core_asr_close(sth->ah, &flags);
01826 return SWITCH_STATUS_FALSE;
01827 }
01828
01829 return SWITCH_STATUS_SUCCESS;
01830 }
01831
01832 if (switch_core_asr_open(ah,
01833 mod_name,
01834 "L16",
01835 read_codec->implementation->actual_samples_per_second, dest, &flags,
01836 switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
01837
01838 if (switch_core_asr_load_grammar(ah, grammar, path) != SWITCH_STATUS_SUCCESS) {
01839 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
01840 switch_core_asr_close(ah, &flags);
01841 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
01842 return SWITCH_STATUS_FALSE;
01843 }
01844 } else {
01845 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
01846 return SWITCH_STATUS_FALSE;
01847 }
01848
01849 sth = switch_core_session_alloc(session, sizeof(*sth));
01850 sth->pool = switch_core_session_get_pool(session);
01851 sth->session = session;
01852 sth->ah = ah;
01853
01854 if ((status = switch_core_media_bug_add(session, speech_callback, sth, 0, SMBF_READ_STREAM, &sth->bug)) != SWITCH_STATUS_SUCCESS) {
01855 switch_core_asr_close(ah, &flags);
01856 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
01857 return status;
01858 }
01859
01860 switch_channel_set_private(channel, SWITCH_SPEECH_KEY, sth);
01861
01862 return SWITCH_STATUS_SUCCESS;
01863 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Load a grammar on a background speech detection handle.
01765 {
01766 switch_channel_t *channel = switch_core_session_get_channel(session);
01767 switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
01768 struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
01769
01770 if (sth) {
01771 if (switch_core_asr_load_grammar(sth->ah, grammar, path) != SWITCH_STATUS_SUCCESS) {
01772 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
01773 switch_core_asr_close(sth->ah, &flags);
01774 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
01775 return SWITCH_STATUS_FALSE;
01776 }
01777 return SWITCH_STATUS_SUCCESS;
01778 }
01779 return SWITCH_STATUS_FALSE;
01780 }
|
Here is the call graph for this function:

|
||||||||||||
|
Unload a grammar on a background speech detection handle.
01783 {
01784 switch_channel_t *channel = switch_core_session_get_channel(session);
01785 switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
01786 struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
01787
01788 if (sth) {
01789 if (switch_core_asr_unload_grammar(sth->ah, grammar) != SWITCH_STATUS_SUCCESS) {
01790 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error unloading Grammar\n");
01791 switch_core_asr_close(sth->ah, &flags);
01792 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
01793 return SWITCH_STATUS_FALSE;
01794 }
01795 return SWITCH_STATUS_SUCCESS;
01796 }
01797 return SWITCH_STATUS_FALSE;
01798 }
|
Here is the call graph for this function:

|
|
Destroys a digit stream object.
01249 {
01250 switch_status_t status = SWITCH_STATUS_FALSE;
01251
01252 if (stream && stream->digits != NULL) {
01253 free(stream->digits);
01254 stream->digits = NULL;
01255 status = SWITCH_STATUS_SUCCESS;
01256 }
01257
01258 return status;
01259 }
|
|
||||||||||||
|
Create a new digit stream object.
01233 {
01234 switch_status_t status = SWITCH_STATUS_FALSE;
01235
01236 /* if we have a parser object memory pool and a stream object pointer that is null */
01237 if (parser != NULL && parser->pool && stream != NULL && *stream == NULL) {
01238 *stream = (switch_ivr_digit_stream_t *) switch_core_alloc(parser->pool, sizeof(switch_ivr_digit_stream_t));
01239 if (*stream != NULL) {
01240 memset(*stream, 0, sizeof(switch_ivr_digit_stream_t));
01241 status = SWITCH_STATUS_SUCCESS;
01242 }
01243 }
01244
01245 return status;
01246 }
|
|
||||||||||||
|
Delete a string to action mapping.
01299 {
01300 switch_status_t status = SWITCH_STATUS_FALSE;
01301
01302 if (parser != NULL && digits != NULL && *digits) {
01303 status = switch_core_hash_delete(parser->hash, digits);
01304 }
01305
01306 if (status != SWITCH_STATUS_SUCCESS) {
01307 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unable to del hash for '%s'\n", digits);
01308 }
01309
01310 return status;
01311 }
|
Here is the call graph for this function:

|
|
Destroy a digit stream parser object.
01215 {
01216 switch_status_t status = SWITCH_STATUS_FALSE;
01217
01218 if (parser != NULL) {
01219 if (parser->hash != |