mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-20 02:04:54 +00:00
Merge branch 'master' into v1.10
This commit is contained in:
commit
f7bdd3845a
47
.drone.yml
Normal file
47
.drone.yml
Normal file
@ -0,0 +1,47 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: unit-tests
|
||||
|
||||
steps:
|
||||
- name: run-tests
|
||||
image: signalwire/freeswitch-public-base
|
||||
pull: true
|
||||
commands:
|
||||
- ./bootstrap.sh -j
|
||||
- echo "applications/mod_test" >> modules.conf
|
||||
- ./configure
|
||||
- echo "#!/bin/bash\nmake -j`nproc --all` |& tee ./unit-tests-build-result.txt\nexitstatus=\${PIPESTATUS[0]}\necho \$exitstatus > ./build-status.txt\nmake install\n" > build.sh
|
||||
- chmod +x build.sh
|
||||
- ./build.sh
|
||||
- cd tests/unit
|
||||
- ./run-tests.sh
|
||||
- mkdir logs && (mv log_run-tests_*.html logs || true)
|
||||
- echo 0 > run-tests-status.txt
|
||||
- ./collect-test-logs.sh && exit 0 || echo 'Some tests failed'
|
||||
- echo 1 > run-tests-status.txt
|
||||
- cd logs && ls -la
|
||||
|
||||
- name: notify
|
||||
image: signalwire/unit-tests-notify
|
||||
pull: true
|
||||
environment:
|
||||
GITHUB_CI_APP_PEM:
|
||||
from_secret: github_ci_app_pem
|
||||
SSH_KEY:
|
||||
from_secret: ssh_key
|
||||
SLACK_WEBHOOK_URL:
|
||||
from_secret: slack_webhook_url
|
||||
commands:
|
||||
- /root/notify.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
---
|
||||
kind: signature
|
||||
hmac: a34718dd1e2b9468a845962219ff05cac0c922ddf90d885af557a937a9e412e0
|
||||
|
||||
...
|
@ -586,6 +586,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_pgsql", "src\mod\databa
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_mariadb", "src\mod\databases\mod_mariadb\mod_mariadb.2017.vcxproj", "{0B612F84-7533-4DEC-AEDD-5C9CBCF15EAC}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_switch_core_db", "tests\unit\test_switch_core_db.2017.vcxproj", "{580675D7-C1C9-4197-AAC5-00F64FAFDE78}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_switch_ivr_originate", "tests\unit\test_switch_ivr_originate.2017.vcxproj", "{69A7464A-9B0D-4804-A108-835229DACF58}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
All|Win32 = All|Win32
|
||||
@ -2689,6 +2693,30 @@ Global
|
||||
{0B612F84-7533-4DEC-AEDD-5C9CBCF15EAC}.Release|Win32.Build.0 = Release|Win32
|
||||
{0B612F84-7533-4DEC-AEDD-5C9CBCF15EAC}.Release|x64.ActiveCfg = Release|x64
|
||||
{0B612F84-7533-4DEC-AEDD-5C9CBCF15EAC}.Release|x64.Build.0 = Release|x64
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.All|Win32.ActiveCfg = Release|Win32
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.All|Win32.Build.0 = Release|Win32
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.All|x64.ActiveCfg = Release|x64
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.All|x64.Build.0 = Release|x64
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.Debug|x64.Build.0 = Debug|x64
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.Release|Win32.Build.0 = Release|Win32
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.Release|x64.ActiveCfg = Release|x64
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78}.Release|x64.Build.0 = Release|x64
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.All|Win32.ActiveCfg = Release|Win32
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.All|Win32.Build.0 = Release|Win32
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.All|x64.ActiveCfg = Release|x64
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.All|x64.Build.0 = Release|x64
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.Debug|x64.Build.0 = Debug|x64
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.Release|Win32.Build.0 = Release|Win32
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.Release|x64.ActiveCfg = Release|x64
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -2901,6 +2929,8 @@ Global
|
||||
{BC1FD72E-1CD5-4525-A7F5-17C5740BFDED} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
|
||||
{1BA65811-5453-46F6-8190-9ECEEFEB7DF2} = {31C2761D-20E0-4BF8-98B9-E32F0D8DD6E1}
|
||||
{0B612F84-7533-4DEC-AEDD-5C9CBCF15EAC} = {31C2761D-20E0-4BF8-98B9-E32F0D8DD6E1}
|
||||
{580675D7-C1C9-4197-AAC5-00F64FAFDE78} = {9388C266-C3FC-468A-92EF-0CBC35941412}
|
||||
{69A7464A-9B0D-4804-A108-835229DACF58} = {9388C266-C3FC-468A-92EF-0CBC35941412}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {09840DE7-9208-45AA-9667-1A71EE93BD1E}
|
||||
|
@ -586,7 +586,7 @@ libs/libzrtp/libzrtp.a:
|
||||
cd libs/libzrtp && $(MAKE)
|
||||
|
||||
libs/libvpx/Makefile: libs/libvpx/.update
|
||||
cd libs/libvpx && CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --enable-pic --disable-docs --disable-examples --disable-install-bins --disable-install-srcs --disable-unit-tests --size-limit=16384x16384 --extra-cflags="$(VISIBILITY_FLAG)"
|
||||
cd libs/libvpx && CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS) $(VISIBILITY_FLAG)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --enable-pic --disable-docs --disable-examples --disable-install-bins --disable-install-srcs --disable-unit-tests --size-limit=16384x16384
|
||||
|
||||
libs/libvpx/libvpx.a: libs/libvpx/Makefile libs/libvpx/.update
|
||||
@cd libs/libvpx && $(MAKE)
|
||||
@ -684,7 +684,7 @@ is-scm:
|
||||
echo ; echo ; \
|
||||
echo "*****************************************************************************************************" ; \
|
||||
echo "You cannot update a release tarball without a git tree. Please clone FreeSWITCH as so: " ; \
|
||||
echo " git clone https://freeswitch.org/stash/scm/fs/freeswitch.git " ; \
|
||||
echo " git clone https://github.com/signalwire/freeswitch.git " ; \
|
||||
echo "*****************************************************************************************************" ; \
|
||||
echo ; echo ; \
|
||||
exit 1; \
|
||||
|
63
README.md
Normal file
63
README.md
Normal file
@ -0,0 +1,63 @@
|
||||
# FreeSWITCH
|
||||
|
||||
FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device. Combined with our hosted cloud platform, SignalWire, FreeSWITCH can interconnect with the outside world and scale to any size.
|
||||
|
||||
Visit [https://signalwire.com](https://signalwire.com/) or https://github.com/signalwire for more info.
|
||||
|
||||
## Getting Started
|
||||
|
||||
FreeSWITCH is available on [Github](https://github.com/signalwire/freeswitch) in source code format. You can checkout the development branch and build for many poplular platforms including Linux, Windows, MacOSX and BSD. There is an issue tracker and pull request system available as part of the repo online.
|
||||
|
||||
See [https://freeswitch.com/#getting-started](https://freeswitch.com/#getting-started) for more detailed instructions.
|
||||
|
||||
## Additional Help
|
||||
|
||||
If you need assistance or have an interest in using a commercially supported build, you can contact coreteam@freeswitch.com to learn about professional services to support your project.
|
||||
|
||||
## Voice-over-IP services - SIP / SMS - App Integrations
|
||||
|
||||
[SignalWire](https://signalwire.com) is the primary sponsor of the FreeSWITCH project and was founded by the original developers of FreeSWITCH. SignalWire provides scalable services to enhance and scale your project such as SMS, SIP, Serverless Application hosting as well as programmable telecom. mod_signalwire which is distributed in this code base allows you to instantly pair with SignalWire and extend your FreeSWITCH.
|
||||
|
||||
## Documentation
|
||||
|
||||
The main index for documentation is available at:
|
||||
|
||||
* https://freeswitch.org/confluence/
|
||||
|
||||
### Release notes:
|
||||
|
||||
* https://freeswitch.org/confluence/display/FREESWITCH/Release+Notes
|
||||
|
||||
### Installation
|
||||
|
||||
Step by step tutorials to install FreeSWITCH from packages or source code are available at:
|
||||
|
||||
* [Debian 10 Buster](https://freeswitch.org/confluence/display/FREESWITCH/Debian+10+Buster) [<b>Recommended</b>]
|
||||
* [Raspberry Pi](https://freeswitch.org/confluence/display/FREESWITCH/Raspberry+Pi)
|
||||
* [CentOS 7](https://freeswitch.org/confluence/display/FREESWITCH/CentOS+7+and+RHEL+7)
|
||||
|
||||
## Downloads
|
||||
|
||||
* [Tarballs](https://files.freeswitch.org/releases/freeswitch/)
|
||||
* [Windows Installer](http://files.freeswitch.org/windows/installer/x64/)
|
||||
* [Windows Sound Packages](http://files.freeswitch.org/windows/installer/x64/sounds/)
|
||||
|
||||
## Contributions
|
||||
|
||||
GitHub pull requests are the recommended way to contribute to the FreeSWITCH source code:
|
||||
|
||||
* https://github.com/signalwire/freeswitch/pulls
|
||||
|
||||
## Community
|
||||
|
||||
Slack is our chat system where the developers, the FreeSWITCH team, and the most active users are present.
|
||||
This is the place to get answers faster and chat with other users in real time. All you need to do is enter your email and verify it on the Slack signup page and you are ready to join in the discussion!
|
||||
|
||||
Slack Community:
|
||||
* https://signalwire.community/
|
||||
|
||||
Mailing list:
|
||||
|
||||
* http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
|
||||
|
||||
**Thank you for using FreeSWITCH!**
|
@ -29,7 +29,7 @@ freeswitch.git/configure: freeswitch.git/bootstrap.sh
|
||||
cd freeswitch.git && sh bootstrap.sh
|
||||
|
||||
freeswitch.git/bootstrap.sh: has-git
|
||||
test -d freeswitch.git || git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
|
||||
test -d freeswitch.git || git clone https://github.com/signalwire/freeswitch.git freeswitch.git
|
||||
|
||||
install: freeswitch
|
||||
cd freeswitch.git && make install cd-sounds-install cd-moh-install
|
||||
|
@ -19,7 +19,7 @@ freeswitch.git/configure: freeswitch.git/bootstrap.sh
|
||||
cd freeswitch.git && sh bootstrap.sh
|
||||
|
||||
freeswitch.git/bootstrap.sh: has-git
|
||||
test -d freeswitch.git || git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
|
||||
test -d freeswitch.git || git clone https://github.com/signalwire/freeswitch.git freeswitch.git
|
||||
|
||||
rpmforge:
|
||||
(which rpm && rpm -i http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm) || true
|
||||
|
@ -24,7 +24,7 @@ freeswitch.git/configure: freeswitch.git/bootstrap.sh
|
||||
cd freeswitch.git && AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.14 LIBTOOL=/usr/local/bin/libtoolize sh bootstrap.sh
|
||||
|
||||
freeswitch.git/bootstrap.sh: has-git
|
||||
test -d freeswitch.git || git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
|
||||
test -d freeswitch.git || git clone https://github.com/signalwire/freeswitch.git freeswitch.git
|
||||
|
||||
install:
|
||||
cd freeswitch.git && AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.14 LIBTOOL=/usr/local/bin/libtoolize gmake install cd-sounds-install cd-moh-install
|
||||
|
@ -31,7 +31,7 @@ freeswitch.git/configure: freeswitch.git/bootstrap.sh
|
||||
cd freeswitch.git && sh bootstrap.sh
|
||||
|
||||
freeswitch.git/bootstrap.sh: has-git
|
||||
test -d freeswitch.git || git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
|
||||
test -d freeswitch.git || git clone https://github.com/signalwire/freeswitch.git freeswitch.git
|
||||
|
||||
install: freeswitch
|
||||
cd freeswitch.git && gmake install cd-sounds-install cd-moh-install
|
||||
|
@ -1 +1 @@
|
||||
1.10.1-release
|
||||
1.10.2-release
|
||||
|
@ -57,6 +57,10 @@
|
||||
<param name="exchange-name" value="TAP.Commands"/>
|
||||
<param name="binding_key" value="commandBindingKey"/>
|
||||
<param name="reconnect_interval_ms" value="1000"/>
|
||||
<param name="queue-passive" value="false"/>
|
||||
<param name="queue-durable" value="false"/>
|
||||
<param name="queue-exclusive" value="false"/>
|
||||
<param name="queue-auto-delete" value="true"/>
|
||||
</params>
|
||||
</profile>
|
||||
</commands>
|
||||
|
@ -1,8 +1,8 @@
|
||||
<configuration name="msrp.conf" description="MSRP">
|
||||
<settings>
|
||||
<param name="listen-ip" value="$${local_ip_v4}"/>
|
||||
<param name="listen-port" value="2855"/>
|
||||
<param name="listen-ssl-port" value="2856"/>
|
||||
<!-- <param name="listen-port" value="2855"/> -->
|
||||
<!-- <param name="listen-ssl-port" value="2856"/> -->
|
||||
<!-- <param name="message-buffer-size" value="50"/> -->
|
||||
<!-- <param name="debug" value="true"/> -->
|
||||
<!-- <param name="secure-cert" value="$${certs_dir}/wss.pem"/> -->
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
# Must change all of the below together
|
||||
# For a release, set revision for that tagged release as well and uncomment
|
||||
AC_INIT([freeswitch], [1.10.1-release], bugs@freeswitch.org)
|
||||
AC_INIT([freeswitch], [1.10.2-release], bugs@freeswitch.org)
|
||||
AC_SUBST(SWITCH_VERSION_MAJOR, [1])
|
||||
AC_SUBST(SWITCH_VERSION_MINOR, [10])
|
||||
AC_SUBST(SWITCH_VERSION_MICRO, [1-release])
|
||||
AC_SUBST(SWITCH_VERSION_MICRO, [2-release])
|
||||
AC_SUBST(SWITCH_VERSION_REVISION, [])
|
||||
AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, [])
|
||||
|
||||
@ -1052,14 +1052,17 @@ fi
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
|
||||
if test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then
|
||||
saved_CFLAGS="$CFLAGS"
|
||||
# Next check added for Xcode 5 and systems with clang 5 llvm 3.3 or above, extended offset must be off
|
||||
AC_CACHE_CHECK([whether compiler supports -Wextended-offsetof], [ac_cv_clang_extended_offsetof], [
|
||||
CFLAGS="$CFLAGS -Wno-extended-offsetof"
|
||||
AC_TRY_COMPILE([],[return 0;],[ac_cv_clang_extended_offsetof=yes],[ac_cv_clang_extended_offsetof=no])
|
||||
])
|
||||
AC_MSG_RESULT($ac_cv_clang_extended_offsetof)
|
||||
if test x"$ac_cv_clang_extended_offsetof" = xyes; then
|
||||
APR_ADDTO(CFLAGS, -Wno-extended-offsetof)
|
||||
fi
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
fi
|
||||
|
||||
# Tested and fixed lot of modules, but some are untested. Will be added back when the core team decide it ready
|
||||
@ -1661,7 +1664,7 @@ if test "x$ac_cv_have_php" != "xno" -a "x$ac_cv_have_php_config" != "xno"; then
|
||||
PHP=php
|
||||
PHP_CONFIG=php-config
|
||||
PHP_LDFLAGS="`$PHP_CONFIG --ldflags`"
|
||||
PHP_LIBS="`$PHP_CONFIG --libs | sed -r 's/ ?-l(bz2|pcre|xml2|gssapi_krb5|krb5|k5crypto|com_err|history|z|readline|gmp|ssl|crypto)//g'`"
|
||||
PHP_LIBS="`$PHP_CONFIG --libs | sed -r 's/ ?-l(bz2|pcre2-8|xml2|gssapi_krb5|krb5|k5crypto|com_err|history|z|readline|gmp|ssl|crypto|argon2|sodium)//g'`"
|
||||
PHP_EXT_DIR="`$PHP_CONFIG --extension-dir`"
|
||||
PHP_INC_DIR="`$PHP -r 'echo ini_get("include_path");' | cut -d: -f2`"
|
||||
PHP_INI_DIR="`$PHP_CONFIG --configure-options | tr " " "\n" | grep -- --with-config-file-scan-dir | cut -f2 -d=`"
|
||||
|
2
debian/README.source
vendored
2
debian/README.source
vendored
@ -18,7 +18,7 @@ of a FreeSWITCH git repository. You can achieve this with:
|
||||
|
||||
aptitude update && aptitude install -y git
|
||||
mkdir -p /usr/src/freeswitch
|
||||
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git /usr/src/freeswitch/src
|
||||
git clone https://github.com/signalwire/freeswitch.git /usr/src/freeswitch/src
|
||||
cd /usr/src/freeswitch/src
|
||||
|
||||
Ensuring you have a clean build directory
|
||||
|
4
debian/bootstrap.sh
vendored
4
debian/bootstrap.sh
vendored
@ -338,8 +338,8 @@ Build-Depends:
|
||||
$(debian_wrap "${mod_build_depends}")
|
||||
Standards-Version: 3.9.3
|
||||
Homepage: https://freeswitch.org/
|
||||
Vcs-Git: https://freeswitch.org/stash/scm/fs/freeswitch.git
|
||||
Vcs-Browser: https://freeswitch.org/stash/projects/FS/repos/freeswitch/browse
|
||||
Vcs-Git: https://github.com/signalwire/freeswitch.git
|
||||
Vcs-Browser: https://github.com/signalwire/freeswitch
|
||||
|
||||
EOF
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ The container exposes the following ports:
|
||||
|
||||
If you wish to help improve these please submit a pull request at:
|
||||
|
||||
https://freeswitch.org/jira
|
||||
https://github.com/signalwire/freeswitch
|
||||
|
||||
Thanks,
|
||||
/b
|
@ -85,7 +85,7 @@ apt-get install freeswitch-conf-vanilla
|
||||
```
|
||||
2) clone freeswitch repo
|
||||
```sh
|
||||
git clone https://freeswitch.org/stash/projects/FS/repos/freeswitch/browse
|
||||
git clone https://github.com/signalwire/freeswitch.git
|
||||
```
|
||||
3) execute ```make_min_archive.sh``` script
|
||||
```sh
|
||||
@ -100,4 +100,4 @@ docker build -t freeswitch_custom .
|
||||
Read more
|
||||
---------
|
||||
|
||||
[Dockerfile of official FreeSwitch container](https://freeswitch.org/stash/projects/FS/repos/freeswitch/browse/docker/release)
|
||||
[Dockerfile of official FreeSwitch container](https://github.com/signalwire/freeswitch/tree/master/docker/release)
|
||||
|
@ -4,7 +4,7 @@ How to Contribute Patches to FreeSWITCH
|
||||
Download the Source Code
|
||||
------------------------
|
||||
|
||||
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git
|
||||
git clone https://github.com/signalwire/freeswitch.git
|
||||
cd freeswitch
|
||||
|
||||
Ensure Git is Setup
|
||||
@ -42,18 +42,18 @@ Create a Pull Request
|
||||
|
||||
# create an account in JIRA and create a new issue
|
||||
|
||||
# navigate to FreeSWITCH Stash
|
||||
chromium https://freeswitch.org/stash
|
||||
# navigate to FreeSWITCH github
|
||||
chromium https://github.com/signalwire/freeswitch
|
||||
|
||||
# Using the same credentials as Jira, login to Stash; create a forked FS repository; read
|
||||
# Using your github credentials, login to github; create a forked FS repository; read
|
||||
# the details here:
|
||||
chromium https://freeswitch.org/confluence/display/FREESWITCH/Pull+Requests
|
||||
|
||||
# add your repository as a remote (change to your username)
|
||||
git remote add stash ssh://git@freeswitch.org:7999/~johndoe/freeswitch.git
|
||||
git remote add fs git@github.com:signalwire/freeswitch.git
|
||||
|
||||
# push your changes to a branch
|
||||
git push stash +HEAD:myfeature
|
||||
git push fs +HEAD:myfeature
|
||||
|
||||
# create a pull request as described here:
|
||||
chromium https://freeswitch.org/confluence/display/FREESWITCH/Pull+Requests
|
||||
|
@ -35,6 +35,6 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://freeswitch.org/stash/scm/fs/freeswitch.git"
|
||||
"url": "https://github.com/signalwire/freeswitch.git"
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Fri Apr 8 13:43:12 EDT 2016
|
||||
Wed Sep 25 15:25:12 EDT 2019
|
||||
|
@ -214,6 +214,12 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
|
||||
#define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \
|
||||
apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
|
||||
APR_POOL__FILE_LINE__)
|
||||
|
||||
APR_DECLARE(int) apr_pool_walk_tree_debug(apr_pool_t *pool,
|
||||
int(*fn)(apr_pool_t *pool, void *data),
|
||||
void *data);
|
||||
|
||||
APR_DECLARE(void) apr_pool_get_stats(apr_pool_t *pool, unsigned int *alloc, unsigned int *total_alloc, unsigned int *clear);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -1126,6 +1126,22 @@ static int apr_pool_walk_tree(apr_pool_t *pool,
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_pool_walk_tree_debug(apr_pool_t *pool,
|
||||
int(*fn)(apr_pool_t *pool, void *data),
|
||||
void *data)
|
||||
{
|
||||
return apr_pool_walk_tree(pool, fn, data);
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_pool_get_stats(apr_pool_t *pool, unsigned int *alloc, unsigned int *total_alloc, unsigned int *clear)
|
||||
{
|
||||
if (pool) {
|
||||
*alloc = pool->stat_alloc;
|
||||
*total_alloc = pool->stat_total_alloc;
|
||||
*clear = pool->stat_clear;
|
||||
}
|
||||
}
|
||||
|
||||
#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
|
||||
static void apr_pool_log_event(apr_pool_t *pool, const char *event,
|
||||
const char *file_line, int deref)
|
||||
@ -1432,7 +1448,7 @@ static void pool_clear_debug(apr_pool_t *pool, const char *file_line)
|
||||
|
||||
for (index = 0; index < node->index; index++) {
|
||||
memset(node->beginp[index], POOL_POISON_BYTE,
|
||||
node->endp[index] - node->beginp[index]);
|
||||
(char *)node->endp[index] - (char *)node->beginp[index]);
|
||||
free(node->beginp[index]);
|
||||
}
|
||||
|
||||
|
@ -674,7 +674,7 @@ static void redisplay(void)
|
||||
esl_mutex_lock(MUTEX);
|
||||
{
|
||||
#ifdef HAVE_LIBEDIT
|
||||
#ifdef XHAVE_DECL_EL_REFRESH
|
||||
#ifdef HAVE_DECL_EL_REFRESH
|
||||
#ifdef HAVE_EL_WSET
|
||||
/* Current libedit versions don't implement EL_REFRESH in eln.c so
|
||||
* use the wide version instead. */
|
||||
@ -1002,10 +1002,13 @@ static const char *basic_gets(int *cnt)
|
||||
for (x = 0; x < (sizeof(command_buf) - 1); x++) {
|
||||
int c = getchar();
|
||||
if (c < 0) {
|
||||
size_t command_buf_len;
|
||||
if (fgets(command_buf, sizeof(command_buf) - 1, stdin) != command_buf) {
|
||||
break;
|
||||
}
|
||||
if ((command_buf_len = strlen(command_buf)) > 0) {
|
||||
command_buf[command_buf_len - 1] = '\0'; /* remove endline */
|
||||
}
|
||||
command_buf[strlen(command_buf)-1] = '\0'; /* remove endline */
|
||||
break;
|
||||
}
|
||||
command_buf[x] = (char) c;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 3.0.2
|
||||
* Version 3.0.12
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
|
@ -3,7 +3,7 @@ WRAP_GCC_WARNING_SILENCE=-Wno-unused-label -Wno-unused-function
|
||||
all: ESL.so
|
||||
|
||||
esl_wrap.cpp:
|
||||
swig3.0 -module ESL -php5 -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
|
||||
swig3.0 -module ESL -php7 -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
|
||||
sed -e 's/ char \*type_name;/ const char \*type_name;/' -i esl_wrap.cpp
|
||||
|
||||
esl_wrap.o: esl_wrap.cpp
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 3.0.2
|
||||
* Version 3.0.12
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
@ -20,16 +20,6 @@ extern zend_module_entry ESL_module_entry;
|
||||
# define PHP_ESL_API
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
PHP_MINIT_FUNCTION(ESL);
|
||||
PHP_MSHUTDOWN_FUNCTION(ESL);
|
||||
PHP_RINIT_FUNCTION(ESL);
|
||||
PHP_RSHUTDOWN_FUNCTION(ESL);
|
||||
PHP_MINFO_FUNCTION(ESL);
|
||||
|
||||
ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_set);
|
||||
ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_get);
|
||||
ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialized_string_set);
|
||||
@ -69,4 +59,6 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setAsyncExecute);
|
||||
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock);
|
||||
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_disconnect);
|
||||
ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel);
|
||||
PHP_MINIT_FUNCTION(ESL);
|
||||
|
||||
#endif /* PHP_ESL_H */
|
||||
|
@ -148,6 +148,7 @@ static const char *EVENT_NAMES[] = {
|
||||
"CALL_DETAIL",
|
||||
"DEVICE_STATE",
|
||||
"TEXT",
|
||||
"SHUTDOWN_REQUESTED",
|
||||
"ALL"
|
||||
};
|
||||
|
||||
|
@ -138,6 +138,7 @@ typedef enum {
|
||||
ESL_EVENT_CALL_DETAIL,
|
||||
ESL_EVENT_DEVICE_STATE,
|
||||
ESL_EVENT_TEXT,
|
||||
ESL_EVENT_SHUTDOWN_REQUESTED,
|
||||
ESL_EVENT_ALL
|
||||
} esl_event_types_t;
|
||||
|
||||
|
@ -757,6 +757,18 @@ process_common_toolchain() {
|
||||
tgt_isa=x86_64
|
||||
tgt_os=darwin16
|
||||
;;
|
||||
*darwin17*)
|
||||
tgt_isa=x86_64
|
||||
tgt_os=darwin17
|
||||
;;
|
||||
*darwin18*)
|
||||
tgt_isa=x86_64
|
||||
tgt_os=darwin18
|
||||
;;
|
||||
*darwin19*)
|
||||
tgt_isa=x86_64
|
||||
tgt_os=darwin19
|
||||
;;
|
||||
x86_64*mingw32*)
|
||||
tgt_os=win64
|
||||
;;
|
||||
@ -885,6 +897,18 @@ process_common_toolchain() {
|
||||
add_cflags "-mmacosx-version-min=10.12"
|
||||
add_ldflags "-mmacosx-version-min=10.12"
|
||||
;;
|
||||
*-darwin17-*)
|
||||
add_cflags "-mmacosx-version-min=10.13"
|
||||
add_ldflags "-mmacosx-version-min=10.13"
|
||||
;;
|
||||
*-darwin18-*)
|
||||
add_cflags "-mmacosx-version-min=10.14"
|
||||
add_ldflags "-mmacosx-version-min=10.14"
|
||||
;;
|
||||
*-darwin19-*)
|
||||
add_cflags "-mmacosx-version-min=10.15"
|
||||
add_ldflags "-mmacosx-version-min=10.15"
|
||||
;;
|
||||
*-iphonesimulator-*)
|
||||
add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
|
||||
add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
|
||||
|
@ -35,8 +35,8 @@ ARM_TARGETS="arm64-darwin-gcc
|
||||
armv7s-darwin-gcc"
|
||||
SIM_TARGETS="x86-iphonesimulator-gcc
|
||||
x86_64-iphonesimulator-gcc"
|
||||
OSX_TARGETS="x86-darwin16-gcc
|
||||
x86_64-darwin16-gcc"
|
||||
OSX_TARGETS="x86-darwin18-gcc
|
||||
x86_64-darwin18-gcc"
|
||||
TARGETS="${ARM_TARGETS} ${SIM_TARGETS}"
|
||||
|
||||
# Configures for the target specified by $1, and invokes make with the dist
|
||||
@ -271,7 +271,7 @@ cat << EOF
|
||||
--help: Display this message and exit.
|
||||
--enable-shared: Build a dynamic framework for use on iOS 8 or later.
|
||||
--extra-configure-args <args>: Extra args to pass when configuring libvpx.
|
||||
--macosx: Uses darwin16 targets instead of iphonesimulator targets for x86
|
||||
--macosx: Uses darwin18 targets instead of iphonesimulator targets for x86
|
||||
and x86_64. Allows linking to framework when builds target MacOSX
|
||||
instead of iOS.
|
||||
--preserve-build-output: Do not delete the build directory.
|
||||
|
5
libs/libvpx/configure
vendored
5
libs/libvpx/configure
vendored
@ -129,6 +129,8 @@ all_platforms="${all_platforms} x86-darwin13-gcc"
|
||||
all_platforms="${all_platforms} x86-darwin14-gcc"
|
||||
all_platforms="${all_platforms} x86-darwin15-gcc"
|
||||
all_platforms="${all_platforms} x86-darwin16-gcc"
|
||||
all_platforms="${all_platforms} x86-darwin17-gcc"
|
||||
all_platforms="${all_platforms} x86-darwin18-gcc"
|
||||
all_platforms="${all_platforms} x86-iphonesimulator-gcc"
|
||||
all_platforms="${all_platforms} x86-linux-gcc"
|
||||
all_platforms="${all_platforms} x86-linux-icc"
|
||||
@ -149,6 +151,9 @@ all_platforms="${all_platforms} x86_64-darwin13-gcc"
|
||||
all_platforms="${all_platforms} x86_64-darwin14-gcc"
|
||||
all_platforms="${all_platforms} x86_64-darwin15-gcc"
|
||||
all_platforms="${all_platforms} x86_64-darwin16-gcc"
|
||||
all_platforms="${all_platforms} x86_64-darwin17-gcc"
|
||||
all_platforms="${all_platforms} x86_64-darwin18-gcc"
|
||||
all_platforms="${all_platforms} x86_64-darwin19-gcc"
|
||||
all_platforms="${all_platforms} x86_64-iphonesimulator-gcc"
|
||||
all_platforms="${all_platforms} x86_64-linux-gcc"
|
||||
all_platforms="${all_platforms} x86_64-linux-icc"
|
||||
|
@ -119,6 +119,12 @@
|
||||
*/
|
||||
#define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN
|
||||
|
||||
#elif defined(__e2k__)
|
||||
/*
|
||||
* Elbrus, little endian
|
||||
*/
|
||||
#define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN
|
||||
|
||||
#endif /* Automatic byte order detection */
|
||||
|
||||
#endif
|
||||
|
@ -1 +1 @@
|
||||
Mon Aug 19 16:25:57 CDT 2019
|
||||
Wed Dec 11 15:38:35 MST 2019
|
||||
|
@ -1040,6 +1040,10 @@ int nua_client_response(nua_client_request_t *cr,
|
||||
if (cr->cr_restarting)
|
||||
return 0;
|
||||
|
||||
if (cr->cr_status == 200 && status < 200) { // ignore 183 follows 200
|
||||
return 0;
|
||||
}
|
||||
|
||||
nua_client_request_ref(cr);
|
||||
|
||||
cr->cr_status = status;
|
||||
|
@ -904,7 +904,7 @@ sres_sip_log_answers(sres_sip_t *srs,
|
||||
SU_DEBUG_5(("srs(%p): %s IN CNAME %s\n", (void *)srs, domain, cname));
|
||||
}
|
||||
#if SU_HAVE_IN6
|
||||
else if (type == sres_type_cname) {
|
||||
else if (type == sres_type_aaaa) {
|
||||
sres_aaaa_record_t const *aaaa = sr->sr_aaaa;
|
||||
su_inet_ntop(AF_INET6, &aaaa->aaaa_addr, addr, sizeof(addr));
|
||||
SU_DEBUG_5(("srs(%p): %s IN AAAA %s\n", (void *)srs, domain, addr));
|
||||
|
@ -210,8 +210,11 @@ su_inline void safefree(void *b) { b ? free(b) : (void)0; }
|
||||
#endif
|
||||
|
||||
static inline su_block_t* MEMLOCK(const su_home_t *h) {
|
||||
if (h && h->suh_lock) _su_home_locker(h->suh_lock);
|
||||
return h->suh_blocks;
|
||||
if (h) {
|
||||
if (h->suh_lock) _su_home_locker(h->suh_lock);
|
||||
return h->suh_blocks;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
static inline void* UNLOCK(const su_home_t *h) {
|
||||
if (h && h->suh_lock) _su_home_unlocker(h->suh_lock);
|
||||
@ -271,9 +274,9 @@ struct su_block_s {
|
||||
|
||||
static void su_home_check_blocks(su_block_t const *b);
|
||||
|
||||
static void su_home_stats_alloc(su_block_t *, void *p, void *preload,
|
||||
static void su_home_stats_alloc(su_block_t *, void *preload,
|
||||
size_t size, int zero);
|
||||
static void su_home_stats_free(su_block_t *sub, void *p, void *preload,
|
||||
static void su_home_stats_free(su_block_t *sub, void *preload,
|
||||
unsigned size);
|
||||
|
||||
static void _su_home_deinit(su_home_t *home);
|
||||
@ -529,7 +532,7 @@ void *sub_alloc(su_home_t *home,
|
||||
sua->sua_home = zero > 1;
|
||||
|
||||
if (sub->sub_stats)
|
||||
su_home_stats_alloc(sub, data, preload, size, zero);
|
||||
su_home_stats_alloc(sub, preload, size, zero);
|
||||
}
|
||||
|
||||
return data;
|
||||
@ -923,7 +926,7 @@ void su_free(su_home_t *home, void *data)
|
||||
preloaded = data;
|
||||
|
||||
if (sub->sub_stats)
|
||||
su_home_stats_free(sub, data, preloaded, allocation->sua_size);
|
||||
su_home_stats_free(sub, preloaded, allocation->sua_size);
|
||||
|
||||
if (allocation->sua_home) {
|
||||
su_home_t *subhome = data;
|
||||
@ -1425,8 +1428,8 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
|
||||
ndata = realloc(data, size + MEMCHECK_EXTRA);
|
||||
if (ndata) {
|
||||
if (sub->sub_stats) {
|
||||
su_home_stats_free(sub, data, 0, sua->sua_size);
|
||||
su_home_stats_alloc(sub, data, 0, size, 1);
|
||||
su_home_stats_free(sub, 0, sua->sua_size);
|
||||
su_home_stats_alloc(sub, 0, size, 1);
|
||||
}
|
||||
|
||||
#if MEMCHECK_EXTRA
|
||||
@ -1453,8 +1456,8 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
|
||||
if (p2 <= sub->sub_prsize) {
|
||||
/* Extend/reduce existing preload */
|
||||
if (sub->sub_stats) {
|
||||
su_home_stats_free(sub, data, data, sua->sua_size);
|
||||
su_home_stats_alloc(sub, data, data, size, 0);
|
||||
su_home_stats_free(sub, data, sua->sua_size);
|
||||
su_home_stats_alloc(sub, data, size, 0);
|
||||
}
|
||||
|
||||
sub->sub_prused = (unsigned)p2;
|
||||
@ -1470,8 +1473,8 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
|
||||
else if (size < (size_t)sua->sua_size) {
|
||||
/* Reduce existing preload */
|
||||
if (sub->sub_stats) {
|
||||
su_home_stats_free(sub, data, data, sua->sua_size);
|
||||
su_home_stats_alloc(sub, data, data, size, 0);
|
||||
su_home_stats_free(sub, data, sua->sua_size);
|
||||
su_home_stats_alloc(sub, data, size, 0);
|
||||
}
|
||||
#if MEMCHECK_EXTRA
|
||||
memcpy((char *)data + size, &term, sizeof (term));
|
||||
@ -1488,7 +1491,7 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
|
||||
/* Free preload */
|
||||
sub->sub_prused = (char *)data - home->suh_blocks->sub_preload;
|
||||
if (sub->sub_stats)
|
||||
su_home_stats_free(sub, data, data, sua->sua_size);
|
||||
su_home_stats_free(sub, data, sua->sua_size);
|
||||
}
|
||||
|
||||
memcpy(ndata, data,
|
||||
@ -1500,7 +1503,7 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
|
||||
#endif
|
||||
|
||||
if (sub->sub_stats)
|
||||
su_home_stats_alloc(sub, data, 0, size, 1);
|
||||
su_home_stats_alloc(sub, 0, size, 1);
|
||||
|
||||
memset(sua, 0, sizeof *sua); sub->sub_used--;
|
||||
|
||||
@ -1837,7 +1840,7 @@ void su_home_get_stats(su_home_t *home, int include_clones,
|
||||
}
|
||||
|
||||
static
|
||||
void su_home_stats_alloc(su_block_t *sub, void *p, void *preload,
|
||||
void su_home_stats_alloc(su_block_t *sub, void *preload,
|
||||
size_t size, int zero)
|
||||
{
|
||||
su_home_stat_t *hs = sub->sub_stats;
|
||||
@ -1866,7 +1869,7 @@ void su_home_stats_alloc(su_block_t *sub, void *p, void *preload,
|
||||
}
|
||||
|
||||
static
|
||||
void su_home_stats_free(su_block_t *sub, void *p, void *preload,
|
||||
void su_home_stats_free(su_block_t *sub, void *preload,
|
||||
unsigned size)
|
||||
{
|
||||
su_home_stat_t *hs = sub->sub_stats;
|
||||
|
@ -1056,15 +1056,19 @@ int tport_register_secondary(tport_t *self, su_wakeup_f wakeup, int events)
|
||||
&&
|
||||
(i = su_root_register(root, wait, wakeup, self, 0)) != -1) {
|
||||
|
||||
/* Can't be added to list of opened if already closed */
|
||||
if (tport_is_closed(self)) goto fail;
|
||||
|
||||
self->tp_index = i;
|
||||
self->tp_events = events;
|
||||
|
||||
/* Can't be added to list of opened if already closed */
|
||||
if (!tport_is_closed(self))
|
||||
tprb_append(&self->tp_pri->pri_open, self);
|
||||
tprb_append(&self->tp_pri->pri_open, self);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
fail:
|
||||
SU_DEBUG_9(("%s(%p): tport is %s!\n", __func__, (void *)self, (tport_is_closed(self) ? "closed" : "opened")));
|
||||
su_wait_destroy(wait);
|
||||
return -1;
|
||||
}
|
||||
@ -2763,6 +2767,7 @@ static int tport_wakeup_pri(su_root_magic_t *m, su_wait_t *w, tport_t *self)
|
||||
int tport_wakeup(su_root_magic_t *magic, su_wait_t *w, tport_t *self)
|
||||
{
|
||||
int events = su_wait_events(w, self->tp_socket);
|
||||
int error;
|
||||
|
||||
#if HAVE_POLL
|
||||
assert(w->fd == self->tp_socket);
|
||||
@ -2777,9 +2782,16 @@ int tport_wakeup(su_root_magic_t *magic, su_wait_t *w, tport_t *self)
|
||||
self->tp_closed ? " (closed)" : ""));
|
||||
|
||||
if (self->tp_pri->pri_vtable->vtp_wakeup)
|
||||
return self->tp_pri->pri_vtable->vtp_wakeup(self, events);
|
||||
error = self->tp_pri->pri_vtable->vtp_wakeup(self, events);
|
||||
else
|
||||
return tport_base_wakeup(self, events);
|
||||
error = tport_base_wakeup(self, events);
|
||||
|
||||
if (tport_is_closed(self)) {
|
||||
SU_DEBUG_9(("%s(%p): tport is closed! Setting secondary timer!\n", "tport_wakeup", (void *)self));
|
||||
tport_set_secondary_timer(self);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static int tport_base_wakeup(tport_t *self, int events)
|
||||
|
@ -969,12 +969,19 @@ int tls_connect(su_root_magic_t *magic, su_wait_t *w, tport_t *self)
|
||||
if (events & SU_WAIT_HUP && !self->tp_closed)
|
||||
tport_hup_event(self);
|
||||
|
||||
if (self->tp_closed)
|
||||
if (self->tp_closed) {
|
||||
SU_DEBUG_9(("%s(%p): tport was closed during connect. Returning, but set secondary timer first.\n",
|
||||
__func__, (void *)self));
|
||||
tport_set_secondary_timer(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
error = su_soerror(self->tp_socket);
|
||||
if (error) {
|
||||
tport_error_report(self, error, NULL);
|
||||
SU_DEBUG_9(("%s(%p): socket error during connect. Returning, but set secondary timer first.\n",
|
||||
__func__, (void *)self));
|
||||
tport_set_secondary_timer(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -133,10 +133,10 @@ config_fs_repos() {
|
||||
curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add -
|
||||
if [ "$FS_REV" = "master" ]; then
|
||||
echo "deb http://files.freeswitch.org/repo/deb/debian-unstable/ jessie main" >/etc/apt/sources.list.d/freeswitch.list
|
||||
REPO="https://freeswitch.org/stash/scm/fs/freeswitch.git"
|
||||
REPO="https://github.com/signalwire/freeswitch.git"
|
||||
elif [ "$FS_REV" = "1.6" ]; then
|
||||
echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list
|
||||
REPO="-b v1.6 https://silik0n@freeswitch.org/stash/scm/fs/freeswitch.git"
|
||||
REPO="-b v1.6 https://github.com/signalwire/freeswitch.git"
|
||||
fi
|
||||
apt-get update 2>&1 >/dev/null
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ apt-get update && apt-get install -y libtool libjpeg62-turbo-dev ntpdate libfree
|
||||
|
||||
cd /usr/src
|
||||
|
||||
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git freeswitch.git
|
||||
git clone https://github.com/signalwire/freeswitch.git freeswitch.git
|
||||
|
||||
cd freeswitch.git
|
||||
|
||||
|
@ -623,6 +623,8 @@ SWITCH_DECLARE(const switch_state_handler_table_t *) switch_core_get_state_handl
|
||||
|
||||
SWITCH_DECLARE(void) switch_core_memory_pool_tag(switch_memory_pool_t *pool, const char *tag);
|
||||
|
||||
SWITCH_DECLARE(void) switch_core_pool_stats(switch_stream_handle_t *stream);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_perform_new_memory_pool(_Out_ switch_memory_pool_t **pool,
|
||||
_In_z_ const char *file, _In_z_ const char *func, _In_ int line);
|
||||
|
||||
@ -1424,6 +1426,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_init_case(_Out_ switch_hash_t *
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(_Inout_ switch_hash_t **hash);
|
||||
|
||||
/*!
|
||||
\brief Insert data into a hash and set flags so the value is automatically freed on delete
|
||||
\param hash the hash to add data to
|
||||
\param key the name of the key to add the data to
|
||||
\param data the data to add
|
||||
\return SWITCH_STATUS_SUCCESS if the data is added
|
||||
\note the string key must be a constant or a dynamic string
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_auto_free(switch_hash_t *hash, const char *key, const void *data);
|
||||
|
||||
/*!
|
||||
\brief Insert data into a hash
|
||||
\param hash the hash to add data to
|
||||
@ -1842,6 +1854,13 @@ SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_video_write_codec(_In_
|
||||
*/
|
||||
SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(const char *filename);
|
||||
|
||||
/*!
|
||||
\brief Open a core db (SQLite) in-memory
|
||||
\param uri to the db to open
|
||||
\return the db handle
|
||||
*/
|
||||
SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_in_memory(const char *uri);
|
||||
|
||||
/*!
|
||||
\brief Execute a sql stmt until it is accepted
|
||||
\param db the db handle
|
||||
@ -2473,7 +2492,8 @@ typedef int (*switch_core_db_event_callback_func_t) (void *pArg, switch_event_t
|
||||
#define CACHE_DB_LEN 256
|
||||
typedef enum {
|
||||
CDF_INUSE = (1 << 0),
|
||||
CDF_PRUNE = (1 << 1)
|
||||
CDF_PRUNE = (1 << 1),
|
||||
CDF_NONEXPIRING = (1 << 2)
|
||||
} cache_db_flag_t;
|
||||
|
||||
typedef enum {
|
||||
@ -2483,13 +2503,14 @@ typedef enum {
|
||||
} switch_cache_db_handle_type_t;
|
||||
|
||||
typedef union {
|
||||
switch_core_db_t *core_db_dbh;
|
||||
switch_coredb_handle_t *core_db_dbh;
|
||||
switch_odbc_handle_t *odbc_dbh;
|
||||
switch_database_interface_handle_t *database_interface_dbh;
|
||||
} switch_cache_db_native_handle_t;
|
||||
|
||||
typedef struct {
|
||||
char *db_path;
|
||||
switch_bool_t in_memory;
|
||||
} switch_cache_db_core_db_options_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -51,6 +51,12 @@ SWITCH_BEGIN_EXTERN_C
|
||||
* following opaque structure.
|
||||
*/
|
||||
typedef struct sqlite3 switch_core_db_t;
|
||||
|
||||
struct switch_coredb_handle {
|
||||
switch_bool_t in_memory;
|
||||
switch_core_db_t *handle;
|
||||
};
|
||||
|
||||
typedef struct sqlite3_stmt switch_core_db_stmt_t;
|
||||
|
||||
typedef int (*switch_core_db_callback_func_t) (void *pArg, int argc, char **argv, char **columnNames);
|
||||
@ -103,41 +109,47 @@ SWITCH_DECLARE(int) switch_core_db_close(switch_core_db_t *db);
|
||||
SWITCH_DECLARE(int) switch_core_db_open(const char *filename, switch_core_db_t **ppDb);
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
* case the first parameter is a pointer to the SQL statement that is being
|
||||
* executed (the switch_core_db_stmt_t* that was returned from switch_core_db_prepare()) and
|
||||
* the second argument is the index of the column for which information
|
||||
* should be returned. iCol is zero-indexed. The left-most column as an
|
||||
* index of 0.
|
||||
Same as switch_core_db_open() but additionally allows SQLITE_OPEN_URI
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_core_db_open_v2(const char *filename, switch_core_db_t **ppDb);
|
||||
|
||||
/**
|
||||
* ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
|
||||
* even empty strings, are always zero-terminated. ^The return
|
||||
* value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
|
||||
*
|
||||
* If the SQL statement is not currently point to a valid row, or if the
|
||||
* the colulmn index is out of range, the result is undefined.
|
||||
* ^The object returned by [sqlite3_column_value()] is an
|
||||
* [unprotected sqlite3_value] object. An unprotected sqlite3_value object
|
||||
* may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
|
||||
* If the [unprotected sqlite3_value] object returned by
|
||||
* [sqlite3_column_value()] is used in any other way, including calls
|
||||
* to routines like [sqlite3_value_int()], [sqlite3_value_text()],
|
||||
* or [sqlite3_value_bytes()], then the behavior is undefined.
|
||||
*
|
||||
* These routines attempt to convert the value where appropriate. For
|
||||
* These routines attempt to convert the value where appropriate. ^For
|
||||
* example, if the internal representation is FLOAT and a text result
|
||||
* is requested, sprintf() is used internally to do the conversion
|
||||
* automatically. The following table details the conversions that
|
||||
* are applied:
|
||||
* is requested, [sqlite3_snprintf()] is used internally to perform the
|
||||
* conversion automatically. ^(The following table details the conversions
|
||||
* that are applied:
|
||||
*
|
||||
* Internal Type Requested Type Conversion
|
||||
* ------------- -------------- --------------------------
|
||||
* NULL INTEGER Result is 0
|
||||
* NULL FLOAT Result is 0.0
|
||||
* NULL TEXT Result is an empty string
|
||||
* NULL BLOB Result is a zero-length BLOB
|
||||
* NULL TEXT Result is a NULL pointer
|
||||
* NULL BLOB Result is a NULL pointer
|
||||
* INTEGER FLOAT Convert from integer to float
|
||||
* INTEGER TEXT ASCII rendering of the integer
|
||||
* INTEGER BLOB Same as for INTEGER->TEXT
|
||||
* FLOAT INTEGER Convert from float to integer
|
||||
* INTEGER BLOB Same as INTEGER->TEXT
|
||||
* FLOAT INTEGER [CAST] to INTEGER
|
||||
* FLOAT TEXT ASCII rendering of the float
|
||||
* FLOAT BLOB Same as FLOAT->TEXT
|
||||
* TEXT INTEGER Use atoi()
|
||||
* TEXT FLOAT Use atof()
|
||||
* FLOAT BLOB [CAST] to BLOB
|
||||
* TEXT INTEGER [CAST] to INTEGER
|
||||
* TEXT FLOAT [CAST] to REAL
|
||||
* TEXT BLOB No change
|
||||
* BLOB INTEGER Convert to TEXT then use atoi()
|
||||
* BLOB FLOAT Convert to TEXT then use atof()
|
||||
* BLOB TEXT Add a "\000" terminator if needed
|
||||
* BLOB INTEGER [CAST] to INTEGER
|
||||
* BLOB FLOAT [CAST] to REAL
|
||||
* BLOB TEXT Add a zero terminator if needed
|
||||
*
|
||||
* Return the value as UTF-8 text.
|
||||
*/
|
||||
|
@ -1052,8 +1052,9 @@ SWITCH_DECLARE(int) switch_dial_handle_get_peers(switch_dial_handle_t *handle, i
|
||||
SWITCH_DECLARE(int) switch_dial_handle_get_vars(switch_dial_handle_t *handle, int idx, switch_event_t **array, int max);
|
||||
SWITCH_DECLARE(switch_event_t *) switch_dial_handle_get_global_vars(switch_dial_handle_t *handle);
|
||||
SWITCH_DECLARE(switch_event_t *) switch_dial_leg_get_vars(switch_dial_leg_t *leg);
|
||||
SWITCH_DECLARE(const char *) switch_dial_leg_get_var(switch_dial_leg_t *leg, const char *key);
|
||||
SWITCH_DECLARE(int) switch_dial_handle_get_total(switch_dial_handle_t *handle);
|
||||
SWITCH_DECLARE(void) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_collect_input(switch_core_session_t *session,
|
||||
const char *prompt,
|
||||
|
@ -34,9 +34,6 @@
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#define MSRP_LISTEN_PORT 2855
|
||||
#define MSRP_SSL_LISTEN_PORT 2856
|
||||
|
||||
enum {
|
||||
MSRP_ST_WAIT_HEADER,
|
||||
MSRP_ST_PARSE_HEADER,
|
||||
|
@ -387,7 +387,9 @@ typedef enum {
|
||||
SCF_DIALPLAN_TIMESTAMPS = (1 << 24),
|
||||
SCF_CPF_SOFT_PREFIX = (1 << 25),
|
||||
SCF_CPF_SOFT_LOOKUP = (1 << 26),
|
||||
SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY = (1 << 27)
|
||||
SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY = (1 << 27),
|
||||
SCF_EVENT_CHANNEL_HIERARCHY_DELIVERY_ONCE = (1 << 28),
|
||||
SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON = (1 << 29)
|
||||
} switch_core_flag_enum_t;
|
||||
typedef uint32_t switch_core_flag_t;
|
||||
|
||||
@ -1892,7 +1894,8 @@ typedef enum {
|
||||
SMBF_SPY_VIDEO_STREAM = (1 << 22),
|
||||
SMBF_SPY_VIDEO_STREAM_BLEG = (1 << 23),
|
||||
SMBF_READ_VIDEO_PATCH = (1 << 24),
|
||||
SMBF_READ_TEXT_STREAM = (1 << 25)
|
||||
SMBF_READ_TEXT_STREAM = (1 << 25),
|
||||
SMBF_FIRST = (1 << 26)
|
||||
} switch_media_bug_flag_enum_t;
|
||||
typedef uint32_t switch_media_bug_flag_t;
|
||||
|
||||
@ -1935,7 +1938,8 @@ typedef enum {
|
||||
SWITCH_FILE_NOMUX = (1 << 17),
|
||||
SWITCH_FILE_BREAK_ON_CHANGE = (1 << 18),
|
||||
SWITCH_FILE_FLAG_VIDEO = (1 << 19),
|
||||
SWITCH_FILE_FLAG_VIDEO_EOF = (1 << 20)
|
||||
SWITCH_FILE_FLAG_VIDEO_EOF = (1 << 20),
|
||||
SWITCH_FILE_PRE_CLOSED = (1 << 21)
|
||||
} switch_file_flag_enum_t;
|
||||
typedef uint32_t switch_file_flag_t;
|
||||
|
||||
@ -2045,6 +2049,7 @@ typedef uint32_t switch_io_flag_t;
|
||||
SWITCH_EVENT_CALL_SETUP_RESULT
|
||||
SWITCH_EVENT_CALL_DETAIL
|
||||
SWITCH_EVENT_DEVICE_STATE
|
||||
SWITCH_EVENT_SHUTDOWN_REQUESTED - Shutdown of the system has been requested
|
||||
SWITCH_EVENT_ALL - All events at once
|
||||
</pre>
|
||||
|
||||
@ -2140,6 +2145,7 @@ typedef enum {
|
||||
SWITCH_EVENT_CALL_DETAIL,
|
||||
SWITCH_EVENT_DEVICE_STATE,
|
||||
SWITCH_EVENT_TEXT,
|
||||
SWITCH_EVENT_SHUTDOWN_REQUESTED,
|
||||
SWITCH_EVENT_ALL
|
||||
} switch_event_types_t;
|
||||
|
||||
@ -2315,6 +2321,7 @@ typedef struct switch_codec_implementation switch_codec_implementation_t;
|
||||
typedef struct switch_buffer switch_buffer_t;
|
||||
typedef union switch_codec_settings switch_codec_settings_t;
|
||||
typedef struct switch_codec_fmtp switch_codec_fmtp_t;
|
||||
typedef struct switch_coredb_handle switch_coredb_handle_t;
|
||||
typedef struct switch_odbc_handle switch_odbc_handle_t;
|
||||
typedef struct switch_database_interface_handle switch_database_interface_handle_t;
|
||||
|
||||
|
@ -57,6 +57,8 @@
|
||||
#define FREESWITCH_XML_H
|
||||
#include <switch.h>
|
||||
|
||||
/* Use UTF-8 as the general encoding */
|
||||
#define USE_UTF_8_ENCODING SWITCH_TRUE
|
||||
|
||||
struct switch_xml_binding;
|
||||
|
||||
@ -69,7 +71,8 @@ SWITCH_BEGIN_EXTERN_C
|
||||
SWITCH_XML_ROOT = (1 << 0), // root
|
||||
SWITCH_XML_NAMEM = (1 << 1), // name is malloced
|
||||
SWITCH_XML_TXTM = (1 << 2), // txt is malloced
|
||||
SWITCH_XML_DUP = (1 << 3) // attribute name and value are strduped
|
||||
SWITCH_XML_DUP = (1 << 3), // attribute name and value are strduped
|
||||
SWITCH_XML_CDATA = (1 << 4) // body is in CDATA
|
||||
} switch_xml_flag_t;
|
||||
|
||||
/*! \brief A representation of an XML tree */
|
||||
@ -212,10 +215,15 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_get(_In_ switch_xml_t xml,...);
|
||||
///\ must be freed.
|
||||
///\param xml the xml node
|
||||
///\param prn_header add <?xml version..> header too
|
||||
///\param use_utf8_encoding encoding into ampersand entities for UTF-8 chars
|
||||
///\return the ampersanded html text string to display xml
|
||||
SWITCH_DECLARE(char *) switch_xml_toxml(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header);
|
||||
SWITCH_DECLARE(char *) switch_xml_toxml_nolock(switch_xml_t xml, _In_ switch_bool_t prn_header);
|
||||
SWITCH_DECLARE(char *) switch_xml_tohtml(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header);
|
||||
#define switch_xml_toxml(xml, prn_header) switch_xml_toxml_ex(xml, prn_header, USE_UTF_8_ENCODING)
|
||||
#define switch_xml_toxml_nolock(xml, prn_header) switch_xml_toxml_nolock_ex(xml, prn_header, USE_UTF_8_ENCODING)
|
||||
#define switch_xml_tohtml(xml, prn_header) switch_xml_tohtml_ex(xml, prn_header, USE_UTF_8_ENCODING)
|
||||
|
||||
SWITCH_DECLARE(char *) switch_xml_toxml_ex(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding);
|
||||
SWITCH_DECLARE(char *) switch_xml_toxml_nolock_ex(switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding);
|
||||
SWITCH_DECLARE(char *) switch_xml_tohtml_ex(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding);
|
||||
|
||||
///\brief Converts an switch_xml structure back to xml using the buffer passed in the parameters.
|
||||
///\param xml the xml node
|
||||
@ -223,9 +231,12 @@ SWITCH_DECLARE(char *) switch_xml_tohtml(_In_ switch_xml_t xml, _In_ switch_bool
|
||||
///\param buflen size of buffer
|
||||
///\param offset offset to start at
|
||||
///\param prn_header add <?xml version..> header too
|
||||
///\param use_utf8_encoding encoding into ampersand entities for UTF-8 chars
|
||||
///\return the xml text string
|
||||
SWITCH_DECLARE(char *) switch_xml_toxml_buf(_In_ switch_xml_t xml, _In_z_ char *buf, _In_ switch_size_t buflen, _In_ switch_size_t offset,
|
||||
_In_ switch_bool_t prn_header);
|
||||
#define switch_xml_toxml_buf(xml, buf, buflen, offset, prn_header) switch_xml_toxml_buf(xml, buf, buflen, offset, prn_header, USE_UTF_8_ENCODING);
|
||||
SWITCH_DECLARE(char *) switch_xml_toxml_buf_ex(_In_ switch_xml_t xml, _In_z_ char *buf, _In_ switch_size_t buflen, _In_ switch_size_t offset,
|
||||
_In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding);
|
||||
|
||||
|
||||
///\brief returns a NULL terminated array of processing instructions for the given
|
||||
///\ target
|
||||
|
@ -3663,9 +3663,12 @@ with. If we fail a setup up, then we go directly to a teardown mode. */
|
||||
fct_ts__add_test( \
|
||||
fctkern_ptr__->ns.ts_curr, fctkern_ptr__->ns.curr_test \
|
||||
); \
|
||||
} else { \
|
||||
fct_test__del(fctkern_ptr__->ns.curr_test); \
|
||||
fctkern_ptr__->ns.curr_test = NULL; \
|
||||
} \
|
||||
} else { \
|
||||
switch_assert("invalid condition for fct_req!"); \
|
||||
switch_assert("invalid condition for fct_req!"); \
|
||||
_fct_req((_CNDTN_)); \
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2018, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2019, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@ -113,7 +113,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
|
||||
switch_core_set_globals();
|
||||
|
||||
if (!minimal) {
|
||||
status = switch_core_init_and_modload(0, SWITCH_TRUE, &err);
|
||||
status = switch_core_init_and_modload(SCF_USE_SQL, SWITCH_TRUE, &err);
|
||||
switch_sleep(1 * 1000000);
|
||||
switch_core_set_variable("sound_prefix", "." SWITCH_PATH_SEPARATOR);
|
||||
if (status != SWITCH_STATUS_SUCCESS && err) {
|
||||
@ -308,7 +308,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
|
||||
/**
|
||||
* Minimal FS core load
|
||||
*/
|
||||
#define FST_MINCORE_BEGIN() \
|
||||
#define FST_MINCORE_BEGIN(confdir) \
|
||||
FCT_BGN() \
|
||||
{ \
|
||||
int fst_core = 0; \
|
||||
@ -317,7 +317,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
|
||||
switch_memory_pool_t *fst_pool = NULL; \
|
||||
int fst_timer_started = 0; \
|
||||
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
|
||||
if (fst_init_core_and_modload(".", NULL, 1) == SWITCH_STATUS_SUCCESS) { /* minimal load */ \
|
||||
if (fst_init_core_and_modload(confdir, NULL, 1) == SWITCH_STATUS_SUCCESS) { /* minimal load */ \
|
||||
fst_core = 1; \
|
||||
} else { \
|
||||
fprintf(stderr, "Failed to load FS core\n"); \
|
||||
@ -699,7 +699,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
|
||||
fst_requires(fst_core > 1); \
|
||||
fst_requires_module("mod_dptools"); \
|
||||
switch_channel_set_variable(fst_channel, "detect_speech_result", ""); \
|
||||
fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mr") == SWITCH_STATUS_SUCCESS); \
|
||||
fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mrf") == SWITCH_STATUS_SUCCESS); \
|
||||
args = switch_core_session_sprintf(fst_session, "%s detect:%s %s", prompt_filename, recognizer, grammar); \
|
||||
fst_requires(switch_core_session_execute_application(fst_session, "play_and_detect_speech", args) == SWITCH_STATUS_SUCCESS); \
|
||||
fst_asr_result = switch_channel_get_variable(fst_channel, "detect_speech_result"); \
|
||||
@ -729,7 +729,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
|
||||
char *args = NULL; \
|
||||
fst_asr_result = NULL; \
|
||||
fst_requires(fst_core > 1); \
|
||||
fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mr") == SWITCH_STATUS_SUCCESS); \
|
||||
fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mrf") == SWITCH_STATUS_SUCCESS); \
|
||||
switch_status_t status = switch_ivr_play_and_detect_speech(fst_session, prompt_filename, recognizer, grammar, (char **)&fst_asr_result, 0, input_args); \
|
||||
fst_check(fst_asr_result != NULL); \
|
||||
}
|
||||
|
@ -1836,15 +1836,13 @@ static char get_media_type_char(enum AVMediaType type)
|
||||
}
|
||||
}
|
||||
|
||||
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev,
|
||||
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev, void **index,
|
||||
int encoder)
|
||||
{
|
||||
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,10,100))
|
||||
while ((prev = av_codec_next(prev))) {
|
||||
#else
|
||||
void *i;
|
||||
|
||||
while ((prev = av_codec_iterate(&i))) {
|
||||
while ((prev = av_codec_iterate(index))) {
|
||||
#endif
|
||||
if (prev->id == id &&
|
||||
(encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
|
||||
@ -1887,10 +1885,11 @@ static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs)
|
||||
static void print_codecs_for_id(switch_stream_handle_t *stream, enum AVCodecID id, int encoder)
|
||||
{
|
||||
const AVCodec *codec = NULL;
|
||||
void *index = 0;
|
||||
|
||||
stream->write_function(stream, " (%s: ", encoder ? "encoders" : "decoders");
|
||||
|
||||
while ((codec = next_codec_for_id(id, codec, encoder))) {
|
||||
while ((codec = next_codec_for_id(id, codec, &index, encoder))) {
|
||||
stream->write_function(stream, "%s ", codec->name);
|
||||
}
|
||||
|
||||
@ -1916,6 +1915,7 @@ void show_codecs(switch_stream_handle_t *stream)
|
||||
for (i = 0; i < nb_codecs; i++) {
|
||||
const AVCodecDescriptor *desc = codecs[i];
|
||||
const AVCodec *codec = NULL;
|
||||
void *index = 0;
|
||||
|
||||
stream->write_function(stream, " ");
|
||||
stream->write_function(stream, avcodec_find_decoder(desc->id) ? "D" : ".");
|
||||
@ -1930,14 +1930,14 @@ void show_codecs(switch_stream_handle_t *stream)
|
||||
|
||||
/* print decoders/encoders when there's more than one or their
|
||||
* names are different from codec name */
|
||||
while ((codec = next_codec_for_id(desc->id, codec, 0))) {
|
||||
while ((codec = next_codec_for_id(desc->id, codec, &index, 0))) {
|
||||
if (strcmp(codec->name, desc->name)) {
|
||||
print_codecs_for_id(stream ,desc->id, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
codec = NULL;
|
||||
while ((codec = next_codec_for_id(desc->id, codec, 1))) {
|
||||
codec = NULL; index = 0;
|
||||
while ((codec = next_codec_for_id(desc->id, codec, &index, 1))) {
|
||||
if (strcmp(codec->name, desc->name)) {
|
||||
print_codecs_for_id(stream, desc->id, 1);
|
||||
break;
|
||||
|
@ -1029,7 +1029,7 @@ void show_formats(switch_stream_handle_t *stream) {
|
||||
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58,9,100))
|
||||
while ((ofmt = av_oformat_next(ofmt))) {
|
||||
#else
|
||||
void *i;
|
||||
void *i = 0;
|
||||
|
||||
while ((ofmt = av_muxer_iterate(&i))) {
|
||||
#endif
|
||||
@ -1047,6 +1047,7 @@ void show_formats(switch_stream_handle_t *stream) {
|
||||
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58,9,100))
|
||||
while ((ifmt = av_iformat_next(ifmt))) {
|
||||
#else
|
||||
i = 0;
|
||||
while ((ifmt = av_demuxer_iterate(&i))) {
|
||||
#endif
|
||||
is_dev = is_device(ifmt->priv_class);
|
||||
|
@ -1403,6 +1403,7 @@ SWITCH_STANDARD_APP(avmd_start_app) {
|
||||
avmd_session_t *avmd_session = NULL;
|
||||
switch_core_media_flag_t flags = 0;
|
||||
const char *direction = "NO DIRECTION";
|
||||
uint8_t report = 0;
|
||||
|
||||
if (session == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "BUGGG. FreeSWITCH session is NULL! Please report to developers\n");
|
||||
@ -1446,6 +1447,8 @@ SWITCH_STANDARD_APP(avmd_start_app) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to set dynamic parameteres for avmd session. Unknown error\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
report = avmd_session->settings.report_status;
|
||||
|
||||
status = init_avmd_session_data(avmd_session, session, avmd_globals.mutex);
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
@ -1508,7 +1511,10 @@ SWITCH_STANDARD_APP(avmd_start_app) {
|
||||
status = switch_core_media_bug_add(session, "avmd", NULL, avmd_callback, avmd_session, 0, flags, &bug); /* Add a media bug that allows me to intercept the audio stream */
|
||||
if (status != SWITCH_STATUS_SUCCESS) { /* If adding a media bug fails exit */
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to add media bug!\n");
|
||||
goto end_unlock;
|
||||
|
||||
switch_mutex_unlock(avmd_session->mutex);
|
||||
avmd_session_close(avmd_session);
|
||||
goto end;
|
||||
}
|
||||
|
||||
switch_mutex_lock(avmd_globals.mutex);
|
||||
@ -1526,7 +1532,7 @@ end_unlock:
|
||||
|
||||
end:
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
if (avmd_session == NULL || avmd_session->settings.report_status == 1) {
|
||||
if (avmd_session == NULL || report) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Avmd on channel [%s] NOT started\n", switch_channel_get_name(channel));
|
||||
}
|
||||
}
|
||||
|
@ -4010,7 +4010,7 @@ SWITCH_STANDARD_API(cc_break_api_function)
|
||||
const char *uuid = NULL;
|
||||
switch_core_session_t *break_session = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
switch_bool_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
if (!zstr(cmd)) {
|
||||
mydata = strdup(cmd);
|
||||
@ -4208,12 +4208,19 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
|
||||
switch_json_api_interface_t *json_api_interface;
|
||||
switch_status_t status;
|
||||
|
||||
|
||||
/* create/register custom event message type */
|
||||
if (switch_event_reserve_subclass(CALLCENTER_EVENT) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", CALLCENTER_EVENT);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
/* Subscribe to presence request events */
|
||||
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY,
|
||||
cc_presence_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to subscribe for presence events!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
globals.pool = pool;
|
||||
|
||||
@ -4221,15 +4228,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
|
||||
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
|
||||
|
||||
if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_unbind(&globals.node);
|
||||
switch_event_free_subclass(CALLCENTER_EVENT);
|
||||
switch_core_hash_destroy(&globals.queue_hash);
|
||||
return status;
|
||||
}
|
||||
|
||||
if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY,
|
||||
cc_presence_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to subscribe for presence events!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
globals.running = 1;
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
@ -4242,7 +4246,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
|
||||
}
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "callcenter", "CallCenter", CC_DESC, callcenter_function, CC_USAGE, SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "callcenter_track", "CallCenter Track Call", "Track external mod_callcenter calls to avoid place new calls", callcenter_track, CC_USAGE, SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "callcenter_track", "CallCenter Track Call", "Track external mod_callcenter calls to avoid place new calls", callcenter_track, CC_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_API(api_interface, "callcenter_config", "Config of callcenter", cc_config_api_function, CC_CONFIG_API_SYNTAX);
|
||||
SWITCH_ADD_API(api_interface, "callcenter_break", "Stop watching an uuid and release agent", cc_break_api_function, "callcenter_break agent <uuid>");
|
||||
|
||||
|
@ -685,6 +685,12 @@ end:
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(pool_stats_function)
|
||||
{
|
||||
switch_core_pool_stats(stream);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(db_cache_function)
|
||||
{
|
||||
int argc;
|
||||
@ -7502,6 +7508,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
||||
SWITCH_ADD_API(commands_api_interface, "nat_map", "Manage NAT", nat_map_function, "[status|republish|reinit] | [add|del] <port> [tcp|udp] [static]");
|
||||
SWITCH_ADD_API(commands_api_interface, "originate", "Originate a call", originate_function, ORIGINATE_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "pause", "Pause media on a channel", pause_function, PAUSE_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "pool_stats", "Core pool memory usage", pool_stats_function, "Core pool memory usage.");
|
||||
SWITCH_ADD_API(commands_api_interface, "quote_shell_arg", "Quote/escape a string for use on shell command line", quote_shell_arg_function, "<data>");
|
||||
SWITCH_ADD_API(commands_api_interface, "regex", "Evaluate a regex", regex_function, "<data>|<pattern>[|<subst string>][n|b]");
|
||||
SWITCH_ADD_API(commands_api_interface, "reloadacl", "Reload XML", reload_acl_function, "");
|
||||
|
@ -651,6 +651,7 @@ void conference_event_adv_la(conference_obj_t *conference, conference_member_t *
|
||||
cJSON_AddItemToObject(msg, "eventChannel", cJSON_CreateString(event_channel));
|
||||
cJSON_AddItemToObject(msg, "eventType", cJSON_CreateString("channelPvtData"));
|
||||
|
||||
cJSON_AddStringToObject(data, "callID", switch_core_session_get_uuid(member->session));
|
||||
cJSON_AddItemToObject(data, "action", cJSON_CreateString(join ? "conference-liveArray-join" : "conference-liveArray-part"));
|
||||
cJSON_AddItemToObject(data, "laChannel", cJSON_CreateString(conference->la_event_channel));
|
||||
cJSON_AddItemToObject(data, "laName", cJSON_CreateString(conference->la_name));
|
||||
|
@ -1193,7 +1193,7 @@ void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *ob
|
||||
|
||||
member->last_score = member->score;
|
||||
|
||||
if (member->id == member->conference->floor_holder) {
|
||||
if ((switch_channel_test_flag(channel, CF_VIDEO) || member->avatar_png_img) && (member->id == member->conference->floor_holder)) {
|
||||
if (member->id != member->conference->video_floor_holder &&
|
||||
(member->floor_packets > member->conference->video_floor_packets || member->energy_level == 0)) {
|
||||
conference_video_set_floor_holder(member->conference, member, SWITCH_FALSE);
|
||||
|
@ -3866,7 +3866,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
switch_image_t *mute_img = omember->video_mute_img ? omember->video_mute_img : omember->pcanvas_img;
|
||||
|
||||
if (mute_img) {
|
||||
switch_image_t *tmp;
|
||||
switch_image_t *tmp = NULL;
|
||||
|
||||
switch_img_copy(mute_img, &tmp);
|
||||
switch_img_fit(&tmp, layer->screen_w, layer->screen_h, SWITCH_FIT_SIZE);
|
||||
|
@ -468,10 +468,10 @@ static switch_status_t load_config(switch_bool_t reload)
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
|
||||
if (switch_database_available(val)) {
|
||||
if (switch_database_available(val) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_set_string(globals.odbc_dsn, val);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DATABASE IS NOT AVAILABLE!\n");
|
||||
}
|
||||
} else if (!strcasecmp(var, "dbname") && !zstr(val)) {
|
||||
globals.dbname = switch_core_strdup(globals.pool, val);
|
||||
|
@ -128,6 +128,7 @@ static int load_config(int reloading)
|
||||
|
||||
if (!(lists = switch_xml_child(cfg, "lists"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find any lists!\n");
|
||||
switch_xml_free(xml);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -4392,10 +4392,10 @@ static switch_status_t read_config_file(switch_xml_t *xml, switch_xml_t *cfg) {
|
||||
if (!strcasecmp(var, "outbound-strategy") && !zstr(val)) {
|
||||
globals.default_strategy = parse_strategy(val);
|
||||
} else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
|
||||
if (switch_database_available(val)) {
|
||||
if (switch_database_available(val) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_set_string(globals.odbc_dsn, val);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DATABASE IS NOT AVAILABLE!\n");
|
||||
}
|
||||
} else if (!strcasecmp(var, "dbname") && !zstr(val)) {
|
||||
globals.dbname = switch_core_strdup(globals.pool, val);
|
||||
|
@ -115,10 +115,14 @@ switch_status_t mod_hiredis_do_config()
|
||||
goto err;
|
||||
}
|
||||
|
||||
switch_xml_free(xml);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
err:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Configuration failed\n");
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
|
@ -3004,7 +3004,8 @@ static switch_status_t file_open(switch_file_handle_t *handle, const char *path,
|
||||
handle->seekable = context->fh.seekable;
|
||||
handle->speed = context->fh.speed;
|
||||
handle->interval = context->fh.interval;
|
||||
handle->channels = context->fh.real_channels;
|
||||
handle->channels = context->fh.channels;
|
||||
handle->cur_channels = context->fh.real_channels;
|
||||
handle->flags |= SWITCH_FILE_NOMUX;
|
||||
|
||||
if (switch_test_flag((&context->fh), SWITCH_FILE_NATIVE)) {
|
||||
|
@ -273,7 +273,7 @@ static void parse_domain(const char *url, char *domain_buf, int domain_buf_len)
|
||||
if (!*start) {
|
||||
return;
|
||||
}
|
||||
strncpy(domain_buf, start, domain_buf_len);
|
||||
snprintf(domain_buf, domain_buf_len, "%s", start);
|
||||
end = strchr(domain_buf, '/');
|
||||
if (end) {
|
||||
*end = '\0';
|
||||
@ -985,7 +985,7 @@ static char *cached_url_filename_create(url_cache_t *cache, const char *url, cha
|
||||
/* filename is constructed from UUID and is stored in cache dir (first 2 characters of UUID) */
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
strncpy(uuid_dir, uuid_str, 2);
|
||||
snprintf(uuid_dir, sizeof(uuid_dir), "%.2s", uuid_str);
|
||||
dirname = switch_mprintf("%s%s%s", cache->location, SWITCH_PATH_SEPARATOR, uuid_dir);
|
||||
|
||||
/* create sub-directory if it doesn't exist */
|
||||
@ -1754,6 +1754,7 @@ static switch_status_t http_cache_file_open(switch_file_handle_t *handle, const
|
||||
handle->speed = context->fh.speed;
|
||||
handle->interval = context->fh.interval;
|
||||
handle->channels = context->fh.channels;
|
||||
handle->cur_channels = context->fh.real_channels;
|
||||
handle->flags |= SWITCH_FILE_NOMUX;
|
||||
handle->pre_buffer_datalen = 0;
|
||||
|
||||
|
@ -459,7 +459,7 @@ SWITCH_STANDARD_API(mod_signalwire_api_function)
|
||||
" /____/_/\\__, /_/ /_/\\__,_/_/ |__/|__/_/_/ \\___/\n"
|
||||
" /____/\n"
|
||||
"\n /=====================================================================\\\n"
|
||||
"| Connection Token: %s |\n"
|
||||
" Connection Token: %s\n"
|
||||
" \\=====================================================================/\n"
|
||||
" Go to https://signalwire.com to set up your Connector now!\n", globals.adoption_token);
|
||||
} else {
|
||||
|
@ -485,7 +485,7 @@ static void destroy_descriptor(void *ptr)
|
||||
{
|
||||
tone_descriptor_t *d = (tone_descriptor_t *) ptr;
|
||||
|
||||
super_tone_rx_free_descriptor(d->spandsp_tone_descriptor);
|
||||
tone_descriptor_destroy(d);
|
||||
}
|
||||
|
||||
switch_status_t load_configuration(switch_bool_t reload)
|
||||
|
@ -133,6 +133,7 @@ typedef struct tone_descriptor tone_descriptor_t;
|
||||
|
||||
|
||||
switch_status_t tone_descriptor_create(tone_descriptor_t **descriptor, const char *name, switch_memory_pool_t *memory_pool);
|
||||
void tone_descriptor_destroy(tone_descriptor_t *descriptor);
|
||||
int tone_descriptor_add_tone(tone_descriptor_t *descriptor, const char *name);
|
||||
switch_status_t tone_descriptor_add_tone_element(tone_descriptor_t *descriptor, int tone_id, int freq1, int freq2, int min, int max);
|
||||
|
||||
|
@ -637,6 +637,20 @@ switch_status_t tone_descriptor_create(tone_descriptor_t **descriptor, const cha
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the tone descriptor
|
||||
*
|
||||
* @param descriptor the descriptor to create
|
||||
* @return void
|
||||
*/
|
||||
void tone_descriptor_destroy(tone_descriptor_t *descriptor)
|
||||
{
|
||||
if (descriptor->spandsp_tone_descriptor) {
|
||||
super_tone_rx_free_descriptor(descriptor->spandsp_tone_descriptor);
|
||||
descriptor->spandsp_tone_descriptor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a tone to the tone descriptor
|
||||
*
|
||||
@ -711,6 +725,48 @@ static void tone_segment_callback(void *user_data, int f1, int f2, int duration)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the tone descriptor
|
||||
*
|
||||
* @param descriptor the descriptor to use
|
||||
* @param memory_pool the pool to use
|
||||
* @return pointer to a copy of descriptor
|
||||
*/
|
||||
static tone_descriptor_t *tone_descriptor_dup(tone_descriptor_t *descriptor, switch_memory_pool_t *pool)
|
||||
{
|
||||
tone_descriptor_t *desc = NULL;
|
||||
int t = 0, s = 0, tone_count = 0;
|
||||
|
||||
if (descriptor && pool) {
|
||||
if (tone_descriptor_create(&desc, descriptor->name, pool) != SWITCH_STATUS_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tone_count = descriptor->idx + 1;
|
||||
|
||||
for (t = 0; t < tone_count; t++) {
|
||||
int tone_id = tone_descriptor_add_tone(desc, descriptor->tone_keys[t]);
|
||||
if (-1 != tone_id) {
|
||||
int step = descriptor->spandsp_tone_descriptor->tone_segs[tone_id];
|
||||
for (s = 0; s < step; s++) {
|
||||
super_tone_rx_segment_t segment = descriptor->spandsp_tone_descriptor->tone_list[tone_id][s];
|
||||
int f1 = (segment.f1 == -1 ? 0 : descriptor->spandsp_tone_descriptor->pitches[segment.f1][0]);
|
||||
int f2 = (segment.f2 == -1 ? 0 : descriptor->spandsp_tone_descriptor->pitches[segment.f2][0]);
|
||||
int min = segment.min_duration / 8;
|
||||
int max = (segment.max_duration == 0x7FFFFFFF ? 0 : segment.max_duration / 8);
|
||||
tone_descriptor_add_tone_element(desc, tone_id, f1, f2, min, max);
|
||||
}
|
||||
} else {
|
||||
tone_descriptor_destroy(desc);
|
||||
desc = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the tone detector
|
||||
*
|
||||
@ -723,11 +779,8 @@ static void tone_segment_callback(void *user_data, int f1, int f2, int duration)
|
||||
static switch_status_t tone_detector_create(switch_core_session_t *session, tone_detector_t **detector, tone_descriptor_t *descriptor)
|
||||
{
|
||||
tone_detector_t *ldetector = switch_core_session_alloc(session, sizeof(tone_detector_t));
|
||||
tone_descriptor_t *desc = switch_core_session_alloc(session, sizeof(tone_descriptor_t));
|
||||
|
||||
memcpy(desc, descriptor, sizeof(tone_descriptor_t));
|
||||
|
||||
ldetector->descriptor = desc;
|
||||
ldetector->descriptor = tone_descriptor_dup(descriptor, switch_core_session_get_pool(session));
|
||||
ldetector->debug = spandsp_globals.tonedebug;
|
||||
ldetector->session = session;
|
||||
*detector = ldetector;
|
||||
@ -777,6 +830,10 @@ static void tone_detector_destroy(tone_detector_t *detector)
|
||||
super_tone_rx_free(detector->spandsp_detector);
|
||||
detector->spandsp_detector = NULL;
|
||||
}
|
||||
if (detector->descriptor) {
|
||||
tone_descriptor_destroy(detector->descriptor);
|
||||
detector->descriptor = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
include $(top_srcdir)/build/modmake.rulesam
|
||||
MODNAME=mod_test
|
||||
|
||||
noinst_LTLIBRARIES = libtestmod.la
|
||||
libtestmod_la_SOURCES = mod_test.c
|
||||
|
||||
mod_LTLIBRARIES = mod_test.la
|
||||
mod_test_la_SOURCES = mod_test.c
|
||||
mod_test_la_CFLAGS = $(AM_CFLAGS)
|
||||
mod_test_la_LIBADD = $(switch_builddir)/libfreeswitch.la
|
||||
mod_test_la_LDFLAGS = -avoid-version -module -no-undefined -shared
|
||||
mod_test_la_SOURCES =
|
||||
mod_test_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(SOFIALA) libtestmod.la
|
||||
mod_test_la_LDFLAGS = -avoid-version -module -no-undefined -shared
|
||||
|
||||
SUBDIRS=. test
|
||||
|
||||
|
@ -257,8 +257,6 @@ static switch_status_t test_asr_get_results(switch_asr_handle_t *ah, char **resu
|
||||
{
|
||||
test_asr_t *context = (test_asr_t *) ah->private_info;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_stream_handle_t result = { 0 };
|
||||
SWITCH_STANDARD_STREAM(result);
|
||||
|
||||
if (switch_test_flag(context, ASRFLAG_RETURNED_RESULT) || switch_test_flag(ah, SWITCH_ASR_FLAG_CLOSED)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -1,5 +1,6 @@
|
||||
include $(top_srcdir)/build/modmake.rulesam
|
||||
noinst_PROGRAMS = test_asr
|
||||
test_asr_CFLAGS = $(AM_CFLAGS) -I../
|
||||
test_asr_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) ../mod_test.la $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
|
||||
test_asr_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS)
|
||||
test_asr_LDADD = ../libtestmod.la
|
||||
TESTS = $(noinst_PROGRAMS)
|
||||
|
@ -70,7 +70,13 @@ typedef struct chromakey_child_context_s {
|
||||
} chromakey_child_context_t;
|
||||
|
||||
|
||||
|
||||
typedef struct video_replace_context_s {
|
||||
switch_image_t *rp_img;
|
||||
switch_file_handle_t vfh;
|
||||
switch_core_session_t *session;
|
||||
} video_replace_context_t;
|
||||
|
||||
|
||||
static void init_context(chromakey_context_t *context)
|
||||
{
|
||||
switch_color_set_rgb(&context->bgcolor, "#000000");
|
||||
@ -817,6 +823,296 @@ SWITCH_STANDARD_API(chromakey_api_function)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t video_replace_thread_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data, switch_abc_type_t type)
|
||||
{
|
||||
video_replace_context_t *context = (video_replace_context_t *)user_data;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_frame_t file_frame = { 0 };
|
||||
|
||||
if (!switch_channel_ready(channel)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (!frame->img) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (switch_test_flag(&context->vfh, SWITCH_FILE_OPEN)) {
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (type == SWITCH_ABC_TYPE_READ_VIDEO_PING || (context->vfh.params && switch_true(switch_event_get_header(context->vfh.params, "scale")))) {
|
||||
context->vfh.mm.scale_w = frame->img->d_w;
|
||||
context->vfh.mm.scale_h = frame->img->d_h;
|
||||
}
|
||||
|
||||
status = switch_core_file_read_video(&context->vfh, &file_frame, SVR_FLUSH);
|
||||
switch_core_file_command(&context->vfh, SCFC_FLUSH_AUDIO);
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
int close = 1;
|
||||
|
||||
if (context->vfh.params) {
|
||||
const char *loopstr = switch_event_get_header(context->vfh.params, "loop");
|
||||
if (switch_true(loopstr)) {
|
||||
uint32_t pos = 0;
|
||||
|
||||
if (switch_core_file_seek(&context->vfh, &pos, 0, SEEK_SET) == SWITCH_STATUS_SUCCESS) close = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (close) {
|
||||
switch_core_file_close(&context->vfh);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_frame.img) {
|
||||
switch_img_free(&(context->rp_img));
|
||||
context->rp_img = file_frame.img;
|
||||
}
|
||||
|
||||
if (context->rp_img) {
|
||||
if (context->rp_img->d_w != frame->img->d_w || context->rp_img->d_h != frame->img->d_h ) {
|
||||
frame->img = NULL;
|
||||
}
|
||||
|
||||
switch_img_copy(context->rp_img, &frame->img);
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_bool_t video_replace_bug_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
|
||||
{
|
||||
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
video_replace_context_t *context = (video_replace_context_t *)user_data;
|
||||
|
||||
switch (type) {
|
||||
case SWITCH_ABC_TYPE_INIT:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_CLOSE:
|
||||
{
|
||||
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
|
||||
switch_img_free(&context->rp_img);
|
||||
|
||||
if (switch_test_flag(&context->vfh, SWITCH_FILE_OPEN)) {
|
||||
switch_core_file_close(&context->vfh);
|
||||
memset(&context->vfh, 0, sizeof(context->vfh));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_READ_VIDEO_PING:
|
||||
case SWITCH_ABC_TYPE_WRITE_VIDEO_PING:
|
||||
{
|
||||
if (switch_test_flag(&context->vfh, SWITCH_FILE_OPEN)) {
|
||||
switch_frame_t *frame = switch_core_media_bug_get_video_ping_frame(bug);
|
||||
video_replace_thread_callback(context->session, frame, context, type);
|
||||
} else {
|
||||
switch_channel_set_private(channel, "_video_replace_bug_", NULL);
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(video_replace_start_function)
|
||||
{
|
||||
switch_media_bug_t *bug;
|
||||
switch_status_t status;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_media_bug_flag_t flags = 0;
|
||||
const char *function = "video_replace";
|
||||
video_replace_context_t *context;
|
||||
char *lbuf;
|
||||
int argc = 0;
|
||||
char *argv[2] = { 0 };
|
||||
char *direction = NULL;
|
||||
char *file = NULL;
|
||||
|
||||
if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_video_replace_bug_"))) {
|
||||
if (!zstr(data) && !strcasecmp(data, "stop")) {
|
||||
switch_channel_set_private(channel, "_video_replace_bug_", NULL);
|
||||
switch_core_media_bug_remove(session, &bug);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "alreday start!\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (data && (lbuf = switch_core_session_strdup(session, data))
|
||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
|
||||
|
||||
if (argc > 1) {
|
||||
direction = argv[0];
|
||||
file = argv[1];
|
||||
} else {
|
||||
direction = "write";
|
||||
file = lbuf;
|
||||
}
|
||||
|
||||
if (!strcasecmp(direction, "read")) {
|
||||
flags = SMBF_READ_VIDEO_PING;
|
||||
} else if (!strcasecmp(direction, "write")) {
|
||||
flags = SMBF_WRITE_VIDEO_PING;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "invalid replace direction!\n");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
switch_channel_wait_for_flag(channel, CF_VIDEO_READY, SWITCH_TRUE, 10000, NULL);
|
||||
|
||||
context = (video_replace_context_t *) switch_core_session_alloc(session, sizeof(*context));
|
||||
switch_assert(context != NULL);
|
||||
memset(context, 0, sizeof(*context));
|
||||
context->session = session;
|
||||
|
||||
switch_thread_rwlock_rdlock(MODULE_INTERFACE->rwlock);
|
||||
|
||||
if (switch_core_file_open(&context->vfh, file, 1, 8000,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT | SWITCH_FILE_FLAG_VIDEO,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening video file\n");
|
||||
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((status = switch_core_media_bug_add(session, function, NULL, video_replace_bug_callback, context, 0, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure!\n");
|
||||
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
|
||||
return;
|
||||
}
|
||||
|
||||
switch_channel_set_private(channel, "_video_replace_bug_", bug);
|
||||
}
|
||||
|
||||
/* API Interface Function */
|
||||
#define VIDEO_REPLACE_API_SYNTAX "<uuid> <stop|start> [read|write] <file>"
|
||||
SWITCH_STANDARD_API(video_replace_api_function)
|
||||
{
|
||||
switch_core_session_t *rsession = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
switch_media_bug_t *bug;
|
||||
switch_status_t status;
|
||||
video_replace_context_t *context;
|
||||
char *mycmd = NULL;
|
||||
int argc = 0;
|
||||
char *argv[4] = { 0 };
|
||||
char *uuid = NULL;
|
||||
char *action = NULL;
|
||||
char *file = NULL;
|
||||
char *direction = NULL;
|
||||
switch_media_bug_flag_t flags = 0;
|
||||
const char *function = "video_replace";
|
||||
|
||||
if (zstr(cmd)) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
if (!(mycmd = strdup(cmd))) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
uuid = argv[0];
|
||||
action = argv[1];
|
||||
|
||||
if (!(rsession = switch_core_session_locate(uuid))) {
|
||||
stream->write_function(stream, "-ERR Cannot locate session!\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
channel = switch_core_session_get_channel(rsession);
|
||||
|
||||
bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_video_replace_bug_");
|
||||
|
||||
if (!strcasecmp(action, "stop")) {
|
||||
if (bug) {
|
||||
switch_channel_set_private(channel, "_video_replace_bug_", NULL);
|
||||
switch_core_media_bug_remove(rsession, &bug);
|
||||
stream->write_function(stream, "+OK Success\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR not start\n");
|
||||
}
|
||||
|
||||
goto done;
|
||||
} else if (!strcasecmp(action, "start")) {
|
||||
if (argc == 3) {
|
||||
direction = "write";
|
||||
file = argv[2];
|
||||
} else {
|
||||
direction = argv[2];
|
||||
file = argv[3];
|
||||
}
|
||||
|
||||
if (zstr(direction) || zstr(file)) goto usage;
|
||||
|
||||
if (!strcasecmp(direction, "read")) {
|
||||
flags = SMBF_READ_VIDEO_PING;
|
||||
} else if (!strcasecmp(direction, "write")) {
|
||||
flags = SMBF_WRITE_VIDEO_PING;
|
||||
} else {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
if (bug) {
|
||||
stream->write_function(stream, "-ERR alreday start\n");
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
context = (video_replace_context_t *) switch_core_session_alloc(rsession, sizeof(*context));
|
||||
switch_assert(context != NULL);
|
||||
context->session = rsession;
|
||||
|
||||
switch_thread_rwlock_rdlock(MODULE_INTERFACE->rwlock);
|
||||
|
||||
if (switch_core_file_open(&context->vfh, file, 1, 8000,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT | SWITCH_FILE_FLAG_VIDEO,
|
||||
switch_core_session_get_pool(rsession)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening video file\n");
|
||||
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((status = switch_core_media_bug_add(rsession, function, NULL,
|
||||
video_replace_bug_callback, context, 0, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "-ERR Failure!\n");
|
||||
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
|
||||
goto done;
|
||||
} else {
|
||||
switch_channel_set_private(channel, "_video_replace_bug_", bug);
|
||||
stream->write_function(stream, "+OK Success\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
usage:
|
||||
stream->write_function(stream, "-USAGE: %s\n", VIDEO_REPLACE_API_SYNTAX);
|
||||
|
||||
done:
|
||||
if (rsession) {
|
||||
switch_core_session_rwunlock(rsession);
|
||||
}
|
||||
|
||||
switch_safe_free(mycmd);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_video_filter_shutdown)
|
||||
{
|
||||
@ -837,7 +1133,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_video_filter_load)
|
||||
|
||||
SWITCH_ADD_API(api_interface, "chromakey", "chromakey", chromakey_api_function, CHROMAKEY_API_SYNTAX);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "video_replace", "video_replace", "video replace bug",
|
||||
video_replace_start_function, "[read|write] <file> | stop", SAF_NONE);
|
||||
|
||||
SWITCH_ADD_API(api_interface, "uuid_video_replace", "video_replace", video_replace_api_function, VIDEO_REPLACE_API_SYNTAX);
|
||||
|
||||
switch_console_set_complete("add chromakey ::console::list_uuid ::[start:stop");
|
||||
switch_console_set_complete("add uuid_video_replace ::console::list_uuid start ::[read:write");
|
||||
switch_console_set_complete("add uuid_video_replace ::console::list_uuid stop");
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -5979,7 +5979,6 @@ SWITCH_STANDARD_API(vm_fsdb_msg_email_function)
|
||||
|
||||
if (switch_xml_locate_user_merged("id", id, domain, NULL, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "-ERR Can't locate user.\n");
|
||||
switch_xml_free(x_user);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -6106,6 +6105,10 @@ SWITCH_STANDARD_API(vm_fsdb_msg_email_function)
|
||||
done:
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
|
||||
if (x_user) {
|
||||
switch_xml_free(x_user);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -186,13 +186,17 @@ static switch_status_t tts_commandline_speech_read_tts(switch_speech_handle_t *s
|
||||
assert(info != NULL);
|
||||
|
||||
if (switch_core_file_read(info->fh, data, &my_datalen) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_core_file_close(info->fh);
|
||||
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
|
||||
switch_core_file_close(info->fh);
|
||||
}
|
||||
unlink(info->file);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
*datalen = my_datalen * 2;
|
||||
if (datalen == 0) {
|
||||
switch_core_file_close(info->fh);
|
||||
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
|
||||
switch_core_file_close(info->fh);
|
||||
}
|
||||
unlink(info->file);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
} else {
|
||||
@ -205,7 +209,7 @@ static void tts_commandline_speech_flush_tts(switch_speech_handle_t *sh)
|
||||
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
|
||||
assert(info != NULL);
|
||||
|
||||
if (info->fh != NULL && info->fh->file_interface != NULL) {
|
||||
if (info->fh != NULL && info->fh->file_interface != NULL && switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
|
||||
switch_core_file_close(info->fh);
|
||||
}
|
||||
if (switch_file_exists(info->file, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -1461,10 +1461,16 @@ static switch_status_t null_channel_on_consume_media(switch_core_session_t *sess
|
||||
static switch_status_t null_channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
|
||||
{
|
||||
null_private_t *tech_pvt = NULL;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *dtmf_str = switch_channel_get_variable(channel, "null_channel_dtmf_queued");
|
||||
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
if (!dtmf_str) dtmf_str = "";
|
||||
|
||||
switch_channel_set_variable_printf(channel, "null_channel_dtmf_queued", "%s%c", dtmf_str, dtmf->digit);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1545,6 +1551,29 @@ static switch_status_t null_channel_receive_message(switch_core_session_t *sessi
|
||||
case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
|
||||
switch_core_timer_sync(&tech_pvt->timer);
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_DEFLECT:
|
||||
if (msg->string_array_arg[0]) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "string_array_arg[0]: %s\n", (char *)msg->string_array_arg[0]);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "string_arg: %s\n", (char *)msg->string_arg);
|
||||
if (msg->string_arg) {
|
||||
if (!strncmp(msg->string_arg, "sip:refer-200", 13)) {
|
||||
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_BLIND_TRANSFER);
|
||||
switch_channel_set_variable(channel, "sip_refer_status_code", "202");
|
||||
switch_channel_set_variable(channel, "sip_refer_reply", "SIP/2.0 200 OK\r\n");
|
||||
} else if (!strncmp(msg->string_arg, "sip:refer-202", 13)) {
|
||||
switch_channel_set_variable(channel, "sip_refer_status_code", "202");
|
||||
// no notify received
|
||||
switch_yield(5000000);
|
||||
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
} else if (!strncmp(msg->string_arg, "sip:refer-403", 13)) {
|
||||
switch_channel_set_variable(channel, "sip_refer_status_code", "202");
|
||||
switch_channel_set_variable(channel, "sip_refer_reply", "SIP/2.0 403 Forbidden\r\n");
|
||||
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_BLIND_TRANSFER);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -360,7 +360,6 @@ switch_status_t sofia_on_destroy(switch_core_session_t *session)
|
||||
{
|
||||
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char *uuid;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA DESTROY\n", switch_channel_get_name(channel));
|
||||
|
||||
@ -376,13 +375,7 @@ switch_status_t sofia_on_destroy(switch_core_session_t *session)
|
||||
}
|
||||
|
||||
if (!zstr(tech_pvt->call_id)) {
|
||||
switch_mutex_lock(tech_pvt->profile->flag_mutex);
|
||||
if ((uuid = switch_core_hash_find(tech_pvt->profile->chat_hash, tech_pvt->call_id))) {
|
||||
free(uuid);
|
||||
uuid = NULL;
|
||||
switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->call_id);
|
||||
}
|
||||
switch_mutex_unlock(tech_pvt->profile->flag_mutex);
|
||||
switch_core_hash_delete_locked(tech_pvt->profile->chat_hash, tech_pvt->call_id, tech_pvt->profile->flag_mutex);
|
||||
}
|
||||
|
||||
|
||||
@ -461,7 +454,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
||||
switch_channel_get_name(channel), switch_channel_cause2str(cause));
|
||||
|
||||
if (tech_pvt->hash_key && !sofia_test_pflag(tech_pvt->profile, PFLAG_DESTROY)) {
|
||||
switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->hash_key);
|
||||
switch_core_hash_delete_locked(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt->profile->flag_mutex);
|
||||
}
|
||||
|
||||
if (session && tech_pvt->profile->pres_type) {
|
||||
@ -4782,6 +4775,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
goto error;
|
||||
}
|
||||
|
||||
profile = gateway_ptr->profile;
|
||||
|
||||
if (gateway_ptr->status != SOFIA_GATEWAY_UP) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Gateway \'%s\' is down!\n", gw);
|
||||
cause = SWITCH_CAUSE_GATEWAY_DOWN;
|
||||
@ -4822,8 +4817,6 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
goto error;
|
||||
}
|
||||
|
||||
profile = gateway_ptr->profile;
|
||||
|
||||
if (profile && sofia_test_pflag(profile, PFLAG_STANDBY)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "System Paused\n");
|
||||
cause = SWITCH_CAUSE_SYSTEM_SHUTDOWN;
|
||||
@ -5187,7 +5180,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
goto done;
|
||||
|
||||
error:
|
||||
if (gateway_ptr) {
|
||||
/* gateway pointer lock is really a readlock of the profile so we let the profile release below free that lock if we have a profile */
|
||||
if (gateway_ptr && !profile) {
|
||||
sofia_reg_release_gateway(gateway_ptr);
|
||||
}
|
||||
|
||||
@ -5391,6 +5385,9 @@ void general_event_handler(switch_event_t *event)
|
||||
|
||||
if (zstr(dst->contact)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid contact uri [%s]\n", switch_str_nil(dst->contact));
|
||||
sofia_glue_free_destination(dst);
|
||||
switch_safe_free(route_uri);
|
||||
sofia_glue_release_profile(profile);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5417,10 +5414,10 @@ void general_event_handler(switch_event_t *event)
|
||||
|
||||
switch_safe_free(route_uri);
|
||||
sofia_glue_free_destination(dst);
|
||||
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
|
||||
sofia_glue_release_profile(profile);
|
||||
|
||||
return;
|
||||
} else if (to_uri || from_uri) {
|
||||
if (!es) {
|
||||
@ -5472,10 +5469,10 @@ void general_event_handler(switch_event_t *event)
|
||||
|
||||
switch_safe_free(route_uri);
|
||||
sofia_glue_free_destination(dst);
|
||||
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
|
||||
sofia_glue_release_profile(profile);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5654,6 +5651,7 @@ void general_event_handler(switch_event_t *event)
|
||||
|
||||
if (!(list = sofia_reg_find_reg_url_multi(profile, user, host))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find registered user %s@%s\n", user, host);
|
||||
sofia_glue_release_profile(profile);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5783,10 +5781,12 @@ void general_event_handler(switch_event_t *event)
|
||||
nua_handle_unref(nh);
|
||||
}
|
||||
|
||||
sofia_glue_release_profile(profile);
|
||||
|
||||
done:
|
||||
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
|
||||
switch_safe_free(local_dup);
|
||||
|
||||
}
|
||||
|
@ -821,8 +821,13 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
|
||||
while ((call_info = call_info->ci_next) != NULL) {
|
||||
char *tmp = sip_header_as_string(nua_handle_home(nh), (void *) call_info);
|
||||
size_t tmp_len = strlen(tmp);
|
||||
hold = realloc(hold, cur_len + tmp_len + 2);
|
||||
switch_assert(hold);
|
||||
char *tmp_hold = realloc(hold, cur_len + tmp_len + 2);
|
||||
if (!tmp_hold) {
|
||||
/* Avoid leak if realloc failed */
|
||||
free(hold);
|
||||
}
|
||||
switch_assert(tmp_hold);
|
||||
hold = tmp_hold;
|
||||
strncpy(hold + cur_len, ",", 2);
|
||||
strncpy(hold + cur_len + 1, tmp, tmp_len +1);
|
||||
su_free(nua_handle_home(nh), tmp);
|
||||
@ -1451,6 +1456,9 @@ static void sofia_handle_sip_r_refer(nua_t *nua, sofia_profile_t *profile, nua_h
|
||||
{
|
||||
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
||||
switch_core_session_t *other_session;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
switch_channel_set_variable_printf(channel, "sip_refer_status_code", "%d", status);
|
||||
|
||||
if (status < 200) {
|
||||
return;
|
||||
@ -2430,7 +2438,7 @@ void sofia_event_callback(nua_event_t event,
|
||||
tech_pvt->nh = NULL;
|
||||
sofia_set_flag(tech_pvt, TFLAG_BYE);
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
switch_core_hash_insert(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session)));
|
||||
switch_core_hash_insert_auto_free(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session)));
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
nua_handle_destroy(nh);
|
||||
} else {
|
||||
@ -2519,10 +2527,11 @@ void sofia_event_callback(nua_event_t event,
|
||||
|
||||
|
||||
if (sip->sip_call_id && sip->sip_call_id->i_id) {
|
||||
char *uuid;
|
||||
char *uuid = NULL, *tmp;
|
||||
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
if ((uuid = (char *) switch_core_hash_find(profile->chat_hash, sip->sip_call_id->i_id))) {
|
||||
if ((tmp = (char *) switch_core_hash_find(profile->chat_hash, sip->sip_call_id->i_id))) {
|
||||
uuid = strdup(tmp);
|
||||
switch_core_hash_delete(profile->chat_hash, sip->sip_call_id->i_id);
|
||||
}
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
@ -5050,6 +5059,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ext-rtp-ip\n");
|
||||
switch_goto_status(SWITCH_STATUS_GENERR, done);
|
||||
}
|
||||
} else if (!strcasecmp(var, "rtp-ip")) {
|
||||
char *ip = mod_sofia_globals.guess_ip;
|
||||
@ -5144,6 +5154,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ext-sip-ip\n");
|
||||
switch_goto_status(SWITCH_STATUS_GENERR, done);
|
||||
}
|
||||
} else if (!strcasecmp(var, "local-network-acl")) {
|
||||
if (val && !strcasecmp(val, "none")) {
|
||||
@ -10125,6 +10136,7 @@ switch_status_t sofia_locate_user(char* user, switch_core_session_t *session, si
|
||||
for (un = sip->sip_unknown; un; un = un->un_next) {
|
||||
switch_event_add_header_string(v_event, SWITCH_STACK_BOTTOM, un->un_name, un->un_value);
|
||||
};
|
||||
switch_channel_event_set_data(switch_core_session_get_channel(session), v_event);
|
||||
}
|
||||
|
||||
result = switch_xml_locate_user_merged("id", username, domain, NULL, x_user, v_event);
|
||||
@ -10530,6 +10542,10 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
switch_channel_set_variable_printf(channel, "sip_invite_stamp", "%" SWITCH_TIME_T_FMT, sip_invite_time);
|
||||
|
||||
if (*acl_token) {
|
||||
if (x_user) {
|
||||
switch_xml_free(x_user);
|
||||
x_user = NULL;
|
||||
}
|
||||
switch_channel_set_variable(channel, "acl_token", acl_token);
|
||||
if (sofia_locate_user(acl_token, session, sip, &x_user) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Authenticating user %s\n", acl_token);
|
||||
@ -10537,6 +10553,9 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Error Authenticating user %s\n", acl_token);
|
||||
if (sofia_test_pflag(profile, PFLAG_AUTH_REQUIRE_USER)) {
|
||||
nua_respond(nh, SIP_480_TEMPORARILY_UNAVAILABLE, TAG_END());
|
||||
if (v_event) {
|
||||
switch_event_destroy(&v_event);
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@ -11321,7 +11340,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
switch_channel_set_variable(channel, "sip_geolocation_error", un->un_value);
|
||||
} else if (!strcasecmp(un->un_name, "userLocation")) {
|
||||
switch_channel_set_variable(channel, "sip_user_location", un->un_value);
|
||||
} else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2) || !strcasecmp(un->un_name, "User-to-User") || !strncasecmp(un->un_name, "On", 2)) {
|
||||
} else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2) || !strcasecmp(un->un_name, "User-to-User") || !strncasecmp(un->un_name, "On", 2) || !strncasecmp(un->un_name, "K-", 2)) {
|
||||
if (!zstr(un->un_value)) {
|
||||
char new_name[512] = "";
|
||||
int reps = 0;
|
||||
|
@ -852,7 +852,7 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char
|
||||
|
||||
stripped = sofia_glue_get_url_from_contact(stripped, 0);
|
||||
|
||||
/* remove our params so we don't make any whiny moronic device piss it's pants and forget who it is for a half-hour */
|
||||
/* remove our params so we don't make any whiny moronic device piss its pants and forget who it is for a half-hour */
|
||||
if ((p = (char *) switch_stristr(";fs_", stripped))) {
|
||||
*p = '\0';
|
||||
}
|
||||
@ -1097,7 +1097,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
|
||||
if (!caller_profile) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
|
||||
|
||||
@ -1126,7 +1126,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
|
||||
if ((status = switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Port Error!\n");
|
||||
return status;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!switch_channel_get_private(tech_pvt->channel, "t38_options") || zstr(tech_pvt->mparams.local_sdp_str)) {
|
||||
@ -1160,7 +1160,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
|
||||
if (zstr(tech_pvt->dest)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "URL Error!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
|
||||
if ((d_url = sofia_glue_get_url_from_contact(tech_pvt->dest, 1))) {
|
||||
@ -1265,7 +1265,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
|
||||
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_TLS) && sofia_glue_transport_has_tls(tech_pvt->transport)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "TLS not supported by profile\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
|
||||
if (zstr(tech_pvt->invite_contact)) {
|
||||
@ -1360,7 +1360,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
if (!strncasecmp(url_str, "tel:", 4)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
|
||||
SWITCH_LOG_ERROR, "URL Error! tel: uri's not supported at this time\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
if (!s) {
|
||||
s = url_str;
|
||||
@ -1386,7 +1386,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
invite_contact);
|
||||
|
||||
switch_safe_free(d_url);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
|
||||
if (tech_pvt->dest && (strstr(tech_pvt->dest, ";fs_nat") || strstr(tech_pvt->dest, ";received")
|
||||
@ -1705,12 +1705,19 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
SIPTAG_PAYLOAD_STR(mp ? mp : tech_pvt->mparams.local_sdp_str), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
|
||||
}
|
||||
|
||||
sofia_glue_free_destination(dst);
|
||||
switch_safe_free(extra_headers);
|
||||
switch_safe_free(mp);
|
||||
tech_pvt->redirected = NULL;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
end:
|
||||
|
||||
if (dst) {
|
||||
sofia_glue_free_destination(dst);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void sofia_glue_do_xfer_invite(switch_core_session_t *session)
|
||||
@ -3336,6 +3343,7 @@ char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua
|
||||
switch_zmalloc(route_encoded, route_encoded_len);
|
||||
switch_url_encode(route, route_encoded, route_encoded_len);
|
||||
contact_str = switch_mprintf("%s <%s;fs_path=%s>", display, full_contact_dup, route_encoded);
|
||||
free(route);
|
||||
free(full_contact_dup);
|
||||
free(route_encoded);
|
||||
}
|
||||
|
@ -1160,6 +1160,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
|
||||
|
||||
if (!mod_sofia_globals.profile_hash) {
|
||||
switch_console_free_matches(&matches);
|
||||
sofia_glue_release_profile(profile);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -1413,6 +1414,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
|
||||
|
||||
|
||||
if (zstr(call_id) && (dh.hits && presence_source && (!strcasecmp(presence_source, "register") || switch_stristr("register", status)))) {
|
||||
sofia_glue_release_profile(profile);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -5000,7 +5002,7 @@ void sofia_presence_handle_sip_i_message(int status,
|
||||
abort();
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT) && (tech_pvt = (private_object_t *) switch_core_hash_find(profile->chat_hash, hash_key))) {
|
||||
if (sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT) && (tech_pvt = (private_object_t *) switch_core_hash_find_locked(profile->chat_hash, hash_key, profile->flag_mutex))) {
|
||||
switch_core_session_queue_event(tech_pvt->session, &event);
|
||||
} else {
|
||||
switch_core_chat_send(proto, event);
|
||||
|
@ -2624,9 +2624,8 @@ void sofia_reg_handle_sip_r_challenge(int status,
|
||||
sip_auth_password = dup_pass;
|
||||
}
|
||||
}
|
||||
|
||||
switch_xml_free(x_user);
|
||||
}
|
||||
switch_xml_free(x_user);
|
||||
}
|
||||
|
||||
switch_event_destroy(&locate_params);
|
||||
@ -2929,7 +2928,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
|
||||
if (switch_xml_locate_user_merged("id", zstr(username) ? "nobody" : username, domain_name, ip, &user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't find user [%s@%s] from %s\n"
|
||||
"You must define a domain called '%s' in your directory and add a user with the id=\"%s\" attribute\n"
|
||||
"and you must configure your device to use the proper domain in it's authentication credentials.\n", username, domain_name,
|
||||
"and you must configure your device to use the proper domain in its authentication credentials.\n", username, domain_name,
|
||||
ip, domain_name, username);
|
||||
|
||||
ret = AUTH_FORBIDDEN;
|
||||
@ -2937,7 +2936,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
|
||||
} else {
|
||||
const char *type = switch_xml_attr(user, "type");
|
||||
if (type && !strcasecmp(type, "pointer")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cant register a pointer.\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't register a pointer.\n");
|
||||
ret = AUTH_FORBIDDEN;
|
||||
goto end;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <test/switch_test.h>
|
||||
#include "../mod_sofia.c"
|
||||
|
||||
FST_MINCORE_BEGIN()
|
||||
FST_MINCORE_BEGIN("./conf")
|
||||
|
||||
FST_SUITE_BEGIN(switch_hash)
|
||||
|
||||
|
@ -1922,7 +1922,7 @@ static void client_run(jsock_t *jsock)
|
||||
int rem = 0;
|
||||
int dur = 0, j = 0;
|
||||
|
||||
if (!(size = atoi(p))) {
|
||||
if ((size = atoi(p)) <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -134,6 +134,12 @@ typedef struct {
|
||||
char *queue;
|
||||
char *binding_key;
|
||||
|
||||
/* Queue properties */
|
||||
switch_bool_t passive;
|
||||
switch_bool_t durable;
|
||||
switch_bool_t exclusive;
|
||||
switch_bool_t auto_delete;
|
||||
|
||||
/* Note: The AMQP channel is not reentrant this MUTEX serializes sending events. */
|
||||
mod_amqp_connection_t *conn_root;
|
||||
mod_amqp_connection_t *conn_active;
|
||||
|
@ -121,6 +121,12 @@ switch_status_t mod_amqp_command_create(char *name, switch_xml_t cfg)
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Default queue properties, set to match formerly hardcoded values */
|
||||
profile->passive = SWITCH_FALSE;
|
||||
profile->durable = SWITCH_FALSE;
|
||||
profile->exclusive = SWITCH_FALSE;
|
||||
profile->auto_delete = SWITCH_TRUE;
|
||||
|
||||
if ((params = switch_xml_child(cfg, "params")) != NULL) {
|
||||
for (param = switch_xml_child(params, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
@ -147,6 +153,14 @@ switch_status_t mod_amqp_command_create(char *name, switch_xml_t cfg)
|
||||
queue = mod_amqp_expand_header(profile->pool, event, val);
|
||||
} else if (!strncmp(var, "binding_key", 11)) {
|
||||
binding_key = mod_amqp_expand_header(profile->pool, event, val);
|
||||
} else if (!strncmp(var, "queue-passive", 13)) {
|
||||
profile->passive = switch_true(val);
|
||||
} else if (!strncmp(var, "queue-durable", 13)) {
|
||||
profile->durable = switch_true(val);
|
||||
} else if (!strncmp(var, "queue-exclusive", 15)) {
|
||||
profile->exclusive = switch_true(val);
|
||||
} else if (!strncmp(var, "queue-auto-delete", 17)) {
|
||||
profile->auto_delete = switch_true(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -308,8 +322,10 @@ void * SWITCH_THREAD_FUNC mod_amqp_command_thread(switch_thread_t *thread, void
|
||||
recv_queue = amqp_queue_declare(profile->conn_active->state, // state
|
||||
1, // channel
|
||||
profile->queue ? amqp_cstring_bytes(profile->queue) : amqp_empty_bytes, // queue name
|
||||
0, 0, // passive, durable
|
||||
0, 1, // exclusive, auto-delete
|
||||
profile->passive,
|
||||
profile->durable,
|
||||
profile->exclusive,
|
||||
profile->auto_delete,
|
||||
amqp_empty_table); // args
|
||||
|
||||
if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring queue\n")) {
|
||||
|
@ -220,7 +220,7 @@ switch_status_t mod_amqp_connection_create(mod_amqp_connection_t **conn, switch_
|
||||
if (interval && interval > 0) {
|
||||
port = interval;
|
||||
}
|
||||
} else if (!strncmp(var, "heartbeat", 4)) {
|
||||
} else if (!strncmp(var, "heartbeat", 9)) {
|
||||
int interval = atoi(val);
|
||||
if (interval && interval > 0) {
|
||||
heartbeat = interval;
|
||||
|
@ -238,34 +238,7 @@ switch_status_t mod_amqp_logging_create(char *name, switch_xml_t cfg)
|
||||
}
|
||||
}
|
||||
profile->conn_active = NULL;
|
||||
|
||||
if ( mod_amqp_connection_open(profile->conn_root, &(profile->conn_active), profile->name, profile->custom_attr) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] was unable to connect to any connection\n", profile->name);
|
||||
goto err;
|
||||
}
|
||||
|
||||
#if AMQP_VERSION_MAJOR == 0 && AMQP_VERSION_MINOR >= 6
|
||||
amqp_exchange_declare(profile->conn_active->state, 1,
|
||||
amqp_cstring_bytes(profile->exchange),
|
||||
amqp_cstring_bytes(profile->exchange_type),
|
||||
0, /* passive */
|
||||
profile->exchange_durable,
|
||||
profile->exchange_auto_delete,
|
||||
0,
|
||||
amqp_empty_table);
|
||||
#else
|
||||
amqp_exchange_declare(profile->conn_active->state, 1,
|
||||
amqp_cstring_bytes(profile->exchange),
|
||||
amqp_cstring_bytes(profile->exchange_type),
|
||||
0, /* passive */
|
||||
profile->exchange_durable,
|
||||
amqp_empty_table);
|
||||
#endif
|
||||
|
||||
if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name);
|
||||
goto err;
|
||||
}
|
||||
/* We are not going to open the logging queue connection on create, but instead wait for the running thread to open it */
|
||||
|
||||
/* Create a bounded FIFO queue for sending messages */
|
||||
if (switch_queue_create(&(profile->send_queue), profile->send_queue_size, profile->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -325,33 +325,7 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg)
|
||||
}
|
||||
}
|
||||
profile->conn_active = NULL;
|
||||
|
||||
if ( mod_amqp_connection_open(profile->conn_root, &(profile->conn_active), profile->name, profile->custom_attr) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] was unable to connect to any connection\n", profile->name);
|
||||
goto err;
|
||||
}
|
||||
#if AMQP_VERSION_MAJOR == 0 && AMQP_VERSION_MINOR >= 6
|
||||
amqp_exchange_declare(profile->conn_active->state, 1,
|
||||
amqp_cstring_bytes(profile->exchange),
|
||||
amqp_cstring_bytes(profile->exchange_type),
|
||||
0, /* passive */
|
||||
profile->exchange_durable,
|
||||
profile->exchange_auto_delete,
|
||||
0,
|
||||
amqp_empty_table);
|
||||
#else
|
||||
amqp_exchange_declare(profile->conn_active->state, 1,
|
||||
amqp_cstring_bytes(profile->exchange),
|
||||
amqp_cstring_bytes(profile->exchange_type),
|
||||
0, /* passive */
|
||||
profile->exchange_durable,
|
||||
amqp_empty_table);
|
||||
#endif
|
||||
|
||||
if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange\n")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name);
|
||||
goto err;
|
||||
}
|
||||
/* We are not going to open the producer queue connection on create, but instead wait for the running thread to open it */
|
||||
|
||||
/* Create a bounded FIFO queue for sending messages */
|
||||
if (switch_queue_create(&(profile->send_queue), profile->send_queue_size, profile->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -324,7 +324,7 @@ static void event_handler(switch_event_t *event)
|
||||
&tmplen, (unsigned char *) MAGIC, (int) strlen((char *) MAGIC));
|
||||
outlen += tmplen;
|
||||
EVP_EncryptFinal(ctx, (unsigned char *) buf + SWITCH_UUID_FORMATTED_LENGTH + outlen, &tmplen);
|
||||
EVP_CIPHER_CTX_cleanup(ctx);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
#else
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
EVP_EncryptInit(&ctx, EVP_bf_cbc(), NULL, NULL);
|
||||
@ -577,7 +577,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_multicast_runtime)
|
||||
EVP_DecryptInit(ctx, NULL, (unsigned char *) globals.psk, (unsigned char *) uuid_str);
|
||||
EVP_DecryptUpdate(ctx, (unsigned char *) tmp, &outl, (unsigned char *) packet, (int) len);
|
||||
EVP_DecryptFinal(ctx, (unsigned char *) tmp + outl, &tmplen);
|
||||
EVP_CIPHER_CTX_cleanup(ctx);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
#else
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
EVP_DecryptInit(&ctx, EVP_bf_cbc(), NULL, NULL);
|
||||
|
@ -375,6 +375,9 @@ static void event_handler(switch_event_t *event)
|
||||
if (!uuid || (l->session && strcmp(uuid, switch_core_session_get_uuid(l->session)))) {
|
||||
send = 0;
|
||||
}
|
||||
if (!strcmp(switch_core_session_get_uuid(l->session), switch_event_get_header_nil(event, "Job-Owner-UUID"))) {
|
||||
send = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (send) {
|
||||
@ -1499,6 +1502,7 @@ struct api_command_struct {
|
||||
listener_t *listener;
|
||||
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
int bg;
|
||||
char bg_owner_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
int ack;
|
||||
int console_execute;
|
||||
switch_memory_pool_t *pool;
|
||||
@ -1557,6 +1561,7 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_BACKGROUND_JOB) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-UUID", acs->uuid_str);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Owner-UUID", acs->bg_owner_uuid_str);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Command", acs->api_cmd);
|
||||
if (acs->arg) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Job-Command-Arg", acs->arg);
|
||||
@ -2357,6 +2362,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(acs->uuid_str, &uuid);
|
||||
}
|
||||
switch_copy_string(acs->bg_owner_uuid_str, switch_core_session_get_uuid(listener->session), sizeof(acs->bg_owner_uuid_str));
|
||||
switch_snprintf(reply, reply_len, "~Reply-Text: +OK Job-UUID: %s\nJob-UUID: %s\n\n", acs->uuid_str, acs->uuid_str);
|
||||
switch_thread_create(&thread, thd_attr, api_exec, acs, acs->pool);
|
||||
sanity = 2000;
|
||||
@ -2631,11 +2637,18 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
|
||||
|
||||
if ((session = listener->session)) {
|
||||
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unable to lock session!\n");
|
||||
locked = 0;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (!listener->sock) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Listener socket is null!\n");
|
||||
switch_clear_flag_locked(listener, LFLAG_RUNNING);
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_socket_opt_set(listener->sock, SWITCH_SO_TCP_NODELAY, TRUE);
|
||||
switch_socket_opt_set(listener->sock, SWITCH_SO_NONBLOCK, TRUE);
|
||||
|
||||
@ -2928,8 +2941,10 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
|
||||
|
||||
while (!prefs.done) {
|
||||
rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_UNSPEC, prefs.port, 0, pool);
|
||||
if (rv)
|
||||
if (rv) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot get information about IP address %s\n", prefs.ip);
|
||||
goto fail;
|
||||
}
|
||||
rv = switch_socket_create(&listen_list.sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, pool);
|
||||
if (rv)
|
||||
goto sock_fail;
|
||||
|
@ -516,8 +516,9 @@ SWITCH_STANDARD_API(exec_api_cmd)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void add_cli_api(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface)
|
||||
void add_cli_api(switch_loadable_module_interface_t **module_interface)
|
||||
{
|
||||
switch_api_interface_t *api_interface = NULL;
|
||||
SWITCH_ADD_API(api_interface, "erlang", KAZOO_DESC, exec_api_cmd, KAZOO_SYNTAX);
|
||||
switch_console_set_complete("add erlang status");
|
||||
switch_console_set_complete("add erlang event_filter");
|
||||
|
@ -104,7 +104,8 @@ static void process_history_item(char* value, cJSON *json)
|
||||
switch_safe_free(item);
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(kz_json_history) {
|
||||
SWITCH_STANDARD_API(kz_json_history)
|
||||
{
|
||||
char *mycmd = NULL, *argv[MAX_HISTORY] = { 0 };
|
||||
int n, argc = 0;
|
||||
cJSON *json = cJSON_CreateObject();
|
||||
@ -145,7 +146,8 @@ SWITCH_STANDARD_API(kz_json_history) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(kz_first_of) {
|
||||
SWITCH_STANDARD_API(kz_first_of)
|
||||
{
|
||||
char delim = '|';
|
||||
char *mycmd = NULL, *argv[MAX_FIRST_OF] = { 0 };
|
||||
int n, argc = 0;
|
||||
@ -498,7 +500,20 @@ done:
|
||||
return status;
|
||||
}
|
||||
|
||||
void add_kz_commands(switch_loadable_module_interface_t **module_interface, switch_api_interface_t *api_interface) {
|
||||
SWITCH_STANDARD_API(kz_expand_api)
|
||||
{
|
||||
if (!zstr(cmd)) {
|
||||
char * val = kz_expand(cmd);
|
||||
stream->write_function(stream, "+OK %s", val);
|
||||
switch_safe_free(val);
|
||||
} else {
|
||||
stream->write_function(stream, "ERR invalid input");
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void add_kz_commands(switch_loadable_module_interface_t **module_interface) {
|
||||
switch_api_interface_t *api_interface = NULL;
|
||||
SWITCH_ADD_API(api_interface, "kz_uuid_setvar_multi", UUID_SET_DESC, uuid_setvar_multi_function, UUID_MULTISET_SYNTAX);
|
||||
SWITCH_ADD_API(api_interface, "kz_uuid_setvar_multi_encoded", UUID_SET_DESC, uuid_setvar_multi_encoded_function, UUID_MULTISET_SYNTAX);
|
||||
switch_console_set_complete("add kz_uuid_setvar_multi ::console::list_uuid");
|
||||
@ -510,5 +525,6 @@ void add_kz_commands(switch_loadable_module_interface_t **module_interface, swit
|
||||
SWITCH_ADD_API(api_interface, "kz_http_put", KZ_HTTP_PUT_DESC, kz_http_put, KZ_HTTP_PUT_SYNTAX);
|
||||
SWITCH_ADD_API(api_interface, "first-of", KZ_FIRST_OF_DESC, kz_first_of, KZ_FIRST_OF_SYNTAX);
|
||||
SWITCH_ADD_API(api_interface, "kz_json_history", KZ_FIRST_OF_DESC, kz_json_history, KZ_FIRST_OF_SYNTAX);
|
||||
SWITCH_ADD_API(api_interface, "kz_expand", KZ_FIRST_OF_DESC, kz_expand_api, KZ_FIRST_OF_SYNTAX);
|
||||
}
|
||||
|
||||
|
9
src/mod/event_handlers/mod_kazoo/kazoo_defs.h
Normal file
9
src/mod/event_handlers/mod_kazoo/kazoo_defs.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef KAZOO_DEFS_H_
|
||||
#define KAZOO_DEFS_H_
|
||||
|
||||
#define INTERACTION_VARIABLE "Call-Interaction-ID"
|
||||
|
||||
#define UNIX_EPOCH_IN_GREGORIAN 62167219200
|
||||
#define UNIX_EPOCH_IN_GREGORIAN_STR "62167219200"
|
||||
|
||||
#endif /* KAZOO_DEFS_H_ */
|
@ -891,7 +891,8 @@ SWITCH_STANDARD_APP(kz_att_xfer_function)
|
||||
}
|
||||
}
|
||||
|
||||
void add_kz_dptools(switch_loadable_module_interface_t **module_interface, switch_application_interface_t *app_interface) {
|
||||
void add_kz_dptools(switch_loadable_module_interface_t **module_interface) {
|
||||
switch_application_interface_t *app_interface = NULL;
|
||||
SWITCH_ADD_APP(app_interface, "kz_set", SET_SHORT_DESC, SET_LONG_DESC, set_function, SET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "kz_set_encoded", SET_SHORT_DESC, SET_LONG_DESC, set_encoded_function, SET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "kz_multiset", MULTISET_SHORT_DESC, MULTISET_LONG_DESC, multiset_function, MULTISET_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
|
@ -10,6 +10,8 @@
|
||||
#define VERSION "mod_kazoo v1.5.0-1 community"
|
||||
|
||||
#define KZ_MAX_SEPARATE_STRINGS 10
|
||||
#define HOSTNAME_MAX 1024
|
||||
#define NODENAME_MAX 1024
|
||||
|
||||
typedef enum {KAZOO_FETCH_PROFILE, KAZOO_EVENT_PROFILE} kazoo_profile_type;
|
||||
|
||||
@ -139,25 +141,7 @@ struct ei_xml_agent_s {
|
||||
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
KZ_TWEAK_INTERACTION_ID,
|
||||
KZ_TWEAK_EXPORT_VARS,
|
||||
KZ_TWEAK_SWITCH_URI,
|
||||
KZ_TWEAK_REPLACES_CALL_ID,
|
||||
KZ_TWEAK_LOOPBACK_VARS,
|
||||
KZ_TWEAK_CALLER_ID,
|
||||
KZ_TWEAK_TRANSFERS,
|
||||
KZ_TWEAK_BRIDGE,
|
||||
KZ_TWEAK_BRIDGE_REPLACES_ALEG,
|
||||
KZ_TWEAK_BRIDGE_REPLACES_CALL_ID,
|
||||
KZ_TWEAK_BRIDGE_VARIABLES,
|
||||
KZ_TWEAK_RESTORE_CALLER_ID_ON_BLIND_XFER,
|
||||
|
||||
/* No new flags below this line */
|
||||
KZ_TWEAK_MAX
|
||||
} kz_tweak_t;
|
||||
|
||||
struct globals_s {
|
||||
struct kz_globals_s {
|
||||
switch_memory_pool_t *pool;
|
||||
switch_atomic_t threads;
|
||||
switch_socket_t *acceptor;
|
||||
@ -180,6 +164,7 @@ struct globals_s {
|
||||
int ei_compat_rel;
|
||||
char *ip;
|
||||
char *hostname;
|
||||
struct hostent* hostname_ent;
|
||||
char *ei_cookie;
|
||||
char *ei_nodename;
|
||||
uint32_t flags;
|
||||
@ -209,8 +194,8 @@ struct globals_s {
|
||||
|
||||
|
||||
};
|
||||
typedef struct globals_s globals_t;
|
||||
extern globals_t kazoo_globals;
|
||||
typedef struct kz_globals_s kz_globals_t;
|
||||
extern kz_globals_t kazoo_globals;
|
||||
|
||||
/* kazoo_event_stream.c */
|
||||
ei_event_stream_t *find_event_stream(ei_event_stream_t *event_streams, const erlang_pid *from);
|
||||
@ -253,7 +238,7 @@ void fetch_config();
|
||||
|
||||
switch_status_t kazoo_load_config();
|
||||
void kazoo_destroy_config();
|
||||
|
||||
void kz_set_hostname();
|
||||
|
||||
#define _ei_x_encode_string(buf, string) { ei_x_encode_binary(buf, string, strlen(string)); }
|
||||
|
||||
|
@ -95,6 +95,19 @@ static int read_cookie_from_file(char *filename) {
|
||||
}
|
||||
}
|
||||
|
||||
void kz_set_hostname()
|
||||
{
|
||||
if (kazoo_globals.hostname == NULL) {
|
||||
char hostname[NODENAME_MAX];
|
||||
memcpy(hostname, switch_core_get_hostname(), NODENAME_MAX);
|
||||
kazoo_globals.hostname_ent = gethostbyname(hostname);
|
||||
if(kazoo_globals.hostname_ent != NULL) {
|
||||
kazoo_globals.hostname = switch_core_strdup(kazoo_globals.pool, kazoo_globals.hostname_ent->h_name);
|
||||
} else {
|
||||
kazoo_globals.hostname = switch_core_strdup(kazoo_globals.pool, hostname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_status_t kazoo_ei_config(switch_xml_t cfg) {
|
||||
switch_xml_t child, param;
|
||||
@ -211,11 +224,18 @@ switch_status_t kazoo_ei_config(switch_xml_t cfg) {
|
||||
}
|
||||
|
||||
if ((child = switch_xml_child(cfg, "tweaks"))) {
|
||||
char *default_tweaks = (char *) switch_xml_attr_soft(param, "default");
|
||||
if (default_tweaks) {
|
||||
int i, v = switch_true(default_tweaks) ? 1 : 0;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set tweak default : %s\n", default_tweaks);
|
||||
for (i = 0; i < KZ_TWEAK_MAX; i++) kazoo_globals.tweaks[i] = v;
|
||||
}
|
||||
for (param = switch_xml_child(child, "tweak"); param; param = param->next) {
|
||||
kz_tweak_t tweak = KZ_TWEAK_MAX;
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if(var && val && kz_name_tweak(var, &tweak) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set tweak %s : %s\n", var, val);
|
||||
if(switch_true(val)) {
|
||||
kz_set_tweak(tweak);
|
||||
} else {
|
||||
@ -230,6 +250,7 @@ switch_status_t kazoo_ei_config(switch_xml_t cfg) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if(var && val) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set core variable %s : %s\n", var, val);
|
||||
switch_core_set_variable(var, val);
|
||||
}
|
||||
}
|
||||
|
@ -332,8 +332,6 @@ switch_socket_t *create_socket_with_port(switch_memory_pool_t *pool, switch_port
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch_getnameinfo(&kazoo_globals.hostname, sa, 0);
|
||||
|
||||
if (kazoo_globals.nat_map && switch_nat_get_type()) {
|
||||
switch_nat_add_mapping(port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE);
|
||||
}
|
||||
@ -347,10 +345,9 @@ switch_socket_t *create_socket(switch_memory_pool_t *pool) {
|
||||
}
|
||||
|
||||
switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei_cnode_s *ei_cnode) {
|
||||
char hostname[EI_MAXHOSTNAMELEN + 1] = "";
|
||||
char hostname[EI_MAXHOSTNAMELEN + 1];
|
||||
char nodename[MAXNODELEN + 1];
|
||||
char cnodename[EI_MAXALIVELEN + 1];
|
||||
//EI_MAX_COOKIE_SIZE+1
|
||||
char *atsign;
|
||||
|
||||
/* copy the erlang interface nodename into something we can modify */
|
||||
@ -358,17 +355,13 @@ switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei
|
||||
|
||||
if ((atsign = strchr(cnodename, '@'))) {
|
||||
/* we got a qualified node name, don't guess the host/domain */
|
||||
snprintf(nodename, MAXNODELEN + 1, "%s", kazoo_globals.ei_nodename);
|
||||
snprintf(nodename, MAXNODELEN + 1, "%s", name);
|
||||
/* truncate the alivename at the @ */
|
||||
*atsign = '\0';
|
||||
*atsign++ = '\0';
|
||||
strncpy(hostname, atsign, EI_MAXHOSTNAMELEN);
|
||||
} else {
|
||||
if (zstr(kazoo_globals.hostname) || !strncasecmp(kazoo_globals.ip, "0.0.0.0", 7) || !strncasecmp(kazoo_globals.ip, "::", 2)) {
|
||||
memcpy(hostname, switch_core_get_hostname(), EI_MAXHOSTNAMELEN);
|
||||
} else {
|
||||
memcpy(hostname, kazoo_globals.hostname, EI_MAXHOSTNAMELEN);
|
||||
}
|
||||
|
||||
snprintf(nodename, MAXNODELEN + 1, "%s@%s", kazoo_globals.ei_nodename, hostname);
|
||||
strncpy(hostname, kazoo_globals.hostname, EI_MAXHOSTNAMELEN);
|
||||
snprintf(nodename, MAXNODELEN + 1, "%s@%s", name, hostname);
|
||||
}
|
||||
|
||||
if (kazoo_globals.ei_shortname) {
|
||||
@ -378,6 +371,8 @@ switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "creating nodename: %s\n", nodename);
|
||||
|
||||
/* init the ec stuff */
|
||||
if (ei_connect_xinit(ei_cnode, hostname, cnodename, nodename, (Erl_IpAddr) ip_addr, kazoo_globals.ei_cookie, 0) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to initialize the erlang interface connection structure\n");
|
||||
@ -866,7 +861,8 @@ static void fetch_config_filters(switch_memory_pool_t *pool)
|
||||
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, params))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open configuration file %s\n", cf);
|
||||
} else if ((child = switch_xml_child(cfg, "event-filter"))) {
|
||||
} else {
|
||||
if ((child = switch_xml_child(cfg, "event-filter"))) {
|
||||
switch_hash_t *filter;
|
||||
switch_hash_t *old_filter;
|
||||
|
||||
@ -881,9 +877,10 @@ static void fetch_config_filters(switch_memory_pool_t *pool)
|
||||
if (old_filter) {
|
||||
switch_core_hash_destroy(&old_filter);
|
||||
}
|
||||
}
|
||||
|
||||
kazoo_globals.config_fetched = 1;
|
||||
switch_xml_free(xml);
|
||||
kazoo_globals.config_fetched = 1;
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,34 +32,75 @@
|
||||
*/
|
||||
#include "mod_kazoo.h"
|
||||
|
||||
#define INTERACTION_VARIABLE "Call-Interaction-ID"
|
||||
|
||||
static const char *x_bridge_variables[] = {
|
||||
"Call-Control-Queue",
|
||||
"Call-Control-PID",
|
||||
"Call-Control-Node",
|
||||
INTERACTION_VARIABLE,
|
||||
"ecallmgr_Ecallmgr-Node",
|
||||
"sip_h_k-cid",
|
||||
"Switch-URI",
|
||||
"Switch-URL",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void kz_tweaks_variables_to_event(switch_core_session_t *session, switch_event_t *event)
|
||||
{
|
||||
int i;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
for(i = 0; x_bridge_variables[i] != NULL; i++) {
|
||||
const char *val = switch_channel_get_variable_dup(channel, x_bridge_variables[i], SWITCH_FALSE, -1);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, x_bridge_variables[i], val);
|
||||
}
|
||||
}
|
||||
|
||||
/* kazoo endpoint */
|
||||
switch_endpoint_interface_t *kz_endpoint_interface;
|
||||
static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *session,
|
||||
switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
|
||||
switch_call_cause_t *cancel_cause);
|
||||
switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
|
||||
switch_call_cause_t *cancel_cause);
|
||||
switch_io_routines_t kz_endpoint_io_routines = {
|
||||
/*.outgoing_channel */ kz_endpoint_outgoing_channel
|
||||
};
|
||||
|
||||
static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *session,
|
||||
switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
|
||||
switch_call_cause_t *cancel_cause)
|
||||
switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
|
||||
switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
switch_xml_t x_user = NULL, x_param, x_params;
|
||||
switch_xml_t x_user = NULL, x_param, x_params, x_callfwd;
|
||||
char *user = NULL, *domain = NULL, *dup_domain = NULL, *dialed_user = NULL;
|
||||
const char *dest = NULL;
|
||||
char *dest = NULL;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NONE;
|
||||
unsigned int timelimit = SWITCH_DEFAULT_TIMEOUT;
|
||||
switch_channel_t *new_channel = NULL;
|
||||
switch_event_t *params = NULL, *var_event_orig = var_event;
|
||||
char stupid[128] = "";
|
||||
const char *skip = NULL, *var = NULL;
|
||||
switch_core_session_t *a_session = NULL, *e_session = NULL;
|
||||
cJSON * ctx = NULL;
|
||||
const char *endpoint_dial = NULL;
|
||||
const char *callforward_dial = NULL;
|
||||
const char *failover_dial = NULL;
|
||||
char *b_failover_dial = NULL;
|
||||
const char *endpoint_separator = NULL;
|
||||
const char *varval = NULL;
|
||||
char *d_dest = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
switch_originate_flag_t myflags = SOF_NONE;
|
||||
char *cid_name_override = NULL;
|
||||
char *cid_num_override = NULL;
|
||||
switch_event_t *event = NULL;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
||||
if (zstr(outbound_profile->destination_number)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "NO DESTINATION NUMBER\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -84,6 +125,9 @@ static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *s
|
||||
switch_assert(params);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "as_channel", "true");
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "user_call");
|
||||
if (session) {
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));
|
||||
}
|
||||
|
||||
if (var_event) {
|
||||
switch_event_merge(params, var_event);
|
||||
@ -102,162 +146,308 @@ static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *s
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (var_event) {
|
||||
const char * str_ctx = switch_event_get_header(var_event, "kz-endpoint-runtime-context");
|
||||
if ( str_ctx ) {
|
||||
ctx = cJSON_Parse(str_ctx);
|
||||
if (ctx) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call context parsed => %s\n", str_ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((x_params = switch_xml_child(x_user, "variables"))) {
|
||||
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
|
||||
const char *pvar = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding variable to var_event => %s = %s\n", pvar, val);
|
||||
if (!var_event) {
|
||||
switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
|
||||
} else {
|
||||
switch_event_del_header(var_event, pvar);
|
||||
}
|
||||
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar, val);
|
||||
}
|
||||
}
|
||||
|
||||
if ((x_params = switch_xml_child(x_user, "params"))) {
|
||||
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
|
||||
const char *pvar = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
|
||||
if (!strcasecmp(pvar, "dial-string")) {
|
||||
dest = val;
|
||||
if (!strcasecmp(pvar, "endpoint-dial-string")) {
|
||||
endpoint_dial = val;
|
||||
} else if (!strcasecmp(pvar, "callforward-dial-string")) {
|
||||
callforward_dial = val;
|
||||
} else if (!strcasecmp(pvar, "endpoint-separator")) {
|
||||
endpoint_separator = val;
|
||||
} else if (!strncasecmp(pvar, "dial-var-", 9)) {
|
||||
if (!var_event) {
|
||||
switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
|
||||
} else {
|
||||
switch_event_del_header(var_event, pvar + 9);
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "adding variable to var_event => %s = %s\n", pvar + 9, val);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding dialog var to var_event => %s = %s\n", pvar + 9, val);
|
||||
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar + 9, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x_callfwd = switch_xml_child(x_user, "call-forward");
|
||||
if (x_callfwd) {
|
||||
switch_bool_t call_fwd_is_substitute = SWITCH_FALSE,
|
||||
call_fwd_is_failover = SWITCH_FALSE,
|
||||
call_fwd_direct_calls_only = SWITCH_FALSE,
|
||||
call_fwd_is_valid = SWITCH_TRUE;
|
||||
for (x_param = switch_xml_child(x_callfwd, "variable"); x_param; x_param = x_param->next) {
|
||||
const char *var = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "cfw %s => %s\n", var, val);
|
||||
if (!strcasecmp(var, "Is-Substitute")) {
|
||||
call_fwd_is_substitute = switch_true(val);
|
||||
} else if (!strcasecmp(var, "Is-Failover")) {
|
||||
call_fwd_is_failover = switch_true(val);
|
||||
} else if (!strcasecmp(var, "Direct-Calls-Only")) {
|
||||
call_fwd_direct_calls_only = switch_true(val);
|
||||
}
|
||||
}
|
||||
|
||||
if (call_fwd_direct_calls_only) {
|
||||
call_fwd_is_valid = SWITCH_FALSE;
|
||||
if (ctx ) {
|
||||
cJSON *json_flags = cJSON_GetObjectItem(ctx, "Flags");
|
||||
if (json_flags && json_flags->type == cJSON_Array) {
|
||||
cJSON *item;
|
||||
cJSON_ArrayForEach(item, json_flags) {
|
||||
if (!strcmp(item->valuestring, "direct_call")) {
|
||||
call_fwd_is_valid = SWITCH_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!call_fwd_is_valid) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call fwd requires direct_call and it was not found\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!call_fwd_is_valid) {
|
||||
dest = strdup(endpoint_dial);
|
||||
} else if (call_fwd_is_failover) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "setting failover => %s\n", callforward_dial);
|
||||
dest = strdup(endpoint_dial);
|
||||
failover_dial = callforward_dial;
|
||||
} else if (call_fwd_is_substitute) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "setting call fwd substitute => %s\n", callforward_dial);
|
||||
dest = strdup(callforward_dial);
|
||||
} else {
|
||||
dest = switch_mprintf("%s%s%s", endpoint_dial ? endpoint_dial : "", (endpoint_dial ? endpoint_separator ? endpoint_separator : "," : ""), callforward_dial);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "setting call fwd append => %s => %s\n", callforward_dial, dest);
|
||||
}
|
||||
} else {
|
||||
dest = strdup(endpoint_dial);
|
||||
}
|
||||
|
||||
dialed_user = (char *)switch_xml_attr(x_user, "id");
|
||||
|
||||
if (var_event) {
|
||||
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user);
|
||||
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
|
||||
if (!zstr(dest) && !strstr(dest, "presence_id=")) {
|
||||
switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, "presence_id", "%s@%s", dialed_user, domain);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dest) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No dial-string available, please check your user directory.\n");
|
||||
cause = SWITCH_CAUSE_MANDATORY_IE_MISSING;
|
||||
} else {
|
||||
const char *varval;
|
||||
char *d_dest = NULL;
|
||||
switch_channel_t *channel;
|
||||
switch_originate_flag_t myflags = SOF_NONE;
|
||||
char *cid_name_override = NULL;
|
||||
char *cid_num_override = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (var_event) {
|
||||
cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
|
||||
cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number");
|
||||
}
|
||||
if (var_event) {
|
||||
cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
|
||||
cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number");
|
||||
}
|
||||
|
||||
if (session) {
|
||||
switch_event_t *event = NULL;
|
||||
switch_event_create(&event, SWITCH_EVENT_GENERAL);
|
||||
channel = switch_core_session_get_channel(session);
|
||||
if ((varval = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))
|
||||
|| (var_event && (varval = switch_event_get_header(var_event, "leg_timeout")))) {
|
||||
timelimit = atoi(varval);
|
||||
}
|
||||
switch_channel_event_set_data(channel, event);
|
||||
if(var_event) {
|
||||
switch_event_merge(event, var_event);
|
||||
}
|
||||
|
||||
switch_channel_set_variable(channel, "dialed_user", dialed_user);
|
||||
switch_channel_set_variable(channel, "dialed_domain", domain);
|
||||
|
||||
d_dest = switch_event_expand_headers(event, dest);
|
||||
|
||||
switch_event_destroy(&event);
|
||||
|
||||
} else {
|
||||
switch_event_t *event = NULL;
|
||||
|
||||
if (var_event) {
|
||||
switch_event_dup(&event, var_event);
|
||||
switch_event_del_header(event, "dialed_user");
|
||||
switch_event_del_header(event, "dialed_domain");
|
||||
if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
|
||||
(varval = switch_event_get_header(var_event, "leg_timeout"))) {
|
||||
timelimit = atoi(varval);
|
||||
}
|
||||
} else {
|
||||
switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
switch_assert(event);
|
||||
}
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
|
||||
d_dest = switch_event_expand_headers(event, dest);
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
|
||||
if ((flags & SOF_NO_LIMITS)) {
|
||||
myflags |= SOF_NO_LIMITS;
|
||||
}
|
||||
|
||||
if ((flags & SOF_FORKED_DIAL)) {
|
||||
myflags |= SOF_NOBLOCK;
|
||||
}
|
||||
|
||||
switch_snprintf(stupid, sizeof(stupid), "kz/%s", dialed_user);
|
||||
if (switch_stristr(stupid, d_dest)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n",
|
||||
stupid);
|
||||
cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
|
||||
} else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL,
|
||||
cid_name_override, cid_num_override, outbound_profile, var_event, myflags,
|
||||
cancel_cause, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
const char *context;
|
||||
switch_caller_profile_t *cp;
|
||||
|
||||
if (var_event) {
|
||||
switch_event_del_header(var_event, "origination_uuid");
|
||||
}
|
||||
|
||||
new_channel = switch_core_session_get_channel(*new_session);
|
||||
|
||||
if ((context = switch_channel_get_variable(new_channel, "user_context"))) {
|
||||
if ((cp = switch_channel_get_caller_profile(new_channel))) {
|
||||
cp->context = switch_core_strdup(cp->pool, context);
|
||||
}
|
||||
}
|
||||
|
||||
if ((x_params = switch_xml_child(x_user, "variables"))) {
|
||||
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
|
||||
const char *pvar = switch_xml_attr(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
switch_channel_set_variable(new_channel, pvar, val);
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "CHECKING CALLER-ID\n");
|
||||
if ((x_params = switch_xml_child(x_user, "profile-variables"))) {
|
||||
switch_caller_profile_t *cp = NULL;
|
||||
const char* val = NULL;
|
||||
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
|
||||
const char *pvar = switch_xml_attr(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "setting profile var %s = %s\n", pvar, val);
|
||||
switch_channel_set_profile_var(new_channel, pvar, val);
|
||||
}
|
||||
cp = switch_channel_get_caller_profile(new_channel);
|
||||
if((val=switch_caller_get_field_by_name(cp, "Endpoint-Caller-ID-Name"))) {
|
||||
cp->callee_id_name = val;
|
||||
cp->orig_caller_id_name = val;
|
||||
}
|
||||
if((val=switch_caller_get_field_by_name(cp, "Endpoint-Caller-ID-Number"))) {
|
||||
cp->callee_id_number = val;
|
||||
cp->orig_caller_id_number = val;
|
||||
}
|
||||
}
|
||||
switch_core_session_rwunlock(*new_session);
|
||||
}
|
||||
|
||||
if (d_dest != dest) {
|
||||
switch_safe_free(d_dest);
|
||||
if(session) {
|
||||
a_session = session;
|
||||
} else if(var_event) {
|
||||
const char* uuid_e_session = switch_event_get_header(var_event, "ent_originate_aleg_uuid");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHECKING ORIGINATE-UUID : %s\n", uuid_e_session);
|
||||
if (uuid_e_session && (e_session = switch_core_session_force_locate(uuid_e_session)) != NULL) {
|
||||
a_session = e_session;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FOUND ORIGINATE-UUID : %s\n", uuid_e_session);
|
||||
}
|
||||
}
|
||||
|
||||
if (a_session) {
|
||||
switch_event_create(&event, SWITCH_EVENT_GENERAL);
|
||||
channel = switch_core_session_get_channel(a_session);
|
||||
if ((varval = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))
|
||||
|| (var_event && (varval = switch_event_get_header(var_event, "leg_timeout")))) {
|
||||
timelimit = atoi(varval);
|
||||
}
|
||||
switch_channel_event_set_data(channel, event);
|
||||
|
||||
switch_channel_set_variable(channel, "dialed_user", dialed_user);
|
||||
switch_channel_set_variable(channel, "dialed_domain", domain);
|
||||
|
||||
} else {
|
||||
if (var_event) {
|
||||
switch_event_dup(&event, var_event);
|
||||
switch_event_del_header(event, "dialed_user");
|
||||
switch_event_del_header(event, "dialed_domain");
|
||||
if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
|
||||
(varval = switch_event_get_header(var_event, "leg_timeout"))) {
|
||||
timelimit = atoi(varval);
|
||||
}
|
||||
} else {
|
||||
switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
switch_assert(event);
|
||||
}
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
|
||||
}
|
||||
|
||||
if ((x_params = switch_xml_child(x_user, "profile-variables"))) {
|
||||
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
|
||||
const char *pvar = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding profile variable to event => %s = %s\n", pvar, val);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar, val);
|
||||
}
|
||||
}
|
||||
|
||||
if ((x_params = switch_xml_child(x_user, "variables"))) {
|
||||
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
|
||||
const char *pvar = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding variable to event => %s = %s\n", pvar, val);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar, val);
|
||||
}
|
||||
}
|
||||
|
||||
if ((x_params = switch_xml_child(x_user, "params"))) {
|
||||
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
|
||||
const char *pvar = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
|
||||
if (!strncasecmp(pvar, "dial-var-", 9)) {
|
||||
switch_event_del_header(event, pvar + 9);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "adding dialog var to event => %s = %s\n", pvar + 9, val);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pvar + 9, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add runtime vars to event for expand
|
||||
if (ctx) {
|
||||
kz_expand_json_to_event(ctx, event, "kz_ctx");
|
||||
}
|
||||
|
||||
d_dest = kz_event_expand_headers(event, dest);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "dialing %s => %s\n", dest, d_dest);
|
||||
|
||||
if(failover_dial) {
|
||||
b_failover_dial = kz_event_expand_headers(event, failover_dial);
|
||||
}
|
||||
|
||||
if (var_event) {
|
||||
kz_expand_headers(event, var_event);
|
||||
}
|
||||
|
||||
switch_event_destroy(&event);
|
||||
|
||||
|
||||
if ((flags & SOF_NO_LIMITS)) {
|
||||
myflags |= SOF_NO_LIMITS;
|
||||
}
|
||||
|
||||
if ((flags & SOF_FORKED_DIAL)) {
|
||||
myflags |= SOF_NOBLOCK;
|
||||
}
|
||||
|
||||
if ( a_session ) {
|
||||
if(var_event) {
|
||||
kz_tweaks_variables_to_event(a_session, var_event);
|
||||
}
|
||||
}
|
||||
|
||||
if(e_session) {
|
||||
switch_core_session_rwunlock(e_session);
|
||||
}
|
||||
|
||||
switch_snprintf(stupid, sizeof(stupid), "kz/%s", dialed_user);
|
||||
if (switch_stristr(stupid, d_dest)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", stupid);
|
||||
cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
|
||||
goto done;
|
||||
}
|
||||
|
||||
status = switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL,
|
||||
cid_name_override, cid_num_override, outbound_profile, var_event, myflags,
|
||||
cancel_cause, NULL);
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS && b_failover_dial) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "trying failover => %s\n", failover_dial);
|
||||
status = switch_ivr_originate(session, new_session, &cause, b_failover_dial, timelimit, NULL,
|
||||
cid_name_override, cid_num_override, outbound_profile, var_event, myflags,
|
||||
cancel_cause, NULL);
|
||||
}
|
||||
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
const char *context;
|
||||
switch_caller_profile_t *cp;
|
||||
|
||||
if (var_event) {
|
||||
switch_event_del_header(var_event, "origination_uuid");
|
||||
}
|
||||
|
||||
new_channel = switch_core_session_get_channel(*new_session);
|
||||
|
||||
if ((context = switch_channel_get_variable(new_channel, "user_context"))) {
|
||||
if ((cp = switch_channel_get_caller_profile(new_channel))) {
|
||||
cp->context = switch_core_strdup(cp->pool, context);
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "CHECKING CALLER-ID\n");
|
||||
if ((x_params = switch_xml_child(x_user, "profile-variables"))) {
|
||||
switch_caller_profile_t *cp = NULL;
|
||||
const char* val = NULL;
|
||||
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
|
||||
const char *pvar = switch_xml_attr(x_param, "name");
|
||||
const char *val = switch_xml_attr(x_param, "value");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG1, "setting profile var %s = %s\n", pvar, val);
|
||||
switch_channel_set_profile_var(new_channel, pvar, val);
|
||||
}
|
||||
cp = switch_channel_get_caller_profile(new_channel);
|
||||
if((val=switch_caller_get_field_by_name(cp, "Endpoint-Caller-ID-Name"))) {
|
||||
cp->callee_id_name = val;
|
||||
cp->orig_caller_id_name = val;
|
||||
}
|
||||
if((val=switch_caller_get_field_by_name(cp, "Endpoint-Caller-ID-Number"))) {
|
||||
cp->callee_id_number = val;
|
||||
cp->orig_caller_id_number = val;
|
||||
}
|
||||
}
|
||||
switch_core_session_rwunlock(*new_session);
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
if (d_dest && d_dest != dest) {
|
||||
switch_safe_free(d_dest);
|
||||
}
|
||||
|
||||
if(b_failover_dial && b_failover_dial != failover_dial) {
|
||||
switch_safe_free(b_failover_dial);
|
||||
}
|
||||
|
||||
switch_safe_free(dest);
|
||||
|
||||
if (ctx) {
|
||||
cJSON_Delete(ctx);
|
||||
}
|
||||
|
||||
if (x_user) {
|
||||
switch_xml_free(x_user);
|
||||
}
|
||||
@ -272,7 +462,6 @@ static switch_call_cause_t kz_endpoint_outgoing_channel(switch_core_session_t *s
|
||||
|
||||
switch_safe_free(user);
|
||||
switch_safe_free(dup_domain);
|
||||
|
||||
return cause;
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,9 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
|
||||
expanded = kz_event_expand_headers(src, field->value);
|
||||
if(expanded != NULL && !zstr(expanded)) {
|
||||
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, expanded);
|
||||
free(expanded);
|
||||
if(expanded != field->value) {
|
||||
free(expanded);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -325,6 +327,21 @@ static switch_status_t kazoo_event_add_fields_to_json(kazoo_logging_ptr logging,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#define EVENT_TIMESTAMP_FIELD "Event-Date-Timestamp"
|
||||
#define JSON_TIMESTAMP_FIELD "Event-Timestamp"
|
||||
|
||||
static switch_status_t kazoo_event_add_timestamp(switch_event_t* evt, cJSON* JObj)
|
||||
{
|
||||
switch_event_header_t *header;
|
||||
cJSON *item = NULL;
|
||||
if((header = switch_event_get_header_ptr(evt, EVENT_TIMESTAMP_FIELD)) != NULL) {
|
||||
if ((item = kazoo_event_json_value(JSON_NUMBER, header->value)) != NULL) {
|
||||
kazoo_cJSON_AddItemToObject(JObj, JSON_TIMESTAMP_FIELD, item);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
return SWITCH_STATUS_NOTFOUND;
|
||||
}
|
||||
|
||||
kazoo_message_ptr kazoo_message_create_event(switch_event_t* evt, kazoo_event_ptr event, kazoo_event_profile_ptr profile)
|
||||
{
|
||||
@ -366,6 +383,8 @@ kazoo_message_ptr kazoo_message_create_event(switch_event_t* evt, kazoo_event_pt
|
||||
|
||||
kazoo_event_init_json(profile->fields, event ? event->fields : NULL, evt, &JObj);
|
||||
|
||||
kazoo_event_add_timestamp(evt, JObj);
|
||||
|
||||
if(profile->fields)
|
||||
kazoo_event_add_fields_to_json(&logging, JObj, evt, profile->fields->head);
|
||||
|
||||
@ -402,6 +421,8 @@ kazoo_message_ptr kazoo_message_create_fetch(switch_event_t* evt, kazoo_fetch_pr
|
||||
|
||||
kazoo_event_init_json(profile->fields, NULL, evt, &JObj);
|
||||
|
||||
kazoo_event_add_timestamp(evt, JObj);
|
||||
|
||||
if(profile->fields)
|
||||
kazoo_event_add_fields_to_json(&logging, JObj, evt, profile->fields->head);
|
||||
|
||||
|
@ -30,9 +30,6 @@
|
||||
*/
|
||||
#include "mod_kazoo.h"
|
||||
|
||||
#define INTERACTION_VARIABLE "Call-Interaction-ID"
|
||||
#define BRIDGE_INTERCEPT_VARIABLE "Bridge-Intercepted"
|
||||
|
||||
static char *TWEAK_NAMES[] = {
|
||||
"interaction-id",
|
||||
"export-vars",
|
||||
@ -69,7 +66,6 @@ static switch_status_t kz_tweaks_signal_bridge_on_hangup(switch_core_session_t *
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak signal bridge on hangup: %s , %s\n", switch_core_session_get_uuid(session), peer_uuid);
|
||||
|
||||
|
||||
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
|
||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
|
||||
@ -106,7 +102,6 @@ static void kz_tweaks_handle_bridge_variables(switch_event_t *event)
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: variables : %s , %s\n", a_leg, b_leg);
|
||||
|
||||
|
||||
if (a_leg && (a_session = switch_core_session_force_locate(a_leg)) != NULL) {
|
||||
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
|
||||
if(switch_channel_get_variable_dup(a_channel, bridge_variables[0], SWITCH_FALSE, -1) == NULL) {
|
||||
@ -137,56 +132,91 @@ static void kz_tweaks_handle_bridge_variables(switch_event_t *event)
|
||||
|
||||
}
|
||||
|
||||
static void kz_tweaks_handle_bridge_intercepted(switch_event_t *event)
|
||||
static void kz_tweaks_handle_bridge_replaces_aleg(switch_event_t *event)
|
||||
{
|
||||
switch_event_t *my_event;
|
||||
switch_core_session_t *a_session = NULL;
|
||||
switch_core_session_t *b_session = NULL;
|
||||
|
||||
const char *uuid = switch_event_get_header(event, "Unique-ID");
|
||||
const char *a_leg = switch_event_get_header(event, "Bridge-A-Unique-ID");
|
||||
const char *b_leg = switch_event_get_header(event, "Bridge-B-Unique-ID");
|
||||
const char *bridge_intercepted = NULL;
|
||||
const char *replaced_call_id = switch_event_get_header(event, "variable_sip_replaces_call_id");
|
||||
const char *a_leg_call_id = switch_event_get_header(event, "variable_sip_replaces_a-leg");
|
||||
const char *peer_uuid = switch_event_get_header(event, "Unique-ID");
|
||||
int processed = 0;
|
||||
|
||||
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_ALEG)) return;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: intercepted : %s , %s, %s\n", uuid, a_leg, b_leg);
|
||||
|
||||
if(a_leg_call_id && replaced_call_id) {
|
||||
const char *call_id = switch_event_get_header(event, "Bridge-B-Unique-ID");
|
||||
switch_core_session_t *session = NULL;
|
||||
if ((session = switch_core_session_locate(peer_uuid)) != NULL) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
processed = switch_true(switch_channel_get_variable_dup(channel, "Bridge-Event-Processed", SWITCH_FALSE, -1));
|
||||
switch_channel_set_variable(channel, "Bridge-Event-Processed", "true");
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
|
||||
if ((a_session = switch_core_session_locate(a_leg)) != NULL) {
|
||||
switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
|
||||
bridge_intercepted = switch_channel_get_variable_dup(a_channel, BRIDGE_INTERCEPT_VARIABLE, SWITCH_TRUE, -1);
|
||||
switch_channel_set_variable(a_channel, BRIDGE_INTERCEPT_VARIABLE, NULL);
|
||||
if (bridge_intercepted && switch_true(bridge_intercepted)) {
|
||||
switch_channel_set_variable(a_channel, "Bridge-B-Unique-ID", b_leg);
|
||||
switch_channel_add_state_handler(a_channel, &kz_tweaks_signal_bridge_state_handlers);
|
||||
|
||||
if ((b_session = switch_core_session_locate(b_leg)) != NULL) {
|
||||
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating channel_bridge event A - %s , B - %s\n", switch_core_session_get_uuid(b_session), uuid);
|
||||
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(b_session));
|
||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", uuid);
|
||||
switch_channel_event_set_data(b_channel, my_event);
|
||||
switch_event_fire(&my_event);
|
||||
if(processed) {
|
||||
if(call_id) {
|
||||
if((session = switch_core_session_locate(call_id)) != NULL) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_set_variable(channel, "Bridge-Event-Processed", "true");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "creating channel_bridge event A - %s , B - %s\n", switch_core_session_get_uuid(session), peer_uuid);
|
||||
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
|
||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
|
||||
switch_channel_event_set_data(channel, my_event);
|
||||
switch_event_fire(&my_event);
|
||||
}
|
||||
switch_channel_set_variable(channel, "Bridge-B-Unique-ID", peer_uuid);
|
||||
switch_channel_add_state_handler(channel, &kz_tweaks_signal_bridge_state_handlers);
|
||||
switch_core_session_rwunlock(session);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "invalid session : %s\n", call_id);
|
||||
DUMP_EVENT(event);
|
||||
}
|
||||
switch_core_session_rwunlock(b_session);
|
||||
}
|
||||
}
|
||||
switch_core_session_rwunlock(a_session);
|
||||
|
||||
}
|
||||
switch_safe_strdup(bridge_intercepted);
|
||||
|
||||
}
|
||||
|
||||
static void kz_tweaks_handle_bridge_replaces_call_id(switch_event_t *event)
|
||||
{
|
||||
switch_event_t *my_event;
|
||||
|
||||
const char *replaced_call_id = switch_event_get_header(event, "variable_sip_replaces_call_id");
|
||||
const char *a_leg_call_id = switch_event_get_header(event, "variable_sip_replaces_a-leg");
|
||||
const char *peer_uuid = switch_event_get_header(event, "Unique-ID");
|
||||
|
||||
if (!kz_test_tweak(KZ_TWEAK_BRIDGE_REPLACES_CALL_ID)) return;
|
||||
|
||||
if(a_leg_call_id && replaced_call_id) {
|
||||
switch_core_session_t *call_session = NULL;
|
||||
const char *call_id = switch_event_get_header(event, "Bridge-B-Unique-ID");
|
||||
if (call_id && (call_session = switch_core_session_force_locate(call_id)) != NULL) {
|
||||
switch_channel_t *call_channel = switch_core_session_get_channel(call_session);
|
||||
if (switch_event_create(&my_event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(call_session));
|
||||
switch_event_add_header_string(my_event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", peer_uuid);
|
||||
switch_channel_event_set_data(call_channel, my_event);
|
||||
switch_event_fire(&my_event);
|
||||
}
|
||||
switch_channel_set_variable(call_channel, "Bridge-B-Unique-ID", peer_uuid);
|
||||
switch_channel_add_state_handler(call_channel, &kz_tweaks_signal_bridge_state_handlers);
|
||||
switch_core_session_rwunlock(call_session);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "NOT FOUND : %s\n", call_id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void kz_tweaks_channel_bridge_event_handler(switch_event_t *event)
|
||||
{
|
||||
const char *uuid = switch_event_get_header(event, "Unique-ID");
|
||||
|
||||
if (!kz_test_tweak(KZ_TWEAK_BRIDGE)) return;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak bridge event handler: %s\n", uuid);
|
||||
|
||||
kz_tweaks_handle_bridge_intercepted(event);
|
||||
kz_tweaks_handle_bridge_replaces_call_id(event);
|
||||
kz_tweaks_handle_bridge_replaces_aleg(event);
|
||||
kz_tweaks_handle_bridge_variables(event);
|
||||
}
|
||||
|
||||
@ -204,21 +234,12 @@ static void kz_tweaks_channel_replaced_event_handler(switch_event_t *event)
|
||||
|
||||
static void kz_tweaks_channel_intercepted_event_handler(switch_event_t *event)
|
||||
{
|
||||
switch_core_session_t *uuid_session = NULL;
|
||||
const char *uuid = switch_event_get_header(event, "Unique-ID");
|
||||
const char *peer_uuid = switch_event_get_header(event, "intercepted_by");
|
||||
|
||||
if (!kz_test_tweak(KZ_TWEAK_TRANSFERS)) return;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "tweak intercepted handler : %s was intercepted by %s\n", uuid, peer_uuid);
|
||||
|
||||
if ((uuid_session = switch_core_session_force_locate(peer_uuid)) != NULL) {
|
||||
switch_channel_t *uuid_channel = switch_core_session_get_channel(uuid_session);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "marking %s for channel_bridge handling\n", peer_uuid);
|
||||
switch_channel_set_variable(uuid_channel, BRIDGE_INTERCEPT_VARIABLE, "true");
|
||||
switch_core_session_rwunlock(uuid_session);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INTERCEPTED : %s => %s\n", uuid, peer_uuid);
|
||||
}
|
||||
|
||||
static void kz_tweaks_channel_transferor_event_handler(switch_event_t *event)
|
||||
@ -423,30 +444,6 @@ static void kz_tweaks_handle_caller_id(switch_core_session_t *session)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
static switch_status_t kz_tweaks_handle_auth_token(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_event_t *event;
|
||||
const char *token = switch_channel_get_variable(channel, "sip_h_X-FS-Auth-Token");
|
||||
if(token) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Authenticating user for nightmare xfer %s\n", token);
|
||||
if (switch_ivr_set_user(session, token) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Authenticated user from nightmare xfer %s\n", token);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Error Authenticating user for nightmare xfer %s\n", token);
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
static switch_status_t kz_tweaks_handle_nightmare_xfer_interaction_id(switch_core_session_t *session)
|
||||
{
|
||||
if (kz_test_tweak(KZ_TWEAK_INTERACTION_ID)) {
|
||||
@ -525,16 +522,26 @@ static switch_status_t kz_tweaks_handle_switch_uri(switch_core_session_t *sessio
|
||||
|
||||
}
|
||||
|
||||
static char * kz_tweaks_new_interaction_id()
|
||||
{
|
||||
long int first = (switch_micro_time_now() / 1000000) + UNIX_EPOCH_IN_GREGORIAN;
|
||||
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
switch_uuid_t uuid;
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
uuid_str[8] = '\0';
|
||||
return switch_mprintf("%ld-%s", first, uuid_str);
|
||||
}
|
||||
|
||||
static void kz_tweaks_handle_interaction_id(switch_core_session_t *session)
|
||||
{
|
||||
const char *expr = "${expr(ceil((${Event-Date-Timestamp} / 1000000) + $${UNIX_EPOCH_IN_GREGORIAN}))}-${regex(${create_uuid()}|^([^-]*)|%1)}";
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char * val = NULL;
|
||||
switch_core_session_t *peer_session = NULL;
|
||||
const char* peer_interaction_id = NULL;
|
||||
|
||||
if (kz_test_tweak(KZ_TWEAK_INTERACTION_ID)) {
|
||||
val = kz_expand(expr);
|
||||
val = kz_tweaks_new_interaction_id();
|
||||
if (val) {
|
||||
switch_channel_set_variable(channel, "Original-"INTERACTION_VARIABLE, val);
|
||||
if(switch_core_session_get_partner(session, &peer_session) == SWITCH_STATUS_SUCCESS) {
|
||||
@ -583,32 +590,6 @@ static switch_status_t kz_tweaks_register_handle_blind_xfer(switch_core_session_
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t kz_tweaks_set_export_vars(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *exports;
|
||||
char *var, *new_exports, *new_exports_d = NULL;
|
||||
|
||||
if (kz_test_tweak(KZ_TWEAK_EXPORT_VARS)) {
|
||||
exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE);
|
||||
var = switch_core_session_strdup(session, "Switch-URI,Switch-URL");
|
||||
|
||||
if (exports) {
|
||||
new_exports_d = switch_mprintf("%s,%s", exports, var);
|
||||
new_exports = new_exports_d;
|
||||
} else {
|
||||
new_exports = var;
|
||||
}
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
|
||||
|
||||
switch_safe_free(new_exports_d);
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t kz_tweaks_on_init(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
@ -618,12 +599,10 @@ static switch_status_t kz_tweaks_on_init(switch_core_session_t *session)
|
||||
kz_tweaks_handle_interaction_id(session);
|
||||
kz_tweaks_handle_switch_uri(session);
|
||||
kz_tweaks_handle_caller_id(session);
|
||||
// kz_tweaks_handle_auth_token(session);
|
||||
kz_tweaks_handle_nightmare_xfer_interaction_id(session);
|
||||
kz_tweaks_handle_replaces_call_id(session);
|
||||
kz_tweaks_handle_loopback(session);
|
||||
kz_tweaks_register_handle_blind_xfer(session);
|
||||
kz_tweaks_set_export_vars(session);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@ -693,7 +672,7 @@ static void kz_tweaks_unbind_events()
|
||||
|
||||
void kz_tweaks_add_core_variables()
|
||||
{
|
||||
switch_core_set_variable("UNIX_EPOCH_IN_GREGORIAN", "62167219200");
|
||||
switch_core_set_variable("UNIX_EPOCH_IN_GREGORIAN", UNIX_EPOCH_IN_GREGORIAN_STR);
|
||||
}
|
||||
|
||||
void kz_tweaks_start()
|
||||
|
32
src/mod/event_handlers/mod_kazoo/kazoo_tweaks.h
Normal file
32
src/mod/event_handlers/mod_kazoo/kazoo_tweaks.h
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
typedef enum {
|
||||
KZ_TWEAK_INTERACTION_ID,
|
||||
KZ_TWEAK_EXPORT_VARS,
|
||||
KZ_TWEAK_SWITCH_URI,
|
||||
KZ_TWEAK_REPLACES_CALL_ID,
|
||||
KZ_TWEAK_LOOPBACK_VARS,
|
||||
KZ_TWEAK_CALLER_ID,
|
||||
KZ_TWEAK_TRANSFERS,
|
||||
KZ_TWEAK_BRIDGE,
|
||||
KZ_TWEAK_BRIDGE_REPLACES_ALEG,
|
||||
KZ_TWEAK_BRIDGE_REPLACES_CALL_ID,
|
||||
KZ_TWEAK_BRIDGE_VARIABLES,
|
||||
KZ_TWEAK_RESTORE_CALLER_ID_ON_BLIND_XFER,
|
||||
|
||||
/* No new flags below this line */
|
||||
KZ_TWEAK_MAX
|
||||
} kz_tweak_t;
|
||||
|
||||
void kz_tweaks_start();
|
||||
void kz_tweaks_stop();
|
||||
SWITCH_DECLARE(const char *) kz_tweak_name(kz_tweak_t tweak);
|
||||
SWITCH_DECLARE(switch_status_t) kz_name_tweak(const char *name, kz_tweak_t *type);
|
||||
|
||||
|
||||
#define kz_test_tweak(flag) (kazoo_globals.tweaks[flag] ? 1 : 0)
|
||||
#define kz_set_tweak(flag) kazoo_globals.tweaks[flag] = 1
|
||||
#define kz_clear_tweak(flag) kazoo_globals.tweaks[flag] = 0
|
||||
|
@ -90,15 +90,11 @@ SWITCH_DECLARE(switch_status_t) kz_expand_api_execute(const char *cmd, const cha
|
||||
switch_assert(stream->data != NULL);
|
||||
switch_assert(stream->write_function != NULL);
|
||||
|
||||
if (strcasecmp(cmd, "console_complete")) {
|
||||
cmd_used = switch_strip_whitespace(cmd);
|
||||
arg_used = switch_strip_whitespace(arg);
|
||||
} else {
|
||||
cmd_used = (char *) cmd;
|
||||
arg_used = (char *) arg;
|
||||
}
|
||||
cmd_used = switch_strip_whitespace(cmd);
|
||||
arg_used = switch_strip_whitespace(arg);
|
||||
|
||||
if (cmd_used && (api = switch_loadable_module_get_api_interface(cmd_used)) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "executing [%s] => [%s]\n", cmd_used, arg_used);
|
||||
if ((status = api->function(arg_used, session, stream)) != SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "COMMAND RETURNED ERROR!\n");
|
||||
}
|
||||
@ -148,6 +144,7 @@ SWITCH_DECLARE(char *) kz_event_expand_headers_check(switch_event_t *event, cons
|
||||
nv = 0;
|
||||
olen = strlen(in) + 1;
|
||||
indup = strdup(in);
|
||||
switch_assert(indup);
|
||||
endof_indup = end_of_p(indup) + 1;
|
||||
|
||||
if ((data = malloc(olen))) {
|
||||
@ -342,46 +339,37 @@ SWITCH_DECLARE(char *) kz_event_expand_headers_check(switch_event_t *event, cons
|
||||
} else {
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
char *expanded = NULL;
|
||||
char *expanded_vname = NULL;
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
if (stream.data) {
|
||||
char *expanded_vname = NULL;
|
||||
|
||||
if ((expanded_vname = kz_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
|
||||
expanded_vname = NULL;
|
||||
} else {
|
||||
vname = expanded_vname;
|
||||
}
|
||||
|
||||
if ((expanded = kz_event_expand_headers_check(event, vval, var_list, api_list, recur+1)) == vval) {
|
||||
expanded = NULL;
|
||||
} else {
|
||||
vval = expanded;
|
||||
}
|
||||
|
||||
if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
|
||||
func_val = NULL;
|
||||
sub_val = "<API execute Permission Denied>";
|
||||
} else {
|
||||
stream.param_event = event;
|
||||
if (kz_expand_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
|
||||
func_val = stream.data;
|
||||
sub_val = func_val;
|
||||
} else {
|
||||
free(stream.data);
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free(expanded);
|
||||
switch_safe_free(expanded_vname);
|
||||
|
||||
if ((expanded_vname = kz_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
|
||||
expanded_vname = NULL;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
|
||||
free(data);
|
||||
free(indup);
|
||||
return (char *) in;
|
||||
vname = expanded_vname;
|
||||
}
|
||||
|
||||
if ((expanded = kz_event_expand_headers_check(event, vval, var_list, api_list, recur+1)) == vval) {
|
||||
expanded = NULL;
|
||||
} else {
|
||||
vval = expanded;
|
||||
}
|
||||
|
||||
if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
|
||||
func_val = NULL;
|
||||
sub_val = "<API execute Permission Denied>";
|
||||
} else {
|
||||
stream.param_event = event;
|
||||
if (kz_expand_api_execute(vname, vval, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
|
||||
func_val = stream.data;
|
||||
sub_val = func_val;
|
||||
} else {
|
||||
free(stream.data);
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free(expanded);
|
||||
switch_safe_free(expanded_vname);
|
||||
}
|
||||
if ((nlen = sub_val ? strlen(sub_val) : 0)) {
|
||||
if (len + nlen >= olen) {
|
||||
@ -435,6 +423,21 @@ SWITCH_DECLARE(char *) kz_event_expand_headers(switch_event_t *event, const char
|
||||
return kz_event_expand_headers_check(event, in, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(char *) kz_event_expand_headers_pool(switch_memory_pool_t *pool, switch_event_t *event, char *val)
|
||||
{
|
||||
char *expanded;
|
||||
char *dup = NULL;
|
||||
|
||||
expanded = kz_event_expand_headers(event, val);
|
||||
dup = switch_core_strdup(pool, expanded);
|
||||
|
||||
if (expanded != val) {
|
||||
free(expanded);
|
||||
}
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(char *) kz_event_expand(const char *in)
|
||||
{
|
||||
switch_event_t *event = NULL;
|
||||
@ -513,6 +516,32 @@ SWITCH_DECLARE(switch_status_t) kz_switch_event_add_variable_name_printf(switch_
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) kz_expand_json_to_event(cJSON *json, switch_event_t *event, char * prefix)
|
||||
{
|
||||
char * fmt = switch_mprintf("%s%s%%s", prefix ? prefix : "", prefix ? "_" : "");
|
||||
if (event) {
|
||||
cJSON *item = NULL;
|
||||
char *response = NULL;
|
||||
cJSON_ArrayForEach(item, json) {
|
||||
if (item->type == cJSON_String) {
|
||||
response = strdup(item->valuestring);
|
||||
} else if (item->type == cJSON_Object) {
|
||||
char * fmt1 = switch_mprintf(fmt, item->string);
|
||||
kz_expand_json_to_event(item, event, fmt1);
|
||||
switch_safe_free(fmt1);
|
||||
continue;
|
||||
} else {
|
||||
response = cJSON_PrintUnformatted(item);
|
||||
}
|
||||
kz_switch_event_add_variable_name_printf(event, SWITCH_STACK_BOTTOM, response, fmt, item->string);
|
||||
switch_safe_free(response);
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free(fmt);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_xml_t) kz_xml_child(switch_xml_t xml, const char *name)
|
||||
{
|
||||
xml = (xml) ? xml->child : NULL;
|
||||
@ -565,6 +594,35 @@ void kz_event_decode(switch_event_t *event)
|
||||
}
|
||||
}
|
||||
|
||||
void kz_expand_headers(switch_event_t *resolver, switch_event_t *event) {
|
||||
switch_event_t *clone = NULL;
|
||||
switch_event_header_t *header = NULL;
|
||||
switch_event_create_plain(&clone, event->event_id);
|
||||
|
||||
for(header = event->headers; header; header = header->next) {
|
||||
char *expanded = kz_event_expand_headers(resolver, header->value);
|
||||
if (expanded != header->value) {
|
||||
switch_event_add_header_string(clone, SWITCH_STACK_BOTTOM, header->name, expanded);
|
||||
switch_safe_free(expanded);
|
||||
}
|
||||
}
|
||||
|
||||
/* we don't want to force unique headers
|
||||
* so we delete and then merge
|
||||
*/
|
||||
for(header = clone->headers; header; header = header->next) {
|
||||
switch_event_del_header(event, header->name);
|
||||
}
|
||||
|
||||
switch_event_merge(event, clone);
|
||||
|
||||
switch_event_destroy(&clone);
|
||||
}
|
||||
|
||||
void kz_expand_headers_self(switch_event_t *event) {
|
||||
kz_expand_headers(event, event);
|
||||
}
|
||||
|
||||
char * kz_expand_vars(char *xml_str) {
|
||||
return kz_expand_vars_pool(xml_str, NULL);
|
||||
}
|
||||
|
53
src/mod/event_handlers/mod_kazoo/kazoo_utils.h
Normal file
53
src/mod/event_handlers/mod_kazoo/kazoo_utils.h
Normal file
@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define KZ_BEGIN_EXTERN_C extern "C" {
|
||||
#define KZ_END_EXTERN_C }
|
||||
#else
|
||||
#define KZ_BEGIN_EXTERN_C
|
||||
#define KZ_END_EXTERN_C
|
||||
#endif
|
||||
|
||||
KZ_BEGIN_EXTERN_C
|
||||
|
||||
void kz_check_set_profile_var(switch_channel_t *channel, char* var, char *val);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) kz_switch_core_merge_variables(switch_event_t *event);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) kz_switch_core_base_headers_for_expand(switch_event_t **event);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) kz_expand_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
|
||||
|
||||
SWITCH_DECLARE(char *) kz_event_expand_headers_check(switch_event_t *event, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur);
|
||||
|
||||
SWITCH_DECLARE(char *) kz_event_expand_headers(switch_event_t *event, const char *in);
|
||||
|
||||
SWITCH_DECLARE(char *) kz_event_expand_headers_pool(switch_memory_pool_t *pool, switch_event_t *event, char *val);
|
||||
|
||||
SWITCH_DECLARE(char *) kz_event_expand(const char *in);
|
||||
|
||||
SWITCH_DECLARE(char *) kz_expand(const char *in);
|
||||
|
||||
SWITCH_DECLARE(char *) kz_expand_pool(switch_memory_pool_t *pool, const char *in);
|
||||
|
||||
char* kz_switch_event_get_first_of(switch_event_t *event, const char *list[]);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) kz_switch_event_add_variable_name_printf(switch_event_t *event, switch_stack_t stack, const char *val, const char *fmt, ...);
|
||||
|
||||
SWITCH_DECLARE(switch_xml_t) kz_xml_child(switch_xml_t xml, const char *name);
|
||||
|
||||
void kz_xml_process(switch_xml_t cfg);
|
||||
void kz_event_decode(switch_event_t *event);
|
||||
|
||||
char * kz_expand_vars(char *xml_str);
|
||||
void kz_expand_headers(switch_event_t *resolver, switch_event_t *event);
|
||||
void kz_expand_headers_self(switch_event_t *event);
|
||||
|
||||
char * kz_expand_vars_pool(char *xml_str, switch_memory_pool_t *pool);
|
||||
switch_status_t kz_json_api(const char * command, cJSON *args, cJSON **res);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) kz_expand_json_to_event(cJSON *json, switch_event_t *event, char * prefix);
|
||||
|
||||
KZ_END_EXTERN_C
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user