RTS API Documentation  1.10.11
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
CoreSession Class Referenceabstract

#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 print (char *txt)
 
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. More...
 
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. More...
 
virtual void destroy (void)
 
void setDTMFCallback (void *cbfunc, char *funcargs)
 set a DTMF callback function More...
 
int speak (char *text)
 
void set_tts_parms (char *tts_name, char *voice_name)
 
void set_tts_params (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)
 
char * getDigits (int maxdigits, char *terminators, int timeout, int interdigit, int abstimeout)
 
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)
 
void detectSpeech (char *arg0, char *arg1=NULL, char *arg2=NULL, char *arg3=NULL)
 
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. More...
 
char * playAndDetectSpeech (char *file, char *engine, char *grammar)
 Play a file and detect speech See API docs switch_ivr_play_and_detect_speech(...) More...
 
int streamFile (char *file, int starting_sample_count=0)
 Play a file that resides on disk into the channel. More...
 
int sleep (int ms, int sync=0)
 
int flushEvents ()
 flush any pending events More...
 
int flushDigits ()
 flush any pending digits More...
 
int setAutoHangup (bool val)
 
void setHangupHook (void *hangup_func)
 Set the hangup callback function. More...
 
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. More...
 
const switch_input_args_tget_cb_args () const
 Get the callback function arguments associated with this session. More...
 
virtual void check_hangup_hook ()=0
 Callback to the language specific hangup callback. More...
 
virtual switch_status_t run_dtmf_callback (void *input, switch_input_type_t itype)=0
 
void consoleLog (char *level_str, char *msg)
 
void consoleLog2 (char *level_str, char *file, char *func, int line, char *msg)
 

Data Fields

switch_core_session_tsession
 
switch_channel_tchannel
 
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_tap
 
char * xml_cdr_text
 
void * on_hangup
 
switch_file_handle_tfhp
 
char dtmf_buf [512]
 

Detailed Description

Definition at line 206 of file switch_cpp.h.

Constructor & Destructor Documentation

◆ CoreSession() [1/3]

CoreSession::CoreSession ( )

Definition at line 620 of file switch_cpp.cpp.

References init_vars.

621 {
622  init_vars();
623 }
#define init_vars()
Definition: switch_cpp.h:16

◆ CoreSession() [2/3]

CoreSession::CoreSession ( char *  nuuid,
CoreSession a_leg = NULL 
)

Definition at line 625 of file switch_cpp.cpp.

References 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, and SWITCH_STATUS_SUCCESS.

626 {
627  switch_channel_t *other_channel = NULL;
628 
629  init_vars();
630 
631  if (a_leg && a_leg->session) {
632  other_channel = switch_core_session_get_channel(a_leg->session);
633  }
634 
635  if (!strchr(nuuid, '/') && (session = switch_core_session_force_locate(nuuid))) {
636  uuid = strdup(nuuid);
638  allocated = 1;
639  } else {
641  if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL)
644  allocated = 1;
645  switch_set_flag(this, S_HUP);
649  }
650  }
651 }
#define switch_core_session_force_locate(uuid_str)
Locate a session based on it&#39;s uuid even if the channel is not ready.
Definition: switch_core.h:941
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:700
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
switch_channel_t * channel
Definition: switch_cpp.h:225
switch_core_session_t * session
Definition: switch_cpp.h:224
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
void switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state)
char * uuid
Definition: switch_cpp.h:233
switch_call_cause_t cause
Definition: switch_cpp.h:231
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
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.
#define init_vars()
Definition: switch_cpp.h:16

◆ CoreSession() [3/3]

CoreSession::CoreSession ( switch_core_session_t new_session)

Definition at line 653 of file switch_cpp.cpp.

References init_vars, switch_core_session_get_channel(), switch_core_session_get_uuid(), switch_core_session_read_lock_hangup(), SWITCH_DECLARE_CONSTRUCTOR, SWITCH_STATUS_SUCCESS, and this_check_void.

