look out below

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8221 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-04-30 19:42:26 +00:00
parent 069d468137
commit b6d649fc86
34 changed files with 4680 additions and 1159 deletions

View File

@ -148,16 +148,16 @@ libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS)
libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS)
libfreeswitch_la_LIBADD = $(CORE_LIBS)
libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES)
nodist_libfreeswitch_la_SOURCES = src/include/switch_version.h
nodist_libfreeswitch_la_SOURCES = src/include/switch_version.h src/include/switch_swigable_cpp.h
MOD_LINK = $(BASE)/libfreeswitch.la
CLEANFILES = src/include/switch_version.h
BUILT_SOURCES = src/include/switch_version.h
CLEANFILES = src/include/switch_version.h src/include/switch_swigable_cpp.h
BUILT_SOURCES = src/include/switch_version.h src/include/switch_swigable_cpp.h
bin_PROGRAMS = freeswitch
freeswitch_SOURCES = src/switch.c
nodist_freeswitch_SOURCES = src/include/switch_version.h
nodist_freeswitch_SOURCES = src/include/switch_version.h
freeswitch_CFLAGS = $(AM_CFLAGS) $(CORE_CFLAGS)
freeswitch_LDFLAGS = $(AM_LDFLAGS) -rpath $(libdir)
freeswitch_LDADD = libfreeswitch.la libs/apr/libapr-1.la
@ -180,6 +180,8 @@ endif
bin_SCRIPTS = scripts/gentls_cert scripts/fsxs
src/include/switch_swigable_cpp.h: src/include/switch_cpp.h
$(CC) -E src/include/switch_cpp.h -DSWITCH_DECLARE\(x\)=x -DSWITCH_DECLARE_CONSTRUCTOR= -DSWITCH_DECLARE_NONSTD\(x\)=x 2>/dev/null | grep -v "^#" > src/include/switch_swigable_cpp.h
libs/libedit/src/.libs/libedit.a:
cd libs/libedit && $(MAKE)

View File

