diff --git a/README.md b/README.md index 923054d848..15cda2e22f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Step by step tutorials to install FreeSWITCH from packages: ### Build from source Example Dockerfiles to build FreeSWITCH and dependencies from source: - * https://github.com/signalwire/freeswitch/tree/dockerfile/docker/examples + * https://github.com/signalwire/freeswitch/tree/master/docker/examples Step by step tutorials to build FreeSWITCH with provided dependency packages: * [Debian](https://freeswitch.org/confluence/display/FREESWITCH/Debian#Debian-buildfromsource) [Recommended] diff --git a/build/next-release.txt b/build/next-release.txt index b61c58c7d4..63fd3adc74 100644 --- a/build/next-release.txt +++ b/build/next-release.txt @@ -1 +1 @@ -1.10.10-dev +1.10.11-dev diff --git a/conf/curl/autoload_configs/timezones.conf.xml b/conf/curl/autoload_configs/timezones.conf.xml index 14f87f8c67..9ddded792c 100644 --- a/conf/curl/autoload_configs/timezones.conf.xml +++ b/conf/curl/autoload_configs/timezones.conf.xml @@ -1,551 +1,661 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - + - - - + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/insideout/autoload_configs/timezones.conf.xml b/conf/insideout/autoload_configs/timezones.conf.xml index 14f87f8c67..9ddded792c 100644 --- a/conf/insideout/autoload_configs/timezones.conf.xml +++ b/conf/insideout/autoload_configs/timezones.conf.xml @@ -1,551 +1,661 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - + - - - + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/minimal/autoload_configs/timezones.conf.xml b/conf/minimal/autoload_configs/timezones.conf.xml index 0af4c77d7f..9ddded792c 100644 --- a/conf/minimal/autoload_configs/timezones.conf.xml +++ b/conf/minimal/autoload_configs/timezones.conf.xml @@ -1,1850 +1,661 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/conf/rayo/autoload_configs/timezones.conf.xml b/conf/rayo/autoload_configs/timezones.conf.xml index 14f87f8c67..9ddded792c 100644 --- a/conf/rayo/autoload_configs/timezones.conf.xml +++ b/conf/rayo/autoload_configs/timezones.conf.xml @@ -1,551 +1,661 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - + - - - + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/sbc/autoload_configs/timezones.conf.xml b/conf/sbc/autoload_configs/timezones.conf.xml index 14f87f8c67..9ddded792c 100644 --- a/conf/sbc/autoload_configs/timezones.conf.xml +++ b/conf/sbc/autoload_configs/timezones.conf.xml @@ -1,551 +1,661 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - + - - - + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/testing/autoload_configs/timezones.conf.xml b/conf/testing/autoload_configs/timezones.conf.xml index 0af4c77d7f..9ddded792c 100644 --- a/conf/testing/autoload_configs/timezones.conf.xml +++ b/conf/testing/autoload_configs/timezones.conf.xml @@ -1,1850 +1,661 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/conf/vanilla/autoload_configs/timezones.conf.xml b/conf/vanilla/autoload_configs/timezones.conf.xml index 48206d1ce4..9ddded792c 100644 --- a/conf/vanilla/autoload_configs/timezones.conf.xml +++ b/conf/vanilla/autoload_configs/timezones.conf.xml @@ -1,1816 +1,661 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + - + - - - - - - - - - + + + + + + + + - - + + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - + - + + + + + + + + + + + - + - + - + - + - + - + - + - + - - - + - + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - - - - - - - - - - - - - + - + + + + + + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/conf/vanilla/freeswitch.xml b/conf/vanilla/freeswitch.xml index dc66fca170..35f9c6bbb9 100644 --- a/conf/vanilla/freeswitch.xml +++ b/conf/vanilla/freeswitch.xml @@ -9,11 +9,11 @@ Before you start to modify this default please visit this wiki page: - http://wiki.freeswitch.org/wiki/Getting_Started_Guide#Some_stuff_to_try_out.21 + https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/Default-Configuration_6587388/#6-configuration-files If all else fails you can read our FAQ located at: - http://wiki.freeswitch.org/wiki/FreeSwitch_FAQ + https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Miscellaneous/FAQ/ NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE --> diff --git a/configure.ac b/configure.ac index 7ca19e49e8..9f852e531a 100644 --- a/configure.ac +++ b/configure.ac @@ -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.10-dev], bugs@freeswitch.org) +AC_INIT([freeswitch], [1.10.11-dev], bugs@freeswitch.org) AC_SUBST(SWITCH_VERSION_MAJOR, [1]) AC_SUBST(SWITCH_VERSION_MINOR, [10]) -AC_SUBST(SWITCH_VERSION_MICRO, [10-dev]) +AC_SUBST(SWITCH_VERSION_MICRO, [11-dev]) AC_SUBST(SWITCH_VERSION_REVISION, []) AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, []) @@ -582,7 +582,7 @@ AC_SUBST(SYS_XMLRPC_CFLAGS) AC_SUBST(SYS_XMLRPC_LDFLAGS) AM_CONDITIONAL([SYSTEM_XMLRPCC],[test "${enable_xmlrpcc}" = "yes"]) -for luaversion in luajit lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua; do +for luaversion in luajit lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua; do PKG_CHECK_MODULES([LUA],[${luaversion}],[have_lua=yes],[have_lua=no]) if test ${have_lua} = yes; then break @@ -716,7 +716,7 @@ PKG_CHECK_MODULES([SPANDSP], [spandsp >= 3.0],[ AC_MSG_ERROR([no usable spandsp; please install spandsp3 devel package or equivalent]) ]) -PKG_CHECK_MODULES([SOFIA_SIP], [sofia-sip-ua >= 1.13.14],[ +PKG_CHECK_MODULES([SOFIA_SIP], [sofia-sip-ua >= 1.13.15],[ AM_CONDITIONAL([HAVE_SOFIA_SIP],[true])],[ AC_MSG_ERROR([no usable sofia-sip; please install sofia-sip-ua devel package or equivalent]) ]) @@ -1352,7 +1352,21 @@ PKG_CHECK_MODULES([MPG123], [libmpg123 >= 1.16.0],[ AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_MPG123],[false])]) PKG_CHECK_MODULES([SHOUT], [shout >= 2.2.2],[ - AM_CONDITIONAL([HAVE_SHOUT],[true])],[ + AM_CONDITIONAL([HAVE_SHOUT],[true]) + SHOUT_VERSION="`$PKG_CONFIG --modversion shout`" + SHOUT_MAJOR_VERSION="`echo $SHOUT_VERSION | cut -d. -f1`" + SHOUT_MINOR_VERSION="`echo $SHOUT_VERSION | cut -d. -f2`" + SHOUT_PATCH_VERSION="`echo $SHOUT_VERSION | cut -d. -f3`" + test -n "$SHOUT_PATCH_VERSION" || SHOUT_PATCH_VERSION=0 + AC_MSG_NOTICE([SHOUT version: $SHOUT_VERSION]) + AC_MSG_NOTICE([SHOUT major version: $SHOUT_MAJOR_VERSION]) + AC_MSG_NOTICE([SHOUT minor version: $SHOUT_MINOR_VERSION]) + AC_MSG_NOTICE([SHOUT patch version: $SHOUT_PATCH_VERSION]) + AC_SUBST([SHOUT_VERSION]) + AC_SUBST([SHOUT_MAJOR_VERSION]) + AC_SUBST([SHOUT_MINOR_VERSION]) + AC_SUBST([SHOUT_PATCH_VERSION]) + ],[ AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SHOUT],[false])]) mp3lame=false @@ -1518,26 +1532,32 @@ PKG_CHECK_MODULES([V8FS_STATIC], [v8-6.1_static >= 6.1.298],[ ]) ]) -PKG_CHECK_MODULES([KS], [libks >= 1.8.2],[ +PKG_CHECK_MODULES([KS], [libks2 >= 2.0.0],[ AM_CONDITIONAL([HAVE_KS],[true])],[ - if module_enabled mod_verto; then - AC_MSG_ERROR([You need to either install libks or disable mod_verto in modules.conf]) - else - if module_enabled mod_signalwire; then - AC_MSG_ERROR([You need to either install libks or disable mod_signalwire in modules.conf]) + PKG_CHECK_MODULES([KS], [libks >= 1.8.2],[ + AM_CONDITIONAL([HAVE_KS],[true])],[ + if module_enabled mod_verto; then + AC_MSG_ERROR([You need to either install libks2 or libks or disable mod_verto in modules.conf]) else - AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_KS],[false]) + if module_enabled mod_signalwire; then + AC_MSG_ERROR([You need to either install libks2 or libks or disable mod_signalwire in modules.conf]) + else + AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_KS],[false]) + fi fi - fi + ]) ]) -PKG_CHECK_MODULES([SIGNALWIRE_CLIENT], [signalwire_client >= 1.0.0],[ +PKG_CHECK_MODULES([SIGNALWIRE_CLIENT], [signalwire_client2 >= 2.0.0],[ AM_CONDITIONAL([HAVE_SIGNALWIRE_CLIENT],[true])],[ - if module_enabled mod_signalwire; then - AC_MSG_ERROR([You need to either install signalwire-client-c or disable mod_signalwire in modules.conf]) - else - AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SIGNALWIRE_CLIENT],[false]) - fi + PKG_CHECK_MODULES([SIGNALWIRE_CLIENT], [signalwire_client >= 1.0.0],[ + AM_CONDITIONAL([HAVE_SIGNALWIRE_CLIENT],[true])],[ + if module_enabled mod_signalwire; then + AC_MSG_ERROR([You need to either install signalwire-client-c2 or signalwire-client-c or disable mod_signalwire in modules.conf]) + else + AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SIGNALWIRE_CLIENT],[false]) + fi + ]) ]) PKG_CHECK_MODULES([AMQP], [librabbitmq >= 0.5.2],[ diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index e3f0b1b9db..a2f0261ab6 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -29,7 +29,7 @@ conf_dir="../conf" lang_dir="../conf/vanilla/lang" fs_description="FreeSWITCH is a scalable open source cross-platform telephony platform designed to route and interconnect popular communication protocols using audio, video, text or any other form of media." mod_build_depends="." mod_depends="." mod_recommends="." mod_suggests="." -supported_debian_distros="wheezy jessie stretch buster bullseye sid" +supported_debian_distros="wheezy jessie stretch buster bullseye bookworm sid" supported_ubuntu_distros="trusty utopic xenial" supported_distros="$supported_debian_distros $supported_ubuntu_distros" avoid_mods=( @@ -71,6 +71,9 @@ avoid_mods_sid=( avoid_mods_jessie=( directories/mod_ldap ) +avoid_mods_bookworm=( + languages/mod_python +) avoid_mods_wheezy=( event_handlers/mod_amqp languages/mod_java @@ -325,14 +328,14 @@ Build-Depends: # configure options libssl1.0-dev | libssl-dev, unixodbc-dev, libpq-dev, libncurses5-dev, libjpeg62-turbo-dev | libjpeg-turbo8-dev | libjpeg62-dev | libjpeg8-dev, - python-dev | python-dev-is-python2, python3-dev, python-all-dev, python-support (>= 0.90) | dh-python, erlang-dev, libtpl-dev (>= 1.5), + python-dev | python-dev-is-python2 | python-dev-is-python3, python3-dev, python-all-dev | python3-all-dev, python-support (>= 0.90) | dh-python, erlang-dev, libtpl-dev (>= 1.5), # documentation doxygen, # for APR (not essential for build) uuid-dev, libexpat1-dev, libgdbm-dev, libdb-dev, # used by many modules libcurl4-openssl-dev | libcurl4-gnutls-dev | libcurl-dev, - bison, zlib1g-dev, libsofia-sip-ua-dev (>= 1.13.14), + bison, zlib1g-dev, libsofia-sip-ua-dev (>= 1.13.15), libspandsp3-dev, # used to format the private freeswitch apt-repo key properly gnupg, @@ -371,7 +374,7 @@ Description: Cross-Platform Scalable Multi-Protocol Soft Switch Package: libfreeswitch1 Architecture: amd64 armhf -Depends: \${shlibs:Depends}, \${misc:Depends}, libsofia-sip-ua0 (>= 1.13.14) +Depends: \${shlibs:Depends}, \${misc:Depends}, libsofia-sip-ua0 (>= 1.13.15) Recommends: Suggests: libfreeswitch1-dbg Conflicts: freeswitch-all (<= 1.6.7) diff --git a/debian/control-modules b/debian/control-modules index b9d7a05933..3179f8eeef 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -12,6 +12,7 @@ Module: applications/mod_av Description: mod_av Adds mod_av. Build-Depends: libavformat-dev, libswscale-dev, libavresample-dev +Build-Depends-Bookworm: libavformat-dev, libswscale-dev, libswresample-dev Module: applications/mod_avmd Description: Advanced voicemail detection @@ -209,7 +210,7 @@ Description: Adds mod_skel Module: applications/mod_signalwire Description: mod_signalwire Adds mod_signalwire. -Build-Depends: libks, signalwire-client-c +Build-Depends: libks2, signalwire-client-c2 Module: applications/mod_sms Description: Astract SMS @@ -485,6 +486,7 @@ Description: Adds mod_verto. Build-Depends: libperl-dev Build-Depends-Buster: libperl-dev, libgdbm-compat-dev Build-Depends-Bullseye: libperl-dev, libgdbm-compat-dev +Build-Depends-Bookworm: libperl-dev, libgdbm-compat-dev ## mod/event_handlers @@ -647,6 +649,7 @@ Module: languages/mod_lua Description: mod_lua Adds mod_lua. Build-Depends: liblua5.2-dev | liblua5.1-dev +Build-Depends-Bookworm: liblua5.3-dev | liblua5.2-dev | liblua5.1-dev Module: languages/mod_managed Description: mod_managed @@ -659,6 +662,7 @@ Description: mod_perl Build-Depends: libperl-dev Build-Depends-Buster: libperl-dev, libgdbm-compat-dev Build-Depends-Bullseye: libperl-dev, libgdbm-compat-dev +Build-Depends-Bookworm: libperl-dev, libgdbm-compat-dev Module: languages/mod_python Description: mod_python @@ -669,6 +673,7 @@ Module: languages/mod_python3 Description: mod_python3 Adds mod_python3. Build-Depends: python3-dev +Build-Depends-Bookworm: python3-dev, python3-setuptools Module: languages/mod_v8 Description: mod_v8 diff --git a/debian/util.sh b/debian/util.sh index 6a5d8f27da..110e6d8763 100755 --- a/debian/util.sh +++ b/debian/util.sh @@ -46,6 +46,7 @@ find_distro () { case "$1" in experimental) echo "sid";; unstable) echo "sid";; + experimental) echo "bookworm";; testing) echo "bullseye";; stable) echo "buster";; oldstable) echo "stretch";; @@ -56,6 +57,7 @@ find_distro () { find_suite () { case "$1" in sid) echo "unstable";; + bookworm) echo "experimental";; bullseye) echo "testing";; buster) echo "stable";; stretch) echo "oldstable";; diff --git a/freeswitch.spec b/freeswitch.spec index f3904afa2c..ecf9dacf13 100644 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -140,7 +140,7 @@ BuildRequires: curl-devel >= 7.19 BuildRequires: gcc-c++ BuildRequires: libtool >= 1.5.17 BuildRequires: openssl-devel >= 1.0.1e -BuildRequires: sofia-sip-devel >= 1.13.14 +BuildRequires: sofia-sip-devel >= 1.13.15 BuildRequires: spandsp3-devel >= 3.0 BuildRequires: pcre-devel BuildRequires: speex-devel @@ -497,7 +497,7 @@ the entries aloud via a TTS engine Summary: FreeSWITCH mod_signalwire Group: System/Libraries Requires: %{name} = %{version}-%{release} -BuildRequires: libks signalwire-client-c +BuildRequires: libks2 signalwire-client-c2 %description application-signalwire Provides FreeSWITCH mod_signalwire diff --git a/libs/libyuv/include/libyuv/planar_functions.h b/libs/libyuv/include/libyuv/planar_functions.h index 5299fe2c0e..50fe5f681d 100644 --- a/libs/libyuv/include/libyuv/planar_functions.h +++ b/libs/libyuv/include/libyuv/planar_functions.h @@ -582,7 +582,7 @@ typedef void (*ARGBBlendRow)(const uint8_t* src_argb0, // Get function to Alpha Blend ARGB pixels and store to destination. LIBYUV_API -ARGBBlendRow GetARGBBlend(); +ARGBBlendRow GetARGBBlend(void); // Alpha Blend ARGB images and store to destination. // Source is pre-multiplied by alpha using ARGBAttenuate. diff --git a/libs/libyuv/source/planar_functions.cc b/libs/libyuv/source/planar_functions.cc index 5a9d56d88a..c07f0943d3 100644 --- a/libs/libyuv/source/planar_functions.cc +++ b/libs/libyuv/source/planar_functions.cc @@ -1185,7 +1185,7 @@ int ARGBMirror(const uint8_t* src_argb, // As there are 6 blenders to choose from, the caller should try to use // the same blend function for all pixels if possible. LIBYUV_API -ARGBBlendRow GetARGBBlend() { +ARGBBlendRow GetARGBBlend(void) { void (*ARGBBlendRow)(const uint8_t* src_argb, const uint8_t* src_argb1, uint8_t* dst_argb, int width) = ARGBBlendRow_C; #if defined(HAS_ARGBBLENDROW_SSSE3) diff --git a/libs/miniupnpc/miniupnpc.c b/libs/miniupnpc/miniupnpc.c index 88faea1c37..a72ef892b6 100644 --- a/libs/miniupnpc/miniupnpc.c +++ b/libs/miniupnpc/miniupnpc.c @@ -679,7 +679,6 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, char * descXML; int descXMLsize = 0; struct UPNPDev * dev; - int ndev = 0; int state; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */ if(!devlist) { @@ -698,7 +697,6 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, lanaddr, lanaddrlen); if(descXML) { - ndev++; memset(data, 0, sizeof(struct IGDdatas)); memset(urls, 0, sizeof(struct UPNPUrls)); parserootdesc(descXML, descXMLsize, data); diff --git a/libs/win32/ffmpeg/ffmpeg.2017.vcxproj b/libs/win32/ffmpeg/ffmpeg.2017.vcxproj index 7eb6ef65ed..b985670dbe 100644 --- a/libs/win32/ffmpeg/ffmpeg.2017.vcxproj +++ b/libs/win32/ffmpeg/ffmpeg.2017.vcxproj @@ -24,7 +24,6 @@ 10.0.17134.0 {BC1FD72E-1CD5-4525-A7F5-17C5740BFDED} - @@ -78,7 +77,7 @@ - BUILDING_avdevice;BUILDING_avfilter;BUILDING_avformat;BUILDING_avcodec;BUILDING_avresample;BUILDING_swresample;BUILDING_swscale;BUILDING_avutil;%(PreprocessorDefinitions) + WC_ERR_INVALID_CHARS=0x00000080;BUILDING_avdevice;BUILDING_avfilter;BUILDING_avformat;BUILDING_avcodec;BUILDING_swresample;BUILDING_swscale;BUILDING_avutil;%(PreprocessorDefinitions) @@ -209,6 +208,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -242,6 +244,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -305,6 +310,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -332,6 +340,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -350,6 +361,18 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -392,6 +415,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -401,6 +427,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -410,6 +442,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -419,18 +457,21 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -458,15 +499,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -533,12 +574,18 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -548,6 +595,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -563,6 +613,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -596,7 +655,7 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -608,10 +667,13 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -638,6 +700,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -680,6 +745,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -719,6 +790,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -755,6 +835,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -764,15 +847,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -782,6 +865,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -815,6 +901,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -875,15 +967,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -908,9 +1000,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -980,6 +1069,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1001,9 +1093,18 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1049,6 +1150,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1097,9 +1201,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1124,6 +1225,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1133,6 +1240,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1241,6 +1354,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1271,6 +1390,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1301,6 +1423,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1406,7 +1531,7 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1415,9 +1540,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1433,9 +1555,18 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1454,6 +1585,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1466,6 +1600,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1484,6 +1621,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1538,6 +1678,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1559,6 +1702,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1586,6 +1732,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1595,6 +1744,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1640,6 +1792,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1673,6 +1828,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1691,48 +1849,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1748,6 +1873,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1763,6 +1891,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1793,18 +1924,36 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1832,6 +1981,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1880,6 +2032,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -1964,6 +2125,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2039,6 +2203,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2060,9 +2230,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2072,13 +2239,16 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2105,6 +2275,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2126,9 +2302,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2168,6 +2341,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2177,21 +2353,24 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2222,6 +2401,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2237,9 +2419,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2282,6 +2461,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2318,12 +2503,18 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2444,12 +2635,18 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2528,6 +2725,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2636,7 +2842,7 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2726,6 +2932,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2816,9 +3025,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2828,6 +3034,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2849,18 +3058,33 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2876,6 +3100,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2897,6 +3127,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2906,12 +3142,21 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2921,12 +3166,30 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2954,6 +3217,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -2996,9 +3265,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3008,6 +3274,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3026,6 +3295,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3038,6 +3310,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3077,6 +3352,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3095,7 +3373,7 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3110,10 +3388,52 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3122,6 +3442,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3140,6 +3463,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3155,6 +3481,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3203,7 +3532,13 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3215,6 +3550,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3227,6 +3565,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3245,6 +3589,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3257,6 +3604,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3266,12 +3619,21 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3284,18 +3646,33 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3320,6 +3697,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3332,6 +3712,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3341,6 +3724,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3353,6 +3739,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3365,15 +3760,27 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3416,18 +3823,30 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3443,9 +3862,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3455,10 +3880,10 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3470,9 +3895,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3494,7 +3925,16 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3512,9 +3952,21 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3554,9 +4006,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3608,10 +4066,10 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3623,6 +4081,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3632,6 +4093,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3641,6 +4105,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3677,33 +4144,39 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3716,6 +4189,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3734,13 +4210,16 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3755,6 +4234,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3764,12 +4246,18 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3779,19 +4267,31 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3800,7 +4300,7 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3809,40 +4309,55 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3869,9 +4384,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3896,6 +4417,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3908,9 +4432,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3923,6 +4453,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3935,9 +4468,21 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -3971,15 +4516,18 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4001,6 +4549,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4010,6 +4564,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4067,9 +4624,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4085,21 +4639,36 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4157,9 +4726,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4211,6 +4777,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4259,6 +4828,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4271,6 +4846,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4319,6 +4897,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4337,15 +4918,24 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4358,6 +4948,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4376,9 +4969,15 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4397,6 +4996,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4415,6 +5017,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4457,6 +5065,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4469,6 +5083,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4520,6 +5137,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4532,6 +5152,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4589,9 +5212,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4652,6 +5272,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4871,6 +5494,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4922,6 +5548,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4934,6 +5563,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -4946,6 +5578,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5027,6 +5662,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5075,6 +5713,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5099,9 +5740,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5114,6 +5752,12 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5174,6 +5818,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5234,6 +5881,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5267,15 +5917,24 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5297,6 +5956,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5309,21 +5971,27 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5426,9 +6094,30 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5447,13 +6136,19 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5480,6 +6175,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5525,6 +6223,9 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ @@ -5543,54 +6244,6 @@ $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - Assembling %(Filename)%(Extension) - $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - Assembling %(Filename)%(Extension) - $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - - - Assembling %(Filename)%(Extension) - $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - - - $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_'))\ - Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" @@ -5636,6 +6289,21 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" @@ -5666,7 +6334,7 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj @@ -5856,7 +6524,7 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj @@ -6041,6 +6709,11 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" @@ -6056,6 +6729,16 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" @@ -6066,12 +6749,27 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj @@ -6086,7 +6784,7 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj @@ -6106,17 +6804,32 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj @@ -6126,12 +6839,12 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj @@ -6141,7 +6854,12 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj - + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj @@ -6151,6 +6869,11 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" @@ -6206,6 +6929,11 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + Assembling %(Filename)%(Extension) $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" @@ -6241,6 +6969,21 @@ $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + + + Assembling %(Filename)%(Extension) + $(YasmCommand) -I %(RelativeDir) -o $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj "%(FullPath)" + $(IntDir)$([System.String]::Copy(%(RelativeDir)).Replace('\','_')).%(FileName).obj + @@ -6256,4 +6999,4 @@ - + \ No newline at end of file diff --git a/libs/xmlrpc-c/include/xmlrpc-c/string_int.h b/libs/xmlrpc-c/include/xmlrpc-c/string_int.h index 04ac8c782b..a0cc58605f 100644 --- a/libs/xmlrpc-c/include/xmlrpc-c/string_int.h +++ b/libs/xmlrpc-c/include/xmlrpc-c/string_int.h @@ -3,7 +3,12 @@ #include + +#ifdef __APPLE__ +#include +#else #include +#endif #include "xmlrpc_config.h" #include "c_util.h" diff --git a/libs/xmlrpc-c/lib/abyss/src/server.c b/libs/xmlrpc-c/lib/abyss/src/server.c index 6337dcfd78..ca05011b83 100644 --- a/libs/xmlrpc-c/lib/abyss/src/server.c +++ b/libs/xmlrpc-c/lib/abyss/src/server.c @@ -1,6 +1,9 @@ /* Copyright information is at end of file */ #define _XOPEN_SOURCE 600 /* Make sure strdup() is in */ +#ifdef __APPLE__ +#define _DARWIN_C_SOURCE +#endif #define _BSD_SOURCE /* Make sure setgroups()is in */ #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE diff --git a/libs/xmlrpc-c/lib/abyss/src/thread_fork.c b/libs/xmlrpc-c/lib/abyss/src/thread_fork.c index d96bf59eb1..7ea382918a 100644 --- a/libs/xmlrpc-c/lib/abyss/src/thread_fork.c +++ b/libs/xmlrpc-c/lib/abyss/src/thread_fork.c @@ -3,7 +3,11 @@ #include #include #include +#ifdef __APPLE__ +#include +#else #include +#endif #include #include "xmlrpc_config.h" diff --git a/libs/xmlrpc-c/lib/libutil/asprintf.c b/libs/xmlrpc-c/lib/libutil/asprintf.c index b52523065a..f078518bb5 100644 --- a/libs/xmlrpc-c/lib/libutil/asprintf.c +++ b/libs/xmlrpc-c/lib/libutil/asprintf.c @@ -1,4 +1,7 @@ #define _XOPEN_SOURCE 600 /* Make sure strdup() is in */ +#ifdef __APPLE__ +#define _DARWIN_C_SOURCE +#endif #ifndef _GNU_SOURCE #define _GNU_SOURCE /* But only when HAVE_ASPRINTF */ #endif diff --git a/scripts/lua/hangup_jitterbuffer_metrics.lua b/scripts/lua/hangup_jitterbuffer_metrics.lua new file mode 100755 index 0000000000..8e3dd37623 --- /dev/null +++ b/scripts/lua/hangup_jitterbuffer_metrics.lua @@ -0,0 +1,53 @@ +local https = require("socket.http") +local ip = os.getenv("LOCAL_IPV4") +local response_body = {} +-- jitter buffer stats +local size_max_ms = session:getVariable("rtp_jb_size_max_ms"); +local size_est_ms = session:getVariable("rtp_jb_size_est_ms"); +local acceleration_ms = session:getVariable("rtp_jb_acceleration_ms"); +local expand_ms = session:getVariable("rtp_jb_expand_ms"); +local jitter_max_ms = session:getVariable("rtp_jb_jitter_max_ms"); +local jitter_est_ms = session:getVariable("rtp_jb_jitter_est_ms"); + +local reset_count = session:getVariable("rtp_jb_reset_count"); +local reset_too_big = session:getVariable("rtp_jb_reset_too_big"); +local reset_missing_frames = session:getVariable("rtp_jb_reset_missing_frames"); +local reset_ts_jump = session:getVariable("rtp_jb_reset_ts_jump"); +local reset_error = session:getVariable("rtp_jb_reset_error"); +local call_id = session:getVariable("sip_call_id"); +local out_call_id = session:getVariable("last_bridge_to"); + +if size_max_ms == nil or size_est_ms == nil or acceleration_ms == nil or expand_ms == nil or jitter_max_ms == nil or jitter_est_ms == nil then + session:consoleLog("info", "[metrics] jitter no data\n"); + return +end +local request_body = '{"in_call_id": "'..call_id..'", "out_call_id": "'..out_call_id..'", "jb":{"size_max_ms":'..size_max_ms.. + ',"size_est_ms":'..size_est_ms..',"acceleration_ms":'..acceleration_ms..',"expand_ms":'..expand_ms.. + ',"jitter_max_ms":'..jitter_max_ms..',"jitter_est_ms":'..jitter_est_ms..',"reset":'..reset_count +-- if reset_too_big ~= "0" then + request_body = request_body .. ',"reset_too_big":'..reset_too_big +-- end +if reset_missing_frames ~= "0" then + request_body = request_body .. ',"reset_missing_frames":'..reset_missing_frames +end +if reset_ts_jump ~= "0" then + request_body = request_body .. ',"reset_ts_jump":'..reset_ts_jump +end +if reset_error ~= "0" then + request_body = request_body .. ',"reset_error":'..reset_error +end + +local v = request_body .. '}}'; + +local r, c, h, s = https.request{ + method = 'POST', + url = "http://"..ip..":80/freeswitch_metrics", + headers = { + ["Content-Type"] = "application/json", + ["Content-Length"] = string.len(v) + }, + source = ltn12.source.string(v), + sink = ltn12.sink.table(response_body) +} +-- print('statusCode ', c) +session:consoleLog("info", "[metrics] jitter:".. v .. "\n"); diff --git a/scripts/perl/timezones/build-zonedata.pl b/scripts/perl/timezones/build-zonedata.pl new file mode 100755 index 0000000000..347a743dae --- /dev/null +++ b/scripts/perl/timezones/build-zonedata.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my $remote_version = `wget --quiet https://data.iana.org/time-zones/tzdb/version --output-document -` =~ s/\n//r; +my $local_version; + +if ( open my $in, " }; + close $in; +} + +my $up_to_date = defined($local_version) && $local_version eq $remote_version; + +if ( ! $up_to_date ) { + open my $out, ">data/version"; + print $out $remote_version; + close $out; +} + +$local_version = $remote_version; + +`wget --quiet --timestamping --directory-prefix=data https://data.iana.org/time-zones/tzdb-latest.tar.lz`; +`tar --extract --file=data/tzdb-latest.tar.lz --directory=data`; +`make DESTDIR=../ TZDIR=zones-$local_version --directory=data/tzdb-$local_version posix_only`; + +print("Yay. Now you can run\n ./timezone-gen.pl --base=data/zones-$local_version --output=timezones-$local_version.conf.xml") \ No newline at end of file diff --git a/scripts/perl/timezones/data/.gitignore b/scripts/perl/timezones/data/.gitignore new file mode 100644 index 0000000000..144983b728 --- /dev/null +++ b/scripts/perl/timezones/data/.gitignore @@ -0,0 +1,4 @@ +tzdb-* +zones-* +version +tzdb-latest.tar.lz \ No newline at end of file diff --git a/scripts/perl/timezones/fix-tzstr.pl b/scripts/perl/timezones/fix-tzstr.pl new file mode 100644 index 0000000000..224c9a550e --- /dev/null +++ b/scripts/perl/timezones/fix-tzstr.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl + +sub fixTzstr { + # switch_time.c expects POSIX-style TZ rule, but it won't process quoted TZ + # rules that look like this: <-04>4 or <-04>4<-03> + # See https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03 + + # Instead it defaults to UTC for these values. Here we process the quoted + # values and convert them into letters. If the zone name has "GMT", we use + # that as the replacement prefix, otherwise a default "STD" is used. Zones + # that have a quoted suffix have their suffix replaced with "DST". + + my ($tzstr, $name) = @_; + + if ( $tzstr =~ /(<(?[^>]+)>)([^<]+)(?<.+>)?(?.+)?/ ) { + my ($tzprefix, $tzsuffix, $tzrest, $offset, $offsetprefix) = ("") x 5; + + if ( defined($+{std}) ) { + my $std = $+{std}; + + if ( lc($name) =~ m/gmt/) { + $tzprefix = "GMT"; + } else { + $tzprefix = "STD"; + } + + if ( $std =~ m/\+/ ) { + $offset = sprintf "%d", $std =~ s/\+//r; + $offsetprefix = "-"; + } else { + $offset = sprintf "%d", $std =~ s/\-//r; + } + + my @chars = split(//, $offset); + if ( @chars > 2 ) { + my $hours = $chars[-3]; + if ( defined( $chars[-4] ) ) { + $hours = $chars[-4].$hours; + } + + $offset = $hours.":".$chars[-2].$chars[-1]; + } + + $offset = $offsetprefix.$offset; + } + + if ( defined($+{dst}) ) { + $tzsuffix = "DST"; + } + + if ( defined($+{rest}) ) { + $tzrest = $+{rest}; + } + + return $tzprefix.$offset.$tzsuffix.$tzrest; + } + + return $tzstr; +} + +1; \ No newline at end of file diff --git a/scripts/perl/timezones/tests.pl b/scripts/perl/timezones/tests.pl new file mode 100644 index 0000000000..3aec76ff68 --- /dev/null +++ b/scripts/perl/timezones/tests.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl +=pod +Tests to verify that the provided modifications to timezone formats produce +the correct results. The first set of tests verify the fixTzstr subroutine +converts the quoted values to something that won't make FreeSWITCH default to +UTC. + +The second set of tests confirms that those timezone changes actually produce +the correct timestamps. + +Make sure FreeSWITCH already has already loaded the timezones.conf.xml that you +want to test. + +To run tests: + +TIMEZONES_XML_PATH=path/to/timezones.conf.xml prove tests.pl +=cut + +use strict; +use warnings; +use Test::More; +use ESL; +use XML::LibXML::Reader; + +require "./fix-tzstr.pl"; + +use Env qw(TIMEZONES_XML_PATH); +die "The TIMEZONES_XML_PATH environment variable must be set to test timezones." unless ( defined($TIMEZONES_XML_PATH) ); + +ok( fixTzstr("<-02>2", "doesntmatterhere") eq "STD2" ); +ok( fixTzstr("EST5EDT,M3.2.0,M11.1.0", "US/Eastern") eq "EST5EDT,M3.2.0,M11.1.0" ); +ok( fixTzstr("<+11>-11", "GMT-11") eq "GMT-11" ); +ok( fixTzstr("<-02>2<-01>,M3.5.0/-1,M10.5.0/0", "America/Godthab") eq "STD2DST,M3.5.0/-1,M10.5.0/0" ); + +my $test_count = 4; + +my $tz_fmt = "%Y-%m-%d %H:%M:%S"; +my $c = new ESL::ESLconnection("127.0.0.1", "8021", "ClueCon"); +$c->api("reloadxml")->getBody(); +my $epoch = $c->api("strepoch")->getBody(); +run_tests($epoch); +run_tests("1699613236"); # testing DST, add more epochs as needed + +sub run_tests { + my $epoch = shift; + my $reader = XML::LibXML::Reader->new(location => $TIMEZONES_XML_PATH); + while ($reader->read) { + my $tag = $reader; + if ( $tag->name eq "zone" && $tag->hasAttributes() ) { + my $zn = $tag->getAttribute("name"); + + my $cmd = `TZ='$zn' date +'$tz_fmt' --date='\@$epoch'`; + my $sys_time = $cmd =~ s/\n//r; + my $fs_time = $c->api("strftime_tz $zn $epoch|$tz_fmt")->getBody(); + + ok ( $sys_time eq $fs_time, $zn ) or diag( + " (sys) $sys_time\t(fs) $fs_time" + ); + + $test_count++; + } + } +} + +done_testing($test_count); \ No newline at end of file diff --git a/scripts/perl/timezone-gen.pl b/scripts/perl/timezones/timezone-gen.pl similarity index 90% rename from scripts/perl/timezone-gen.pl rename to scripts/perl/timezones/timezone-gen.pl index e812023ef0..86822cc553 100755 --- a/scripts/perl/timezone-gen.pl +++ b/scripts/perl/timezones/timezone-gen.pl @@ -1,10 +1,12 @@ #!/usr/bin/perl use strict; +use warnings; use Getopt::Long; use XML::Entities; use HTML::Entities; +require "./fix-tzstr.pl"; my $base = "/usr/share/zoneinfo"; my $output = "timezones.conf.xml"; @@ -18,7 +20,7 @@ my $res = GetOptions( "base=s" => \$base, "debug+" => \$debug, "help" => \$help, - "output" => \$output + "output=s" => \$output ); if ( !$res || $help ) { print "$0 [--base=/usr/share/zoneinfo] [--output=timezones.conf.xml] [--debug] [--help]\n"; @@ -64,7 +66,9 @@ foreach my $name ( sort( keys(%name_to_file) ) ) { next; } - $zones{$name} = pop(@strings); + my $tzstr = fixTzstr( pop(@strings), $name ); + + $zones{$name} = $tzstr; } open( my $out, ">$output" ); @@ -83,7 +87,7 @@ foreach my $zone ( sort( keys(%zones) ) ) { } $lastprefix = $newprefix; - print $out "\t\n"; + print $out " " x 8, "\n"; } print $out " " x 4, "\n"; print $out "\n"; diff --git a/src/fs_encode.c b/src/fs_encode.c index 235a5d9f11..527dc3eeff 100644 --- a/src/fs_encode.c +++ b/src/fs_encode.c @@ -46,7 +46,7 @@ #pragma warning (disable:167) #endif -static void fs_encode_cleanup() +static void fs_encode_cleanup(void) { switch_safe_free(SWITCH_GLOBAL_dirs.conf_dir); switch_safe_free(SWITCH_GLOBAL_dirs.mod_dir); diff --git a/src/fs_tts.c b/src/fs_tts.c index 2a963ee68e..6632e86566 100644 --- a/src/fs_tts.c +++ b/src/fs_tts.c @@ -46,7 +46,7 @@ #pragma warning (disable:167) #endif -static void fs_tts_cleanup() +static void fs_tts_cleanup(void) { switch_safe_free(SWITCH_GLOBAL_dirs.conf_dir); switch_safe_free(SWITCH_GLOBAL_dirs.mod_dir); diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index af6a4f53bd..fafaae3cba 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -310,7 +310,7 @@ extern struct switch_session_manager session_manager; switch_status_t switch_core_sqldb_init(const char **err); -void switch_core_sqldb_destroy(); +void switch_core_sqldb_destroy(void); switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_t manage); void switch_core_sqldb_stop(void); void switch_core_session_init(switch_memory_pool_t *pool); diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index ee927e6db9..352e399d2a 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -325,6 +325,24 @@ SWITCH_DECLARE(switch_status_t) switch_channel_get_scope_variables(switch_channe SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup, int idx); #define switch_channel_get_variable(_c, _v) switch_channel_get_variable_dup(_c, _v, SWITCH_TRUE, -1) +/*! + \brief Retrieve a copy of a variable from a given channel. switch_safe_free() call will be required. + \param channel channel to retrieve variable from + \param varname the name of the variable + \return a strdup copy the value of the requested variable without using a memory pool. +*/ +SWITCH_DECLARE(const char *) switch_channel_get_variable_strdup(switch_channel_t *channel, const char *varname); + +/*! + \brief Retrieve a variable from a given channel to a pre-allocated buffer without using a memory pool. + \param channel channel to retrieve variable from + \param varname the name of the variable + \param buf a pre allocated buffer to put the value to + \param buflen size of the buffer + \return SWITCH_STATUS_SUCCESS if the value was copied to the buffer and it is not NULL, SWITCH_STATUS_FALSE otherwise. +*/ +SWITCH_DECLARE(switch_status_t) switch_channel_get_variable_buf(switch_channel_t *channel, const char *varname, char *buf, switch_size_t buflen); + SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event); SWITCH_DECLARE(switch_status_t) switch_channel_get_variables_prefix(switch_channel_t *channel, const char *prefix, switch_event_t **event); SWITCH_DECLARE(switch_status_t) switch_channel_pass_callee_id(switch_channel_t *channel, switch_channel_t *other_channel); diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 8694a0bc88..1c1c321cb3 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -399,6 +399,10 @@ SWITCH_DECLARE(void) switch_core_media_set_smode(switch_core_session_t *session, SWITCH_DECLARE(void) switch_core_media_set_resolveice(switch_bool_t resolve_ice); SWITCH_DECLARE(switch_bool_t) switch_core_media_has_resolveice(void); +typedef struct switch_rtp_engine_s switch_rtp_engine_t; +SWITCH_DECLARE(switch_rtp_engine_t *) switch_core_media_get_engine(switch_core_session_t *session, int media_type); +SWITCH_DECLARE(switch_codec_t*) switch_core_media_get_codec(switch_core_session_t *session, switch_media_type_t type); + SWITCH_END_EXTERN_C #endif /* For Emacs: diff --git a/src/include/switch_core_video.h b/src/include/switch_core_video.h index 1af0dec7ac..f65c322d30 100644 --- a/src/include/switch_core_video.h +++ b/src/include/switch_core_video.h @@ -448,7 +448,7 @@ SWITCH_DECLARE(switch_status_t) switch_img_to_raw(switch_image_t *src, void *des * \param[in] width The raw data width * \param[in] height The raw data height */ -SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void *src, switch_img_fmt_t fmt, int width, int height); +SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t** destP, void *src, switch_img_fmt_t fmt, int width, int height); SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_bool_t full, const char *text); SWITCH_DECLARE(switch_image_t *) switch_img_read_file(const char* file_name); diff --git a/src/include/switch_curl.h b/src/include/switch_curl.h index 5872527865..bad116daf2 100644 --- a/src/include/switch_curl.h +++ b/src/include/switch_curl.h @@ -40,6 +40,9 @@ typedef int switch_CURLINFO; typedef int switch_CURLcode; typedef int switch_CURLoption; +#define HAVE_SWITCH_CURL_MIME +typedef void switch_curl_mime; + SWITCH_DECLARE(switch_CURL *) switch_curl_easy_init(void); SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_perform(switch_CURL *handle); SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_getinfo(switch_CURL *curl, switch_CURLINFO info, ... ); @@ -50,7 +53,9 @@ SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_setopt(CURL *handle, switch_CUR SWITCH_DECLARE(const char *) switch_curl_easy_strerror(switch_CURLcode errornum ); SWITCH_DECLARE(void) switch_curl_init(void); SWITCH_DECLARE(void) switch_curl_destroy(void); -SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_event_t *event, switch_CURL *curl_handle, struct curl_httppost **formpostp); +SWITCH_DECLARE(switch_status_t) switch_curl_process_mime(switch_event_t *event, switch_CURL *curl_handle, switch_curl_mime **mimep); +SWITCH_DECLARE(void) switch_curl_mime_free(switch_curl_mime **mimep); +SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_setopt_mime(switch_CURL *curl_handle, switch_curl_mime *mime); #define switch_curl_easy_setopt curl_easy_setopt SWITCH_END_EXTERN_C diff --git a/src/include/switch_jitterbuffer.h b/src/include/switch_jitterbuffer.h index bee0fa02f8..f098ede2db 100644 --- a/src/include/switch_jitterbuffer.h +++ b/src/include/switch_jitterbuffer.h @@ -61,6 +61,7 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp SWITCH_DECLARE(uint32_t) switch_jb_pop_nack(switch_jb_t *jb); SWITCH_DECLARE(switch_status_t) switch_jb_get_packet_by_seq(switch_jb_t *jb, uint16_t seq, switch_rtp_packet_t *packet, switch_size_t *len); SWITCH_DECLARE(void) switch_jb_set_session(switch_jb_t *jb, switch_core_session_t *session); +SWITCH_DECLARE(void) switch_jb_set_jitter_estimator(switch_jb_t *jb, double *jitter, uint32_t samples_per_frame, uint32_t samples_per_second); SWITCH_DECLARE(void) switch_jb_ts_mode(switch_jb_t *jb, uint32_t samples_per_frame, uint32_t samples_per_second); SWITCH_DECLARE(void) switch_jb_set_flag(switch_jb_t *jb, switch_jb_flag_t flag); SWITCH_DECLARE(void) switch_jb_clear_flag(switch_jb_t *jb, switch_jb_flag_t flag); diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index 7c54ed67df..ddaaf120a1 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -676,8 +676,14 @@ struct switch_codec_fmtp { int bits_per_second; /*! number of microseconds of media in one packet (ptime * 1000) */ int microseconds_per_packet; - /*! stereo */ - int stereo; + /*! maximum ptime in ms */ + int max_ptime; + /*! minimum ptime in ms */ + int min_ptime; + /*! stereo, typically bidirectional */ + int stereo; + /* sender properties (stereo) */ + int sprop_stereo; /*! private data for the codec module to store handle specific info */ void *private_info; diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index ca915cf77a..dfcad5453c 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -106,12 +106,13 @@ typedef struct icand_s { } icand_t; #define MAX_CAND 50 +#define MAX_CAND_IDX_COUNT 2 typedef struct ice_s { - icand_t cands[MAX_CAND][2]; - int cand_idx[2]; - int chosen[2]; - int is_chosen[2]; + icand_t cands[MAX_CAND][MAX_CAND_IDX_COUNT]; + int cand_idx[MAX_CAND_IDX_COUNT]; + int chosen[MAX_CAND_IDX_COUNT]; + int is_chosen[MAX_CAND_IDX_COUNT]; char *ufrag; char *pwd; char *options; diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 7b519899af..94a4c62cca 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -2249,7 +2249,8 @@ typedef enum { SWITCH_CAUSE_BAD_IDENTITY_INFO = 821, SWITCH_CAUSE_UNSUPPORTED_CERTIFICATE = 822, SWITCH_CAUSE_INVALID_IDENTITY = 823, - SWITCH_CAUSE_STALE_DATE = 824 + SWITCH_CAUSE_STALE_DATE = 824, + SWITCH_CAUSE_REJECT_ALL = 825 } switch_call_cause_t; typedef enum { @@ -2424,6 +2425,7 @@ typedef enum { SCC_VIDEO_RESET, SCC_AUDIO_PACKET_LOSS, SCC_AUDIO_ADJUST_BITRATE, + SCC_AUDIO_VAD, SCC_DEBUG, SCC_CODEC_SPECIFIC } switch_codec_control_command_t; diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 62f3fcd97e..1d33939f4c 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -498,6 +498,14 @@ SWITCH_DECLARE(switch_size_t) switch_fp_read_dline(FILE *fd, char **buf, switch_ SWITCH_DECLARE(switch_status_t) switch_frame_alloc(switch_frame_t **frame, switch_size_t size); SWITCH_DECLARE(switch_status_t) switch_frame_dup(switch_frame_t *orig, switch_frame_t **clone); SWITCH_DECLARE(switch_status_t) switch_frame_free(switch_frame_t **frame); + +/*! \brief Check if a 32 bit unsigned number is in a range. + * \param str string to check. Should not contain non-digit characters. + * \param from start of range including this number + * \param to end of range including this number + * \return true or false + */ +SWITCH_DECLARE(switch_bool_t) switch_is_uint_in_range(const char *str, unsigned int from, unsigned int to); SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str); SWITCH_DECLARE(switch_bool_t) switch_is_leading_number(const char *str); SWITCH_DECLARE(char *) switch_find_parameter(const char *str, const char *param, switch_memory_pool_t *pool); diff --git a/src/include/test/switch_fct.h b/src/include/test/switch_fct.h index 8cb07cc20f..b28feabb74 100644 --- a/src/include/test/switch_fct.h +++ b/src/include/test/switch_fct.h @@ -255,7 +255,7 @@ fctstr_safe_cpy(char *dst, char const *src, size_t num) #if defined(WIN32) && _MSC_VER >= 1400 strncpy_s(dst, num, src, _TRUNCATE); #else - strncpy(dst, src, num); + strncpy(dst, src, num - 1); #endif dst[num-1] = '\0'; } @@ -760,6 +760,7 @@ fct_nlist__init2(fct_nlist_t *list, size_t start_sz) list->itm_list = (void**)malloc(sizeof(void*)*start_sz); if ( list->itm_list == NULL ) { + list->used_itm_num = 0; return 0; } } diff --git a/src/mod/applications/mod_av/avcodec.c b/src/mod/applications/mod_av/avcodec.c index a9f6d0927e..16d268273b 100644 --- a/src/mod/applications/mod_av/avcodec.c +++ b/src/mod/applications/mod_av/avcodec.c @@ -26,6 +26,7 @@ * Seven Du * Anthony Minessale * Emmanuel Schmidbauer + * Jakub Karolczyk * * mod_avcodec -- Codec with libav.org and ffmpeg * @@ -34,6 +35,9 @@ #include #include "mod_av.h" #include +#ifdef _MSC_VER +#include /* LIBAVCODEC_VERSION_INT */ +#endif #include #include #include @@ -373,8 +377,13 @@ typedef struct our_h264_nalu_s { typedef struct h264_codec_context_s { switch_buffer_t *nalu_buffer; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) AVCodec *decoder; AVCodec *encoder; +#else + const AVCodec *decoder; + const AVCodec *encoder; +#endif AVCodecContext *decoder_ctx; int got_pps; /* if pps packet received */ int64_t pts; @@ -393,12 +402,13 @@ typedef struct h264_codec_context_s { switch_codec_settings_t codec_settings; AVCodecContext *encoder_ctx; AVFrame *encoder_avframe; - AVPacket encoder_avpacket; + AVPacket *encoder_avpacket; AVFrame *decoder_avframe; our_h264_nalu_t nalus[MAX_NALUS]; enum AVCodecID av_codec_id; uint16_t last_seq; // last received frame->seq int hw_encoder; + switch_packetizer_t *packetizer; } h264_codec_context_t; #ifndef AV_INPUT_BUFFER_PADDING_SIZE @@ -825,7 +835,11 @@ static void fs_rtp_parse_h263_rfc2190(h264_codec_context_t *context, AVPacket *p const uint8_t *p = buf; const uint8_t *buf_base = buf; uint32_t code = (ntohl(*(uint32_t *)buf) & 0xFFFFFC00) >> 10; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) int mb_info_size = 0; +#else + switch_size_t mb_info_size = 0; +#endif int mb_info_pos = 0, mb_info_count = 0; const uint8_t *mb_info; @@ -889,7 +903,11 @@ static void fs_rtp_parse_h263_rfc2190(h264_codec_context_t *context, AVPacket *p "Unable to split H263 packet! mb_info_pos=%d mb_info_count=%d pos=%d max=%"SWITCH_SIZE_T_FMT"\n", mb_info_pos, mb_info_count, pos, (switch_size_t)(end - buf_base)); } } else { +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Should Not Happen!!! mb_info_pos=%d mb_info_count=%d mb_info_size=%d\n", mb_info_pos, mb_info_count, mb_info_size); +#else + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Should Not Happen!!! mb_info_pos=%d mb_info_count=%d mb_info_size=%ld\n", mb_info_pos, mb_info_count, mb_info_size); +#endif } } } @@ -1033,7 +1051,7 @@ static switch_status_t consume_h263_bitstream(h264_codec_context_t *context, swi } if (!context->nalus[context->nalu_current_index].len) { - av_packet_unref(&context->encoder_avpacket); + av_packet_unref(context->encoder_avpacket); frame->m = 1; } @@ -1081,81 +1099,27 @@ static switch_status_t consume_h263p_bitstream(h264_codec_context_t *context, sw #endif if (frame->m) { - av_packet_unref(&context->encoder_avpacket); + av_packet_unref(context->encoder_avpacket); return SWITCH_STATUS_SUCCESS; } return SWITCH_STATUS_MORE_DATA; } -static switch_status_t consume_h264_bitstream(h264_codec_context_t *context, switch_frame_t *frame) -{ - AVPacket *pkt = &context->encoder_avpacket; - our_h264_nalu_t *nalu = &context->nalus[context->nalu_current_index]; - uint8_t nalu_hdr = *(uint8_t *)(nalu->start); - uint8_t nalu_type = nalu_hdr & 0x1f; - uint8_t nri = nalu_hdr & 0x60; - int left = nalu->len - (nalu->eat - nalu->start); - uint8_t *p = frame->data; - uint8_t start = nalu->start == nalu->eat ? 0x80 : 0; - int n = nalu->len / SLICE_SIZE; - int slice_size = nalu->len / (n + 1) + 1 + 2; - - if (nalu->len <= SLICE_SIZE) { - memcpy(frame->data, nalu->start, nalu->len); - frame->datalen = nalu->len; - context->nalu_current_index++; - - if (context->nalus[context->nalu_current_index].len) { - frame->m = 0; - return SWITCH_STATUS_MORE_DATA; - } - - if (pkt->size > 0) av_packet_unref(pkt); - - switch_clear_flag(frame, SFF_CNG); - frame->m = 1; - - return SWITCH_STATUS_SUCCESS; - } - - if (left <= (slice_size - 2)) { - p[0] = nri | 28; // FU-A - p[1] = 0x40 | nalu_type; - memcpy(p+2, nalu->eat, left); - nalu->eat += left; - frame->datalen = left + 2; - context->nalu_current_index++; - - if (!context->nalus[context->nalu_current_index].len) { - if (pkt->size > 0) av_packet_unref(pkt); - frame->m = 1; - return SWITCH_STATUS_SUCCESS; - } - - return SWITCH_STATUS_MORE_DATA; - } - - p[0] = nri | 28; // FU-A - p[1] = start | nalu_type; - if (start) nalu->eat++; - memcpy(p+2, nalu->eat, slice_size - 2); - nalu->eat += (slice_size - 2); - frame->datalen = slice_size; - frame->m = 0; - return SWITCH_STATUS_MORE_DATA; -} - static switch_status_t consume_nalu(h264_codec_context_t *context, switch_frame_t *frame) { - AVPacket *pkt = &context->encoder_avpacket; + AVPacket *pkt = context->encoder_avpacket; our_h264_nalu_t *nalu = &context->nalus[context->nalu_current_index]; if (!nalu->len) { frame->datalen = 0; frame->m = 0; - if (pkt->size > 0) av_packet_unref(pkt); + if (pkt->size > 0) { + av_packet_unref(pkt); + } + context->nalu_current_index = 0; + return SWITCH_STATUS_NOTFOUND; } @@ -1167,7 +1131,9 @@ static switch_status_t consume_nalu(h264_codec_context_t *context, switch_frame_ return consume_h263p_bitstream(context, frame); } - return consume_h264_bitstream(context, frame); + switch_assert(0); + + return SWITCH_STATUS_FALSE; } static void set_h264_private_data(h264_codec_context_t *context, avcodec_profile_t *profile) @@ -1342,9 +1308,7 @@ FF_ENABLE_DEPRECATION_WARNINGS set_h264_private_data(context, aprofile); } -GCC_DIAG_OFF(deprecated-declarations) avcodec_string(codec_string, sizeof(codec_string), context->encoder_ctx, 0); -GCC_DIAG_ON(deprecated-declarations) dump_encoder_ctx(context->encoder_ctx); @@ -1436,6 +1400,16 @@ static switch_status_t switch_h264_init(switch_codec_t *codec, switch_codec_flag } } + switch (context->av_codec_id) { + case AV_CODEC_ID_H264: + context->packetizer = switch_packetizer_create(SPT_H264_BITSTREAM, SLICE_SIZE); + break; + default: + break; + } + + context->encoder_avpacket = av_packet_alloc(); + switch_buffer_create_dynamic(&(context->nalu_buffer), H264_NALU_BUFFER_SIZE, H264_NALU_BUFFER_SIZE * 8, 0); codec->private_info = context; @@ -1460,7 +1434,7 @@ static switch_status_t switch_h264_encode(switch_codec_t *codec, switch_frame_t int ret; int *got_output = &context->got_encoded_output; AVFrame *avframe = NULL; - AVPacket *pkt = &context->encoder_avpacket; + AVPacket **pkt = &context->encoder_avpacket; uint32_t width = 0; uint32_t height = 0; switch_image_t *img = frame->img; @@ -1480,6 +1454,16 @@ static switch_status_t switch_h264_encode(switch_codec_t *codec, switch_frame_t } if (frame->flags & SFF_SAME_IMAGE) { + if (context->packetizer) { + switch_status_t status = switch_packetizer_read(context->packetizer, frame); + + if (status == SWITCH_STATUS_SUCCESS && (*pkt)->size > 0) { + av_packet_unref(*pkt); + } + + return status; + } + // read from nalu buffer return consume_nalu(context, frame); } @@ -1489,6 +1473,7 @@ static switch_status_t switch_h264_encode(switch_codec_t *codec, switch_frame_t if (open_encoder(context, width, height) != SWITCH_STATUS_SUCCESS) { goto error; } + avctx = context->encoder_ctx; } @@ -1498,6 +1483,7 @@ static switch_status_t switch_h264_encode(switch_codec_t *codec, switch_frame_t if (open_encoder(context, width, height) != SWITCH_STATUS_SUCCESS) { goto error; } + avctx = context->encoder_ctx; } @@ -1507,13 +1493,13 @@ static switch_status_t switch_h264_encode(switch_codec_t *codec, switch_frame_t if (open_encoder(context, width, height) != SWITCH_STATUS_SUCCESS) { goto error; } + avctx = context->encoder_ctx; switch_set_flag(frame, SFF_WAIT_KEY_FRAME); } - av_init_packet(pkt); - pkt->data = NULL; // packet data will be allocated by the encoder - pkt->size = 0; + av_packet_unref(*pkt); + /* packet data will be allocated by the encoder */ avframe = context->encoder_avframe; @@ -1578,14 +1564,42 @@ static switch_status_t switch_h264_encode(switch_codec_t *codec, switch_frame_t /* encode the image */ memset(context->nalus, 0, sizeof(context->nalus)); context->nalu_current_index = 0; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) GCC_DIAG_OFF(deprecated-declarations) - ret = avcodec_encode_video2(avctx, pkt, avframe, got_output); + ret = avcodec_encode_video2(avctx, *pkt, avframe, got_output); GCC_DIAG_ON(deprecated-declarations) if (ret < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoding Error %d\n", ret); goto error; } +#else + ret = avcodec_send_frame(avctx, avframe); + + if (ret == AVERROR_EOF) { + ret = 0; + } else if (ret == AVERROR(EAGAIN)) { + /* we fully drain all the output in each encode call, so this should not ever happen */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending frame to encoder - BUG, should never happen\n"); + ret = AVERROR_BUG; + goto error; + } else if (ret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error sending frame to encoder\n"); + goto error; + } + + while (ret >= 0) { + ret = avcodec_receive_packet(avctx, *pkt); + if (ret == AVERROR(EAGAIN)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video packets at the moment\n"); + } else if (ret == AVERROR_EOF) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video packets at all\n"); + } else if (ret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoding error\n"); + av_packet_unref(*pkt); + goto error; + } +#endif if (context->need_key_frame && avframe->key_frame == 1) { avframe->pict_type = 0; @@ -1595,81 +1609,78 @@ GCC_DIAG_ON(deprecated-declarations) // process: +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) if (*got_output) { - const uint8_t *p = pkt->data; - int i = 0; +#else + if (ret >= 0) { +#endif + switch_status_t status = SWITCH_STATUS_SUCCESS; *got_output = 0; if (context->av_codec_id == AV_CODEC_ID_H263) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG5, "Encoded frame %" SWITCH_INT64_T_FMT " (size=%5d) [0x%02x 0x%02x 0x%02x 0x%02x] got_output: %d slices: %d\n", - context->pts, pkt->size, *((uint8_t *)pkt->data), *((uint8_t *)(pkt->data + 1)), *((uint8_t *)(pkt->data + 2)), - *((uint8_t *)(pkt->data + 3)), *got_output, avctx->slices); + context->pts, (*pkt)->size, *((uint8_t *)(*pkt)->data), *((uint8_t *)((*pkt)->data + 1)), *((uint8_t *)((*pkt)->data + 2)), + *((uint8_t *)((*pkt)->data + 3)), *got_output, avctx->slices); #ifdef H263_MODE_B - fs_rtp_parse_h263_rfc2190(context, pkt); + fs_rtp_parse_h263_rfc2190(context, *pkt); #endif context->nalu_current_index = 0; + return consume_nalu(context, frame); } else if (context->av_codec_id == AV_CODEC_ID_H263P){ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG5, "Encoded frame %" SWITCH_INT64_T_FMT " (size=%5d) [0x%02x 0x%02x 0x%02x 0x%02x] got_output: %d slices: %d\n", - context->pts, pkt->size, *((uint8_t *)pkt->data), *((uint8_t *)(pkt->data + 1)), *((uint8_t *)(pkt->data + 2)), - *((uint8_t *)(pkt->data + 3)), *got_output, avctx->slices); - fs_rtp_parse_h263_rfc4629(context, pkt); + context->pts, (*pkt)->size, *((uint8_t *)(*pkt)->data), *((uint8_t *)((*pkt)->data + 1)), *((uint8_t *)((*pkt)->data + 2)), + *((uint8_t *)((*pkt)->data + 3)), *got_output, avctx->slices); + fs_rtp_parse_h263_rfc4629(context, *pkt); context->nalu_current_index = 0; + return consume_nalu(context, frame); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG5, "Encoded frame %" SWITCH_INT64_T_FMT " (size=%5d) nalu_type=0x%x %d\n", - context->pts, pkt->size, *((uint8_t *)pkt->data +4), *got_output); - } - /* split into nalus */ - memset(context->nalus, 0, sizeof(context->nalus)); - - while ((p = fs_avc_find_startcode(p, pkt->data+pkt->size)) < (pkt->data + pkt->size)) { - if (!context->nalus[i].start) { - while (!(*p++)) ; /* eat the sync bytes, what ever 0 0 1 or 0 0 0 1 */ - context->nalus[i].start = p; - context->nalus[i].eat = p; - - if ((*p & 0x1f) == 7) { // Got Keyframe - // prevent to generate key frame too frequently - context->last_keyframe_request = switch_time_now(); - if (mod_av_globals.debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "KEY FRAME GENERATED\n"); - } - } - } else { - context->nalus[i].len = p - context->nalus[i].start; - while (!(*p++)) ; /* eat the sync bytes, what ever 0 0 1 or 0 0 0 1 */ - i++; - context->nalus[i].start = p; - context->nalus[i].eat = p; - } - if (i >= MAX_NALUS - 2) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "TOO MANY SLICES!\n"); - break; - } + context->pts, (*pkt)->size, *((uint8_t *)(*pkt)->data +4), *got_output); } - context->nalus[i].len = p - context->nalus[i].start; - context->nalu_current_index = 0; - return consume_nalu(context, frame); + status = switch_packetizer_feed(context->packetizer, (*pkt)->data, (*pkt)->size); + if (status != SWITCH_STATUS_SUCCESS) { + if ((*pkt)->size > 0) { + av_packet_unref(*pkt); + } + + return status; + } + + status = switch_packetizer_read(context->packetizer, frame); + if (status == SWITCH_STATUS_SUCCESS && (*pkt)->size > 0) { + av_packet_unref(*pkt); + } + + return status; } +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + break; + } +#endif + error: frame->datalen = 0; + return SWITCH_STATUS_FALSE; } static switch_status_t switch_h264_decode(switch_codec_t *codec, switch_frame_t *frame) { h264_codec_context_t *context = (h264_codec_context_t *)codec->private_info; - AVCodecContext *avctx= context->decoder_ctx; switch_status_t status; +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + int ret = 0; +#endif switch_assert(frame); @@ -1702,27 +1713,57 @@ static switch_status_t switch_h264_decode(switch_codec_t *codec, switch_frame_t if (frame->m) { uint32_t size = switch_buffer_inuse(context->nalu_buffer); - AVPacket pkt = { 0 }; + AVPacket *pkt = NULL; AVFrame *picture; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) int got_picture = 0; int decoded_len; +#endif if (size > 0) { - av_init_packet(&pkt); + pkt = av_packet_alloc(); switch_buffer_zero_fill(context->nalu_buffer, AV_INPUT_BUFFER_PADDING_SIZE); - switch_buffer_peek_zerocopy(context->nalu_buffer, (const void **)&pkt.data); - pkt.size = size; + switch_buffer_peek_zerocopy(context->nalu_buffer, (const void **)&pkt->data); + pkt->size = size; if (!context->decoder_avframe) context->decoder_avframe = av_frame_alloc(); picture = context->decoder_avframe; switch_assert(picture); +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) GCC_DIAG_OFF(deprecated-declarations) - decoded_len = avcodec_decode_video2(avctx, picture, &got_picture, &pkt); + decoded_len = avcodec_decode_video2(context->decoder_ctx, picture, &got_picture, pkt); GCC_DIAG_ON(deprecated-declarations) +#else + ret = avcodec_send_packet(context->decoder_ctx, pkt); + + if (ret == AVERROR_EOF) { + ret = 0; + } else if (ret == AVERROR(EAGAIN)) { + /* we fully drain all the output in each decode call, so this should not ever happen */ + ret = AVERROR_BUG; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error sending packet to decoder BUG, should never happen\n"); + } else if (ret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error sending packet to decoder\n"); + } + + while (ret >= 0) { + ret = avcodec_receive_frame(context->decoder_ctx, picture); + if (ret == AVERROR(EAGAIN)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video frames at the moment\n"); + } else if (ret == AVERROR_EOF) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video frames at all\n"); + } else if (ret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Video decoding error\n"); + } +#endif // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer: %d got pic: %d len: %d [%dx%d]\n", size, got_picture, decoded_len, picture->width, picture->height); +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) if (got_picture && decoded_len > 0) { +#else + if (ret >= 0) { +#endif int width = picture->width; int height = picture->height; @@ -1744,7 +1785,15 @@ GCC_DIAG_ON(deprecated-declarations) frame->img = context->img; } +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + if (ret < 0) { + break; + } + } +#endif + av_frame_unref(picture); + av_packet_free(&pkt); } switch_buffer_zero(context->nalu_buffer); @@ -1825,6 +1874,10 @@ static switch_status_t switch_h264_destroy(switch_codec_t *codec) av_free(context->encoder_ctx); } + if (context->packetizer) { + switch_packetizer_close(&context->packetizer); + } + if (context->encoder_avframe) { av_frame_free(&context->encoder_avframe); } @@ -1833,6 +1886,10 @@ static switch_status_t switch_h264_destroy(switch_codec_t *codec) av_frame_free(&context->decoder_avframe); } + if (context->encoder_avpacket) { + av_packet_free(&context->encoder_avpacket); + } + return SWITCH_STATUS_SUCCESS; } @@ -1860,8 +1917,10 @@ static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev, #endif if (prev->id == id && (encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev))) + return prev; } + return NULL; } @@ -2208,7 +2267,7 @@ static void parse_codecs(avcodec_profile_t *aprofile, switch_xml_t codecs) } -static void load_config() +static void load_config(void) { switch_xml_t cfg = NULL, xml = NULL; diff --git a/src/mod/applications/mod_av/avformat.c b/src/mod/applications/mod_av/avformat.c index a791665c08..69475c169f 100644 --- a/src/mod/applications/mod_av/avformat.c +++ b/src/mod/applications/mod_av/avformat.c @@ -25,6 +25,7 @@ * * Seven Du * Anthony Minessale + * Jakub Karolczyk * * mod_avformat -- File Formats with libav.org * @@ -34,7 +35,13 @@ #include "mod_av.h" GCC_DIAG_OFF(deprecated-declarations) #include +#ifdef _MSC_VER +#include /* LIBAVCODEC_VERSION_INT */ +#endif #include +#ifdef _MSC_VER +#include /* LIBAVFORMAT_VERSION_INT */ +#endif #include #include #include @@ -88,7 +95,9 @@ typedef struct MediaStream { AVStream *st; AVFrame *frame; AVFrame *tmp_frame; - +#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_V) + AVCodecContext *codec; +#endif // audio int channels; int sample_rate; @@ -137,8 +146,13 @@ struct av_file_context { MediaStream video_st; MediaStream audio_st[2]; AVFormatContext *fc; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) AVCodec *audio_codec; AVCodec *video_codec; +#else + const AVCodec *audio_codec; + const AVCodec *video_codec; +#endif enum AVColorSpace colorspace; int has_audio; @@ -220,9 +234,57 @@ static inline char *av_ts_make_time_string(char *buf, int64_t ts, AVRational *tb static switch_status_t av_file_close(switch_file_handle_t *handle); SWITCH_MODULE_LOAD_FUNCTION(mod_avformat_load); +static inline AVCodecContext *av_get_codec_context(MediaStream *stream) +{ + AVCodecContext *c = NULL; + +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) +GCC_DIAG_OFF(deprecated-declarations) + if (stream->st) { + c = stream->st->codec; + } +GCC_DIAG_ON(deprecated-declarations) +#else + c = stream->codec; +#endif + + return c; +} + +static inline enum AVCodecID av_get_codec_id(AVStream *av_stream) +{ + if (!av_stream) { + return AV_CODEC_ID_NONE; + } + +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) +GCC_DIAG_OFF(deprecated-declarations) + return av_stream->codec->codec_id; +GCC_DIAG_ON(deprecated-declarations) +#else + return av_stream->codecpar->codec_id; +#endif +} + +static inline enum AVMediaType av_get_codec_type(AVStream *av_stream) +{ + if (!av_stream) { + return AVMEDIA_TYPE_UNKNOWN; + } + +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) +GCC_DIAG_OFF(deprecated-declarations) + return av_stream->codec->codec_type; +GCC_DIAG_ON(deprecated-declarations) +#else + return av_stream->codecpar->codec_type; +#endif +} + static char *const get_error_text(const int error, char *error_buffer, switch_size_t error_buflen) { av_strerror(error, error_buffer, error_buflen); + return error_buffer; } @@ -354,18 +416,24 @@ static int interrupt_cb(void *cp) } -static int mod_avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat, - const char *format, const char *filename, av_file_context_t *context) +static int mod_avformat_alloc_output_context2(AVFormatContext **avctx, const char *format, const char *filename, av_file_context_t *context) { AVFormatContext *s = avformat_alloc_context(); int ret = 0; +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) + AVOutputFormat *oformat = NULL; +#else + const AVOutputFormat *oformat = NULL; +#endif + s->interrupt_callback.callback = interrupt_cb; s->interrupt_callback.opaque = context; - + *avctx = NULL; - if (!s) + if (!s) { goto nomem; + } if (!oformat) { if (format) { @@ -389,14 +457,17 @@ static int mod_avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputF s->oformat = oformat; if (s->oformat->priv_data_size > 0) { s->priv_data = av_mallocz(s->oformat->priv_data_size); - if (!s->priv_data) + if (!s->priv_data) { goto nomem; + } + if (s->oformat->priv_class) { *(const AVClass**)s->priv_data= s->oformat->priv_class; av_opt_set_defaults(s->priv_data); } - } else + } else { s->priv_data = NULL; + } if (filename) { #if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,7,100)) @@ -408,12 +479,14 @@ static int mod_avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputF } *avctx = s; + return 0; nomem: av_log(s, AV_LOG_ERROR, "Out of memory\n"); ret = AVERROR(ENOMEM); error: avformat_free_context(s); + return ret; } @@ -429,9 +502,13 @@ static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AV } /* Add an output stream. */ +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) static switch_status_t add_stream(av_file_context_t *context, MediaStream *mst, AVFormatContext *fc, AVCodec **codec, enum AVCodecID codec_id, switch_mm_t *mm) +#else +static switch_status_t add_stream(av_file_context_t *context, MediaStream *mst, AVFormatContext *fc, const AVCodec **codec, enum AVCodecID codec_id, switch_mm_t *mm) +#endif { - AVCodecContext *c; + AVCodecContext *c = NULL; switch_status_t status = SWITCH_STATUS_FALSE; //int threads = switch_core_cpu_count(); int buffer_bytes = 2097152; /* 2 mb */ @@ -457,9 +534,19 @@ static switch_status_t add_stream(av_file_context_t *context, MediaStream *mst, return status; } mst->st->id = fc->nb_streams - 1; -GCC_DIAG_OFF(deprecated-declarations) - c = mst->st->codec; -GCC_DIAG_ON(deprecated-declarations) + +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + mst->codec = avcodec_alloc_context3(*codec); + + if (!mst->codec) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate codec context\n"); + + return status; + } +#endif + + c = av_get_codec_context(mst); + //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "id:%d den:%d num:%d\n", mst->st->id, mst->st->time_base.den, mst->st->time_base.num); //if (threads > 4) { @@ -471,8 +558,12 @@ GCC_DIAG_ON(deprecated-declarations) c->sample_fmt = (*codec)->sample_fmts ? (*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP; c->bit_rate = 128000; c->sample_rate = mst->sample_rate = context->handle->samplerate; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) c->channels = mst->channels; c->channel_layout = av_get_default_channel_layout(c->channels); +#else + av_channel_layout_default(&c->ch_layout, mst->channels); +#endif if (mm) { if (mm->ab) { @@ -651,23 +742,28 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height) return picture; } +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) static switch_status_t open_video(AVFormatContext *fc, AVCodec *codec, MediaStream *mst) +#else +static switch_status_t open_video(AVFormatContext *fc, const AVCodec *codec, MediaStream *mst) +#endif { int ret; -GCC_DIAG_OFF(deprecated-declarations) - AVCodecContext *c = mst->st->codec; -GCC_DIAG_ON(deprecated-declarations) + AVCodecContext *c = NULL; switch_status_t status = SWITCH_STATUS_FALSE; //int threads = switch_core_cpu_count(); // if (threads > 4) threads = 4; // c->thread_count = threads; + c = av_get_codec_context(mst); + /* open the codec */ ret = avcodec_open2(c, codec, NULL); if (ret < 0) { char ebuf[255] = ""; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open video codec: %s\n", get_error_text(ret, ebuf, sizeof(ebuf))); + return status; } @@ -679,17 +775,29 @@ GCC_DIAG_ON(deprecated-declarations) // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "pix_fmt: %d\n", c->pix_fmt); switch_assert(c->pix_fmt == AV_PIX_FMT_YUV420P); // always I420 for NOW +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + if (((ret = avcodec_parameters_from_context(mst->st->codecpar, mst->codec)) < 0)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not copy to codec params ret=%d\n", ret); + + return SWITCH_STATUS_FALSE; + } +#endif + return SWITCH_STATUS_SUCCESS; } +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) static switch_status_t open_audio(AVFormatContext *fc, AVCodec *codec, MediaStream *mst) +#else +static switch_status_t open_audio(AVFormatContext *fc, const AVCodec *codec, MediaStream *mst) +#endif { - AVCodecContext *c; + AVCodecContext *c = NULL; int ret; switch_status_t status = SWITCH_STATUS_FALSE; -GCC_DIAG_OFF(deprecated-declarations) - c = mst->st->codec; -GCC_DIAG_ON(deprecated-declarations) + + c = av_get_codec_context(mst); + ret = avcodec_open2(c, codec, NULL); if (ret == AVERROR_EXPERIMENTAL) { @@ -711,11 +819,19 @@ GCC_DIAG_ON(deprecated-declarations) mst->frame->sample_rate = c->sample_rate; mst->frame->format = AV_SAMPLE_FMT_S16; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) mst->frame->channel_layout = c->channel_layout; +#else + mst->frame->ch_layout = c->ch_layout; +#endif if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) { //mst->frame->nb_samples = 10000; - mst->frame->nb_samples = (mst->frame->sample_rate / 50) * c->channels; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) + mst->frame->nb_samples = (mst->frame->sample_rate / 50) * c->channels; +#else + mst->frame->nb_samples = (mst->frame->sample_rate / 50) * c->ch_layout.nb_channels; +#endif } else { mst->frame->nb_samples = c->frame_size; } @@ -733,19 +849,33 @@ GCC_DIAG_ON(deprecated-declarations) } /* set options */ +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59,27,100)) /* FFmpeg 5.0 */ av_opt_set_int(mst->resample_ctx, "in_channel_count", c->channels, 0); +#else /* FFmpeg 5.1 */ + av_opt_set_chlayout(mst->resample_ctx, "in_chlayout", &c->ch_layout, 0); +#endif av_opt_set_int(mst->resample_ctx, "in_sample_rate", c->sample_rate, 0); +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59,27,100)) av_opt_set_int(mst->resample_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0); av_opt_set_int(mst->resample_ctx, "in_channel_layout", c->channel_layout, 0); av_opt_set_int(mst->resample_ctx, "out_channel_count", c->channels, 0); +#else + av_opt_set_sample_fmt(mst->resample_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0); + av_opt_set_chlayout(mst->resample_ctx, "out_chlayout", &c->ch_layout, 0); +#endif av_opt_set_int(mst->resample_ctx, "out_sample_rate", c->sample_rate, 0); +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59,27,100)) av_opt_set_int(mst->resample_ctx, "out_sample_fmt", c->sample_fmt, 0); av_opt_set_int(mst->resample_ctx, "out_channel_layout", c->channel_layout, 0); +#else + av_opt_set_sample_fmt(mst->resample_ctx, "out_sample_fmt", c->sample_fmt, 0); +#endif if (swr_init(mst->resample_ctx) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to initialize the resampling context\n"); av_free(mst->resample_ctx); mst->resample_ctx = NULL; + return status; } } @@ -753,6 +883,7 @@ GCC_DIAG_ON(deprecated-declarations) ret = av_frame_get_buffer(mst->frame, 0); if (ret < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate audio frame.\n"); + return status; } @@ -762,7 +893,11 @@ GCC_DIAG_ON(deprecated-declarations) mst->tmp_frame->sample_rate = c->sample_rate; mst->tmp_frame->format = c->sample_fmt; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) mst->tmp_frame->channel_layout = c->channel_layout; +#else + mst->tmp_frame->ch_layout = c->ch_layout; +#endif mst->tmp_frame->nb_samples = mst->frame->nb_samples; ret = av_frame_get_buffer(mst->tmp_frame, 0); @@ -772,6 +907,14 @@ GCC_DIAG_ON(deprecated-declarations) } } +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + if (((ret = avcodec_parameters_from_context(mst->st->codecpar, mst->codec)) < 0)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not copy to codec params ret=%d\n", ret); + + return SWITCH_STATUS_FALSE; + } +#endif + return SWITCH_STATUS_SUCCESS; } @@ -797,8 +940,7 @@ static void flush_video_pkt_queue(switch_queue_t *q) AVPacket *pkt; while (switch_queue_trypop(q, (void **)&pkt) == SWITCH_STATUS_SUCCESS) { - av_packet_unref(pkt); - free(pkt); + av_packet_free(&pkt); } } @@ -811,12 +953,16 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void * int size = 0, skip = 0, skip_freq = 0, skip_count = 0, skip_total = 0, skip_total_count = 0; uint64_t delta_avg = 0, delta_sum = 0, delta_i = 0, delta = 0; int first = 1; + AVCodecContext *c = NULL; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "video thread start\n"); - switch_assert(context->eh.video_queue); + switch_assert(context->eh.video_queue); + for(;;) { - AVPacket pkt = { 0 }; + AVPacket *pkt = NULL; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) int got_packet; +#endif int ret = -1; top: @@ -829,7 +975,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void * switch_img_free(&tmp_img); } if (switch_queue_pop(context->eh.video_queue, &pop) == SWITCH_STATUS_SUCCESS) { - switch_img_free(&img); + switch_img_free(&img); if (!pop) { goto endfor; @@ -877,8 +1023,6 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void * context->eh.in_callback = 1; - av_init_packet(&pkt); - if (context->eh.video_st->frame) { ret = av_frame_make_writable(context->eh.video_st->frame); } @@ -890,7 +1034,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void * if (context->eh.record_timer_paused) { context->eh.last_ts = 0; continue; - } + } fill_avframe(context->eh.video_st->frame, img); @@ -937,59 +1081,149 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void * } } + pkt = av_packet_alloc(); + context->eh.last_ts = context->eh.video_st->frame->pts; // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "pts: %" SWITCH_INT64_T_FMT "\n", context->eh.video_st->frame->pts); /* encode the image */ + c = av_get_codec_context(context->eh.video_st); + +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) GCC_DIAG_OFF(deprecated-declarations) - ret = avcodec_encode_video2(context->eh.video_st->st->codec, &pkt, context->eh.video_st->frame, &got_packet); + ret = avcodec_encode_video2(c, pkt, context->eh.video_st->frame, &got_packet); GCC_DIAG_ON(deprecated-declarations) - + if (ret < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoding Error %d\n", ret); + c = NULL; + av_packet_free(&pkt); continue; } if (got_packet) { +#else + ret = avcodec_send_frame(c, context->eh.video_st->frame); + + if (ret == AVERROR_EOF) { + ret = 0; + } else if (ret == AVERROR(EAGAIN)) { + /* we fully drain all the output in each encode call, so this should not ever happen */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending frame to encoder AVERROR_BUG - should never happen\n"); + ret = AVERROR_BUG; + } else if (ret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending frame to encoder\n"); + } + + while (ret >= 0) { + ret = avcodec_receive_packet(c, pkt); + if (ret == AVERROR(EAGAIN)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video packets at the moment\n"); + break; + } else if (ret == AVERROR_EOF) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video packets at all\n"); + break; + } else if (ret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoding error\n"); + break; + } +#endif + switch_mutex_lock(context->eh.mutex); -GCC_DIAG_OFF(deprecated-declarations) - write_frame(context->eh.fc, &context->eh.video_st->st->codec->time_base, context->eh.video_st->st, &pkt); -GCC_DIAG_ON(deprecated-declarations) + write_frame(context->eh.fc, &c->time_base, context->eh.video_st->st, pkt); switch_mutex_unlock(context->eh.mutex); - av_packet_unref(&pkt); } context->eh.in_callback = 0; + av_packet_free(&pkt); + c = NULL; //switch_mutex_unlock(context->eh.mutex); } endfor: for(;;) { - AVPacket pkt = { 0 }; - int got_packet = 0; + AVPacket *pkt = av_packet_alloc(); int ret = 0; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) + int got_packet = 0; +#else + int wret = 0; +#endif - av_init_packet(&pkt); + c = av_get_codec_context(context->eh.video_st); -GCC_DIAG_OFF(deprecated-declarations) - ret = avcodec_encode_video2(context->eh.video_st->st->codec, &pkt, NULL, &got_packet); +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) +GCC_DIAG_OFF(deprecated-declarations) + ret = avcodec_encode_video2(c, pkt, NULL, &got_packet); GCC_DIAG_ON(deprecated-declarations) if (ret < 0) { - break; + goto do_break; } else if (got_packet) { - switch_mutex_lock(context->eh.mutex); -GCC_DIAG_OFF(deprecated-declarations) - ret = write_frame(context->eh.fc, &context->eh.video_st->st->codec->time_base, context->eh.video_st->st, &pkt); -GCC_DIAG_ON(deprecated-declarations) - switch_mutex_unlock(context->eh.mutex); - av_packet_unref(&pkt); - if (ret < 0) break; - } else { +#else + ret = avcodec_send_frame(c, NULL); + + if (ret == AVERROR_EOF) { + ret = 0; + } else if (ret == AVERROR(EAGAIN)) { + /* we fully drain all the output in each encode call, so this should not ever happen */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending frame to encoder on draining AVERROR_BUG - should never happen\n"); + ret = AVERROR_BUG; + goto do_break; + } else if (ret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending frame to encoder on draining\n"); + c = NULL; + goto do_break; + } + + while (ret >= 0) { + ret = avcodec_receive_packet(c, pkt); + if (ret == AVERROR(EAGAIN)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video packets at the moment on draining\n"); + break; + } else if (ret == AVERROR_EOF) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video packets at all on draining \n"); + break; + } else if (ret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoding error on draining\n"); break; } +#endif + switch_mutex_lock(context->eh.mutex); +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) + ret = write_frame(context->eh.fc, &c->time_base, context->eh.video_st->st, pkt); +#else + wret = write_frame(context->eh.fc, &c->time_base, context->eh.video_st->st, pkt); +#endif + switch_mutex_unlock(context->eh.mutex); +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) + if (ret < 0) { + goto do_break; + } + } else { + goto do_break; +#else + if (wret < 0) { + goto do_break; + } +#endif + } + + av_packet_free(&pkt); + c = NULL; + +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + if (ret < 0 && ret != AVERROR(EAGAIN)) { + break; + } +#endif + + continue; + do_break: + av_packet_free(&pkt); + break; } while(switch_queue_trypop(context->eh.video_queue, &pop) == SWITCH_STATUS_SUCCESS) { @@ -1006,6 +1240,8 @@ GCC_DIAG_ON(deprecated-declarations) static void close_stream(AVFormatContext *fc, MediaStream *mst) { + AVCodecContext *c = NULL; + if (!mst->active) return; if (mst->resample_ctx) swr_free(&mst->resample_ctx); @@ -1013,12 +1249,13 @@ static void close_stream(AVFormatContext *fc, MediaStream *mst) if (mst->frame) av_frame_free(&mst->frame); if (mst->tmp_frame) av_frame_free(&mst->tmp_frame); -GCC_DIAG_OFF(deprecated-declarations) - if (mst->st && mst->st->codec) { - avcodec_close(mst->st->codec); - } -GCC_DIAG_ON(deprecated-declarations) - + c = av_get_codec_context(mst); +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) + avcodec_close(c); +#else + /* avcodec_close() will be called in avcodec_free_context() */ + avcodec_free_context(&c); +#endif mst->active = 0; } @@ -1136,8 +1373,15 @@ static void mod_avformat_destroy_output_context(av_file_context_t *context) static switch_status_t open_input_file(av_file_context_t *context, switch_file_handle_t *handle, const char *filename) { +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) AVCodec *audio_codec = NULL; AVCodec *video_codec = NULL; +#else + const AVCodec *audio_codec = NULL; + const AVCodec *video_codec = NULL; +#endif + enum AVCodecID codec_id; + AVCodecContext *cc = NULL; AVDictionary *opts = NULL; int error; int i, idx = 0; @@ -1147,7 +1391,7 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h /** Open the input file to read from it. */ - if (!context->fc) { + if (!context->fc) { context->fc = avformat_alloc_context(); } @@ -1166,7 +1410,7 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h context->fc = NULL; switch_goto_status(SWITCH_STATUS_FALSE, err); } - + handle->seekable = context->fc->iformat->read_seek2 ? 1 : (context->fc->iformat->read_seek ? 1 : 0); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "file %s is %sseekable\n", filename, handle->seekable ? "" : "not "); @@ -1183,15 +1427,16 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h av_dump_format(context->fc, 0, filename, 0); for (i = 0; i< context->fc->nb_streams; i++) { -GCC_DIAG_OFF(deprecated-declarations) - if (context->fc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && context->has_audio < 2 && idx < 2) { + enum AVMediaType codec_type = av_get_codec_type(context->fc->streams[i]); + + if (codec_type == AVMEDIA_TYPE_AUDIO && context->has_audio < 2 && idx < 2) { context->audio_st[idx++].st = context->fc->streams[i]; context->has_audio++; - } else if (context->fc->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && !context->has_video) { -GCC_DIAG_ON(deprecated-declarations) + } else if (codec_type == AVMEDIA_TYPE_VIDEO && !context->has_video) { context->video_st.st = context->fc->streams[i]; if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) { context->has_video = 1; +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) handle->duration = av_rescale_q(context->video_st.st->duration != AV_NOPTS_VALUE ? context->video_st.st->duration : context->fc->duration / AV_TIME_BASE * 1000, context->video_st.st->time_base, AV_TIME_BASE_Q); } @@ -1207,42 +1452,95 @@ GCC_DIAG_ON(deprecated-declarations) } context->read_fps = (int)handle->mm.source_fps; +#else + } +#endif } } /** Find a decoder for the audio stream. */ -GCC_DIAG_OFF(deprecated-declarations) - if (context->has_audio && !(audio_codec = avcodec_find_decoder(context->audio_st[0].st->codec->codec_id))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not find input codec %d\n", context->audio_st[0].st->codec->codec_id); + if (context->has_audio && !(audio_codec = avcodec_find_decoder((codec_id = av_get_codec_id(context->audio_st[0].st))))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not find input codec %d\n", codec_id); context->has_audio = 0; } - if (context->has_video && !(video_codec = avcodec_find_decoder(context->video_st.st->codec->codec_id))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find input codec %d\n", context->video_st.st->codec->codec_id); + if (context->has_video && !(video_codec = avcodec_find_decoder((codec_id = av_get_codec_id(context->video_st.st))))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find input codec %d\n", codec_id); context->has_video = 0; } - if (context->has_audio && (error = avcodec_open2(context->audio_st[0].st->codec, audio_codec, NULL)) < 0) { +#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_V) + if (context->has_audio == 2) { + context->audio_st[1].codec = avcodec_alloc_context3(audio_codec); + context->audio_st[0].codec = avcodec_alloc_context3(audio_codec); + } else if (context->has_audio) { + context->audio_st[0].codec = avcodec_alloc_context3(audio_codec); + } + + if (context->has_video) { + context->video_st.codec = avcodec_alloc_context3(video_codec); + } +#endif + + cc = av_get_codec_context(&context->audio_st[0]); +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) + if (context->has_audio && ((error = avcodec_open2(cc, audio_codec, NULL)) < 0)) { +#else + if (context->has_audio && (((error = avcodec_parameters_to_context(cc, context->audio_st[0].st->codecpar)) < 0) || ((error = avcodec_open2(cc, audio_codec, NULL)) < 0))) { +#endif char ebuf[255] = ""; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open input audio codec (error '%s')\n", get_error_text(error, ebuf, sizeof(ebuf))); context->has_audio = 0; } - if (context->has_audio == 2 && (error = avcodec_open2(context->audio_st[1].st->codec, audio_codec, NULL)) < 0) { + cc = av_get_codec_context(&context->audio_st[1]); +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) + if (context->has_audio == 2 && ((error = avcodec_open2(cc, audio_codec, NULL)) < 0)) { +#else + if (context->has_audio == 2 && (((error = avcodec_parameters_to_context(cc, context->audio_st[1].st->codecpar)) < 0) || ((error = avcodec_open2(cc, audio_codec, NULL)) < 0))) { +#endif char ebuf[255] = ""; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open input audio codec channel 2 (error '%s')\n", get_error_text(error, ebuf, sizeof(ebuf))); - if (context->audio_st[0].st->codec) { - avcodec_close(context->audio_st[0].st->codec); + if ((cc = av_get_codec_context(&context->audio_st[0]))) { + avcodec_close(cc); } + context->has_audio = 0; } - if (context->has_video && (error = avcodec_open2(context->video_st.st->codec, video_codec, NULL)) < 0) { + cc = av_get_codec_context(&context->video_st); + +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) + if (context->has_video && (error = avcodec_open2(cc, video_codec, NULL)) < 0) { +#else + if (context->has_video) { + if (((error = avcodec_parameters_to_context(cc, context->video_st.st->codecpar)) < 0) || ((error = avcodec_open2(cc, video_codec, NULL)) < 0)) { +#endif char ebuf[255] = ""; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open input codec (error '%s')\n", get_error_text(error, ebuf, sizeof(ebuf))); context->has_video = 0; } -GCC_DIAG_ON(deprecated-declarations) + +#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_V) + handle->duration = av_rescale_q(context->video_st.st->duration != AV_NOPTS_VALUE ? context->video_st.st->duration : context->fc->duration / AV_TIME_BASE * 1000, + context->video_st.st->time_base, AV_TIME_BASE_Q); + + if (context->fc->bit_rate) { + handle->mm.source_kps = context->fc->bit_rate / 1024; + } + + if (context->video_st.st->avg_frame_rate.num) { + handle->mm.source_fps = ceil(av_q2d(context->video_st.st->avg_frame_rate)); + } else { + handle->mm.source_fps = 25; + } + + context->read_fps = (int)handle->mm.source_fps; + + } +#endif context->video_st.active = 1; @@ -1254,16 +1552,14 @@ GCC_DIAG_ON(deprecated-declarations) } if (context->has_audio) { -GCC_DIAG_OFF(deprecated-declarations) AVCodecContext *c[2] = { NULL }; - c[0] = context->audio_st[0].st->codec; + c[0] = av_get_codec_context(&context->audio_st[0]); - if (context->audio_st[1].st && context->audio_st[1].st->codec) { - c[1] = context->audio_st[1].st->codec; + if ((cc = av_get_codec_context(&context->audio_st[1]))) { + c[1] = cc; } -GCC_DIAG_ON(deprecated-declarations) - + context->audio_st[0].frame = av_frame_alloc(); switch_assert(context->audio_st[0].frame); @@ -1278,33 +1574,49 @@ GCC_DIAG_ON(deprecated-declarations) context->audio_st[0].channels = 1; context->audio_st[1].channels = 1; } else { +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVFORMAT_V) handle->channels = c[0]->channels > 2 ? 2 : c[0]->channels; +#else + handle->channels = c[0]->ch_layout.nb_channels > 2 ? 2 : c[0]->ch_layout.nb_channels; +#endif context->audio_st[0].channels = handle->channels; } context->audio_st[0].sample_rate = handle->samplerate; context->audio_st[1].sample_rate = handle->samplerate; -GCC_DIAG_OFF(deprecated-declarations) - if (context->audio_st[0].st->codec->sample_fmt != AV_SAMPLE_FMT_S16 || context->audio_st[0].st->codec->sample_rate != handle->samplerate) { -GCC_DIAG_ON(deprecated-declarations) + if (c[0]->sample_fmt != AV_SAMPLE_FMT_S16 || c[0]->sample_rate != handle->samplerate) { int x; + for (x = 0; x < context->has_audio && x < 2 && c[x]; x++) { struct SwrContext *resample_ctx = swr_alloc(); if (resample_ctx) { int ret; - + +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59,27,100)) /* FFmpeg 5.0 */ av_opt_set_int(resample_ctx, "in_channel_count", c[x]->channels, 0); +#else /* FFmpeg 5.1 */ + av_opt_set_chlayout(resample_ctx, "in_chlayout", &c[x]->ch_layout, 0); +#endif av_opt_set_int(resample_ctx, "in_sample_rate", c[x]->sample_rate, 0); +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59,27,100)) av_opt_set_int(resample_ctx, "in_sample_fmt", c[x]->sample_fmt, 0); av_opt_set_int(resample_ctx, "in_channel_layout", (c[x]->channel_layout == 0 && c[x]->channels == 2) ? AV_CH_LAYOUT_STEREO : c[x]->channel_layout, 0); av_opt_set_int(resample_ctx, "out_channel_count", handle->channels, 0); +#else + av_opt_set_sample_fmt(resample_ctx, "in_sample_fmt", c[x]->sample_fmt, 0); + av_opt_set_chlayout(resample_ctx, "out_chlayout", &c[x]->ch_layout, 0); +#endif av_opt_set_int(resample_ctx, "out_sample_rate", handle->samplerate,0); +#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59,27,100)) av_opt_set_int(resample_ctx, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); av_opt_set_int(resample_ctx, "out_channel_layout", handle->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO, 0); - +#else + av_opt_set_sample_fmt(resample_ctx, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); +#endif + if ((ret = swr_init(resample_ctx)) < 0) { char errbuf[1024]; av_strerror(ret, errbuf, 1024); @@ -1323,8 +1635,11 @@ GCC_DIAG_ON(deprecated-declarations) if (!context->has_video) { switch_clear_flag(handle, SWITCH_FILE_FLAG_VIDEO); } else { -GCC_DIAG_OFF(deprecated-declarations) - switch (context->video_st.st->codec->pix_fmt) { + if (!(cc = av_get_codec_context(&context->video_st))) { + goto err; + } + + switch (cc->pix_fmt) { case AV_PIX_FMT_YUVA420P: case AV_PIX_FMT_RGBA: case AV_PIX_FMT_ARGB: @@ -1335,8 +1650,7 @@ GCC_DIAG_OFF(deprecated-declarations) context->handle->mm.fmt = SWITCH_IMG_FMT_I420; break; } -GCC_DIAG_ON(deprecated-declarations) - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opening file in mode: %s\n", context->handle->mm.fmt == SWITCH_IMG_FMT_ARGB ? "ARGB" : "I420"); } @@ -1368,12 +1682,20 @@ err: static void *SWITCH_THREAD_FUNC file_read_thread_run(switch_thread_t *thread, void *obj) { av_file_context_t *context = (av_file_context_t *) obj; - AVPacket pkt = { 0 }; + AVPacket *pkt = NULL; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) int got_data = 0; +#else + int dret = -1; +#endif int error; int sync = 0; int eof = 0; - + AVCodecContext *c = NULL; +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + AVFrame *vframe = NULL; +#endif + switch_mutex_lock(context->mutex); context->file_read_thread_started = 1; context->file_read_thread_running = 1; @@ -1390,8 +1712,6 @@ static void *SWITCH_THREAD_FUNC file_read_thread_run(switch_thread_t *thread, vo switch_buffer_zero(context->audio_buffer); switch_mutex_unlock(context->mutex); - - // if (context->has_audio) stream_id = context->audio_st.st->index; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "seeking to %" SWITCH_INT64_T_FMT "\n", context->seek_ts); avformat_seek_file(context->fc, stream_id, 0, context->seek_ts, INT64_MAX, 0); @@ -1402,10 +1722,12 @@ static void *SWITCH_THREAD_FUNC file_read_thread_run(switch_thread_t *thread, vo context->video_st.next_pts = 0; context->video_start_time = 0; -GCC_DIAG_OFF(deprecated-declarations) - avcodec_flush_buffers(context->video_st.st->codec); -GCC_DIAG_ON(deprecated-declarations) - + if (!(c = av_get_codec_context(&context->video_st))) { + break; + } + + avcodec_flush_buffers(c); + while(switch_queue_trypop(context->eh.video_queue, &pop) == SWITCH_STATUS_SUCCESS) { switch_image_t *img; if (!pop) break; @@ -1425,21 +1747,18 @@ GCC_DIAG_ON(deprecated-declarations) continue; } + if (pkt) av_packet_free(&pkt); + pkt = av_packet_alloc(); - - av_init_packet(&pkt); - pkt.data = NULL; - pkt.size = 0; - - if ((error = av_read_frame(context->fc, &pkt)) < 0) { + if ((error = av_read_frame(context->fc, pkt)) < 0) { if (error == AVERROR_EOF) { if (!context->has_video) break; eof = 1; /* just make sure*/ - pkt.data = NULL; - pkt.size = 0; - pkt.stream_index = context->video_st.st->index; + pkt->data = NULL; + pkt->size = 0; + pkt->stream_index = context->video_st.st->index; } else { char ebuf[255] = ""; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not read frame (error '%s')\n", get_error_text(error, ebuf, sizeof(ebuf))); @@ -1448,8 +1767,11 @@ GCC_DIAG_ON(deprecated-declarations) } // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "stream: %d, pkt size %d\n", pkt.stream_index, pkt.size); - if (context->has_video && pkt.stream_index == context->video_st.st->index) { - AVFrame *vframe; + + if (context->has_video && pkt->stream_index == context->video_st.st->index) { +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) + AVFrame *vframe = NULL; +#endif switch_image_t *img; if (context->no_video_decode) { @@ -1457,24 +1779,22 @@ GCC_DIAG_ON(deprecated-declarations) break; } else { switch_status_t status; - AVPacket *new_pkt = malloc(sizeof(AVPacket)); + AVPacket *new_pkt = av_packet_alloc(); if (0) { // debug - uint8_t *p = pkt.data; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "size = %u %x %x %x %x %x %x\n", pkt.size, *p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5)); + uint8_t *p = pkt->data; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "size = %u %x %x %x %x %x %x\n", pkt->size, *p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5)); } - av_init_packet(new_pkt); - av_packet_ref(new_pkt, &pkt); + av_packet_ref(new_pkt, pkt); status = switch_queue_push(context->video_pkt_queue, new_pkt); // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "size = %4u flag=%x pts=%" SWITCH_INT64_T_FMT " dts=%" SWITCH_INT64_T_FMT "\n", pkt.size, pkt.flags, pkt.pts, pkt.dts); context->vid_ready = 1; if (status != SWITCH_STATUS_SUCCESS) { - av_packet_unref(new_pkt); - free(new_pkt); + av_packet_free(&new_pkt); } - av_packet_unref(&pkt); + continue; } } @@ -1488,18 +1808,57 @@ again: vframe = av_frame_alloc(); switch_assert(vframe); + if (!(c = av_get_codec_context(&context->video_st))) { + break; + } + +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) GCC_DIAG_OFF(deprecated-declarations) - if ((error = avcodec_decode_video2(context->video_st.st->codec, vframe, &got_data, &pkt)) < 0) { + error = avcodec_decode_video2(c, vframe, &got_data, pkt); GCC_DIAG_ON(deprecated-declarations) +#else + if (eof) { + dret = avcodec_send_packet(c, NULL); + } else { + dret = avcodec_send_packet(c, pkt); + } + + if (dret == AVERROR_EOF) { + dret = 0; + } else if (dret == AVERROR(EAGAIN)) { + /* we fully drain all the output in each decode call, so this should not ever happen */ + dret = AVERROR_BUG; + goto check_errors; + } else if (dret < 0) { + goto check_errors; + } + + while (dret >= 0) { + dret = avcodec_receive_frame(c, vframe); + if (dret == AVERROR(EAGAIN)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video frames at the moment\n"); + } else if (dret == AVERROR_EOF) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more video frames at all\n"); + } else if (dret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Video decoding error\n"); + } +#endif + +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + check_errors: + if (dret < 0 && dret != AVERROR(EAGAIN) && dret != AVERROR_EOF) { +#else + if (error < 0) { +#endif char ebuf[255] = ""; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not decode frame (error '%s')\n", get_error_text(error, ebuf, sizeof(ebuf))); - av_packet_unref(&pkt); av_frame_free(&vframe); continue; } // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "pkt: %d, pts: %lld dts: %lld\n", pkt.size, pkt.pts, pkt.dts); - av_packet_unref(&pkt); + av_packet_unref(pkt); //if (switch_queue_size(context->eh.video_queue) > 300) { // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Dropping frames\n"); @@ -1508,7 +1867,11 @@ GCC_DIAG_ON(deprecated-declarations) //} // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got_data=%d, error=%d\n", got_data, error); +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) if (got_data && error >= 0) { +#else + if (dret >= 0) { +#endif switch_img_fmt_t fmt = SWITCH_IMG_FMT_I420; if (( vframe->format == AV_PIX_FMT_YUVA420P || @@ -1530,7 +1893,7 @@ GCC_DIAG_ON(deprecated-declarations) if (!context->video_st.sws_ctx) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot init sws context\n"); av_frame_free(&frm); - continue; + goto do_continue; } } @@ -1541,9 +1904,11 @@ GCC_DIAG_ON(deprecated-declarations) vframe->width = frm->width; vframe->height = frm->height; vframe->pts = frm->pts; +#if (LIBAVUTIL_VERSION_MAJOR < LIBAVUTIL_V) GCC_DIAG_OFF(deprecated-declarations) vframe->pkt_pts = frm->pkt_pts; GCC_DIAG_ON(deprecated-declarations) +#endif vframe->pkt_dts = frm->pkt_dts; ret = av_frame_get_buffer(vframe, 32); @@ -1556,7 +1921,7 @@ GCC_DIAG_ON(deprecated-declarations) if (ret <= 0 ) { av_frame_free(&vframe); - continue; + goto do_continue; } } @@ -1572,9 +1937,13 @@ GCC_DIAG_ON(deprecated-declarations) int diff; int sleep = 66000; #endif +#if (LIBAVUTIL_VERSION_MAJOR < LIBAVUTIL_V) GCC_DIAG_OFF(deprecated-declarations) *pts = vframe->pkt_pts; GCC_DIAG_ON(deprecated-declarations) +#else + *pts = vframe->pts; +#endif avframe2img(vframe, img); img->user_priv = pts; @@ -1591,36 +1960,89 @@ GCC_DIAG_ON(deprecated-declarations) context->vid_ready = 1; switch_queue_push(context->eh.video_queue, img); context->last_vid_push = switch_time_now(); + } else { + switch_img_free(&img); } } } +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) av_frame_free(&vframe); +#endif if (eof) { +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) if (got_data) { +#else + if (dret != AVERROR_EOF) { +#endif +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) goto again; // to get all delayed video frames in decoder +#else + av_frame_free(&vframe); + goto again; // to get all delayed video frames in decoder +#endif } else { - break; + goto do_break; } } - continue; - } else if (context->has_audio && pkt.stream_index == context->audio_st[0].st->index) { + +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + } + + av_frame_free(&vframe); +#endif + goto do_continue; + } else if (context->has_audio && pkt->stream_index == context->audio_st[0].st->index) { AVFrame in_frame = { { 0 } }; -GCC_DIAG_OFF(deprecated-declarations) - if ((error = avcodec_decode_audio4(context->audio_st[0].st->codec, &in_frame, &got_data, &pkt)) < 0) { -GCC_DIAG_ON(deprecated-declarations) - char ebuf[255] = ""; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not decode frame (error '%s')\n", get_error_text(error, ebuf, sizeof(ebuf))); - av_packet_unref(&pkt); + if (!(c = av_get_codec_context(&context->audio_st[0]))) { continue; } - // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "pkt: %d, decodedddd: %d pts: %lld dts: %lld\n", pkt.size, error, pkt.pts, pkt.dts); - av_packet_unref(&pkt); +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) +GCC_DIAG_OFF(deprecated-declarations) + if ((error = avcodec_decode_audio4(c, &in_frame, &got_data, pkt)) < 0) { +GCC_DIAG_ON(deprecated-declarations) + char ebuf[255] = ""; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not decode frame (error '%s')\n", get_error_text(error, ebuf, sizeof(ebuf))); + continue; + } +#else + dret = avcodec_send_packet(c, pkt); + if (dret == AVERROR_EOF) { + dret = 0; + } else if (dret == AVERROR(EAGAIN)) { + /* we fully drain all the output in each decode call, so this should not ever happen */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending audio packet to decoder - BUG, should never happen\n"); + dret = AVERROR_BUG; + goto do_continue; + } else if (dret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Error sending audio packet to decoder\n"); + goto do_continue; + } + + while (dret >= 0) { + dret = avcodec_receive_frame(c, &in_frame); + if (dret == AVERROR(EAGAIN)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more audio frames at the moment\n"); + } else if (dret == AVERROR_EOF) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more audio frames at all\n"); + } else if (dret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Video decoding error\n"); + goto do_continue; + } +#endif + + // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "pkt: %d, decodedddd: %d pts: %lld dts: %lld\n", pkt.size, error, pkt.pts, pkt.dts); + av_packet_unref(pkt); + +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) if (got_data) { +#else + if (dret >= 0) { +#endif // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got data frm->format: %d samples: %d\n", in_frame.format, in_frame.nb_samples); if (context->audio_st[0].resample_ctx) { @@ -1659,12 +2081,26 @@ GCC_DIAG_ON(deprecated-declarations) } } - - } else { - av_packet_unref(&pkt); +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + } } +#else + } else { + av_packet_unref(pkt); + } +#endif + + do_continue: + continue; + do_break: + break; } + av_packet_free(&pkt); +#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_V) + av_frame_free(&vframe); +#endif + if (context->has_video) switch_queue_push(context->eh.video_queue, NULL); context->file_read_thread_running = 0; @@ -1677,7 +2113,13 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa av_file_context_t *context = NULL; char *ext; const char *tmp = NULL; +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) AVOutputFormat *fmt; +#else + const AVOutputFormat *fmt; + enum AVCodecID video_codec = AV_CODEC_ID_NONE; + enum AVCodecID audio_codec = AV_CODEC_ID_NONE; +#endif const char *format = NULL; int ret; char file[1024]; @@ -1795,18 +2237,28 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa return SWITCH_STATUS_SUCCESS; } - mod_avformat_alloc_output_context2(&context->fc, NULL, format, (char *)file, context); + mod_avformat_alloc_output_context2(&context->fc, format, (char *)file, context); if (!context->fc) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not deduce output format from file extension\n"); switch_goto_status(SWITCH_STATUS_GENERR, end); } +#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_V) + fmt = context->fc->oformat; + video_codec = fmt->video_codec; + audio_codec = fmt->audio_codec; +#endif + fmt = context->fc->oformat; if (handle->params && (tmp = switch_event_get_header(handle->params, "av_audio_codec"))) { if ((context->audio_codec = avcodec_find_encoder_by_name(tmp))) { +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) fmt->audio_codec = context->audio_codec->id; +#else + audio_codec = context->audio_codec->id; +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "specified audio codec %s %s [%s]\n", tmp, context->audio_codec->name, context->audio_codec->long_name); @@ -1827,7 +2279,11 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa if (handle->params && (tmp = switch_event_get_header(handle->params, "av_video_codec"))) { if ((context->video_codec = avcodec_find_encoder_by_name(tmp))) { +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) fmt->video_codec = context->video_codec->id; +#else + video_codec = context->video_codec->id; +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "specified video codec %s %s [%s]\n", tmp, context->video_codec->name, context->video_codec->long_name); } @@ -1864,16 +2320,28 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa handle->mm.vb = switch_calc_bitrate(handle->mm.vw, handle->mm.vh, 1, handle->mm.fps); } +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) && fmt->video_codec != AV_CODEC_ID_NONE) { +#else + if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) && video_codec != AV_CODEC_ID_NONE) { +#endif const AVCodecDescriptor *desc; if ((handle->stream_name && (!strcasecmp(handle->stream_name, "rtmp") || !strcasecmp(handle->stream_name, "rtmps") || !strcasecmp(handle->stream_name, "youtube")))) { - +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) if (fmt->video_codec != AV_CODEC_ID_H264 ) { fmt->video_codec = AV_CODEC_ID_H264; // force H264 +#else + if (video_codec != AV_CODEC_ID_H264 ) { + video_codec = AV_CODEC_ID_H264; // force H264 +#endif } +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) fmt->audio_codec = AV_CODEC_ID_AAC; +#else + audio_codec = AV_CODEC_ID_AAC; +#endif handle->samplerate = 44100; handle->mm.samplerate = 44100; handle->mm.ab = 128; @@ -1909,12 +2377,21 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa } } +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) desc = avcodec_descriptor_get(fmt->video_codec); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "use video codec: [%d] %s (%s)\n", fmt->video_codec, desc->name, desc->long_name); +#else + desc = avcodec_descriptor_get(video_codec); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "use video codec: [%d] %s (%s)\n", video_codec, desc->name, desc->long_name); +#endif } +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) if (fmt->audio_codec != AV_CODEC_ID_NONE) { +#else + if (audio_codec != AV_CODEC_ID_NONE) { +#endif const char *issplit = 0; context->audio_st[0].channels = handle->channels; @@ -1927,8 +2404,13 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa if (lr || rl) { context->audio_st[0].channels = 1; context->audio_st[1].channels = 1; +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) add_stream(context, &context->audio_st[0], context->fc, &context->audio_codec, fmt->audio_codec, &handle->mm); add_stream(context, &context->audio_st[1], context->fc, &context->audio_codec, fmt->audio_codec, &handle->mm); +#else + add_stream(context, &context->audio_st[0], context->fc, &context->audio_codec, audio_codec, &handle->mm); + add_stream(context, &context->audio_st[1], context->fc, &context->audio_codec, audio_codec, &handle->mm); +#endif } if (lr) { @@ -1939,7 +2421,11 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa } if (!context->audio_st[0].active) { +#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_V) add_stream(context, &context->audio_st[0], context->fc, &context->audio_codec, fmt->audio_codec, &handle->mm); +#else + add_stream(context, &context->audio_st[0], context->fc, &context->audio_codec, audio_codec, &handle->mm); +#endif } if (open_audio(context->fc, context->audio_codec, &context->audio_st[0]) != SWITCH_STATUS_SUCCESS) { @@ -2012,11 +2498,16 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s uint32_t bytes; int inuse; int sample_start = 0; + AVCodecContext *c = NULL; if (!switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { return SWITCH_STATUS_FALSE; } + if (!context->has_audio) { + return SWITCH_STATUS_SUCCESS; + } + if (!context->vid_ready) { if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) { switch_buffer_zero(context->audio_buffer); @@ -2049,9 +2540,7 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s switch_buffer_write(context->audio_buffer, data, datalen); } -GCC_DIAG_OFF(deprecated-declarations) bytes = context->audio_st[0].frame->nb_samples * 2 * context->handle->channels; //context->audio_st[0].st->codec->channels; -GCC_DIAG_ON(deprecated-declarations) //{ // int inuse = switch_buffer_inuse(context->audio_buffer); @@ -2095,13 +2584,18 @@ GCC_DIAG_ON(deprecated-declarations) } while (switch_buffer_inuse(context->audio_buffer) >= bytes) { - AVPacket pkt[2] = { {0} }; + AVPacket *pkt[2]; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) int got_packet[2] = {0}; + int result[2] = {0}; +#else + int dret = -1; +#endif int j = 0, ret = -1, audio_stream_count = 1; AVFrame *use_frame = NULL; - av_init_packet(&pkt[0]); - av_init_packet(&pkt[1]); + pkt[0] = av_packet_alloc(); + pkt[1] = av_packet_alloc(); if (context->audio_st[1].active) { switch_size_t len = 0; @@ -2137,17 +2631,17 @@ GCC_DIAG_ON(deprecated-declarations) if (context->audio_st[j].resample_ctx) { int out_samples = swr_get_out_samples(context->audio_st[j].resample_ctx, context->audio_st[j].frame->nb_samples); - av_frame_make_writable(context->audio_st[j].tmp_frame); + av_frame_make_writable(context->audio_st[j].tmp_frame); /* convert to destination format */ ret = swr_convert(context->audio_st[j].resample_ctx, - context->audio_st[j].tmp_frame->data, out_samples, - (const uint8_t **)context->audio_st[j].frame->data, context->audio_st[j].frame->nb_samples); + context->audio_st[j].tmp_frame->data, out_samples, + (const uint8_t **)context->audio_st[j].frame->data, context->audio_st[j].frame->nb_samples); if (ret < 0) { char ebuf[255] = ""; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while converting %d samples, error text: %s\n", - context->audio_st[j].frame->nb_samples, get_error_text(ret, ebuf, sizeof(ebuf))); + context->audio_st[j].frame->nb_samples, get_error_text(ret, ebuf, sizeof(ebuf))); continue; } @@ -2158,24 +2652,90 @@ GCC_DIAG_ON(deprecated-declarations) // context->audio_st[j].next_pts = use_frame->pts + use_frame->nb_samples; -GCC_DIAG_OFF(deprecated-declarations) - ret = avcodec_encode_audio2(context->audio_st[j].st->codec, &pkt[j], use_frame, &got_packet[j]); -GCC_DIAG_ON(deprecated-declarations) + if (!(c = av_get_codec_context(&context->audio_st[j]))) { + continue; + } +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) +GCC_DIAG_OFF(deprecated-declarations) + result[j] = avcodec_encode_audio2(c, pkt[j], use_frame, &got_packet[j]); +GCC_DIAG_ON(deprecated-declarations) +#else + dret = avcodec_send_frame(c, use_frame); + + if (dret == AVERROR_EOF) { + dret = 0; + } else if (dret == AVERROR(EAGAIN)) { + /* we fully drain all the output in each decode call, so this should not ever happen */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Encoding error for channel %d on sending frame to encode - BUG, should never happen\n", j); + dret = AVERROR_BUG; + } else if (dret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoding error for channel %d on sending frame to encode\n", j); + } + + while (dret >= 0) { + dret = avcodec_receive_packet(c, pkt[j]); + if (dret == AVERROR(EAGAIN)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more audio packets at the moment for channel %d\n", j); + break; + } else if (dret == AVERROR_EOF) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "No more audio packets at all for channel %d\n", j); + break; + } else if (dret < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoding error for channel %d\n", j); + break; + } + + if (context->mutex) switch_mutex_lock(context->mutex); + + ret = write_frame(context->fc, &c->time_base, context->audio_st[j].st, pkt[j]); + + if (context->mutex) switch_mutex_unlock(context->mutex); + + if (ret < 0) { + context->errs++; + if ((context->errs % 10) == 0) { + char ebuf[255] = ""; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while writing audio frame: %d %s\n", ret, get_error_text(ret, ebuf, sizeof(ebuf))); + if ((ret == -5 || ret == -104) && handle->stream_name) { + context->errs = 1001; + } + } + //switch_goto_status(SWITCH_STATUS_FALSE, end); + } else { + context->errs = 0; + } + + if (context->errs > 1000) { + av_packet_free(&pkt[0]); + av_packet_free(&pkt[1]); + switch_goto_status(SWITCH_STATUS_FALSE, end); + } + } +#endif context->audio_st[j].next_pts += use_frame->nb_samples; - } - - if (ret < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error encoding audio frame: %d\n", ret); + } + +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) + if (result[0] < 0 || result[1] < 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error encoding audio frame: %d %d \n", result[0], result[1]); + av_packet_free(&pkt[0]); + av_packet_free(&pkt[1]); continue; } - + for (j = 0; j < audio_stream_count; j++) { if (got_packet[j]) { if (context->mutex) switch_mutex_lock(context->mutex); -GCC_DIAG_OFF(deprecated-declarations) - ret = write_frame(context->fc, &context->audio_st[j].st->codec->time_base, context->audio_st[j].st, &pkt[j]); -GCC_DIAG_ON(deprecated-declarations) + + if (!(c = av_get_codec_context(&context->audio_st[j]))) { + if (context->mutex) switch_mutex_unlock(context->mutex); + continue; + } + + ret = write_frame(context->fc, &c->time_base, context->audio_st[j].st, pkt[j]); + if (context->mutex) switch_mutex_unlock(context->mutex); if (ret < 0) { @@ -2195,6 +2755,10 @@ GCC_DIAG_ON(deprecated-declarations) } } } +#endif + + av_packet_free(&pkt[0]); + av_packet_free(&pkt[1]); } end: @@ -2467,10 +3031,10 @@ static switch_status_t no_video_decode_packets(switch_file_handle_t *handle, swi if (context->last_read_pkt) { status = switch_packetizer_read(context->packetizer, frame); if (status == SWITCH_STATUS_SUCCESS) { - av_packet_unref(context->last_read_pkt); - free(context->last_read_pkt); + av_packet_free(&context->last_read_pkt); context->last_read_pkt = NULL; } + return status; } @@ -2478,6 +3042,7 @@ static switch_status_t no_video_decode_packets(switch_file_handle_t *handle, swi if (status != SWITCH_STATUS_SUCCESS || !pkt) { switch_cond_next(); + return SWITCH_STATUS_BREAK; } @@ -2489,12 +3054,10 @@ static switch_status_t no_video_decode_packets(switch_file_handle_t *handle, swi // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "pts=%" SWITCH_INT64_T_FMT " status = %d\n", pts, status); if (status == SWITCH_STATUS_SUCCESS) { - av_packet_unref(context->last_read_pkt); - free(context->last_read_pkt); + av_packet_free(&context->last_read_pkt); context->last_read_pkt = NULL; } - if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_MORE_DATA) { if (!context->video_start_time) { context->video_start_time = switch_time_now() - pts; @@ -2529,6 +3092,8 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f double fl_to = 0.02; int do_fl = 0; int smaller_ts = context->read_fps; + AVCodecContext *c = NULL; + AVCodecParserContext *cp = NULL; if (!context->has_video) return SWITCH_STATUS_FALSE; @@ -2636,18 +3201,17 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f } #endif -GCC_DIAG_OFF(deprecated-declarations) - if (st->codec->time_base.num) { - ticks = st->parser ? st->parser->repeat_pict + 1 : st->codec->ticks_per_frame; + if ((c = av_get_codec_context(mst)) && c->time_base.num) { + cp = av_stream_get_parser(st); + ticks = cp ? cp->repeat_pict + 1 : c->ticks_per_frame; // mst->next_pts += ((int64_t)AV_TIME_BASE * st->codec->time_base.num * ticks) / st->codec->time_base.den; } if (!context->video_start_time) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "start: %" SWITCH_INT64_T_FMT " ticks: %d ticks_per_frame: %d st num:%d st den:%d codec num:%d codec den:%d start: %" SWITCH_TIME_T_FMT ", duration:%" SWITCH_INT64_T_FMT " nb_frames:%" SWITCH_INT64_T_FMT " q2d:%f\n", - context->video_start_time, ticks, st->codec->ticks_per_frame, st->time_base.num, st->time_base.den, st->codec->time_base.num, st->codec->time_base.den, + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "start: %" SWITCH_INT64_T_FMT " ticks: %d ticks_per_frame: %d st num:%d st den:%d codec num:%d codec den:%d start: %" SWITCH_TIME_T_FMT ", duration:%" SWITCH_INT64_T_FMT " nb_frames:%" SWITCH_INT64_T_FMT " q2d:%f\n", + context->video_start_time, ticks, c ? c->ticks_per_frame : -1, st->time_base.num, st->time_base.den, c ? c->time_base.num : -1, c ? c->time_base.den : -1, st->start_time, st->duration == AV_NOPTS_VALUE ? context->fc->duration / AV_TIME_BASE * 1000 : st->duration, st->nb_frames, av_q2d(st->time_base)); } -GCC_DIAG_ON(deprecated-declarations) again: @@ -2748,6 +3312,7 @@ static switch_status_t av_file_write_video(switch_file_handle_t *handle, switch_ switch_status_t status = SWITCH_STATUS_SUCCESS; av_file_context_t *context = (av_file_context_t *)handle->private_info; switch_image_t *img = NULL; + AVCodecContext *c = NULL; if (!switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) { return SWITCH_STATUS_FALSE; @@ -2764,12 +3329,13 @@ static switch_status_t av_file_write_video(switch_file_handle_t *handle, switch_ if (add_stream(context, &context->video_st, context->fc, &context->video_codec, context->fc->oformat->video_codec, &handle->mm) == SWITCH_STATUS_SUCCESS && open_video(context->fc, context->video_codec, &context->video_st) == SWITCH_STATUS_SUCCESS) { - char codec_str[256]; + char codec_str[256] = ""; int ret; -GCC_DIAG_OFF(deprecated-declarations) - avcodec_string(codec_str, sizeof(codec_str), context->video_st.st->codec, 1); -GCC_DIAG_ON(deprecated-declarations) + if ((c = av_get_codec_context(&context->video_st))) { + avcodec_string(codec_str, sizeof(codec_str), c, 1); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "use video codec implementation %s\n", codec_str); context->has_video = 1; @@ -2802,8 +3368,11 @@ GCC_DIAG_ON(deprecated-declarations) switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_core_timer_init(&context->video_timer, "soft", 1, 1, context->pool); context->eh.video_timer = &context->video_timer; - context->audio_st[0].frame->pts = 0; - context->audio_st[0].next_pts = 0; + if (context->has_audio) { + context->audio_st[0].frame->pts = 0; + context->audio_st[0].next_pts = 0; + } + switch_thread_create(&context->eh.video_thread, thd_attr, video_thread_run, context, handle->memory_pool); } @@ -2859,7 +3428,7 @@ static char *supported_formats[SWITCH_MAX_CODECS] = { 0 }; static const char modname[] = "mod_av"; -static switch_status_t load_config() +static switch_status_t load_config(void) { char *cf = "avformat.conf"; switch_xml_t cfg, xml, param, settings; diff --git a/src/mod/applications/mod_av/mod_av.c b/src/mod/applications/mod_av/mod_av.c index 5d93d9adc7..02a481fd2e 100644 --- a/src/mod/applications/mod_av/mod_av.c +++ b/src/mod/applications/mod_av/mod_av.c @@ -25,6 +25,7 @@ * * Seven Du * Anthony Minessale + * Jakub Karolczyk * * mod_av -- FS Video Codec / File Format using libav.org * @@ -33,7 +34,13 @@ #include #include "mod_av.h" #include +#ifdef _MSC_VER +#include /* LIBAVCODEC_VERSION_INT */ +#endif #include +#ifdef _MSC_VER +#include /* LIBAVFORMAT_VERSION_INT */ +#endif SWITCH_MODULE_LOAD_FUNCTION(mod_avformat_load); SWITCH_MODULE_LOAD_FUNCTION(mod_avcodec_load); @@ -49,6 +56,7 @@ typedef struct av_mutex_helper_s { switch_memory_pool_t *pool; } av_mutex_helper_t; +#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V) int mod_av_lockmgr_cb(void **m, enum AVLockOp op) { av_mutex_helper_t *context = NULL; @@ -93,6 +101,7 @@ int mod_av_lockmgr_cb(void **m, enum AVLockOp op) } return 0; } +#endif #ifndef AV_LOG_TRACE #define AV_LOG_TRACE 96 diff --git a/src/mod/applications/mod_av/mod_av.h b/src/mod/applications/mod_av/mod_av.h index b240f98aa7..a89e6cb8f7 100644 --- a/src/mod/applications/mod_av/mod_av.h +++ b/src/mod/applications/mod_av/mod_av.h @@ -30,6 +30,7 @@ * Marcel Barbulescu * Raymond Chandler * Emmanuel Schmidbauer + * Jakub Karolczyk * * * mod_av.h -- LibAV mod @@ -39,6 +40,10 @@ #ifndef MOD_AV_H #define MOD_AV_H +#define LIBAVCODEC_V 59 +#define LIBAVFORMAT_V 59 +#define LIBAVUTIL_V 57 + struct mod_av_globals { int debug; }; diff --git a/src/mod/applications/mod_avmd/avmd_fast_acosf.c b/src/mod/applications/mod_avmd/avmd_fast_acosf.c index 572c6a84f9..59b581b98d 100644 --- a/src/mod/applications/mod_avmd/avmd_fast_acosf.c +++ b/src/mod/applications/mod_avmd/avmd_fast_acosf.c @@ -86,7 +86,6 @@ typedef union { static uint32_t index_from_float(float f); static float float_from_index(uint32_t d); static float *acos_table = NULL; -static int acos_fd = -1; #ifdef FAST_ACOSF_TESTING @@ -112,6 +111,10 @@ extern int compute_table(void) acos_table_file = fopen(ACOS_TABLE_FILENAME, "w"); + if (!acos_table_file) { + return -3; + } + for (i = 0; i < ACOS_TABLE_LENGTH; i++) { f = acosf(float_from_index(i)); res = fwrite(&f, sizeof(f), 1, acos_table_file); @@ -124,10 +127,12 @@ extern int compute_table(void) if (res != 0) { return -2; } + return 0; fail: fclose(acos_table_file); + return -1; } @@ -144,8 +149,9 @@ extern int init_fast_acosf(void) * or some other error occured */ errsv = errno; strerror_r(errsv, err, 150); - if (errsv != ENOENT) return -1; - else { + if (errsv != ENOENT) { + return -1; + } else { switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, @@ -166,10 +172,10 @@ extern int init_fast_acosf(void) acos_fp = fopen(ACOS_TABLE_FILENAME, "r"); if (acos_fp == NULL) return -3; /* can't fail */ - acos_fd = fileno(acos_fp); acos_table = (float *) mmap( NULL, /* kernel chooses the address at which to create the mapping */ - ACOS_TABLE_LENGTH * sizeof(float), PROT_READ, MAP_SHARED, acos_fd, 0); + ACOS_TABLE_LENGTH * sizeof(float), PROT_READ, MAP_SHARED, fileno(acos_fp), 0); + fclose(acos_fp); if (acos_table == MAP_FAILED) return -4; return 0; @@ -178,9 +184,7 @@ extern int init_fast_acosf(void) extern int destroy_fast_acosf(void) { if (munmap(acos_table, ACOS_TABLE_LENGTH) == -1) return -1; - if (acos_fd != -1) { - if (close(acos_fd) == -1) return -2; - } + /* disable use of fast arc cosine file */ acos_table = NULL; diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index dde3dfbf93..e5076c1500 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -1138,6 +1138,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) { switch_application_interface_t *app_interface; switch_api_interface_t *api_interface; + + if (pool == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No memory pool assigned!\n"); + + return SWITCH_STATUS_TERM; + } + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); @@ -1147,10 +1154,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) { } memset(&avmd_globals, 0, sizeof(avmd_globals)); - if (pool == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No memory pool assigned!\n"); - return SWITCH_STATUS_TERM; - } switch_mutex_init(&avmd_globals.mutex, SWITCH_MUTEX_NESTED, pool); avmd_globals.pool = pool; @@ -1622,9 +1625,6 @@ SWITCH_STANDARD_APP(avmd_start_function) { SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) { size_t session_n; -#ifndef WIN32 - int res; -#endif switch_mutex_lock(avmd_globals.mutex); @@ -1638,18 +1638,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) { #ifndef WIN32 if (avmd_globals.settings.fast_math == 1) { - res = destroy_fast_acosf(); - if (res != 0) { - switch (res) { - case -1: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed unmap arc cosine table\n"); - break; - case -2: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed closing arc cosine table\n"); - break; - default: - break; - } + if (destroy_fast_acosf()) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed unmap arc cosine table\n"); } } #endif @@ -1658,6 +1648,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) { switch_mutex_unlock(avmd_globals.mutex); switch_mutex_destroy(avmd_globals.mutex); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Advanced voicemail detection disabled\n"); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index fd7bb3dafa..b035b6d7f9 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -1969,9 +1969,10 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa playback_array(agent_session, o_announce); } - /* This is used for the waiting caller to quit waiting for a agent */ + /* This is used to set the reason for callcenter_function breakout */ switch_channel_set_variable(member_channel, "cc_agent_found", "true"); switch_channel_set_variable(member_channel, "cc_agent_uuid", agent_uuid); + if (switch_true(switch_channel_get_variable(member_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE)) || switch_true(switch_channel_get_variable(agent_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE))) { switch_channel_set_flag(member_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE); } @@ -1990,6 +1991,12 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa switch_channel_set_variable(agent_channel, "cc_agent_bridged", "false"); switch_channel_set_variable(member_channel, "cc_agent_bridged", "false"); + /* Set member to Abandoned state, previous Trying */ + sql = switch_mprintf("UPDATE members SET state = '%q', session_uuid = '', abandoned_epoch = '%" SWITCH_TIME_T_FMT "' WHERE uuid = '%q' AND instance_id = '%q'", + cc_member_state2str(CC_MEMBER_STATE_ABANDONED), local_epoch_time_now(NULL), h->member_uuid, globals.cc_instance_id); + cc_execute_sql(NULL, sql, NULL); + switch_safe_free(sql); + if ((o_announce = switch_channel_get_variable(member_channel, "cc_bridge_failed_outbound_announce"))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Playing bridge failed audio to agent %s, audio: %s\n", h->agent_name, o_announce); playback_array(agent_session, o_announce); @@ -2008,9 +2015,15 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa bridged = 1; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Member \"%s\" %s is bridged to agent %s\n", h->member_cid_name, h->member_cid_number, h->agent_name); + switch_channel_set_variable(member_channel, "cc_agent_bridged", "true"); switch_channel_set_variable(agent_channel, "cc_agent_bridged", "true"); - switch_channel_set_variable(member_channel, "cc_agent_uuid", agent_uuid); + + /* Update member to Answered state, previous Trying */ + sql = switch_mprintf("UPDATE members SET state = '%q', bridge_epoch = '%" SWITCH_TIME_T_FMT "' WHERE uuid = '%q' AND instance_id = '%q'", + cc_member_state2str(CC_MEMBER_STATE_ANSWERED), local_epoch_time_now(NULL), h->member_uuid, globals.cc_instance_id); + cc_execute_sql(NULL, sql, NULL); + switch_safe_free(sql); } if (bridged) { @@ -2111,7 +2124,7 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa } } else { - /* Agent didn't answer or originate failed */ + /* Agent didn't answer or originate/bridge failed */ int delay_next_agent_call = 0; switch_channel_t *member_channel = switch_core_session_get_channel(member_session); switch_channel_clear_app_flag_key(CC_APP_KEY, member_channel, CC_APP_AGENT_CONNECTING); @@ -3051,6 +3064,10 @@ SWITCH_STANDARD_APP(callcenter_function) switch_channel_set_variable(member_channel, "cc_side", "member"); switch_channel_set_variable(member_channel, "cc_member_uuid", member_uuid); + /* Clear flags in case previously set */ + switch_channel_set_variable(member_channel, "cc_agent_found", NULL); + switch_channel_set_variable(member_channel, "cc_agent_bridged", NULL); + /* Add manually imported score */ if (cc_base_score) { cc_base_score_int += atoi(cc_base_score); @@ -3178,8 +3195,8 @@ SWITCH_STANDARD_APP(callcenter_function) args.buf = (void *) &ht; args.buflen = sizeof(h); - /* An agent was found, time to exit and let the bridge do it job */ - if ((p = switch_channel_get_variable(member_channel, "cc_agent_found")) && (agent_found = switch_true(p))) { + /* If the bridge didn't break the loop, break out now */ + if ((p = switch_channel_get_variable(member_channel, "cc_agent_bridged")) && (agent_found = switch_true(p))) { break; } /* If the member thread set a different reason, we monitor it so we can quit the wait */ @@ -3201,8 +3218,6 @@ SWITCH_STANDARD_APP(callcenter_function) switch_channel_set_variable(member_channel, "cc_exit_key", buf); h->member_cancel_reason = CC_MEMBER_CANCEL_REASON_EXIT_WITH_KEY; break; - } else if (!SWITCH_READ_ACCEPTABLE(status)) { - break; } } else { switch_status_t status = switch_ivr_collect_digits_callback(member_session, &args, 0, 0); @@ -3230,12 +3245,18 @@ SWITCH_STANDARD_APP(callcenter_function) h->running = 0; } + /* Stop uuid_broadcasts */ + switch_core_session_flush_private_events(member_session); + switch_channel_stop_broadcast(member_channel); + switch_channel_set_flag_value(member_channel, CF_BREAK, 2); + /* Check if we were removed because FS Core(BREAK) asked us to */ if (h->member_cancel_reason == CC_MEMBER_CANCEL_REASON_NONE && !agent_found) { h->member_cancel_reason = CC_MEMBER_CANCEL_REASON_BREAK_OUT; } switch_channel_set_variable(member_channel, "cc_agent_found", NULL); + /* Canceled for some reason */ if (!switch_channel_up(member_channel) || h->member_cancel_reason != CC_MEMBER_CANCEL_REASON_NONE) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Member %s <%s> abandoned waiting in queue %s\n", switch_str_nil(switch_channel_get_variable(member_channel, "caller_id_name")), switch_str_nil(switch_channel_get_variable(member_channel, "caller_id_number")), queue_name); @@ -3282,12 +3303,6 @@ SWITCH_STANDARD_APP(callcenter_function) } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Member %s <%s> is answered by an agent in queue %s\n", switch_str_nil(switch_channel_get_variable(member_channel, "caller_id_name")), switch_str_nil(switch_channel_get_variable(member_channel, "caller_id_number")), queue_name); - /* Update member state */ - sql = switch_mprintf("UPDATE members SET state = '%q', bridge_epoch = '%" SWITCH_TIME_T_FMT "' WHERE uuid = '%q' AND instance_id = '%q'", - cc_member_state2str(CC_MEMBER_STATE_ANSWERED), local_epoch_time_now(NULL), member_uuid, globals.cc_instance_id); - cc_execute_sql(NULL, sql, NULL); - switch_safe_free(sql); - /* Update some channel variables for xml_cdr needs */ switch_channel_set_variable_printf(member_channel, "cc_cause", "%s", "answered"); if ((queue = get_queue(queue_name))) { diff --git a/src/mod/applications/mod_cidlookup/mod_cidlookup.c b/src/mod/applications/mod_cidlookup/mod_cidlookup.c index 7df22fb3ef..5531222197 100644 --- a/src/mod/applications/mod_cidlookup/mod_cidlookup.c +++ b/src/mod/applications/mod_cidlookup/mod_cidlookup.c @@ -347,7 +347,7 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data) return realsize; } -static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, char **response, const char *query, struct curl_httppost *post, +static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, char **response, const char *query, switch_curl_mime *post, switch_curl_slist_t *headers, int timeout) { switch_time_t start_time = switch_micro_time_now(); @@ -373,7 +373,7 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); } if (post) { - switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, post); + switch_curl_easy_setopt_mime(curl_handle, post); } else { switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1); } @@ -845,6 +845,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load) Macro expands to: switch_status_t mod_cidlookup_shutdown() */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cidlookup_shutdown) { + switch_xml_config_cleanup(instructions); switch_event_unbind(&reload_xml_event); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 8e737a78a2..5b9620a781 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2417,7 +2417,7 @@ SWITCH_STANDARD_API(uptime_function) return SWITCH_STATUS_SUCCESS; } -#define CTL_SYNTAX "[recover|send_sighup|hupall|pause [inbound|outbound]|resume [inbound|outbound]|shutdown [cancel|elegant|asap|now|restart]|sps|sps_peak_reset|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel [level]|debug_level [level]|mdns_resolve [enable|disable]]" +#define CTL_SYNTAX "[api_expansion [on|off]|recover|send_sighup|hupall|pause [inbound|outbound]|resume [inbound|outbound]|shutdown [cancel|elegant|asap|now|restart]|sps|sps_peak_reset|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel [level]|debug_level [level]|mdns_resolve [enable|disable]]" SWITCH_STANDARD_API(ctl_function) { int argc; @@ -3225,6 +3225,7 @@ SWITCH_STANDARD_API(uuid_capture_text) } else { if ((tsession = switch_core_session_locate(uuid))) { switch_ivr_capture_text(tsession, switch_true(onoff)); + switch_core_session_rwunlock(tsession); } else { stream->write_function(stream, "-ERR No such channel %s!\n", uuid); } @@ -5653,22 +5654,26 @@ SWITCH_STANDARD_API(alias_function) #define COALESCE_SYNTAX "[^^],,..." SWITCH_STANDARD_API(coalesce_function) { - switch_status_t status = SWITCH_STATUS_FALSE; - char *data = (char *) cmd; char *mydata = NULL, *argv[256] = { 0 }; + char *arg = (char *) cmd; int argc = -1; + char delim = ','; - if (data && *data && (mydata = strdup(data))) { - argc = switch_separate_string(mydata, ',', argv, + if (!zstr(arg) && *arg == '^' && *(arg+1) == '^') { + arg += 2; + delim = *arg++; + } + + if (!zstr(arg) && (mydata = strdup(arg))) { + argc = switch_separate_string(mydata, delim, argv, (sizeof(argv) / sizeof(argv[0]))); } if (argc > 0) { int i; for (i = 0; i < argc; i++) { - if (argv[i] && *argv[i]) { + if (!zstr(argv[i])) { stream->write_function(stream, argv[i]); - status = SWITCH_STATUS_SUCCESS; break; } } @@ -5676,7 +5681,9 @@ SWITCH_STANDARD_API(coalesce_function) stream->write_function(stream, "-USAGE: %s\n", COALESCE_SYNTAX); } - return status; + switch_safe_free(mydata); + + return SWITCH_STATUS_SUCCESS; } #define SHOW_SYNTAX "codec|endpoint|application|api|dialplan|file|timer|calls [count]|channels [count|like ]|calls|detailed_calls|bridged_calls|detailed_bridged_calls|aliases|complete|chat|management|modules|nat_map|say|interfaces|interface_types|tasks|limits|status" @@ -7745,6 +7752,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add complete add"); switch_console_set_complete("add complete del"); switch_console_set_complete("add db_cache status"); + switch_console_set_complete("add fsctl api_expansion on"); + switch_console_set_complete("add fsctl api_expansion off"); switch_console_set_complete("add fsctl debug_level"); switch_console_set_complete("add fsctl debug_pool"); switch_console_set_complete("add fsctl debug_sql"); @@ -7793,6 +7802,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add fsctl shutdown restart elegant"); switch_console_set_complete("add fsctl sps"); switch_console_set_complete("add fsctl sync_clock"); + switch_console_set_complete("add fsctl sync_clock_when_idle"); switch_console_set_complete("add fsctl flush_db_handles"); switch_console_set_complete("add fsctl min_idle_cpu"); switch_console_set_complete("add fsctl send_sighup"); diff --git a/src/mod/applications/mod_conference/conference_api.c b/src/mod/applications/mod_conference/conference_api.c index 8bcfc5862f..7e566367fb 100644 --- a/src/mod/applications/mod_conference/conference_api.c +++ b/src/mod/applications/mod_conference/conference_api.c @@ -4087,7 +4087,6 @@ switch_status_t conference_api_sub_set(conference_obj_t *conference, switch_status_t conference_api_sub_xml_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) { - int count = 0; switch_hash_index_t *hi; void *val; switch_xml_t x_conference, x_conferences; @@ -4106,7 +4105,6 @@ switch_status_t conference_api_sub_xml_list(conference_obj_t *conference, switch x_conference = switch_xml_add_child_d(x_conferences, "conference", off++); switch_assert(conference); - count++; conference_xlist(conference, x_conference, off); } @@ -4114,7 +4112,7 @@ switch_status_t conference_api_sub_xml_list(conference_obj_t *conference, switch } else { x_conference = switch_xml_add_child_d(x_conferences, "conference", off++); switch_assert(conference); - count++; + conference_xlist(conference, x_conference, off); } diff --git a/src/mod/applications/mod_conference/conference_cdr.c b/src/mod/applications/mod_conference/conference_cdr.c index b6eb630540..9f2ccba63c 100644 --- a/src/mod/applications/mod_conference/conference_cdr.c +++ b/src/mod/applications/mod_conference/conference_cdr.c @@ -662,6 +662,9 @@ void conference_cdr_render(conference_obj_t *conference) x_tag = switch_xml_add_child_d(x_flags, "end_conference", flag_off++); switch_xml_set_txt_d(x_tag, conference_cdr_test_mflag(np, MFLAG_ENDCONF) ? "true" : "false"); + x_tag = switch_xml_add_child_d(x_flags, "mandatory_member_end_conference", flag_off++); + switch_xml_set_txt_d(x_tag, conference_cdr_test_mflag(np, MFLAG_MANDATORY_MEMBER_ENDCONF) ? "true" : "false"); + x_tag = switch_xml_add_child_d(x_flags, "was_kicked", flag_off++); switch_xml_set_txt_d(x_tag, conference_cdr_test_mflag(np, MFLAG_KICKED) ? "true" : "false"); @@ -737,7 +740,7 @@ void conference_cdr_render(conference_obj_t *conference) #endif int wrote; wrote = write(fd, xml_text, (unsigned) strlen(xml_text)); - wrote++; + (void)wrote; close(fd); } else { char ebuf[512] = { 0 }; diff --git a/src/mod/applications/mod_conference/conference_loop.c b/src/mod/applications/mod_conference/conference_loop.c index f6c2856892..8f112f5453 100644 --- a/src/mod/applications/mod_conference/conference_loop.c +++ b/src/mod/applications/mod_conference/conference_loop.c @@ -75,7 +75,7 @@ struct _mapping control_mappings[] = { {"deaf off", conference_loop_deaf_off} }; -int conference_loop_mapping_len() +int conference_loop_mapping_len(void) { return (sizeof(control_mappings)/sizeof(control_mappings[0])); } diff --git a/src/mod/applications/mod_conference/conference_member.c b/src/mod/applications/mod_conference/conference_member.c index 6112a2890c..c258e59783 100644 --- a/src/mod/applications/mod_conference/conference_member.c +++ b/src/mod/applications/mod_conference/conference_member.c @@ -766,7 +766,12 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m conference->count++; } + if (conference_utils_member_test_flag(member, MFLAG_ENDCONF)) { + conference->endconference_time = 0; + } + + if (conference_utils_member_test_flag(member, MFLAG_MANDATORY_MEMBER_ENDCONF)) { if (conference->end_count++) { conference->endconference_time = 0; } @@ -1314,9 +1319,14 @@ switch_status_t conference_member_del(conference_obj_t *conference, conference_m conference_video_check_flush(member, SWITCH_FALSE); + /* End conference when any member with "endconf" flag disconnects */ if (conference_utils_member_test_flag(member, MFLAG_ENDCONF)) { + conference_utils_set_flag_locked(conference, CFLAG_DESTRUCT); + } + + /* End conference only if all mandatory members have disconnected */ + if (conference_utils_member_test_flag(member, MFLAG_MANDATORY_MEMBER_ENDCONF)) { if (!--conference->end_count) { - //conference_utils_set_flag_locked(conference, CFLAG_DESTRUCT); conference->endconference_time = switch_epoch_time_now(NULL); } } diff --git a/src/mod/applications/mod_conference/conference_utils.c b/src/mod/applications/mod_conference/conference_utils.c index c8dd0fd4e9..a441594ddc 100644 --- a/src/mod/applications/mod_conference/conference_utils.c +++ b/src/mod/applications/mod_conference/conference_utils.c @@ -132,6 +132,8 @@ void conference_utils_set_mflags(const char *flags, member_flag_t *f) f[MFLAG_NOMOH] = 1; } else if (!strcasecmp(argv[i], "endconf")) { f[MFLAG_ENDCONF] = 1; + } else if (!strcasecmp(argv[i], "mandatory_member_endconf")) { + f[MFLAG_MANDATORY_MEMBER_ENDCONF] = 1; } else if (!strcasecmp(argv[i], "mintwo")) { f[MFLAG_MINTWO] = 1; } else if (!strcasecmp(argv[i], "talk-data-events")) { diff --git a/src/mod/applications/mod_conference/conference_video.c b/src/mod/applications/mod_conference/conference_video.c index e94b835c3d..9105605185 100644 --- a/src/mod/applications/mod_conference/conference_video.c +++ b/src/mod/applications/mod_conference/conference_video.c @@ -3803,6 +3803,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr switch_image_t *use_img = NULL; if (!omember->session || !switch_channel_test_flag(omember->channel, CF_VIDEO_READY) || + (conference_utils_test_flag(omember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) && !conference_utils_member_test_flag(omember, MFLAG_CAN_BE_SEEN)) || switch_core_session_media_flow(omember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY || switch_core_session_media_flow(omember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) { continue; } diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 619cd8c4a6..bf03d2a5bc 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1347,6 +1347,9 @@ void conference_xlist(conference_obj_t *conference, switch_xml_t x_conference, i x_tag = switch_xml_add_child_d(x_flags, "end_conference", count++); switch_xml_set_txt_d(x_tag, conference_utils_member_test_flag(member, MFLAG_ENDCONF) ? "true" : "false"); + x_tag = switch_xml_add_child_d(x_flags, "mandatory_member_end_conference", count++); + switch_xml_set_txt_d(x_tag, conference_utils_member_test_flag(member, MFLAG_MANDATORY_MEMBER_ENDCONF) ? "true" : "false"); + x_tag = switch_xml_add_child_d(x_flags, "is_ghost", count++); switch_xml_set_txt_d(x_tag, conference_utils_member_test_flag(member, MFLAG_GHOST) ? "true" : "false"); @@ -1456,6 +1459,7 @@ void conference_jlist(conference_obj_t *conference, cJSON *json_conferences) ADDBOOL(json_conference_member_flags, "has_floor", member->id == member->conference->floor_holder); ADDBOOL(json_conference_member_flags, "is_moderator", conference_utils_member_test_flag(member, MFLAG_MOD)); ADDBOOL(json_conference_member_flags, "end_conference", conference_utils_member_test_flag(member, MFLAG_ENDCONF)); + ADDBOOL(json_conference_member_flags, "mandatory_member_end_conference", conference_utils_member_test_flag(member, MFLAG_MANDATORY_MEMBER_ENDCONF)); ADDBOOL(json_conference_member_flags, "pass_digits", conference_utils_member_test_flag(member, MFLAG_DIST_DTMF)); } switch_mutex_unlock(conference->member_mutex); diff --git a/src/mod/applications/mod_conference/mod_conference.h b/src/mod/applications/mod_conference/mod_conference.h index 3c28634264..e45a921c21 100644 --- a/src/mod/applications/mod_conference/mod_conference.h +++ b/src/mod/applications/mod_conference/mod_conference.h @@ -178,6 +178,7 @@ typedef enum { MFLAG_NO_MINIMIZE_ENCODING, MFLAG_FLUSH_BUFFER, MFLAG_ENDCONF, + MFLAG_MANDATORY_MEMBER_ENDCONF, MFLAG_HAS_AUDIO, MFLAG_TALKING, MFLAG_RESTART, @@ -1123,7 +1124,7 @@ void conference_video_canvas_del_fnode_layer(conference_obj_t *conference, confe void conference_video_canvas_set_fnode_layer(mcu_canvas_t *canvas, conference_file_node_t *fnode, int idx); void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim); const char *conference_utils_combine_flag_var(switch_core_session_t *session, const char *var_name); -int conference_loop_mapping_len(); +int conference_loop_mapping_len(void); void conference_api_set_agc(conference_member_t *member, const char *data); switch_status_t conference_outcall(conference_obj_t *conference, diff --git a/src/mod/applications/mod_curl/mod_curl.c b/src/mod/applications/mod_curl/mod_curl.c index 02079d6767..c780e6947e 100644 --- a/src/mod/applications/mod_curl/mod_curl.c +++ b/src/mod/applications/mod_curl/mod_curl.c @@ -104,8 +104,13 @@ struct http_sendfile_data_obj { char *extrapost_elements; switch_CURL *curl_handle; char *cacert; +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + curl_mime *mime; + curl_mimepart *part; +#else struct curl_httppost *formpost; struct curl_httppost *lastptr; +#endif uint8_t flags; /* This is for where to send output of the curl_sendfile commands */ switch_stream_handle_t *stream; char *sendfile_response; @@ -456,8 +461,19 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data) curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEFUNCTION, http_sendfile_response_callback); curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEDATA, (void *) http_data); + /* Initial http_data->mime */ +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + http_data->mime = curl_mime_init(http_data->curl_handle); +#endif + /* Add the file to upload as a POST form field */ +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + http_data->part = curl_mime_addpart(http_data->mime); + curl_mime_name(http_data->part, http_data->filename_element_name); + curl_mime_filedata(http_data->part, http_data->filename_element); +#else curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, http_data->filename_element_name, CURLFORM_FILE, http_data->filename_element, CURLFORM_END); +#endif if(!zstr(http_data->extrapost_elements)) { @@ -476,16 +492,32 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data) if(argc2 == 2) { switch_url_decode(argv2[0]); switch_url_decode(argv2[1]); +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + http_data->part = curl_mime_addpart(http_data->mime); + curl_mime_name(http_data->part, argv2[0]); + curl_mime_data(http_data->part, argv2[1], CURL_ZERO_TERMINATED); +#else curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, argv2[0], CURLFORM_COPYCONTENTS, argv2[1], CURLFORM_END); +#endif } } } /* Fill in the submit field too, even if this isn't really needed */ +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + http_data->part = curl_mime_addpart(http_data->mime); + curl_mime_name(http_data->part, "submit"); + curl_mime_data(http_data->part, "or_die", CURL_ZERO_TERMINATED); +#else curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "or_die", CURLFORM_END); +#endif /* what URL that receives this POST */ +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + curl_easy_setopt(http_data->curl_handle, CURLOPT_MIMEPOST, http_data->mime); +#else curl_easy_setopt(http_data->curl_handle, CURLOPT_HTTPPOST, http_data->formpost); +#endif // This part actually fires off the curl, captures the HTTP response code, and then frees up the handle. curl_easy_perform(http_data->curl_handle); @@ -494,7 +526,11 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data) curl_easy_cleanup(http_data->curl_handle); // Clean up the form data from POST +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + curl_mime_free(http_data->mime); +#else curl_formfree(http_data->formpost); +#endif } static switch_status_t http_sendfile_test_file_open(http_sendfile_data_t *http_data, switch_event_t *event) diff --git a/src/mod/applications/mod_cv/mod_cv.cpp b/src/mod/applications/mod_cv/mod_cv.cpp index 800452dd9a..de39943b4b 100644 --- a/src/mod/applications/mod_cv/mod_cv.cpp +++ b/src/mod/applications/mod_cv/mod_cv.cpp @@ -854,7 +854,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi } if (context->rawImage && (context->debug || !context->overlay_count)) { - switch_img_from_raw(frame->img, (uint8_t *)context->rawImage->imageData, SWITCH_IMG_FMT_RGB24, context->rawImage->width, context->rawImage->height); + switch_img_from_raw(&frame->img, (uint8_t *)context->rawImage->imageData, SWITCH_IMG_FMT_RGB24, context->rawImage->width, context->rawImage->height); } int abs = 0; diff --git a/src/mod/applications/mod_db/mod_db.c b/src/mod/applications/mod_db/mod_db.c index 0e3e227de7..5f14792f2c 100644 --- a/src/mod/applications/mod_db/mod_db.c +++ b/src/mod/applications/mod_db/mod_db.c @@ -280,7 +280,7 @@ static switch_xml_config_item_t config_settings[] = { SWITCH_CONFIG_ITEM_END() }; -static switch_status_t do_config() +static switch_status_t do_config(void) { switch_cache_db_handle_t *dbh = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index f38509016b..f52b1184e5 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -161,7 +161,6 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match) char *string = NULL; switch_channel_t *channel; switch_core_session_t *use_session = act->session; - int x = 0; char *flags = ""; if (act->target == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_BOTH) { @@ -171,7 +170,6 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match) } top: - x++; string = switch_core_session_strdup(use_session, act->string); exec = 0; @@ -4584,7 +4582,7 @@ SWITCH_STANDARD_APP(wait_for_silence_function) timeout_ms = switch_atoui(argv[3]); } - if (thresh > 0 && silence_hits > 0 && listen_hits >= 0) { + if (thresh > 0 && silence_hits > 0) { switch_ivr_wait_for_silence(session, thresh, silence_hits, listen_hits, timeout_ms, argv[4]); return; } diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c index 2908a1eb1e..aa87f24826 100644 --- a/src/mod/applications/mod_enum/mod_enum.c +++ b/src/mod/applications/mod_enum/mod_enum.c @@ -497,6 +497,7 @@ switch_status_t ldns_lookup(const char *number, const char *root, char *server_n /* create a new resolver from /etc/resolv.conf */ if (res) { ldns_resolver_free(res); + res = NULL; } s = ldns_resolver_new_frm_file(&res, NULL); } diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index 4b32d87c6d..1254a6f93c 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -1419,7 +1419,7 @@ static switch_status_t httapi_sync(client_t *client) switch_status_t status = SWITCH_STATUS_FALSE; int get_style_method = 0; char *method = NULL; - struct curl_httppost *formpost=NULL; + switch_curl_mime *formpost = NULL; switch_event_t *save_params = NULL; const char *put_file; FILE *fd = NULL; @@ -1476,7 +1476,7 @@ static switch_status_t httapi_sync(client_t *client) } if (!put_file) { - switch_curl_process_form_post_params(client->params, curl_handle, &formpost); + switch_curl_process_mime(client->params, curl_handle, &formpost); } if (formpost) { @@ -1588,7 +1588,7 @@ static switch_status_t httapi_sync(client_t *client) curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, put_file_read); } else if (formpost) { - curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, formpost); + switch_curl_easy_setopt_mime(curl_handle, formpost); } else { switch_curl_easy_setopt(curl_handle, CURLOPT_POST, !get_style_method); } @@ -1670,9 +1670,7 @@ static switch_status_t httapi_sync(client_t *client) switch_curl_easy_cleanup(curl_handle); switch_curl_slist_free_all(headers); - if (formpost) { - curl_formfree(formpost); - } + switch_curl_mime_free(&formpost); if (client->err) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error encountered! [%s]\ndata: [%s]\n", client->profile->url, data); diff --git a/src/mod/applications/mod_http_cache/azure.c b/src/mod/applications/mod_http_cache/azure.c index f1e4cf8925..a16d2e9f94 100644 --- a/src/mod/applications/mod_http_cache/azure.c +++ b/src/mod/applications/mod_http_cache/azure.c @@ -279,7 +279,11 @@ switch_status_t azure_blob_finalise_put(http_profile_t *profile, const char *url goto done; } +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x070c01) + switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1); +#else switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1); +#endif switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); switch_curl_easy_setopt(curl_handle, CURLOPT_URL, full_url); diff --git a/src/mod/applications/mod_http_cache/mod_http_cache.c b/src/mod/applications/mod_http_cache/mod_http_cache.c index 9d19099e56..365ba27425 100644 --- a/src/mod/applications/mod_http_cache/mod_http_cache.c +++ b/src/mod/applications/mod_http_cache/mod_http_cache.c @@ -393,7 +393,9 @@ static switch_status_t http_put(url_cache_t *cache, http_profile_t *profile, swi goto done; } switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1); +#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x070c01) switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1); +#endif switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); switch_curl_easy_setopt(curl_handle, CURLOPT_URL, full_url); diff --git a/src/mod/applications/mod_ladspa/mod_ladspa.c b/src/mod/applications/mod_ladspa/mod_ladspa.c index 2bccfffb9c..6e04e414a9 100644 --- a/src/mod/applications/mod_ladspa/mod_ladspa.c +++ b/src/mod/applications/mod_ladspa/mod_ladspa.c @@ -370,6 +370,11 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s } } } + + if (pvt->ldesc->activate) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "ACTIVATE\n"); + pvt->ldesc->activate(pvt->handle); + } } break; @@ -382,6 +387,10 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s } if (pvt->handle && pvt->ldesc) { + if (pvt->ldesc->deactivate) { + pvt->ldesc->deactivate(pvt->handle); + } + pvt->ldesc->cleanup(pvt->handle); } diff --git a/src/mod/applications/mod_signalwire/mod_signalwire.c b/src/mod/applications/mod_signalwire/mod_signalwire.c index 5b0be47a91..108f99b2c5 100644 --- a/src/mod/applications/mod_signalwire/mod_signalwire.c +++ b/src/mod/applications/mod_signalwire/mod_signalwire.c @@ -228,7 +228,7 @@ static ks_status_t load_credentials_from_json(ks_json_t *json) const char *relay_connector_id = NULL; #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 - if ((bootstrap = ks_json_get_string(json, "bootstrap")) == NULL) { + if ((bootstrap = ks_json_get_object_string(json, "bootstrap", NULL)) == NULL) { #else if ((bootstrap = ks_json_get_object_cstr(json, "bootstrap")) == NULL) { #endif @@ -238,7 +238,7 @@ static ks_status_t load_credentials_from_json(ks_json_t *json) } #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 - if ((relay_connector_id = ks_json_get_string(json, "relay_connector_id")) == NULL) { + if ((relay_connector_id = ks_json_get_object_string(json, "relay_connector_id", NULL)) == NULL) { #else if ((relay_connector_id = ks_json_get_object_cstr(json, "relay_connector_id")) == NULL) { #endif @@ -704,7 +704,7 @@ done: return status; } -static switch_status_t load_config() +static switch_status_t load_config(void) { char *cf = "signalwire.conf"; switch_xml_t cfg, xml; @@ -797,6 +797,7 @@ static ks_status_t load_credentials(void) status = KS_STATUS_FAIL; goto done; } + fclose(fp); json = ks_json_parse(data); @@ -805,6 +806,7 @@ static ks_status_t load_credentials(void) status = KS_STATUS_FAIL; goto done; } + status = load_credentials_from_json(json); ks_json_delete(&json); @@ -981,7 +983,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_signalwire_load) #ifdef WIN32 sslLoadWindowsCACertificate(); #endif - // Configuration swclt_config_create(&globals.config); load_config(); @@ -1206,6 +1207,7 @@ static void mod_signalwire_state_configure(void) #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &reply)) { if (reply->type == SWCLT_CMD_TYPE_RESULT) { + ks_json_t *result; #else if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &cmd)) { SWCLT_CMD_TYPE cmd_type; @@ -1215,7 +1217,8 @@ static void mod_signalwire_state_configure(void) #endif signalwire_provisioning_configure_response_t *configure_res; #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 - if (!SIGNALWIRE_PROVISIONING_CONFIGURE_RESPONSE_PARSE(reply->pool, reply->json, &configure_res)) { + result = ks_json_get_object_item(reply->json, "result"); + if (!SIGNALWIRE_PROVISIONING_CONFIGURE_RESPONSE_PARSE(reply->pool, result, &configure_res)) { #else swclt_cmd_result(cmd, &result); result = ks_json_get_object_item(result, "result"); @@ -1223,7 +1226,7 @@ static void mod_signalwire_state_configure(void) #endif ks_json_t *configuration = configure_res->configuration; #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 - const char *configuration_profile = ks_json_get_string(configuration, "profile"); + const char *configuration_profile = ks_json_get_object_string(configuration, "profile", NULL); #else const char *configuration_profile = ks_json_get_object_cstr(configuration, "profile"); #endif @@ -1231,6 +1234,7 @@ static void mod_signalwire_state_configure(void) switch_xml_free(globals.signalwire_profile); globals.signalwire_profile = NULL; } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\"\n", configuration_profile); globals.signalwire_profile = switch_xml_parse_str_dynamic((char *)configuration_profile, SWITCH_TRUE); if (!globals.signalwire_profile) { @@ -1386,7 +1390,7 @@ static void mod_signalwire_state_register(void) } } -static void mod_signalwire_state_ready() +static void mod_signalwire_state_ready(void) { if (globals.profile_update) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Signalwire SIP profile update initiated\n"); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c index 560a78be44..1f8a88cc75 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c @@ -897,9 +897,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi fail: - if (new_session) { - switch_core_session_destroy(new_session); - } + switch_core_session_destroy(new_session); if (modem) { modem_set_state(modem, MODEM_STATE_ONHOOK); diff --git a/src/mod/applications/mod_translate/mod_translate.c b/src/mod/applications/mod_translate/mod_translate.c index efbcd3f14b..34b1ad54fc 100644 --- a/src/mod/applications/mod_translate/mod_translate.c +++ b/src/mod/applications/mod_translate/mod_translate.c @@ -130,6 +130,7 @@ static void translate_number(char *number, char *profile, char **translated, swi hi = switch_core_hash_find_rdlock(globals.translate_profiles, (const char *)profile, globals.profile_hash_rwlock); if (!hi) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "can't find key for profile matching [%s]\n", profile); + return; } @@ -142,6 +143,7 @@ static void translate_number(char *number, char *profile, char **translated, swi switch_regex_safe_free(re); goto end; } + memset(substituted, 0, len); switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector); @@ -153,16 +155,21 @@ static void translate_number(char *number, char *profile, char **translated, swi } else if (event) { subbed = switch_event_expand_headers(event, substituted); } + + if (subbed != substituted) { + switch_safe_free(substituted); + } + if (session) { substituted = switch_core_session_strdup(session, subbed); } else { substituted = switch_core_strdup(pool, subbed); } - if (subbed != substituted) { - switch_safe_free(subbed); - } + + switch_safe_free(subbed); } + switch_regex_safe_free(re); break; } } diff --git a/src/mod/applications/mod_video_filter/mod_video_filter.c b/src/mod/applications/mod_video_filter/mod_video_filter.c index 7cf1f1dd0f..605559fdbb 100644 --- a/src/mod/applications/mod_video_filter/mod_video_filter.c +++ b/src/mod/applications/mod_video_filter/mod_video_filter.c @@ -645,7 +645,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi } - switch_img_from_raw(frame->img, patch_data, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h); + switch_img_from_raw(&frame->img, patch_data, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h); switch_img_free(&img); diff --git a/src/mod/codecs/mod_amr/bitshift.c b/src/mod/codecs/mod_amr/bitshift.c index fd3fc55606..05a00ff1b5 100644 --- a/src/mod/codecs/mod_amr/bitshift.c +++ b/src/mod/codecs/mod_amr/bitshift.c @@ -47,7 +47,7 @@ extern int switch_amr_array_lshift(uint8_t lshift, uint8_t *buf, int a_len) if (!buf || !a_len) return (-1); - if ((lshift < 0) || (lshift > 8)) + if (lshift > 8) return (-1); first_byte = 0xFF >> lshift; diff --git a/src/mod/codecs/mod_ilbc/mod_ilbc.c b/src/mod/codecs/mod_ilbc/mod_ilbc.c index 14d67d372e..2588cdf46b 100644 --- a/src/mod/codecs/mod_ilbc/mod_ilbc.c +++ b/src/mod/codecs/mod_ilbc/mod_ilbc.c @@ -48,7 +48,7 @@ static switch_status_t switch_ilbc_fmtp_parse(const char *fmtp, switch_codec_fmt memset(codec_fmtp, '\0', sizeof(struct switch_codec_fmtp)); - if (fmtp && (mode = strstr(fmtp, "mode=")) && (mode + 5)) { + if (fmtp && (mode = strstr(fmtp, "mode=")) && *(mode + 5)) { codec_ms = atoi(mode + 5); } if (!codec_ms) { diff --git a/src/mod/codecs/mod_opus/Makefile.am b/src/mod/codecs/mod_opus/Makefile.am index 690c5fa471..70710898e7 100644 --- a/src/mod/codecs/mod_opus/Makefile.am +++ b/src/mod/codecs/mod_opus/Makefile.am @@ -4,7 +4,7 @@ MODNAME=mod_opus if HAVE_OPUS mod_LTLIBRARIES = mod_opus.la -mod_opus_la_SOURCES = mod_opus.c +mod_opus_la_SOURCES = mod_opus.c opus_parse.c mod_opus_la_CFLAGS = $(AM_CFLAGS) $(OPUS_CFLAGS) mod_opus_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(OPUS_LIBS) mod_opus_la_LDFLAGS = -avoid-version -module -no-undefined -shared -lm -lz diff --git a/src/mod/codecs/mod_opus/mod_opus.2017.vcxproj b/src/mod/codecs/mod_opus/mod_opus.2017.vcxproj index 3b73a6c42f..18478701c8 100644 --- a/src/mod/codecs/mod_opus/mod_opus.2017.vcxproj +++ b/src/mod/codecs/mod_opus/mod_opus.2017.vcxproj @@ -130,6 +130,10 @@ + + + + diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c index a90aba346a..a38389d031 100644 --- a/src/mod/codecs/mod_opus/mod_opus.c +++ b/src/mod/codecs/mod_opus/mod_opus.c @@ -33,6 +33,7 @@ #include "switch.h" #include "opus.h" +#include "opus_parse.h" #define SWITCH_OPUS_MIN_BITRATE 6000 #define SWITCH_OPUS_MAX_BITRATE 510000 @@ -142,25 +143,26 @@ struct opus_context { dec_stats_t decoder_stats; enc_stats_t encoder_stats; codec_control_state_t control_state; + switch_bool_t recreate_decoder; }; struct { - int use_vbr; - int use_dtx; + switch_bool_t use_vbr; + switch_bool_t use_dtx; int complexity; int maxaveragebitrate; int maxplaybackrate; int sprop_maxcapturerate; int plpct; - int asymmetric_samplerates; - int bitrate_negotiation; - int keep_fec; - int fec_decode; - int adjust_bitrate; + switch_bool_t asymmetric_samplerates; + switch_bool_t bitrate_negotiation; + switch_bool_t keep_fec; + switch_bool_t fec_decode; + switch_bool_t adjust_bitrate; int debuginfo; - uint32_t use_jb_lookahead; + switch_bool_t use_jb_lookahead; switch_mutex_t *mutex; - int mono; + switch_bool_t mono; } opus_prefs; static struct { @@ -272,10 +274,12 @@ static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmt if (!strcasecmp(data, "maxptime")) { codec_settings->maxptime = atoi(arg); + codec_fmtp->max_ptime = codec_settings->maxptime; } if (!strcasecmp(data, "minptime")) { codec_settings->minptime = atoi(arg); + codec_fmtp->min_ptime = codec_settings->minptime; } if (!strcasecmp(data, "ptime")) { @@ -290,6 +294,7 @@ static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmt if (!strcasecmp(data, "sprop-stereo")) { codec_settings->sprop_stereo = atoi(arg); + codec_fmtp->sprop_stereo = codec_settings->sprop_stereo; } if (!strcasecmp(data, "maxaveragebitrate")) { @@ -310,6 +315,10 @@ static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmt if (!switch_opus_acceptable_rate(codec_settings->sprop_maxcapturerate)) { codec_settings->sprop_maxcapturerate = 0; /* value not supported */ } + + if (codec_settings->sprop_maxcapturerate) { + codec_fmtp->actual_samples_per_second = codec_settings->sprop_maxcapturerate; + } } } } @@ -471,7 +480,7 @@ static int switch_opus_get_fec_bitrate(int fs, int loss) return SWITCH_STATUS_FALSE ; } -static switch_status_t switch_opus_info(void * encoded_data, uint32_t len, uint32_t samples_per_second, char *print_text) +static switch_status_t switch_opus_info(switch_core_session_t *session, void * encoded_data, uint32_t len, uint32_t samples_per_second, char *print_text) { int nb_samples, nb_opus_frames, nb_channels; int audiobandwidth; @@ -483,18 +492,18 @@ static switch_status_t switch_opus_info(void * encoded_data, uint32_t len, uint3 if (!encoded_data) { /* print stuff, even if encoded_data is NULL. eg: "PLC correction" */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s", print_text); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s", print_text); return SWITCH_STATUS_FALSE; } audiobandwidth = opus_packet_get_bandwidth(encoded_data); if (!switch_opus_show_audio_bandwidth(audiobandwidth,audiobandwidth_str)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s: OPUS_INVALID_PACKET !\n", print_text); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s: OPUS_INVALID_PACKET !\n", print_text); } if ((nb_opus_frames = opus_packet_parse(encoded_data, len, NULL, frame_data, frame_sizes, NULL)) <= 0 ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s: OPUS_INVALID_PACKET ! frames: %d\n", print_text, nb_opus_frames); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s: OPUS_INVALID_PACKET ! frames: %d\n", print_text, nb_opus_frames); return SWITCH_STATUS_FALSE; } @@ -504,7 +513,7 @@ static switch_status_t switch_opus_info(void * encoded_data, uint32_t len, uint3 nb_channels = opus_packet_get_nb_channels(payload); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: opus_frames [%d] samples [%d] audio bandwidth [%s] bytes [%d] FEC[%s] channels[%d]\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s: opus_frames [%d] samples [%d] audio bandwidth [%s] bytes [%d] FEC[%s] channels[%d]\n", print_text, nb_opus_frames, nb_samples, audiobandwidth_str, len, has_fec ? "yes" : "no", nb_channels); return SWITCH_STATUS_SUCCESS; @@ -518,6 +527,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag switch_codec_fmtp_t codec_fmtp, codec_fmtp_only_remote = { 0 }; opus_codec_settings_t opus_codec_settings = { 0 }; opus_codec_settings_t opus_codec_settings_remote = { 0 }; + switch_core_session_t *session = codec->session; if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) { return SWITCH_STATUS_FALSE; @@ -591,7 +601,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag if (settings && settings->maxplaybackrate < enc_samplerate && settings->maxplaybackrate) { enc_samplerate = settings->maxplaybackrate; /*R1*/ context->enc_frame_size = enc_samplerate * (codec->implementation->microseconds_per_packet / 1000) / 1000; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder will be created at sample rate %d hz\n",enc_samplerate); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Opus encoder will be created at sample rate %d hz\n",enc_samplerate); } else { enc_samplerate = codec->implementation->actual_samples_per_second; } @@ -604,19 +614,19 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag codec->implementation->number_of_channels == 1 ? OPUS_APPLICATION_VOIP : OPUS_APPLICATION_AUDIO, &err); if (err != OPUS_OK) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create encoder: %s\n", opus_strerror(err)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create encoder: %s\n", opus_strerror(err)); return SWITCH_STATUS_GENERR; } /* https://tools.ietf.org/html/rfc7587 */ if (opus_codec_settings.maxaveragebitrate) { opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(opus_codec_settings.maxaveragebitrate)); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: set bitrate based on maxaveragebitrate value found in SDP or local config [%dbps]\n", opus_codec_settings.maxaveragebitrate); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Opus encoder: set bitrate based on maxaveragebitrate value found in SDP or local config [%dbps]\n", opus_codec_settings.maxaveragebitrate); } else { opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(OPUS_AUTO)); opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(bitrate_bps)); /* OPUS_AUTO */ opus_encoder_ctl(context->encoder_object, OPUS_GET_BITRATE(&bitrate_bps)); /* return average bps for this audio bandwidth */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: set bitrate to local settings [%dbps]\n", bitrate_bps); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Opus encoder: set bitrate to local settings [%dbps]\n", bitrate_bps); } /* Another fmtp setting from https://tools.ietf.org/html/rfc7587 - "RTP Payload Format for the Opus Speech and Audio Codec" */ if (opus_codec_settings.maxplaybackrate) { @@ -627,14 +637,14 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag if (!switch_opus_show_audio_bandwidth(audiobandwidth,audiobandwidth_str)) { snprintf(audiobandwidth_str, sizeof(audiobandwidth_str), "%s", "OPUS_AUTO"); } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: set audio bandwidth to [%s] based on maxplaybackrate value found in SDP or local config [%dHz]\n",audiobandwidth_str,opus_codec_settings.maxplaybackrate); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Opus encoder: set audio bandwidth to [%s] based on maxplaybackrate value found in SDP or local config [%dHz]\n",audiobandwidth_str,opus_codec_settings.maxplaybackrate); } if (use_vbr) { /* VBR is default*/ opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR(use_vbr)); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: CBR mode enabled\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Opus encoder: CBR mode enabled\n"); opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR(0)); } @@ -684,7 +694,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag if (settings && dec_samplerate > settings->sprop_maxcapturerate && settings->sprop_maxcapturerate) { dec_samplerate = settings->sprop_maxcapturerate; /* R2 */ context->dec_frame_size = dec_samplerate*(codec->implementation->microseconds_per_packet / 1000) / 1000; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus decoder will be created at sample rate %d hz\n",dec_samplerate); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Opus decoder will be created at sample rate %d hz\n",dec_samplerate); } else { dec_samplerate = codec->implementation->actual_samples_per_second; } @@ -697,7 +707,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag switch_set_flag(codec, SWITCH_CODEC_FLAG_HAS_PLC); if (err != OPUS_OK) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create decoder: %s\n", opus_strerror(err)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create decoder: %s\n", opus_strerror(err)); if (context->encoder_object) { opus_encoder_destroy(context->encoder_object); @@ -774,7 +784,7 @@ static switch_status_t switch_opus_encode(switch_codec_t *codec, if (globals.debug || context->debug > 1) { int samplerate = context->enc_frame_size * 1000 / (codec->implementation->microseconds_per_packet / 1000); - switch_opus_info(encoded_data, bytes, samplerate, "encode"); + switch_opus_info(codec->session, encoded_data, bytes, samplerate, "encode"); } if (bytes > 0) { @@ -796,7 +806,7 @@ static switch_status_t switch_opus_encode(switch_codec_t *codec, return SWITCH_STATUS_SUCCESS; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "Encoder Error: %s Decoded Datalen %u Codec NumberChans %u Len %u DecodedDate %p EncodedData %p ContextEncoderObject %p!\n", opus_strerror(bytes),decoded_data_len,codec->implementation->number_of_channels,len,(void *) decoded_data, (void *) encoded_data,(void *) context->encoder_object); @@ -817,6 +827,8 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, int fec = 0, plc = 0; int32_t frame_size = 0, last_frame_size = 0; uint32_t frame_samples; + uint8_t buf[SWITCH_RTP_MAX_BUF_LEN]; + switch_core_session_t *session = codec->session; if (!context) { return SWITCH_STATUS_FALSE; @@ -826,7 +838,6 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, frame_size = frame_samples - (frame_samples % (codec->implementation->actual_samples_per_second / 400)); if (*flag & SFF_PLC) { - switch_core_session_t *session = codec->session; switch_jb_t *jb = NULL; plc = 1; @@ -842,7 +853,6 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, } if (codec->cur_frame && (jb = switch_core_session_get_jb(session, SWITCH_MEDIA_TYPE_AUDIO))) { switch_frame_t frame = { 0 }; - uint8_t buf[SWITCH_RTP_MAX_BUF_LEN]; uint32_t ts = 0; uint16_t seq = 0; @@ -856,12 +866,12 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, frame.buflen = sizeof(buf); if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Missing %s %u Checking JB\n", seq ? "SEQ" : "TS", seq ? seq : ts); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Missing %s %u Checking JB\n", seq ? "SEQ" : "TS", seq ? seq : ts); } if (switch_jb_peek_frame(jb, ts, seq, 1, &frame) == SWITCH_STATUS_SUCCESS) { if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lookahead frame found: %u:%u\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Lookahead frame found: %u:%u\n", frame.timestamp, frame.seq); } @@ -873,10 +883,10 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, if (globals.debug || context->debug) { if (fec) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FEC info available in packet with SEQ: %d LEN: %d\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "FEC info available in packet with SEQ: %d LEN: %d\n", frame.seq, frame.datalen); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NO FEC info in this packet with SEQ: %d LEN: %d\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "NO FEC info in this packet with SEQ: %d LEN: %d\n", frame.seq, frame.datalen); } } @@ -890,9 +900,9 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, if (globals.debug || context->debug) { if (opus_prefs.use_jb_lookahead || context->use_jb_lookahead) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "MISSING FRAME: %s\n", fec ? "Look-ahead FEC" : "PLC"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MISSING FRAME: %s\n", fec ? "Look-ahead FEC" : "PLC"); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "MISSING FRAME: OPUS_PLC\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MISSING FRAME: OPUS_PLC\n"); } } @@ -901,7 +911,7 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, if (globals.debug || context->debug > 1) { int samplerate = context->dec_frame_size * 1000 / (codec->implementation->microseconds_per_packet / 1000); - switch_opus_info(encoded_data, encoded_data_len, + switch_opus_info(codec->session, encoded_data, encoded_data_len, samplerate ? samplerate : codec->implementation->actual_samples_per_second, !encoded_data ? "PLC correction" : fec ? "FEC correction" : "decode"); } @@ -918,8 +928,8 @@ static switch_status_t switch_opus_decode(switch_codec_t *codec, samples = opus_decode(context->decoder_object, encoded_data, encoded_data_len, decoded_data, frame_size, fec); if (samples < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decoder Error: %s fs:%u plc:%s!\n", - opus_strerror(samples), frame_size, plc ? "true" : "false"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Decoder Error: %s fs:%u plc:%s!\n", + opus_strerror(samples), frame_size, plc ? "true" : "false"); return SWITCH_STATUS_NOOP; } @@ -962,7 +972,7 @@ static switch_status_t switch_opus_encode_repacketize(switch_codec_t *codec, } frame_size = (decoded_data_len / 2) / nb_frames; if((frame_size * nb_frames) != context->enc_frame_size) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"Encoder Error: Decoded Datalen %u Number of frames: %u Encoder frame size: %u\n",decoded_data_len,nb_frames,context->enc_frame_size); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR,"Encoder Error: Decoded Datalen %u Number of frames: %u Encoder frame size: %u\n",decoded_data_len,nb_frames,context->enc_frame_size); switch_goto_status(SWITCH_STATUS_GENERR, end); } opus_repacketizer_init(rp); @@ -982,7 +992,7 @@ static switch_status_t switch_opus_encode_repacketize(switch_codec_t *codec, bytes = opus_encode(context->encoder_object, (opus_int16 *) dec_ptr_buf, frame_size, enc_ptr_buf, len); if (bytes < 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoder Error: %s Decoded Datalen %u Codec NumberChans %u" \ + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "Encoder Error: %s Decoded Datalen %u Codec NumberChans %u" \ "Len %u DecodedDate %p EncodedData %p ContextEncoderObject %p enc_frame_size: %d\n", opus_strerror(bytes), decoded_data_len, codec->implementation->number_of_channels, len, (void *) decoded_data, (void *) encoded_data, (void *) context->encoder_object, context->enc_frame_size); @@ -991,7 +1001,7 @@ static switch_status_t switch_opus_encode_repacketize(switch_codec_t *codec, /* enc_ptr_buf : Opus API manual: "The application must ensure this pointer remains valid until the next call to opus_repacketizer_init() or opus_repacketizer_destroy()." */ ret = opus_repacketizer_cat(rp, enc_ptr_buf, bytes); if (ret != OPUS_OK) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opus encoder: error while repacketizing (cat) : %s !\n",opus_strerror(ret)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "Opus encoder: error while repacketizing (cat) : %s !\n",opus_strerror(ret)); switch_goto_status(SWITCH_STATUS_GENERR, end); } enc_ptr_buf += bytes; @@ -1000,18 +1010,18 @@ static switch_status_t switch_opus_encode_repacketize(switch_codec_t *codec, } /* this will never happen, unless there is a huge and unsupported number of frames */ if (total_len + opus_repacketizer_get_nb_frames(rp) > len / 2) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opus encoder: error while repacketizing: not enough buffer space\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "Opus encoder: error while repacketizing: not enough buffer space\n"); switch_goto_status(SWITCH_STATUS_GENERR, end); } ret = opus_repacketizer_out(rp, encoded_data, total_len+opus_repacketizer_get_nb_frames(rp)); if (globals.debug || context->debug) { int samplerate = context->enc_frame_size * 1000 / (codec->implementation->microseconds_per_packet / 1000); - switch_opus_info(encoded_data, ret, samplerate, "encode_repacketize"); + switch_opus_info(codec->session, encoded_data, ret, samplerate, "encode_repacketize"); } if (ret <= 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opus encoder: error while repacketizing (out) : %s ! packed nb_frames: %d\n", opus_strerror(ret), opus_repacketizer_get_nb_frames(rp)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "Opus encoder: error while repacketizing (out) : %s ! packed nb_frames: %d\n", opus_strerror(ret), opus_repacketizer_get_nb_frames(rp)); switch_goto_status(SWITCH_STATUS_GENERR, end); } if (want_fec) { @@ -1052,25 +1062,25 @@ static switch_status_t opus_load_config(switch_bool_t reload) char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(key, "use-vbr") && !zstr(val)) { - opus_prefs.use_vbr = atoi(val); + opus_prefs.use_vbr = switch_true(val); } else if (!strcasecmp(key, "use-dtx")) { - opus_prefs.use_dtx = atoi(val); + opus_prefs.use_dtx = switch_true(val); } else if (!strcasecmp(key, "complexity")) { opus_prefs.complexity = atoi(val); } else if (!strcasecmp(key, "packet-loss-percent")) { opus_prefs.plpct = atoi(val); } else if (!strcasecmp(key, "asymmetric-sample-rates")) { - opus_prefs.asymmetric_samplerates = atoi(val); + opus_prefs.asymmetric_samplerates = switch_true(val); } else if (!strcasecmp(key, "bitrate-negotiation")) { - opus_prefs.bitrate_negotiation = atoi(val); + opus_prefs.bitrate_negotiation = switch_true(val); } else if (!strcasecmp(key, "use-jb-lookahead")) { opus_prefs.use_jb_lookahead = switch_true(val); } else if (!strcasecmp(key, "keep-fec-enabled")) { /* encoder */ - opus_prefs.keep_fec = atoi(val); + opus_prefs.keep_fec = switch_true(val); } else if (!strcasecmp(key, "advertise-useinbandfec")) { /*decoder, has meaning only for FMTP: useinbandfec=1 by default */ - opus_prefs.fec_decode = atoi(val); + opus_prefs.fec_decode = switch_true(val); } else if (!strcasecmp(key, "adjust-bitrate")) { /* encoder, this setting will make the encoder adjust its bitrate based on a feedback loop (RTCP). This is not "VBR".*/ - opus_prefs.adjust_bitrate = atoi(val); + opus_prefs.adjust_bitrate = switch_true(val); } else if (!strcasecmp(key, "maxaveragebitrate")) { opus_prefs.maxaveragebitrate = atoi(val); if (opus_prefs.maxaveragebitrate < SWITCH_OPUS_MIN_BITRATE || opus_prefs.maxaveragebitrate > SWITCH_OPUS_MAX_BITRATE) { @@ -1087,7 +1097,7 @@ static switch_status_t opus_load_config(switch_bool_t reload) opus_prefs.sprop_maxcapturerate = 0; /* value not supported */ } } else if (!strcasecmp(key, "mono")) { - opus_prefs.mono = atoi(val); + opus_prefs.mono = switch_true(val); } } } @@ -1105,7 +1115,7 @@ static switch_status_t switch_opus_keep_fec_enabled(switch_codec_t *codec) uint32_t LBRR_threshold_bitrate,LBRR_rate_thres_bps,real_target_bitrate ; opus_int32 a32,b32; uint32_t fs = context->enc_frame_size * 1000 / (codec->implementation->microseconds_per_packet / 1000); - float frame_rate =(float)(1000 / (codec->implementation->microseconds_per_packet / 1000)); + float frame_rate =(float)(1000 / (float)(codec->implementation->microseconds_per_packet / 1000)); uint32_t step = (codec->implementation->microseconds_per_packet / 1000) != 60 ? 8000 / (codec->implementation->microseconds_per_packet / 1000 ) : 134 ; opus_encoder_ctl(context->encoder_object, OPUS_GET_BITRATE(¤t_bitrate)); @@ -1132,7 +1142,7 @@ static switch_status_t switch_opus_keep_fec_enabled(switch_codec_t *codec) LBRR_threshold_bitrate = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16); if (!real_target_bitrate || !LBRR_threshold_bitrate) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opus encoder: error while controlling FEC params\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_ERROR, "Opus encoder: error while controlling FEC params\n"); return SWITCH_STATUS_FALSE; } @@ -1141,7 +1151,7 @@ static switch_status_t switch_opus_keep_fec_enabled(switch_codec_t *codec) if (real_target_bitrate > LBRR_threshold_bitrate) { /*FEC is already enabled, do nothing*/ if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: FEC is enabled\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "Opus encoder: FEC is enabled\n"); } return SWITCH_STATUS_SUCCESS; } else { @@ -1153,13 +1163,40 @@ static switch_status_t switch_opus_keep_fec_enabled(switch_codec_t *codec) opus_encoder_ctl(context->encoder_object,OPUS_SET_BITRATE(current_bitrate)); if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: increased bitrate to [%d] to keep FEC enabled\n", current_bitrate); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "Opus encoder: increased bitrate to [%d] to keep FEC enabled\n", current_bitrate); } return SWITCH_STATUS_SUCCESS; } } +static switch_bool_t switch_opus_vad(struct opus_context *context, void *encoded_data, uint32_t encoded_data_len) +{ + const uint8_t *payload = (const uint8_t *)encoded_data; + opus_packet_info_t opus_packet_info; + switch_bool_t debug = (globals.debug || context->debug > 1); + + if (!switch_opus_packet_parse(payload, encoded_data_len, &opus_packet_info, debug)) { + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "OPUS PACKET PARSING ERROR len:%d bytes:%02x %02x\n", + (int)encoded_data_len, payload[0], payload[1]); + } + + return SWITCH_TRUE; + } + + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "OPUS EXTRACT PAYLOAD VAD len:%d vad_ms:%d bytes:%02x %02x\n", + (int)encoded_data_len, opus_packet_info.vad_ms, payload[0], payload[1]); + } + + if (opus_packet_info.vad_ms == 0) { + return SWITCH_FALSE; + } + + return SWITCH_TRUE; +} + static switch_status_t switch_opus_control(switch_codec_t *codec, switch_codec_control_command_t cmd, switch_codec_control_type_t ctype, @@ -1229,7 +1266,7 @@ static switch_status_t switch_opus_control(switch_codec_t *codec, } if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: Adjusting packet loss percent from %d%% to %d%%!\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "Opus encoder: Adjusting packet loss percent from %d%% to %d%%!\n", context->old_plpct, plpct); } } @@ -1243,7 +1280,7 @@ static switch_status_t switch_opus_control(switch_codec_t *codec, float steps = (float)((float)(range / 100) / base_step); int br_step = (int)(round(steps) * base_step) * plpct; if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "Opus encoder: bitrate increase/decrease step now is: %d bps, range:%d\n", br_step, range); } context->control_state.increase_step = context->control_state.decrease_step = br_step; @@ -1251,6 +1288,15 @@ static switch_status_t switch_opus_control(switch_codec_t *codec, context->old_plpct = plpct; } break; + case SCC_AUDIO_VAD: + { + void *encoded_data = (void *)cmd_data; + uint16_t *encoded_data_len = (uint16_t *)cmd_arg; + switch_bool_t *ret = (switch_bool_t *)*ret_data; + + *ret = switch_opus_vad(context, encoded_data, *encoded_data_len); + } + break; case SCC_AUDIO_ADJUST_BITRATE: { const char *cmd = (const char *)cmd_data; @@ -1269,7 +1315,7 @@ static switch_status_t switch_opus_control(switch_codec_t *codec, opus_prefs.keep_fec = 1; /* enable back FEC if it was disabled by SCC_AUDIO_ADJUST_BITRATE, we have enough network bandwidth now */ } if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (increase)\n", current_bitrate+br_step); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (increase)\n", current_bitrate+br_step); } } } else if (!strcasecmp(cmd, "decrease")) { @@ -1283,7 +1329,7 @@ static switch_status_t switch_opus_control(switch_codec_t *codec, } opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(current_bitrate-br_step)); if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (decrease)\n", current_bitrate-br_step); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (decrease)\n", current_bitrate-br_step); } } } else if (!strcasecmp(cmd, "default")) { @@ -1293,7 +1339,7 @@ static switch_status_t switch_opus_control(switch_codec_t *codec, opus_prefs.keep_fec = 1; /* enable back FEC, we have enough network bandwidth now */ } if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (configured maxaveragebitrate)\n", opus_prefs.maxaveragebitrate); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (configured maxaveragebitrate)\n", opus_prefs.maxaveragebitrate); } } else { /* set Opus minimum bitrate */ @@ -1302,7 +1348,7 @@ static switch_status_t switch_opus_control(switch_codec_t *codec, opus_prefs.keep_fec = 0; /* do not enforce FEC anymore, we're low on network bandwidth */ } if (globals.debug || context->debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (minimum)\n", SWITCH_OPUS_MIN_BITRATE); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (minimum)\n", SWITCH_OPUS_MIN_BITRATE); } } } @@ -1340,7 +1386,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load) { switch_codec_interface_t *codec_interface; switch_api_interface_t *commands_api_interface; - int samples = 480; + int samples = 480; /* start with 10 ms ptime */ int bytes = 960; int mss = 10000; int x = 0; @@ -1441,7 +1487,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load) } /* 16 khz */ - samples = 480; + samples = 160; bytes = 320; mss = 10000; rate = 16000; @@ -1538,7 +1584,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load) } /* 8 khz */ - samples = 480; + samples = 80; bytes = 160; mss = 10000; rate = 8000; diff --git a/src/mod/codecs/mod_opus/opus_parse.c b/src/mod/codecs/mod_opus/opus_parse.c new file mode 100644 index 0000000000..48f596836a --- /dev/null +++ b/src/mod/codecs/mod_opus/opus_parse.c @@ -0,0 +1,401 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2023, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Claude Lamblin + * Julien Chavanton + * + */ + +#include "switch.h" +#include "opus.h" +#include "opus_parse.h" +/* Tables for LBRR_sympbol decoding */ + +static const opus_int16 silk_LBRR_flags_2_PDFCum[3] = { 53, 106, 256 }; /* 256 - silk_LBRR_flags_2_iCDF[i] ; silk_LBRR_flags_2_iCDF[ 3 ] = { 203, 150, 0 }; */ +static const opus_int16 silk_LBRR_flags_3_PDFCum[7] = { 41, 61, 90, 131, 146, 174, 256 }; /* 256 - silk_LBRR_flags_3_iCDF[i] ; silk_LBRR_flags_3_iCDF[ 7 ] = { 215, 195, 166, 125, 110, 82, 0 }; */ + +/* Get the number of VAD flags - i.e. number of 20 ms frame - from the config + * in a silk-only or hybrid opus frame mono or stereo + * 5 MSB TOC byte (see table 2 of IETF RFC6716 clause 3.1) + * if 10 ms frame (config=0, 4, 8, 12, 14) : return 1 + * if CELT_only frame no VAD flag =>return 0 */ +static opus_int16 switch_opus_get_nb_flags_in_silk_frame(int16_t config) +{ + opus_int16 silk_frame_nb_flags; + + if (config > 15) { + /* CELT_only frame no VAD flag nor LBRR flag */ + silk_frame_nb_flags = 0; + } else { + silk_frame_nb_flags = 1; /* default */ + + if (config < 12) { + /* silk-only NB, MB or WB + * The least two significant bits give the number of VAD flags inside the silk frame 1, 2 or 3 */ + silk_frame_nb_flags = config & 0x3; + + if (silk_frame_nb_flags == 0) { /* 0 => 10ms frame : one VAD flag */ + silk_frame_nb_flags++; + } + } + } + + return silk_frame_nb_flags; +} + +/* Get the time in ms corresponding to one VAD flag from the config + * in a silk-only or hybrid opus frame mono or stereo + * 5 MSB TOC byte (see table 2 of IETF RFC6716 clause 3.1) + * if CELT_only frame (config >15) no VAD flag =>return FALSE + * if 10 ms frame (config=0, 4, 8, 12, 14) : return 10 + * otherwise return 20 */ +static opus_int16 switch_opus_get_silk_frame_ms_per_flag(int16_t config, opus_int16 silk_frame_nb_flags) +{ + opus_int16 silk_size_frame_ms_per_flag; + + if (config > 15) { + /* CELT_only frame no VAD flag nor LBRR flag */ + /* switch_opus_get_silk_frame_ms_per_flag: code not written for CELT-only mode */ + + return 0; + } + + silk_size_frame_ms_per_flag = 20; /* default*/ + if (silk_frame_nb_flags == 1) { /* could be 10 or 20 ms */ + if ((config & 0x01) == 0) { + silk_size_frame_ms_per_flag = 10; + } + } + + return silk_size_frame_ms_per_flag; +} + +/* Code written only for mono, silk-only or hybrid mode + * for CELT-only frame no vad flags for LBRR flag the routine must not be called + * for stereo : the mid frame VAD_flags and the LBRR_flag could be obtained + * yet, to get the LBRR_flags of the mid frame the routine should be modified + * to skip the side VAD flags and the side LBRR flag and to get the mid LBRR_symbol */ +static void switch_opus_get_VAD_LBRR_flags(const uint8_t *buf, opus_int16 silk_frame_nb_flags, + opus_int16 *VAD_flags, opus_int16 *LBRR_flags, opus_int16 *nb_VAD1, opus_int16 *nb_FEC) +{ + const opus_int16 *ptr_pdf_cum; + opus_int nb_pdf_symbol; + opus_uint16 LBRR_symbol; + opus_int16 val, nb_bit, compl_nb_bit, mask, mask2; + opus_int16 *ptr_flags; + opus_int16 LBRR_flag; + opus_int16 nb_vad, nb_fec; + int i; + + nb_vad = 0; + nb_fec = 0; + + /* Get VAD_FLAGS & LBRR_FLAG + * silk_frame_nb_flags = 1 (10 or 20 ms), the two MSB of the first byte are the VAD flag and the LBRR flag + * silk_frame_nb_flags = 2 (40 ms), the three MSB of the first byte are the two VAD flags and the LBRR flag + * silk_frame_nb_flags = 3 (60 ms), the four MSB of the first byte are the three VAD flags and the LBRR flag + * compute the number of MSB to analyze */ + nb_bit = silk_frame_nb_flags + 1; + + /* number of right shifts to apply to the first byte to only have the bits of LBRR flag and of the VAD flags */ + compl_nb_bit = 8 - nb_bit; + mask = (1 << nb_bit) - 1; + + /* The bits of the silk_frame_nb_flags VAD flags and the LBRR flag are the MSB of the first byte + * silk_frame_nb_flags = 1 (10 or 20 ms), VAD_flags(0) | LBRR_flag + * silk_frame_nb_flags = 2 (40 ms), VAD_flags(0) | VAD_flags(1) | LBRR_flag + * silk_frame_nb_flags = 3 (60 ms), VAD_flags(0) | VAD_flags(1) | VAD_flags(2) |LBRR_flag */ + val = (buf[0] >> compl_nb_bit) & mask; + + LBRR_flag = val & 0x1; /* LBRR_FLAG LSB */ + + /* get VAD_flags */ + ptr_flags = VAD_flags + silk_frame_nb_flags; + for (i = 0; i < silk_frame_nb_flags; i++) { + LBRR_flags[i] = 0; /* init */ + val >>= 1; + *(--ptr_flags) = val & 0x1; + } + + if (LBRR_flag != 0) { /* there is at least one LBRR frame */ + if (silk_frame_nb_flags == 1) { + LBRR_flags[0] = 1; + nb_fec = 1; + } else { /* get LBRR_symbol then LBRR_flags */ + /* LBRR symbol is encoded with range encoder : range on 8 bits + * silk_frame_nb_flags = 2 ; 3 possible values for LBRR_flags(1) | LBRR_flags(0))= 01, 10, 11 + * silk_frame_nb_flags = 3 ; 7 possible values for LBRR_flags(2) | LBRR_flags(1) | LBRR_flags(0))= 001, 010, 011, 100, 101, 110, 111 */ + mask2 = (1 << compl_nb_bit) - 1; + /* get next 8 bits: (8-nb_bit) LSB of the first byte and nb_bit MSB of the second byte */ + val = (((buf[0]) & mask2) << nb_bit) | ((buf[1] >> compl_nb_bit) & mask); + + if (silk_frame_nb_flags == 2) { + nb_pdf_symbol = 3; + ptr_pdf_cum = silk_LBRR_flags_2_PDFCum; + } else { + nb_pdf_symbol = 7; + ptr_pdf_cum = silk_LBRR_flags_3_PDFCum; + } + + LBRR_symbol = 0; + for (i = 1; i <= nb_pdf_symbol; i++) { + if (val < *ptr_pdf_cum++) { + LBRR_symbol = i; + break; + } + } + + for (i = 0; i < silk_frame_nb_flags; i++) { + LBRR_flags[i] = LBRR_symbol & 0x01; + LBRR_symbol >>= 1; + nb_fec += LBRR_flags[i]; + } + } + } + + for (i = 0; i < silk_frame_nb_flags; i++) { + nb_vad += VAD_flags[i]; + } + + *nb_VAD1 = nb_vad; + *nb_FEC = nb_fec; + + return; +} + +/* Parse the packet to retrieve informations about its content + * RFC6716: Definition of the Opus Audio Codec + * return: SWITCH_FALSE if there was a problem found parsing the packet, the info returned should be ignored. + * */ +switch_bool_t switch_opus_packet_parse(const uint8_t *payload, int payload_length_bytes, opus_packet_info_t *packet_info, switch_bool_t debug) +{ + int f; + int32_t samplerate; + int i, shift_silk, silk_frame_packet; + int16_t vad_flags_per_silk_frame, fec_flags_per_silk_frame; + opus_int16 frame_sizes[48]; + const unsigned char *frame_data[48]; + opus_int16 packet_LBBR_FLAGS[3 * 48], packet_VAD_FLAGS[3 * 48]; + opus_int16 *ptr_LBBR_FLAGS, *ptr_VAD_FLAGS; + opus_int16 silk_frame_nb_flags, silk_size_frame_ms_per_flag; + opus_int16 silk_frame_nb_fec, silk_frame_nb_vad1; + opus_int sample_per_frame; + + packet_info->config = 0; + packet_info->fec = 0; + packet_info->fec_ms = 0; + packet_info->vad = 0; + packet_info->vad_ms = 0; + packet_info->stereo = FALSE; + packet_info->frames = 0; + packet_info->channels = 1; /* as stereo is set to FALSE */ + packet_info->ms_per_frame = 0; + packet_info->ptime_ts = 0; + + if (payload == NULL || payload_length_bytes <= 0) { + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "opus_packet_parse: payload null."); + } + + return SWITCH_FALSE; + } + + /* In CELT_ONLY mode, packets should not have FEC. */ + if (payload[0] & 0x80) { + /* opus_packet_parse: CELT_ONLY mode, we do not support this mode. */ + return SWITCH_FALSE; + } else { + int mode = (payload[0] >> 3); + + if (mode <= 3) { + samplerate = 8000; + } else if (mode <= 7) { + samplerate = 12000; + } else if (mode <= 11) { + samplerate = 16000; + } else if (mode <= 13) { + samplerate = 24000; + } else if (mode <= 15) { + samplerate = 48000; + } else { + /* opus_packet_parse: CELT_ONLY mode, we do not support this mode. */ + return SWITCH_FALSE; + } + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "opus_packet_parse: mode[%d]s[%d]c[%d] [%d]Hz\n", mode, (payload[0] >> 2) & 0x1, (payload[0]) & 0x3, samplerate); + } + } + + if (payload[0] & 0x04) { + packet_info->stereo = TRUE; + packet_info->channels = 2; + } + + packet_info->config = payload[0] >> 3; + sample_per_frame = opus_packet_get_samples_per_frame(payload, samplerate); + packet_info->ms_per_frame = sample_per_frame * 1000 / samplerate; + if (packet_info->ms_per_frame < 10 || packet_info->ms_per_frame > 120) { + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "opus_packet_parse: invalid packet."); + } + + return SWITCH_FALSE; + } + + packet_info->frames = opus_packet_parse(payload, payload_length_bytes, NULL, frame_data, frame_sizes, NULL); + if (packet_info->frames < 0) { + packet_info->frames = 0; + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "opus_packet_parse: opus_packet_parse found no frame.\n"); + } + + return SWITCH_FALSE; + } + + packet_info->ptime_ts = packet_info->frames * sample_per_frame; + + if (frame_sizes[0] <= 1) { + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "opus_packet_parse: opus_packet_parse frame size too small.\n"); + } + + return SWITCH_FALSE; + } + + /* +---------------+-----------+-----------+-------------------+ + | Configuration | Mode | Bandwidth | Frame Sizes | + | Number(s) | | | | + +---------------+-----------+-----------+-------------------+ + | 0...3 | SILK-only | NB | 10, 20, 40, 60 ms | + | 4...7 | SILK-only | MB | 10, 20, 40, 60 ms | + | 8...11 | SILK-only | WB | 10, 20, 40, 60 ms | + | 12...13 | Hybrid | SWB | 10, 20 ms | + | 14...15 | Hybrid | FB | 10, 20 ms | + | 16...19 | CELT-only | NB | 2.5, 5, 10, 20 ms | + | 20...23 | CELT-only | WB | 2.5, 5, 10, 20 ms | + | 24...27 | CELT-only | SWB | 2.5, 5, 10, 20 ms | + | 28...31 | CELT-only | FB | 2.5, 5, 10, 20 ms | + +---------------+-----------+-----------+-------------------+ */ + + if (!packet_info->stereo) { + /* The routines opus_get_nb_flags_in_silk_frame and opus_get_silk_frame_ms_per_flag are also valid for stereo frames + * yet the routine opus_get_VAD_LBRR_flags is currently only for mono frame */ + silk_frame_nb_flags = switch_opus_get_nb_flags_in_silk_frame(packet_info->config); /* =1 for 10 or 20 ms frame; = 2 for 40 ms; = 3 for 60 ms */ + if (!silk_frame_nb_flags) { + /* We should not go there as CELT_ONLY is already tested above */ + return SWITCH_FALSE; + } + + packet_info->frames_silk = silk_frame_nb_flags; + silk_size_frame_ms_per_flag = switch_opus_get_silk_frame_ms_per_flag(packet_info->config, silk_frame_nb_flags); /* 10 or 20 ms frame*/ + if (!silk_size_frame_ms_per_flag) { + /* we should not go there as CELT_ONLY is already tested above */ + return SWITCH_FALSE; + } + + ptr_LBBR_FLAGS = packet_LBBR_FLAGS; + ptr_VAD_FLAGS = packet_VAD_FLAGS; + + for (f = 0; f < packet_info->frames; f++) { + switch_opus_get_VAD_LBRR_flags(frame_data[f], silk_frame_nb_flags, ptr_VAD_FLAGS, ptr_LBBR_FLAGS, + &silk_frame_nb_vad1, &silk_frame_nb_fec); + packet_info->vad += silk_frame_nb_vad1; + packet_info->fec += silk_frame_nb_fec; + packet_info->vad_ms += silk_frame_nb_vad1 * silk_size_frame_ms_per_flag; + packet_info->fec_ms += silk_frame_nb_fec * silk_size_frame_ms_per_flag; + + ptr_VAD_FLAGS += silk_frame_nb_flags; + ptr_LBBR_FLAGS += silk_frame_nb_flags; + } + + /* store the VAD & LBRR flags of all 20 ms silk-frames of the packet; LSB the first frame, MSB: the last */ + vad_flags_per_silk_frame = 0; + fec_flags_per_silk_frame = 0; + silk_frame_packet = packet_info->frames * packet_info->frames_silk; + if (silk_frame_packet > 15) { + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "opus_packet_parse: more than %d 20-ms frames in the packet ; only first 15 silk-frames data will be stored (pb silkFastAccelerate)\n", silk_frame_packet); + } + + silk_frame_packet = 15; + } + + ptr_LBBR_FLAGS = packet_LBBR_FLAGS; + ptr_VAD_FLAGS = packet_VAD_FLAGS; + shift_silk = 0; + for (i = 0; i < silk_frame_packet; i++) { + vad_flags_per_silk_frame += (*ptr_VAD_FLAGS) << shift_silk; + fec_flags_per_silk_frame += (*ptr_LBBR_FLAGS) << shift_silk; + shift_silk++; + ptr_LBBR_FLAGS++; ptr_VAD_FLAGS++; + } + + packet_info->vad_flags_per_silk_frame = vad_flags_per_silk_frame; + packet_info->fec_flags_per_silk_frame = fec_flags_per_silk_frame; + + return SWITCH_TRUE; + } + + if (packet_info->config != 1 && packet_info->config != 5 && packet_info->config != 9) { + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "opus_packet_parse: the current parser implementation does not support muliple SILK frames for VAD or FEC detection.\n"); + } + + return SWITCH_FALSE; + } + + /* + * Parse the VAD and LBRR flags in each Opus frame + * */ + for (f = 0; f < packet_info->frames; f++) { + if (frame_data[f][0] & 0x80) { + packet_info->vad++; + } + + if (frame_data[f][0] & 0x40) { + packet_info->fec++; + } + + if (debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "opus_packet_parse: LP layer opus_frame[%d] VAD[%d] FEC[%d]\n", f + 1, (frame_data[f][0] & 0x80) >> 7, (frame_data[f][0] & 0x40) >> 6); + } + } + + packet_info->vad_ms = packet_info->vad * packet_info->ms_per_frame; + packet_info->fec_ms = packet_info->fec * packet_info->ms_per_frame; + + return SWITCH_TRUE; +} + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/codecs/mod_opus/opus_parse.h b/src/mod/codecs/mod_opus/opus_parse.h new file mode 100644 index 0000000000..7f1d144754 --- /dev/null +++ b/src/mod/codecs/mod_opus/opus_parse.h @@ -0,0 +1,69 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2023, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Julien Chavanton + * + */ + +#ifndef SWITCH_OPUS_PARSE_H +#define SWITCH_OPUS_PARSE_H + +typedef enum { false, true } bool_t; + +typedef struct opus_packet_info { + int16_t vad; + int16_t vad_ms; + int16_t fec; + int16_t fec_ms; + bool_t stereo; + /* number of opus frames in the packet */ + int16_t frames; + int16_t config; + int16_t channels; + int16_t ms_per_frame; + int32_t ptime_ts; + bool_t valid; + /* number of silk_frames in an opus frame */ + int16_t frames_silk; + /* VAD flag of all 20 ms silk-frames of the packet; LSB the first frame, MSB: the last */ + int16_t vad_flags_per_silk_frame; + /* LBRR (FEC) flag of all 20 ms silk-frames of the packet; LSB the first frame, MSB: the last */ + int16_t fec_flags_per_silk_frame; +} opus_packet_info_t; + +switch_bool_t switch_opus_packet_parse(const uint8_t *payload, int payload_length_bytes, opus_packet_info_t *packet_info, switch_bool_t debug); + +#endif /* SWITCH_OPUS_PARSE_H */ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: + */ diff --git a/src/mod/databases/mod_mariadb/mod_mariadb.c b/src/mod/databases/mod_mariadb/mod_mariadb.c index 7926ec0c3f..09b67468bb 100644 --- a/src/mod/databases/mod_mariadb/mod_mariadb.c +++ b/src/mod/databases/mod_mariadb/mod_mariadb.c @@ -411,7 +411,7 @@ switch_status_t mariadb_finish_results_real(const char* file, const char* func, if ((status = mysql_next_result(&handle->con))) { if (status > 0) { err_str = mariadb_handle_get_error(handle); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "An error occurred trying to get next for query (%s): %s\n", handle->sql, err_str); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "An error occurred trying to get next for query (%s): %s\n", handle->sql, switch_str_nil(err_str)); switch_safe_free(err_str); break; @@ -627,13 +627,27 @@ switch_status_t mariadb_send_query(mariadb_handle_t *handle, const char* sql) { char *err_str; int ret; + unsigned retries = 60; /* 60 tries, will take 30 to 60 seconds at worst */ switch_safe_free(handle->sql); handle->sql = strdup(sql); + again: handle->stored_results = 0; ret = mysql_real_query(&handle->con, sql, (unsigned long)strlen(sql)); if (ret) { err_str = mariadb_handle_get_error(handle); + if (strstr(err_str, "Deadlock found when trying to get lock; try restarting transaction")) { + if (--retries > 0) { + switch_safe_free(err_str); + /* We are waiting for 500 ms and random time is not more than 500 ms. + This is necessary so that the delay on the primary and secondary servers does not coincide and deadlock does not occur again. */ + switch_yield(500 + (rand() & 511)); + goto again; + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DeadLock. The retries are over.\n"); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to send query (%s) to database: %s\n", sql, err_str); switch_safe_free(err_str); mariadb_finish_results(handle); diff --git a/src/mod/databases/mod_pgsql/mod_pgsql.c b/src/mod/databases/mod_pgsql/mod_pgsql.c index 575252223b..0308f1f1fd 100644 --- a/src/mod/databases/mod_pgsql/mod_pgsql.c +++ b/src/mod/databases/mod_pgsql/mod_pgsql.c @@ -629,6 +629,8 @@ done: error: + pgsql_free_result(&result); + return SWITCH_STATUS_FALSE; } diff --git a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c index 24119f6f8c..652d292e65 100644 --- a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c +++ b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c @@ -142,6 +142,7 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt) if (!caller_profile || zstr(caller_profile->destination_number)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n"); + return NULL; } @@ -150,6 +151,7 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt) if (!switch_config_open_file(&cfg, cf)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return NULL; } @@ -226,12 +228,14 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt) } } else { if (pattern && strcasecmp(pattern, field_data)) { + switch_safe_free(field_expanded); continue; } } if (cid) { if (strcasecmp(cid, caller_profile->caller_id_number)) { + switch_safe_free(field_expanded); continue; } } @@ -266,15 +270,19 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt) switch_perform_substitution(re, proceed, argument, field_data, substituted, sizeof(substituted), ovector); argument = substituted; } + switch_regex_safe_free(re); if (!extension) { if (zstr(field_data)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No extension!\n"); + switch_safe_free(field_expanded); break; } + if ((extension = switch_caller_extension_new(session, field_data, field_data)) == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); + switch_safe_free(field_expanded); break; } } diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 62eba524d3..acd578e2e2 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -1296,9 +1296,9 @@ error: } switch_mutex_unlock(endpoint->mutex); } - if (new_session && *new_session) { - switch_core_session_destroy(new_session); - } + + switch_core_session_destroy(new_session); + return retcause; } diff --git a/src/mod/endpoints/mod_rtmp/handshake.h b/src/mod/endpoints/mod_rtmp/handshake.h index 19c77810b0..bfbea48289 100644 --- a/src/mod/endpoints/mod_rtmp/handshake.h +++ b/src/mod/endpoints/mod_rtmp/handshake.h @@ -42,6 +42,7 @@ #if OPENSSL_VERSION_NUMBER < 0x0090800 || !defined(SHA256_DIGEST_LENGTH) #error Your OpenSSL is too old, need 0.9.8 or newer with SHA256 #endif +#if OPENSSL_VERSION_NUMBER < 0x30000000L #if OPENSSL_VERSION_NUMBER < 0x10100000L #define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0) #define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, buf, len) @@ -51,6 +52,7 @@ #define HMAC_crunch(ctx, buf, len)HMAC_Update(ctx, buf, len) #define HMAC_finish(ctx, dig, dlen) HMAC_Final(ctx, dig, &dlen); HMAC_CTX_free(ctx) #endif +#endif #define FP10 #define RTMP_SIG_SIZE 1536 @@ -155,9 +157,13 @@ static unsigned int GetDigestOffset1(uint8_t *handshake, unsigned int len) static getoff *digoff[] = {GetDigestOffset1, GetDigestOffset2}; // static getoff *dhoff[] = {GetDHOffset1, GetDHOffset2}; -static void HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t *key, size_t keylen, uint8_t *digest) +static void HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t *key, int keylen, uint8_t *digest) { unsigned int digestLen; + +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + HMAC(EVP_sha256(), key, keylen, (uint8_t *)message, messageLen, digest, &digestLen); +#else #if OPENSSL_VERSION_NUMBER < 0x10100000L HMAC_CTX ctx; #else @@ -167,11 +173,12 @@ static void HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t HMAC_setup(ctx, key, (int)keylen); HMAC_crunch(ctx, message, messageLen); HMAC_finish(ctx, digest, digestLen); +#endif assert(digestLen == 32); } -static void CalculateDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, size_t keyLen, uint8_t *digest) +static void CalculateDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, int keyLen, uint8_t *digest) { const int messageLen = RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH; uint8_t message[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH]; @@ -184,7 +191,7 @@ static void CalculateDigest(unsigned int digestPos, uint8_t *handshakeMessage, c HMACsha256(message, messageLen, key, keyLen, digest); } -static int VerifyDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, size_t keyLen) +static int VerifyDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, int keyLen) { uint8_t calcDigest[SHA256_DIGEST_LENGTH]; diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index c6cfc716c7..64464e4ef6 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -2136,7 +2136,7 @@ void launch_skinny_profile_thread(skinny_profile_t *profile) { /*****************************************************************************/ /* MODULE FUNCTIONS */ /*****************************************************************************/ -switch_endpoint_interface_t *skinny_get_endpoint_interface() +switch_endpoint_interface_t *skinny_get_endpoint_interface(void) { return skinny_endpoint_interface; } diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index 69096ab64e..aff2ee92c0 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -355,7 +355,7 @@ switch_status_t channel_kill_channel(switch_core_session_t *session, int sig); /*****************************************************************************/ /* MODULE FUNCTIONS */ /*****************************************************************************/ -switch_endpoint_interface_t *skinny_get_endpoint_interface(); +switch_endpoint_interface_t *skinny_get_endpoint_interface(void); /*****************************************************************************/ /* TEXT FUNCTIONS */ diff --git a/src/mod/endpoints/mod_skinny/skinny_api.c b/src/mod/endpoints/mod_skinny/skinny_api.c index f79f36c014..4657a5a9d3 100644 --- a/src/mod/endpoints/mod_skinny/skinny_api.c +++ b/src/mod/endpoints/mod_skinny/skinny_api.c @@ -697,7 +697,7 @@ switch_status_t skinny_api_register(switch_loadable_module_interface_t **module_ return SWITCH_STATUS_SUCCESS; } -switch_status_t skinny_api_unregister() +switch_status_t skinny_api_unregister(void) { switch_console_set_complete("del skinny"); diff --git a/src/mod/endpoints/mod_skinny/skinny_api.h b/src/mod/endpoints/mod_skinny/skinny_api.h index e246957f0d..833d0c15da 100644 --- a/src/mod/endpoints/mod_skinny/skinny_api.h +++ b/src/mod/endpoints/mod_skinny/skinny_api.h @@ -34,7 +34,7 @@ #define _SKINNY_API_H switch_status_t skinny_api_register(switch_loadable_module_interface_t **module_interface); -switch_status_t skinny_api_unregister(); +switch_status_t skinny_api_unregister(void); #endif /* _SKINNY_API_H */ diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index 0ae1772521..574f2a907e 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -92,14 +92,14 @@ char* skinny_codec2string(skinny_codecs skinnycodec); /*****************************************************************************/ #define skinny_create_message(message,msgtype,field) \ - message = calloc(1, 12 + sizeof(message->data.field)); \ + message = calloc(1, sizeof(skinny_message_t)); \ message->type = msgtype; \ message->length = 4 + sizeof(message->data.field) #define skinny_create_empty_message(message,msgtype) \ - message = calloc(1, 12); \ - message->type = msgtype; \ - message->length = 4 + message = calloc(1, sizeof(skinny_empty_message_t)); \ + ((skinny_empty_message_t *)message)->type = msgtype; \ + ((skinny_empty_message_t *)message)->length = 4 /* KeepAliveMessage */ @@ -937,6 +937,12 @@ union skinny_data { #pragma pack(push, r1, 1) #endif +struct PACKED skinny_empty_message { + uint32_t length; + uint32_t version; + uint32_t type; +}; + /* * header is length+version * body is type+data @@ -954,6 +960,7 @@ struct PACKED skinny_message { #endif typedef struct skinny_message skinny_message_t; +typedef struct skinny_empty_message skinny_empty_message_t; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 0b74b89c9d..f58bb40ac0 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -54,7 +54,7 @@ switch_endpoint_interface_t *sofia_endpoint_interface; #define STRLEN 15 -void mod_sofia_shutdown_cleanup(); +void mod_sofia_shutdown_cleanup(void); static switch_status_t sofia_on_init(switch_core_session_t *session); static switch_status_t sofia_on_exchange_media(switch_core_session_t *session); @@ -348,6 +348,7 @@ static int hangup_cause_to_sip(switch_call_cause_t cause) case SWITCH_CAUSE_BUSY_EVERYWHERE: return 600; case SWITCH_CAUSE_DECLINE: + case SWITCH_CAUSE_REJECT_ALL: return 603; case SWITCH_CAUSE_DOES_NOT_EXIST_ANYWHERE: return 604; @@ -472,7 +473,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) 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) { + if (tech_pvt->profile->pres_type) { char *sql = switch_mprintf("delete from sip_dialogs where uuid='%q'", switch_core_session_get_uuid(session)); switch_assert(sql); sofia_glue_execute_sql_now(tech_pvt->profile, &sql, SWITCH_TRUE); @@ -2205,11 +2206,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi argv[i], (double)((double)(MAX_REDIR + 1 - i))/1000); } } else { - if (i == argc - 1) { - switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>", argv[i]); - } else { - switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>,", argv[i]); - } + switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>", argv[i]); } } else { if (i == argc - 1) { @@ -3258,8 +3255,6 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl switch_hash_index_t *hi; void *val; const void *vvar; - int c = 0; - int ac = 0; const char *header = ""; if (argc > 0) { @@ -3469,7 +3464,6 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl if (sofia_test_pflag(profile, PFLAG_RUNNING)) { if (strcmp(vvar, profile->name)) { - ac++; stream->write_function(stream, "\n%s\n%s\n%s\n%s\n\n", vvar, "alias", profile->name, "ALIASED"); } else { @@ -3495,8 +3489,6 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl profile->inuse); } - c++; - for (gp = profile->gateways; gp; gp = gp->next) { switch_assert(gp->state < REG_STATE_LAST); stream->write_function(stream, "\n%s\n%s\n%s\n%s\n\n", @@ -4313,6 +4305,8 @@ SWITCH_STANDARD_API(sofia_presence_data_function) user = argv[1]; } + if (!user) goto end; + if ((domain = strchr(user, '@'))) { *domain++ = '\0'; if ((concat = strchr(domain, '/'))) { @@ -4329,8 +4323,6 @@ SWITCH_STANDARD_API(sofia_presence_data_function) domain = dup_domain; } - if (!user) goto end; - if (zstr(profile_name) || strcmp(profile_name, "*") || zstr(domain)) { if (!zstr(profile_name)) { profile = sofia_glue_find_profile(profile_name); @@ -6836,7 +6828,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) return status; } -void mod_sofia_shutdown_cleanup() { +void mod_sofia_shutdown_cleanup(void) { int sanity = 0; int i; switch_status_t st; diff --git a/src/mod/endpoints/mod_sofia/sip-dig.c b/src/mod/endpoints/mod_sofia/sip-dig.c index e89f5aef44..10a0a26763 100644 --- a/src/mod/endpoints/mod_sofia/sip-dig.c +++ b/src/mod/endpoints/mod_sofia/sip-dig.c @@ -82,9 +82,6 @@ *
-6
*
Query IP6 addresses (AAAA records). *
- *
-v
- *
Be verbatim. - *
*
*
*
@@ -201,7 +198,7 @@ switch_bool_t verify_ip(sres_record_t **answers, const char *ip, switch_bool_t i switch_status_t sip_dig_function(_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream) { - int o_sctp = 1, o_tls_sctp = 1, o_verbatim = 1; + int o_sctp = 1, o_tls_sctp = 1; int family = 0, multiple = 0; char const *string; url_t *uri = NULL; @@ -247,9 +244,7 @@ switch_status_t sip_dig_function(_In_opt_z_ const char *cmd, _In_opt_ switch_cor } while (argv[i] && argv[i][0] == '-') { - if (strcmp(argv[i], "-v") == 0) { - o_verbatim++; - } else if (strcmp(argv[i], "-6") == 0) { + if (strcmp(argv[i], "-6") == 0) { dig->ip6 = ++family; } else if (strcmp(argv[i], "-4") == 0) { dig->ip4 = ++family; @@ -815,8 +810,12 @@ sres_record_t ** dig_addr_simple(struct dig *dig, uint16_t type) { sres_record_t **answers = NULL; + int error; - sres_blocking_query(dig->sres, type, host, 0, &answers); + error = sres_blocking_query(dig->sres, type, host, 0, &answers); + if (error < 0) { + return NULL; + } return answers; } diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index a2af9c3849..c5b5bcc190 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2818,7 +2818,10 @@ void event_handler(switch_event_t *event) if ((sptr = strstr(fixed_contact_str, needle))) { char *origsptr = strstr(contact_str, needle); - eptr = strchr(++origsptr, ';'); + + if (origsptr) { + eptr = strchr(++origsptr, ';'); + } } else { sptr = strchr(fixed_contact_str, '\0') - 1; } @@ -2949,6 +2952,9 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread sofia_set_pflag_locked(profile, PFLAG_WORKER_RUNNING); + /* Seed PRNG for functions within worker thread */ + srand((unsigned)((intptr_t) switch_thread_self() + switch_micro_time_now())); + while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING))) { if (tick) { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 35704b44ab..eceae218f8 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -446,14 +446,16 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t a_id = switch_strip_whitespace(duped); - if (zstr(a_id)) return; + if (zstr(a_id)) { + goto end; + } p = strchr(a_id, ';'); if (p) *p = '\0'; if (!sofia_glue_is_valid_session_uuid(a_id)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Session-ID: Ignoring \"%s\" parsed as \"%s\"\n", header, a_id); - return; + goto end; } /* RFC7329 compatibility */ @@ -483,7 +485,7 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t if (!p) { switch_channel_set_flag(channel, CF_RFC7329_COMPAT); switch_channel_set_flag_partner(channel, CF_RFC7329_COMPAT); - return; + goto end; } p++; remote_param = strstr(p, "remote="); @@ -491,7 +493,7 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t switch_channel_set_flag(channel, CF_RFC7329_COMPAT); switch_channel_set_flag_partner(channel, CF_RFC7329_COMPAT); sofia_glue_check_filter_generic_params(session, profile, p); - return; + goto end; } b_id = remote_param + 7; if (!zstr(b_id) && strlen(b_id) == RFC7989_SESSION_UUID_LEN /*32*/) { @@ -503,6 +505,9 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Session-ID: invalid uuid, ignored.\n"); } + +end: + switch_safe_free(a_id); } /* add "Session-ID:" header */ @@ -924,9 +929,9 @@ char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix if ( !exclude_regex || !(/*proceed*/ switch_regex_perform(name, exclude_regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { const char *hname = name + strlen(prefix); stream.write_function(&stream, "%s: %s\r\n", hname, value); - switch_regex_safe_free(re); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ignoring Extra Header [%s] , matches exclude_outgoing_extra_header [%s]\n", name, exclude_regex); + switch_regex_safe_free(re); } } } @@ -2277,8 +2282,7 @@ int sofia_recover_callback(switch_core_session_t *session) switch_channel_t *channel = switch_core_session_get_channel(session); private_object_t *tech_pvt = NULL; sofia_profile_t *profile = NULL; - const char *tmp; - const char *rr; + const char *tmp, *rr, *use_uuid; int r = 0; const char *profile_name = switch_channel_get_variable_dup(channel, "recovery_profile_name", SWITCH_FALSE, -1); int swap = switch_channel_var_true(channel, "dlg_req_swap_direction"); @@ -2369,17 +2373,13 @@ int sofia_recover_callback(switch_core_session_t *session) ); } - if (session) { - const char *use_uuid; - - if ((use_uuid = switch_channel_get_variable(channel, "origination_uuid"))) { - if (switch_core_session_set_uuid(session, use_uuid) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s set UUID=%s\n", switch_channel_get_name(channel), - use_uuid); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s set UUID=%s FAILED\n", - switch_channel_get_name(channel), use_uuid); - } + if ((use_uuid = switch_channel_get_variable(channel, "origination_uuid"))) { + if (switch_core_session_set_uuid(session, use_uuid) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s set UUID=%s\n", switch_channel_get_name(channel), + use_uuid); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s set UUID=%s FAILED\n", + switch_channel_get_name(channel), use_uuid); } } diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 00cc8561d6..579cea83e2 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -399,6 +399,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) switch_safe_free(route_uri); switch_safe_free(ffrom); switch_safe_free(dup); + switch_safe_free(extra_headers); if (profile) { switch_thread_rwlock_unlock(profile->rwlock); @@ -1620,7 +1621,6 @@ void *SWITCH_THREAD_FUNC sofia_presence_event_thread_run(switch_thread_t *thread switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Event Thread Started\n"); while (mod_sofia_globals.running == 1) { - int count = 0; if (switch_queue_pop(mod_sofia_globals.presence_queue, &pop) == SWITCH_STATUS_SUCCESS) { switch_event_t *event = (switch_event_t *) pop; @@ -1655,7 +1655,6 @@ void *SWITCH_THREAD_FUNC sofia_presence_event_thread_run(switch_thread_t *thread } switch_event_destroy(&event); - count++; } } @@ -3755,7 +3754,6 @@ void sofia_presence_handle_sip_i_subscribe(int status, if ((sub_max_deviation_var = profile->sip_subscription_max_deviation)) { int sub_deviation; - srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) ); /* random negative number between 0 and negative sub_max_deviation_var: */ sub_deviation = ( rand() % sub_max_deviation_var ) - sub_max_deviation_var; if ( (exp_delta + sub_deviation) > 45 ) { diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 9791190f5f..d9e04528a8 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -884,7 +884,6 @@ long sofia_reg_uniform_distribution(int max) int result; int range = max + 1; - srand((unsigned)((intptr_t) switch_thread_self() + switch_micro_time_now())); result = (int)((double)rand() / (((double)RAND_MAX + (double)1) / range)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Generated random %ld, max is %d\n", (long) result, max); @@ -894,8 +893,7 @@ long sofia_reg_uniform_distribution(int max) void sofia_reg_check_ping_expire(sofia_profile_t *profile, time_t now, int interval) { char *sql; - int mean = interval / 2; - long next, irand; + long next; char buf[32] = ""; int count; @@ -952,8 +950,7 @@ void sofia_reg_check_ping_expire(sofia_profile_t *profile, time_t now, int inter /* only update if needed */ if (count) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9, "Updating ping expires for profile %s\n", profile->name); - irand = mean + sofia_reg_uniform_distribution(interval); - next = (long) now + irand; + next = (long) now + interval; sql = switch_mprintf("update sip_registrations set ping_expires = %ld where hostname='%q' and profile_name='%q' and ping_expires <= %ld ", next, mod_sofia_globals.hostname, profile->name, (long) now); @@ -1765,7 +1762,6 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu (( exp_max_deviation_var = profile->sip_expires_max_deviation )) ) { if (exp_max_deviation_var > 0) { int exp_deviation; - srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) ); /* random number between negative exp_max_deviation_var and positive exp_max_deviation_var: */ exp_deviation = ( rand() % ( exp_max_deviation_var * 2 ) ) - exp_max_deviation_var; exptime += exp_deviation; @@ -2013,23 +2009,26 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu sql = switch_mprintf("insert into sip_registrations " "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires," "user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm," - "mwi_user,mwi_host, orig_server_host, orig_hostname, sub_host, ping_status, ping_count, force_ping) " - "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q','%q', '%q', %d, %d)", + "mwi_user,mwi_host, orig_server_host, orig_hostname, sub_host, ping_status, ping_count, ping_expires, force_ping) " + "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q','%q', '%q', %d, %ld, %d)", call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : "", contact_str, reg_desc, rpid, (long) reg_time + (long) exptime + profile->sip_expires_late_margin, agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm, - mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host, "Reachable", 0, force_ping); + mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host, "Reachable", 0, + (long) switch_epoch_time_now(NULL) + sofia_reg_uniform_distribution(profile->iping_seconds), force_ping); } else { sql = switch_mprintf("update sip_registrations set call_id='%q'," "sub_host='%q', network_ip='%q',network_port='%q'," "presence_hosts='%q', server_host='%q', orig_server_host='%q'," "hostname='%q', orig_hostname='%q'," - "expires = %ld, force_ping=%d where sip_user='%q' and sip_username='%q' and sip_host='%q' and contact='%q'", + "expires = %ld, ping_expires=%ld, force_ping=%d " + "where sip_user='%q' and sip_username='%q' and sip_host='%q' and contact='%q'", call_id, sub_host, network_ip, network_port_c, profile->presence_hosts ? profile->presence_hosts : "", guess_ip4, guess_ip4, mod_sofia_globals.hostname, mod_sofia_globals.hostname, - (long) reg_time + (long) exptime + profile->sip_expires_late_margin, force_ping, - to_user, username, reg_host, contact_str); + (long) reg_time + (long) exptime + profile->sip_expires_late_margin, + (long) switch_epoch_time_now(NULL) + sofia_reg_uniform_distribution(profile->iping_seconds), + force_ping, to_user, username, reg_host, contact_str); } if (sql) { diff --git a/src/mod/endpoints/mod_sofia/test/sipp-based-tests.c b/src/mod/endpoints/mod_sofia/test/sipp-based-tests.c index 60a7b61a3a..7b2d7964c9 100644 --- a/src/mod/endpoints/mod_sofia/test/sipp-based-tests.c +++ b/src/mod/endpoints/mod_sofia/test/sipp-based-tests.c @@ -90,7 +90,7 @@ static const char *test_wait_for_chan_var(switch_channel_t *channel, const char return var; } -static switch_bool_t has_ipv6() +static switch_bool_t has_ipv6(void) { switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); @@ -110,7 +110,7 @@ static switch_bool_t has_ipv6() return SWITCH_TRUE; } -static void register_gw() +static void register_gw(void) { switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); @@ -118,7 +118,7 @@ static void register_gw() switch_safe_free(stream.data); } -static void unregister_gw() +static void unregister_gw(void) { switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); diff --git a/src/mod/endpoints/mod_verto/mcast/mcast.c b/src/mod/endpoints/mod_verto/mcast/mcast.c index fcb3035872..aaa6da995c 100644 --- a/src/mod/endpoints/mod_verto/mcast/mcast.c +++ b/src/mod/endpoints/mod_verto/mcast/mcast.c @@ -86,6 +86,7 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle, if ( setsockopt(handle->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)) != 0 ) { mcast_socket_close(handle); + return -1; } @@ -103,11 +104,13 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle, if (setsockopt(handle->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq)) < 0) { mcast_socket_close(handle); + return -1; } if (bind(handle->sock, (struct sockaddr *) &handle->recv_addr, sizeof(handle->recv_addr)) < 0) { mcast_socket_close(handle); + return -1; } @@ -124,7 +127,11 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle, addr_criteria.ai_flags |= AI_NUMERICHOST; snprintf(service, sizeof(service), "%d", port); - getaddrinfo(host, service, &addr_criteria, &mcast_addr); + if (getaddrinfo(host, service, &addr_criteria, &mcast_addr) != 0) { + mcast_socket_close(handle); + + return -1; + } memset(&handle->recv_addr6, 0, sizeof(handle->recv_addr6)); @@ -134,11 +141,14 @@ int mcast_socket_create(const char *host, int16_t port, mcast_handle_t *handle, memcpy(&mreq.ipv6mr_multiaddr, &((struct sockaddr_in6 *)mcast_addr->ai_addr)->sin6_addr, sizeof(struct in6_addr)); + freeaddrinfo(mcast_addr); + mreq.ipv6mr_interface = 0; setsockopt(handle->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&mreq, sizeof(mreq)); if (bind(handle->sock, (struct sockaddr *) &handle->recv_addr6, sizeof(handle->recv_addr6)) < 0) { mcast_socket_close(handle); + return -1; } } diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index d98e1abdef..ac042fe626 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -43,7 +43,7 @@ SWITCH_MODULE_DEFINITION(mod_verto, mod_verto_load, mod_verto_shutdown, mod_vert #define HTTP_CHUNK_SIZE 1024 * 32 #define EP_NAME "verto.rtc" //#define WSS_STANDALONE 1 -#include "ks.h" +#include "libks/ks.h" #include #ifndef WIN32 @@ -771,10 +771,6 @@ static void jsock_send_event(cJSON *event) } switch_thread_rwlock_unlock(verto_globals.event_channel_rwlock); - if (use_jsock) { - switch_thread_rwlock_unlock(use_jsock->rwlock); - use_jsock = NULL; - } } static jrpc_func_t jrpc_get_func(jsock_t *jsock, const char *method) @@ -827,7 +823,6 @@ static void set_perm(const char *str, switch_event_t **event, switch_bool_t add) { char delim = ','; char *cur, *next; - int count = 0; char *edup; if (!zstr(str)) { @@ -840,7 +835,7 @@ static void set_perm(const char *str, switch_event_t **event, switch_bool_t add) switch_event_create(event, SWITCH_EVENT_REQUEST_PARAMS); } - if (!zstr(str)) { + if (!zstr(str) && event && *event) { edup = strdup(str); switch_assert(edup); @@ -848,7 +843,7 @@ static void set_perm(const char *str, switch_event_t **event, switch_bool_t add) delim = ' '; } - for (cur = edup; cur; count++) { + for (cur = edup; cur;) { if ((next = strchr(cur, delim))) { *next++ = '\0'; } @@ -1063,13 +1058,13 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char * *code = CODE_AUTH_FAILED; switch_snprintf(message, mlen, "Login Incorrect"); login_fire_custom_event(jsock, params, 0, "Login Incorrect"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Login incorrect for user: %s domain: %s\n", id, domain ? domain : "N/A"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Login incorrect for user: %s domain: %s\n", id, domain); } else { switch_xml_t x_param, x_params; const char *use_passwd = NULL, *verto_context = NULL, *verto_dialplan = NULL; time_t now = switch_epoch_time_now(NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Login sucessful for user: %s domain: %s\n", id, domain ? domain : "N/A"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Login sucessful for user: %s domain: %s\n", id, domain); jsock->logintime = now; jsock->id = switch_core_strdup(jsock->pool, id); @@ -3870,6 +3865,15 @@ static switch_bool_t verto__info_func(const char *method, cJSON *params, jsock_t cJSON *i, *indialog = cJSON_GetObjectItem(msg, "inDialog"); const char *body = cJSON_GetObjectCstr(msg, "body"); switch_bool_t is_dialog = indialog && (indialog->type == cJSON_True || (indialog->type == cJSON_String && switch_true(indialog->valuestring))); + const char *context = NULL; + + switch_mutex_lock(jsock->flag_mutex); + + if (!(context = switch_event_get_header(jsock->vars, "user_context"))) { + context = switch_either(jsock->context, jsock->profile->context); + } + + switch_mutex_unlock(jsock->flag_mutex); if (!zstr(to)) { if (strchr(to, '+')) { @@ -3906,6 +3910,8 @@ static switch_bool_t verto__info_func(const char *method, cJSON *params, jsock_t switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call_id", call_id); } + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "context", context); + switch_event_add_body(event, "%s", body); if (strcasecmp(proto, VERTO_CHAT_PROTO)) { @@ -3958,7 +3964,7 @@ static switch_bool_t verto__invite_func(const char *method, cJSON *params, jsock cJSON *obj = cJSON_CreateObject(), *vobj = NULL, *dedEnc = NULL, *mirrorInput, *bandwidth = NULL, *canvas = NULL; switch_core_session_t *session = NULL; switch_channel_t *channel; - switch_event_t *var_event; + switch_event_t *var_event = NULL; switch_call_cause_t reason = SWITCH_CAUSE_INVALID_MSG_UNSPECIFIED, cancel_cause = 0; switch_caller_profile_t *caller_profile; int err = 0; @@ -4760,14 +4766,12 @@ static int start_jsock(verto_profile_t *profile, ks_socket_t sock, int family) error: - if (jsock) { - if (jsock->client_socket != KS_SOCK_INVALID) { - close_socket(&jsock->client_socket); - } - - switch_core_destroy_memory_pool(&pool); + if (jsock->client_socket != KS_SOCK_INVALID) { + close_socket(&jsock->client_socket); } + switch_core_destroy_memory_pool(&pool); + return -1; } @@ -5585,8 +5589,6 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl { verto_profile_t *profile = NULL; jsock_t *jsock; - int cp = 0; - int cc = 0; const char *header = ""; int i; @@ -5600,14 +5602,12 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl stream->write_function(stream, "\n%s\n%s\n%s\n%s\n\n", profile->name, "profile", tmpurl, (profile->running) ? "RUNNING" : "DOWN"); switch_safe_free(tmpurl); } - cp++; switch_mutex_lock(profile->mutex); for(jsock = profile->jsock_head; jsock; jsock = jsock->next) { char *tmpname = switch_mprintf("%s@%s", jsock->id, jsock->domain); stream->write_function(stream, "\n%s\n%s\n%s\n%s\n%s (%s)\n\n", profile->name, tmpname, "client", jsock->name, (!zstr(jsock->uid)) ? "CONN_REG" : "CONN_NO_REG", (jsock->ptype & PTYPE_CLIENT_SSL) ? "WSS": "WS"); - cc++; switch_safe_free(tmpname); } switch_mutex_unlock(profile->mutex); @@ -5617,7 +5617,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl return SWITCH_STATUS_SUCCESS; } -static cJSON *json_status() +static cJSON *json_status(void) { cJSON *obj, *profiles, *jprofile, *users, *user; verto_profile_t *profile = NULL; @@ -6746,14 +6746,14 @@ static void mod_verto_ks_logger(const char *file, const char *func, int line, in va_end(ap); } -static void verto_event_free_subclass() +static void verto_event_free_subclass(void) { switch_event_free_subclass(MY_EVENT_LOGIN); switch_event_free_subclass(MY_EVENT_CLIENT_DISCONNECT); switch_event_free_subclass(MY_EVENT_CLIENT_CONNECT); } -static void verto_destroy_globals_hash_tables() +static void verto_destroy_globals_hash_tables(void) { if (verto_globals.method_hash) { switch_core_hash_destroy(&verto_globals.method_hash); diff --git a/src/mod/endpoints/mod_verto/mod_verto.h b/src/mod/endpoints/mod_verto/mod_verto.h index f3326f605d..f13e8ef2b9 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.h +++ b/src/mod/endpoints/mod_verto/mod_verto.h @@ -62,7 +62,7 @@ #include #include "mcast.h" -#include "ks.h" +#include "libks/ks.h" #define MAX_QUEUE_LEN 100000 #define MAX_MISSED 500 diff --git a/src/mod/event_handlers/mod_amqp/mod_amqp.h b/src/mod/event_handlers/mod_amqp/mod_amqp.h index 0717876040..f5c63780a4 100644 --- a/src/mod/event_handlers/mod_amqp/mod_amqp.h +++ b/src/mod/event_handlers/mod_amqp/mod_amqp.h @@ -87,6 +87,11 @@ typedef struct mod_amqp_keypart_s { int size; } mod_amqp_keypart_t; +typedef struct { + switch_event_types_t id; + char* subclass; +} mod_amqp_events_t; + typedef struct { char *name; @@ -103,7 +108,7 @@ typedef struct { /* Array to store the possible event subscriptions */ int event_subscriptions; switch_event_node_t *event_nodes[SWITCH_EVENT_ALL]; - switch_event_types_t event_ids[SWITCH_EVENT_ALL]; + mod_amqp_events_t events[SWITCH_EVENT_ALL]; switch_event_node_t *eventNode; diff --git a/src/mod/event_handlers/mod_amqp/mod_amqp_connection.c b/src/mod/event_handlers/mod_amqp/mod_amqp_connection.c index 91feec93d5..73cf09a354 100644 --- a/src/mod/event_handlers/mod_amqp/mod_amqp_connection.c +++ b/src/mod/event_handlers/mod_amqp/mod_amqp_connection.c @@ -203,7 +203,11 @@ switch_status_t mod_amqp_connection_create(mod_amqp_connection_t **conn, switch_ amqp_boolean_t ssl_verify_peer = 1; if (zstr(name)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Connection missing name attribute\n%s\n", switch_xml_toxml(cfg, 1)); + char *str_tmp = switch_xml_toxml(cfg, 1); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Connection missing name attribute\n%s\n", str_tmp); + switch_safe_free(str_tmp); + return SWITCH_STATUS_GENERR; } @@ -260,6 +264,7 @@ switch_status_t mod_amqp_connection_create(mod_amqp_connection_t **conn, switch_ new_con->ssl_verify_peer = ssl_verify_peer; *conn = new_con; + return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/event_handlers/mod_amqp/mod_amqp_producer.c b/src/mod/event_handlers/mod_amqp/mod_amqp_producer.c index d7741d3f41..303927285e 100644 --- a/src/mod/event_handlers/mod_amqp/mod_amqp_producer.c +++ b/src/mod/event_handlers/mod_amqp/mod_amqp_producer.c @@ -186,7 +186,8 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg) profile->name = switch_core_strdup(profile->pool, name); profile->running = 1; memset(profile->format_fields, 0, (MAX_ROUTING_KEY_FORMAT_FIELDS + 1) * sizeof(mod_amqp_keypart_t)); - profile->event_ids[0] = SWITCH_EVENT_ALL; + profile->events[0].id = SWITCH_EVENT_ALL; + profile->events[0].subclass = SWITCH_EVENT_SUBCLASS_ANY; profile->event_subscriptions = 1; profile->conn_root = NULL; profile->conn_active = NULL; @@ -269,7 +270,14 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Found %d subscriptions\n", profile->event_subscriptions); for (arg = 0; arg < profile->event_subscriptions; arg++) { - if (switch_name_event(argv[arg], &(profile->event_ids[arg])) != SWITCH_STATUS_SUCCESS) { + char *subclass = SWITCH_EVENT_SUBCLASS_ANY; + if ((subclass = strchr(argv[arg], '^'))) { + *subclass++ = '\0'; + } + + if (switch_name_event(argv[arg], &(profile->events[arg].id)) == SWITCH_STATUS_SUCCESS) { + profile->events[arg].subclass = subclass; + } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "The switch event %s was not recognised.\n", argv[arg]); } } @@ -344,13 +352,13 @@ switch_status_t mod_amqp_producer_create(char *name, switch_xml_t cfg) /* Subscribe events */ for (i = 0; i < profile->event_subscriptions; i++) { if (switch_event_bind_removable("AMQP", - profile->event_ids[i], - SWITCH_EVENT_SUBCLASS_ANY, + profile->events[i].id, + profile->events[i].subclass, mod_amqp_producer_event_handler, profile, &(profile->event_nodes[i])) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot bind to event handler %d!\n",(int)profile->event_ids[i]); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot bind to event handler %d!\n",(int)profile->events[i].id); goto err; } } diff --git a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c index 20259251de..3ec8b060df 100644 --- a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c +++ b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c @@ -272,7 +272,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) } -static void do_rotate_all() +static void do_rotate_all(void) { switch_hash_index_t *hi; void *val; @@ -294,7 +294,7 @@ static void do_rotate_all() } -static void do_teardown() +static void do_teardown(void) { switch_hash_index_t *hi; void *val; diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c index d15f748eb7..bd7bf8e26c 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c @@ -1998,7 +1998,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_erlang_event_runtime) struct ei_cnode_s ec; ErlConnect conn; int clientfd; - switch_os_socket_t epmdfd; + switch_os_socket_t epmdfd = SWITCH_SOCK_INVALID; switch_socket_t *epmd_sock = NULL; if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c index 1ebf5cb7fe..ac58ee8ed9 100644 --- a/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c +++ b/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c @@ -153,16 +153,18 @@ static switch_status_t load_config(switch_xml_t input_cfg) } if ((settings = switch_xml_child(cfg, "settings"))) { + for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); + char *val_no_whitespace = switch_strip_whitespace(val); if (!strcasecmp(var, "address")) { - set_global_dst_addrs(switch_strip_whitespace(val)); + set_global_dst_addrs(val_no_whitespace); } else if (!strcasecmp(var, "source_address")) { - set_global_src_addr(switch_strip_whitespace(val)); + set_global_src_addr(val_no_whitespace); } else if (!strcasecmp(var, "source_address_ipv6")) { - set_global_src_addr6(switch_strip_whitespace(val)); + set_global_src_addr6(val_no_whitespace); } else if (!strcasecmp(var, "bindings")) { set_global_bindings(val); } else if (!strcasecmp(var, "port")) { @@ -183,6 +185,8 @@ static switch_status_t load_config(switch_xml_t input_cfg) } else if (!strcasecmp(var, "loopback")) { globals.loopback = switch_true(val); } + + switch_safe_free(val_no_whitespace); } } @@ -190,6 +194,7 @@ static switch_status_t load_config(switch_xml_t input_cfg) if (globals.bindings) { + for (cur = globals.bindings; cur; count++) { switch_event_types_t type; @@ -293,13 +298,13 @@ static switch_status_t initialize_sockets(switch_xml_t input_cfg) char *host_string; char ipv6_first_octet[3]; - memset(&globals.dst_sockaddrs[globals.num_dst_addrs].sockaddr, 0, sizeof(dst_sockaddr_t)); - - if (globals.num_dst_addrs > MAX_DST_HOSTS) { + if (globals.num_dst_addrs >= MAX_DST_HOSTS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot add destination address: %s, exceeded maximum of %d\n", dst_hosts[i], MAX_DST_HOSTS); continue; } + memset(&globals.dst_sockaddrs[globals.num_dst_addrs], 0, sizeof(dst_sockaddr_t)); + if (switch_sockaddr_info_get(&globals.dst_sockaddrs[globals.num_dst_addrs].sockaddr, dst_hosts[i], SWITCH_UNSPEC, globals.port, 0, module_pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find address: %s\n", dst_hosts[i]); switch_goto_status(SWITCH_STATUS_TERM, fail); @@ -627,8 +632,8 @@ static void event_handler(switch_event_t *event) len = strlen(packet) + strlen((char *) MAGIC); #endif buf = malloc(len + 1); - memset(buf, 0, len + 1); switch_assert(buf); + memset(buf, 0, len + 1); #ifdef HAVE_OPENSSL if (globals.psk) { @@ -777,7 +782,11 @@ static switch_status_t process_packet(char* packet, size_t len) switch_url_decode(val); switch_snprintf(tmpname, sizeof(tmpname), "Orig-%s", var); switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, tmpname, val); - var = term + 1; + if (term) { + var = term + 1; + } else { + var = NULL; + } } else { /* This should be our magic packet, done processing incoming headers */ break; diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 70331a95e2..520bd92ac7 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -866,7 +866,7 @@ SWITCH_STANDARD_API(event_sink_function) char *loglevel = switch_event_get_header(stream->param_event, "loglevel"); switch_memory_pool_t *pool; char *next, *cur; - uint32_t count = 0, key_count = 0; + uint32_t key_count = 0; uint8_t custom = 0; char *edup; @@ -925,7 +925,7 @@ SWITCH_STANDARD_API(event_sink_function) delim = ' '; } - for (cur = edup; cur; count++) { + for (cur = edup; cur;) { switch_event_types_t type; if ((next = strchr(cur, delim))) { @@ -1846,7 +1846,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even if (allowed_events) { char delim = ','; char *cur, *next; - int count = 0, custom = 0, key_count = 0; + int custom = 0; switch_set_flag(listener, LFLAG_AUTH_EVENTS); @@ -1862,7 +1862,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even delim = ' '; } - for (cur = edup; cur; count++) { + for (cur = edup; cur;) { switch_event_types_t type; if ((next = strchr(cur, delim))) { @@ -1872,7 +1872,6 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even if (custom) { switch_core_hash_insert(listener->allowed_event_hash, cur, MARKER); } else if (switch_name_event(cur, &type) == SWITCH_STATUS_SUCCESS) { - key_count++; if (type == SWITCH_EVENT_ALL) { uint32_t x = 0; switch_set_flag(listener, LFLAG_ALL_EVENTS_AUTHED); @@ -1904,7 +1903,6 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even if (allowed_api) { char delim = ','; char *cur, *next; - int count = 0; switch_snprintf(api_reply, sizeof(api_reply), "Allowed-API: %s\n", allowed_api); @@ -1916,7 +1914,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even delim = ' '; } - for (cur = edup; cur; count++) { + for (cur = edup; cur;) { if ((next = strchr(cur, delim))) { *next++ = '\0'; } @@ -2540,14 +2538,14 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even } else if (!strncasecmp(cmd, "nixevent", 8)) { char *next, *cur; - uint32_t count = 0, key_count = 0; + uint32_t key_count = 0; uint8_t custom = 0; strip_cr(cmd); cur = cmd + 8; if ((cur = strchr(cur, ' '))) { - for (cur++; cur; count++) { + for (cur++; cur;) { switch_event_types_t type; if ((next = strchr(cur, ' '))) { diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_commands.c b/src/mod/event_handlers/mod_kazoo/kazoo_commands.c index 6d956376a8..16f00ad1a0 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_commands.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_commands.c @@ -366,7 +366,9 @@ SWITCH_STANDARD_API(kz_http_put) goto done; } switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1); +#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x070c01) switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1); +#endif switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url); diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_ei_config.c b/src/mod/event_handlers/mod_kazoo/kazoo_ei_config.c index f1726b677b..3c626c15da 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_ei_config.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_ei_config.c @@ -564,13 +564,16 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c switch_memory_pool_t *pool = NULL; char *name = (char *) switch_xml_attr_soft(cfg, "name"); + if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "missing name in profile\n"); + return SWITCH_STATUS_GENERR; } if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error allocation pool for new profile : %s\n", name); + return SWITCH_STATUS_GENERR; } @@ -582,6 +585,7 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c fetch_section = switch_xml_parse_section_string(name); 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"); char *val = (char *) switch_xml_attr_soft(param, "value"); @@ -605,7 +609,9 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c } if (fetch_section == SWITCH_XML_SECTION_RESULT) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Fetch Profile[%s] invalid fetch-section: %s\n", name, switch_xml_toxml(cfg, SWITCH_FALSE)); + char *tmp = switch_xml_toxml(cfg, SWITCH_FALSE); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Fetch Profile[%s] invalid fetch-section: %s\n", name, tmp); + free(tmp); goto err; } @@ -622,17 +628,20 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c } } - if(ptr) + if (ptr) { *ptr = profile; + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "fetch handler profile %s successfully configured\n", name); + return SWITCH_STATUS_SUCCESS; err: /* Cleanup */ - if(pool) { - switch_core_destroy_memory_pool(&pool); - } + if(pool) { + switch_core_destroy_memory_pool(&pool); + } + return SWITCH_STATUS_GENERR; } diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_message.c b/src/mod/event_handlers/mod_kazoo/kazoo_message.c index e43d656b4c..43716a8e02 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_message.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_message.c @@ -233,9 +233,11 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie } else if((header = switch_event_get_header_ptr(src, field->name)) != NULL) { if (header->idx) { item = cJSON_CreateArray(); + for(i = 0; i < header->idx; i++) { cJSON_AddItemToArray(item, kazoo_event_json_value(field->out_type, header->array[i])); } + kazoo_cJSON_AddItemToObject(dst, field->as ? field->as : field->name, item); } else if (field->out_type_as_array) { item = cJSON_CreateArray(); @@ -251,13 +253,16 @@ 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); - if(expanded != field->value) { - free(expanded); - } } + + if (expanded != field->value) { + switch_safe_free(expanded); + } + break; case FIELD_FIRST_OF: + for(n = 0; n < field->list.size; n++) { if(*field->list.value[n] == '#') { item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, ++field->list.value[n]); @@ -267,33 +272,41 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie if(header) { if (header->idx) { item = cJSON_CreateArray(); + for(i = 0; i < header->idx; i++) { cJSON_AddItemToArray(item, kazoo_event_json_value(field->out_type, header->array[i])); } + kazoo_cJSON_AddItemToObject(dst, field->as ? field->as : field->name, item); } else { item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, header->value); } + break; } } } + break; case FIELD_PREFIX: + for (header = src->headers; header; header = header->next) { if(!strncmp(header->name, field->name, strlen(field->name))) { if (header->idx) { cJSON *array = cJSON_CreateArray(); + for(i = 0; i < header->idx; i++) { cJSON_AddItemToArray(array, kazoo_event_json_value(field->out_type, header->array[i])); } + kazoo_cJSON_AddItemToObject(dst, field->exclude_prefix ? header->name+strlen(field->name) : header->name, array); } else { kazoo_event_add_json_value(dst, field, field->exclude_prefix ? header->name+strlen(field->name) : header->name, header->value); } } } + break; case FIELD_STATIC: @@ -308,7 +321,7 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie break; } - return item; + return item; } static switch_status_t kazoo_event_add_fields_to_json(kazoo_logging_ptr logging, cJSON *dst, switch_event_t *src, kazoo_field_ptr field) { diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_node.c b/src/mod/event_handlers/mod_kazoo/kazoo_node.c index feb8970a86..f75c327023 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_node.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_node.c @@ -1097,23 +1097,27 @@ static switch_status_t handle_request_fetch_reply(ei_node_t *ei_node, erlang_pid if (ei_decode_atom_safe(buf->buff, &buf->index, section_str) || !(section = switch_xml_parse_section_string(section_str))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without a configuration section\n"); + return erlang_response_badarg(rbuf); } if (ei_decode_string_or_binary_limited(buf->buff, &buf->index, sizeof(uuid_str), uuid_str) || zstr_buf(uuid_str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without request UUID\n"); + return erlang_response_badarg(rbuf); } if (ei_decode_string_or_binary(buf->buff, &buf->index, &xml_str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without XML : %s \n", uuid_str); + return erlang_response_badarg(rbuf); } if (zstr(xml_str)) { switch_safe_free(xml_str); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring an empty fetch reply : %s\n", uuid_str); + return erlang_response_badarg(rbuf); } @@ -1138,13 +1142,19 @@ static switch_status_t handle_request_fetch_reply(ei_node_t *ei_node, erlang_pid break; default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received fetch reply %s for an unknown configuration section: %s : %s\n", uuid_str, section_str, xml_str); + switch_safe_free(xml_str); + return erlang_response_badarg(rbuf); } if (result == SWITCH_STATUS_SUCCESS) { + switch_safe_free(xml_str); + return erlang_response_ok(rbuf); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received fetch reply %s is unknown or has expired : %s\n", uuid_str, xml_str); + switch_safe_free(xml_str); + return erlang_response_baduuid(rbuf); } } diff --git a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c index 490a7911f1..153ec6252d 100644 --- a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c +++ b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c @@ -166,8 +166,10 @@ static switch_status_t my_on_routing(switch_core_session_t *session) if (channel) { const char *disable_flag = switch_channel_get_variable(channel, "disable_radius_start"); + if (switch_true(disable_flag)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Not Sending RADIUS Start\n"); + return SWITCH_STATUS_SUCCESS; } } @@ -250,6 +252,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->caller_id_number) { if (rc_avpair_add(rad_config, &send, PW_FS_SRC, (void *) profile->caller_id_number, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Src: %s\n", profile->caller_id_number); @@ -257,6 +260,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->caller_id_name) { if (rc_avpair_add(rad_config, &send, PW_FS_CLID, (void *) profile->caller_id_name, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name); @@ -264,6 +268,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->destination_number) { if (rc_avpair_add(rad_config, &send, PW_FS_DST, (void *) profile->destination_number, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dst: %s\n", profile->destination_number); @@ -271,6 +276,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->dialplan) { if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, (void *) profile->dialplan, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan); @@ -278,6 +284,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->network_addr) { inet_pton(AF_INET, (void *) profile->network_addr, &framed_addr); framed_addr = htonl(framed_addr); @@ -287,6 +294,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->rdnis) { if (rc_avpair_add(rad_config, &send, PW_FS_RDNIS, (void *) profile->rdnis, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-RDNIS: %s\n", profile->rdnis); @@ -294,6 +302,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->context) { if (rc_avpair_add(rad_config, &send, PW_FS_CONTEXT, (void *) profile->context, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Context: %s\n", profile->context); @@ -301,6 +310,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->ani) { if (rc_avpair_add(rad_config, &send, PW_FS_ANI, (void *) profile->ani, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANI: %s\n", profile->ani); @@ -308,6 +318,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->aniii) { if (rc_avpair_add(rad_config, &send, PW_FS_ANIII, (void *) profile->aniii, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANIII: %s\n", profile->aniii); @@ -315,6 +326,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (profile->source) { if (rc_avpair_add(rad_config, &send, PW_FS_SOURCE, (void *) profile->source, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Source: %s\n", profile->source); @@ -322,6 +334,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session) goto end; } } + if (callstartdate > 0) { switch_time_exp_tz(&tm, callstartdate, requested_tm.tm_gmtoff); switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", @@ -380,25 +393,33 @@ static switch_status_t my_on_routing(switch_core_session_t *session) } if (radius_avpair) { + char *radius_avpair_data_tmp = NULL; + radius_avpair_data = strdup(radius_avpair + (strncmp(radius_avpair, "ARRAY::", 7) ? 0 : 7)); + radius_avpair_data_tmp = radius_avpair_data; + do { - delim = strstr(radius_avpair_data, "|:"); + delim = strstr(radius_avpair_data_tmp, "|:"); if (delim) { *delim = '\0'; } - if (rc_avpair_add(rad_config, &send, PW_FS_AVPAIR, (void *) radius_avpair_data, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-AVPair: %s\n", radius_avpair_data); + if (rc_avpair_add(rad_config, &send, PW_FS_AVPAIR, (void *)radius_avpair_data_tmp, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-AVPair: %s\n", radius_avpair_data_tmp); rc_destroy(rad_config); + switch_safe_free(radius_avpair_data); goto end; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "added Freeswitch-AVPair: %s\n", radius_avpair_data); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "added Freeswitch-AVPair: %s\n", radius_avpair_data_tmp); if (delim) { - radius_avpair_data = delim + 2; + radius_avpair_data_tmp = delim + 2; } } while (delim); + + switch_safe_free(radius_avpair_data); } } else { @@ -413,11 +434,13 @@ static switch_status_t my_on_routing(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] RADIUS Accounting Failed\n"); retval = SWITCH_STATUS_TERM; } + rc_avpair_free(send); rc_destroy(rad_config); end: switch_xml_free(cdr); switch_thread_rwlock_unlock(globals.rwlock); + return (retval); } diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 6ed46489a7..228e89b323 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -4765,7 +4765,7 @@ static void send_console_command(struct rayo_client *client, const char *to, con iks *command = NULL; iksparser *p = iks_dom_new(&command); - if (iks_parse(p, command_str, 0, 1) == IKS_OK && command) { + if (p && iks_parse(p, command_str, 0, 1) == IKS_OK && command) { char *str; iks *iq = NULL; @@ -4784,9 +4784,11 @@ static void send_console_command(struct rayo_client *client, const char *to, con if (!iks_find_attrib(iq, "type")) { iks_insert_attrib(iq, "type", "set"); } + if (!iks_find_attrib(iq, "id")) { iks_insert_attrib_printf(iq, "id", "console-%i", RAYO_SEQ_NEXT(client)); } + iks_insert_attrib(iq, "from", RAYO_JID(client)); /* send command */ @@ -4794,10 +4796,13 @@ static void send_console_command(struct rayo_client *client, const char *to, con switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nSEND: to %s, %s\n", to, str); rayo_client_command_recv(client, iq); iks_delete(command); + iks_parser_delete(p); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "bad request xml\n"); + if (p) { + iks_parser_delete(p); + } } - iks_parser_delete(p); } /** diff --git a/src/mod/formats/mod_imagick/mod_imagick.c b/src/mod/formats/mod_imagick/mod_imagick.c index ce789637cf..5c185a5e44 100644 --- a/src/mod/formats/mod_imagick/mod_imagick.c +++ b/src/mod/formats/mod_imagick/mod_imagick.c @@ -384,10 +384,11 @@ static switch_status_t read_page(pdf_file_context_t *context) if (ret == MagickFalse && context->exception->severity != UndefinedException) { CatchException(context->exception); free(storage); + return SWITCH_STATUS_FALSE; } - switch_img_from_raw(context->img, storage, SWITCH_IMG_FMT_BGR24, w, h); + switch_img_from_raw(&context->img, storage, SWITCH_IMG_FMT_BGR24, w, h); free(storage); } else { switch_image_t *img = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, image->columns, image->rows, 0); @@ -397,6 +398,8 @@ static switch_status_t read_page(pdf_file_context_t *context) if (ret == MagickFalse && context->exception->severity != UndefinedException) { CatchException(context->exception); + switch_img_free(&img); + return SWITCH_STATUS_FALSE; } diff --git a/src/mod/formats/mod_opusfile/mod_opusfile.c b/src/mod/formats/mod_opusfile/mod_opusfile.c index afd5f51267..a065108f5c 100644 --- a/src/mod/formats/mod_opusfile/mod_opusfile.c +++ b/src/mod/formats/mod_opusfile/mod_opusfile.c @@ -295,6 +295,7 @@ static switch_status_t switch_opusfile_open(switch_file_handle_t *handle, const context->of = op_open_file(path, &ret); if (!context->of) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[OGG/OPUS File] Error opening %s\n", path); + switch_thread_rwlock_unlock(context->rwlock); return SWITCH_STATUS_GENERR; } @@ -653,6 +654,7 @@ static switch_status_t switch_opusstream_stream_decode(opus_stream_context_t *co } switch_goto_status(SWITCH_STATUS_SUCCESS, end); } + break; case OP_EREAD: /*An underlying read operation failed. This may signal a truncation attack from an source.*/ case OP_EFAULT: /* An internal memory allocation failed. */ diff --git a/src/mod/formats/mod_png/mod_png.c b/src/mod/formats/mod_png/mod_png.c index 36e38e9c83..fbbe6aaf20 100644 --- a/src/mod/formats/mod_png/mod_png.c +++ b/src/mod/formats/mod_png/mod_png.c @@ -215,7 +215,7 @@ static switch_status_t png_file_read_video(switch_file_handle_t *handle, switch_ switch_goto_status(SWITCH_STATUS_FALSE, end); } - if ((flags && SVR_BLOCK)) { + if ((flags & SVR_BLOCK)) { switch_yield(33000); have_frame = 1; } else if ((context->reads++ % 20) == 0) { diff --git a/src/mod/formats/mod_shout/Makefile.am b/src/mod/formats/mod_shout/Makefile.am index ace4ce4af4..6318d312a0 100644 --- a/src/mod/formats/mod_shout/Makefile.am +++ b/src/mod/formats/mod_shout/Makefile.am @@ -7,8 +7,8 @@ if HAVE_MP3LAME mod_LTLIBRARIES = mod_shout.la mod_shout_la_SOURCES = mod_shout.c -mod_shout_la_CFLAGS = $(AM_CFLAGS) -mod_shout_la_CPPFLAGS = $(CURL_CFLAGS) $(AM_CPPFLAGS) $(SHOUT_CFLAGS) $(MP3LAME_CFLAGS) $(MPG123_CFLAGS) +mod_shout_la_CFLAGS = $(AM_CFLAGS) -DSHOUT_VERSION=$(SHOUT_VERSION) -DSHOUT_MAJOR_VERSION=$(SHOUT_MAJOR_VERSION) -DSHOUT_MINOR_VERSION=$(SHOUT_MINOR_VERSION) -DSHOUT_PATCH_VERSION=$(SHOUT_PATCH_VERSION) +mod_shout_la_CPPFLAGS = $(CURL_CFLAGS) $(AM_CPPFLAGS) $(SHOUT_CFLAGS) $(MP3LAME_CFLAGS) $(MPG123_CFLAGS) -DSHOUT_VERSION=$(SHOUT_VERSION) -DSHOUT_MAJOR_VERSION=$(SHOUT_MAJOR_VERSION) -DSHOUT_MINOR_VERSION=$(SHOUT_MINOR_VERSION) -DSHOUT_PATCH_VERSION=$(SHOUT_PATCH_VERSION) mod_shout_la_LIBADD = $(switch_builddir)/libfreeswitch.la mod_shout_la_LDFLAGS = $(CURL_LIBS) -avoid-version -module -no-undefined -shared $(SHOUT_LIBS) $(MP3LAME_LIBS) $(MPG123_LIBS) diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index 14cba068d3..be05ba5c32 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -51,6 +51,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_shout_shutdown); SWITCH_MODULE_DEFINITION(mod_shout, mod_shout_load, mod_shout_shutdown, NULL); +#define CHECK_SHOUT_MIN_VERSION(major, minor, patch) \ + (SHOUT_MAJOR_VERSION > major || \ + (SHOUT_MAJOR_VERSION == major && SHOUT_MINOR_VERSION > minor) || \ + (SHOUT_MAJOR_VERSION == major && SHOUT_MINOR_VERSION == minor && SHOUT_PATCH_VERSION >= patch)) + static char *supported_formats[SWITCH_MAX_CODECS] = { 0 }; static struct { @@ -463,7 +468,11 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data) return 0; } +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x072000) +static int progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) +#else static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) +#endif { shout_context_t *context = (shout_context_t *) clientp; return context->err; @@ -496,8 +505,13 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void switch_mutex_unlock(context->audio_mutex); curl_handle = switch_curl_easy_init(); switch_curl_easy_setopt(curl_handle, CURLOPT_URL, context->stream_url); +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x072000) + curl_easy_setopt(curl_handle, CURLOPT_XFERINFOFUNCTION, progress_callback); + curl_easy_setopt(curl_handle, CURLOPT_XFERINFODATA, (void *)context); +#else curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, progress_callback); curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, (void *)context); +#endif switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10); switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, stream_callback); @@ -862,12 +876,20 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char goto error; } +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_URL, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) { +#else if (shout_set_url(context->shout, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) { +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout)); goto error; } +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_DESCRIPTION, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) { +#else if (shout_set_description(context->shout, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) { +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting description: %s\n", shout_get_error(context->shout)); goto error; } @@ -877,7 +899,11 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char goto error; } +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_content_format(context->shout, SHOUT_FORMAT_MP3, SHOUT_USAGE_AUDIO, NULL) != SHOUTERR_SUCCESS) { +#else if (shout_set_format(context->shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) { +#endif switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting format: %s\n", shout_get_error(context->shout)); goto error; } @@ -1127,21 +1153,33 @@ static switch_status_t shout_file_set_string(switch_file_handle_t *handle, switc switch (col) { case SWITCH_AUDIO_COL_STR_TITLE: +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_NAME, string) == SHOUTERR_SUCCESS) { +#else if (shout_set_name(context->shout, string) == SHOUTERR_SUCCESS) { +#endif status = SWITCH_STATUS_SUCCESS; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout)); } break; case SWITCH_AUDIO_COL_STR_COMMENT: +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_URL, string) == SHOUTERR_SUCCESS) { +#else if (shout_set_url(context->shout, string) == SHOUTERR_SUCCESS) { +#endif status = SWITCH_STATUS_SUCCESS; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout)); } break; case SWITCH_AUDIO_COL_STR_ARTIST: +#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6)) + if (shout_set_meta(context->shout, SHOUT_META_DESCRIPTION, string) == SHOUTERR_SUCCESS) { +#else if (shout_set_description(context->shout, string) == SHOUTERR_SUCCESS) { +#endif status = SWITCH_STATUS_SUCCESS; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout)); diff --git a/src/mod/languages/mod_java/modjava.c b/src/mod/languages/mod_java/modjava.c index a334af302d..9c38bdb70f 100644 --- a/src/mod/languages/mod_java/modjava.c +++ b/src/mod/languages/mod_java/modjava.c @@ -189,169 +189,163 @@ SWITCH_STANDARD_APP(java_function) static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount, vm_control_t * vmControl) { - switch_xml_t cfg, xml; - switch_status_t status = SWITCH_STATUS_SUCCESS; + switch_xml_t cfg, xml; + switch_status_t status = SWITCH_STATUS_SUCCESS; char *derr = NULL; - xml = switch_xml_open_cfg("java.conf", &cfg, NULL); - if (xml) - { - switch_xml_t javavm; - switch_xml_t options; - switch_xml_t startup; - switch_xml_t shutdown; + xml = switch_xml_open_cfg("java.conf", &cfg, NULL); + if (xml) { + switch_xml_t javavm; + switch_xml_t options; + switch_xml_t startup; + switch_xml_t shutdown; - javavm = switch_xml_child(cfg, "javavm"); - if (javavm != NULL) - { - const char *path = switch_xml_attr_soft(javavm, "path"); - if (path != NULL) - { + javavm = switch_xml_child(cfg, "javavm"); + if (javavm != NULL) { + const char *path = switch_xml_attr_soft(javavm, "path"); + + if (path != NULL) { javaVMHandle = switch_dso_open(path, 0, &derr); if (derr || !javaVMHandle) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path); + switch_safe_free(derr); } - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n"); - status = SWITCH_STATUS_FALSE; - } - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n"); - status = SWITCH_STATUS_FALSE; - goto close; - } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n"); + status = SWITCH_STATUS_FALSE; + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n"); + status = SWITCH_STATUS_FALSE; + goto close; + } + + options = switch_xml_child(cfg, "options"); + if (options != NULL) { + switch_xml_t option; + int i = 0; + + *optionCount = 0; + + for (option = switch_xml_child(options, "option"); option; option = option->next) { + const char *value = switch_xml_attr_soft(option, "value"); + + if (value != NULL) { + ++*optionCount; + } + } + + *optionCount += 1; + *javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption))); + if (*javaOptions == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n"); + status = SWITCH_STATUS_FALSE; + goto close; + } + + for (option = switch_xml_child(options, "option"); option; option = option->next) { + const char *value = switch_xml_attr_soft(option, "value"); + + if (value == NULL) { + continue; + } + + (*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value); + if ((*javaOptions)[i].optionString == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n"); + status = SWITCH_STATUS_FALSE; + goto close; + } + + ++i; + } - options = switch_xml_child(cfg, "options"); - if (options != NULL) - { - switch_xml_t option; - int i = 0; - *optionCount = 0; - for (option = switch_xml_child(options, "option"); option; option = option->next) - { - const char *value = switch_xml_attr_soft(option, "value"); - if (value != NULL) - ++*optionCount; - } - *optionCount += 1; - *javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption))); - if (*javaOptions == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n"); - status = SWITCH_STATUS_FALSE; - goto close; - } - for (option = switch_xml_child(options, "option"); option; option = option->next) - { - const char *value = switch_xml_attr_soft(option, "value"); - if (value == NULL) - continue; - (*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value); - if ((*javaOptions)[i].optionString == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n"); - status = SWITCH_STATUS_FALSE; - goto close; - } - ++i; - } (*javaOptions)[i].optionString = switch_core_sprintf(memoryPool, "-Djava.library.path=%s", SWITCH_GLOBAL_dirs.mod_dir); - } + } - /* - - - */ + /* + + + */ - memset(vmControl, 0, sizeof(struct vm_control)); - startup = switch_xml_child(cfg, "startup"); - if (startup != NULL) { - vmControl->startup.class = switch_xml_attr_soft(startup, "class"); - vmControl->startup.method = switch_xml_attr_soft(startup, "method"); - vmControl->startup.arg = switch_xml_attr_soft(startup, "arg"); - } - shutdown = switch_xml_child(cfg, "shutdown"); - if (shutdown != NULL) { - vmControl->shutdown.class = switch_xml_attr_soft(shutdown, "class"); - vmControl->shutdown.method = switch_xml_attr_soft(shutdown, "method"); - vmControl->shutdown.arg = switch_xml_attr_soft(shutdown, "arg"); - } + memset(vmControl, 0, sizeof(struct vm_control)); + startup = switch_xml_child(cfg, "startup"); + if (startup != NULL) { + vmControl->startup.class = switch_xml_attr_soft(startup, "class"); + vmControl->startup.method = switch_xml_attr_soft(startup, "method"); + vmControl->startup.arg = switch_xml_attr_soft(startup, "arg"); + } - close: - switch_xml_free(xml); - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n"); - status = SWITCH_STATUS_FALSE; - } - return status; + shutdown = switch_xml_child(cfg, "shutdown"); + if (shutdown != NULL) { + vmControl->shutdown.class = switch_xml_attr_soft(shutdown, "class"); + vmControl->shutdown.method = switch_xml_attr_soft(shutdown, "method"); + vmControl->shutdown.arg = switch_xml_attr_soft(shutdown, "arg"); + } + + close: + switch_xml_free(xml); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n"); + status = SWITCH_STATUS_FALSE; + } + + return status; } static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm_control_t * vmControl) { - jint (JNICALL *pJNI_CreateJavaVM)(JavaVM**,void**,void*); - switch_status_t status; + jint (JNICALL *pJNI_CreateJavaVM)(JavaVM**,void**,void*); + switch_status_t status; char *derr = NULL; pJNI_CreateJavaVM = (jint (*)(JavaVM **, void **, void *))switch_dso_func_sym(javaVMHandle, "JNI_CreateJavaVM", &derr); - if (!derr) - { - JNIEnv *env; - JavaVMInitArgs initArgs; - jint res; + if (!derr) { + JNIEnv *env; + JavaVMInitArgs initArgs; + jint res; - memset(&initArgs, 0, sizeof(initArgs)); - initArgs.version = JNI_VERSION_1_4; - initArgs.nOptions = optionCount; - initArgs.options = options; - initArgs.ignoreUnrecognized = JNI_TRUE; + memset(&initArgs, 0, sizeof(initArgs)); + initArgs.version = JNI_VERSION_1_4; + initArgs.nOptions = optionCount; + initArgs.options = options; + initArgs.ignoreUnrecognized = JNI_TRUE; - res = pJNI_CreateJavaVM(&javaVM, (void*) &env, &initArgs); - if (res == JNI_OK) - { - // call FindClass here already so that the Java VM executes the static - // initializer (@see org.freeswitch.Launcher) which loads the jni library - // so we can use jni functions right away (for example in the startup method) - launcherClass = (*env)->FindClass(env, "org/freeswitch/Launcher"); - if ( launcherClass == NULL ) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find 'org.freeswitch.Launcher' class!\n"); - (*env)->ExceptionDescribe(env); - } + res = pJNI_CreateJavaVM(&javaVM, (void*) &env, &initArgs); + if (res == JNI_OK) { + /* call FindClass here already so that the Java VM executes the static + initializer (@see org.freeswitch.Launcher) which loads the jni library + so we can use jni functions right away (for example in the startup method) */ - // store a global reference for use in the launch_java() function - launcherClass = (*env)->NewGlobalRef(env, launcherClass); - if ( launcherClass == NULL ) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n"); - (*env)->ExceptionDescribe(env); - status = SWITCH_STATUS_FALSE; - } - else - { - status = SWITCH_STATUS_SUCCESS; - } + launcherClass = (*env)->FindClass(env, "org/freeswitch/Launcher"); + if ( launcherClass == NULL ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find 'org.freeswitch.Launcher' class!\n"); + (*env)->ExceptionDescribe(env); + } - (*javaVM)->DetachCurrentThread(javaVM); - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating Java VM!\n"); - status = SWITCH_STATUS_FALSE; - } - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Specified Java VM doesn't have JNI_CreateJavaVM\n"); - status = SWITCH_STATUS_FALSE; - } - return status; + /* store a global reference for use in the launch_java() function */ + launcherClass = (*env)->NewGlobalRef(env, launcherClass); + if ( launcherClass == NULL ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n"); + (*env)->ExceptionDescribe(env); + status = SWITCH_STATUS_FALSE; + } else { + status = SWITCH_STATUS_SUCCESS; + } + + (*javaVM)->DetachCurrentThread(javaVM); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating Java VM!\n"); + status = SWITCH_STATUS_FALSE; + } + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Specified Java VM doesn't have JNI_CreateJavaVM\n"); + switch_safe_free(derr); + status = SWITCH_STATUS_FALSE; + } + + return status; } SWITCH_MODULE_LOAD_FUNCTION(mod_java_load) diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 89614987b5..742e4f979e 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -21077,6 +21077,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_frame_free___(void * } +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_is_uint_in_range___(char * jarg1, unsigned int jarg2, unsigned int jarg3) { + int jresult ; + char *arg1 = (char *) 0 ; + unsigned int arg2 ; + unsigned int arg3 ; + switch_bool_t result; + + arg1 = (char *)jarg1; + arg2 = (unsigned int)jarg2; + arg3 = (unsigned int)jarg3; + result = (switch_bool_t)switch_is_uint_in_range((char const *)arg1,arg2,arg3); + jresult = (int)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_is_number___(char * jarg1) { int jresult ; char *arg1 = (char *) 0 ; @@ -33245,6 +33261,50 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_microsecon } +SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_max_ptime_set___(void * jarg1, int jarg2) { + switch_codec_fmtp *arg1 = (switch_codec_fmtp *) 0 ; + int arg2 ; + + arg1 = (switch_codec_fmtp *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->max_ptime = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_max_ptime_get___(void * jarg1) { + int jresult ; + switch_codec_fmtp *arg1 = (switch_codec_fmtp *) 0 ; + int result; + + arg1 = (switch_codec_fmtp *)jarg1; + result = (int) ((arg1)->max_ptime); + jresult = result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_min_ptime_set___(void * jarg1, int jarg2) { + switch_codec_fmtp *arg1 = (switch_codec_fmtp *) 0 ; + int arg2 ; + + arg1 = (switch_codec_fmtp *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->min_ptime = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_min_ptime_get___(void * jarg1) { + int jresult ; + switch_codec_fmtp *arg1 = (switch_codec_fmtp *) 0 ; + int result; + + arg1 = (switch_codec_fmtp *)jarg1; + result = (int) ((arg1)->min_ptime); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_stereo_set___(void * jarg1, int jarg2) { switch_codec_fmtp *arg1 = (switch_codec_fmtp *) 0 ; int arg2 ; @@ -33267,6 +33327,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_stereo_get } +SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_sprop_stereo_set___(void * jarg1, int jarg2) { + switch_codec_fmtp *arg1 = (switch_codec_fmtp *) 0 ; + int arg2 ; + + arg1 = (switch_codec_fmtp *)jarg1; + arg2 = (int)jarg2; + if (arg1) (arg1)->sprop_stereo = arg2; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_sprop_stereo_get___(void * jarg1) { + int jresult ; + switch_codec_fmtp *arg1 = (switch_codec_fmtp *) 0 ; + int result; + + arg1 = (switch_codec_fmtp *)jarg1; + result = (int) ((arg1)->sprop_stereo); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_codec_fmtp_private_info_set___(void * jarg1, void * jarg2) { switch_codec_fmtp *arg1 = (switch_codec_fmtp *) 0 ; void *arg2 = (void *) 0 ; @@ -36802,6 +36884,44 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_channel_get_variab } +SWIGEXPORT char * SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_channel_get_variable_strdup___(void * jarg1, char * jarg2) { + char * jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + + arg1 = (switch_channel_t *)jarg1; + arg2 = (char *)jarg2; + result = (char *)switch_channel_get_variable_strdup(arg1,(char const *)arg2); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_channel_get_variable_buf___(void * jarg1, char * jarg2, char * jarg3, void * jarg4) { + int jresult ; + switch_channel_t *arg1 = (switch_channel_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_size_t arg4 ; + switch_size_t *argp4 ; + switch_status_t result; + + arg1 = (switch_channel_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + argp4 = (switch_size_t *)jarg4; + if (!argp4) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return 0; + } + arg4 = *argp4; + result = (switch_status_t)switch_channel_get_variable_buf(arg1,(char const *)arg2,arg3,arg4); + jresult = (int)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_channel_get_variables___(void * jarg1, void * jarg2) { int jresult ; switch_channel_t *arg1 = (switch_channel_t *) 0 ; @@ -45145,6 +45265,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_MAX_CAND_get___() { } +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_MAX_CAND_IDX_COUNT_get___() { + int jresult ; + int result; + + result = (int)(2); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_ice_t_cands_set___(void * jarg1, void * jarg2) { ice_s *arg1 = (ice_s *) 0 ; icand_t (*arg2)[2] ; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 6483ed103b..02848257bf 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -10932,6 +10932,11 @@ else return ret; } + public static switch_bool_t switch_is_uint_in_range(string str, uint from, uint to) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_is_uint_in_range(str, from, to); + return ret; + } + public static switch_bool_t switch_is_number(string str) { switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_is_number(str); return ret; @@ -11884,6 +11889,17 @@ else return ret; } + public static string switch_channel_get_variable_strdup(SWIGTYPE_p_switch_channel channel, string varname) { + string ret = freeswitchPINVOKE.switch_channel_get_variable_strdup(SWIGTYPE_p_switch_channel.getCPtr(channel), varname); + return ret; + } + + public static switch_status_t switch_channel_get_variable_buf(SWIGTYPE_p_switch_channel channel, string varname, string buf, SWIGTYPE_p_switch_size_t buflen) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_channel_get_variable_buf(SWIGTYPE_p_switch_channel.getCPtr(channel), varname, buf, SWIGTYPE_p_switch_size_t.getCPtr(buflen)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + public static switch_status_t switch_channel_get_variables(SWIGTYPE_p_switch_channel channel, SWIGTYPE_p_p_switch_event arg1) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_channel_get_variables(SWIGTYPE_p_switch_channel.getCPtr(channel), SWIGTYPE_p_p_switch_event.getCPtr(arg1)); return ret; @@ -15223,6 +15239,7 @@ else public static readonly string SWITCH_RTP_CRYPTO_KEY_80 = freeswitchPINVOKE.SWITCH_RTP_CRYPTO_KEY_80_get(); public static readonly int SWITCH_RTP_BUNDLE_INTERNAL_PT = freeswitchPINVOKE.SWITCH_RTP_BUNDLE_INTERNAL_PT_get(); public static readonly int MAX_CAND = freeswitchPINVOKE.MAX_CAND_get(); + public static readonly int MAX_CAND_IDX_COUNT = freeswitchPINVOKE.MAX_CAND_IDX_COUNT_get(); public static readonly int SWITCH_XML_BUFSIZE = freeswitchPINVOKE.SWITCH_XML_BUFSIZE_get(); } @@ -20575,6 +20592,9 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_frame_free___")] public static extern int switch_frame_free(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_is_uint_in_range___")] + public static extern int switch_is_uint_in_range(string jarg1, uint jarg2, uint jarg3); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_is_number___")] public static extern int switch_is_number(string jarg1); @@ -23614,12 +23634,30 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_microseconds_per_packet_get___")] public static extern int switch_codec_fmtp_microseconds_per_packet_get(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_max_ptime_set___")] + public static extern void switch_codec_fmtp_max_ptime_set(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_max_ptime_get___")] + public static extern int switch_codec_fmtp_max_ptime_get(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_min_ptime_set___")] + public static extern void switch_codec_fmtp_min_ptime_set(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_min_ptime_get___")] + public static extern int switch_codec_fmtp_min_ptime_get(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_stereo_set___")] public static extern void switch_codec_fmtp_stereo_set(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_stereo_get___")] public static extern int switch_codec_fmtp_stereo_get(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_sprop_stereo_set___")] + public static extern void switch_codec_fmtp_sprop_stereo_set(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_sprop_stereo_get___")] + public static extern int switch_codec_fmtp_sprop_stereo_get(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_codec_fmtp_private_info_set___")] public static extern void switch_codec_fmtp_private_info_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); @@ -24487,6 +24525,12 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_channel_get_variable_dup___")] public static extern string switch_channel_get_variable_dup(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, int jarg3, int jarg4); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_channel_get_variable_strdup___")] + public static extern string switch_channel_get_variable_strdup(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_channel_get_variable_buf___")] + public static extern int switch_channel_get_variable_buf(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, string jarg3, global::System.Runtime.InteropServices.HandleRef jarg4); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_channel_get_variables___")] public static extern int switch_channel_get_variables(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); @@ -26281,6 +26325,9 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_MAX_CAND_get___")] public static extern int MAX_CAND_get(); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_MAX_CAND_IDX_COUNT_get___")] + public static extern int MAX_CAND_IDX_COUNT_get(); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_ice_t_cands_set___")] public static extern void ice_t_cands_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); @@ -31066,7 +31113,8 @@ public enum switch_call_cause_t { SWITCH_CAUSE_BAD_IDENTITY_INFO = 821, SWITCH_CAUSE_UNSUPPORTED_CERTIFICATE = 822, SWITCH_CAUSE_INVALID_IDENTITY = 823, - SWITCH_CAUSE_STALE_DATE = 824 + SWITCH_CAUSE_STALE_DATE = 824, + SWITCH_CAUSE_REJECT_ALL = 825 } } @@ -32781,6 +32829,7 @@ public enum switch_codec_control_command_t { SCC_VIDEO_RESET, SCC_AUDIO_PACKET_LOSS, SCC_AUDIO_ADJUST_BITRATE, + SCC_AUDIO_VAD, SCC_DEBUG, SCC_CODEC_SPECIFIC } @@ -32905,6 +32954,26 @@ public class switch_codec_fmtp : global::System.IDisposable { } } + public int max_ptime { + set { + freeswitchPINVOKE.switch_codec_fmtp_max_ptime_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_codec_fmtp_max_ptime_get(swigCPtr); + return ret; + } + } + + public int min_ptime { + set { + freeswitchPINVOKE.switch_codec_fmtp_min_ptime_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_codec_fmtp_min_ptime_get(swigCPtr); + return ret; + } + } + public int stereo { set { freeswitchPINVOKE.switch_codec_fmtp_stereo_set(swigCPtr, value); @@ -32915,6 +32984,16 @@ public class switch_codec_fmtp : global::System.IDisposable { } } + public int sprop_stereo { + set { + freeswitchPINVOKE.switch_codec_fmtp_sprop_stereo_set(swigCPtr, value); + } + get { + int ret = freeswitchPINVOKE.switch_codec_fmtp_sprop_stereo_get(swigCPtr); + return ret; + } + } + public SWIGTYPE_p_void private_info { set { freeswitchPINVOKE.switch_codec_fmtp_private_info_set(swigCPtr, SWIGTYPE_p_void.getCPtr(value)); diff --git a/src/mod/languages/mod_python3/mod_python3.c b/src/mod/languages/mod_python3/mod_python3.c index ca05f18710..263c2de1d4 100644 --- a/src/mod/languages/mod_python3/mod_python3.c +++ b/src/mod/languages/mod_python3/mod_python3.c @@ -86,6 +86,9 @@ static void print_python_error(const char * script) { PyObject *pyType = NULL, *pyValue = NULL, *pyTraceback = NULL, *pyString = NULL; PyObject *pyModule=NULL, *pyFunction = NULL, *pyResult = NULL; +#if PY_VERSION_HEX >= 0x030B0000 + PyCodeObject *pcode = NULL; +#endif char * buffer = (char*) malloc( 20 * 1024 * sizeof(char)); /* Variables for the traceback */ PyTracebackObject * pyTB = NULL/*, *pyTB2 = NULL*/; @@ -153,10 +156,23 @@ static void print_python_error(const char * script) /* Traceback */ do { - sprintf((char*)sTemp, "\n\tFile: \"%s\", line %i, in %s", +#if PY_VERSION_HEX >= 0x030B0000 + if (pyTB->tb_frame != NULL) { + pcode = PyFrame_GetCode(pyTB->tb_frame); + } else { + pcode = NULL; + } + + snprintf((char*)sTemp, sizeof(sTemp), "\n\tFile: \"%s\", line %i, in %s", + (pcode)?PyString_AsString(pcode->co_filename):"", + pyTB->tb_lineno, + (pcode)?PyString_AsString(pcode->co_name):"" ); +#else + snprintf((char*)sTemp, sizeof(sTemp), "\n\tFile: \"%s\", line %i, in %s", PyString_AsString(pyTB->tb_frame->f_code->co_filename), pyTB->tb_lineno, PyString_AsString(pyTB->tb_frame->f_code->co_name) ); +#endif strcat(buffer, (char*)sTemp); pyTB=pyTB->tb_next; diff --git a/src/mod/languages/mod_v8/src/fsglobal.cpp b/src/mod/languages/mod_v8/src/fsglobal.cpp index 99a0626f8f..c360955687 100644 --- a/src/mod/languages/mod_v8/src/fsglobal.cpp +++ b/src/mod/languages/mod_v8/src/fsglobal.cpp @@ -169,6 +169,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash) } else { /* The var exists, but is wrong type - exit with error */ info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Second argument is the name of an existing var of the wrong type")); + return; } } else if (info.Length() > 1 && info[1]->IsArray()) { @@ -177,6 +178,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash) } else if (info.Length() > 1) { /* The var exists, but is wrong type - exit with error */ info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Second argument is of the wrong type")); + return; } else { /* Second argument doesn't exist, this is also ok. The hash will be returned as the result */ @@ -185,6 +187,11 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash) } curl_handle = switch_curl_easy_init(); + if (!curl_handle) { + info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session.")); + + return; + } if (!strncasecmp(js_safe_str(*url), "https", 5)) { switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); @@ -224,14 +231,22 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLFile) const char *url = NULL, *filename = NULL; String::Utf8Value str1(info[0]); String::Utf8Value str2(info[1]); + url = js_safe_str(*str1); filename = js_safe_str(*str2); curl_handle = switch_curl_easy_init(); + if (!curl_handle) { + info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session.")); + + return; + } + if (!strncasecmp(url, "https", 5)) { switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); } + config_data.isolate = info.GetIsolate(); if ((config_data.fileHandle = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) { @@ -245,13 +260,14 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLFile) switch_curl_easy_perform(curl_handle); - switch_curl_easy_cleanup(curl_handle); close(config_data.fileHandle); info.GetReturnValue().Set(true); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file [%s]\n", filename); info.GetReturnValue().Set(false); } + + switch_curl_easy_cleanup(curl_handle); } else { info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Invalid arguments")); } @@ -270,12 +286,19 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURL) if (info.Length() >= 1) { const char *url; String::Utf8Value str(info[0]); + url = js_safe_str(*str); if (info.Length() > 1) { buffer_size = info[1]->Int32Value(); } curl_handle = switch_curl_easy_init(); + if (!curl_handle) { + info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session.")); + + return; + } + if (!strncasecmp(url, "https", 5)) { switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); @@ -289,6 +312,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURL) if (config_data.buffer == NULL) { info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to allocate data buffer.")); switch_curl_easy_cleanup(curl_handle); + return; } diff --git a/src/mod/loggers/mod_logfile/mod_logfile.c b/src/mod/loggers/mod_logfile/mod_logfile.c index 877403c5b6..e79e23129a 100644 --- a/src/mod/loggers/mod_logfile/mod_logfile.c +++ b/src/mod/loggers/mod_logfile/mod_logfile.c @@ -98,6 +98,8 @@ static switch_status_t mod_logfile_openlogfile(logfile_profile_t *profile, switc stat = switch_file_open(&afd, profile->logfile, flags, SWITCH_FPROT_OS_DEFAULT, module_pool); if (stat != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "logfile %s open error, status=%d\n", profile->logfile, stat); + return SWITCH_STATUS_FALSE; } @@ -459,7 +461,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_logfile_load) if ((profiles = switch_xml_child(cfg, "profiles"))) { for (xprofile = switch_xml_child(profiles, "profile"); xprofile; xprofile = xprofile->next) { if (load_profile(xprofile) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error loading profile."); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error loading profile.\n"); } } } diff --git a/src/mod/say/mod_say_en/mod_say_en.c b/src/mod/say/mod_say_en/mod_say_en.c index 5ea52357dd..1f8d6e017a 100644 --- a/src/mod/say/mod_say_en/mod_say_en.c +++ b/src/mod/say/mod_say_en/mod_say_en.c @@ -196,7 +196,7 @@ static switch_status_t en_say_general_count(switch_say_file_handle_t *sh, char * static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args) { - int32_t t = 0; + int64_t t = 0; switch_time_t target = 0, target_now = 0; switch_time_exp_t tm, tm_now; uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0; @@ -287,7 +287,7 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw if (strchr(tosay, ':')) { switch_time_t tme = switch_str_time(tosay); - t = (int32_t) ((tme) / (int64_t) (1000000)); + t = (int64_t) ((tme) / (int64_t) (1000000)); target = switch_time_make(t, 0); target_now = switch_micro_time_now(); diff --git a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c index 4e3bd81f78..8a6efbf544 100644 --- a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c +++ b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c @@ -88,7 +88,7 @@ static size_t httpCallBack(char *buffer, size_t size, size_t nitems, void *outst return size * nitems; } -static switch_status_t set_xml_cdr_log_dirs() +static switch_status_t set_xml_cdr_log_dirs(void) { switch_time_exp_t tm; char *path = NULL; @@ -254,7 +254,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) #endif int wrote; wrote = write(fd, xml_text, (unsigned) strlen(xml_text)); - wrote++; + (void)wrote; close(fd); } else { char ebuf[512] = { 0 }; @@ -427,7 +427,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) #endif int wrote; wrote = write(fd, xml_text, (unsigned) strlen(xml_text)); - wrote++; + (void)wrote; close(fd); } else { char ebuf[512] = { 0 }; diff --git a/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c b/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c index 6a8f2aac53..67181e26c4 100644 --- a/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c +++ b/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c @@ -210,13 +210,6 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con switch_uuid_format(uuid_str, &uuid); switch_snprintf(filename, sizeof(filename), "%s%s%s.tmp.xml", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str); - curl_handle = switch_curl_easy_init(); - headers = switch_curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded"); - - if (!strncasecmp(binding->url, "https", 5)) { - switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); - switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); - } memset(&config_data, 0, sizeof(config_data)); @@ -224,6 +217,14 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con config_data.max_bytes = binding->curl_max_bytes; if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) { + curl_handle = switch_curl_easy_init(); + headers = switch_curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded"); + + if (!strncasecmp(binding->url, "https", 5)) { + switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); + switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); + } + if (!zstr(binding->cred)) { switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, binding->auth_scheme); switch_curl_easy_setopt(curl_handle, CURLOPT_USERPWD, binding->cred); diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c index 43e25b6f9e..8e49462d2c 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c @@ -614,7 +614,7 @@ abyss_bool websocket_hook(TSession *r) if (ret != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "handshake error %d\n", ret); - return FALSE; + goto err; } if (switch_event_bind_removable("websocket", SWITCH_EVENT_CUSTOM, "websocket::stophook", stop_hook_event_handler, wsh, &nodes[node_count++]) != SWITCH_STATUS_SUCCESS) { @@ -696,8 +696,11 @@ abyss_bool websocket_hook(TSession *r) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "wsh->down = %d, node_count = %d\n", wsh->down, node_count); switch_yield(2000); + while (--node_count >= 0) switch_event_unbind(&nodes[node_count]); + err: + ws_destroy(wsh); switch_safe_free(wsh); return FALSE; diff --git a/src/mod/xml_int/mod_xml_scgi/mod_xml_scgi.c b/src/mod/xml_int/mod_xml_scgi/mod_xml_scgi.c index 63306c76a3..24c0270a57 100644 --- a/src/mod/xml_int/mod_xml_scgi/mod_xml_scgi.c +++ b/src/mod/xml_int/mod_xml_scgi/mod_xml_scgi.c @@ -176,6 +176,10 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con if (bytes > XML_SCGI_MAX_BYTES) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Data too big!\n"); len = -1; + if (expanded != (char*)buf) { + free(expanded); + } + break; } diff --git a/src/switch.c b/src/switch.c index 19a3d93fad..5011ff2d46 100644 --- a/src/switch.c +++ b/src/switch.c @@ -101,7 +101,7 @@ static void handle_SIGTERM(int sig) } /* kill a freeswitch process running in background mode */ -static int freeswitch_kill_background() +static int freeswitch_kill_background(void) { FILE *f; /* FILE handle to open the pid file */ char path[PATH_MAX] = ""; /* full path of the PID file */ diff --git a/src/switch_apr.c b/src/switch_apr.c index 9bc5d8a759..bd6cfdec56 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -74,7 +74,16 @@ #if (defined(HAVE_LIBMD5) || defined(HAVE_LIBMD) || defined(HAVE_MD5INIT)) #include #elif defined(HAVE_LIBCRYPTO) -#include + #ifndef OPENSSL_VERSION_NUMBER + #include + #endif + #if OPENSSL_VERSION_NUMBER < 0x30000000 + #include + #else + #include + #endif +#else + #include #endif #ifndef WIN32 @@ -1174,11 +1183,24 @@ SWITCH_DECLARE(switch_status_t) switch_md5(unsigned char digest[SWITCH_MD5_DIGES return SWITCH_STATUS_SUCCESS; #elif defined(HAVE_LIBCRYPTO) - MD5_CTX md5_context; + #if OPENSSL_VERSION_NUMBER < 0x30000000 + MD5_CTX md5_context; - MD5_Init(&md5_context); - MD5_Update(&md5_context, input, inputLen); - MD5_Final(digest, &md5_context); + MD5_Init(&md5_context); + MD5_Update(&md5_context, input, inputLen); + MD5_Final(digest, &md5_context); + #else + EVP_MD_CTX *md5_context; + + /* MD5_Init */ + md5_context = EVP_MD_CTX_new(); + EVP_DigestInit_ex(md5_context, EVP_md5(), NULL); + /* MD5_Update */ + EVP_DigestUpdate(md5_context, input, inputLen); + /* MD5_Final */ + EVP_DigestFinal_ex(md5_context, digest, NULL); + EVP_MD_CTX_free(md5_context); + #endif return SWITCH_STATUS_SUCCESS; #else diff --git a/src/switch_channel.c b/src/switch_channel.c index ea3f66c246..9c7b8e433d 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -135,6 +135,7 @@ static struct switch_cause_table CAUSE_CHART[] = { {"UNSUPPORTED_CERTIFICATE", SWITCH_CAUSE_UNSUPPORTED_CERTIFICATE}, {"INVALID_IDENTITY", SWITCH_CAUSE_INVALID_IDENTITY}, {"STALE_DATE", SWITCH_CAUSE_STALE_DATE}, + {"REJECT_ALL", SWITCH_CAUSE_REJECT_ALL}, {NULL, 0} }; @@ -1021,6 +1022,24 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *c return r; } +SWITCH_DECLARE(const char *) switch_channel_get_variable_strdup(switch_channel_t *channel, const char *varname) +{ + const char *value = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1); + + return value ? (const char *)strdup(value) : NULL; +} + +SWITCH_DECLARE(switch_status_t) switch_channel_get_variable_buf(switch_channel_t *channel, const char *varname, char *buf, switch_size_t buflen) +{ + const char *value = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1); + + if (value && buf && buflen && switch_copy_string(buf, value, buflen)) { + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_FALSE; +} + SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname) { const char *uuid; diff --git a/src/switch_console.c b/src/switch_console.c index 8e26fec749..2157fda8a2 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -1849,7 +1849,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string) SWITCH_STANDARD_STREAM(mystream); if (!strcasecmp(argv[0], "stickyadd")) { - mystream.write_function(&mystream, "insert into complete values (1,"); + mystream.write_function(&mystream, "insert into complete (sticky, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, hostname) values (1,"); for (x = 0; x < 10; x++) { if (argv[x + 1] && !strcasecmp(argv[x + 1], "_any_")) { mystream.write_function(&mystream, "%s", "'', "); @@ -1865,7 +1865,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string) switch_core_sql_exec(mystream.data); status = SWITCH_STATUS_SUCCESS; } else if (!strcasecmp(argv[0], "add")) { - mystream.write_function(&mystream, "insert into complete values (0,"); + mystream.write_function(&mystream, "insert into complete (sticky, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, hostname) values (0,"); for (x = 0; x < 10; x++) { if (argv[x + 1] && !strcasecmp(argv[x + 1], "_any_")) { mystream.write_function(&mystream, "%s", "'', "); diff --git a/src/switch_core.c b/src/switch_core.c index 83db2fc0d9..7ec10d8885 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -147,7 +147,7 @@ static void check_ip(void) } else if (strcmp(hostname, runtime.hostname)) { if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "condition", "hostname-change"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "old-hostname", hostname ? hostname : "nil"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "old-hostname", hostname); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "new-hostname", runtime.hostname); switch_event_fire(&event); } @@ -3009,7 +3009,7 @@ SWITCH_DECLARE(switch_bool_t) switch_core_ready_outbound(void) return (switch_test_flag((&runtime), SCF_SHUTTING_DOWN) || switch_test_flag((&runtime), SCF_NO_NEW_OUTBOUND_SESSIONS)) ? SWITCH_FALSE : SWITCH_TRUE; } -void switch_core_sqldb_destroy() +void switch_core_sqldb_destroy(void) { if (switch_test_flag((&runtime), SCF_USE_SQL)) { switch_core_sqldb_stop(); @@ -3566,7 +3566,7 @@ SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t } } -SWITCH_DECLARE(uint16_t) switch_core_get_rtp_port_range_start_port() +SWITCH_DECLARE(uint16_t) switch_core_get_rtp_port_range_start_port(void) { uint16_t start_port = 0; @@ -3577,7 +3577,7 @@ SWITCH_DECLARE(uint16_t) switch_core_get_rtp_port_range_start_port() return start_port; } -SWITCH_DECLARE(uint16_t) switch_core_get_rtp_port_range_end_port() +SWITCH_DECLARE(uint16_t) switch_core_get_rtp_port_range_end_port(void) { uint16_t end_port = 0; diff --git a/src/switch_core_cert.c b/src/switch_core_cert.c index c4fdd84210..64f497ea1a 100644 --- a/src/switch_core_cert.c +++ b/src/switch_core_cert.c @@ -287,7 +287,10 @@ SWITCH_DECLARE(int) switch_core_gen_certs(const char *prefix) //bio_err=BIO_new_fp(stderr, BIO_NOCLOSE); - mkcert(&x509, &pkey, 4096, 0, 36500); + if (!mkcert(&x509, &pkey, 4096, 0, 36500)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Certificate generation failed\n"); + goto end; + } //RSA_print_fp(stdout, pkey->pkey.rsa, 0); //X509_print_fp(stdout, x509); @@ -410,7 +413,9 @@ static int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days { X509 *x; EVP_PKEY *pk; +#if OPENSSL_VERSION_NUMBER < 0x30000000 RSA *rsa; +#endif X509_NAME *name=NULL; switch_assert(pkeyp); @@ -432,7 +437,26 @@ static int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days x = *x509p; } -#if OPENSSL_VERSION_NUMBER >= 0x10100000 +#if OPENSSL_VERSION_NUMBER >= 0x30000000 + { + EVP_PKEY_CTX *ctx; + + ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL); + /* Setup the key context */ + if ((!ctx) || (EVP_PKEY_keygen_init(ctx) <= 0) || (EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) <= 0)) { + abort(); + goto err; + } + + /* Generate key */ + if (EVP_PKEY_generate(ctx, &pk) <= 0) { + abort(); + goto err; + } + + EVP_PKEY_CTX_free(ctx); + } +#elif OPENSSL_VERSION_NUMBER >= 0x10100000 rsa = RSA_new(); { static const BN_ULONG ULONG_RSA_F4 = RSA_F4; @@ -449,11 +473,13 @@ static int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days rsa = RSA_generate_key(bits, RSA_F4, NULL, NULL); #endif +#if OPENSSL_VERSION_NUMBER < 0x30000000 if (!EVP_PKEY_assign_RSA(pk, rsa)) { abort(); } rsa = NULL; +#endif X509_set_version(x, 2); ASN1_INTEGER_set(X509_get_serialNumber(x), serial); @@ -476,13 +502,21 @@ static int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days */ X509_set_issuer_name(x, name); - if (!X509_sign(x, pk, EVP_sha1())) +#if OPENSSL_VERSION_NUMBER >= 0x30000000 + if (!X509_sign(x, pk, EVP_sha256())) { +#else + if (!X509_sign(x, pk, EVP_sha1())) { +#endif goto err; + } *x509p = x; *pkeyp = pk; + return(1); - err: +err: + ERR_print_errors_fp(stdout); + return(0); } diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index 69883f8122..e5c22cd610 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -120,8 +120,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c } } else { /* replace real_read_codec */ switch_codec_t *cur_codec; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Original read codec replaced with %s:%d\n", - switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode); + switch_channel_get_name(session->channel), codec->implementation ? codec->implementation->iananame : "undefined", codec->implementation ? codec->implementation->ianacode : -1); /* Set real_read_codec to front of the list of read_codecs */ cur_codec = session->read_codec; while (cur_codec != NULL) { @@ -129,8 +130,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c cur_codec->next = codec; break; } + cur_codec = cur_codec->next; } + session->real_read_codec = codec; session->real_read_impl = *codec->implementation; @@ -154,6 +157,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c session->bug_codec.implementation->iananame, session->bug_codec.implementation->ianacode); switch_core_codec_destroy(&session->bug_codec); } + switch_thread_rwlock_unlock(session->bug_rwlock); } else { status = SWITCH_STATUS_FALSE; @@ -169,6 +173,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c if (session->read_impl.actual_samples_per_second != session->read_impl.samples_per_second) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-reported-read-codec-rate", "%d", session->read_impl.samples_per_second); } + switch_event_fire(&event); } @@ -191,6 +196,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_c } switch_mutex_unlock(session->codec_read_mutex); + return status; } @@ -221,7 +227,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s goto end; } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Push codec %s:%d\n", - switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode); + switch_channel_get_name(session->channel), codec->implementation ? codec->implementation->iananame : "undefined", codec->implementation ? codec->implementation->ianacode : -1); codec->next = session->read_codec; session->read_codec = codec; if (codec->implementation) { diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 0754494ee3..252d947035 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -110,7 +110,7 @@ struct switch_rtp_text_factory_s { }; -typedef struct switch_rtp_engine_s { +struct switch_rtp_engine_s { switch_secure_settings_t ssec[CRYPTO_INVALID+1]; switch_rtp_crypto_key_type_t crypto_type; @@ -204,7 +204,7 @@ typedef struct switch_rtp_engine_s { void *engine_user_data; int8_t engine_function_running; switch_frame_buffer_t *write_fb; -} switch_rtp_engine_t; +}; #define MAX_REJ_STREAMS 10 @@ -1170,7 +1170,7 @@ static uint32_t parse_lifetime_mki(const char **p, const char *end) val += ((**p) - '0') * i; } res |= (val & 0x000000ff); /* MKI_SIZE */ - } else if (isdigit(*(field_begin + 1)) && (field_begin + 2) && (*(field_begin + 2) == '^') && (field_begin + 3) && isdigit(*(field_begin + 3))) { + } else if (isdigit(*(field_begin + 1)) && (*(field_begin + 2) == '^') && isdigit(*(field_begin + 3))) { res |= (CRYPTO_KEY_MATERIAL_LIFETIME << 24); val = ((uint32_t) (*(field_begin + 1) - '0')) << 8; res |= val; /* LIFETIME base. */ @@ -3057,7 +3057,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session uint32_t codec_ms = (int) (engine->read_frame.timestamp - engine->last_ts) / (engine->read_impl.samples_per_second / 1000); if (engine->last_seq && (int) (engine->read_frame.seq - engine->last_seq) > 1) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[%s]: Correcting calculated ptime value from [%d] to [%d] to compensate for [%d] lost packet(s). \n", is_vbr?"VBR":"CBR", codec_ms, codec_ms / (int) (engine->read_frame.seq - engine->last_seq), (int) (engine->read_frame.seq - engine->last_seq - 1)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[CBR]: Correcting calculated ptime value from [%d] to [%d] to compensate for [%d] lost packet(s). \n", codec_ms, codec_ms / (int) (engine->read_frame.seq - engine->last_seq), (int) (engine->read_frame.seq - engine->last_seq - 1)); codec_ms = codec_ms / (int) (engine->read_frame.seq - engine->last_seq); } @@ -3080,9 +3080,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session if (codec_ms > 120) { /* yeah right */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "[%s]: Your phone is trying to send timestamps that suggest an increment of %dms per packet\n" + "[CBR]: Your phone is trying to send timestamps that suggest an increment of %dms per packet\n" "That seems hard to believe so I am going to go on ahead and um ignore that, mmkay?\n", - is_vbr?"VBR":"CBR", (int) codec_ms); engine->check_frames = MAX_CODEC_CHECK_FRAMES; goto skip; @@ -3092,8 +3091,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session if (codec_ms != engine->cur_payload_map->codec_ms) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "[%s]: Asynchronous PTIME not supported, changing our end from %d to %d\n", - is_vbr?"VBR":"CBR", + "[CBR]: Asynchronous PTIME not supported, changing our end from %d to %d\n", (int) engine->cur_payload_map->codec_ms, (int) codec_ms ); @@ -3123,7 +3121,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session engine->last_ts) / (engine->read_impl.samples_per_second / 1000); if (engine->last_seq && (int) (engine->read_frame.seq - engine->last_seq) > 1) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[%s]: Correcting calculated ptime value from [%d] to [%d] to compensate for [%d] lost packet(s)\n", is_vbr?"VBR":"CBR", codec_ms, codec_ms / (int) (engine->read_frame.seq - engine->last_seq), (int) (engine->read_frame.seq - engine->last_seq - 1)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[VBR]: Correcting calculated ptime value from [%d] to [%d] to compensate for [%d] lost packet(s)\n", codec_ms, codec_ms / (int) (engine->read_frame.seq - engine->last_seq), (int) (engine->read_frame.seq - engine->last_seq - 1)); codec_ms = codec_ms / (int) (engine->read_frame.seq - engine->last_seq); } @@ -3142,8 +3140,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session if (codec_ms > 120) { /*will show too many times with packet loss*/ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG3, - "[%s]: Remote party is trying to send timestamps that suggest an increment of [%d] ms per packet, which is too high. Ignoring.\n", - is_vbr?"VBR":"CBR", + "[VBR]: Remote party is trying to send timestamps that suggest an increment of [%d] ms per packet, which is too high. Ignoring.\n", (int) codec_ms); engine->last_ts = engine->read_frame.timestamp; engine->last_seq = engine->read_frame.seq; @@ -3152,8 +3149,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session if (codec_ms != engine->cur_payload_map->codec_ms) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, - "[%s]: Packet size change detected. Remote PTIME changed from [%d] to [%d]\n", - is_vbr?"VBR":"CBR", + "[VBR]: Packet size change detected. Remote PTIME changed from [%d] to [%d]\n", (int) engine->cur_payload_map->codec_ms, (int) codec_ms ); @@ -3605,11 +3601,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_ int resetting = 0; switch_media_handle_t *smh; switch_rtp_engine_t *a_engine; - switch_time_t start = switch_micro_time_now(); switch_assert(session); -retry: + switch_core_session_lock_codec_write(session); + switch_core_session_lock_codec_read(session); + switch_mutex_lock(session->codec_init_mutex); if (!(smh = session->media_handle)) { @@ -3631,17 +3628,7 @@ retry: (uint32_t) a_engine->read_impl.microseconds_per_packet / 1000 != a_engine->cur_payload_map->codec_ms || a_engine->read_impl.samples_per_second != a_engine->cur_payload_map->rm_rate ) { - if (switch_core_session_try_reset(session, 0, 0) != SWITCH_STATUS_SUCCESS) { - switch_time_t elapsed = switch_micro_time_now() - start; - if (elapsed > 1000000) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Could not reset session in %"SWITCH_TIME_T_FMT" us. Give up.\n", elapsed); - switch_goto_status(SWITCH_STATUS_FALSE, end); - } - - switch_mutex_unlock(session->codec_init_mutex); - switch_yield(10000); - goto retry; - } + switch_core_session_reset(session, 0, 0); switch_channel_audio_sync(session->channel); @@ -3655,9 +3642,6 @@ retry: a_engine->cur_payload_map->codec_ms, a_engine->cur_payload_map->rm_rate); - switch_yield(a_engine->read_impl.microseconds_per_packet); - switch_core_session_lock_codec_write(session); - switch_core_session_lock_codec_read(session); resetting = 1; switch_yield(a_engine->read_impl.microseconds_per_packet); switch_core_codec_destroy(&a_engine->read_codec); @@ -3771,12 +3755,13 @@ retry: if (resetting) { switch_channel_execute_on(session->channel, "execute_on_audio_change"); - switch_core_session_unlock_codec_write(session); - switch_core_session_unlock_codec_read(session); } switch_mutex_unlock(session->codec_init_mutex); + switch_core_session_unlock_codec_read(session); + switch_core_session_unlock_codec_write(session); + return status; } static void clear_ice(switch_core_session_t *session, switch_media_type_t type) @@ -4182,10 +4167,15 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t argc = switch_split(data, ' ', fields); + if (argc < 6 || !switch_is_uint_in_range(fields[1], 1, MAX_CAND_IDX_COUNT)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_WARNING, "Invalid data\n"); + continue; + } + cid = fields[1] ? atoi(fields[1]) - 1 : 0; - if (argc < 6 || engine->ice_in.cand_idx[cid] >= MAX_CAND - 1) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_WARNING, "Invalid data\n"); + if (engine->ice_in.cand_idx[cid] >= MAX_CAND - 1) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_WARNING, "Too many candidates\n"); continue; } @@ -4265,7 +4255,7 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t relay: - for (cid = 0; cid < 2; cid++) { + for (cid = 0; cid < MAX_CAND_IDX_COUNT; cid++) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "Searching for %s candidate.\n", cid ? "rtcp" : "rtp"); for (ai = 0; ai < engine->cand_acl_count; ai++) { @@ -4514,19 +4504,28 @@ struct matches { int codec_idx; }; +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + static void greedy_sort(switch_media_handle_t *smh, struct matches *matches, int m_idx, const switch_codec_implementation_t **codec_array, int total_codecs) { int j = 0, f = 0, g; struct matches mtmp[MAX_MATCHES] = { { 0 } }; + + m_idx = MIN(m_idx, MAX_MATCHES); + for(j = 0; j < m_idx; j++) { *&mtmp[j] = *&matches[j]; - } - for (g = 0; g < smh->mparams->num_codecs && g < total_codecs; g++) { + } + + for (g = 0; g < smh->mparams->num_codecs && g < total_codecs && f < MAX_MATCHES; g++) { const switch_codec_implementation_t *imp = codec_array[g]; for(j = 0; j < m_idx; j++) { - if (mtmp[j].imp == imp) { + if (mtmp[j].imp && mtmp[j].imp == imp) { *&matches[f++] = *&mtmp[j]; + mtmp[j].imp = NULL; } } } @@ -4777,7 +4776,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s switch_channel_t *channel = switch_core_session_get_channel(session); const char *val; const char *crypto = NULL; - int got_crypto = 0, got_video_crypto = 0, got_audio = 0, saw_audio = 0, saw_video = 0, got_avp = 0, got_video_avp = 0, got_video_savp = 0, got_savp = 0, got_udptl = 0, got_webrtc = 0, got_text = 0, got_text_crypto = 0, got_msrp = 0; + int got_crypto = 0, got_video_crypto = 0, got_audio = 0, saw_audio = 0, saw_video = 0, got_avp = 0, got_savp = 0, got_udptl = 0, got_webrtc = 0, got_text = 0, got_text_crypto = 0, got_msrp = 0; int scrooge = 0; sdp_parser_t *parser = NULL; sdp_session_t *sdp; @@ -4973,14 +4972,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s if (m->m_proto == sdp_proto_srtp || m->m_proto == sdp_proto_extended_srtp) { if (m->m_type == sdp_media_audio) { got_savp++; - } else { - got_video_savp++; } } else if (m->m_proto == sdp_proto_rtp) { if (m->m_type == sdp_media_audio) { got_avp++; - } else { - got_video_avp++; } } else if (m->m_proto == sdp_proto_udptl) { got_udptl++; @@ -5512,6 +5507,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s } else if (!strcasecmp(map->rm_encoding, "opus")) { map_channels = 1; } + + if (codec_fmtp.max_ptime) { + maxptime = codec_fmtp.max_ptime; + } } } @@ -5560,6 +5559,13 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s /* ptime does not match */ match = 0; + if (nm_idx >= MAX_MATCHES) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + "Audio Codec Compare [%s:%d:%u:%u:%d:%u:%d] was not saved as a near-match. Too many. Ignoring.\n", + imp->iananame, imp->ianacode, codec_rate, imp->actual_samples_per_second, imp->microseconds_per_packet / 1000, bit_rate, imp->number_of_channels); + continue; + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d:%u:%d] is saved as a near-match\n", imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate, imp->number_of_channels); @@ -6168,10 +6174,18 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s imp->iananame, map->rm_pt); m_idx++; + + if (m_idx >= MAX_MATCHES) { + break; + } } vmatch = 0; } + + if (m_idx >= MAX_MATCHES) { + break; + } } if (consider_video_fmtp && (!m_idx || almost_vmatch)) { @@ -6676,10 +6690,6 @@ SWITCH_DECLARE(void) switch_core_session_write_blank_video(switch_core_session_t if (!height) height = 288; if (!fps) fps = 15; - if (!(width && height && fps)) { - return; - } - fr.packet = buf; fr.packetlen = buflen; fr.data = buf + 12; @@ -7421,7 +7431,7 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi switch_status_t status; switch_frame_t *read_frame = NULL; switch_media_handle_t *smh; - uint32_t loops = 0, xloops = 0, vloops = 0; + uint32_t loops = 0, xloops = 0; switch_image_t *blank_img = NULL; switch_frame_t fr = { 0 }; unsigned char *buf = NULL; @@ -7546,8 +7556,6 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi continue; } - vloops++; - send_blank = blank_enabled || switch_channel_test_flag(channel, CF_VIDEO_ECHO); if (switch_channel_test_flag(channel, CF_VIDEO_READY) && !switch_test_flag(read_frame, SFF_CNG)) { @@ -8743,7 +8751,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port, a_engine->cur_payload_map->pt, - a_engine->read_impl.samples_per_packet, + strcasecmp("opus", a_engine->read_impl.iananame) ? a_engine->read_impl.samples_per_packet : + a_engine->read_impl.samples_per_second * (a_engine->read_impl.microseconds_per_packet / 1000) / 1000, a_engine->cur_payload_map->codec_ms * 1000, flags, timer_name, &err, switch_core_session_get_pool(session), 0, 0); @@ -12443,7 +12452,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_media_params(switch_core_sessi *val++ = '\0'; } - if (name && val) { + if (val) { if (!strcmp(name, "aspect")) { aspect = val; vid++; @@ -14257,7 +14266,7 @@ SWITCH_DECLARE(char *) switch_core_media_filter_sdp(const char *sdp_str, const c switch_size_t len; const char *i; char *o; - int in_m = 0, m_tally = 0, slash = 0; + int in_m = 0, slash = 0; int number = 0, skip = 0; int remove = !strcasecmp(cmd, "remove"); int only = !strcasecmp(cmd, "only"); @@ -14291,7 +14300,6 @@ SWITCH_DECLARE(char *) switch_core_media_filter_sdp(const char *sdp_str, const c if (*i == 'm' && *(i+1) == '=') { in_m = 1; - m_tally++; } if (in_m) { @@ -14995,7 +15003,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core { switch_status_t status = SWITCH_STATUS_FALSE; switch_io_event_hook_video_read_frame_t *ptr; - uint32_t loops = 0; switch_media_handle_t *smh; int is_keyframe = 0; @@ -15007,8 +15014,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core top: - loops++; - if (switch_channel_down_nosig(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -15864,7 +15869,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess if (!(switch_core_codec_ready(session->write_codec) && switch_core_codec_ready(frame->codec))) goto error; - if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) { + if (frame->codec && session->write_codec->implementation != frame->codec->implementation) { if (session->write_impl.codec_id == frame->codec->implementation->codec_id || session->write_impl.microseconds_per_packet != frame->codec->implementation->microseconds_per_packet) { ptime_mismatch = TRUE; @@ -16429,7 +16434,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess return status; } +SWITCH_DECLARE(switch_rtp_engine_t *) switch_core_media_get_engine(switch_core_session_t *session, int media_type) +{ + if (!session) return NULL; + return &session->media_handle->engines[media_type]; +} + +SWITCH_DECLARE(switch_codec_t*) switch_core_media_get_codec(switch_core_session_t *session, switch_media_type_t type) +{ + switch_rtp_engine_t *engine = switch_core_media_get_engine(session, type); + + if (!engine) return NULL; + + return &engine->read_codec; +} /* For Emacs: * Local Variables: diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 44b653d9ce..61aa500070 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -799,6 +799,7 @@ static const char *message_names[] = { "DEFLECT", "VIDEO_REFRESH_REQ", "DISPLAY", + "MEDIA_PARAMS", "TRANSCODING_NECESSARY", "AUDIO_SYNC", "VIDEO_SYNC", @@ -3005,7 +3006,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_se { char *dp[25]; char *dpstr; - int argc, x, count = 0; + int argc, x; uint32_t stack_count = 0; switch_caller_profile_t *profile, *new_profile, *pp = NULL; switch_channel_t *channel = switch_core_session_get_channel(session); @@ -3059,8 +3060,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_se continue; } - count++; - extension = dialplan_interface->hunt_function(session, dparg, new_profile); UNPROTECT_INTERFACE(dialplan_interface); diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 702ee6a79c..5a75aeb573 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -3181,6 +3181,8 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName if (!(ep = switch_loadable_module_get_endpoint_interface(argv[0]))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "EP ERROR\n"); + switch_xml_free(xml); + return 0; } diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 0d377f9c3e..dad3181c2a 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -3521,11 +3521,18 @@ SWITCH_DECLARE(switch_status_t) switch_img_to_raw(switch_image_t *src, void *des #endif } -SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void *src, switch_img_fmt_t fmt, int width, int height) +SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t **destP, void *src, switch_img_fmt_t fmt, int width, int height) { #ifdef SWITCH_HAVE_YUV uint32_t fourcc; int ret = -1; + switch_image_t *dest = NULL; + + if (!destP) { + return SWITCH_STATUS_FALSE; + } + + dest = *destP; fourcc = switch_img_fmt2fourcc(fmt); @@ -3574,6 +3581,8 @@ SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void * 0, fourcc); } + *destP = dest; + return ret == 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; #else return SWITCH_STATUS_FALSE; @@ -3586,10 +3595,12 @@ SWITCH_DECLARE(switch_status_t) switch_img_scale(switch_image_t *src, switch_ima switch_image_t *dest = NULL; int ret = 0; - if (destP) { - dest = *destP; + if (!destP) { + return SWITCH_STATUS_FALSE; } + dest = *destP; + switch_assert(width > 0); switch_assert(height > 0); @@ -3615,15 +3626,13 @@ SWITCH_DECLARE(switch_status_t) switch_img_scale(switch_image_t *src, switch_ima kFilterBox); } + *destP = dest; + if (ret != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scaling Error: ret: %d\n", ret); return SWITCH_STATUS_FALSE; } - if (destP) { - *destP = dest; - } - return SWITCH_STATUS_SUCCESS; #else return SWITCH_STATUS_FALSE; @@ -3637,10 +3646,12 @@ SWITCH_DECLARE(switch_status_t) switch_img_mirror(switch_image_t *src, switch_im switch_image_t *dest = NULL; int ret = 0; - if (destP) { - dest = *destP; + if (!destP) { + return SWITCH_STATUS_FALSE; } + dest = *destP; + if (dest && src->fmt != dest->fmt) switch_img_free(&dest); if (!dest) dest = switch_img_alloc(NULL, src->fmt, src->d_w, src->d_h, 1); @@ -3660,15 +3671,13 @@ SWITCH_DECLARE(switch_status_t) switch_img_mirror(switch_image_t *src, switch_im } + *destP = dest; + if (ret != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Mirror Error: ret: %d\n", ret); return SWITCH_STATUS_FALSE; } - if (destP) { - *destP = dest; - } - return SWITCH_STATUS_SUCCESS; #else return SWITCH_STATUS_FALSE; diff --git a/src/switch_curl.c b/src/switch_curl.c index c99a5f61de..d6cfd6ce19 100644 --- a/src/switch_curl.c +++ b/src/switch_curl.c @@ -58,11 +58,16 @@ SWITCH_DECLARE(void) switch_curl_destroy(void) curl_global_cleanup(); } -SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_event_t *event, switch_CURL *curl_handle, struct curl_httppost **formpostp) +SWITCH_DECLARE(switch_status_t) switch_curl_process_mime(switch_event_t *event, switch_CURL *curl_handle, switch_curl_mime **mimep) { - +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + curl_mime *mime = NULL; + curl_mimepart *part = NULL; + uint8_t added = 0; +#else struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; +#endif switch_event_header_t *hp; int go = 0; @@ -77,39 +82,87 @@ SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_even return SWITCH_STATUS_FALSE; } - for (hp = event->headers; hp; hp = hp->next) { +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + mime = curl_mime_init(curl_handle); +#endif + for (hp = event->headers; hp; hp = hp->next) { if (!strncasecmp(hp->name, "attach_file:", 12)) { char *pname = strdup(hp->name + 12); if (pname) { char *fname = strchr(pname, ':'); + if (fname) { *fname++ = '\0'; +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + part = curl_mime_addpart(mime); + curl_mime_name(part, pname); + curl_mime_filename(part, fname); + curl_mime_filedata(part, hp->value); + added++; +#else curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, pname, CURLFORM_FILENAME, fname, CURLFORM_FILE, hp->value, CURLFORM_END); +#endif } + free(pname); } } else { +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + part = curl_mime_addpart(mime); + curl_mime_name(part, hp->name); + curl_mime_data(part, hp->value, CURL_ZERO_TERMINATED); + added++; +#else curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, hp->name, CURLFORM_COPYCONTENTS, hp->value, CURLFORM_END); - +#endif } } - *formpostp = formpost; +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + if (!added) { + curl_mime_free(mime); + mime = NULL; + } + + *mimep = mime; +#else + *mimep = formpost; +#endif return SWITCH_STATUS_SUCCESS; +} +SWITCH_DECLARE(void) switch_curl_mime_free(switch_curl_mime **mimep) +{ + if (mimep && *mimep) { +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + curl_mime_free(*mimep); +#else + curl_formfree(*mimep); +#endif + mimep = NULL; + } +} + +SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_setopt_mime(switch_CURL *curl_handle, switch_curl_mime *mime) +{ +#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) + return curl_easy_setopt(curl_handle, CURLOPT_MIMEPOST, mime); +#else + return curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, mime); +#endif } /* For Emacs: diff --git a/src/switch_event.c b/src/switch_event.c index 843469bd72..02a6f81505 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -651,7 +651,6 @@ SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max) { switch_threadattr_t *thd_attr; uint32_t index = 0; - int launched = 0; uint32_t sanity = 200; switch_memory_pool_t *pool = RUNTIME_POOL; @@ -682,7 +681,6 @@ SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max) } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Create additional event dispatch thread %d\n", index); } - launched++; } SOFT_MAX_DISPATCH = index; @@ -1909,6 +1907,8 @@ SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const ch data = (char *) malloc(2048); if (!data) { va_end(ap); + switch_xml_free(xml); + return NULL; } ret = vsnprintf(data, 2048, fmt, ap); @@ -1918,6 +1918,8 @@ SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const ch #ifndef HAVE_VASPRINTF free(data); #endif + switch_xml_free(xml); + return NULL; } } @@ -2069,15 +2071,18 @@ SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, swit switch_mutex_lock(CUSTOM_HASH_MUTEX); if (!(subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) { - switch_event_reserve_subclass_detailed(id, subclass_name); - subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name); - subclass->bind = 1; + if (switch_event_reserve_subclass_detailed(id, subclass_name) == SWITCH_STATUS_SUCCESS) { + if ((subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) { + subclass->bind = 1; + } + } } switch_mutex_unlock(CUSTOM_HASH_MUTEX); if (!subclass) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not reserve subclass. '%s'\n", subclass_name); + return SWITCH_STATUS_FALSE; } } @@ -2092,6 +2097,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, swit if (subclass_name) { event_node->subclass_name = DUP(subclass_name); } + event_node->callback = callback; event_node->user_data = user_data; @@ -2950,14 +2956,17 @@ static void ecd_deliver(event_channel_data_t **ecdP) int x_argc = switch_separate_string_string(key, (char*) sep, x_argv, SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS); char buf[1024]; int i, r; + for(i=x_argc - 1; i > 0; i--) { int z; + memset(buf, 0, 1024); - sprintf(buf, "%s", x_argv[0]); + switch_snprintf(buf, sizeof(buf), "%s", x_argv[0]); for(z=1; z < i; z++) { strcat(buf, sep); - strcat(buf, x_argv[z]); + strncat(buf, x_argv[z], sizeof(buf) - strlen(buf) - 1); } + r = _switch_event_channel_broadcast(buf, ecd->event_channel, ecd->json, ecd->key, ecd->id); t += r; if (r && switch_core_test_flag(SCF_EVENT_CHANNEL_HIERARCHY_DELIVERY_ONCE)) { @@ -2966,11 +2975,13 @@ static void ecd_deliver(event_channel_data_t **ecdP) } } else { char *p = NULL; + if ((p = strchr(key, '.'))) { *p = '\0'; t += _switch_event_channel_broadcast(key, ecd->event_channel, ecd->json, ecd->key, ecd->id); } } + switch_safe_free(key); t += _switch_event_channel_broadcast(SWITCH_EVENT_CHANNEL_GLOBAL, ecd->event_channel, ecd->json, ecd->key, ecd->id); @@ -2978,6 +2989,7 @@ static void ecd_deliver(event_channel_data_t **ecdP) if(t == 0) { if (switch_core_test_flag(SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON)) { char *json = cJSON_Print(ecd->json); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no subscribers for %s , %s => %s\n", ecd->event_channel, ecd->key, json); switch_safe_free(json); } else { diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 6dfdcf7248..9a33b43340 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -546,6 +546,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_ping(switch_ivr_dmachine_t * } if (dmachine->pinging) { + switch_mutex_unlock(dmachine->mutex); return SWITCH_STATUS_BREAK; } @@ -2129,7 +2130,7 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data break; } - if (ep->eavesdropper && switch_core_session_read_lock(ep->eavesdropper) == SWITCH_STATUS_SUCCESS) { + if (switch_core_session_read_lock(ep->eavesdropper) == SWITCH_STATUS_SUCCESS) { if (switch_core_session_write_video_frame(ep->eavesdropper, bug->video_ping_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error writing video to %s\n", switch_core_session_get_name(ep->eavesdropper)); ep->errs++; @@ -2177,10 +2178,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_pop_eavesdropper(switch_cor struct eavesdrop_pvt *ep = (struct eavesdrop_pvt *) switch_core_media_bug_get_user_data(bug); if (ep && ep->eavesdropper && ep->eavesdropper != session) { - switch_core_session_read_lock(ep->eavesdropper); - *sessionp = ep->eavesdropper; - switch_core_media_bug_set_flag(bug, SMBF_PRUNE); - status = SWITCH_STATUS_SUCCESS; + if (switch_core_session_read_lock(ep->eavesdropper) == SWITCH_STATUS_SUCCESS) { + *sessionp = ep->eavesdropper; + switch_core_media_bug_set_flag(bug, SMBF_PRUNE); + status = SWITCH_STATUS_SUCCESS; + } } } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index f91fc2c69f..527058f70c 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -237,7 +237,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj) continue; } - if (switch_channel_media_up(b_channel)) { + if (read_frame && switch_channel_media_up(b_channel)) { if (switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { switch_cond_next(); continue; diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index f1e3e39de1..a39553e2f9 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -186,15 +186,16 @@ struct key_collect { static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void *obj) { struct key_collect *collect = (struct key_collect *) obj; - switch_channel_t *channel = switch_core_session_get_channel(collect->session); + switch_channel_t *channel = NULL; char buf[10] = SWITCH_BLANK_STRING; switch_application_interface_t *application_interface = NULL; - if (collect->session) { - if (switch_core_session_read_lock(collect->session) != SWITCH_STATUS_SUCCESS) { - return NULL; - } - } else { + if (!collect->session) { + return NULL; + } + + channel = switch_core_session_get_channel(collect->session); + if (switch_core_session_read_lock(collect->session) != SWITCH_STATUS_SUCCESS) { return NULL; } @@ -232,6 +233,7 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void switch_channel_set_flag(channel, CF_WINNER); switch_channel_set_variable(channel, "group_dial_status", "winner"); } + goto wbreak; } @@ -271,6 +273,7 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void switch_ivr_play_file(collect->session, NULL, collect->error_file, NULL); } } + wbreak: switch_core_session_rwunlock(collect->session); @@ -909,6 +912,9 @@ static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map return -1; } wrote = teletone_mux_tones(ts, map); + if (wrote <= 0) { + return -1; + } if (tto->channels != 1) { if (tto->mux_buflen < wrote * 2 * tto->channels) { @@ -3215,6 +3221,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess l_session = NULL; } + switch_channel_set_variable(oglobals.originate_status[i].peer_channel, "originate_endpoint", chan_type); switch_channel_execute_on(oglobals.originate_status[i].peer_channel, SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE); switch_channel_api_on(oglobals.originate_status[i].peer_channel, SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE); } diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 25486eee7f..33f3a4e51a 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -1271,7 +1271,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess int sleep_val_i = 250; int eof = 0; switch_size_t bread = 0; - int l16 = 0; switch_codec_implementation_t read_impl = { 0 }; char *file_dup; char *argv[128] = { 0 }; @@ -1334,10 +1333,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess arg_recursion_check_start(args); - if (!zstr(read_impl.iananame) && !strcasecmp(read_impl.iananame, "l16")) { - l16++; - } - if (play_delimiter) { file_dup = switch_core_session_strdup(session, file); argc = switch_separate_string(file_dup, play_delimiter, argv, (sizeof(argv) / sizeof(argv[0]))); diff --git a/src/switch_jitterbuffer.c b/src/switch_jitterbuffer.c index d68b269024..6f142aec6d 100644 --- a/src/switch_jitterbuffer.c +++ b/src/switch_jitterbuffer.c @@ -44,6 +44,8 @@ struct switch_jb_s; +static inline int check_jb_size(switch_jb_t *jb); + typedef struct switch_jb_node_s { struct switch_jb_s *parent; switch_rtp_packet_t packet; @@ -56,6 +58,29 @@ typedef struct switch_jb_node_s { switch_bool_t complete_frame_mark; } switch_jb_node_t; +typedef struct switch_jb_stats_s { + uint32_t reset_too_big; + uint32_t reset_missing_frames; + uint32_t reset_ts_jump; + uint32_t reset_error; + uint32_t reset; + uint32_t size_max; + uint32_t size_est; + uint32_t acceleration; + uint32_t expand; + uint32_t jitter_max_ms; + int estimate_ms; + int buffer_size_ms; +} switch_jb_stats_t; + +typedef struct switch_jb_jitter_s { + double *estimate; + uint32_t samples_per_second; + uint32_t samples_per_frame; + uint32_t drop_gap; + switch_jb_stats_t stats; +} switch_jb_jitter_t; + struct switch_jb_s { struct switch_jb_node_s *node_list; uint32_t last_target_seq; @@ -104,6 +129,7 @@ struct switch_jb_s { switch_jb_flag_t flags; switch_jb_type_t type; switch_core_session_t *session; + switch_jb_jitter_t jitter; switch_channel_t *channel; uint32_t buffer_lag; uint32_t flush; @@ -112,6 +138,8 @@ struct switch_jb_s { uint32_t period_len; uint32_t nack_saved_the_day; uint32_t nack_didnt_save_the_day; + switch_bool_t elastic; + switch_codec_t *codec; }; @@ -233,6 +261,7 @@ static inline switch_jb_node_t *new_node(switch_jb_t *jb) if (jb->allocated_nodes > jb->max_frame_len * mult) { jb_debug(jb, 2, "ALLOCATED FRAMES TOO HIGH! %d\n", jb->allocated_nodes); + jb->jitter.stats.reset_too_big++; switch_jb_reset(jb); switch_mutex_unlock(jb->list_mutex); return NULL; @@ -332,6 +361,26 @@ static inline void hide_nodes(switch_jb_t *jb) switch_mutex_unlock(jb->list_mutex); } +static inline switch_bool_t packet_vad(switch_jb_t *jb, switch_rtp_packet_t *packet, switch_size_t len) { + void *payload = packet ? (packet->ebody ? packet->ebody : packet->body) : NULL; + uint16_t payload_len = len; + + if (payload && payload_len > 0) { + switch_bool_t ret = SWITCH_FALSE, *ret_p = &ret; + switch_codec_control_type_t ret_t; + + switch_core_media_codec_control(jb->session, SWITCH_MEDIA_TYPE_AUDIO, + SWITCH_IO_WRITE, SCC_AUDIO_VAD, + SCCT_STRING, (void *)payload, + SCCT_INT, (void *)&payload_len, + &ret_t, (void *)&ret_p); + + return ret; + } + + return SWITCH_TRUE; +} + static inline void drop_ts(switch_jb_t *jb, uint32_t ts) { switch_jb_node_t *np; @@ -667,6 +716,7 @@ static inline void add_node(switch_jb_t *jb, switch_rtp_packet_t *packet, switch if (((seq_diff >= 100) || (ts_diff > (900000 * 5)))) { jb_debug(jb, 2, "CHANGE DETECTED, PUNT %u\n", abs(((int)ntohs(packet->header.seq) - ntohs(jb->highest_wrote_seq)))); + jb->jitter.stats.reset_ts_jump++; switch_jb_reset(jb); } } @@ -732,6 +782,12 @@ static inline void increment_seq(switch_jb_t *jb) jb->target_seq = htons((ntohs(jb->target_seq) + 1)); } +static inline void decrement_seq(switch_jb_t *jb) +{ + jb->last_target_seq = jb->target_seq; + jb->target_seq = htons((ntohs(jb->target_seq) - 1)); +} + static inline void set_read_seq(switch_jb_t *jb, uint16_t seq) { jb->last_target_seq = seq; @@ -854,13 +910,156 @@ static inline switch_status_t jb_next_packet_by_ts(switch_jb_t *jb, switch_jb_no } +static inline int check_jb_size(switch_jb_t *jb) +{ + switch_jb_node_t *np; + uint16_t seq_hs, target_seq_hs; + uint16_t l_seq = 0; + uint16_t h_seq = 0; + uint16_t count = 0; + uint16_t old = 0; + + switch_mutex_lock(jb->list_mutex); + + target_seq_hs = ntohs(jb->target_seq); + + for (np = jb->node_list; np; np = np->next) { + if (!np->visible) { + continue; + } + + seq_hs = ntohs(np->packet.header.seq); + if (target_seq_hs > seq_hs) { + hide_node(np, SWITCH_FALSE); + old++; + continue; + } + + if (count == 0) { + l_seq = h_seq = seq_hs; + } + + count++; + + if (seq_hs < l_seq) { + l_seq = seq_hs; + } + + if (seq_hs > h_seq) { + h_seq = seq_hs; + } + } + + if (count > jb->jitter.stats.size_max) { + jb->jitter.stats.size_max = count; + } + + if (jb->jitter.stats.size_est == 0) { + jb->jitter.stats.size_est = count; + } else { + jb->jitter.stats.size_est = ((99 * jb->jitter.stats.size_est) + (1 * count)) / 100; + } + + /* update the stats every x packets */ + if (target_seq_hs % 50 == 0) { + int packet_ms = jb->jitter.samples_per_frame / (jb->jitter.samples_per_second / 1000); + + jb->jitter.stats.estimate_ms = (*jb->jitter.estimate) / jb->jitter.samples_per_second * 1000; + if (jb->channel) { + switch_channel_set_variable_printf(jb->channel, "rtp_jb_size_max_ms", "%u", jb->jitter.stats.size_max * packet_ms); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_size_est_ms", "%u", jb->jitter.stats.size_est * packet_ms); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_acceleration_ms", "%u", jb->jitter.stats.acceleration * packet_ms); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_expand_ms", "%u", jb->jitter.stats.expand * packet_ms); + } + + if (jb->jitter.stats.jitter_max_ms < jb->jitter.stats.estimate_ms) { + jb->jitter.stats.jitter_max_ms = jb->jitter.stats.estimate_ms; + } + + if (jb->channel) { + switch_channel_set_variable_printf(jb->channel, "rtp_jb_jitter_max_ms", "%u", jb->jitter.stats.jitter_max_ms); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_jitter_est_ms", "%u", jb->jitter.stats.estimate_ms); + } + } + + if (old) { + sort_free_nodes(jb); + } + + switch_mutex_unlock(jb->list_mutex); + + jb_debug(jb, SWITCH_LOG_INFO, "JITTER buffersize %u == %u old[%u] target[%u] seq[%u|%u]\n", count, h_seq - l_seq + 1, old, target_seq_hs, l_seq, h_seq); + + return count; +} + +static inline switch_status_t jb_next_packet_by_seq_with_acceleration(switch_jb_t *jb, switch_jb_node_t **nodep) +{ + switch_status_t status = jb_next_packet_by_seq(jb, nodep); + switch_rtp_packet_t *packet; + uint32_t len; + uint16_t seq = ntohs(jb->target_seq); + + /* When using a Codec that provides voice activity detection ex. Opus, use it to + select packet to drop/accelerate. */ + + if (jb->elastic && jb->jitter.estimate && (jb->visible_nodes * jb->jitter.samples_per_frame) > 0 && jb->jitter.samples_per_second) { + int visible_not_old = check_jb_size(jb); + + jb->jitter.stats.estimate_ms = (int)((*jb->jitter.estimate) / ((jb->jitter.samples_per_second)) * 1000); + jb->jitter.stats.buffer_size_ms = (int)((visible_not_old * jb->jitter.samples_per_frame) / (jb->jitter.samples_per_second / 1000)); + + /* We try to accelerate in order to remove delay when the jitter buffer is 3x larger than the estimation. */ + if (jb->jitter.stats.buffer_size_ms > (3 * jb->jitter.stats.estimate_ms) && jb->jitter.stats.buffer_size_ms > 60) { + if (status == SWITCH_STATUS_SUCCESS) { + packet = &(*nodep)->packet; + seq = ntohs((*nodep)->packet.header.seq); + len = (*nodep)->len; + } + + if (jb->jitter.drop_gap > 0) { + jb_debug(jb, SWITCH_LOG_INFO, "JITTER estimation %dms buffersize %d/%d %dms seq:%u [drop-gap][%d]\n", + jb->jitter.stats.estimate_ms, jb->complete_frames, jb->frame_len, jb->jitter.stats.buffer_size_ms, seq, jb->jitter.drop_gap); + jb->jitter.drop_gap--; + } else { + if (status != SWITCH_STATUS_SUCCESS || packet_vad(jb, packet, len) == SWITCH_FALSE) { + jb->jitter.drop_gap = 3; + if (status != SWITCH_STATUS_SUCCESS) { + jb_debug(jb, SWITCH_LOG_INFO, "JITTER estimation n/a buffersize %d/%d %dms seq:%u [drop-missing/no-plc]\n", + jb->complete_frames, jb->frame_len, jb->jitter.stats.buffer_size_ms, seq); + } else { + jb_debug(jb, SWITCH_LOG_INFO, "JITTER estimation %dms buffersize %d/%d %dms seq:%u ACCELERATE [drop]\n", + jb->jitter.stats.estimate_ms, jb->complete_frames, jb->frame_len, jb->jitter.stats.buffer_size_ms, seq); + } + + jb->jitter.stats.acceleration++; + + return jb_next_packet_by_seq(jb, nodep); + } else { + jb_debug(jb, SWITCH_LOG_INFO, "JITTER estimation %dms buffersize %d/%d %dms seq:%u [drop-skip-vad]\n", + jb->jitter.stats.estimate_ms, jb->complete_frames, jb->frame_len, jb->jitter.stats.buffer_size_ms, seq); + } + } + } else { + jb_debug(jb, 2, "JITTER estimation %dms buffersize %d/%d %dms\n", + jb->jitter.stats.estimate_ms, jb->complete_frames, jb->frame_len, jb->jitter.stats.buffer_size_ms); + } + } + + return status; +} + static inline switch_status_t jb_next_packet(switch_jb_t *jb, switch_jb_node_t **nodep) { if (jb->samples_per_frame) { return jb_next_packet_by_ts(jb, nodep); - } else { - return jb_next_packet_by_seq(jb, nodep); } + + if (jb->elastic && jb->jitter.estimate) { + return jb_next_packet_by_seq_with_acceleration(jb, nodep); + } + + return jb_next_packet_by_seq(jb, nodep); } static inline void free_nodes(switch_jb_t *jb) @@ -877,16 +1076,58 @@ SWITCH_DECLARE(void) switch_jb_ts_mode(switch_jb_t *jb, uint32_t samples_per_fra switch_core_inthash_init(&jb->node_hash_ts); } +SWITCH_DECLARE(void) switch_jb_set_jitter_estimator(switch_jb_t *jb, double *jitter, uint32_t samples_per_frame, uint32_t samples_per_second) +{ + if (jb && jitter) { + memset(&jb->jitter, 0, sizeof(switch_jb_jitter_t)); + if (jb->channel) { + switch_channel_set_variable_printf(jb->channel, "rtp_jb_max_ms", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_size_ms", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_acceleration_ms", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_expand_ms", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_jitter_max_ms", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_jitter_ms", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_count", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_too_big", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_missing_frames", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_ts_jump", "%u", 0); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_error", "%u", 0); + } + + jb->jitter.estimate = jitter; + jb->jitter.samples_per_frame = samples_per_frame; + jb->jitter.samples_per_second = samples_per_second; + jb->jitter.drop_gap = 5; + } +} + SWITCH_DECLARE(void) switch_jb_set_session(switch_jb_t *jb, switch_core_session_t *session) { const char *var; if (session) { + jb->codec = switch_core_session_get_read_codec(session); jb->session = session; jb->channel = switch_core_session_get_channel(session); - if (jb->type == SJB_VIDEO && !switch_test_flag(jb, SJB_QUEUE_ONLY) && + if (jb->type == SJB_AUDIO) { + if (!strcmp(jb->codec->implementation->iananame, "opus")) { + if (switch_channel_var_true(jb->channel, "rtp_jitter_buffer_accelerate")) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "audio codec is %s, accelerate on\n", jb->codec->implementation->iananame); + jb->elastic = SWITCH_TRUE; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "audio codec is %s, accelerate off\n", jb->codec->implementation->iananame); + jb->elastic = SWITCH_FALSE; + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "audio codec is not Opus: %s\n", jb->codec->implementation->iananame); + jb->elastic = SWITCH_FALSE; + } + } + + if (jb->type == SJB_VIDEO && !switch_test_flag(jb, SJB_QUEUE_ONLY) && (var = switch_channel_get_variable_dup(jb->channel, "jb_video_low_bitrate", SWITCH_FALSE, -1))) { int tmp = atoi(var); + if (tmp >= 128 && tmp <= 10240) { jb->video_low_bitrate = (uint32_t)tmp; } @@ -932,6 +1173,14 @@ SWITCH_DECLARE(void) switch_jb_debug_level(switch_jb_t *jb, uint8_t level) SWITCH_DECLARE(void) switch_jb_reset(switch_jb_t *jb) { + jb->jitter.stats.reset++; + if (jb->channel) { + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_count", "%u", jb->jitter.stats.reset); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_too_big", "%u", jb->jitter.stats.reset_too_big); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_missing_frames", "%u", jb->jitter.stats.reset_missing_frames); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_ts_jump", "%u", jb->jitter.stats.reset_ts_jump); + switch_channel_set_variable_printf(jb->channel, "rtp_jb_reset_error", "%u", jb->jitter.stats.reset_error); + } if (jb->type == SJB_VIDEO) { switch_mutex_lock(jb->mutex); @@ -943,13 +1192,13 @@ SWITCH_DECLARE(void) switch_jb_reset(switch_jb_t *jb) switch_core_session_request_video_refresh(jb->session); } } - + jb_debug(jb, 2, "%s", "RESET BUFFER\n"); switch_mutex_lock(jb->mutex); hide_nodes(jb); switch_mutex_unlock(jb->mutex); - + jb->drop_flag = 0; jb->last_target_seq = 0; jb->target_seq = 0; @@ -1257,9 +1506,9 @@ SWITCH_DECLARE(switch_status_t) switch_jb_put_packet(switch_jb_t *jb, switch_rtp if (got > want) { if (got - want > jb->max_frame_len && got - want > 17) { jb_debug(jb, 2, "Missing %u frames, Resetting\n", got - want); + jb->jitter.stats.reset_missing_frames++; switch_jb_reset(jb); } else { - if (jb->type != SJB_VIDEO && jb->frame_len < got - want) { jb_frame_inc(jb, 1); } @@ -1434,6 +1683,7 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp switch(status) { case SWITCH_STATUS_RESTART: jb_debug(jb, 2, "%s", "Error encountered\n"); + jb->jitter.stats.reset_error++; switch_jb_reset(jb); switch_goto_status(SWITCH_STATUS_RESTART, end); case SWITCH_STATUS_NOTFOUND: @@ -1444,7 +1694,24 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp jb_debug(jb, 2, "%s", "Too many frames not found, RESIZE\n"); switch_goto_status(SWITCH_STATUS_RESTART, end); } else { - jb_debug(jb, 2, "%s", "Frame not found suggest PLC\n"); + if (jb->elastic) { + int visible_not_old = check_jb_size(jb); + + jb->jitter.stats.estimate_ms = (int)((*jb->jitter.estimate) / ((jb->jitter.samples_per_second)) * 1000); + jb->jitter.stats.buffer_size_ms = (int)((visible_not_old * jb->jitter.samples_per_frame) / (jb->jitter.samples_per_second / 1000)); + /* When playing PLC, we take the oportunity to expand the buffer if the jitter buffer is smaller than the 3x the estimated jitter. */ + if (jb->jitter.stats.buffer_size_ms < (3 * jb->jitter.stats.estimate_ms)) { + jb_debug(jb, SWITCH_LOG_INFO, "JITTER estimation %dms buffersize %d/%d %dms EXPAND [plc]\n", + jb->jitter.stats.estimate_ms, jb->complete_frames, jb->frame_len, jb->jitter.stats.buffer_size_ms); + jb->jitter.stats.expand++; + decrement_seq(jb); + } else { + jb_debug(jb, 2, "%s", "Frame not found suggest PLC\n"); + } + } else { + jb_debug(jb, 2, "%s", "Frame not found suggest PLC\n"); + } + plc = 1; switch_goto_status(SWITCH_STATUS_NOTFOUND, end); } diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index f782e89f6e..bacd2f012a 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -115,12 +115,11 @@ static void *SWITCH_THREAD_FUNC switch_loadable_module_exec(switch_thread_t *thr switch_status_t status = SWITCH_STATUS_SUCCESS; switch_core_thread_session_t *ts = obj; switch_loadable_module_t *module = ts->objs[0]; - int restarts; switch_assert(thread != NULL); switch_assert(module != NULL); - for (restarts = 0; status != SWITCH_STATUS_TERM && !module->shutting_down; restarts++) { + while (status != SWITCH_STATUS_TERM && !module->shutting_down) { status = module->switch_module_runtime(); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Thread ended for %s\n", module->module_interface->module_name); diff --git a/src/switch_log.c b/src/switch_log.c index 74a5713635..563a554510 100644 --- a/src/switch_log.c +++ b/src/switch_log.c @@ -246,7 +246,7 @@ SWITCH_DECLARE(cJSON *) switch_log_node_to_json(const switch_log_node_t *node, i return json; } -static switch_log_node_t *switch_log_node_alloc() +static switch_log_node_t *switch_log_node_alloc(void) { switch_log_node_t *node = NULL; #ifdef SWITCH_LOG_RECYCLE diff --git a/src/switch_msrp.c b/src/switch_msrp.c index 1f5db7ac20..9fd84d846b 100644 --- a/src/switch_msrp.c +++ b/src/switch_msrp.c @@ -99,7 +99,7 @@ static switch_bool_t msrp_check_success_report(switch_msrp_msg_t *msrp_msg) return (msrp_h_success_report && !strcmp(msrp_h_success_report, "yes")); } -static void msrp_deinit_ssl() +static void msrp_deinit_ssl(void) { globals.ssl_ready = 0; if (globals.ssl_ctx) { @@ -112,7 +112,7 @@ static void msrp_deinit_ssl() } } -static void msrp_init_ssl() +static void msrp_init_ssl(void) { const char *err = ""; @@ -187,7 +187,7 @@ static void msrp_init_ssl() SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip); -static switch_status_t load_config() +static switch_status_t load_config(void) { char *cf = "msrp.conf"; switch_xml_t cfg, xml = NULL, settings, param; @@ -286,12 +286,12 @@ sock_fail: return rv; } -SWITCH_DECLARE(const char *) switch_msrp_listen_ip() +SWITCH_DECLARE(const char *) switch_msrp_listen_ip(void) { return globals.ip; } -SWITCH_DECLARE(switch_status_t) switch_msrp_init() +SWITCH_DECLARE(switch_status_t) switch_msrp_init(void) { switch_memory_pool_t *pool; switch_thread_t *thread; @@ -346,7 +346,7 @@ SWITCH_DECLARE(switch_status_t) switch_msrp_init() return SWITCH_STATUS_SUCCESS; } -SWITCH_DECLARE(switch_status_t) switch_msrp_destroy() +SWITCH_DECLARE(switch_status_t) switch_msrp_destroy(void) { switch_status_t st = SWITCH_STATUS_SUCCESS; switch_socket_t *sock; @@ -1622,7 +1622,7 @@ SWITCH_DECLARE (switch_status_t) switch_msrp_perform_send(switch_msrp_session_t return status; } -SWITCH_DECLARE(switch_msrp_msg_t *) switch_msrp_msg_create() +SWITCH_DECLARE(switch_msrp_msg_t *) switch_msrp_msg_create(void) { switch_msrp_msg_t *msg = malloc(sizeof(switch_msrp_msg_t)); switch_assert(msg); diff --git a/src/switch_nat.c b/src/switch_nat.c index f6b9bc553b..a1620b4bfd 100644 --- a/src/switch_nat.c +++ b/src/switch_nat.c @@ -506,7 +506,7 @@ static switch_status_t switch_nat_add_mapping_upnp(switch_port_t port, switch_na if (r == UPNPCOMMAND_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mapped public port %s protocol %s to localport %s\n", port_str, - (proto == SWITCH_NAT_TCP) ? "TCP" : (proto == SWITCH_NAT_UDP ? "UDP" : "UNKNOWN"), port_str); + (proto == SWITCH_NAT_TCP) ? "TCP" : "UDP", port_str); status = SWITCH_STATUS_SUCCESS; } @@ -566,7 +566,7 @@ static switch_status_t switch_nat_del_mapping_upnp(switch_port_t port, switch_na if (r == UPNPCOMMAND_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unmapped public port %s protocol %s to localport %s\n", port_str, - (proto == SWITCH_NAT_TCP) ? "TCP" : (proto == SWITCH_NAT_UDP ? "UDP" : "UNKNOWN"), port_str); + (proto == SWITCH_NAT_TCP) ? "TCP" : "UDP", port_str); status = SWITCH_STATUS_SUCCESS; } return status; diff --git a/src/switch_packetizer.c b/src/switch_packetizer.c index 05688f8a86..c9cdcbf3e7 100644 --- a/src/switch_packetizer.c +++ b/src/switch_packetizer.c @@ -160,8 +160,6 @@ SWITCH_DECLARE(switch_status_t) switch_packetizer_feed_extradata(switch_packetiz p += 5; left -= 5; - if (left < 0) return SWITCH_STATUS_FALSE; - //sps n_sps = *p & 0x1f; p += 1; @@ -267,7 +265,7 @@ SWITCH_DECLARE(switch_status_t) switch_packetizer_feed(switch_packetizer_t *pack context->nalus[i].eat = p; } else { context->nalus[i].len = p - context->nalus[i].start; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "#%d %x len=%u\n", i, *context->nalus[i].start, context->nalus[i].len); + //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "#%d %x len=%u\n", i, *context->nalus[i].start, context->nalus[i].len); while (!(*p++)) ; /* eat the sync bytes, what ever 0 0 1 or 0 0 0 1 */ i++; context->nalus[i].start = p; @@ -309,8 +307,8 @@ SWITCH_DECLARE(switch_status_t) switch_packetizer_read(switch_packetizer_t *pack nri = nalu_hdr & 0x60; if (real_slice_size > slice_size) real_slice_size = slice_size; - if (frame->buflen < slice_size) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "frame buffer too small %u < %u\n", frame->buflen, slice_size); + if (frame->datalen < slice_size) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "frame buffer too small %u < %u\n", frame->datalen, slice_size); return SWITCH_STATUS_FALSE; } diff --git a/src/switch_rtp.c b/src/switch_rtp.c index e8a3d30da1..17c93f2fa2 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -262,8 +262,8 @@ typedef struct { struct switch_rtp; -static void switch_rtp_dtls_init(); -static void switch_rtp_dtls_destroy(); +static void switch_rtp_dtls_init(void); +static void switch_rtp_dtls_destroy(void); #define MAX_DTLS_MTU 4096 @@ -1277,7 +1277,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d } - if (ice->ice_params && ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].cand_type && + if (ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].cand_type && !strcasecmp(ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].cand_type, "relay")) { do_adj++; } @@ -1353,7 +1353,6 @@ SWITCH_DECLARE(void) switch_srtp_err_to_txt(srtp_err_status_t stat, char **msg) else if (stat == srtp_err_status_read_fail) *msg="couldn't read data"; else if (stat == srtp_err_status_write_fail) *msg="couldn't write data"; else if (stat == srtp_err_status_parse_err) *msg="error parsing data"; - else if (stat == srtp_err_status_write_fail) *msg="couldn't read data"; else if (stat == srtp_err_status_encode_err) *msg="error encoding data"; else if (stat == srtp_err_status_semaphore_err) *msg="error while using semaphores"; else if (stat == srtp_err_status_pfkey_err) *msg="error while using pfkey "; @@ -1661,7 +1660,7 @@ static void rtcp_generate_sender_info(switch_rtp_t *rtp_session, struct switch_r ); } -static inline uint32_t calc_local_lsr_now() +static inline uint32_t calc_local_lsr_now(void) { switch_time_t now; uint32_t ntp_sec, ntp_usec, lsr_now, sec; @@ -3010,7 +3009,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_ rtp_session->dtls->sock_output = rtp_session->sock_output; if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) { - switch_sockaddr_info_get(&rtp_session->dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool); + status = switch_sockaddr_info_get(&rtp_session->dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool); } } @@ -3494,7 +3493,7 @@ static BIO_METHOD dtls_bio_filter_methods = { static BIO_METHOD *dtls_bio_filter_methods = NULL; #endif -static void switch_rtp_dtls_init() { +static void switch_rtp_dtls_init(void) { #if OPENSSL_VERSION_NUMBER >= 0x10100000L dtls_bio_filter_methods = BIO_meth_new(BIO_TYPE_FILTER | BIO_get_new_index(), "DTLS filter"); BIO_meth_set_write(dtls_bio_filter_methods, dtls_bio_filter_write); @@ -3504,7 +3503,7 @@ static void switch_rtp_dtls_init() { #endif } -static void switch_rtp_dtls_destroy() { +static void switch_rtp_dtls_destroy(void) { #if OPENSSL_VERSION_NUMBER >= 0x10100000L if (dtls_bio_filter_methods) { BIO_meth_free(dtls_bio_filter_methods); @@ -3529,9 +3528,13 @@ SWITCH_DECLARE(dtls_state_t) switch_rtp_dtls_state(switch_rtp_t *rtp_session, dt { dtls_state_t s = DS_OFF; + if (!rtp_session) { + return s; + } + switch_mutex_lock(rtp_session->ice_mutex); - if (!rtp_session || (!rtp_session->dtls && !rtp_session->rtcp_dtls)) { + if (!rtp_session->dtls && !rtp_session->rtcp_dtls) { s = DS_OFF; goto done; } @@ -3556,9 +3559,13 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_del_dtls(switch_rtp_t *rtp_session, d { switch_status_t status = SWITCH_STATUS_SUCCESS; + if (!rtp_session) { + return SWITCH_STATUS_FALSE; + } + switch_mutex_lock(rtp_session->ice_mutex); - if (!rtp_session || (!rtp_session->dtls && !rtp_session->rtcp_dtls)) { + if (!rtp_session->dtls && !rtp_session->rtcp_dtls) { switch_goto_status(SWITCH_STATUS_FALSE, done); } @@ -3635,8 +3642,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_dtls(switch_rtp_t *rtp_session, d unsigned long ssl_ctx_error = 0; const SSL_METHOD *ssl_method; SSL_CTX *ssl_ctx; +#if OPENSSL_VERSION_NUMBER < 0x30000000 BIO *bio; DH *dh; +#endif switch_status_t status = SWITCH_STATUS_SUCCESS; #ifndef OPENSSL_NO_EC #if OPENSSL_VERSION_NUMBER < 0x10002000L @@ -3715,6 +3724,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_dtls(switch_rtp_t *rtp_session, d switch_assert(dtls->ssl_ctx); +#if OPENSSL_VERSION_NUMBER < 0x30000000 bio = BIO_new_file(dtls->pem, "r"); dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); BIO_free(bio); @@ -3722,7 +3732,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_dtls(switch_rtp_t *rtp_session, d SSL_CTX_set_tmp_dh(dtls->ssl_ctx, dh); DH_free(dh); } - +#else + if(!SSL_CTX_set_dh_auto(dtls->ssl_ctx, 1)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Failed enable auto DH!\n"); + } +#endif SSL_CTX_set_mode(dtls->ssl_ctx, SSL_MODE_AUTO_RETRY); //SSL_CTX_set_verify(dtls->ssl_ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL); @@ -3927,12 +3941,6 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess case SWITCH_RTP_CRYPTO_RECV: switch_channel_set_variable(channel, "srtp_remote_crypto_key", (const char *)b64_key); break; - case SWITCH_RTP_CRYPTO_SEND_RTCP: - switch_channel_set_variable(channel, "srtcp_local_crypto_key", (const char *)b64_key); - break; - case SWITCH_RTP_CRYPTO_RECV_RTCP: - switch_channel_set_variable(channel, "srtcp_remote_crypto_key", (const char *)b64_key); - break; default: break; } @@ -3945,12 +3953,6 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess case SWITCH_RTP_CRYPTO_RECV: switch_channel_set_variable(channel, "srtp_remote_video_crypto_key", (const char *)b64_key); break; - case SWITCH_RTP_CRYPTO_SEND_RTCP: - switch_channel_set_variable(channel, "srtcp_local_video_crypto_key", (const char *)b64_key); - break; - case SWITCH_RTP_CRYPTO_RECV_RTCP: - switch_channel_set_variable(channel, "srtcp_remote_video_crypto_key", (const char *)b64_key); - break; default: break; } @@ -3963,12 +3965,6 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess case SWITCH_RTP_CRYPTO_RECV: switch_channel_set_variable(channel, "srtp_remote_audio_crypto_key", (const char *)b64_key); break; - case SWITCH_RTP_CRYPTO_SEND_RTCP: - switch_channel_set_variable(channel, "srtcp_local_audio_crypto_key", (const char *)b64_key); - break; - case SWITCH_RTP_CRYPTO_RECV_RTCP: - switch_channel_set_variable(channel, "srtcp_remote_audio_crypto_key", (const char *)b64_key); - break; default: break; } @@ -4669,6 +4665,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t * READ_INC(rtp_session); status = switch_jb_create(&rtp_session->jb, SJB_AUDIO, queue_frames, max_queue_frames, rtp_session->pool); switch_jb_set_session(rtp_session->jb, rtp_session->session); + switch_jb_set_jitter_estimator(rtp_session->jb, &rtp_session->stats.rtcp.inter_jitter, samples_per_packet, samples_per_second); if (switch_true(switch_channel_get_variable_dup(switch_core_session_get_channel(rtp_session->session), "jb_use_timestamps", SWITCH_FALSE, -1))) { switch_jb_ts_mode(rtp_session->jb, samples_per_packet, samples_per_second); } @@ -4764,11 +4761,12 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio if ((type & ICE_VANILLA)) { switch_snprintf(ice_user, sizeof(ice_user), "%s:%s", login, rlogin); switch_snprintf(user_ice, sizeof(user_ice), "%s:%s", rlogin, login); - switch_snprintf(luser_ice, sizeof(user_ice), "%s%s", rlogin, login); + switch_snprintf(luser_ice, sizeof(luser_ice), "%s%s", rlogin, login); ice->ready = ice->rready = 0; } else { switch_snprintf(ice_user, sizeof(ice_user), "%s%s", login, rlogin); switch_snprintf(user_ice, sizeof(user_ice), "%s%s", rlogin, login); + switch_snprintf(luser_ice, sizeof(luser_ice), ""); ice->ready = ice->rready = 1; } @@ -4938,7 +4936,7 @@ SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session) } if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) { - if (rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_input != rtp_session->sock_input) { + if (rtp_session->sock_input && rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_input != rtp_session->sock_input) { ping_socket(rtp_session); switch_socket_shutdown(rtp_session->rtcp_sock_input, SWITCH_SHUTDOWN_READWRITE); } @@ -5485,7 +5483,6 @@ static switch_size_t do_flush(switch_rtp_t *rtp_session, int force, switch_size_ { int was_blocking = 0; switch_size_t bytes; - uint32_t flushed = 0; switch_size_t bytes_out = 0; if (!switch_rtp_ready(rtp_session)) { @@ -5567,8 +5564,6 @@ static switch_size_t do_flush(switch_rtp_t *rtp_session, int force, switch_size_ #endif } - flushed++; - rtp_session->stats.inbound.raw_bytes += bytes; rtp_session->stats.inbound.flush_packet_count++; rtp_session->stats.inbound.packet_count++; @@ -6966,13 +6961,10 @@ static void check_timeout(switch_rtp_t *rtp_session) elapsed, rtp_session->media_timeout); if (elapsed > rtp_session->media_timeout) { - - if (rtp_session->session) { switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session); switch_channel_execute_on(channel, "execute_on_media_timeout"); switch_channel_hangup(channel, SWITCH_CAUSE_MEDIA_TIMEOUT); - } } } diff --git a/src/switch_speex.c b/src/switch_speex.c index 122ae79a73..5a97b082f2 100644 --- a/src/switch_speex.c +++ b/src/switch_speex.c @@ -470,7 +470,7 @@ static switch_status_t switch_speex_destroy(switch_codec_t *codec) /** * read default settings from speex.conf */ -static void load_configuration() +static void load_configuration(void) { switch_xml_t xml = NULL, cfg = NULL; diff --git a/src/switch_time.c b/src/switch_time.c index 445e698f9b..a56c5e96f1 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -1173,9 +1173,8 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime) } else { if (tfd > -1 && globals.RUNNING == 1) { uint64_t exp; - int r; - r = read(tfd, &exp, sizeof(exp)); - r++; + read(tfd, &exp, sizeof(exp)); + (void)exp; } else { switch_time_t timediff = runtime.reference - ts; diff --git a/src/switch_utils.c b/src/switch_utils.c index d8b830943a..c51953f0cf 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -139,13 +139,10 @@ struct switch_frame_buffer_s { static switch_frame_t *find_free_frame(switch_frame_buffer_t *fb, switch_frame_t *orig) { switch_frame_node_t *np; - int x = 0; switch_mutex_lock(fb->mutex); for (np = fb->head; np; np = np->next) { - x++; - if (!np->inuse && ((orig->packet && np->frame->packet) || (!orig->packet && !np->frame->packet))) { if (np == fb->head) { @@ -1610,6 +1607,30 @@ SWITCH_DECLARE(char *) switch_separate_paren_args(char *str) return args; } +SWITCH_DECLARE(switch_bool_t) switch_is_uint_in_range(const char *str, unsigned int from, unsigned int to) +{ + unsigned int number; + const char *original_str = str; + + if (str == NULL || *str == '\0' || from > to) { + return SWITCH_FALSE; + } + + for (; *str != '\0'; str++) { + if (!isdigit(*str)) { + return SWITCH_FALSE; + } + } + + number = atoi(original_str); + + if (number < from || number > to) { + return SWITCH_FALSE; + } + + return SWITCH_TRUE; +} + SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str) { const char *p; @@ -2383,7 +2404,7 @@ SWITCH_DECLARE(int) switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *s return (s1->sin_addr.s_addr == s2->sin_addr.s_addr && s1->sin_port == s2->sin_port); } case AF_INET6: - if (s16->sin6_addr.s6_addr && s26->sin6_addr.s6_addr) { + { int i; if (!ip_only) { @@ -2437,7 +2458,7 @@ SWITCH_DECLARE(int) switch_cp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa return 1; case AF_INET6: - if (s16->sin6_addr.s6_addr && s26->sin6_addr.s6_addr) { + { int i; s16->sin6_port = s26->sin6_port; diff --git a/src/switch_vpx.c b/src/switch_vpx.c index e35d87712f..751f2b8c5b 100644 --- a/src/switch_vpx.c +++ b/src/switch_vpx.c @@ -1853,7 +1853,7 @@ static void parse_codecs(my_vpx_cfg_t *my_cfg, switch_xml_t codecs) } } -static void load_config() +static void load_config(void) { switch_xml_t cfg = NULL, xml = NULL; my_vpx_cfg_t *my_cfg = NULL; diff --git a/src/switch_xml.c b/src/switch_xml.c index c43a530252..8ed7c27658 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -550,15 +550,22 @@ SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target switch_xml_root_t root = (switch_xml_root_t) xml; int i = 0; - if (!root) + if (!root) { return (const char **) SWITCH_XML_NIL; - while (root->xml.parent) + } + + while (root && root->xml.parent) { root = (switch_xml_root_t) root->xml.parent; /* root tag */ + } + if (!root || !root->pi) { return (const char **) SWITCH_XML_NIL; } - while (root->pi[i] && strcmp(target, root->pi[i][0])) + + while (root->pi[i] && strcmp(target, root->pi[i][0])) { i++; /* find target */ + } + return (const char **) ((root->pi[i]) ? root->pi[i] + 1 : SWITCH_XML_NIL); } @@ -1146,7 +1153,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str(char *s, switch_size_t len) return switch_xml_err(root, d, "unclosed