654 {
655  init_vars();
656 
657  if (new_session && switch_core_session_read_lock_hangup(new_session) == SWITCH_STATUS_SUCCESS) {
658  session = new_session;
660  allocated = 1;
662  }
663 }
switch_channel_t * channel
Definition: switch_cpp.h:225
switch_core_session_t * session
Definition: switch_cpp.h:224
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
char * uuid
Definition: switch_cpp.h:233
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
switch_status_t switch_core_session_read_lock_hangup(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
#define init_vars()
Definition: switch_cpp.h:16

◆ ~ CoreSession()

virtual CoreSession::~ CoreSession ( )
virtual

Member Function Documentation

◆ answer()

int CoreSession::answer ( )

Definition at line 699 of file switch_cpp.cpp.

References sanity_check, switch_channel_answer, SWITCH_STATUS_SUCCESS, and this_check.

700 {
701  switch_status_t status;
702  this_check(-1);
703  sanity_check(-1);
704  status = switch_channel_answer(channel);
705  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
706 }
#define switch_channel_answer(channel)
Answer a channel (initiate/acknowledge a successful connection)
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_status_t
Common return values.

◆ answered()

bool CoreSession::answered ( )

Definition at line 1182 of file switch_cpp.cpp.

References CF_ANSWERED, sanity_check, switch_channel_test_flag(), and this_check.

1182  {
1183 
1184  this_check(false);
1185  sanity_check(false);
1187 }
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
#define sanity_check(x)
Definition: switch_cpp.h:14

◆ begin_allow_threads()

virtual bool CoreSession::begin_allow_threads ( )
pure virtual

Referenced by bridge(), and originate().

◆ bridged()

bool CoreSession::bridged ( )

Definition at line 1163 of file switch_cpp.cpp.

References CF_BRIDGED, sanity_check, switch_channel_test_flag(), switch_channel_up, and this_check.

1163  {
1164 
1165  this_check(false);
1166 
1167  if (!session) {
1168  return false;
1169  }
1170  sanity_check(false);
1171 
1173 }
#define switch_channel_up(_channel)
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14

◆ check_hangup_hook()

virtual void CoreSession::check_hangup_hook ( )
pure virtual

Callback to the language specific hangup callback.

Referenced by hanguphook().

◆ collectDigits() [1/2]

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 881 of file switch_cpp.cpp.

881  {
882  return collectDigits(0, abs_timeout);
883 }
int collectDigits(int abs_timeout)
Definition: switch_cpp.cpp:881

◆ collectDigits() [2/2]

int CoreSession::collectDigits ( int  digit_timeout,
int  abs_timeout 
)

Definition at line 885 of file switch_cpp.cpp.

References sanity_check, switch_ivr_collect_digits_callback(), SWITCH_STATUS_SUCCESS, and this_check.

885  {
886  this_check(-1);
887  sanity_check(-1);
889  switch_ivr_collect_digits_callback(session, ap, digit_timeout, abs_timeout);
891  return SWITCH_STATUS_SUCCESS;
892 }
switch_input_args_t * ap
Definition: switch_cpp.h:211
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
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
virtual bool end_allow_threads()=0

◆ consoleLog()

void CoreSession::consoleLog ( char *  level_str,
char *  msg 
)

Definition at line 1384 of file switch_cpp.cpp.

References SWITCH_CHANNEL_SESSION_LOG, SWITCH_LOG_DEBUG, SWITCH_LOG_INVALID, switch_log_printf(), switch_log_str2level(), and switch_str_nil.

1385 {
1387  if (level_str) {
1388  level = switch_log_str2level(level_str);
1389  if (level == SWITCH_LOG_INVALID) {
1390  level = SWITCH_LOG_DEBUG;
1391  }
1392  }
1394 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_core_session_t * session
Definition: switch_cpp.h:224
switch_log_level_t switch_log_str2level(_In_z_ const char *str)
Return the level number of the specified log level name.
#define switch_str_nil(s)
Make a null string a blank string instead.
Definition: switch_utils.h:993
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_log_level_t
Log Level Enumeration.

◆ consoleLog2()

void CoreSession::consoleLog2 ( char *  level_str,
char *  file,
char *  func,
int  line,
char *  msg 
)

Definition at line 1396 of file switch_cpp.cpp.

References SWITCH_CHANNEL_ID_SESSION, SWITCH_LOG_DEBUG, SWITCH_LOG_INVALID, switch_log_printf(), switch_log_str2level(), and switch_str_nil.

1397 {
1399  if (level_str) {
1400  level = switch_log_str2level(level_str);
1401  if (level == SWITCH_LOG_INVALID) {
1402  level = SWITCH_LOG_DEBUG;
1403  }
1404  }
1405  switch_log_printf(SWITCH_CHANNEL_ID_SESSION, file, func, line, (const char*)session,
1406  level, "%s", switch_str_nil(msg));
1407 }
switch_core_session_t * session
Definition: switch_cpp.h:224
switch_log_level_t switch_log_str2level(_In_z_ const char *str)
Return the level number of the specified log level name.
#define switch_str_nil(s)
Make a null string a blank string instead.
Definition: switch_utils.h:993
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_log_level_t
Log Level Enumeration.

◆ destroy()

void CoreSession::destroy ( void  )
virtual

Definition at line 1189 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.

1190 {
1191  this_check_void();
1192 
1193  if (!allocated) {
1194  return;
1195  }
1196 
1197  allocated = 0;
1198 
1203 
1204  if (session) {
1205  if (!channel) {
1207  }
1208 
1209  if (channel) {
1211  "%s destroy/unlink session from object\n", switch_channel_get_name(channel));
1212  switch_channel_set_private(channel, "CoreSession", NULL);
1215  }
1216  }
1217 
1219  session = NULL;
1220  channel = NULL;
1221  }
1222 
1223  init_vars();
1224 
1225 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it&#39;s state machine to end.
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_status_t switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info)
Set private data on channel.
#define switch_channel_up(_channel)
switch_channel_t * channel
Definition: switch_cpp.h:225
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_core_session_t * session
Definition: switch_cpp.h:224
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
char * uuid
Definition: switch_cpp.h:233
char * xml_cdr_text
Definition: switch_cpp.h:213
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
#define this_check_void()
Definition: switch_cpp.h:13
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
char * voice_name
Definition: switch_cpp.h:235
#define init_vars()
Definition: switch_cpp.h:16
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
char * tts_name
Definition: switch_cpp.h:234

◆ detectSpeech()

void CoreSession::detectSpeech ( char *  arg0,
char *  arg1 = NULL,
char *  arg2 = NULL,
char *  arg3 = NULL 
)

Definition at line 1010 of file switch_cpp.cpp.

References sanity_check_noreturn, SWITCH_CHANNEL_LOG, switch_ivr_detect_speech(), switch_ivr_detect_speech_disable_all_grammars(), switch_ivr_detect_speech_disable_grammar(), switch_ivr_detect_speech_enable_grammar(), switch_ivr_detect_speech_init(), switch_ivr_detect_speech_load_grammar(), switch_ivr_detect_speech_start_input_timers(), switch_ivr_detect_speech_unload_grammar(), switch_ivr_pause_detect_speech(), switch_ivr_resume_detect_speech(), switch_ivr_set_param_detect_speech(), switch_ivr_stop_detect_speech(), switch_log_printf(), SWITCH_LOG_WARNING, and this_check_void.

