merge changes from branch http://svn.freeswitch.org/svn/freeswitch/branches/greenlizard/ that changes the session container implementation to use the one in the core, and an inherited class in python. Please note that this changes the python script api to more closely match (it is still a subset) the one already in place and documented for spidermonkey, and will break all your scripts that are currently working.. Fix a fatal bug causing segfaults in mod_python when using the callbacks.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5242 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2007-06-01 18:50:34 +00:00
parent f0573f0607
commit fedefcb69f
10 changed files with 5411 additions and 1282 deletions
@@ -10,40 +10,41 @@ extern "C" {
}
#endif
#include <switch.h>
#include <switch_cpp.h>
// declaration for function that is defined in mod_python.i
extern switch_status_t PythonDTMFCallback(switch_core_session *session,
void *input,
switch_input_type_t itype,
void *buf,
unsigned int buflen);
extern switch_status_t PythonDTMFCallback(switch_core_session * session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
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);
class SessionContainer {
private:
switch_core_session_t *session;
switch_channel_t *channel;
PyObject *dtmfCallbackFunction;
char *tts_name;
char *voice_name;
public:
SessionContainer(char *uuid);
~SessionContainer();
char *uuid;
struct input_callback_state {
PyObject *function;
PyThreadState *threadState;
void *extra;
char *funcargs;
};
class PySession : public CoreSession {
private:
PyObject *dtmfCallbackFunction;
PyThreadState *threadState;
public:
PySession(char *uuid) : CoreSession(uuid) {};
PySession(switch_core_session_t *session) : CoreSession(session) {};
~PySession();
int streamfile(char *file, PyObject *pyfunc, char *funcargs, int starting_sample_count);
void begin_allow_threads();
void end_allow_threads();
int answer();
int pre_answer();
void hangup(char *cause);
void set_variable(char *var, char *val);
char *get_variable(char *var);
int play_file(char *file, char *timer_name);
void set_dtmf_callback(PyObject * pyfunc);
int speak_text(char *text);
void set_tts_parms(char *tts_name, char *voice_name);
int get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout);
int transfer(char *extensions, char *dialplan, char *context);
int play_and_get_digits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators,
char *audio_files, char *bad_input_audio_files, char *dtmf_buf, char *digits_regex);
void execute(char *app, char *data);
protected:
};