2007-05-08 00:29:49 +00:00
|
|
|
#ifndef SWITCH_CPP_H
|
|
|
|
#define SWITCH_CPP_H
|
|
|
|
|
2007-06-01 18:50:34 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#ifdef DOH
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-05-08 00:29:49 +00:00
|
|
|
#include <switch.h>
|
|
|
|
|
2007-06-01 18:50:34 +00:00
|
|
|
|
2007-05-08 00:29:49 +00:00
|
|
|
void console_log(char *level_str, char *msg);
|
|
|
|
void console_clean_log(char *msg);
|
|
|
|
char *api_execute(char *cmd, char *arg);
|
|
|
|
void api_reply_delete(char *reply);
|
2007-06-01 18:50:34 +00:00
|
|
|
switch_status_t process_callback_result(char *raw_result,
|
|
|
|
struct input_callback_state *cb_state,
|
|
|
|
switch_core_session_t *session);
|
2007-05-08 00:29:49 +00:00
|
|
|
|
2007-06-15 17:25:41 +00:00
|
|
|
|
|
|
|
typedef struct input_callback_state {
|
|
|
|
void *function; // pointer to the language specific callback function
|
|
|
|
// eg, PyObject *pyfunc
|
|
|
|
void *threadState; // pointer to the language specific thread state
|
|
|
|
// eg, PyThreadState *threadState
|
|
|
|
void *extra; // currently used to store a switch_file_handle_t
|
|
|
|
char *funcargs; // extra string that will be passed to callback function
|
2007-06-16 03:56:44 +00:00
|
|
|
} input_callback_state;
|
2007-06-15 17:25:41 +00:00
|
|
|
|
|
|
|
|
2007-05-08 00:29:49 +00:00
|
|
|
class CoreSession {
|
2007-06-15 17:25:41 +00:00
|
|
|
protected:
|
2007-05-08 00:29:49 +00:00
|
|
|
switch_input_args_t args;
|
|
|
|
switch_input_args_t *ap;
|
2007-06-15 17:25:41 +00:00
|
|
|
char *uuid;
|
|
|
|
char *tts_name;
|
|
|
|
char *voice_name;
|
|
|
|
void store_file_handle(switch_file_handle_t *fh);
|
2007-05-08 00:29:49 +00:00
|
|
|
public:
|
|
|
|
CoreSession(char *uuid);
|
2007-06-08 14:52:50 +00:00
|
|
|
CoreSession(switch_core_session_t *new_session);
|
2007-06-15 17:25:41 +00:00
|
|
|
virtual ~CoreSession();
|
2007-05-08 00:29:49 +00:00
|
|
|
switch_core_session_t *session;
|
|
|
|
switch_channel_t *channel;
|
2007-06-15 17:25:41 +00:00
|
|
|
input_callback_state cb_state;
|
2007-05-08 00:29:49 +00:00
|
|
|
int answer();
|
|
|
|
int preAnswer();
|
|
|
|
void hangup(char *cause);
|
|
|
|
void setVariable(char *var, char *val);
|
2007-05-11 19:41:11 +00:00
|
|
|
char *getVariable(char *var);
|
2007-06-15 17:25:41 +00:00
|
|
|
|
|
|
|
/** \brief Play a file that resides on disk into the channel
|
|
|
|
*
|
|
|
|
* \param file - the path to the .wav/.mp3 to be played
|
|
|
|
* \param timer_name - ?? does not seem to be used, what is this?
|
|
|
|
* \return an int status code indicating success or failure
|
|
|
|
*
|
|
|
|
* NOTE: if a dtmf callback is installed before calling this
|
|
|
|
* function, that callback will be called upon receiving any
|
|
|
|
* dtmfs
|
|
|
|
*/
|
2007-05-08 00:29:49 +00:00
|
|
|
int playFile(char *file, char *timer_name);
|
2007-06-15 17:25:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** \brief 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 playFile(), streamfile(), and
|
|
|
|
* certain other methods are executing.
|
|
|
|
*
|
|
|
|
* Note that language specific sessions might need to create
|
|
|
|
* their own version of this with a slightly different signature
|
|
|
|
* (as done in freeswitch_python.h)
|
|
|
|
*/
|
|
|
|
void setDTMFCallback(switch_input_callback_function_t cb,
|
|
|
|
void *buf,
|
|
|
|
uint32_t buflen);
|
|
|
|
|
|
|
|
int speak(char *text);
|
2007-05-08 00:29:49 +00:00
|
|
|
void set_tts_parms(char *tts_name, char *voice_name);
|
2007-06-15 17:25:41 +00:00
|
|
|
|
|
|
|
int getDigits(char *dtmf_buf,
|
|
|
|
int len,
|
|
|
|
char *terminators,
|
|
|
|
char *terminator,
|
|
|
|
int timeout);
|
|
|
|
|
2007-05-08 00:29:49 +00:00
|
|
|
int transfer(char *extensions, char *dialplan, char *context);
|
2007-06-15 17:25:41 +00:00
|
|
|
|
|
|
|
/** \brief 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.
|
|
|
|
*/
|
|
|
|
int playAndGetDigits(int min_digits,
|
|
|
|
int max_digits,
|
|
|
|
int max_tries,
|
|
|
|
int timeout,
|
|
|
|
char *terminators,
|
|
|
|
char *audio_files,
|
|
|
|
char *bad_input_audio_files,
|
|
|
|
char *dtmf_buf,
|
2007-06-01 18:50:34 +00:00
|
|
|
char *digits_regex);
|
2007-06-15 17:25:41 +00:00
|
|
|
|
|
|
|
/** \brief Play a file that resides on disk into the channel
|
|
|
|
*
|
|
|
|
* \param file - the path to the .wav/.mp3 to be played
|
|
|
|
* \param starting_sample_count - the index of the sample to
|
|
|
|
* start playing from
|
|
|
|
* \return an int status code indicating success or failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int streamfile(char *file, int starting_sample_count);
|
|
|
|
|
|
|
|
bool ready();
|
|
|
|
|
2007-05-08 00:29:49 +00:00
|
|
|
void execute(char *app, char *data);
|
2007-06-15 17:25:41 +00:00
|
|
|
virtual void begin_allow_threads();
|
|
|
|
virtual void end_allow_threads();
|
|
|
|
|
2007-06-01 18:50:34 +00:00
|
|
|
|
2007-05-08 00:29:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-06-01 18:50:34 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-05-08 00:29:49 +00:00
|
|
|
#endif
|
|
|
|
/* For Emacs:
|
|
|
|
* Local Variables:
|
|
|
|
* mode:c
|
|
|
|
* indent-tabs-mode:t
|
|
|
|
* tab-width:4
|
|
|
|
* c-basic-offset:4
|
|
|
|
* End:
|
|
|
|
* For VIM:
|
|
|
|
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
|
|
|
|
*/
|
|
|
|
|