FreeSWITCH API Documentation  1.7.0
Functions
switch_swig.c File Reference
#include <switch.h>
+ Include dependency graph for switch_swig.c:

Go to the source code of this file.

Functions

void fs_core_set_globals (void)
 
int fs_core_init (char *path)
 
int fs_core_destroy (void)
 
int fs_loadable_module_init (void)
 
int fs_loadable_module_shutdown (void)
 
int fs_console_loop (void)
 
void fs_consol_log (char *level_str, char *msg)
 
void fs_consol_clean (char *msg)
 
switch_core_session_tfs_core_session_locate (char *uuid)
 
void fs_channel_answer (switch_core_session_t *session)
 
void fs_channel_pre_answer (switch_core_session_t *session)
 
void fs_channel_hangup (switch_core_session_t *session, char *cause)
 
void fs_channel_set_variable (switch_core_session_t *session, char *var, char *val)
 
void fs_channel_get_variable (switch_core_session_t *session, char *var)
 
void fs_channel_set_state (switch_core_session_t *session, char *state)
 
int fs_ivr_play_file (switch_core_session_t *session, switch_file_handle_t *fh, char *file, switch_input_args_t *args)
 
int fs_switch_ivr_record_file (switch_core_session_t *session, switch_file_handle_t *fh, char *file, switch_input_args_t *args, unsigned int limit)
 
int fs_switch_ivr_sleep (switch_core_session_t *session, uint32_t ms)
 
int fs_ivr_play_file2 (switch_core_session_t *session, char *file)
 
int fs_switch_ivr_collect_digits_callback (switch_core_session_t *session, switch_input_args_t *args, unsigned int timeout)
 
int fs_switch_ivr_collect_digits_count (switch_core_session_t *session, char *buf, unsigned int buflen, unsigned int maxdigits, const char *terminators, char *terminator, unsigned int timeout)
 
int fs_switch_ivr_originate (switch_core_session_t *session, switch_core_session_t **bleg, char *bridgeto, uint32_t timelimit_sec)
 
int fs_switch_ivr_session_transfer (switch_core_session_t *session, char *extension, char *dialplan, char *context)
 
int fs_switch_ivr_speak_text (switch_core_session_t *session, char *tts_name, char *voice_name, char *text)
 
char * fs_switch_channel_get_variable (switch_channel_t *channel, char *varname)
 
int fs_switch_channel_set_variable (switch_channel_t *channel, char *varname, char *value)
 

Function Documentation

void fs_channel_answer ( switch_core_session_t session)

Definition at line 113 of file switch_swig.c.

References switch_channel_answer, and switch_core_session_get_channel().

114 {
116  switch_channel_answer(channel);
117 }
#define switch_channel_answer(channel)
Answer a channel (initiate/acknowledge a successful connection)
_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 fs_channel_get_variable ( switch_core_session_t session,
char *  var 
)

Definition at line 137 of file switch_swig.c.

References switch_channel_get_variable, and switch_core_session_get_channel().

138 {
140  switch_channel_get_variable(channel, var);
141 }
_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 switch_channel_get_variable(_c, _v)
void fs_channel_hangup ( switch_core_session_t session,
char *  cause 
)

Definition at line 125 of file switch_swig.c.

References switch_channel_hangup, switch_channel_str2cause(), and switch_core_session_get_channel().