1011 {
1012  this_check_void();
1014 
1016 
1017  if (!arg0) return;
1018 
1019  if (!strcasecmp(arg0, "grammar") && arg1 && arg2) {
1021  } else if (!strcasecmp(arg0, "nogrammar") && arg1) {
1023  } else if (!strcasecmp(arg0, "grammaron") && arg1) {
1025  } else if (!strcasecmp(arg0, "grammaroff") && arg1) {
1027  } else if (!strcasecmp(arg0, "grammarsalloff")) {
1029  } else if (!strcasecmp(arg0, "init") && arg1 && arg2) {
1030  switch_ivr_detect_speech_init(session, arg1, arg2, NULL);
1031  } else if (!strcasecmp(arg0, "pause")) {
1033  } else if (!strcasecmp(arg0, "resume")) {
1035  } else if (!strcasecmp(arg0, "stop")) {
1037  } else if (!strcasecmp(arg0, "param") && arg1 && arg2) {
1039  } else if (!strcasecmp(arg0, "start-input-timers")) {
1041  } else if (!strcasecmp(arg0, "start_input_timers")) {
1042  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "start_input_timers is deprecated, please use start-input-timers instead!\n");
1044  } else if (arg1 && arg2 && arg3) {
1045  switch_ivr_detect_speech(session, arg0, arg1, arg2, arg3, NULL);
1046  }
1047 
1049 }
#define SWITCH_CHANNEL_LOG
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
switch_status_t switch_ivr_stop_detect_speech(switch_core_session_t *session)
Stop background Speech detection on a session.
switch_status_t switch_ivr_pause_detect_speech(switch_core_session_t *session)
Pause background Speech detection on a session.
switch_status_t switch_ivr_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_ivr_detect_speech_disable_grammar(switch_core_session_t *session, const char *name)
Disable a grammar on a background speech detection handle.
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_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_resume_detect_speech(switch_core_session_t *session)
Resume background Speech detection on a session.
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
switch_status_t switch_ivr_detect_speech_disable_all_grammars(switch_core_session_t *session)
Disable all grammars on a background speech detection handle.
switch_status_t switch_ivr_set_param_detect_speech(switch_core_session_t *session, const char *name, const char *val)
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.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
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.
virtual bool end_allow_threads()=0
switch_status_t switch_ivr_detect_speech_start_input_timers(switch_core_session_t *session)
Start input timers on a background speech detection handle.

◆ end_allow_threads()

virtual bool CoreSession::end_allow_threads ( )
pure virtual

Referenced by bridge(), and originate().

◆ execute()

void CoreSession::execute ( const char *  app,
const char *  data = NULL 
)

Definition at line 785 of file switch_cpp.cpp.

References sanity_check_noreturn, SWITCH_CHANNEL_SESSION_LOG, switch_core_session_execute_application, SWITCH_LOG_ERROR, switch_log_printf(), this_check_void, and zstr.

786 {
787  this_check_void();
789 
790  if (zstr(app)) {
791  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No application specified\n");
792  return;
793  }
794 
798 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define zstr(x)
Definition: switch_utils.h:314
#define switch_core_session_execute_application(_a, _b, _c)
Execute an application on a session.
Definition: switch_core.h:1129
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
virtual bool end_allow_threads()=0

◆ flushDigits()

int CoreSession::flushDigits ( )

flush any pending digits

Definition at line 1337 of file switch_cpp.cpp.

References sanity_check, switch_channel_flush_dtmf(), switch_core_session_get_channel(), SWITCH_STATUS_SUCCESS, and this_check.

1338 {
1339  this_check(-1);
1340  sanity_check(-1);
1342  return SWITCH_STATUS_SUCCESS;
1343 }
void switch_channel_flush_dtmf(_In_ switch_channel_t *channel)
#define this_check(x)
Definition: switch_cpp.h:12
switch_core_session_t * session
Definition: switch_cpp.h:224
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
#define sanity_check(x)
Definition: switch_cpp.h:14

◆ flushEvents()

int CoreSession::flushEvents ( )

flush any pending events

Definition at line 1320 of file switch_cpp.cpp.

References sanity_check, switch_core_session_dequeue_event(), switch_event_destroy(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, SWITCH_TRUE, and this_check.

1321 {
1322  switch_event_t *event;
1323 
1324  this_check(-1);
1325  sanity_check(-1);
1326 
1327  if (!session) {
1328  return SWITCH_STATUS_FALSE;
1329  }
1330 
1332  switch_event_destroy(&event);
1333  }
1334  return SWITCH_STATUS_SUCCESS;
1335 }
Representation of an event.
Definition: switch_event.h:80
#define this_check(x)
Definition: switch_cpp.h:12
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_status_t switch_core_session_dequeue_event(_In_ switch_core_session_t *session, _Out_ switch_event_t **event, switch_bool_t force)
DE-Queue an event on a given session.
void switch_event_destroy(switch_event_t **event)
Destroy an event.

◆ get_cb_args()

const switch_input_args_t& CoreSession::get_cb_args ( ) const
inline

Get the callback function arguments associated with this session.

Returns
a const reference to the callback function arguments

Definition at line 400 of file switch_cpp.h.

References bridge(), buf, buflen, console_clean_log(), console_log(), console_log2(), consoleLog(), consoleLog2(), dtmf_callback(), hanguphook(), SWITCH_DECLARE, SWITCH_DECLARE_NONSTD, and switch_msleep().

Referenced by bridge().

400  {
401  return args;
402  };
switch_input_args_t args
Definition: switch_cpp.h:209

◆ get_uuid()

const char* CoreSession::get_uuid ( ) const
inline

Get the uuid of this session.

Returns
the uuid of this session

Definition at line 393 of file switch_cpp.h.

393  {
394  return uuid ? uuid : (char *) "uninitialized";
395  };
char * uuid
Definition: switch_cpp.h:233

◆ getDigits() [1/3]

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 894 of file switch_cpp.cpp.

895 {
896  return getDigits(maxdigits, terminators, timeout, 0);
897 }
char * getDigits(int maxdigits, char *terminators, int timeout)
Definition: switch_cpp.cpp:894

◆ getDigits() [2/3]

char * CoreSession::getDigits ( int  maxdigits,
char *  terminators,
int  timeout,
int  interdigit 
)

Definition at line 899 of file switch_cpp.cpp.

900 {
901  return getDigits(maxdigits, terminators, timeout, interdigit, 0);
902 }
char * getDigits(int maxdigits, char *terminators, int timeout)
Definition: switch_cpp.cpp:894

◆ getDigits() [3/3]

char * CoreSession::getDigits ( int  maxdigits,
char *  terminators,
int  timeout,
int  interdigit,
int  abstimeout 
)

Definition at line 904 of file switch_cpp.cpp.

References memset(), sanity_check, SWITCH_CHANNEL_SESSION_LOG, switch_channel_var_true(), switch_core_session_get_channel(), switch_ivr_collect_digits_count(), SWITCH_LOG_DEBUG, switch_log_printf(), SWITCH_SENSITIVE_DTMF_VARIABLE, and this_check.

909 {
910  this_check((char *)"");
911  sanity_check((char *)"");
913  char terminator;
914 
915  memset(dtmf_buf, 0, sizeof(dtmf_buf));
917  dtmf_buf,
918  sizeof(dtmf_buf),
919  maxdigits,
920  terminators,
921  &terminator,
922  (uint32_t) timeout, (uint32_t)interdigit, (uint32_t)abstimeout);
923 
924  /* Only log DTMF buffer if sensitive_dtmf channel variable not set to true */
927  }
928 
930  return dtmf_buf;
931 }
#define SWITCH_SENSITIVE_DTMF_VARIABLE
Definition: switch_types.h:146
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
#define sanity_check(x)
Definition: switch_cpp.h:14
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
static int switch_channel_var_true(switch_channel_t *channel, const char *variable)
char dtmf_buf[512]
Definition: switch_cpp.h:217
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
memset(buf, 0, buflen)
virtual bool end_allow_threads()=0

