[Freeswitch-svn] [commit] r3541 - freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python
Freeswitch SVN
jkr888 at freeswitch.org
Tue Dec 5 11:09:37 EST 2006
Author: jkr888
Date: Tue Dec 5 11:09:36 2006
New Revision: 3541
Modified:
freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/Makefile
freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.h
Log:
Modified: freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/Makefile
==============================================================================
--- freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/Makefile (original)
+++ freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/Makefile Tue Dec 5 11:09:36 2006
@@ -4,13 +4,18 @@
LDFLAGS=-lpython2.4 -Xlinker -export-dynamic -L$(PREFIX)/lib/python2.4/config/ -lutil
SWIGCFILE=../../../switch_swig.c
SWIGIFILE=../../../switch_swig.i
+CPPCC = g++
+OBJS=freeswitch_python.o
#all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PYMOD).$(DYNAMIC_LIB_EXTEN)
-all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
+all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(OBJS)
depends:
MAKE=$(MAKE) PY_CFLAGS=-fPIC $(BASE)/build/buildlib.sh $(BASE) install Python-2.4.3.tgz --prefix=$(PREFIX) --enable-threads
+%.o: %.cpp
+ $(CPPCC) -Wall -Werror -fPIC $(CFLAGS) -c -o $@ $<
+
%.o: %.c
$(CC) $(LCFLAGS) $(CFLAGS) -c $< -o $@
@@ -18,8 +23,9 @@
$(CC) $(LCFLAGS) $(CFLAGS) -c mod_python.c -o mod_python.o
reswig:
- rm -f switch_swig_wrap.c config.m4 CREDITS *${PYMOD}*
- swig -o switch_swig_wrap.c -l$(SWIGIFILE) -ignoremissing -DMULTIPLICITY -python -module $(PYMOD) $(SWIGCFILE)
+ # rm -f switch_swig_wrap.c config.m4 CREDITS *${PYMOD}*
+ # swig -o switch_swig_wrap.c -l$(SWIGIFILE) -ignoremissing -DMULTIPLICITY -python -module $(PYMOD) $(SWIGCFILE)
+ swig -python -shadow -c++ mod_python.i
# patch -p0 -i fix.diff
switch_swig_wrap.o: switch_swig_wrap.c Makefile
Modified: freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.cpp (original)
+++ freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.cpp Tue Dec 5 11:09:36 2006
@@ -1,8 +1,12 @@
#include "freeswitch_python.h"
-SessionContainer::SessionContainer()
+SessionContainer::SessionContainer(char *nuuid)
{
-
+ uuid = nuuid;
+ if ((session = switch_core_session_locate(uuid))) {
+ switch_core_session_rwunlock(session);
+ channel = switch_core_session_get_channel(session);
+ }
}
SessionContainer::~SessionContainer()
@@ -10,4 +14,51 @@
}
+void SessionContainer::console_log(char *level_str, char *msg)
+{
+ switch_log_level_t level = SWITCH_LOG_DEBUG;
+ if (level_str) {
+ level = switch_log_str2level(level_str);
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
+}
+
+void SessionContainer::console_clean_log(char *msg)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, msg);
+}
+
+void SessionContainer::answer()
+{
+ switch_channel_answer(channel);
+}
+
+void SessionContainer::pre_answer()
+{
+ switch_channel_pre_answer(channel);
+}
+
+void SessionContainer::hangup(char *cause)
+{
+ switch_channel_hangup(channel, switch_channel_str2cause(cause));
+}
+
+void SessionContainer::set_variable(char *var, char *val)
+{
+ switch_channel_set_variable(channel, var, val);
+}
+
+void SessionContainer::get_variable(char *var, char *val)
+{
+ switch_channel_get_variable(channel, var);
+}
+
+void SessionContainer::set_state(char *state)
+{
+ switch_channel_state_t current_state = switch_channel_get_state(channel);
+
+ if ((current_state = switch_channel_name_state(state)) < CS_HANGUP) {
+ switch_channel_set_state(channel, current_state);
+ }
+}
Modified: freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.h
==============================================================================
--- freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.h (original)
+++ freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.h Tue Dec 5 11:09:36 2006
@@ -1,5 +1,5 @@
#ifdef __cplusplus
-exten "C" {
+extern "C" {
#endif
#include <switch.h>
@@ -10,11 +10,20 @@
switch_channel_t *channel;
char *uuid;
public:
- SessionContainer();
+ SessionContainer(char *uuid);
~SessionContainer();
+ void console_log(char *level_str, char *msg);
+ void console_clean_log(char *msg);
+ void answer();
+ void pre_answer();
+ void hangup(char *cause);
+ void set_variable(char *var, char *val);
+ void get_variable(char *var, char *val);
+ void set_state(char *state);
protected:
};
#ifdef __cplusplus
}
#endif
+
More information about the Freeswitch-svn
mailing list