switch_cpp.h File Reference

#include <switch.h>

Include dependency graph for switch_cpp.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  IVRMenu
class  API
struct  input_callback_state
class  DTMF
class  Stream
class  Event
class  EventConsumer
class  CoreSession

Defines

#define this_check(x)   do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n"); return x;}} while(0)
#define this_check_void()   do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n"); return;}} while(0)
#define sanity_check(x)   do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
#define sanity_check_noreturn   do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0)
#define init_vars()

Typedefs

typedef input_callback_state input_callback_state_t

Enumerations

enum  session_flag_t { S_HUP = (1 << 0), S_FREE = (1 << 1), S_RDLOCK = (1 << 2) }

Functions

void setGlobalVariable (char *var_name, char *var_val)
char * getGlobalVariable (char *var_name)
void consoleLog (char *level_str, char *msg)
void consoleCleanLog (char *msg)
bool email (char *to, char *from, char *headers=NULL, char *body=NULL, char *file=NULL, char *convert_cmd=NULL, char *convert_ext=NULL)
void console_log (char *level_str, char *msg)
void console_clean_log (char *msg)
void msleep (unsigned ms)
void bridge (CoreSession &session_a, CoreSession &session_b)
 bridge the audio of session_b into session_a
switch_status_t hanguphook (switch_core_session_t *session)
 the actual hangup hook called back by freeswitch core which in turn gets the session and calls the appropriate instance method to complete the callback.
switch_status_t dtmf_callback (switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)


Define Documentation

 
#define init_vars (  ) 

Value:

allocated = 0;                                          \
        session = NULL;                                                                         \
        channel = NULL;                                                                         \
        uuid = NULL;                                                                            \
        tts_name = NULL;                                                                        \
        voice_name = NULL;                                                                      \
        xml_cdr_text = NULL;                                                            \
        memset(&args, 0, sizeof(args));                                         \
        ap = NULL;                                                                                      \
        flags = 0;                                                                                      \
        on_hangup = NULL;                                                                       \
        memset(&cb_state, 0, sizeof(cb_state));                         \
        hook_state = CS_NEW;                                                            \
        fhp = NULL;                                                                                     \
        cause = SWITCH_CAUSE_NONE

Definition at line 16 of file switch_cpp.h.

Referenced by CoreSession::CoreSession(), and CoreSession::destroy().

#define sanity_check (  )     do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)

Definition at line 14 of file switch_cpp.h.

Referenced by CoreSession::answer(), CoreSession::answered(), CoreSession::bridged(), CoreSession::collectDigits(), CoreSession::flushDigits(), CoreSession::flushEvents(), CoreSession::getDigits(), CoreSession::getPrivate(), CoreSession::getVariable(), CoreSession::getXMLCDR(), CoreSession::insertFile(), CoreSession::mediaReady(), CoreSession::playAndGetDigits(), CoreSession::preAnswer(), CoreSession::process_callback_result(), CoreSession::read(), CoreSession::ready(), CoreSession::recordFile(), CoreSession::setAutoHangup(), CoreSession::sleep(), CoreSession::speak(), CoreSession::streamFile(), and CoreSession::transfer().

#define sanity_check_noreturn   do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0)

Definition at line 15 of file switch_cpp.h.

Referenced by CoreSession::execute(), CoreSession::hangup(), CoreSession::hangupState(), CoreSession::say(), CoreSession::sayPhrase(), CoreSession::sendEvent(), CoreSession::set_tts_parms(), CoreSession::setDTMFCallback(), CoreSession::setEventData(), CoreSession::setHangupHook(), CoreSession::setPrivate(), CoreSession::setVariable(), and CoreSession::waitForAnswer().

#define this_check (  )     do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n"); return x;}} while(0)

Definition at line 12 of file switch_cpp.h.

