[Freeswitch-svn] [commit] r8924 - in freeswitch/trunk: scripts/scenario src/mod/asr_tts/mod_pocketsphinx src/mod/languages/mod_python

Freeswitch SVN mikej at freeswitch.org
Tue Jul 8 02:59:02 EDT 2008


Author: mikej
Date: Tue Jul  8 02:59:02 2008
New Revision: 8924

Modified:
   freeswitch/trunk/scripts/scenario/phones.cfg
   freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c
   freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
   freeswitch/trunk/src/mod/languages/mod_python/mod_python.c

Log:
fix seg src/mod/languages/mod_python

Modified: freeswitch/trunk/scripts/scenario/phones.cfg
==============================================================================
--- freeswitch/trunk/scripts/scenario/phones.cfg	(original)
+++ freeswitch/trunk/scripts/scenario/phones.cfg	Tue Jul  8 02:59:02 2008
@@ -1,4 +1,4 @@
-Snom_300,10.0.1.241,1000
+Snom_300,10.0.1.17,1000
 Snom_320,10.0.1.242,1002
 Snom_360,10.0.1.243,1006
 Snom_370,10.0.1.244,1007

Modified: freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c	(original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c	Tue Jul  8 02:59:02 2008
@@ -32,7 +32,6 @@
 
 #include <switch.h>
 #include <pocketsphinx.h>
-#define MODELDIR "/usr/local/share/pocketsphinx/model"
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_pocketsphinx_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_pocketsphinx_shutdown);

Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp	Tue Jul  8 02:59:02 2008
@@ -1,6 +1,6 @@
 #include "freeswitch_python.h"
 
-#define sanity_check(x) do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
+#define py_sanity_check(x) do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
 #define py_init_vars() do { caller_profile.source = "mod_python"; swapstate = S_SWAPPED_IN; } while(0)
 
 PySession::PySession():CoreSession()
@@ -21,7 +21,7 @@
 
 void PySession::setDTMFCallback(PyObject * pyfunc, char *funcargs)
 {
-	sanity_check();
+	py_sanity_check();
 
 	if (!PyCallable_Check(pyfunc)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "DTMF function is not a python function.\n");
@@ -51,10 +51,12 @@
 
 void PySession::check_hangup_hook()
 {
+#if 0
 	PyObject *func;
 	PyObject *result;
 	char *resultStr;
 	bool did_swap_in = false;
+#endif
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
 					  "check_hangup_hook has been DISABLED, please do not use hangup hooks in python code until further notice!\n");

Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python.c	Tue Jul  8 02:59:02 2008
@@ -249,40 +249,11 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_application_interface_t python_application_interface = {
-	/*.interface_name */ "python",
-	/*.application_function */ python_function,
-	NULL, NULL, NULL,
-	/* flags */ SAF_NONE,
-	/* should we support no media mode here?  If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
-	/*.next */ NULL
-};
-
-static switch_api_interface_t python_run_interface = {
-	/*.interface_name */ "python",
-	/*.desc */ "run a python script",
-	/*.function */ launch_python,
-	/*.syntax */ "python </path/to/script>",
-	/*.next */ NULL
-};
-
-static switch_loadable_module_interface_t python_module_interface = {
-	/*.module_name */ modname,
-	/*.endpoint_interface */ NULL,
-	/*.timer_interface */ NULL,
-	/*.dialplan_interface */ NULL,
-	/*.codec_interface */ NULL,
-	/*.application_interface */ &python_application_interface,
-	/*.api_interface */ &python_run_interface,
-	/*.file_interface */ NULL,
-	/*.speech_interface */ NULL,
-	/*.directory_interface */ NULL
-};
-
 SWITCH_MODULE_LOAD_FUNCTION(mod_python_load)
 {
-	/* connect my internal structure to the blank pointer passed to me */
-	*module_interface = &python_module_interface;
+	switch_api_interface_t *api_interface;
+	switch_application_interface_t *app_interface;
+
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Python Framework Loading...\n");
 
 	if (!Py_IsInitialized()) {
@@ -305,6 +276,13 @@
 		PyEval_ReleaseLock();
 	}
 
+
+	/* connect my internal structure to the blank pointer passed to me */
+	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
+	SWITCH_ADD_API(api_interface, "python", "run a python script", launch_python, "python </path/to/script>");
+	SWITCH_ADD_APP(app_interface, "python", "Launch python ivr", "Run a python ivr on a channel", python_function, "<script> [additional_vars [...]]",
+				   SAF_SUPPORT_NOMEDIA);
+
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }



More information about the Freeswitch-svn mailing list