Merge pull request #2707 from signalwire/soundtouch
[mod_soundtouch] Remove from tree
This commit is contained in:
commit
6a5ac7e0a9
|
@ -40,7 +40,6 @@ applications/mod_sms
|
||||||
#applications/mod_snapshot
|
#applications/mod_snapshot
|
||||||
#applications/mod_snom
|
#applications/mod_snom
|
||||||
#applications/mod_sonar
|
#applications/mod_sonar
|
||||||
#applications/mod_soundtouch
|
|
||||||
applications/mod_spandsp
|
applications/mod_spandsp
|
||||||
#applications/mod_spy
|
#applications/mod_spy
|
||||||
applications/mod_test
|
applications/mod_test
|
||||||
|
|
|
@ -40,7 +40,6 @@ applications/mod_sms
|
||||||
applications/mod_snapshot
|
applications/mod_snapshot
|
||||||
applications/mod_snom
|
applications/mod_snom
|
||||||
applications/mod_sonar
|
applications/mod_sonar
|
||||||
applications/mod_soundtouch
|
|
||||||
applications/mod_spandsp
|
applications/mod_spandsp
|
||||||
applications/mod_spy
|
applications/mod_spy
|
||||||
applications/mod_test
|
applications/mod_test
|
||||||
|
|
|
@ -1079,7 +1079,7 @@ if test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Tested and fixed lot of modules, but some are untested. Will be added back when the core team decide it ready
|
# Tested and fixed lot of modules, but some are untested. Will be added back when the core team decide it ready
|
||||||
# Untested modules : mod_osp mod_soundtouch mod_opal mod_h323 mod_khomp
|
# Untested modules : mod_osp mod_opal mod_h323 mod_khomp
|
||||||
# mod_erlang_event mod_snmp mod_perl mod_java mod_managed
|
# mod_erlang_event mod_snmp mod_perl mod_java mod_managed
|
||||||
#
|
#
|
||||||
#saved_CFLAGS="$CFLAGS"
|
#saved_CFLAGS="$CFLAGS"
|
||||||
|
@ -1469,10 +1469,6 @@ PKG_CHECK_MODULES([OPUS], [opus >= 1.1],[
|
||||||
AM_CONDITIONAL([HAVE_OPUS],[true])],[
|
AM_CONDITIONAL([HAVE_OPUS],[true])],[
|
||||||
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_OPUS],[false])])
|
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_OPUS],[false])])
|
||||||
|
|
||||||
PKG_CHECK_MODULES([SOUNDTOUCH], [soundtouch >= 1.7.0],[
|
|
||||||
AM_CONDITIONAL([HAVE_SOUNDTOUCH],[true])],[
|
|
||||||
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SOUNDTOUCH],[false])])
|
|
||||||
|
|
||||||
flite="true"
|
flite="true"
|
||||||
PKG_CHECK_MODULES([FLITE], [flite >= 2],[],[
|
PKG_CHECK_MODULES([FLITE], [flite >= 2],[],[
|
||||||
AC_CHECK_LIB([flite], [flite_init],[
|
AC_CHECK_LIB([flite], [flite_init],[
|
||||||
|
@ -2132,7 +2128,6 @@ AC_CONFIG_FILES([Makefile
|
||||||
src/mod/applications/mod_snapshot/Makefile
|
src/mod/applications/mod_snapshot/Makefile
|
||||||
src/mod/applications/mod_snom/Makefile
|
src/mod/applications/mod_snom/Makefile
|
||||||
src/mod/applications/mod_sonar/Makefile
|
src/mod/applications/mod_sonar/Makefile
|
||||||
src/mod/applications/mod_soundtouch/Makefile
|
|
||||||
src/mod/applications/mod_spandsp/Makefile
|
src/mod/applications/mod_spandsp/Makefile
|
||||||
src/mod/applications/mod_spy/Makefile
|
src/mod/applications/mod_spy/Makefile
|
||||||
src/mod/applications/mod_test/Makefile
|
src/mod/applications/mod_test/Makefile
|
||||||
|
|
|
@ -78,7 +78,6 @@ avoid_mods_wheezy=(
|
||||||
applications/mod_hiredis
|
applications/mod_hiredis
|
||||||
formats/mod_shout
|
formats/mod_shout
|
||||||
applications/mod_sonar
|
applications/mod_sonar
|
||||||
applications/mod_soundtouch
|
|
||||||
formats/mod_vlc
|
formats/mod_vlc
|
||||||
)
|
)
|
||||||
avoid_mods_trusty=(
|
avoid_mods_trusty=(
|
||||||
|
@ -547,7 +546,6 @@ Recommends:
|
||||||
freeswitch-mod-snapshot (= \${binary:Version}),
|
freeswitch-mod-snapshot (= \${binary:Version}),
|
||||||
freeswitch-mod-snom (= \${binary:Version}),
|
freeswitch-mod-snom (= \${binary:Version}),
|
||||||
freeswitch-mod-sonar (= \${binary:Version}),
|
freeswitch-mod-sonar (= \${binary:Version}),
|
||||||
freeswitch-mod-soundtouch (= \${binary:Version}),
|
|
||||||
freeswitch-mod-spandsp (= \${binary:Version}),
|
freeswitch-mod-spandsp (= \${binary:Version}),
|
||||||
freeswitch-mod-spy (= \${binary:Version}),
|
freeswitch-mod-spy (= \${binary:Version}),
|
||||||
freeswitch-mod-valet-parking (= \${binary:Version}),
|
freeswitch-mod-valet-parking (= \${binary:Version}),
|
||||||
|
@ -636,7 +634,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}),
|
||||||
freeswitch-mod-snapshot (= \${binary:Version}),
|
freeswitch-mod-snapshot (= \${binary:Version}),
|
||||||
freeswitch-mod-snom (= \${binary:Version}),
|
freeswitch-mod-snom (= \${binary:Version}),
|
||||||
freeswitch-mod-sonar (= \${binary:Version}),
|
freeswitch-mod-sonar (= \${binary:Version}),
|
||||||
freeswitch-mod-soundtouch (= \${binary:Version}),
|
|
||||||
freeswitch-mod-spandsp (= \${binary:Version}),
|
freeswitch-mod-spandsp (= \${binary:Version}),
|
||||||
freeswitch-mod-spy (= \${binary:Version}),
|
freeswitch-mod-spy (= \${binary:Version}),
|
||||||
freeswitch-mod-translate (= \${binary:Version}),
|
freeswitch-mod-translate (= \${binary:Version}),
|
||||||
|
@ -862,7 +859,6 @@ Depends: \${misc:Depends}, freeswitch (= \${binary:Version}),
|
||||||
freeswitch-mod-snapshot-dbg (= \${binary:Version}),
|
freeswitch-mod-snapshot-dbg (= \${binary:Version}),
|
||||||
freeswitch-mod-snom-dbg (= \${binary:Version}),
|
freeswitch-mod-snom-dbg (= \${binary:Version}),
|
||||||
freeswitch-mod-sonar-dbg (= \${binary:Version}),
|
freeswitch-mod-sonar-dbg (= \${binary:Version}),
|
||||||
freeswitch-mod-soundtouch-dbg (= \${binary:Version}),
|
|
||||||
freeswitch-mod-spandsp-dbg (= \${binary:Version}),
|
freeswitch-mod-spandsp-dbg (= \${binary:Version}),
|
||||||
freeswitch-mod-spy-dbg (= \${binary:Version}),
|
freeswitch-mod-spy-dbg (= \${binary:Version}),
|
||||||
freeswitch-mod-translate-dbg (= \${binary:Version}),
|
freeswitch-mod-translate-dbg (= \${binary:Version}),
|
||||||
|
|
|
@ -210,11 +210,6 @@ Description: Sonar ping timer
|
||||||
This module measures the latency on an audio link by sending audible
|
This module measures the latency on an audio link by sending audible
|
||||||
audio sonar pings.
|
audio sonar pings.
|
||||||
|
|
||||||
Module: applications/mod_soundtouch
|
|
||||||
Description: Soundtouch
|
|
||||||
This module implements example media bugs.
|
|
||||||
Build-Depends: libsoundtouch-dev
|
|
||||||
|
|
||||||
Module: applications/mod_spandsp
|
Module: applications/mod_spandsp
|
||||||
Description: SpanDSP
|
Description: SpanDSP
|
||||||
This module implements spandsp fax, dsp, and codec functionality.
|
This module implements spandsp fax, dsp, and codec functionality.
|
||||||
|
|
|
@ -514,18 +514,6 @@ Requires: %{name} = %{version}-%{release}
|
||||||
Provides FreeSWITCH mod_snom, an application for controlling the functionality
|
Provides FreeSWITCH mod_snom, an application for controlling the functionality
|
||||||
and appearance of the programmable softkeys on Snom phones
|
and appearance of the programmable softkeys on Snom phones
|
||||||
|
|
||||||
%package application-soundtouch
|
|
||||||
Summary: FreeSWITCH mod_soundtouch
|
|
||||||
Group: System/Libraries
|
|
||||||
Requires: %{name} = %{version}-%{release}
|
|
||||||
BuildRequires: soundtouch-devel >= 1.7.1
|
|
||||||
|
|
||||||
%description application-soundtouch
|
|
||||||
Provides FreeSWITCH mod_soundtouch, uses the soundtouch library, which can do
|
|
||||||
pitch shifting and other audio effects, so you can pipe the audio of a call
|
|
||||||
(or any other channel audio) through this module and achieve those effects. You
|
|
||||||
can specifically adjust pitch, rate, and tempo.
|
|
||||||
|
|
||||||
%package application-spy
|
%package application-spy
|
||||||
Summary: FreeSWITCH mod_spy
|
Summary: FreeSWITCH mod_spy
|
||||||
Group: System/Libraries
|
Group: System/Libraries
|
||||||
|
@ -1217,7 +1205,6 @@ Requires: freeswitch-application-signalwire
|
||||||
Requires: freeswitch-application-sms
|
Requires: freeswitch-application-sms
|
||||||
Requires: freeswitch-application-snapshot
|
Requires: freeswitch-application-snapshot
|
||||||
Requires: freeswitch-application-snom
|
Requires: freeswitch-application-snom
|
||||||
Requires: freeswitch-application-soundtouch
|
|
||||||
Requires: freeswitch-application-spy
|
Requires: freeswitch-application-spy
|
||||||
Requires: freeswitch-application-valet_parking
|
Requires: freeswitch-application-valet_parking
|
||||||
Requires: freeswitch-application-video_filter
|
Requires: freeswitch-application-video_filter
|
||||||
|
@ -1296,7 +1283,7 @@ APPLICATION_MODULES_FR="applications/mod_fifo applications/mod_fsk applications/
|
||||||
applications/mod_memcache applications/mod_mongo applications/mod_nibblebill applications/mod_rad_auth \
|
applications/mod_memcache applications/mod_mongo applications/mod_nibblebill applications/mod_rad_auth \
|
||||||
applications/mod_redis applications/mod_rss "
|
applications/mod_redis applications/mod_rss "
|
||||||
|
|
||||||
APPLICATION_MODULES_SZ="applications/mod_signalwire applications/mod_sms applications/mod_snapshot applications/mod_snom applications/mod_soundtouch \
|
APPLICATION_MODULES_SZ="applications/mod_signalwire applications/mod_sms applications/mod_snapshot applications/mod_snom \
|
||||||
applications/mod_spandsp applications/mod_spy \
|
applications/mod_spandsp applications/mod_spy \
|
||||||
applications/mod_valet_parking applications/mod_translate applications/mod_voicemail \
|
applications/mod_valet_parking applications/mod_translate applications/mod_voicemail \
|
||||||
applications/mod_voicemail_ivr applications/mod_video_filter"
|
applications/mod_voicemail_ivr applications/mod_video_filter"
|
||||||
|
@ -1963,9 +1950,6 @@ fi
|
||||||
%files application-snom
|
%files application-snom
|
||||||
%{MODINSTDIR}/mod_snom.so*
|
%{MODINSTDIR}/mod_snom.so*
|
||||||
|
|
||||||
%files application-soundtouch
|
|
||||||
%{MODINSTDIR}/mod_soundtouch.so*
|
|
||||||
|
|
||||||
%files application-spy
|
%files application-spy
|
||||||
%{MODINSTDIR}/mod_spy.so*
|
%{MODINSTDIR}/mod_spy.so*
|
||||||
|
|
||||||
|
|
|
@ -420,8 +420,6 @@ opal
|
||||||
/sofia-sip/win32/Makefile
|
/sofia-sip/win32/Makefile
|
||||||
/sofia-sip/win32/Makefile.in
|
/sofia-sip/win32/Makefile.in
|
||||||
/sounds/
|
/sounds/
|
||||||
/soundtouch/
|
|
||||||
/soundtouch-*/
|
|
||||||
/sphinxbase-*/
|
/sphinxbase-*/
|
||||||
/srtp/aes_tables
|
/srtp/aes_tables
|
||||||
/srtp/config_in.h
|
/srtp/config_in.h
|
||||||
|
|
|
@ -6,7 +6,6 @@ wget -c http://svn.freeswitch.org/downloads/libs/libshout-2.2.2.tar.gz
|
||||||
wget -c http://svn.freeswitch.org/downloads/libs/mpg123.tar.gz
|
wget -c http://svn.freeswitch.org/downloads/libs/mpg123.tar.gz
|
||||||
wget -c http://svn.freeswitch.org/downloads/libs/openldap-2.4.11.tar.gz
|
wget -c http://svn.freeswitch.org/downloads/libs/openldap-2.4.11.tar.gz
|
||||||
wget -c http://svn.freeswitch.org/downloads/libs/pocketsphinx-0.5.99-latest.tar.gz
|
wget -c http://svn.freeswitch.org/downloads/libs/pocketsphinx-0.5.99-latest.tar.gz
|
||||||
wget -c http://svn.freeswitch.org/downloads/libs/soundtouch-1.3.1.tar.gz
|
|
||||||
wget -c http://svn.freeswitch.org/downloads/libs/sphinxbase-0.4.99-latest.tar.gz
|
wget -c http://svn.freeswitch.org/downloads/libs/sphinxbase-0.4.99-latest.tar.gz
|
||||||
wget -c http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-8000-1.0.8.tar.gz
|
wget -c http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-8000-1.0.8.tar.gz
|
||||||
wget -c http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-16000-1.0.8.tar.gz
|
wget -c http://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-16000-1.0.8.tar.gz
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
include $(top_srcdir)/build/modmake.rulesam
|
|
||||||
MODNAME=mod_soundtouch
|
|
||||||
|
|
||||||
if HAVE_SOUNDTOUCH
|
|
||||||
|
|
||||||
mod_LTLIBRARIES = mod_soundtouch.la
|
|
||||||
mod_soundtouch_la_SOURCES = mod_soundtouch.cpp
|
|
||||||
mod_soundtouch_la_CFLAGS = $(AM_CFLAGS) $(SOUNDTOUCH_CFLAGS) -DINTEGER_SAMPLES
|
|
||||||
mod_soundtouch_la_CXXFLAGS = $(SOUNDTOUCH_CFLAGS) -DINTEGER_SAMPLES
|
|
||||||
mod_soundtouch_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(SOUNDTOUCH_LIBS)
|
|
||||||
mod_soundtouch_la_LDFLAGS = -avoid-version -module -no-undefined -shared
|
|
||||||
|
|
||||||
else
|
|
||||||
install: error
|
|
||||||
all: error
|
|
||||||
error:
|
|
||||||
$(error You must install libsoundtouch-dev to build mod_soundtouch)
|
|
||||||
endif
|
|
|
@ -1,472 +0,0 @@
|
||||||
/*
|
|
||||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
|
||||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
|
||||||
*
|
|
||||||
* Version: MPL 1.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Anthony Minessale II <anthm@freeswitch.org>
|
|
||||||
* Portions created by the Initial Developer are Copyright (C)
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
* Anthony Minessale II <anthm@freeswitch.org>
|
|
||||||
*
|
|
||||||
* mod_soundtouch.cpp -- Example of writeable media bugs
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <SoundTouch.h>
|
|
||||||
using namespace soundtouch;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#define STSTART 1024 * 2
|
|
||||||
#define STBLOCK 1024
|
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_soundtouch_load);
|
|
||||||
SWITCH_MODULE_DEFINITION(mod_soundtouch, mod_soundtouch_load, NULL, NULL);
|
|
||||||
|
|
||||||
static const float ADJUST_AMOUNT = 0.05f;
|
|
||||||
struct soundtouch_helper {
|
|
||||||
SoundTouch *st;
|
|
||||||
switch_core_session_t *session;
|
|
||||||
bool send_not_recv;
|
|
||||||
bool hook_dtmf;
|
|
||||||
float pitch;
|
|
||||||
float rate;
|
|
||||||
float tempo;
|
|
||||||
bool literal;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* type is p=>pitch,r=>rate,t=>tempo */
|
|
||||||
static float normalize_soundtouch_value(char type, float value)
|
|
||||||
{
|
|
||||||
float min,max;
|
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
case 'p':
|
|
||||||
min = 0.01f;
|
|
||||||
max = 1000.0f;
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
min = 0.01f;
|
|
||||||
max = 1000.0f;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
min = 0.01f;
|
|
||||||
max = 1000.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (value < min)
|
|
||||||
value = min;
|
|
||||||
if (value > max)
|
|
||||||
value = max;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Computation taken from SoundTouch library for conversion*/
|
|
||||||
static float compute_pitch_from_octaves(float octaves)
|
|
||||||
{
|
|
||||||
return (float)exp(0.69314718056f * octaves);
|
|
||||||
}
|
|
||||||
|
|
||||||
static switch_status_t on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
|
|
||||||
{
|
|
||||||
|
|
||||||
switch_media_bug_t *bug;
|
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
|
||||||
if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
|
|
||||||
struct soundtouch_helper *sth = (struct soundtouch_helper *) switch_core_media_bug_get_user_data(bug);
|
|
||||||
|
|
||||||
if (sth) {
|
|
||||||
if (sth->literal) {
|
|
||||||
sth->literal = false;
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
switch (dtmf->digit) {
|
|
||||||
case '*':
|
|
||||||
sth->literal=true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '1':
|
|
||||||
sth->pitch = normalize_soundtouch_value('p',sth->pitch - ADJUST_AMOUNT);
|
|
||||||
sth->st->setPitch(sth->pitch);
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
sth->pitch = 1.0f;
|
|
||||||
sth->st->setPitch(sth->pitch);
|
|
||||||
break;
|
|
||||||
case '3':
|
|
||||||
sth->pitch = normalize_soundtouch_value('p',sth->pitch + ADJUST_AMOUNT);
|
|
||||||
sth->st->setPitch(sth->pitch);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '4':
|
|
||||||
sth->rate = normalize_soundtouch_value('r',sth->rate - ADJUST_AMOUNT);
|
|
||||||
sth->st->setRate(sth->rate);
|
|
||||||
break;
|
|
||||||
case '5':
|
|
||||||
sth->rate = 1.0f;
|
|
||||||
sth->st->setRate(sth->rate);
|
|
||||||
break;
|
|
||||||
case '6':
|
|
||||||
sth->rate = normalize_soundtouch_value('r',sth->rate + ADJUST_AMOUNT);
|
|
||||||
sth->st->setRate(sth->rate);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '7':
|
|
||||||
sth->tempo = normalize_soundtouch_value('t',sth->tempo - ADJUST_AMOUNT);
|
|
||||||
sth->st->setTempo(sth->tempo);
|
|
||||||
break;
|
|
||||||
case '8':
|
|
||||||
sth->tempo = 1.0f;
|
|
||||||
sth->st->setTempo(sth->tempo);
|
|
||||||
break;
|
|
||||||
case '9':
|
|
||||||
sth->tempo = normalize_soundtouch_value('t',sth->tempo + ADJUST_AMOUNT);
|
|
||||||
sth->st->setTempo(sth->tempo);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '0':
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "pitch: %f tempo: %f rate: %f\n",sth->pitch,sth->tempo,sth->rate);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
|
||||||
}
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
static switch_bool_t soundtouch_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
|
|
||||||
{
|
|
||||||
struct soundtouch_helper *sth = (struct soundtouch_helper *) user_data;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case SWITCH_ABC_TYPE_INIT:
|
|
||||||
{
|
|
||||||
switch_codec_t *read_codec = switch_core_session_get_read_codec(sth->session);
|
|
||||||
sth->st = new SoundTouch();
|
|
||||||
sth->st->setSampleRate(read_codec->implementation->samples_per_second);
|
|
||||||
sth->st->setChannels(read_codec->implementation->number_of_channels);
|
|
||||||
|
|
||||||
sth->st->setSetting(SETTING_USE_QUICKSEEK, 1);
|
|
||||||
sth->st->setSetting(SETTING_USE_AA_FILTER, 1);
|
|
||||||
|
|
||||||
if (sth->pitch) {
|
|
||||||
sth->st->setPitch(sth->pitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sth->rate) {
|
|
||||||
sth->st->setRate(sth->rate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sth->tempo) {
|
|
||||||
sth->st->setTempo(sth->tempo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sth->hook_dtmf)
|
|
||||||
{
|
|
||||||
if (sth->send_not_recv) {
|
|
||||||
switch_core_event_hook_add_send_dtmf(sth->session, on_dtmf);
|
|
||||||
} else {
|
|
||||||
switch_core_event_hook_add_recv_dtmf(sth->session, on_dtmf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SWITCH_ABC_TYPE_CLOSE:
|
|
||||||
{
|
|
||||||
delete sth->st;
|
|
||||||
if (sth->send_not_recv) {
|
|
||||||
switch_core_event_hook_remove_send_dtmf(sth->session, on_dtmf);
|
|
||||||
} else {
|
|
||||||
switch_core_event_hook_remove_recv_dtmf(sth->session, on_dtmf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SWITCH_ABC_TYPE_READ:
|
|
||||||
case SWITCH_ABC_TYPE_WRITE:
|
|
||||||
break;
|
|
||||||
case SWITCH_ABC_TYPE_READ_REPLACE:
|
|
||||||
case SWITCH_ABC_TYPE_WRITE_REPLACE:
|
|
||||||
{
|
|
||||||
switch_frame_t *frame;
|
|
||||||
|
|
||||||
assert(sth != NULL);
|
|
||||||
assert(sth->st != NULL);
|
|
||||||
|
|
||||||
if (! sth->send_not_recv) {
|
|
||||||
frame = switch_core_media_bug_get_read_replace_frame(bug);
|
|
||||||
} else {
|
|
||||||
frame = switch_core_media_bug_get_write_replace_frame(bug);
|
|
||||||
}
|
|
||||||
|
|
||||||
sth->st->putSamples((SAMPLETYPE *) frame->data, frame->samples);
|
|
||||||
|
|
||||||
if (sth->st->numSamples() >= frame->samples * 2) {
|
|
||||||
frame->samples = sth->st->receiveSamples((SAMPLETYPE *) frame->data, frame->samples);
|
|
||||||
frame->datalen = frame->samples * 2;
|
|
||||||
} else {
|
|
||||||
memset(frame->data, 0, frame->datalen);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! sth->send_not_recv) {
|
|
||||||
switch_core_media_bug_set_read_replace_frame(bug, frame);
|
|
||||||
} else {
|
|
||||||
switch_core_media_bug_set_write_replace_frame(bug, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SWITCH_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SWITCH_STANDARD_APP(soundtouch_start_function)
|
|
||||||
{
|
|
||||||
switch_media_bug_t *bug;
|
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
|
||||||
struct soundtouch_helper *sth;
|
|
||||||
char *argv[6];
|
|
||||||
int argc;
|
|
||||||
char *lbuf = NULL;
|
|
||||||
int x;
|
|
||||||
int n=0;
|
|
||||||
|
|
||||||
if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
|
|
||||||
if (!zstr(data) && !strcasecmp(data, "stop")) {
|
|
||||||
switch_channel_set_private(channel, "_soundtouch_", NULL);
|
|
||||||
switch_core_media_bug_remove(session, &bug);
|
|
||||||
} else {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sth = (struct soundtouch_helper *) switch_core_session_alloc(session, sizeof(*sth));
|
|
||||||
assert(sth != NULL);
|
|
||||||
|
|
||||||
|
|
||||||
if (data && (lbuf = switch_core_session_strdup(session, data))
|
|
||||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
|
||||||
sth->pitch = 1;
|
|
||||||
sth->rate = 1;
|
|
||||||
sth->tempo = 1;
|
|
||||||
sth->hook_dtmf = false;
|
|
||||||
sth->send_not_recv = false;
|
|
||||||
n = 0;
|
|
||||||
for (x = 0; x < argc; x++) {
|
|
||||||
if (!strncasecmp(argv[x], "send_leg", 8)) {
|
|
||||||
sth->send_not_recv = true;
|
|
||||||
} else if (!strncasecmp(argv[x], "hook_dtmf", 9)) {
|
|
||||||
sth->hook_dtmf = true;
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 'p')) {
|
|
||||||
sth->pitch = normalize_soundtouch_value('p', atof(argv[x]));
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 'r')) {
|
|
||||||
sth->rate = normalize_soundtouch_value('r', atof(argv[x]));
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 'o')) {
|
|
||||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x])) );
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 's')) {
|
|
||||||
/*12.0f taken from soundtouch conversion to octaves*/
|
|
||||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 't')) {
|
|
||||||
sth->tempo = normalize_soundtouch_value('t', atof(argv[x]));
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n < 1) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run, no pitch set\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sth->session = session;
|
|
||||||
|
|
||||||
if (switch_core_media_bug_add(session, "soundtouch", NULL, soundtouch_callback, sth, 0,
|
|
||||||
sth->send_not_recv ? SMBF_WRITE_REPLACE : SMBF_READ_REPLACE, &bug) != SWITCH_STATUS_SUCCESS) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_channel_set_private(channel, "_soundtouch_", bug);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* API Interface Function */
|
|
||||||
#define SOUNDTOUCH_API_SYNTAX "<uuid> [start|stop] [send_leg] [hook_dtmf] [-]<X>s [-]<X>o <X>p <X>r <X>t"
|
|
||||||
SWITCH_STANDARD_API(soundtouch_api_function)
|
|
||||||
{
|
|
||||||
switch_core_session_t *rsession = NULL;
|
|
||||||
switch_channel_t *channel = NULL;
|
|
||||||
switch_media_bug_t *bug;
|
|
||||||
struct soundtouch_helper *sth;
|
|
||||||
char *mycmd = NULL;
|
|
||||||
int argc = 0;
|
|
||||||
char *argv[10] = { 0 };
|
|
||||||
char *uuid = NULL;
|
|
||||||
char *action = NULL;
|
|
||||||
int x, n;
|
|
||||||
|
|
||||||
if (zstr(cmd)) {
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(mycmd = strdup(cmd))) {
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
uuid = argv[0];
|
|
||||||
action = argv[1];
|
|
||||||
|
|
||||||
if (!(rsession = switch_core_session_locate(uuid))) {
|
|
||||||
stream->write_function(stream, "-ERR Cannot locate session!\n");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(rsession);
|
|
||||||
|
|
||||||
if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) {
|
|
||||||
if (!zstr(action) && !strcasecmp(action, "stop")) {
|
|
||||||
switch_channel_set_private(channel, "_soundtouch_", NULL);
|
|
||||||
switch_core_media_bug_remove(rsession, &bug);
|
|
||||||
stream->write_function(stream, "+OK Success\n");
|
|
||||||
} else {
|
|
||||||
stream->write_function(stream, "-ERR Cannot run 2 at once on the same channel!\n");
|
|
||||||
}
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!zstr(action) && strcasecmp(action, "start")) {
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc < 3) {
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
sth = (struct soundtouch_helper *) switch_core_session_alloc(rsession, sizeof(*sth));
|
|
||||||
assert(sth != NULL);
|
|
||||||
|
|
||||||
|
|
||||||
sth->pitch = 1;
|
|
||||||
sth->rate = 1;
|
|
||||||
sth->tempo = 1;
|
|
||||||
sth->hook_dtmf = false;
|
|
||||||
sth->send_not_recv = false;
|
|
||||||
n = 0;
|
|
||||||
for (x = 2; x < argc; x++) {
|
|
||||||
if (!strncasecmp(argv[x], "send_leg", 8)) {
|
|
||||||
sth->send_not_recv = true;
|
|
||||||
} else if (!strncasecmp(argv[x], "hook_dtmf", 9)) {
|
|
||||||
sth->hook_dtmf = true;
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 'p')) {
|
|
||||||
sth->pitch = normalize_soundtouch_value('p', atof(argv[x]));
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 'r')) {
|
|
||||||
sth->rate = normalize_soundtouch_value('r', atof(argv[x]));
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 'o')) {
|
|
||||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x])) );
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 's')) {
|
|
||||||
/*12.0f taken from soundtouch conversion to octaves*/
|
|
||||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
|
|
||||||
n++;
|
|
||||||
} else if (strchr(argv[x], 't')) {
|
|
||||||
sth->tempo = normalize_soundtouch_value('t', atof(argv[x]));
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n < 1) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rsession), SWITCH_LOG_WARNING, "Cannot run, no pitch set\n");
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
sth->session = rsession;
|
|
||||||
|
|
||||||
if (switch_core_media_bug_add(rsession, "soundtouch", NULL, soundtouch_callback, sth, 0,
|
|
||||||
sth->send_not_recv ? SMBF_WRITE_REPLACE : SMBF_READ_REPLACE, &bug) != SWITCH_STATUS_SUCCESS) {
|
|
||||||
stream->write_function(stream, "-ERR Failure!\n");
|
|
||||||
goto done;
|
|
||||||
} else {
|
|
||||||
switch_channel_set_private(channel, "_soundtouch_", bug);
|
|
||||||
stream->write_function(stream, "+OK Success\n");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
usage:
|
|
||||||
stream->write_function(stream, "-USAGE: %s\n", SOUNDTOUCH_API_SYNTAX);
|
|
||||||
|
|
||||||
done:
|
|
||||||
if (rsession) {
|
|
||||||
switch_core_session_rwunlock(rsession);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_safe_free(mycmd);
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_soundtouch_load)
|
|
||||||
{
|
|
||||||
switch_application_interface_t *app_interface;
|
|
||||||
switch_api_interface_t *api_interface;
|
|
||||||
|
|
||||||
/* connect my internal structure to the blank pointer passed to me */
|
|
||||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
|
||||||
|
|
||||||
SWITCH_ADD_APP(app_interface, "soundtouch", "Alter the audio stream", "Alter the audio stream pitch/rate/tempo",
|
|
||||||
soundtouch_start_function, "[send_leg] [hook_dtmf] [-]<X>s [-]<X>o <X>p <X>r <X>t", SAF_NONE);
|
|
||||||
|
|
||||||
SWITCH_ADD_API(api_interface, "soundtouch", "soundtouch", soundtouch_api_function, SOUNDTOUCH_API_SYNTAX);
|
|
||||||
|
|
||||||
switch_console_set_complete("add soundtouch ::console::list_uuid ::[start:stop");
|
|
||||||
|
|
||||||
/* indicate that the module should continue to be loaded */
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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:
|
|
||||||
*/
|
|
Loading…
Reference in New Issue