126 {
129 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
_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.
switch_call_cause_t switch_channel_str2cause(_In_ const char *str)
return a cause code for a given string
void fs_channel_pre_answer ( switch_core_session_t session)

Definition at line 119 of file switch_swig.c.

References switch_channel_pre_answer, and switch_core_session_get_channel().

120 {
122  switch_channel_pre_answer(channel);
123 }
_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 switch_channel_pre_answer(channel)
Indicate progress on a channel to attempt early media.
void fs_channel_set_state ( switch_core_session_t session,
char *  state 
)

Definition at line 143 of file switch_swig.c.

References CS_HANGUP, switch_channel_get_state(), switch_channel_name_state(), switch_channel_set_state, and switch_core_session_get_channel().

144 {
147 
148  if ((fs_state = switch_channel_name_state(state)) < CS_HANGUP) {
149  switch_channel_set_state(channel, fs_state);
150  }
151 }
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
switch_channel_state_t switch_channel_name_state(_In_ const char *name)
Render the enum of the provided state name.
_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.
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
void fs_channel_set_variable ( switch_core_session_t session,
char *  var,
char *  val 
)

Definition at line 131 of file switch_swig.c.

References switch_channel_set_variable, and switch_core_session_get_channel().

132 {
134  switch_channel_set_variable(channel, var, val);
135 }
_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 switch_channel_set_variable(_channel, _var, _val)
void fs_consol_clean ( char *  msg)

Definition at line 97 of file switch_swig.c.

References SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, and switch_log_printf().

98 {
100 }
#define SWITCH_CHANNEL_LOG_CLEAN
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.
void fs_consol_log ( char *  level_str,
char *  msg 
)

Definition at line 87 of file switch_swig.c.

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

88 {
90  if (level_str) {
91  level = switch_log_str2level(level_str);
92  }
93 
95 }
#define SWITCH_CHANNEL_LOG
switch_log_level_t switch_log_str2level(_In_z_ const char *str)
Return the level number of the specified log level name.
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.
int fs_console_loop ( void  )

Definition at line 81 of file switch_swig.c.

References switch_console_loop().

82 {
84  return 0;
85 }
void switch_console_loop(void)
A simple comand loop that reads input from the terminal.
int fs_core_destroy ( void  )

Definition at line 61 of file switch_swig.c.

References switch_core_destroy(), and SWITCH_STATUS_SUCCESS.

62 {
63  switch_status_t status;
64 
65  status = switch_core_destroy();
66 
67  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
68 }
switch_status_t switch_core_destroy(void)
Destroy the core.
Definition: switch_core.c:2877
switch_status_t
Common return values.
int fs_core_init ( char *  path)

Definition at line 47 of file switch_swig.c.

References SCF_NONE, switch_core_init(), SWITCH_STATUS_SUCCESS, and zstr.

48 {
49  switch_status_t status;
50  const char *err = NULL;
51 
52  if (zstr(path)) {
53  path = NULL;
54  }
55 
56  status = switch_core_init(path, SCF_NONE, &err);
57 
58  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
59 }
switch_status_t switch_core_init(_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err)
Initilize the core.
#define zstr(x)
Definition: switch_utils.h:281
switch_status_t
Common return values.
switch_core_session_t* fs_core_session_locate ( char *  uuid)

Definition at line 102 of file switch_swig.c.

References switch_core_session_locate, and switch_core_session_rwunlock().

103 {
104  switch_core_session_t *session;
105 
106  if ((session = switch_core_session_locate(uuid))) {
108  }
109 
110  return session;
111 }
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define switch_core_session_locate(uuid_str)
Locate a session based on it's uuid.
Definition: switch_core.h:916
void fs_core_set_globals ( void  )

Definition at line 42 of file switch_swig.c.

References switch_core_set_globals().

43 {
45 }
void switch_core_set_globals(void)
Initiate Globals.
Definition: switch_core.c:620
int fs_ivr_play_file ( switch_core_session_t session,
switch_file_handle_t fh,
char *  file,
switch_input_args_t args 
)

Definition at line 157 of file switch_swig.c.

References switch_ivr_play_file(), and SWITCH_STATUS_SUCCESS.

158 {
159  switch_status_t status;
160 
161  status = switch_ivr_play_file(session, fh, file, args);
162  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
163 }
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_status_t
Common return values.
int fs_ivr_play_file2 ( switch_core_session_t session,
char *  file 
)

Definition at line 180 of file switch_swig.c.

References switch_ivr_play_file(), and SWITCH_STATUS_SUCCESS.

181 {
182  switch_status_t status;
183 
184  status = switch_ivr_play_file(session, NULL, file, NULL);
185  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
186 }
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_status_t
Common return values.
int fs_loadable_module_init ( void  )

Definition at line 70 of file switch_swig.c.

References switch_loadable_module_init(), and SWITCH_STATUS_SUCCESS.

71 {
73 }
switch_status_t switch_loadable_module_init(switch_bool_t autoload)
Initilize the module backend and load all the modules.
int fs_loadable_module_shutdown ( void  )

Definition at line 75 of file switch_swig.c.

References switch_loadable_module_shutdown().

76 {
78  return 1;
79 }
void switch_loadable_module_shutdown(void)
Shutdown the module backend and call the shutdown routine in all loaded modules.
char* fs_switch_channel_get_variable ( switch_channel_t channel,
char *  varname 
)

Definition at line 272 of file switch_swig.c.

References switch_channel_get_variable.

273 {
274  return switch_channel_get_variable(channel, varname);
275 }
#define switch_channel_get_variable(_c, _v)
int fs_switch_channel_set_variable ( switch_channel_t channel,
char *  varname,
char *  value 
)

Definition at line 277 of file switch_swig.c.

References switch_channel_set_variable, and SWITCH_STATUS_SUCCESS.

278 {
279  switch_status_t status;
280 
281  status = switch_channel_set_variable(channel, varname, value);
282  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
283 }
switch_status_t
Common return values.
#define switch_channel_set_variable(_channel, _var, _val)
int fs_switch_ivr_collect_digits_callback ( switch_core_session_t session,
switch_input_args_t args,
unsigned int  timeout 
)

Definition at line 189 of file switch_swig.c.

References switch_ivr_collect_digits_callback(), and SWITCH_STATUS_SUCCESS.

190 {
191  switch_status_t status;
192 
193  status = switch_ivr_collect_digits_callback(session, args, timeout);
194  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
195 }
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:1173
switch_status_t
Common return values.
int fs_switch_ivr_collect_digits_count ( switch_core_session_t session,
char *  buf,
unsigned int  buflen,
unsigned int  maxdigits,
const char *  terminators,
char *  terminator,
unsigned int  timeout 
)

Definition at line 197 of file switch_swig.c.

References switch_ivr_collect_digits_count(), and SWITCH_STATUS_SUCCESS.

200 {
201  switch_status_t status;
202 
203  status = switch_ivr_collect_digits_count(session, buf, buflen, maxdigits, terminators, terminator, timeout);
204  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
205 }
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:1287
switch_byte_t switch_byte_t * buf
switch_byte_t switch_byte_t uint32_t buflen
switch_status_t
Common return values.
int fs_switch_ivr_originate ( switch_core_session_t session,
switch_core_session_t **  bleg,
char *  bridgeto,
uint32_t  timelimit_sec 
)

Definition at line 220 of file switch_swig.c.

References SOF_NONE, SWITCH_CAUSE_NORMAL_CLEARING, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL, switch_channel_get_variable, switch_channel_hangup, SWITCH_CHANNEL_SESSION_LOG, switch_core_session_get_channel(), switch_core_session_rwunlock(), switch_ivr_multi_threaded_bridge(), switch_ivr_originate(), SWITCH_LOG_NOTICE, switch_log_printf(), and SWITCH_STATUS_SUCCESS.

225 {
226 
227  switch_channel_t *caller_channel;
228  switch_core_session_t *peer_session;
229  unsigned int timelimit = 60;
230  char *var;
232 
233  caller_channel = switch_core_session_get_channel(session);
234  assert(caller_channel != NULL);
235 
236  if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
237  timelimit = atoi(var);
238  }
239 
240  if (switch_ivr_originate(session, &peer_session, &cause, bridgeto, timelimit, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
241  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Cannot Create Outgoing Channel!\n");
243  return;
244  } else {
245  switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
246  switch_core_session_rwunlock(peer_session);
247  }
248 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
#define SWITCH_CHANNEL_SESSION_LOG(x)
_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.
switch_status_t switch_ivr_multi_threaded_bridge(_In_ switch_core_session_t *session, _In_ switch_core_session_t *peer_session, switch_input_callback_function_t dtmf_callback, void *session_data, void *peer_session_data)
Bridge Audio from one session to another.
#define switch_channel_get_variable(_c, _v)
switch_call_cause_t
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
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_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)
Make an outgoing call.
int fs_switch_ivr_record_file ( switch_core_session_t session,
switch_file_handle_t fh,
char *  file,
switch_input_args_t args,
unsigned int  limit 
)

Definition at line 165 of file switch_swig.c.

References switch_ivr_record_file(), and SWITCH_STATUS_SUCCESS.

166 {
167  switch_status_t status;
168 
169  status = switch_ivr_record_file(session, fh, file, args, limit);
170  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
171 }
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.
int fs_switch_ivr_session_transfer ( switch_core_session_t session,
char *  extension,
char *  dialplan,
char *  context 
)

Definition at line 250 of file switch_swig.c.

References switch_ivr_session_transfer(), and SWITCH_STATUS_SUCCESS.

251 {
252  switch_status_t status;
253 
254  status = switch_ivr_session_transfer(session, extension, dialplan, context);
255  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
256 }
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.
switch_status_t
Common return values.
int fs_switch_ivr_sleep ( switch_core_session_t session,
uint32_t  ms 
)

Definition at line 173 of file switch_swig.c.

References switch_ivr_sleep(), and SWITCH_STATUS_SUCCESS.

174 {
175  switch_status_t status;
176  status = switch_ivr_sleep(session, ms);
177  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
178 }
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_status_t
Common return values.
int fs_switch_ivr_speak_text ( switch_core_session_t session,
char *  tts_name,
char *  voice_name,
char *  text 
)

Definition at line 258 of file switch_swig.c.

References switch_ivr_speak_text(), and SWITCH_STATUS_SUCCESS.

259 {
260  switch_status_t status;
261 
262  status = switch_ivr_speak_text(session, tts_name, voice_name, text, NULL);
263  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
264 }
switch_status_t switch_ivr_speak_text(switch_core_session_t *session, const char *tts_name, const char *voice_name, char *text, switch_input_args_t *args)
Speak given text with given tts engine.
switch_status_t
Common return values.