Referenced by Event::addBody(), Event::addHeader(), CoreSession::answer(), CoreSession::answered(), CoreSession::bridged(), CoreSession::collectDigits(), Event::delHeader(), API::execute(), API::executeString(), Event::fire(), CoreSession::flushDigits(), CoreSession::flushEvents(), Stream::get_data(), Event::getBody(), CoreSession::getDigits(), Event::getHeader(), CoreSession::getPrivate(), CoreSession::getState(), Event::getType(), CoreSession::getVariable(), CoreSession::getXMLCDR(), CoreSession::hangupCause(), CoreSession::insertFile(), CoreSession::mediaReady(), CoreSession::originate(), CoreSession::playAndGetDigits(), CoreSession::preAnswer(), CoreSession::process_callback_result(), CoreSession::read(), CoreSession::ready(), CoreSession::recordFile(), Event::serialize(), CoreSession::setAutoHangup(), Event::setPriority(), CoreSession::sleep(), CoreSession::speak(), CoreSession::streamFile(), and CoreSession::transfer().

 
#define this_check_void (  )     do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n"); return;}} while(0)

Definition at line 13 of file switch_cpp.h.

Referenced by IVRMenu::bindAction(), CoreSession::destroy(), CoreSession::execute(), IVRMenu::execute(), CoreSession::hangup(), CoreSession::say(), CoreSession::sayPhrase(), CoreSession::sendEvent(), CoreSession::set_tts_parms(), CoreSession::setDTMFCallback(), CoreSession::setEventData(), CoreSession::setHangupHook(), CoreSession::setPrivate(), CoreSession::setVariable(), CoreSession::waitForAnswer(), Stream::write(), and CoreSession::~CoreSession().


Typedef Documentation

typedef struct input_callback_state input_callback_state_t


Enumeration Type Documentation

enum session_flag_t

Enumerator:
S_HUP 
S_FREE 
S_RDLOCK 

Definition at line 126 of file switch_cpp.h.

00126                       {
00127                  S_HUP = (1 << 0),
00128                  S_FREE = (1 << 1),
00129                  S_RDLOCK = (1 << 2)
00130          } session_flag_t;


Function Documentation

void bridge ( CoreSession session_a,
CoreSession session_b 
)

bridge the audio of session_b into session_a

NOTE: the stuff regarding the dtmf callback might be completely wrong and has not been reviewed or tested

Definition at line 1249 of file switch_cpp.cpp.

References switch_input_args_t::buf, switch_input_args_t::input_callback, SWITCH_CALL_DIRECTION_INBOUND, switch_channel_direction(), switch_channel_media_ready, switch_channel_pre_answer, switch_channel_ready, SWITCH_CHANNEL_SESSION_LOG, switch_core_session_get_channel(), switch_ivr_multi_threaded_bridge(), SWITCH_LOG_ERROR, and switch_log_printf().

Referenced by switch_channel_set_timestamps().

01250 {
01251         switch_input_callback_function_t dtmf_func = NULL;
01252         switch_input_args_t args;
01253         switch_channel_t *channel_a = NULL, *channel_b = NULL;
01254         const char *err = "Channels not ready\n";
01255         
01256         if (session_a.allocated && session_a.session && session_b.allocated && session_b.session) {
01257                 channel_a = switch_core_session_get_channel(session_a.session);
01258                 channel_b = switch_core_session_get_channel(session_b.session);
01259 
01260                 if (switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
01261                         session_a.begin_allow_threads();
01262                         if (switch_channel_direction(channel_a) == SWITCH_CALL_DIRECTION_INBOUND && !switch_channel_media_ready(channel_a)) {
01263                                 switch_channel_pre_answer(channel_a);
01264                         }
01265 
01266                         if (switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
01267                                 args = session_a.get_cb_args();  // get the cb_args data structure for session a
01268                                 dtmf_func = args.input_callback;   // get the call back function
01269                                 err = NULL;
01270                                 switch_ivr_multi_threaded_bridge(session_a.session, session_b.session, dtmf_func, args.buf, args.buf);
01271                         }
01272                         session_a.end_allow_threads();
01273                 }
01274         }
01275 
01276         if (err) {
01277                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a.session), SWITCH_LOG_ERROR, "%s", err);
01278         }
01279 
01280 
01281 }

void console_clean_log ( char *  msg  ) 

Definition at line 1230 of file switch_cpp.cpp.

References SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, switch_log_printf(), and switch_str_nil.

Referenced by consoleCleanLog().

void console_log ( char *  level_str,
char *  msg 
)

Definition at line 1218 of file switch_cpp.cpp.

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

Referenced by consoleLog().

01219 {
01220     switch_log_level_t level = SWITCH_LOG_DEBUG;
01221     if (level_str) {
01222         level = switch_log_str2level(level_str);
01223                 if (level == SWITCH_LOG_INVALID) {
01224                         level = SWITCH_LOG_DEBUG;
01225                 }
01226     }
01227     switch_log_printf(SWITCH_CHANNEL_LOG, level, "%s", switch_str_nil(msg));
01228 }

void consoleCleanLog ( char *  msg  ) 

Definition at line 1213 of file switch_cpp.cpp.

References console_clean_log().

01214 {
01215         return console_clean_log(msg);
01216 }

void consoleLog ( char *  level_str,
char *  msg 
)

Definition at line 1208 of file switch_cpp.cpp.

References console_log().

01209 {
01210         return console_log(level_str, msg);
01211 }

switch_status_t dtmf_callback ( switch_core_session_t session,
void *  input,
switch_input_type_t  itype,
void *  buf,
unsigned int  buflen 
)

Definition at line 1300 of file switch_cpp.cpp.

References CoreSession::run_dtmf_callback(), switch_channel_get_private(), switch_core_session_get_channel(), and SWITCH_STATUS_FALSE.

Referenced by CoreSession::setDTMFCallback().

01304                                                                                                                               {
01305         
01306         switch_channel_t *channel = switch_core_session_get_channel(session_cb);
01307         CoreSession *coresession = NULL;
01308 
01309         coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession");
01310 
01311         if (!coresession) {
01312                 return SWITCH_STATUS_FALSE;
01313         }
01314 
01315         return coresession->run_dtmf_callback(input, itype);
01316 }

bool email ( char *  to,
char *  from,
char *  headers = NULL,
char *  body = NULL,
char *  file = NULL,
char *  convert_cmd = NULL,
char *  convert_ext = NULL 
)

Definition at line 1235 of file switch_cpp.cpp.

References switch_simple_email(), and SWITCH_TRUE.

01236 {
01237     if (switch_simple_email(to, from, headers, body, file, convert_cmd, convert_ext) == SWITCH_TRUE) {
01238       return true;
01239     }
01240     return false;
01241 }

char* getGlobalVariable ( char *  var_name  ) 

Definition at line 1202 of file switch_cpp.cpp.

References switch_core_get_variable_dup().

01203 {
01204         return switch_core_get_variable_dup(var_name);
01205 }

switch_status_t hanguphook ( switch_core_session_t session  ) 

the actual hangup hook called back by freeswitch core which in turn gets the session and calls the appropriate instance method to complete the callback.

Definition at line 1283 of file switch_cpp.cpp.

References CoreSession::check_hangup_hook(), CoreSession::hook_state, switch_channel_get_private(), switch_channel_get_state(), switch_core_session_get_channel(), and SWITCH_STATUS_SUCCESS.

Referenced by hanguphook(), CoreSession::setHangupHook(), and signal_bridge_on_hibernate().

01284 {
01285         switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
01286         CoreSession *coresession = NULL;
01287         switch_channel_state_t state = switch_channel_get_state(channel);
01288 
01289         if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
01290                 if (coresession->hook_state != state) {
01291                         coresession->hook_state = state;
01292                         coresession->check_hangup_hook();
01293                 }
01294         }
01295 
01296         return SWITCH_STATUS_SUCCESS;
01297 }

void msleep ( unsigned  ms  ) 

Definition at line 1243 of file switch_cpp.cpp.

References switch_sleep().

01244 {
01245         switch_sleep(ms * 1000);
01246         return;
01247 }

void setGlobalVariable ( char *  var_name,
char *  var_val 
)

Definition at line 1197 of file switch_cpp.cpp.

References switch_core_set_variable().

01198 {
01199         switch_core_set_variable(var_name, var_val);
01200 }


Generated on Sun May 20 04:00:10 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7