◆ getPrivate()

void * CoreSession::getPrivate ( char *  var)

Definition at line 763 of file switch_cpp.cpp.

References sanity_check, switch_channel_get_private(), and this_check.

764 {
765  this_check(NULL);
766  sanity_check(NULL);
767  return switch_channel_get_private(channel, var);
768 }
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
#define sanity_check(x)
Definition: switch_cpp.h:14
void * switch_channel_get_private(switch_channel_t *channel, const char *key)
Retrieve private from a given channel.

◆ getState()

const char * CoreSession::getState ( )

Definition at line 1233 of file switch_cpp.cpp.

References switch_channel_get_state(), switch_channel_state_name(), and this_check.

1234 {
1235  this_check(NULL);
1236 
1237  if (channel) {
1239  }
1240 
1241  return "ERROR";
1242 
1243 }
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
const char * switch_channel_state_name(_In_ switch_channel_state_t state)
Render the name of the provided state enum.

◆ getVariable()

const char * CoreSession::getVariable ( char *  var)

Definition at line 778 of file switch_cpp.cpp.

References sanity_check, switch_channel_get_variable, and this_check.

779 {
780  this_check("");
781  sanity_check("");
783 }
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
#define sanity_check(x)
Definition: switch_cpp.h:14
#define switch_channel_get_variable(_c, _v)

◆ getXMLCDR()

char * CoreSession::getXMLCDR ( )

Definition at line 671 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.

672 {
673 
674  switch_xml_t cdr = NULL;
675 
676  this_check((char *)"");
677  sanity_check((char *)"");
678 
680 
683  switch_xml_free(cdr);
684  }
685 
686  return (char *) (xml_cdr_text ? xml_cdr_text : "");
687 }
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
#define this_check(x)
Definition: switch_cpp.h:12
A representation of an XML tree.
Definition: switch_xml.h:79
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
char * xml_cdr_text
Definition: switch_cpp.h:213
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
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
#define switch_xml_toxml(xml, prn_header)
Converts an switch_xml structure back to xml in html format. Returns a string of html data that \ mus...
Definition: switch_xml.h:224

◆ hangup()

void CoreSession::hangup ( const char *  cause = "normal_clearing")

Definition at line 746 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.

747 {
748  this_check_void();
751  this->begin_allow_threads();
753  this->end_allow_threads();
754 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it&#39;s state machine to end.
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_channel_t * channel
Definition: switch_cpp.h:225
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
switch_call_cause_t switch_channel_str2cause(_In_ const char *str)
return a cause code for a given string
switch_call_cause_t cause
Definition: switch_cpp.h:231
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
virtual bool end_allow_threads()=0

◆ hangupCause()

const char * CoreSession::hangupCause ( )

Definition at line 1227 of file switch_cpp.cpp.

References switch_channel_cause2str(), and this_check.

1228 {
1229  this_check(NULL);
1231 }
const char * switch_channel_cause2str(_In_ switch_call_cause_t cause)
return a cause string for a given cause
#define this_check(x)
Definition: switch_cpp.h:12
switch_call_cause_t cause
Definition: switch_cpp.h:231

◆ hangupState()

void CoreSession::hangupState ( void  )

Definition at line 736 of file switch_cpp.cpp.

References sanity_check_noreturn, switch_channel_down, switch_core_session_hangup_state(), and SWITCH_FALSE.

737 {
739  this->begin_allow_threads();
742  }
743  this->end_allow_threads();
744 }
void switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force)
switch_channel_t * channel
Definition: switch_cpp.h:225
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check_noreturn
Definition: switch_cpp.h:15
#define switch_channel_down(_channel)
virtual bool end_allow_threads()=0

◆ insertFile()

int CoreSession::insertFile ( const char *  file,
const char *  insert_file,
int  sample_point 
)

Definition at line 718 of file switch_cpp.cpp.

References sanity_check, switch_ivr_insert_file(), SWITCH_STATUS_SUCCESS, and this_check.

719 {
720  switch_status_t status;
721  this_check(-1);
722  sanity_check(-1);
723  status = switch_ivr_insert_file(session, file, insert_file, (switch_size_t)sample_point);
724  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
725 }
#define this_check(x)
Definition: switch_cpp.h:12
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_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
uintptr_t switch_size_t
switch_status_t
Common return values.

