From a3b18e5b7cf33bf9de36cb12c953a5b527549a9f Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Sat, 19 Feb 2011 16:47:19 +0100 Subject: [PATCH 001/104] [SDK] Import autotools version of fs-mod-sdk. This is a autotools (autoconf/automake/libtool) based skeleton framework for developing external (= out-of-tree) modules for FreeSWITCH. Variants of this framework have been used to develop modules like mod_openais, mod_ssh and others. NOTE: This version of the SDK relies on pkg-config to detect FreeSWITCH installations. Other SDKs for external modules should be added in: "src/mod/sdk//" e.g. a scons-based SDK should be put in: "src/mod/sdk/scons/" Signed-off-by: Stefan Knoblich Requested-by: Michal Bielicki - cypromis --- src/mod/sdk/autotools/.gitignore | 35 +++ src/mod/sdk/autotools/Makefile.am | 4 + src/mod/sdk/autotools/autogen.sh | 2 + src/mod/sdk/autotools/configure.ac | 252 ++++++++++++++++++ .../sdk/autotools/m4/ax_compiler_vendor.m4 | 15 ++ src/mod/sdk/autotools/src/Makefile.am | 66 +++++ src/mod/sdk/autotools/src/mod_example.c | 84 ++++++ 7 files changed, 458 insertions(+) create mode 100644 src/mod/sdk/autotools/.gitignore create mode 100644 src/mod/sdk/autotools/Makefile.am create mode 100755 src/mod/sdk/autotools/autogen.sh create mode 100644 src/mod/sdk/autotools/configure.ac create mode 100644 src/mod/sdk/autotools/m4/ax_compiler_vendor.m4 create mode 100644 src/mod/sdk/autotools/src/Makefile.am create mode 100644 src/mod/sdk/autotools/src/mod_example.c diff --git a/src/mod/sdk/autotools/.gitignore b/src/mod/sdk/autotools/.gitignore new file mode 100644 index 0000000000..57b51acef5 --- /dev/null +++ b/src/mod/sdk/autotools/.gitignore @@ -0,0 +1,35 @@ +*.o +*.lo +*.so +*.a +*.orig +*.rej +*.log +*.la + +.deps +.libs + +stamp-h1 +samples* +Makefile +Makefile.in +config.log +config.sub +config.guess +config.status +configure +libtool +aclocal.m4 +autom4te.cache +depcomp +install-sh +compile +missing +ltmain.sh +doxygen +m4/libtool.m4 +m4/ltsugar.m4 +m4/ltoptions.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 diff --git a/src/mod/sdk/autotools/Makefile.am b/src/mod/sdk/autotools/Makefile.am new file mode 100644 index 0000000000..8f8a25a048 --- /dev/null +++ b/src/mod/sdk/autotools/Makefile.am @@ -0,0 +1,4 @@ +ACLOCAL_AMFLAGS = -I m4 +AUTOMAKE_OPTIONS = foreign no-dist subdir-objects + +SUBDIRS = src diff --git a/src/mod/sdk/autotools/autogen.sh b/src/mod/sdk/autotools/autogen.sh new file mode 100755 index 0000000000..08240fdfcd --- /dev/null +++ b/src/mod/sdk/autotools/autogen.sh @@ -0,0 +1,2 @@ +#!/bin/sh +autoreconf -i -f diff --git a/src/mod/sdk/autotools/configure.ac b/src/mod/sdk/autotools/configure.ac new file mode 100644 index 0000000000..d4f29f492b --- /dev/null +++ b/src/mod/sdk/autotools/configure.ac @@ -0,0 +1,252 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +# website url +m4_define([AC_PACKAGE_URL], [http://www.example.com/]) + +AC_PREREQ([2.61]) +AC_INIT([mod_example], [0.0.0], [contact@example.com]) +AC_CONFIG_SRCDIR([src/mod_example.c]) +AC_CONFIG_MACRO_DIR([m4]) + +AM_INIT_AUTOMAKE([foreign no-dist subdir-objects]) +AC_DISABLE_STATIC + +# disable libtool fortran and c++ checks +m4_defun([_LT_AC_LANG_F77_CONFIG], [:]) +m4_defun([_LT_AC_LANG_CXX_CONFIG], [:]) + +# >=automake-1.11 +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +# Checks for programs. +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_LIBTOOL + +# pkgconfig +AC_PATH_PROG([PKG_CONFIG], [pkg-config], ["no"]) +if test "x${PKG_CONFIG}" = "xno" +then + AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed in your PATH]) +fi +PKG_PROG_PKG_CONFIG + +# Checks for cflags +AC_MSG_RESULT([${as_nl}<<>> Compiler vendor and features]) + +## +## Compiler vendor and flag checks +## +HAVE_VISIBILITY="no" +AC_ARG_ENABLE([visibility], + [AS_HELP_STRING([--disable-visibility], [Disable symbol visibility support (default: enabled, if available)])], + [case "${enableval}" in + yes) enable_visibility="yes" ;; + no) enable_visibility="no" ;; + *) AC_MSG_ERROR([Invalid value ${enableval} for parameter --disable-visibility]) ;; + esac], + [enable_visibility="yes"] +) + +AX_COMPILER_VENDOR + +case "${ax_cv_c_compiler_vendor}" in +gnu) + AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden]) + AS_IF([test "x${enable_visibility}" != "xno"], + [save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} -fvisibility=hidden" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [int foo __attribute__ ((visibility("default")));], + [;] + )], + + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_VISIBILITY],[1],[GCC visibility support]) + HAVE_VISIBILITY="yes"], + + [AC_MSG_RESULT([no]) + HAVE_VISIBILITY="no"] + ) + CFLAGS="${save_CFLAGS}"], + [AC_MSG_RESULT([disabled by user])] + ) + + AS_IF([test "x${HAVE_VISIBILITY}" != "xno"], + [save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} -fvisibility-inlines-hidden" + AC_MSG_CHECKING([whether the compiler supports -fvisibility-inlines-hidden]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [;], [;] + )], + + [AC_MSG_RESULT([yes]) + HAVE_VISIBILITY_INLINES_HIDDEN="yes"], + + [AC_MSG_RESULT([no]) + HAVE_VISIBILITY_INLINES_HIDDEN="no"] + ) + CFLAGS="${save_CFLAGS}"], + [:] + ) + AC_DEFINE([COMPILER_GCC], [1], [Compiler is GCC]) + ;; +sun) + AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden]) + AS_IF([test "x${enable_visibility}" != "xno"], + [save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} -xldscope=hidden" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [int foo __attribute__ ((visibility("default")));], + [;] + )], + + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_VISIBILITY],[1],[SUNCC visibility support]) + HAVE_VISIBILITY="yes"], + + [AC_MSG_RESULT([no]) + HAVE_VISIBILITY="no"] + ) + CFLAGS="${save_CFLAGS}"], + [AC_MSG_RESULT([disabled by user])] + ) + AC_DEFINE([COMPILER_SUNCC], [1], [Compiler is SunCC]) + ;; +*) + AC_MSG_WARN([No visibility checks for this compiler defined]) + ;; +esac + +AM_CONDITIONAL([COMPILER_GCC], [test "x${ax_cv_c_compiler_vendor}" = "xgnu"]) +AM_CONDITIONAL([COMPILER_SUNCC], [test "x${ax_cv_c_compiler_vendor}" = "xsun"]) + +AM_CONDITIONAL([HAVE_VISIBILITY], [test "x${HAVE_VISIBILITY}" = "xyes"]) +AM_CONDITIONAL([HAVE_VISIBILITY_INLINES_HIDDEN], [test "x${HAVE_VISIBILITY_INLINES_HIDDEN}" = "xyes"]) + +## +## pkgconfig based freeswitch detection code +## +AC_MSG_RESULT([${as_nl}<<>> FreeSWITCH environment]) + +PKG_CHECK_MODULES([freeswitch], [freeswitch], + [save_LIBS="${LIBS}" + save_CFLAGS="${CFLAGS}" + save_CPPFLAGS="${CPPFLAGS}" + + AC_MSG_CHECKING([FreeSWITCH version]) + + FREESWITCH_VERSION="`${PKG_CONFIG} --modversion freeswitch 2>/dev/null`" + AS_IF([test "x${FREESWITCH_VERSION}" = "x"], + [AC_MSG_ERROR([failed to get FreeSWITCH version])], + [AC_MSG_RESULT([$FREESWITCH_VERSION])] + ) + + AC_MSG_CHECKING([whether FreeSWITCH ${FREESWITCH_VERSION} is usable]) + CFLAGS="${freeswitch_CFLAGS}" + CPPFLAGS="${freeswitch_CPPFLAGS}" + LIBS="${freeswitch_LIBS}" + AC_TRY_LINK([#include ], + [switch_core_init(0, 0, NULL);], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([libfreeswitch is unusable, please check config.log for details])] + ) + LIBS="${save_LIBS}" + CFLAGS="${save_CFLAGS}" + CPPFLAGS="${save_CPPFLAGS}" + + # get locations, critical first + AC_MSG_CHECKING([for installation prefix]) + FREESWITCH_PREFIX_DIR="`${PKG_CONFIG} --variable=prefix freeswitch 2>/dev/null`" + AS_IF( + [test "x${FREESWITCH_PREFIX_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH prefix directory])], + [test ! -e "${FREESWITCH_PREFIX_DIR}"], [AC_MSG_ERROR([FreeSWITCH prefix directory ${FREESWITCH_PREFIX_DIR} does not exist])] + ) + AC_MSG_RESULT([${FREESWITCH_PREFIX_DIR}]) + + AC_MSG_CHECKING([for modules directory]) + FREESWITCH_MODULES_DIR="`${PKG_CONFIG} --variable=modulesdir freeswitch 2>/dev/null`" + AS_IF( + [test "x${FREESWITCH_MODULES_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH modules directory])], + [test ! -e "${FREESWITCH_MODULES_DIR}"], [AC_MSG_ERROR([FreeSWITCH modules directory ${FREESWITCH_MODULES_DIR} does not exist])] + ) + AC_MSG_RESULT([${FREESWITCH_MODULES_DIR}]) + + AC_MSG_CHECKING([for configuration directory]) + FREESWITCH_CONFIG_DIR="`${PKG_CONFIG} --variable=sysconfdir freeswitch 2>/dev/null`" + AS_IF( + [test "x${FREESWITCH_CONFIG_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH configuration directory])], + [test ! -e "${FREESWITCH_CONFIG_DIR}"], [AC_MSG_ERROR([FreeSWITCH configuration directory ${FREESWITCH_CONFIG_DIR} does not exist])] + ) + AC_MSG_RESULT([${FREESWITCH_CONFIG_DIR}]) + + # non-critical paths + FREESWITCH_HTDOCS_DIR="`${PKG_CONFIG} --variable=htdocsdir freeswitch 2>/dev/null`" + + FREESWITCH_RUNTIME_DIR="`${PKG_CONFIG} --variable=runtimedir freeswitch 2>/dev/null`" + FREESWITCH_SCRIPTS_DIR="`${PKG_CONFIG} --variable=scriptsdir freeswitch 2>/dev/null`" + + # cflags, libs + AC_SUBST([FREESWITCH_CFLAGS], [${freeswitch_CFLAGS}]) + AC_SUBST([FREESWITCH_CPPFLAGS], [${freeswitch_CPPFLAGS}]) + AC_SUBST([FREESWITCH_LIBS], [${freeswitch_LIBS}]) + + # version + AC_SUBST([FREESWITCH_VERSION]) + + # locations + AC_SUBST([FREESWITCH_PREFIX_DIR]) + AC_SUBST([FREESWITCH_HTDOCS_DIR]) + AC_SUBST([FREESWITCH_CONFIG_DIR]) + AC_SUBST([FREESWITCH_MODULES_DIR]) + AC_SUBST([FREESWITCH_SCRIPTS_DIR]) + AC_SUBST([FREESWITCH_RUNTIME_DIR]) + ], + [AC_MSG_ERROR([FreeSWITCH not found])] +) + +## +## Add your other dependency checks here +## +AC_MSG_RESULT([${as_nl}<<>> Other dependencies]) + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. + +AC_MSG_RESULT([${as_nl}<<>> Create output files]) +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT + +AC_MSG_RESULT([ +====================== Configuration Summary ===================== ++ Package + Name:...................... ${PACKAGE_NAME} + Version:................... ${PACKAGE_VERSION} + Bugreports:................ ${PACKAGE_BUGREPORT} + Website:................... ${PACKAGE_URL} + ++ Compiler + Vendor:.................... ${ax_cv_c_compiler_vendor} + Symbol visibility:......... ${HAVE_VISIBILITY} + ++ FreeSWITCH + Version:................... ${FREESWITCH_VERSION} + Prefix:.................... ${FREESWITCH_PREFIX_DIR} + Modules directory:......... ${FREESWITCH_MODULES_DIR} + Configuration directory:... ${FREESWITCH_CONFIG_DIR} + + Cflags/CPPflags/CXXflags:.. ${FREESWITCH_CFLAGS} ${FREESWITCH_CPPFLAGS} + LDflags/Libs:.............. ${FREESWITCH_LIBS} ${FREESWITCH_LDFLAGS} + ++ Other + N/A +================================================================== +]) diff --git a/src/mod/sdk/autotools/m4/ax_compiler_vendor.m4 b/src/mod/sdk/autotools/m4/ax_compiler_vendor.m4 new file mode 100644 index 0000000000..a24a58da0f --- /dev/null +++ b/src/mod/sdk/autotools/m4/ax_compiler_vendor.m4 @@ -0,0 +1,15 @@ +AC_DEFUN([AX_COMPILER_VENDOR], +[ +AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, + [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown + # note: don't check for gcc first since some other compilers define __GNUC__ + for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do + vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ +#if !($vencpp) + thisisanerror; +#endif +])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break]) + done + ]) +]) diff --git a/src/mod/sdk/autotools/src/Makefile.am b/src/mod/sdk/autotools/src/Makefile.am new file mode 100644 index 0000000000..d2bad5bc80 --- /dev/null +++ b/src/mod/sdk/autotools/src/Makefile.am @@ -0,0 +1,66 @@ +moddir = @FREESWITCH_MODULES_DIR@ +sysconfdir = @FREESWITCH_CONFIG_DIR@ + +### +# Flags +# +AM_CFLAGS = +AM_CXXFLAGS= +AM_CPPFLAGS= -I. -I$(includedir) +AM_LDFLAGS = -L. -L$(libdir) -avoid-version -module -no-undefined -shared + +### +# GCC specific flags +# +if COMPILER_GCC +AM_CFLAGS += -Wall +# symbol visibility support +if HAVE_VISIBILITY +AM_CFLAGS += -fvisibility=hidden +AM_CXXFLAGS+= -fvisibility=hidden +AM_CPPFLAGS+= -DSWITCH_API_VISIBILITY=1 +endif +if HAVE_VISIBILITY_INLINES_HIDDEN +AM_CXXFLAGS += -fvisibility-inlines-hidden +endif +endif + +### +# SunCC specific flags +# +if COMPILER_SUNCC +AM_CFLAGS += +# symbol visibility support +if HAVE_VISIBILITY +AM_CFLAGS += -xldscope=hidden +AM_CXXFLAGS += -xldscope=hidden +AM_CPPFLAGS += -DSWITCH_API_VISIBILITY=1 +endif +endif + + +### +# add module(s) here, with suffix '.la' +# +mod_LTLIBRARIES = mod_example.la + +### +# mod_example +# +mod_example_la_SOURCES = mod_example.c +mod_example_la_CFLAGS = $(AM_CFLAGS) $(FREESWITCH_CFLAGS) +mod_example_la_CPPFLAGS= $(AM_CPPFLAGS) $(FREESWITCH_CPPFLAGS) +mod_example_la_LDFLAGS = $(AM_LDFLAGS) +mod_example_la_LIBADD = $(FREESWITCH_LIBS) + +# configuration file +#sysconf_DATA = example.conf.xml + +# +# install configuration +# +#install-sysconfDATA: +# $(INSTALL) -d $(DESTDIR)/$(sysconfdir) +# for x in $(sysconf_DATA); do \ +# test -e $(DESTDIR)$(sysconfdir)/$$x || $(INSTALL) -m644 $$x $(DESTDIR)$(sysconfdir)/$$x ; \ +# done diff --git a/src/mod/sdk/autotools/src/mod_example.c b/src/mod/sdk/autotools/src/mod_example.c new file mode 100644 index 0000000000..5e7755c752 --- /dev/null +++ b/src/mod/sdk/autotools/src/mod_example.c @@ -0,0 +1,84 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005/2006, Anthony Minessale II + * + * 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 + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Anthony Minessale II + * Neal Horman + * + * + * mod_example.c -- Framework Demo Module + * + */ +#include + +/* +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_example_shutdown); +SWITCH_MODULE_RUNTIME_FUNCTION(mod_example_runtime); +*/ + +SWITCH_MODULE_LOAD_FUNCTION(mod_example_load); +SWITCH_MODULE_DEFINITION(mod_example, mod_example_load, NULL, NULL); + +SWITCH_MODULE_LOAD_FUNCTION(mod_example_load) +{ + /* connect my internal structure to the blank pointer passed to me */ + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n"); + + /* indicate that the module should continue to be loaded */ + return SWITCH_STATUS_SUCCESS; +} + +/* + Called when the system shuts down +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_example_shutdown); +{ + return SWITCH_STATUS_SUCCESS; +} +*/ + +/* + If it exists, this is called in it's own thread when the module-load completes + If it returns anything but SWITCH_STATUS_TERM it will be called again automaticly +SWITCH_MODULE_RUNTIME_FUNCTION(mod_example_runtime); +{ + while(looping) + { + switch_yield(1000); + } + return SWITCH_STATUS_TERM; +} +*/ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:nil + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: + */ From f20ba4d1f6f145118362d3c5246f27d647fbb6d2 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Sat, 19 Feb 2011 23:07:22 +0100 Subject: [PATCH 002/104] Add --with-pkglibdir option to set the installation directory of freeswitch.pc. Default behaviour is unchanged. Packagers should use this option to install freeswitch.pc into the system's main pkg-config directory (e.g. /usr/lib/pkgconfig). Signed-off-by: Stefan Knoblich Tested-by: Stefan Knoblich --- Makefile.am | 2 +- configure.in | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 37a01d27fb..5b6b9896ac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -356,7 +356,7 @@ scripts/fsxs: scripts/fsxs.in ## misc ## -pkgconfigdir = $(libdir)/pkgconfig +pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = build/freeswitch.pc $(switch_builddir)/modules.conf: diff --git a/configure.in b/configure.in index a0c9418751..0e45e064f1 100644 --- a/configure.in +++ b/configure.in @@ -93,6 +93,17 @@ AC_SUBST(libdir) AC_SUBST(bindir) AC_SUBST(includedir) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: \${libdir}/pkgconfig)])], + [case "${withval}" in + yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;; + *) pkgconfigdir="${withval}" ;; + esac + ], + [pkgconfigdir="${libdir}/pkgconfig"] +) +AC_SUBST([pkgconfigdir]) + #Set default language AC_LANG_C # Checks for programs. From c8065499adc3bfdd97d3c51e44465865f9417efb Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Sat, 19 Feb 2011 23:35:41 +0100 Subject: [PATCH 003/104] [FreeTDM] Add --with-pkgconfigdir option to FreeTDM. Default behaviour is unchanged. Packagers should use this option to install freetdm.pc into the system's main pkg-config directory (e.g. /usr/lib/pkgconfig). Signed-off-by: Stefan Knoblich Tested-by: Stefan Knoblich --- libs/freetdm/Makefile.am | 2 +- libs/freetdm/configure.ac | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/Makefile.am b/libs/freetdm/Makefile.am index b3353f32de..63e04b6d0b 100644 --- a/libs/freetdm/Makefile.am +++ b/libs/freetdm/Makefile.am @@ -62,7 +62,7 @@ LINK = $(LIBTOOL) --mode=link --tag=CC $(CC) $(FTDM_CFLAGS) $(LDFLAGS) -o $ # EXTRA_DIST = freetdm.pc.in -pkgconfigdir = $(libdir)/pkgconfig +pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = freetdm.pc diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac index 1f4fc9c6ac..29661c1cdf 100644 --- a/libs/freetdm/configure.ac +++ b/libs/freetdm/configure.ac @@ -65,6 +65,18 @@ AC_ARG_WITH([modinstdir], ) AC_SUBST([modinstdir]) +# freetdm.pc pkgconfig file +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: ${libdir}/pkgconfig)])], + [case "${withval}" in + yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;; + *) pkgconfigdir="${withval}" ;; + esac + ], + [pkgconfigdir="${libdir}/pkgconfig"] +) +AC_SUBST([pkgconfigdir]) + AC_ARG_ENABLE([enable_64], [AS_HELP_STRING([--enable-64], [Enable 64bit compilation])], [enable_64="${enableval}"], From 78472897cdf1432fd3ceb9814ebee6b8376fd6e7 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Sat, 19 Feb 2011 23:38:04 +0100 Subject: [PATCH 004/104] Do not escape ${libdir} in --with-pkgconfigdir option's AS_HELP_STRING description parameter (not needed and ends up in output). Signed-off-by: Stefan Knoblich --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 0e45e064f1..7978d04754 100644 --- a/configure.in +++ b/configure.in @@ -94,7 +94,7 @@ AC_SUBST(bindir) AC_SUBST(includedir) AC_ARG_WITH([pkgconfigdir], - [AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: \${libdir}/pkgconfig)])], + [AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: ${libdir}/pkgconfig)])], [case "${withval}" in yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;; *) pkgconfigdir="${withval}" ;; From 180e3d4ab1943361610ca241d150565aad8d16fd Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sun, 20 Feb 2011 14:37:23 -0600 Subject: [PATCH 005/104] agc tweaks --- src/include/switch_resample.h | 9 ++ .../mod_conference/mod_conference.c | 84 +++++++++++++------ src/switch_resample.c | 37 ++++++++ 3 files changed, 104 insertions(+), 26 deletions(-) diff --git a/src/include/switch_resample.h b/src/include/switch_resample.h index b38e094dd6..3dff620c4b 100644 --- a/src/include/switch_resample.h +++ b/src/include/switch_resample.h @@ -39,6 +39,7 @@ */ #define switch_normalize_volume(x) if (x > 4) x = 4; if (x < -4) x = -4; +#define switch_normalize_volume_granular(x) if (x > 12) x = 12; if (x < -12) x = -12; #ifndef SWITCH_RESAMPLE_H #define SWITCH_RESAMPLE_H @@ -158,6 +159,14 @@ SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples \param vol the volume factor -4 -> 4 */ SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol); + +/*! + \brief Change the volume of a signed linear audio frame with more granularity + \param data the audio data + \param samples the number of 2 byte samples + \param vol the volume factor -12 -> 12 + */ +SWITCH_DECLARE(void) switch_change_sln_volume_granular(int16_t *data, uint32_t samples, int32_t vol); ///\} SWITCH_DECLARE(uint32_t) switch_merge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples); diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 5eeae5c781..8a3f53e17a 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -318,6 +318,7 @@ struct conference_member { switch_mutex_t *audio_in_mutex; switch_mutex_t *audio_out_mutex; switch_mutex_t *read_mutex; + switch_codec_implementation_t read_impl; switch_codec_implementation_t orig_read_impl; switch_codec_t read_codec; switch_codec_t write_codec; @@ -1942,14 +1943,37 @@ static void conference_loop_fn_hangup(conference_member_t *member, caller_contro switch_clear_flag_locked(member, MFLAG_RUNNING); } +static void check_agc_levels(conference_member_t *member) +{ + if (!member->avg_score) return; + + if (member->avg_score < member->conference->agc_level - 200) { + member->agc_volume_in_level++; + switch_normalize_volume_granular(member->agc_volume_in_level); + } else if (member->avg_score > member->conference->agc_level + 200) { + member->agc_volume_in_level--; + switch_normalize_volume_granular(member->agc_volume_in_level); + } + //} else { + //member->vol_period = (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 5; + //} +} + static void clear_avg(conference_member_t *member) { - member->agc_volume_in_level = 0; + if (member->agc_volume_in_level < -5) { + member->agc_volume_in_level = 0; + } + + if (member->conference->agc_level) { + check_agc_levels(member); + } + member->avg_score = 0; member->avg_itt = 0; member->avg_tally = 0; - member->nt_tally = 0; + member->agc_concur = 0; } @@ -1962,7 +1986,6 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_status_t status; switch_frame_t *read_frame = NULL; uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400; - switch_codec_implementation_t read_impl = { 0 }; switch_core_session_t *session = member->session; int check_floor_change; @@ -1972,7 +1995,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v channel = switch_core_session_get_channel(session); - switch_core_session_get_read_impl(session, &read_impl); + switch_core_session_get_read_impl(session, &member->read_impl); /* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it and mux it with any audio from other channels. */ @@ -1997,6 +2020,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } if (switch_test_flag(read_frame, SFF_CNG)) { + if (member->conference->agc_level) { + member->nt_tally++; + } + if (hangunder_hits) { hangunder_hits--; } @@ -2017,6 +2044,11 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v goto do_continue; } + + if (member->nt_tally > (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 3) { + member->agc_volume_in_level = 0; + clear_avg(member); + } /* Check for input volume adjustments */ if (!member->conference->agc_level) { @@ -2031,30 +2063,29 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v uint32_t energy = 0, i = 0, samples = 0, j = 0; int16_t *data; int divisor = 0; - int agc_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) / 2; - int combined_vol = 0; + int agc_period = (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) / 4; + data = read_frame->data; - if (!(divisor = read_impl.actual_samples_per_second / 8000)) { + if (!(divisor = member->read_impl.actual_samples_per_second / 8000)) { divisor = 1; } member->score = 0; - combined_vol = member->agc_volume_in_level; - if (member->conference->agc_level) { - combined_vol += member->agc_volume_in_level; + if (member->volume_in_level) { + switch_change_sln_volume(read_frame->data, read_frame->datalen / 2, member->volume_in_level); } - if (combined_vol) { - switch_change_sln_volume(read_frame->data, read_frame->datalen / 2, combined_vol); + if (member->agc_volume_in_level) { + switch_change_sln_volume_granular(read_frame->data, read_frame->datalen / 2, member->agc_volume_in_level); } if ((samples = read_frame->datalen / sizeof(*data))) { for (i = 0; i < samples; i++) { energy += abs(data[j]); - j += read_impl.number_of_channels; + j += member->read_impl.number_of_channels; } member->score = energy / (samples / divisor); } @@ -2082,22 +2113,14 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v - if (++member->nt_tally >= agc_period) { + if (++member->agc_concur >= agc_period) { if (!member->vol_period) { - if (member->avg_score < member->conference->agc_level) { - member->agc_volume_in_level++; - switch_normalize_volume(member->agc_volume_in_level); - member->vol_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) * 2; - } - - if (member->avg_score > member->conference->agc_level) { - member->agc_volume_in_level--; - switch_normalize_volume(member->agc_volume_in_level); - member->vol_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) * 2; - } + check_agc_levels(member); } - member->nt_tally = 0; + member->agc_concur = 0; } + } else { + member->nt_tally++; } member->score_iir = (int) (((1.0 - SCORE_DECAY) * (float) member->score) + (SCORE_DECAY * (float) member->score_iir)); @@ -2112,6 +2135,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v hangover_hits--; } + if (member->conference->agc_level) { + member->nt_tally = 0; + } + if (diff >= diff_level || ++hangunder_hits >= hangunder) { check_floor_change = 1; @@ -2147,6 +2174,11 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (hangunder_hits) { hangunder_hits--; } + + if (member->conference->agc_level) { + member->nt_tally++; + } + if (switch_test_flag(member, MFLAG_TALKING) && switch_test_flag(member, MFLAG_CAN_SPEAK)) { switch_event_t *event; if (++hangover_hits >= hangover) { diff --git a/src/switch_resample.c b/src/switch_resample.c index 10c633c01a..64656b6c61 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -269,6 +269,43 @@ SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, switch_size_t samples, u } +SWITCH_DECLARE(void) switch_change_sln_volume_granular(int16_t *data, uint32_t samples, int32_t vol) +{ + double newrate = 0; + double pos[12] = {1.25, 1.50, 1.75, 2.0, 2.25, 2.50, 2.75, 3.0, 3.25, 3.50, 3.75, 4.0}; + double neg[12] = {.917, .834, .751, .668, .585, .502, .419, .336, .253, .017, .087, .004}; + double *chart; + uint32_t i; + + if (vol == 0) return; + + switch_normalize_volume_granular(vol); + + if (vol > 0) { + chart = pos; + } else { + chart = neg; + } + + i = abs(vol) - 1; + + switch_assert(i < 12); + + newrate = chart[i]; + + if (newrate) { + int32_t tmp; + uint32_t x; + int16_t *fp = data; + + for (x = 0; x < samples; x++) { + tmp = (int32_t) fp[x] * newrate; + switch_normalize_to_16bit(tmp); + fp[x] = (int16_t) tmp; + } + } +} + SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol) { double newrate = 0; From 3cd120a02e28225cc89f6898a317fd4f93b0c138 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Sun, 20 Feb 2011 14:50:20 -0600 Subject: [PATCH 006/104] fix warning --- src/switch_resample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_resample.c b/src/switch_resample.c index 64656b6c61..949b351785 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -299,7 +299,7 @@ SWITCH_DECLARE(void) switch_change_sln_volume_granular(int16_t *data, uint32_t s int16_t *fp = data; for (x = 0; x < samples; x++) { - tmp = (int32_t) fp[x] * newrate; + tmp = (int32_t) (fp[x] * newrate); switch_normalize_to_16bit(tmp); fp[x] = (int16_t) tmp; } From 06988e1a36d0f6f8b35651d36fdab79ac8c63c5c Mon Sep 17 00:00:00 2001 From: Brian West Date: Sun, 20 Feb 2011 15:10:02 -0600 Subject: [PATCH 007/104] FS-3084 --- src/mod/endpoints/mod_sofia/sofia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 8a3d1b10f6..90193ac63a 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2135,7 +2135,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) register_transport = (char *) sofia_glue_transport2str(gateway->register_transport); - if (contact_params) { + if (! zstr(contact_params)) { if (*contact_params == ';') { params = switch_core_sprintf(gateway->pool, "%s;transport=%s;gw=%s", contact_params, register_transport, gateway->name); } else { From 4f5ca9e88dc1a94efa78878ca576d62345203ca2 Mon Sep 17 00:00:00 2001 From: Christopher Rienzo Date: Mon, 21 Feb 2011 15:00:35 +0000 Subject: [PATCH 008/104] FS-3077 prevent crash on double call to asr_close --- src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c index d5bac5f7f4..8698e4a02c 100644 --- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c +++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c @@ -3155,15 +3155,19 @@ static switch_status_t recog_asr_disable_all_grammars(switch_asr_handle_t *ah) static switch_status_t recog_asr_close(switch_asr_handle_t *ah, switch_asr_flag_t *flags) { speech_channel_t *schannel = (speech_channel_t *) ah->private_info; - recognizer_data_t *r = (recognizer_data_t *) schannel->data; - speech_channel_stop(schannel); - speech_channel_destroy(schannel); - switch_core_hash_destroy(&r->grammars); - switch_core_hash_destroy(&r->enabled_grammars); - if (r->dtmf_generator) { - mpf_dtmf_generator_destroy(r->dtmf_generator); - } + recognizer_data_t *r = NULL; + /* close if not already closed */ + if (schannel != NULL && !switch_test_flag(ah, SWITCH_ASR_FLAG_CLOSED)) { + r = (recognizer_data_t *) schannel->data; + speech_channel_stop(schannel); + speech_channel_destroy(schannel); + switch_core_hash_destroy(&r->grammars); + switch_core_hash_destroy(&r->enabled_grammars); + if (r->dtmf_generator) { + mpf_dtmf_generator_destroy(r->dtmf_generator); + } + } /* this lets FreeSWITCH's speech_thread know the handle is closed */ switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED); From 38b430f43f52efda748ceabb47341fca284103b0 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 10:51:26 -0600 Subject: [PATCH 009/104] FS-3057 --- src/switch_rtp.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index d0c22ce585..bbb0468775 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -2396,7 +2396,7 @@ static void do_flush(switch_rtp_t *rtp_session) #define return_cng_frame() do_cng = 1; goto timer_check -static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes, switch_frame_flag_t *flags) +static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes, switch_frame_flag_t *flags, switch_bool_t return_jb_packet) { switch_status_t status = SWITCH_STATUS_FALSE; stfu_frame_t *jb_frame; @@ -2493,8 +2493,11 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t stfu_n_eat(rtp_session->jb, rtp_session->last_read_ts, rtp_session->recv_msg.header.pt, rtp_session->recv_msg.body, *bytes - rtp_header_len, rtp_session->timer.samplecount); - *bytes = 0; status = SWITCH_STATUS_FALSE; + if (!return_jb_packet) { + return status; + } + *bytes = 0; } if (rtp_session->jb && !rtp_session->pause_jb && !rtp_session->checked_jb) { @@ -2668,17 +2671,19 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ if ((switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOFLUSH) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_STICKY_FLUSH)) && rtp_session->read_pollfd) { if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) { - status = read_rtp_packet(rtp_session, &bytes, flags); - /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initial %d\n", bytes); */ - read_pretriggered = 1; + status = read_rtp_packet(rtp_session, &bytes, flags, SWITCH_FALSE); + /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initial (%i) %d\n", status, bytes); */ + if (status != SWITCH_STATUS_FALSE) { + read_pretriggered = 1; + } - if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) { - /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Trigger %d\n", rtp_session->hot_hits); */ - rtp_session->hot_hits += rtp_session->samples_per_interval; - } else { - rtp_session->hot_hits = 0; - switch_core_timer_sync(&rtp_session->timer); - goto recvfrom; + if (bytes) { + if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) { + /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Trigger %d\n", rtp_session->hot_hits); */ + rtp_session->hot_hits += rtp_session->samples_per_interval; + } else { + rtp_session->hot_hits = 0; + } } if (rtp_session->hot_hits >= rtp_session->samples_per_second * 5) { @@ -2737,9 +2742,11 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ } if (poll_status == SWITCH_STATUS_SUCCESS) { - if (!read_pretriggered) { - status = read_rtp_packet(rtp_session, &bytes, flags); - /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Read bytes %d\n", bytes); */ + if (read_pretriggered) { + read_pretriggered = 0; + } else { + status = read_rtp_packet(rtp_session, &bytes, flags, SWITCH_TRUE); + /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Read bytes (%i) %d\n", status, bytes); */ } } else { if (!SWITCH_STATUS_IS_BREAK(poll_status) && poll_status != SWITCH_STATUS_TIMEOUT) { From 4e60f14a4d0e942aef7973546dbe040ef330640f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 11:02:42 -0600 Subject: [PATCH 010/104] FS-3072 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 4853dff3bf..7125bceb7c 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -3513,7 +3513,7 @@ SWITCH_STANDARD_API(sofia_contact_function) profile = sofia_glue_find_profile(profile_name); } - if (!profile) { + if (!profile && !zstr(domain)) { profile = sofia_glue_find_profile(domain); } } From 4a4ac354268cd7699bc2f39e8e728acbf3855703 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 13:12:51 -0600 Subject: [PATCH 011/104] another round of agc changes --- .../mod_conference/mod_conference.c | 81 ++++++++++--------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 8a3f53e17a..92ca1042a0 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -266,7 +266,6 @@ typedef struct conference_obj { switch_thread_rwlock_t *rwlock; uint32_t count; int32_t energy_level; - int32_t agc_energy_level; uint8_t min; switch_speech_handle_t lsh; switch_speech_handle_t *sh; @@ -1943,6 +1942,28 @@ static void conference_loop_fn_hangup(conference_member_t *member, caller_contro switch_clear_flag_locked(member, MFLAG_RUNNING); } + +static int noise_gate_check(conference_member_t *member) +{ + int r = 0; + + + if (member->conference->agc_level && member->agc_volume_in_level != 0) { + int target_score = 0; + + target_score = (member->energy_level + (25 * member->agc_volume_in_level)); + + if (target_score < 0) target_score = 0; + + r = member->score > target_score; + + } else { + r = member->score > member->energy_level; + } + + return r; +} + static void check_agc_levels(conference_member_t *member) { if (!member->avg_score) return; @@ -1954,6 +1975,9 @@ static void check_agc_levels(conference_member_t *member) member->agc_volume_in_level--; switch_normalize_volume_granular(member->agc_volume_in_level); } + + + //} else { //member->vol_period = (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 5; //} @@ -1962,9 +1986,9 @@ static void check_agc_levels(conference_member_t *member) static void clear_avg(conference_member_t *member) { - if (member->agc_volume_in_level < -5) { - member->agc_volume_in_level = 0; - } + //if (member->agc_volume_in_level < -5) { + //member->agc_volume_in_level = 0; + //} if (member->conference->agc_level) { check_agc_levels(member); @@ -1985,7 +2009,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_channel_t *channel; switch_status_t status; switch_frame_t *read_frame = NULL; - uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400; + uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, diff_level = 400; switch_core_session_t *session = member->session; int check_floor_change; @@ -2049,13 +2073,17 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v member->agc_volume_in_level = 0; clear_avg(member); } + + if (member->avg_itt > (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 3) { + clear_avg(member); + } + /* Check for input volume adjustments */ if (!member->conference->agc_level) { clear_avg(member); } - energy_level = member->energy_level; /* if the member can speak, compute the audio energy level and */ /* generate events when the level crosses the threshold */ @@ -2096,9 +2124,9 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (member->conference->agc_level && member->score && switch_test_flag(member, MFLAG_CAN_SPEAK) && - member->score > member->conference->agc_energy_level + noise_gate_check(member) ) { - + member->avg_tally += member->score; member->avg_itt++; if (!member->avg_itt) member->avg_itt++; @@ -2129,8 +2157,8 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v member->score_iir = SCORE_MAX_IIR; } - if (member->score > energy_level) { - uint32_t diff = member->score - energy_level; + if (noise_gate_check(member)) { + uint32_t diff = member->score - member->energy_level; if (hangover_hits) { hangover_hits--; } @@ -2198,7 +2226,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } /* skip frames that are not actual media or when we are muted or silent */ - if ((switch_test_flag(member, MFLAG_TALKING) || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) && + if ((switch_test_flag(member, MFLAG_TALKING) || member->energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) && !switch_test_flag(member->conference, CFLAG_WAIT_MOD)) { switch_audio_resampler_t *read_resampler = member->read_resampler; void *data; @@ -3444,7 +3472,7 @@ static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_str static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) { - int level, energy_level; + int level; int on = 0; if (argc == 2) { @@ -3462,13 +3490,7 @@ static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_str if (argc > 3) { level = atoi(argv[3]); } else { - level = 650; - } - - if (argc > 4) { - energy_level = atoi(argv[4]); - } else { - energy_level = 100; + level = 1200; } if (level > conference->energy_level) { @@ -3476,10 +3498,9 @@ static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_str conference->avg_itt = 0; conference->avg_tally = 0; conference->agc_level = level; - conference->agc_energy_level = energy_level; if (stream) { - stream->write_function(stream, "OK AGC ENABLED %d %d\n", conference->agc_level, conference->agc_energy_level); + stream->write_function(stream, "OK AGC ENABLED %d\n", conference->agc_level); } } else { @@ -3853,7 +3874,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer if (conference->agc_level) { char tmp[30] = ""; - switch_snprintf(tmp, sizeof(tmp), "%d:%d", conference->agc_level, conference->agc_energy_level); + switch_snprintf(tmp, sizeof(tmp), "%d", conference->agc_level); switch_xml_set_attr_d_buf(x_conference, "agc", tmp); } @@ -6421,30 +6442,16 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c if (!zstr(auto_gain_level)) { int level = 0; - int energy_level = 100; if (switch_true(auto_gain_level)) { - level = 650; + level = 1200; } else { - char *p; - int tmp = 0; - level = atoi(auto_gain_level); - if ((p = strchr(auto_gain_level, ':'))) { - p++; - if (p) tmp = atoi(p); - if (tmp > 0) { - energy_level = tmp; - } - } } if (level > 0 && level > conference->energy_level) { conference->agc_level = level; } - - conference->agc_energy_level = energy_level; - } if (!zstr(maxmember_sound)) { From 1ba1c57eff854f13e34e8f03a012f5442cb69b36 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 13:28:41 -0600 Subject: [PATCH 012/104] move jb debug to level 8 --- src/switch_rtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index bbb0468775..f06771880c 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1830,7 +1830,7 @@ static void jb_callback(stfu_instance_t *i, void *udata) stfu_n_report(i, &r); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG8, "%s JB REPORT:\nlen: %u\nin: %u\nclean: %u\ngood: %u\nbad: %u\n", switch_core_session_get_name(session), r.qlen, From a79b64ee2016ba90af72821990d8ae678c96623d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 14:35:13 -0600 Subject: [PATCH 013/104] more agc --- .../mod_conference/mod_conference.c | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 92ca1042a0..1fc4ed58ba 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -311,6 +311,7 @@ struct conference_member { switch_buffer_t *resample_buffer; uint32_t flags; uint32_t score; + uint32_t last_score; uint32_t score_iir; switch_mutex_t *flag_mutex; switch_mutex_t *write_mutex; @@ -2126,20 +2127,26 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_test_flag(member, MFLAG_CAN_SPEAK) && noise_gate_check(member) ) { + int last_shift = abs(member->last_score - member->score); - member->avg_tally += member->score; - member->avg_itt++; - if (!member->avg_itt) member->avg_itt++; - member->avg_score = member->avg_tally / member->avg_itt; - + if (member->score && member->last_score && last_shift > 900) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7, + "AGC %s:%d drop anomalous shift of %d\n", + member->conference->name, + member->id, last_shift); + + } else { + member->avg_tally += member->score; + member->avg_itt++; + if (!member->avg_itt) member->avg_itt++; + member->avg_score = member->avg_tally / member->avg_itt; + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7, - "conf %s AGC %d %d %d %d %d %d\n", + "AGC %s:%d diff:%d level:%d cur:%d avg:%d vol:%d\n", member->conference->name, member->id, member->conference->agc_level - member->avg_score, member->conference->agc_level, member->score, member->avg_score, member->agc_volume_in_level); - - if (++member->agc_concur >= agc_period) { if (!member->vol_period) { @@ -2223,6 +2230,9 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } } } + + + member->last_score = member->score; } /* skip frames that are not actual media or when we are muted or silent */ @@ -3490,7 +3500,7 @@ static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_str if (argc > 3) { level = atoi(argv[3]); } else { - level = 1200; + level = 1400; } if (level > conference->energy_level) { @@ -6444,7 +6454,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c int level = 0; if (switch_true(auto_gain_level)) { - level = 1200; + level = 1400; } else { level = atoi(auto_gain_level); } From e431481d4d45ca13c4d2f929f4ef0f23521fe922 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 17:16:34 -0600 Subject: [PATCH 014/104] agc --- .../mod_conference/mod_conference.c | 82 +++++++++---------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 1fc4ed58ba..53b3bfcaca 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -36,7 +36,8 @@ * */ #include -//#define INTENSE_DEBUG +#define DEFAULT_AGC_LEVEL 1000 + SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown); SWITCH_MODULE_DEFINITION(mod_conference, mod_conference_load, mod_conference_shutdown, NULL); @@ -1965,42 +1966,44 @@ static int noise_gate_check(conference_member_t *member) return r; } -static void check_agc_levels(conference_member_t *member) -{ - if (!member->avg_score) return; - - if (member->avg_score < member->conference->agc_level - 200) { - member->agc_volume_in_level++; - switch_normalize_volume_granular(member->agc_volume_in_level); - } else if (member->avg_score > member->conference->agc_level + 200) { - member->agc_volume_in_level--; - switch_normalize_volume_granular(member->agc_volume_in_level); - } - - - - //} else { - //member->vol_period = (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 5; - //} -} - static void clear_avg(conference_member_t *member) { - //if (member->agc_volume_in_level < -5) { - //member->agc_volume_in_level = 0; - //} - - if (member->conference->agc_level) { - check_agc_levels(member); - } - member->avg_score = 0; member->avg_itt = 0; member->avg_tally = 0; member->agc_concur = 0; } +static void check_agc_levels(conference_member_t *member) +{ + int x = 0; + + if (!member->avg_score) return; + + if (member->avg_score < member->conference->agc_level - 100) { + member->agc_volume_in_level++; + switch_normalize_volume_granular(member->agc_volume_in_level); + x = 1; + } else if (member->avg_score > member->conference->agc_level + 100) { + member->agc_volume_in_level--; + switch_normalize_volume_granular(member->agc_volume_in_level); + x = -1; + } + + if (x) { + 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, + member->id, member->conference->agc_level - member->avg_score, member->conference->agc_level, + member->score, member->avg_score, member->agc_volume_in_level, x > 0 ? "+++" : "---"); + + clear_avg(member); + } +} + + + /* marshall frames from the call leg to the conference thread for muxing to other call legs */ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj) @@ -2056,6 +2059,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (++hangover_hits >= hangover) { hangover_hits = hangunder_hits = 0; switch_clear_flag_locked(member, MFLAG_TALKING); + check_agc_levels(member); clear_avg(member); if (test_eflag(member->conference, EFLAG_STOP_TALKING) && @@ -2075,13 +2079,9 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v clear_avg(member); } - if (member->avg_itt > (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 3) { - clear_avg(member); - } - - /* Check for input volume adjustments */ if (!member->conference->agc_level) { + member->conference->agc_level = 0; clear_avg(member); } @@ -2091,16 +2091,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if ((switch_test_flag(member, MFLAG_CAN_SPEAK) || switch_test_flag(member, MFLAG_MUTE_DETECT))) { uint32_t energy = 0, i = 0, samples = 0, j = 0; int16_t *data; - int divisor = 0; int agc_period = (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) / 4; data = read_frame->data; - - if (!(divisor = member->read_impl.actual_samples_per_second / 8000)) { - divisor = 1; - } - member->score = 0; if (member->volume_in_level) { @@ -2116,7 +2110,8 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v energy += abs(data[j]); j += member->read_impl.number_of_channels; } - member->score = energy / (samples / divisor); + + member->score = energy / samples; } if (member->vol_period) { @@ -2219,8 +2214,9 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (++hangover_hits >= hangover) { hangover_hits = hangunder_hits = 0; switch_clear_flag_locked(member, MFLAG_TALKING); + check_agc_levels(member); clear_avg(member); - + if (test_eflag(member->conference, EFLAG_STOP_TALKING) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_member_data(member, event); @@ -3500,7 +3496,7 @@ static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_str if (argc > 3) { level = atoi(argv[3]); } else { - level = 1400; + level = DEFAULT_AGC_LEVEL; } if (level > conference->energy_level) { @@ -6454,7 +6450,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c int level = 0; if (switch_true(auto_gain_level)) { - level = 1400; + level = DEFAULT_AGC_LEVEL; } else { level = atoi(auto_gain_level); } From f6dd557e5db9dacede48d26c98aee639378612f9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 17:24:35 -0600 Subject: [PATCH 015/104] agc --- src/mod/applications/mod_conference/mod_conference.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 53b3bfcaca..71ed1ed4b7 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -36,7 +36,7 @@ * */ #include -#define DEFAULT_AGC_LEVEL 1000 +#define DEFAULT_AGC_LEVEL 1100 SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown); From b61fc39622ce76067852f142dcc5ec53a56c1c30 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 20:01:01 -0600 Subject: [PATCH 016/104] add support for bz2 to getlibs --- build/getlib.sh.in | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/build/getlib.sh.in b/build/getlib.sh.in index ebad7b5084..a42fe3a58f 100755 --- a/build/getlib.sh.in +++ b/build/getlib.sh.in @@ -1,5 +1,8 @@ #!/bin/sh +bz="false" + +BUNZUP=/usr/bin/bunzip2 TAR=@TAR@ ZCAT=@ZCAT@ WGET=@WGET@ @@ -17,14 +20,26 @@ base=http://files.freeswitch.org/downloads/libs/ tarfile=$1 url=`echo $tarfile | grep "://"` +if [ `echo $tarfile | grep bz2` ] ; then + bz="true" + UNZIPPER=$BUNZIP +else + UNZIPPER=$ZCAT +fi + if [ ! -z $url ] ; then base=$tarfile/ tarfile=$2 fi if [ ! -d $tarfile ] ; then - uncompressed=`echo $tarfile | sed "s/\.tar\.gz//g"` - uncompressed=`echo $uncompressed | sed "s/\.tgz//g"` + + if [ $bz = "true" ] ; then + uncompressed=`echo $tarfile | sed "s/\.tar\.bz2//g"` + else + uncompressed=`echo $tarfile | sed "s/\.tar\.gz//g"` + uncompressed=`echo $uncompressed | sed "s/\.tgz//g"` + fi if [ ! -f $tarfile ] ; then rm -fr $uncompressed @@ -35,7 +50,7 @@ if [ ! -d $tarfile ] ; then fi fi if [ ! -d $uncompressed ] ; then - $ZCAT -c -d $tarfile | $TAR xf - + $UNZIPPER -c -d $tarfile | $TAR xf - fi fi From 079f3f73ed63733b5642ae3b49ec5cf66db2d6dc Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 20:01:46 -0600 Subject: [PATCH 017/104] bump mod_shout to use mpg123-1.13.2 to hopefully address unwanted calls to exit() and inherit other upstream fixes --- src/mod/formats/mod_shout/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/formats/mod_shout/Makefile b/src/mod/formats/mod_shout/Makefile index 0ff6fc6525..7388bc0c67 100644 --- a/src/mod/formats/mod_shout/Makefile +++ b/src/mod/formats/mod_shout/Makefile @@ -1,6 +1,6 @@ LAME=lame-3.97 SHOUT=libshout-2.2.2 -MPG123=mpg123 +MPG123=mpg123-1.13.2 BASE=../../../.. WANT_CURL=yes From e7acd4d138e0faa6b4a3cec1667015c430e8f3f6 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Feb 2011 20:17:58 -0600 Subject: [PATCH 018/104] FS-3054 re-open if this does not fix it. --- .../endpoints/mod_dingaling/mod_dingaling.c | 6 ++-- src/mod/endpoints/mod_sofia/mod_sofia.c | 35 ++++++++++++++++--- src/switch_nat.c | 6 ++-- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 9fb1f39e11..f9f0788c93 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -596,9 +596,9 @@ static void ipchanged_event_handler(switch_event_t *event) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n"); - if (cond && !strcmp(cond, "network-address-change")) { - const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4"); - const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4"); + if (cond && !strcmp(cond, "network-external-address-change")) { + const char *old_ip4 = switch_event_get_header_nil(event, "network-external-address-previous-v4"); + const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4"); switch_hash_index_t *hi; void *val; char *tmp; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 7125bceb7c..dff33ee6f5 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -4587,17 +4587,42 @@ static void general_event_handler(switch_event_t *event) case SWITCH_EVENT_TRAP: { const char *cond = switch_event_get_header(event, "condition"); + switch_hash_index_t *hi; + const void *var; + void *val; + sofia_profile_t *profile; + if (zstr(cond)) { + cond = ""; + } - if (cond && !strcmp(cond, "network-address-change") && mod_sofia_globals.auto_restart) { + if (!strcmp(cond, "network-external-address-change") && mod_sofia_globals.auto_restart) { + const char *old_ip4 = switch_event_get_header_nil(event, "network-external-address-previous-v4"); + const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4"); + + switch_mutex_lock(mod_sofia_globals.hash_mutex); + if (mod_sofia_globals.profile_hash) { + for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &var, NULL, &val); + + if ((profile = (sofia_profile_t *) val)) { + if (!strcmp(profile->extsipip, old_ip4)) { + profile->extsipip = switch_core_strdup(profile->pool, new_ip4); + } + + if (!strcmp(profile->extrtpip, old_ip4)) { + profile->extrtpip = switch_core_strdup(profile->pool, new_ip4); + } + } + } + } + switch_mutex_unlock(mod_sofia_globals.hash_mutex); + sofia_glue_restart_all_profiles(); + } else if (!strcmp(cond, "network-address-change") && mod_sofia_globals.auto_restart) { const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4"); const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4"); const char *old_ip6 = switch_event_get_header_nil(event, "network-address-previous-v6"); const char *new_ip6 = switch_event_get_header_nil(event, "network-address-change-v6"); - switch_hash_index_t *hi; - const void *var; - void *val; - sofia_profile_t *profile; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IP change detected [%s]->[%s] [%s]->[%s]\n", old_ip4, new_ip4, old_ip6, new_ip6); diff --git a/src/switch_nat.c b/src/switch_nat.c index 85b0247d6d..d9110efe18 100644 --- a/src/switch_nat.c +++ b/src/switch_nat.c @@ -325,9 +325,9 @@ static void *SWITCH_THREAD_FUNC switch_nat_multicast_runtime(switch_thread_t * t do_repub = SWITCH_TRUE; switch_event_create(&event, SWITCH_EVENT_TRAP); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "network-address-change"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-address-previous-v4", nat_globals.pub_addr); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-address-change-v4", newip); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "network-external-address-change"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-external-address-previous-v4", nat_globals.pub_addr); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-external-address-change-v4", newip); switch_event_fire(&event); switch_set_string(nat_globals.pub_addr, newip); From f28c211c0c69c8f34a8c483cbb5de379a2b96b84 Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 22 Feb 2011 09:56:07 -0600 Subject: [PATCH 019/104] FS-3077 --- src/switch_ivr_async.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index be360138c2..3afbfb6397 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -3216,8 +3216,10 @@ static switch_status_t speech_on_dtmf(switch_core_session_t *session, const swit switch_status_t status = SWITCH_STATUS_SUCCESS; switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; - if (switch_core_asr_feed_dtmf(sth->ah, dtmf, &flags) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Feeding DTMF\n"); + if (sth) { + if (switch_core_asr_feed_dtmf(sth->ah, dtmf, &flags) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Feeding DTMF\n"); + } } return status; @@ -3231,6 +3233,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_detect_speech(switch_core_sessio switch_assert(channel != NULL); if ((sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY))) { switch_channel_set_private(channel, SWITCH_SPEECH_KEY, NULL); + switch_core_event_hook_remove_recv_dtmf(session, speech_on_dtmf); switch_core_media_bug_remove(session, &sth->bug); return SWITCH_STATUS_SUCCESS; } @@ -3265,14 +3268,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_resume_detect_speech(switch_core_sess SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, char *grammar, char *name) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_load_grammar(sth->ah, grammar, name)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error loading Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3307,14 +3309,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_start_input_timers(swit SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_core_session_t *session, const char *name) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_unload_grammar(sth->ah, name)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error unloading Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3324,14 +3325,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_c SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_enable_grammar(switch_core_session_t *session, const char *name) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_enable_grammar(sth->ah, name)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error enabling Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3341,14 +3341,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_enable_grammar(switch_c SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_grammar(switch_core_session_t *session, const char *name) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_disable_grammar(sth->ah, name)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error disabling Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3358,14 +3357,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_grammar(switch_ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_all_grammars(switch_core_session_t *session) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_disable_all_grammars(sth->ah)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error disabling all Grammars\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3397,7 +3395,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t * if (sth) { if (switch_core_asr_load_grammar(sth->ah, grammar, name) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error loading Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); return SWITCH_STATUS_FALSE; } From 3116334d277b0f69305434388bd56f32ae1cb2e6 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 22 Feb 2011 13:16:16 -0600 Subject: [PATCH 020/104] FS-3086 --comment-only This should fix the 'hupall' based lockups --- src/switch_core_session.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/switch_core_session.c b/src/switch_core_session.c index d2e28de523..dfe419ed15 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -203,16 +203,12 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); if (val) { - const char *this_val; session = (switch_core_session_t *) val; if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { - if (switch_channel_up(session->channel) && - (this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) { - np = switch_core_alloc(pool, sizeof(*np)); - np->str = switch_core_strdup(pool, session->uuid_str); - np->next = head; - head = np; - } + np = switch_core_alloc(pool, sizeof(*np)); + np->str = switch_core_strdup(pool, session->uuid_str); + np->next = head; + head = np; switch_core_session_rwunlock(session); } } @@ -221,7 +217,11 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam for(np = head; np; np = np->next) { if ((session = switch_core_session_locate(np->str))) { - switch_channel_hangup(session->channel, cause); + const char *this_val; + if (switch_channel_up(session->channel) && + (this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) { + switch_channel_hangup(session->channel, cause); + } switch_core_session_rwunlock(session); } } From e8a1055854bb4cc7037f3be434e261280714dfdf Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 22 Feb 2011 17:07:18 -0600 Subject: [PATCH 021/104] ESL-56 null terminate buffer after reading from the socket to prevent cross-over to old data that confuses the parser and throws off framing. (regression from 2081bf97b9836f5299c22edbb1ead077842ea2bc) --- libs/esl/src/esl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c index 078c5de973..cd103ecd17 100644 --- a/libs/esl/src/esl.c +++ b/libs/esl/src/esl.c @@ -949,15 +949,18 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ while(!revent && handle->connected) { esl_size_t len1; - if ((len1 = esl_buffer_read_packet(handle->packet_buf, handle->socket_buf, sizeof(handle->socket_buf)))) { + if ((len1 = esl_buffer_read_packet(handle->packet_buf, handle->socket_buf, sizeof(handle->socket_buf) - 1))) { char *data = (char *) handle->socket_buf; char *p, *e; + + *(data + len1) = '\0'; esl_event_create(&revent, ESL_EVENT_CLONE); revent->event_id = ESL_EVENT_SOCKET_DATA; esl_event_add_header_string(revent, ESL_STACK_BOTTOM, "Event-Name", "SOCKET_DATA"); hname = p = data; + while(p) { hname = p; p = NULL; @@ -984,7 +987,8 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ break; } - rrval = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf)); + rrval = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1); + *((char *)handle->socket_buf + rrval) = '\0'; if (rrval == 0) { if (++zc >= 100) { @@ -1020,7 +1024,8 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_ if (s >= len) { sofar = esl_buffer_read(handle->packet_buf, body, len); } else { - r = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf)); + r = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1); + *((char *)handle->socket_buf + r) = '\0'; if (r < 0) { strerror_r(handle->errnum, handle->err, sizeof(handle->err)); From 0dcdd78cb5ba84f940fdcf0dfefcfb7ee17cc0c6 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 22 Feb 2011 17:22:01 -0600 Subject: [PATCH 022/104] FS-3054 --comment-only try latest commit, I can guess what probably causes the seg based on my last patch --- src/mod/endpoints/mod_sofia/mod_sofia.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index dff33ee6f5..9e8d8200f4 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -4601,16 +4601,16 @@ static void general_event_handler(switch_event_t *event) const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4"); switch_mutex_lock(mod_sofia_globals.hash_mutex); - if (mod_sofia_globals.profile_hash) { + if (mod_sofia_globals.profile_hash && !zstr(old_ip4) && !zstr(new_ip4)) { for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, &var, NULL, &val); if ((profile = (sofia_profile_t *) val)) { - if (!strcmp(profile->extsipip, old_ip4)) { + if (!zstr(profile->extsipip) && !strcmp(profile->extsipip, old_ip4)) { profile->extsipip = switch_core_strdup(profile->pool, new_ip4); } - if (!strcmp(profile->extrtpip, old_ip4)) { + if (!zstr(profile->extrtpip) && !strcmp(profile->extrtpip, old_ip4)) { profile->extrtpip = switch_core_strdup(profile->pool, new_ip4); } } From f202328effa33588b3766a63ca0a7f6ab835ef76 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Wed, 23 Feb 2011 00:31:26 +0100 Subject: [PATCH 023/104] Doc: somes details on user registration functions --- src/include/switch_core.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 984b54fac7..9505fe4c40 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2227,9 +2227,33 @@ SWITCH_DECLARE(const char *) switch_core_banner(void); SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session); SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number); +/*! + \brief Add user registration + \param [in] user + \param [in] realm + \param [in] token + \param [in] url - a freeswitch dial string + \param [in] expires + \param [in] network_ip + \param [in] network_port + \param [in] network_proto - one of tls, tcp, udp + \param [out] err - Error if it exists +*/ SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires, const char *network_ip, const char *network_port, const char *network_proto); +/*! + \brief Delete user registration + \param [in] user + \param [in] realm + \param [in] token + \param [out] err - Error if it exists +*/ SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, const char *realm, const char *token); +/*! + \brief Expire user registrations + \param [in] force delete all registrations + \param [out] err - Error if it exists +*/ SWITCH_DECLARE(switch_status_t) switch_core_expire_registration(int force); SWITCH_END_EXTERN_C From ea29a1dfcc53729af1e7798050a62566700d99fa Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Wed, 23 Feb 2011 00:56:00 +0100 Subject: [PATCH 024/104] centralized registration: - allow infinite registrations (expire=0) - when removing a registration, keep the other with same user if multiple reg is allowed --- src/switch_core_sqldb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 1274213893..2a6f9e3bf2 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -1696,7 +1696,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, c return SWITCH_STATUS_FALSE; } - sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", user, realm, switch_core_get_hostname()); + if (!zstr(token) && runtime.multiple_registrations) { + sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q' and token='%q'", user, realm, switch_core_get_hostname(), token); + } else { + sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", user, realm, switch_core_get_hostname()); + } switch_cache_db_execute_sql(dbh, sql, NULL); switch_cache_db_release_db_handle(&dbh); @@ -1723,7 +1727,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_expire_registration(int force) if (force) { sql = switch_mprintf("delete from registrations where hostname='%q'", switch_core_get_hostname()); } else { - sql = switch_mprintf("delete from registrations where expires <= %ld and hostname='%q'", now, switch_core_get_hostname()); + sql = switch_mprintf("delete from registrations where expires > 0 and expires <= %ld and hostname='%q'", now, switch_core_get_hostname()); } switch_cache_db_execute_sql(dbh, sql, NULL); From e7a8189b2b87d600c290998772d0aa53c26bc964 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Wed, 23 Feb 2011 00:57:19 +0100 Subject: [PATCH 025/104] Skinny: centralized registration --- src/mod/endpoints/mod_skinny/mod_skinny.c | 27 ++++++++++++++++++++ src/mod/endpoints/mod_skinny/skinny_server.c | 10 ++++++++ 2 files changed, 37 insertions(+) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 5320ca52d1..91d81dacf2 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1243,6 +1243,21 @@ static void walk_listeners(skinny_listener_callback_func_t callback, void *pvt) switch_mutex_unlock(globals.mutex); } +static int flush_listener_callback(void *pArg, int argc, char **argv, char **columnNames) +{ + char *profile_name = argv[0]; + char *value = argv[1]; + char *domain_name = argv[2]; + char *device_name = argv[3]; + char *device_instance = argv[4]; + + char *token = switch_mprintf("skinny/%q/%q/%q:%q", profile_name, value, device_name, device_instance); + switch_core_del_registration(value, domain_name, token); + switch_safe_free(token); + + return 0; +} + static void flush_listener(listener_t *listener) { @@ -1250,6 +1265,18 @@ static void flush_listener(listener_t *listener) skinny_profile_t *profile = listener->profile; char *sql; + if ((sql = switch_mprintf( + "SELECT '%q', value, '%q', '%q', '%d' " + "FROM skinny_lines " + "WHERE device_name='%s' AND device_instance=%d " + "ORDER BY position", + profile->name, profile->domain, listener->device_name, listener->device_instance, + listener->device_name, listener->device_instance + ))) { + skinny_execute_sql_callback(profile, profile->sql_mutex, sql, flush_listener_callback, NULL); + switch_safe_free(sql); + } + if ((sql = switch_mprintf( "DELETE FROM skinny_devices " "WHERE name='%s' and instance=%d", diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index e7c761dfca..7d66a9c281 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -1006,6 +1006,10 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r } if ((xbuttons = switch_xml_child(xskinny, "buttons"))) { uint32_t line_instance = 1; + char *network_ip = inet_ntoa(request->data.reg.ip); + int network_port = 0; + char network_port_c[6]; + snprintf(network_port_c, sizeof(network_port_c), "%d", network_port); for (xbutton = switch_xml_child(xbuttons, "button"); xbutton; xbutton = xbutton->next) { uint32_t position = atoi(switch_xml_attr_soft(xbutton, "position")); uint32_t type = skinny_str2button(switch_xml_attr_soft(xbutton, "type")); @@ -1031,8 +1035,14 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r label, value, caller_name, ring_on_idle, ring_on_active, busy_trigger, forward_all, forward_busy, forward_noanswer, noanswer_duration))) { + char *token, *url; skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); + token = switch_mprintf("skinny/%q/%q/%q:%d", profile->name, value, request->data.reg.device_name, request->data.reg.instance); + url = switch_mprintf("skinny/%q/%q", profile->name, value); + switch_core_add_registration(value, profile->domain, token, url, 0, network_ip, network_port_c, "tcp"); + switch_safe_free(token); + switch_safe_free(url); } if (line_instance == 1) { switch_event_t *message_query_event = NULL; From 0a14839bf9e760fa10b186d4ea5ab561a508902b Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Wed, 23 Feb 2011 00:58:05 +0100 Subject: [PATCH 026/104] Skinny: mark ring ready --- src/mod/endpoints/mod_skinny/skinny_server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 7d66a9c281..538100359f 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -555,6 +555,7 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance); send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_BLINK); send_set_ringer(listener, SKINNY_RING_INSIDE, SKINNY_RING_FOREVER, 0, helper->tech_pvt->call_id); + switch_channel_mark_ring_ready(channel); } return 0; } From e0a0a56f240ec397d2074cf28d3c9976ab3bfd83 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Wed, 23 Feb 2011 01:13:00 +0100 Subject: [PATCH 027/104] mod_command reg_url: correct field name --- src/mod/applications/mod_commands/mod_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 517134d2e1..a6df087cb0 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -90,11 +90,11 @@ static switch_status_t select_url(const char *user, if (exclude_contact) { sql = switch_mprintf("select url, '%q' " - "from registrations where user='%q' and realm='%q' " + "from registrations where reg_user='%q' and realm='%q' " "and url not like '%%%s%%'", (concat != NULL) ? concat : "", user, domain, exclude_contact); } else { sql = switch_mprintf("select url, '%q' " - "from registrations where user='%q' and realm='%q'", + "from registrations where reg_user='%q' and realm='%q'", (concat != NULL) ? concat : "", user, domain); } From b53a68484361c9581a26f6b090a58b0803bd412d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 22 Feb 2011 18:35:54 -0600 Subject: [PATCH 028/104] fix bug in switch_itodtmf from a8f5bf60a87fb27420846bd9d9af5e61f1f947d6 --- src/include/switch_utils.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index a1a93c6ac8..7fcb1e8c75 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -189,10 +189,12 @@ static inline char switch_itodtmf(char i) char r = i; if (i > 9 && i < 14) { - r = i + 55; + r += 55; + } else { + r += 48; } - return r + 48; + return r; } static inline int switch_dtmftoi(char *s) From cb6f1ed61da20672600db792d3a86e051fa484c5 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Tue, 22 Feb 2011 20:25:16 -0500 Subject: [PATCH 029/104] Fix storage class for 'cause' in user_outgoing_channel() so that each call has its very own hangup cause --- src/mod/applications/mod_dptools/mod_dptools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 9a1258a5b6..346cdaa9f8 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -2893,7 +2893,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params; char *user = NULL, *domain = NULL, *dup_domain = NULL; const char *dest = NULL; - static switch_call_cause_t cause = SWITCH_CAUSE_NONE; + switch_call_cause_t cause = SWITCH_CAUSE_NONE; unsigned int timelimit = 60; switch_channel_t *new_channel = NULL; switch_event_t *params = NULL, *var_event_orig = var_event; From 155aafd3f4942a8cf42c3dedf5421645d051d7dd Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 Feb 2011 10:17:33 -0600 Subject: [PATCH 030/104] FS-3097 regression from 4f93ea25ece53df029e6dc6c913ad7c190df22d5 --- src/include/switch_channel.h | 1 + src/switch_ivr_bridge.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index c0bef4be59..25273bafc4 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -79,6 +79,7 @@ SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_ #define switch_channel_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_FALSE) #define switch_channel_media_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_TRUE) +#define switch_channel_media_up(_channel) (switch_channel_test_flag(_channel, CF_ANSWERED) || switch_channel_test_flag(_channel, CF_EARLY_MEDIA)) #define switch_channel_up(_channel) (switch_channel_get_state(_channel) < CS_HANGUP) #define switch_channel_down(_channel) (switch_channel_get_state(_channel) >= CS_HANGUP) diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index f130625a75..88c72bf1b8 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1398,10 +1398,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu return SWITCH_STATUS_FALSE; } - //if (!switch_channel_test_flag(originator_channel, CF_ANSWERED)) { - if (!switch_channel_media_ready(originator_channel)) { - if (switch_channel_media_ready(originatee_channel)) { - //if (switch_channel_test_flag(originatee_channel, CF_ANSWERED)) { + if (!switch_channel_media_up(originator_channel)) { + if (switch_channel_media_up(originatee_channel)) { swap_session = originator_session; originator_session = originatee_session; originatee_session = swap_session; From deec244b9d1c55f46efaf87f908462838d4f8416 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 Feb 2011 10:22:47 -0600 Subject: [PATCH 031/104] FS-3098 You are probably right about the sql statement, we must have missed that when the contributor gave us the patch. Be aware this code is depricated in favor of the broadsoft SCA shared appeareances and will probably be removed eventually --- src/mod/endpoints/mod_sofia/sofia_reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 5109e0bc72..6e3649a68f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -653,7 +653,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot) "and profile_name='%s' and expires <= %ld", mod_sofia_globals.hostname, profile->name, (long) now); sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sla_dialog_del_callback, profile); - switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s' and expires <= %ld", + switch_snprintf(sql, sizeof(sql), "delete from sip_shared_appearance_dialogs where expires > 0 and hostname='%s' and expires <= %ld", mod_sofia_globals.hostname, (long) now); From 62d000ed20305dcccefd5ac8b9ddbb40016e879b Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Thu, 24 Feb 2011 13:14:23 -0500 Subject: [PATCH 032/104] freetdm: remove sanity state check in outgoing function --- libs/freetdm/src/ftdm_io.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 504c00f33c..133420922b 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2430,11 +2430,6 @@ static ftdm_status_t _ftdm_channel_call_place_nl(const char *file, const char *f goto done; } - if (ftdmchan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Cannot place call in channel in state %s!\n", ftdm_channel_state2str(ftdmchan->state)); - goto done; - } - status = ftdmchan->span->outgoing_call(ftdmchan); if (status == FTDM_BREAK) { /* the signaling module detected glare on time */ From 69d1d984feff8bf616ba8a0c7c921ccfe07d3b16 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 Feb 2011 12:17:33 -0600 Subject: [PATCH 033/104] sleep 2 seconds on confernece outcall at the end to prevent auto-answer race --- src/mod/applications/mod_conference/mod_conference.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 71ed1ed4b7..35412afb17 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1396,6 +1396,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v if (switch_test_flag(conference, CFLAG_OUTCALL)) { conference->cancel_cause = SWITCH_CAUSE_ORIGINATOR_CANCEL; + switch_yield(2000000); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Ending pending outcall channels for Conference: '%s'\n", conference->name); while(conference->originating) { switch_yield(200000); From cbf610c5aa1747e930e8678375285f59c56f08c2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 Feb 2011 14:24:53 -0600 Subject: [PATCH 034/104] reswig --- .../src/org/freeswitch/swig/freeswitch.java | 4 + .../org/freeswitch/swig/freeswitchJNI.java | 1 + .../languages/mod_java/switch_swig_wrap.cpp | 61 ++++++++ .../languages/mod_managed/freeswitch_wrap.cxx | 112 ++++++++++++++ src/mod/languages/mod_managed/managed/swig.cs | 62 ++++++++ src/mod/languages/mod_perl/freeswitch.pm | 1 + src/mod/languages/mod_perl/mod_perl_wrap.cpp | 138 ++++++++++++++++-- src/mod/languages/mod_python/freeswitch.py | 1 + .../languages/mod_python/mod_python_wrap.cpp | 122 +++++++++++++++- 9 files changed, 479 insertions(+), 23 deletions(-) diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java index 7b53db475c..ea825c9014 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java @@ -17,6 +17,10 @@ public class freeswitch { freeswitchJNI.consoleCleanLog(msg); } + public static boolean email(String to, String from, String headers, String body, String file, String convert_cmd, String convert_ext) { + return freeswitchJNI.email(to, from, headers, body, file, convert_cmd, convert_ext); + } + public static void console_log(String level_str, String msg) { freeswitchJNI.console_log(level_str, msg); } diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java index f90a9cca11..5e778de59c 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java @@ -11,6 +11,7 @@ package org.freeswitch.swig; class freeswitchJNI { public final static native void consoleLog(String jarg1, String jarg2); public final static native void consoleCleanLog(String jarg1); + public final static native boolean email(String jarg1, String jarg2, String jarg3, String jarg4, String jarg5, String jarg6, String jarg7); public final static native long new_IVRMenu(long jarg1, IVRMenu jarg1_, String jarg2, String jarg3, String jarg4, String jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10, int jarg11, int jarg12, int jarg13, int jarg14, int jarg15, int jarg16); public final static native void delete_IVRMenu(long jarg1); public final static native void IVRMenu_bindAction(long jarg1, IVRMenu jarg1_, String jarg2, String jarg3, String jarg4); diff --git a/src/mod/languages/mod_java/switch_swig_wrap.cpp b/src/mod/languages/mod_java/switch_swig_wrap.cpp index 720e7571db..34f62d5c9d 100644 --- a/src/mod/languages/mod_java/switch_swig_wrap.cpp +++ b/src/mod/languages/mod_java/switch_swig_wrap.cpp @@ -244,6 +244,67 @@ SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_consoleCleanLog(J } +SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_email(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3, jstring jarg4, jstring jarg5, jstring jarg6, jstring jarg7) { + jboolean jresult = 0 ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + char *arg5 = (char *) NULL ; + char *arg6 = (char *) NULL ; + char *arg7 = (char *) NULL ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + arg5 = 0; + if (jarg5) { + arg5 = (char *)jenv->GetStringUTFChars(jarg5, 0); + if (!arg5) return 0; + } + arg6 = 0; + if (jarg6) { + arg6 = (char *)jenv->GetStringUTFChars(jarg6, 0); + if (!arg6) return 0; + } + arg7 = 0; + if (jarg7) { + arg7 = (char *)jenv->GetStringUTFChars(jarg7, 0); + if (!arg7) return 0; + } + result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + jresult = (jboolean)result; + if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1); + if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2); + if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); + if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4); + if (arg5) jenv->ReleaseStringUTFChars(jarg5, (const char *)arg5); + if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6); + if (arg7) jenv->ReleaseStringUTFChars(jarg7, (const char *)arg7); + return jresult; +} + + SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1IVRMenu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4, jstring jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9, jstring jarg10, jint jarg11, jint jarg12, jint jarg13, jint jarg14, jint jarg15, jint jarg16) { jlong jresult = 0 ; IVRMenu *arg1 = (IVRMenu *) 0 ; diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 71e9f99819..1c6adf9aff 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -7473,6 +7473,42 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable(char * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable_dup(char * jarg1) { + char * jresult ; + char *arg1 = (char *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + result = (char *)switch_core_get_variable_dup((char const *)arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable_pdup(char * jarg1, void * jarg2) { + char * jresult ; + char *arg1 = (char *) 0 ; + switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (switch_memory_pool_t *)jarg2; + result = (char *)switch_core_get_variable_pdup((char const *)arg1,arg2); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_hostname() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_core_get_hostname(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_set_variable(char * jarg1, char * jarg2) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -10913,6 +10949,60 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_default_ptime(char * jarg1, u } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, char * jarg2, char * jarg3, char * jarg4, unsigned long jarg5, char * jarg6, char * jarg7, char * jarg8) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + uint32_t arg5 ; + char *arg6 = (char *) 0 ; + char *arg7 = (char *) 0 ; + char *arg8 = (char *) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + arg5 = (uint32_t)jarg5; + arg6 = (char *)jarg6; + arg7 = (char *)jarg7; + arg8 = (char *)jarg8; + result = (switch_status_t)switch_core_add_registration((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_del_registration(char * jarg1, char * jarg2, char * jarg3) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_core_del_registration((char const *)arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_expire_registration(int jarg1) { + int jresult ; + int arg1 ; + switch_status_t result; + + arg1 = (int)jarg1; + result = (switch_status_t)switch_core_expire_registration(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_module_name_set(void * jarg1, char * jarg2) { switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; char *arg2 = (char *) 0 ; @@ -26411,6 +26501,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_change_sln_volume(void * jarg1, unsign } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_change_sln_volume_granular(void * jarg1, unsigned long jarg2, int jarg3) { + int16_t *arg1 = (int16_t *) 0 ; + uint32_t arg2 ; + int32_t arg3 ; + + arg1 = (int16_t *)jarg1; + arg2 = (uint32_t)jarg2; + arg3 = (int32_t)jarg3; + switch_change_sln_volume_granular(arg1,arg2,arg3); +} + + SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_merge_sln(void * jarg1, unsigned long jarg2, void * jarg3, unsigned long jarg4) { unsigned long jresult ; int16_t *arg1 = (int16_t *) 0 ; @@ -29829,6 +29931,16 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_telephony_recv_event(void * ja } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_recv_pt(void * jarg1, unsigned char jarg2) { + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + switch_payload_t arg2 ; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (switch_payload_t)jarg2; + switch_rtp_set_recv_pt(arg1,arg2); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_cng_pt(void * jarg1, unsigned char jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_payload_t arg2 ; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index c640199353..e1d81a820c 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -1384,6 +1384,21 @@ public class freeswitch { return ret; } + public static string switch_core_get_variable_dup(string varname) { + string ret = freeswitchPINVOKE.switch_core_get_variable_dup(varname); + return ret; + } + + public static string switch_core_get_variable_pdup(string varname, SWIGTYPE_p_apr_pool_t pool) { + string ret = freeswitchPINVOKE.switch_core_get_variable_pdup(varname, SWIGTYPE_p_apr_pool_t.getCPtr(pool)); + return ret; + } + + public static string switch_core_get_hostname() { + string ret = freeswitchPINVOKE.switch_core_get_hostname(); + return ret; + } + public static void switch_core_set_variable(string varname, string value) { freeswitchPINVOKE.switch_core_set_variable(varname, value); } @@ -2415,6 +2430,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_add_registration(string user, string realm, string token, string url, uint expires, string network_ip, string network_port, string network_proto) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_add_registration(user, realm, token, url, expires, network_ip, network_port, network_proto); + return ret; + } + + public static switch_status_t switch_core_del_registration(string user, string realm, string token) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_del_registration(user, realm, token); + return ret; + } + + public static switch_status_t switch_core_expire_registration(int force) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_expire_registration(force); + return ret; + } + public static switch_status_t switch_loadable_module_init(switch_bool_t autoload) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_loadable_module_init((int)autoload); return ret; @@ -3974,6 +4004,10 @@ public class freeswitch { freeswitchPINVOKE.switch_change_sln_volume(SWIGTYPE_p_short.getCPtr(data), samples, vol); } + public static void switch_change_sln_volume_granular(SWIGTYPE_p_short data, uint samples, int vol) { + freeswitchPINVOKE.switch_change_sln_volume_granular(SWIGTYPE_p_short.getCPtr(data), samples, vol); + } + public static uint switch_merge_sln(SWIGTYPE_p_short data, uint samples, SWIGTYPE_p_short other_data, uint other_samples) { uint ret = freeswitchPINVOKE.switch_merge_sln(SWIGTYPE_p_short.getCPtr(data), samples, SWIGTYPE_p_short.getCPtr(other_data), other_samples); return ret; @@ -4857,6 +4891,10 @@ public class freeswitch { freeswitchPINVOKE.switch_rtp_set_telephony_recv_event(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), te); } + public static void switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { + freeswitchPINVOKE.switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); + } + public static void switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { freeswitchPINVOKE.switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); } @@ -7569,6 +7607,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable")] public static extern string switch_core_get_variable(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable_dup")] + public static extern string switch_core_get_variable_dup(string jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable_pdup")] + public static extern string switch_core_get_variable_pdup(string jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_hostname")] + public static extern string switch_core_get_hostname(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_set_variable")] public static extern void switch_core_set_variable(string jarg1, string jarg2); @@ -8349,6 +8396,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_default_ptime")] public static extern uint switch_default_ptime(string jarg1, uint jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_add_registration")] + public static extern int switch_core_add_registration(string jarg1, string jarg2, string jarg3, string jarg4, uint jarg5, string jarg6, string jarg7, string jarg8); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_del_registration")] + public static extern int switch_core_del_registration(string jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_expire_registration")] + public static extern int switch_core_expire_registration(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_module_name_set")] public static extern void switch_loadable_module_interface_module_name_set(HandleRef jarg1, string jarg2); @@ -12042,6 +12098,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_change_sln_volume")] public static extern void switch_change_sln_volume(HandleRef jarg1, uint jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_change_sln_volume_granular")] + public static extern void switch_change_sln_volume_granular(HandleRef jarg1, uint jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_merge_sln")] public static extern uint switch_merge_sln(HandleRef jarg1, uint jarg2, HandleRef jarg3, uint jarg4); @@ -12738,6 +12797,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_telephony_recv_event")] public static extern void switch_rtp_set_telephony_recv_event(HandleRef jarg1, byte jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_recv_pt")] + public static extern void switch_rtp_set_recv_pt(HandleRef jarg1, byte jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_cng_pt")] public static extern void switch_rtp_set_cng_pt(HandleRef jarg1, byte jarg2); diff --git a/src/mod/languages/mod_perl/freeswitch.pm b/src/mod/languages/mod_perl/freeswitch.pm index cb31101489..e55ffac7de 100644 --- a/src/mod/languages/mod_perl/freeswitch.pm +++ b/src/mod/languages/mod_perl/freeswitch.pm @@ -50,6 +50,7 @@ package freeswitch; *consoleLog = *freeswitchc::consoleLog; *consoleCleanLog = *freeswitchc::consoleCleanLog; +*email = *freeswitchc::email; *console_log = *freeswitchc::console_log; *console_clean_log = *freeswitchc::console_clean_log; *msleep = *freeswitchc::msleep; diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index e8a4b9f409..9be038585a 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -1566,6 +1566,19 @@ SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +SWIGINTERNINLINE SV * +SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value) +{ + SV *obj = sv_newmortal(); + if (value) { + sv_setsv(obj, &PL_sv_yes); + } else { + sv_setsv(obj, &PL_sv_no); + } + return obj; +} + + #include #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) @@ -1780,19 +1793,6 @@ SWIG_From_char SWIG_PERL_DECL_ARGS_1(char c) } -SWIGINTERNINLINE SV * -SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value) -{ - SV *obj = sv_newmortal(); - if (value) { - sv_setsv(obj, &PL_sv_yes); - } else { - sv_setsv(obj, &PL_sv_no); - } - return obj; -} - - SWIGINTERN int SWIG_AsVal_unsigned_SS_long SWIG_PERL_DECL_ARGS_2(SV *obj, unsigned long *val) { @@ -1982,6 +1982,111 @@ XS(_wrap_consoleCleanLog) { } +XS(_wrap_email) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + char *arg5 = (char *) NULL ; + char *arg6 = (char *) NULL ; + char *arg7 = (char *) NULL ; + bool result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + int res6 ; + char *buf6 = 0 ; + int alloc6 = 0 ; + int res7 ; + char *buf7 = 0 ; + int alloc7 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 7)) { + SWIG_croak("Usage: email(to,from,headers,body,file,convert_cmd,convert_ext);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "email" "', argument " "1"" of type '" "char *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "email" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "email" "', argument " "3"" of type '" "char *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "email" "', argument " "4"" of type '" "char *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + if (items > 4) { + res5 = SWIG_AsCharPtrAndSize(ST(4), &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "email" "', argument " "5"" of type '" "char *""'"); + } + arg5 = reinterpret_cast< char * >(buf5); + } + if (items > 5) { + res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "email" "', argument " "6"" of type '" "char *""'"); + } + arg6 = reinterpret_cast< char * >(buf6); + } + if (items > 6) { + res7 = SWIG_AsCharPtrAndSize(ST(6), &buf7, NULL, &alloc7); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "email" "', argument " "7"" of type '" "char *""'"); + } + arg7 = reinterpret_cast< char * >(buf7); + } + result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + SWIG_croak_null(); + } +} + + XS(_wrap_new_IVRMenu) { { IVRMenu *arg1 = (IVRMenu *) 0 ; @@ -9336,6 +9441,7 @@ static swig_variable_info swig_variables[] = { static swig_command_info swig_commands[] = { {"freeswitchc::consoleLog", _wrap_consoleLog}, {"freeswitchc::consoleCleanLog", _wrap_consoleCleanLog}, +{"freeswitchc::email", _wrap_email}, {"freeswitchc::new_IVRMenu", _wrap_new_IVRMenu}, {"freeswitchc::delete_IVRMenu", _wrap_delete_IVRMenu}, {"freeswitchc::IVRMenu_bindAction", _wrap_IVRMenu_bindAction}, @@ -9793,17 +9899,17 @@ XS(SWIG_init) { SWIG_TypeClientData(SWIGTYPE_p_IVRMenu, (void*) "freeswitch::IVRMenu"); SWIG_TypeClientData(SWIGTYPE_p_API, (void*) "freeswitch::API"); SWIG_TypeClientData(SWIGTYPE_p_input_callback_state, (void*) "freeswitch::input_callback_state_t"); - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_HUP", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_HUP))); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_FREE", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_FREE))); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_RDLOCK", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_RDLOCK))); SvREADONLY_on(sv); diff --git a/src/mod/languages/mod_python/freeswitch.py b/src/mod/languages/mod_python/freeswitch.py index 03deb31d13..d49016d305 100644 --- a/src/mod/languages/mod_python/freeswitch.py +++ b/src/mod/languages/mod_python/freeswitch.py @@ -50,6 +50,7 @@ del types consoleLog = _freeswitch.consoleLog consoleCleanLog = _freeswitch.consoleCleanLog +email = _freeswitch.email class IVRMenu(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, IVRMenu, name, value) diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index 3326a19dcd..ccb5cac78e 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -2687,6 +2687,13 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +SWIGINTERNINLINE PyObject* + SWIG_From_bool (bool value) +{ + return PyBool_FromLong(value ? 1 : 0); +} + + #include #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) @@ -2916,13 +2923,6 @@ SWIG_From_char (char c) } -SWIGINTERNINLINE PyObject* - SWIG_From_bool (bool value) -{ - return PyBool_FromLong(value ? 1 : 0); -} - - SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { @@ -3071,6 +3071,113 @@ fail: } +SWIGINTERN PyObject *_wrap_email(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + char *arg5 = (char *) NULL ; + char *arg6 = (char *) NULL ; + char *arg7 = (char *) NULL ; + bool result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + int res6 ; + char *buf6 = 0 ; + int alloc6 = 0 ; + int res7 ; + char *buf7 = 0 ; + int alloc7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO|OOOOO:email",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "email" "', argument " "1"" of type '" "char *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "email" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "email" "', argument " "3"" of type '" "char *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (obj3) { + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "email" "', argument " "4"" of type '" "char *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + if (obj4) { + res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "email" "', argument " "5"" of type '" "char *""'"); + } + arg5 = reinterpret_cast< char * >(buf5); + } + if (obj5) { + res6 = SWIG_AsCharPtrAndSize(obj5, &buf6, NULL, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "email" "', argument " "6"" of type '" "char *""'"); + } + arg6 = reinterpret_cast< char * >(buf6); + } + if (obj6) { + res7 = SWIG_AsCharPtrAndSize(obj6, &buf7, NULL, &alloc7); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "email" "', argument " "7"" of type '" "char *""'"); + } + arg7 = reinterpret_cast< char * >(buf7); + } + result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + return NULL; +} + + SWIGINTERN PyObject *_wrap_new_IVRMenu(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; IVRMenu *arg1 = (IVRMenu *) 0 ; @@ -8878,6 +8985,7 @@ SWIGINTERN PyObject *Session_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObje static PyMethodDef SwigMethods[] = { { (char *)"consoleLog", _wrap_consoleLog, METH_VARARGS, NULL}, { (char *)"consoleCleanLog", _wrap_consoleCleanLog, METH_VARARGS, NULL}, + { (char *)"email", _wrap_email, METH_VARARGS, NULL}, { (char *)"new_IVRMenu", _wrap_new_IVRMenu, METH_VARARGS, NULL}, { (char *)"delete_IVRMenu", _wrap_delete_IVRMenu, METH_VARARGS, NULL}, { (char *)"IVRMenu_bindAction", _wrap_IVRMenu_bindAction, METH_VARARGS, NULL}, From 3a10d6a1c51ffc1aba78e7864fc8ba707494bb9d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 Feb 2011 14:54:13 -0600 Subject: [PATCH 035/104] use strdup instead of core_session_strdup in hangup hook --- src/switch_core_state_machine.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index 276acb8585..e2d50704b5 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -468,7 +468,7 @@ static void api_hook(switch_core_session_t *session, const char *hook_var, int u { if (!zstr(hook_var)) { switch_stream_handle_t stream = { 0 }; - char *cmd = switch_core_session_strdup(session, hook_var); + char *cmd = strdup(hook_var); char *arg = NULL; char *expanded = NULL; @@ -485,7 +485,7 @@ static void api_hook(switch_core_session_t *session, const char *hook_var, int u switch_channel_get_variables(session->channel, &stream.param_event); switch_channel_event_set_data(session->channel, stream.param_event); - expanded = switch_channel_expand_variables(session->channel, arg); + expanded = switch_event_expand_headers(stream.param_event, arg); switch_api_execute(cmd, expanded, use_session ? session : NULL, &stream); @@ -496,6 +496,9 @@ static void api_hook(switch_core_session_t *session, const char *hook_var, int u if (expanded != arg) { switch_safe_free(expanded); } + + switch_safe_free(cmd); + switch_safe_free(stream.data); } } From 61d3c56fdeed7b2a6c8000dda2343d9a1a693677 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 Feb 2011 15:29:22 -0600 Subject: [PATCH 036/104] fix jb + no timer situations --- src/switch_rtp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index f06771880c..029f067ab5 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -235,7 +235,6 @@ struct switch_rtp { uint32_t sync_packets; int rtcp_interval; switch_bool_t rtcp_fresh_frame; - uint8_t checked_jb; #ifdef ENABLE_ZRTP zrtp_session_t *zrtp_session; zrtp_profile_t *zrtp_profile; @@ -2500,7 +2499,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes = 0; } - if (rtp_session->jb && !rtp_session->pause_jb && !rtp_session->checked_jb) { + if (rtp_session->jb && !rtp_session->pause_jb) { if ((jb_frame = stfu_n_read_a_frame(rtp_session->jb))) { memcpy(rtp_session->recv_msg.body, jb_frame->data, jb_frame->dlen); @@ -2514,8 +2513,6 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t rtp_session->recv_msg.header.pt = jb_frame->pt; status = SWITCH_STATUS_SUCCESS; } - - rtp_session->checked_jb++; } return status; @@ -2660,8 +2657,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ READ_INC(rtp_session); - rtp_session->checked_jb = 0; - while (switch_rtp_ready(rtp_session)) { int do_cng = 0; int read_pretriggered = 0; From c9aab94aa428bec3e9354abb47cbdd481ad84384 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Thu, 24 Feb 2011 22:25:59 +0100 Subject: [PATCH 037/104] Skinny: use a const for SKINNY_KEY_SET_IN_USE_HINT --- src/mod/endpoints/mod_skinny/mod_skinny.c | 2 +- src/mod/endpoints/mod_skinny/skinny_tables.c | 1 + src/mod/endpoints/mod_skinny/skinny_tables.h | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 91d81dacf2..46acdb6bac 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -651,7 +651,7 @@ int channel_on_routing_callback(void *pArg, int argc, char **argv, char **column } else { send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_ON); skinny_line_set_state(listener, line_instance, helper->tech_pvt->call_id, SKINNY_IN_USE_REMOTELY); - send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, 10, 0xffff); + send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, SKINNY_KEY_SET_IN_USE_HINT, 0xffff); send_display_prompt_status(listener, 0, SKINNY_DISP_IN_USE_REMOTE, line_instance, helper->tech_pvt->call_id); skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance); diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.c b/src/mod/endpoints/mod_skinny/skinny_tables.c index 466a70538d..4488b7571c 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.c +++ b/src/mod/endpoints/mod_skinny/skinny_tables.c @@ -216,6 +216,7 @@ struct skinny_table SKINNY_KEY_SETS[] = { {"KeySetConnectedWithConference", SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE}, {"KeySetRingOut", SKINNY_KEY_SET_RING_OUT}, {"KeySetOffHookWithFeatures", SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES}, + {"KeySetInUseHint", SKINNY_KEY_SET_IN_USE_HINT}, {NULL, 0} }; SKINNY_DECLARE_ID2STR(skinny_soft_key_set2str, SKINNY_KEY_SETS, "UNKNOWN_SOFT_KEY_SET") diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.h b/src/mod/endpoints/mod_skinny/skinny_tables.h index bc92f9f4bf..e1144a9203 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.h +++ b/src/mod/endpoints/mod_skinny/skinny_tables.h @@ -210,8 +210,9 @@ enum skinny_key_set { SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE = 7, SKINNY_KEY_SET_RING_OUT = 8, SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES = 9, + SKINNY_KEY_SET_IN_USE_HINT = 10, }; -extern struct skinny_table SKINNY_KEY_SETS[11]; +extern struct skinny_table SKINNY_KEY_SETS[12]; const char *skinny_soft_key_set2str(uint32_t id); uint32_t skinny_str2soft_key_set(const char *str); #define SKINNY_PUSH_SOFT_KEY_SETS SKINNY_DECLARE_PUSH_MATCH(SKINNY_KEY_SETS) From cffd62aa36840f1b132ee60cf012aeb5f3542883 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Thu, 24 Feb 2011 22:32:19 +0100 Subject: [PATCH 038/104] Skinny: complete list of softkeysets --- conf/skinny_profiles/internal.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/conf/skinny_profiles/internal.xml b/conf/skinny_profiles/internal.xml index 52da89741d..5ea6a56439 100644 --- a/conf/skinny_profiles/internal.xml +++ b/conf/skinny_profiles/internal.xml @@ -16,12 +16,16 @@ - - - + + + + + + + From 2148d81d74e18c49e92375c1cdc970a08d7fac21 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Thu, 24 Feb 2011 23:53:53 +0100 Subject: [PATCH 039/104] Skinny: avoid crash when loading config with blank soft-key-set value --- src/mod/endpoints/mod_skinny/mod_skinny.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 46acdb6bac..4061b94518 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1811,6 +1811,9 @@ static switch_status_t load_skinny_config(void) size_t string_len = strlen(val); size_t string_pos, start = 0; int field_no = 0; + if (zstr(val)) { + continue; + } if (soft_key_set_id > 15) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "soft-key-set name '%s' is greater than 15 in soft-key-set-set '%s' in profile %s.\n", From 646ad887d7d91388e68330374ab1cc7d1632352b Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Fri, 25 Feb 2011 00:05:46 +0100 Subject: [PATCH 040/104] Skinny: enhance soft-key-sets --- conf/skinny_profiles/internal.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/skinny_profiles/internal.xml b/conf/skinny_profiles/internal.xml index 5ea6a56439..0ca4ed0c46 100644 --- a/conf/skinny_profiles/internal.xml +++ b/conf/skinny_profiles/internal.xml @@ -20,12 +20,12 @@ - + - - + + - + From e96acac3c803d00d5fe0802dfa1e17865290e50e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 Feb 2011 17:48:36 -0600 Subject: [PATCH 041/104] add optional job-uuid param to bgapi in oop mod --- libs/esl/java/esl_wrap.cpp | 11 +++++++++-- .../org/freeswitch/esl/ESLconnection.java | 4 ++-- libs/esl/java/org/freeswitch/esl/eslJNI.java | 2 +- libs/esl/lua/esl_wrap.cpp | 9 +++++++-- libs/esl/managed/ESLPINVOKE.cs | 2 +- libs/esl/managed/ESLconnection.cs | 4 ++-- libs/esl/managed/esl_wrap.cpp | 6 ++++-- libs/esl/perl/esl_wrap.cpp | 19 ++++++++++++++++--- libs/esl/php/ESL.php | 5 +++-- libs/esl/php/esl_wrap.cpp | 14 +++++++++++--- libs/esl/python/esl_wrap.cpp | 18 ++++++++++++++++-- libs/esl/ruby/esl_wrap.cpp | 17 +++++++++++++++-- libs/esl/src/esl_oop.cpp | 11 ++++++++--- libs/esl/src/include/esl_oop.h | 2 +- 14 files changed, 96 insertions(+), 28 deletions(-) diff --git a/libs/esl/java/esl_wrap.cpp b/libs/esl/java/esl_wrap.cpp index d508aa2074..9a764dd030 100644 --- a/libs/esl/java/esl_wrap.cpp +++ b/libs/esl/java/esl_wrap.cpp @@ -790,11 +790,12 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_ESLconnection_1api(JNIEn } -SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_ESLconnection_1bgapi(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) { +SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_ESLconnection_1bgapi(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4) { jlong jresult = 0 ; ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; ESLevent *result = 0 ; (void)jenv; @@ -811,10 +812,16 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_ESLconnection_1bgapi(JNI arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); if (!arg3) return 0; } - result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); *(ESLevent **)&jresult = result; if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2); if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); + if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4); return jresult; } diff --git a/libs/esl/java/org/freeswitch/esl/ESLconnection.java b/libs/esl/java/org/freeswitch/esl/ESLconnection.java index 6dbc37728b..e20509bf10 100644 --- a/libs/esl/java/org/freeswitch/esl/ESLconnection.java +++ b/libs/esl/java/org/freeswitch/esl/ESLconnection.java @@ -72,8 +72,8 @@ public class ESLconnection { return (cPtr == 0) ? null : new ESLevent(cPtr, true); } - public ESLevent bgapi(String cmd, String arg) { - long cPtr = eslJNI.ESLconnection_bgapi(swigCPtr, this, cmd, arg); + public ESLevent bgapi(String cmd, String arg, String job_uuid) { + long cPtr = eslJNI.ESLconnection_bgapi(swigCPtr, this, cmd, arg, job_uuid); return (cPtr == 0) ? null : new ESLevent(cPtr, true); } diff --git a/libs/esl/java/org/freeswitch/esl/eslJNI.java b/libs/esl/java/org/freeswitch/esl/eslJNI.java index c08ee2f83d..e6e576f0dc 100644 --- a/libs/esl/java/org/freeswitch/esl/eslJNI.java +++ b/libs/esl/java/org/freeswitch/esl/eslJNI.java @@ -39,7 +39,7 @@ class eslJNI { public final static native int ESLconnection_send(long jarg1, ESLconnection jarg1_, String jarg2); public final static native long ESLconnection_sendRecv(long jarg1, ESLconnection jarg1_, String jarg2); public final static native long ESLconnection_api(long jarg1, ESLconnection jarg1_, String jarg2, String jarg3); - public final static native long ESLconnection_bgapi(long jarg1, ESLconnection jarg1_, String jarg2, String jarg3); + public final static native long ESLconnection_bgapi(long jarg1, ESLconnection jarg1_, String jarg2, String jarg3, String jarg4); public final static native long ESLconnection_sendEvent(long jarg1, ESLconnection jarg1_, long jarg2, ESLevent jarg2_); public final static native long ESLconnection_recvEvent(long jarg1, ESLconnection jarg1_); public final static native long ESLconnection_recvEventTimed(long jarg1, ESLconnection jarg1_, int jarg2); diff --git a/libs/esl/lua/esl_wrap.cpp b/libs/esl/lua/esl_wrap.cpp index bcdb11d2e0..25fceb7bea 100644 --- a/libs/esl/lua/esl_wrap.cpp +++ b/libs/esl/lua/esl_wrap.cpp @@ -2498,12 +2498,14 @@ static int _wrap_ESLconnection_bgapi(lua_State* L) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; ESLevent *result = 0 ; - SWIG_check_num_args("bgapi",2,3) + SWIG_check_num_args("bgapi",2,4) if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("bgapi",1,"ESLconnection *"); if(!lua_isstring(L,2)) SWIG_fail_arg("bgapi",2,"char const *"); if(lua_gettop(L)>=3 && !lua_isstring(L,3)) SWIG_fail_arg("bgapi",3,"char const *"); + if(lua_gettop(L)>=4 && !lua_isstring(L,4)) SWIG_fail_arg("bgapi",4,"char const *"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){ SWIG_fail_ptr("ESLconnection_bgapi",1,SWIGTYPE_p_ESLconnection); @@ -2513,7 +2515,10 @@ static int _wrap_ESLconnection_bgapi(lua_State* L) { if(lua_gettop(L)>=3){ arg3 = (char *)lua_tostring(L, 3); } - result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); + if(lua_gettop(L)>=4){ + arg4 = (char *)lua_tostring(L, 4); + } + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); SWIG_arg=0; SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLevent,1); SWIG_arg++; return SWIG_arg; diff --git a/libs/esl/managed/ESLPINVOKE.cs b/libs/esl/managed/ESLPINVOKE.cs index d7dfb6f2ff..1e487895d9 100644 --- a/libs/esl/managed/ESLPINVOKE.cs +++ b/libs/esl/managed/ESLPINVOKE.cs @@ -275,7 +275,7 @@ class ESLPINVOKE { public static extern IntPtr ESLconnection_Api(HandleRef jarg1, string jarg2, string jarg3); [DllImport("ESL", EntryPoint="CSharp_ESLconnection_Bgapi")] - public static extern IntPtr ESLconnection_Bgapi(HandleRef jarg1, string jarg2, string jarg3); + public static extern IntPtr ESLconnection_Bgapi(HandleRef jarg1, string jarg2, string jarg3, string jarg4); [DllImport("ESL", EntryPoint="CSharp_ESLconnection_SendEvent")] public static extern IntPtr ESLconnection_SendEvent(HandleRef jarg1, HandleRef jarg2); diff --git a/libs/esl/managed/ESLconnection.cs b/libs/esl/managed/ESLconnection.cs index 10a77748c2..88435830ad 100644 --- a/libs/esl/managed/ESLconnection.cs +++ b/libs/esl/managed/ESLconnection.cs @@ -80,8 +80,8 @@ public class ESLconnection : IDisposable { return ret; } - public ESLevent Bgapi(string cmd, string arg) { - IntPtr cPtr = ESLPINVOKE.ESLconnection_Bgapi(swigCPtr, cmd, arg); + public ESLevent Bgapi(string cmd, string arg, string job_uuid) { + IntPtr cPtr = ESLPINVOKE.ESLconnection_Bgapi(swigCPtr, cmd, arg, job_uuid); ESLevent ret = (cPtr == IntPtr.Zero) ? null : new ESLevent(cPtr, true); return ret; } diff --git a/libs/esl/managed/esl_wrap.cpp b/libs/esl/managed/esl_wrap.cpp index eb9559b684..4d0e27d261 100644 --- a/libs/esl/managed/esl_wrap.cpp +++ b/libs/esl/managed/esl_wrap.cpp @@ -677,17 +677,19 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Api(void * jarg1, char * jarg } -SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Bgapi(void * jarg1, char * jarg2, char * jarg3) { +SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Bgapi(void * jarg1, char * jarg2, char * jarg3, char * jarg4) { void * jresult ; ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; ESLevent *result = 0 ; arg1 = (ESLconnection *)jarg1; arg2 = (char *)jarg2; arg3 = (char *)jarg3; - result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); + arg4 = (char *)jarg4; + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); jresult = (void *)result; return jresult; } diff --git a/libs/esl/perl/esl_wrap.cpp b/libs/esl/perl/esl_wrap.cpp index e965458cb5..ccce4bb6d0 100644 --- a/libs/esl/perl/esl_wrap.cpp +++ b/libs/esl/perl/esl_wrap.cpp @@ -3072,6 +3072,7 @@ XS(_wrap_ESLconnection_bgapi) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -3081,11 +3082,14 @@ XS(_wrap_ESLconnection_bgapi) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; int argvi = 0; dXSARGS; - if ((items < 2) || (items > 3)) { - SWIG_croak("Usage: ESLconnection_bgapi(self,cmd,arg);"); + if ((items < 2) || (items > 4)) { + SWIG_croak("Usage: ESLconnection_bgapi(self,cmd,arg,job_uuid);"); } res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); if (!SWIG_IsOK(res1)) { @@ -3104,16 +3108,25 @@ XS(_wrap_ESLconnection_bgapi) { } arg3 = reinterpret_cast< char * >(buf3); } - result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_bgapi" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ; if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; XSRETURN(argvi); fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; SWIG_croak_null(); } } diff --git a/libs/esl/php/ESL.php b/libs/esl/php/ESL.php index 96d96e3e90..70ff62ac0d 100644 --- a/libs/esl/php/ESL.php +++ b/libs/esl/php/ESL.php @@ -152,10 +152,11 @@ class ESLconnection { return is_resource($r) ? new ESLevent($r) : $r; } - function bgapi($cmd,$arg=null) { + function bgapi($cmd,$arg=null,$job_uuid=null) { switch (func_num_args()) { case 1: $r=ESLconnection_bgapi($this->_cPtr,$cmd); break; - default: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg); + case 2: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg); break; + default: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg,$job_uuid); } return is_resource($r) ? new ESLevent($r) : $r; } diff --git a/libs/esl/php/esl_wrap.cpp b/libs/esl/php/esl_wrap.cpp index c2eea23034..c38ea1fa62 100644 --- a/libs/esl/php/esl_wrap.cpp +++ b/libs/esl/php/esl_wrap.cpp @@ -2075,13 +2075,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_bgapi) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; ESLevent *result = 0 ; - zval **args[3]; + zval **args[4]; int arg_count; SWIG_ResetError(); arg_count = ZEND_NUM_ARGS(); - if(arg_count<2 || arg_count>3 || + if(arg_count<2 || arg_count>4 || zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) WRONG_PARAM_COUNT; @@ -2104,7 +2105,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_bgapi) { /*@SWIG@*/; } - result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); + if(arg_count > 3) { + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@SWIG@*/; + + } + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); { SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); } diff --git a/libs/esl/python/esl_wrap.cpp b/libs/esl/python/esl_wrap.cpp index a7040ef200..3ef587561c 100644 --- a/libs/esl/python/esl_wrap.cpp +++ b/libs/esl/python/esl_wrap.cpp @@ -4151,6 +4151,7 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -4160,12 +4161,16 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (!PyArg_ParseTuple(args,(char *)"OO|O:ESLconnection_bgapi",&obj0,&obj1,&obj2)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO|OO:ESLconnection_bgapi",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_bgapi" "', argument " "1"" of type '" "ESLconnection *""'"); @@ -4183,19 +4188,28 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P } arg3 = reinterpret_cast< char * >(buf3); } + if (obj3) { + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_bgapi" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } { SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } diff --git a/libs/esl/ruby/esl_wrap.cpp b/libs/esl/ruby/esl_wrap.cpp index 7892ed6d00..3769b5bc24 100644 --- a/libs/esl/ruby/esl_wrap.cpp +++ b/libs/esl/ruby/esl_wrap.cpp @@ -3055,6 +3055,7 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -3064,9 +3065,12 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) { int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; VALUE vresult = Qnil; - if ((argc < 1) || (argc > 2)) { + if ((argc < 1) || (argc > 3)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; } res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); @@ -3086,14 +3090,23 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) { } arg3 = reinterpret_cast< char * >(buf3); } - result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); + if (argc > 2) { + res4 = SWIG_AsCharPtrAndSize(argv[2], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char const *","bgapi", 4, argv[2] )); + } + arg4 = reinterpret_cast< char * >(buf4); + } + result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4); vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return vresult; fail: if (alloc2 == SWIG_NEWOBJ) delete[] buf2; if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; return Qnil; } diff --git a/libs/esl/src/esl_oop.cpp b/libs/esl/src/esl_oop.cpp index 0ea88e17cc..8ea3dfa4d3 100644 --- a/libs/esl/src/esl_oop.cpp +++ b/libs/esl/src/esl_oop.cpp @@ -105,7 +105,7 @@ ESLevent *ESLconnection::api(const char *cmd, const char *arg) return event; } -ESLevent *ESLconnection::bgapi(const char *cmd, const char *arg) +ESLevent *ESLconnection::bgapi(const char *cmd, const char *arg, const char *job_uuid) { size_t len; char *cmd_buf; @@ -115,12 +115,17 @@ ESLevent *ESLconnection::bgapi(const char *cmd, const char *arg) return NULL; } - len = strlen(cmd) + (arg ? strlen(arg) : 0) + 10; + len = strlen(cmd) + (arg ? strlen(arg) : 0) + (job_uuid ? strlen(job_uuid) + 12 : 0) + 10; cmd_buf = (char *) malloc(len + 1); assert(cmd_buf); + + if (job_uuid) { + snprintf(cmd_buf, len, "bgapi %s%s%s\nJob-UUID: %s", cmd, arg ? " " : "", arg ? arg : "", job_uuid); + } else { + snprintf(cmd_buf, len, "bgapi %s%s%s", cmd, arg ? " " : "", arg ? arg : ""); + } - snprintf(cmd_buf, len, "bgapi %s %s", cmd, arg ? arg : ""); *(cmd_buf + (len)) = '\0'; event = sendRecv(cmd_buf); diff --git a/libs/esl/src/include/esl_oop.h b/libs/esl/src/include/esl_oop.h index 8562a9d965..3947d0cfb7 100644 --- a/libs/esl/src/include/esl_oop.h +++ b/libs/esl/src/include/esl_oop.h @@ -82,7 +82,7 @@ class ESLconnection { int send(const char *cmd); ESLevent *sendRecv(const char *cmd); ESLevent *api(const char *cmd, const char *arg = NULL); - ESLevent *bgapi(const char *cmd, const char *arg = NULL); + ESLevent *bgapi(const char *cmd, const char *arg = NULL, const char *job_uuid = NULL); ESLevent *sendEvent(ESLevent *send_me); ESLevent *recvEvent(); ESLevent *recvEventTimed(int ms); From 986f258db05f7b841fcb68231ae07d5174fbcb38 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 Feb 2011 18:48:16 -0600 Subject: [PATCH 042/104] let ctl-c work until you are connected --- libs/esl/fs_cli.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index a70d63fab5..19c5795bee 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -53,6 +53,7 @@ static unsigned char esl_console_complete(const char *buffer, const char *cursor #endif static char prompt_str[512] = ""; +static int CONNECTED = 0; typedef struct { char name[128]; @@ -537,6 +538,11 @@ static void handle_SIGINT(int sig) { if (sig); + if (!CONNECTED) { + fprintf(stdout, "Interrupted.\n"); + exit(1); + } + WARN_STOP = 1; signal(SIGINT, handle_SIGINT); @@ -1235,6 +1241,8 @@ int main(int argc, char *argv[]) connect: + CONNECTED = 0; + while (--loops > 0) { memset(&handle, 0, sizeof(handle)); if (esl_connect(&handle, profile->host, profile->port, profile->user, profile->pass)) { @@ -1252,6 +1260,8 @@ int main(int argc, char *argv[]) esl_log(ESL_LOG_INFO, "Retrying\n"); } } else { + CONNECTED = 1; + if (temp_log < 0 ) { esl_global_set_default_logger(profile->debug); } else { From c18835d3f919c7ba260dfa0e61254fb305850518 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Fri, 25 Feb 2011 01:52:58 +0100 Subject: [PATCH 043/104] Skinny: Allow to listen on ipv6 also allow to specify a blank ip which means: all --- src/mod/endpoints/mod_skinny/mod_skinny.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 4061b94518..a30b0fd666 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -1524,7 +1524,7 @@ static void *SWITCH_THREAD_FUNC skinny_profile_run(switch_thread_t *thread, void new_socket: while(globals.running) { switch_clear_flag_locked(profile, PFLAG_RESPAWN); - rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_INET, profile->port, 0, tmp_pool); + rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_UNSPEC, profile->port, 0, tmp_pool); if (rv) goto fail; rv = switch_socket_create(&profile->sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, tmp_pool); @@ -1663,7 +1663,7 @@ switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, c profile->domain = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "ip")) { if (!profile->ip || strcmp(val, profile->ip)) { - profile->ip = switch_core_strdup(profile->pool, val); + profile->ip = switch_core_strdup(profile->pool, zstr(val) ? NULL : val); switch_set_flag_locked(profile, PFLAG_SHOULD_RESPAWN); } } else if (!strcasecmp(var, "port")) { From 687d39f259cf62bea5c6508acd76d8732dcc0e11 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Fri, 25 Feb 2011 10:35:25 -0500 Subject: [PATCH 044/104] freetdm: ftmod_analog - Add timeout parameter for dial tone. 0 means not waiting for dial tone. --- libs/freetdm/conf/freetdm.conf.xml | 3 +++ libs/freetdm/mod_freetdm/mod_freetdm.c | 4 ++++ libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/conf/freetdm.conf.xml b/libs/freetdm/conf/freetdm.conf.xml index 43197af4bc..7d5de5a189 100644 --- a/libs/freetdm/conf/freetdm.conf.xml +++ b/libs/freetdm/conf/freetdm.conf.xml @@ -54,6 +54,9 @@ with the signaling protocols that you can run on top of your I/O interfaces. + + + diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 4dc6cfcfd2..b746f51b10 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -2790,6 +2790,7 @@ static switch_status_t load_config(void) const char *hangup_polarity = "false"; int polarity_delay = 600; int callwaiting = 1; + int dialtone_timeout = 5000; uint32_t span_id = 0, to = 0, max = 0; ftdm_span_t *span = NULL; @@ -2830,6 +2831,8 @@ static switch_status_t load_config(void) tonegroup = val; } else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) { digit_timeout = val; + } else if (!strcasecmp(var, "wait-dialtone-timeout")) { + dialtone_timeout = atoi(val); } else if (!strcasecmp(var, "context")) { context = val; } else if (!strcasecmp(var, "dialplan")) { @@ -2930,6 +2933,7 @@ static switch_status_t load_config(void) "hangup_polarity_reverse", hangup_polarity, "polarity_delay", &polarity_delay, "callwaiting", &callwaiting, + "wait_dialtone_timeout", &dialtone_timeout, FTDM_TAG_END) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM analog span %s\n", ftdm_span_get_name(span)); continue; diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c index 818f1c5754..d25d38f3d7 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c @@ -182,7 +182,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span) const char *tonemap = "us"; const char *hotline = ""; uint32_t digit_timeout = 10; - uint32_t wait_dialtone_timeout = 30000; + uint32_t wait_dialtone_timeout = 5000; uint32_t max_dialstr = MAX_DTMF; uint32_t polarity_delay = 600; const char *var, *val; From bc397ab6000d8e8acaeecf351a3281428226d0d9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 25 Feb 2011 10:55:33 -0600 Subject: [PATCH 045/104] FS-2971 --- libs/esl/src/esl_event.c | 2 + libs/esl/src/include/esl_event.h | 2 + src/include/switch_types.h | 2 + src/switch_channel.c | 3 ++ src/switch_event.c | 2 + src/switch_ivr_play_say.c | 78 +++++++++++++++++++++++++++++--- 6 files changed, 83 insertions(+), 6 deletions(-) diff --git a/libs/esl/src/esl_event.c b/libs/esl/src/esl_event.c index db7c581ee9..9bd78a838d 100644 --- a/libs/esl/src/esl_event.c +++ b/libs/esl/src/esl_event.c @@ -131,6 +131,8 @@ static const char *EVENT_NAMES[] = { "NAT", "RECORD_START", "RECORD_STOP", + "PLAYBACK_START", + "PLAYBACK_STOP", "CALL_UPDATE", "FAILURE", "SOCKET_DATA", diff --git a/libs/esl/src/include/esl_event.h b/libs/esl/src/include/esl_event.h index 0e6d3e37db..7e619f4764 100644 --- a/libs/esl/src/include/esl_event.h +++ b/libs/esl/src/include/esl_event.h @@ -119,6 +119,8 @@ typedef enum { ESL_EVENT_NAT, ESL_EVENT_RECORD_START, ESL_EVENT_RECORD_STOP, + ESL_EVENT_PLAYBACK_START, + ESL_EVENT_PLAYBACK_STOP, ESL_EVENT_CALL_UPDATE, ESL_EVENT_FAILURE, ESL_EVENT_SOCKET_DATA, diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 3972404290..4253d0e542 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1504,6 +1504,8 @@ typedef enum { SWITCH_EVENT_NAT, SWITCH_EVENT_RECORD_START, SWITCH_EVENT_RECORD_STOP, + SWITCH_EVENT_PLAYBACK_START, + SWITCH_EVENT_PLAYBACK_STOP, SWITCH_EVENT_CALL_UPDATE, SWITCH_EVENT_FAILURE, SWITCH_EVENT_SOCKET_DATA, diff --git a/src/switch_channel.c b/src/switch_channel.c index 9e3064b625..179f63da79 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -2042,10 +2042,13 @@ SWITCH_DECLARE(void) switch_channel_event_set_extended_data(switch_channel_t *ch event->event_id == SWITCH_EVENT_REQUEST_PARAMS || event->event_id == SWITCH_EVENT_CHANNEL_DATA || event->event_id == SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE || + event->event_id == SWITCH_EVENT_CHANNEL_DESTROY || event->event_id == SWITCH_EVENT_SESSION_HEARTBEAT || event->event_id == SWITCH_EVENT_API || event->event_id == SWITCH_EVENT_RECORD_START || event->event_id == SWITCH_EVENT_RECORD_STOP || + event->event_id == SWITCH_EVENT_PLAYBACK_START || + event->event_id == SWITCH_EVENT_PLAYBACK_STOP || event->event_id == SWITCH_EVENT_CALL_UPDATE || event->event_id == SWITCH_EVENT_MEDIA_BUG_START || event->event_id == SWITCH_EVENT_MEDIA_BUG_STOP || diff --git a/src/switch_event.c b/src/switch_event.c index b626d5b846..56ee9e9a9c 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -189,6 +189,8 @@ static char *EVENT_NAMES[] = { "NAT", "RECORD_START", "RECORD_STOP", + "PLAYBACK_START", + "PLAYBACK_STOP", "CALL_UPDATE", "FAILURE", "SOCKET_DATA", diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index dc263e9be5..98dfd0f71e 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -746,12 +746,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se } - if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(channel, event); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", file); - switch_event_fire(&event); - } - if (fill_cng || waste_resources) { switch_core_codec_destroy(&write_codec); } @@ -766,6 +760,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se switch_channel_set_variable_printf(channel, "record_samples", "%d", fh->samples_out); + if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", file); + switch_event_fire(&event); + } + switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE); return status; } @@ -951,6 +951,38 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_release_file_handle(switch_core_sessi #define FILE_BLOCKSIZE 1024 * 8 #define FILE_BUFSIZE 1024 * 64 +static void add_playback_vars_to_event(switch_core_session_t *session, switch_event_t *event, char *vars) +{ + char *tmp; + + if (!session || !event || !vars) + return; + + if ((tmp = switch_core_session_strdup(session, vars))) { + char *argv[128] = { 0 }; + int argc, i; + + if (!(argc = switch_separate_string(tmp, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) + return; + + for (i = 0; i < argc; i++) { + char *var, *val; + + if ((var = strchr(argv[i], '='))) { + *var = '\0'; + val = var+1; + var = argv[i]; + + if (var && *var && val && *val) { + if ((var = switch_core_session_sprintf(session, "playback_variable_%s", var))) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val); + } + } + } + } + } +} + SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -990,6 +1022,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess int timeout_samples = 0; const char *var; int more_data = 0; + char *playback_vars, *tmp; + switch_event_t *event; if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; @@ -1138,6 +1172,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } } + /* Try to parse extra parameters for this playback (parameters within {} at the end of the filename */ + playback_vars = NULL; + if ((tmp = strchr(file, '{'))) { + char *tfile, *e; + + if ((tfile = switch_core_session_strdup(session, tmp))) { + if ((e = switch_find_end_paren(tfile, '{', '}')) && *(e + 1) == '\0') { + *tmp = '\0'; + *e = '\0'; + playback_vars = tfile+1; + } + } + } if (!fh) { fh = &lfh; @@ -1293,6 +1340,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess ilen = samples; + if (switch_event_create(&event, SWITCH_EVENT_PLAYBACK_START) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-File-Path", file); + add_playback_vars_to_event(session, event, playback_vars); + switch_event_fire(&event); + } + for (;;) { int do_speed = 1; int last_speed = -1; @@ -1586,6 +1640,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_in); + if (switch_event_create(&event, SWITCH_EVENT_PLAYBACK_STOP) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-File-Path", file); + if (status == SWITCH_STATUS_BREAK) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-Status", "break"); + } else { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-Status", "done"); + } + add_playback_vars_to_event(session, event, playback_vars); + switch_event_fire(&event); + } + switch_core_session_io_write_lock(session); switch_channel_set_private(channel, "__fh", NULL); switch_core_session_io_rwunlock(session); From d59d41d7b4d0609ebdbbab1592baa3f45240481e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 25 Feb 2011 11:59:45 -0600 Subject: [PATCH 046/104] add param to jb to try to recapture latency (disabled by default) --- src/include/switch_rtp.h | 2 +- src/mod/endpoints/mod_sofia/mod_sofia.c | 13 +++++++++---- src/mod/endpoints/mod_sofia/sofia_glue.c | 12 ++++++++---- src/switch_ivr.c | 2 +- src/switch_rtp.c | 17 +++++++++++------ 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index 2870bba3af..94c9d671e9 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -232,7 +232,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session, uint32_t queue_frames, uint32_t max_queue_frames, - uint32_t samples_per_packet, uint32_t samples_per_second); + uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift); SWITCH_DECLARE(switch_status_t) switch_rtp_debug_jitter_buffer(switch_rtp_t *rtp_session, const char *name); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 9e8d8200f4..e8e78e51f5 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1349,10 +1349,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_JITTER_BUFFER: { if (switch_rtp_ready(tech_pvt->rtp_session)) { - int len, maxlen = 0, qlen = 0, maxqlen = 50; + int len, maxlen = 0, qlen = 0, maxqlen = 50, max_drift = 0; if (msg->string_arg) { - char *p; + char *p, *q; const char *s; if (!strcasecmp(msg->string_arg, "pause")) { @@ -1379,6 +1379,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if ((p = strchr(msg->string_arg, ':'))) { p++; maxlen = atol(p); + if ((q = strchr(p, ':'))) { + q++; + max_drift = abs(atol(q)); + } } } @@ -1391,9 +1395,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (qlen) { if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen, tech_pvt->read_impl.samples_per_packet, - tech_pvt->read_impl.samples_per_second) == SWITCH_STATUS_SUCCESS) { + tech_pvt->read_impl.samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), - SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames)\n", len, qlen, maxqlen); + SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames) (%d max drift)\n", + len, qlen, maxqlen, max_drift); switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 01a70f32b6..66f5e52140 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -3166,12 +3166,16 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec")) || (val = tech_pvt->profile->jb_msec)) { int jb_msec = atoi(val); - int maxlen = 0; - char *p; - + int maxlen = 0, max_drift = 0; + char *p, *q; + if ((p = strchr(val, ':'))) { p++; maxlen = atoi(p); + if ((q = strchr(p, ':'))) { + q++; + max_drift = abs(atoi(q)); + } } if (jb_msec < 20 || jb_msec > 10000) { @@ -3188,7 +3192,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen, tech_pvt->read_impl.samples_per_packet, - tech_pvt->read_impl.samples_per_second) == SWITCH_STATUS_SUCCESS) { + tech_pvt->read_impl.samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", jb_msec, qlen); switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER); diff --git a/src/switch_ivr.c b/src/switch_ivr.c index a40da1b077..5a082763b2 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -2289,7 +2289,7 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3 qlen = delay_ms / (interval); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting delay to %dms (%d frames)\n", delay_ms, qlen); - jb = stfu_n_init(qlen, qlen, read_impl.samples_per_packet, read_impl.samples_per_second); + jb = stfu_n_init(qlen, qlen, read_impl.samples_per_packet, read_impl.samples_per_second, 0); write_frame.codec = switch_core_session_get_read_codec(session); diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 029f067ab5..b6b3832081 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1909,7 +1909,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t * uint32_t queue_frames, uint32_t max_queue_frames, uint32_t samples_per_packet, - uint32_t samples_per_second) + uint32_t samples_per_second, + uint32_t max_drift) { if (!switch_rtp_ready(rtp_session)) { @@ -1920,7 +1921,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t * if (rtp_session->jb) { stfu_n_resize(rtp_session->jb, queue_frames); } else { - rtp_session->jb = stfu_n_init(queue_frames, max_queue_frames ? max_queue_frames : 50, samples_per_packet, samples_per_second); + rtp_session->jb = stfu_n_init(queue_frames, max_queue_frames ? max_queue_frames : 50, samples_per_packet, samples_per_second, max_drift); } READ_DEC(rtp_session); @@ -2402,7 +2403,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t uint32_t ts; switch_assert(bytes); - + more: *bytes = sizeof(rtp_msg_t); status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, bytes); ts = ntohl(rtp_session->recv_msg.header.ts); @@ -2489,9 +2490,13 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t stfu_n_reset(rtp_session->jb); } - stfu_n_eat(rtp_session->jb, rtp_session->last_read_ts, - rtp_session->recv_msg.header.pt, - rtp_session->recv_msg.body, *bytes - rtp_header_len, rtp_session->timer.samplecount); + if (stfu_n_eat(rtp_session->jb, rtp_session->last_read_ts, + rtp_session->recv_msg.header.pt, + rtp_session->recv_msg.body, *bytes - rtp_header_len, rtp_session->timer.samplecount) == STFU_ITS_TOO_LATE) { + printf("doh\n"); + goto more; + } + status = SWITCH_STATUS_FALSE; if (!return_jb_packet) { return status; From 4ef6280a05cea21e52a4be29fb31d33aa50a19a7 Mon Sep 17 00:00:00 2001 From: Michael S Collins Date: Fri, 25 Feb 2011 10:27:18 -0800 Subject: [PATCH 047/104] Add ring (Israel ring tone) to vars.xml --- conf/vars.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/vars.xml b/conf/vars.xml index 0e8782cff0..94529aa9bc 100644 --- a/conf/vars.xml +++ b/conf/vars.xml @@ -207,6 +207,7 @@ + + + + + + diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index ab0777ed3b..0ef64d1079 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -249,6 +249,8 @@ struct switch_runtime { switch_dbtype_t odbc_dbtype; char hostname[256]; int multiple_registrations; + uint32_t max_db_handles; + uint32_t db_handle_timeout; }; extern struct switch_runtime runtime; diff --git a/src/switch_core.c b/src/switch_core.c index 50fe313f82..96e4b4ae27 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1283,7 +1283,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc memset(&runtime, 0, sizeof(runtime)); gethostname(runtime.hostname, sizeof(runtime.hostname)); - + runtime.max_db_handles = 50; + runtime.db_handle_timeout = 5000000;; + runtime.runlevel++; runtime.sql_buffer_len = 1024 * 32; runtime.max_sql_buffer_len = 1024 * 1024; @@ -1550,6 +1552,23 @@ static void switch_load_core_config(const char *file) if (tmp > -1 && tmp < 11) { switch_core_session_ctl(SCSC_DEBUG_LEVEL, &tmp); } + } else if (!strcasecmp(var, "max-db-handles")) { + long tmp = atol(val); + + if (tmp > 4 && tmp < 5001) { + runtime.max_db_handles = (uint32_t) tmp; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-db-handles must be between 5 and 5000\n"); + } + } else if (!strcasecmp(var, "db-handle-timeout")) { + long tmp = atol(val); + + if (tmp > 0 && tmp < 5001) { + runtime.db_handle_timeout = (uint32_t) tmp * 1000000; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "db-handle-timeout must be between 1 and 5000\n"); + } + } else if (!strcasecmp(var, "multiple-registrations")) { runtime.multiple_registrations = switch_true(val); } else if (!strcasecmp(var, "sql-buffer-len")) { diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 8dbdd44895..a4ed5ca83c 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -66,8 +66,8 @@ static struct { switch_cache_db_handle_t *handle_pool; switch_thread_cond_t *cond; switch_mutex_t *cond_mutex; - int total_handles; - int total_used_handles; + uint32_t total_handles; + uint32_t total_used_handles; } sql_manager; @@ -273,11 +273,29 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h char db_callsite_str[CACHE_DB_LEN] = ""; switch_cache_db_handle_t *new_dbh = NULL; switch_ssize_t hlen = -1; + int waiting = 0; + uint32_t yield_len = 100000, total_yield = 0; const char *db_name = NULL; const char *db_user = NULL; const char *db_pass = NULL; + while(runtime.max_db_handles && sql_manager.total_handles >= runtime.max_db_handles && sql_manager.total_used_handles >= sql_manager.total_handles) { + if (!waiting++) { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING, "Max handles %u exceeded, blocking....\n", + runtime.max_db_handles); + } + + switch_yield(yield_len); + total_yield += yield_len; + + if (runtime.db_handle_timeout && total_yield > runtime.db_handle_timeout) { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Error connecting\n"); + *dbh = NULL; + return SWITCH_STATUS_FALSE; + } + } + switch (type) { case SCDB_TYPE_ODBC: { From fac74d55916f0fba7f2dd25698c2ab00eaa288f2 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 4 Mar 2011 22:20:40 +0000 Subject: [PATCH 102/104] don't ignore 393 files which are in the tree This partially reverts commit 17d521128014853b24f983307fc28317f11e950b. Some changes in that commit caused 393 files which are in the tree to be mistakenly ignored. --- .gitignore | 68 ++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 2480b83823..31421b8d33 100644 --- a/.gitignore +++ b/.gitignore @@ -46,47 +46,45 @@ core.* !/w32/Console/FreeSwitchConsole.vcproj.user !/w32/Setup/inno_setup/vcredist_x64.exe !/w32/Setup/inno_setup/vcredist_x86.exe -.version -AUTHORS -COPYING -ChangeLog -Makefile -Makefile.in -NEWS -README -TAGS +/.version +/AUTHORS +/COPYING +/ChangeLog +/Makefile +/Makefile.in +/NEWS +/README +/TAGS aclocal.m4 autom4te.cache -build/Makefile -build/Makefile.in -build/config/compile -build/config/config.guess -build/config/depcomp -build/config/install-sh -build/config/ltmain.sh -build/config/missing -build/freeswitch.pc -build/getlib.sh -build/getsounds.sh -build/modmake.rules -build/getg729.sh +/build/Makefile +/build/Makefile.in +/build/config/compile +/build/config/config.guess +/build/config/depcomp +/build/config/install-sh +/build/config/ltmain.sh +/build/config/missing +/build/freeswitch.pc +/build/getlib.sh +/build/getsounds.sh +/build/modmake.rules config.cache config.log config.status -configure +/configure configure.lineno -freeswitch -fs_cli -fs_encode -fs_ivrd -libtool -noreg -modules.conf -quiet_libtool -tone2wav -scripts/fsxs -scripts/gentls_cert -a.out.dSYM +/freeswitch +/fs_cli +/fs_encode +/fs_ivrd +/libtool +/modules.conf +/quiet_libtool +/tone2wav +/scripts/fsxs +/scripts/gentls_cert +/a.out.dSYM src/mod/applications/mod_easyroute/Makefile src/mod/applications/mod_lcr/Makefile src/mod/applications/mod_nibblebill/Makefile From 541a99153d3a539d13e8d8c4c4e65a3716e807eb Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 4 Mar 2011 22:36:37 +0000 Subject: [PATCH 103/104] organize root .gitignore --- .gitignore | 164 ++++++++++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 78 deletions(-) diff --git a/.gitignore b/.gitignore index 31421b8d33..1fc3016d3f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,10 +11,6 @@ .deps .\#* \#* -/Debug/ -/Release/ -/All/ -/bin/ *.user *.suo *.ncb @@ -39,26 +35,46 @@ *.xz *.bz2 *.tbz2 +aclocal.m4 +autom4te.cache +config.cache +configure.lineno +config.log +config.status core.* -/Path + /w32/Library/lastversion /w32/Library/tmpVersion.Bat !/w32/Console/FreeSwitchConsole.vcproj.user !/w32/Setup/inno_setup/vcredist_x64.exe !/w32/Setup/inno_setup/vcredist_x86.exe + /.version +/a.out.dSYM /AUTHORS -/COPYING /ChangeLog +/configure +/COPYING +/freeswitch +/fs_cli +/fs_encode +/fs_ivrd +/libtool /Makefile /Makefile.in +/modules.conf /NEWS +/Path +/quiet_libtool /README /TAGS -aclocal.m4 -autom4te.cache -/build/Makefile -/build/Makefile.in +/tone2wav + +/All/ +/Debug/ +/bin/ +/Release/ + /build/config/compile /build/config/config.guess /build/config/depcomp @@ -68,74 +84,66 @@ autom4te.cache /build/freeswitch.pc /build/getlib.sh /build/getsounds.sh +/build/Makefile +/build/Makefile.in /build/modmake.rules -config.cache -config.log -config.status -/configure -configure.lineno -/freeswitch -/fs_cli -/fs_encode -/fs_ivrd -/libtool -/modules.conf -/quiet_libtool -/tone2wav + +/libs/curl/lib/ca-bundle.h +/libs/esl/fs_cli +/libs/esl/ivrd +/libs/esl/testclient +/libs/esl/testserver +/libs/freetdm/detect_dtmf +/libs/freetdm/detect_tones +/libs/freetdm/testanalog +/libs/freetdm/testapp +/libs/freetdm/testcid +/libs/freetdm/testpri +/libs/freetdm/testr2 +/libs/freetdm/testsangomaboost +/libs/freetdm/testtones +/libs/fsg729-*-installer +/libs/g729/ +/libs/libcodec2/config.guess +/libs/libcodec2/config.sub +/libs/libcodec2/configure +/libs/libcodec2/depcomp +/libs/libcodec2/install-sh +/libs/libcodec2/libtool +/libs/libcodec2/ltmain.sh +/libs/libcodec2/Makefile +/libs/libcodec2/Makefile.in +/libs/libcodec2/missing +/libs/libcodec2/src/Makefile +/libs/libcodec2/src/Makefile.in +/libs/libcodec2/unittest/Makefile +/libs/libcodec2/unittest/Makefile.in + /scripts/fsxs /scripts/gentls_cert -/a.out.dSYM -src/mod/applications/mod_easyroute/Makefile -src/mod/applications/mod_lcr/Makefile -src/mod/applications/mod_nibblebill/Makefile -src/mod/applications/mod_rss/Makefile -src/mod/applications/mod_snipe_hunt/Makefile -src/mod/codecs/mod_dahdi_codec/Makefile -src/mod/dialplans/mod_dialplan_directory/Makefile -src/mod/formats/mod_shell_stream/Makefile -src/mod/say/mod_say_de/Makefile -src/mod/say/mod_say_es/Makefile -src/mod/say/mod_say_fr/Makefile -src/mod/say/mod_say_it/Makefile -src/mod/say/mod_say_nl/Makefile -src/mod/say/mod_say_th/Makefile -src/mod/say/mod_say_zh/Makefile -libs/curl/lib/ca-bundle.h -libs/g729/ -libs/fsg729-*-installer -src/mod/codecs/mod_com_g729/ -src/mod/languages/mod_lua/mod_lua_wrap.cpp.orig -src/mod/languages/mod_perl/mod_perl_wrap.cpp.orig -src/mod/languages/mod_python/mod_python_wrap.cpp.orig -libs/freetdm/detect_dtmf -libs/freetdm/detect_tones -libs/freetdm/testanalog -libs/freetdm/testapp -libs/freetdm/testcid -libs/freetdm/testpri -libs/freetdm/testr2 -libs/freetdm/testsangomaboost -libs/freetdm/testtones -libs/esl/fs_cli -libs/esl/ivrd -libs/esl/testserver -libs/esl/testclient -libs/libcodec2/Makefile -libs/libcodec2/Makefile.in -libs/libcodec2/config.guess -libs/libcodec2/config.sub -libs/libcodec2/configure -libs/libcodec2/depcomp -libs/libcodec2/install-sh -libs/libcodec2/libtool -libs/libcodec2/ltmain.sh -libs/libcodec2/missing -libs/libcodec2/src/Makefile -libs/libcodec2/src/Makefile.in -libs/libcodec2/unittest/Makefile -libs/libcodec2/unittest/Makefile.in -src/mod/applications/mod_osp/Makefile -src/mod/applications/mod_osp/Makefile.in -src/mod/applications/mod_hash/Makefile -src/mod/applications/mod_hash/Makefile.in -src/mod/applications/mod_hash/mod_hash.log + +/src/mod/applications/mod_easyroute/Makefile +/src/mod/applications/mod_hash/Makefile +/src/mod/applications/mod_hash/Makefile.in +/src/mod/applications/mod_hash/mod_hash.log +/src/mod/applications/mod_lcr/Makefile +/src/mod/applications/mod_nibblebill/Makefile +/src/mod/applications/mod_osp/Makefile +/src/mod/applications/mod_osp/Makefile.in +/src/mod/applications/mod_rss/Makefile +/src/mod/applications/mod_snipe_hunt/Makefile +/src/mod/codecs/mod_com_g729/ +/src/mod/codecs/mod_dahdi_codec/Makefile +/src/mod/dialplans/mod_dialplan_directory/Makefile +/src/mod/formats/mod_shell_stream/Makefile +/src/mod/languages/mod_lua/mod_lua_wrap.cpp.orig +/src/mod/languages/mod_perl/mod_perl_wrap.cpp.orig +/src/mod/languages/mod_python/mod_python_wrap.cpp.orig +/src/mod/say/mod_say_de/Makefile +/src/mod/say/mod_say_es/Makefile +/src/mod/say/mod_say_fr/Makefile +/src/mod/say/mod_say_it/Makefile +/src/mod/say/mod_say_nl/Makefile +/src/mod/say/mod_say_th/Makefile +/src/mod/say/mod_say_zh/Makefile + From 0911ed740861f7e173c155c67388284b0053df57 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Sat, 5 Mar 2011 12:49:19 -0500 Subject: [PATCH 104/104] FS-3124 Use the channel's sound_prefix if it's not set in the conference's config --- conf/autoload_configs/conference.conf.xml | 11 ++++++----- src/mod/applications/mod_conference/mod_conference.c | 10 +++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/conf/autoload_configs/conference.conf.xml b/conf/autoload_configs/conference.conf.xml index cab0578a57..d4e5aa60ee 100644 --- a/conf/autoload_configs/conference.conf.xml +++ b/conf/autoload_configs/conference.conf.xml @@ -52,8 +52,9 @@ - - + + + @@ -106,7 +107,7 @@ - + @@ -131,7 +132,7 @@ - + @@ -156,7 +157,7 @@ - + diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 6892cbab9e..56c85ad2f3 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -6423,6 +6423,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c comfort_noise_level = 1400; } } else if (!strcasecmp(var, "sound-prefix") && !zstr(val)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "override sound-prefix with: %s\n", val); sound_prefix = val; } else if (!strcasecmp(var, "max-members") && !zstr(val)) { errno = 0; /* sanity first */ @@ -6527,8 +6528,15 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c set_cflags(conference_flags, &conference->flags); } - if (sound_prefix) { + if (!zstr(sound_prefix)) { conference->sound_prefix = switch_core_strdup(conference->pool, sound_prefix); + } else { + const char *val; + if ((val = switch_channel_get_variable(channel, "sound_prefix")) && !zstr(val)) { + /* if no sound_prefix was set, use the channel sound_prefix */ + conference->sound_prefix = switch_core_strdup(conference->pool, val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "using channel sound prefix: %s\n", conference->sound_prefix); + } } if (!zstr(enter_sound)) {