#include <switch_swigable_cpp.h>
Collaboration diagram for CoreSession:

Public Member Functions | |
| SWITCH_DECLARE_CONSTRUCTOR | CoreSession () |
| SWITCH_DECLARE_CONSTRUCTOR | CoreSession (char *nuuid, CoreSession *a_leg=NULL) |
| SWITCH_DECLARE_CONSTRUCTOR | CoreSession (switch_core_session_t *new_session) |
| virtual SWITCH_DECLARE_CONSTRUCTOR | ~CoreSession () |
| int | answer () |
| int | preAnswer () |
| void | hangup (const char *cause="normal_clearing") |
| 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) |
| void | sayPhrase (const char *phrase_name, const char *phrase_data="", const char *phrase_lang=NULL) |
| int | recordFile (char *file_name, int time_limit=0, int silence_threshold=0, int silence_hits=0) |
| Record to a file. | |
| void | setCallerData (char *var, char *val) |
| Set attributes of caller data for purposes of outgoing calls. | |
| int | originate (CoreSession *a_leg_session, char *dest, int timeout=60) |
| Originate a call to a destination. | |
| 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 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) |
| 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) |
| 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 | 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 | answered () |
| bool | mediaReady () |
| void | waitForAnswer (CoreSession *calling_session) |
| void | execute (char *app, 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 |
| 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 |
| CoreSession () | |
| CoreSession (char *nuuid, CoreSession *a_leg=NULL) | |
| CoreSession (switch_core_session_t *new_session) | |
| virtual | ~CoreSession () |
| int | answer () |
| int | preAnswer () |
| void | hangup (const char *cause="normal_clearing") |
| 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) |
| void | sayPhrase (const char *phrase_name, const char *phrase_data="", const char *phrase_lang=NULL) |
| int | recordFile (char *file_name, int time_limit=0, int silence_threshold=0, int silence_hits=0) |
| void | setCallerData (char *var, char *val) |
| int | originate (CoreSession *a_leg_session, char *dest, int timeout=60) |
| void | destroy (void) |
| void | setDTMFCallback (void *cbfunc, char *funcargs) |
| int | speak (char *text) |
| void | set_tts_parms (char *tts_name, char *voice_name) |
| int | collectDigits (int 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) |
| 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) |
| int | streamFile (char *file, int starting_sample_count=0) |
| int | sleep (int ms) |
| int | flushEvents () |
| int | flushDigits () |
| int | setAutoHangup (bool val) |
| void | setHangupHook (void *hangup_func) |
| bool | ready () |
| bool | answered () |
| bool | mediaReady () |
| void | waitForAnswer (CoreSession *calling_session) |
| void | execute (char *app, 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 |
| char * | get_uuid () const |
| const switch_input_args_t & | get_cb_args () const |
| virtual void | check_hangup_hook ()=0 |
| 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 |
| char * | uuid |
| char * | tts_name |
| char * | voice_name |
| switch_core_session_t * | session |
| switch_channel_t * | channel |
| char * | uuid |
| char * | tts_name |
| char * | voice_name |
Protected Member Functions | |
| void | store_file_handle (switch_file_handle_t *fh) |
| void | store_file_handle (switch_file_handle_t *fh) |
Protected Attributes | |
| switch_input_args_t | args |
| switch_input_args_t * | ap |
| switch_caller_profile_t | caller_profile |
| char * | xml_cdr_text |
| void * | on_hangup |
| switch_file_handle_t | local_fh |
| switch_file_handle_t * | fhp |
| char | dtmf_buf [512] |
| switch_input_args_t * | ap |
| char * | xml_cdr_text |
| void * | on_hangup |
| switch_file_handle_t * | fhp |
|
|
00456 {
00457 init_vars();
00458 }
|
|
||||||||||||
|
00461 {
00462 init_vars();
00463
00464 if (!strchr(nuuid, '/') && (session = switch_core_session_locate(nuuid))) {
00465 uuid = strdup(nuuid);
00466 channel = switch_core_session_get_channel(session);
00467 allocated = 1;
00468 } else {
00469 switch_call_cause_t cause;
00470 if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) {
00471 channel = switch_core_session_get_channel(session);
00472 allocated = 1;
00473 switch_set_flag(this, S_HUP);
00474 uuid = strdup(switch_core_session_get_uuid(session));
00475 switch_channel_set_state(switch_core_session_get_channel(session), CS_SOFT_EXECUTE);
00476 }
00477 }
00478 }
|
Here is the call graph for this function:

