mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-22 03:51:48 +00:00
change mod_python so freeswitch module is auto-loaded and session is auto declared
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5103 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
cb09b09f82
commit
50b4a37771
@ -54,6 +54,9 @@ class SessionContainer(_object):
|
|||||||
try:
|
try:
|
||||||
if self.thisown: destroy(self)
|
if self.thisown: destroy(self)
|
||||||
except: pass
|
except: pass
|
||||||
|
__swig_setmethods__["uuid"] = _freeswitch.SessionContainer_uuid_set
|
||||||
|
__swig_getmethods__["uuid"] = _freeswitch.SessionContainer_uuid_get
|
||||||
|
if _newclass:uuid = property(_freeswitch.SessionContainer_uuid_get, _freeswitch.SessionContainer_uuid_set)
|
||||||
def answer(*args): return _freeswitch.SessionContainer_answer(*args)
|
def answer(*args): return _freeswitch.SessionContainer_answer(*args)
|
||||||
def pre_answer(*args): return _freeswitch.SessionContainer_pre_answer(*args)
|
def pre_answer(*args): return _freeswitch.SessionContainer_pre_answer(*args)
|
||||||
def hangup(*args): return _freeswitch.SessionContainer_hangup(*args)
|
def hangup(*args): return _freeswitch.SessionContainer_hangup(*args)
|
||||||
|
@ -6,42 +6,46 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef DOH
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
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_log(char *level_str, char *msg);
|
||||||
void console_clean_log(char *msg);
|
void console_clean_log(char *msg);
|
||||||
char *api_execute(char *cmd, char *arg);
|
char *api_execute(char *cmd, char *arg);
|
||||||
void api_reply_delete(char *reply);
|
void api_reply_delete(char *reply);
|
||||||
|
|
||||||
class SessionContainer {
|
class SessionContainer {
|
||||||
private:
|
private:
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
switch_channel_t *channel;
|
switch_channel_t *channel;
|
||||||
char *uuid;
|
PyObject *dtmfCallbackFunction;
|
||||||
PyObject *dtmfCallbackFunction;
|
char *tts_name;
|
||||||
char *tts_name;
|
char *voice_name;
|
||||||
char *voice_name;
|
public:
|
||||||
public:
|
SessionContainer(char *uuid);
|
||||||
SessionContainer(char *uuid);
|
~SessionContainer();
|
||||||
~SessionContainer();
|
char *uuid;
|
||||||
int answer();
|
|
||||||
int pre_answer();
|
int answer();
|
||||||
void hangup(char *cause);
|
int pre_answer();
|
||||||
void set_variable(char *var, char *val);
|
void hangup(char *cause);
|
||||||
void get_variable(char *var, char *val);
|
void set_variable(char *var, char *val);
|
||||||
int play_file(char *file, char *timer_name);
|
void get_variable(char *var, char *val);
|
||||||
void set_dtmf_callback(PyObject * pyfunc);
|
int play_file(char *file, char *timer_name);
|
||||||
int speak_text(char *text);
|
void set_dtmf_callback(PyObject * pyfunc);
|
||||||
void set_tts_parms(char *tts_name, char *voice_name);
|
int speak_text(char *text);
|
||||||
int get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout);
|
void set_tts_parms(char *tts_name, char *voice_name);
|
||||||
int transfer(char *extensions, char *dialplan, char *context);
|
int get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout);
|
||||||
int play_and_get_digits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators,
|
int transfer(char *extensions, char *dialplan, char *context);
|
||||||
char *audio_files, char *bad_input_audio_files, char *dtmf_buf, char *digits_regex);
|
int play_and_get_digits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators,
|
||||||
void execute(char *app, char *data);
|
char *audio_files, char *bad_input_audio_files, char *dtmf_buf, char *digits_regex);
|
||||||
protected:
|
void execute(char *app, char *data);
|
||||||
};
|
protected:
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -73,14 +73,8 @@ static void eval_some_python(char *uuid, char *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
script = argv[0];
|
script = argv[0];
|
||||||
|
lead = 1;
|
||||||
if (uuid) {
|
|
||||||
argv[0] = uuid;
|
|
||||||
} else {
|
|
||||||
lead = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (switch_is_file_path(script)) {
|
if (switch_is_file_path(script)) {
|
||||||
script_path = script;
|
script_path = script;
|
||||||
if ((script = strrchr(script_path, *SWITCH_PATH_SEPARATOR))) {
|
if ((script = strrchr(script_path, *SWITCH_PATH_SEPARATOR))) {
|
||||||
@ -114,7 +108,11 @@ static void eval_some_python(char *uuid, char *args)
|
|||||||
PyThreadState_Clear(tstate);
|
PyThreadState_Clear(tstate);
|
||||||
init_freeswitch();
|
init_freeswitch();
|
||||||
PyRun_SimpleString("from freeswitch import *");
|
PyRun_SimpleString("from freeswitch import *");
|
||||||
|
if (uuid) {
|
||||||
|
char code[128];
|
||||||
|
snprintf(code, sizeof(code), "session = SessionContainer(\"%s\");", uuid);
|
||||||
|
PyRun_SimpleString(code);
|
||||||
|
}
|
||||||
PySys_SetArgv(argc - lead, &argv[lead]);
|
PySys_SetArgv(argc - lead, &argv[lead]);
|
||||||
PyRun_SimpleFile(pythonfile, script);
|
PyRun_SimpleFile(pythonfile, script);
|
||||||
Py_EndInterpreter(tstate);
|
Py_EndInterpreter(tstate);
|
||||||
|
@ -931,6 +931,47 @@ static PyObject *_wrap_delete_SessionContainer(PyObject *self, PyObject *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static PyObject *_wrap_SessionContainer_uuid_set(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *resultobj;
|
||||||
|
SessionContainer *arg1 = (SessionContainer *) 0 ;
|
||||||
|
char *arg2 ;
|
||||||
|
PyObject * obj0 = 0 ;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args,(char *)"Os:SessionContainer_uuid_set",&obj0,&arg2)) goto fail;
|
||||||
|
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_SessionContainer,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
|
||||||
|
{
|
||||||
|
if (arg1->uuid) delete [] arg1->uuid;
|
||||||
|
if (arg2) {
|
||||||
|
arg1->uuid = (char *) (new char[strlen(arg2)+1]);
|
||||||
|
strcpy((char *) arg1->uuid,arg2);
|
||||||
|
} else {
|
||||||
|
arg1->uuid = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Py_INCREF(Py_None); resultobj = Py_None;
|
||||||
|
return resultobj;
|
||||||
|
fail:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static PyObject *_wrap_SessionContainer_uuid_get(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *resultobj;
|
||||||
|
SessionContainer *arg1 = (SessionContainer *) 0 ;
|
||||||
|
char *result;
|
||||||
|
PyObject * obj0 = 0 ;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args,(char *)"O:SessionContainer_uuid_get",&obj0)) goto fail;
|
||||||
|
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_SessionContainer,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
|
||||||
|
result = (char *) ((arg1)->uuid);
|
||||||
|
|
||||||
|
resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
|
||||||
|
return resultobj;
|
||||||
|
fail:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *_wrap_SessionContainer_answer(PyObject *self, PyObject *args) {
|
static PyObject *_wrap_SessionContainer_answer(PyObject *self, PyObject *args) {
|
||||||
PyObject *resultobj;
|
PyObject *resultobj;
|
||||||
SessionContainer *arg1 = (SessionContainer *) 0 ;
|
SessionContainer *arg1 = (SessionContainer *) 0 ;
|
||||||
@ -1235,6 +1276,8 @@ static PyMethodDef SwigMethods[] = {
|
|||||||
{ (char *)"api_reply_delete", _wrap_api_reply_delete, METH_VARARGS },
|
{ (char *)"api_reply_delete", _wrap_api_reply_delete, METH_VARARGS },
|
||||||
{ (char *)"new_SessionContainer", _wrap_new_SessionContainer, METH_VARARGS },
|
{ (char *)"new_SessionContainer", _wrap_new_SessionContainer, METH_VARARGS },
|
||||||
{ (char *)"delete_SessionContainer", _wrap_delete_SessionContainer, METH_VARARGS },
|
{ (char *)"delete_SessionContainer", _wrap_delete_SessionContainer, METH_VARARGS },
|
||||||
|
{ (char *)"SessionContainer_uuid_set", _wrap_SessionContainer_uuid_set, METH_VARARGS },
|
||||||
|
{ (char *)"SessionContainer_uuid_get", _wrap_SessionContainer_uuid_get, METH_VARARGS },
|
||||||
{ (char *)"SessionContainer_answer", _wrap_SessionContainer_answer, METH_VARARGS },
|
{ (char *)"SessionContainer_answer", _wrap_SessionContainer_answer, METH_VARARGS },
|
||||||
{ (char *)"SessionContainer_pre_answer", _wrap_SessionContainer_pre_answer, METH_VARARGS },
|
{ (char *)"SessionContainer_pre_answer", _wrap_SessionContainer_pre_answer, METH_VARARGS },
|
||||||
{ (char *)"SessionContainer_hangup", _wrap_SessionContainer_hangup, METH_VARARGS },
|
{ (char *)"SessionContainer_hangup", _wrap_SessionContainer_hangup, METH_VARARGS },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user