FreeSWITCH API Documentation  1.7.0
switch_ivr.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  * Neal Horman <neal at wanlink dot com>
28  * Bret McDanel <trixter AT 0xdecafbad dot com>
29  * Luke Dashjr <luke@openmethods.com> (OpenMethods, LLC)
30  *
31  * switch_ivr.h -- IVR Library
32  *
33  */
34 /**
35  * @file switch_ivr.h
36  * @brief IVR Library
37  * @see switch_ivr
38  */
39 
40 #ifndef SWITCH_IVR_H
41 #define SWITCH_IVR_H
42 
43 #include <switch.h>
44 #include <switch_core_video.h>
45 #include "switch_json.h"
46 
53  char *local_ip;
55  char *remote_ip;
60  int32_t flags;
61  int type;
62  int transport;
63  int stream_id;
65 };
67 
68 #define SWITCH_IVR_VERIFY_SILENCE_DIVISOR(divisor) \
69  { \
70  if ((divisor) <= 0 && (divisor) != -1) { \
71  divisor = 400; \
72  } \
73  }
74 
75 /**
76  * @defgroup switch_ivr IVR Library
77  * @ingroup core1
78  * A group of core functions to do IVR related functions designed to be
79  * building blocks for a higher level IVR interface.
80  * @{
81  */
82 
85  char *local_ip,
87  char *remote_ip, switch_port_t remote_port, char *transport, char *flags);
88 /*!
89  \brief Generate an JSON CDR report.
90  \param session the session to get the data from.
91  \param json_cdr pointer to the json object
92  \return SWITCH_STATUS_SUCCESS if successful
93  \note on success the json object must be freed
94 */
96 
97 /*!
98  \brief Generate an XML CDR report.
99  \param session the session to get the data from.
100  \param xml_cdr pointer to the xml_record
101  \return SWITCH_STATUS_SUCCESS if successful
102  \note on success the xml object must be freed
103 */
107 
108 /*!
109  \brief Parse command from an event
110  \param session the session on which to parse the event
111  \param event the event to parse
112  \return SWITCH_STATUS_SUCCESS if successful
113 */
115 
116 /*!
117  \brief Parse all commands from an event
118  \param session the session on which to parse the events
119  \return SWITCH_STATUS_SUCCESS if successful
120 */
128 
129 /*!
130  \brief Wait for time to pass for a specified number of milliseconds
131  \param session the session to wait for.
132  \param ms the number of milliseconds
133  \param sync synchronize the channel's audio before waiting
134  \param args arguements to pass for callbacks etc
135  \return SWITCH_STATUS_SUCCESS if the channel is still up
136 */
138 
140 
141 /*!
142  \brief Wait for DTMF digits calling a pluggable callback function when digits are collected.
143  \param session the session to read.
144  \param args arguements to pass for callbacks etc
145  \param timeout a timeout in milliseconds
146  \return SWITCH_STATUS_SUCCESS to keep the collection moving.
147 */
149  uint32_t abs_timeout);
150 
151 /*!
152  \brief Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up.
153  \param session the session to read.
154  \param buf strig to write to
155  \param buflen max size of buf
156  \param maxdigits max number of digits to read
157  \param terminators digits to end the collection
158  \param terminator actual digit that caused the collection to end (if any)
159  \param first_timeout timeout in ms
160  \param digit_timeout digit timeout in ms
161  \param abs_timeout abs timeout in ms
162  \return SWITCH_STATUS_SUCCESS to keep the collection moving.
163 */
165  char *buf,
167  switch_size_t maxdigits,
168  const char *terminators, char *terminator,
169  uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout);
170 
171 /*!
172  \brief play a file to the session while doing speech recognition.
173  \param session the session to play and detect on
174  \param file the path to the file
175  \param mod_name the module name of the ASR library
176  \param grammar the grammar text, URI, or local file name
177  \param result of speech recognition, allocated from the session pool
178  \param input_timeout time to wait for input
179  \param args arguements to pass for callbacks etc
180  \return SWITCH_STATUS_SUCCESS if all is well
181 */
183  const char *file,
184  const char *mod_name,
185  const char *grammar,
186  char **result,
187  uint32_t input_timeout,
188  switch_input_args_t *args);
189 
190 
191 /*!
192  \brief Initialize background Speech detection on a session, so that parameters can be set, and grammars loaded.
193  After calling this function, it is possible to call switch_ivr_set_param_detect_speech() to set recognition parameters.
194  Calling switch_ivr_detect_speech_load_grammar() starts the speech recognition.
195  \param session the session to attach
196  \param mod_name the module name of the ASR library
197  \param dest the destination address
198  \param ah an ASR handle to use (NULL to create one)
199  \return SWITCH_STATUS_SUCCESS if all is well
200 */
202  const char *dest, switch_asr_handle_t *ah);
203 /*!
204  \brief Engage background Speech detection on a session
205  \param session the session to attach
206  \param mod_name the module name of the ASR library
207  \param grammar the grammar text, URI, or local file name
208  \param name the grammar name
209  \param dest the destination address
210  \param ah an ASR handle to use (NULL to create one)
211  \return SWITCH_STATUS_SUCCESS if all is well
212 */
214  const char *mod_name,
215  const char *grammar, const char *name, const char *dest, switch_asr_handle_t *ah);
216 
217 /*!
218  \brief Stop background Speech detection on a session
219  \param session The session to stop detection on
220  \return SWITCH_STATUS_SUCCESS if all is well
221 */
223 
224 /*!
225  \brief Pause background Speech detection on a session
226  \param session The session to pause detection on
227  \return SWITCH_STATUS_SUCCESS if all is well
228 */
230 
231 /*!
232  \brief Resume background Speech detection on a session
233  \param session The session to resume detection on
234  \return SWITCH_STATUS_SUCCESS if all is well
235 */
237 
238 /*!
239  \brief Load a grammar on a background speech detection handle
240  \param session The session to change the grammar on
241  \param grammar the grammar text, URI, or local file name
242  \param name the grammar name
243  \return SWITCH_STATUS_SUCCESS if all is well
244 */
245 SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, const char *grammar, const char *name);
246 
247 /*!
248  \brief Unload a grammar on a background speech detection handle
249  \param session The session to change the grammar on
250  \param name the grammar name
251  \return SWITCH_STATUS_SUCCESS if all is well
252 */
254 
255 /*!
256  \brief Enable a grammar on a background speech detection handle
257  \param session The session to change the grammar on
258  \param name the grammar name
259  \return SWITCH_STATUS_SUCCESS if all is well
260 */
262 
263 /*!
264  \brief Disable a grammar on a background speech detection handle
265  \param session The session to change the grammar on
266  \param name the grammar name
267  \return SWITCH_STATUS_SUCCESS if all is well
268 */
270 
271 /*!
272  \brief Disable all grammars on a background speech detection handle
273  \param session The session to change the grammar on
274  \return SWITCH_STATUS_SUCCESS if all is well
275 */
277 
278 SWITCH_DECLARE(switch_status_t) switch_ivr_set_param_detect_speech(switch_core_session_t *session, const char *name, const char *val);
279 
280 /*!
281  \brief Start input timers on a background speech detection handle
282  \param session The session to start the timers on
283  \return SWITCH_STATUS_SUCCESS if all is well
284 */
286 
287 /*!
288  \brief Record a session to disk
289  \param session the session to record
290  \param file the path to the file
291  \param limit stop recording after this amount of time (in ms, 0 = never stop)
292  \param fh file handle to use (NULL for builtin one)
293  \return SWITCH_STATUS_SUCCESS if all is well
294 */
297 
298 
300 SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_exec_all(switch_core_session_t *session, const char *app, const char *arg);
301 SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_update_display(switch_core_session_t *session, const char *name, const char *number);
302 
303 /*!
304  \brief Eavesdrop on a another session
305  \param session our session
306  \param uuid the uuid of the session to spy on
307  \param require_group group name to use to limit by group
308  \param flags tweak read-mux, write-mux and dtmf
309  \return SWITCH_STATUS_SUCESS if all is well
310 */
312  const char *uuid, const char *require_group, switch_eavesdrop_flag_t flags);
313 
314 /*!
315  \brief displace the media for a session with the audio from a file
316  \param session the session to displace
317  \param file filename
318  \param limit time limit in ms
319  \param flags m (mux) l (loop) or r(read session instead of write session)
320  \return SWITCH_STATUS_SUCCESS if all is well
321 */
322 SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags);
323 
324 /*!
325  \brief Stop displacing a session
326  \param session the session
327  \param file file name from the switch_ivr_displace_session call
328  \return SWITCH_STATUS_SUCCESS if all is well
329 */
331 
332 /*!
333  \brief Stop Recording a session
334  \param session the session to stop recording
335  \param file the path to the file
336  \return SWITCH_STATUS_SUCCESS if all is well
337 */
339 
340 
341 SWITCH_DECLARE(switch_status_t) switch_ivr_session_audio(switch_core_session_t *session, const char *cmd, const char *direction, int level);
343 
344 /*!
345  \brief Start looking for DTMF inband
346  \param session the session to start looking
347  \return SWITCH_STATUS_SUCCESS if all is well
348 */
350 
351 /*!
352  \brief Stop looking for DTMF inband
353  \param session the session to stop looking
354  \return SWITCH_STATUS_SUCCESS if all is well
355 */
357 
358 
359 /*!
360  \brief Start generating DTMF inband
361  \param session the session to generate on
362  \param read_stream true to use the session we are reading from, false for the session we are writing to.
363  \return SWITCH_STATUS_SUCCESS if all is well
364 */
366 
367 /*!
368  \brief Stop generating DTMF inband
369  \param session the session to stop generating
370  \return SWITCH_STATUS_SUCCESS if all is well
371 */
373 
374 /*!
375  \brief - NEEDDESC -
376  \param session the session to act on
377 */
379 
380 /*!
381  \brief Stop looking for TONES
382  \param session the session to stop looking
383  \return SWITCH_STATUS_SUCCESS if all is well
384 */
386 
387 /*!
388  \brief Start looking for TONES
389  \param session the session to start looking
390  \param key the name of the tone.
391  \param tone_spec comma sep list of tone freqs
392  \param flags one or both of 'r' and 'w'
393  \param timeout timeout
394  \param app optional application to execute when tone is found
395  \param data optional data for appliaction
396  \return SWITCH_STATUS_SUCCESS if all is well
397 */
399  const char *key, const char *tone_spec,
400  const char *flags, time_t timeout, int hits,
401  const char *app, const char *data, switch_tone_detect_callback_t callback);
402 
403 
404 
405 
406 /*!
407  \brief play a file from the disk to the session
408  \param session the session to play the file too
409  \param fh file handle to use (NULL for builtin one)
410  \param file the path to the file
411  \param args arguements to pass for callbacks etc
412  \return SWITCH_STATUS_SUCCESS if all is well
413 */
415  switch_input_args_t *args);
416 
417 SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_t *session, uint32_t thresh, uint32_t silence_hits,
418  uint32_t listen_hits, uint32_t timeout_ms, const char *file);
419 
420 SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, const char *script, int32_t loops, switch_input_args_t *args);
421 
422 /*!
423  \brief record a file from the session to a file
424  \param session the session to record from
425  \param fh file handle to use
426  \param file the path to the file
427  \param args arguements to pass for callbacks etc
428  \param limit max limit to record for (0 for infinite)
429  \return SWITCH_STATUS_SUCCESS if all is well
430 */
433  _In_z_ const char *file, _In_opt_ switch_input_args_t *args, _In_ uint32_t limit);
434 
435 
436 /*!
437  \brief Play a sound and gather digits with the number of retries specified if the user doesn't give digits in the set time
438  \param session the current session to play sound to and collect digits
439  \param min_digits the fewest digits allowed for the response to be valid
440  \param max_digits the max number of digits to accept
441  \param max_tries number of times to replay the sound and capture digits
442  \param timeout time to wait for input (this is per iteration, so total possible time = max_tries * (timeout + audio playback length)
443  \param valid_terminators for input that can include # or * (useful for variable length prompts)
444  \param audio_file file to play
445  \param bad_input_audio_file file to play if the input from the user was invalid
446  \param var_name variable name to put results in
447  \param digit_buffer variable digits captured will be put back into (empty if capture failed)
448  \param digit_buffer_length length of the buffer for digits (should be the same or larger than max_digits)
449  \param digits_regex the qualifying regex
450  \return switch status, used to note status of channel (will still return success if digit capture failed)
451  \note to test for digit capture failure look for \\0 in the first position of the buffer
452 */
454  uint32_t min_digits,
455  uint32_t max_digits,
456  uint32_t max_tries,
457  uint32_t timeout,
458  const char *valid_terminators,
459  const char *audio_file,
460  const char *bad_input_audio_file,
461  const char *var_name, char *digit_buffer, uint32_t digit_buffer_length,
462  const char *digits_regex,
463  uint32_t digit_timeout,
464  const char *transfer_on_failure);
465 
468  switch_codec_t *codec, switch_timer_t *timer, char *text, switch_input_args_t *args);
470 /*!
471  \brief Speak given text with given tts engine
472  \param session the session to speak on
473  \param tts_name the desired tts module
474  \param voice_name the desired voice
475  \param text the text to speak
476  \param args arguements to pass for callbacks etc
477  \return SWITCH_STATUS_SUCCESS if all is well
478 */
480  const char *tts_name, const char *voice_name, char *text, switch_input_args_t *args);
481 
482 /*!
483  \brief Make an outgoing call
484  \param session originating session
485  \param bleg B leg session
486  \param cause a pointer to hold call cause
487  \param bridgeto the desired remote callstring
488  \param timelimit_sec timeout in seconds for outgoing call
489  \param table optional state handler table to install on the channel
490  \param cid_name_override override the caller id name
491  \param cid_num_override override the caller id number
492  \param caller_profile_override override the entire calling caller profile
493  \param ovars variables to be set on the outgoing channel
494  \param flags flags to pass
495  \return SWITCH_STATUS_SUCCESS if bleg is a running session.
496  \note bleg will be read locked which must be unlocked with switch_core_session_rwunlock() before losing scope
497 */
499  switch_core_session_t **bleg,
500  switch_call_cause_t *cause,
501  const char *bridgeto,
502  uint32_t timelimit_sec,
503  const switch_state_handler_table_t *table,
504  const char *cid_name_override,
505  const char *cid_num_override,
506  switch_caller_profile_t *caller_profile_override,
507  switch_event_t *ovars, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
508 
510  switch_core_session_t **bleg,
511  switch_call_cause_t *cause,
512  const char *bridgeto,
513  uint32_t timelimit_sec,
514  const switch_state_handler_table_t *table,
515  const char *cid_name_override,
516  const char *cid_num_override,
517  switch_caller_profile_t *caller_profile_override,
519  switch_call_cause_t *cancel_cause);
520 
522 
523 /*!
524  \brief Bridge Audio from one session to another
525  \param session one session
526  \param peer_session the other session
527  \param dtmf_callback a callback for messages and dtmf
528  \param session_data data to pass to the DTMF callback for session
529  \param peer_session_data data to pass to the DTMF callback for peer_session
530  \return SWITCH_STATUS_SUCCESS if all is well
531 */
533  _In_ switch_core_session_t *peer_session,
535  void *peer_session_data);
536 
537 /*!
538  \brief Bridge Signalling from one session to another
539  \param session one session
540  \param peer_session the other session
541  \return SWITCH_STATUS_SUCCESS if all is well
542 */
544 
545 /*!
546  \brief Transfer an existing session to another location
547  \param session the session to transfer
548  \param extension the new extension
549  \param dialplan the new dialplan (OPTIONAL, may be NULL)
550  \param context the new context (OPTIONAL, may be NULL)
551 */
552 SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan,
553  const char *context);
554 
555 /*!
556  \brief Transfer an existing session to another location in the future
557  \param runtime the time (int epoch seconds) to transfer the call
558  \param uuid the uuid of the session to transfer
559  \param extension the new extension
560  \param dialplan the new dialplan (OPTIONAL, may be NULL)
561  \param context the new context (OPTIONAL, may be NULL)
562  \return the id of the task
563 */
564 SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, const char *uuid, char *extension, char *dialplan, char *context);
565 
566 
567 /*!
568  \brief Hangup an existing session in the future
569  \param runtime the time (int epoch seconds) to transfer the call
570  \param uuid the uuid of the session to hangup
571  \param cause the hanup cause code
572  \param bleg hangup up the B-Leg if possible
573  \return the id of the task
574 */
575 SWITCH_DECLARE(uint32_t) switch_ivr_schedule_hangup(time_t runtime, const char *uuid, switch_call_cause_t cause, switch_bool_t bleg);
576 
577 /*!
578  \brief Bridge two existing sessions
579  \param originator_uuid the uuid of the originator
580  \param originatee_uuid the uuid of the originator
581  \remark Any custom state handlers on both channels will be deleted
582  \return SWITCH_STATUS_SUCCESS if all is well
583 */
584 SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uuid, const char *originatee_uuid);
585 
586 /*!
587  \brief Signal a session to request direct media access to it's remote end
588  \param uuid the uuid of the session to request
589  \param flags flags to influence behaviour (SMF_REBRIDGE to rebridge the call in media mode)
590  \return SWITCH_STATUS_SUCCESS if all is well
591 */
594 /*!
595  \brief Signal a session to request indirect media allowing it to exchange media directly with another device
596  \param uuid the uuid of the session to request
597  \param flags flags to influence behaviour (SMF_REBRIDGE to rebridge the call in no_media mode)
598  \return SWITCH_STATUS_SUCCESS if all is well
599 */
602 
603 SWITCH_DECLARE(void) switch_ivr_bg_media(const char *uuid, switch_media_flag_t flags, switch_bool_t on, switch_bool_t is3p, uint32_t delay);
604 
605 /*!
606  \brief Signal the session with a protocol specific hold message.
607  \param uuid the uuid of the session to hold
608  \param message optional message
609  \param moh play music-on-hold
610  \return SWITCH_STATUS_SUCCESS if all is well
611 */
612 SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message, switch_bool_t moh);
613 
614 /*!
615  \brief Toggles channel hold state of session
616  \param uuid the uuid of the session to hold
617  \param message optional message
618  \param moh play music-on-hold
619  \return SWITCH_STATUS_SUCCESS if all is well
620 */
621 SWITCH_DECLARE(switch_status_t) switch_ivr_hold_toggle_uuid(const char *uuid, const char *message, switch_bool_t moh);
622 
623 /*!
624  \brief Signal the session with a protocol specific unhold message.
625  \param uuid the uuid of the session to hold
626  \return SWITCH_STATUS_SUCCESS if all is well
627 */
629 
630 /*!
631  \brief Signal the session with a protocol specific hold message.
632  \param session the session to hold
633  \param message optional message
634  \param moh play music-on-hold
635  \return SWITCH_STATUS_SUCCESS if all is well
636 */
638 
639 /*!
640  \brief Signal the session with a protocol specific unhold message.
641  \param session the session to unhold
642  \return SWITCH_STATUS_SUCCESS if all is well
643 */
645 
646 /*!
647  \brief Signal the session to broadcast audio in the future
648  \param runtime when (in epoch time) to run the broadcast
649  \param uuid the uuid of the session to broadcast on
650  \param path the path data of the broadcast "/path/to/file.wav [<timer name>]" or "speak:<engine>|<voice>|<Text to say>"
651  \param flags flags to send to the request (SMF_ECHO_BRIDGED to send the broadcast to both sides of the call)
652  \return the id of the task
653 */
654 SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, const char *uuid, const char *path, switch_media_flag_t flags);
655 
656 /*!
657  \brief Signal the session to broadcast audio
658  \param uuid the uuid of the session to broadcast on
659  \param path the path data of the broadcast "/path/to/file.wav [<timer name>]" or "speak:<engine>|<voice>|<Text to say>"
660  \param flags flags to send to the request (SMF_ECHO_BRIDGED to send the broadcast to both sides of the call)
661  \return SWITCH_STATUS_SUCCESS if all is well
662 */
663 SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(const char *uuid, const char *path, switch_media_flag_t flags);
664 SWITCH_DECLARE(void) switch_ivr_broadcast_in_thread(switch_core_session_t *session, const char *app, int flags);
665 
666 /*!
667  \brief Transfer variables from one session to another
668  \param sessa the original session
669  \param sessb the new session
670  \param var the name of the variable to transfer (NULL for all)
671  \return SWITCH_STATUS_SUCCESS if all is well
672 */
674 
675 
676 /******************************************************************************************************/
677 
679  typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t;
681  typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t;
682 /*!
683  \brief Create a digit stream parser object
684  \param pool the pool to use for the new hash
685  \param parser a pointer to the object pointer
686  \return SWITCH_STATUS_SUCCESS if all is well
687 */
688 SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t ** parser);
689 
690 /*!
691  \brief Destroy a digit stream parser object
692  \param parser a pointer to the parser object
693  \return SWITCH_STATUS_SUCCESS if all is well
694 */
695 SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t *parser);
696 
697 /*!
698  \brief Create a new digit stream object
699  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
700  \param stream a pointer to the stream object pointer
701  \return NULL if no match found or consumer data that was associated with a given digit string when matched
702 */
703 SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t ** stream);
704 
705 /*!
706  \brief Destroys a digit stream object
707  \param stream a pointer to the stream object
708  \return NULL if no match found or consumer data that was associated with a given digit string when matched
709 */
710 SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t ** stream);
711 
712 /*!
713  \brief Set a digit string to action mapping
714  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
715  \param digits a string of digits to associate with an action
716  \param data consumer data attached to this digit string
717  \return SWITCH_STATUS_SUCCESS if all is well
718 */
719 SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_ivr_digit_stream_parser_t *parser, char *digits, void *data);
720 
721 /*!
722  \brief Delete a string to action mapping
723  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
724  \param digits the digit string to be removed from the map
725  \return SWITCH_STATUS_SUCCESS if all is well
726 */
727 SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t *parser, char *digits);
728 
729 /*!
730  \brief Feed digits collected into the stream for event match testing
731  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
732  \param stream a stream to write data to
733  \param digit a digit to collect and test against the map of digit strings
734  \return NULL if no match found or consumer data that was associated with a given digit string when matched
735 */
736 SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t *stream, char digit);
737 
738 /*!
739  \brief Reset the collected digit stream to nothing
740  \param stream a pointer to the parser stream object created by switch_ivr_digit_stream_new
741  \return SWITCH_STATUS_SUCCESS if all is well
742 */
743 SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t *stream);
744 
745 /*!
746  \brief Set a digit string terminator
747  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
748  \param digit the terminator digit
749  \return SWITCH_STATUS_SUCCESS if all is well
750 */
751 SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t *parser, char digit);
752 
753 
754 /******************************************************************************************************/
755 
756 
757 /** @} */
758 
759 /**
760  * @defgroup switch_ivr_menu IVR Menu Library
761  * @ingroup switch_ivr
762  * IVR menu functions
763  *
764  * @{
765  */
766 
767  typedef enum {
772 /* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */
773  typedef enum {
774  SWITCH_IVR_ACTION_DIE, /* Exit the menu. */
775  SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */
776  SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */
777  SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */
778  SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */
779  SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */
780  SWITCH_IVR_ACTION_NOOP /* No operation */
782  struct switch_ivr_menu;
783  typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *);
786 /******************************************************************************************************/
787 
788 /*!
789  *\brief Create a new menu object.
790  *\param new_menu the pointer to the new menu
791  *\param main The top level menu, (NULL if this is the top level one).
792  *\param name A pointer to the name of this menu.
793  *\param greeting_sound Optional pointer to a main sound (press 1 for this 2 for that).
794  *\param short_greeting_sound Optional pointer to a shorter main sound for subsequent loops.
795  *\param invalid_sound Optional pointer to a sound to play after invalid input.
796  *\param exit_sound Optional pointer to a sound to play upon exiting the menu.
797  *\param transfer_sound Optional pointer to a sound to play upon transfer away from the menu.
798  *\param confirm_macro phrase macro name to confirm input
799  *\param confirm_key the dtmf key required for positive confirmation
800  *\param tts_engine the tts engine to use for this menu
801  *\param tts_voice the tts voice to use for this menu
802  *\param confirm_attempts number of times to prompt to confirm input before failure
803  *\param inter_timeout inter-digit timeout
804  *\param digit_len max number of digits
805  *\param timeout A number of milliseconds to pause before looping.
806  *\param max_failures Maximum number of failures to withstand before hangingup This resets everytime you enter the menu.
807  *\param pool memory pool (NULL to create one).
808  *\return SWITCH_STATUS_SUCCESS if the menu was created.
809  */
810 
813  const char *name,
814  const char *greeting_sound,
815  const char *short_greeting_sound,
816  const char *invalid_sound,
817  const char *exit_sound,
818  const char *transfer_sound,
819  const char *confirm_macro,
820  const char *confirm_key,
821  const char *tts_engine,
822  const char *tts_voice,
823  int confirm_attempts,
824  int inter_timeout, int digit_len, int timeout, int max_failures,
825  int max_timeouts, switch_memory_pool_t *pool);
826 
827 /*!
828  *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
829  *\param menu The menu obj you wish to bind to.
830  *\param ivr_action switch_ivr_action_t enum of what you want to do.
831  *\param arg Optional (sometimes necessary) string arguement.
832  *\param bind KeyStrokes to bind the action to.
833  *\return SWUTCH_STATUS_SUCCESS if the action was binded
834  */
836 
837 
838 /*!
839  *\brief Bind a keystroke to a callback function.
840  *\param menu The menu obj you wish to bind to.
841  *\param function The function to call [int proto(struct switch_ivr_menu *, char *, size_t, void *)]
842  *\param arg Optional (sometimes necessary) string arguement.
843  *\param bind KeyStrokes to bind the action to.
844  *\note The function is passed a buffer to fill in with any required argument data.
845  *\note The function is also passed an optional void pointer to an object set upon menu execution. (think threads)
846  *\note The function returns an switch_ivr_action_t enum of what you want to do. and looks to your buffer for args.
847  *\return SWUTCH_STATUS_SUCCESS if the function was binded
848  */
850  switch_ivr_menu_action_function_t *function, const char *arg, const char *bind);
851 
852 
853 /*!
854  *\brief Execute a menu.
855  *\param session The session running the menu.
856  *\param stack The top-level menu object (the first one you created.)
857  *\param name A pointer to the name of the menu.
858  *\param obj A void pointer to an object you want to make avaliable to your callback functions that you may have binded with switch_ivr_menu_bind_function.
859  *\return SWITCH_STATUS_SUCCESS if all is well
860  */
862 
863 /*!
864  *\brief free a stack of menu objects.
865  *\param stack The top level menu you wish to destroy.
866  *\return SWITCH_STATUS_SUCCESS if the object was a top level menu and it was freed
867  */
869 
871  typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
872 /*!
873  *\brief Build a menu stack from an xml source
874  *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
875  *\param menu_stack The menu stack object that will be created for you
876  *\param xml_menus The xml Menus source
877  *\param xml_menu The xml Menu source of the menu to be created
878  *\return SWITCH_STATUS_SUCCESS if all is well
879  */
880 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
881  switch_ivr_menu_t ** menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu);
882 
884 
885 /*!
886  *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
887  *\param name The xml tag name to add to the parser engine
888  *\param function The menu function callback that will be executed when menu digits are bound to this name
889  *\return SWITCH_STATUS_SUCCESS if all is well
890  */
891 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
892  const char *name, switch_ivr_menu_action_function_t *function);
893 
894 /*!
895  *\param xml_menu_ctx A pointer of a XML menu parser context to be created
896  *\param pool memory pool (NULL to create one)
897  *\return SWITCH_STATUS_SUCCESS if all is well
898  */
899 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t ** xml_menu_ctx, switch_memory_pool_t *pool);
900 
901 SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_session_t *session, const char *macro_name, const char *data, switch_event_t *event, const char *lang,
902  switch_input_args_t *args);
903 #define switch_ivr_phrase_macro(session, macro_name, data, lang, args) switch_ivr_phrase_macro_event(session, macro_name, data, NULL, lang, args)
904 SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms);
905 SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen);
909 
911  uint32_t min_digits,
912  uint32_t max_digits,
913  const char *prompt_audio_file,
914  const char *var_name,
915  char *digit_buffer,
916  switch_size_t digit_buffer_length,
917  uint32_t timeout,
918  const char *valid_terminators,
919  uint32_t digit_timeout);
920 
921 
924 
926  switch_bind_flag_t bind_flags, const char *app);
928 SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b);
930  const char *tosay,
931  const char *module_name,
932  const char *say_type,
933  const char *say_method,
934  const char *say_gender,
935  switch_input_args_t *args);
936 
938  const char *lang,
939  const char *ext,
940  const char *tosay,
941  const char *module_name,
942  const char *say_type,
943  const char *say_method,
944  const char *say_gender,
945  char **rstr);
946 
952  char *tosay,
953  switch_say_callback_t number_func,
954  switch_say_args_t *say_args,
955  switch_input_args_t *args);
956 
959  const char *user, const char *domain, switch_xml_t x_user);
960 
962 SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname, const char *prefix);
965 
966 
967 
974  const char *name,
975  switch_memory_pool_t *pool,
976  uint32_t digit_timeout, uint32_t input_timeout,
977  switch_ivr_dmachine_callback_t match_callback,
978  switch_ivr_dmachine_callback_t nonmatch_callback,
979  void *user_data);
980 
982 
984  const char *realm,
985  const char *digits,
986  int32_t key,
988  void *user_data);
989 
995 SWITCH_DECLARE(void) switch_ivr_dmachine_set_digit_timeout_ms(switch_ivr_dmachine_t *dmachine, uint32_t digit_timeout_ms);
996 SWITCH_DECLARE(void) switch_ivr_dmachine_set_input_timeout_ms(switch_ivr_dmachine_t *dmachine, uint32_t input_timeout_ms);
999 
1000 
1004 SWITCH_DECLARE(switch_status_t) switch_ivr_insert_file(switch_core_session_t *session, const char *file, const char *insert_file, switch_size_t sample_point);
1005 
1007 SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, const char *domain_name);
1011 
1012 
1015  switch_img_position_t pos, uint8_t alpha);
1016 
1017 
1018 /** @} */
1019 
1021 #endif
1022 /* For Emacs:
1023  * Local Variables:
1024  * mode:c
1025  * indent-tabs-mode:t
1026  * tab-width:4
1027  * c-basic-offset:4
1028  * End:
1029  * For VIM:
1030  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
1031  */
void switch_ivr_dmachine_set_nonmatch_callback(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_callback_t nonmatch_callback)
video includes header
switch_status_t switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t *stream)
Reset the collected digit stream to nothing.
Definition: switch_ivr.c:2435
uint32_t switch_bind_flag_t
Definition: switch_types.h:308
int switch_ivr_set_xml_profile_data(switch_xml_t xml, switch_caller_profile_t *caller_profile, int off)
Definition: switch_ivr.c:2463
switch_sockaddr_t * local_addr
Definition: switch_ivr.h:57
switch_ivr_menu_action_function_t * function
switch_socket_t * socket
Definition: switch_ivr.h:52
void switch_ivr_bg_media(const char *uuid, switch_media_flag_t flags, switch_bool_t on, switch_bool_t is3p, uint32_t delay)
Definition: switch_ivr.c:2014
switch_status_t switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t *parser, char digit)
Set a digit string terminator.
Definition: switch_ivr.c:2448
switch_status_t switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp)
Definition: switch_ivr.c:3888
switch_say_type_t switch_ivr_get_say_type_by_name(const char *name)
Call Specific Data.
Definition: switch_caller.h:73
switch_status_t switch_ivr_set_user(switch_core_session_t *session, const char *data)
Definition: switch_ivr.c:3816
void switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms)
Definition: switch_ivr.c:3419
switch_status_t switch_ivr_read(switch_core_session_t *session, uint32_t min_digits, uint32_t max_digits, const char *prompt_audio_file, const char *var_name, char *digit_buffer, switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators, uint32_t digit_timeout)
switch_status_t switch_ivr_dmachine_feed(switch_ivr_dmachine_t *dmachine, const char *digits, switch_ivr_dmachine_match_t **match)
switch_status_t switch_ivr_parse_all_signal_data(switch_core_session_t *session)
Definition: switch_ivr.c:859
switch_status_t switch_ivr_gentones(switch_core_session_t *session, const char *script, int32_t loops, switch_input_args_t *args)
switch_status_t switch_ivr_eavesdrop_exec_all(switch_core_session_t *session, const char *app, const char *arg)
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 *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...
switch_status_t switch_ivr_process_indications(switch_core_session_t *session, switch_core_session_message_t *message)
Definition: switch_ivr.c:772
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_dmachine_create(switch_ivr_dmachine_t **dmachine_p, const char *name, switch_memory_pool_t *pool, uint32_t digit_timeout, uint32_t input_timeout, switch_ivr_dmachine_callback_t match_callback, switch_ivr_dmachine_callback_t nonmatch_callback, void *user_data)
switch_ivr_dmachine_match_t * switch_ivr_dmachine_get_match(switch_ivr_dmachine_t *dmachine)
switch_bool_t switch_ivr_uuid_exists(const char *uuid)
Definition: switch_ivr.c:3862
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_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.
Definition: switch_ivr.c:127
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
switch_status_t switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session)
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...
Definition: switch_ivr.c:1880
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.
Definition: switch_ivr.c:1173
#define SWITCH_RECOMMENDED_BUFFER_SIZE
Definition: switch_types.h:557
switch_bool_t
Definition: switch_types.h:405
switch_status_t switch_ivr_stop_session_audio(switch_core_session_t *session)
switch_status_t switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t **stream)
Destroys a digit stream object.
Definition: switch_ivr.c:2311
switch_status_t switch_ivr_unhold_uuid(const char *uuid)
Signal the session with a protocol specific unhold message.
Definition: switch_ivr.c:1548
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_gender_t switch_ivr_get_say_gender_by_name(const char *name)
switch_status_t switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind)
switch_ivr_menu_bind_action: Bind a keystroke to an action.
switch_memory_pool_t * pool
Representation of an event.
Definition: switch_event.h:80
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.
Definition: switch_ivr.c:1449
switch_status_t switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args)
Definition: switch_ivr.c:892
switch_bool_t switch_ivr_uuid_force_exists(const char *uuid)
Definition: switch_ivr.c:3875
switch_status_t dtmf_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
switch_status_t switch_ivr_insert_file(switch_core_session_t *session, const char *file, const char *insert_file, switch_size_t sample_point)
Definition: switch_ivr.c:4009
switch_sockaddr_t * remote_addr
Definition: switch_ivr.h:58
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_phrase_macro_event(switch_core_session_t *session, const char *macro_name, const char *data, switch_event_t *event, const char *lang, switch_input_args_t *args)
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.
Definition: switch_xml.h:76
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_say_callback_t)(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
switch_status_t switch_ivr_enterprise_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_event_t *ovars, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
uint32_t switch_originate_flag_t
Definition: switch_types.h:325
switch_status_t switch_ivr_parse_all_events(switch_core_session_t *session)
Parse all commands from an event.
Definition: switch_ivr.c:867
void switch_ivr_dmachine_set_match_callback(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_callback_t match_callback)
switch_status_t switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack, char *name, void *obj)
Execute a menu.
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.
Definition: switch_ivr.c:1674
void switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg)
Abstract handler to a timer module.
switch_status_t switch_ivr_eavesdrop_pop_eavesdropper(switch_core_session_t *session, switch_core_session_t **sessionp)
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)
const char * switch_ivr_dmachine_get_failed_digits(switch_ivr_dmachine_t *dmachine)
struct switch_runtime runtime
Definition: switch_core.c:64
switch_status_t switch_ivr_dmachine_clear(switch_ivr_dmachine_t *dmachine)
switch_status_t switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, const char *name, switch_ivr_menu_action_function_t *function)
switch_status_t switch_ivr_stop_inband_dtmf_session(switch_core_session_t *session)
Stop looking for DTMF inband.
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:177
switch_status_t switch_ivr_unblock_dtmf_session(switch_core_session_t *session)
uint8_t switch_byte_t
Definition: switch_types.h:246
switch_status_t switch_ivr_dmachine_last_ping(switch_ivr_dmachine_t *dmachine)
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.
switch_status_t switch_ivr_parse_next_event(switch_core_session_t *session)
Definition: switch_ivr.c:755
void switch_ivr_broadcast_in_thread(switch_core_session_t *session, const char *app, int flags)
switch_status_t switch_ivr_blind_transfer_ack(switch_core_session_t *session, switch_bool_t success)
Definition: switch_ivr.c:4254
int main(int argc, char *argv[])
Definition: fs_encode.c:56
switch_bool_t switch_ivr_dmachine_is_parsing(switch_ivr_dmachine_t *dmachine)
switch_status_t switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause)
Definition: switch_ivr.c:4240
switch_port_t remote_port
Definition: switch_ivr.h:56
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...
Definition: switch_ivr.c:1287
switch_byte_t switch_byte_t * buf
switch_status_t switch_ivr_play_and_detect_speech(switch_core_session_t *session, const char *file, const char *mod_name, const char *grammar, char **result, uint32_t input_timeout, switch_input_args_t *args)
play a file to the session while doing speech recognition.
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_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t *parser, char *digits)
Delete a string to action mapping.
Definition: switch_ivr.c:2367
switch_status_t switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen)
struct apr_sockaddr_t switch_sockaddr_t
Definition: switch_apr.h:1029
switch_status_t(* switch_input_callback_function_t)(switch_core_session_t *session, void *input, switch_input_type_t input_type, void *buf, unsigned int buflen)
switch_status_t switch_ivr_stop_detect_speech(switch_core_session_t *session)
Stop background Speech detection on a session.
switch_img_position_t
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_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser)
Create a digit stream parser object.
Definition: switch_ivr.c:2237
switch_codec_t read_codec
Definition: switch_ivr.h:49
switch_ivr_action_t ivr_action
switch_say_gender_t
Definition: switch_types.h:442
switch_status_t switch_ivr_uuid_bridge(const char *originator_uuid, const char *originatee_uuid)
Bridge two existing sessions.
switch_status_t switch_ivr_inband_dtmf_session(switch_core_session_t *session)
Start looking for DTMF inband.
switch_status_t switch_ivr_hold_toggle_uuid(const char *uuid, const char *message, switch_bool_t moh)
Toggles channel hold state of session.
Definition: switch_ivr.c:1493
#define _In_opt_
switch_status_t switch_ivr_dmachine_bind(switch_ivr_dmachine_t *dmachine, const char *realm, const char *digits, int32_t key, switch_ivr_dmachine_callback_t callback, void *user_data)
switch_status_t switch_ivr_video_write_overlay_session(switch_core_session_t *session, const char *img_path, switch_img_position_t pos, uint8_t alpha)
An abstraction of a data frame.
Definition: switch_frame.h:43
uintptr_t switch_size_t
switch_status_t switch_ivr_session_audio(switch_core_session_t *session, const char *cmd, const char *direction, int level)
switch_status_t switch_ivr_stop_tone_detect_session(switch_core_session_t *session)
Stop looking for TONES.
switch_status_t switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file)
Stop displacing a session.
uint16_t switch_port_t
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.
Definition: switch_ivr.c:2182
switch_status_t switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, const char *grammar, const char *name)
Load a grammar on a background speech detection handle.
switch_byte_t switch_byte_t uint32_t buflen
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.
uint32_t switch_eavesdrop_flag_t
Definition: switch_types.h:345
switch_status_t switch_ivr_detect_speech_disable_grammar(switch_core_session_t *session, const char *name)
Disable a grammar on a background speech detection handle.
#define _In_z_
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_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *)
Definition: switch_ivr.h:783
switch_call_cause_t
switch_status_t switch_ivr_sound_test(switch_core_session_t *session)
Definition: switch_ivr.c:41
switch_status_t switch_ivr_get_file_handle(switch_core_session_t *session, switch_file_handle_t **fh)
switch_status_t switch_ivr_detect_speech_unload_grammar(switch_core_session_t *session, const char *name)
Unload a grammar on a background speech detection handle.
switch_status_t switch_ivr_stop_inband_dtmf_generate_session(switch_core_session_t *session)
Stop generating DTMF inband.
switch_status_t switch_ivr_resume_detect_speech(switch_core_session_t *session)
Resume background Speech detection on a session.
switch_mutex_t * flag_mutex
Definition: switch_ivr.h:59
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.
Definition: switch_ivr.c:2325
switch_thread_t * thread
Definition: switch_ivr.h:64
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.
Definition: switch_ivr.c:2382
switch_status_t switch_ivr_parse_next_signal_data(switch_core_session_t *session)
Definition: switch_ivr.c:863
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.
Definition: switch_ivr.c:2295
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
char * switch_ivr_check_presence_mapping(const char *exten_name, const char *domain_name)
Definition: switch_ivr.c:4176
switch_frame_t write_frame
Definition: switch_ivr.h:50
void switch_ivr_park_session(switch_core_session_t *session)
Definition: switch_ivr.c:3411
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, int hits, const char *app, const char *data, switch_tone_detect_callback_t callback)
Start looking for TONES.
void switch_ivr_dmachine_set_digit_timeout_ms(switch_ivr_dmachine_t *dmachine, uint32_t digit_timeout_ms)
switch_status_t switch_ivr_dmachine_clear_realm(switch_ivr_dmachine_t *dmachine, const char *realm)
switch_status_t switch_ivr_3p_nomedia(const char *uuid, switch_media_flag_t flags)
Definition: switch_ivr.c:1774
switch_status_t switch_ivr_menu_init(switch_ivr_menu_t **new_menu, switch_ivr_menu_t *main, const char *name, const char *greeting_sound, const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, const char *tts_voice, int confirm_attempts, int inter_timeout, int digit_len, int timeout, int max_failures, int max_timeouts, switch_memory_pool_t *pool)
Create a new menu object.
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)
Definition: switch_ivr.c:398
struct apr_thread_mutex_t switch_mutex_t
Definition: switch_apr.h:314
switch_status_t switch_ivr_generate_json_cdr(switch_core_session_t *session, cJSON **json_cdr, switch_bool_t urlencode)
Generate an JSON CDR report.
Definition: switch_ivr.c:3177
switch_status_t switch_ivr_stop_video_write_overlay_session(switch_core_session_t *session)
switch_status_t
Common return values.
switch_status_t switch_ivr_say_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
switch_status_t switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, switch_ivr_menu_t **menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu)
Build a menu stack from an xml source.
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_unhold(switch_core_session_t *session)
Signal the session with a protocol specific unhold message.
Definition: switch_ivr.c:1515
switch_status_t switch_ivr_dmachine_set_realm(switch_ivr_dmachine_t *dmachine, const char *realm)
switch_status_t switch_ivr_create_message_reply(switch_event_t **reply, switch_event_t *message, const char *new_proto)
Definition: switch_ivr.c:4163
void switch_ivr_dmachine_set_input_timeout_ms(switch_ivr_dmachine_t *dmachine, uint32_t input_timeout_ms)
switch_status_t switch_ivr_detect_speech_disable_all_grammars(switch_core_session_t *session)
Disable all grammars 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.
struct apr_thread_t switch_thread_t
Definition: switch_apr.h:941
Main Library Header.
switch_status_t switch_ivr_parse_signal_data(switch_core_session_t *session, switch_bool_t all, switch_bool_t only_session_thread)
Definition: switch_ivr.c:823
switch_ivr_action_t
Definition: switch_ivr.h:773
switch_status_t switch_ivr_set_param_detect_speech(switch_core_session_t *session, const char *name, const char *val)
switch_status_t switch_ivr_eavesdrop_update_display(switch_core_session_t *session, const char *name, const char *number)
#define SWITCH_DECLARE(type)
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_core_session_t * session
Definition: switch_ivr.h:48
switch_port_t local_port
Definition: switch_ivr.h:54
void switch_ivr_bridge_display(switch_core_session_t *session, switch_core_session_t *peer_session)
switch_status_t switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action)
int switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channel_t *channel, int off)
Definition: switch_ivr.c:2689
switch_status_t(* switch_ivr_dmachine_callback_t)(switch_ivr_dmachine_match_t *match)
switch_status_t switch_ivr_dmachine_ping(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_match_t **match_p)
switch_status_t switch_ivr_say_ip(switch_core_session_t *session, char *tosay, switch_say_callback_t number_func, switch_say_args_t *say_args, switch_input_args_t *args)
switch_say_type_t
Definition: switch_types.h:420
switch_status_t switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, switch_bind_flag_t bind_flags, const char *app)
switch_status_t switch_ivr_block_dtmf_session(switch_core_session_t *session)
switch_status_t switch_ivr_detect_speech_enable_grammar(switch_core_session_t *session, const char *name)
Enable a grammar on a background speech detection handle.
switch_say_method_t switch_ivr_get_say_method_by_name(const char *name)
switch_status_t switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session, uint32_t key)
switch_status_t switch_ivr_release_file_handle(switch_core_session_t *session, switch_file_handle_t **fh)
switch_say_method_t
Definition: switch_types.h:411
struct apr_pool_t switch_memory_pool_t
uint32_t switch_ivr_schedule_broadcast(time_t runtime, const char *uuid, const char *path, switch_media_flag_t flags)
Signal the session to broadcast audio in the future.
uint32_t switch_media_flag_t
Definition: switch_types.h:477
const char * switch_ivr_dmachine_get_name(switch_ivr_dmachine_t *dmachine)
switch_status_t switch_ivr_detect_speech_init(switch_core_session_t *session, const char *mod_name, const char *dest, switch_asr_handle_t *ah)
Initialize background Speech detection on a session, so that parameters can be set, and grammars loaded. After calling this function, it is possible to call switch_ivr_set_param_detect_speech() to set recognition parameters. Calling switch_ivr_detect_speech_load_grammar() starts the speech recognition.
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_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx, switch_memory_pool_t *pool)
switch_status_t switch_ivr_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session)
switch_status_t switch_ivr_deactivate_unicast(switch_core_session_t *session)
Definition: switch_ivr.c:365
switch_status_t switch_ivr_session_echo(switch_core_session_t *session, switch_input_args_t *args)
NEEDDESC -
void switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname, const char *prefix)
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.
void switch_ivr_dmachine_destroy(switch_ivr_dmachine_t **dmachine)
switch_status_t switch_ivr_3p_media(const char *uuid, switch_media_flag_t flags)
Definition: switch_ivr.c:1564
struct apr_socket_t switch_socket_t
Definition: switch_apr.h:1026
switch_status_t switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender, switch_input_args_t *args)
Definition: switch_ivr.c:3507
switch_status_t switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr)
Generate an XML CDR report.
Definition: switch_ivr.c:2713
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.
Definition: switch_ivr.c:1481
switch_ivr_menu_flags
Definition: switch_ivr.h:767
switch_byte_t write_frame_data[SWITCH_RECOMMENDED_BUFFER_SIZE]
Definition: switch_ivr.h:51
switch_status_t switch_ivr_say_string(switch_core_session_t *session, const char *lang, const char *ext, const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender, char **rstr)
Definition: switch_ivr.c:3629
switch_status_t switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b)
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_event_t *ovars, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
Make an outgoing call.
switch_status_t switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t *parser)
Destroy a digit stream parser object.
Definition: switch_ivr.c:2277
switch_status_t switch_ivr_set_user_xml(switch_core_session_t *session, const char *prefix, const char *user, const char *domain, switch_xml_t x_user)
Definition: switch_ivr.c:3761
switch_status_t switch_ivr_detect_speech_start_input_timers(switch_core_session_t *session)
Start input timers on a background speech detection handle.
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.
switch_bool_t(* switch_tone_detect_callback_t)(switch_core_session_t *, const char *, const char *)
switch_status_t switch_ivr_record_session_mask(switch_core_session_t *session, const char *file, switch_bool_t on)
void switch_ivr_clear_speech_cache(switch_core_session_t *session)
#define _In_
switch_status_t switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, switch_ivr_menu_action_function_t *function, const char *arg, const char *bind)
Bind a keystroke to a callback function.
switch_status_t switch_ivr_menu_stack_free(switch_ivr_menu_t *stack)
free a stack of menu objects.
switch_status_t switch_ivr_parse_all_messages(switch_core_session_t *session)
Definition: switch_ivr.c:801
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42