From 8311b9a01a3024a58123d7d6e8881ffd9c2215c2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 6 Dec 2005 17:18:56 +0000 Subject: [PATCH] iax and empty core for opal git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@86 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- modules.conf | 5 ++-- src/include/switch_loadable_module.h | 1 + src/include/switch_types.h | 3 +- src/include/switch_utils.h | 3 +- src/mod/mod_exosip/mod_exosip.c | 16 +++++----- src/switch_channel.c | 4 +++ src/switch_loadable_module.c | 14 +++++++++ src/switch_utils.c | 44 ++++++++++++++++++++++++++++ 8 files changed, 78 insertions(+), 12 deletions(-) diff --git a/modules.conf b/modules.conf index dfaa64d96c..f85c99176d 100644 --- a/modules.conf +++ b/modules.conf @@ -2,11 +2,12 @@ mod_bridgecall mod_dialplan_demo mod_softtimer -mod_woomerachan +#mod_woomerachan mod_playback #mod_wanchan mod_speexcodec mod_exosip mod_g711codec mod_rawaudio -mod_opalchan +mod_iaxchan +#mod_opalchan diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index a2692a8d65..20de1ff294 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -55,6 +55,7 @@ SWITCH_DECLARE(switch_dialplan_interface *) loadable_module_get_dialplan_interfa SWITCH_DECLARE(switch_timer_interface *) loadable_module_get_timer_interface(char *name); SWITCH_DECLARE(switch_application_interface *) loadable_module_get_application_interface(char *name); SWITCH_DECLARE(int) loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array, int arraylen); +SWITCH_DECLARE(int) loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen); SWITCH_DECLARE(void) loadable_module_shutdown(void); #ifdef __cplusplus diff --git a/src/include/switch_types.h b/src/include/switch_types.h index fc015cf985..a45be31339 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -44,7 +44,8 @@ extern "C" { //#include //#include -#define SWITCH_GLOBAL_VERSION "1.5" +#define SWITCH_GLOBAL_VERSION "1" +#define SWITCH_MAX_CODECS 30 typedef enum { SWITCH_STATUS_SUCCESS, diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 5a2840099f..05a3cb8c0e 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -79,9 +79,10 @@ typedef typeof(tv.tv_usec) switch_suseconds_t; #define switch_strlen_zero(s) (s && *s != '\0') ? 0 : 1 #define switch_yield(ms) apr_sleep(ms * 10); apr_thread_yield(); +SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen); SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, unsigned int flags, switch_memory_pool *pool); SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms); - +SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len); #if !defined(switch_strdupa) && defined(__GNUC__) # define switch_strdupa(s) \ diff --git a/src/mod/mod_exosip/mod_exosip.c b/src/mod/mod_exosip/mod_exosip.c index 8e54c9ce3f..128fb38130 100644 --- a/src/mod/mod_exosip/mod_exosip.c +++ b/src/mod/mod_exosip/mod_exosip.c @@ -230,7 +230,7 @@ static switch_status exosip_on_init(switch_core_session *session) if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) { char *dest_uri; - switch_codec_interface *codecs[512]; + switch_codec_interface *codecs[SWITCH_MAX_CODECS]; int num_codecs = 0; /* do SIP Goodies...*/ @@ -592,7 +592,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram } switch_clear_flag(tech_pvt, TFLAG_READING); - + if (switch_test_flag(tech_pvt, TFLAG_BYE)) { switch_channel_hangup(channel); return SWITCH_STATUS_FALSE; @@ -751,7 +751,6 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) switch_yield(1000); } } - eXosip_quit(); return SWITCH_STATUS_SUCCESS; } @@ -785,7 +784,7 @@ static switch_status exosip_create_call(eXosip_event_t *event) if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL))) { struct private_object *tech_pvt; - switch_codec_interface *codecs[512]; + switch_codec_interface *codecs[SWITCH_MAX_CODECS]; int num_codecs = 0; @@ -1374,15 +1373,16 @@ static int config_exosip(int reload) switch_console_printf(SWITCH_CHANNEL_CONSOLE, "eXosip_listen_addr failed!\n"); return SWITCH_STATUS_GENERR; } - + switch_mutex_init(&globals.port_lock, SWITCH_MUTEX_NESTED, module_pool); - /* Setup the user agent */ - eXosip_set_user_agent("OPENSWITCH 2.0"); - + eXosip_set_user_agent("FreeSWITCH"); monitor_thread_run(); + + eXosip_quit(); + return 0; } diff --git a/src/switch_channel.c b/src/switch_channel.c index a53afb4036..acce3e909e 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -241,6 +241,10 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch return state; } + if (last_state >= CS_HANGUP) { + return last_state; + } + /* STUB for more dev case CS_INIT: switch(state) { diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index c7b603f627..1d0ea912c6 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -367,3 +367,17 @@ SWITCH_DECLARE(int) loadable_module_get_codecs(switch_memory_pool *pool, switch_ return i; } + +SWITCH_DECLARE(int) loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen) +{ + int x, i = 0; + switch_codec_interface *codec_interface; + + for(x = 0; x < preflen; x++) { + if ((codec_interface = loadable_module_get_codec_interface(prefs[x]))) { + array[i++] = codec_interface; + } + } + + return i; +} diff --git a/src/switch_utils.c b/src/switch_utils.c index 3a69e4fd00..8ba5503a12 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -31,6 +31,50 @@ */ #include +SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len) +{ + int i; + for (i = 0; i < len; i++) { + buf[i] = ((buf[i] >> 8) & 0x00ff) | ((buf[i] << 8) & 0xff00); + } +} + + +SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen) +{ + int argc; + char *scan; + int paren = 0; + + if (!buf || !array || !arraylen) { + return 0; + } + + memset(array, 0, arraylen * sizeof(*array)); + + scan = buf; + + for (argc = 0; *scan && (argc < arraylen - 1); argc++) { + array[argc] = scan; + for (; *scan; scan++) { + if (*scan == '(') + paren++; + else if (*scan == ')') { + if (paren) + paren--; + } else if ((*scan == delim) && !paren) { + *scan++ = '\0'; + break; + } + } + } + + if (*scan) { + array[argc++] = scan; + } + + return argc; +} SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, unsigned int flags, switch_memory_pool *pool) {