#include <switch_cpp.h>
Collaboration diagram for CoreSession:
Public Member Functions | |
| CoreSession () | |
| CoreSession (char *nuuid, CoreSession *a_leg=NULL) | |
| CoreSession (switch_core_session_t *new_session) | |
| virtual | ~CoreSession () |
| int | insertFile (const char *file, const char *insert_file, int sample_point) |
| int | answer () |
| int | preAnswer () |
| void | hangup (const char *cause="normal_clearing") |
| void | hangupState (void) |
| void | setVariable (char *var, char *val) |
| void | setPrivate (char *var, void *val) |
| void * | getPrivate (char *var) |
| const char * | getVariable (char *var) |
| switch_status_t | process_callback_result (char *result) |
| void | say (const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender=NULL) |
| void | sayPhrase (const char *phrase_name, const char *phrase_data="", const char *phrase_lang=NULL) |
| const char * | hangupCause () |
| const char * | getState () |
| int | recordFile (char *file_name, int time_limit=0, int silence_threshold=0, int silence_hits=0) |
| Record to a file. | |
| int | originate (CoreSession *a_leg_session, char *dest, int timeout=60, switch_state_handler_table_t *handlers=NULL) |
| Set attributes of caller data for purposes of outgoing calls Originate a call to a destination. | |
| virtual void | destroy (void) |
| void | setDTMFCallback (void *cbfunc, char *funcargs) |
| set a DTMF callback function | |
| int | speak (char *text) |
| void | set_tts_parms (char *tts_name, char *voice_name) |
| int | collectDigits (int abs_timeout) |
| int | collectDigits (int digit_timeout, int abs_timeout) |
| char * | getDigits (int maxdigits, char *terminators, int timeout) |
| char * | getDigits (int maxdigits, char *terminators, int timeout, int interdigit) |
| int | transfer (char *extension, char *dialplan=NULL, char *context=NULL) |
| char * | read (int min_digits, int max_digits, const char *prompt_audio_file, int timeout, const char *valid_terminators, int digit_timeout=0) |
| char * | playAndGetDigits (int min_digits, int max_digits, int max_tries, int timeout, char *terminators, char *audio_files, char *bad_input_audio_files, char *digits_regex, const char *var_name=NULL, int digit_timeout=0, const char *transfer_on_failure=NULL) |
| Play a file into channel and collect dtmfs. | |
| int | streamFile (char *file, int starting_sample_count=0) |
| Play a file that resides on disk into the channel. | |
| int | sleep (int ms, int sync=0) |
| int | flushEvents () |
| flush any pending events | |
| int | flushDigits () |
| flush any pending digits | |
| int | setAutoHangup (bool val) |
| void | setHangupHook (void *hangup_func) |
| Set the hangup callback function. | |
| bool | ready () |
| bool | bridged () |
| bool | answered () |
| bool | mediaReady () |
| void | waitForAnswer (CoreSession *calling_session) |
| void | execute (const char *app, const char *data=NULL) |
| void | sendEvent (Event *sendME) |
| void | setEventData (Event *e) |
| char * | getXMLCDR () |
| virtual bool | begin_allow_threads ()=0 |
| virtual bool | end_allow_threads ()=0 |
| const char * | get_uuid () const |
| Get the uuid of this session. | |
| const switch_input_args_t & | get_cb_args () const |
| Get the callback function arguments associated with this session. | |
| virtual void | check_hangup_hook ()=0 |
| Callback to the language specific hangup callback. | |
| virtual switch_status_t | run_dtmf_callback (void *input, switch_input_type_t itype)=0 |
Data Fields | |
| switch_core_session_t * | session |
| switch_channel_t * | channel |
| unsigned int | flags |
| int | allocated |
| input_callback_state | cb_state |
| switch_channel_state_t | hook_state |
| switch_call_cause_t | cause |
| char * | uuid |
| char * | tts_name |
| char * | voice_name |
Protected Member Functions | |
| void | store_file_handle (switch_file_handle_t *fh) |
Protected Attributes | |
| switch_input_args_t | args |
| switch_input_args_t * | ap |
| char * | xml_cdr_text |
| void * | on_hangup |
| switch_file_handle_t * | fhp |
| char | dtmf_buf [512] |
Definition at line 198 of file switch_cpp.h.
| CoreSession::CoreSession | ( | ) |
Definition at line 514 of file switch_cpp.cpp.
References init_vars.
00515 { 00516 init_vars(); 00517 }
| CoreSession::CoreSession | ( | char * | nuuid, | |
| CoreSession * | a_leg = NULL | |||
| ) |
Definition at line 519 of file switch_cpp.cpp.
References allocated, cause, channel, CS_SOFT_EXECUTE, init_vars, S_HUP, session, SOF_NONE, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, switch_channel_set_state, switch_channel_wait_for_state(), switch_core_session_force_locate(), switch_core_session_get_channel(), switch_core_session_get_uuid(), switch_ivr_originate(), switch_set_flag, SWITCH_STATUS_SUCCESS, and uuid.
00520 { 00521 switch_channel_t *other_channel = NULL; 00522 00523 init_vars(); 00524 00525 if (a_leg && a_leg->session) { 00526 other_channel = switch_core_session_get_channel(a_leg->session); 00527 } 00528 00529 if (!strchr(nuuid, '/') && (session = switch_core_session_force_locate(nuuid))) { 00530 uuid = strdup(nuuid); 00531 channel = switch_core_session_get_channel(session); 00532 allocated = 1; 00533 } else { 00534 cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; 00535 if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) 00536 == SWITCH_STATUS_SUCCESS) { 00537 channel = switch_core_session_get_channel(session); 00538 allocated = 1; 00539 switch_set_flag(this, S_HUP); 00540 uuid = strdup(switch_core_session_get_uuid(session)); 00541 switch_channel_set_state(switch_core_session_get_channel(session), CS_SOFT_EXECUTE); 00542 switch_channel_wait_for_state(channel, other_channel, CS_SOFT_EXECUTE); 00543 } 00544 } 00545 }
| CoreSession::CoreSession | ( | switch_core_session_t * | new_session | ) |
Definition at line 547 of file switch_cpp.cpp.
References allocated, channel, init_vars, session, switch_core_session_get_channel(), switch_core_session_get_uuid(), switch_core_session_read_lock_hangup(), and uuid.
00548 { 00549 init_vars(); 00550 00551 if (new_session) { 00552 session = new_session; 00553 channel = switch_core_session_get_channel(session); 00554 allocated = 1; 00555 switch_core_session_read_lock_hangup(session); 00556 uuid = strdup(switch_core_session_get_uuid(session)); 00557 } 00558 }
| CoreSession::~CoreSession | ( | ) | [virtual] |
Definition at line 560 of file switch_cpp.cpp.
References allocated, destroy(), and this_check_void.
00561 { 00562 this_check_void(); 00563 if (allocated) destroy(); 00564 }
| int CoreSession::answer | ( | ) |
Definition at line 594 of file switch_cpp.cpp.
References sanity_check, switch_channel_answer, SWITCH_STATUS_SUCCESS, and this_check.
00595 { 00596 switch_status_t status; 00597 this_check(-1); 00598 sanity_check(-1); 00599 status = switch_channel_answer(channel); 00600 return status == SWITCH_STATUS_SUCCESS ? 1 : 0; 00601 }
| bool CoreSession::answered | ( | ) |
Definition at line 979 of file switch_cpp.cpp.
References CF_ANSWERED, sanity_check, switch_channel_test_flag(), and this_check.
00979 { 00980 00981 this_check(false); 00982 sanity_check(false); 00983 return switch_channel_test_flag(channel, CF_ANSWERED) != 0; 00984 }
| virtual bool CoreSession::begin_allow_threads | ( | ) | [pure virtual] |
| bool CoreSession::bridged | ( | ) |
Definition at line 960 of file switch_cpp.cpp.
References CF_BRIDGED, sanity_check, switch_channel_test_flag(), switch_channel_up, and this_check.
00960 { 00961 00962 this_check(false); 00963 00964 if (!session) { 00965 return false; 00966 } 00967 sanity_check(false); 00968 00969 return (switch_channel_up(channel) && switch_channel_test_flag(channel, CF_BRIDGED)); 00970 }
| virtual void CoreSession::check_hangup_hook | ( | ) | [pure virtual] |
| int CoreSession::collectDigits | ( | int | digit_timeout, | |
| int | abs_timeout | |||
| ) |
Definition at line 755 of file switch_cpp.cpp.
References sanity_check, switch_ivr_collect_digits_callback(), SWITCH_STATUS_SUCCESS, and this_check.
00755 { 00756 this_check(-1); 00757 sanity_check(-1); 00758 begin_allow_threads(); 00759 switch_ivr_collect_digits_callback(session, ap, digit_timeout, abs_timeout); 00760 end_allow_threads(); 00761 return SWITCH_STATUS_SUCCESS; 00762 }
| int CoreSession::collectDigits | ( | int | abs_timeout | ) |
For timeout milliseconds, call the dtmf function set previously by setDTMFCallback whenever a dtmf or event is received
Definition at line 751 of file switch_cpp.cpp.
00751 { 00752 return collectDigits(0, abs_timeout); 00753 }
| void CoreSession::destroy | ( | void | ) | [virtual] |
Definition at line 986 of file switch_cpp.cpp.
References CF_TRANSFER, init_vars, S_HUP, SWITCH_CAUSE_NORMAL_CLEARING, switch_channel_get_name(), switch_channel_hangup, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_private(), switch_channel_test_flag(), switch_channel_up, switch_core_session_get_channel(), switch_core_session_rwunlock(), SWITCH_LOG_DEBUG, switch_log_printf(), switch_safe_free, switch_test_flag, and this_check_void.
Referenced by ~CoreSession().
00987 { 00988 this_check_void(); 00989 00990 if (!allocated) { 00991 return; 00992 } 00993 00994 allocated = 0; 00995 00996 switch_safe_free(xml_cdr_text); 00997 switch_safe_free(uuid); 00998 switch_safe_free(tts_name); 00999 switch_safe_free(voice_name); 01000 01001 if (session) { 01002 if (!channel) { 01003 channel = switch_core_session_get_channel(session); 01004 } 01005 01006 if (channel) { 01007 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, 01008 "%s destroy/unlink session from object\n", switch_channel_get_name(channel)); 01009 switch_channel_set_private(channel, "CoreSession", NULL); 01010 if (switch_channel_up(channel) && switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) { 01011 switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); 01012 } 01013 } 01014 01015 switch_core_session_rwunlock(session); 01016 session = NULL; 01017 channel = NULL; 01018 } 01019 01020 init_vars(); 01021 01022 }
| virtual bool CoreSession::end_allow_threads | ( | ) | [pure virtual] |
| void CoreSession::execute | ( | const char * | app, | |
| const char * | data = NULL | |||
| ) |
Definition at line 669 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_core_session_execute_application, and this_check_void.
00670 { 00671 this_check_void(); 00672 sanity_check_noreturn; 00673 00674 begin_allow_threads(); 00675 switch_core_session_execute_application(session, app, data); 00676 end_allow_threads(); 00677 }
| int CoreSession::flushDigits | ( | ) |
flush any pending digits
Definition at line 1134 of file switch_cpp.cpp.
References sanity_check, switch_channel_flush_dtmf(), switch_core_session_get_channel(), SWITCH_STATUS_SUCCESS, and this_check.
01135 { 01136 this_check(-1); 01137 sanity_check(-1); 01138 switch_channel_flush_dtmf(switch_core_session_get_channel(session)); 01139 return SWITCH_STATUS_SUCCESS; 01140 }
| int CoreSession::flushEvents | ( | ) |
flush any pending events
Definition at line 1115 of file switch_cpp.cpp.
References sanity_check, switch_core_session_dequeue_event(), switch_core_session_get_channel(), switch_event_destroy(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, SWITCH_TRUE, and this_check.
01116 { 01117 switch_event_t *event; 01118 switch_channel_t *channel; 01119 01120 this_check(-1); 01121 sanity_check(-1); 01122 01123 if (!session) { 01124 return SWITCH_STATUS_FALSE; 01125 } 01126 channel = switch_core_session_get_channel(session); 01127 01128 while (switch_core_session_dequeue_event(session, &event, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { 01129 switch_event_destroy(&event); 01130 } 01131 return SWITCH_STATUS_SUCCESS; 01132 }
| const switch_input_args_t& CoreSession::get_cb_args | ( | ) | const [inline] |
Get the callback function arguments associated with this session.
Definition at line 377 of file switch_cpp.h.
00377 { 00378 return args; 00379 };
| const char* CoreSession::get_uuid | ( | ) | const [inline] |
Get the uuid of this session.
Definition at line 370 of file switch_cpp.h.
| char * CoreSession::getDigits | ( | int | maxdigits, | |
| char * | terminators, | |||
| int | timeout, | |||
| int | interdigit | |||
| ) |
Definition at line 769 of file switch_cpp.cpp.
References sanity_check, SWITCH_CHANNEL_SESSION_LOG, switch_ivr_collect_digits_count(), SWITCH_LOG_DEBUG, switch_log_printf(), and this_check.
00773 { 00774 switch_status_t status; 00775 this_check((char *)""); 00776 sanity_check((char *)""); 00777 begin_allow_threads(); 00778 char terminator; 00779 00780 memset(dtmf_buf, 0, sizeof(dtmf_buf)); 00781 status = switch_ivr_collect_digits_count(session, 00782 dtmf_buf, 00783 sizeof(dtmf_buf), 00784 maxdigits, 00785 terminators, 00786 &terminator, 00787 (uint32_t) timeout, (uint32_t)interdigit, 0); 00788 00789 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "getDigits dtmf_buf: %s\n", dtmf_buf); 00790 end_allow_threads(); 00791 return dtmf_buf; 00792 }
| char * CoreSession::getDigits | ( | int | maxdigits, | |
| char * | terminators, | |||
| int | timeout | |||
| ) |
Collect up to maxdigits digits worth of digits and store them in dtmf_buf. In the case of mod_python, the dtmf_buf parameter is configured to act as a _return_ value, (see mod_python.i). This does NOT call any callbacks upon receiving dtmf digits. For that, use collectDigits.
Definition at line 764 of file switch_cpp.cpp.
00765 { 00766 return getDigits(maxdigits, terminators, timeout, 0); 00767 }
| void * CoreSession::getPrivate | ( | char * | var | ) |
Definition at line 648 of file switch_cpp.cpp.
References sanity_check, switch_channel_get_private(), and this_check.
00649 { 00650 this_check(NULL); 00651 sanity_check(NULL); 00652 return switch_channel_get_private(channel, var); 00653 }
| const char * CoreSession::getState | ( | ) |
Definition at line 1030 of file switch_cpp.cpp.
References switch_channel_get_state(), switch_channel_state_name(), and this_check.
01031 { 01032 this_check(NULL); 01033 01034 if (channel) { 01035 return switch_channel_state_name(switch_channel_get_state(channel)); 01036 } 01037 01038 return "ERROR"; 01039 01040 }
| const char * CoreSession::getVariable | ( | char * | var | ) |
Definition at line 662 of file switch_cpp.cpp.
References sanity_check, switch_channel_get_variable, and this_check.
00663 { 00664 this_check(""); 00665 sanity_check(""); 00666 return switch_channel_get_variable(channel, var); 00667 }
| char * CoreSession::getXMLCDR | ( | ) |
Definition at line 566 of file switch_cpp.cpp.
References sanity_check, SWITCH_FALSE, switch_ivr_generate_xml_cdr(), switch_safe_free, SWITCH_STATUS_SUCCESS, switch_xml_free(), switch_xml_toxml(), and this_check.
00567 { 00568 00569 switch_xml_t cdr = NULL; 00570 00571 this_check((char *)""); 00572 sanity_check((char *)""); 00573 00574 switch_safe_free(xml_cdr_text); 00575 00576 if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { 00577 xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE); 00578 switch_xml_free(cdr); 00579 } 00580 00581 return (char *) (xml_cdr_text ? xml_cdr_text : ""); 00582 }
| void CoreSession::hangup | ( | const char * | cause = "normal_clearing" |
) |
Definition at line 631 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_channel_hangup, SWITCH_CHANNEL_SESSION_LOG, switch_channel_str2cause(), SWITCH_LOG_DEBUG, switch_log_printf(), and this_check_void.
00632 { 00633 this_check_void(); 00634 sanity_check_noreturn; 00635 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::hangup\n"); 00636 this->begin_allow_threads(); 00637 switch_channel_hangup(channel, switch_channel_str2cause(cause)); 00638 this->end_allow_threads(); 00639 }
| const char * CoreSession::hangupCause | ( | ) |
Definition at line 1024 of file switch_cpp.cpp.
References switch_channel_cause2str(), and this_check.
01025 { 01026 this_check(NULL); 01027 return switch_channel_cause2str(cause); 01028 }
| void CoreSession::hangupState | ( | void | ) |
Definition at line 621 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_channel_down, switch_core_session_hangup_state(), and SWITCH_FALSE.
00622 { 00623 sanity_check_noreturn; 00624 this->begin_allow_threads(); 00625 if (switch_channel_down(channel)) { 00626 switch_core_session_hangup_state(session, SWITCH_FALSE); 00627 } 00628 this->end_allow_threads(); 00629 }
| int CoreSession::insertFile | ( | const char * | file, | |
| const char * | insert_file, | |||
| int | sample_point | |||
| ) |
Definition at line 603 of file switch_cpp.cpp.
References sanity_check, switch_ivr_insert_file(), SWITCH_STATUS_SUCCESS, and this_check.
00604 { 00605 switch_status_t status; 00606 this_check(-1); 00607 sanity_check(-1); 00608 status = switch_ivr_insert_file(session, file, insert_file, (switch_size_t)sample_point); 00609 return status == SWITCH_STATUS_SUCCESS ? 1 : 0; 00610 }
| bool CoreSession::mediaReady | ( | ) |
Definition at line 972 of file switch_cpp.cpp.
References sanity_check, switch_channel_media_ready, and this_check.
00972 { 00973 00974 this_check(false); 00975 sanity_check(false); 00976 return switch_channel_media_ready(channel) != 0; 00977 }
| int CoreSession::originate | ( | CoreSession * | a_leg_session, | |
| char * | dest, | |||
| int | timeout = 60, |
|||
| switch_state_handler_table_t * | handlers = NULL | |||
| ) |
Set attributes of caller data for purposes of outgoing calls Originate a call to a destination.
| a_leg_session | - the session where the call is originating from and also the session in which _this_ session was created | |
| dest | - a string representing destination, eg, sofia/mydomain.com/foo@bar.com | |
| timeout | - time to wait for call to be answered |
Definition at line 1042 of file switch_cpp.cpp.
References CS_SOFT_EXECUTE, SOF_NONE, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER, SWITCH_CHANNEL_LOG, switch_channel_set_state, switch_core_session_get_channel(), switch_core_session_get_uuid(), switch_ivr_originate(), switch_log_printf(), SWITCH_LOG_WARNING, switch_safe_free, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and this_check.
01043 { 01044 01045 switch_core_session_t *aleg_core_session = NULL; 01046 01047 this_check(0); 01048 01049 cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; 01050 01051 if (a_leg_session != NULL) { 01052 aleg_core_session = a_leg_session->session; 01053 } 01054 01055 // this session has no valid switch_core_session_t at this point, and therefore 01056 // no valid channel. since the threadstate is stored in the channel, and there 01057 // is none, if we try to call begin_alllow_threads it will fail miserably. 01058 // use the 'a leg session' to do the thread swapping stuff. 01059 if (a_leg_session) a_leg_session->begin_allow_threads(); 01060 01061 if (switch_ivr_originate(aleg_core_session, 01062 &session, 01063 &cause, 01064 dest, 01065 timeout, 01066 handlers, 01067 NULL, 01068 NULL, 01069 NULL, 01070 NULL, 01071 SOF_NONE, 01072 NULL) != SWITCH_STATUS_SUCCESS) { 01073 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest); 01074 goto failed; 01075 01076 } 01077 01078 if (a_leg_session) a_leg_session->end_allow_threads(); 01079 channel = switch_core_session_get_channel(session); 01080 allocated = 1; 01081 switch_safe_free(uuid); 01082 uuid = strdup(switch_core_session_get_uuid(session)); 01083 switch_channel_set_state(switch_core_session_get_channel(session), CS_SOFT_EXECUTE); 01084 01085 return SWITCH_STATUS_SUCCESS; 01086 01087 failed: 01088 if (a_leg_session) a_leg_session->end_allow_threads(); 01089 return SWITCH_STATUS_FALSE; 01090 }
| char * CoreSession::playAndGetDigits | ( | int | min_digits, | |
| int | max_digits, | |||
| int | max_tries, | |||
| int | timeout, | |||
| char * | terminators, | |||
| char * | audio_files, | |||
| char * | bad_input_audio_files, | |||
| char * | digits_regex, | |||
| const char * | var_name = NULL, |
|||
| int | digit_timeout = 0, |
|||
| const char * | transfer_on_failure = NULL | |||
| ) |
Play a file into channel and collect dtmfs.
See API docs in switch_ivr.h: switch_play_and_get_digits(..)
NOTE: this does not call any dtmf callbacks set by setDTMFCallback(..) as it uses its own internal callback handler.
Definition at line 836 of file switch_cpp.cpp.
References sanity_check, switch_play_and_get_digits(), and this_check.
00847 { 00848 switch_status_t status; 00849 sanity_check((char *)""); 00850 this_check((char *)""); 00851 begin_allow_threads(); 00852 memset(dtmf_buf, 0, sizeof(dtmf_buf)); 00853 status = switch_play_and_get_digits( session, 00854 (uint32_t) min_digits, 00855 (uint32_t) max_digits, 00856 (uint32_t) max_tries, 00857 (uint32_t) timeout, 00858 terminators, 00859 audio_files, 00860 bad_input_audio_files, 00861 var_name, 00862 dtmf_buf, 00863 sizeof(dtmf_buf), 00864 digits_regex, 00865 (uint32_t) digit_timeout, 00866 transfer_on_failure); 00867 00868 end_allow_threads(); 00869 return dtmf_buf; 00870 }
| int CoreSession::preAnswer | ( | ) |
Definition at line 612 of file switch_cpp.cpp.
References sanity_check, switch_channel_pre_answer, SWITCH_STATUS_SUCCESS, and this_check.
00613 { 00614 switch_status_t status; 00615 this_check(-1); 00616 sanity_check(-1); 00617 status = switch_channel_pre_answer(channel); 00618 return status == SWITCH_STATUS_SUCCESS ? 1 : 0; 00619 }
| switch_status_t CoreSession::process_callback_result | ( | char * | result | ) |
Definition at line 1319 of file switch_cpp.cpp.
References sanity_check, switch_ivr_process_fh(), SWITCH_STATUS_FALSE, and this_check.
01320 { 01321 01322 this_check(SWITCH_STATUS_FALSE); 01323 sanity_check(SWITCH_STATUS_FALSE); 01324 01325 return switch_ivr_process_fh(session, result, fhp); 01326 }
| char * CoreSession::read | ( | int | min_digits, | |
| int | max_digits, | |||
| const char * | prompt_audio_file, | |||
| int | timeout, | |||
| const char * | valid_terminators, | |||
| int | digit_timeout = 0 | |||
| ) |
Definition at line 807 of file switch_cpp.cpp.
References sanity_check, switch_ivr_read(), and this_check.
00813 { 00814 this_check((char *)""); 00815 sanity_check((char *)""); 00816 if (min_digits < 1) { 00817 min_digits = 1; 00818 } 00819 00820 if (max_digits < 1) { 00821 max_digits = 1; 00822 } 00823 00824 if (timeout < 1) { 00825 timeout = 1; 00826 } 00827 00828 begin_allow_threads(); 00829 switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf, 00830 sizeof(dtmf_buf), timeout, valid_terminators, (uint32_t)digit_timeout); 00831 end_allow_threads(); 00832 00833 return dtmf_buf; 00834 }
| bool CoreSession::ready | ( | ) |
Definition at line 947 of file switch_cpp.cpp.
References sanity_check, switch_channel_ready, and this_check.
00947 { 00948 00949 this_check(false); 00950 00951 if (!session) { 00952 return false; 00953 } 00954 sanity_check(false); 00955 00956 return switch_channel_ready(channel) != 0; 00957 }
| int CoreSession::recordFile | ( | char * | file_name, | |
| int | time_limit = 0, |
|||
| int | silence_threshold = 0, |
|||
| int | silence_hits = 0 | |||
| ) |
Record to a file.
| file_name | ||
| <[max_len]> | maximum length of the recording in seconds | |
| <[silence_threshold]> | energy level audio must fall below to be considered silence (500 is a good starting point). | |
| <[silence_secs]> | seconds of silence to interrupt the record. |
Definition at line 1092 of file switch_cpp.cpp.
References sanity_check, switch_ivr_record_file(), SWITCH_STATUS_SUCCESS, and this_check.
01093 { 01094 switch_status_t status; 01095 switch_file_handle_t local_fh; 01096 01097 this_check(-1); 01098 sanity_check(-1); 01099 01100 memset(&local_fh, 0, sizeof(local_fh)); 01101 fhp = &local_fh; 01102 local_fh.thresh = silence_threshold; 01103 local_fh.silence_hits = silence_hits; 01104 01105 begin_allow_threads(); 01106 status = switch_ivr_record_file(session, &local_fh, file_name, &args, time_limit); 01107 end_allow_threads(); 01108 01109 fhp = NULL; 01110 01111 return status == SWITCH_STATUS_SUCCESS ? 1 : 0; 01112 01113 }
| virtual switch_status_t CoreSession::run_dtmf_callback | ( | void * | input, | |
| switch_input_type_t | itype | |||
| ) | [pure virtual] |
Referenced by dtmf_callback().
| void CoreSession::say | ( | const char * | tosay, | |
| const char * | module_name, | |||
| const char * | say_type, | |||
| const char * | say_method, | |||
| const char * | say_gender = NULL | |||
| ) |
Definition at line 872 of file switch_cpp.cpp.
References sanity_check_noreturn, SWITCH_CHANNEL_SESSION_LOG, switch_ivr_say(), SWITCH_LOG_ERROR, switch_log_printf(), and this_check_void.
00873 { 00874 this_check_void(); 00875 sanity_check_noreturn; 00876 if (!(tosay && module_name && say_type && say_method)) { 00877 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error! invalid args.\n"); 00878 return; 00879 } 00880 begin_allow_threads(); 00881 switch_ivr_say(session, tosay, module_name, say_type, say_method, say_gender, ap); 00882 end_allow_threads(); 00883 }
| void CoreSession::sayPhrase | ( | const char * | phrase_name, | |
| const char * | phrase_data = "", |
|||
| const char * | phrase_lang = NULL | |||
| ) |
Definition at line 885 of file switch_cpp.cpp.
References sanity_check_noreturn, SWITCH_CHANNEL_SESSION_LOG, switch_ivr_phrase_macro, SWITCH_LOG_ERROR, switch_log_printf(), and this_check_void.
00886 { 00887 this_check_void(); 00888 sanity_check_noreturn; 00889 00890 if (!(phrase_name)) { 00891 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error! invalid args.\n"); 00892 return; 00893 } 00894 00895 begin_allow_threads(); 00896 switch_ivr_phrase_macro(session, phrase_name, phrase_data, phrase_lang, ap); 00897 end_allow_threads(); 00898 }
| void CoreSession::sendEvent | ( | Event * | sendME | ) |
Definition at line 702 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_core_session_receive_event(), switch_event_dup(), SWITCH_STATUS_SUCCESS, and this_check_void.
00703 { 00704 this_check_void(); 00705 sanity_check_noreturn; 00706 00707 if (sendME->event) { 00708 switch_event_t *new_event; 00709 if (switch_event_dup(&new_event, sendME->event) == SWITCH_STATUS_SUCCESS) { 00710 switch_core_session_receive_event(session, &new_event); 00711 } 00712 } 00713 }
| void CoreSession::set_tts_parms | ( | char * | tts_name, | |
| char * | voice_name | |||
| ) |
Definition at line 739 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_safe_free, and this_check_void.
00740 { 00741 this_check_void(); 00742 sanity_check_noreturn; 00743 switch_safe_free(tts_name); 00744 switch_safe_free(voice_name); 00745 tts_name = strdup(tts_name_p); 00746 voice_name = strdup(voice_name_p); 00747 }
| int CoreSession::setAutoHangup | ( | bool | val | ) |
Definition at line 1142 of file switch_cpp.cpp.
References S_HUP, sanity_check, switch_clear_flag, switch_set_flag, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and this_check.
01143 { 01144 this_check(-1); 01145 sanity_check(-1); 01146 01147 if (!session) { 01148 return SWITCH_STATUS_FALSE; 01149 } 01150 if (val) { 01151 switch_set_flag(this, S_HUP); 01152 } else { 01153 switch_clear_flag(this, S_HUP); 01154 } 01155 return SWITCH_STATUS_SUCCESS; 01156 }
| void CoreSession::setDTMFCallback | ( | void * | cbfunc, | |
| char * | funcargs | |||
| ) |
set a DTMF callback function
The DTMF callback function will be set and persist for the life of the session, and be called when a dtmf is pressed by user during streamfile(), collectDigits(), and certain other methods are executing.
Definition at line 679 of file switch_cpp.cpp.
References dtmf_callback(), sanity_check_noreturn, switch_channel_set_private(), and this_check_void.
00679 { 00680 00681 this_check_void(); 00682 sanity_check_noreturn; 00683 00684 cb_state.funcargs = funcargs; 00685 cb_state.function = cbfunc; 00686 00687 args.buf = &cb_state; 00688 args.buflen = sizeof(cb_state); // not sure what this is used for, copy mod_spidermonkey 00689 00690 switch_channel_set_private(channel, "CoreSession", this); 00691 00692 // we cannot set the actual callback to a python function, because 00693 // the callback is a function pointer with a specific signature. 00694 // so, set it to the following c function which will act as a proxy, 00695 // finding the python callback in the args callback args structure 00696 args.input_callback = dtmf_callback; 00697 ap = &args; 00698 00699 00700 }
| void CoreSession::setEventData | ( | Event * | e | ) |
Definition at line 584 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_channel_event_set_data(), and this_check_void.
00585 { 00586 this_check_void(); 00587 sanity_check_noreturn; 00588 00589 if (channel && e->event) { 00590 switch_channel_event_set_data(channel, e->event); 00591 } 00592 }
| void CoreSession::setHangupHook | ( | void * | hangup_func | ) |
Set the hangup callback function.
| hangup_func | - language specific function ptr cast into void * |
Definition at line 1167 of file switch_cpp.cpp.
References hanguphook(), sanity_check_noreturn, switch_channel_get_state(), SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_private(), switch_core_session_get_channel(), SWITCH_LOG_DEBUG, switch_log_printf(), and this_check_void.
01167 { 01168 01169 this_check_void(); 01170 sanity_check_noreturn; 01171 01172 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::seHangupHook, hangup_func: %p\n", hangup_func); 01173 on_hangup = hangup_func; 01174 switch_channel_t *channel = switch_core_session_get_channel(session); 01175 01176 hook_state = switch_channel_get_state(channel); 01177 switch_channel_set_private(channel, "CoreSession", this); 01178 switch_core_event_hook_add_state_change(session, hanguphook); 01179 }
| void CoreSession::setPrivate | ( | char * | var, | |
| void * | val | |||
| ) |
Definition at line 641 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_channel_set_private(), and this_check_void.
00642 { 00643 this_check_void(); 00644 sanity_check_noreturn; 00645 switch_channel_set_private(channel, var, val); 00646 }
| void CoreSession::setVariable | ( | char * | var, | |
| char * | val | |||
| ) |
Definition at line 655 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_channel_set_variable_var_check(), SWITCH_FALSE, and this_check_void.
00656 { 00657 this_check_void(); 00658 sanity_check_noreturn; 00659 switch_channel_set_variable_var_check(channel, var, val, SWITCH_FALSE); 00660 }
| int CoreSession::sleep | ( | int | ms, | |
| int | sync = 0 | |||
| ) |
Definition at line 932 of file switch_cpp.cpp.
References sanity_check, switch_ivr_sleep(), SWITCH_STATUS_SUCCESS, and this_check.
00932 { 00933 00934 switch_status_t status; 00935 00936 this_check(-1); 00937 sanity_check(-1); 00938 00939 begin_allow_threads(); 00940 status = switch_ivr_sleep(session, ms, (switch_bool_t) sync, ap); 00941 end_allow_threads(); 00942 00943 return status == SWITCH_STATUS_SUCCESS ? 1 : 0; 00944 00945 }
| int CoreSession::speak | ( | char * | text | ) |
Definition at line 715 of file switch_cpp.cpp.
References sanity_check, SWITCH_CHANNEL_SESSION_LOG, switch_ivr_speak_text(), SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and this_check.
00716 { 00717 switch_status_t status; 00718 00719 this_check(-1); 00720 sanity_check(-1); 00721 00722 if (!tts_name) { 00723 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No TTS engine specified\n"); 00724 return SWITCH_STATUS_FALSE; 00725 } 00726 00727 if (!voice_name) { 00728 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No TTS voice specified\n"); 00729 return SWITCH_STATUS_FALSE; 00730 } 00731 00732 00733 begin_allow_threads(); 00734 status = switch_ivr_speak_text(session, tts_name, voice_name, text, ap); 00735 end_allow_threads(); 00736 return status == SWITCH_STATUS_SUCCESS ? 1 : 0; 00737 }
| void CoreSession::store_file_handle | ( | switch_file_handle_t * | fh | ) | [protected] |
| int CoreSession::streamFile | ( | char * | file, | |
| int | starting_sample_count = 0 | |||
| ) |
Play a file that resides on disk into the channel.
| file | - the path to the .wav/.mp3 to be played | |
| starting_sample_count | - the index of the sample to start playing from |
Definition at line 900 of file switch_cpp.cpp.
References sanity_check, switch_channel_get_variable, switch_ivr_play_file(), SWITCH_STATUS_SUCCESS, and this_check.
00900 { 00901 00902 switch_status_t status; 00903 //switch_file_handle_t fh = { 0 }; 00904 const char *prebuf; 00905 switch_file_handle_t local_fh; 00906 00907 this_check(-1); 00908 sanity_check(-1); 00909 00910 memset(&local_fh, 0, sizeof(local_fh)); 00911 fhp = &local_fh; 00912 local_fh.samples = starting_sample_count; 00913 00914 00915 if ((prebuf = switch_channel_get_variable(this->channel, "stream_prebuffer"))) { 00916 int maybe = atoi(prebuf); 00917 if (maybe > 0) { 00918 local_fh.prebuf = maybe; 00919 } 00920 } 00921 00922 begin_allow_threads(); 00923 status = switch_ivr_play_file(session, fhp, file, ap); 00924 end_allow_threads(); 00925 00926 fhp = NULL; 00927 00928 return status == SWITCH_STATUS_SUCCESS ? 1 : 0; 00929 00930 }
| int CoreSession::transfer | ( | char * | extension, | |
| char * | dialplan = NULL, |
|||
| char * | context = NULL | |||
| ) |
Definition at line 794 of file switch_cpp.cpp.
References sanity_check, SWITCH_CHANNEL_SESSION_LOG, switch_ivr_session_transfer(), SWITCH_LOG_DEBUG, switch_log_printf(), SWITCH_STATUS_SUCCESS, and this_check.
00795 { 00796 switch_status_t status; 00797 this_check(-1); 00798 sanity_check(-1); 00799 begin_allow_threads(); 00800 status = switch_ivr_session_transfer(session, extension, dialplan, context); 00801 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "transfer result: %d\n", status); 00802 end_allow_threads(); 00803 return status == SWITCH_STATUS_SUCCESS ? 1 : 0; 00804 }
| void CoreSession::waitForAnswer | ( | CoreSession * | calling_session | ) |
Definition at line 1158 of file switch_cpp.cpp.
References sanity_check_noreturn, switch_ivr_wait_for_answer(), and this_check_void.
01159 { 01160 this_check_void(); 01161 sanity_check_noreturn; 01162 01163 switch_ivr_wait_for_answer(calling_session ? calling_session->session : NULL, session); 01164 01165 }
switch_input_args_t* CoreSession::ap [protected] |
Definition at line 203 of file switch_cpp.h.
switch_input_args_t CoreSession::args [protected] |
Definition at line 201 of file switch_cpp.h.
Definition at line 220 of file switch_cpp.h.
char CoreSession::dtmf_buf[512] [protected] |
Definition at line 209 of file switch_cpp.h.
switch_file_handle_t* CoreSession::fhp [protected] |
Definition at line 208 of file switch_cpp.h.
| unsigned int CoreSession::flags |
Definition at line 218 of file switch_cpp.h.
void* CoreSession::on_hangup [protected] |
Definition at line 207 of file switch_cpp.h.
| char* CoreSession::tts_name |
Definition at line 226 of file switch_cpp.h.
| char* CoreSession::uuid |
| char* CoreSession::voice_name |
Definition at line 227 of file switch_cpp.h.
char* CoreSession::xml_cdr_text [protected] |
Definition at line 205 of file switch_cpp.h.
1.4.7