Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch

This commit is contained in:
Giovanni Maruzzelli
2011-05-21 02:37:38 -05:00
76 changed files with 2102 additions and 519 deletions
-2
View File
@@ -9,8 +9,6 @@
/applications/mod_conference/Makefile
/applications/mod_db/Makefile
/applications/mod_dptools/Makefile
/applications/mod_enum/Makefile
/applications/mod_enum/Makefile.in
/applications/mod_enum/mod_enum.log
/applications/mod_expr/Makefile
/applications/mod_expr/Makefile.in
@@ -1985,12 +1985,12 @@ static int members_callback(void *pArg, int argc, char **argv, char **columnName
/* Checking for cleanup Abandonded calls from the db */
if (!strcasecmp(member_state, cc_member_state2str(CC_MEMBER_STATE_ABANDONED))) {
long abandoned_epoch = atol(member_abandoned_epoch);
switch_time_t abandoned_epoch = atoll(member_abandoned_epoch);
if (abandoned_epoch == 0) {
abandoned_epoch = atol(cbt.member_joined_epoch);
abandoned_epoch = atoll(cbt.member_joined_epoch);
}
/* Once we pass a certain point, we want to get rid of the abandoned call */
if (abandoned_epoch + discard_abandoned_after < (long) local_epoch_time_now(NULL)) {
if (abandoned_epoch + discard_abandoned_after < local_epoch_time_now(NULL)) {
sql = switch_mprintf("DELETE FROM members WHERE system = 'single_box' AND uuid = '%q' AND (abandoned_epoch = '%" SWITCH_TIME_T_FMT "' OR joined_epoch = '%q')", cbt.member_uuid, abandoned_epoch, cbt.member_joined_epoch);
cc_execute_sql(NULL, sql, NULL);
switch_safe_free(sql);
@@ -200,7 +200,6 @@ typedef enum {
EFLAG_FLOOR_CHANGE = (1 << 25),
EFLAG_MUTE_DETECT = (1 << 26),
EFLAG_RECORD = (1 << 27),
EFLAG_AUTO_GAIN_LEVEL = (1 << 28)
} event_type_t;
typedef struct conference_file_node {
@@ -815,12 +814,19 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe
switch_event_t *event;
conference_file_node_t *member_fnode;
switch_speech_handle_t *member_sh;
const char *exit_sound = NULL;
switch_assert(conference != NULL);
switch_assert(member != NULL);
switch_thread_rwlock_wrlock(member->rwlock);
if (member->session && (exit_sound = switch_channel_get_variable(switch_core_session_get_channel(member->session), "conference_exit_sound"))) {
conference_play_file(conference, (char *)exit_sound, CONF_DEFAULT_LEADIN,
switch_core_session_get_channel(member->session), !switch_test_flag(conference, CFLAG_WAIT_MOD) ? 0 : 1);
}
lock_member(member);
member_fnode = member->fnode;
member_sh = member->sh;
@@ -910,7 +916,7 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe
|| (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0)) {
switch_set_flag(conference, CFLAG_DESTRUCT);
} else {
if (conference->exit_sound && switch_test_flag(conference, CFLAG_EXIT_SOUND)) {
if (!exit_sound && conference->exit_sound && switch_test_flag(conference, CFLAG_EXIT_SOUND)) {
conference_play_file(conference, conference->exit_sound, 0, switch_core_session_get_channel(member->session), 0);
}
if (conference->count == 1 && conference->alone_sound && !switch_test_flag(conference, CFLAG_WAIT_MOD)) {
@@ -2056,7 +2062,7 @@ static void clear_avg(conference_member_t *member)
static void check_agc_levels(conference_member_t *member)
{
int x = 0, y = member->agc_volume_in_level;
int x = 0;
if (!member->avg_score) return;
@@ -2071,8 +2077,6 @@ static void check_agc_levels(conference_member_t *member)
}
if (x) {
switch_event_t *event;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7,
"AGC %s:%d diff:%d level:%d cur:%d avg:%d vol:%d %s\n",
member->conference->name,
@@ -2080,17 +2084,6 @@ static void check_agc_levels(conference_member_t *member)
member->score, member->avg_score, member->agc_volume_in_level, x > 0 ? "+++" : "---");
clear_avg(member);
if (test_eflag(member->conference, EFLAG_AUTO_GAIN_LEVEL) &&
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "auto-gain-level");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Level", "%d", y);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->agc_volume_in_level);
switch_event_fire(&event);
}
}
}
+2 -2
View File
@@ -1664,7 +1664,7 @@ static void write_data(switch_stream_handle_t *stream, switch_bool_t as_xml, con
SWITCH_STANDARD_API(dialplan_lcr_function)
{
char *argv[4] = { 0 };
char *argv[9] = { 0 };
int argc;
char *mydata = NULL;
//char *dialstring = NULL;
@@ -1825,7 +1825,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function)
if (as_xml) {
event_xml = switch_event_xmlize(current->fields, SWITCH_VA_NONE);
event_str = switch_xml_toxml(event_xml, SWITCH_FALSE);
stream->write_function(stream, event_str);
stream->write_function(stream, "%s", event_str);
switch_xml_free(event_xml);
switch_safe_free(event_str);
}
+29
View File
@@ -0,0 +1,29 @@
BASE=../../../..
MONGO_CXX_DRIVER_VERSION=v1.8
MONGO_CXX_DRIVER_URL=http://downloads.mongodb.org/cxx-driver
MONGO_CXX_DRIVER_TARBALL=mongodb-linux-x86_64-$(MONGO_CXX_DRIVER_VERSION)-latest.tgz
MONGO_CXX_DRIVER_SRC=$(BASE)/libs/mongo-cxx-driver-$(MONGO_CXX_DRIVER_VERSION)
LIBMONGOCLIENT_A =$(MONGO_CXX_DRIVER_SRC)/libmongoclient.a
LOCAL_SOURCES=mongo_conn.cpp
LOCAL_OBJS=mongo_conn.o
LOCAL_CFLAGS=-I$(MONGO_CXX_DRIVER_SRC)/mongo
LOCAL_LIBADD=$(LIBMONGOCLIENT_A)
LOCAL_LDFLAGS=-lboost_thread -lboost_filesystem-mt -lboost_system-mt
MODDIR=$(shell pwd)
include $(BASE)/build/modmake.rules
$(MONGO_CXX_DRIVER_SRC):
$(GETLIB) $(MONGO_CXX_DRIVER_URL) $(MONGO_CXX_DRIVER_TARBALL)
cd $(MONGO_CXX_DRIVER_SRC) && patch -p0 -i $(MODDIR)/fpic_hack.diff
$(TOUCH_TARGET)
$(LIBMONGOCLIENT_A): $(MONGO_CXX_DRIVER_SRC)
cd $(MONGO_CXX_DRIVER_SRC) && scons
$(TOUCH_TARGET)
@@ -0,0 +1,11 @@
--- SConstruct.orig 2011-04-28 19:00:36.000000000 +0200
+++ SConstruct 2011-04-28 19:01:19.000000000 +0200
@@ -45,7 +45,7 @@
linux = True
if nix:
- env.Append( CPPFLAGS=" -O3" )
+ env.Append( CPPFLAGS=" -I../pcre -fPIC -O3" )
env.Append( LIBS=["pthread"] )
if linux:
env.Append( LINKFLAGS=" -Wl,--as-needed -Wl,-zdefs " )
@@ -0,0 +1,151 @@
#include <switch.h>
#include "mod_mongo.h"
static struct {
mongo_connection_pool_t *conn_pool;
} globals;
static const char *SYNTAX = "mongo_find_one ns; query; fields";
SWITCH_STANDARD_API(mongo_find_one_function)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
char *ns = NULL, *json_query = NULL, *json_fields = NULL;
char delim = ';';
ns = strdup(cmd);
switch_assert(ns != NULL);
if ((json_query = strchr(ns, delim))) {
*json_query++ = '\0';
if ((json_fields = strchr(json_query, delim))) {
*json_fields++ = '\0';
}
}
if (!zstr(ns) && !zstr(json_query) && !zstr(json_fields)) {
DBClientConnection *conn = NULL;
try {
BSONObj query = fromjson(json_query);
BSONObj fields = fromjson(json_fields);
conn = mongo_connection_pool_get(globals.conn_pool);
if (conn) {
BSONObj res = conn->findOne(ns, Query(query), &fields);
mongo_connection_pool_put(globals.conn_pool, conn);
stream->write_function(stream, "-OK\n%s\n", res.toString().c_str());
} else {
stream->write_function(stream, "-ERR\nNo connection\n");
}
} catch (DBException &e) {
if (conn) {
mongo_connection_destroy(&conn);
}
stream->write_function(stream, "-ERR\n%s\n", e.toString().c_str());
}
} else {
stream->write_function(stream, "-ERR\n%s\n", SYNTAX);
}
switch_safe_free(ns);
return status;
}
static switch_status_t config(void)
{
const char *cf = "mongo.conf";
switch_xml_t cfg, xml, settings, param;
switch_status_t status = SWITCH_STATUS_SUCCESS;
const char *host = "127.0.0.1";
switch_size_t min_connections = 1, max_connections = 1;
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
return SWITCH_STATUS_GENERR;
}
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
int tmp;
if (!strcmp(var, "host")) {
host = val;
} else if (!strcmp(var, "min-connections")) {
if ((tmp = atoi(val)) > 0) {
min_connections = tmp;
}
} else if (!strcmp(var, "max-connections")) {
if ((tmp = atoi(val)) > 0) {
max_connections = tmp;
}
}
}
}
if (mongo_connection_pool_create(&globals.conn_pool, min_connections, max_connections, host) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Can't create connection pool\n");
status = SWITCH_STATUS_GENERR;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Mongo connection pool created [%s %d/%d]\n", host, (int)min_connections, (int)max_connections);
}
switch_xml_free(xml);
return status;
}
SWITCH_BEGIN_EXTERN_C
SWITCH_MODULE_LOAD_FUNCTION(mod_mongo_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_mongo_shutdown);
SWITCH_MODULE_DEFINITION(mod_mongo, mod_mongo_load, mod_mongo_shutdown, NULL);
SWITCH_MODULE_LOAD_FUNCTION(mod_mongo_load)
{
switch_api_interface_t *api_interface;
switch_application_interface_t *app_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
memset(&globals, 0, sizeof(globals));
if (config() != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_TERM;
}
SWITCH_ADD_API(api_interface, "mongo_find_one", "mongo", mongo_find_one_function, SYNTAX);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_mongo_shutdown)
{
mongo_connection_pool_destroy(&globals.conn_pool);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_END_EXTERN_C
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4
*/
@@ -0,0 +1,38 @@
#ifndef MOD_MONGO_H
#define MOD_MONGO_H
#include <client/dbclient.h>
#include <client/connpool.h>
#include <db/json.h>
#include <bson/bson.h>
using namespace mongo;
typedef struct {
char *host;
switch_size_t min_connections;
switch_size_t max_connections;
switch_size_t size;
switch_queue_t *connections;
switch_mutex_t *mutex;
switch_memory_pool_t *pool;
} mongo_connection_pool_t;
switch_status_t mongo_connection_create(DBClientConnection **connection, const char *host);
void mongo_connection_destroy(DBClientConnection **conn);
switch_status_t mongo_connection_pool_create(mongo_connection_pool_t **conn_pool, switch_size_t min_connections, switch_size_t max_connections,
const char *host);
void mongo_connection_pool_destroy(mongo_connection_pool_t **conn_pool);
DBClientConnection *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool);
switch_status_t mongo_connection_pool_put(mongo_connection_pool_t *conn_pool, DBClientConnection *conn);
#endif
@@ -0,0 +1,161 @@
#include <switch.h>
#include "mod_mongo.h"
/*
we could use the driver's connection pool,
if we could set the max connections (PoolForHost::setMaxPerHost)
ScopedDbConnection scoped_conn("host");
DBClientConnection *conn = dynamic_cast< DBClientConnection* >(&scoped_conn.conn());
scoped_conn.done();
*/
switch_status_t mongo_connection_create(DBClientConnection **connection, const char *host)
{
DBClientConnection *conn = new DBClientConnection();
try {
conn->connect(host);
} catch (DBException &e) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect to mongo [%s]\n", host);
return SWITCH_STATUS_GENERR;
}
*connection = conn;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to mongo [%s]\n", host);
return SWITCH_STATUS_SUCCESS;
}
void mongo_connection_destroy(DBClientConnection **conn)
{
switch_assert(*conn != NULL);
delete *conn;
*conn = NULL;
}
switch_status_t mongo_connection_pool_create(mongo_connection_pool_t **conn_pool, switch_size_t min_connections, switch_size_t max_connections,
const char *host)
{
switch_memory_pool_t *pool = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
mongo_connection_pool_t *cpool = NULL;
DBClientConnection *conn = NULL;
if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
return status;
}
if (!(cpool = (mongo_connection_pool_t *)switch_core_alloc(pool, sizeof(mongo_connection_pool_t)))) {
switch_goto_status(SWITCH_STATUS_MEMERR, done);
}
if ((status = switch_mutex_init(&cpool->mutex, SWITCH_MUTEX_NESTED, pool)) != SWITCH_STATUS_SUCCESS) {
goto done;
}
if ((status = switch_queue_create(&cpool->connections, max_connections, pool)) != SWITCH_STATUS_SUCCESS) {
goto done;
}
cpool->min_connections = min_connections;
cpool->max_connections = max_connections;
cpool->host = switch_core_strdup(pool, host);
cpool->pool = pool;
for (cpool->size = 0; cpool->size < min_connections; cpool->size++) {
if (mongo_connection_create(&conn, host) == SWITCH_STATUS_SUCCESS) {
mongo_connection_pool_put(cpool, conn);
} else {
break;
}
}
done:
if (status == SWITCH_STATUS_SUCCESS) {
*conn_pool = cpool;
} else {
switch_core_destroy_memory_pool(&pool);
}
return status;
}
void mongo_connection_pool_destroy(mongo_connection_pool_t **conn_pool)
{
mongo_connection_pool_t *cpool = *conn_pool;
void *data = NULL;
switch_assert(cpool != NULL);
while (switch_queue_trypop(cpool->connections, &data) == SWITCH_STATUS_SUCCESS) {
mongo_connection_destroy((DBClientConnection **)&data);
}
switch_mutex_destroy(cpool->mutex);
switch_core_destroy_memory_pool(&cpool->pool);
*conn_pool = NULL;
}
DBClientConnection *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool)
{
DBClientConnection *conn = NULL;
void *data = NULL;
switch_assert(conn_pool != NULL);
switch_mutex_lock(conn_pool->mutex);
if (switch_queue_trypop(conn_pool->connections, &data) == SWITCH_STATUS_SUCCESS) {
conn = (DBClientConnection *) data;
} else if (mongo_connection_create(&conn, conn_pool->host) == SWITCH_STATUS_SUCCESS) {
if (++conn_pool->size > conn_pool->max_connections) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Connection pool is empty. You may want to increase 'max-connections'\n");
}
}
switch_mutex_unlock(conn_pool->mutex);
#ifdef MONGO_POOL_DEBUG
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL get: size %d conn: %p\n", (int) switch_queue_size(conn_pool->connections), conn);
#endif
return conn;
}
switch_status_t mongo_connection_pool_put(mongo_connection_pool_t *conn_pool, DBClientConnection *conn)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_assert(conn_pool != NULL);
switch_assert(conn != NULL);
switch_mutex_lock(conn_pool->mutex);
if (conn_pool->size > conn_pool->max_connections) {
#ifdef MONGO_POOL_DEBUG
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: Destroy connection %p\n", conn);
#endif
mongo_connection_destroy(&conn);
conn_pool->size--;
} else {
#ifdef MONGO_POOL_DEBUG
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: push connection %p\n", conn);
#endif
status = switch_queue_push(conn_pool->connections, conn);
}
switch_mutex_unlock(conn_pool->mutex);
#ifdef MONGO_POOL_DEBUG
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POOL: put size %d conn: %p\n", (int) switch_queue_size(conn_pool->connections), conn);
#endif
return status;
}
@@ -902,7 +902,7 @@ switch_state_handler_table_t nibble_state_handler = {
/* on_hibernate */ NULL,
/* on_reset */ NULL,
/* on_park */ NULL,
/* on_reporting */ process_hangup, /* force billing event on b-leg if we can */
/* on_reporting */ NULL,
/* on_destroy */ NULL
};
@@ -96,7 +96,7 @@ vocallo_codec_t g_codec_map[] =
/* manually initialized */
{ SNGTC_CODEC_GSM_FR, IANA_GSM_A_8000_1, "GSM", "Sangoma GSM", 20, 13200, 20000, 160, 320, 33, 8000, 8000, 0 },
{ SNGTC_CODEC_G723_1_63, IANA_G723_A_8000_1, "G723", "Sangoma G723", 90, 6300, 30000, 240, 480, 24, 8000, 8000, 0 },
{ SNGTC_CODEC_AMR_1220, IANA_AMR_WB_16000_1, "AMR", "Sangoma AMR", 20, 12200, 20000, 160, 320, 0, 8000, 8000, 0 },
{ SNGTC_CODEC_AMR_1220, IANA_AMR_A_8000_1, "AMR", "Sangoma AMR", 20, 12200, 20000, 160, 320, 0, 8000, 8000, 0 },
{ SNGTC_CODEC_SIREN7_24, IANA_SIREN7, "G7221", "Sangoma G722.1", 20, 24000, 20000, 320, 640, 60, 16000, 16000, 0 },
{ SNGTC_CODEC_SIREN7_32, IANA_SIREN7, "G7221", "Sangoma G722.1", 20, 32000, 20000, 320, 640, 80, 16000, 16000, 0 },
{ SNGTC_CODEC_ILBC_133, IANA_ILBC_133_8000_1, "iLBC", "Sangoma iLBC", 30, 13300, 30000, 240, 480, 50, 8000, 8000, 0 },
@@ -131,6 +131,7 @@ struct codec_data {
/* packet counters */
unsigned long tx;
unsigned long rx;
unsigned long ticks;
/* Lost packets */
long lastrxseqno;
@@ -467,6 +468,8 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
func_start_time = switch_micro_time_now();
}
sess->encoder.ticks++;
/* start assuming we will not encode anything */
*encoded_data_len = 0;
@@ -547,7 +550,7 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
continue;
}
if (encoded_frame.datalen != codec->implementation->encoded_bytes_per_packet) {
if (codec->implementation->encoded_bytes_per_packet && encoded_frame.datalen != codec->implementation->encoded_bytes_per_packet) {
/* seen when silence suppression is enabled */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ignoring encoded frame of %d bytes intead of %d bytes\n", encoded_frame.datalen, codec->implementation->encoded_bytes_per_packet);
continue;
@@ -619,7 +622,7 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
sess->encoder.rtp_queue[sess->encoder.queue_rindex].datalen = 0;
SAFE_INDEX_INC(sess->encoder.rtp_queue, sess->encoder.queue_rindex);
sess->encoder.queue_size--;
if (*encoded_data_len != codec->implementation->encoded_bytes_per_packet) {
if (codec->implementation->encoded_bytes_per_packet && *encoded_data_len != codec->implementation->encoded_bytes_per_packet) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Returning odd encoded frame of %d bytes intead of %d bytes\n", *encoded_data_len, codec->implementation->encoded_bytes_per_packet);
}
} else {
@@ -667,6 +670,7 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
}
dbuf_linear = decoded_data;
sess->decoder.ticks++;
/* start assuming we will not decode anything */
*decoded_data_len = 0;
@@ -989,6 +993,7 @@ SWITCH_STANDARD_API(sangoma_function)
stream->write_function(stream, "Rx %s at %d.%d.%d.%d:%d from %d.%d.%d.%d:%d\n\n", sess->impl->iananame, SNGTC_NIPV4(sess->encoder.reply.b.host_ip), sess->encoder.reply.b.host_udp_port,
SNGTC_NIPV4(sess->encoder.reply.b.codec_ip), sess->encoder.reply.b.codec_udp_port);
stream->write_function(stream, "Ticks: %lu\n", sess->encoder.ticks);
stream->write_function(stream, "-- Inbound Stats --\n");
stream->write_function(stream, "Rx Discarded: %lu\n", sess->encoder.rxdiscarded);
@@ -1008,6 +1013,7 @@ SWITCH_STANDARD_API(sangoma_function)
SNGTC_NIPV4(sess->decoder.reply.a.codec_ip), sess->decoder.reply.a.codec_udp_port);
stream->write_function(stream, "Rx L16 at %d.%d.%d.%d:%d from %d.%d.%d.%d:%d\n\n", SNGTC_NIPV4(sess->decoder.reply.b.host_ip), sess->decoder.reply.b.host_udp_port,
SNGTC_NIPV4(sess->decoder.reply.b.codec_ip), sess->decoder.reply.b.codec_udp_port);
stream->write_function(stream, "Ticks: %lu\n", sess->decoder.ticks);
stream->write_function(stream, "-- Inbound Stats --\n");
stream->write_function(stream, "Rx Discarded: %lu\n", sess->decoder.rxdiscarded);
@@ -30,6 +30,7 @@
*
*/
#include <switch.h>
#include <switch_ssl.h>
#include <switch_stun.h>
#include <libdingaling.h>
@@ -1399,7 +1400,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
{
struct private_object *tech_pvt = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
int payload = 0;
//int payload = 0;
tech_pvt = (struct private_object *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
@@ -1443,7 +1444,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
payload = tech_pvt->read_frame.payload;
//payload = tech_pvt->read_frame.payload;
#if 0
elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000);
@@ -1911,6 +1912,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dingaling_load)
SWITCH_ADD_API(api_interface, "dingaling", "DingaLing Menu", dingaling, DINGALING_SYNTAX);
SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send);
switch_ssl_init_ssl_locks();
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
@@ -2008,6 +2012,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dingaling_shutdown)
switch_safe_free(globals.codec_string);
switch_safe_free(globals.codec_rates_string);
switch_ssl_destroy_ssl_locks();
return SWITCH_STATUS_SUCCESS;
}
+1 -13
View File
@@ -1,13 +1 @@
faststart and codecs v CallProceeding due to h323plus, grep "Very Frustrating - S.H." in h323plus
source and uncomment commented lines.
exploration form developer of h323plus:
Yes that should be mera.
The problem is that Callproceeding does not always come from the remote it
may be generated by the gatekeeper. MERA where sending fast start elements
in the Call proceeding and connect. The call proceeding where not valid and
causing the media to fail. Normally (although valid) EP's do not set Fast
Start in Call proceeding so the code was disabled to resolve the MERA issue.
seems none for now
+7 -2
View File
@@ -1241,6 +1241,7 @@ static void start_udptl(private_object_t *tech_pvt, switch_t38_options_t *t38_op
switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->rtp_session);
const char *err, *val;
sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
switch_rtp_udptl_mode(tech_pvt->rtp_session);
if (!t38_options || !t38_options->remote_ip) {
@@ -1527,8 +1528,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
}
if (sofia_test_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE)) {
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
if (!switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_UDPTL) &&
!switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
}
sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
}
@@ -2153,6 +2157,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (t38_options) {
sofia_glue_set_image_sdp(tech_pvt, t38_options, 0);
if (switch_rtp_ready(tech_pvt->rtp_session)) {
sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
switch_rtp_udptl_mode(tech_pvt->rtp_session);
}
}
+1 -7
View File
@@ -4514,6 +4514,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU) && has_t38) {
if (switch_rtp_ready(tech_pvt->rtp_session) && switch_rtp_ready(other_tech_pvt->rtp_session)) {
sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
switch_rtp_udptl_mode(tech_pvt->rtp_session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating T38 Passthru\n");
}
@@ -5558,13 +5559,6 @@ nua_handle_t *sofia_global_nua_handle_by_replaces(sip_replaces_t *replaces)
const void *var;
void *val;
sofia_profile_t *profile;
switch_xml_t xml_root;
const char *err;
if ((xml_root = switch_xml_open_root(1, &err))) {
switch_xml_free(xml_root);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Reload XML [%s]\n", err);
}
switch_mutex_lock(mod_sofia_globals.hash_mutex);
if (mod_sofia_globals.profile_hash) {
+26 -2
View File
@@ -2171,6 +2171,15 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
if (!strncasecmp(url_str, "sips:", 5)) {
s = url_str + 5;
}
/* tel: patch from jaybinks, added by MC
It compiles but I don't have a way to test it
*/
if (!strncasecmp(url_str, "tel:", 4)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
SWITCH_LOG_ERROR, "URL Error! tel: uri's not supported at this time\n");
return SWITCH_STATUS_FALSE;
}
if (!s) {
s = url_str;
}
@@ -3009,6 +3018,21 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_audio_ip) && remote_port == tech_pvt->remote_sdp_audio_port) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Audio params are unchanged for %s.\n",
switch_channel_get_name(tech_pvt->channel));
if (switch_rtp_ready(tech_pvt->rtp_session)) {
if (tech_pvt->audio_recv_pt != tech_pvt->agreed_pt) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
"%s Set audio receive payload in Re-INVITE for non-matching dynamic PT to %u\n",
switch_channel_get_name(tech_pvt->channel), tech_pvt->audio_recv_pt);
switch_rtp_set_recv_pt(tech_pvt->rtp_session, tech_pvt->audio_recv_pt);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
"%s Setting audio receive payload in Re-INVITE to %u\n",
switch_channel_get_name(tech_pvt->channel), tech_pvt->audio_recv_pt);
switch_rtp_set_recv_pt(tech_pvt->rtp_session, tech_pvt->agreed_pt);
}
}
goto video;
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Audio params changed for %s from %s:%d to %s:%d\n",
@@ -3436,9 +3460,9 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) &&
!((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
} else {
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
}
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
+76 -44
View File
@@ -1417,6 +1417,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
}
if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find handle for call id %s\n", call_id);
}
goto end;
}
@@ -1468,12 +1473,18 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
const char *astate = switch_str_nil(switch_event_get_header(helper->event, "astate"));
const char *answer_state = switch_str_nil(switch_event_get_header(helper->event, "answer-state"));
const char *dft_state;
const char *from_id = switch_str_nil(switch_event_get_header(helper->event, "Other-Leg-Caller-ID-Number"));
const char *from_id;
const char *to_user = switch_str_nil(switch_event_get_header(helper->event, "variable_sip_to_user"));
const char *from_user = switch_str_nil(switch_event_get_header(helper->event, "variable_sip_from_user"));
char *clean_to_user = NULL;
char *clean_from_user = NULL;
int force_status = 0;
if (!strcasecmp(direction, "inbound")) {
from_id = switch_str_nil(switch_event_get_header(helper->event, "Caller-Destination-Number"));
} else {
from_id = switch_str_nil(switch_event_get_header(helper->event, "Other-Leg-Caller-ID-Number"));
}
#if 0
char *buf;
switch_event_serialize(helper->event, &buf, SWITCH_FALSE);
@@ -2175,58 +2186,79 @@ void sofia_presence_handle_sip_i_subscribe(int status,
sip->sip_expires->ex_delta = 31536000;
}
if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
sql = switch_mprintf("delete from sip_subscriptions where call_id='%q' "
"or (proto='%q' and sip_user='%q' and sip_host='%q' "
"and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q' "
"and contact='%q')",
call_id, proto, from_user, from_host, to_user, to_host, event, mod_sofia_globals.hostname, contact_str);
} else {
sql = switch_mprintf("delete from sip_subscriptions where "
"proto='%q' and sip_user='%q' and sip_host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q'",
proto, from_user, from_host, to_user, to_host, event, mod_sofia_globals.hostname);
}
switch_mutex_lock(profile->ireg_mutex);
switch_assert(sql != NULL);
sofia_glue_actually_execute_sql(profile, sql, NULL);
switch_safe_free(sql);
if (sub_state == nua_substate_terminated) {
sstr = switch_mprintf("terminated");
} else {
sip_accept_t *ap = sip->sip_accept;
char accept[256] = "";
full_agent = sip_header_as_string(profile->home, (void *) sip->sip_user_agent);
while (ap) {
switch_snprintf(accept + strlen(accept), sizeof(accept) - strlen(accept), "%s%s ", ap->ac_type, ap->ac_next ? "," : "");
ap = ap->ac_next;
}
sql = switch_mprintf("insert into sip_subscriptions "
"(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip) "
"values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%d','%q')",
proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : to_host,
event, contact_str, call_id, full_from, full_via,
//sofia_test_pflag(profile, PFLAG_MULTIREG) ? switch_epoch_time_now(NULL) + exp_delta : exp_delta * -1,
if ((sub_state == nua_substate_active) && (switch_stristr("dialog", (const char *) event))) {
sstr = switch_mprintf("active;expires=%ld", exp_delta);
sql = switch_mprintf("update sip_subscriptions "
"set expires=%ld "
"where call_id='%q' and event='dialog' and hostname='%q' ",
(long) switch_epoch_time_now(NULL) + (exp_delta * 2),
full_agent, accept, profile->name, mod_sofia_globals.hostname, np.network_port, np.network_ip);
switch_assert(sql != NULL);
call_id,
mod_sofia_globals.hostname);
if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s SUBSCRIBE %s@%s %s@%s\n%s\n",
profile->name, from_user, from_host, to_user, to_host, sql);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"re-subscribe with dialog detected, sql: %s\n", sql);
}
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
} else {
if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
sql = switch_mprintf("delete from sip_subscriptions where call_id='%q' "
"or (proto='%q' and sip_user='%q' and sip_host='%q' "
"and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q' "
"and contact='%q')",
call_id, proto, from_user, from_host, to_user, to_host, event, mod_sofia_globals.hostname, contact_str);
} else {
sql = switch_mprintf("delete from sip_subscriptions where "
"proto='%q' and sip_user='%q' and sip_host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q'",
proto, from_user, from_host, to_user, to_host, event, mod_sofia_globals.hostname);
}
switch_mutex_lock(profile->ireg_mutex);
switch_assert(sql != NULL);
sofia_glue_actually_execute_sql(profile, sql, NULL);
switch_safe_free(sql);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
sstr = switch_mprintf("active;expires=%ld", exp_delta);
if (sub_state == nua_substate_terminated) {
sstr = switch_mprintf("terminated");
} else {
sip_accept_t *ap = sip->sip_accept;
char accept[256] = "";
full_agent = sip_header_as_string(profile->home, (void *) sip->sip_user_agent);
while (ap) {
switch_snprintf(accept + strlen(accept), sizeof(accept) - strlen(accept), "%s%s ", ap->ac_type, ap->ac_next ? "," : "");
ap = ap->ac_next;
}
sql = switch_mprintf("insert into sip_subscriptions "
"(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip) "
"values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%d','%q')",
proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : to_host,
event, contact_str, call_id, full_from, full_via,
//sofia_test_pflag(profile, PFLAG_MULTIREG) ? switch_epoch_time_now(NULL) + exp_delta : exp_delta * -1,
(long) switch_epoch_time_now(NULL) + (exp_delta * 2),
full_agent, accept, profile->name, mod_sofia_globals.hostname, np.network_port, np.network_ip);
switch_assert(sql != NULL);
if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s SUBSCRIBE %s@%s %s@%s\n%s\n",
profile->name, from_user, from_host, to_user, to_host, sql);
}
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
sstr = switch_mprintf("active;expires=%ld", exp_delta);
}
switch_mutex_unlock(profile->ireg_mutex);
}
if (status < 200) {
char *sticky = NULL;
@@ -1106,7 +1106,7 @@ static int config(void)
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid encoding strategy '%s' specified\n", val);
}
} else if (!strcasecmp(var, "apply-inbound-acl")) {
} else if (!strcasecmp(var, "apply-inbound-acl") && ! zstr(val)) {
if (prefs.acl_count < MAX_ACL) {
prefs.acl[prefs.acl_count++] = strdup(val);
} else {
+3 -3
View File
@@ -36,7 +36,7 @@
#include <switch.h>
#include <shout/shout.h>
#include <lame.h>
#include <curl/curl.h>
#include <switch_curl.h>
#define OUTSCALE 8192 * 2
#define MP3_SCACHE 16384 * 2
@@ -1480,7 +1480,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load)
supported_formats[0] = "shout";
supported_formats[1] = "mp3";
curl_global_init(CURL_GLOBAL_ALL);
switch_curl_init();
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -1507,7 +1507,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_shout_shutdown)
{
curl_global_cleanup();
switch_curl_destroy();
mpg123_exit();
return SWITCH_STATUS_SUCCESS;
}
@@ -3023,6 +3023,35 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_flush_packet_count_get
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_numbers_t_largest_jb_size_set(void * jarg1, void * jarg2) {
switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ;
switch_size_t arg2 ;
switch_size_t *argp2 ;
arg1 = (switch_rtp_numbers_t *)jarg1;
argp2 = (switch_size_t *)jarg2;
if (!argp2) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0);
return ;
}
arg2 = *argp2;
if (arg1) (arg1)->largest_jb_size = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_rtp_numbers_t_largest_jb_size_get(void * jarg1) {
void * jresult ;
switch_rtp_numbers_t *arg1 = (switch_rtp_numbers_t *) 0 ;
switch_size_t result;
arg1 = (switch_rtp_numbers_t *)jarg1;
result = ((arg1)->largest_jb_size);
jresult = new switch_size_t((switch_size_t &)result);
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_rtp_numbers_t() {
void * jresult ;
switch_rtp_numbers_t *result = 0 ;
@@ -6597,6 +6597,12 @@ class freeswitchPINVOKE {
[DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_flush_packet_count_get")]
public static extern IntPtr switch_rtp_numbers_t_flush_packet_count_get(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_largest_jb_size_set")]
public static extern void switch_rtp_numbers_t_largest_jb_size_set(HandleRef jarg1, HandleRef jarg2);
[DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_numbers_t_largest_jb_size_get")]
public static extern IntPtr switch_rtp_numbers_t_largest_jb_size_get(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_new_switch_rtp_numbers_t")]
public static extern IntPtr new_switch_rtp_numbers_t();
@@ -29222,6 +29228,18 @@ public class switch_rtp_numbers_t : IDisposable {
}
}
public SWIGTYPE_p_switch_size_t largest_jb_size {
set {
freeswitchPINVOKE.switch_rtp_numbers_t_largest_jb_size_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value));
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
}
get {
SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_rtp_numbers_t_largest_jb_size_get(swigCPtr), true);
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
public switch_rtp_numbers_t() : this(freeswitchPINVOKE.new_switch_rtp_numbers_t(), true) {
}
@@ -35,7 +35,7 @@
#include "mod_spidermonkey.h"
#ifdef HAVE_CURL
#include <curl/curl.h>
#include <switch_curl.h>
#endif
static int foo = 0;
static jsval check_hangup_hook(struct js_session *jss, jsval * rp);
@@ -2551,7 +2551,6 @@ static JSBool js_fetchurl_file(JSContext * cx, JSObject * obj, uintN argc, jsval
url = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
filename = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
if (!strncasecmp(url, "https", 5)) {
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
@@ -2600,7 +2599,6 @@ static JSBool js_fetchurl(JSContext * cx, JSObject * obj, uintN argc, jsval * ar
JS_ValueToInt32(cx, argv[1], &buffer_size);
}
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
if (!strncasecmp(url, "https", 5)) {
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
@@ -3803,7 +3801,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load)
SWITCH_ADD_APP(app_interface, "javascript", "Launch JS ivr", "Run a javascript ivr on a channel", js_dp_function, "<script> [additional_vars [...]]",
SAF_SUPPORT_NOMEDIA);
curl_global_init(CURL_GLOBAL_ALL);
switch_curl_init();
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_NOUNLOAD;
@@ -3814,7 +3812,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown)
// this causes a crash
//JS_DestroyRuntime(globals.rt);
curl_global_cleanup();
switch_curl_destroy();
switch_core_hash_destroy(&module_manager.mod_hash);
switch_core_hash_destroy(&module_manager.load_hash);
@@ -30,7 +30,7 @@
*
*/
#include "mod_spidermonkey.h"
#include <curl/curl.h>
#include <switch_curl.h>
static const char modname[] = "CURL";
@@ -242,7 +242,7 @@ const sm_module_interface_t curl_module_interface = {
SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t ** module_interface)
{
curl_global_init(CURL_GLOBAL_ALL);
switch_curl_init();
*module_interface = &curl_module_interface;
return SWITCH_STATUS_SUCCESS;
}
+8 -1
View File
@@ -32,7 +32,7 @@
*/
#include <sys/stat.h>
#include <switch.h>
#include <curl/curl.h>
#include <switch_curl.h>
#define MAX_URLS 20
#define ENCODING_NONE 0
@@ -610,6 +610,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
set_xml_cdr_log_dirs();
switch_xml_free(xml);
if (status == SWITCH_STATUS_SUCCESS) {
switch_curl_init();
}
return status;
}
@@ -626,6 +631,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_cdr_shutdown)
switch_thread_rwlock_destroy(globals.log_path_lock);
switch_curl_destroy();
return SWITCH_STATUS_SUCCESS;
}
+4 -3
View File
@@ -31,7 +31,8 @@
*
*/
#include <switch.h>
#include <curl/curl.h>
#include <switch_curl.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_curl_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_curl_shutdown);
@@ -548,7 +549,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_curl_load)
globals.hash_tail = NULL;
if (do_config() == SWITCH_STATUS_SUCCESS) {
curl_global_init(CURL_GLOBAL_ALL);
switch_curl_init();
} else {
return SWITCH_STATUS_FALSE;
}
@@ -573,7 +574,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_curl_shutdown)
}
switch_xml_unbind_search_function_ptr(xml_url_fetch);
curl_global_cleanup();
switch_curl_destroy();
return SWITCH_STATUS_SUCCESS;
}