mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 12:42:02 +00:00
Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch
This commit is contained in:
@@ -253,6 +253,8 @@ struct switch_runtime {
|
||||
int multiple_registrations;
|
||||
uint32_t max_db_handles;
|
||||
uint32_t db_handle_timeout;
|
||||
int curl_count;
|
||||
int ssl_count;
|
||||
};
|
||||
|
||||
extern struct switch_runtime runtime;
|
||||
|
||||
@@ -56,6 +56,15 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct profile_node_s {
|
||||
char *var;
|
||||
char *val;
|
||||
struct profile_node_s *next;
|
||||
} profile_node_t;
|
||||
|
||||
|
||||
|
||||
/*! \brief Call Specific Data
|
||||
*/
|
||||
struct switch_caller_profile {
|
||||
@@ -110,6 +119,7 @@ SWITCH_BEGIN_EXTERN_C
|
||||
switch_memory_pool_t *pool;
|
||||
struct switch_caller_profile *next;
|
||||
switch_call_direction_t direction;
|
||||
profile_node_t *soft;
|
||||
};
|
||||
|
||||
/*! \brief An Abstract Representation of a dialplan Application */
|
||||
|
||||
@@ -57,6 +57,7 @@ SWITCH_BEGIN_EXTERN_C
|
||||
struct switch_app_log {
|
||||
char *app;
|
||||
char *arg;
|
||||
switch_time_t stamp;
|
||||
struct switch_app_log *next;
|
||||
};
|
||||
|
||||
@@ -434,6 +435,9 @@ SWITCH_DECLARE(void) switch_core_session_rwunlock(_In_ switch_core_session_t *se
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_core_add_state_handler(_In_ const switch_state_handler_table_t *state_handler);
|
||||
|
||||
SWITCH_DECLARE(int) switch_core_curl_count(int *val);
|
||||
SWITCH_DECLARE(int) switch_core_ssl_count(int *val);
|
||||
|
||||
/*!
|
||||
\brief Remove a global state handler
|
||||
\param state_handler the state handler to remove
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* switch_curl.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SWITCH_CURL_H
|
||||
#define __SWITCH_CURL_H
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <switch_ssl.h>
|
||||
|
||||
static inline void switch_curl_init(void)
|
||||
{
|
||||
int curl_count = switch_core_curl_count(NULL);
|
||||
|
||||
if (curl_count == 0) {
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
#if defined(HAVE_OPENSSL)
|
||||
switch_ssl_init_ssl_locks();
|
||||
#endif
|
||||
}
|
||||
|
||||
curl_count++;
|
||||
switch_core_curl_count(&curl_count);
|
||||
}
|
||||
|
||||
static inline void switch_curl_destroy()
|
||||
{
|
||||
int curl_count = switch_core_curl_count(NULL);
|
||||
|
||||
curl_count--;
|
||||
|
||||
if (curl_count == 0) {
|
||||
|
||||
#if defined(HAVE_OPENSSL)
|
||||
switch_ssl_destroy_ssl_locks();
|
||||
#endif
|
||||
curl_global_cleanup();
|
||||
}
|
||||
switch_core_curl_count(&curl_count);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* 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,107 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* switch_ssl.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SWITCH_SSL_H
|
||||
#define __SWITCH_SSL_H
|
||||
|
||||
#if defined(HAVE_OPENSSL)
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
static switch_mutex_t **ssl_mutexes;
|
||||
static switch_memory_pool_t *ssl_pool = NULL;
|
||||
|
||||
|
||||
static inline void switch_ssl_ssl_lock_callback(int mode, int type, char *file, int line)
|
||||
{
|
||||
if (mode & CRYPTO_LOCK) {
|
||||
switch_mutex_lock(ssl_mutexes[type]);
|
||||
}
|
||||
else {
|
||||
switch_mutex_unlock(ssl_mutexes[type]);
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long switch_ssl_ssl_thread_id(void)
|
||||
{
|
||||
return (unsigned long) switch_thread_self();
|
||||
}
|
||||
|
||||
static inline void switch_ssl_init_ssl_locks(void)
|
||||
{
|
||||
|
||||
int ssl_count = switch_core_ssl_count(NULL);
|
||||
int i, num;
|
||||
|
||||
if (ssl_count == 0) {
|
||||
num = CRYPTO_num_locks();
|
||||
|
||||
ssl_mutexes = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(switch_mutex_t*));
|
||||
switch_assert(ssl_mutexes != NULL);
|
||||
|
||||
switch_core_new_memory_pool(&ssl_pool);
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
switch_mutex_init(&(ssl_mutexes[i]), SWITCH_MUTEX_NESTED, ssl_pool);
|
||||
switch_assert(ssl_mutexes[i] != NULL);
|
||||
}
|
||||
|
||||
CRYPTO_set_id_callback(switch_ssl_ssl_thread_id);
|
||||
CRYPTO_set_locking_callback((void (*)(int, int, const char*, int))switch_ssl_ssl_lock_callback);
|
||||
}
|
||||
|
||||
ssl_count++;
|
||||
switch_core_ssl_count(&ssl_count);
|
||||
}
|
||||
|
||||
static inline void switch_ssl_destroy_ssl_locks()
|
||||
{
|
||||
int i;
|
||||
int ssl_count = switch_core_ssl_count(NULL);
|
||||
|
||||
ssl_count--;
|
||||
|
||||
if (ssl_count == 0) {
|
||||
CRYPTO_set_locking_callback(NULL);
|
||||
for (i = 0; i < CRYPTO_num_locks(); i++) {
|
||||
switch_mutex_destroy(ssl_mutexes[i]);
|
||||
}
|
||||
|
||||
OPENSSL_free(ssl_mutexes);
|
||||
}
|
||||
|
||||
switch_core_ssl_count(&ssl_count);
|
||||
|
||||
}
|
||||
#else
|
||||
static inline void switch_ssl_init_ssl_locks(void) { return; }
|
||||
static inline void switch_ssl_destroy_ssl_locks(void) { return; }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 +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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -324,6 +324,16 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_
|
||||
switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->profile_index);
|
||||
}
|
||||
|
||||
if (caller_profile->soft) {
|
||||
profile_node_t *pn;
|
||||
|
||||
for (pn = caller_profile->soft; pn; pn = pn->next) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pn->var, pn->val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (caller_profile->times) {
|
||||
switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Created-Time", prefix);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
|
||||
|
||||
+25
-5
@@ -877,7 +877,20 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t
|
||||
} else if (!strcasecmp(name, "chan_name")) {
|
||||
channel->caller_profile->chan_name = v;
|
||||
} else {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
profile_node_t *pn, *n = switch_core_alloc(channel->caller_profile->pool, sizeof(*n));
|
||||
|
||||
n->var = switch_core_strdup(channel->caller_profile->pool, name);
|
||||
n->val = v;
|
||||
|
||||
if (!channel->caller_profile->soft) {
|
||||
channel->caller_profile->soft = n;
|
||||
} else {
|
||||
for(pn = channel->caller_profile->soft; pn && pn->next; pn = pn->next);
|
||||
|
||||
if (pn) {
|
||||
pn->next = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(channel->profile_mutex);
|
||||
|
||||
@@ -1638,11 +1651,8 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
|
||||
const char *file, const char *func, int line)
|
||||
{
|
||||
int x;
|
||||
switch_mutex_lock(channel->state_mutex);
|
||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s\n",
|
||||
channel->name, state_names[state]);
|
||||
channel->running_state = state;
|
||||
|
||||
switch_mutex_lock(channel->flag_mutex);
|
||||
if (channel->state_flags[0]) {
|
||||
for (x = 1; x < CF_FLAG_MAX; x++) {
|
||||
if (channel->state_flags[x]) {
|
||||
@@ -1652,8 +1662,18 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
|
||||
}
|
||||
channel->state_flags[0] = 0;
|
||||
}
|
||||
switch_mutex_unlock(channel->flag_mutex);
|
||||
|
||||
switch_channel_clear_flag(channel, CF_TAGGED);
|
||||
|
||||
|
||||
|
||||
switch_mutex_lock(channel->state_mutex);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s\n",
|
||||
channel->name, state_names[state]);
|
||||
|
||||
channel->running_state = state;
|
||||
|
||||
if (channel->state == CS_ROUTING || channel->state == CS_HANGUP) {
|
||||
switch_channel_presence(channel, "unknown", (const char *) state_names[state], NULL);
|
||||
|
||||
@@ -197,6 +197,34 @@ SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel)
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(int) switch_core_curl_count(int *val)
|
||||
{
|
||||
if (!val) {
|
||||
switch_mutex_lock(runtime.global_mutex);
|
||||
return runtime.curl_count;
|
||||
}
|
||||
|
||||
runtime.curl_count = *val;
|
||||
switch_mutex_unlock(runtime.global_mutex);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(int) switch_core_ssl_count(int *val)
|
||||
{
|
||||
if (!val) {
|
||||
switch_mutex_lock(runtime.global_mutex);
|
||||
return runtime.ssl_count;
|
||||
}
|
||||
|
||||
runtime.ssl_count = *val;
|
||||
switch_mutex_unlock(runtime.global_mutex);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_core_remove_state_handler(const switch_state_handler_table_t *state_handler)
|
||||
{
|
||||
int index, tmp_index = 0;
|
||||
@@ -1300,6 +1328,7 @@ static void switch_core_set_serial(void)
|
||||
switch_core_set_variable("switch_serial", buf);
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switch_bool_t console, const char **err)
|
||||
{
|
||||
switch_uuid_t uuid;
|
||||
|
||||
@@ -445,15 +445,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh,
|
||||
switch_set_flag(fh, SWITCH_FILE_SEEK);
|
||||
status = fh->file_interface->file_seek(fh, cur_pos, samples, whence);
|
||||
|
||||
if (samples) {
|
||||
fh->offset_pos = *cur_pos;
|
||||
fh->offset_pos = *cur_pos;
|
||||
|
||||
if (switch_test_flag(fh, SWITCH_FILE_FLAG_WRITE)) {
|
||||
fh->samples_out = *cur_pos;
|
||||
}
|
||||
if (switch_test_flag(fh, SWITCH_FILE_FLAG_WRITE)) {
|
||||
fh->samples_out = *cur_pos;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -2010,6 +2010,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
|
||||
log->arg = switch_core_session_strdup(session, expanded);
|
||||
}
|
||||
|
||||
log->stamp = switch_time_now();
|
||||
|
||||
for (lp = session->app_log; lp && lp->next; lp = lp->next);
|
||||
|
||||
if (lp) {
|
||||
|
||||
@@ -1350,6 +1350,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
/* If we had early media in bypass mode before, it is no longer relevant */
|
||||
if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
|
||||
switch_core_session_message_t msg2 = { 0 };
|
||||
|
||||
msg2.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS;
|
||||
msg2.from = __FILE__;
|
||||
switch_core_session_receive_message(session, &msg2);
|
||||
}
|
||||
|
||||
if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't re-establsh media on %s\n", switch_channel_get_name(channel));
|
||||
switch_core_session_rwunlock(session);
|
||||
@@ -1954,6 +1964,21 @@ SWITCH_DECLARE(int) switch_ivr_set_xml_profile_data(switch_xml_t xml, switch_cal
|
||||
}
|
||||
switch_xml_set_txt_d(param, caller_profile->chan_name);
|
||||
|
||||
|
||||
if (caller_profile->soft) {
|
||||
profile_node_t *pn;
|
||||
|
||||
for (pn = caller_profile->soft; pn; pn = pn->next) {
|
||||
|
||||
if (!(param = switch_xml_add_child_d(xml, pn->var, off++))) {
|
||||
return -1;
|
||||
}
|
||||
switch_xml_set_txt_d(param, pn->val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
@@ -2043,6 +2068,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_
|
||||
goto error;
|
||||
}
|
||||
for (ap = app_log; ap; ap = ap->next) {
|
||||
char tmp[128];
|
||||
|
||||
if (!(x_application = switch_xml_add_child_d(x_apps, "application", app_off++))) {
|
||||
goto error;
|
||||
@@ -2050,6 +2076,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_
|
||||
|
||||
switch_xml_set_attr_d(x_application, "app_name", ap->app);
|
||||
switch_xml_set_attr_d(x_application, "app_data", ap->arg);
|
||||
|
||||
switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, ap->stamp);
|
||||
switch_xml_set_attr_d_buf(x_application, "app_stamp", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2454,6 +2454,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
||||
|
||||
if (fail_on_single_reject == 1 || switch_stristr(cause_str, fail_on_single_reject_var)) {
|
||||
force_reason = reason;
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto outer_for;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1900,7 +1900,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
|
||||
|
||||
|
||||
if (tb[0]) {
|
||||
char *p;
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_READ_TERMINATOR_USED_VARIABLE, tb);
|
||||
|
||||
if ((p = strchr(valid_terminators, tb[0]))) {
|
||||
if (p >= (valid_terminators + 1) && (*(p - 1) == '+' || *(p - 1) == 'x')) {
|
||||
switch_snprintf(digit_buffer + strlen(digit_buffer), digit_buffer_length - strlen(digit_buffer), "%s", tb);
|
||||
if (*(p - 1) == 'x') {
|
||||
status = SWITCH_STATUS_RESTART;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
len = strlen(digit_buffer);
|
||||
@@ -1923,7 +1934,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session,
|
||||
|
||||
end:
|
||||
|
||||
if (max_digits == 1 && len == 1 && valid_terminators && strchr(valid_terminators, *digit_buffer)) {
|
||||
if (status != SWITCH_STATUS_RESTART && max_digits == 1 && len == 1 && valid_terminators && strchr(valid_terminators, *digit_buffer)) {
|
||||
*digit_buffer = '\0';
|
||||
}
|
||||
|
||||
@@ -1958,6 +1969,11 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
|
||||
|
||||
status = switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name,
|
||||
digit_buffer, digit_buffer_length, timeout, valid_terminators, digit_timeout);
|
||||
|
||||
if (status == SWITCH_STATUS_RESTART) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (status == SWITCH_STATUS_TIMEOUT && strlen(digit_buffer) >= min_digits) {
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
+4
-5
@@ -1262,9 +1262,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
|
||||
READ_INC(rtp_session);
|
||||
WRITE_INC(rtp_session);
|
||||
|
||||
if (rtp_session->timer.timer_interface) {
|
||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) || rtp_session->timer.timer_interface) {
|
||||
switch_core_timer_destroy(&rtp_session->timer);
|
||||
memset(&rtp_session->timer, 0, sizeof(rtp_session->timer));
|
||||
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
}
|
||||
|
||||
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP);
|
||||
@@ -1293,9 +1294,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
|
||||
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_UDPTL);
|
||||
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA);
|
||||
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
|
||||
|
||||
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
|
||||
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
|
||||
|
||||
WRITE_DEC(rtp_session);
|
||||
READ_DEC(rtp_session);
|
||||
@@ -3850,7 +3849,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
|
||||
rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
|
||||
} else {
|
||||
rtp_session->last_write_timestamp = (uint32_t) switch_micro_time_now();
|
||||
rtp_session->last_write_timestamp = switch_micro_time_now();
|
||||
}
|
||||
|
||||
rtp_session->last_write_ts = this_ts;
|
||||
|
||||
+12
-2
@@ -1329,11 +1329,17 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in)
|
||||
char replace[1024] = "";
|
||||
switch_time_t ret = 0;
|
||||
char *pattern = "^(\\d+)-(\\d+)-(\\d+)\\s*(\\d*):{0,1}(\\d*):{0,1}(\\d*)";
|
||||
char *pattern2 = "^(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})";
|
||||
|
||||
switch_time_exp_lt(&tm, switch_micro_time_now());
|
||||
tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
|
||||
|
||||
if ((proceed = switch_regex_perform(in, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
if (!(proceed = switch_regex_perform(in, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
switch_regex_safe_free(re);
|
||||
proceed = switch_regex_perform(in, pattern2, &re, ovector, sizeof(ovector) / sizeof(ovector[0]));
|
||||
}
|
||||
|
||||
if (proceed) {
|
||||
|
||||
if (proceed > 1) {
|
||||
switch_regex_copy_substring(in, ovector, proceed, 1, replace, sizeof(replace));
|
||||
@@ -1365,10 +1371,14 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in)
|
||||
tm.tm_sec = atoi(replace);
|
||||
}
|
||||
|
||||
switch_regex_safe_free(re);
|
||||
|
||||
switch_time_exp_gmt_get(&ret, &tm);
|
||||
return ret;
|
||||
}
|
||||
/* possible else with more patterns later */
|
||||
|
||||
switch_regex_safe_free(re);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user