@ -11,6 +11,7 @@ extern "C" {
#include <switch.h>
#define sanity_check(x) do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
#define sanity_check_noreturn do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0)
#define init_vars() do { session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; memset(&args, 0, sizeof(args)); ap = NULL; caller_profile.source = "mod_unknown"; caller_profile.dialplan = ""; caller_profile.context = ""; caller_profile.caller_id_name = ""; caller_profile.caller_id_number = ""; caller_profile.network_addr = ""; caller_profile.ani = ""; caller_profile.aniii = ""; caller_profile.rdnis = ""; caller_profile.username = ""; on_hangup = NULL; memset(&cb_state, 0, sizeof(cb_state)); hook_state = CS_NEW; } while(0)
@ -26,7 +27,7 @@ extern "C" {
// Copyright: See COPYING file that comes with this distribution
//
#if 0
#ifndef SWITCHTOMEMPOOL
#define SWITCHTOMEMPOOL
class SwitchToMempool {
@ -42,7 +43,7 @@ class SwitchToMempool {
switch_memory_pool_t *memorypool;
};
#endif
#endif
/*
@ -100,13 +101,15 @@ class Event {
SWITCH_DECLARE_CONSTRUCTOR Event(switch_event_t *wrap_me, int free_me=0);
virtual SWITCH_DECLARE_CONSTRUCTOR ~Event();
SWITCH_DECLARE(const char *)serialize(const char *format=NULL);
SWITCH_DECLARE(bool) set_priority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
SWITCH_DECLARE(char *)get_header(char *header_name);
SWITCH_DECLARE(char *)get_body(void);
SWITCH_DECLARE(bool) add_body(const char *value);
SWITCH_DECLARE(bool) add_header(const char *header_name, const char *value);
SWITCH_DECLARE(bool) del_header(const char *header_name);
SWITCH_DECLARE(bool) setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
SWITCH_DECLARE(char *)getHeader(char *header_name);
SWITCH_DECLARE(char *)getBody(void);
SWITCH_DECLARE(char *)getType(void);
SWITCH_DECLARE(bool) addBody(const char *value);
SWITCH_DECLARE(bool) addHeader(const char *header_name, const char *value);
SWITCH_DECLARE(bool) delHeader(const char *header_name);
SWITCH_DECLARE(bool) fire(void);
};

View File

@ -52,6 +52,6 @@
%include "enums.swg"
%include switch_cpp.h
%include switch_swigable_cpp.h
%include freeswitch_java.h

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
@ -59,6 +59,14 @@ public class CoreSession {
return freeswitchJNI.CoreSession_flags_get(swigCPtr, this);
}
public void setAllocated(int value) {
freeswitchJNI.CoreSession_allocated_set(swigCPtr, this, value);
}
public int getAllocated() {
return freeswitchJNI.CoreSession_allocated_get(swigCPtr, this);
}
public void setCb_state(input_callback_state_t value) {
freeswitchJNI.CoreSession_cb_state_set(swigCPtr, this, input_callback_state_t.getCPtr(value), value);
}
@ -85,19 +93,44 @@ public class CoreSession {
}
public void hangup(String cause) {
freeswitchJNI.CoreSession_hangup(swigCPtr, this, cause);
freeswitchJNI.CoreSession_hangup__SWIG_0(swigCPtr, this, cause);
}
public void hangup() {
freeswitchJNI.CoreSession_hangup__SWIG_1(swigCPtr, this);
}
public void setVariable(String var, String val) {
freeswitchJNI.CoreSession_setVariable(swigCPtr, this, var, val);
}
public void setPrivate(String var, SWIGTYPE_p_void val) {
freeswitchJNI.CoreSession_setPrivate(swigCPtr, this, var, SWIGTYPE_p_void.getCPtr(val));
}
public SWIGTYPE_p_void getPrivate(String var) {
long cPtr = freeswitchJNI.CoreSession_getPrivate(swigCPtr, this, var);
return (cPtr == 0) ? null : new SWIGTYPE_p_void(cPtr, false);
}
public String getVariable(String var) {
return freeswitchJNI.CoreSession_getVariable(swigCPtr, this, var);
}
public int recordFile(String file_name, int max_len, int silence_threshold, int silence_secs) {
return freeswitchJNI.CoreSession_recordFile(swigCPtr, this, file_name, max_len, silence_threshold, silence_secs);
return freeswitchJNI.CoreSession_recordFile__SWIG_0(swigCPtr, this, file_name, max_len, silence_threshold, silence_secs);
}
public int recordFile(String file_name, int max_len, int silence_threshold) {
return freeswitchJNI.CoreSession_recordFile__SWIG_1(swigCPtr, this, file_name, max_len, silence_threshold);
}
public int recordFile(String file_name, int max_len) {
return freeswitchJNI.CoreSession_recordFile__SWIG_2(swigCPtr, this, file_name, max_len);
}
public int recordFile(String file_name) {
return freeswitchJNI.CoreSession_recordFile__SWIG_3(swigCPtr, this, file_name);
}
public void setCallerData(String var, String val) {
@ -105,7 +138,11 @@ public class CoreSession {
}
public int originate(CoreSession a_leg_session, String dest, int timeout) {
return freeswitchJNI.CoreSession_originate(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest, timeout);
return freeswitchJNI.CoreSession_originate__SWIG_0(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest, timeout);
}
public int originate(CoreSession a_leg_session, String dest) {
return freeswitchJNI.CoreSession_originate__SWIG_1(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest);
}
public void setDTMFCallback(SWIGTYPE_p_void cbfunc, String funcargs) {
@ -124,8 +161,8 @@ public class CoreSession {
return freeswitchJNI.CoreSession_collectDigits(swigCPtr, this, timeout);
}
public int getDigits(byte[] dtmf_buf, int buflen, int maxdigits, String terminators, byte[] terminator, int timeout) {
return freeswitchJNI.CoreSession_getDigits(swigCPtr, this, dtmf_buf, buflen, maxdigits, terminators, terminator, timeout);
public int getDigits(byte[] dtmf_buf, SWIGTYPE_p_switch_size_t buflen, SWIGTYPE_p_switch_size_t maxdigits, String terminators, byte[] terminator, int timeout) {
return freeswitchJNI.CoreSession_getDigits(swigCPtr, this, dtmf_buf, SWIGTYPE_p_switch_size_t.getCPtr(buflen), SWIGTYPE_p_switch_size_t.getCPtr(maxdigits), terminators, terminator, timeout);
}
public int transfer(String extensions, String dialplan, String context) {
@ -137,7 +174,11 @@ public class CoreSession {
}
public int streamFile(String file, int starting_sample_count) {
return freeswitchJNI.CoreSession_streamFile(swigCPtr, this, file, starting_sample_count);
return freeswitchJNI.CoreSession_streamFile__SWIG_0(swigCPtr, this, file, starting_sample_count);
}
public int streamFile(String file) {
return freeswitchJNI.CoreSession_streamFile__SWIG_1(swigCPtr, this, file);
}
public int flushEvents() {
@ -164,6 +205,10 @@ public class CoreSession {
freeswitchJNI.CoreSession_execute(swigCPtr, this, app, data);
}
public void sendEvent(Event sendME) {
freeswitchJNI.CoreSession_sendEvent(swigCPtr, this, Event.getCPtr(sendME), sendME);
}
public boolean begin_allow_threads() {
return freeswitchJNI.CoreSession_begin_allow_threads(swigCPtr, this);
}

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
@ -25,10 +25,6 @@ public class freeswitch {
freeswitchJNI.api_reply_delete(reply);
}
public static SWIGTYPE_p_switch_status_t process_callback_result(String raw_result, input_callback_state_t cb_state, SWIGTYPE_p_switch_core_session_t session) {
return new SWIGTYPE_p_switch_status_t(freeswitchJNI.process_callback_result(raw_result, input_callback_state_t.getCPtr(cb_state), cb_state, SWIGTYPE_p_switch_core_session_t.getCPtr(session)), true);
}
public static void bridge(CoreSession session_a, CoreSession session_b) {
freeswitchJNI.bridge(CoreSession.getCPtr(session_a), session_a, CoreSession.getCPtr(session_b), session_b);
}

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
@ -9,11 +9,6 @@
package org.freeswitch.swig;
class freeswitchJNI {
public final static native void console_log(String jarg1, String jarg2);
public final static native void console_clean_log(String jarg1);
public final static native String api_execute(String jarg1, String jarg2);
public final static native void api_reply_delete(String jarg1);
public final static native long process_callback_result(String jarg1, long jarg2, input_callback_state_t jarg2_, long jarg3);
public final static native void input_callback_state_t_function_set(long jarg1, input_callback_state_t jarg1_, long jarg2);
public final static native long input_callback_state_t_function_get(long jarg1, input_callback_state_t jarg1_);
public final static native void input_callback_state_t_threadState_set(long jarg1, input_callback_state_t jarg1_, long jarg2);
@ -27,6 +22,33 @@ class freeswitchJNI {
public final static native int S_HUP_get();
public final static native int S_FREE_get();
public final static native int S_RDLOCK_get();
public final static native long new_Stream__SWIG_0();
public final static native long new_Stream__SWIG_1(long jarg1);
public final static native void delete_Stream(long jarg1);
public final static native void Stream_write(long jarg1, Stream jarg1_, String jarg2);
public final static native String Stream_get_data(long jarg1, Stream jarg1_);
public final static native void Event_event_set(long jarg1, Event jarg1_, long jarg2);
public final static native long Event_event_get(long jarg1, Event jarg1_);
public final static native void Event_serialized_string_set(long jarg1, Event jarg1_, String jarg2);
public final static native String Event_serialized_string_get(long jarg1, Event jarg1_);
public final static native void Event_mine_set(long jarg1, Event jarg1_, int jarg2);
public final static native int Event_mine_get(long jarg1, Event jarg1_);
public final static native long new_Event__SWIG_0(String jarg1, String jarg2);
public final static native long new_Event__SWIG_1(String jarg1);
public final static native long new_Event__SWIG_2(long jarg1, int jarg2);
public final static native long new_Event__SWIG_3(long jarg1);
public final static native void delete_Event(long jarg1);
public final static native String Event_serialize__SWIG_0(long jarg1, Event jarg1_, String jarg2);
public final static native String Event_serialize__SWIG_1(long jarg1, Event jarg1_);
public final static native boolean Event_setPriority__SWIG_0(long jarg1, Event jarg1_, long jarg2);
public final static native boolean Event_setPriority__SWIG_1(long jarg1, Event jarg1_);
public final static native String Event_getHeader(long jarg1, Event jarg1_, String jarg2);
public final static native String Event_getBody(long jarg1, Event jarg1_);
public final static native String Event_getType(long jarg1, Event jarg1_);
public final static native boolean Event_addBody(long jarg1, Event jarg1_, String jarg2);
public final static native boolean Event_addHeader(long jarg1, Event jarg1_, String jarg2, String jarg3);
public final static native boolean Event_delHeader(long jarg1, Event jarg1_, String jarg2);
public final static native boolean Event_fire(long jarg1, Event jarg1_);
public final static native void delete_CoreSession(long jarg1);
public final static native void CoreSession_session_set(long jarg1, CoreSession jarg1_, long jarg2);
public final static native long CoreSession_session_get(long jarg1, CoreSession jarg1_);
@ -34,38 +56,53 @@ class freeswitchJNI {
public final static native long CoreSession_channel_get(long jarg1, CoreSession jarg1_);
public final static native void CoreSession_flags_set(long jarg1, CoreSession jarg1_, long jarg2);
public final static native long CoreSession_flags_get(long jarg1, CoreSession jarg1_);
public final static native void CoreSession_allocated_set(long jarg1, CoreSession jarg1_, int jarg2);
public final static native int CoreSession_allocated_get(long jarg1, CoreSession jarg1_);
public final static native void CoreSession_cb_state_set(long jarg1, CoreSession jarg1_, long jarg2, input_callback_state_t jarg2_);
public final static native long CoreSession_cb_state_get(long jarg1, CoreSession jarg1_);
public final static native void CoreSession_hook_state_set(long jarg1, CoreSession jarg1_, long jarg2);
public final static native long CoreSession_hook_state_get(long jarg1, CoreSession jarg1_);
public final static native int CoreSession_answer(long jarg1, CoreSession jarg1_);
public final static native int CoreSession_preAnswer(long jarg1, CoreSession jarg1_);
public final static native void CoreSession_hangup(long jarg1, CoreSession jarg1_, String jarg2);
public final static native void CoreSession_hangup__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2);
public final static native void CoreSession_hangup__SWIG_1(long jarg1, CoreSession jarg1_);
public final static native void CoreSession_setVariable(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
public final static native void CoreSession_setPrivate(long jarg1, CoreSession jarg1_, String jarg2, long jarg3);
public final static native long CoreSession_getPrivate(long jarg1, CoreSession jarg1_, String jarg2);
public final static native String CoreSession_getVariable(long jarg1, CoreSession jarg1_, String jarg2);
public final static native int CoreSession_recordFile(long jarg1, CoreSession jarg1_, String jarg2, int jarg3, int jarg4, int jarg5);
public final static native int CoreSession_recordFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3, int jarg4, int jarg5);
public final static native int CoreSession_recordFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2, int jarg3, int jarg4);
public final static native int CoreSession_recordFile__SWIG_2(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_recordFile__SWIG_3(long jarg1, CoreSession jarg1_, String jarg2);
public final static native void CoreSession_setCallerData(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
public final static native int CoreSession_originate(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3, int jarg4);
public final static native int CoreSession_originate__SWIG_0(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3, int jarg4);
public final static native int CoreSession_originate__SWIG_1(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3);
public final static native void CoreSession_setDTMFCallback(long jarg1, CoreSession jarg1_, long jarg2, String jarg3);
public final static native int CoreSession_speak(long jarg1, CoreSession jarg1_, String jarg2);
public final static native void CoreSession_set_tts_parms(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
public final static native int CoreSession_collectDigits(long jarg1, CoreSession jarg1_, int jarg2);
public final static native int CoreSession_getDigits(long jarg1, CoreSession jarg1_, byte[] jarg2, int jarg3, int jarg4, String jarg5, byte[] jarg6, int jarg7);
public final static native int CoreSession_getDigits(long jarg1, CoreSession jarg1_, byte[] jarg2, long jarg3, long jarg4, String jarg5, byte[] jarg6, int jarg7);
public final static native int CoreSession_transfer(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4);
public final static native int CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, byte[] jarg9, String jarg10);
public final static native int CoreSession_streamFile(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
public final static native int CoreSession_flushEvents(long jarg1, CoreSession jarg1_);
public final static native int CoreSession_flushDigits(long jarg1, CoreSession jarg1_);
public final static native int CoreSession_setAutoHangup(long jarg1, CoreSession jarg1_, boolean jarg2);
public final static native void CoreSession_setHangupHook(long jarg1, CoreSession jarg1_, long jarg2);
public final static native boolean CoreSession_ready(long jarg1, CoreSession jarg1_);
public final static native void CoreSession_execute(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
public final static native void CoreSession_sendEvent(long jarg1, CoreSession jarg1_, long jarg2, Event jarg2_);
public final static native boolean CoreSession_begin_allow_threads(long jarg1, CoreSession jarg1_);
public final static native boolean CoreSession_end_allow_threads(long jarg1, CoreSession jarg1_);
public final static native String CoreSession_get_uuid(long jarg1, CoreSession jarg1_);
public final static native long CoreSession_get_cb_args(long jarg1, CoreSession jarg1_);
public final static native void CoreSession_check_hangup_hook(long jarg1, CoreSession jarg1_);
public final static native long CoreSession_run_dtmf_callback(long jarg1, CoreSession jarg1_, long jarg2, long jarg3);
public final static native void console_log(String jarg1, String jarg2);
public final static native void console_clean_log(String jarg1);
public final static native String api_execute(String jarg1, String jarg2);
public final static native void api_reply_delete(String jarg1);
public final static native void bridge(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_);
public final static native long hanguphook(long jarg1);
public final static native long dtmf_callback(long jarg1, long jarg2, long jarg3, long jarg4, long jarg5);

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.31
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
@ -27,15 +27,18 @@ public enum session_flag_t {
throw new IllegalArgumentException("No enum " + session_flag_t.class + " with value " + swigValue);
}
@SuppressWarnings("unused")
private session_flag_t() {
this.swigValue = SwigNext.next++;
}
@SuppressWarnings("unused")
private session_flag_t(int swigValue) {
this.swigValue = swigValue;
SwigNext.next = swigValue+1;
}
@SuppressWarnings("unused")
private session_flag_t(session_flag_t swigEnum) {
this.swigValue = swigEnum.swigValue;
SwigNext.next = this.swigValue+1;

File diff suppressed because it is too large Load Diff

View File

@ -21,8 +21,8 @@ freeswitch_lua.o: freeswitch_lua.h
allclean: clean luaclean
rm -f mod_lua_wrap.* freeswitch_lua.$(DYNAMIC_LIB_EXTEN)
swigclean:
rm mod_lua_wrap.*
swigclean: clean
rm -f mod_lua_wrap.*
mod_lua_wrap.cpp: mod_lua_extra.c
swig -lua -c++ -I../../../../src/include -oh mod_lua_wrap.h -o mod_lua_wrap.cpp freeswitch.i

View File

@ -12,6 +12,7 @@
/** insert the following includes into generated code so it compiles */
%{
#include "switch.h"
#include "switch_cpp.h"
#include "freeswitch_lua.h"
%}
@ -23,7 +24,7 @@
* tell swig to grok everything defined in these header files and
* build all sorts of c wrappers and lua shadows of the c wrappers.
*/
%include switch_cpp.h
%include switch_swigable_cpp.h
%include freeswitch_lua.h

View File

@ -1,26 +1,22 @@
#include <switch.h>
#include "freeswitch_lua.h"
SWITCH_BEGIN_EXTERN_C
#include "lua.h"
#include <lauxlib.h>
#include <lualib.h>
#include "mod_lua_extra.h"
SWITCH_END_EXTERN_C
Session::Session() : CoreSession()
{
cb_function = cb_arg = hangup_func_str = NULL;
hh = mark = 0;
}
Session::Session(char *uuid) : CoreSession(uuid)
{
cb_function = cb_arg = hangup_func_str = NULL;
hh = mark = 0;
}
Session::Session(switch_core_session_t *new_session) : CoreSession(new_session)
{
cb_function = cb_arg = hangup_func_str = NULL;
hh = mark = 0;
}
static switch_status_t lua_hanguphook(switch_core_session_t *session_hungup);
Session::~Session()
@ -31,31 +27,68 @@ Session::~Session()
switch_core_event_hook_remove_state_change(session, lua_hanguphook);
}
bool Session::begin_allow_threads()
{
do_hangup_hook();
return true;
}
bool Session::end_allow_threads()
{
do_hangup_hook();
return true;
}
void Session::setLUA(lua_State *state)
{
L = state;
}
lua_State *Session::getLUA()
{
if (!L) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh!\n");
}
return L;
}
bool Session::ready() {
bool r;
sanity_check(false);
r = switch_channel_ready(channel) != 0;
do_hangup_hook();
return r;
}
void Session::check_hangup_hook()
{
if (hangup_func_str && (hook_state == CS_HANGUP || hook_state == CS_RING)) {
lua_State *L;
L = (lua_State *) getPrivate("__L");
hh++;
}
}
if (!L) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh!\n");
void Session::do_hangup_hook()
{
if (hh && !mark) {
const char *err = NULL;
mark++;
if (!getLUA()) {
return;
}
lua_getfield(L, LUA_GLOBALSINDEX, (char *)hangup_func_str);
lua_pushstring(L, hook_state == CS_HANGUP ? "hangup" : "transfer");
lua_call(L, 1, 0);
lua_call(L, 1, 1);
err = lua_tostring(L, -1);
if (!switch_strlen_zero(err)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err);
}
}
}
@ -82,9 +115,6 @@ void Session::setHangupHook(char *func) {
switch_safe_free(hangup_func_str);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Not Currently Available\n");
func = NULL;
if (func) {
hangup_func_str = strdup(func);
switch_channel_set_private(channel, "CoreSession", this);
@ -106,7 +136,7 @@ void Session::setInputCallback(char *cbfunc, char *funcargs) {
if (funcargs) {
cb_arg = strdup(funcargs);
}
args.buf = this;
switch_channel_set_private(channel, "CoreSession", this);
@ -116,13 +146,10 @@ void Session::setInputCallback(char *cbfunc, char *funcargs) {
switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t itype)
{
lua_State *L;
const char *ret;
L = (lua_State *) getPrivate("__L");
if (!L) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh!\n");
return SWITCH_STATUS_FALSE;
if (!getLUA()) {
return SWITCH_STATUS_FALSE;;
}
switch (itype) {

View File

@ -1,25 +1,41 @@
#ifndef FREESWITCH_LUA_H
#define FREESWITCH_LUA_H
extern "C" {
#include "lua.h"
#include <lauxlib.h>
#include <lualib.h>
#include "mod_lua_extra.h"
}
#include <switch_cpp.h>
class Session : public CoreSession {
private:
virtual void do_hangup_hook();
lua_State *getLUA();
lua_State *L;
int hh;
int mark;
public:
Session();
Session(char *uuid);
Session(switch_core_session_t *session);
~Session();
virtual bool begin_allow_threads();
virtual bool end_allow_threads();
virtual void check_hangup_hook();
virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
void setInputCallback(char *cbfunc, char *funcargs);
void setHangupHook(char *func);
bool ready();
char *cb_function;
char *cb_arg;
char *hangup_func_str;
void setLUA(lua_State *state);
};
#endif

View File

@ -5,7 +5,7 @@
result = (Session *)new Session();
SWIG_arg=0;
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++;
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; result->setPrivate("__L", L);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; result->setLUA(L);
return SWIG_arg;
if(0) SWIG_fail;
@ -14,7 +14,7 @@
result = (Session *)new Session(arg1);
SWIG_arg=0;
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++;
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; result->setPrivate("__L", L);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; result->setLUA(L);
return SWIG_arg;
if(0) SWIG_fail;
@ -23,7 +23,7 @@
result = (Session *)new Session(arg1);
SWIG_arg=0;
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++;
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; result->setPrivate("__L", L);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; result->setLUA(L);
return SWIG_arg;
if(0) SWIG_fail;

View File

@ -2,8 +2,8 @@
#define MOD_LUA_EXTRA
SWITCH_BEGIN_EXTERN_C
int mod_lua_conjure_event(lua_State *L, switch_event_t *event, const char *name, int destroy_me);
int mod_lua_conjure_stream(lua_State *L, switch_stream_handle_t *stream, const char *name, int destroy_me);
void mod_lua_conjure_event(lua_State *L, switch_event_t *event, const char *name, int destroy_me);
void mod_lua_conjure_stream(lua_State *L, switch_stream_handle_t *stream, const char *name, int destroy_me);
SWITCH_END_EXTERN_C
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,196 @@
typedef struct input_callback_state {
void *function;
void *threadState;
void *extra;
char *funcargs;
} input_callback_state_t;
typedef enum {
S_HUP = (1 << 0),
S_FREE = (1 << 1),
S_RDLOCK = (1 << 2)
} session_flag_t;
class Stream {
protected:
switch_stream_handle_t mystream;
switch_stream_handle_t *stream_p;
int mine;
public:
Stream(void);
Stream(switch_stream_handle_t *);
virtual ~Stream();
void write(const char *data);
const char *get_data(void);
};
class Event {
protected:
public:
switch_event_t *event;
char *serialized_string;
int mine;
Event(const char *type, const char *subclass_name = NULL);
Event(switch_event_t *wrap_me, int free_me=0);
virtual ~Event();
const char *serialize(const char *format=NULL);
bool setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
char *getHeader(char *header_name);
char *getBody(void);
char *getType(void);
bool addBody(const char *value);
bool addHeader(const char *header_name, const char *value);
bool delHeader(const char *header_name);
bool fire(void);
};
class CoreSession {
protected:
switch_input_args_t args;
switch_input_args_t *ap;
switch_caller_profile_t caller_profile;
char *uuid;
char *tts_name;
char *voice_name;
void store_file_handle(switch_file_handle_t *fh);
void *on_hangup;
switch_file_handle_t local_fh;
switch_file_handle_t *fhp;
switch_status_t process_callback_result(char *ret);
public:
CoreSession();
CoreSession(char *uuid);
CoreSession(switch_core_session_t *new_session);
virtual ~CoreSession();
switch_core_session_t *session;
switch_channel_t *channel;
unsigned int flags;
int allocated;
input_callback_state cb_state;
switch_channel_state_t hook_state;
int answer();
int preAnswer();
virtual void hangup(char *cause = "normal_clearing");
void setVariable(char *var, char *val);
void setPrivate(char *var, void *val);
void *getPrivate(char *var);
const char *getVariable(char *var);
int recordFile(char *file_name, int max_len=0, int silence_threshold=0, int silence_secs=0);
void setCallerData(char *var, char *val);
int originate(CoreSession *a_leg_session,
char *dest,
int timeout=60);
void setDTMFCallback(void *cbfunc, char *funcargs);
int speak(char *text);
void set_tts_parms(char *tts_name, char *voice_name);
int collectDigits(int timeout);
int getDigits(char *dtmf_buf,
switch_size_t buflen,
switch_size_t maxdigits,
char *terminators,
char *terminator,
int timeout);
int transfer(char *extensions, char *dialplan, char *context);
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,
char *digits_regex);
int streamFile(char *file, int starting_sample_count=0);
int flushEvents();
int flushDigits();
int setAutoHangup(bool val);
void setHangupHook(void *hangup_func);
bool ready();
void execute(char *app, char *data);
void sendEvent(Event *sendME);
virtual bool begin_allow_threads() = 0;
virtual bool end_allow_threads() = 0;
char* get_uuid() const { return uuid; };
const switch_input_args_t& get_cb_args() const { return args; };
virtual void check_hangup_hook() = 0;
virtual switch_status_t run_dtmf_callback(void *input,
switch_input_type_t itype) = 0;
};
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);
void bridge(CoreSession &session_a, CoreSession &session_b);
switch_status_t hanguphook(switch_core_session_t *session);
switch_status_t dtmf_callback(switch_core_session_t *session,
void *input,
switch_input_type_t itype,
void *buf,
unsigned int buflen);

View File

@ -9,10 +9,11 @@ VERBOSE=1
include $(BASE)/build/modmake.rules
swigclean: clean
rm mod_perl_wrap.*
mod_perl_wrap.cpp: $(TOLUA_A)
swigclean: clean
rm -f mod_perl_wrap.*
mod_perl_wrap.cpp:
swig -static -shadow -perl5 -c++ -DMULTIPLICITY -I../../../../src/include -o mod_perl_wrap.cpp freeswitch.i
freeswitch.$(DYNAMIC_LIB_EXTEN): $(LOCAL_OBJS) $(LOCAL_LIBADD)

View File

@ -23,7 +23,7 @@
* tell swig to grok everything defined in these header files and
* build all sorts of c wrappers and lua shadows of the c wrappers.
*/
%include switch_cpp.h
%include switch_swigable_cpp.h
%include freeswitch_perl.h

View File

@ -171,12 +171,13 @@ sub DESTROY {
}
*serialize = *freeswitchc::Event_serialize;
*set_priority = *freeswitchc::Event_set_priority;
*get_header = *freeswitchc::Event_get_header;
*get_body = *freeswitchc::Event_get_body;
*add_body = *freeswitchc::Event_add_body;
*add_header = *freeswitchc::Event_add_header;
*del_header = *freeswitchc::Event_del_header;
*setPriority = *freeswitchc::Event_setPriority;
*getHeader = *freeswitchc::Event_getHeader;
*getBody = *freeswitchc::Event_getBody;
*getType = *freeswitchc::Event_getType;
*addBody = *freeswitchc::Event_addBody;
*addHeader = *freeswitchc::Event_addHeader;
*delHeader = *freeswitchc::Event_delHeader;
*fire = *freeswitchc::Event_fire;
sub DISOWN {
my $self = shift;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.31
# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
# This file is compatible with both classic and new-style classes.
@ -48,10 +48,6 @@ except AttributeError:
del types
console_log = _freeswitch.console_log
console_clean_log = _freeswitch.console_clean_log
api_execute = _freeswitch.api_execute
api_reply_delete = _freeswitch.api_reply_delete
class input_callback_state_t(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, input_callback_state_t, name, value)
@ -121,12 +117,13 @@ class Event(_object):
__swig_destroy__ = _freeswitch.delete_Event
__del__ = lambda self : None;
def serialize(*args): return _freeswitch.Event_serialize(*args)
def set_priority(*args): return _freeswitch.Event_set_priority(*args)
def get_header(*args): return _freeswitch.Event_get_header(*args)
def get_body(*args): return _freeswitch.Event_get_body(*args)
def add_body(*args): return _freeswitch.Event_add_body(*args)
def add_header(*args): return _freeswitch.Event_add_header(*args)
def del_header(*args): return _freeswitch.Event_del_header(*args)
def setPriority(*args): return _freeswitch.Event_setPriority(*args)
def getHeader(*args): return _freeswitch.Event_getHeader(*args)
def getBody(*args): return _freeswitch.Event_getBody(*args)
def getType(*args): return _freeswitch.Event_getType(*args)
def addBody(*args): return _freeswitch.Event_addBody(*args)
def addHeader(*args): return _freeswitch.Event_addHeader(*args)
def delHeader(*args): return _freeswitch.Event_delHeader(*args)
def fire(*args): return _freeswitch.Event_fire(*args)
Event_swigregister = _freeswitch.Event_swigregister
Event_swigregister(Event)
@ -136,7 +133,7 @@ class CoreSession(_object):
__setattr__ = lambda self, name, value: _swig_setattr(self, CoreSession, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, CoreSession, name)
def __init__(self): raise AttributeError, "No constructor defined"
def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
__swig_destroy__ = _freeswitch.delete_CoreSession
__del__ = lambda self : None;
@ -192,6 +189,10 @@ class CoreSession(_object):
CoreSession_swigregister = _freeswitch.CoreSession_swigregister
CoreSession_swigregister(CoreSession)
console_log = _freeswitch.console_log
console_clean_log = _freeswitch.console_clean_log
api_execute = _freeswitch.api_execute
api_reply_delete = _freeswitch.api_reply_delete
bridge = _freeswitch.bridge
hanguphook = _freeswitch.hanguphook
dtmf_callback = _freeswitch.dtmf_callback

View File

@ -23,7 +23,7 @@
* tell swig to grok everything defined in these header files and
* build all sorts of c wrappers and python shadows of the c wrappers.
*/
%include switch_cpp.h
%include switch_swigable_cpp.h
%include freeswitch_python.h

File diff suppressed because it is too large Load Diff

View File

@ -120,7 +120,7 @@ SWITCH_DECLARE(bool) Event::fire(void)
return false;
}
SWITCH_DECLARE(bool) Event::set_priority(switch_priority_t priority)
SWITCH_DECLARE(bool) Event::setPriority(switch_priority_t priority)
{
if (event) {
switch_event_set_priority(event, priority);
@ -129,7 +129,7 @@ SWITCH_DECLARE(bool) Event::set_priority(switch_priority_t priority)
return false;
}
SWITCH_DECLARE(char *)Event::get_header(char *header_name)
SWITCH_DECLARE(char *)Event::getHeader(char *header_name)
{
if (event) {
return switch_event_get_header(event, header_name);
@ -137,7 +137,7 @@ SWITCH_DECLARE(char *)Event::get_header(char *header_name)
return NULL;
}
SWITCH_DECLARE(bool) Event::add_header(const char *header_name, const char *value)
SWITCH_DECLARE(bool) Event::addHeader(const char *header_name, const char *value)
{
if (event) {
return switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, value) == SWITCH_STATUS_SUCCESS ? true : false;
@ -146,7 +146,7 @@ SWITCH_DECLARE(bool) Event::add_header(const char *header_name, const char *valu
return false;
}
SWITCH_DECLARE(bool) Event::del_header(const char *header_name)
SWITCH_DECLARE(bool) Event::delHeader(const char *header_name)
{
if (event) {
return switch_event_del_header(event, header_name) == SWITCH_STATUS_SUCCESS ? true : false;
@ -156,7 +156,7 @@ SWITCH_DECLARE(bool) Event::del_header(const char *header_name)
}
SWITCH_DECLARE(bool) Event::add_body(const char *value)
SWITCH_DECLARE(bool) Event::addBody(const char *value)
{
if (event) {
return switch_event_add_body(event, "%s", value) == SWITCH_STATUS_SUCCESS ? true : false;
@ -165,7 +165,7 @@ SWITCH_DECLARE(bool) Event::add_body(const char *value)
return false;
}
SWITCH_DECLARE(char *)Event::get_body(void)
SWITCH_DECLARE(char *)Event::getBody(void)
{
if (event) {
return switch_event_get_body(event);
@ -174,6 +174,15 @@ SWITCH_DECLARE(char *)Event::get_body(void)
return NULL;
}
SWITCH_DECLARE(char *)Event::getType(void)
{
if (event) {
return switch_event_name(event->event_id);
}
return "invalid";
}
SWITCH_DECLARE_CONSTRUCTOR Stream::Stream()
{
SWITCH_STANDARD_STREAM(mystream);
@ -520,21 +529,11 @@ SWITCH_DECLARE(int) CoreSession::streamFile(char *file, int starting_sample_coun
SWITCH_DECLARE(bool) CoreSession::ready() {
switch_channel_t *channel;
if (!session) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "You must call the session.originate method before calling this method!\n");
return false;
}
channel = switch_core_session_get_channel(session);
sanity_check(false);
return switch_channel_ready(channel) != 0;
}
SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session,
char *dest,
int timeout)
SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session, char *dest, int timeout)
{
switch_memory_pool_t *pool = NULL;