◆ mediaReady()

bool CoreSession::mediaReady ( )

Definition at line 1175 of file switch_cpp.cpp.

References sanity_check, switch_channel_media_ready, and this_check.

1175  {
1176 
1177  this_check(false);
1178  sanity_check(false);
1179  return switch_channel_media_ready(channel) != 0;
1180 }
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
#define switch_channel_media_ready(_channel)
#define sanity_check(x)
Definition: switch_cpp.h:14

◆ originate()

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.

Parameters
var- the variable name, eg, "caller_id_name"
val- the data to set, eg, "bob"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
Returns
an int status code indicating success or failure

Definition at line 1245 of file switch_cpp.cpp.

References begin_allow_threads(), CS_SOFT_EXECUTE, end_allow_threads(), session, 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.

1246 {
1247 
1248  switch_core_session_t *aleg_core_session = NULL;
1249 
1250  this_check(0);
1251 
1253 
1254  if (a_leg_session != NULL) {
1255  aleg_core_session = a_leg_session->session;
1256  }
1257 
1258  // this session has no valid switch_core_session_t at this point, and therefore
1259  // no valid channel. since the threadstate is stored in the channel, and there
1260  // is none, if we try to call begin_alllow_threads it will fail miserably.
1261  // use the 'a leg session' to do the thread swapping stuff.
1262  if (a_leg_session) a_leg_session->begin_allow_threads();
1263 
1264  if (switch_ivr_originate(aleg_core_session,
1265  &session,
1266  &cause,
1267  dest,
1268  timeout,
1269  handlers,
1270  NULL,
1271  NULL,
1272  NULL,
1273  NULL,
1274  SOF_NONE,
1275  NULL,
1276  NULL) != SWITCH_STATUS_SUCCESS) {
1277  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest);
1278  goto failed;
1279 
1280  }
1281 
1282  if (a_leg_session) a_leg_session->end_allow_threads();
1284  allocated = 1;
1288 
1289  return SWITCH_STATUS_SUCCESS;
1290 
1291  failed:
1292  if (a_leg_session) a_leg_session->end_allow_threads();
1293  return SWITCH_STATUS_FALSE;
1294 }
#define SWITCH_CHANNEL_LOG
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
char * uuid
Definition: switch_cpp.h:233
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
switch_call_cause_t cause
Definition: switch_cpp.h:231
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
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.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
virtual bool end_allow_threads()=0

◆ playAndDetectSpeech()

char * CoreSession::playAndDetectSpeech ( char *  file,
char *  engine,
char *  grammar 
)

Play a file and detect speech See API docs switch_ivr_play_and_detect_speech(...)

Definition at line 1051 of file switch_cpp.cpp.

References sanity_check, SWITCH_CHANNEL_SESSION_LOG, switch_ivr_play_and_detect_speech(), SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_GENERR, SWITCH_STATUS_NOT_INITALIZED, SWITCH_STATUS_SUCCESS, and this_check.

1052 {
1053  sanity_check((char *)"");
1054  this_check((char *)"");
1056 
1057  char *result = NULL;
1058 
1059  switch_status_t status = switch_ivr_play_and_detect_speech(session, file, engine, grammar, &result, 0, ap);
1060  if (status == SWITCH_STATUS_SUCCESS) {
1061  // good
1062  } else if (status == SWITCH_STATUS_GENERR) {
1064  } else if (status == SWITCH_STATUS_NOT_INITALIZED) {
1066  } else {
1067  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "ERROR status = %d\n", status);
1068  }
1069 
1071 
1072  return result ? strdup(result) : NULL; // remeber to free me
1073 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_input_args_t * ap
Definition: switch_cpp.h:211
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
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
Common return values.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
virtual bool end_allow_threads()=0

◆ playAndGetDigits()

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 975 of file switch_cpp.cpp.

References memset(), sanity_check, switch_play_and_get_digits(), and this_check.

986 {
987  sanity_check((char *)"");
988  this_check((char *)"");
990  memset(dtmf_buf, 0, sizeof(dtmf_buf));
992  (uint32_t) min_digits,
993  (uint32_t) max_digits,
994  (uint32_t) max_tries,
995  (uint32_t) timeout,
996  terminators,
997  audio_files,
998  bad_input_audio_files,
999  var_name,
1000  dtmf_buf,
1001  sizeof(dtmf_buf),
1002  digits_regex,
1003  (uint32_t) digit_timeout,
1004  transfer_on_failure);
1005 
1007  return dtmf_buf;
1008 }
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...
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
char dtmf_buf[512]
Definition: switch_cpp.h:217
memset(buf, 0, buflen)
virtual bool end_allow_threads()=0

◆ preAnswer()

int CoreSession::preAnswer ( )

Definition at line 727 of file switch_cpp.cpp.

References sanity_check, switch_channel_pre_answer, SWITCH_STATUS_SUCCESS, and this_check.

728 {
729  switch_status_t status;
730  this_check(-1);
731  sanity_check(-1);
733  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
734 }
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_status_t
Common return values.
#define switch_channel_pre_answer(channel)
Indicate progress on a channel to attempt early media.

◆ print()

int CoreSession::print ( char *  txt)

Definition at line 709 of file switch_cpp.cpp.

References sanity_check, switch_core_session_print(), SWITCH_STATUS_SUCCESS, switch_str_nil, and this_check.

710 {
711  switch_status_t status;
713  this_check(-1);
714  sanity_check(-1);
715  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
716 }
switch_status_t switch_core_session_print(switch_core_session_t *session, const char *data)
#define this_check(x)
Definition: switch_cpp.h:12
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
#define switch_str_nil(s)
Make a null string a blank string instead.
Definition: switch_utils.h:993
switch_status_t
Common return values.

◆ process_callback_result()

switch_status_t CoreSession::process_callback_result ( char *  result)