|
|
00481 {
00482 init_vars();
00483
00484 if (new_session) {
00485 session = new_session;
00486 channel = switch_core_session_get_channel(session);
00487 allocated = 1;
00488 switch_core_session_read_lock(session);
00489 }
00490 }
|
Here is the call graph for this function:

|
|
00493 {
00494 this_check_void();
00495 destroy();
00496 }
|
Here is the call graph for this function:

|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
00527 {
00528 switch_status_t status;
00529 this_check(-1);
00530 sanity_check(-1);
00531 status = switch_channel_answer(channel);
00532 return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
00533 }
|
|
|
|
|
|
00864 {
00865
00866 this_check(false);
00867 sanity_check(false);
00868 return switch_channel_test_flag(channel, CF_ANSWERED) != 0;
00869 }
|
Here is the call graph for this function:

|
|
|
|
|
|
|
|
|
|
|
Callback to the language specific hangup callback.
|
|
|
|
|
|
For timeout milliseconds, call the dtmf function set previously by setDTMFCallback whenever a dtmf or event is received 00668 {
00669 this_check(-1);
00670 sanity_check(-1);
00671 begin_allow_threads();
00672 switch_ivr_collect_digits_callback(session, ap, timeout);
00673 end_allow_threads();
00674 return SWITCH_STATUS_SUCCESS;
00675 }
|
Here is the call graph for this function:

|
|
|
|
|
00872 {
00873 this_check_void();
00874
00875 switch_safe_free(xml_cdr_text);
00876 switch_safe_free(uuid);
00877 switch_safe_free(tts_name);
00878 switch_safe_free(voice_name);
00879
00880 if (session) {
00881 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy/unlink session from object\n");
00882 if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
00883 switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
00884 }
00885 switch_core_session_rwunlock(session);
00886 session = NULL;
00887 }
00888
00889 allocated = 0;
00890
00891 }
|
Here is the call graph for this function:

|
|
|
|
|
|
|
||||||||||||
|
|
|
||||||||||||
|
00583 {
00584 const switch_application_interface_t *application_interface;
00585 this_check_void();
00586 sanity_check_noreturn;
00587
00588 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::execute. app: %s data:%s\n", app, data);
00589 if ((application_interface = switch_loadable_module_get_application_interface(app))) {
00590 begin_allow_threads();
00591 switch_core_session_exec(session, application_interface, data);
00592 end_allow_threads();
00593 }
00594 }
|
Here is the call graph for this function:

|
|
|
|
|
flush any pending digits
00988 {
00989 this_check(-1);
00990 sanity_check(-1);
00991 switch_channel_flush_dtmf(switch_core_session_get_channel(session));
00992 return SWITCH_STATUS_SUCCESS;
00993 }
|
Here is the call graph for this function:

|
|
|
|
|
flush any pending events
00969 {
00970 switch_event_t *event;
00971 switch_channel_t *channel;
00972
00973 this_check(-1);
00974 sanity_check(-1);
00975
00976 if (!session) {
00977 return SWITCH_STATUS_FALSE;
00978 }
00979 channel = switch_core_session_get_channel(session);
00980
00981 while (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
00982 switch_event_destroy(&event);
00983 }
00984 return SWITCH_STATUS_SUCCESS;
00985 }
|
Here is the call graph for this function:

|
|
00228 {
00229 return args;
00230 };
|
|
|
Get the callback function arguments associated with this session.
00359 {
00360 return args;
00361 };
|
|
|
|
|
|
Get the uuid of this session.
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||||||
|
00686 {
00687 switch_status_t status;
00688 this_check((char *)"");
00689 sanity_check((char *)"");
00690 begin_allow_threads();
00691 char terminator;
00692
00693 memset(dtmf_buf, 0, sizeof(dtmf_buf));
00694 status = switch_ivr_collect_digits_count(session,
00695 dtmf_buf,
00696 sizeof(dtmf_buf),
00697 maxdigits,
00698 terminators,
00699 &terminator,
00700 (uint32_t) timeout, (uint32_t)interdigit, 0);
00701
00702 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "getDigits dtmf_buf: %s\n", dtmf_buf);
00703 end_allow_threads();
00704 return dtmf_buf;
00705 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
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. 00678 {
00679 return getDigits(maxdigits, terminators, timeout, 0);
00680 }
|
|
|
|
|
|
00562 {
00563 this_check(NULL);
00564 sanity_check(NULL);
00565 return switch_channel_get_private(channel, var);
00566 }
|
Here is the call graph for this function:

|
|
|
|
|
00576 {
00577 this_check("");
00578 sanity_check("");
00579 return switch_channel_get_variable(channel, var);
00580 }
|
Here is the call graph for this function:

|
|
|
|
|
00499 {
00500
00501 switch_xml_t cdr;
00502
00503 this_check((char *)"");
00504 sanity_check((char *)"");
00505
00506 switch_safe_free(xml_cdr_text);
00507
00508 if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
00509 xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
00510 switch_xml_free(cdr);
00511 }
00512
00513 return (char *) (xml_cdr_text ? xml_cdr_text : "");
00514 }
|
Here is the call graph for this function:

|
|
|
|
|
00545 {
00546 this_check_void();
00547 sanity_check_noreturn;
00548 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::hangup\n");
00549 this->begin_allow_threads();
00550 switch_channel_hangup(channel, switch_channel_str2cause(cause));
00551 this->end_allow_threads();
00552 }
|
Here is the call graph for this function:

|
|
|
|
|
00857 {
00858
00859 this_check(false);
00860 sanity_check(false);
00861 return switch_channel_media_ready(channel) != 0;
00862 }
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
Originate a call to a destination.
00894 {
00895
00896 switch_memory_pool_t *pool = NULL;
00897 switch_core_session_t *aleg_core_session = NULL;
00898 switch_call_cause_t cause;
00899
00900 this_check(0);
00901
00902 cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
00903
00904 if (a_leg_session != NULL) {
00905 aleg_core_session = a_leg_session->session;
00906 }
00907
00908 // this session has no valid switch_core_session_t at this point, and therefore
00909 // no valid channel. since the threadstate is stored in the channel, and there
00910 // is none, if we try to call begin_alllow_threads it will fail miserably.
00911 // use the 'a leg session' to do the thread swapping stuff.
00912 if (a_leg_session) a_leg_session->begin_allow_threads();
00913
00914 if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
00915 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
00916 goto failed;
00917 }
00918
00919 if (switch_ivr_originate(aleg_core_session,
00920 &session,
00921 &cause,
00922 dest,
00923 timeout,
00924 NULL,
00925 NULL,
00926 NULL,
00927 &caller_profile,
00928 SOF_NONE) != SWITCH_STATUS_SUCCESS) {
00929 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest);
00930 goto failed;
00931
00932 }
00933
00934 if (a_leg_session) a_leg_session->end_allow_threads();
00935 channel = switch_core_session_get_channel(session);
00936 allocated = 1;
00937 switch_channel_set_state(switch_core_session_get_channel(session), CS_SOFT_EXECUTE);
00938
00939 return SWITCH_STATUS_SUCCESS;
00940
00941 failed:
00942 if (a_leg_session) a_leg_session->end_allow_threads();
00943 return SWITCH_STATUS_FALSE;
00944 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||
|
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. 00752 {
00753 switch_status_t status;
00754 sanity_check((char *)"");
00755 this_check((char *)"");
00756 begin_allow_threads();
00757 memset(dtmf_buf, 0, sizeof(dtmf_buf));
00758 status = switch_play_and_get_digits( session,
00759 (uint32_t) min_digits,
00760 (uint32_t) max_digits,
00761 (uint32_t) max_tries,
00762 (uint32_t) timeout,
00763 terminators,
00764 audio_files,
00765 bad_input_audio_files,
00766 dtmf_buf,
00767 sizeof(dtmf_buf),
00768 digits_regex);
00769
00770 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playAndGetDigits dtmf_buf: %s\n", dtmf_buf);
00771
00772 end_allow_threads();
00773 return dtmf_buf;
00774 }
|
Here is the call graph for this function:

|
|
|
|
|
00536 {
00537 switch_status_t status;
00538 this_check(-1);
00539 sanity_check(-1);
00540 status = switch_channel_pre_answer(channel);
00541 return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
00542 }
|
|
|
|
|
|
|
|
||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||
|
00725 {
00726 this_check((char *)"");
00727 sanity_check((char *)"");
00728 if (min_digits < 1) {
00729 min_digits = 1;
00730 }
00731
00732 if (max_digits < 1) {
00733 max_digits = 1;
00734 }
00735
00736 if (timeout < 1) {
00737 timeout = 1;
00738 }
00739
00740 switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf, sizeof(dtmf_buf), timeout, valid_terminators);
00741 return dtmf_buf;
00742 }
|
Here is the call graph for this function:

|
|
|
|
|
00850 {
00851
00852 this_check(false);
00853 sanity_check(false);
00854 return switch_channel_ready(channel) != 0;
00855 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
Record to a file.
00947 {
00948 switch_status_t status;
00949
00950 this_check(-1);
00951 sanity_check(-1);
00952
00953 memset(&local_fh, 0, sizeof(local_fh));
00954 fhp = &local_fh;
00955 |