RTS API Documentation  1.10.11
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-2021, 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  do { \
70  if ((divisor) <= 0 && (divisor) != -1) { \
71  divisor = 400; \
72  } \
73  } while (0)
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 */
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 
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 */
298 
299 
303 
304 /*!
305  \brief Eavesdrop on a another session
306  \param session our session
307  \param uuid the uuid of the session to spy on
308  \param require_group group name to use to limit by group
309  \param flags tweak read-mux, write-mux and dtmf
310  \return SWITCH_STATUS_SUCESS if all is well
311 */
313  const char *uuid, const char *require_group, switch_eavesdrop_flag_t flags);
314 
315 /*!
316  \brief displace the media for a session with the audio from a file
317  \param session the session to displace
318  \param file filename
319  \param limit time limit in ms
320  \param flags m (mux) l (loop) or r(read session instead of write session)
321  \return SWITCH_STATUS_SUCCESS if all is well
322 */
323 SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags);
324 
325 /*!
326  \brief Stop displacing a session
327  \param session the session
328  \param file file name from the switch_ivr_displace_session call
329  \return SWITCH_STATUS_SUCCESS if all is well
330 */
332 
333 /*!
334  \brief Stop Recording a session
335  \param session the session to stop recording
336  \param file the path to the file
337  \return SWITCH_STATUS_SUCCESS if all is well
338 */
340 
341 
342 SWITCH_DECLARE(switch_status_t) switch_ivr_session_audio(switch_core_session_t *session, const char *cmd, const char *direction, int level);
344 
345 /*!
346  \brief Start looking for DTMF inband
347  \param session the session to start looking
348  \return SWITCH_STATUS_SUCCESS if all is well
349 */
351 
352 /*!
353  \brief Stop looking for DTMF inband
354  \param session the session to stop looking
355  \return SWITCH_STATUS_SUCCESS if all is well
356 */
358 
359 
360 /*!
361  \brief Start generating DTMF inband
362  \param session the session to generate on
363  \param read_stream true to use the session we are reading from, false for the session we are writing to.
364  \return SWITCH_STATUS_SUCCESS if all is well
365 */
367 
368 /*!
369  \brief Stop generating DTMF inband
370  \param session the session to stop generating
371  \return SWITCH_STATUS_SUCCESS if all is well
372 */
374 
375 /*!
376  \brief - NEEDDESC -
377  \param session the session to act on
378 */
380 
381 /*!
382  \brief Stop looking for TONES
383  \param session the session to stop looking
384  \return SWITCH_STATUS_SUCCESS if all is well
385 */
387 
388 /*!
389  \brief Start looking for TONES
390  \param session the session to start looking
391  \param key the name of the tone.
392  \param tone_spec comma sep list of tone freqs
393  \param flags one or both of 'r' and 'w'
394  \param timeout timeout
395  \param app optional application to execute when tone is found
396  \param data optional data for appliaction
397  \return SWITCH_STATUS_SUCCESS if all is well
398 */
400  const char *key, const char *tone_spec,
401  const char *flags, time_t timeout, int hits,
402  const char *app, const char *data, switch_tone_detect_callback_t callback);
403 
404 
405 
406 
407 /*!
408  \brief play a file from the disk to the session
409  \param session the session to play the file too
410  \param fh file handle to use (NULL for builtin one)
411  \param file the path to the file
412  \param args arguements to pass for callbacks etc
413  \return SWITCH_STATUS_SUCCESS if all is well
414 */
416  switch_input_args_t *args);
417 
419  uint32_t timeout_ms, const char *file);
420 
422  uint32_t timeout_ms, const char *file);
423 
425  uint32_t listen_hits, uint32_t timeout_ms, const char *file);
426 
428 
429 /*!
430  \brief record a file from the session to a file
431  \param session the session to record from
432  \param fh file handle to use
433  \param file the path to the file
434  \param args arguements to pass for callbacks etc
435  \param limit max limit to record for (0 for infinite)
436  \return SWITCH_STATUS_SUCCESS if all is well
437 */
440  _In_z_ const char *file, _In_opt_ switch_input_args_t *args, _In_ uint32_t limit);
441 /*!
442  \brief record a file from the session to a file
443  \param session the session to record from
444  \param fh file handle to use
445  \param file the path to the file
446  \param args arguements to pass for callbacks etc
447  \param limit max limit to record for (0 for infinite)
448  \param vars vars to add to RECORD_START and RECORD_STOP automatically prefixed with Recording-Variable-
449  \return SWITCH_STATUS_SUCCESS if all is well
450 */
453  _In_z_ const char *file, _In_opt_ switch_input_args_t *args, _In_ uint32_t limit, switch_event_t *vars);
454 
455 /*!
456  \brief Play a sound and gather digits with the number of retries specified if the user doesn't give digits in the set time
457  \param session the current session to play sound to and collect digits
458  \param min_digits the fewest digits allowed for the response to be valid
459  \param max_digits the max number of digits to accept
460  \param max_tries number of times to replay the sound and capture digits
461  \param timeout time to wait for input (this is per iteration, so total possible time = max_tries * (timeout + audio playback length)
462  \param valid_terminators for input that can include # or * (useful for variable length prompts)
463  \param audio_file file to play
464  \param bad_input_audio_file file to play if the input from the user was invalid
465  \param var_name variable name to put results in
466  \param digit_buffer variable digits captured will be put back into (empty if capture failed)
467  \param digit_buffer_length length of the buffer for digits (should be the same or larger than max_digits)
468  \param digits_regex the qualifying regex
469  \return switch status, used to note status of channel (will still return success if digit capture failed)
470  \note to test for digit capture failure look for \\0 in the first position of the buffer
471 */
473  uint32_t min_digits,
474  uint32_t max_digits,
475  uint32_t max_tries,
476  uint32_t timeout,
477  const char *valid_terminators,
478  const char *audio_file,
479  const char *bad_input_audio_file,
480  const char *var_name, char *digit_buffer, uint32_t digit_buffer_length,
481  const char *digits_regex,
482  uint32_t digit_timeout,
483  const char *transfer_on_failure);
484 
487  switch_codec_t *codec, switch_timer_t *timer, const char *text, switch_input_args_t *args);
489 /*!
490  \brief Speak given text with given tts engine
491  \param session the session to speak on
492  \param tts_name the desired tts module
493  \param voice_name the desired voice
494  \param text the text to speak
495  \param args arguements to pass for callbacks etc
496  \return SWITCH_STATUS_SUCCESS if all is well
497 */
499  const char *tts_name, const char *voice_name, const char *text, switch_input_args_t *args);
500 
501 /*!
502  \brief Make an outgoing call
503  \param session originating session
504  \param bleg B leg session
505  \param cause a pointer to hold call cause
506  \param bridgeto the desired remote callstring
507  \param timelimit_sec timeout in seconds for outgoing call
508  \param table optional state handler table to install on the channel
509  \param cid_name_override override the caller id name
510  \param cid_num_override override the caller id number
511  \param caller_profile_override override the entire calling caller profile
512  \param ovars variables to be set on the outgoing channel
513  \param flags flags to pass
514  \return SWITCH_STATUS_SUCCESS if bleg is a running session.
515  \note bleg will be read locked which must be unlocked with switch_core_session_rwunlock() before losing scope
516 */
518  switch_core_session_t **bleg,
519  switch_call_cause_t *cause,
520  const char *bridgeto,
521  uint32_t timelimit_sec,
522  const switch_state_handler_table_t *table,
523  const char *cid_name_override,
524  const char *cid_num_override,
525  switch_caller_profile_t *caller_profile_override,
527  switch_call_cause_t *cancel_cause,
529 
531  switch_core_session_t **bleg,
532  switch_call_cause_t *cause,
533  const char *bridgeto,
534  uint32_t timelimit_sec,
535  const switch_state_handler_table_t *table,
536  const char *cid_name_override,
537  const char *cid_num_override,
538  switch_caller_profile_t *caller_profile_override,
540  switch_call_cause_t *cancel_cause,
542 
544 
545 /*!
546  \brief Bridge Audio from one session to another
547  \param session one session
548  \param peer_session the other session
549  \param dtmf_callback a callback for messages and dtmf
550  \param session_data data to pass to the DTMF callback for session
551  \param peer_session_data data to pass to the DTMF callback for peer_session
552  \return SWITCH_STATUS_SUCCESS if all is well
553 */
555  _In_ switch_core_session_t *peer_session,
557  void *peer_session_data);
558 
559 /*!
560  \brief Bridge leaving b-leg in the control of another thread. Call from b-leg first then call switch_ivr_multi_threaded_bridge on a-leg and b-leg.
561  \param session b-leg session
562  \return SWITCH_STATUS_SUCCESS if all is well
563 */
565 
566 
567 /*!
568  \brief Bridge Signalling from one session to another
569  \param session one session
570  \param peer_session the other session
571  \return SWITCH_STATUS_SUCCESS if all is well
572 */
574 
576 
577 
578 /*!
579  \brief Transfer an existing session to another location
580  \param session the session to transfer
581  \param extension the new extension
582  \param dialplan the new dialplan (OPTIONAL, may be NULL)
583  \param context the new context (OPTIONAL, may be NULL)
584 */
585 SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan,
586  const char *context);
587 
588 /*!
589  \brief Transfer an existing session to another location in the future
590  \param runtime the time (int epoch seconds) to transfer the call
591  \param uuid the uuid of the session to transfer
592  \param extension the new extension
593  \param dialplan the new dialplan (OPTIONAL, may be NULL)
594  \param context the new context (OPTIONAL, may be NULL)
595  \return the id of the task
596 */
597 SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, const char *uuid, char *extension, char *dialplan, char *context);
598 
599 
600 /*!
601  \brief Hangup an existing session in the future
602  \param runtime the time (int epoch seconds) to transfer the call
603  \param uuid the uuid of the session to hangup
604  \param cause the hanup cause code
605  \param bleg hangup up the B-Leg if possible
606  \return the id of the task
607 */
608 SWITCH_DECLARE(uint32_t) switch_ivr_schedule_hangup(time_t runtime, const char *uuid, switch_call_cause_t cause, switch_bool_t bleg);
609 
610 /*!
611  \brief Bridge two existing sessions
612  \param originator_uuid the uuid of the originator
613  \param originatee_uuid the uuid of the originator
614  \remark Any custom state handlers on both channels will be deleted
615  \return SWITCH_STATUS_SUCCESS if all is well
616 */
617 SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uuid, const char *originatee_uuid);
618 
619 /*!
620  \brief Signal a session to request direct media access to it's remote end
621  \param uuid the uuid of the session to request
622  \param flags flags to influence behaviour (SMF_REBRIDGE to rebridge the call in media mode)
623  \return SWITCH_STATUS_SUCCESS if all is well
624 */
627 /*!
628  \brief Signal a session to request indirect media allowing it to exchange media directly with another device
629  \param uuid the uuid of the session to request
630  \param flags flags to influence behaviour (SMF_REBRIDGE to rebridge the call in no_media mode)
631  \return SWITCH_STATUS_SUCCESS if all is well
632 */
635 
636 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);
637 
638 /*!
639  \brief Signal the session with a protocol specific hold message.
640  \param uuid the uuid of the session to hold
641  \param message optional message
642  \param moh play music-on-hold
643  \return SWITCH_STATUS_SUCCESS if all is well
644 */
645 SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message, switch_bool_t moh);
646 
647 /*!
648  \brief Toggles channel hold state of session
649  \param uuid the uuid of the session to hold
650  \param message optional message
651  \param moh play music-on-hold
652  \return SWITCH_STATUS_SUCCESS if all is well
653 */
654 SWITCH_DECLARE(switch_status_t) switch_ivr_hold_toggle_uuid(const char *uuid, const char *message, switch_bool_t moh);
655 
656 /*!
657  \brief Signal the session with a protocol specific unhold message.
658  \param uuid the uuid of the session to hold
659  \return SWITCH_STATUS_SUCCESS if all is well
660 */
662 
663 /*!
664  \brief Signal the session with a protocol specific hold message.
665  \param session the session to hold
666  \param message optional message
667  \param moh play music-on-hold
668  \return SWITCH_STATUS_SUCCESS if all is well
669 */
671 
672 /*!
673  \brief Signal the session with a protocol specific unhold message.
674  \param session the session to unhold
675  \return SWITCH_STATUS_SUCCESS if all is well
676 */
678 
679 /*!
680  \brief Signal the session to broadcast audio in the future
681  \param runtime when (in epoch time) to run the broadcast
682  \param uuid the uuid of the session to broadcast on
683  \param path the path data of the broadcast "/path/to/file.wav [<timer name>]" or "speak:<engine>|<voice>|<Text to say>"
684  \param flags flags to send to the request (SMF_ECHO_BRIDGED to send the broadcast to both sides of the call)
685  \return the id of the task
686 */
687 SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, const char *uuid, const char *path, switch_media_flag_t flags);
688 
689 /*!
690  \brief Signal the session to broadcast audio
691  \param uuid the uuid of the session to broadcast on
692  \param path the path data of the broadcast "/path/to/file.wav [<timer name>]" or "speak:<engine>|<voice>|<Text to say>"
693  \param flags flags to send to the request (SMF_ECHO_BRIDGED to send the broadcast to both sides of the call)
694  \return SWITCH_STATUS_SUCCESS if all is well
695 */
698 
699 /*!
700  \brief Transfer variables from one session to another
701  \param sessa the original session
702  \param sessb the new session
703  \param var the name of the variable to transfer (NULL for all)
704  \return SWITCH_STATUS_SUCCESS if all is well
705 */
707 
708 
709 /******************************************************************************************************/
710 
715 /*!
716  \brief Create a digit stream parser object
717  \param pool the pool to use for the new hash
718  \param parser a pointer to the object pointer
719  \return SWITCH_STATUS_SUCCESS if all is well
720 */
722 
723 /*!
724  \brief Destroy a digit stream parser object
725  \param parser a pointer to the parser object
726  \return SWITCH_STATUS_SUCCESS if all is well
727 */
729 
730 /*!
731  \brief Create a new digit stream object
732  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
733  \param stream a pointer to the stream object pointer
734  \return NULL if no match found or consumer data that was associated with a given digit string when matched
735 */
737 
738 /*!
739  \brief Destroys a digit stream object
740  \param stream a pointer to the stream object
741  \return NULL if no match found or consumer data that was associated with a given digit string when matched
742 */
744 
745 /*!
746  \brief Set a digit string to action mapping
747  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
748  \param digits a string of digits to associate with an action
749  \param data consumer data attached to this digit string
750  \return SWITCH_STATUS_SUCCESS if all is well
751 */
753 
754 /*!
755  \brief Delete a string to action mapping
756  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
757  \param digits the digit string to be removed from the map
758  \return SWITCH_STATUS_SUCCESS if all is well
759 */
761 
762 /*!
763  \brief Feed digits collected into the stream for event match testing
764  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
765  \param stream a stream to write data to
766  \param digit a digit to collect and test against the map of digit strings
767  \return NULL if no match found or consumer data that was associated with a given digit string when matched
768 */
770 
771 /*!
772  \brief Reset the collected digit stream to nothing
773  \param stream a pointer to the parser stream object created by switch_ivr_digit_stream_new
774  \return SWITCH_STATUS_SUCCESS if all is well
775 */
777 
778 /*!
779  \brief Set a digit string terminator
780  \param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
781  \param digit the terminator digit
782  \return SWITCH_STATUS_SUCCESS if all is well
783 */
785 
786 
787 /******************************************************************************************************/
788 
789 
790 /** @} */
791 
792 /**
793  * @defgroup switch_ivr_menu IVR Menu Library
794  * @ingroup switch_ivr
795  * IVR menu functions
796  *
797  * @{
798  */
799 
800  typedef enum {
805 /* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */
806  typedef enum {
807  SWITCH_IVR_ACTION_DIE, /* Exit the menu. */
808  SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */
809  SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */
810  SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */
811  SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */
812  SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */
813  SWITCH_IVR_ACTION_NOOP /* No operation */
815  struct switch_ivr_menu;
816  typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *);
819 /******************************************************************************************************/
820 
821 /*!
822  *\brief Create a new menu object.
823  *\param new_menu the pointer to the new menu
824  *\param main The top level menu, (NULL if this is the top level one).
825  *\param name A pointer to the name of this menu.
826  *\param greeting_sound Optional pointer to a main sound (press 1 for this 2 for that).
827  *\param short_greeting_sound Optional pointer to a shorter main sound for subsequent loops.
828  *\param invalid_sound Optional pointer to a sound to play after invalid input.
829  *\param exit_sound Optional pointer to a sound to play upon exiting the menu.
830  *\param transfer_sound Optional pointer to a sound to play upon transfer away from the menu.
831  *\param confirm_macro phrase macro name to confirm input
832  *\param confirm_key the dtmf key required for positive confirmation
833  *\param tts_engine the tts engine to use for this menu
834  *\param tts_voice the tts voice to use for this menu
835  *\param confirm_attempts number of times to prompt to confirm input before failure
836  *\param inter_timeout inter-digit timeout
837  *\param digit_len max number of digits
838  *\param timeout A number of milliseconds to pause before looping.
839  *\param max_failures Maximum number of failures to withstand before hangingup This resets everytime you enter the menu.
840  *\param pool memory pool (NULL to create one).
841  *\return SWITCH_STATUS_SUCCESS if the menu was created.
842  */
843 
846  const char *name,
847  const char *greeting_sound,
848  const char *short_greeting_sound,
849  const char *invalid_sound,
850  const char *exit_sound,
851  const char *transfer_sound,
852  const char *confirm_macro,
853  const char *confirm_key,
854  const char *tts_engine,
855  const char *tts_voice,
856  int confirm_attempts,
857  int inter_timeout, int digit_len, int timeout, int max_failures,
858  int max_timeouts, switch_memory_pool_t *pool);
859 
860 /*!
861  *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
862  *\param menu The menu obj you wish to bind to.
863  *\param ivr_action switch_ivr_action_t enum of what you want to do.
864  *\param arg Optional (sometimes necessary) string arguement.
865  *\param bind KeyStrokes to bind the action to.
866  *\return SWUTCH_STATUS_SUCCESS if the action was binded
867  */
868 SWITCH_DECLARE(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);
869 
870 
871 /*!
872  *\brief Bind a keystroke to a callback function.
873  *\param menu The menu obj you wish to bind to.
874  *\param function The function to call [int proto(struct switch_ivr_menu *, char *, size_t, void *)]
875  *\param arg Optional (sometimes necessary) string arguement.
876  *\param bind KeyStrokes to bind the action to.
877  *\note The function is passed a buffer to fill in with any required argument data.
878  *\note The function is also passed an optional void pointer to an object set upon menu execution. (think threads)
879  *\note The function returns an switch_ivr_action_t enum of what you want to do. and looks to your buffer for args.
880  *\return SWUTCH_STATUS_SUCCESS if the function was binded
881  */
883  switch_ivr_menu_action_function_t *function, const char *arg, const char *bind);
884 
885 
886 /*!
887  *\brief Execute a menu.
888  *\param session The session running the menu.
889  *\param stack The top-level menu object (the first one you created.)
890  *\param name A pointer to the name of the menu.
891  *\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.
892  *\return SWITCH_STATUS_SUCCESS if all is well
893  */
895 
896 /*!
897  *\brief free a stack of menu objects.
898  *\param stack The top level menu you wish to destroy.
899  *\return SWITCH_STATUS_SUCCESS if the object was a top level menu and it was freed
900  */
902 
905 /*!
906  *\brief Build a menu stack from an xml source
907  *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
908  *\param menu_stack The menu stack object that will be created for you
909  *\param xml_menus The xml Menus source
910  *\param xml_menu The xml Menu source of the menu to be created
911  *\return SWITCH_STATUS_SUCCESS if all is well
912  */
914  switch_ivr_menu_t ** menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu);
915 
916 SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action);
917 
918 /*!
919  *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
920  *\param name The xml tag name to add to the parser engine
921  *\param function The menu function callback that will be executed when menu digits are bound to this name
922  *\return SWITCH_STATUS_SUCCESS if all is well
923  */
925  const char *name, switch_ivr_menu_action_function_t *function);
926 
927 /*!
928  *\param xml_menu_ctx A pointer of a XML menu parser context to be created
929  *\param pool memory pool (NULL to create one)
930  *\return SWITCH_STATUS_SUCCESS if all is well
931  */
933 
934 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,
935  switch_input_args_t *args);
936 #define switch_ivr_phrase_macro(session, macro_name, data, lang, args) switch_ivr_phrase_macro_event(session, macro_name, data, NULL, lang, args)
938 SWITCH_DECLARE(switch_status_t) switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen);
942 
944  uint32_t min_digits,
945  uint32_t max_digits,
946  const char *prompt_audio_file,
947  const char *var_name,
948  char *digit_buffer,
949  switch_size_t digit_buffer_length,
950  uint32_t timeout,
951  const char *valid_terminators,
952  uint32_t digit_timeout);
953 
954 
957 
959  switch_bind_flag_t bind_flags, const char *app);
961 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);
963  const char *tosay,
964  const char *module_name,
965  const char *say_type,
966  const char *say_method,
967  const char *say_gender,
968  switch_input_args_t *args);
969 
971  const char *lang,
972  const char *ext,
973  const char *tosay,
974  const char *module_name,
975  const char *say_type,
976  const char *say_method,
977  const char *say_gender,
978  char **rstr);
979 
985  char *tosay,
986  switch_say_callback_t number_func,
987  switch_say_args_t *say_args,
988  switch_input_args_t *args);
989 
993  const char *user, const char *domain, switch_xml_t x_user);
994 
996 SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname, const char *prefix);
999 
1000 
1001 
1008  const char *name,
1010  uint32_t digit_timeout, uint32_t input_timeout,
1011  switch_ivr_dmachine_callback_t match_callback,
1012  switch_ivr_dmachine_callback_t nonmatch_callback,
1013  void *user_data);
1014 
1016 
1018  const char *realm,
1019  const char *digits,
1020  switch_byte_t is_priority,
1021  int32_t key,
1023  void *user_data);
1024 
1030 SWITCH_DECLARE(void) switch_ivr_dmachine_set_digit_timeout_ms(switch_ivr_dmachine_t *dmachine, uint32_t digit_timeout_ms);
1031 SWITCH_DECLARE(void) switch_ivr_dmachine_set_input_timeout_ms(switch_ivr_dmachine_t *dmachine, uint32_t input_timeout_ms);
1034 
1035 
1039 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);
1040 
1042 SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, const char *domain_name);
1047 
1048 
1051  switch_img_position_t pos, uint8_t alpha);
1052 
1054 
1062 SWITCH_DECLARE(void) switch_dial_leg_list_add_leg(switch_dial_leg_list_t *parent, switch_dial_leg_t **legP, const char *dial_string);
1064 SWITCH_DECLARE(void) switch_dial_handle_add_global_var(switch_dial_handle_t *handle, const char *var, const char *val);
1065 SWITCH_DECLARE(void) switch_dial_handle_add_global_var_printf(switch_dial_handle_t *handle, const char *var, const char *fmt, ...);
1066 SWITCH_DECLARE(switch_status_t) switch_dial_handle_add_leg_var(switch_dial_leg_t *leg, const char *var, const char *val);
1068 SWITCH_DECLARE(int) switch_dial_handle_get_peers(switch_dial_handle_t *handle, int idx, char **array, int max);
1069 SWITCH_DECLARE(int) switch_dial_handle_get_vars(switch_dial_handle_t *handle, int idx, switch_event_t **array, int max);
1072 SWITCH_DECLARE(const char *) switch_dial_leg_get_var(switch_dial_leg_t *leg, const char *key);
1081 SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var(switch_dial_handle_list_t *hl, const char *var, const char *val);
1085 SWITCH_DECLARE(switch_status_t) switch_ivr_send_prompt(switch_core_session_t *session, const char *type, const char *text, const char *regex);
1086 
1088  const char *prompt,
1089  const char *recognizer_mod_name,
1090  const char *recognizer_grammar,
1091  int min_digits,
1092  int max_digits,
1093  const char *terminators,
1094  uint32_t digit_timeout,
1095  cJSON **recognition_result,
1096  char **digits_collected,
1097  char *terminator_collected,
1098  switch_input_args_t *args);
1099 
1100 /** @} */
1101 
1103 #endif
1104 /* For Emacs:
1105  * Local Variables:
1106  * mode:c
1107  * indent-tabs-mode:t
1108  * tab-width:4
1109  * c-basic-offset:4
1110  * End:
1111  * For VIM:
1112  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
1113  */
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:2571
uint32_t switch_bind_flag_t
Definition: switch_types.h:318
int switch_ivr_set_xml_profile_data(switch_xml_t xml, switch_caller_profile_t *caller_profile, int off)
Definition: switch_ivr.c:2599
switch_sockaddr_t * local_addr
Definition: switch_ivr.h:57
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:2121
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:2584
switch_status_t switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp)
Definition: switch_ivr.c:4052
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:3976
void switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms)
Definition: switch_ivr.c:3579
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)
const char *const const double number
Definition: switch_cJSON.h:254
switch_status_t switch_ivr_parse_all_signal_data(switch_core_session_t *session)
Definition: switch_ivr.c:905
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_detect_silence(switch_core_session_t *session, uint32_t thresh, uint32_t silence_hits, uint32_t timeout_ms, const char *file)
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&#39;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:813
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:4026
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:1987
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:1225
switch_status_t switch_dial_handle_list_create_json_obj(switch_dial_handle_list_t **handle, cJSON *json)
#define SWITCH_RECOMMENDED_BUFFER_SIZE
Definition: switch_types.h:590
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, switch_dial_handle_list_t *hl)
switch_bool_t
Definition: switch_types.h:437
switch_status_t switch_dial_handle_add_leg_var_printf(switch_dial_leg_t *leg, const char *var, const char *fmt,...)
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:2447
switch_status_t switch_ivr_unhold_uuid(const char *uuid)
Signal the session with a protocol specific unhold message.
Definition: switch_ivr.c:1646
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
void switch_dial_handle_add_leg_list(switch_dial_handle_t *handle, switch_dial_leg_list_t **leg_listP)
switch_event_t * switch_dial_leg_get_vars(switch_dial_leg_t *leg)
switch_status_t switch_dial_handle_create_json(switch_dial_handle_t **handle, const char *handle_string)
switch_status_t switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause)
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:1525
switch_status_t switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args)
Definition: switch_ivr.c:946
switch_bool_t switch_ivr_uuid_force_exists(const char *uuid)
Definition: switch_ivr.c:4039
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:4173
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:79
uint32_t switch_originate_flag_t
Definition: switch_types.h:335
switch_status_t switch_ivr_intercept_session(switch_core_session_t *session, const char *uuid, switch_bool_t bleg)
switch_status_t switch_ivr_parse_all_events(switch_core_session_t *session)
Parse all commands from an event.
Definition: switch_ivr.c:913
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&#39;s remote end.
Definition: switch_ivr.c:1773
Abstract handler to a timer module.
switch_status_t switch_ivr_eavesdrop_pop_eavesdropper(switch_core_session_t *session, switch_core_session_t **sessionp)
const char * switch_ivr_dmachine_get_failed_digits(switch_ivr_dmachine_t *dmachine)
struct switch_runtime runtime
Definition: switch_core.c:86
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_speak_text(switch_core_session_t *session, const char *tts_name, const char *voice_name, const char *text, switch_input_args_t *args)
Speak given text with given tts engine.
switch_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:179
switch_status_t switch_ivr_unblock_dtmf_session(switch_core_session_t *session)
uint8_t switch_byte_t
Definition: switch_types.h:256
switch_status_t switch_dial_handle_serialize_json_obj(switch_dial_handle_t *handle, cJSON **json)
int cJSON_bool fmt
Definition: switch_cJSON.h:150
void switch_dial_handle_list_add_global_var(switch_dial_handle_list_t *hl, const char *var, const char *val)
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.
const char * switch_dial_leg_get_var(switch_dial_leg_t *leg, const char *key)
switch_status_t switch_ivr_dmachine_bind(switch_ivr_dmachine_t *dmachine, const char *realm, const char *digits, switch_byte_t is_priority, int32_t key, switch_ivr_dmachine_callback_t callback, void *user_data)
switch_status_t switch_ivr_parse_next_event(switch_core_session_t *session)
Definition: switch_ivr.c:796
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:4418
switch_status_t switch_ivr_enterprise_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_list_t *hl, switch_call_cause_t *cause)
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:4404
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:1342
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:2503
switch_status_t switch_ivr_find_bridged_uuid(const char *uuid, char *b_uuid, switch_size_t blen)
switch_event_t * switch_dial_handle_get_global_vars(switch_dial_handle_t *handle)
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_record_session_event(switch_core_session_t *session, const char *file, uint32_t limit, switch_file_handle_t *fh, switch_event_t *variables)
switch_img_position_t
void switch_dial_leg_list_add_leg(switch_dial_leg_list_t *parent, switch_dial_leg_t **legP, const char *dial_string)
void switch_dial_handle_add_global_var_printf(switch_dial_handle_t *handle, const char *var, const char *fmt,...)
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:2373
switch_codec_t read_codec
Definition: switch_ivr.h:49
switch_status_t switch_ivr_bridge_bleg(switch_core_session_t *session, switch_core_session_t *peer_session, uint32_t max_wait_ms)
Bridge leaving b-leg in the control of another thread. Call from b-leg first then call switch_ivr_mul...
switch_ivr_action_t ivr_action
switch_say_gender_t
Definition: switch_types.h:474
switch_status_t switch_ivr_uuid_bridge(const char *originator_uuid, const char *originatee_uuid)
Bridge two existing sessions.
switch_status_t switch_ivr_capture_text(switch_core_session_t *session, switch_bool_t on)
switch_status_t switch_dial_handle_list_serialize_json_obj(switch_dial_handle_list_t *hl, cJSON **json)
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_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:1580
void switch_dial_handle_list_destroy(switch_dial_handle_list_t **hl)
int switch_dial_handle_get_vars(switch_dial_handle_t *handle, int idx, switch_event_t **array, int max)
#define _In_opt_
switch_status_t switch_dial_handle_list_create_handle(switch_dial_handle_list_t *hl, switch_dial_handle_t **handle)
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)
switch_status_t switch_dial_handle_serialize_json(switch_dial_handle_t *handle, char **str)
An abstraction of a data frame.
Definition: switch_frame.h:54
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:2318
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_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_byte_t switch_byte_t uint32_t buflen
switch_status_t switch_ivr_send_prompt(switch_core_session_t *session, const char *type, const char *text, const char *regex)
Definition: switch_ivr.c:1510
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:358
switch_status_t switch_ivr_record_session_pause(switch_core_session_t *session, const char *file, switch_bool_t on)
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_status_t switch_dial_handle_create_json_obj(switch_dial_handle_t **handle, cJSON *json)
switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *)
Definition: switch_ivr.h:816
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:2461
switch_thread_t * thread
Definition: switch_ivr.h:64
void switch_dial_handle_destroy(switch_dial_handle_t **handle)
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:2518
switch_status_t switch_ivr_parse_next_signal_data(switch_core_session_t *session)
Definition: switch_ivr.c:909
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:2431
struct fspr_sockaddr_t switch_sockaddr_t
Definition: switch_apr.h:1029
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_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, switch_dial_handle_t *dh)
Make an outgoing call.
char * switch_ivr_check_presence_mapping(const char *exten_name, const char *domain_name)
Definition: switch_ivr.c:4340
switch_frame_t write_frame
Definition: switch_ivr.h:50
struct fspr_thread_mutex_t switch_mutex_t
Definition: switch_apr.h:314
void switch_ivr_park_session(switch_core_session_t *session)
Definition: switch_ivr.c:3571
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:1881
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:404
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:3335
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_play_and_collect_input(switch_core_session_t *session, const char *prompt, const char *recognizer_mod_name, const char *recognizer_grammar, int min_digits, int max_digits, const char *terminators, uint32_t digit_timeout, cJSON **recognition_result, char **digits_collected, char *terminator_collected, switch_input_args_t *args)
Play prompt and collect input.
void switch_dial_leg_list_add_leg_printf(switch_dial_leg_list_t *parent, switch_dial_leg_t **legP, const char *fmt,...)
switch_status_t(* switch_ivr_dmachine_callback_t)(switch_ivr_dmachine_match_t *match)
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)
const char *const const char *const path
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_detect_audio(switch_core_session_t *session, uint32_t thresh, uint32_t audio_hits, uint32_t timeout_ms, const char *file)
switch_status_t switch_dial_handle_add_leg_var(switch_dial_leg_t *leg, const char *var, const char *val)
switch_bool_t(* switch_tone_detect_callback_t)(switch_core_session_t *, const char *, const char *)
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:1603
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:4327
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_dial_handle_list_serialize_json(switch_dial_handle_list_t *hl, char **str)
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:869
switch_ivr_action_t
Definition: switch_ivr.h:806
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)
void switch_dial_handle_list_add_global_var_printf(switch_dial_handle_list_t *hl, const char *var, const char *fmt,...)
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:2838
switch_status_t switch_ivr_record_file_event(_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, switch_event_t *vars)
record a file from the session to a file
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:452
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)
char * key
Definition: switch_msrp.c:64
switch_say_method_t
Definition: switch_types.h:443
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:509
const char * switch_ivr_dmachine_get_name(switch_ivr_dmachine_t *dmachine)
switch_status_t switch_ivr_speak_text_handle(switch_core_session_t *session, switch_speech_handle_t *sh, switch_codec_t *codec, switch_timer_t *timer, const char *text, switch_input_args_t *args)
int switch_dial_handle_get_peers(switch_dial_handle_t *handle, int idx, char **array, int max)
void switch_ivr_check_hold(switch_core_session_t *session)
Definition: switch_ivr.c:2143
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.
void switch_dial_handle_add_global_var(switch_dial_handle_t *handle, const char *var, const char *val)
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)
struct fspr_pool_t switch_memory_pool_t
const char *const name
Definition: switch_cJSON.h:250
switch_status_t switch_ivr_deactivate_unicast(switch_core_session_t *session)
Definition: switch_ivr.c:371
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)
struct fspr_socket_t switch_socket_t
Definition: switch_apr.h:1026
switch_status_t switch_ivr_set_user_extended(switch_core_session_t *session, const char *data, switch_event_t *params)
Definition: switch_ivr.c:3981
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:1663
struct fspr_thread_t switch_thread_t
Definition: switch_apr.h:941
switch_status_t switch_ivr_record_session(switch_core_session_t *session, const char *file, uint32_t limit, switch_file_handle_t *fh)
Record a session to disk.
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:3667
int switch_dial_handle_get_total(switch_dial_handle_t *handle)
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:2862
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:1567
switch_ivr_menu_flags
Definition: switch_ivr.h:800
switch_status_t switch_dial_handle_create(switch_dial_handle_t **handle)
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:3789
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_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t *parser)
Destroy a digit stream parser object.
Definition: switch_ivr.c:2413
switch_status_t switch_dial_handle_list_create(switch_dial_handle_list_t **hl)
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:3921
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_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:847
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42
switch_status_t switch_dial_handle_list_create_json(switch_dial_handle_list_t **handle, const char *handle_string)