Definition at line 1576 of file switch_cpp.cpp.

References sanity_check, switch_ivr_process_fh(), SWITCH_STATUS_FALSE, and this_check.

1577 {
1578 
1581 
1582  return switch_ivr_process_fh(session, result, fhp);
1583 }
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
#define this_check(x)
Definition: switch_cpp.h:12
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_file_handle_t * fhp
Definition: switch_cpp.h:216

◆ read()

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 946 of file switch_cpp.cpp.

References sanity_check, switch_ivr_read(), and this_check.

952 {
953  this_check((char *)"");
954  sanity_check((char *)"");
955  if (min_digits < 1) {
956  min_digits = 1;
957  }
958 
959  if (max_digits < 1) {
960  max_digits = 1;
961  }
962 
963  if (timeout < 1) {
964  timeout = 1;
965  }
966 
968  switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf,
969  sizeof(dtmf_buf), timeout, valid_terminators, (uint32_t)digit_timeout);
971 
972  return dtmf_buf;
973 }
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)
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
char dtmf_buf[512]
Definition: switch_cpp.h:217
virtual bool end_allow_threads()=0

◆ ready()

bool CoreSession::ready ( )

Definition at line 1150 of file switch_cpp.cpp.

References sanity_check, switch_channel_ready, and this_check.

1150  {
1151 
1152  this_check(false);
1153 
1154  if (!session) {
1155  return false;
1156  }
1157  sanity_check(false);
1158 
1159  return switch_channel_ready(channel) != 0;
1160 }
#define switch_channel_ready(_channel)
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14

◆ recordFile()

int CoreSession::recordFile ( char *  file_name,
int  time_limit = 0,
int  silence_threshold = 0,
int  silence_hits = 0 
)

Record to a file.

Parameters
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 1296 of file switch_cpp.cpp.

References memset(), sanity_check, switch_file_handle::silence_hits, switch_ivr_record_file(), SWITCH_STATUS_SUCCESS, this_check, and switch_file_handle::thresh.

1297 {
1298  switch_status_t status;
1299  switch_file_handle_t local_fh;
1300 
1301  this_check(-1);
1302  sanity_check(-1);
1303 
1304  if (!file_name) return 0;
1305  memset(&local_fh, 0, sizeof(local_fh));
1306  fhp = &local_fh;
1307  local_fh.thresh = silence_threshold;
1308  local_fh.silence_hits = silence_hits;
1309 
1311  status = switch_ivr_record_file(session, &local_fh, file_name, ap, time_limit);
1313 
1314  fhp = NULL;
1315 
1316  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
1317 
1318 }
switch_input_args_t * ap
Definition: switch_cpp.h:211
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_file_handle_t * fhp
Definition: switch_cpp.h:216
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
Common return values.
memset(buf, 0, buflen)
virtual bool end_allow_threads()=0

◆ run_dtmf_callback()

virtual switch_status_t CoreSession::run_dtmf_callback ( void *  input,
switch_input_type_t  itype 
)
pure virtual

Referenced by dtmf_callback().

◆ say()

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 1075 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.

1076 {
1077  this_check_void();
1079  if (!(tosay && module_name && say_type && say_method)) {
1081  return;
1082  }
1084  switch_ivr_say(session, tosay, module_name, say_type, say_method, say_gender, ap);
1086 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_input_args_t * ap
Definition: switch_cpp.h:211
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
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
virtual bool end_allow_threads()=0

◆ sayPhrase()

void CoreSession::sayPhrase ( const char *  phrase_name,
const char *  phrase_data = "",
const char *  phrase_lang = NULL 
)

Definition at line 1088 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.

1089 {
1090  this_check_void();
1092 
1093  if (!(phrase_name)) {
1095  return;
1096  }
1097 
1099  switch_ivr_phrase_macro(session, phrase_name, phrase_data, phrase_lang, ap);
1101 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_input_args_t * ap
Definition: switch_cpp.h:211
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
#define switch_ivr_phrase_macro(session, macro_name, data, lang, args)
Definition: switch_ivr.h:936
virtual bool end_allow_threads()=0

◆ sendEvent()

void CoreSession::sendEvent ( Event sendME)

Definition at line 823 of file switch_cpp.cpp.

References Event::event, sanity_check_noreturn, switch_core_session_receive_event(), switch_event_dup(), SWITCH_STATUS_SUCCESS, and this_check_void.

824 {
825  this_check_void();
827 
828  if (sendME->event) {
829  switch_event_t *new_event;
830  if (switch_event_dup(&new_event, sendME->event) == SWITCH_STATUS_SUCCESS) {
832  }
833  }
834 }
Representation of an event.
Definition: switch_event.h:80
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
switch_core_session_t * session
Definition: switch_cpp.h:224
switch_event_t * event
Definition: switch_cpp.h:161
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
switch_status_t switch_core_session_receive_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event)
Send an event to a session translating it to it&#39;s native message format.

◆ set_tts_params()

void CoreSession::set_tts_params ( char *  tts_name,
char *  voice_name 
)

Definition at line 871 of file switch_cpp.cpp.

References sanity_check_noreturn, switch_safe_free, switch_str_nil, and this_check_void.

872 {
873  this_check_void();
877  tts_name = strdup(switch_str_nil(tts_name_p));
878  voice_name = strdup(switch_str_nil(voice_name_p));
879 }
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
#define switch_str_nil(s)
Make a null string a blank string instead.
Definition: switch_utils.h:993
char * voice_name
Definition: switch_cpp.h:235
char * tts_name
Definition: switch_cpp.h:234

◆ set_tts_parms()

void CoreSession::set_tts_parms ( char *  tts_name,
char *  voice_name 
)

Definition at line 860 of file switch_cpp.cpp.

References sanity_check_noreturn, SWITCH_CHANNEL_SESSION_LOG, SWITCH_LOG_ERROR, switch_log_printf(), switch_safe_free, and this_check_void.

861 {
862  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "set_tts_parms is deprecated. Use set_tts_params.\n");
863  this_check_void();
867  tts_name = strdup(tts_name_p);
868  voice_name = strdup(voice_name_p);
869 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_core_session_t * session
Definition: switch_cpp.h:224
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
char * voice_name
Definition: switch_cpp.h:235
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
char * tts_name
Definition: switch_cpp.h:234

◆ setAutoHangup()

int CoreSession::setAutoHangup ( bool  val)

Definition at line 1345 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.

1346 {
1347  this_check(-1);
1348  sanity_check(-1);
1349 
1350  if (!session) {
1351  return SWITCH_STATUS_FALSE;
1352  }
1353  if (val) {
1354  switch_set_flag(this, S_HUP);
1355  } else {
1356  switch_clear_flag(this, S_HUP);
1357  }
1358  return SWITCH_STATUS_SUCCESS;
1359 }
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:700
#define this_check(x)
Definition: switch_cpp.h:12
switch_core_session_t * session
Definition: switch_cpp.h:224
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
Definition: switch_utils.h:724
#define sanity_check(x)
Definition: switch_cpp.h:14

◆ setDTMFCallback()

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 800 of file switch_cpp.cpp.

References dtmf_callback(), sanity_check_noreturn, switch_channel_set_private(), and this_check_void.

800  {
801 
802  this_check_void();
804 
805  cb_state.funcargs = funcargs;
806  cb_state.function = cbfunc;
807 
808  args.buf = &cb_state;
809  args.buflen = sizeof(cb_state); // not sure what this is used for, copy mod_spidermonkey
810 
811  switch_channel_set_private(channel, "CoreSession", this);
812 
813  // we cannot set the actual callback to a python function, because
814  // the callback is a function pointer with a specific signature.
815  // so, set it to the following c function which will act as a proxy,
816  // finding the python callback in the args callback args structure
818  ap = &args;
819 
820 
821 }
switch_status_t switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info)
Set private data on channel.
switch_input_args_t * ap
Definition: switch_cpp.h:211
switch_channel_t * channel
Definition: switch_cpp.h:225
switch_status_t dtmf_callback(switch_core_session_t *session_cb, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
switch_input_callback_function_t input_callback
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
switch_input_args_t args
Definition: switch_cpp.h:209
input_callback_state cb_state
Definition: switch_cpp.h:228

◆ setEventData()

void CoreSession::setEventData ( Event e)

Definition at line 689 of file switch_cpp.cpp.

References Event::event, sanity_check_noreturn, switch_channel_event_set_data(), and this_check_void.

690 {
691  this_check_void();
693 
694  if (channel && e->event) {
696  }
697 }
void switch_channel_event_set_data(_In_ switch_channel_t *channel, _In_ switch_event_t *event)
Add information about a given channel to an event object.
switch_channel_t * channel
Definition: switch_cpp.h:225
switch_event_t * event
Definition: switch_cpp.h:161
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15

◆ setHangupHook()

void CoreSession::setHangupHook ( void *  hangup_func)

Set the hangup callback function.

Parameters
hangup_func- language specific function ptr cast into void *

Definition at line 1370 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.

1370  {
1371 
1372  this_check_void();
1374 
1375  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::seHangupHook, hangup_func: %p\n", hangup_func);
1376  on_hangup = hangup_func;
1378 
1380  switch_channel_set_private(channel, "CoreSession", this);
1381  switch_core_event_hook_add_state_change(session, hanguphook);
1382 }
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
switch_status_t hanguphook(switch_core_session_t *session_hungup)
the actual hangup hook called back by freeswitch core which in turn gets the session and calls the ap...
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_status_t switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info)
Set private data on channel.
switch_channel_t * channel
Definition: switch_cpp.h:225
switch_core_session_t * session
Definition: switch_cpp.h:224
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
void * on_hangup
Definition: switch_cpp.h:215
switch_channel_state_t hook_state
Definition: switch_cpp.h:230
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.

◆ setPrivate()

void CoreSession::setPrivate ( char *  var,
void *  val 
)

Definition at line 756 of file switch_cpp.cpp.

References sanity_check_noreturn, switch_channel_set_private(), and this_check_void.

757 {
758  this_check_void();
761 }
switch_status_t switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info)
Set private data on channel.
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15

◆ setVariable()

void CoreSession::setVariable ( char *  var,
char *  val 
)

Definition at line 770 of file switch_cpp.cpp.

References sanity_check_noreturn, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_variable_var_check(), SWITCH_FALSE, SWITCH_LOG_DEBUG, switch_log_printf(), and this_check_void.

771 {
772  this_check_void();
774  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::setVariable('%s', '%s')\n", var, val);
776 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_channel_t * channel
Definition: switch_cpp.h:225
switch_core_session_t * session
Definition: switch_cpp.h:224
#define this_check_void()
Definition: switch_cpp.h:13
switch_status_t switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
#define sanity_check_noreturn
Definition: switch_cpp.h:15
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.

◆ sleep()

int CoreSession::sleep ( int  ms,
int  sync = 0 
)

Definition at line 1135 of file switch_cpp.cpp.

References sanity_check, switch_ivr_sleep(), SWITCH_STATUS_SUCCESS, and this_check.

1135  {
1136 
1137  switch_status_t status;
1138 
1139  this_check(-1);
1140  sanity_check(-1);
1141 
1143  status = switch_ivr_sleep(session, ms, (switch_bool_t) sync, ap);
1145 
1146  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
1147 
1148 }
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
switch_input_args_t * ap
Definition: switch_cpp.h:211
switch_bool_t
Definition: switch_types.h:437
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_status_t
Common return values.
virtual bool end_allow_threads()=0

◆ speak()

int CoreSession::speak ( char *  text)

Definition at line 836 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.

837 {
838  switch_status_t status;
839 
840  this_check(-1);
841  sanity_check(-1);
842 
843  if (!tts_name) {
845  return SWITCH_STATUS_FALSE;
846  }
847 
848  if (!voice_name) {
850  return SWITCH_STATUS_FALSE;
851  }
852 
853 
857  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
858 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_input_args_t * ap
Definition: switch_cpp.h:211
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
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.
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_status_t
Common return values.
char * voice_name
Definition: switch_cpp.h:235
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
virtual bool end_allow_threads()=0
char * tts_name
Definition: switch_cpp.h:234

◆ store_file_handle()

void CoreSession::store_file_handle ( switch_file_handle_t fh)
protected

◆ streamFile()

int CoreSession::streamFile ( char *  file,
int  starting_sample_count = 0 
)

Play a file that resides on disk into the channel.

Parameters
file- the path to the .wav/.mp3 to be played
starting_sample_count- the index of the sample to start playing from
Returns
an int status code indicating success or failure

Definition at line 1103 of file switch_cpp.cpp.

References memset(), switch_file_handle::prebuf, switch_file_handle::samples, sanity_check, switch_channel_get_variable, switch_ivr_play_file(), SWITCH_STATUS_SUCCESS, and this_check.

1103  {
1104 
1105  switch_status_t status;
1106  //switch_file_handle_t fh = { 0 };
1107  const char *prebuf;
1108  switch_file_handle_t local_fh;
1109 
1110  this_check(-1);
1111  sanity_check(-1);
1112 
1113  memset(&local_fh, 0, sizeof(local_fh));
1114  fhp = &local_fh;
1115  local_fh.samples = starting_sample_count;
1116 
1117 
1118  if ((prebuf = switch_channel_get_variable(this->channel, "stream_prebuffer"))) {
1119  int maybe = atoi(prebuf);
1120  if (maybe > 0) {
1121  local_fh.prebuf = maybe;
1122  }
1123  }
1124 
1126  status = switch_ivr_play_file(session, fhp, file, ap);
1128 
1129  fhp = NULL;
1130 
1131  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
1132 
1133 }
switch_input_args_t * ap
Definition: switch_cpp.h:211
switch_channel_t * channel
Definition: switch_cpp.h:225
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_status_t switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
play a file from the disk to the session
switch_core_session_t * session
Definition: switch_cpp.h:224
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_file_handle_t * fhp
Definition: switch_cpp.h:216
#define switch_channel_get_variable(_c, _v)
switch_status_t
Common return values.
memset(buf, 0, buflen)
virtual bool end_allow_threads()=0

◆ transfer()

int CoreSession::transfer ( char *  extension,
char *  dialplan = NULL,
char *  context = NULL 
)

Definition at line 933 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.

934 {
935  switch_status_t status;
936  this_check(-1);
937  sanity_check(-1);
939  status = switch_ivr_session_transfer(session, extension, dialplan, context);
940  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "transfer result: %d\n", status);
942  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
943 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define this_check(x)
Definition: switch_cpp.h:12
virtual bool begin_allow_threads()=0
switch_core_session_t * session
Definition: switch_cpp.h:224
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.
#define sanity_check(x)
Definition: switch_cpp.h:14
switch_status_t
Common return values.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
virtual bool end_allow_threads()=0

◆ waitForAnswer()

void CoreSession::waitForAnswer ( CoreSession calling_session)

Definition at line 1361 of file switch_cpp.cpp.

References sanity_check_noreturn, session, switch_ivr_wait_for_answer(), and this_check_void.

1362 {
1363  this_check_void();
1365 
1366  switch_ivr_wait_for_answer(calling_session ? calling_session->session : NULL, session);
1367 
1368 }
switch_status_t switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session)
switch_core_session_t * session
Definition: switch_cpp.h:224
#define this_check_void()
Definition: switch_cpp.h:13
#define sanity_check_noreturn
Definition: switch_cpp.h:15

Field Documentation

◆ allocated

int CoreSession::allocated

Definition at line 227 of file switch_cpp.h.

Referenced by bridge().

◆ ap

switch_input_args_t* CoreSession::ap
protected

Definition at line 211 of file switch_cpp.h.

◆ args

switch_input_args_t CoreSession::args
protected

Definition at line 209 of file switch_cpp.h.

◆ cause

switch_call_cause_t CoreSession::cause

Definition at line 231 of file switch_cpp.h.

Referenced by hanguphook().

◆ cb_state

input_callback_state CoreSession::cb_state

Definition at line 228 of file switch_cpp.h.

◆ channel

switch_channel_t* CoreSession::channel

Definition at line 225 of file switch_cpp.h.

◆ dtmf_buf

char CoreSession::dtmf_buf[512]
protected

Definition at line 217 of file switch_cpp.h.

◆ fhp

switch_file_handle_t* CoreSession::fhp
protected

Definition at line 216 of file switch_cpp.h.

◆ flags

unsigned int CoreSession::flags

Definition at line 226 of file switch_cpp.h.

◆ hook_state

switch_channel_state_t CoreSession::hook_state

Definition at line 230 of file switch_cpp.h.

Referenced by hanguphook().

◆ on_hangup

void* CoreSession::on_hangup
protected

Definition at line 215 of file switch_cpp.h.

◆ session

switch_core_session_t* CoreSession::session

Definition at line 224 of file switch_cpp.h.

Referenced by API::API(), bridge(), CoreSession(), IVRMenu::execute(), originate(), and waitForAnswer().

◆ tts_name

char* CoreSession::tts_name

Definition at line 234 of file switch_cpp.h.

◆ uuid

char* CoreSession::uuid

Definition at line 233 of file switch_cpp.h.

◆ voice_name

char* CoreSession::voice_name

Definition at line 235 of file switch_cpp.h.

◆ xml_cdr_text

char* CoreSession::xml_cdr_text
protected

Definition at line 213 of file switch_cpp.h.


The documentation for this class was generated from the following files: